فهرست منبع

CMakeLists: Use GNUInstallDirs to determine install directories

CMake's GNUInstallDirs knows where particular Linux architectures and
distributions want to have their libraries installed. In particular,
Debian-derived "multi-arch" distributions keep their libraries in triplet
directories under /lib. Other "bi-arch" distributions keep 64-bit libraries
in /lib64.

Including GNUInstallDirs and using CMAKE_INSTALL_LIBDIR,
CMAKE_INSTALL_BINDIR and CMAKE_INSTALL_INCLUDEDIR means that civetweb's
libraries, binaries and header files are installed in the correct
collection.

The placement of the include(GnuInstallDirs) appears to be critical to
ensure that the variables it uses are available. Immediately after
determine_target_architecture appears to work for me.

Tested with OpenEmbedded and on Debian GNU/Linux 9 (the special naming only
applies when installing in /usr.)
Mike Crowe 6 سال پیش
والد
کامیت
e0921f63fd
2فایلهای تغییر یافته به همراه15 افزوده شده و 14 حذف شده
  1. 1 0
      CMakeLists.txt
  2. 14 14
      src/CMakeLists.txt

+ 1 - 0
CMakeLists.txt

@@ -35,6 +35,7 @@ set(CIVETWEB_VERSION_MAJOR "${CMAKE_MATCH_1}")
 set(CIVETWEB_VERSION_MINOR "${CMAKE_MATCH_2}")
 set(CIVETWEB_VERSION_MINOR "${CMAKE_MATCH_2}")
 set(CIVETWEB_VERSION_PATCH "${CMAKE_MATCH_3}")
 set(CIVETWEB_VERSION_PATCH "${CMAKE_MATCH_3}")
 determine_target_architecture(CIVETWEB_ARCHITECTURE)
 determine_target_architecture(CIVETWEB_ARCHITECTURE)
+include(GNUInstallDirs)
 
 
 # Detect the platform reliably
 # Detect the platform reliably
 if(NOT MACOSX AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 if(NOT MACOSX AND ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")

+ 14 - 14
src/CMakeLists.txt

@@ -17,13 +17,13 @@ target_include_directories(
   ${PROJECT_SOURCE_DIR}/include)
   ${PROJECT_SOURCE_DIR}/include)
 install(
 install(
   TARGETS civetweb-c-library
   TARGETS civetweb-c-library
-  ARCHIVE DESTINATION lib
-  LIBRARY DESTINATION lib
-  RUNTIME DESTINATION bin
+  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
   COMPONENT civetweb-c-library)
   COMPONENT civetweb-c-library)
 install(FILES
 install(FILES
   ${PROJECT_SOURCE_DIR}/include/civetweb.h
   ${PROJECT_SOURCE_DIR}/include/civetweb.h
-  DESTINATION include
+  DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
   COMPONENT civetweb-c-library)
   COMPONENT civetweb-c-library)
 
 
 # Need Windows sockets if available
 # Need Windows sockets if available
@@ -252,9 +252,9 @@ if (CIVETWEB_ENABLE_SERVER_EXECUTABLE)
     if (CIVETWEB_INSTALL_EXECUTABLE)
     if (CIVETWEB_INSTALL_EXECUTABLE)
         install(
         install(
             TARGETS civetweb-c-executable
             TARGETS civetweb-c-executable
-            ARCHIVE DESTINATION lib
-            LIBRARY DESTINATION lib
-            RUNTIME DESTINATION bin
+            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
             COMPONENT server)
             COMPONENT server)
     endif()
     endif()
     target_include_directories(
     target_include_directories(
@@ -278,9 +278,9 @@ if (CIVETWEB_ENABLE_LUA)
     ${PROJECT_SOURCE_DIR}/src/third_party/lua-5.2.4)
     ${PROJECT_SOURCE_DIR}/src/third_party/lua-5.2.4)
   install(
   install(
     TARGETS lua-library
     TARGETS lua-library
-    ARCHIVE DESTINATION lib
-    LIBRARY DESTINATION lib
-    RUNTIME DESTINATION bin
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
     COMPONENT lua-library)
     COMPONENT lua-library)
 endif()
 endif()
 
 
@@ -303,12 +303,12 @@ if (CIVETWEB_ENABLE_CXX)
     ${PROJECT_SOURCE_DIR}/include)
     ${PROJECT_SOURCE_DIR}/include)
   install(
   install(
     TARGETS civetweb-cpp
     TARGETS civetweb-cpp
-    ARCHIVE DESTINATION lib
-    LIBRARY DESTINATION lib
-    RUNTIME DESTINATION bin
+    ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
     COMPONENT civetweb-cpp)
     COMPONENT civetweb-cpp)
   install(FILES
   install(FILES
     ${PROJECT_SOURCE_DIR}/include/CivetServer.h
     ${PROJECT_SOURCE_DIR}/include/CivetServer.h
-    DESTINATION include
+    DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
     COMPONENT civetweb-cpp)
     COMPONENT civetweb-cpp)
 endif()
 endif()