Browse Source

CMake: use GNUInstallDirs to set library destination

This will know the right places for many systems without manual intervention.

(cherry picked from commit 108df596bea5d948b89152586129c8773ce70772)
Rolf Eike Beer 4 years ago
parent
commit
5afcb642a7
3 changed files with 9 additions and 11 deletions
  1. 5 7
      CMakeLists.txt
  2. 3 3
      debian/open62541-dev.install
  3. 1 1
      debian/open62541.install

+ 5 - 7
CMakeLists.txt

@@ -11,6 +11,7 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
 find_package(PythonInterp REQUIRED)
 find_package(Git)
 include(AssignSourceGroup)
+include(GNUInstallDirs)
 
 # Set when installed via make install
 set(open62541_TOOLS_DIR ${PROJECT_SOURCE_DIR}/tools)
@@ -36,9 +37,6 @@ set(OPEN62541_VER_MINOR 4)
 set(OPEN62541_VER_PATCH 0)
 set(OPEN62541_VER_LABEL "-dev") # Appended to the X.Y.Z version format. For example "-rc1" or an empty string
 
-#  If a relative path is specified, it is treated as relative to the $<INSTALL_PREFIX>
-set(LIB_INSTALL_DIR lib CACHE PATH "Installation path of libraries")
-
 # Set OPEN62541_VER_COMMIT
 if(GIT_FOUND)
     execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
@@ -1106,7 +1104,7 @@ include(linting_target)
 # specify install location with `-DCMAKE_INSTALL_PREFIX=xyz`
 # Enable shared library with `-DBUILD_SHARED_LIBS=ON`
 
-set(cmake_configfile_install ${LIB_INSTALL_DIR}/cmake/open62541)
+set(cmake_configfile_install ${CMAKE_INSTALL_LIBDIR}/cmake/open62541)
 set(open62541_install_tools_dir share/open62541/tools)
 set(open62541_install_nodeset_dir share/open62541/tools/ua-nodeset)
 
@@ -1154,8 +1152,8 @@ endif()
 # export library (either static or shared depending on BUILD_SHARED_LIBS)
 install(TARGETS open62541
         EXPORT open62541Targets
-        LIBRARY DESTINATION ${LIB_INSTALL_DIR}
-        ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
+        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
         RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}
         INCLUDES DESTINATION include)
 
@@ -1201,7 +1199,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/open62541Config.cmake"
 
 if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
     install(FILES "${PROJECT_BINARY_DIR}/src_generated/open62541.pc"
-            DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+            DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
 endif()
 
 set(UA_install_tools_dirs "tools/certs"

+ 3 - 3
debian/open62541-dev.install

@@ -1,5 +1,5 @@
 usr/include/*
-usr/lib/lib{*.a,*.so,*.so.*}
-usr/lib/cmake/open62541/*
-usr/lib/pkgconfig/open62541.pc
+usr/lib/*/lib{*.a,*.so,*.so.*}
+usr/lib/*/cmake/open62541/*
+usr/lib/*/pkgconfig/open62541.pc
 usr/share/open62541/*

+ 1 - 1
debian/open62541.install

@@ -1 +1 @@
-usr/lib/lib{*.a,*.so,*.so.*}
+usr/lib/*/lib{*.a,*.so,*.so.*}