Skip to content

Commit

Permalink
Only add relevant directories to flatzinc library/executable RUNPATHs
Browse files Browse the repository at this point in the history
The flatzinc library is installed to the same location (LIBDIR) as the
ortools library, so "$ORIGIN" suffices.
The executables should use the relative path between LIBDIR and BINDIR.
  • Loading branch information
StefanBruens committed Jul 15, 2022
1 parent 62108fa commit a19c84f
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions cmake/flatzinc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ target_compile_options(flatzinc PUBLIC ${FLATZINC_COMPILE_OPTIONS})
## Properties
if(NOT APPLE)
set_target_properties(flatzinc PROPERTIES VERSION ${PROJECT_VERSION})
if(UNIX)
set_target_properties(flatzinc PROPERTIES INSTALL_RPATH "$ORIGIN")
endif()
else()
# Clang don't support version x.y.z with z > 255
set_target_properties(flatzinc PROPERTIES
Expand All @@ -115,14 +118,6 @@ endif()
add_library(${PROJECT_NAMESPACE}::flatzinc ALIAS flatzinc)


if(APPLE)
set(CMAKE_INSTALL_RPATH
"@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN/../lib64:$ORIGIN/../lib:$ORIGIN")
endif()


# fzn-ortools Binary
add_executable(fzn
ortools/flatzinc/fz.cc
Expand All @@ -146,6 +141,17 @@ target_compile_options(fzn PUBLIC ${FLATZINC_COMPILE_OPTIONS})
target_link_libraries(fzn PRIVATE ${PROJECT_NAMESPACE}::flatzinc)
## Alias
add_executable(${PROJECT_NAME}::fzn ALIAS fzn)
## INSTALL_RPATH
if(APPLE)
set_target_properties(fzn PROPERTIES
INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
elseif(UNIX)
cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
BASE_DIRECTORY ${CMAKE_INSTALL_FULL_BINDIR}
OUTPUT_VARIABLE libdir_relative_path)
set_target_properties(fzn PROPERTIES
INSTALL_RPATH "$ORIGIN/${libdir_relative_path}")
endif()


# Parser-main Binary
Expand Down

0 comments on commit a19c84f

Please sign in to comment.