Commit 5e6891ca authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

#1217 CMake: add the install command and make sure it works for shared...

#1217 CMake: add the install command and make sure it works for shared libraries as well. Currently done only for Heat; next commit will add it for all targets.
parent 76cf4c38
...@@ -65,7 +65,6 @@ project( "MoReFEM_CMAKE") ...@@ -65,7 +65,6 @@ project( "MoReFEM_CMAKE")
set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
...@@ -76,8 +75,6 @@ MESSAGE("Module path: ${CMAKE_MODULE_PATH}") ...@@ -76,8 +75,6 @@ MESSAGE("Module path: ${CMAKE_MODULE_PATH}")
include(CustomCommands) include(CustomCommands)
# All --all_load in target_link_libraries of executables if STATIC library are chose. # All --all_load in target_link_libraries of executables if STATIC library are chose.
if(LIBRARY_TYPE MATCHES STATIC) if(LIBRARY_TYPE MATCHES STATIC)
...@@ -111,7 +108,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources / ...@@ -111,7 +108,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/Sources /
${BOOST_INCL_DIR} ${BOOST_INCL_DIR}
) )
# TO complete for release mode! (see SCons) # To complete for release mode! (see SCons)
add_definitions(-DOPS_WITH_EXCEPTION) add_definitions(-DOPS_WITH_EXCEPTION)
add_definitions(-DSELDON_WITH_LAPACK -DSELDON_WITH_LAPACK -DSELDON_WITH_BLAS -DSELDON_WITH_COMPILED_LIBRARY -DSELDON_CHECK_BOUNDS -DSELDON_CHECK_DIMENSIONS) add_definitions(-DSELDON_WITH_LAPACK -DSELDON_WITH_LAPACK -DSELDON_WITH_BLAS -DSELDON_WITH_COMPILED_LIBRARY -DSELDON_CHECK_BOUNDS -DSELDON_CHECK_DIMENSIONS)
...@@ -138,14 +135,39 @@ set(MOREFEM_COMMON_DEP ...@@ -138,14 +135,39 @@ set(MOREFEM_COMMON_DEP
${LIB_OPEN_MPI} ${LIB_OPEN_MPI}
${LIB_OPEN_MPI_CXX} ${LIB_OPEN_MPI_CXX}
${LIB_PETSC} ${LIB_PETSC}
${LIB_PARMETIS} ${LIB_PARMETIS}
${LIB_LUA}
${LIB_BOOST_FILESYSTEM} ${LIB_BOOST_FILESYSTEM}
${LIB_BOOST_SYSTEM} ${LIB_BOOST_SYSTEM}
${LIB_BLAS} ${LIB_BLAS}
) )
set(MOREFEM_INSTALL_DIR_EXE ${MOREFEM_INSTALL_DIR}/bin)
set(MOREFEM_INSTALL_DIR_LIB ${MOREFEM_INSTALL_DIR}/lib)
######################################################
# Settings to make shared library work correctly
######################################################
#SET(CMAKE_INSTALL_RPATH "/Volumes/Data/sebastien/Morefem/CMake/lib")
set(CMAKE_MACOSX_RPATH True)
# use, i.e. don't skip the full RPATH for the build tree
set(CMAKE_SKIP_BUILD_RPATH False)
# when building, don't use the install RPATH already
# (but later on when installing)
set(CMAKE_BUILD_WITH_INSTALL_RPATH False)
set(CMAKE_INSTALL_RPATH "${MOREFEM_INSTALL_DIR}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH True)
######################################################
# Walk through Sources directory to find all sources to build.
######################################################
add_subdirectory(Sources) add_subdirectory(Sources)
......
...@@ -35,7 +35,6 @@ include(ThirdParty/Ops.cmake) ...@@ -35,7 +35,6 @@ include(ThirdParty/Ops.cmake)
include(ThirdParty/Seldon.cmake) include(ThirdParty/Seldon.cmake)
include(ThirdParty/Source/CMakeLists.txt) include(ThirdParty/Source/CMakeLists.txt)
include(Core/SourceList.cmake) include(Core/SourceList.cmake)
include(Geometry/SourceList.cmake) include(Geometry/SourceList.cmake)
...@@ -54,7 +53,29 @@ include(FormulationSolver/SourceList.cmake) ...@@ -54,7 +53,29 @@ include(FormulationSolver/SourceList.cmake)
include(Model/SourceList.cmake) include(Model/SourceList.cmake)
if (BUILD_MOREFEM_UNIQUE_LIBRARY)
install(TARGETS morefem
RUNTIME DESTINATION ${MOREFEM_INSTALL_DIR_EXE}
LIBRARY DESTINATION ${MOREFEM_INSTALL_DIR_LIB}
ARCHIVE DESTINATION ${MOREFEM_INSTALL_DIR_LIB})
else()
install(TARGETS morefem_utilities morefem_core morefem_geometry morefem_felt morefem_param morefem_op morefem_param_instances morefem_op_instances morefem_formulation_solver morefem_model
RUNTIME DESTINATION ${MOREFEM_INSTALL_DIR_EXE}
LIBRARY DESTINATION ${MOREFEM_INSTALL_DIR_LIB}
ARCHIVE DESTINATION ${MOREFEM_INSTALL_DIR_LIB})
endif()
include(PostProcessing/CMakeLists.txt) include(PostProcessing/CMakeLists.txt)
include(ModelInstances/CMakeLists.txt) include(ModelInstances/CMakeLists.txt)
include(Test/CMakeLists.txt) include(Test/CMakeLists.txt)
\ No newline at end of file
# How to get tge list of files related to a library. But XCode project built is unstable; something is probably amiss in what I do.
# get_property(core_sources TARGET ${MOREFEM_CORE} PROPERTY SOURCES)
# string(REPLACE "//" " /" core_sources ${core_sources})
# source_group(TREE ${CMAKE_CURRENT_LIST_DIR}/Core FILES ${core_sources})
...@@ -17,3 +17,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/LinearAlgebra/SourceList.cmake) ...@@ -17,3 +17,4 @@ include(${CMAKE_CURRENT_LIST_DIR}/LinearAlgebra/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/InputParameterData/SourceList.cmake) include(${CMAKE_CURRENT_LIST_DIR}/InputParameterData/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/InputParameter/SourceList.cmake) include(${CMAKE_CURRENT_LIST_DIR}/InputParameter/SourceList.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/TimeManager/SourceList.cmake) include(${CMAKE_CURRENT_LIST_DIR}/TimeManager/SourceList.cmake)
add_library(MoReFEM4elasticity_lib STATIC "") add_library(MoReFEM4elasticity_lib ${LIBRARY_TYPE} "")
target_sources(MoReFEM4elasticity_lib target_sources(MoReFEM4elasticity_lib
PRIVATE PRIVATE
......
add_library(MoReFEM4heat_lib STATIC "") add_library(MoReFEM4heat_lib ${LIBRARY_TYPE} "")
target_sources(MoReFEM4heat_lib target_sources(MoReFEM4heat_lib
PRIVATE PRIVATE
...@@ -20,5 +20,12 @@ target_link_libraries(MoReFEM4heat_lib ...@@ -20,5 +20,12 @@ target_link_libraries(MoReFEM4heat_lib
add_executable(MoReFEM4heat ${CMAKE_CURRENT_LIST_DIR}/main.cpp) add_executable(MoReFEM4heat ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4heat target_link_libraries(MoReFEM4heat
MoReFEM4heat_lib) MoReFEM4heat_lib)
# Additional step to make shared library work on macOS; see https://gist.github.com/robertmaynard/5750737
set_target_properties(MoReFEM4heat PROPERTIES INSTALL_RPATH "@loader_path/../lib")
install(TARGETS MoReFEM4heat MoReFEM4heat_lib
RUNTIME DESTINATION ${MOREFEM_INSTALL_DIR_EXE}
LIBRARY DESTINATION ${MOREFEM_INSTALL_DIR_LIB}
ARCHIVE DESTINATION ${MOREFEM_INSTALL_DIR_LIB})
\ No newline at end of file
...@@ -67,7 +67,7 @@ Unknown1 = { ...@@ -67,7 +67,7 @@ Unknown1 = {
Mesh1 = { Mesh1 = {
-- Input Mesh file name -- Input Mesh file name
-- Expected format: "VALUE" -- Expected format: "VALUE"
mesh = "${HOME}/Codes/MoReFEM/Data/Mesh/heat_bar.mesh", mesh = "${HOME}/Codes/MoReFEM/CoreLibrary/Data/Mesh/heat_bar.mesh",
-- Format of the input mesh. -- Format of the input mesh.
-- Expected format: "VALUE" -- Expected format: "VALUE"
......
add_library(MoReFEM4hyperelasticity_lib STATIC "") add_library(MoReFEM4hyperelasticity_lib ${LIBRARY_TYPE} "")
target_sources(MoReFEM4hyperelasticity_lib target_sources(MoReFEM4hyperelasticity_lib
PRIVATE PRIVATE
......
add_library(MoReFEM4laplacian_lib STATIC "") add_library(MoReFEM4laplacian_lib ${LIBRARY_TYPE} "")
target_sources(MoReFEM4laplacian_lib target_sources(MoReFEM4laplacian_lib
PRIVATE PRIVATE
......
add_library(morefem_rivlin_cube_lib STATIC "") add_library(morefem_rivlin_cube_lib ${LIBRARY_TYPE} "")
target_sources(morefem_rivlin_cube_lib target_sources(morefem_rivlin_cube_lib
PRIVATE PRIVATE
......
add_library(MoReFEM4stokes_lib STATIC "") add_library(MoReFEM4stokes_lib ${LIBRARY_TYPE} "")
target_sources(MoReFEM4stokes_lib target_sources(MoReFEM4stokes_lib
PRIVATE PRIVATE
......
add_library(MoReFEM_test_tools ${LIBRARY_TYPE} "") add_library(MoReFEM_test_tools ${LIBRARY_TYPE} "")
include(${CMAKE_CURRENT_LIST_DIR}/Tools/CMakeLists.txt) include(${CMAKE_CURRENT_LIST_DIR}/Tools/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/Utilities/CMakeLists.txt) include(${CMAKE_CURRENT_LIST_DIR}/Utilities/CMakeLists.txt)
......
...@@ -5,4 +5,6 @@ target_sources(MoReFEM_test_tools ...@@ -5,4 +5,6 @@ target_sources(MoReFEM_test_tools
PUBLIC PUBLIC
"${CMAKE_CURRENT_LIST_DIR}/TestLinearAlgebra.hpp" / "${CMAKE_CURRENT_LIST_DIR}/TestLinearAlgebra.hpp" /
"${CMAKE_CURRENT_LIST_DIR}/TestLinearAlgebra.hxx" / "${CMAKE_CURRENT_LIST_DIR}/TestLinearAlgebra.hxx" /
) )
\ No newline at end of file
target_link_libraries(MoReFEM_test_tools ${MOREFEM_MODEL})
\ No newline at end of file
...@@ -10,4 +10,11 @@ target_sources(Ops ...@@ -10,4 +10,11 @@ target_sources(Ops
# Suppress all warnings from this third party library. PRIVATE is important not to propagate that to the MoReFEM libraries! # Suppress all warnings from this third party library. PRIVATE is important not to propagate that to the MoReFEM libraries!
target_compile_options(Ops PRIVATE -w) target_compile_options(Ops PRIVATE -w)
target_link_libraries(Ops ${LIB_LUA})
install(TARGETS Ops
RUNTIME DESTINATION ${MOREFEM_INSTALL_DIR_EXE}
LIBRARY DESTINATION ${MOREFEM_INSTALL_DIR_LIB}
ARCHIVE DESTINATION ${MOREFEM_INSTALL_DIR_LIB})
target_link_libraries(${MOREFEM_UTILITIES} Ops) target_link_libraries(${MOREFEM_UTILITIES} Ops)
\ No newline at end of file
...@@ -11,4 +11,9 @@ target_sources(Seldon ...@@ -11,4 +11,9 @@ target_sources(Seldon
# Suppress all warnings from this third party library. PRIVATE is important not to propagate that to the MoReFEM libraries! # Suppress all warnings from this third party library. PRIVATE is important not to propagate that to the MoReFEM libraries!
target_compile_options(Seldon PRIVATE -w) target_compile_options(Seldon PRIVATE -w)
install(TARGETS Seldon
RUNTIME DESTINATION ${MOREFEM_INSTALL_DIR_EXE}
LIBRARY DESTINATION ${MOREFEM_INSTALL_DIR_LIB}
ARCHIVE DESTINATION ${MOREFEM_INSTALL_DIR_LIB})
target_link_libraries(${MOREFEM_UTILITIES} Seldon) target_link_libraries(${MOREFEM_UTILITIES} Seldon)
\ No newline at end of file
...@@ -41,7 +41,6 @@ function(morefem_find_library _macro _libnames _dir _name) ...@@ -41,7 +41,6 @@ function(morefem_find_library _macro _libnames _dir _name)
endfunction() endfunction()
# ########################################################################################## # ##########################################################################################
# #
# Set the alias related to a module depending on the value of BUILD_MOREFEM_UNIQUE_LIBRARY: # Set the alias related to a module depending on the value of BUILD_MOREFEM_UNIQUE_LIBRARY:
...@@ -63,3 +62,6 @@ function(morefem_library_module _alias _module) ...@@ -63,3 +62,6 @@ function(morefem_library_module _alias _module)
endfunction() endfunction()
# Installation directory for executables and libraries.
set(MOREFEM_INSTALL_DIR /Volumes/Data/sebastien/Morefem/CMake/)
# Choose C and C++ compilers. You might also specifies here clang static analyzer (paths to ccc-analyzer and c++-analyzer respectively) to perform static analysis of the code. # Choose C and C++ compilers. You might also specifies here clang static analyzer (paths to ccc-analyzer and c++-analyzer respectively) to perform static analysis of the code.
# Attention: those will be used only if user does not supersede them by prioviding -DCMAKE_C_COMPILER or -DCMAKE_CXX_COMPILER on command line! # Attention: those will be used only if user does not supersede them by prioviding -DCMAKE_C_COMPILER or -DCMAKE_CXX_COMPILER on command line!
set(MPI_CC /Users/Shared/LibraryVersions/clang/Openmpi/bin/mpicc ) set(MPI_CC /Users/Shared/LibraryVersions/clang/Openmpi/bin/mpicc )
......
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