mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-03 12:19:41 -06:00
74829f01b1Help: Add notes for topic 'clang-gnulike-support'19669abe1dTests: handle string escaping differences with NMake+clanga2a90f41e3Tests: require C++14 for the Tutorial4819ff9647Tests: fix failures with gnu mode clang on windows26af0b25e7cmake: use correct stack size with gnu mode clang on windowsd44c0db0b2clang: setup correct configuration in gnu modeb7d5ef23e9cmGlobalNinjaGenerator: use gnu compatible paths with clang in gnu mode3d0210d8dcbinutils: add the llvm-* variants to the tool lists. ... Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Francesco Bertolaccini <francesco@bertolaccini.dev> Acked-by: Stanislav Ershov <digital.stream.of.mind@gmail.com> Acked-by: Saleem Abdulrasool <compnerd@compnerd.org> Merge-request: !2992
75 lines
2.1 KiB
CMake
75 lines
2.1 KiB
CMake
cmake_minimum_required(VERSION 2.8)
|
|
|
|
project(CompileOptions)
|
|
|
|
add_library(testlib other.cpp)
|
|
|
|
if(TEST_FORTRAN)
|
|
enable_language(Fortran)
|
|
endif()
|
|
|
|
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)
|
|
if(TEST_FORTRAN)
|
|
get_compiler_test_genex(fortran_tests Fortran)
|
|
endif()
|
|
|
|
set_property(TARGET CompileOptions PROPERTY COMPILE_OPTIONS
|
|
"-DTEST_DEFINE"
|
|
"-DNEEDS_ESCAPE=\"E$CAPE\""
|
|
"$<$<CXX_COMPILER_ID:GNU>:-DTEST_DEFINE_GNU>"
|
|
"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-DTEST_DEFINE_CXX_AND_GNU>"
|
|
"SHELL:" # produces no options
|
|
${c_tests}
|
|
${cxx_tests}
|
|
${fortran_tests}
|
|
)
|
|
if(BORLAND OR WATCOM)
|
|
# these compilers do not support separate -D flags
|
|
target_compile_definitions(CompileOptions PRIVATE NO_DEF_TESTS)
|
|
else()
|
|
set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
|
|
"SHELL:-D DEF_A"
|
|
"$<1:SHELL:-D DEF_B>"
|
|
"SHELL:-D 'DEF_C' -D \"DEF_D\""
|
|
[[SHELL:-D "DEF_STR=\"string with spaces\""]]
|
|
)
|
|
endif()
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|Borland|Embarcadero" AND NOT "${CMAKE_GENERATOR}" MATCHES "NMake Makefiles")
|
|
set_property(TARGET CompileOptions APPEND PROPERTY COMPILE_OPTIONS
|
|
"-DTEST_OCTOTHORPE=\"#\""
|
|
)
|
|
endif()
|
|
|
|
target_link_libraries(CompileOptions testlib)
|
|
|
|
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
|
target_compile_definitions(CompileOptions
|
|
PRIVATE
|
|
"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}\""
|
|
)
|
|
|
|
if(TEST_FORTRAN)
|
|
# Definitions for the C++ code to test the values
|
|
target_compile_definitions(CompileOptions
|
|
PRIVATE
|
|
"TEST_FORTRAN"
|
|
"EXPECTED_Fortran_COMPILER_VERSION=\"${CMAKE_Fortran_COMPILER_VERSION}\""
|
|
)
|
|
endif()
|