summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
Diffstat (limited to 'Tests')
-rw-r--r--Tests/CompileOptions/CMakeLists.txt18
-rw-r--r--Tests/CompileOptions/main.cpp6
2 files changed, 23 insertions, 1 deletions
diff --git a/Tests/CompileOptions/CMakeLists.txt b/Tests/CompileOptions/CMakeLists.txt
index 52c3759..9b6c9c2 100644
--- a/Tests/CompileOptions/CMakeLists.txt
+++ b/Tests/CompileOptions/CMakeLists.txt
@@ -5,11 +5,23 @@ project(CompileOptions)
add_library(testlib other.cpp)
add_executable(CompileOptions main.cpp)
+
+macro(get_compiler_test_genex lst lang)
+ list(APPEND ${lst} -DTEST_${lang}_COMPILER_VERSION="$<${lang}_COMPILER_VERSION>")
+ list(APPEND ${lst} -DTEST_${lang}_COMPILER_VERSION_EQUALITY=$<${lang}_COMPILER_VERSION:${CMAKE_${lang}_COMPILER_VERSION}>)
+endmacro()
+
+get_compiler_test_genex(c_tests C)
+get_compiler_test_genex(cxx_tests CXX)
+
set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS
"-DTEST_DEFINE"
"-DNEEDS_ESCAPE=\"E$CAPE\""
"$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>"
+ ${c_tests}
+ ${cxx_tests}
)
+
target_link_libraries(CompileOptions testlib)
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
@@ -18,3 +30,9 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
"DO_GNU_TESTS"
)
endif()
+
+target_compile_definitions(CompileOptions
+ PRIVATE
+ "EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\""
+ "EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\""
+)
diff --git a/Tests/CompileOptions/main.cpp b/Tests/CompileOptions/main.cpp
index 90740f1..42f4cca 100644
--- a/Tests/CompileOptions/main.cpp
+++ b/Tests/CompileOptions/main.cpp
@@ -16,5 +16,9 @@
int main()
{
- return strcmp(NEEDS_ESCAPE, "E$CAPE") == 0 ? 0 : 1;
+ return (strcmp(NEEDS_ESCAPE, "E$CAPE") == 0
+ && strcmp(EXPECTED_C_COMPILER_VERSION, TEST_C_COMPILER_VERSION) == 0
+ && strcmp(EXPECTED_CXX_COMPILER_VERSION, TEST_CXX_COMPILER_VERSION) == 0
+ && TEST_C_COMPILER_VERSION_EQUALITY == 1
+ && TEST_CXX_COMPILER_VERSION_EQUALITY == 1) ? 0 : 1;
}