From 6a9fdbeb48eb16a0f7082329f0d0840bf0c0a98c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 9 May 2014 17:27:55 +0200 Subject: Test: Parameterize the language in the CompileFeature test. --- Tests/CompileFeatures/CMakeLists.txt | 42 ++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 925f757..adf50d5 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -34,25 +34,29 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL GNU ) endif() -if (CMAKE_CXX_COMPILE_FEATURES) - foreach(feature ${CXX_non_features}) - message("Testing feature : ${feature}") - try_compile(${feature}_works - "${CMAKE_CURRENT_BINARY_DIR}/${feature}_test" - "${CMAKE_CURRENT_SOURCE_DIR}/feature_test.cpp" - COMPILE_DEFINITIONS "-DTEST=${CMAKE_CURRENT_SOURCE_DIR}/${feature}.cpp" - CMAKE_FLAGS "-DCMAKE_CXX_STANDARD=11" - OUTPUT_VARIABLE OUTPUT - ) - if (${feature}_works) - message(SEND_ERROR - "Feature ${feature} expected not to work for ${CMAKE_CXX_COMPILER_ID}-${CMAKE_CXX_COMPILER_VERSION}. -Update the supported features or blacklist it.\n${OUTPUT}") - else() - message("Testing feature : ${feature} -- Fails, as expected.") - endif() - endforeach() -endif() +set(CXX_ext cpp) +set(CXX_standard_flag 11) +foreach(lang CXX) + if (CMAKE_${lang}_COMPILE_FEATURES) + foreach(feature ${${lang}_non_features}) + message("Testing feature : ${feature}") + try_compile(${feature}_works + "${CMAKE_CURRENT_BINARY_DIR}/${feature}_test" + "${CMAKE_CURRENT_SOURCE_DIR}/feature_test.${${lang}_ext}" + COMPILE_DEFINITIONS "-DTEST=${CMAKE_CURRENT_SOURCE_DIR}/${feature}.${${lang}_ext}" + CMAKE_FLAGS "-DCMAKE_${lang}_STANDARD=${${lang}_standard_flag}" + OUTPUT_VARIABLE OUTPUT + ) + if (${feature}_works) + message(SEND_ERROR + "Feature ${feature} expected not to work for ${lang} ${CMAKE_${lang}_COMPILER_ID}-${CMAKE_${lang}_COMPILER_VERSION}. + Update the supported features or blacklist it.\n${OUTPUT}") + else() + message("Testing feature : ${feature} -- Fails, as expected.") + endif() + endforeach() + endif() +endforeach() add_executable(CompileFeatures main.cpp) set_property(TARGET CompileFeatures -- cgit v0.12