80 lines
2.8 KiB
Diff
80 lines
2.8 KiB
Diff
|
From 500db60f899ae6845039d4eca503133d0db81dbd Mon Sep 17 00:00:00 2001
|
||
|
From: Paul Novotny <paul@paulnovo.us>
|
||
|
Date: Wed, 25 Nov 2015 11:33:36 -0500
|
||
|
Subject: [PATCH] Include cmake files in install
|
||
|
|
||
|
This adds yaml-cpp-config.cmake, yaml-cpp-config-version.cmake, and
|
||
|
yaml-cpp-targets.cmake to the cmake install. As a result, cmake's
|
||
|
find_package can easily find yaml-cpp for software that depends on
|
||
|
yaml-cpp.
|
||
|
|
||
|
Add code to install cmake files to $CMAKE_INSTALL_PREFIX/CMake on
|
||
|
Windows, which is the de-facto standard.
|
||
|
|
||
|
Closes jbeder/yaml-cpp#336 jbeder/yaml-cpp#127
|
||
|
---
|
||
|
CMakeLists.txt | 28 +++++++++++++++++++++++-----
|
||
|
1 file changed, 23 insertions(+), 5 deletions(-)
|
||
|
|
||
|
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||
|
index 5b326a3..cbaad07 100644
|
||
|
--- a/CMakeLists.txt
|
||
|
+++ b/CMakeLists.txt
|
||
|
@@ -256,15 +256,15 @@ else()
|
||
|
set(_library_dir lib)
|
||
|
endif()
|
||
|
|
||
|
-set(INCLUDE_INSTALL_ROOT_DIR include)
|
||
|
+set(INCLUDE_INSTALL_ROOT_DIR ${CMAKE_INSTALL_PREFIX}/include)
|
||
|
|
||
|
set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_ROOT_DIR}/yaml-cpp)
|
||
|
-set(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}")
|
||
|
+set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${_library_dir}${LIB_SUFFIX}")
|
||
|
|
||
|
set(_INSTALL_DESTINATIONS
|
||
|
- RUNTIME DESTINATION bin
|
||
|
+ RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
|
||
|
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
|
||
|
- ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
|
||
|
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
|
||
|
)
|
||
|
|
||
|
|
||
|
@@ -300,7 +300,7 @@ if(MSVC)
|
||
|
endif()
|
||
|
endif()
|
||
|
|
||
|
-install(TARGETS yaml-cpp ${_INSTALL_DESTINATIONS})
|
||
|
+install(TARGETS yaml-cpp EXPORT yaml-cpp-targets ${_INSTALL_DESTINATIONS})
|
||
|
install(
|
||
|
DIRECTORY ${header_directory}
|
||
|
DESTINATION ${INCLUDE_INSTALL_DIR}
|
||
|
@@ -316,9 +316,27 @@ set(EXPORT_TARGETS yaml-cpp CACHE INTERNAL "export targets")
|
||
|
set(CONFIG_INCLUDE_DIRS "${YAML_CPP_SOURCE_DIR}/include")
|
||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
|
||
|
"${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" @ONLY)
|
||
|
+
|
||
|
+if(WIN32 AND NOT CYGWIN)
|
||
|
+ set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/CMake)
|
||
|
+else()
|
||
|
+ set(INSTALL_CMAKE_DIR ${LIB_INSTALL_DIR}/cmake/yaml-cpp)
|
||
|
+endif()
|
||
|
+
|
||
|
+file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INCLUDE_INSTALL_ROOT_DIR}")
|
||
|
+set(CONFIG_INCLUDE_DIRS "\${YAML_CPP_CMAKE_DIR}/${REL_INCLUDE_DIR}")
|
||
|
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
|
||
|
+ "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yaml-cpp-config.cmake" @ONLY)
|
||
|
+
|
||
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config-version.cmake.in
|
||
|
"${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" @ONLY)
|
||
|
|
||
|
+install(FILES
|
||
|
+ "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yaml-cpp-config.cmake"
|
||
|
+ "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
|
||
|
+ DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
|
||
|
+install(EXPORT yaml-cpp-targets DESTINATION ${INSTALL_CMAKE_DIR})
|
||
|
+
|
||
|
if(UNIX)
|
||
|
set(PC_FILE ${CMAKE_BINARY_DIR}/yaml-cpp.pc)
|
||
|
configure_file("yaml-cpp.pc.cmake" ${PC_FILE} @ONLY)
|