Skip to content

Commit

Permalink
cmake: Switch to GNUInstallDirs
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jdemel committed Jan 12, 2024
1 parent 5447d06 commit 2f55f54
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
12 changes: 5 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,15 @@ 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
########################################################################
#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(
Expand All @@ -216,15 +214,15 @@ configure_file(

install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/volk.pc
DESTINATION lib${LIB_SUFFIX}/pkgconfig
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT "volk_devel"
)

########################################################################
# 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(
Expand Down Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions cmake/Modules/FindORC.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}
Expand Down
8 changes: 4 additions & 4 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 2f55f54

Please sign in to comment.