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

[CMake] Moved packaging executable dependencies to package target.

Beforehand this logic was executed in a forced addional CMake run
everytime after the specific executable was built. Now this is done
at the moment this information is needed (at building the package or
install target).
parent 241195ac
No related branches found
No related tags found
No related merge requests found
......@@ -19,6 +19,9 @@
### Infrastructure
- Added a generic natural boundary condition class. #1337
- Migrated all important Jenkins jobs to script-based [Jenkins Pipeline](https://jenkins.io/doc/pipeline/) functionality (#1392, #1396, #1404, #1411, #1424, #1428, #1436). For an introduction see [docs.opengeosys.org - Continuous Integration](https://docs.opengeosys.org/docs/devguide/development-workflows/continuous-integration)
- Moved CMake logic for packaging executable dependencies (such as shared libs)
to the install and package targets instead of running after each executable
gets build, #1458
### Fixes:
- Fix an issue that a shape vector was defined as a column vector. Corrected to a row vector #1288
......
......@@ -220,3 +220,4 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/BaseLib/BuildInfo.cpp.in"
"${CMAKE_CURRENT_BINARY_DIR}/BaseLib/BuildInfo.cpp" @ONLY)
include(scripts/cmake/MarkVariablesAdvanced.cmake)
include(scripts/cmake/packaging/GetDependencies.cmake)
foreach(TARGET ${INSTALL_DEPENDENCIES})
if(MSVC AND NOT CMAKE_GENERATOR STREQUAL "Ninja" )
if(USE_CONAN)
set(TARGET_EXE ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_BUILD_TYPE}/${TARGET}${CMAKE_EXECUTABLE_SUFFIX})
else()
set(TARGET_EXE ${EXECUTABLE_OUTPUT_PATH}/Release/${TARGET}${CMAKE_EXECUTABLE_SUFFIX})
endif()
else()
set(TARGET_EXE ${EXECUTABLE_OUTPUT_PATH}/${TARGET}${CMAKE_EXECUTABLE_SUFFIX})
endif()
if(EXISTS ${TARGET_EXE})
include(GetPrerequisites)
# arg3: exclude system, arg4: recursive
if (VTK_BUILD_SHARED_LIBS)
list(APPEND dirs ${vtkIOXML_RUNTIME_LIBRARY_DIRS})
endif()
list(APPEND dirs "/usr/local/lib")
get_prerequisites(${TARGET_EXE} TARGET_DEPENDENCIES 1 1 "" ${dirs})
if(PRE_INSTALL_RUN)
message("-- Dependencies of target ${TARGET}:")
endif()
foreach(DEPENDENCY ${TARGET_DEPENDENCIES})
if(NOT ${DEPENDENCY} MATCHES "@loader_path")
gp_resolve_item("${TARGET_EXE}" "${DEPENDENCY}" "" "" DEPENDENCY_PATH)
get_filename_component(RESOLVED_DEPENDENCY_PATH "${DEPENDENCY_PATH}" REALPATH)
string(TOLOWER ${DEPENDENCY} DEPENDENCY_LOWER)
set(DEPENDENCY_PATHS ${DEPENDENCY_PATHS} ${RESOLVED_DEPENDENCY_PATH})
if(PRE_INSTALL_RUN)
message(" ${RESOLVED_DEPENDENCY_PATH}")
endif()
endif()
endforeach()
if(PRE_INSTALL_RUN)
message("")
endif()
install(FILES ${DEPENDENCY_PATHS} DESTINATION bin COMPONENT ${INSTALL_COMPONENT})
endif()
endforeach()
unset(PRE_INSTALL_RUN CACHE)
# Registers a target for installing its dependencies (dll / so files)
macro(InstallDependencies TARGET INSTALL_COMPONENT)
if(MSVC AND NOT CMAKE_GENERATOR STREQUAL "Ninja" )
set(TARGET_EXE ${EXECUTABLE_OUTPUT_PATH}/Release/${TARGET}${CMAKE_EXECUTABLE_SUFFIX})
else()
set(TARGET_EXE ${EXECUTABLE_OUTPUT_PATH}/${TARGET}${CMAKE_EXECUTABLE_SUFFIX})
endif()
if(EXISTS ${TARGET_EXE})
include(GetPrerequisites)
# arg3: exclude system, arg4: recursive
if (VTK_BUILD_SHARED_LIBS)
list(APPEND dirs ${vtkIOXML_RUNTIME_LIBRARY_DIRS})
endif()
list(APPEND dirs "/usr/local/lib")
get_prerequisites(${TARGET_EXE} TARGET_DEPENDENCIES 1 1 "" ${dirs})
message(STATUS "${TARGET_EXE} dependencies:")
foreach(DEPENDENCY ${TARGET_DEPENDENCIES})
if(NOT ${DEPENDENCY} MATCHES "@loader_path")
gp_resolve_item("${TARGET_EXE}" "${DEPENDENCY}" "" "" DEPENDENCY_PATH)
get_filename_component(RESOLVED_DEPENDENCY_PATH "${DEPENDENCY_PATH}" REALPATH)
string(TOLOWER ${DEPENDENCY} DEPENDENCY_LOWER)
set(DEPENDENCY_PATHS ${DEPENDENCY_PATHS} ${RESOLVED_DEPENDENCY_PATH})
message(" ${RESOLVED_DEPENDENCY_PATH}")
endif()
endforeach()
install(FILES ${DEPENDENCY_PATHS} DESTINATION bin COMPONENT ${INSTALL_COMPONENT})
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ;)
else()
# Run CMake after target was built to run GetPrerequisites on executable
add_custom_command(TARGET ${TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND}
ARGS ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR} VERBATIM)
endif()
set(INSTALL_DEPENDENCIES "${INSTALL_DEPENDENCIES};${TARGET}" CACHE INTERNAL "")
endmacro()
......@@ -100,3 +100,14 @@ cpack_add_component(ogs_docs
DESCRIPTION "PDF documentation."
GROUP Utilities
)
# Clear cache variable holding all targets to install dependencies for.
set(INSTALL_DEPENDENCIES "" CACHE INTERNAL "")
# Rerun CMake on install
install(CODE "\
message(STATUS \"Rerunning CMake for getting executable dependencies.\")\n \
execute_process(COMMAND ${CMAKE_COMMAND} \
ARGS ${CMAKE_SOURCE_DIR} -DPRE_INSTALL_RUN=ON \
WORKING_DIRECTORY ${CMAKE_BINARY_DIR} OUTPUT_QUIET)"
)
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