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

has_cxx11 flag corrected

parent 7dd92158
......@@ -3,35 +3,23 @@ include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
if (ENABLE_CXX11)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11_FLAG)
if (NOT COMPILER_SUPPORTS_CXX11)
set(CXX11_CODE "#include <tuple>\\n#include <array>\\ntemplate<class... T> using std::tuple<T...>;int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}")
if (COMPILER_SUPPORTS_CXX11_FLAG)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX11)
check_cxx_source_compiles("${CXX11_CODE}" CXX11_COMPILES_WITH_CXX11_FLAG)
set(CMAKE_REQUIRED_FLAGS "")
endif ()
if (COMPILER_SUPPORTS_CXX11 OR CXX_COMPILES_WITH_CXX11)
if (COMPILER_SUPPORTS_CXX11_FLAG AND CXX11_COMPILES_WITH_CXX11_FLAG)
add_definitions("-std=c++11")
else ()
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (NOT COMPILER_SUPPORTS_CXX0X)
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX0X)
set(CMAKE_REQUIRED_FLAGS "")
endif ()
if (COMPILER_SUPPORTS_CXX0X OR CXX_COMPILES_WITH_CXX0X)
add_definitions("-std=c++0x")
else ()
check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX11_COMPILES)
check_include_file_cxx("array" CXX11_INCLUDES)
check_cxx_source_compiles("${CXX11_CODE}" CXX11_COMPILES)
if (CXX11_COMPILES AND CXX11_INCLUDES)
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
else ()
message (FATAL_ERROR "Compiler does not support C++11.")
endif ()
if (NOT CXX11_COMPILES)
message (FATAL_ERROR "Compiler does not support C++11.")
endif ()
endif ()
......
......@@ -14,8 +14,8 @@
# target_link_libraries(yourTarget AMDiS)
#
if (${CMAKE_VERSION} VERSION_LESS "3.0")
message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.0")
if (${CMAKE_VERSION} VERSION_LESS "3.2")
message(FATAL_ERROR "The Configuration file was created for CMake version >= 3.2")
endif ()
list(APPEND CMAKE_MODULE_PATH ${AMDIS_DIR})
......@@ -39,13 +39,11 @@ set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)
target_compile_definitions(amdis_base INTERFACE
$<$<CONFIG:Release>:DEBUG=0>
$<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
target_compile_definitions(amdis_base INTERFACE)
if (AMDIS_NEED_CXX11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(test_compile_features)
target_enable_cxx11(AMDIS_NEED_CXX11 amdis_base INTERFACE)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
else ()
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
......@@ -220,8 +218,11 @@ endif ()
get_target_property(AMDIS_INCLUDE_DIRS AMDiS INTERFACE_INCLUDE_DIRECTORIES)
get_target_property(AMDIS_LIBRARIES AMDiS INTERFACE_LINK_LIBRARIES)
get_target_property(AMDIS_COMPILEFLAGS AMDiS INTERFACE_COMPILE_OPTIONS)
if (NOT AMDIS_COMPILEFLAGS)
set(AMDIS_COMPILEFLAGS "")
endif()
get_target_property(_DEFINITIONS AMDiS INTERFACE_COMPILE_DEFINITIONS)
foreach(defn ${_DEFINITIONS})
list(APPEND AMDIS_COMPILEFLAGS "-D${defn}")
endforeach(s)
endforeach(defn)
......@@ -42,9 +42,7 @@ add_library(amdis_base INTERFACE)
add_library(AMDiS::base ALIAS amdis_base)
target_include_directories(amdis_base INTERFACE ${SOURCE_DIR})
target_compile_definitions(amdis_base INTERFACE
$<$<CONFIG:Release>:DEBUG=0>
$<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
target_compile_definitions(amdis_base INTERFACE)
include(test_compile_features)
target_enable_cxx11(ENABLE_CXX11 amdis_base INTERFACE)
......
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
macro(target_enable_cxx11 RESULT_VAR _TARGET_ _SCOPE_)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11_FLAG)
if (NOT COMPILER_SUPPORTS_CXX11)
set(CXX11_CODE "#include <tuple>\\n#include <array>\\ntemplate<class... T> using std::tuple<T...>;int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}")
if (COMPILER_SUPPORTS_CXX11_FLAG)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX11)
check_cxx_source_compiles("${CXX11_CODE}" CXX11_COMPILES_WITH_CXX11_FLAG)
set(CMAKE_REQUIRED_FLAGS "")
endif ()
if (COMPILER_SUPPORTS_CXX11 OR CXX_COMPILES_WITH_CXX11)
if (COMPILER_SUPPORTS_CXX11_FLAG AND CXX11_COMPILES_WITH_CXX11_FLAG)
target_compile_options(${_TARGET_} ${_SCOPE_} "-std=c++11")
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features" FORCE)
else ()
check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if (NOT COMPILER_SUPPORTS_CXX0X)
set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX0X)
set(CMAKE_REQUIRED_FLAGS "")
endif ()
check_cxx_source_compiles("${CXX11_CODE}" CXX11_COMPILES)
if (COMPILER_SUPPORTS_CXX0X OR CXX_COMPILES_WITH_CXX0X)
target_compile_options(${_TARGET_} ${_SCOPE_} "-std=c++0x")
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
if (CXX11_COMPILES)
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features" FORCE)
else ()
check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX11_COMPILES)
check_include_file_cxx("array" CXX11_INCLUDES)
if (CXX11_COMPILES AND CXX11_INCLUDES)
set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
else ()
set(${RESULT_VAR} false CACHE BOOL "Enable C++11 compiler features")
endif ()
set(${RESULT_VAR} false CACHE BOOL "Enable C++11 compiler features" FORCE)
endif ()
endif ()
endmacro(target_enable_cxx11)
......@@ -47,7 +47,7 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features
// --------------
#ifdef HAS_CXX11
#if HAS_CXX11
// __has_feature(cxx_rvalue_references)
#if CLANG_VERSION >= 20900 && !defined(HAS_VARIADIC_TEMPLATES)
......
......@@ -47,7 +47,7 @@ typedef size_t aligned_size_t __attribute__ ((aligned(CACHE_LINE)));
// C++11 features
// --------------
#ifdef HAS_CXX11
#if HAS_CXX11
#if GCC_VERSION >= 40300 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
......
......@@ -51,7 +51,7 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
// C++11 features
// --------------
#ifdef HAS_CXX11
#if HAS_CXX11
#if INTEL_VERSION >= 1201 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1
......
......@@ -35,7 +35,7 @@
#include <boost/utility/enable_if.hpp>
#endif
#ifdef HAS_CXX11
#if HAS_CXX11
#include <type_traits>
#endif
......@@ -45,7 +45,7 @@ namespace AMDiS
// introduce some shortcuts for boost::mpl
// ---------------------------------------
#ifdef HAS_CXX11
#if HAS_CXX11
template <bool B>
using bool_ = std::integral_constant<bool, B>;
......
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