Commit 782e445c authored by GILLES Sebastien's avatar GILLES Sebastien

#1342 Prepare a Python script which generated the and actual pre-cache file...

#1342 Prepare a Python script which generated the and actual pre-cache file from a default pre-cache file (provided in the repository) and eventually command-line arguments to superseded those default values.
parent 51bd27b9
......@@ -18,8 +18,6 @@ endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
get_property(MOREFEM_COMPILE_DEFINITIONS DIRECTORY PROPERTY COMPILE_DEFINITIONS)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION False) # Set it true only for the model executables.
......@@ -43,30 +41,6 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/cmake)
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.")
# Relevant only if BLAS_CUSTOM_LINKER is false.
if (NOT ${BLAS_CUSTOM_LINKER})
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).")
endif()
# ===================================================================================================================
# Set project.
# ===================================================================================================================
......
......@@ -138,6 +138,7 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/../../cmake/CustomCommands.cmake
${CMAKE_CURRENT_BINARY_DIR}/../../cmake/MoReFEMSettings.cmake
${CMAKE_CURRENT_BINARY_DIR}/../PreCacheFile.cmake
DESTINATION ${MOREFEM_INSTALL_DIR_CMAKE})
install(EXPORT ${PROJECT_NAME}-targets
......
......@@ -21,4 +21,5 @@ if(NOT TARGET @PROJECT_NAME@)
endif()
include("${CMAKE_CURRENT_LIST_DIR}/CustomCommands.cmake")
endif()
\ No newline at end of file
......@@ -20,6 +20,21 @@ set(MOREFEM_NO_TRAP_SNES_EXCEPTION False CACHE BOOL "If true, exceptions aren't
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 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(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(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.")
......
......@@ -19,9 +19,23 @@ 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(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(BLAS_LIB_DIR None CACHE STRING "None or path to the lib directory of Blas (see BLAS_CUSTOM_LINKER).")
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(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.")
......
This diff is collapsed.
"""
Prepare the CMake command to configure the project, using to sdo so the settings used to compile the MoReFEM library.
"""
import argparse
import os
import subprocess
def cmake_command(args):
"""Generates the cmake command, and either run it or print it depending on no_run_command flag.
\param[in] args: The parsed arguments to the command line.
"""
cmd = "cmake -C {0}/cmake/PreCacheFile.cmake -DMoReFEM_DIR={0}/cmake {1} {2}".format(args.morefem_install_dir,
args.cmake_args, args.root_directory)
if args.no_run_command:
print("The generated CMake command is:\n\n\t{}".format(cmd))
else:
subprocess.Popen(cmd, shell=True).communicate()
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description='Wrapper over the CMake command.')
parser.add_argument(
'--morefem_install_dir',
help=
'The directory where MoReFEM was installed (through for instance "ninja install" command).'
)
parser.add_argument(
'--root_directory',
default="..",
help=
'The path to the root directory of the project (in which the base CMakeLists.txt should be)'
)
parser.add_argument(
'--cmake_args',
help=
"Arguments you would like to give to cmake command, e.g. '-G Ninja ..'. Please use quotes or double quotes if there are several components. You should put there at least the relative path to the root folder."
)
parser.add_argument(
'--no_run_command',
action='store_true',
help=
"If this flag is set, the cmake command is just printed on screen, not run."
)
args = parser.parse_args()
cmake_command(args)
\ No newline at end of file
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