summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-01-07 23:34:41 (GMT)
committerBrad King <brad.king@kitware.com>2013-01-10 14:46:58 (GMT)
commitfc61a7a746c3c899d42ccff3014686365c36ee11 (patch)
tree1a8079e72ae1d66b8f73303fb12f73e696aa1e86 /Tests
parent8a37ebec784cefe4f04cb8897c23a014c3930052 (diff)
downloadCMake-fc61a7a746c3c899d42ccff3014686365c36ee11.zip
CMake-fc61a7a746c3c899d42ccff3014686365c36ee11.tar.gz
CMake-fc61a7a746c3c899d42ccff3014686365c36ee11.tar.bz2
Add the target_compile_definitions command.
This is a convenience API to populate the corresponding properties.
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt26
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/consumer.cpp18
-rw-r--r--Tests/CMakeCommands/target_compile_definitions/main.cpp14
-rw-r--r--Tests/CMakeLists.txt1
4 files changed, 59 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
new file mode 100644
index 0000000..84a23ef
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt
@@ -0,0 +1,26 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(target_compile_definitions)
+
+add_executable(target_compile_definitions
+ "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
+)
+target_compile_definitions(target_compile_definitions
+ PRIVATE MY_PRIVATE_DEFINE
+ PUBLIC MY_PUBLIC_DEFINE
+ INTERFACE MY_INTERFACE_DEFINE
+)
+
+add_library(importedlib UNKNOWN IMPORTED)
+target_compile_definitions(importedlib
+ INTERFACE MY_IMPORTEDINTERFACE_DEFINE
+)
+
+add_executable(consumer
+ "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp"
+)
+
+target_compile_definitions(consumer
+ PRIVATE target_compile_definitions importedlib
+)
diff --git a/Tests/CMakeCommands/target_compile_definitions/consumer.cpp b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
new file mode 100644
index 0000000..e3788dd
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_definitions/consumer.cpp
@@ -0,0 +1,18 @@
+
+#ifdef MY_PRIVATE_DEFINE
+#error Unexpected MY_PRIVATE_DEFINE
+#endif
+
+#ifndef MY_PUBLIC_DEFINE
+#error Expected MY_PUBLIC_DEFINE
+#endif
+
+#ifndef MY_INTERFACE_DEFINE
+#error Expected MY_INTERFACE_DEFINE
+#endif
+
+#ifndef MY_IMPORTEDINTERFACE_DEFINE
+#error Expected MY_IMPORTEDINTERFACE_DEFINE
+#endif
+
+int main() { return 0; }
diff --git a/Tests/CMakeCommands/target_compile_definitions/main.cpp b/Tests/CMakeCommands/target_compile_definitions/main.cpp
new file mode 100644
index 0000000..addb33c
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_definitions/main.cpp
@@ -0,0 +1,14 @@
+
+#ifndef MY_PRIVATE_DEFINE
+#error Expected MY_PRIVATE_DEFINE
+#endif
+
+#ifndef MY_PUBLIC_DEFINE
+#error Expected MY_PUBLIC_DEFINE
+#endif
+
+#ifdef MY_INTERFACE_DEFINE
+#error Unexpected MY_INTERFACE_DEFINE
+#endif
+
+int main() { return 0; }
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 2dced5f..2f7df01 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1931,6 +1931,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
ADD_TEST_MACRO(CMakeCommands.target_link_libraries target_link_libraries)
ADD_TEST_MACRO(CMakeCommands.target_include_directories target_include_directories)
+ ADD_TEST_MACRO(CMakeCommands.target_compile_definitions target_compile_definitions)
configure_file(
"${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in"