Skip to content

Commit

Permalink
[libhv] Export CMake config files (microsoft#25042)
Browse files Browse the repository at this point in the history
* [libhv] Export CMake config files

* x-add-version

* update patch

* x-add-version

Co-authored-by: Lily Wang <[email protected]>
  • Loading branch information
LilyWangLL and Lily Wang authored Jun 6, 2022
1 parent d431830 commit 3e7517b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 2 deletions.
36 changes: 36 additions & 0 deletions ports/libhv/fix-export_cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f478fb4..1e3556a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -196,9 +196,10 @@ list_source_directories(LIBHV_SRCS ${LIBHV_SRCDIRS})
if(BUILD_SHARED)
add_library(hv SHARED ${LIBHV_SRCS})
target_compile_definitions(hv PRIVATE HV_DYNAMICLIB)
- target_include_directories(hv PRIVATE ${LIBHV_SRCDIRS})
+ target_include_directories(hv PRIVATE ${LIBHV_SRCDIRS} INTERFACE $<INSTALL_INTERFACE:include>)
target_link_libraries(hv ${LIBS})
install(TARGETS hv
+ EXPORT libhvConfig
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
@@ -208,14 +209,17 @@ endif()
if(BUILD_STATIC)
add_library(hv_static STATIC ${LIBHV_SRCS})
target_compile_definitions(hv_static PRIVATE HV_STATICLIB)
- target_include_directories(hv_static PRIVATE ${LIBHV_SRCDIRS})
+ target_include_directories(hv_static PRIVATE ${LIBHV_SRCDIRS} INTERFACE $<INSTALL_INTERFACE:include>)
target_link_libraries(hv_static ${LIBS})
- install(TARGETS hv_static DESTINATION lib)
+ install(TARGETS hv_static
+ EXPORT libhvConfig
+ ARCHIVE DESTINATION lib)
add_custom_target(libhv_static DEPENDS hv_static)
endif()

file(INSTALL ${LIBHV_HEADERS} DESTINATION include/hv)
install(FILES ${LIBHV_HEADERS} DESTINATION include/hv)
+install(EXPORT libhvConfig DESTINATION lib/cmake/libhv)

if(BUILD_SHARED)
set(HV_LIBRARIES hv CACHE INTERNAL "link hv libraries")
2 changes: 2 additions & 0 deletions ports/libhv/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
fix-find_package.patch
fix-export_cmake.patch #Sync up the upstream changes
)

string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC)
Expand All @@ -29,6 +30,7 @@ vcpkg_cmake_configure(

vcpkg_cmake_install()

vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/libhv)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")

file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
Expand Down
6 changes: 5 additions & 1 deletion ports/libhv/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "libhv",
"version": "1.2.4",
"port-version": 1,
"port-version": 2,
"description": "Libhv is a C/C++ network library similar to libevent/libuv.",
"homepage": "https://github.com/ithewei/libhv",
"license": "BSD-3-Clause",
Expand All @@ -10,6 +10,10 @@
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3662,7 +3662,7 @@
},
"libhv": {
"baseline": "1.2.4",
"port-version": 1
"port-version": 2
},
"libhydrogen": {
"baseline": "2021-12-02",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/libhv.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "3533f306ae38ad29c619656d006ae9536bfcdcb4",
"version": "1.2.4",
"port-version": 2
},
{
"git-tree": "b5953fb3634520fafd04507d0a7266e92c87a129",
"version": "1.2.4",
Expand Down

0 comments on commit 3e7517b

Please sign in to comment.