Skip to content

Commit

Permalink
Merge pull request #55 from NiLuJe/cmake-pkgconfig
Browse files Browse the repository at this point in the history
Make the CMake build more pkg-config friendly
  • Loading branch information
kientzle committed Mar 16, 2014
2 parents e20fc9c + b985a5a commit ead037a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 6 deletions.
15 changes: 9 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -328,7 +328,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 */
Expand Down Expand Up @@ -1283,13 +1283,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)

Expand Down Expand Up @@ -1532,6 +1532,9 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/cmake/config.h.in
INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
ADD_DEFINITIONS(-DHAVE_CONFIG_H)

# Handle generation of the libarchive.pc file for pkg-config
INCLUDE(CreatePkgConfigFile)

#
# Register installation of PDF documents.
#
Expand Down
31 changes: 31 additions & 0 deletions build/cmake/CreatePkgConfigFile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# - Generate a libarchive.pc like autotools for pkg-config
#

# Set the required variables (we use the same input file as autotools)
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 of the libraries doesn't take dependencies into account,
# thus there's a good chance it'll make some binutils versions unhappy...
# This only affects Libs.private (looked up for static builds) though.
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")

0 comments on commit ead037a

Please sign in to comment.