diff --git a/examples/vcpkg_example_chat/CMakeLists.txt b/examples/vcpkg_example_chat/CMakeLists.txt index 4419c76..264a9ee 100644 --- a/examples/vcpkg_example_chat/CMakeLists.txt +++ b/examples/vcpkg_example_chat/CMakeLists.txt @@ -14,5 +14,11 @@ add_executable( example_chat ../example_chat.cpp) -# This example links GameNetworkingSockets as a shared lib. -target_link_libraries(example_chat GameNetworkingSockets::shared) +# Link against shared or static depending on how vcpkg built the library. +# Pass -DGNS_LINK_STATIC=ON to link statically (e.g. with x64-windows-static triplet). +option(GNS_LINK_STATIC "Link GameNetworkingSockets statically" OFF) +if(GNS_LINK_STATIC) + target_link_libraries(example_chat GameNetworkingSockets::static) +else() + target_link_libraries(example_chat GameNetworkingSockets::shared) +endif() diff --git a/vcpkg.json b/vcpkg.json index c73b1e5..2452cd4 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -5,7 +5,12 @@ "description": "A basic transport layer for games.", "homepage": "https://github.com/ValveSoftware/GameNetworkingSockets", "builtin-baseline": "522253caf47268c1724f486a035e927a42a90092", - "dependencies": [ "protobuf", "openssl" ], + "dependencies": [ + "protobuf", + "openssl", + { "name": "vcpkg-cmake", "host": true }, + { "name": "vcpkg-cmake-config", "host": true } + ], "default-features": [ "openssl" ], "features": { "openssl": { diff --git a/vcpkg_ports/gamenetworkingsockets/portfile.cmake b/vcpkg_ports/gamenetworkingsockets/portfile.cmake index 5603bce..0765e82 100644 --- a/vcpkg_ports/gamenetworkingsockets/portfile.cmake +++ b/vcpkg_ports/gamenetworkingsockets/portfile.cmake @@ -1,4 +1,6 @@ -set(SOURCE_PATH ".") +# For local testing only -- points at the repo root instead of downloading a release. +# The official vcpkg portfile replaces this line with vcpkg_from_github(...). +get_filename_component(SOURCE_PATH "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) # Select crypto backend based on the selected crypto "feature" # WE ARE NOT SUPPOSED TO BE DOING THIS. @@ -6,9 +8,12 @@ set(SOURCE_PATH ".") if ("libsodium" IN_LIST FEATURES) set(CRYPTO_BACKEND "libsodium") endif() -if ("bcrypt" IN_LIST FEATURES) - set(CRYPTO_BACKEND "BCrypt") -endif() +# BCrypt is not supported as a vcpkg feature because it is only used for Xbox, +# which does not use vcpkg. If you want to use this for some reason, you'll +# need to configure and build yourself. +#if ("bcrypt" IN_LIST FEATURES) +# set(CRYPTO_BACKEND "BCrypt") +#endif() if ( ( "${CRYPTO_BACKEND}" STREQUAL "" ) OR ( "openssl" IN_LIST FEATURES ) ) set(CRYPTO_BACKEND "OpenSSL") endif() diff --git a/vcpkg_ports/gamenetworkingsockets/vcpkg.json b/vcpkg_ports/gamenetworkingsockets/vcpkg.json new file mode 120000 index 0000000..fa268e1 --- /dev/null +++ b/vcpkg_ports/gamenetworkingsockets/vcpkg.json @@ -0,0 +1 @@ +../../vcpkg.json \ No newline at end of file