Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
amdis
Commits
12da37b5
Commit
12da37b5
authored
Feb 24, 2016
by
Praetorius, Simon
Browse files
CMake with test_compile_feature macro
parent
f8aa34a9
Changes
8
Hide whitespace changes
Inline
Side-by-side
AMDiS/cmake/CMakeLists.txt
View file @
12da37b5
...
...
@@ -11,6 +11,11 @@ endif()
SET
(
LIB_DIR
${
AMDIS_SOURCE_DIR
}
/lib
)
SET
(
SOURCE_DIR
${
AMDIS_SOURCE_DIR
}
/src
)
#define the build type, empty can be everything and nothing
if
(
CMAKE_BUILD_TYPE STREQUAL
""
)
set
(
CMAKE_BUILD_TYPE
"Release"
)
endif
()
#TODO: use the cmake build type
SET
(
MTL_INCLUDE_DIR
${
LIB_DIR
}
/mtl4/ CACHE PATH
"mtl4 directory"
)
...
...
@@ -34,10 +39,6 @@ if(NOT AMDIS_MINOR)
endif
()
list
(
APPEND COMPILEFLAGS
"-DAMDIS_VERSION=
${
CurrentRevision
}
"
)
#define the build type, empty can be everything and nothing
if
(
CMAKE_BUILD_TYPE STREQUAL
""
)
set
(
CMAKE_BUILD_TYPE
"Release"
)
endif
()
if
(
CMAKE_CXX_COMPILER MATCHES
".*icpc"
)
Message
(
"Compiler: Intel"
)
...
...
AMDiS/cmake3/AMDISConfig.cmake.in
View file @
12da37b5
...
...
@@ -34,6 +34,7 @@ set(AMDIS_NEED_REINIT @ENABLE_REINIT@)
set(AMDIS_NEED_COMPOSITE_FEM @ENABLE_COMPOSITE_FEM@)
set(BUILD_SHARED_LIBS @BUILD_SHARED_LIBS@)
set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@)
add_library(amdis_base INTERFACE)
add_library(AMDiS ALIAS amdis_base)
...
...
@@ -43,17 +44,11 @@ target_compile_definitions(amdis_base INTERFACE
$<$<NOT:$<CONFIG:Release>>:DEBUG=1>)
if (AMDIS_NEED_CXX11)
target_compile_features(amdis_base INTERFACE
cxx_alias_templates
cxx_auto_type
cxx_lambdas
cxx_override
cxx_range_for
cxx_static_assert
cxx_variadic_templates)
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 (AMDIS_NEED_CXX11)
...
...
@@ -171,7 +166,7 @@ endif (AMDIS_NEED_REINIT)
if (AMDIS_NEED_COMPOSITE_FEM)
find_library(_COMPOSITE_FEM_LIB amdis_compositeFEM PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_COMPOSITE_FEM_LIB)
target_include_directories(amdis_base INTERFACE ${
Boost
_INCLUDE_DIR}/compositeFEM)
target_include_directories(amdis_base INTERFACE ${
AMDIS
_INCLUDE_DIR}/compositeFEM)
target_link_libraries(amdis_base INTERFACE ${_COMPOSITE_FEM_LIB})
else ()
message(ERROR "CompositeFEM library not found")
...
...
@@ -184,7 +179,7 @@ endif (AMDIS_NEED_COMPOSITE_FEM)
# --------------------
find_library(_MUPARSER_LIB muparser PATHS ${AMDIS_DIR}/../../lib/amdis/)
if (_MUPARSER_LIB)
target_include_directories(amdis_base INTERFACE ${
Boost
_INCLUDE_DIR}/muparser)
target_include_directories(amdis_base INTERFACE ${
AMDIS
_INCLUDE_DIR}/muparser)
target_link_libraries(amdis_base INTERFACE ${_MUPARSER_LIB})
else ()
message(ERROR "MuParser library not found")
...
...
AMDiS/cmake3/CMakeLists.txt
View file @
12da37b5
...
...
@@ -7,30 +7,44 @@ set(BASE_DIR ${AMDiS_SOURCE_DIR})
set
(
SOURCE_DIR
${
BASE_DIR
}
/src
)
list
(
APPEND CMAKE_MODULE_PATH
${
BASE_DIR
}
/cmake3
)
option
(
ENABLE_CXX11
"Enable C++11 compiler features"
false
)
if
(
NOT CMAKE_BUILD_TYPE
)
set
(
CMAKE_BUILD_TYPE
"Release"
CACHE STRING
""
)
endif
()
# ------------------------------------------------------------------------------
#some options to control the build process
option
(
ENABLE_PARALLEL_DOMAIN
"Use parallel domain decomposition"
false
)
option
(
ENABLE_UMFPACK
"Enable support for the UMFPACK solver"
false
)
option
(
ENABLE_COMPRESSION
"Use output compression for vtu and arh files"
false
)
option
(
ENABLE_UMFPACK
"Enable support for the UMFPACK solver"
true
)
option
(
ENABLE_EXTENSIONS
"Use extensions for AMDiS"
false
)
# enable/disable some more features
option
(
ENABLE_COMPRESSION
"Use output compression for vtu and arh files"
true
)
mark_as_advanced
(
ENABLE_COMPRESSION
)
option
(
ENABLE_REINIT
"Compile reinit library"
true
)
mark_as_advanced
(
ENABLE_REINIT
)
option
(
ENABLE_COMPOSITE_FEM
"Compile compositeFEM library"
true
)
mark_as_advanced
(
ENABLE_COMPOSITE_FEM
)
option
(
BUILD_SHARED_LIBS
"Build all libraries as shared or static, default: shared"
ON
)
option
(
BUILD_SHARED_LIBS
"Build all libraries as shared or static, default: shared"
true
)
mark_as_advanced
(
BUILD_SHARED_LIBS
)
if
(
MSVC
)
# if (${CMAKE_VERSION} VERSION_LESS "3.4")
set
(
BUILD_SHARED_LIBS
OFF
)
set
(
BUILD_SHARED_LIBS
false
)
mark_as_advanced
(
BUILD_SHARED_LIBS
)
message
(
WARNING
"Currently we can only build static libraries wi
h
t Visual Studio"
)
message
(
WARNING
"Currently we can only build static libraries wit
h
Visual Studio"
)
# elseif (BUILD_SHARED_LIBS)
# set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS true)
# set(MSVC_SHARED_LIBS true)
# endif ()
endif
(
MSVC
)
# ------------------------------------------------------------------------------
# define an interface-library for flags and compile-definitions
add_library
(
amdis_base INTERFACE
)
add_library
(
AMDiS::base ALIAS amdis_base
)
...
...
@@ -38,16 +52,17 @@ target_include_directories(amdis_base INTERFACE ${SOURCE_DIR})
target_compile_definitions
(
amdis_base INTERFACE
$<$<CONFIG:Release>:DEBUG=0>
$<$<NOT:$<CONFIG:Release>>:DEBUG=1>
)
include
(
test_compile_features
)
test_compile_features
(
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
)
target_compile_features
(
amdis_base INTERFACE
cxx_alias_templates
cxx_auto_type
cxx_lambdas
cxx_override
cxx_range_for
cxx_static_assert
cxx_variadic_templates
)
target_compile_definitions
(
amdis_base INTERFACE HAS_CXX11=1
)
else
()
target_compile_definitions
(
amdis_base INTERFACE HAS_CXX11=0
)
...
...
@@ -58,6 +73,8 @@ endif (ENABLE_CXX11)
include
(
find_mtl4
)
# -> target mtl4
install
(
FILES
${
BASE_DIR
}
/cmake3/find_mtl4.cmake DESTINATION share/amdis/
)
include
(
find_umfpack
)
include
(
find_boost
)
# -> target boost
install
(
FILES
${
BASE_DIR
}
/cmake3/find_boost.cmake DESTINATION share/amdis/
)
...
...
@@ -186,7 +203,7 @@ add_library(amdis
${
SOURCE_DIR
}
/time/RosenbrockMethod.cc
${
SOURCE_DIR
}
/time/RosenbrockStationary.cc
)
add_library
(
amdis_debug INTERFACE
)
target_sources
(
amdis_debug INTERFACE
${
SOURCE_DIR
}
/Debug.cc
...
...
@@ -194,7 +211,13 @@ target_sources(amdis_debug INTERFACE
${
SOURCE_DIR
}
/GlobalElementNumbering.cc
# not used by any other class
${
SOURCE_DIR
}
/ProblemStatDbg.cc
)
include
(
amdis_parallel
)
# adds sources to amdis
include
(
amdis_extensions
)
# -> target AMDiS::extensions
include
(
muparser
)
# -> target muparser
# ------------------------------------------------------------------------------
if
(
ENABLE_COMPRESSION
)
target_compile_definitions
(
amdis PRIVATE HAVE_COMPRESSION=1
)
endif
(
ENABLE_COMPRESSION
)
...
...
@@ -202,8 +225,6 @@ endif (ENABLE_COMPRESSION)
if
(
ENABLE_UMFPACK
)
target_compile_definitions
(
amdis PRIVATE HAVE_UMFPACK=1
)
endif
(
ENABLE_UMFPACK
)
include
(
amdis_parallel
)
# adds sources to amdis
if
(
ENABLE_REINIT
)
include
(
amdis_reinit
)
# -> target AMDiS::reinit
...
...
@@ -213,17 +234,15 @@ if (ENABLE_COMPOSITE_FEM)
include
(
amdis_compositeFEM
)
# -> target AMDiS::compositeFEM
endif
(
ENABLE_COMPOSITE_FEM
)
include
(
amdis_extensions
)
# -> target AMDiS::extensions
include
(
muparser
)
# -> target muparser
# ------------------------------------------------------------------------------
if
(
MSVC
)
target_compile_definitions
(
amdis PRIVATE
_SCL_SECURE_NO_WARNINGS
target_compile_definitions
(
amdis PRIVATE
_SCL_SECURE_NO_WARNINGS
_CRT_SECURE_NO_WARNINGS
)
endif
(
MSVC
)
target_link_libraries
(
amdis AMDiS::base muparser
target_link_libraries
(
amdis AMDiS::base muparser
$<$<CONFIG:Debug>:amdis_debug>
)
# specify how to install this target:
...
...
AMDiS/cmake3/amdis_extensions.cmake
View file @
12da37b5
if
(
ENABLE_EXTENSIONS
)
option
(
ENABLE_BASE_PROBLEMS
"Use base_problems"
true
)
mark_as_advanced
(
ENABLE_BASE_PROBLEMS
)
find_path
(
EXTENSIONS_DIR NAMES Helpers.h
HINTS
${
BASE_DIR
}
/../extensions
...
...
AMDiS/cmake3/dummy.cc
0 → 100644
View file @
12da37b5
AMDiS/cmake3/find_mtl4.cmake
View file @
12da37b5
...
...
@@ -6,20 +6,21 @@ else ()
target_include_directories
(
mtl4 INTERFACE
${
BASE_DIR
}
/lib/mtl4
)
endif
(
IS_AMDISCONFIG
)
if
(
ENABLE_CXX11
)
target_compile_features
(
mtl4 INTERFACE
cxx_rvalue_references
cxx_auto_type
cxx_range_for
cxx_generalized_initializers
cxx_static_assert
cxx_defaulted_functions
)
include
(
test_compile_features
)
test_compile_features
(
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
)
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
}
)
endforeach
()
endif
(
ENABLE_CXX11
)
endif
(
MTL_
ENABLE_CXX11
)
if
(
ENABLE_OPENMP
)
...
...
@@ -34,8 +35,6 @@ endif (ENABLE_OPENMP)
if
(
NOT IS_AMDISCONFIG
)
include
(
find_umfpack
)
# specify how to install this target:
# -----------------------------------
install
(
DIRECTORY
${
BASE_DIR
}
/lib/mtl4/
...
...
AMDiS/cmake3/find_umfpack.cmake
View file @
12da37b5
...
...
@@ -10,6 +10,7 @@ if (ENABLE_UMFPACK OR AMDIS_NEED_UMFPACK)
# try to use a cmake-package of suitesparse
find_package
(
SuiteSparse QUIET HINTS
${
AMDIS_SuiteSparse_DIR
}
)
if
(
SuiteSparse_FOUND
)
message
(
STATUS
"Found SuiteSparse CMake-library"
)
include
(
${
USE_SuiteSparse
}
)
target_link_libraries
(
amdis_base INTERFACE
${
SuiteSparse_LIBRARIES
}
)
target_include_directories
(
amdis_base INTERFACE
${
SuiteSparse_INCLUDE_DIR
}
${
SuiteSparse_METIS_INCLUDE_DIR
}
)
...
...
AMDiS/cmake3/test_compile_features.cmake
0 → 100644
View file @
12da37b5
macro
(
test_compile_features RESULT_VAR TARGET SCOPE
)
# feature1 feature2 feature3 ...)
set
(
_FEATURES
""
)
foreach
(
FEATURE
${
ARGN
}
)
set
(
_FEATURES
"
${
_FEATURES
}
${
FEATURE
}
"
)
endforeach
()
# 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
${
BASE_DIR
}
/cmake3/tmp
)
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"
)
set
(
${
RESULT_VAR
}
true CACHE BOOL
"Enable C++11 compiler features"
)
target_compile_features
(
${
TARGET
}
${
SCOPE
}
${
ARGN
}
)
else
()
set
(
${
RESULT_VAR
}
false CACHE BOOL
"Enable C++11 compiler features"
)
endif
()
mark_as_advanced
(
${
RESULT_VAR
}
)
unset
(
_RES_VAR
)
unset
(
_DIR
)
unset
(
_FEATURES
)
endmacro
(
test_compile_features
)
\ No newline at end of file
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment