"...resnet50_tensorflow.git" did not exist on "d305396de02f488470eabc58c360824dafbadd55"
Unverified Commit 4aad2b16 authored by Felix Schwitzer's avatar Felix Schwitzer Committed by GitHub
Browse files

Fix CMake export files (#1077)

After configuring 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.

Also untabify CMakeLists.txt in some places to align with the other code parts in this file.
parent a6db7e32
...@@ -133,10 +133,16 @@ set_target_properties(yaml-cpp PROPERTIES ...@@ -133,10 +133,16 @@ set_target_properties(yaml-cpp PROPERTIES
PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}" PROJECT_LABEL "yaml-cpp ${yaml-cpp-label-postfix}"
DEBUG_POSTFIX "${CMAKE_DEBUG_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( configure_package_config_file(
"${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in" "${PROJECT_SOURCE_DIR}/yaml-cpp-config.cmake.in"
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" "${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( write_basic_package_version_file(
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
...@@ -145,30 +151,31 @@ write_basic_package_version_file( ...@@ -145,30 +151,31 @@ write_basic_package_version_file(
configure_file(yaml-cpp.pc.in yaml-cpp.pc @ONLY) configure_file(yaml-cpp.pc.in yaml-cpp.pc @ONLY)
if (YAML_CPP_INSTALL) if (YAML_CPP_INSTALL)
install(TARGETS yaml-cpp install(TARGETS yaml-cpp
EXPORT yaml-cpp-targets EXPORT yaml-cpp-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h") FILES_MATCHING PATTERN "*.h")
install(EXPORT yaml-cpp-targets install(EXPORT yaml-cpp-targets
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp") DESTINATION "${CONFIG_EXPORT_DIR}")
install(FILES install(FILES
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake"
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/yaml-cpp") DESTINATION "${CONFIG_EXPORT_DIR}")
install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc" install(FILES "${PROJECT_BINARY_DIR}/yaml-cpp.pc"
DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig) DESTINATION ${CMAKE_INSTALL_DATADIR}/pkgconfig)
endif() endif()
unset(CONFIG_EXPORT_DIR)
if(YAML_CPP_BUILD_TESTS) if(YAML_CPP_BUILD_TESTS)
add_subdirectory(test) add_subdirectory(test)
endif() endif()
if(YAML_CPP_BUILD_TOOLS) if(YAML_CPP_BUILD_TOOLS)
add_subdirectory(util) add_subdirectory(util)
endif() endif()
if (YAML_CPP_CLANG_FORMAT_EXE) if (YAML_CPP_CLANG_FORMAT_EXE)
......
...@@ -3,12 +3,14 @@ ...@@ -3,12 +3,14 @@
# YAML_CPP_INCLUDE_DIR - include directory # YAML_CPP_INCLUDE_DIR - include directory
# YAML_CPP_LIBRARIES - libraries to link against # YAML_CPP_LIBRARIES - libraries to link against
# Compute paths @PACKAGE_INIT@
get_filename_component(YAML_CPP_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(YAML_CPP_INCLUDE_DIR "@CONFIG_INCLUDE_DIRS@") set_and_check(YAML_CPP_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@")
# Our library dependencies (contains definitions for IMPORTED targets) # 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 # These are IMPORTED targets created by yaml-cpp-targets.cmake
set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@") set(YAML_CPP_LIBRARIES "@EXPORT_TARGETS@")
check_required_components(@EXPORT_TARGETS@)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment