Use relative rpath, force relative rpath for older CMake versions

This allows you to copy around the built binaries together with the
binaries.
This commit is contained in:
heinrich5991 2020-03-14 01:48:45 +01:00
parent 2574c060e4
commit bda3adabcc

View file

@ -1151,6 +1151,14 @@ target_link_libraries(${TARGET_SERVER} ${LIBS_SERVER})
list(APPEND TARGETS_OWN ${TARGET_SERVER}) list(APPEND TARGETS_OWN ${TARGET_SERVER})
list(APPEND TARGETS_LINK ${TARGET_SERVER}) list(APPEND TARGETS_LINK ${TARGET_SERVER})
if(ANTIBOT)
if(CMAKE_VERSION VERSION_LESS 3.14 AND (CMAKE_VERSION VERSION_GREATER 3.8 OR CMAKE_VERSION VERSION_EQUAL 3.8))
set_property(TARGET ${TARGET_SERVER} PROPERTY BUILD_RPATH "$ORIGIN")
else()
message(STATUS "Can't set BUILD_RPATH in CMake before 3.8, pass -Wl,-rpath,'$ORIGIN' manually if you wish to emulate this. Or just install a newer version of CMake...")
endif()
endif()
if(TARGET_OS AND TARGET_OS STREQUAL "mac") if(TARGET_OS AND TARGET_OS STREQUAL "mac")
set(SERVER_LAUNCHER_SRC src/osxlaunch/server.mm) set(SERVER_LAUNCHER_SRC src/osxlaunch/server.mm)
set(TARGET_SERVER_LAUNCHER ${TARGET_SERVER}-Launcher) set(TARGET_SERVER_LAUNCHER ${TARGET_SERVER}-Launcher)
@ -1679,6 +1687,9 @@ foreach(target ${TARGETS_OWN})
set_property(TARGET ${target} PROPERTY CXX_STANDARD 11) set_property(TARGET ${target} PROPERTY CXX_STANDARD 11)
set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON) set_property(TARGET ${target} PROPERTY CXX_STANDARD_REQUIRED ON)
endif() endif()
if(CMAKE_VERSION VERSION_GREATER 3.14 OR CMAKE_VERSION VERSION_EQUAL 3.14)
set_property(TARGET ${TARGET_SERVER} PROPERTY BUILD_RPATH_USE_ORIGIN TRUE)
endif()
if(MSVC) if(MSVC)
target_compile_options(${target} PRIVATE /wd4244) # Possible loss of data (float -> int, int -> float, etc.). target_compile_options(${target} PRIVATE /wd4244) # Possible loss of data (float -> int, int -> float, etc.).