2013-05-16 17:15:28 +04:00
|
|
|
cmake_minimum_required(VERSION 2.8)
|
|
|
|
|
|
|
|
project(CompileOptions)
|
|
|
|
|
|
|
|
add_library(testlib other.cpp)
|
|
|
|
|
|
|
|
add_executable(CompileOptions main.cpp)
|
2013-06-11 12:48:47 +04:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2013-06-27 19:49:06 +04:00
|
|
|
set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS
|
|
|
|
"-DTEST_DEFINE"
|
|
|
|
"-DNEEDS_ESCAPE=\"E$CAPE\""
|
|
|
|
"$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>"
|
2013-06-11 12:48:47 +04:00
|
|
|
${c_tests}
|
|
|
|
${cxx_tests}
|
2013-06-27 19:49:06 +04:00
|
|
|
)
|
2013-06-11 12:48:47 +04:00
|
|
|
|
2013-05-16 17:15:28 +04:00
|
|
|
target_link_libraries(CompileOptions testlib)
|
|
|
|
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
|
|
target_compile_definitions(CompileOptions
|
|
|
|
PRIVATE
|
|
|
|
"DO_GNU_TESTS"
|
|
|
|
)
|
|
|
|
endif()
|
2013-06-11 12:48:47 +04:00
|
|
|
|
|
|
|
target_compile_definitions(CompileOptions
|
|
|
|
PRIVATE
|
|
|
|
"EXPECTED_C_COMPILER_VERSION=\"${CMAKE_C_COMPILER_VERSION}\""
|
|
|
|
"EXPECTED_CXX_COMPILER_VERSION=\"${CMAKE_CXX_COMPILER_VERSION}\""
|
|
|
|
)
|