Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

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

several corrections in the cmake files, e.g. test_compile_features and blas-lapack

parent b8063b9f
...@@ -2,12 +2,9 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0) ...@@ -2,12 +2,9 @@ set(CMAKE_LEGACY_CYGWIN_WIN32 0)
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(AMDiS) project(AMDiS)
if (USE_NEW_CMAKE AND ${CMAKE_VERSION} VERSION_GREATER "3.2") if (${CMAKE_VERSION} VERSION_GREATER "3.2")
# Experimental implementation of new CMakeLists.txt
# Can be selected by calling cmake -DUSE_NEW_CMAKE=ON .
# Use only if you know what you are doing :-)
include(${AMDiS_SOURCE_DIR}/cmake3/CMakeLists.txt) include(${AMDiS_SOURCE_DIR}/cmake3/CMakeLists.txt)
else () else ()
# By defualt the classical CMakeLists file ist used # Fallback to classical CMakeLists file
include(${AMDiS_SOURCE_DIR}/cmake/CMakeLists.txt) include(${AMDiS_SOURCE_DIR}/cmake/CMakeLists.txt)
endif () endif ()
#thats bad because it affects each target # globally add compile options and include directories
add_definitions(${AMDIS_COMPILEFLAGS}) add_definitions(${AMDIS_COMPILEFLAGS})
include_directories(${AMDIS_INCLUDE_DIRS}) include_directories(${AMDIS_INCLUDE_DIRS})
...@@ -30,12 +30,12 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ...@@ -30,12 +30,12 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS
# #message("svn-rev: ${svn_info_WC_REVISION}") # #message("svn-rev: ${svn_info_WC_REVISION}")
# set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}") # set(AMDIS_SUB_MINOR "${svn_info_WC_REVISION}")
# endif() # endif()
set(CurrentRevision "0.9") set(CurrentRevision "1.1")
if(NOT AMDIS_MAJOR) if(NOT AMDIS_MAJOR)
set(AMDIS_MAJOR "0") set(AMDIS_MAJOR "1")
endif() endif()
if(NOT AMDIS_MINOR) if(NOT AMDIS_MINOR)
set(AMDIS_MINOR "9") set(AMDIS_MINOR "1")
endif() endif()
list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}") list(APPEND COMPILEFLAGS "-DAMDIS_VERSION=${CurrentRevision}")
......
# enable the c++11 features. From cmake version 3.0 this is simply done by setting include(CheckCXXCompilerFlag)
# the cxx_standard variables. For older cmake version the compile-flags must be added manually. include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
if (ENABLE_CXX11) if (ENABLE_CXX11)
list(APPEND COMPILEFLAGS "-DHAS_CXX11=1") check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
if (${CMAKE_VERSION} VERSION_GREATER "3.0")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") # cmake can not detect intel compile features
set(REQUIRED_CXX_FEATURES "cxx_alias_templates" "cxx_auto_type" "cxx_lambdas" "cxx_override" "cxx_range_for" "cxx_static_assert" "cxx_variadic_templates")
add_library(test_compiler_features cmake/dummy.cc) if (NOT COMPILER_SUPPORTS_CXX11)
foreach(feature ${REQUIRED_CXX_FEATURES}) set(CMAKE_REQUIRED_FLAGS "-std=c++11")
target_compile_features(test_compiler_features PUBLIC ${feature}) check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX11)
endforeach(feature) set(CMAKE_REQUIRED_FLAGS "")
endif () endif ()
else()
if (CMAKE_COMPILER_IS_GNUCXX) if (COMPILER_SUPPORTS_CXX11 OR CXX_COMPILES_WITH_CXX11)
set(GXX_MIN_VER "4.8") add_definitions("-std=c++11")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS GXX_MIN_VER) else ()
message (FATAL_ERROR "For C++11-Features the G++ Compiler must be at least version $GXX_MIN_VER") check_cxx_compiler_flag("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
endif () if (NOT COMPILER_SUPPORTS_CXX0X)
list(APPEND COMPILEFLAGS "-std=gnu++11") set(CMAKE_REQUIRED_FLAGS "-std=c++0x")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX0X)
set(CLANG_MIN_VER "3.0") set(CMAKE_REQUIRED_FLAGS "")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS CLANG_MIN_VER)
message (FATAL_ERROR "For C++11-Features the Clang Compiler must be at least version $CLANG_MIN_VER")
endif () endif ()
list(APPEND COMPILEFLAGS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel") if (COMPILER_SUPPORTS_CXX0X OR CXX_COMPILES_WITH_CXX0X)
set(INTEL_MIN_VER "12.1") add_definitions("-std=c++0x")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS INTEL_MIN_VER) else ()
message (FATAL_ERROR "For C++11-Features the Intel C++ Compiler must be at least version $INTEL_MIN_VER") 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 ()
message (FATAL_ERROR "Compiler does not support C++11.")
endif () endif ()
list(APPEND COMPILEFLAGS "-std=c++11")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(MSVC_MIN_VER "12.0")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS MSVC_MIN_VER)
message (FATAL_ERROR "For C++11-Features the MSVC C++ Compiler must be at least version $MSVC_MIN_VER")
endif () endif ()
endif () endif ()
endif()
list(APPEND COMPILEFLAGS "-DHAS_CXX11=1")
else () else ()
list(APPEND COMPILEFLAGS "-DHAS_CXX11=0") list(APPEND COMPILEFLAGS "-DHAS_CXX11=0")
endif (ENABLE_CXX11) endif (ENABLE_CXX11)
...@@ -103,21 +103,39 @@ if (AMDIS_HAS_PARALLEL_DOMAIN) ...@@ -103,21 +103,39 @@ if (AMDIS_HAS_PARALLEL_DOMAIN)
HAVE_PARALLEL_DOMAIN_AMDIS=1) HAVE_PARALLEL_DOMAIN_AMDIS=1)
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
if (MPI_FOUND) target_include_directories(amdis_base INTERFACE ${MPI_CXX_INCLUDE_PATH})
target_include_directories(amdis_base INTERFACE ${MPI_INCLUDE_PATH}) target_compile_options(amdis_base INTERFACE ${MPI_CXX_COMPILE_FLAGS})
target_compile_options(amdis_base INTERFACE ${MPI_COMPILE_FLAGS}) string(STRIP " ${MPI_CXX_LINK_FLAGS} " MPI_CXX_LINK_FLAGS_)
target_link_libraries(amdis_base INTERFACE ${MPI_LIBRARIES}) target_link_libraries(amdis_base INTERFACE ${MPI_CXX_LINK_FLAGS_} ${MPI_CXX_LIBRARIES})
endif (MPI_FOUND)
set(PETSC_EXECUTABLE_RUNS ON) set(PETSC_EXECUTABLE_RUNS ON)
set(AMDIS_PETSC_DIR @PETSC_DIR@) set(AMDIS_PETSC_DIR @PETSC_DIR@)
include(find_petsc) include(find_petsc)
if (PETSc_FOUND) if (PETSc_FOUND)
target_include_directories(amdis_base INTERFACE ${PETSC_INCLUDES}) target_include_directories(amdis_base INTERFACE ${PETSC_INCLUDES})
find_library(BLAS_LIB
NAMES blas fblas openblas
HINTS ${BLAS_DIR}/lib ${PETSC_LIB_DIR} ${PETSC_DIR}/lib /usr/lib/openblas-base /usr/lib/atlas-base)
if (BLAS_LIB)
set(BLAS_LIBRARIES ${BLAS_LIB})
else ()
find_package(BLAS REQUIRED)
endif ()
find_library(LAPACK_LIB
NAMES lapack flapack
HINTS ${LAPACK_DIR}/lib ${PETSC_LIB_DIR} ${PETSC_DIR}/lib)
if (LAPACK_LIB)
set(LAPACK_LIBRARIES ${LAPACK_LIB})
else ()
find_package(LAPACK REQUIRED)
endif ()
target_link_libraries(amdis_base INTERFACE target_link_libraries(amdis_base INTERFACE
${PETSC_LIBRARY_SYS} ${PETSC_LIBRARY_SYS}
${PETSC_LIBRARIES} ${PETSC_LIBRARIES}
blas lapack) ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
target_compile_definitions(amdis_base INTERFACE target_compile_definitions(amdis_base INTERFACE
HAVE_PARALLEL_PETSC=1) HAVE_PARALLEL_PETSC=1)
else() else()
...@@ -198,4 +216,12 @@ if (AMDIS_NEED_ZOLTAN) ...@@ -198,4 +216,12 @@ if (AMDIS_NEED_ZOLTAN)
endif() endif()
endif () endif ()
set(AMDIS_LIBRARIES AMDiS) # Extract some variables from INTERFACE target AMDiS
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)
get_target_property(_DEFINITIONS AMDiS INTERFACE_COMPILE_DEFINITIONS)
foreach(defn ${_DEFINITIONS})
list(APPEND AMDIS_COMPILEFLAGS "-D${defn}")
endforeach(s)
message(STATUS "To compile your program with AMDiS simply add the target 'AMDiS' to the target_link_libraries(...) command") # globally add compile options and include directories
\ No newline at end of file add_definitions(${AMDIS_COMPILEFLAGS})
include_directories(${AMDIS_INCLUDE_DIRS})
cmake_minimum_required(VERSION 3.2 FATAL_ERROR) cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
project(AMDiS VERSION 0.9 LANGUAGES CXX) project(AMDiS VERSION 1.1 LANGUAGES CXX)
message(WARNING "This is an experimental CMakeLists.txt file.")
set(BASE_DIR ${AMDiS_SOURCE_DIR}) set(BASE_DIR ${AMDiS_SOURCE_DIR})
set(SOURCE_DIR ${BASE_DIR}/src) set(SOURCE_DIR ${BASE_DIR}/src)
...@@ -32,14 +30,9 @@ option(BUILD_SHARED_LIBS "Build all libraries as shared or static, default: shar ...@@ -32,14 +30,9 @@ option(BUILD_SHARED_LIBS "Build all libraries as shared or static, default: shar
mark_as_advanced(BUILD_SHARED_LIBS) mark_as_advanced(BUILD_SHARED_LIBS)
if (MSVC) if (MSVC)
# if (${CMAKE_VERSION} VERSION_LESS "3.4")
set(BUILD_SHARED_LIBS false) set(BUILD_SHARED_LIBS false)
mark_as_advanced(BUILD_SHARED_LIBS) mark_as_advanced(BUILD_SHARED_LIBS)
message(WARNING "Currently we can only build static libraries with Visual Studio") message(WARNING "Currently we can only build static libraries with Visual Studio")
# elseif (BUILD_SHARED_LIBS)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true)
# set(MSVC_SHARED_LIBS true)
# endif ()
endif (MSVC) endif (MSVC)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
...@@ -54,17 +47,9 @@ target_compile_definitions(amdis_base INTERFACE ...@@ -54,17 +47,9 @@ target_compile_definitions(amdis_base INTERFACE
$<$<NOT:$<CONFIG:Release>>:DEBUG=1>) $<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
include(test_compile_features) include(test_compile_features)
test_compile_features(ENABLE_CXX11 amdis_base INTERFACE target_enable_cxx11(ENABLE_CXX11 amdis_base INTERFACE)
cxx_alias_templates
cxx_auto_type
cxx_lambdas
cxx_override
cxx_range_for
cxx_static_assert
cxx_variadic_templates)
if (ENABLE_CXX11) if (ENABLE_CXX11)
# set(CMAKE_CXX_STANDARD 11)
# set(CMAKE_CXX_STANDARD_REQUIRED ON)
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1) target_compile_definitions(amdis_base INTERFACE HAS_CXX11=1)
else () else ()
target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0) target_compile_definitions(amdis_base INTERFACE HAS_CXX11=0)
...@@ -245,7 +230,7 @@ if (MSVC) ...@@ -245,7 +230,7 @@ if (MSVC)
endif (MSVC) endif (MSVC)
target_link_libraries(amdis AMDiS::base muparser target_link_libraries(amdis AMDiS::base muparser
$<$<CONFIG:Debug>:amdis_debug>) $<$<NOT:$<CONFIG:Release>>:amdis_debug>)
# specify how to install this target: # specify how to install this target:
# ----------------------------------- # -----------------------------------
...@@ -271,4 +256,3 @@ configure_file(${BASE_DIR}/cmake3/AMDISConfig.cmake.in ...@@ -271,4 +256,3 @@ configure_file(${BASE_DIR}/cmake3/AMDISConfig.cmake.in
install(FILES ${AMDiS_BINARY_DIR}/AMDISConfig.cmake DESTINATION share/amdis/) install(FILES ${AMDiS_BINARY_DIR}/AMDISConfig.cmake DESTINATION share/amdis/)
install(FILES ${BASE_DIR}/cmake3/AMDISUse.cmake DESTINATION share/amdis/) install(FILES ${BASE_DIR}/cmake3/AMDISUse.cmake DESTINATION share/amdis/)
install(FILES ${BASE_DIR}/cmake3/test_compile_features.cmake DESTINATION share/amdis/) install(FILES ${BASE_DIR}/cmake3/test_compile_features.cmake DESTINATION share/amdis/)
install(FILES ${BASE_DIR}/cmake3/dummy.cc DESTINATION share/amdis/)
...@@ -31,12 +31,13 @@ if (ENABLE_PARALLEL_DOMAIN) ...@@ -31,12 +31,13 @@ if (ENABLE_PARALLEL_DOMAIN)
# MPI is required # MPI is required
find_package(MPI REQUIRED) find_package(MPI REQUIRED)
if (MPI_FOUND)
target_include_directories(amdis_parallel INTERFACE target_include_directories(amdis_parallel INTERFACE
${MPI_INCLUDE_PATH}) ${MPI_CXX_INCLUDE_PATH})
target_compile_options(amdis_parallel INTERFACE target_compile_options(amdis_parallel INTERFACE
${MPI_COMPILE_FLAGS}) ${MPI_CXX_COMPILE_FLAGS})
endif (MPI_FOUND) string(STRIP " ${MPI_CXX_LINK_FLAGS} " MPI_CXX_LINK_FLAGS_)
target_link_libraries(amdis_parallel INTERFACE
${MPI_CXX_LINK_FLAGS_} ${MPI_CXX_LIBRARIES})
# PETSc library is required # PETSc library is required
set(PETSC_EXECUTABLE_RUNS ON) set(PETSC_EXECUTABLE_RUNS ON)
...@@ -47,7 +48,7 @@ if (ENABLE_PARALLEL_DOMAIN) ...@@ -47,7 +48,7 @@ if (ENABLE_PARALLEL_DOMAIN)
${PETSC_DIR}/${PETSC_ARCH}/include) ${PETSC_DIR}/${PETSC_ARCH}/include)
# parmetis is required # parmetis is required
find_file(PARMETIS_HEADER_FILE "parmetis.h" HINTS ${PETSC_DIR}/include ) find_file(PARMETIS_HEADER_FILE "parmetis.h" HINTS ${PETSC_DIR}/include ${PARMETIS_DIR}/include )
if (PARMETIS_HEADER_FILE) if (PARMETIS_HEADER_FILE)
get_filename_component(PARMETIS_INCLUDE_PATH "${PARMETIS_HEADER_FILE}" PATH CACHE) get_filename_component(PARMETIS_INCLUDE_PATH "${PARMETIS_HEADER_FILE}" PATH CACHE)
target_include_directories(amdis_parallel INTERFACE ${PARMETIS_INCLUDE_PATH}) target_include_directories(amdis_parallel INTERFACE ${PARMETIS_INCLUDE_PATH})
...@@ -57,10 +58,10 @@ if (ENABLE_PARALLEL_DOMAIN) ...@@ -57,10 +58,10 @@ if (ENABLE_PARALLEL_DOMAIN)
# add support for the zoltan library # add support for the zoltan library
if (ENABLE_ZOLTAN) if (ENABLE_ZOLTAN)
find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${PETSC_DIR}/include) find_file(ZOLTAN_HEADER_FILE "zoltan_cpp.h" HINTS ${ZOLTAN_DIR}/include ${PETSC_DIR}/include)
if (ZOLTAN_HEADER_FILE) if (ZOLTAN_HEADER_FILE)
get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE) get_filename_component(ZOLTAN_HEADER_DIR "${ZOLTAN_HEADER_FILE}" PATH CACHE)
target_include_directories(amdis_parallel PRIINTERFACEVATE ${ZOLTAN_HEADER_DIR}) target_include_directories(amdis_parallel INTERFACE ${ZOLTAN_HEADER_DIR})
else() else()
message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!") message(FATAL_ERROR "Could not find Zoltan include file 'zoltan_cpp.h'!")
endif(ZOLTAN_HEADER_FILE) endif(ZOLTAN_HEADER_FILE)
......
...@@ -7,17 +7,9 @@ else () ...@@ -7,17 +7,9 @@ else ()
endif (IS_AMDISCONFIG) endif (IS_AMDISCONFIG)
include(test_compile_features) include(test_compile_features)
test_compile_features(MTL_ENABLE_CXX11 mtl4 INTERFACE target_enable_cxx11(MTL_ENABLE_CXX11 mtl4 INTERFACE)
cxx_rvalue_references
cxx_auto_type
cxx_range_for
cxx_generalized_initializers
cxx_static_assert
cxx_defaulted_functions)
if (MTL_ENABLE_CXX11) 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") set (CXX_ELEVEN_FEATURE_LIST "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL")
foreach (feature ${CXX_ELEVEN_FEATURE_LIST}) foreach (feature ${CXX_ELEVEN_FEATURE_LIST})
target_compile_definitions(mtl4 INTERFACE MTL_WITH_${feature}) target_compile_definitions(mtl4 INTERFACE MTL_WITH_${feature})
......
...@@ -47,7 +47,7 @@ if (PETSC_DIR) ...@@ -47,7 +47,7 @@ if (PETSC_DIR)
endif (PETSC_DIR) endif (PETSC_DIR)
find_path (PETSC_DIR include/petsc.h find_path (PETSC_DIR include/petsc.h
HINTS ${AMDIS_PETSC_DIR} $ENV{HOME}/petsc ENV PETSC_DIR HINTS ${AMDIS_PETSC_DIR} $ENV{HOME}/petsc /usr/lib/petsc ENV PETSC_DIR
DOC "PETSc Directory") DOC "PETSc Directory")
if (PETSC_DIR AND NOT PETSC_ARCH) if (PETSC_DIR AND NOT PETSC_ARCH)
......
...@@ -87,5 +87,7 @@ if (ENABLE_UMFPACK OR AMDIS_NEED_UMFPACK) ...@@ -87,5 +87,7 @@ if (ENABLE_UMFPACK OR AMDIS_NEED_UMFPACK)
HAVE_UMFPACK=1 HAVE_UMFPACK=1
MTL_HAS_UMFPACK=1) MTL_HAS_UMFPACK=1)
if (NOT IS_AMDISCONFIG)
install(FILES ${BASE_DIR}/cmake3/find_umfpack.cmake DESTINATION share/amdis/) install(FILES ${BASE_DIR}/cmake3/find_umfpack.cmake DESTINATION share/amdis/)
endif ()
endif (ENABLE_UMFPACK OR AMDIS_NEED_UMFPACK) endif (ENABLE_UMFPACK OR AMDIS_NEED_UMFPACK)
\ No newline at end of file
...@@ -17,8 +17,7 @@ add_library(muparser ...@@ -17,8 +17,7 @@ add_library(muparser
target_include_directories(muparser PUBLIC ${MUPARSER_INCLUDE_DIR}) target_include_directories(muparser PUBLIC ${MUPARSER_INCLUDE_DIR})
if (ENABLE_CXX11) if (ENABLE_CXX11)
set_property(TARGET muparser PROPERTY CXX_STANDARD 11) target_enable_cxx11(MUPARSER_ENABLE_CXX11 muparser PRIVATE)
set_property(TARGET muparser PROPERTY CXX_STANDARD_REQUIRED ON)
target_compile_definitions(muparser PRIVATE HAS_CXX11=1) target_compile_definitions(muparser PRIVATE HAS_CXX11=1)
endif (ENABLE_CXX11) endif (ENABLE_CXX11)
......
include(CheckCXXCompilerFlag)
include(CheckCXXSourceCompiles)
include(CheckIncludeFileCXX)
macro(test_compile_features RESULT_VAR TARGET SCOPE) # feature1 feature2 feature3 ...) macro(target_enable_cxx11 RESULT_VAR _TARGET_ _SCOPE_)
set(_FEATURES "") check_cxx_compiler_flag("-std=c++11" COMPILER_SUPPORTS_CXX11)
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 if (NOT COMPILER_SUPPORTS_CXX11)
# previous call to this macro set(CMAKE_REQUIRED_FLAGS "-std=c++11")
if (NOT DEFINED ${RESULT_VAR}) check_cxx_source_compiles("int main(){decltype(1) vec[]={1,2,3}; for(auto&& x:vec);}" CXX_COMPILES_WITH_CXX11)
if (EXISTS "${BASE_DIR}/cmake3/dummy.cc") set(CMAKE_REQUIRED_FLAGS "")
set(DUMMY_FILE ${BASE_DIR}/cmake3/dummy.cc)
else ()
set(DUMMY_FILE ${AMDIS_DIR}/dummy.cc)
endif () endif ()
message(STATUS "Test for cxx11 features for target ${TARGET}") if (COMPILER_SUPPORTS_CXX11 OR CXX_COMPILES_WITH_CXX11)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_DIR}) target_compile_options(${_TARGET_} ${_SCOPE_} "-std=c++11")
file(WRITE ${_DIR}/CMakeLists.txt " set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
project(TestCxx LANGUAGES CXX)
add_library(test_cxx ${DUMMY_FILE})
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 () else ()
set(_ERR_CODE "1") 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 () endif ()
if ("${_ERR_CODE}" STREQUAL "0") 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")
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") set(${RESULT_VAR} true CACHE BOOL "Enable C++11 compiler features")
target_compile_features(${TARGET} ${SCOPE} ${ARGN})
else () else ()
set(${RESULT_VAR} false CACHE BOOL "Enable C++11 compiler features") set(${RESULT_VAR} false CACHE BOOL "Enable C++11 compiler features")
endif () endif ()
mark_as_advanced(${RESULT_VAR}) endif ()
endif ()
unset(_ERR_CODE) endmacro(target_enable_cxx11)
unset(_DIR)
unset(_FEATURES)
endmacro(test_compile_features)
\ No newline at end of file
...@@ -52,13 +52,6 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t; ...@@ -52,13 +52,6 @@ typedef __declspec(align(CACHE_LINE)) size_t aligned_size_t;
#define ALWAYS_INLINE __forceinline #define ALWAYS_INLINE __forceinline
#define OPENMODE std::ios::open_mode #define OPENMODE std::ios::open_mode
// C++11 features
// --------------
// #if __cplusplus > 199711L
// #ifndef HAS_CXX11
// #define HAS_CXX11 1
// #endif
#if MSC_VERSION >= 1800 && !defined(HAS_VARIADIC_TEMPLATES) #if MSC_VERSION >= 1800 && !defined(HAS_VARIADIC_TEMPLATES)
#define HAS_VARIADIC_TEMPLATES 1 #define HAS_VARIADIC_TEMPLATES 1
#endif #endif
......
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