Skip to content

Commit 1ca99ea

Browse files
fedepellrichiware
andauthored
Build: use GNUInstallDirs CMake module to create directory paths (#300)
* Build: use GNUInstallDirs CMake module to create directory paths Instead of defining manually certain install paths, use the standard (since 3.0) CMake module GNUInstallDirs to derive them. This is cross-platform and offers an automatic integration on distributions customizations (ie. when certain distribution system-wide define a specific place where to install stuff). See also: https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html The goal is to make the build more modern and software easy to deploy in any distribution. Signed-off-by: Federico Pellegrin <fede@evolware.org> * Improve code with suggestions from code review Co-authored-by: Ricardo González <correoricky@gmail.com> Signed-off-by: Federico Pellegrin <fede@evolware.org> --------- Signed-off-by: Federico Pellegrin <fede@evolware.org> Co-authored-by: Ricardo González <correoricky@gmail.com>
1 parent b0e48f1 commit 1ca99ea

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

CMakeLists.txt

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,21 +90,17 @@ option(APPEND_PROJECT_NAME_TO_INCLUDEDIR
9090
overriding this package from a merged catkin, ament, or colcon workspace."
9191
OFF)
9292

93-
set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries")
94-
set(_include_dir "include/")
93+
include(GNUInstallDirs)
94+
set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Installation directory for binaries")
95+
set(_include_dir "${CMAKE_INSTALL_INCLUDEDIR}")
9596
if(APPEND_PROJECT_NAME_TO_INCLUDEDIR)
9697
string(APPEND _include_dir "${PROJECT_NAME}/")
9798
endif()
9899
set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for C++ headers")
99100
unset(_include_dir)
100-
set(LIB_INSTALL_DIR lib${LIB_SUFFIX}/ CACHE PATH "Installation directory for libraries")
101-
set(DATA_INSTALL_DIR share/ CACHE PATH "Installation directory for data")
102-
if(WIN32)
103-
set(DOC_DIR "doc")
104-
else()
105-
set(DOC_DIR "${DATA_INSTALL_DIR}/doc")
106-
endif()
107-
set(DOC_INSTALL_DIR ${DOC_DIR} CACHE PATH "Installation directory for documentation")
101+
set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation directory for libraries")
102+
set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}" CACHE PATH "Installation directory for data")
103+
set(DOC_INSTALL_DIR ${CMAKE_INSTALL_DOCDIR} CACHE PATH "Installation directory for documentation")
108104
set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses")
109105

110106
###############################################################################

0 commit comments

Comments
 (0)