diff options
author | Brad King <brad.king@kitware.com> | 2018-04-23 14:16:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-23 14:16:24 (GMT) |
commit | ba234392b1ca82549d57488f18e2ab622019d8f6 (patch) | |
tree | 1ac39485ef168ea304f8091e0f81ee436aab6ecd /Tests | |
parent | c74539aad738e7ceddaa223b0edb622724b6a2e2 (diff) | |
parent | cb83314e659ccb6396b897d8c7301f758b415fc1 (diff) | |
download | CMake-ba234392b1ca82549d57488f18e2ab622019d8f6.zip CMake-ba234392b1ca82549d57488f18e2ab622019d8f6.tar.gz CMake-ba234392b1ca82549d57488f18e2ab622019d8f6.tar.bz2 |
Merge topic 'add_compile_definitions'
cb83314e65 add_compile_definitions: add new command
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1988
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/CMakeCommands/add_compile_definitions/main.cpp | 17 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 1 |
3 files changed, 33 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt new file mode 100644 index 0000000..2eb887e --- /dev/null +++ b/Tests/CMakeCommands/add_compile_definitions/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.1) + +project(add_compile_definitions LANGUAGES CXX) + +add_compile_definitions(TEST_DEFINITION + $<$<COMPILE_LANGUAGE:CXX>:LANG_$<COMPILE_LANGUAGE>> + $<$<EQUAL:0,1>:UNEXPECTED_DEFINITION>) + +add_executable(add_compile_definitions main.cpp) + +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp COMPILE_DEFINITIONS) +if (_res) + message(SEND_ERROR "add_compile_definitions populated the COMPILE_DEFINITIONS target property") +endif() diff --git a/Tests/CMakeCommands/add_compile_definitions/main.cpp b/Tests/CMakeCommands/add_compile_definitions/main.cpp new file mode 100644 index 0000000..b382922 --- /dev/null +++ b/Tests/CMakeCommands/add_compile_definitions/main.cpp @@ -0,0 +1,17 @@ + +#ifndef TEST_DEFINITION +#error Expected TEST_DEFINITION +#endif + +#ifndef LANG_CXX +#error Expected LANG_CXX +#endif + +#ifdef UNPEXTED_DEFINITION +#error Unexpected UNPEXTED_DEFINITION +#endif + +int main(void) +{ + return 0; +} diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 38b4828..ed090ec 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2756,6 +2756,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release --output-log "${CMake_BINARY_DIR}/Tests/CTestConfig/ScriptWithArgs.log" ) + ADD_TEST_MACRO(CMakeCommands.add_compile_definitions add_compile_definitions) ADD_TEST_MACRO(CMakeCommands.add_compile_options add_compile_options) ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries) ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories) |