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

CMakeLists corrected

parent 54bff534
......@@ -63,9 +63,11 @@ test_compile_features(ENABLE_CXX11 amdis_base INTERFACE
cxx_static_assert
cxx_variadic_templates)
if (ENABLE_CXX11)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
# 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)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
endif (ENABLE_CXX11)
# ------------------------------------------------------------------------------
......
......@@ -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})
......@@ -24,13 +26,13 @@ endif (MTL_ENABLE_CXX11)
if (ENABLE_OPENMP)
find_package(OpenMP REQUIRED)
if (OPENMP_FOUND)
target_compile_definitions(mtl4 INTERFACE MTL_WITH_OPENMP)
target_compile_options(mtl4 INTERFACE ${OpenMP_CXX_FLAGS})
else ()
message(FATAL_ERROR "OpenMP not found")
endif (OPENMP_FOUND)
find_package(OpenMP REQUIRED)
if (OPENMP_FOUND)
target_compile_definitions(mtl4 INTERFACE MTL_WITH_OPENMP)
target_compile_options(mtl4 INTERFACE ${OpenMP_CXX_FLAGS})
else ()
message(FATAL_ERROR "OpenMP not found")
endif (OPENMP_FOUND)
endif (ENABLE_OPENMP)
......
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 ()
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 "
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(TestCxx LANGUAGES CXX)
add_library(test_cxx ${BASE_DIR}/cmake3/dummy.cc)
target_compile_features(test_cxx PRIVATE ${_FEATURES})")
execute_process(COMMAND ${CMAKE_COMMAND} ${_DIR}
WORKING_DIRECTORY ${_DIR}
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 ()
set(_DIR ${CMAKE_BINARY_DIR}/test_cxx11)
message(STATUS "Test for cxx11 features for target ${TARGET}")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_DIR})
file(WRITE ${_DIR}/CMakeLists.txt "
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(TestCxx LANGUAGES CXX)
add_library(test_cxx ${BASE_DIR}/cmake3/dummy.cc)
target_compile_features(test_cxx PRIVATE ${_FEATURES})")
execute_process(COMMAND ${CMAKE_COMMAND} ${_DIR}
WORKING_DIRECTORY ${_DIR}
RESULT_VARIABLE _RES_VAR OUTPUT_QUIET)
execute_process(COMMAND ${CMAKE_COMMAND} -E remove_directory ${_DIR})
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