From 2f55f542bd5bf99ec0a0d8d027c67c6b24e3d6f4 Mon Sep 17 00:00:00 2001 From: Johannes Demel Date: Fri, 12 Jan 2024 20:53:26 +0100 Subject: [PATCH] cmake: Switch to GNUInstallDirs The custom code to determine `lib` vs `lib64` folder names on different distros was error prone. There's a better tool for that. Let's use it and potentially fix more issues that arise. Signed-off-by: Johannes Demel --- CMakeLists.txt | 12 +++++------- cmake/Modules/FindORC.cmake | 8 ++++---- lib/CMakeLists.txt | 8 ++++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ff536a7c..1a1df9139 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -196,9 +196,7 @@ add_subdirectory(docs) ######################################################################## # Detect /lib versus /lib64 ######################################################################## -if (${CMAKE_INSTALL_LIBDIR} MATCHES lib64) - set(LIB_SUFFIX 64) -endif() +include(GNUInstallDirs) ######################################################################## # Setup the package config file @@ -206,7 +204,7 @@ endif() #set variables found in the pc.in file set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}") -set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") +set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}") set(includedir "\${prefix}/include") configure_file( @@ -216,7 +214,7 @@ configure_file( install( FILES ${CMAKE_CURRENT_BINARY_DIR}/volk.pc - DESTINATION lib${LIB_SUFFIX}/pkgconfig + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT "volk_devel" ) @@ -224,7 +222,7 @@ install( # Install all headers in the include directories ######################################################################## set(VOLK_RUNTIME_DIR bin) -set(VOLK_LIBRARY_DIR lib${LIB_SUFFIX}) +set(VOLK_LIBRARY_DIR ${CMAKE_INSTALL_LIBDIR}) set(VOLK_INCLUDE_DIR include) install( @@ -314,7 +312,7 @@ configure_file( ######################################################################## if(NOT CMAKE_MODULES_DIR) - set(CMAKE_MODULES_DIR lib${LIB_SUFFIX}/cmake) + set(CMAKE_MODULES_DIR ${CMAKE_INSTALL_LIBDIR}/cmake) endif(NOT CMAKE_MODULES_DIR) install( diff --git a/cmake/Modules/FindORC.cmake b/cmake/Modules/FindORC.cmake index 5b43c98b4..57fef3843 100644 --- a/cmake/Modules/FindORC.cmake +++ b/cmake/Modules/FindORC.cmake @@ -8,7 +8,7 @@ FIND_PACKAGE(PkgConfig) PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.11") - +INCLUDE(GNUInstallDirs) FIND_PROGRAM(ORCC_EXECUTABLE orcc @@ -23,15 +23,15 @@ FIND_PATH(ORC_INCLUDE_DIR NAMES orc/orc.h FIND_PATH(ORC_LIBRARY_DIR NAMES ${CMAKE_SHARED_LIBRARY_PREFIX}orc-0.4${CMAKE_SHARED_LIBRARY_SUFFIX} HINTS ${PC_ORC_LIBDIR} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) FIND_LIBRARY(ORC_LIB orc-0.4 HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) FIND_LIBRARY(ORC_LIBRARY_STATIC liborc-0.4.a HINTS ${PC_ORC_LIBRARY_DIRS} - PATHS ${ORC_ROOT}/lib${LIB_SUFFIX} ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}) + PATHS ${ORC_ROOT}/${CMAKE_INSTALL_LIBDIR} ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}) LIST(APPEND ORC_LIBRARY ${ORC_LIB} diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index dc8d4e6e1..9c4fc1345 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -568,9 +568,9 @@ set_target_properties(volk PROPERTIES DEFINE_SYMBOL "volk_EXPORTS") #Install locations install(TARGETS volk EXPORT VOLK-export - LIBRARY DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_runtime" # .so file - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_devel" # .lib file - RUNTIME DESTINATION bin COMPONENT "volk_runtime" # .dll file + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_runtime" # .so file + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_devel" # .lib file + RUNTIME DESTINATION bin COMPONENT "volk_runtime" # .dll file ) #Configure static library @@ -609,7 +609,7 @@ if(ENABLE_STATIC_LIBS) install(TARGETS volk_static EXPORT VOLK-export - ARCHIVE DESTINATION lib${LIB_SUFFIX} COMPONENT "volk_devel" + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT "volk_devel" ) endif(ENABLE_STATIC_LIBS)