[enet] Export config, support BUILD_SHARED_LIBS, and add usage (#20282)

* [enet] Export config, support BUILD_SHARED_LIBS, and add usage

* [enet] Update with requested changes

* Update the port version

* Update the deprecated funcutions

Co-authored-by: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com>
This commit is contained in:
Spirrwell 2021-09-23 20:57:27 -04:00 committed by GitHub
parent e6256745c6
commit b8a9f2b6d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 52 additions and 14 deletions

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.0.2)
project(enet)
@ -55,9 +55,7 @@ if(HAS_SOCKLEN_T)
add_definitions(-DHAS_SOCKLEN_T=1)
endif()
include_directories(${PROJECT_SOURCE_DIR}/include)
add_library(enet STATIC
add_library(enet
callbacks.c
compress.c
host.c
@ -69,13 +67,37 @@ add_library(enet STATIC
win32.c
)
add_library(enet::enet ALIAS enet)
target_include_directories(enet PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if (BUILD_SHARED_LIBS)
target_compile_definitions(enet
PUBLIC ENET_DLL
PRIVATE ENET_BUILDING_LIB
)
endif()
if (WIN32)
target_link_libraries(enet winmm ws2_32)
endif()
install(TARGETS enet ARCHIVE DESTINATION lib
set(ENET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/enet)
install(TARGETS enet EXPORT unofficial-enet-config
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
INSTALL(EXPORT unofficial-enet-config
NAMESPACE unofficial::enet::
FILE unofficial-enet-config.cmake
DESTINATION share/unofficial-enet
)
install(DIRECTORY include/
DESTINATION include)

View File

@ -5,20 +5,20 @@ vcpkg_from_github(OUT_SOURCE_PATH SOURCE_PATH
SHA512 006a78edcc2059d8cee47a163d308dd02120a54f9c203401b83eb6cb4ab3e56cf09988d3c35b436a1e9f74c01296995ae6fdd46f6d354fe8261cf19cdde3df5d
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA # Disable this option if project cannot be built with Ninja
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
# OPTIONS -DUSE_THIS_IN_ALL_BUILDS=1 -DUSE_THIS_TOO=2
# OPTIONS_RELEASE -DOPTIMIZE=1
# OPTIONS_DEBUG -DDEBUGGABLE=1
)
vcpkg_install_cmake()
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-enet CONFIG_PATH share/unofficial-enet)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_copy_pdbs()
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)

View File

@ -1,6 +1,17 @@
{
"name": "enet",
"version": "1.3.17",
"port-version": 1,
"description": "Reliable UDP networking library",
"homepage": "https://github.com/lsalzman/enet"
"homepage": "https://github.com/lsalzman/enet",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

View File

@ -1970,7 +1970,7 @@
},
"enet": {
"baseline": "1.3.17",
"port-version": 0
"port-version": 1
},
"ensmallen": {
"baseline": "2.17.0",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a31699670612c88cdf69dd80af975d44c10ac1f6",
"version": "1.3.17",
"port-version": 1
},
{
"git-tree": "004a06d1e158f14059f597a1848b8f4a8d0a42f8",
"version": "1.3.17",