Commit 7ab1369d authored by GILLES Sebastien's avatar GILLES Sebastien

#1364 CMake: adapt to the new way (again...) in which debug and release are separated.

parent 2e9e80d1
# A minimum version for cmake command is required.
cmake_minimum_required(VERSION 3.8)
# ===================================================================================================================
# Include a file with default setting. Some of them might be overriden by command line, such as the C or C++ compiler.
# ===================================================================================================================
if (NOT OPEN_MPI_LIB_DIR)
message(FATAL_ERROR "OPEN_MPI_LIB_DIR was not found; the recommended way to build MoReFEM is to provide a setting file that provide many cache values with -C, e.g. cmake -C ../cmake/Settings/clang_shared_lib.cmake.")
endif()
if(MOREFEM_NO_TRAP_SNES_EXCEPTION)
message("Adding flag MOREFEM_NO_TRAP_SNES_EXCEPTION")
add_definitions(-DMOREFEM_NO_TRAP_SNES_EXCEPTION)
......@@ -45,6 +36,31 @@ endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake)
# ===================================================================================================================
# Set C and C++ compiler (or more exactly their mpi wrappers)
# ===================================================================================================================
set(CMAKE_C_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpicc CACHE FILEPATH "C compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpic++ CACHE FILEPATH "C++ compiler. Prefer to use an openmpi wrapper.")
# ===================================================================================================================
# Set third party include and lib directories
# ===================================================================================================================
set(OPEN_MPI_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/include CACHE PATH "Include directory of Openmpi library.")
set(OPEN_MPI_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/lib CACHE PATH "Lib directory of Openmpi library." )
set(PETSC_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/include CACHE PATH "Include directory of Petsc library.")
set(PETSC_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/lib CACHE PATH "Library directory of Petsc.")
set(PARMETIS_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/include CACHE PATH "Include directory of Parmetis library.")
set(PARMETIS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/lib CACHE PATH "Lib directory of Parmetis library.")
set(LUA_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/include CACHE PATH "Include directory of Lua library.")
set(LUA_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/lib CACHE PATH "Lib directory of Lua library.")
set(BOOST_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/include CACHE PATH "Include directory of Boost library.")
set(BOOST_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/lib CACHE PATH "Lib directory of Boost library.")
# ===================================================================================================================
# Set project.
# ===================================================================================================================
......@@ -60,7 +76,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources /
${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Tclap/include /
${CMAKE_CURRENT_SOURCE_DIR}/Sources/ThirdParty/Source/Seldon /
${OPEN_MPI_INCL_DIR} /
${PETSC_SPECIFIC_INCL_DIR} /
${PETSC_INCL_DIR} /
${PARMETIS_INCL_DIR} /
${LUA_INCL_DIR} /
${BOOST_INCL_DIR}
......@@ -70,7 +86,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources /
morefem_find_library(LIB_OPEN_MPI "mpi" ${OPEN_MPI_LIB_DIR} "Openmpi")
morefem_find_library(LIB_OPEN_MPI_CXX "mpi_cxx" ${OPEN_MPI_LIB_DIR} "Openmpi (C++)")
morefem_find_library(LIB_PETSC "petsc" ${PETSC_SPECIFIC_LIB_DIR} "Petsc")
morefem_find_library(LIB_PETSC "petsc" ${PETSC_LIB_DIR} "Petsc")
morefem_find_library(LIB_PARMETIS "parmetis" ${PARMETIS_LIB_DIR} "Parmetis")
morefem_find_library(LIB_METIS "metis" ${PARMETIS_LIB_DIR} "Metis")
morefem_find_library(LIB_LUA "lua" ${LUA_LIB_DIR} "Lua")
......@@ -126,7 +142,8 @@ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True)
set(MOREFEM_TEST_OUTPUT_DIR /tmp/MoReFEM/${CMAKE_C_COMPILER_ID}/${CMAKE_BUILD_TYPE})
######################################################
# Walk through Sources directory to find all sources to build.
######################################################
......
......@@ -2,10 +2,7 @@ set(CMAKE_INSTALL_PREFIX /placeholder_value CACHE PATH "Installation directory f
set(MOREFEM_ASAN True CACHE BOOL "If true address sanitizer is enabled.")
set(MOREFEM_THIRD_PARTY_LIBRARIES_DIR /media/suppl_drive/opt)
set(CMAKE_C_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpicc CACHE FILEPATH "C compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpic++ CACHE FILEPATH "C++ compiler. Prefer to use an openmpi wrapper.")
set(MOREFEM_THIRD_PARTY_LIBRARIES_DIR /opt/gcc_release CACHE STRING "Path to third party directory")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard; at least 17 is expected.")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE STRING "Leave this one active.")
......@@ -21,34 +18,10 @@ set(MOREFEM_EXTENDED_TIME_KEEP False CACHE BOOL "If true, TimeKeep gains the abi
set(MOREFEM_NO_TRAP_SNES_EXCEPTION False CACHE BOOL "If true, exceptions aren't caught in the three SNES functions I have to define for a Petsc Newton (at least the default ones; if you define your own it's up to you to introduce the macro in your code). If not caught, an eventual exception will be written properly but the exception is not guaranteed to be caught and it might result in a rather messy output. I therefore advise not to set it to True in debug mode; in release mode it is ok to do so as such exceptios are rare.")
set(OPEN_MPI_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/include CACHE PATH "Include directory of Openmpi library.")
set(OPEN_MPI_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/lib CACHE PATH "Lib directory of Openmpi library." )
set(BLAS_CUSTOM_LINKER False CACHE BOOL "If BLAS_CUSTOM_LINKER is true, BLAS_LIB field must give the command use to link with Blas. For instance on macOS it is usually \"-framework Accelerate\" (Beware: Without the quotes CMake will mute this into -framework -Accelerate). If False, FindLibrary is used to find the Blas library to be used, as for the other libraries in this file. The difference is that the name of the .a, .so or .dylib is not known, so it must be given in BLAS_LIB_NAME field. For instance openblas to find libopenblas.a in BLAS_LIB_DIR.")
set(BLAS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openblas/lib CACHE STRING "None or path to the lib directory of Blas (see BLAS_CUSTOM_LINKER).")
set(BLAS_LIB openblas CACHE STRING "Name of the Blas lib (e.g. openblas) or command to pass if custom linker is used; see BLAS_CUSTOM_LINKER." )
set(PETSC_DEBUG_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/debug/include CACHE PATH "Include directory of Petsc library specific to debug configuration.")
set(PETSC_RELEASE_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/release/include CACHE PATH "Include directory of Petsc library specific to release configuration.")
set(PETSC_DEBUG_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/debug/lib CACHE PATH "Library directory of Petsc in debug mode.")
set(PETSC_RELEASE_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/release/lib CACHE PATH "Library directory of Petsc in release mode.")
set(PARMETIS_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/include CACHE PATH "Include directory of Parmetis library.")
set(PARMETIS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/lib CACHE PATH "Lib directory of Parmetis library.")
# Lua library.
set(LUA_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/include CACHE PATH "Include directory of Lua library.")
set(LUA_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/lib CACHE PATH "Lib directory of Lua library.")
set(BOOST_DEBUG_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/debug/include CACHE PATH "Include directory of Boost library.")
set(BOOST_DEBUG_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/debug/lib CACHE PATH "Lib directory of Boost library.")
set(BOOST_RELEASE_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/release/include CACHE PATH "Include directory of Boost library.")
set(BOOST_RELEASE_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/release/lib CACHE PATH "Lib directory of Boost library.")
set(PHILLIPS_DIR False CACHE BOOL "If you want to couple Morefem with Phillips library. False in most of the cases! Beware: it is not put in MOREFEM_COMMON_DEP; if you need it you must add it in your add_executable command.")
set(CMAKE_INSTALL_PREFIX /placeholder_value CACHE PATH "Installation directory for executables and libraries. A MoReFEM folder will be created there when install is invoked. This value should be overridden in command line!")
set(MOREFEM_THIRD_PARTY_LIBRARIES_DIR /opt/gcc)
set(MOREFEM_THIRD_PARTY_LIBRARIES_DIR /opt/gcc_release CACHE STRING "Path to third party directory")
set(MOREFEM_ASAN False CACHE BOOL "If true address sanitizer is enabled.")
set(CMAKE_C_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpicc CACHE FILEPATH "C compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpic++ CACHE FILEPATH "C++ compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard; at least 17 is expected.")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE STRING "Leave this one active.")
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "If ON you might be using gnu++17; with OFF you'll use c++17.")
......@@ -21,34 +18,10 @@ set(MOREFEM_EXTENDED_TIME_KEEP False CACHE BOOL "If true, TimeKeep gains the abi
set(MOREFEM_NO_TRAP_SNES_EXCEPTION False CACHE BOOL "If true, exceptions aren't caught in the three SNES functions I have to define for a Petsc Newton (at least the default ones; if you define your own it's up to you to introduce the macro in your code). If not caught, an eventual exception will be written properly but the exception is not guaranteed to be caught and it might result in a rather messy output. I therefore advise not to set it to True in debug mode; in release mode it is ok to do so as such exceptios are rare.")
set(OPEN_MPI_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/include CACHE PATH "Include directory of Openmpi library.")
set(OPEN_MPI_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/lib CACHE PATH "Lib directory of Openmpi library." )
set(BLAS_CUSTOM_LINKER False CACHE BOOL "If BLAS_CUSTOM_LINKER is true, BLAS_LIB field must give the command use to link with Blas. For instance on macOS it is usually \"-framework Accelerate\" (Beware: Without the quotes CMake will mute this into -framework -Accelerate). If False, FindLibrary is used to find the Blas library to be used, as for the other libraries in this file. The difference is that the name of the .a, .so or .dylib is not known, so it must be given in BLAS_LIB_NAME field. For instance openblas to find libopenblas.a in BLAS_LIB_DIR.")
set(BLAS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openblas/lib CACHE STRING "None or path to the lib directory of Blas (see BLAS_CUSTOM_LINKER).")
set(BLAS_LIB openblas CACHE STRING "Name of the Blas lib (e.g. openblas) or command to pass if custom linker is used; see BLAS_CUSTOM_LINKER." )
set(PETSC_DEBUG_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/debug/include CACHE PATH "Include directory of Petsc library specific to debug configuration.")
set(PETSC_RELEASE_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/release/include CACHE PATH "Include directory of Petsc library specific to release configuration.")
set(PETSC_DEBUG_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/debug/lib CACHE PATH "Library directory of Petsc in debug mode.")
set(PETSC_RELEASE_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/release/lib CACHE PATH "Library directory of Petsc in release mode.")
set(PARMETIS_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/include CACHE PATH "Include directory of Parmetis library.")
set(PARMETIS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/lib CACHE PATH "Lib directory of Parmetis library.")
# Lua library.
set(LUA_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/include CACHE PATH "Include directory of Lua library.")
set(LUA_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/lib CACHE PATH "Lib directory of Lua library.")
set(BOOST_DEBUG_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/debug/include CACHE PATH "Include directory of Boost library.")
set(BOOST_DEBUG_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/debug/lib CACHE PATH "Lib directory of Boost library.")
set(BOOST_RELEASE_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/release/include CACHE PATH "Include directory of Boost library.")
set(BOOST_RELEASE_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/release/lib CACHE PATH "Lib directory of Boost library.")
set(PHILLIPS_DIR False CACHE BOOL "If you want to couple Morefem with Phillips library. False in most of the cases! Beware: it is not put in MOREFEM_COMMON_DEP; if you need it you must add it in your add_executable command.")
set(CMAKE_INSTALL_PREFIX /placeholder_value CACHE PATH "Installation directory for executables and libraries. A MoReFEM folder will be created there when install is invoked. This value should be overridden in command line!")
set(MOREFEM_THIRD_PARTY_LIBRARIES_DIR /Volumes/Data/opt)
set(MOREFEM_THIRD_PARTY_LIBRARIES_DIR /Volumes/Data/opt/clang_debug CACHE STRING "Path to third party directory")
set(MOREFEM_ASAN False CACHE BOOL "If true address sanitizer is enabled.")
set(CMAKE_C_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpicc CACHE FILEPATH "C compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_COMPILER ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/bin/mpic++ CACHE FILEPATH "C++ compiler. Prefer to use an openmpi wrapper.")
set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard; at least 17 is expected.")
set(CMAKE_CXX_STANDARD_REQUIRED ON CACHE STRING "Leave this one active.")
set(CMAKE_CXX_EXTENSIONS OFF CACHE STRING "If ON you might be using gnu++17; with OFF you'll use c++17.")
......@@ -21,35 +18,11 @@ set(MOREFEM_EXTENDED_TIME_KEEP False CACHE BOOL "If true, TimeKeep gains the abi
set(MOREFEM_NO_TRAP_SNES_EXCEPTION False CACHE BOOL "If true, exceptions aren't caught in the three SNES functions I have to define for a Petsc Newton (at least the default ones; if you define your own it's up to you to introduce the macro in your code). If not caught, an eventual exception will be written properly but the exception is not guaranteed to be caught and it might result in a rather messy output. I therefore advise not to set it to True in debug mode; in release mode it is ok to do so as such exceptios are rare.")
set(OPEN_MPI_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/include CACHE PATH "Include directory of Openmpi library.")
set(OPEN_MPI_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Openmpi/lib CACHE PATH "Lib directory of Openmpi library." )
set(BLAS_CUSTOM_LINKER True CACHE BOOL "If BLAS_CUSTOM_LINKER is true, BLAS_LIB field must give the command use to link with Blas. For instance on macOS it is usually \"-framework Accelerate\" (Beware: Without the quotes CMake will mute this into -framework -Accelerate). If False, FindLibrary is used to find the Blas library to be used, as for the other libraries in this file. The difference is that the name of the .a, .so or .dylib is not known, so it must be given in BLAS_LIB_NAME field. For instance openblas to find libopenblas.a in BLAS_LIB_DIR.")
set(BLAS_LIB_DIR None CACHE STRING "None or path to the lib directory of Blas (see BLAS_CUSTOM_LINKER).")
set(BLAS_LIB "-framework Accelerate" CACHE STRING "Name of the Blas lib (e.g. openblas) or command to pass if custom linker is used; see BLAS_CUSTOM_LINKER." )
set(PETSC_GENERAL_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/include CACHE PATH "Include directory of Petsc library common to any build.")
set(PETSC_DEBUG_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/debug/include CACHE PATH "Include directory of Petsc library specific to debug configuration.")
set(PETSC_RELEASE_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/release/include CACHE PATH "Include directory of Petsc library specific to release configuration.")
set(PETSC_DEBUG_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/debug/lib CACHE PATH "Library directory of Petsc in debug mode.")
set(PETSC_RELEASE_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Petsc/release/lib CACHE PATH "Library directory of Petsc in release mode.")
set(PARMETIS_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/include CACHE PATH "Include directory of Parmetis library.")
set(PARMETIS_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Parmetis/lib CACHE PATH "Lib directory of Parmetis library.")
# Lua library.
set(LUA_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/include CACHE PATH "Include directory of Lua library.")
set(LUA_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Lua/lib CACHE PATH "Lib directory of Lua library.")
set(BOOST_DEBUG_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/debug/include CACHE PATH "Include directory of Boost library.")
set(BOOST_DEBUG_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/debug/lib CACHE PATH "Lib directory of Boost library.")
set(BOOST_RELEASE_INCL_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/release/include CACHE PATH "Include directory of Boost library.")
set(BOOST_RELEASE_LIB_DIR ${MOREFEM_THIRD_PARTY_LIBRARIES_DIR}/Boost/release/lib CACHE PATH "Lib directory of Boost library.")
set(PHILLIPS_DIR False CACHE BOOL "If you want to couple Morefem with Phillips library. False in most of the cases! Beware: it is not put in MOREFEM_COMMON_DEP; if you need it you must add it in your add_executable command.")
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