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 | 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 | 11 | endif() |
| 6 | 12 | |
| 7 | 13 | set(VERSION_REGEX "#define CLI11_VERSION[ \t]+\"(.+)\"") |
| ... | ... | @@ -13,10 +19,9 @@ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/CLI/Version.hpp" |
| 13 | 19 | # Pick out just the version |
| 14 | 20 | string(REGEX REPLACE ${VERSION_REGEX} "\\1" VERSION_STRING "${VERSION_STRING}") |
| 15 | 21 | |
| 22 | +# Add the project | |
| 16 | 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 | 25 | # Only if built as the main project |
| 21 | 26 | if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) |
| 22 | 27 | # User settable | ... | ... |
tests/CMakeLists.txt
| ... | ... | @@ -3,10 +3,12 @@ if(NOT EXISTS "${CLI11_SOURCE_DIR}/extern/googletest/CMakeLists.txt") |
| 3 | 3 | git submodule update --init") |
| 4 | 4 | endif() |
| 5 | 5 | |
| 6 | +list(APPEND CMAKE_MODULE_PATH "${CLI11_SOURCE_DIR}/cmake") | |
| 7 | + | |
| 6 | 8 | # If submodule is available, add sanitizers |
| 7 | 9 | # Set SANITIZE_ADDRESS, SANITIZE_MEMORY, SANITIZE_THREAD or SANITIZE_UNDEFINED |
| 8 | 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 | 12 | find_package(Sanitizers) |
| 11 | 13 | if(SANITIZE_ADDRESS) |
| 12 | 14 | message(STATUS "You might want to use \"${ASan_WRAPPER}\" to run your program") | ... | ... |