]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Make the CMake build more pkg-config friendly
authorNiLuJe <ninuje@gmail.com>
Sun, 22 Dec 2013 17:44:46 +0000 (18:44 +0100)
committerNiLuJe <ninuje@gmail.com>
Sun, 22 Dec 2013 17:44:46 +0000 (18:44 +0100)
Build & install a libarchive.pc file, like autotools

CMakeLists.txt

index 11b71394a23c3a1a0ea40c3b040120d2c084a32c..9623b7899c3a53d5009041b2c10b1775608bf1d1 100644 (file)
@@ -59,7 +59,7 @@ SET(LIBARCHIVE_VERSION_NUMBER  "${_version_number}")
 SET(LIBARCHIVE_VERSION_STRING  "${VERSION}")
 
 # INTERFACE_VERSION increments with every release
-# libarchive 2.7 == interface version 9 = 2 + 7 
+# libarchive 2.7 == interface version 9 = 2 + 7
 # libarchive 2.8 == interface version 10 = 2 + 8
 # libarchive 2.9 == interface version 11 = 2 + 9
 # libarchive 3.0 == interface version 12
@@ -314,7 +314,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
   #--- zconf.h.orig    2005-07-21 00:40:26.000000000
   #+++ zconf.h 2009-01-19 11:39:10.093750000
   #@@ -286,7 +286,7 @@
-  # 
+  #
   # #if 1           /* HAVE_UNISTD_H -- this line is updated by ./configure */
   # #  include <sys/types.h> /* for off_t */
   #-#  include <unistd.h>    /* for SEEK_* and off_t */
@@ -1269,13 +1269,13 @@ CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG)
 CHECK_TYPE_SIZE("__int64" __INT64)
 CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64)
 
-CHECK_TYPE_SIZE(int16_t INT16_T) 
+CHECK_TYPE_SIZE(int16_t INT16_T)
 CHECK_TYPE_SIZE(int32_t INT32_T)
 CHECK_TYPE_SIZE(int64_t INT64_T)
 CHECK_TYPE_SIZE(intmax_t INTMAX_T)
-CHECK_TYPE_SIZE(uint8_t UINT8_T) 
-CHECK_TYPE_SIZE(uint16_t UINT16_T) 
-CHECK_TYPE_SIZE(uint32_t UINT32_T) 
+CHECK_TYPE_SIZE(uint8_t UINT8_T)
+CHECK_TYPE_SIZE(uint16_t UINT16_T)
+CHECK_TYPE_SIZE(uint32_t UINT32_T)
 CHECK_TYPE_SIZE(uint64_t UINT64_T)
 CHECK_TYPE_SIZE(uintmax_t UINTMAX_T)
 
@@ -1518,6 +1518,33 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in
 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
 ADD_DEFINITIONS(-DHAVE_CONFIG_H)
 
+# Generate a libarchive.pc like autotools for pkg-config
+SET(prefix ${CMAKE_INSTALL_PREFIX})
+SET(exec_prefix \${prefix})
+SET(libdir \${exec_prefix}/lib)
+SET(includedir \${prefix}/include)
+# Now, this is not particularly pretty, nor is it terribly accurate...
+# Loop over all our additional libs
+FOREACH(mylib ${ADDITIONAL_LIBS})
+       # Extract the filename from the absolute path
+       GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE)
+       # Strip the lib prefix
+       STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name})
+       # Append it to our LIBS string
+       SET(LIBS "${LIBS} -l${mylib_name}")
+ENDFOREACH()
+# libxml2 is easier, since it's already using pkg-config
+FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS})
+       SET(LIBS "${LIBS} ${mylib}")
+ENDFOREACH()
+# FIXME: The order is all wrong, thus there's a good chance it'll make some binutils versions unhappy...
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in
+               ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+               @ONLY)
+# And install it, of course ;).
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+       DESTINATION "lib/pkgconfig")
+
 #
 # Register installation of PDF documents.
 #