diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-03-04 20:53:15 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-03-09 19:49:17 (GMT) |
commit | b734fa44719a780683e2eb0dfaabd38d64daa3f6 (patch) | |
tree | 55e4a63eb8ebb01ccc216b146fd5a126ea0698b1 /Tests/CMakeCommands | |
parent | 0b945ea9a6a38d1b3ee27cc32afb4268bd571600 (diff) | |
download | CMake-b734fa44719a780683e2eb0dfaabd38d64daa3f6.zip CMake-b734fa44719a780683e2eb0dfaabd38d64daa3f6.tar.gz CMake-b734fa44719a780683e2eb0dfaabd38d64daa3f6.tar.bz2 |
Genex: Allow COMPILE_LANGUAGE when processing include directories.
Issue an error if this is encountered by an IDE generator.
Diffstat (limited to 'Tests/CMakeCommands')
5 files changed, 37 insertions, 0 deletions
diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 661bbaa..d57556a 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -42,6 +42,20 @@ add_executable(consumer "${CMAKE_CURRENT_SOURCE_DIR}/consumer.cpp" ) +if (CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "Ninja") + target_sources(consumer PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/consumer.c" + ) + target_include_directories(consumer + PRIVATE + $<$<COMPILE_LANGUAGE:CXX>:${CMAKE_CURRENT_SOURCE_DIR}/cxx_only> + $<$<COMPILE_LANGUAGE:C>:${CMAKE_CURRENT_SOURCE_DIR}/c_only> + ) + target_compile_definitions(consumer + PRIVATE -DTEST_LANG_DEFINES + ) +endif() + target_include_directories(consumer PRIVATE $<TARGET_PROPERTY:target_include_directories,INTERFACE_INCLUDE_DIRECTORIES> diff --git a/Tests/CMakeCommands/target_include_directories/c_only/c_only.h b/Tests/CMakeCommands/target_include_directories/c_only/c_only.h new file mode 100644 index 0000000..29f68ee --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/c_only/c_only.h @@ -0,0 +1,2 @@ + +#define C_ONLY_DEFINE diff --git a/Tests/CMakeCommands/target_include_directories/consumer.c b/Tests/CMakeCommands/target_include_directories/consumer.c new file mode 100644 index 0000000..8821f5b --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/consumer.c @@ -0,0 +1,10 @@ + +#ifdef TEST_LANG_DEFINES + #include "c_only.h" + + #ifndef C_ONLY_DEFINE + #error Expected C_ONLY_DEFINE + #endif +#endif + +int consumer_c() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/consumer.cpp b/Tests/CMakeCommands/target_include_directories/consumer.cpp index 7e3443e..649510c 100644 --- a/Tests/CMakeCommands/target_include_directories/consumer.cpp +++ b/Tests/CMakeCommands/target_include_directories/consumer.cpp @@ -4,6 +4,9 @@ #include "interfaceinclude.h" #include "relative_dir.h" #include "consumer.h" +#ifdef TEST_LANG_DEFINES + #include "cxx_only.h" +#endif #ifdef PRIVATEINCLUDE_DEFINE #error Unexpected PRIVATEINCLUDE_DEFINE @@ -29,4 +32,10 @@ #error Expected CONSUMER_DEFINE #endif +#ifdef TEST_LANG_DEFINES + #ifndef CXX_ONLY_DEFINE + #error Expected CXX_ONLY_DEFINE + #endif +#endif + int main() { return 0; } diff --git a/Tests/CMakeCommands/target_include_directories/cxx_only/cxx_only.h b/Tests/CMakeCommands/target_include_directories/cxx_only/cxx_only.h new file mode 100644 index 0000000..67289a4 --- /dev/null +++ b/Tests/CMakeCommands/target_include_directories/cxx_only/cxx_only.h @@ -0,0 +1,2 @@ + +#define CXX_ONLY_DEFINE |