Commit fcff6be8 authored by GILLES Sebastien's avatar GILLES Sebastien

#1217 CMake: add a new custom function to handle shared libraries...

#1217 CMake: add a new custom function to handle shared libraries installation, and deploy it for all executables and librairies (except EnsightOutput ones not yet used).
parent 5e6891ca
......@@ -69,11 +69,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
MESSAGE("Module path: ${CMAKE_MODULE_PATH}")
include(CustomCommands)
include(cmake/CustomCommands.cmake)
# All --all_load in target_link_libraries of executables if STATIC library are chose.
......@@ -87,7 +83,7 @@ endif()
MESSAGE("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}")
include(compiler)
include(cmake/Compiler.cmake)
# Add LTO support in non debug mode.
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
......
......@@ -20,5 +20,5 @@ target_link_libraries(MoReFEM4elasticity_lib
add_executable(MoReFEM4elasticity ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4elasticity
MoReFEM4elasticity_lib)
\ No newline at end of file
morefem_install(MoReFEM4elasticity MoReFEM4elasticity_lib)
......@@ -21,11 +21,4 @@ add_executable(MoReFEM4heat ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4heat
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
morefem_install(MoReFEM4heat MoReFEM4heat_lib)
\ No newline at end of file
......@@ -20,5 +20,5 @@ target_link_libraries(MoReFEM4hyperelasticity_lib
add_executable(MoReFEM4hyperelasticity ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4hyperelasticity
MoReFEM4hyperelasticity_lib)
\ No newline at end of file
morefem_install(MoReFEM4hyperelasticity MoReFEM4hyperelasticity_lib)
......@@ -21,4 +21,5 @@ add_executable(MoReFEM4laplacian ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4laplacian
MoReFEM4laplacian_lib)
morefem_install(MoReFEM4laplacian MoReFEM4laplacian_lib)
\ No newline at end of file
add_library(morefem_rivlin_cube_lib ${LIBRARY_TYPE} "")
add_library(MoReFEM4RivlinCube_lib ${LIBRARY_TYPE} "")
target_sources(morefem_rivlin_cube_lib
target_sources(MoReFEM4RivlinCube_lib
PRIVATE
"${CMAKE_CURRENT_LIST_DIR}/Model.cpp" /
"${CMAKE_CURRENT_LIST_DIR}/VariationalFormulation.cpp"
......@@ -12,13 +12,13 @@ target_sources(morefem_rivlin_cube_lib
"${CMAKE_CURRENT_LIST_DIR}/VariationalFormulation.hxx"
)
target_link_libraries(morefem_rivlin_cube_lib
target_link_libraries(MoReFEM4RivlinCube_lib
${MOREFEM_MODEL}
${ALL_LOAD_FLAG})
add_executable(morefem_rivlin_cube ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(morefem_rivlin_cube
morefem_rivlin_cube_lib)
add_executable(MoReFEM4RivlinCube ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4RivlinCube
MoReFEM4RivlinCube_lib)
\ No newline at end of file
morefem_install(MoReFEM4RivlinCube MoReFEM4RivlinCube_lib)
\ No newline at end of file
......@@ -21,4 +21,4 @@ add_executable(MoReFEM4stokes ${CMAKE_CURRENT_LIST_DIR}/main.cpp)
target_link_libraries(MoReFEM4stokes
MoReFEM4stokes_lib)
\ No newline at end of file
morefem_install(MoReFEM4stokes MoReFEM4stokes_lib)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestVariableTimeStep
)
target_link_libraries(MoReFEMTestVariableTimeStep
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEM_test_tools)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestColoring
)
target_link_libraries(MoReFEMTestColoring
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestColoring)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestCoordsInParallel
)
target_link_libraries(MoReFEMTestCoordsInParallel
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestCoordsInParallel)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestDomainListInCoords
)
target_link_libraries(MoReFEMTestDomainListInCoords
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestDomainListInCoords)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestLightweightDomainList
)
target_link_libraries(MoReFEMTestLightweightDomainList
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestLightweightDomainList)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestMovemesh
)
target_link_libraries(MoReFEMTestMovemesh
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestMovemesh)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestNcoordInDomain
)
target_link_libraries(MoReFEMTestNcoordInDomain
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestNcoordInDomain)
\ No newline at end of file
......@@ -10,4 +10,6 @@ add_executable(MoReFEMTestOndomatic
)
target_link_libraries(MoReFEMTestOndomatic
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestOndomatic)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestConformProjector
)
target_link_libraries(MoReFEMTestConformProjector
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestConformProjector)
\ No newline at end of file
......@@ -17,4 +17,6 @@ add_executable(MoReFEMTestP1_to_P2
)
target_link_libraries(MoReFEMTestP1_to_P2
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestP1_to_P2 MoReFEMTestP1_to_P1b)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestParameterAtDof
)
target_link_libraries(MoReFEMTestParameterAtDof
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestParameterAtDof)
\ No newline at end of file
......@@ -7,4 +7,6 @@ add_executable(MoReFEMTestParameterTimeDependancy
)
target_link_libraries(MoReFEMTestParameterTimeDependancy
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestParameterTimeDependancy)
\ No newline at end of file
......@@ -4,4 +4,6 @@ add_executable(MoReFEMTestMpiErrorHandling
)
target_link_libraries(MoReFEMTestMpiErrorHandling
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestMpiErrorHandling)
\ No newline at end of file
......@@ -4,4 +4,6 @@ add_executable(MoReFEMTestMpiFunctions
)
target_link_libraries(MoReFEMTestMpiFunctions
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestMpiFunctions)
\ No newline at end of file
......@@ -12,4 +12,6 @@ add_executable(MoReFEMTestMpiSendReceiveArray
)
target_link_libraries(MoReFEMTestMpiSendReceiveArray
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestMpiSendReceiveSingleValue MoReFEMTestMpiSendReceiveArray)
\ No newline at end of file
......@@ -7,4 +7,6 @@ target_sources(MoReFEM_test_tools
"${CMAKE_CURRENT_LIST_DIR}/TestLinearAlgebra.hxx" /
)
target_link_libraries(MoReFEM_test_tools ${MOREFEM_MODEL})
\ No newline at end of file
target_link_libraries(MoReFEM_test_tools ${MOREFEM_MODEL})
morefem_install(MoReFEM_test_tools)
\ No newline at end of file
......@@ -4,4 +4,6 @@ add_executable(MoReFEMTestInputParameterList
)
target_link_libraries(MoReFEMTestInputParameterList
${MOREFEM_MODEL})
\ No newline at end of file
${MOREFEM_MODEL})
morefem_install(MoReFEMTestInputParameterList)
\ No newline at end of file
......@@ -62,6 +62,27 @@ function(morefem_library_module _alias _module)
endfunction()
# ##########################################################################################
# A wrapper over install() command which performs the following additional tasks:
# - If the target is an executable, call set_target_properties() to properly define RPATH for the target. This is r
# required at least for shared libraries on macOS.
# - Install the targets in the MoReFEM installation directories.
# ##########################################################################################
function(morefem_install)
foreach(target ${ARGN})
get_target_property(target_type ${target} TYPE)
if (target_type STREQUAL "EXECUTABLE")
# Additional step to make shared library work on macOS; see https://gist.github.com/robertmaynard/5750737
set_target_properties(${target} PROPERTIES INSTALL_RPATH "@loader_path/../lib")
endif ()
install(TARGETS ${target}
RUNTIME DESTINATION ${MOREFEM_INSTALL_DIR_EXE}
LIBRARY DESTINATION ${MOREFEM_INSTALL_DIR_LIB}
ARCHIVE DESTINATION ${MOREFEM_INSTALL_DIR_LIB})
endforeach()
endfunction()
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