diff options
author | Brad King <brad.king@kitware.com> | 2020-01-13 15:37:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-01-13 15:38:00 (GMT) |
commit | 4bac5b628ea1e854ab23b6e713ad3eb211b3a9e3 (patch) | |
tree | b445d0ca679da65f42f13f25085108aaf647769f /Tests/RunCMake | |
parent | 041e58d195587ddc9aa6d87148ea9c3ab63310d1 (diff) | |
parent | 2678e310537a965b531cfc2c1f54fc72aac9d7d5 (diff) | |
download | CMake-4bac5b628ea1e854ab23b6e713ad3eb211b3a9e3.zip CMake-4bac5b628ea1e854ab23b6e713ad3eb211b3a9e3.tar.gz CMake-4bac5b628ea1e854ab23b6e713ad3eb211b3a9e3.tar.bz2 |
Merge topic 'target_compile_options-BEFORE-keyword'
2678e31053 target_compile_options: ensure BEFORE keyword is handled in all scopes
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4203
Diffstat (limited to 'Tests/RunCMake')
8 files changed, 54 insertions, 1 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index a46393e..b8ac45b 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -450,7 +450,7 @@ add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_I add_RunCMake_test(target_compile_definitions) add_RunCMake_test(target_compile_features) -add_RunCMake_test(target_compile_options) +add_RunCMake_test(target_compile_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}) add_RunCMake_test(target_include_directories) add_RunCMake_test(target_sources) add_RunCMake_test(CheckModules) diff --git a/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake b/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake new file mode 100644 index 0000000..8016230 --- /dev/null +++ b/Tests/RunCMake/target_compile_options/BEFORE_keyword.cmake @@ -0,0 +1,8 @@ + +add_executable (CMP0101_OLD CMP0101.c) +target_compile_options (main PRIVATE -UBEFORE_KEYWORD) +target_compile_options (main BEFORE PRIVATE -DBEFORE_KEYWORD) + +add_executable (CMP0101_NEW CMP0101.c) +target_compile_options (main PRIVATE -UBEFORE_KEYWORD) +target_compile_options (main BEFORE PRIVATE -DBEFORE_KEYWORD) diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-NEW-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt new file mode 100644 index 0000000..8d98f9d --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-result.txt @@ -0,0 +1 @@ +.* diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt new file mode 100644 index 0000000..850aa65 --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword-OLD-stdout.txt @@ -0,0 +1 @@ +BEFORE not honored diff --git a/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake new file mode 100644 index 0000000..577427f --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101-BEFORE_keyword.cmake @@ -0,0 +1,15 @@ + +enable_language(C) + +cmake_policy (SET CMP0101 OLD) + +add_executable (CMP0101_OLD CMP0101.c) +target_compile_options (CMP0101_OLD PRIVATE -UBEFORE_KEYWORD) +target_compile_options (CMP0101_OLD BEFORE PRIVATE -DBEFORE_KEYWORD) + + +cmake_policy (SET CMP0101 NEW) + +add_executable (CMP0101_NEW CMP0101.c) +target_compile_options (CMP0101_NEW PRIVATE -UBEFORE_KEYWORD) +target_compile_options (CMP0101_NEW BEFORE PRIVATE -DBEFORE_KEYWORD) diff --git a/Tests/RunCMake/target_compile_options/CMP0101.c b/Tests/RunCMake/target_compile_options/CMP0101.c new file mode 100644 index 0000000..250869a --- /dev/null +++ b/Tests/RunCMake/target_compile_options/CMP0101.c @@ -0,0 +1,9 @@ + +#if defined(BEFORE_KEYWORD) +# error "BEFORE not honored" +#endif + +int main() +{ + return 0; +} diff --git a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake index b67c598..9f51a9a 100644 --- a/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_compile_options/RunCMakeTest.cmake @@ -1,3 +1,21 @@ include(RunCMake) run_cmake(empty_keyword_args) + +if (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang") + macro(run_cmake_target test subtest target) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_OUTPUT_MERGE 1) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} ${ARGN}) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_OUTPUT_MERGE) + unset(RunCMake_TEST_NO_CLEAN) + endmacro() + + run_cmake(CMP0101-BEFORE_keyword) + + run_cmake_target(CMP0101-BEFORE_keyword OLD CMP0101_OLD) + run_cmake_target(CMP0101-BEFORE_keyword NEW CMP0101_NEW) +endif() |