[apr] provides CMake targets (#23499)

* [apr] provides CMake targets

* update version

* update patch

* update version

* Export CMake files

* x-add-version

* update vcpkg.json

* x-add-version

* update patch

* x-add-version

* remove target export

* x-add-version

Co-authored-by: Lily Wang <v-lilywang@microsoft.com>
This commit is contained in:
JonLiu1993 2022-05-13 10:36:04 +08:00 committed by GitHub
parent f5905e204c
commit 6be82cfac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 19 deletions

View File

@ -0,0 +1,62 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b4632c3..0b86d12 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -259,27 +259,35 @@ SET(install_targets)
SET(install_bin_pdb)
# libapr-1 is shared, apr-1 is static
+IF(BUILD_SHARED_LIBS)
ADD_LIBRARY(libapr-1 SHARED ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED} libapr.rc)
SET(install_targets ${install_targets} libapr-1)
SET(install_bin_pdb ${install_bin_pdb} ${PROJECT_BINARY_DIR}/libapr-1.pdb)
TARGET_LINK_LIBRARIES(libapr-1 ${APR_SYSTEM_LIBS})
SET_TARGET_PROPERTIES(libapr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_EXPORT;WINNT")
ADD_DEPENDENCIES(libapr-1 test_char_header)
-
+TARGET_INCLUDE_DIRECTORIES(libapr-1 INTERFACE $<INSTALL_INTERFACE:include>)
+ELSE()
ADD_LIBRARY(apr-1 STATIC ${APR_SOURCES} ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} apr-1)
TARGET_LINK_LIBRARIES(apr-1 ${APR_SYSTEM_LIBS})
SET_TARGET_PROPERTIES(apr-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;WINNT")
ADD_DEPENDENCIES(apr-1 test_char_header)
+TARGET_INCLUDE_DIRECTORIES(apr-1 INTERFACE $<INSTALL_INTERFACE:include>)
+ENDIF()
# libaprapp-1 and aprapp-1 are static
+IF(BUILD_SHARED_LIBS)
ADD_LIBRARY(libaprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} libaprapp-1)
SET_TARGET_PROPERTIES(libaprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_APP;WINNT")
-
+TARGET_INCLUDE_DIRECTORIES(libaprapp-1 INTERFACE $<INSTALL_INTERFACE:include>)
+ELSE()
ADD_LIBRARY(aprapp-1 STATIC misc/win32/apr_app.c misc/win32/internal.c ${APR_PUBLIC_HEADERS_GENERATED})
SET(install_targets ${install_targets} aprapp-1)
SET_TARGET_PROPERTIES(aprapp-1 PROPERTIES COMPILE_DEFINITIONS "APR_DECLARE_STATIC;APR_APP;WINNT")
+TARGET_INCLUDE_DIRECTORIES(aprapp-1 INTERFACE $<INSTALL_INTERFACE:include>)
+ENDIF()
IF(APR_BUILD_TESTAPR)
ENABLE_TESTING()
@@ -385,12 +393,18 @@ ENDIF (APR_BUILD_TESTAPR)
# Installation
-INSTALL(TARGETS ${install_targets}
+INSTALL(TARGETS ${install_targets} EXPORT unofficial-apr-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
+INSTALL(EXPORT unofficial-apr-config
+ NAMESPACE unofficial::apr::
+ DESTINATION share/unofficial-apr
+ FILE unofficial-apr-config.cmake
+)
+
IF(INSTALL_PDB)
INSTALL(FILES ${install_bin_pdb}
DESTINATION bin

View File

@ -10,12 +10,14 @@ vcpkg_download_distfile(ARCHIVE
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
fix-configcmake.patch
)
if (VCPKG_TARGET_IS_WINDOWS)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
private-headers INSTALL_PRIVATE_H
private-headers APR_INSTALL_PRIVATE_H
)
vcpkg_cmake_configure(
@ -24,29 +26,14 @@ if (VCPKG_TARGET_IS_WINDOWS)
-DINSTALL_PDB=OFF
-DMIN_WINDOWS_VER=Windows7
-DAPR_HAVE_IPV6=ON
-DAPR_INSTALL_PRIVATE_H=${INSTALL_PRIVATE_H}
${FEATURE_OPTIONS}
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-apr CONFIG_PATH share/unofficial-apr)
# There is no way to suppress installation of the headers in debug builds.
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
# Both dynamic and static are built, so keep only the one needed
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/apr-1.lib"
"${CURRENT_PACKAGES_DIR}/lib/aprapp-1.lib"
"${CURRENT_PACKAGES_DIR}/debug/lib/apr-1.lib"
"${CURRENT_PACKAGES_DIR}/debug/lib/aprapp-1.lib")
else()
file(REMOVE "${CURRENT_PACKAGES_DIR}/lib/libapr-1.lib"
"${CURRENT_PACKAGES_DIR}/lib/libaprapp-1.lib"
"${CURRENT_PACKAGES_DIR}/debug/lib/libapr-1.lib"
"${CURRENT_PACKAGES_DIR}/debug/lib/libaprapp-1.lib")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/bin" "${CURRENT_PACKAGES_DIR}/debug/bin")
endif()
vcpkg_copy_pdbs()
else()
# To cross-compile you will need a triplet file that locates the tool chain and sets --host and --cache parameters of "./configure".
@ -93,6 +80,7 @@ else()
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/apr-1-config" "APR_SOURCE_DIR=\"${SOURCE_PATH}\"" "")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/tools/${PORT}/debug/bin/apr-1-config" "APR_BUILD_DIR=\"${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-dbg\"" "")
endif()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
endif()
# Handle copyright

View File

@ -1,7 +1,7 @@
{
"name": "apr",
"version": "1.7.0",
"port-version": 8,
"port-version": 9,
"description": "The Apache Portable Runtime (APR) is a C library that forms a system portability layer that covers many operating systems.",
"homepage": "https://apr.apache.org/",
"license": "Apache-2.0",
@ -11,6 +11,11 @@
"name": "vcpkg-cmake",
"host": true,
"platform": "windows"
},
{
"name": "vcpkg-cmake-config",
"host": true,
"platform": "windows"
}
],
"features": {

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "419034d960a2d9d932f18154e386d1ce4947d514",
"version": "1.7.0",
"port-version": 9
},
{
"git-tree": "9fd8035a5cce96ad1b89000ac34431551ca39458",
"version": "1.7.0",

View File

@ -110,7 +110,7 @@
},
"apr": {
"baseline": "1.7.0",
"port-version": 8
"port-version": 9
},
"apr-util": {
"baseline": "1.6.1",