Select Git revision
CMakeLists.txt 4.81 KiB
cmake_minimum_required (VERSION 3.14)
option(CM_ALL_VTK_OUTPUT "VTK output routine" OFF)
option(CM_ALL_VORONOI "Voronoi-based loadbalancing scheme (requires Voro++)" OFF)
option(CM_ALL_FORTRAN "VTK output routine" OFF)
option(CM_ALL_DEBUG "Enable debug information" OFF)
option(CM_ALL_USE_F08 "Use some Fortran 2008 features (mpi_f08)" OFF)
option(CM_ALL_FORTRAN_ERROR_ABORT "Abort on any error when using the
Fortran interface" OFF)
option(CM_ALL_TESTS "Enables test suite" OFF)
option(CM_ALL_AUTO_DOC "Enables creation of auto-documentation")
# leading and trailing whitespace should be silently ignored
# thanks to an old FindMPI script
cmake_policy(SET CMP0004 OLD)
enable_language(CXX)
enable_language(C)
if (CM_ALL_USE_F08)
if (NOT CM_ALL_FORTRAN)
message(FATAL_ERROR "Flag for Fortran 08 MPI interface set, while Fortran interface is not enabled!")
endif ()
endif ()
if (CM_ALL_FORTRAN)
enable_language(Fortran)
# todo(s.schulz): This should be extended for other compilers, if they
# support standard checking. The Intel Fortran compiler
# does not.
if(CM_ALL_USE_F08)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-std=f2008>)
else()
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-std=f2003>)
endif()
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-fbacktrace>)
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:Intel>>:-traceback>)
endif (CM_ALL_FORTRAN)
# set standards compliance flags
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (CM_ALL_FORTRAN)
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:Fortran>,$<Fortran_COMPILER_ID:GNU>>:-Wall;-Wextra>")
endif (CM_ALL_FORTRAN)
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:C>,$<C_COMPILER_ID:GNU>>:-Wall;-Wextra>")
add_compile_options("$<$<AND:$<CONFIG:Debug>,$<COMPILE_LANGUAGE:CXX>,$<CXX_COMPILER_ID:GNU>>:-Wall;-Wextra>")
project(ALL
VERSION "0.9.1"
DESCRIPTION "A Loadbalacing Library"
HOMEPAGE_URL "http://slms.pages.jsc.fz-juelich.de/websites/all-website/")
# add custom find-scripts to module path
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
if (CM_ALL_FORTRAN)
find_package(MPI REQUIRED COMPONENTS CXX Fortran)
else()
find_package(MPI REQUIRED COMPONENTS CXX)
endif (CM_ALL_FORTRAN)
if(CM_ALL_VTK_OUTPUT)
message("Using VTK output")
find_package(VTK REQUIRED COMPONENTS
vtkCommonCore
vtkCommonDataModel
vtkFiltersProgrammable
vtkIOParallelXML
vtkIOXML
vtkParallelMPI
)
if(NOT VTK_FOUND)
message(FATAL_ERROR "VTK not found, help CMake to find it by setting VTK_LIBRARY and VTK_INCLUDE_DIR")
endif()
# todo(s.schulz): this can be replaced from 3.12 onwards with add_compile_definitions
add_compile_options("-DALL_VTK_OUTPUT")
endif(CM_ALL_VTK_OUTPUT)
if (CM_ALL_DEBUG)
message("Using ALL debug information")
add_compile_options("-DALL_DEBUG_ENABLED")
endif(CM_ALL_DEBUG)
if(CM_ALL_FORTRAN_ERROR_ABORT)
add_compile_options("-DALL_FORTRAN_ERROR_ABORT")
endif()
if(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
add_compile_options("-DALL_USE_F08")
elseif(CM_ALL_USE_F08 AND NOT MPI_Fortran_HAVE_F08_MODULE)
message(FATAL_ERROR "Fortran 2008 MPI chosen, but MPI installation does not support the Fortran 2008 modules")
endif(CM_ALL_USE_F08 AND MPI_Fortran_HAVE_F08_MODULE)
if(CM_ALL_VORONOI)
message(STATUS "compiling voro++ version in contrib/voro++")
add_subdirectory(contrib/voro++)
set(CM_ALL_VORO_INC ${CMAKE_SOURCE_DIR}/contrib/voro++/include)
set(CM_ALL_VORO_LIB "-L${CMAKE_BINARY_DIR}/contrib/voro++/src -lvoro")
add_compile_options("-DALL_VORONOI_ACTIVE")
endif()
set(STB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/contrib/stb)
add_subdirectory(src)
add_subdirectory(example)
if (CM_ALL_TESTS)
enable_testing()
include(FindPackageHandleStandardArgs)
add_subdirectory(tests)
endif(CM_ALL_TESTS)
if(CM_ALL_AUTO_DOC)
add_subdirectory("docs")
endif(CM_ALL_AUTO_DOC)
# Export targets and create package
install(EXPORT ALLTargets
NAMESPACE ALL::
FILE ALLTargets.cmake
DESTINATION lib/cmake/ALL
)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/ALLConfig.cmake"
INSTALL_DESTINATION lib/cmake/ALL
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/ALLConfigVersion.cmake"
VERSION "${ALL_VERSION}"
COMPATIBILITY SameMajorVersion)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/ALLConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/ALLConfigVersion.cmake"
DESTINATION lib/cmake/ALL)
# vim: sw=4 ts=4 et