From 37aee610c8663db6ee7c10d01a4e7e5cfaa86c7c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20D=C3=BCrrenberger?= Date: Thu, 9 Aug 2018 22:20:35 +0200 Subject: [PATCH] Fixed the installation of pkg-config files * Removed duplicated CMake code * Made it possible to manually specify the pkg-config path * Install pkg-config files by default on Linux and BSD systems --- CMakeLists.txt | 39 ++++++++++++--------------------------- cmake/Config.cmake | 15 +++++---------- 2 files changed, 17 insertions(+), 37 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bb30b46cf..8de83b3a1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -269,30 +269,6 @@ if(SFML_OS_MACOSX) set(XCODE_TEMPLATES_ARCH "\$(NATIVE_ARCH_ACTUAL)") endif() -if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD) - set(PKGCONFIG_DIR lib${LIB_SUFFIX}/pkgconfig) - if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD) - set(PKGCONFIG_DIR libdata/pkgconfig) - endif() - if(BUILD_SHARED_LIBS) - sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES FALSE BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") - if(SFML_INSTALL_PKGCONFIG_FILES) - foreach(sfml_module IN ITEMS all system window graphics audio network) - CONFIGURE_FILE( - "tools/pkg-config/sfml-${sfml_module}.pc.in" - "tools/pkg-config/sfml-${sfml_module}.pc" - @ONLY) - INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/sfml-${sfml_module}.pc" - DESTINATION "${CMAKE_INSTALL_PREFIX}/${PKGCONFIG_DIR}") - endforeach() - endif() - else() - if(SFML_INSTALL_PKGCONFIG_FILES) - message(WARNING "No pkg-config files are provided for the static SFML libraries (SFML_INSTALL_PKGCONFIG_FILES will be ignored).") - endif() - endif() -endif() - # enable project folders set_property(GLOBAL PROPERTY USE_FOLDERS ON) set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake") @@ -306,16 +282,25 @@ if(SFML_BUILD_DOC) add_subdirectory(doc) endif() -sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES FALSE BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") +# on Linux and BSD-like OS, install pkg-config files by default +set(SFML_INSTALL_PKGCONFIG_DEFAULT FALSE) + +if(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_OPENBSD) + set(SFML_INSTALL_PKGCONFIG_DEFAULT TRUE) +endif() + +sfml_set_option(SFML_INSTALL_PKGCONFIG_FILES ${SFML_INSTALL_PKGCONFIG_DEFAULT} BOOL "TRUE to automatically install pkg-config files so other projects can find SFML") + +if(SFML_INSTALL_PKGCONFIG_FILES) + sfml_set_option(SFML_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${SFML_PKGCONFIG_DIR}" PATH "Install directory for SFML's pkg-config .pc files") -if(SFML_OS_SUPPORTS_PKGCONFIG OR SFML_INSTALL_PKGCONFIG_FILES) foreach(sfml_module IN ITEMS all system window graphics audio network) CONFIGURE_FILE( "tools/pkg-config/sfml-${sfml_module}.pc.in" "tools/pkg-config/sfml-${sfml_module}.pc" @ONLY) INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/tools/pkg-config/sfml-${sfml_module}.pc" - DESTINATION "${CMAKE_INSTALL_PREFIX}/${SFML_OS_PKGCONFIG_DIR}") + DESTINATION "${SFML_PKGCONFIG_INSTALL_PREFIX}") endforeach() endif() diff --git a/cmake/Config.cmake b/cmake/Config.cmake index 82a094cd0..0a286602e 100644 --- a/cmake/Config.cmake +++ b/cmake/Config.cmake @@ -69,17 +69,12 @@ else() return() endif() -# check if OS or package system supports pkg-config +# set pkgconfig install directory # this could be e.g. macports on mac or msys2 on windows etc. -find_package(PkgConfig QUIET) -if(PKG_CONFIG_EXECUTABLE) - if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig") - set(SFML_OS_SUPPORTS_PKGCONFIG ON) - set(SFML_OS_PKGCONFIG_DIR "/lib${LIB_SUFFIX}/pkgconfig") - elseif(EXISTS "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig") - set(SFML_OS_SUPPORTS_PKGCONFIG ON) - set(SFML_OS_PKGCONFIG_DIR "/libdata/pkgconfig") - endif() +set(SFML_PKGCONFIG_DIR "/lib${LIB_SUFFIX}/pkgconfig") + +if(SFML_OS_FREEBSD OR SFML_OS_OPENBSD) + set(SFML_PKGCONFIG_DIR "/libdata/pkgconfig") endif() # detect the compiler and its version