Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions ports/enet/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.6)
cmake_minimum_required(VERSION 3.0.2)

project(enet)

Expand Down Expand Up @@ -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
Expand All @@ -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)
14 changes: 7 additions & 7 deletions ports/enet/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
13 changes: 12 additions & 1 deletion ports/enet/vcpkg.json
Original file line number Diff line number Diff line change
@@ -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
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -1966,7 +1966,7 @@
},
"enet": {
"baseline": "1.3.17",
"port-version": 0
"port-version": 1
},
"ensmallen": {
"baseline": "2.17.0",
Expand Down
5 changes: 5 additions & 0 deletions versions/e-/enet.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a31699670612c88cdf69dd80af975d44c10ac1f6",
"version": "1.3.17",
"port-version": 1
},
{
"git-tree": "004a06d1e158f14059f597a1848b8f4a8d0a42f8",
"version": "1.3.17",
Expand Down