diff --git a/CMakeLists.txt b/CMakeLists.txt index 0a7a351cb..336e790e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -365,12 +365,46 @@ else() set (LIBDIR "lib") endif() -install(TARGETS torrent-rasterbar DESTINATION ${LIBDIR}) -install(DIRECTORY include/libtorrent - DESTINATION include - PATTERN ".svn" EXCLUDE) +install(TARGETS torrent-rasterbar EXPORT torrent-rasterbarTargets + DESTINATION ${LIBDIR} INCLUDES DESTINATION include) +install(DIRECTORY include/libtorrent DESTINATION include) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar.pc DESTINATION ${LIBDIR}/pkgconfig) +# === generate a CMake Config File === +include(CMakePackageConfigHelpers) +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar/libtorrent-rasterbarConfigVersion.cmake" + VERSION ${VERSION} + COMPATIBILITY ExactVersion +) + +export(EXPORT torrent-rasterbarTargets + FILE "${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar/libtorrent-rasterbarTargets.cmake" + NAMESPACE Libtorrent:: +) + +configure_file(libtorrent-rasterbarConfig.cmake + "${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar/libtorrent-rasterbarConfig.cmake" + COPYONLY +) + +set(ConfigPackageLocation lib/cmake/libtorrent-rasterbar) +install(EXPORT torrent-rasterbarTargets + FILE + libtorrent-rasterbarTargets.cmake + NAMESPACE + Libtorrent:: + DESTINATION + ${ConfigPackageLocation} +) +install( + FILES + libtorrent-rasterbarConfig.cmake + "${CMAKE_CURRENT_BINARY_DIR}/libtorrent-rasterbar/libtorrent-rasterbarConfigVersion.cmake" + DESTINATION + ${ConfigPackageLocation} +) + # === set up examples directory as an independent project === file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/examples) configure_file(examples/run_cmake.sh.in examples/run_cmake.sh) diff --git a/libtorrent-rasterbarConfig.cmake b/libtorrent-rasterbarConfig.cmake new file mode 100644 index 000000000..e4bdebff7 --- /dev/null +++ b/libtorrent-rasterbarConfig.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/libtorrent-rasterbarTargets.cmake")