diff options
author | David Cole <david.cole@kitware.com> | 2012-08-24 18:24:24 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2012-08-24 18:24:24 (GMT) |
commit | 05784dadc59ee3c87ab6140d684ff4c602de9ec1 (patch) | |
tree | dbaac2b00fb70a112a9e1ee71323c5c224bde6b9 /Tests | |
parent | 286f7c9644d1fb8ac8b5d46e2a3c9c393680acef (diff) | |
parent | f0a1065393a57f503bc2c86f432f50dd4b8d5bbd (diff) | |
download | CMake-05784dadc59ee3c87ab6140d684ff4c602de9ec1.zip CMake-05784dadc59ee3c87ab6140d684ff4c602de9ec1.tar.gz CMake-05784dadc59ee3c87ab6140d684ff4c602de9ec1.tar.bz2 |
Merge topic 'compile-definitions-unique'
f0a1065 Rename files from main.cpp to more meaningful names.
ca7fb14 Fix the test setting COMPILE_DEFINITIONS target property
733deb6 Fix CompileDefinitions test on Visual Studio.
3dae652 Don't duplicate -D defines sent to the compiler.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/CompileDefinitions/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt | 7 | ||||
-rw-r--r-- | Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/CompileDefinitions/compiletest.cpp | 33 | ||||
-rw-r--r-- | Tests/CompileDefinitions/target_prop/CMakeLists.txt | 9 |
6 files changed, 80 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 35a8d41..e03b926 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -213,6 +213,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(Unset Unset) ADD_TEST_MACRO(PolicyScope PolicyScope) ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) + ADD_TEST_MACRO(CompileDefinitions CompileDefinitions) set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") ADD_TEST_MACRO(CrossCompile CrossCompile) diff --git a/Tests/CompileDefinitions/CMakeLists.txt b/Tests/CompileDefinitions/CMakeLists.txt new file mode 100644 index 0000000..e7d91bf --- /dev/null +++ b/Tests/CompileDefinitions/CMakeLists.txt @@ -0,0 +1,16 @@ + +cmake_minimum_required(VERSION 2.8) + +project(CompileDefinitions) + +if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 6") + add_definitions(-DNO_SPACES_IN_DEFINE_VALUES) +endif() + +add_subdirectory(add_definitions_command) +add_subdirectory(target_prop) +add_subdirectory(add_definitions_command_with_target_prop) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummyexecutable.cpp" "int main(int, char **) { return 0; }\n") + +add_executable(CompileDefinitions "${CMAKE_CURRENT_BINARY_DIR}/dummyexecutable.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..a6372af --- /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 ../compiletest.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..e415390 --- /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 ../compiletest.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/compiletest.cpp b/Tests/CompileDefinitions/compiletest.cpp new file mode 100644 index 0000000..6db6f3f --- /dev/null +++ b/Tests/CompileDefinitions/compiletest.cpp @@ -0,0 +1,33 @@ + +#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_; +#ifndef NO_SPACES_IN_DEFINE_VALUES +static const char very_fun_string[] = CMAKE_IS_REALLY; +#endif + +enum { + StringLiteralTest1 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>) +#ifndef NO_SPACES_IN_DEFINE_VALUES + , + StringLiteralTest2 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>) +#endif +}; + +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..e2b6ba9 --- /dev/null +++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt @@ -0,0 +1,9 @@ + +project(target_prop) + +add_executable(target_prop_executable ../compiletest.cpp) + +set_target_properties(target_prop_executable PROPERTIES COMPILE_DEFINITIONS CMAKE_IS_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") |