[cmake] fix RPATH configuration

* ConfigureRPATH must use option or cache variables (visibility scope)
* include CommonConfigOptions (and with it ConfigureRPATH) only after
  all required variables have been defined
This commit is contained in:
akallabeth 2024-03-11 19:45:11 +01:00 committed by Martin Fleisz
parent 47354c4519
commit 44c86c8049
2 changed files with 16 additions and 12 deletions

View File

@ -58,7 +58,6 @@ endif()
# Include our extra modules # Include our extra modules
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/) list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)
include(CommonConfigOptions)
if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0")) if((CMAKE_SYSTEM_NAME MATCHES "WindowsStore") AND (CMAKE_SYSTEM_VERSION MATCHES "10.0"))
set(UWP 1) set(UWP 1)
@ -727,10 +726,6 @@ else()
set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}") set(FREERDP_PROXY_PLUGINDIR "${PROXY_PLUGINDIR}")
endif() endif()
if (BUILD_SHARED_LIBS)
set(CMAKE_MACOSX_RPATH ON)
endif()
# Android profiling # Android profiling
if(ANDROID) if(ANDROID)
if(WITH_GPROF) if(WITH_GPROF)
@ -755,6 +750,8 @@ if(BUILD_TESTING)
endif() endif()
endif() endif()
include(CommonConfigOptions)
# WinPR # WinPR
# We want to control the winpr assert for the whole project # We want to control the winpr assert for the whole project
option(WITH_VERBOSE_WINPR_ASSERT "Compile with verbose WINPR_ASSERT." ON) option(WITH_VERBOSE_WINPR_ASSERT "Compile with verbose WINPR_ASSERT." ON)

View File

@ -1,18 +1,25 @@
# RPATH configuration # RPATH configuration
set(CMAKE_SKIP_BUILD_RPATH FALSE) option(CMAKE_SKIP_BUILD_RPATH "skip build RPATH" OFF)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) option(CMAKE_BUILD_WITH_INSTALL_RPATH "build with install RPATH" OFF)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) option(CMAKE_INSTALL_RPATH_USE_LINK_PATH "build with link RPATH" OFF)
if (BUILD_SHARED_LIBS)
option(CMAKE_MACOSX_RPATH "MacOSX RPATH" ON)
endif()
if (APPLE) if (APPLE)
file(RELATIVE_PATH FRAMEWORK_PATH ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_LIBDIR}) file(RELATIVE_PATH FRAMEWORK_PATH ${CMAKE_INSTALL_FULL_BINDIR} ${CMAKE_INSTALL_FULL_LIBDIR})
set(CMAKE_INSTALL_RPATH "@loader_path/${FRAMEWORK_PATH}") set(CFG_INSTALL_RPATH "@loader_path/${FRAMEWORK_PATH}")
else (APPLE) else (APPLE)
if (NOT FREEBSD) if (NOT FREEBSD)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..")
option(WITH_ADD_PLUGIN_TO_RPATH "Add extension and plugin path to RPATH" OFF) option(WITH_ADD_PLUGIN_TO_RPATH "Add extension and plugin path to RPATH" OFF)
if (WITH_ADD_PLUGIN_TO_RPATH) if (WITH_ADD_PLUGIN_TO_RPATH)
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${FREERDP_EXTENSION_REL_PATH}:\$ORIGIN/../${FREERDP_PLUGIN_PATH}:${CMAKE_INSTALL_RPATH}") set(CFG_INSTALL_RPATH "\$ORIGIN/../${FREERDP_EXTENSION_REL_PATH}:\$ORIGIN/../${FREERDP_PLUGIN_PATH}:\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..")
else()
set(CFG_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:\$ORIGIN/..")
endif() endif()
endif() endif()
endif(APPLE) endif(APPLE)
set(CMAKE_INSTALL_RPATH ${CFG_INSTALL_RPATH} CACHE INTERNAL "ConfigureRPATH")
message("Configured RPATH=${CMAKE_INSTALL_RPATH}")