From 93c7e6242334958ac5c51924b29563821b91a436 Mon Sep 17 00:00:00 2001 From: Federico Pellegrin Date: Tue, 30 Dec 2025 10:07:40 +0100 Subject: [PATCH 1/2] 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 --- CMakeLists.txt | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 16d2417d..73a20e25 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,7 @@ endif() # Project # ############################################################################### project(fastcdr VERSION 2.3.4 LANGUAGES CXX) +include(GNUInstallDirs) set(PROJECT_NAME_STYLED "FastCDR") set(PROJECT_NAME_LARGE "Fast CDR") @@ -90,20 +91,16 @@ option(APPEND_PROJECT_NAME_TO_INCLUDEDIR overriding this package from a merged catkin, ament, or colcon workspace." OFF) -set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries") -set(_include_dir "include/") +set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Installation directory for binaries") +set(_include_dir "${CMAKE_INSTALL_INCLUDEDIR}") if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) string(APPEND _include_dir "${PROJECT_NAME}/") endif() set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for C++ headers") unset(_include_dir) -set(LIB_INSTALL_DIR lib${LIB_SUFFIX}/ CACHE PATH "Installation directory for libraries") -set(DATA_INSTALL_DIR share/ CACHE PATH "Installation directory for data") -if(WIN32) - set(DOC_DIR "doc") -else() - set(DOC_DIR "${DATA_INSTALL_DIR}/doc") -endif() +set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation directory for libraries") +set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}" CACHE PATH "Installation directory for data") +set(DOC_DIR "${CMAKE_INSTALL_DOCDIR}") set(DOC_INSTALL_DIR ${DOC_DIR} CACHE PATH "Installation directory for documentation") set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses") From 99935a14c3c541d7dc45c3ecd92d46b5a1cc31a1 Mon Sep 17 00:00:00 2001 From: Federico Pellegrin Date: Mon, 19 Jan 2026 08:22:15 +0100 Subject: [PATCH 2/2] Improve code with suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Ricardo González Signed-off-by: Federico Pellegrin --- CMakeLists.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 73a20e25..c1462490 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,6 @@ endif() # Project # ############################################################################### project(fastcdr VERSION 2.3.4 LANGUAGES CXX) -include(GNUInstallDirs) set(PROJECT_NAME_STYLED "FastCDR") set(PROJECT_NAME_LARGE "Fast CDR") @@ -91,6 +90,7 @@ option(APPEND_PROJECT_NAME_TO_INCLUDEDIR overriding this package from a merged catkin, ament, or colcon workspace." OFF) +include(GNUInstallDirs) set(BIN_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}" CACHE PATH "Installation directory for binaries") set(_include_dir "${CMAKE_INSTALL_INCLUDEDIR}") if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) @@ -100,8 +100,7 @@ set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for unset(_include_dir) set(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE PATH "Installation directory for libraries") set(DATA_INSTALL_DIR "${CMAKE_INSTALL_DATAROOTDIR}" CACHE PATH "Installation directory for data") -set(DOC_DIR "${CMAKE_INSTALL_DOCDIR}") -set(DOC_INSTALL_DIR ${DOC_DIR} CACHE PATH "Installation directory for documentation") +set(DOC_INSTALL_DIR ${CMAKE_INSTALL_DOCDIR} CACHE PATH "Installation directory for documentation") set(LICENSE_INSTALL_DIR ${DATA_INSTALL_DIR}/${PROJECT_NAME} CACHE PATH "Installation directory for licenses") ###############################################################################