Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:ALP:Source:Standard:0.1
yaml-cpp
fix-cmake-export.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File fix-cmake-export.patch of Package yaml-cpp
From c1f987850a6282435f499bee76b12e32d7472f12 Mon Sep 17 00:00:00 2001 From: Felix <flx107809@gmail.com> Date: Thu, 30 Dec 2021 15:35:54 +0100 Subject: [PATCH] fix cmake export After configure the file `yaml-cpp-config.cmake.in` the result ends up with empty variables. (see also the discussion in #774). Rework this file and the call to `configure_package_config_file` according the cmake documentation (https://cmake.org/cmake/help/v3.22/module/CMakePackageConfigHelpers.html?highlight=configure_package_config#command:configure_package_config_file) to overcome this issue and allow a simple `find_package` after install. As there was some discussion about the place where to install the `yaml-cpp-config.cmake` file, e.g. #1055, factor out the install location into an extra variable to make it easier changing this location in the future. --- CMakeLists.txt | 17 ++++++++++++----- yaml-cpp-config.cmake.in | 10 ++++++---- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6adbf45a2..e9310792e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,10 +129,16 @@ set_target_properties(yaml-cpp PROPERTIES PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}" DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") +# FIXME(felix2012): A more common place for the cmake export would be +# `CMAKE_INSTALL_LIBDIR`, as e.g. done in ubuntu or in this project for GTest +set(CONFIG_EXPORT_DIR "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp") +set(EXPORT_TARGETS yaml-cpp) configure_package_config_file( "${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in" "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" - INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp") + INSTALL_DESTINATION "${CONFIG_EXPORT_DIR}" + PATH_VARS CMAKE_INSTALL_INCLUDEDIR CONFIG_EXPORT_DIR) +unset(EXPORT_TARGETS) write_basic_package_version_file( "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" @@ -150,14 +156,15 @@ if (YAML_CPP_INSTALL) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h") install(EXPORT yaml-cpp-targets - DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp") + DESTINATION "${CONFIG_EXPORT_DIR}") install(FILES - "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" - "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" - DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp") + "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" + "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" + DESTINATION "${CONFIG_EXPORT_DIR}") install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc" DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig) endif() +unset(CONFIG_EXPORT_DIR) if(YAML_CPP_BUILD_TESTS) add_subdirectory(test) diff --git a/yaml-cpp-config.cmake.in b/yaml-cpp-config.cmake.in index 7b41e3f30..a7ace3dc0 100644 --- a/yaml-cpp-config.cmake.in +++ b/yaml-cpp-config.cmake.in @@ -3,12 +3,14 @@ # YAML_CPP_INCLUDE_DIR - include directory # YAML_CPP_LIBRARIES - libraries to link against -# Compute paths -get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -set(YAML_CPP_INCLUDE_DIR "@CONFIG_INCLUDE_DIRS@") +@PACKAGE_INIT@ + +set_and_check(YAML_CPP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@") # Our library dependencies (contains definitions for IMPORTED targets) -include("${YAML_CPP_CMAKE_DIR}/yaml-cpp-targets.cmake") +include(@PACKAGE_CONFIG_EXPORT_DIR@/yaml-cpp-targets.cmake) # These are IMPORTED targets created by yaml-cpp-targets.cmake set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@") + +check_required_components(@EXPORT_TARGETS@)
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor