Commit 37f7406f authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

new cmake system continued

parent f4e5a9f1
......@@ -96,6 +96,9 @@ endif ()
add_subdirectory(cmake)
add_subdirectory(lib)
add_subdirectory(src)
if (ENABLE_EXTENSIONS)
add_subdirectory(../extensions extensions)
endif (ENABLE_EXTENSIONS)
if(TARGET AMDiS::AMDiS)
feature_summary(WHAT ALL)
......
@PACKAGE_INIT@
get_filename_component(AMDiS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CMAKE_MODULE_PATH "${AMDiS_CMAKE_DIR}" ${CMAKE_MODULE_PATH})
include(CMakeFindDependencyMacro)
include(target_enable_boost)
set(CMAKE_MODULE_PATH "${AMDiS_CMAKE_DIR}" ${CMAKE_MODULE_PATH})
# global dependencies
find_dependency(MTL REQUIRED)
target_enable_boost()
find_dependency(MuParser REQUIRED)
if(NOT TARGET AMDiS::AMDiS)
include("${AMDiS_CMAKE_DIR}/AMDiSTargets.cmake")
if(AMDiS_FIND_REQUIRED_SEQUENTIAL AND NOT TARGET AMDiS::AMDiS-s)
find_dependency(UMFPACK REQUIRED)
include("${AMDiS_CMAKE_DIR}/AMDiSTargets-s.cmake")
set(AMDiS_SEQUENTIAL_FOUND TRUE)
elseif(AMDiS_FIND_REQUIRED_PARALLEL AND NOT TARGET AMDiS::AMDiS-p)
find_dependency(MPI)
find_dependency(PETSc)
include("${AMDiS_CMAKE_DIR}/AMDiSTargets-p.cmake")
set(AMDiS_PARALLEL_FOUND TRUE)
endif()
if (AMDiS_FIND_REQUIRED_SEQUENTIAL OR NOT AMDiS_FIND_REQUIRED_PARALLEL)
add_library(AMDiS INTERFACE)
target_link_libraries(AMDiS INTERFACE AMDiS::AMDiS-s)
elseif (AMDiS_FIND_REQUIRED_PARALLEL)
add_library(AMDiS INTERFACE)
target_link_libraries(AMDiS INTERFACE AMDiS::AMDiS-p)
endif ()
check_required_components(AMDiS)
......@@ -22,7 +22,7 @@ write_basic_package_version_file(
install(FILES
${PROJECT_CONFIG_VERSION_FILE}
${PROJECT_CONFIG_FILE}
FindMPI.cmake
#FindMPI.cmake
FindMTL.cmake
FindPETSc.cmake
FindUMFPACK.cmake
......
# FindMTL.cmake
#
# Finds the MPI library
#
# This will define the following variables
#
# MPI_FOUND
#
# and the following imported targets
#
# MPI::MPI
#
# Author: Simon Praetorius <simon.praetorius@tu-dresden.de>
mark_as_advanced(MTL_FOUND)
find_package(MPI QUIET)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MPI
REQUIRED_VARS MPI_CXX_INCLUDE_PATH MPI_CXX_LIBRARIES
)
if (MPI_FOUND AND NOT TARGET MPI::MPI)
add_library(MPI::MPI INTERFACE IMPORTED)
# the parameter --enable-new-dtags causes a linker problem, i.e. some libraries are
# linked without an rpath (or any other path information) and can not be found while
# running the executable. The hack below removes this flag manually from the linker flags.
string(REPLACE "-Wl,--enable-new-dtags" "" MY_MPI_CXX_LINK_FLAGS " ${MPI_CXX_LINK_FLAGS} ")
string(STRIP "${MY_MPI_CXX_LINK_FLAGS}" MY_MPI_CXX_LINK_FLAGS)
set_target_properties(MPI::MPI PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${MPI_CXX_INCLUDE_PATH}"
INTERFACE_COMPILE_OPTIONS "${MPI_CXX_COMPILE_FLAGS}"
INTERFACE_LINK_LIBRARIES "${MPI_CXX_LIBRARIES}"
INTERFACE_LINK_OPTIONS "${MY_MPI_CXX_LINK_FLAGS}"
)
endif()
\ No newline at end of file
......@@ -19,8 +19,8 @@ mark_as_advanced(MTL_FOUND MTL_COMPILE_DEFINITIONS MTL_INCLUDE_DIR)
find_path(MTL_INCLUDE_DIR boost/numeric/mtl/mtl.hpp
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/../lib/mtl4
${CMAKE_CURRENT_SOURCE_DIR}/../../include/mtl4
${CMAKE_CURRENT_LIST_DIR}/../lib/mtl4
${CMAKE_CURRENT_LIST_DIR}/../../../include/mtl4
ENV EBROOTMTL
PATHS
/opt/software/mtl4
......@@ -28,8 +28,6 @@ find_path(MTL_INCLUDE_DIR boost/numeric/mtl/mtl.hpp
/opt/development/mtl4
)
set(MTL_COMPILE_DEFINITIONS MTL_ASSERT_FOR_THROW=1)
foreach(feature "MOVE" "AUTO" "RANGEDFOR" "INITLIST" "STATICASSERT" "DEFAULTIMPL")
list(APPEND MTL_COMPILE_DEFINITIONS MTL_WITH_${feature})
......
......@@ -21,7 +21,9 @@ find_path(PETSC_PKG_CONFIG "PETSc.pc"
HINTS
${PETSC_DIR}
${PETSC_ROOT}
ENV PETSC_DIR PETSC_ROOT PKG_CONFIG_PATH
ENV PETSC_DIR
ENV PETSC_ROOT
ENV PKG_CONFIG_PATH
PATHS
/usr/lib/petsc
/usr/lib/petsc/linux-gnu-cxx-opt
......@@ -31,7 +33,11 @@ find_path(PETSC_PKG_CONFIG "PETSc.pc"
if (PETSC_PKG_CONFIG)
set(ENV{PKG_CONFIG_PATH} "${PETSC_PKG_CONFIG_PATH}:$ENV{PKG_CONFIG_PATH}")
pkg_check_modules(PETSC QUIET PETSc>=${PETSc_FIND_VERSION} IMPORTED_TARGET)
if (PETSc_FIND_VERSION)
pkg_check_modules(PETSC QUIET PETSc>=${PETSc_FIND_VERSION} IMPORTED_TARGET)
else ()
pkg_check_modules(PETSC QUIET PETSc IMPORTED_TARGET)
endif ()
if (PETSC_STATIC_FOUND)
set(PETSc_VERSION ${PETSC_STATIC_VERSION})
......@@ -41,7 +47,7 @@ if (PETSC_PKG_CONFIG)
if ((PETSC_STATIC_FOUND OR PETSC_FOUND) AND NOT TARGET PETSc::PETSc)
add_library(PETSc::PETSc INTERFACE IMPORTED)
target_link_libraries(PETSc::PETSc PkgConfig::PETSC)
target_link_libraries(PETSc::PETSc INTERFACE PkgConfig::PETSC)
endif()
endif (PETSC_PKG_CONFIG)
......
......@@ -21,7 +21,8 @@ find_library(UMFPACK_LIBRARY umfpack
HINTS
${AMDIS_UMFPACK_ROOT_DIR}
${SUITESPARSE_ROOT}
ENV SUITESPARSE_ROOT EBROOTSUITESPARSE
ENV SUITESPARSE_ROOT
ENV EBROOTSUITESPARSE
PATH_SUFFIXES lib/ lib64/
DOC "Library file for UMFPACK"
)
......@@ -30,7 +31,8 @@ find_file(UMFPACK_HEADER umfpack.h
HINTS
${AMDIS_UMFPACK_ROOT_DIR}
${SUITESPARSE_ROOT}
ENV SUITESPARSE_ROOT EBROOTSUITESPARSE
ENV SUITESPARSE_ROOT
ENV EBROOTSUITESPARSE
PATH_SUFFIXES include/ include/suitesparse/ include/ufsparse/
DOC "Headerfile umfpack.h for UMFPACK"
)
......
macro(target_enable_boost _TARGET_)
macro(target_enable_boost)
if (BOOST_ROOT)
file(TO_CMAKE_PATH ${BOOST_ROOT} BOOST_ROOT)
endif (BOOST_ROOT)
......@@ -20,7 +20,9 @@ macro(target_enable_boost _TARGET_)
endif (NOT BUILD_SHARED_LIBS)
find_package(Boost ${BOOST_VERSION} REQUIRED COMPONENTS ${BOOST_LIBS_REQUIRED})
foreach (_C ${BOOST_LIBS_REQUIRED})
target_link_libraries(${_TARGET_} Boost::${_C})
endforeach ()
if (${ARGC} GREATER 0)
foreach (_C ${BOOST_LIBS_REQUIRED})
target_link_libraries(${ARGV0} Boost::${_C})
endforeach ()
endif ()
endmacro(target_enable_boost)
add_subdirectory(mtl4)
add_subdirectory(muparser_v134)
\ No newline at end of file
project (mtl4) # GPU version
cmake_minimum_required(VERSION 2.8)
option(ENABLE_GCOV "enable gnu coverage flags for gnu compiler" OFF)
option(ENABLE_WARNINGS "Enable gnu specific warnings" ON)
option(ENABLE_DEVELOPMENT "enable program parts under development" OFF)
# adding the Path of our own Modules
SET(CMAKE_MODULE_PATH $ENV{CMAKE_MODULE_PATH})
SET(MTL4_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
#SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MTL4_ROOT_PATH}/Cmake_Module)
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MTL4_ROOT_PATH})
#look for mtl4, use THIS directory as mtl dir
find_package(MTL REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${MTL_INCLUDE_DIRS})
add_definitions(${MTL_CXX_DEFINITIONS})
#REMAINING PART USES MTL4
include(CheckCXXCompilerFlag)
#let cmake look for the svn-version, only needed for packages?
if (NOT MSVC)
find_package(Subversion)
if(Subversion_FOUND)
Subversion_WC_INFO(${CMAKE_CURRENT_SOURCE_DIR} mtlSubinfo)
set(CurrentRevision ${mtlSubinfo_WC_REVISION})
# message("current revision: ${mtlSubinfo_WC_REVISION}")
else(Subversion_FOUND)
set(CurrentRevision "0")
endif(Subversion_FOUND)
endif (NOT MSVC)
# if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lstdc++")
# endif()
configure_file(boost/numeric/mtl/version.hpp.in boost/numeric/mtl/version.hpp @ONLY)
#look for compiler specific settings
if (MSVC)
# to quiet DevStudio 2005 secure code warnings
add_definitions(/D_SCL_SECURE_NO_WARNINGS)
add_definitions(/D_CRT_SECURE_NO_WARNINGS)
add_definitions(/DMTL_ASSERT_FOR_THROW /D_CRT_SECURE_NO_DEPRECATE /DNOMINMAX /D_CONSOLE /D"_HAS_ITERATOR_DEBUGGING=0" /D"_SECURE_SCL=0" )
# specialty flags such as the C++ language exception model etc. come from the init flags determined by CMAKE
# you may override them, but I have not found it necessary
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} /wd4018 /wd4099 /wd4522 /wd4996 /wd4355 /wd4244 /Z7")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE_INIT} /wd4018 /wd4099 /wd4522 /wd4996 /wd4355 /wd4244 /Z7")
endif (MSVC)
if( "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND ENABLE_WARNINGS)
add_definitions("-Wall -Wextra -Wpointer-arith -Wcast-align -Wcast-qual -Wwrite-strings")
foreach(FLAG "-Wno-long-long") # "-Wno-unused-local-typedefs")
# message(STATUS "Check flag ${FLAG}")
mtl_check_cxx_compiler_flag(${FLAG} FLAG_OKAY)
if(FLAG_OKAY)
message(STATUS "Add ${FLAG}")
add_definitions("${FLAG}")
endif()
endforeach()
endif()
if (ENABLE_DEVELOPMENT)
add_definitions("-DMTL_WITH_DEVELOPMENT")
endif()
if (ENABLE_SHORT_ELE_PROD)
add_definitions("-DMTL_WITH_SHORT_ELE_PROD")
endif()
set(BUILDNAME "${TESTBUILDNAME}")
enable_testing()
include(CTest)
set(MTL_IS_CONFIGURED True) # impede double double configuration in libs
add_subdirectory(libs)
install(DIRECTORY boost DESTINATION include/mtl4)
\ No newline at end of file
......@@ -239,76 +239,81 @@ set(AMDIS_SOURCES
ZeroOrderTerm.cc
)
add_library(AMDiS
add_library(AMDiS${POSTFIX}
${AMDIS_HEADERS}
${AMDIS_SOURCES}
)
add_library(AMDiS::AMDiS ALIAS AMDiS)
add_library(AMDiS::AMDiS ALIAS AMDiS${POSTFIX})
target_include_directories(AMDiS
target_include_directories(AMDiS${POSTFIX}
PUBLIC $<INSTALL_INTERFACE:include/amdis>
PRIVATE ${CMAKE_SOURCE_DIR}/src
)
set_target_properties(AMDiS
set_target_properties(AMDiS${POSTFIX}
PROPERTIES OUTPUT_NAME amdis${POSTFIX}
DEBUG_OUTPUT_NAME amdis${POSTFIX}d)
# set compiler standard
target_enable_cxx14(SUPPORTS_CXX14 AMDiS PUBLIC)
target_enable_cxx14(SUPPORTS_CXX14 AMDiS${POSTFIX} PUBLIC)
if (SUPPORTS_CXX14)
target_compile_definitions(AMDiS PRIVATE AMDIS_HAS_CXX14=1)
target_compile_definitions(AMDiS${POSTFIX} PRIVATE AMDIS_HAS_CXX14=1)
else ()
target_enable_cxx11(SUPPORTS_CXX11 AMDiS PUBLIC)
target_enable_cxx11(SUPPORTS_CXX11 AMDiS${POSTFIX} PUBLIC)
endif ()
if (NOT SUPPORTS_CXX11 AND NOT SUPPORTS_CXX14)
message(FATAL_ERROR "AMDiS needs at least c++11, but the current compiler does not support this standard!")
endif ()
target_compile_definitions(AMDiS PRIVATE AMDIS_HAS_CXX11=1)
target_compile_definitions(AMDiS${POSTFIX} PRIVATE AMDIS_HAS_CXX11=1)
find_package(MTL REQUIRED)
target_link_libraries(AMDiS MTL::MTL)
target_link_libraries(AMDiS${POSTFIX} MTL::MTL)
target_enable_boost(AMDiS)
target_enable_boost(AMDiS${POSTFIX})
find_package(MuParser 1.34 CONFIG REQUIRED)
target_link_libraries(AMDiS MuParser::MuParser)
target_link_libraries(AMDiS${POSTFIX} MuParser::MuParser)
if (ENABLE_PNG)
target_enable_png(AMDiS PUBLIC)
target_enable_png(AMDiS${POSTFIX} PUBLIC)
endif (ENABLE_PNG)
if (ENABLE_MPI)
find_package(MPI REQUIRED)
target_link_libraries(AMDiS MPIP::MPI)
target_compile_definitions(AMDiS PUBLIC HAVE_MPI=1)
endif (ENABLE_MPI)
if (ENABLE_MPI OR ENABLE_PARALLEL_DOMAIN)
find_package(MPI REQUIRED MPICXX)
target_link_libraries(AMDiS${POSTFIX} MPI::MPI_CXX)
target_compile_definitions(AMDiS${POSTFIX} PUBLIC HAVE_MPI=1)
endif ()
if (ENABLE_COMPRESSION)
target_compile_definitions(AMDiS PRIVATE AMDIS_HAS_COMPRESSION=1)
target_compile_definitions(AMDiS${POSTFIX} PRIVATE AMDIS_HAS_COMPRESSION=1)
endif (ENABLE_COMPRESSION)
if (ENABLE_UMFPACK)
find_package(UMFPACK REQUIRED)
target_link_libraries(AMDiS UMFPACK::UMFPACK)
find_package(UMFPACK 4.5 REQUIRED)
target_link_libraries(AMDiS${POSTFIX} UMFPACK::UMFPACK)
endif (ENABLE_UMFPACK)
if (ENABLE_HYPRE)
target_enable_hypre(AMDiS PUBLIC)
target_enable_hypre(AMDiS${POSTFIX} PUBLIC)
endif (ENABLE_HYPRE)
if (ENABLE_SEQ_PETSC OR ENABLE_PARALLEL_DOMAIN)
find_package(PETSc 3.3 REQUIRED)
target_link_libraries(AMDiS PETSc::PETSc)
target_link_libraries(AMDiS${POSTFIX} PETSc::PETSc)
target_compile_definitions(AMDiS${POSTFIX} PRIVATE PETSC_VERSION=${PETSc_VERSION})
endif ()
if (ENABLE_PARALLEL_DOMAIN)
target_compile_definitions(AMDiS${POSTFIX} PUBLIC HAVE_PARALLEL_DOMAIN_AMDIS=1 HAVE_PARALLEL_PETSC=1)
endif (ENABLE_PARALLEL_DOMAIN)
if (ENABLE_BDDCML)
target_enable_bddcml(AMDiS PUBLIC)
target_enable_bddcml(AMDiS${POSTFIX} PUBLIC)
endif (ENABLE_BDDCML)
if (ENABLE_ZOLTAN)
target_enable_zoltan(AMDiS PUBLIC)
target_enable_zoltan(AMDiS${POSTFIX} PUBLIC)
endif (ENABLE_ZOLTAN)
# install files
......@@ -317,7 +322,7 @@ install(FILES
DESTINATION include/amdis
)
install(TARGETS AMDiS
install(TARGETS AMDiS${POSTFIX}
EXPORT AMDiS-export
COMPONENT $<IF:ENABLE_PARALLEL_DOMAIN,PARALLEL,SEQUENTIAL>
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/amdis
......@@ -327,6 +332,7 @@ install(TARGETS AMDiS
install(EXPORT AMDiS-export
FILE AMDiSTargets${POSTFIX}.cmake
NAMESPACE AMDiS::
COMPONENT $<IF:ENABLE_PARALLEL_DOMAIN,PARALLEL,SEQUENTIAL>
DESTINATION ${CMAKE_INSTALL_LIBDIR}/amdis/cmake
)
......@@ -336,7 +342,7 @@ export(EXPORT AMDiS-export
NAMESPACE AMDiS::)
# Register the package in the user's package registry.
export(PACKAGE AMDiS)
export(PACKAGE AMDiS${POSTFIX})
# ------------------------------------------------------------------------------
......
......@@ -24,7 +24,7 @@ set(AMDIS_COMPOSITEFEM_SOURCES
SubElementAssembler.cc
SubPolytope.cc
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_COMPOSITEFEM_HEADERS}
${AMDIS_COMPOSITEFEM_SOURCES}
)
......
......@@ -8,7 +8,7 @@ set(AMDIS_CONFIG_HEADERS
Config_pgi.h
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_CONFIG_HEADERS}
)
......
......@@ -7,7 +7,7 @@ set(AMDIS_DEPRECATED_HEADERS
set(AMDIS_DEPRECATED_SOURCES
ProblemImplicit.cc
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_DEPRECATED_HEADERS}
${AMDIS_DEPRECATED_SOURCES}
)
......
......@@ -12,7 +12,7 @@ set(AMDIS_EST_SOURCES
ResidualEstimator.cc
SimpleResidualEstimator.cc
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_EST_HEADERS}
${AMDIS_EST_SOURCES}
)
......
......@@ -18,7 +18,7 @@ set(AMDIS_EXPRESSIONS_HEADERS
vec_functors.hpp
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_EXPRESSIONS_HEADERS}
)
......
......@@ -5,7 +5,7 @@ set(AMDIS_IO_HEADERS
Arh3Reader.h
Arh3Writer.h
ArhReader.h
#ArhWriter.h
ArhWriter.h
DataCollector.h
DataCollector.hh
DofWriter.h
......@@ -60,7 +60,7 @@ set(AMDIS_IO_SOURCES
VtkWriter.cc
XYZReader.cc
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_IO_HEADERS}
${AMDIS_IO_SOURCES}
)
......
......@@ -24,7 +24,7 @@ set(AMDIS_IO_DETAIL_SOURCES
ArhWriter.cc
VtkWriter.cc
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_IO_DETAIL_HEADERS}
${AMDIS_IO_DETAIL_SOURCES}
)
......
......@@ -10,7 +10,7 @@ set(AMDIS_NONLIN_SOURCES
ProblemNonLin.cc
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_NONLIN_HEADERS}
${AMDIS_NONLIN_SOURCES}
)
......
......@@ -6,7 +6,7 @@ set(AMDIS_OPERATIONS_HEADERS
product.hpp
)
target_sources_local(AMDiS PRIVATE
target_sources_local(AMDiS${POSTFIX} PRIVATE
${AMDIS_OPERATIONS_HEADERS}
)
......
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