From 544ad6f9759de6acc109307caee2100478cba8ed Mon Sep 17 00:00:00 2001 From: Sander Vrijders Date: Tue, 6 Feb 2018 17:17:28 +0100 Subject: build: Use GNUInstallDirs instead of hardcoded values This changes the build to use GNUInstallDirs instead of hardcoded values. Package maintainers can then override these defaults by passing the correct value to cmake on the command line. Signed-off-by: Sander Vrijders --- CMakeLists.txt | 14 +++++++------- doc/man/CMakeLists.txt | 2 +- include/ouroboros/CMakeLists.txt | 2 +- src/ipcpd/eth-llc/CMakeLists.txt | 2 +- src/ipcpd/local/CMakeLists.txt | 2 +- src/ipcpd/normal/CMakeLists.txt | 2 +- src/ipcpd/raptor/CMakeLists.txt | 2 +- src/ipcpd/udp/CMakeLists.txt | 2 +- src/irmd/CMakeLists.txt | 2 +- src/lib/CMakeLists.txt | 6 +++--- src/tools/cbr/CMakeLists.txt | 2 +- src/tools/echo/CMakeLists.txt | 2 +- src/tools/irm/CMakeLists.txt | 2 +- src/tools/operf/CMakeLists.txt | 2 +- src/tools/oping/CMakeLists.txt | 2 +- 15 files changed, 23 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8f946b..c5ea3bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,14 +22,14 @@ if (NOT CMAKE_BUILD_TYPE) endif() if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "/" CACHE STRING "Installation Prefix" FORCE) + set(CMAKE_INSTALL_PREFIX "/usr" CACHE STRING "Installation Prefix" FORCE) endif () if (APPLE) set(CMAKE_MACOSX_RPATH 1) endif() -if (CMAKE_INSTALL_PREFIX STREQUAL "/") +if (CMAKE_INSTALL_PREFIX STREQUAL "/usr") set(RPATH_PREFIX "") else () set(RPATH_PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -40,9 +40,9 @@ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${RPATH_PREFIX}/usr/lib" isSystemDir) + "${RPATH_PREFIX}/lib" isSystemDir) IF ("${isSystemDir}" STREQUAL "-1") - set(CMAKE_INSTALL_RPATH "${RPATH_PREFIX}/usr/lib") + set(CMAKE_INSTALL_RPATH "${RPATH_PREFIX}/lib") ENDIF ("${isSystemDir}" STREQUAL "-1") message(STATUS "Package name is: ${PACKAGE_NAME}") @@ -101,17 +101,17 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/ouroboros-irm.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-dev.pc" - DESTINATION "usr/lib/pkgconfig") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ouroboros-irm.pc" - DESTINATION "usr/lib/pkgconfig") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") if (IS_DIRECTORY "/usr/lib/systemd") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/irmd.service.in" "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" @ONLY) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/irmd.service" - DESTINATION "usr/lib/systemd/system") + DESTINATION "${CMAKE_INSTALL_LIBDIR}/systemd/system") endif () enable_testing() diff --git a/doc/man/CMakeLists.txt b/doc/man/CMakeLists.txt index e1d5c04..add68d6 100644 --- a/doc/man/CMakeLists.txt +++ b/doc/man/CMakeLists.txt @@ -28,7 +28,7 @@ set(MAN_NAMES macro(INSTALL_MAN __mans) foreach (_man ${ARGV}) string(REGEX REPLACE "^.+[.]([1-9]).gz" "\\1" _mansect ${_man}) - install(FILES ${_man} DESTINATION "usr/share/man/man${_mansect}") + install(FILES ${_man} DESTINATION "${CMAKE_INSTALL_MANDIR}/man${_mansect}") endforeach (_man) endmacro(INSTALL_MAN __mans) diff --git a/include/ouroboros/CMakeLists.txt b/include/ouroboros/CMakeLists.txt index d3b6e84..c0a8303 100644 --- a/include/ouroboros/CMakeLists.txt +++ b/include/ouroboros/CMakeLists.txt @@ -15,6 +15,6 @@ set(HEADER_FILES ${CMAKE_CURRENT_BINARY_DIR}/version.h ) -install(FILES ${HEADER_FILES} DESTINATION usr/include/ouroboros) +install(FILES ${HEADER_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ouroboros) add_subdirectory(wrap) diff --git a/src/ipcpd/eth-llc/CMakeLists.txt b/src/ipcpd/eth-llc/CMakeLists.txt index 11a631b..0e7f074 100644 --- a/src/ipcpd/eth-llc/CMakeLists.txt +++ b/src/ipcpd/eth-llc/CMakeLists.txt @@ -102,5 +102,5 @@ if (HAVE_LLC) add_compile_flags(ipcpd-eth-llc -DCONFIG_OUROBOROS_DEBUG) endif () - install(TARGETS ipcpd-eth-llc RUNTIME DESTINATION sbin) + install(TARGETS ipcpd-eth-llc RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) endif () diff --git a/src/ipcpd/local/CMakeLists.txt b/src/ipcpd/local/CMakeLists.txt index ab416c6..a84f4f1 100644 --- a/src/ipcpd/local/CMakeLists.txt +++ b/src/ipcpd/local/CMakeLists.txt @@ -26,7 +26,7 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug*") add_compile_flags(ipcpd-local -DCONFIG_OUROBOROS_DEBUG) endif () -install(TARGETS ipcpd-local RUNTIME DESTINATION sbin) +install(TARGETS ipcpd-local RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) # Enable once ipcp-local has tests # add_subdirectory(tests) diff --git a/src/ipcpd/normal/CMakeLists.txt b/src/ipcpd/normal/CMakeLists.txt index 5ba0c4d..0b44485 100644 --- a/src/ipcpd/normal/CMakeLists.txt +++ b/src/ipcpd/normal/CMakeLists.txt @@ -53,7 +53,7 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug*") add_compile_flags(ipcpd-normal -DCONFIG_OUROBOROS_DEBUG) endif () -install(TARGETS ipcpd-normal RUNTIME DESTINATION sbin) +install(TARGETS ipcpd-normal RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) add_subdirectory(pol/tests) diff --git a/src/ipcpd/raptor/CMakeLists.txt b/src/ipcpd/raptor/CMakeLists.txt index 2eb3b9b..06e6ee2 100644 --- a/src/ipcpd/raptor/CMakeLists.txt +++ b/src/ipcpd/raptor/CMakeLists.txt @@ -41,7 +41,7 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Linux") add_compile_flags(ipcpd-raptor -DCONFIG_OUROBOROS_DEBUG) endif () - install(TARGETS ipcpd-raptor RUNTIME DESTINATION sbin) + install(TARGETS ipcpd-raptor RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) else () message(STATUS "Raptor support disabled by user") endif () diff --git a/src/ipcpd/udp/CMakeLists.txt b/src/ipcpd/udp/CMakeLists.txt index 20c1b58..b21afe7 100644 --- a/src/ipcpd/udp/CMakeLists.txt +++ b/src/ipcpd/udp/CMakeLists.txt @@ -57,4 +57,4 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug*") add_compile_flags(ipcpd-udp -DCONFIG_OUROBOROS_DEBUG) endif () -install(TARGETS ipcpd-udp RUNTIME DESTINATION sbin) +install(TARGETS ipcpd-udp RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) diff --git a/src/irmd/CMakeLists.txt b/src/irmd/CMakeLists.txt index 5142362..51719dc 100644 --- a/src/irmd/CMakeLists.txt +++ b/src/irmd/CMakeLists.txt @@ -48,7 +48,7 @@ if (CMAKE_BUILD_TYPE MATCHES "Debug*") add_compile_flags(irmd -DCONFIG_OUROBOROS_DEBUG) endif () -install(TARGETS irmd RUNTIME DESTINATION sbin) +install(TARGETS irmd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) # Enable once irmd has tests # add_subdirectory(tests) diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 2460ce4..2ee285f 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -238,9 +238,9 @@ target_link_libraries(ouroboros-dev ouroboros-common) target_link_libraries(ouroboros-irm ouroboros-common) -install(TARGETS ouroboros-common LIBRARY DESTINATION usr/lib) -install(TARGETS ouroboros-dev LIBRARY DESTINATION usr/lib) -install(TARGETS ouroboros-irm LIBRARY DESTINATION usr/lib) +install(TARGETS ouroboros-common LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ouroboros-dev LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ouroboros-irm LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) target_include_directories(ouroboros-common PUBLIC ${CMAKE_CURRENT_BINARY_DIR} ${SYS_RND_HDR} ${LIBGCRYPT_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR}) diff --git a/src/tools/cbr/CMakeLists.txt b/src/tools/cbr/CMakeLists.txt index 2a64a65..158b5c8 100644 --- a/src/tools/cbr/CMakeLists.txt +++ b/src/tools/cbr/CMakeLists.txt @@ -13,4 +13,4 @@ add_executable(cbr ${SOURCE_FILES}) target_link_libraries(cbr LINK_PUBLIC ouroboros-dev) -install(TARGETS cbr RUNTIME DESTINATION usr/bin) +install(TARGETS cbr RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/tools/echo/CMakeLists.txt b/src/tools/echo/CMakeLists.txt index 0cca846..4766ab8 100644 --- a/src/tools/echo/CMakeLists.txt +++ b/src/tools/echo/CMakeLists.txt @@ -13,4 +13,4 @@ add_executable(echo-app ${SOURCE_FILES}) target_link_libraries(echo-app LINK_PUBLIC ouroboros-dev) -install(TARGETS echo-app RUNTIME DESTINATION usr/bin) +install(TARGETS echo-app RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/tools/irm/CMakeLists.txt b/src/tools/irm/CMakeLists.txt index 08bf548..e87bd0a 100644 --- a/src/tools/irm/CMakeLists.txt +++ b/src/tools/irm/CMakeLists.txt @@ -31,4 +31,4 @@ add_executable(irm ${SOURCE_FILES}) target_link_libraries(irm LINK_PUBLIC ouroboros-irm) -install(TARGETS irm RUNTIME DESTINATION sbin) +install(TARGETS irm RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}) diff --git a/src/tools/operf/CMakeLists.txt b/src/tools/operf/CMakeLists.txt index 271a992..895d706 100644 --- a/src/tools/operf/CMakeLists.txt +++ b/src/tools/operf/CMakeLists.txt @@ -18,4 +18,4 @@ add_executable(operf ${SOURCE_FILES}) target_link_libraries(operf LINK_PUBLIC ${LIBM_LIBRARIES} ouroboros-dev) -install(TARGETS operf RUNTIME DESTINATION usr/bin) +install(TARGETS operf RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/src/tools/oping/CMakeLists.txt b/src/tools/oping/CMakeLists.txt index d314678..ebf96bd 100644 --- a/src/tools/oping/CMakeLists.txt +++ b/src/tools/oping/CMakeLists.txt @@ -20,4 +20,4 @@ add_executable(oping ${SOURCE_FILES}) target_link_libraries(oping LINK_PUBLIC ${LIBM_LIBRARIES} ouroboros-dev) -install(TARGETS oping RUNTIME DESTINATION usr/bin) +install(TARGETS oping RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) -- cgit v1.1