diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-05-16 13:52:25 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-05-24 13:06:53 (GMT) |
commit | 32410140a7c592090249db772fd5f18c7808a3aa (patch) | |
tree | 055e13759b3d6a1a7d67311c3f0fcb609c5adcdb /Tests | |
parent | a7ba4520c7b15dc9f56d2c4718748b79b12c0c89 (diff) | |
download | CMake-32410140a7c592090249db772fd5f18c7808a3aa.zip CMake-32410140a7c592090249db772fd5f18c7808a3aa.tar.gz CMake-32410140a7c592090249db772fd5f18c7808a3aa.tar.bz2 |
Add $<LINK_LANGUAGE> generator expression
They can't be used when evaluating link libraries, but they can be
used for include directories and compile definitions. Later they can
be used for compile options.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CompileDefinitions/compiletest.c | 19 | ||||
-rw-r--r-- | Tests/CompileDefinitions/compiletest.cpp | 15 | ||||
-rw-r--r-- | Tests/CompileDefinitions/compiletest_mixed_c.c | 19 | ||||
-rw-r--r-- | Tests/CompileDefinitions/compiletest_mixed_cxx.cpp | 19 | ||||
-rw-r--r-- | Tests/CompileDefinitions/target_prop/CMakeLists.txt | 20 | ||||
-rw-r--r-- | Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt | 16 | ||||
-rw-r--r-- | Tests/IncludeDirectories/TargetIncludeDirectories/main.c | 7 | ||||
-rw-r--r-- | Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp | 1 |
8 files changed, 116 insertions, 0 deletions
diff --git a/Tests/CompileDefinitions/compiletest.c b/Tests/CompileDefinitions/compiletest.c new file mode 100644 index 0000000..d7883af --- /dev/null +++ b/Tests/CompileDefinitions/compiletest.c @@ -0,0 +1,19 @@ + +#ifndef LINK_C_DEFINE +#error Expected LINK_C_DEFINE +#endif +#ifndef LINK_LANGUAGE_IS_C +#error Expected LINK_LANGUAGE_IS_C +#endif + +#ifdef LINK_CXX_DEFINE +#error Unexpected LINK_CXX_DEFINE +#endif +#ifdef LINK_LANGUAGE_IS_CXX +#error Unexpected LINK_LANGUAGE_IS_CXX +#endif + +int main(void) +{ + return 0; +} diff --git a/Tests/CompileDefinitions/compiletest.cpp b/Tests/CompileDefinitions/compiletest.cpp index 7379380..7df09df 100644 --- a/Tests/CompileDefinitions/compiletest.cpp +++ b/Tests/CompileDefinitions/compiletest.cpp @@ -56,6 +56,21 @@ enum { #error Expect PREFIX_DEF2 #endif +#ifndef LINK_CXX_DEFINE +#error Expected LINK_CXX_DEFINE +#endif +#ifndef LINK_LANGUAGE_IS_CXX +#error Expected LINK_LANGUAGE_IS_CXX +#endif + +#ifdef LINK_C_DEFINE +#error Unexpected LINK_C_DEFINE +#endif +#ifdef LINK_LANGUAGE_IS_C +#error Unexpected LINK_LANGUAGE_IS_C +#endif + + // TEST_GENERATOR_EXPRESSIONS #endif diff --git a/Tests/CompileDefinitions/compiletest_mixed_c.c b/Tests/CompileDefinitions/compiletest_mixed_c.c new file mode 100644 index 0000000..698c989 --- /dev/null +++ b/Tests/CompileDefinitions/compiletest_mixed_c.c @@ -0,0 +1,19 @@ + +#ifndef LINK_CXX_DEFINE +#error Expected LINK_CXX_DEFINE +#endif +#ifndef LINK_LANGUAGE_IS_CXX +#error Expected LINK_LANGUAGE_IS_CXX +#endif + +#ifdef LINK_C_DEFINE +#error Unexpected LINK_C_DEFINE +#endif +#ifdef LINK_LANGUAGE_IS_C +#error Unexpected LINK_LANGUAGE_IS_C +#endif + +void someFunc(void) +{ + +} diff --git a/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp new file mode 100644 index 0000000..c686854 --- /dev/null +++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp @@ -0,0 +1,19 @@ + +#ifndef LINK_CXX_DEFINE +#error Expected LINK_CXX_DEFINE +#endif +#ifndef LINK_LANGUAGE_IS_CXX +#error Expected LINK_LANGUAGE_IS_CXX +#endif + +#ifdef LINK_C_DEFINE +#error Unexpected LINK_C_DEFINE +#endif +#ifdef LINK_LANGUAGE_IS_C +#error Unexpected LINK_LANGUAGE_IS_C +#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 index 34be917..66a3aa6 100644 --- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt +++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt @@ -19,9 +19,29 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS LETTER_LIST3=\"$<JOIN:A;B;C;D,,->\" LETTER_LIST4=\"$<JOIN:A;B;C;D,-,->\" LETTER_LIST5=\"$<JOIN:A;B;C;D,-,>\" + "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>" + "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>" ) set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS BUILD_IS_DEBUG=$<CONFIG:Debug> BUILD_IS_NOT_DEBUG=$<NOT:$<CONFIG:Debug>> ) + +add_executable(target_prop_c_executable ../compiletest.c) + +set_property(TARGET target_prop_c_executable APPEND PROPERTY COMPILE_DEFINITIONS + "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>" + "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>" + ) + +# Resulting link language will be CXX +add_executable(target_prop_mixed_executable ../compiletest_mixed_c.c ../compiletest_mixed_cxx.cpp) + +set_property(TARGET target_prop_mixed_executable APPEND PROPERTY COMPILE_DEFINITIONS + "$<$<LINK_LANGUAGE:CXX>:LINK_CXX_DEFINE>" + "$<$<LINK_LANGUAGE:C>:LINK_C_DEFINE>" + "LINK_LANGUAGE_IS_$<LINK_LANGUAGE>" + ) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 60d4c6a..50f12ee 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -128,3 +128,19 @@ file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_ba file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/prefix_foo/prefix_bar/prefix_bat/prefix_foo_bar_bat.h" "// prefix_foo_bar_bat.h\n") target_include_directories(TargetIncludeDirectories PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/prefix_$<JOIN:foo;bar;bat,/prefix_>") + +# Test that the language generator expressions work +set_property(TARGET TargetIncludeDirectories + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<$<LINK_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$<LINK_LANGUAGE:CXX>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$<STREQUAL:$<LINK_LANGUAGE>,CXX>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" +) + +add_executable(TargetIncludeDirectories_C main.c) +set_property(TARGET TargetIncludeDirectories_C + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<$<LINK_LANGUAGE:CXX>:${CMAKE_CURRENT_BINARY_DIR}/bad>" + "$<$<LINK_LANGUAGE:C>:${CMAKE_CURRENT_BINARY_DIR}/good>" + "$<$<STREQUAL:$<LINK_LANGUAGE>,C>:${CMAKE_CURRENT_BINARY_DIR}/othergood/>" +) diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.c b/Tests/IncludeDirectories/TargetIncludeDirectories/main.c new file mode 100644 index 0000000..a597daa --- /dev/null +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.c @@ -0,0 +1,7 @@ + +#include "common.h" + +int main(void) +{ + return 0; +} diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp index 5bb34aa..aed0bde 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -11,6 +11,7 @@ #include "list.h" #include "target.h" #include "prefix_foo_bar_bat.h" +#include "common.h" int main(int, char**) { |