| 1 |
include(GNUInstallDirs) |
| 2 |
set(DPP_EXPORT_NAME dpp) |
| 3 |
set(DPP_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${DPP_EXPORT_NAME}) |
| 4 |
set(DPP_VERSION_FILE ${PROJECT_BINARY_DIR}/${DPP_EXPORT_NAME}-config-version.cmake) |
| 5 |
|
| 6 |
# The three lines below are only used for windows builds |
| 7 |
set(DPP_VERSIONED ${DPP_EXPORT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) |
| 8 |
set(DPP_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${DPP_VERSIONED}) |
| 9 |
set(DPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}/${DPP_VERSIONED}) |
| 10 |
|
| 11 |
|
| 12 |
## Pack the binary output |
| 13 |
if (WIN32) |
| 14 |
install(TARGETS dpp |
| 15 |
EXPORT ${DPP_EXPORT_NAME} |
| 16 |
LIBRARY DESTINATION ${DPP_INSTALL_LIBRARY_DIR} |
| 17 |
ARCHIVE DESTINATION ${DPP_INSTALL_LIBRARY_DIR} |
| 18 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 19 |
INCLUDES DESTINATION ${DPP_INSTALL_INCLUDE_DIR}) |
| 20 |
install(DIRECTORY "${DPP_ROOT_PATH}/include/" DESTINATION "${DPP_INSTALL_INCLUDE_DIR}") |
| 21 |
else() |
| 22 |
install(TARGETS dpp |
| 23 |
EXPORT ${DPP_EXPORT_NAME} |
| 24 |
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 25 |
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 26 |
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} |
| 27 |
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 28 |
endif() |
| 29 |
|
| 30 |
## Allow for a specific version to be chosen in the `find_package` command |
| 31 |
include(CMakePackageConfigHelpers) |
| 32 |
write_basic_package_version_file(${DPP_VERSION_FILE} |
| 33 |
VERSION ${PROJECT_VERSION} |
| 34 |
COMPATIBILITY SameMajorVersion) |
| 35 |
|
| 36 |
## Include the file which allows `find_package(dpp)` to function. |
| 37 |
install(FILES "${DPP_ROOT_PATH}/cmake/dpp-config.cmake" "${DPP_VERSION_FILE}" DESTINATION "${DPP_CMAKE_DIR}") |
| 38 |
|
| 39 |
## Export the targets to allow other projects to easily include this project |
| 40 |
install(EXPORT "${DPP_EXPORT_NAME}" DESTINATION "${DPP_CMAKE_DIR}" NAMESPACE dpp::) |
| 41 |
|
| 42 |
# Prepare information for packaging into .zip, .deb, .rpm |
| 43 |
## Project installation metadata |
| 44 |
set(CPACK_PACKAGE_NAME libdpp) # Name of generated file |
| 45 |
set(CPACK_PACKAGE_VENDOR Brainbox.cc) # Maker of the application |
| 46 |
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "An incredibly lightweight C++ Discord library") |
| 47 |
set(CPACK_PACKAGE_DESCRIPTION "An incredibly lightweight C++ Discord library") |
| 48 |
set(CPACK_PACKAGE_HOMEPAGE_URL "https://dpp.dev/") |
| 49 |
set(CPACK_FREEBSD_PACKAGE_MAINTAINER "[email protected]") |
| 50 |
set(CPACK_FREEBSD_PACKAGE_ORIGIN "misc/libdpp") |
| 51 |
set(CPACK_RPM_PACKAGE_LICENSE "Apache 2.0") |
| 52 |
set(CPACK_PACKAGE_CONTACT "https://discord.gg/dpp") # D++ Development Discord |
| 53 |
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libopus0 (>= 1.3-1)") |
| 54 |
set(CPACK_RPM_PACKAGE_REQUIRES "opus >= 1.3.1") |
| 55 |
set(CPACK_DEBIAN_PACKAGE_DESCRIPTION "An incredibly lightweight C++ Discord library") |
| 56 |
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional") |
| 57 |
set(CPACK_DEBIAN_PACKAGE_SECTION "libs") |
| 58 |
|
| 59 |
## Select generated based on what operating system |
| 60 |
if(WIN32) |
| 61 |
set(CPACK_GENERATOR ZIP) |
| 62 |
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 63 |
set(CPACK_GENERATOR "DEB;RPM") |
| 64 |
else() |
| 65 |
set(CPACK_GENERATOR "TBZ2") |
| 66 |
endif() |