summaryrefslogtreecommitdiffstats
path: root/Tests/CompileDefinitions
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/CompileDefinitions')
-rw-r--r--Tests/CompileDefinitions/CMakeLists.txt12
-rw-r--r--Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt7
-rw-r--r--Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt14
-rw-r--r--Tests/CompileDefinitions/main.cpp28
-rw-r--r--Tests/CompileDefinitions/target_prop/CMakeLists.txt9
5 files changed, 70 insertions, 0 deletions
diff --git a/Tests/CompileDefinitions/CMakeLists.txt b/Tests/CompileDefinitions/CMakeLists.txt
new file mode 100644
index 0000000..3e4181b
--- /dev/null
+++ b/Tests/CompileDefinitions/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+cmake_minimum_required(VERSION 2.8)
+
+project(CompileDefinitions)
+
+add_subdirectory(add_definitions_command)
+add_subdirectory(target_prop)
+add_subdirectory(add_definitions_command_with_target_prop)
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" "int main(int, char **) { return 0; }\n")
+
+add_executable(CompileDefinitions "${CMAKE_CURRENT_BINARY_DIR}/main.cpp")
diff --git a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt b/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt
new file mode 100644
index 0000000..4ca269d
--- /dev/null
+++ b/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt
@@ -0,0 +1,7 @@
+
+project(add_definitions_command)
+
+add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun -DCMAKE_IS_="Fun" -DCMAKE_IS_REALLY="Very Fun")
+add_definitions(-DCMAKE_IS_="Fun" -DCMAKE_IS_REALLY="Very Fun" -DCMAKE_IS_FUN -DCMAKE_IS=Fun)
+
+add_executable(add_definitions_command_executable ../main.cpp)
diff --git a/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt b/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt
new file mode 100644
index 0000000..4161ed6
--- /dev/null
+++ b/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt
@@ -0,0 +1,14 @@
+
+project(add_definitions_command_with_target_prop)
+
+add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun)
+
+add_executable(add_definitions_command_with_target_prop_executable ../main.cpp)
+
+set_target_properties(add_definitions_command_with_target_prop_executable PROPERTIES COMPILE_DEFINITIONS CMAKE_IS_="Fun")
+
+set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun")
+
+add_definitions(-DCMAKE_IS_FUN)
+
+set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS=Fun CMAKE_IS_="Fun")
diff --git a/Tests/CompileDefinitions/main.cpp b/Tests/CompileDefinitions/main.cpp
new file mode 100644
index 0000000..d80c9dc
--- /dev/null
+++ b/Tests/CompileDefinitions/main.cpp
@@ -0,0 +1,28 @@
+
+#ifndef CMAKE_IS_FUN
+#error Expect CMAKE_IS_FUN definition
+#endif
+
+#if CMAKE_IS != Fun
+#error Expect CMAKE_IS=Fun definition
+#endif
+
+
+template<bool test>
+struct CMakeStaticAssert;
+
+template<>
+struct CMakeStaticAssert<true> {};
+
+static const char fun_string[] = CMAKE_IS_;
+static const char very_fun_string[] = CMAKE_IS_REALLY;
+
+enum {
+ StringLiteralTest1 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>),
+ StringLiteralTest2 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>)
+};
+
+int main(int argc, char **argv)
+{
+ return 0;
+}
diff --git a/Tests/CompileDefinitions/target_prop/CMakeLists.txt b/Tests/CompileDefinitions/target_prop/CMakeLists.txt
new file mode 100644
index 0000000..8248a21
--- /dev/null
+++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt
@@ -0,0 +1,9 @@
+
+project(target_prop)
+
+add_executable(target_prop_executable ../main.cpp)
+
+set_target_properties(target_prop_executable PROPERTIES CMAKE_IS_FUN -DCMAKE_IS_REALLY="Very Fun")
+
+set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun" CMAKE_IS=Fun)
+set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_FUN CMAKE_IS_="Fun")