From f612aa91cc22a84752d639b08d95c686af370151 Mon Sep 17 00:00:00 2001 From: NexAdn Date: Wed, 4 Jan 2023 12:27:29 +0100 Subject: [PATCH] fix(cmake): Use standard install dirs on Linux The previous method of installation didn't respect the standard dirs, leading to build tools not recognizing DPP correctly. This commit fixes this by moving everything to the standard dirs. As a side effect, files are no longer installed twice, due to CMake already placing some files in the right spots. Issue: https://github.com/brainboxdotcc/DPP/issues/590 Issue: https://github.com/brainboxdotcc/DPP/issues/335 --- cmake/CPackSetup.cmake | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/cmake/CPackSetup.cmake b/cmake/CPackSetup.cmake index 01929c1acd..f812f0ace6 100644 --- a/cmake/CPackSetup.cmake +++ b/cmake/CPackSetup.cmake @@ -1,9 +1,10 @@ include(GNUInstallDirs) set(DPP_EXPORT_NAME dpp) +set(DPP_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/${DPP_EXPORT_NAME}) set(DPP_VERSIONED ${DPP_EXPORT_NAME}-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}) set(DPP_VERSION_FILE ${PROJECT_BINARY_DIR}/${DPP_EXPORT_NAME}-config-version.cmake) -set(DPP_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}/${DPP_VERSIONED}) -set(DPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}/${DPP_VERSIONED}) +set(DPP_INSTALL_INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) +set(DPP_INSTALL_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}) ## Pack the binary output install(TARGETS dpp @@ -19,15 +20,11 @@ write_basic_package_version_file(${DPP_VERSION_FILE} VERSION ${PROJECT_VERSION} COMPATIBILITY SameMajorVersion) -## Package the include headers (the trailing slash is important, otherwise -## the include folder will be copied, instead of it's contents) -install(DIRECTORY "${CMAKE_SOURCE_DIR}/include/" DESTINATION "${DPP_INSTALL_INCLUDE_DIR}") - ## Include the file which allows `find_package(libdpp)` to function. -install(FILES "${CMAKE_SOURCE_DIR}/cmake/libdpp-config.cmake" "${DPP_VERSION_FILE}" DESTINATION "${DPP_INSTALL_LIBRARY_DIR}") +install(FILES "${CMAKE_SOURCE_DIR}/cmake/libdpp-config.cmake" "${DPP_VERSION_FILE}" DESTINATION "${DPP_CMAKE_DIR}") ## Export the targets to allow other projects to easily include this project -install(EXPORT "${DPP_EXPORT_NAME}" DESTINATION "${DPP_INSTALL_LIBRARY_DIR}" NAMESPACE dpp::) +install(EXPORT "${DPP_EXPORT_NAME}" DESTINATION "${DPP_CMAKE_DIR}" NAMESPACE dpp::) # Prepare information for packaging into .zip, .deb, .rpm ## Project installation metadata