Commit 73411e1e3821b09ed6a84ed87f8fdbfade47ca28
Committed by
GitHub
1 parent
92b8f6e3
Minor build system improvements (#154)
Showing
2 changed files
with
12 additions
and
5 deletions
CMakeLists.txt
| 1 | -cmake_minimum_required(VERSION 3.4...3.11) | 1 | +cmake_minimum_required(VERSION 3.4) |
| 2 | +# Note: this is a header only library. If you have an older CMake than 3.4, | ||
| 3 | +# just add the CLI11/include directory and that's all you need to do. | ||
| 2 | 4 | ||
| 5 | +# Make sure users don't get warnings on a tested (3.4 to 3.12) version | ||
| 6 | +# of CMake. For most of the policies, the new version is better (hence the change). | ||
| 3 | if(${CMAKE_VERSION} VERSION_LESS 3.12) | 7 | if(${CMAKE_VERSION} VERSION_LESS 3.12) |
| 4 | - cmake_policy(VERSION ${CMAKE_VERSION}) | 8 | + cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}) |
| 9 | +else() | ||
| 10 | + cmake_policy(VERSION 3.12) | ||
| 5 | endif() | 11 | endif() |
| 6 | 12 | ||
| 7 | set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") | 13 | set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") |
| @@ -13,10 +19,9 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/Version.hpp" | @@ -13,10 +19,9 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/Version.hpp" | ||
| 13 | # Pick out just the version | 19 | # Pick out just the version |
| 14 | string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}") | 20 | string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}") |
| 15 | 21 | ||
| 22 | +# Add the project | ||
| 16 | project(CLI11 LANGUAGES CXX VERSION ${VERSION_STRING}) | 23 | project(CLI11 LANGUAGES CXX VERSION ${VERSION_STRING}) |
| 17 | 24 | ||
| 18 | -set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) | ||
| 19 | - | ||
| 20 | # Only if built as the main project | 25 | # Only if built as the main project |
| 21 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) | 26 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) |
| 22 | # User settable | 27 | # User settable |
tests/CMakeLists.txt
| @@ -3,10 +3,12 @@ if(NOT EXISTS "${CLI11_SOURCE_DIR}/extern/googletest/CMakeLists.txt") | @@ -3,10 +3,12 @@ if(NOT EXISTS "${CLI11_SOURCE_DIR}/extern/googletest/CMakeLists.txt") | ||
| 3 | git submodule update --init") | 3 | git submodule update --init") |
| 4 | endif() | 4 | endif() |
| 5 | 5 | ||
| 6 | +list(APPEND CMAKE_MODULE_PATH "${CLI11_SOURCE_DIR}/cmake") | ||
| 7 | + | ||
| 6 | # If submodule is available, add sanitizers | 8 | # If submodule is available, add sanitizers |
| 7 | # Set SANITIZE_ADDRESS, SANITIZE_MEMORY, SANITIZE_THREAD or SANITIZE_UNDEFINED | 9 | # Set SANITIZE_ADDRESS, SANITIZE_MEMORY, SANITIZE_THREAD or SANITIZE_UNDEFINED |
| 8 | if(EXISTS "${CLI11_SOURCE_DIR}/extern/sanitizers/cmake/FindSanitizers.cmake") | 10 | if(EXISTS "${CLI11_SOURCE_DIR}/extern/sanitizers/cmake/FindSanitizers.cmake") |
| 9 | - set(CMAKE_MODULE_PATH "${CLI11_SOURCE_DIR}/extern/sanitizers/cmake" ${CMAKE_MODULE_PATH}) | 11 | + list(APPEND CMAKE_MODULE_PATH "${CLI11_SOURCE_DIR}/extern/sanitizers/cmake") |
| 10 | find_package(Sanitizers) | 12 | find_package(Sanitizers) |
| 11 | if(SANITIZE_ADDRESS) | 13 | if(SANITIZE_ADDRESS) |
| 12 | message(STATUS "You might want to use \"${ASan_WRAPPER}\" to run your program") | 14 | message(STATUS "You might want to use \"${ASan_WRAPPER}\" to run your program") |