From 37629682b0ec9274dd4ed327761ac5b51693b650 Mon Sep 17 00:00:00 2001 From: Spirrwell Date: Wed, 22 Sep 2021 01:37:41 -0400 Subject: [PATCH 1/4] [enet] Export config, support BUILD_SHARED_LIBS, and add usage --- ports/enet/CMakeLists.txt | 37 ++++++++++++++++++++++++++++++++----- ports/enet/portfile.cmake | 2 ++ ports/enet/usage | 4 ++++ 3 files changed, 38 insertions(+), 5 deletions(-) create mode 100644 ports/enet/usage diff --git a/ports/enet/CMakeLists.txt b/ports/enet/CMakeLists.txt index 012e21d64556a6..528d59e150a701 100644 --- a/ports/enet/CMakeLists.txt +++ b/ports/enet/CMakeLists.txt @@ -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,42 @@ add_library(enet STATIC win32.c ) +add_library(enet::enet ALIAS enet) + +target_include_directories(enet PUBLIC + $ + $ +) + +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(INSTALL_TARGETS enet) +set(ENET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/enet) + +install(TARGETS enet EXPORT enetConfig + ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) +export(TARGETS ${INSTALL_TARGETS} + NAMESPACE enet:: + FILE "${CMAKE_CURRENT_BINARY_DIR}/enetConfig.cmake" +) + +install(EXPORT + enetConfig DESTINATION ${ENET_CMAKE_DIR} + NAMESPACE enet:: +) + install(DIRECTORY include/ DESTINATION include) \ No newline at end of file diff --git a/ports/enet/portfile.cmake b/ports/enet/portfile.cmake index 065a00ba9e4e3b..43f15a8ca74e28 100644 --- a/ports/enet/portfile.cmake +++ b/ports/enet/portfile.cmake @@ -16,9 +16,11 @@ vcpkg_configure_cmake( ) vcpkg_install_cmake() +vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/${PORT}) 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 ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) diff --git a/ports/enet/usage b/ports/enet/usage new file mode 100644 index 00000000000000..8d68b22afd99a2 --- /dev/null +++ b/ports/enet/usage @@ -0,0 +1,4 @@ +The package enet provides CMake targets: + + find_package(enet CONFIG REQUIRED) + target_link_libraries(main PRIVATE enet::enet) From ed0a23c2623565477d332184404cd4a2772f895e Mon Sep 17 00:00:00 2001 From: Spirrwell Date: Wed, 22 Sep 2021 06:22:49 -0400 Subject: [PATCH 2/4] [enet] Update with requested changes --- ports/enet/CMakeLists.txt | 15 +++++---------- ports/enet/portfile.cmake | 3 +-- ports/enet/usage | 4 ---- 3 files changed, 6 insertions(+), 16 deletions(-) delete mode 100644 ports/enet/usage diff --git a/ports/enet/CMakeLists.txt b/ports/enet/CMakeLists.txt index 528d59e150a701..a82e7aa4a7427a 100644 --- a/ports/enet/CMakeLists.txt +++ b/ports/enet/CMakeLists.txt @@ -86,22 +86,17 @@ if (WIN32) target_link_libraries(enet winmm ws2_32) endif() -set(INSTALL_TARGETS enet) set(ENET_CMAKE_DIR ${CMAKE_INSTALL_LIBDIR}/cmake/enet) -install(TARGETS enet EXPORT enetConfig +install(TARGETS enet EXPORT unofficial-enet-config ARCHIVE DESTINATION lib LIBRARY DESTINATION lib RUNTIME DESTINATION bin) -export(TARGETS ${INSTALL_TARGETS} - NAMESPACE enet:: - FILE "${CMAKE_CURRENT_BINARY_DIR}/enetConfig.cmake" -) - -install(EXPORT - enetConfig DESTINATION ${ENET_CMAKE_DIR} - NAMESPACE enet:: +INSTALL(EXPORT unofficial-enet-config + NAMESPACE unofficial::enet:: + FILE unofficial-enet-config.cmake + DESTINATION share/unofficial-enet ) install(DIRECTORY include/ diff --git a/ports/enet/portfile.cmake b/ports/enet/portfile.cmake index 43f15a8ca74e28..f4e039328de2ed 100644 --- a/ports/enet/portfile.cmake +++ b/ports/enet/portfile.cmake @@ -16,11 +16,10 @@ vcpkg_configure_cmake( ) vcpkg_install_cmake() -vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/${PORT}) +vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-enet) 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 ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}) diff --git a/ports/enet/usage b/ports/enet/usage deleted file mode 100644 index 8d68b22afd99a2..00000000000000 --- a/ports/enet/usage +++ /dev/null @@ -1,4 +0,0 @@ -The package enet provides CMake targets: - - find_package(enet CONFIG REQUIRED) - target_link_libraries(main PRIVATE enet::enet) From e26c151a32cbe6f267792799e9868ac39926a3c3 Mon Sep 17 00:00:00 2001 From: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com> Date: Wed, 22 Sep 2021 17:47:22 -0700 Subject: [PATCH 3/4] Update the port version --- ports/enet/vcpkg.json | 1 + versions/baseline.json | 2 +- versions/e-/enet.json | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ports/enet/vcpkg.json b/ports/enet/vcpkg.json index 3b920e909a7425..5f80e0c8233467 100644 --- a/ports/enet/vcpkg.json +++ b/ports/enet/vcpkg.json @@ -1,6 +1,7 @@ { "name": "enet", "version": "1.3.17", + "port-version": 1, "description": "Reliable UDP networking library", "homepage": "https://github.com/lsalzman/enet" } diff --git a/versions/baseline.json b/versions/baseline.json index 5307c8cc285464..a62ecdb7cbae62 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -1966,7 +1966,7 @@ }, "enet": { "baseline": "1.3.17", - "port-version": 0 + "port-version": 1 }, "ensmallen": { "baseline": "2.17.0", diff --git a/versions/e-/enet.json b/versions/e-/enet.json index 373fd575ae69b5..26c66b6f19f7fb 100644 --- a/versions/e-/enet.json +++ b/versions/e-/enet.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "5fe2375f7ce85792dae4b9ad06196c89efd386a7", + "version": "1.3.17", + "port-version": 1 + }, { "git-tree": "004a06d1e158f14059f597a1848b8f4a8d0a42f8", "version": "1.3.17", From 442f9ea8e9e6586e4dbe75e5a0e9ebe50aecb511 Mon Sep 17 00:00:00 2001 From: PhoebeHui <20694052+PhoebeHui@users.noreply.github.com> Date: Wed, 22 Sep 2021 18:09:38 -0700 Subject: [PATCH 4/4] Update the deprecated funcutions --- ports/enet/portfile.cmake | 15 +++++++-------- ports/enet/vcpkg.json | 12 +++++++++++- versions/e-/enet.json | 2 +- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ports/enet/portfile.cmake b/ports/enet/portfile.cmake index f4e039328de2ed..ad4d17374c24a5 100644 --- a/ports/enet/portfile.cmake +++ b/ports/enet/portfile.cmake @@ -5,21 +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_fixup_cmake_targets(CONFIG_PATH share/unofficial-enet) +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) diff --git a/ports/enet/vcpkg.json b/ports/enet/vcpkg.json index 5f80e0c8233467..7d2a4289af6ba7 100644 --- a/ports/enet/vcpkg.json +++ b/ports/enet/vcpkg.json @@ -3,5 +3,15 @@ "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 + } + ] } diff --git a/versions/e-/enet.json b/versions/e-/enet.json index 26c66b6f19f7fb..b2f8a6fee12635 100644 --- a/versions/e-/enet.json +++ b/versions/e-/enet.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "5fe2375f7ce85792dae4b9ad06196c89efd386a7", + "git-tree": "a31699670612c88cdf69dd80af975d44c10ac1f6", "version": "1.3.17", "port-version": 1 },