Skip to content

Commit

Permalink
fix(cmake): Use standard install dirs on Linux
Browse files Browse the repository at this point in the history
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: brainboxdotcc#590
Issue: brainboxdotcc#335
  • Loading branch information
NexAdn committed Jan 4, 2023
1 parent ab47438 commit f612aa9
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions cmake/CPackSetup.cmake
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down

0 comments on commit f612aa9

Please sign in to comment.