Skip to content
Snippets Groups Projects
Commit c012e995 authored by Lars Bilke's avatar Lars Bilke
Browse files

[cmake] format top-level.

parent c54a2aec
No related branches found
No related tags found
No related merge requests found
##################### # ---- OGS-6 Project ----
### OGS-6 Project ###
#####################
# Specify minimum CMake version # Specify minimum CMake version
cmake_minimum_required(VERSION 3.12) cmake_minimum_required(VERSION 3.12)
...@@ -15,27 +13,27 @@ if(POLICY CMP0074) ...@@ -15,27 +13,27 @@ if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) cmake_policy(SET CMP0074 NEW)
endif() endif()
if(WIN32 AND if(WIN32
NOT ${CMAKE_GENERATOR} STREQUAL Ninja AND AND NOT ${CMAKE_GENERATOR} STREQUAL Ninja
NOT ${CMAKE_GENERATOR} MATCHES 2015) # does not work on 2015 AND NOT ${CMAKE_GENERATOR} MATCHES 2015) # does not work on 2015 Force 64-bit
# Force 64-bit VS compiler # VS compiler
set(CMAKE_GENERATOR_TOOLSET host=x64) set(CMAKE_GENERATOR_TOOLSET host=x64)
endif() endif()
# Project name # Project name
project( OGS-6 ) project(OGS-6)
include(scripts/cmake/CMakeSetup.cmake) include(scripts/cmake/CMakeSetup.cmake)
include(ParseCMakeArgs) include(ParseCMakeArgs)
include(CTest) include(CTest)
########################### # ---- Preliminary Options ----
### Preliminary Options ###
###########################
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
option(BUILD_SHARED_LIBS "Create shared libraries?" OFF) option(BUILD_SHARED_LIBS "Create shared libraries?" OFF)
set(CMAKE_LIBRARY_SEARCH_PATH "" CACHE PATH set(CMAKE_LIBRARY_SEARCH_PATH
"Additional library installation path, e.g. /opt/local or C:/libs") ""
CACHE PATH
"Additional library installation path, e.g. /opt/local or C:/libs")
set(OGS_CPU_ARCHITECTURE "native" CACHE STRING "Processor architecture, \ set(OGS_CPU_ARCHITECTURE "native" CACHE STRING "Processor architecture, \
defaults to native (*nix) / blend (MSVC).") defaults to native (*nix) / blend (MSVC).")
option(OGS_ENABLE_AVX2 "Enable the use of AVX2 instructions" OFF) option(OGS_ENABLE_AVX2 "Enable the use of AVX2 instructions" OFF)
...@@ -45,14 +43,24 @@ if(DEFINED CMAKE_CXX_CLANG_TIDY) ...@@ -45,14 +43,24 @@ if(DEFINED CMAKE_CXX_CLANG_TIDY)
endif() endif()
option(OGS_USE_CONAN "Should Conan package manager be used?" ON) option(OGS_USE_CONAN "Should Conan package manager be used?" ON)
set(OGS_CONAN_BUILD "missing" CACHE STRING "Possible values: all, missing, \ set(OGS_CONAN_BUILD "missing" CACHE STRING "Possible values: all, missing, \
never or list of libs to build" ) never or list of libs to build")
# Third-party libraries, names come from Conan package names # Third-party libraries, names come from Conan package names
set(OGS_LIBS set(OGS_LIBS
vtk boost eigen qt shapelib libgeotiff petsc lis cvode vtk
boost
eigen
qt
shapelib
libgeotiff
petsc
lis
cvode
CACHE INTERNAL "") CACHE INTERNAL "")
foreach(LIB ${OGS_LIBS}) foreach(LIB ${OGS_LIBS})
set(OGS_LIB_${LIB} "Default" CACHE STRING "Which ${LIB} library should be used?") set(OGS_LIB_${LIB}
"Default"
CACHE STRING "Which ${LIB} library should be used?")
set_property(CACHE OGS_LIB_${LIB} PROPERTY STRINGS "Default" "System") set_property(CACHE OGS_LIB_${LIB} PROPERTY STRINGS "Default" "System")
endforeach(LIB) endforeach(LIB)
...@@ -61,7 +69,7 @@ if(OGS_USE_PETSC) ...@@ -61,7 +69,7 @@ if(OGS_USE_PETSC)
endif() endif()
option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF) option(OGS_USE_CVODE "Use the Sundials CVODE module?" OFF)
### CMake includes ### # ---- CMake includes ----
include(PreFind) include(PreFind)
include(CheckTypeSizes) include(CheckTypeSizes)
include(Functions) include(Functions)
...@@ -78,13 +86,12 @@ if(OGS_COVERAGE AND NOT IS_SUBPROJECT) ...@@ -78,13 +86,12 @@ if(OGS_COVERAGE AND NOT IS_SUBPROJECT)
endif() endif()
include(CppCheck) include(CppCheck)
#################### # ---- More Options ----
### More Options ###
####################
# Profiling # Profiling
if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) AND GPROF_PATH) if((CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_GNUCC) AND GPROF_PATH)
option(OGS_PROFILE "Enables compiling with flags set for profiling with gprof." OFF) option(OGS_PROFILE
"Enables compiling with flags set for profiling with gprof." OFF)
endif() # GCC AND GPROF_PATH endif() # GCC AND GPROF_PATH
# Enable / Disable parts # Enable / Disable parts
...@@ -99,11 +106,10 @@ endif() ...@@ -99,11 +106,10 @@ endif()
option(OGS_BUILD_UTILS "Should the utilities programms be built?" OFF) option(OGS_BUILD_UTILS "Should the utilities programms be built?" OFF)
if(OGS_BUILD_UTILS AND OGS_USE_MPI) if(OGS_BUILD_UTILS AND OGS_USE_MPI)
message(WARNING "OGS_BUILD_UTILS cannot be used with OGS_USE_MPI " message(WARNING "OGS_BUILD_UTILS cannot be used with OGS_USE_MPI "
"(OGS_USE_PETSC)! Disabling OGS_BUILD_UTILS.") "(OGS_USE_PETSC)! Disabling OGS_BUILD_UTILS.")
set(OGS_BUILD_UTILS OFF CACHE BOOL "" FORCE) set(OGS_BUILD_UTILS OFF CACHE BOOL "" FORCE)
endif() endif()
# A list of processes to be build. Also used in the ProcessLib to select # A list of processes to be build. Also used in the ProcessLib to select
# processes to be build. # processes to be build.
set(ProcessesList set(ProcessesList
...@@ -134,12 +140,17 @@ foreach(process ${ProcessesList}) ...@@ -134,12 +140,17 @@ foreach(process ${ProcessesList})
option(OGS_BUILD_PROCESS_${process} "Build the ${process} process." ON) option(OGS_BUILD_PROCESS_${process} "Build the ${process} process." ON)
endforeach() endforeach()
set(OGS_BUILD_PROCESSES "" CACHE STRING "Semicolon-separated list of processes to build") set(OGS_BUILD_PROCESSES
""
CACHE STRING "Semicolon-separated list of processes to build")
if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "") if(NOT "${OGS_BUILD_PROCESSES}" STREQUAL "")
foreach(process ${OGS_BUILD_PROCESSES}) foreach(process ${OGS_BUILD_PROCESSES})
if(NOT "${process}" IN_LIST ProcessesList) if(NOT "${process}" IN_LIST ProcessesList)
message(FATAL_ERROR "${process} given in OGS_BUILD_PROCESSES is " message(
"not a valid process name! Valid names are ${ProcessesList}") FATAL_ERROR
"${process} given in OGS_BUILD_PROCESSES is "
"not a valid process name! Valid names are ${ProcessesList}"
)
endif() endif()
endforeach() endforeach()
message(STATUS "Enabled processes:") message(STATUS "Enabled processes:")
...@@ -177,41 +188,49 @@ option(OGS_USE_EIGEN_UNSUPPORTED "Use Eigen unsupported modules" ON) ...@@ -177,41 +188,49 @@ option(OGS_USE_EIGEN_UNSUPPORTED "Use Eigen unsupported modules" ON)
option(OGS_EIGEN_INITIALIZE_MATRICES_BY_NAN "" ON) option(OGS_EIGEN_INITIALIZE_MATRICES_BY_NAN "" ON)
option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF) option(EIGEN_NO_DEBUG "Disables Eigen's assertions" OFF)
# We assume that it's save to use vectorization with Eigen < 3.3 (strictly smaller than 3.3.!). # We assume that it's save to use vectorization with Eigen < 3.3 (strictly
# At least we only observed vectorization issues with Eigen 3.3.x. # smaller than 3.3.!). At least we only observed vectorization issues with Eigen
# If you want to use Eigen vectorization, make sure that you run all the ctests several times, e.g.: # 3.3.x. If you want to use Eigen vectorization, make sure that you run all the
# $ ctest --repeat-until-fail 50 # ctests several times, e.g.: $ ctest --repeat-until-fail 50 You might also want
# You might also want to take a look at https://github.com/ufz/ogs/issues/1881. # to take a look at https://github.com/ufz/ogs/issues/1881.
option(EIGEN_DONT_VECTORIZE "Disables explicit vectorization when defined." ON) option(EIGEN_DONT_VECTORIZE "Disables explicit vectorization when defined." ON)
set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES "Default" CACHE STRING "Use dynamically allocated shape matrices") set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES
"Default"
CACHE STRING "Use dynamically allocated shape matrices")
set_property(CACHE OGS_EIGEN_DYNAMIC_SHAPE_MATRICES set_property(CACHE OGS_EIGEN_DYNAMIC_SHAPE_MATRICES
PROPERTY STRINGS "Default" "ON" "OFF") PROPERTY STRINGS
"Default"
"ON"
"OFF")
if(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES STREQUAL "Default") if(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES STREQUAL "Default")
if(CMAKE_BUILD_TYPE STREQUAL "Release" OR if(CMAKE_BUILD_TYPE STREQUAL "Release"
CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo") OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL OFF) set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL OFF)
else() else()
set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL ON) set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL ON)
endif() endif()
else() else()
set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL ${OGS_EIGEN_DYNAMIC_SHAPE_MATRICES}) set(OGS_EIGEN_DYNAMIC_SHAPE_MATRICES_INTERNAL
${OGS_EIGEN_DYNAMIC_SHAPE_MATRICES})
endif() endif()
# MKL # MKL
option(OGS_USE_MKL "Use Intel MKL" OFF) option(OGS_USE_MKL "Use Intel MKL" OFF)
# Logging # Logging
set(OGS_LOG_LEVEL "LOGOG_LEVEL_DEBUG" CACHE STRING "Set logging level included in compilation.") set(OGS_LOG_LEVEL
set_property(CACHE OGS_LOG_LEVEL PROPERTY STRINGS "LOGOG_LEVEL_DEBUG"
LOGOG_LEVEL_NONE CACHE STRING "Set logging level included in compilation.")
LOGOG_LEVEL_ERROR set_property(CACHE OGS_LOG_LEVEL
LOGOG_LEVEL_WARN PROPERTY STRINGS
LOGOG_LEVEL_INFO LOGOG_LEVEL_NONE
LOGOG_LEVEL_DEBUG LOGOG_LEVEL_ERROR
LOGOG_LEVEL_ALL LOGOG_LEVEL_WARN
) LOGOG_LEVEL_INFO
LOGOG_LEVEL_DEBUG
LOGOG_LEVEL_ALL)
# Debug # Debug
option(OGS_FATAL_ABORT "Abort in OGS_FATAL" OFF) option(OGS_FATAL_ABORT "Abort in OGS_FATAL" OFF)
...@@ -221,36 +240,44 @@ set(OGS_CXX_FLAGS "" CACHE STRING "Additional C++ compiler flags.") ...@@ -221,36 +240,44 @@ set(OGS_CXX_FLAGS "" CACHE STRING "Additional C++ compiler flags.")
option(STL_NO_DEBUG "Disable STL debug in debug build" OFF) option(STL_NO_DEBUG "Disable STL debug in debug build" OFF)
# Print CMake variable values # Print CMake variable values
if (OGS_CMAKE_DEBUG) if(OGS_CMAKE_DEBUG)
include(ListAllCMakeVariableValues) include(ListAllCMakeVariableValues)
list_all_cmake_variable_values() list_all_cmake_variable_values()
endif () endif()
# Code coverage # Code coverage
option(OGS_COVERAGE "Enables code coverage measurements with gcov/lcov." OFF) option(OGS_COVERAGE "Enables code coverage measurements with gcov/lcov." OFF)
option(OGS_SYNC_SUBMODULES "Sync git submodules on CMake run. Overwrites custom URLs!" ON) option(OGS_SYNC_SUBMODULES
"Sync git submodules on CMake run. Overwrites custom URLs!" ON)
# Options controlling which FEM elements will be compiled # Options controlling which FEM elements will be compiled
set(OGS_MAX_ELEMENT_DIM 3 CACHE STRING "Maximum dimension of FEM elements to be built.") set(OGS_MAX_ELEMENT_DIM
set(OGS_MAX_ELEMENT_ORDER 2 CACHE STRING "Maximum order of FEM elements to be built.") 3
option(OGS_ENABLE_ELEMENT_SIMPLEX "Build FEM elements for simplices (triangles, tetrahedra)." ON) CACHE STRING "Maximum dimension of FEM elements to be built.")
option(OGS_ENABLE_ELEMENT_CUBOID "Build FEM elements for cuboids (quads, hexahedra)." ON) set(OGS_MAX_ELEMENT_ORDER
option(OGS_ENABLE_ELEMENT_PRISM "Build FEM elements for prisms." ON) 2
CACHE STRING "Maximum order of FEM elements to be built.")
option(OGS_ENABLE_ELEMENT_SIMPLEX
"Build FEM elements for simplices (triangles, tetrahedra)." ON)
option(OGS_ENABLE_ELEMENT_CUBOID
"Build FEM elements for cuboids (quads, hexahedra)." ON)
option(OGS_ENABLE_ELEMENT_PRISM "Build FEM elements for prisms." ON)
option(OGS_ENABLE_ELEMENT_PYRAMID "Build FEM elements for pyramids." ON) option(OGS_ENABLE_ELEMENT_PYRAMID "Build FEM elements for pyramids." ON)
option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation." OFF) option(OGS_CHECK_HEADER_COMPILATION "Check header for standalone compilation."
OFF)
option(OGS_USE_PYTHON "Interface with Python" OFF) option(OGS_USE_PYTHON "Interface with Python" OFF)
if(OGS_USE_PYTHON AND NOT Python_FOUND) if(OGS_USE_PYTHON AND NOT Python_FOUND)
message(FATAL_ERROR "Python not found but required for OGS_USE_PYTHON=ON!") message(FATAL_ERROR "Python not found but required for OGS_USE_PYTHON=ON!")
endif() endif()
option(OGS_USE_MFRONT "Enable solid material models by MFront (https://tfel.sourceforge.net)" OFF) option(OGS_USE_MFRONT
"Enable solid material models by MFront (https://tfel.sourceforge.net)"
OFF)
################### # ---- Definitions ----
### Definitions ###
###################
if(OGS_USE_LIS) if(OGS_USE_LIS)
add_definitions(-DUSE_LIS) add_definitions(-DUSE_LIS)
include_directories(SYSTEM ${LIS_INCLUDE_DIR}) include_directories(SYSTEM ${LIS_INCLUDE_DIR})
...@@ -276,11 +303,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") ...@@ -276,11 +303,11 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_NAN) add_definitions(-DEIGEN_INITIALIZE_MATRICES_BY_NAN)
endif() endif()
if (EIGEN_NO_DEBUG) if(EIGEN_NO_DEBUG)
add_definitions(-DEIGEN_NO_DEBUG) add_definitions(-DEIGEN_NO_DEBUG)
endif() endif()
if (EIGEN_DONT_VECTORIZE) if(EIGEN_DONT_VECTORIZE)
add_definitions(-DEIGEN_DONT_VECTORIZE) add_definitions(-DEIGEN_DONT_VECTORIZE)
endif() endif()
...@@ -302,7 +329,7 @@ if(MSVC AND OGS_32_BIT) ...@@ -302,7 +329,7 @@ if(MSVC AND OGS_32_BIT)
endif() endif()
# End Eigen # End Eigen
if (OGS_FATAL_ABORT) if(OGS_FATAL_ABORT)
add_definitions(-DOGS_FATAL_ABORT) add_definitions(-DOGS_FATAL_ABORT)
endif() endif()
...@@ -310,12 +337,12 @@ endif() ...@@ -310,12 +337,12 @@ endif()
add_definitions(-DLOGOG_LEVEL=${OGS_LOG_LEVEL}) add_definitions(-DLOGOG_LEVEL=${OGS_LOG_LEVEL})
# Packaging # Packaging
option(OGS_DOWNLOAD_ADDITIONAL_CONTENT "Should additional content such as manuals be downloaded and packaged?" OFF) option(OGS_DOWNLOAD_ADDITIONAL_CONTENT
"Should additional content such as manuals be downloaded and packaged?"
OFF)
include(scripts/cmake/packaging/Pack.cmake) include(scripts/cmake/packaging/Pack.cmake)
###################### # ---- Subdirectories ----
### Subdirectories ###
######################
# External projects # External projects
if(OGS_INSITU) if(OGS_INSITU)
...@@ -323,33 +350,34 @@ if(OGS_INSITU) ...@@ -323,33 +350,34 @@ if(OGS_INSITU)
add_definitions(-DUSE_INSITU) add_definitions(-DUSE_INSITU)
endif() endif()
# Add subdirectories with the projects # Add subdirectories with the projects
add_subdirectory( ThirdParty ) add_subdirectory(ThirdParty)
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty ) include_directories(
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/googletest/googletest/include ) SYSTEM
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/autocheck/include ) ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/tclap/include ) ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/googletest/googletest/include
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/json/include ) ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/autocheck/include
include_directories( SYSTEM ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/exprtk ) ${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/tclap/include
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/json/include
${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/exprtk)
include(scripts/cmake/CheckHeaderCompilation.cmake) include(scripts/cmake/CheckHeaderCompilation.cmake)
add_subdirectory( Applications ) add_subdirectory(Applications)
add_subdirectory( BaseLib ) add_subdirectory(BaseLib)
add_subdirectory( GeoLib ) add_subdirectory(GeoLib)
add_subdirectory( MathLib ) add_subdirectory(MathLib)
add_subdirectory( MeshLib ) add_subdirectory(MeshLib)
add_subdirectory( MeshGeoToolsLib ) add_subdirectory(MeshGeoToolsLib)
add_subdirectory( NumLib ) add_subdirectory(NumLib)
add_subdirectory( ChemistryLib ) add_subdirectory(ChemistryLib)
if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR BUILD_TESTING) if(OGS_BUILD_CLI OR OGS_BUILD_UTILS OR BUILD_TESTING)
add_subdirectory( ParameterLib ) add_subdirectory(ParameterLib)
add_subdirectory( MaterialLib ) add_subdirectory(MaterialLib)
add_subdirectory( ProcessLib ) add_subdirectory(ProcessLib)
endif() endif()
if( BUILD_TESTING AND NOT IS_SUBPROJECT ) if(BUILD_TESTING AND NOT IS_SUBPROJECT)
add_subdirectory( Tests ) add_subdirectory(Tests)
endif() endif()
file(WRITE ${PROJECT_BINARY_DIR}/disabled-tests.log "${DISABLED_TESTS_LOG}") file(WRITE ${PROJECT_BINARY_DIR}/disabled-tests.log "${DISABLED_TESTS_LOG}")
...@@ -357,7 +385,7 @@ unset(DISABLED_TESTS_LOG CACHE) # Don't write to CMakeCache.txt ...@@ -357,7 +385,7 @@ unset(DISABLED_TESTS_LOG CACHE) # Don't write to CMakeCache.txt
# The configuration must be called from the source dir and not BaseLib/. # The configuration must be called from the source dir and not BaseLib/.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BaseLib/BuildInfo.cpp.in" configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BaseLib/BuildInfo.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/BaseLib/BuildInfo.cpp" @ONLY) "${CMAKE_CURRENT_BINARY_DIR}/BaseLib/BuildInfo.cpp" @ONLY)
check_header_compilation() check_header_compilation()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment