Commit 89120709 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

CMakeLists corrected

parent 54bff534
......@@ -63,6 +63,8 @@ test_compile_features(ENABLE_CXX11 amdis_base INTERFACE
cxx_static_assert
cxx_variadic_templates)
if (ENABLE_CXX11)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
else ()
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
......
......@@ -16,6 +16,8 @@ test_compile_features(MTL_ENABLE_CXX11 mtl4 INTERFACE
cxx_defaulted_functions)
if (MTL_ENABLE_CXX11)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
set (CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL")
foreach (feature ${CXX_ELEVEN_FEATURE_LIST})
target_compile_definitions(mtl4 INTERFACE MTL_WITH_${feature})
......
function(test_compile_features RESULT_VAR TARGET SCOPE) # feature1 feature2 feature3 ...)
macro(test_compile_features RESULT_VAR TARGET SCOPE) # feature1 feature2 feature3 ...)
set(_FEATURES "")
foreach(FEATURE ${ARGN})
set(_FEATURES "${_FEATURES} ${FEATURE}")
endforeach()
set(_DIR ${CMAKE_BINARY_DIR}/test_cxx11)
# test only of variable RESULT_VAR not yet set manually or by a
# previous call to this macro
if (DEFINED ${RESULT_VAR})
return ()
endif ()
set(_DIR ${CMAKE_BINARY_DIR}/test_cxx11)
if (NOT DEFINED ${RESULT_VAR})
message(STATUS "Test for cxx11 features for target ${TARGET}")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_DIR})
file(WRITE ${_DIR}/CMakeLists.txt "
......@@ -23,11 +19,16 @@ function(test_compile_features RESULT_VAR TARGET SCOPE) # feature1 feature2 feat
execute_process(COMMAND ${CMAKE_COMMAND} ${_DIR}
WORKING_DIRECTORY ${_DIR}
RESULT_VARIABLE _RES_VAR OUTPUT_QUIET)
RESULT_VARIABLE _ERR_CODE OUTPUT_QUIET)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${_DIR})
elseif (${RESULT_VAR})
set(_ERR_CODE "0")
else ()
set(_ERR_CODE "1")
endif ()
if ("${_RES_VAR}" STREQUAL "0")
if ("${_ERR_CODE}" STREQUAL "0")
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
target_compile_features(${TARGET} ${SCOPE} ${ARGN})
else ()
......@@ -35,7 +36,7 @@ function(test_compile_features RESULT_VAR TARGET SCOPE) # feature1 feature2 feat
endif ()
mark_as_advanced(${RESULT_VAR})
#unset(_RES_VAR)
#unset(_DIR)
#unset(_FEATURES)
endfunction(test_compile_features)
\ No newline at end of file
unset(_ERR_CODE)
unset(_DIR)
unset(_FEATURES)
endmacro(test_compile_features)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment