-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #55 from NiLuJe/cmake-pkgconfig
Make the CMake build more pkg-config friendly
- Loading branch information
Showing
2 changed files
with
40 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |