From 953a6cda54d6efff0f1c4e8e847bdf3cf67f7645 Mon Sep 17 00:00:00 2001 From: Ben Beasley Date: Sun, 9 Feb 2025 12:04:01 -0500 Subject: [PATCH] [c]: use GNUInstallDirs to help determine installation paths (#345) In particular, this handles cases where libraries should be installed in e.g. `/usr/lib64` rather than `/usr/lib`. https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html --- c/CMakeLists.txt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/c/CMakeLists.txt b/c/CMakeLists.txt index b3ad67d2c..545dd22df 100644 --- a/c/CMakeLists.txt +++ b/c/CMakeLists.txt @@ -131,10 +131,11 @@ add_custom_command( COMMAND ${CMAKE_CTEST_COMMAND} ) ############ Installation section ############ -set(include_install_dir "include") -set(lib_install_dir "lib/") -set(bin_install_dir "bin/") -set(config_install_dir "lib/cmake/") +include(GNUInstallDirs) +set(include_install_dir "${CMAKE_INSTALL_INCLUDEDIR}") +set(lib_install_dir "${CMAKE_INSTALL_LIBDIR}/") +set(bin_install_dir "${CMAKE_INSTALL_BINDIR}/") +set(config_install_dir "${CMAKE_INSTALL_LIBDIR}/cmake/") set(project_config "${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_NAME}Config.cmake") set(targets_export_name "${PROJECT_NAME}Targets")