Skip to content

Commit

Permalink
cmake,pc: fix static library build (#1036)
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored Jan 3, 2024
1 parent 6799654 commit 5a34ac7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
25 changes: 25 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ if(LIBRE_BUILD_STATIC)

if(MSVC)
set_target_properties(re PROPERTIES OUTPUT_NAME "re-static")
if(NOT LIBRE_BUILD_SHARED)
set(PC_LIBNAME "re-static")
endif()
endif()
endif()

Expand All @@ -668,6 +671,28 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
add_subdirectory(packaging)
endif()

if(NOT PC_LIBNAME)
set(PC_LIBNAME "re")
endif()
set(PC_REQUIRES "")
set(PC_LINKLIBS "")
foreach(item IN LISTS RE_LIBS)
if(item STREQUAL "Threads::Threads")
list(APPEND PC_LINKLIBS ${CMAKE_THREADS_LIBS_INIT})
elseif(item STREQUAL "OpenSSL::Crypto")
list(APPEND PC_REQUIRES "libcrypto")
elseif(item STREQUAL "OpenSSL::SSL")
list(APPEND PC_REQUIRES "libssl")
elseif(item STREQUAL "ZLIB::ZLIB")
list(APPEND PC_REQUIRES "zlib")
elseif(item MATCHES "^-|/")
list(APPEND PC_LINKLIBS "${item}")
else()
list(APPEND PC_LINKLIBS "-l${item}")
endif()
endforeach()
list(JOIN PC_LINKLIBS " " PC_LINKLIBS)
list(JOIN PC_REQUIRES " " PC_REQUIRES)
configure_file(packaging/libre.pc.in libre.pc @ONLY)


Expand Down
5 changes: 3 additions & 2 deletions packaging/libre.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Name: libre
Description: @CMAKE_PROJECT_DESCRIPTION@
Version: @PROJECT_VERSION@
URL: @CMAKE_PROJECT_HOMEPAGE_URL@
Libs: -L${libdir} -lre
Libs.private: -L${libdir} -lre -ldl -lssl -lcrypto -lz -lpthread
Libs: -L${libdir} -l@PC_LIBNAME@
Libs.private: @PC_LINKLIBS@
Requires.private: @PC_REQUIRES@
Cflags: -I${includedir}

0 comments on commit 5a34ac7

Please sign in to comment.