add cmake package support

This enables libtorrent to be used with the find_package command for easy
integration with applications which use cmake.
This commit is contained in:
Steven Siloti 2017-07-08 14:11:22 -07:00 committed by Arvid Norberg
parent cba3ae4849
commit d48c835f65
2 changed files with 39 additions and 4 deletions

View File

@ -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)

View File

@ -0,0 +1 @@
include("${CMAKE_CURRENT_LIST_DIR}/libtorrent-rasterbarTargets.cmake")