Author: brane Date: Fri Sep 28 11:06:59 2018 New Revision: 1842236 URL: http://svn.apache.org/viewvc?rev=1842236&view=rev Log: In the CMake build on macOS, add an option to use @rpath in the shared library.
* CMakeLists.txt: Reorder build options before their use (style change only). Put platform-relative build options last. (RELATIVE_RPATH): New macOS-specific build option. (serf_shared): Only add the INSTALL_LIB_DIR property on macOS, depending on RELATIVE_RPATH. * build/SerfPlatform.cmake (CMAKE_MACOSX_RPATH): Depends on RELATIVE_RPATH. Modified: serf/trunk/CMakeLists.txt serf/trunk/build/SerfPlatform.cmake Modified: serf/trunk/CMakeLists.txt URL: http://svn.apache.org/viewvc/serf/trunk/CMakeLists.txt?rev=1842236&r1=1842235&r2=1842236&view=diff ============================================================================== --- serf/trunk/CMakeLists.txt (original) +++ serf/trunk/CMakeLists.txt Fri Sep 28 11:06:59 2018 @@ -45,18 +45,6 @@ message(WARNING "Some features are not supported and the build " "has not been tested on many supported platforms.") -# Initialize the build type if it was not set on the command line. -if(NOT CMAKE_BUILD_TYPE) - if(DEBUG) - set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Default to debug build.") - else() - set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "Default to release build.") - endif() -endif() - -include(SerfPlatform) -include(SerfWindowsToolkit) - # Build options option(DEBUG "Enable debugging info and strict compile warnings" OFF) @@ -65,16 +53,32 @@ option(SKIP_STATIC "Disable building sta option(LIBDIR "Install directory for architecture-dependent libraries" "") option(GSSAPI "Path to GSSAPI's install area" "") option(BROTLI "Path to Brotli's install area" "") -option(APR_STATIC "Windows: Link with static APR/-Util libraries" OFF) -option(EXPAT "Windows: optional path to Expat's install area for APR_STATIC" "") option(DISABLE_LOGGING "Disable the logging framework at compile time" OFF) option(SKIP_TESTS "Disable building the unit tests and utilities" OFF) option(ENABLE_SLOW_TESTS "Enable long-running unit tests" OFF) +# Platform-specific build options +option(APR_STATIC "Windows: Link with static APR/-Util libraries" OFF) +option(EXPAT "Windows: optional path to Expat's install area for APR_STATIC" "") +option(RELATIVE_RPATH "macOS: Use @rpath in installed shared library" OFF) + if(SKIP_SHARED AND SKIP_STATIC) message(FATAL_ERROR "You have disabled both shared and static library builds.") endif() +# Initialize the build type if it was not set on the command line. +if(NOT CMAKE_BUILD_TYPE) + if(DEBUG) + set(CMAKE_BUILD_TYPE DEBUG CACHE STRING "Default to debug build.") + else() + set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "Default to release build.") + endif() +endif() + +include(SerfPlatform) +include(SerfWindowsToolkit) + + # Public headers list(APPEND HEADERS "serf.h" @@ -299,11 +303,13 @@ if(NOT SKIP_SHARED) PRIVATE ${SERF_PRIVATE_TARGETS} ${SERF_STANDARD_LIBRARIES} PUBLIC ${SERF_PUBLIC_TARGETS}) - set_target_properties(serf_shared - PROPERTIES + set_target_properties(serf_shared PROPERTIES VERSION ${SERF_VERSION} - SOVERSION ${SERF_SOVERSION} - INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") + SOVERSION ${SERF_SOVERSION}) + if(SERF_DARWIN AND NOT RELATIVE_RPATH) + set_target_properties(serf_shared PROPERTIES + INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") + endif() set(SERF_TARGETS "serf_shared") if(SERF_WINDOWS) Modified: serf/trunk/build/SerfPlatform.cmake URL: http://svn.apache.org/viewvc/serf/trunk/build/SerfPlatform.cmake?rev=1842236&r1=1842235&r2=1842236&view=diff ============================================================================== --- serf/trunk/build/SerfPlatform.cmake (original) +++ serf/trunk/build/SerfPlatform.cmake Fri Sep 28 11:06:59 2018 @@ -19,7 +19,9 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(SERF_DARWIN TRUE) - set(CMAKE_MACOSX_RPATH FALSE) + if(NOT RELATIVE_RPATH) + set(CMAKE_MACOSX_RPATH FALSE) + endif() message(STATUS "Target platform is Darwin (macOS)") elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(SERF_LINUX TRUE)