|
1 | 1 | cmake_minimum_required(VERSION 3.5)
|
2 |
| -set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) |
3 |
| -include(GetGitRevisionDescription) |
4 |
| -git_describe(GitTagVersion --tags) |
5 |
| -string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GitTagVersion}") |
6 |
| -string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GitTagVersion}") |
7 |
| -string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GitTagVersion}") |
8 |
| -set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") |
| 2 | + |
| 3 | +# By default, the version information is extracted from the git index. However, |
| 4 | +# we can override this behavior by explicitly setting ADS_VERSION and |
| 5 | +# skipping the git checks. This is useful for cases where this project is being |
| 6 | +# used independently of its original git repo (e.g. vendored in another project) |
| 7 | +if(NOT ADS_VERSION) |
| 8 | + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH}) |
| 9 | + include(GetGitRevisionDescription) |
| 10 | + git_describe(GitTagVersion --tags) |
| 11 | + string(REGEX REPLACE "^([0-9]+)\\..*" "\\1" VERSION_MAJOR "${GitTagVersion}") |
| 12 | + string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1" VERSION_MINOR "${GitTagVersion}") |
| 13 | + string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" VERSION_PATCH "${GitTagVersion}") |
| 14 | + set(VERSION_SHORT "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") |
| 15 | +else() |
| 16 | + string(REGEX MATCHALL "[\.]" VERSION_DOT_MATCHES ${ADS_VERSION}) |
| 17 | + list(LENGTH VERSION_DOT_MATCHES VERSION_DOT_COUNT) |
| 18 | + if(VERSION_DOT_COUNT EQUAL 2) |
| 19 | + set(VERSION_SHORT ${ADS_VERSION}) |
| 20 | + else() |
| 21 | + message(FATAL_ERROR "ADS_VERSION must be in major.minor.patch format, e.g. 3.8.1. Got ${ADS_VERSION}") |
| 22 | + endif() |
| 23 | +endif() |
| 24 | + |
| 25 | + |
9 | 26 | project(QtADS LANGUAGES CXX VERSION ${VERSION_SHORT})
|
| 27 | + |
10 | 28 | option(BUILD_STATIC "Build the static library" OFF)
|
11 | 29 | option(BUILD_EXAMPLES "Build the examples" ON)
|
| 30 | + |
12 | 31 | if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
|
13 | 32 | set(ads_PlatformDir "x86")
|
14 | 33 | else()
|
15 | 34 | set(ads_PlatformDir "x64")
|
16 | 35 | endif()
|
| 36 | + |
17 | 37 | add_subdirectory(src)
|
| 38 | + |
18 | 39 | if(BUILD_EXAMPLES)
|
19 | 40 | add_subdirectory(examples)
|
20 | 41 | add_subdirectory(demo)
|
|
0 commit comments