diff options
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeCommands/target_compile_options/CMakeLists.txt | 35 | ||||
-rw-r--r-- | Tests/CMakeCommands/target_compile_options/consumer.cpp | 18 | ||||
-rw-r--r-- | Tests/CMakeCommands/target_compile_options/main.cpp | 18 | ||||
-rw-r--r-- | Tests/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/CompileOptions/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/CompileOptions/main.cpp | 11 | ||||
-rw-r--r-- | Tests/CompileOptions/other.cpp | 5 |
7 files changed, 105 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/target_compile_options/CMakeLists.txt b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt new file mode 100644 index 0000000..06a48fb --- /dev/null +++ b/Tests/CMakeCommands/target_compile_options/CMakeLists.txt @@ -0,0 +1,35 @@ + +cmake_minimum_required(VERSION 2.8) + +project(target_compile_options) + +add_executable(target_compile_options + "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp" +) +target_compile_options(target_compile_options + PRIVATE $<$<CXX_COMPILER_ID:GNU>:-DMY_PRIVATE_DEFINE> + PUBLIC $<$<CXX_COMPILER_ID:GNU>:-DMY_PUBLIC_DEFINE> + INTERFACE $<$<CXX_COMPILER_ID:GNU>:-DMY_INTERFACE_DEFINE> +) + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_definitions(target_compile_options + PRIVATE + "DO_GNU_TESTS" + ) +endif() + +add_executable(consumer + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" +) + +target_compile_options(consumer + PRIVATE $<$<CXX_COMPILER_ID:GNU>:$<TARGET_PROPERTY:target_compile_options,INTERFACE_COMPILE_OPTIONS>> +) + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_definitions(consumer + PRIVATE + "DO_GNU_TESTS" + ) +endif() diff --git a/Tests/CMakeCommands/target_compile_options/consumer.cpp b/Tests/CMakeCommands/target_compile_options/consumer.cpp new file mode 100644 index 0000000..1299606 --- /dev/null +++ b/Tests/CMakeCommands/target_compile_options/consumer.cpp @@ -0,0 +1,18 @@ + +#ifdef DO_GNU_TESTS + +# 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 + +#endif + +int main() { return 0; } diff --git a/Tests/CMakeCommands/target_compile_options/main.cpp b/Tests/CMakeCommands/target_compile_options/main.cpp new file mode 100644 index 0000000..961c06d --- /dev/null +++ b/Tests/CMakeCommands/target_compile_options/main.cpp @@ -0,0 +1,18 @@ + +#ifdef DO_GNU_TESTS + +# 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 + +#endif + +int main() { return 0; } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index cd562c2..ee6c3e6 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -245,6 +245,7 @@ if(BUILD_TESTING) ADD_TEST_MACRO(PolicyScope PolicyScope) ADD_TEST_MACRO(EmptyLibrary EmptyLibrary) ADD_TEST_MACRO(CompileDefinitions CompileDefinitions) + ADD_TEST_MACRO(CompileOptions CompileOptions) ADD_TEST_MACRO(CompatibleInterface CompatibleInterface) set_tests_properties(EmptyLibrary PROPERTIES PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target:test") @@ -1990,6 +1991,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) + ADD_TEST_MACRO(CMakeCommands.target_compile_options target_compile_options) configure_file( "${CMake_SOURCE_DIR}/Tests/CTestTestCrash/test.cmake.in" diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt new file mode 100644 index 0000000..6d8a96a --- /dev/null +++ b/Tests/CompileOptions/CMakeLists.txt @@ -0,0 +1,16 @@ +cmake_minimum_required(VERSION 2.8) + +project(CompileOptions) + +add_library(testlib other.cpp) + +add_executable(CompileOptions main.cpp) +set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE>") +target_link_libraries(CompileOptions testlib) + +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") + target_compile_definitions(CompileOptions + PRIVATE + "DO_GNU_TESTS" + ) +endif() diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp new file mode 100644 index 0000000..0d39050 --- /dev/null +++ b/Tests/CompileOptions/main.cpp @@ -0,0 +1,11 @@ + +#ifdef DO_GNU_TESTS +# ifndef TEST_DEFINE +# error Expected TEST_DEFINE +# endif +#endif + +int main(int argc, char **argv) +{ + return 0; +} diff --git a/Tests/CompileOptions/other.cpp b/Tests/CompileOptions/other.cpp new file mode 100644 index 0000000..0e34375 --- /dev/null +++ b/Tests/CompileOptions/other.cpp @@ -0,0 +1,5 @@ + +void foo(void) +{ + +} |