Meta: Fix Lagom RPATH for non-Ubuntu Linux and macOS hosts

Multi-lib distros like Gentoo and Fedora install lagom-core.so into
lagom-install/lib64 rather than lib. Set the install RPATH based on
CMAKE_INSTALL_LIBDIR to avoid the wrong path being set in the binaries.

Also apply macOS specific RPATH rules to fix the build on that platform.
This commit is contained in:
Andrew Kaster 2021-09-15 09:45:49 -06:00 committed by Brian Gianforcaro
parent 951cd68979
commit 04d91e90c2
Notes: sideshowbarker 2024-07-18 03:50:47 +09:00

View file

@ -71,12 +71,19 @@ set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
include(GNUInstallDirs) # make sure to include before we mess w/RPATH
set(CMAKE_SKIP_BUILD_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
# See slide 100 of the following ppt :^)
# https://crascit.com/wp-content/uploads/2019/09/Deep-CMake-For-Library-Authors-Craig-Scott-CppCon-2019.pdf
if (NOT APPLE)
set(CMAKE_INSTALL_RPATH $ORIGIN:$ORIGIN/../lib)
if (APPLE)
# FIXME: This doesn't work for the full BUILD_LAGOM=ON build, see #10055
set(CMAKE_MACOSX_RPATH TRUE)
set(CMAKE_INSTALL_NAME_DIR "@rpath")
set(CMAKE_INSTALL_RPATH "@loader_path/../lib")
else()
set(CMAKE_INSTALL_RPATH "$ORIGIN:$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
@ -129,7 +136,6 @@ include_directories(${CMAKE_CURRENT_BINARY_DIR})
# install rules, think about moving to its own helper cmake file
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
# find_package(<package>) call for consumers to find this project
set(package Lagom)