diff options
author | Brad King <brad.king@kitware.com> | 2021-06-03 14:40:56 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-06-07 17:39:21 (GMT) |
commit | 8f68bcad8fafddc82b73b69f21e122ece8603a8f (patch) | |
tree | 6989359100a0b17e3e293f17c9327e86e0790e92 /Tests/CompileOptions/CMakeLists.txt | |
parent | ccc83ce1623a90c9354a940370ed8c06d2fea30b (diff) | |
download | CMake-8f68bcad8fafddc82b73b69f21e122ece8603a8f.zip CMake-8f68bcad8fafddc82b73b69f21e122ece8603a8f.tar.gz CMake-8f68bcad8fafddc82b73b69f21e122ece8603a8f.tar.bz2 |
Tests: Add cases verifying flag ordering rules
Diffstat (limited to 'Tests/CompileOptions/CMakeLists.txt')
-rw-r--r-- | Tests/CompileOptions/CMakeLists.txt | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt index cd6cacd..96bafea 100644 --- a/Tests/CompileOptions/CMakeLists.txt +++ b/Tests/CompileOptions/CMakeLists.txt @@ -1,5 +1,11 @@ -cmake_minimum_required(VERSION 2.8.12) - +cmake_minimum_required(VERSION 3.0) +if(POLICY CMP0092) + cmake_policy(SET CMP0092 NEW) +endif() +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +if(NOT _isMultiConfig AND NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build" FORCE) +endif() project(CompileOptions) add_library(testlib other.cpp) @@ -49,6 +55,24 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAK ) endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang|MSVC)$") + target_compile_definitions(CompileOptions PRIVATE "DO_FLAG_TESTS") + if(CMAKE_CXX_COMPILER_ID MATCHES "^(GNU|AppleClang)$") + string(APPEND CMAKE_CXX_FLAGS " -w") + endif() + string(APPEND CMAKE_CXX_FLAGS " -DFLAG_A=1 -DFLAG_B=1") + string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DFLAG_A=2 -DFLAG_C=1") + string(APPEND CMAKE_CXX_FLAGS_RELEASE " -DFLAG_A=2 -DFLAG_C=1") + string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DFLAG_A=2 -DFLAG_C=1") + string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DFLAG_A=2 -DFLAG_C=1") + set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS "-DFLAG_B=2" "-DFLAG_C=2" "-DFLAG_D=1") + set_property(TARGET testlib APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-DFLAG_D=2") + if(NOT CMAKE_GENERATOR MATCHES "^Visual Studio 9") + set_property(TARGET testlib APPEND PROPERTY INTERFACE_COMPILE_OPTIONS "-DFLAG_E=1") + set_property(SOURCE main.cpp PROPERTY COMPILE_OPTIONS "-DFLAG_E=2") + endif() +endif() + target_link_libraries(CompileOptions testlib) if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") |