diff options
author | Brad King <brad.king@kitware.com> | 2022-12-14 14:02:54 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2022-12-14 14:03:08 (GMT) |
commit | 84c2518a7bfa9a05f658c14bde0e9494508e30ed (patch) | |
tree | 1a84d4866c7464e79f5f0a15011bc469ad3f273e /Tests | |
parent | 15dcb41f202c2d2123ce47f7afb06e9adc735101 (diff) | |
parent | 7480fa0a5fd0ebc3fe06c702f3368e06a50c10ab (diff) | |
download | CMake-84c2518a7bfa9a05f658c14bde0e9494508e30ed.zip CMake-84c2518a7bfa9a05f658c14bde0e9494508e30ed.tar.gz CMake-84c2518a7bfa9a05f658c14bde0e9494508e30ed.tar.bz2 |
Merge topic 'COMPILE_DEFINITIONS-property-cleanup'
7480fa0a5f COMPILE_DEFINITIONS property: ensure leading -D is removed in all cases
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8004
Diffstat (limited to 'Tests')
11 files changed, 83 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 78615d9..d5c07dd 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -693,6 +693,7 @@ add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_I set_property(TEST RunCMake.target_link_options APPEND PROPERTY LABELS "CUDA") +add_RunCMake_test(add_compile_definitions) add_RunCMake_test(target_compile_definitions) add_RunCMake_test(target_compile_features) add_RunCMake_test(target_compile_options diff --git a/Tests/RunCMake/CompileDefinitions/RemoveLeadingMinusD.cmake b/Tests/RunCMake/CompileDefinitions/RemoveLeadingMinusD.cmake new file mode 100644 index 0000000..3db6cff1f --- /dev/null +++ b/Tests/RunCMake/CompileDefinitions/RemoveLeadingMinusD.cmake @@ -0,0 +1,11 @@ + +enable_language(C) + +set_property(SOURCE foo.c PROPERTY COMPILE_DEFINITIONS -DDEF0 "$<1:-DDEF1>") + +add_library(lib1 foo.c) +set_property(TARGET lib1 PROPERTY COMPILE_DEFINITIONS -DDEF2 "$<1:-DDEF3>") +set_property(TARGET lib1 PROPERTY INTERFACE_COMPILE_DEFINITIONS -DDEF4 "$<1:-DDEF5>") + +add_library(lib2 foo.c) +target_link_libraries(lib2 PRIVATE lib1) diff --git a/Tests/RunCMake/CompileDefinitions/RunCMakeTest.cmake b/Tests/RunCMake/CompileDefinitions/RunCMakeTest.cmake index 233fe34..eebcd22 100644 --- a/Tests/RunCMake/CompileDefinitions/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileDefinitions/RunCMakeTest.cmake @@ -1,3 +1,16 @@ include(RunCMake) run_cmake(SetEmpty) + + +macro(run_cmake_build test) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test} ${CMAKE_COMMAND} --build . --config Release) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +run_cmake(RemoveLeadingMinusD) +run_cmake_build(RemoveLeadingMinusD) diff --git a/Tests/RunCMake/CompileDefinitions/foo.c b/Tests/RunCMake/CompileDefinitions/foo.c new file mode 100644 index 0000000..74a86e1 --- /dev/null +++ b/Tests/RunCMake/CompileDefinitions/foo.c @@ -0,0 +1,4 @@ + +void foo() +{ +} diff --git a/Tests/RunCMake/add_compile_definitions/CMakeLists.txt b/Tests/RunCMake/add_compile_definitions/CMakeLists.txt new file mode 100644 index 0000000..14ef56e --- /dev/null +++ b/Tests/RunCMake/add_compile_definitions/CMakeLists.txt @@ -0,0 +1,5 @@ +cmake_minimum_required(VERSION 3.11) + +project(${RunCMake_TEST} LANGUAGES NONE) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/add_compile_definitions/RunCMakeTest.cmake b/Tests/RunCMake/add_compile_definitions/RunCMakeTest.cmake new file mode 100644 index 0000000..27d77ef --- /dev/null +++ b/Tests/RunCMake/add_compile_definitions/RunCMakeTest.cmake @@ -0,0 +1,13 @@ +include(RunCMake) + +macro(run_cmake_build test) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test} ${CMAKE_COMMAND} --build . --config Release) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +run_cmake(remove_leading_minusD) +run_cmake_build(remove_leading_minusD) diff --git a/Tests/RunCMake/add_compile_definitions/foo.c b/Tests/RunCMake/add_compile_definitions/foo.c new file mode 100644 index 0000000..74a86e1 --- /dev/null +++ b/Tests/RunCMake/add_compile_definitions/foo.c @@ -0,0 +1,4 @@ + +void foo() +{ +} diff --git a/Tests/RunCMake/add_compile_definitions/remove_leading_minusD.cmake b/Tests/RunCMake/add_compile_definitions/remove_leading_minusD.cmake new file mode 100644 index 0000000..0d94340 --- /dev/null +++ b/Tests/RunCMake/add_compile_definitions/remove_leading_minusD.cmake @@ -0,0 +1,6 @@ + +enable_language(C) + +add_compile_definitions(-DDEF0 "$<1:-DDEF1>") + +add_library(lib1 foo.c) diff --git a/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake index a419cc9..4dd01db 100644 --- a/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_compile_definitions/RunCMakeTest.cmake @@ -2,3 +2,16 @@ include(RunCMake) run_cmake(empty_keyword_args) run_cmake(unknown_imported_target) + + +macro(run_cmake_build test) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test} ${CMAKE_COMMAND} --build . --config Release) + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endmacro() + +run_cmake(remove_leading_minusD) +run_cmake_build(remove_leading_minusD) diff --git a/Tests/RunCMake/target_compile_definitions/foo.c b/Tests/RunCMake/target_compile_definitions/foo.c new file mode 100644 index 0000000..74a86e1 --- /dev/null +++ b/Tests/RunCMake/target_compile_definitions/foo.c @@ -0,0 +1,4 @@ + +void foo() +{ +} diff --git a/Tests/RunCMake/target_compile_definitions/remove_leading_minusD.cmake b/Tests/RunCMake/target_compile_definitions/remove_leading_minusD.cmake new file mode 100644 index 0000000..53c03c1 --- /dev/null +++ b/Tests/RunCMake/target_compile_definitions/remove_leading_minusD.cmake @@ -0,0 +1,9 @@ + +enable_language(C) + +add_library(lib1 foo.c) +target_compile_definitions(lib1 PRIVATE -DDEF0 "$<1:-DDEF1>") +target_compile_definitions(lib1 PUBLIC -DDEF2 "$<1:-DDEF3>") + +add_library(lib2 foo.c) +target_link_libraries(lib2 PRIVATE lib1) |