packaging support improvements

This grew out of my work creating an sfml port for macports, but should
be helpful for package maintainers of various distributions:

* add an SFML_USE_SYSTEM_DEPS option to ignore everything in extlibs/
  except for headers/stb_image, and use the system versions

* install pkg-config files if a pkg-config program is found
  and either lib/pkgconfig or libdata/pkgconfig exists under the
  INSTALL_PREFIX, or the SFML_INSTALL_PKGCONFIG_FILES flag is set
  explicitly

* install pkg-config files for static libs too, add the necessary
  Requires.private and Libs.private entries to the .pc files to support
  static linking

* on OS X, honor all INSTALL_NAME and RPATH related cmake variables and
  only set the INSTALL_NAME_DIR to "@rpath" if none of them is set, this
  preserves the default behavior of using @rpath but also allows
  overriding by the usual cmake mechanisms
This commit is contained in:
Rafael Kitover 2016-12-19 13:16:07 -08:00 committed by Lukas Dürrenberger
parent 40ae477cc3
commit 5fe5e5d6d7
6 changed files with 81 additions and 27 deletions

View file

@ -105,9 +105,17 @@ macro(sfml_add_library target)
endif()
# adapt install directory to allow distributing dylibs/frameworks in user's frameworks/application bundle
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@rpath")
# but only if cmake rpath options aren't set
if(NOT CMAKE_SKIP_RPATH AND NOT CMAKE_SKIP_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH AND NOT CMAKE_INSTALL_RPATH_USE_LINK_PATH AND NOT CMAKE_INSTALL_NAME_DIR)
if(CMAKE_SKIP_BUILD_RPATH)
set_target_properties(${target} PROPERTIES
INSTALL_NAME_DIR "@rpath")
else()
set_target_properties(${target} PROPERTIES
BUILD_WITH_INSTALL_RPATH 1
INSTALL_NAME_DIR "@rpath")
endif()
endif()
endif()
# enable automatic reference counting on iOS