Description: Install libs and cmake files to the Debian location
 Instead of moving the libs to the DEB_HOST_MULTIARCH lib directory during
 packaging, have cmake install the libs directly. This is needed so the CMake
 development files point to the correct location for the libs. Also, install
 yaml-cpp-config.cmake, yaml-cpp-config-version.cmake, and
 yaml-cpp-targets.cmake.
Author: Paul Novotny <paul@paulnovo.us>
Forwarded: not-needed
Last-Update: 2015-11-29

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -251,18 +251,21 @@
 if(WIN32)
 	set(_library_dir bin)	# .dll are in PATH, like executables
 else()
-	set(_library_dir lib)
+	set(_library_dir ${CMAKE_INSTALL_PREFIX}/lib)
 endif()
 
 set(INCLUDE_INSTALL_ROOT_DIR include)
 
 set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_ROOT_DIR}/yaml-cpp)
-set(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}")
+SET(LIB_INSTALL_DIR "${_library_dir}${LIB_SUFFIX}" CACHE
+    "Directory relative to CMAKE_INSTALL_PREFIX in which to install libraries"
+    STRING)
+MARK_AS_ADVANCED(LIB_INSTALL_DIR)
 
 set(_INSTALL_DESTINATIONS
 	RUNTIME DESTINATION bin
 	LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-	ARCHIVE DESTINATION "lib${LIB_SUFFIX}"
+	ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
 )
 
 
@@ -298,7 +301,7 @@
 	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}
@@ -314,9 +317,22 @@
 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)
+
+set(INSTALL_CMAKE_DIR ${LIB_INSTALL_DIR}/cmake/yaml-cpp)
+file(RELATIVE_PATH REL_INCLUDE_DIR "${INSTALL_CMAKE_DIR}" "${CMAKE_INSTALL_PREFIX}/include")
+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)
