summaryrefslogtreecommitdiff
path: root/Tests/CompileDefinitions
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/CompileDefinitions')
-rw-r--r--Tests/CompileDefinitions/CMakeLists.txt1
-rw-r--r--Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt11
-rw-r--r--Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt4
-rw-r--r--Tests/CompileDefinitions/compiletest.c19
-rw-r--r--Tests/CompileDefinitions/compiletest.cpp35
-rw-r--r--Tests/CompileDefinitions/compiletest_mixed_c.c23
-rw-r--r--Tests/CompileDefinitions/compiletest_mixed_cxx.cpp23
-rw-r--r--Tests/CompileDefinitions/target_prop/CMakeLists.txt33
8 files changed, 142 insertions, 7 deletions
diff --git a/Tests/CompileDefinitions/CMakeLists.txt b/Tests/CompileDefinitions/CMakeLists.txt
index d3e9a3eae..930d22058 100644
--- a/Tests/CompileDefinitions/CMakeLists.txt
+++ b/Tests/CompileDefinitions/CMakeLists.txt
@@ -5,6 +5,7 @@ project(CompileDefinitions)
if ("${CMAKE_GENERATOR}" STREQUAL "Visual Studio 6")
add_definitions(-DNO_SPACES_IN_DEFINE_VALUES)
+ set(NO_SPACES_IN_DEFINE_VALUES 1)
endif()
# Use compile flags to tell executables which config is built
diff --git a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt b/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt
index d3886a104..23e013425 100644
--- a/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt
+++ b/Tests/CompileDefinitions/add_definitions_command/CMakeLists.txt
@@ -1,8 +1,15 @@
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_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun -DCMAKE_IS_="Fun")
+if (NOT NO_SPACES_IN_DEFINE_VALUES)
+ add_definitions(-DCMAKE_IS_REALLY="Very Fun")
+endif()
+add_definitions(-DCMAKE_IS_="Fun")
+if (NOT NO_SPACES_IN_DEFINE_VALUES)
+ add_definitions(-DCMAKE_IS_REALLY="Very Fun")
+endif()
+add_definitions(-DCMAKE_IS_FUN -DCMAKE_IS=Fun)
add_definitions(-DBUILD_IS_DEBUG=$<CONFIG:Debug> -DBUILD_IS_NOT_DEBUG=$<NOT:$<CONFIG:Debug>>)
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
index 5587f7f99..55108db7a 100644
--- a/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt
+++ b/Tests/CompileDefinitions/add_definitions_command_with_target_prop/CMakeLists.txt
@@ -7,7 +7,9 @@ add_executable(add_definitions_command_with_target_prop_executable ../compiletes
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")
+if (NOT NO_SPACES_IN_DEFINE_VALUES)
+ set_property(TARGET add_definitions_command_with_target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun")
+endif()
add_definitions(-DCMAKE_IS_FUN)
diff --git a/Tests/CompileDefinitions/compiletest.c b/Tests/CompileDefinitions/compiletest.c
new file mode 100644
index 000000000..d7883af77
--- /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 14b8eab4a..7df09df81 100644
--- a/Tests/CompileDefinitions/compiletest.cpp
+++ b/Tests/CompileDefinitions/compiletest.cpp
@@ -20,10 +20,16 @@ static const char very_fun_string[] = CMAKE_IS_REALLY;
#endif
enum {
- StringLiteralTest1 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>)
+ StringLiteralTest1 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_) == sizeof("Fun")>),
#ifndef NO_SPACES_IN_DEFINE_VALUES
- ,
- StringLiteralTest2 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>)
+ StringLiteralTest2 = sizeof(CMakeStaticAssert<sizeof(CMAKE_IS_REALLY) == sizeof("Very Fun")>),
+#endif
+#ifdef TEST_GENERATOR_EXPRESSIONS
+ StringLiteralTest3 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST1) == sizeof("A,B,C,D")>),
+ StringLiteralTest4 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST2) == sizeof("A,,B,,C,,D")>),
+ StringLiteralTest5 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST3) == sizeof("A,-B,-C,-D")>),
+ StringLiteralTest6 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST4) == sizeof("A-,-B-,-C-,-D")>),
+ StringLiteralTest7 = sizeof(CMakeStaticAssert<sizeof(LETTER_LIST5) == sizeof("A-,B-,C-,D")>)
#endif
};
@@ -42,6 +48,29 @@ enum {
#error Expected define expanded from list
#endif
+#ifndef PREFIX_DEF1
+#error Expect PREFIX_DEF1
+#endif
+
+#ifndef PREFIX_DEF2
+#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 000000000..a270b2b12
--- /dev/null
+++ b/Tests/CompileDefinitions/compiletest_mixed_c.c
@@ -0,0 +1,23 @@
+
+#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
+
+#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C
+#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
+#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 000000000..ae6befc5f
--- /dev/null
+++ b/Tests/CompileDefinitions/compiletest_mixed_cxx.cpp
@@ -0,0 +1,23 @@
+
+#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
+
+#ifndef C_EXECUTABLE_LINK_LANGUAGE_IS_C
+#error Expected C_EXECUTABLE_LINK_LANGUAGE_IS_C define
+#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 1ef2d6d6e..a0d3f4e96 100644
--- a/Tests/CompileDefinitions/target_prop/CMakeLists.txt
+++ b/Tests/CompileDefinitions/target_prop/CMakeLists.txt
@@ -5,7 +5,11 @@ 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)
+if (NOT NO_SPACES_IN_DEFINE_VALUES)
+ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_REALLY="Very Fun" CMAKE_IS=Fun)
+else()
+ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS=Fun)
+endif()
set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_IS_FUN CMAKE_IS_="Fun")
set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS
@@ -13,9 +17,36 @@ set_property(TARGET target_prop_executable APPEND PROPERTY COMPILE_DEFINITIONS
"$<1:CMAKE_IS_DECLARATIVE>"
"$<0:GE_NOT_DEFINED>"
"$<1:ARGUMENT;LIST>"
+ PREFIX_$<JOIN:DEF1;DEF2,;PREFIX_>
+ LETTER_LIST1=\"$<JOIN:A;B;C;D,,>\"
+ LETTER_LIST2=\"$<JOIN:A;B;C;D,,,>\"
+ LETTER_LIST3=\"$<JOIN:A;B;C;D,,->\"
+ LETTER_LIST4=\"$<JOIN:A;B;C;D,-,->\"
+ LETTER_LIST5=\"$<JOIN:A;B;C;D,-,>\"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>"
+ "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_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
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>"
+ "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_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
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,CXX>:LINK_CXX_DEFINE>"
+ "$<$<STREQUAL:$<TARGET_PROPERTY:LINKER_LANGUAGE>,C>:LINK_C_DEFINE>"
+ "LINK_LANGUAGE_IS_$<TARGET_PROPERTY:LINKER_LANGUAGE>"
+ "C_EXECUTABLE_LINK_LANGUAGE_IS_$<TARGET_PROPERTY:target_prop_c_executable,LINKER_LANGUAGE>"
+ )