500db60f899ae6845039d4eca503133d0db81dbd.patch 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. From 500db60f899ae6845039d4eca503133d0db81dbd Mon Sep 17 00:00:00 2001
  2. From: Paul Novotny <paul@paulnovo.us>
  3. Date: Wed, 25 Nov 2015 11:33:36 -0500
  4. Subject: [PATCH] Include cmake files in install
  5. This adds yaml-cpp-config.cmake, yaml-cpp-config-version.cmake, and
  6. yaml-cpp-targets.cmake to the cmake install. As a result, cmake's
  7. find_package can easily find yaml-cpp for software that depends on
  8. yaml-cpp.
  9. Add code to install cmake files to $CMAKE_INSTALL_PREFIX/CMake on
  10. Windows, which is the de-facto standard.
  11. Closes jbeder/yaml-cpp#336 jbeder/yaml-cpp#127
  12. ---
  13. CMakeLists.txt | 28 +++++++++++++++++++++++-----
  14. 1 file changed, 23 insertions(+), 5 deletions(-)
  15. diff --git a/CMakeLists.txt b/CMakeLists.txt
  16. index 5b326a3..cbaad07 100644
  17. --- a/CMakeLists.txt
  18. +++ b/CMakeLists.txt
  19. @@ -256,15 +256,15 @@ else()
  20. set(_library_dir lib)
  21. endif()
  22. -set(INCLUDE_INSTALL_ROOT_DIR include)
  23. +set(INCLUDE_INSTALL_ROOT_DIR ${CMAKE_INSTALL_PREFIX}/include)
  24. set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_ROOT_DIR}/yaml-cpp)
  25. -set(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}")
  26. +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${_library_dir}${LIB_SUFFIX}")
  27. set(_INSTALL_DESTINATIONS
  28. - RUNTIME DESTINATION bin
  29. + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
  30. LIBRARY DESTINATION ${LIB_INSTALL_DIR}
  31. - ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
  32. + ARCHIVE DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
  33. )
  34. @@ -300,7 +300,7 @@ if(MSVC)
  35. endif()
  36. endif()
  37. -install(TARGETS yaml-cpp ${_INSTALL_DESTINATIONS})
  38. +install(TARGETS yaml-cpp EXPORT yaml-cpp-targets ${_INSTALL_DESTINATIONS})
  39. install(
  40. DIRECTORY ${header_directory}
  41. DESTINATION ${INCLUDE_INSTALL_DIR}
  42. @@ -316,9 +316,27 @@ set(EXPORT_TARGETS yaml-cpp CACHE INTERNAL "export targets")
  43. set(CONFIG_INCLUDE_DIRS "${YAML_CPP_SOURCE_DIR}/include")
  44. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
  45. "${PROJECT_BINARY_DIR}/yaml-cpp-config.cmake" @ONLY)
  46. +
  47. +if(WIN32 AND NOT CYGWIN)
  48. + set(INSTALL_CMAKE_DIR ${CMAKE_INSTALL_PREFIX}/CMake)
  49. +else()
  50. + set(INSTALL_CMAKE_DIR ${LIB_INSTALL_DIR}/cmake/yaml-cpp)
  51. +endif()
  52. +
  53. +file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${INCLUDE_INSTALL_ROOT_DIR}")
  54. +set(CONFIG_INCLUDE_DIRS "\${YAML_CPP_CMAKE_DIR}/${REL_INCLUDE_DIR}")
  55. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config.cmake.in
  56. + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yaml-cpp-config.cmake" @ONLY)
  57. +
  58. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/yaml-cpp-config-version.cmake.in
  59. "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake" @ONLY)
  60. +install(FILES
  61. + "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/yaml-cpp-config.cmake"
  62. + "${PROJECT_BINARY_DIR}/yaml-cpp-config-version.cmake"
  63. + DESTINATION "${INSTALL_CMAKE_DIR}" COMPONENT dev)
  64. +install(EXPORT yaml-cpp-targets DESTINATION ${INSTALL_CMAKE_DIR})
  65. +
  66. if(UNIX)
  67. set(PC_FILE ${CMAKE_BINARY_DIR}/yaml-cpp.pc)
  68. configure_file("yaml-cpp.pc.cmake" ${PC_FILE} @ONLY)