mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-01 12:49:07 +08:00
d9e62b5d3c
* libre 3.2.0 * update hash * vcpkg_cmake_config_fixup: add PACKAGE_NAME * update hash * update usage: See example usage from testcode here: https://github.com/baresip/re/blob/main/test/CMakeLists.txt#L62 * update hash * patch from Kai * update hash * patch: fix Libs (thanks Kai) * update hash * update patch * update hash * patch: fix bug with libre::re_shared (thanks Kai) * update hash * rename from libre to baresip-libre * update hash * delete libre.json
155 lines
4.7 KiB
Diff
155 lines
4.7 KiB
Diff
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
|
index f85cb1e..b364219 100644
|
|
--- a/CMakeLists.txt
|
|
+++ b/CMakeLists.txt
|
|
@@ -93,7 +93,7 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
|
endif()
|
|
|
|
set(re_DIR ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
|
-find_package(re CONFIG REQUIRED)
|
|
+include("${CMAKE_CURRENT_LIST_DIR}/cmake/re-config.cmake")
|
|
|
|
list(APPEND RE_DEFINITIONS
|
|
-DVERSION="${PROJECT_VERSION_FULL}"
|
|
@@ -642,7 +642,7 @@ if(WIN32)
|
|
dbghelp
|
|
)
|
|
else()
|
|
- list(APPEND LINKLIBS -lm)
|
|
+ list(APPEND LINKLIBS m)
|
|
endif()
|
|
|
|
if(UNIX)
|
|
@@ -668,7 +668,7 @@ target_include_directories(re-objs PRIVATE
|
|
${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIRS})
|
|
target_include_directories(re-objs PUBLIC
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
|
- $<INSTALL_INTERFACE:include>
|
|
+ $<INSTALL_INTERFACE:include> # pointless, object libs don't get installed.
|
|
)
|
|
|
|
|
|
@@ -697,11 +697,14 @@ endif()
|
|
if(LIBRE_BUILD_STATIC)
|
|
list(APPEND RE_INSTALL_TARGETS re)
|
|
add_library(re STATIC $<TARGET_OBJECTS:re-objs>)
|
|
- target_link_libraries(re PUBLIC ${LINKLIBS})
|
|
+ target_link_libraries(re PRIVATE ${LINKLIBS})
|
|
add_library(libre::re ALIAS re)
|
|
|
|
if(MSVC)
|
|
set_target_properties(re PROPERTIES OUTPUT_NAME "re-static")
|
|
+ if(NOT LIBRE_BUILD_SHARED)
|
|
+ set(PC_LIBNAME "re-static")
|
|
+ endif()
|
|
endif()
|
|
endif()
|
|
|
|
@@ -714,6 +717,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 LINKLIBS)
|
|
+ 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)
|
|
|
|
|
|
@@ -725,6 +750,9 @@ configure_file(packaging/libre.pc.in libre.pc @ONLY)
|
|
|
|
install(TARGETS ${RE_INSTALL_TARGETS}
|
|
EXPORT libre
|
|
+ RUNTIME
|
|
+ DESTINATION ${CMAKE_INSTALL_BINDIR}
|
|
+ COMPONENT Libraries
|
|
LIBRARY
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
COMPONENT Libraries
|
|
@@ -743,7 +771,9 @@ install(FILES ${HEADERS}
|
|
|
|
install(EXPORT libre
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libre
|
|
+ FILE libre-targets.cmake
|
|
NAMESPACE libre::
|
|
+ COMPONENT Development
|
|
)
|
|
|
|
if(LIBRE_BUILD_SHARED)
|
|
@@ -755,12 +785,8 @@ if(LIBRE_BUILD_SHARED)
|
|
)
|
|
endif()
|
|
|
|
-install(FILES cmake/re-config.cmake
|
|
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/re
|
|
- COMPONENT Development
|
|
-)
|
|
-
|
|
-install(FILES cmake/libre-config.cmake
|
|
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/libre-config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/cmake/libre-config.cmake" @ONLY)
|
|
+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/cmake/libre-config.cmake"
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libre
|
|
COMPONENT Development
|
|
)
|
|
diff --git a/cmake/libre-config.cmake b/cmake/libre-config.cmake
|
|
index 0965b84..af7f2de 100644
|
|
--- a/cmake/libre-config.cmake
|
|
+++ b/cmake/libre-config.cmake
|
|
@@ -1 +1,23 @@
|
|
-include("${CMAKE_CURRENT_LIST_DIR}/libre.cmake")
|
|
+if("@LIBRE_BUILD_STATIC@")
|
|
+ include(CMakeFindDependencyMacro)
|
|
+ find_dependency(Threads)
|
|
+ if("@USE_OPENSSL@")
|
|
+ find_dependency(OpenSSL)
|
|
+ endif()
|
|
+ if("@ZLIB_FOUND@")
|
|
+ find_dependency(ZLIB)
|
|
+ endif()
|
|
+endif()
|
|
+
|
|
+include("${CMAKE_CURRENT_LIST_DIR}/libre-targets.cmake")
|
|
+
|
|
+# convenience target libre::libre for uniform usage
|
|
+if(NOT TARGET libre::libre)
|
|
+ if(TARGET libre::re_shared AND (BUILD_SHARED_LIBS OR NOT TARGET libre::re))
|
|
+ add_library(libre::libre INTERFACE IMPORTED)
|
|
+ set_target_properties(libre::libre PROPERTIES INTERFACE_LINK_LIBRARIES libre::re_shared)
|
|
+ elseif(TARGET libre::re AND (NOT BUILD_SHARED_LIBS OR NOT TARGET libre::re_shared))
|
|
+ add_library(libre::libre INTERFACE IMPORTED)
|
|
+ set_target_properties(libre::libre PROPERTIES INTERFACE_LINK_LIBRARIES libre::re)
|
|
+ endif()
|
|
+endif()
|
|
diff --git a/packaging/libre.pc.in b/packaging/libre.pc.in
|
|
index 5817066..2df8f6c 100644
|
|
--- a/packaging/libre.pc.in
|
|
+++ b/packaging/libre.pc.in
|
|
@@ -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}
|