diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 000000000..b6f986f87 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,14 @@ +[submodule "submodules/vcpkg"] + path = submodules/vcpkg + url = https://github.com/microsoft/vcpkg +[submodule "submodules/private"] + path = submodules/private + url = https://github.com/heroiclabs/nakama-cpp-private +[submodule "submodules/devkits"] + path = submodules/devkits + url = https://github.com/heroiclabs/console-devkits.git + shallow = true +[submodule "submodules/libHttpClient"] + path = submodules/libHttpClient + url = https://github.com/microsoft/libHttpClient.git + fetchRecurseSubmodules = false diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c59481b7..aaddd2c91 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,22 @@ All notable changes to this project are documented below. The format is based on [keep a changelog](http://keepachangelog.com/) and this project uses [semantic versioning](http://semver.org/). +### [unreleased] + +## Fixed +- Fixed libHttpClient builds + +## Changed + +- Removed support for Windows 7 +- Updated dependencies: + * Discontinued the use of the libHttpClient fork in favor of the upstream version. +- Significant improvements in the build process across all platforms: + * The `VCPKG_ROOT` setup is no longer required; it is now included as a submodule within the project. + * Private NDAed platforms are now built within the same build tree. + * Transport implementation selection has been streamlined with the introduction of `WITH_HTTP_*` and `WITH_WS_*` build options. + * macOS now natively builds universal binaries, eliminating the need for a manual `lipo` step. + ### [2.8.5] - [2024-05-23] ### Fixed - Fixed initialization of shared pointer in `authenticateSteamAsync`. diff --git a/CMakeLists.txt b/CMakeLists.txt index 056359318..70fc75dc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,95 +1,78 @@ # I think we are constrained to the version that the latest android sdk uses, for Android builds. cmake_minimum_required(VERSION 3.22.1) include(version.cmake) +include(cmake/checkPresets.cmake) -if (CMAKE_OSX_SYSROOT STREQUAL "iphonesimulator") - # this hack seems to be required for now, otherwise CMake still thinks we are building for arm... - set(CMAKE_XCODE_ATTRIBUTE_EXCLUDED_ARCHS[sdk=iphonesimulator*] "arm64") -endif() +option(WITH_HTTP_CURL "Use CURL for HTTP transport" OFF) +option(WITH_HTTP_LIBHTTPC "Use libHttpClient for HTTP transport" OFF) +option(WITH_HTTP_CPPREST "Use CppRestSDK for HTTP transport" OFF) -if (ANDROID) - SET(ANDROID_USE_LEGACY_TOOLCHAIN_FILE FALSE) -endif() +option(WITH_WS_WSLAY "Use wslay for WS transport" OFF) +option(WITH_WS_LIBHTTPC "Use libHttpClient for WS transport" OFF) +option(WITH_WS_CPPREST "Use CppRestSDK for WS transport" OFF) -set(CMAKE_CONFIGURATION_TYPES "Debug;MinSizeRel") -set(VCPKG_OVERLAY_TRIPLETS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/triplets") -set(CMAKE_SUPPRESS_REGENERATION true) ## for Xcode -set(VCPKG_PREFER_SYSTEM_LIBS OFF) +option(CFG_WSLAY_CURL_IO "Use CURL-based NetIO when wslay is enabled" ON) +option(CFG_LIBHTTPC_SYSTEM "Use system-installed libhttpc" OFF) +option(CFG_CURL_SYSTEM "Use system-installed libCURL" OFF) -## TODO figure out why vcpkg seems to toggle these on and prevent downloading from fetchcontent -set(FETCHCONTENT_FULLY_DISCONNECTED OFF) -set(FETCHCONTENT_UPDATES_DISCONNECTED OFF) +option(WITH_GRPC_CLIENT "Build gRPC Client" OFF) -# By default, assume user will not obtain optional-lite via third party mechanism. -option(DISTRIBUTE_OPTIONAL_LITE "Distribute optional lite with the Nakama client." ON) -option(BUILD_SHARED_LIBS "Build a shared library." ON) -option(FORCE_DLL_IMPORT_EXPORT "Force exporting and importing of symbols regardless of the platform." OFF) -option(BUILD_APPLE_FRAMEWORK "Build frameworks instead of .dylib files for Apple." ON) +if (WITH_WS_WSLAY) + list(APPEND VCPKG_MANIFEST_FEATURES "wslay") +endif() -set(HTTP_IMPL "") -set(WS_IMPL "") -set(NAKAMA_SDK_DEPS "") +if (WITH_HTTP_CURL OR (WITH_WS_WSLAY AND CFG_WSLAY_CURL_IO)) + if (NOT CFG_CURL_SYSTEM) + list(APPEND VCPKG_MANIFEST_FEATURES "curl") + endif() +endif() -if (WITH_LIBHTTPCLIENT_HTTP) - set(HTTP_IMPL "libhttpclient") -elseif (WITH_CPPRESTSDK) - set(HTTP_IMPL "cpprestsdk") -elseif (BUILD_CURL_HTTP OR BUILD_CURL_HTTP_SYSTEM) - set(HTTP_IMPL "curl") +if ((WITH_WS_LIBHTTPC OR WITH_HTTP_LIBHTTPC) AND NOT CFG_LIBHTTPC_SYSTEM) + list(APPEND VCPKG_MANIFEST_FEATURES "libhttpclient") endif() -if (WITH_LIBHTTPCLIENT_WS) - set(WS_IMPL "libhttpclient") -elseif (BUILD_WSLAY) - set(WS_IMPL "wslay") -elseif (WITH_CPPRESTSDK) - set(WS_IMPL "cpprestsdk") +if (WITH_HTTP_CPPREST OR WITH_WS_CPPREST) + list(APPEND VCPKG_MANIFEST_FEATURES "cpprestsdk") endif() -set(HTTP_COMPILE_DEFINITION "") +if (WITH_HTTP_LIBHTTPC OR WITH_HTTP_CURL OR WITH_HTTP_CPPREST) + # This var goes into public config.h, so set it early + set(HAVE_DEFAULT_TRANSPORT_FACTORY ON) +endif() -if(WITH_LIBHTTPCLIENT_HTTP) - set(HTTP_COMPILE_DEFINITION "BUILD_HTTP_LIBHTTPCLIENT") -elseif(WITH_CPPRESTSDK) - set(HTTP_COMPILE_DEFINITION "BUILD_HTTP_CPPRESTSDK") -elseif(BUILD_CURL_HTTP OR BUILD_CURL_HTTP_SYSTEM) - set(HTTP_COMPILE_DEFINITION "BUILD_HTTP_CURL") -else() - set(HTTP_COMPILE_DEFINITION "WITH_EXTERNAL_HTTP") +if (WITH_WS_LIBHTTPC OR WITH_WS_WSLAY OR WITH_WS_CPPREST) + # This var goes into public config.h, so set it early + set(HAVE_DEFAULT_RT_TRANSPORT_FACTORY ON) endif() -set(WS_COMPILE_DEFINITION "") -set(WS_IO_COMPILE_DEFINITION "") +if (ANDROID) + SET(ANDROID_USE_LEGACY_TOOLCHAIN_FILE FALSE) +endif() -if (WITH_LIBHTTPCLIENT_WS) - set(WS_COMPILE_DEFINITION BUILD_WEBSOCKET_LIBHTTPCLIENT) -elseif (BUILD_WSLAY) - set(WS_COMPILE_DEFINITION BUILD_WEBSOCKET_WSLAY) +set(CMAKE_CONFIGURATION_TYPES "Debug;MinSizeRel") +set(CMAKE_SUPPRESS_REGENERATION true) ## for Xcode - if (BUILD_CURL_IO OR BUILD_CURL_IO_SYSTEM) - set(WS_IO_COMPILE_DEFINITION BUILD_CURL_IO) - else() - # no IO baked in for Wslay -- we expect user to provide the IO. - set(WS_IO_COMPILE_DEFINITION BUILD_IO_EXTERNAL) - endif() -elseif (WITH_CPPRESTSDK) - set(WS_COMPILE_DEFINITION BUILD_WEBSOCKET_CPPRESTSDK) -else() - # no WS baked in -- we expect user to provide WS transport - set(WS_COMPILE_DEFINITION WITH_EXTERNAL_WS) - set(WS_IO_COMPILE_DEFINITION WITH_EXTERNAL_WS_IO) -endif() +# By default, assume user will not obtain optional-lite via third party mechanism. +option(DISTRIBUTE_OPTIONAL_LITE "Distribute optional lite with the Nakama client." ON) +option(FORCE_DLL_IMPORT_EXPORT "Force exporting and importing of symbols regardless of the platform." OFF) +option(BUILD_APPLE_FRAMEWORK "Build frameworks instead of .dylib files for Apple." ON) + +set(NAKAMA_SDK_DEPS) cmake_policy(SET CMP0012 NEW) ## force so that gradle doesn't stomp vcpkg toolchain with the android toolchain -set(CMAKE_TOOLCHAIN_FILE $ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "Vcpkg toolchain file" FORCE) +set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/submodules/vcpkg/scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "Vcpkg toolchain file" FORCE) if (DEFINED ANDROID_ABI AND NOT DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE) # CmakePresets.json doesn't allow us to use cmake vars in values, so set it here set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE $ENV{ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake) endif() +include("cmake/triplets/${VCPKG_TARGET_TRIPLET}.cmake" OPTIONAL) +include("submodules/devkits/cmake/platform-${VCPKG_TARGET_TRIPLET}.cmake" OPTIONAL) +include("submodules/private/cmake/preproject-${VCPKG_TARGET_TRIPLET}.cmake" OPTIONAL) + project(nakama-sdk LANGUAGES CXX) include(cmake/platformSupport.cmake) @@ -107,14 +90,6 @@ endif() option(ADDRESS_SANITIZER "Enable address sanitizer (broken on windows)" OFF) -# libhttpclient uses websocketpp when system winhttp doesn't provide one (< Windows 8) -# this flag allows us to force use of websocketpp so that it can be tested on current Windows versions -option(LIBHTTPCLIENT_FORCE_WEBSOCKETPP "Force use of websocketpp instead of winhttp in the libhttpclient" OFF) - -if (LIBHTTPCLIENT_FORCE_WEBSOCKETPP) - list(APPEND VCPKG_MANIFEST_FEATURES "websocketpp") -endif() - if(LOGS_ENABLED) add_compile_definitions(NLOGS_ENABLED) endif(LOGS_ENABLED) @@ -124,134 +99,84 @@ if (ADDRESS_SANITIZER) string(REPLACE /RTC1 "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) endif() -if(BUILD_SHARED_LIBS) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - add_compile_definitions(NAKAMA_SHARED_LIBRARY NAKAMA_SHARED_LIBRARY_EXPORTS) -endif() - +add_compile_definitions(NAKAMA_SHARED_LIBRARY_EXPORTS) -if(APPLE AND BUILD_SHARED_LIBS AND BUILD_APPLE_FRAMEWORK) +if(APPLE AND BUILD_APPLE_FRAMEWORK) # Just copy over headers into framework dir, because "official" way of doing it # via PUBLIC_HEADER property is full of bugs (see comment on PUBLIC_HEADER property below) set(CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_LIBDIR}/nakama-sdk.framework/Headers) - endif() -if (BUILD_CURL_IO_SYSTEM OR BUILD_CURL_IO OR BUILD_CURL_HTTP_SYSTEM OR BUILD_CURL_HTTP) - if (BUILD_CURL_IO_SYSTEM OR BUILD_CURL_HTTP_SYSTEM) +if (WITH_HTTP_CURL OR (WITH_WS_WSLAY AND CFG_WSLAY_CURL_IO)) + if (CFG_CURL_SYSTEM) find_package(CURL REQUIRED) # system curl not guaranteed to contain a CMake config file. else() find_package(CURL CONFIG REQUIRED) endif() endif() -if(WS_IMPL STREQUAL "libhttpclient" OR HTTP_IMPL STREQUAL "libhttpclient") - if (NOT LIBHTTPCLIENT_BUILTIN) - if (LINUX OR APPLE) - find_package(CURL CONFIG REQUIRED) - target_compile_definitions(CURL::libcurl INTERFACE CURL_STRICTER) - endif() - - if (ANDROID) - set(LIBHTTPCLIENT_SOURCE_SUBDIR Utilities/CMake/Android/libHttpClient) - set(LIBHTTPCLIENT_TARGET libHttpClient.Android) - else() - set(LIBHTTPCLIENT_SOURCE_SUBDIR Utilities/CMake) - - if(XDK) - if (WINRT) - set(LIBHTTPCLIENT_TARGET libHttpClient.XDK.WinRT) - else() - set(LIBHTTPCLIENT_TARGET libHttpClient.XDK.C) - endif() - elseif (BUILDWIN32) - set(LIBHTTPCLIENT_TARGET libHttpClient.Win32.C) - elseif (GDK) - set(LIBHTTPCLIENT_TARGET libHttpClient.GDK.C) - elseif (APPLE) - set(LIBHTTPCLIENT_TARGET libHttpClient.Apple.C) - elseif(DEFINED LINUX) - set(LIBHTTPCLIENT_TARGET libHttpClient.Linux.C) - else() - if (WINRT) - set(LIBHTTPCLIENT_TARGET libHttpClient.UWP.WinRT) - else() - set(LIBHTTPCLIENT_TARGET libHttpClient.UWP.C) - endif() - endif() - endif() - - # We build LIBHTTPCLIENT as OBJECT library so that its symbols - # wont be excluded due to '--exclude-libs ALL' linker flag. Although we - # dont expose libhttpclient in our API , we still want it's symbols exported - # in our ABI, because that is how JVM finds native code on Android platform. - list(APPEND NAKAMA_SDK_DEPS ${LIBHTTPCLIENT_TARGET}) - - set(LIBHTTPCLIENT_OBJECT_LIBRARY TRUE) - set(WAS_SHARED_LIBS ${BUILD_SHARED_LIBS}) - - ## force libhttpclient to build statically - set(BUILD_SHARED_LIBS OFF) - FetchContent_Declare( - libHttpClient - GIT_REPOSITORY https://github.com/heroiclabs/libHttpClient.git - GIT_TAG c535d5943516bb5d8f3a50858da617ebd0dd3f3f - SOURCE_SUBDIR ${LIBHTTPCLIENT_SOURCE_SUBDIR} - GIT_PROGRESS TRUE - GIT_SHALLOW TRUE - USES_TERMINAL_DOWNLOAD TRUE - ) - - FetchContent_MakeAvailable(libHttpClient) - if (${WAS_SHARED_LIBS}) - set(BUILD_SHARED_LIBS ON) - endif() - - if (NOT WS_IMPL STREQUAL "libhttpclient") - target_compile_definitions(${LIBHTTPCLIENT_TARGET} PRIVATE "HC_NOWEBSOCKETS") - else() - if (LIBHTTPCLIENT_FORCE_WEBSOCKETPP) - message(STATUS "Forcing libhttpclient to use websocketpp even on modern Windows platforms") - target_compile_definitions(${LIBHTTPCLIENT_TARGET} PRIVATE "HC_FORCE_WINSOCKETPP") - endif() - endif() + +if(WITH_HTTP_LIBHTTPC OR WITH_WS_LIBHTTPC) + # build libHttpClient dependency if not using system + if (NOT CFG_LIBHTTPC_SYSTEM) + include(cmake/libhttpClient.cmake) endif() endif() -if (HTTP_IMPL STREQUAL "cpprestsdk") +find_package(optional-lite CONFIG REQUIRED) +# SDK API +add_subdirectory(interface) + +# Implements API, but without concrete implementations of transports +add_subdirectory(core EXCLUDE_FROM_ALL) + +# Factories, that's where all messy ifdefs to select concrete implementations are +add_subdirectory(factory EXCLUDE_FROM_ALL) + +include("submodules/private/cmake/target-${VCPKG_TARGET_TRIPLET}.cmake" OPTIONAL) + +if (WITH_HTTP_CPPREST) + set(HTTP_IMPL_LIB nakama::impl-http-cppRest) add_subdirectory(impl/httpCppRest EXCLUDE_FROM_ALL) -elseif(HTTP_IMPL STREQUAL "curl") +elseif(WITH_HTTP_CURL) + set(HTTP_IMPL_LIB nakama::impl-http-libcurl) add_subdirectory(impl/httpCurl EXCLUDE_FROM_ALL) +elseif(WITH_HTTP_LIBHTTPC) + set(HTTP_IMPL_LIB nakama::impl-http-libhttpclient) + add_subdirectory(impl/httpLibHttpClient EXCLUDE_FROM_ALL) +endif() +if (HTTP_IMPL_LIB) + target_link_libraries(nakama-sdk-client-factory + PRIVATE ${HTTP_IMPL_LIB} + INTERFACE $) endif() -add_library(nakama-ws-impl INTERFACE) -if(WS_IMPL STREQUAL "libhttpclient") - set(WS_IMPL_LIB nakama-impl-ws-libhttpclient) +if(WITH_WS_LIBHTTPC) + set(WS_IMPL_LIB nakama::impl-ws-libhttpclient) add_subdirectory(impl/wsLibHttpClient EXCLUDE_FROM_ALL) -elseif(WS_IMPL STREQUAL "wslay") - set(BUILD_WEBSOCKET_WSLAY ON) - set(WS_IMPL_LIB nakama-impl-ws-wslay) +elseif(WITH_WS_WSLAY) + set(WS_IMPL_LIB nakama::impl-ws-wslay) add_subdirectory(impl/wsWslay EXCLUDE_FROM_ALL) -elseif(WS_IMPL STREQUAL "cpprestsdk") - set(WS_IMPL_LIB nakama-impl-ws-cppRest) +elseif(WITH_WS_CPPREST) + set(WS_IMPL_LIB nakama::impl-ws-cppRest) add_subdirectory(impl/wsCppRest EXCLUDE_FROM_ALL) endif() - -if(HTTP_IMPL STREQUAL "libhttpclient") - set(BUILD_HTTP_LIBHTTPCLIENT ON) - add_subdirectory(impl/httpLibHttpClient EXCLUDE_FROM_ALL) +if (WS_IMPL_LIB) + target_link_libraries(nakama-sdk-rtclient-factory + PRIVATE ${WS_IMPL_LIB} + INTERFACE $) endif() -if (ANDROID AND (HTTP_IMPL STREQUAL "curl" OR WS_IMPL STREQUAL "wslay")) +if (ANDROID AND (WITH_HTTP_CURL OR WITH_WS_WSLAY)) add_subdirectory(impl/android) set(CREATE_JAR TRUE) # we need the code for accessing native Android CA store. - if (HTTP_IMPL STREQUAL "curl") + if (TARGET nakama::impl-http-libcurl) target_link_libraries(nakama-impl-http-libcurl PUBLIC android-ca) endif() - if (WS_IMPL STREQUAL "wslay") - target_link_libraries(nakama-impl-ws-wslay INTERFACE android-ca) + if (TARGET nakama::impl-ws-wslay) + target_link_libraries(nakama-impl-ws-wslay PUBLIC android-ca) endif() list(APPEND NAKAMA_SDK_DEPS android-ca) @@ -277,16 +202,6 @@ if (CREATE_JAR) install(FILES ${LIBNAKAMA_AAR} DESTINATION ${CMAKE_INSTALL_LIBDIR}) endif() -find_package(optional-lite CONFIG REQUIRED) -# SDK API -add_subdirectory(interface) - -# Factories, that's where all messy ifdefs to select concrete implementations are -add_subdirectory(factory EXCLUDE_FROM_ALL) - -# Implements API, but without concrete implementations of transports -add_subdirectory(core EXCLUDE_FROM_ALL) - # create dummy file because pure "library of libraries" is not supported: https://gitlab.kitware.com/cmake/cmake/-/issues/23688 set(DUMMY_CPP "") set(DUMMY_H "") @@ -297,29 +212,39 @@ if (APPLE) set(DUMMY_H ${CMAKE_BINARY_DIR}/dummy.h) endif() + +# Use 'nakama::' ALIASes because it forces CMake to reference +# defined target and not to fallback to '-lname' when target doesn't exist, +# thus failing at configure time, rather than at link time should we make mistake +# in build scripts list(APPEND NAKAMA_SDK_DEPS - nakama-sdk-core-misc - nakama-sdk-core-rest - nakama-sdk-core-rt - nakama-sdk-core-common - nakama-sdk-client-factory - nakama-sdk-rtclient-factory + nakama::sdk-core-misc + nakama::sdk-core-rest + nakama::sdk-core-rt + nakama::sdk-core-common + nakama::sdk-client-factory + nakama::sdk-rtclient-factory ) - -if (BUILD_GRPC_CLIENT) - list(APPEND NAKAMA_SDK_DEPS nakama-sdk-core-grpc) +if (WITH_GRPC_CLIENT) + list(APPEND NAKAMA_SDK_DEPS nakama::sdk-core-grpc) endif() -set(NAKAMA_SDK_DEPS_OBJECTS "") - -foreach(lib ${NAKAMA_SDK_DEPS}) - # Append the TARGET_OBJECTS of the current library to the list - list(APPEND NAKAMA_SDK_DEPS_OBJECTS $) -endforeach() - -add_library(nakama-sdk ${NAKAMA_SDK_DEPS_OBJECTS} ${DUMMY_CPP} ${DUMMY_H}) +add_library(nakama-sdk SHARED ${DUMMY_CPP} ${DUMMY_H}) +add_library(nakama::sdk ALIAS nakama-sdk) +target_link_libraries(nakama-sdk + PUBLIC + nakama::sdk-interface + PRIVATE + nakama::api-proto + $ + $<$:$> + ${NAKAMA_SDK_DEPS} +) +if (WITH_HTTP_CURL OR (WITH_WS_WSLAY AND CFG_WSLAY_CURL_IO)) + target_link_libraries(nakama-sdk PRIVATE CURL::libcurl) +endif() -if (BUILD_SHARED_LIBS AND APPLE AND BUILD_APPLE_FRAMEWORK) +if (APPLE AND BUILD_APPLE_FRAMEWORK) set_target_properties(nakama-sdk PROPERTIES FRAMEWORK TRUE FRAMEWORK_VERSION A @@ -336,24 +261,6 @@ elseif (APPLE) FRAMEWORK FALSE) endif() -add_library(nakama::sdk ALIAS nakama-sdk) -target_link_libraries(nakama-sdk - PUBLIC nakama::sdk-interface ${PTHREADS_LIB}) - -set(DEPENDENCY_LINK_SCOPE "") -if (BUILD_SHARED_LIBS) - set(DEPENDENCY_LINK_SCOPE "PRIVATE") -else() # propogate the static dependencies - set(DEPENDENCY_LINK_SCOPE "PUBLIC") -endif() - -target_link_libraries(nakama-sdk - ${DEPENDENCY_LINK_SCOPE} - nakama-api-proto - $<$:nakama-grpc-proto> - ${HTTP_IMPL_LIB} ${WS_IMPL_LIB} -) - if (ADDRESS_SANITIZER) if (MSVC) @@ -369,44 +276,29 @@ if (ADDRESS_SANITIZER) endif() -# ensure we only perform a single 'target_link_libraries' to libcurl to prevent duplicate linkage for linkers that do not deduplicate. -if (BUILD_CURL_IO_SYSTEM OR BUILD_CURL_IO OR BUILD_CURL_HTTP_SYSTEM OR BUILD_CURL_HTTP) - target_link_libraries(nakama-sdk PRIVATE CURL::libcurl) -endif() - install(TARGETS nakama-sdk nakama-sdk-interface - nakama-api-proto - ${HTTP_IMPL_LIB} - ${WS_IMPL_LIB} - ${NAKAMA_SDK_DEPS} EXPORT nakama-export - FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT nakama-sdk - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT nakama-sdk - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT nakama-sdk - RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT nakama-sdk + FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} FILE_SET HEADERS COMPONENT headers INCLUDES DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" ) -if(MSVC AND BUILD_SHARED_LIBS) +if(MSVC) install(FILES $ DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT nakama-sdk OPTIONAL) endif() + ## use share directory for export files (at least a vcpkg convention) install(EXPORT nakama-export DESTINATION share/nakama-sdk) - include(CMakePackageConfigHelpers) -if(BUILD_SHARED_LIBS) - set(NAKAMA_SDK_BUILD_TYPE "SHARED") -else() - set(NAKAMA_SDK_BUILD_TYPE "STATIC") -endif() - configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/nakama-sdk-config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/nakama-sdk-config.cmake" INSTALL_DESTINATION share/nakama-sdk @@ -414,11 +306,8 @@ configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/nakama-sdk-config.cmak NO_CHECK_REQUIRED_COMPONENTS_MACRO ) -## for any variables that need to be read by consuming packages before their project() call, since find_package must be done after project() -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/nakama-sdk-preconfig.cmake.in ${CMAKE_BINARY_DIR}/nakama-sdk-preconfig.cmake) install(FILES - ${CMAKE_CURRENT_BINARY_DIR}/nakama-sdk-preconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/nakama-sdk-config.cmake DESTINATION share/nakama-sdk ) diff --git a/CMakePresets.json b/CMakePresets.json index f614e00c0..344e7452a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,8 +1,8 @@ { - "version": 3, + "version": 6, "cmakeMinimumRequired": { "major": 3, - "minor": 21, + "minor": 28, "patch": 0 }, "configurePresets": [ @@ -12,93 +12,54 @@ "description": "No shipped websocket or http implementation.", "binaryDir": "build/${presetName}", "hidden": true, + "toolchainFile": "${sourceDir}/submodules/vcpkg/scripts/buildsystems/vcpkg.cmake", "cacheVariables": { - "LOGS_ENABLED": "ON", - "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME": "nakama-sdk" - } + "CMAKE_INSTALL_DEFAULT_COMPONENT_NAME": "nakama-sdk", + "VCPKG_OVERLAY_PORTS": "${sourceDir}/cmake/vcpkg-ports", + "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/cmake/triplets;${sourceDir}/submodules/devkits/cmake/triplets" + }, + "installDir": "out/${presetName}" }, { "name": "win-x64", "inherits": [ "default" ], - "generator": "Visual Studio 17 2022", + "generator": "Ninja Multi-Config", "cacheVariables": { - "WindowsDesktop": "ON", - "VCPKG_HOST_TRIPLET": "x64-windows-static-heroic", + "CMAKE_SYSTEM_PROCESSOR": "AMD64", "VCPKG_TARGET_TRIPLET": "x64-windows-static-heroic", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON", - "BUILD_CURL_HTTP": "ON", - "VCPKG_MANIFEST_FEATURES": "wslay;curl" + "VCPKG_CHAINLOAD_TOOLCHAIN_FILE": "${sourceDir}/cmake/toolchains/vcpkg-msvc.cmake", + "WITH_WS_LIBHTTPC": "ON", + "WITH_HTTP_LIBHTTPC": "ON" }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Windows" - }, - "installDir": "out/win-x64" + } }, { "name": "win-arm64", "inherits": [ - "default" + "default", "win-x64" ], - "generator": "Visual Studio 17 2022", "cacheVariables": { - "WindowsDesktop": "ON", - "VCPKG_HOST_TRIPLET": "arm64-windows-static-heroic", - "VCPKG_TARGET_TRIPLET": "arm64-windows-static-heroic", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON", - "BUILD_CURL_HTTP": "ON", - "VCPKG_MANIFEST_FEATURES": "wslay;curl" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - }, - "installDir": "out/win-arm64" - }, - { - "name": "win-x86", - "inherits": [ - "default" - ], - "generator": "Visual Studio 17 2022", - "architecture": "Win32", - "cacheVariables": { - "WindowsDesktop": "ON", - "VCPKG_HOST_TRIPLET": "x86-windows-release", - "VCPKG_TARGET_TRIPLET": "x86-windows-release", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON", - "BUILD_CURL_HTTP": "ON", - "VCPKG_MANIFEST_FEATURES": "wslay;curl" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Windows" - }, - "installDir": "out/win-x86" + "CMAKE_SYSTEM_PROCESSOR": "ARM64", + "VCPKG_TARGET_TRIPLET": "arm64-windows-static-heroic" + } }, { - "name": "macosx-arm64-host_arm64", + "name": "macosx-universal", "inherits": [ "default" ], - "installDir": "out/macosx-arm64", "generator": "Xcode", "cacheVariables": { - "VCPKG_HOST_TRIPLET": "arm64-osx-heroic", - "VCPKG_TARGET_TRIPLET": "arm64-osx-heroic", - "CMAKE_OSX_ARCHITECTURES": "arm64", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON", - "BUILD_CURL_HTTP": "ON", - "VCPKG_MANIFEST_FEATURES": "wslay;curl" + "VCPKG_TARGET_TRIPLET": "universal-osx-heroic", + "CMAKE_OSX_ARCHITECTURES": "arm64;x86_64", + "WITH_WS_WSLAY": "ON", + "WITH_HTTP_CURL": "ON" }, "condition": { "type": "equals", @@ -107,83 +68,24 @@ } }, { - "name": "macosx-arm64-host_x64", - "inherits": [ - "macosx-arm64-host_arm64" - ], - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-osx-heroic", - "CMAKE_OSX_ARCHITECTURES": "arm64" - }, - "installDir": "out/macosx-arm64" - }, - { - "name": "macosx-x64-host_x64", - "inherits": [ - "macosx-arm64-host_x64" - ], - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-osx-heroic", - "VCPKG_TARGET_TRIPLET": "x64-osx-heroic", - "CMAKE_OSX_ARCHITECTURES": "x86_64" - }, - "installDir": "out/macosx-x64" - }, - { - "name": "macosx-x64-host_arm64", - "inherits": [ - "macosx-x64-host_x64" - ], - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "arm64-osx-heroic", - "CMAKE_OSX_ARCHITECTURES": "x86_64" - } - }, - { - "name": "ios-arm64-host_arm64", + "name": "ios-arm64", "inherits": [ - "macosx-arm64-host_arm64" + "macosx-universal" ], "cacheVariables": { "VCPKG_TARGET_TRIPLET": "arm64-ios-heroic", "CMAKE_SYSTEM_NAME": "iOS", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON" - }, - "installDir": "out/ios-arm64" - }, - { - "name": "ios-arm64-host_x64", - "inherits": [ - "ios-arm64-host_arm64" - ], - "installDir": "out/ios-arm64", - "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "arm64-ios-heroic", - "VCPKG_HOST_TRIPLET": "x64-osx-heroic" - } - }, - { - "name": "iphonesimulator-x64-host_arm64", - "inherits": [ - "macosx-x64-host_arm64" - ], - "cacheVariables": { - "VCPKG_TARGET_TRIPLET": "x64-iphonesimulator-heroic", - "CMAKE_SYSTEM_NAME": "iOS", - "CMAKE_OSX_SYSROOT": "iphonesimulator", - "CMAKE_OSX_ARCHITECTURES": "x86_64", - "BUILD_WSLAY": "ON", - "BUILD_CURL": "ON" + "CMAKE_OSX_ARCHITECTURES": "arm64" } }, { - "name": "iphonesimulator-x64-host_x64", + "name": "iphonesimulator-arm64", "inherits": [ - "iphonesimulator-x64-host_arm64" + "ios-arm64" ], "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-osx-heroic" + "VCPKG_TARGET_TRIPLET": "arm64-iphonesimulator-heroic", + "CMAKE_OSX_SYSROOT": "iphonesimulator" } }, { @@ -198,11 +100,9 @@ "ANDROID_ARM_NEON": "ON", "ANDROID_STL": "c++_shared", "ANDROID_PLATFORM": "android-21", - "BUILD_CURL_HTTP": "ON", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON", - "CMAKE_SYSTEM_NAME": "Android", - "VCPKG_MANIFEST_FEATURES": "curl;wslay" + "WITH_HTTP_CURL": "ON", + "WITH_WS_WSLAY": "ON", + "CMAKE_SYSTEM_NAME": "Android" }, "condition": { "type": "equals", @@ -211,112 +111,24 @@ } }, { - "name": "android-arm64-v8a-host_osx_x64", + "name": "android-arm64-v8a", "inherits": [ "android-default" ], - "generator": "Ninja Multi-Config", "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-osx-heroic", "VCPKG_TARGET_TRIPLET": "arm64-android-heroic", "ANDROID_ABI": "arm64-v8a" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "installDir": "out/android-arm64-v8a" - }, - { - "name": "android-x64-host_osx_x64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-osx-heroic", - "VCPKG_TARGET_TRIPLET": "x64-android-heroic", - "ANDROID_ABI": "x86_64" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "installDir": "out/android-x64" - }, - { - "name": "android-armeabi-v7a-host_osx_x64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-osx-heroic", - "VCPKG_TARGET_TRIPLET": "arm-neon-android-heroic", - "ANDROID_ABI": "armeabi-v7a" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "installDir": "out/android-armeabi-v7a" + } }, { - "name": "android-armeabi-v7a-host_osx_arm64", + "name": "android-armeabi-v7a", "inherits": [ "android-default" ], - "generator": "Ninja Multi-Config", "cacheVariables": { - "VCPKG_HOST_TRIPLET": "arm64-osx-heroic", "VCPKG_TARGET_TRIPLET": "arm-neon-android-heroic", "ANDROID_ABI": "armeabi-v7a" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "installDir": "out/android-armeabi-v7a" - }, - { - "name": "android-arm64-v8a-host_osx_arm64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "arm64-osx-heroic", - "VCPKG_TARGET_TRIPLET": "arm64-android-heroic", - "ANDROID_ABI": "arm64-v8a" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "installDir": "out/android-arm64-v8a" - }, - { - "name": "android-x64-host_osx_arm64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "arm64-osx-heroic", - "VCPKG_TARGET_TRIPLET": "x64-android-heroic", - "ANDROID_ABI": "x86_64" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Darwin" - }, - "installDir": "out/android-x64" + } }, { "name": "linux-amd64", @@ -325,19 +137,19 @@ ], "generator": "Ninja Multi-Config", "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-linux-heroic", "VCPKG_TARGET_TRIPLET": "x64-linux-heroic", - "BUILD_CURL_HTTP": "ON", - "BUILD_WSLAY": "ON", - "BUILD_CURL_IO": "ON", - "VCPKG_MANIFEST_FEATURES": "curl;wslay" + "WITH_HTTP_CURL": "ON", + "WITH_WS_WSLAY": "ON", + "CFG_CURL_SYSTEM": "ON" + }, + "environment": { + "VCPKG_FORCE_SYSTEM_BINARIES": "1" }, "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux" - }, - "installDir": "out/linux-amd64" + } }, { "name": "ubuntu1804-amd64", @@ -350,60 +162,6 @@ "CXX": "/usr/bin/g++-11" }, "installDir": "out/ubuntu1804-amd64" - }, - { - "name": "android-armeabi-v7a-host_linux-x64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-linux-release", - "VCPKG_TARGET_TRIPLET": "arm-neon-android-heroic", - "ANDROID_ABI": "armeabi-v7a" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "installDir": "out/android-armeabi-v7a" - }, - { - "name": "android-arm64-v8a-host_linux-x64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-linux-release", - "VCPKG_TARGET_TRIPLET": "arm64-android-heroic", - "ANDROID_ABI": "arm64-v8a" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "installDir": "out/android-arm64-v8a" - }, - { - "name": "android-x64-host_linux-x64", - "inherits": [ - "android-default" - ], - "generator": "Ninja Multi-Config", - "cacheVariables": { - "VCPKG_HOST_TRIPLET": "x64-linux-release", - "VCPKG_TARGET_TRIPLET": "x64-android-heroic", - "ANDROID_ABI": "x86_64" - }, - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "installDir": "out/android-x64" } ] -} \ No newline at end of file +} diff --git a/README.md b/README.md index 5cd358762..e40fbf0a3 100644 --- a/README.md +++ b/README.md @@ -178,8 +178,6 @@ Note: to use logging macros you have to define `NLOGS_ENABLED`. Nakama C++ client has built-in support for WebSocket. This is available on all supported platforms. -Client will default to use the Websocket transport provided by [C++ REST SDK](https://github.com/microsoft/cpprestsdk). - You can use a custom Websocket transport by implementing the [NRtTransportInterface](https://github.com/heroiclabs/nakama-cpp/blob/master/include/nakama-cpp/realtime/NRtTransportInterface.h): ```cpp @@ -212,22 +210,49 @@ Then you will need to load our native library from Java by calling `System.loadL # How to build -## Prerequisite +First, clone the repository. It uses some submodules that are not publicly available and are needed to build +`nakama-sdk` on NDAed platforms. It is not an error if `./submodules/devkits` and `./submodules/private` are +not available. To clone cleanly use following commands: -You should download vcpkg (https://github.com/microsoft/vcpkg) somewhere on your machine set your $VCPKG_ROOT environment variable to point to the -repository. +``` +git clone --filter=blob:none https://github.com/heroiclabs/nakama-cpp +cd nakama-cpp +git submodule update --filter=blob:none --init ':!submodules/devkits' ':!submodules/private' +``` ### Windows -- [CMake >= 3.22](https://cmake.org/download/) +Use following command from powershell to install minimal set of required dependencies +``` +winget install Git.Git Ninja-build.Ninja Kitware.CMake + +winget install Microsoft.VisualStudio.2022.BuildTools --override ("--wait " + + "--passive " + + "--add Microsoft.VisualStudio.Component.VC.Tools.ARM " + + "--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 " + + "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 " + + "--add Microsoft.VisualStudio.Component.Windows11SDK.22621 ") +``` + + +- Git +- [CMake >= 3.29](https://cmake.org/download/) - [Ninja](https://ninja-build.org/) - [Build Tools for Visual Studio 2022](https://visualstudio.microsoft.com/downloads/) +- Windows 11 SDK v.22000 + ### Linux - CMake - Ninja - gcc-c++/clang++ +- libcurl-dev (Debian/Ubuntu) or libcurl-devel (RPM based distros) + +Fedora: +``` +sudo dnf install cmake ninja-build libcurl-devel gcc g++ +``` #### Ubuntu 18.04 @@ -299,10 +324,10 @@ Your NDK is typically located within your SDK:`/ndk/` Our prebuilt libraries target Android NDK 25.1.8937393. -### Windows 32-Bit +### Mac OSX Universal binary -We support native 32-bit builds. Keep in mind that when building from source, you must run your command -in a 32-bit (e.g., C:\Windows\System32\cmd.exe) environment. +Mac OSX preset is `macosx-universal` builds Framework with universal binaries +for x86_64 and arm64 architectures. ### Build modifiers @@ -313,19 +338,13 @@ a way to alter build behaviour of any preset with a build modifiers mechanism. Supported build modifiers are: -- `LIBHTTPCLIENT_FORCE_WEBSOCKETPP`: On Windows platforms libhttpclient always includes - websocketpp transport and uses it if Windows doesn't support websocket natively (< Windows 8). - You can set this build modifier to force use of websocketpp transport, so that it can be tested without - installing Windows 7. If you -- `WITH_LIBCXX`: dynamically link with libc++ instead of libstdc++ on Linux platform. - - `LIBCXX_STATIC`: link libc++ statically - `ADDRESS_SANITIZER`: instrument library with [AddressSanitizer](https://github.com/google/sanitizers/wiki/AddressSanitizer) Build modifiers are CMake variables passed at configure time using `-D` switch. Example use: ``` -cmake --preset linux-amd64 -DWITH_LIBCXX=ON +cmake --preset linux-amd64 -DADDRESS_SANITIZER=ON ``` ## Release @@ -339,31 +358,6 @@ You should see dynamic library and headers in the `./out` directory. This is you It is safe to combine (overlay) multiple platforms releases in the same directory structure, because binary artifacts paths won't clash and include files are identical on all platforms. -### MacOSX Universal binary - -Currently, our dependency manager can't build non-CMake based projects as universal binary. -Watch [this PR](https://github.com/microsoft/vcpkg/pull/22898) for a proper fix. Until then -building universal binaries requires building shared libs for `arm64` and `x86_64` architectures -and gluing them together with [lipo](https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary/) -tool. - -To build universal binary first compile individual shared lib for arm64 and x86_64. Following commands are for M1, -adjust preset names if you are on Intel CPU: - -``` -cmake --preset macosx-x64-host_arm64 -cmake --build build/macosx-x64-host_arm64 --config MinSizeRel --target install - -cmake --preset macosx-arm64-host_arm64 -cmake --build build/macosx-arm64-host_arm64 --config MinSizeRel --target install -``` - -``` -cp -r out/macosx-x64 out/macosx-universal -lipo -create -output out/macosx-universal/nakama-sdk.framework/Versions/A/nakama-sdk out/macosx-{arm64,x64}/nakama-sdk.framework/nakama-sdk -``` - -You can then archive and release `out/osx-universal` directory. ## Transports @@ -372,14 +366,13 @@ transports, `libhttpclient` itself can use different implementations depending o HTTP: -Platform | Transport | - --- |---------------------------| -Windows | libhttpclient -> winhttp | -Android | libcurl | -Linux | libhttpclient->curl | -MacOS | libhttpclient -> OS | -iOS | libhttpclient -> OS | -Windows 7 | libhttpclient -> websocketpp | +Platform | Transport | + --- |--------------------------| +Windows | libhttpclient -> winhttp | +Android | libcurl | +Linux | libcurl (system from OS) | +MacOS | libcurl | +iOS | libcurl | Websockets: @@ -390,7 +383,6 @@ Android | wslay | Linux | wslay | MacOS | wslay | iOS | wslay | -Windows 7 | libhttpclient -> websocketpp | # How to integrate the SDK @@ -415,7 +407,7 @@ Our SDK integrates with vcpkg by providing itself and a few dependencies through "repository": "https://github.com/heroiclabs/nakama-vcpkg-registry", "baseline": "", "reference": "", - "packages": ["nakama-sdk", "wslay"] + "packages": ["nakama-sdk"] } ] } @@ -425,10 +417,5 @@ Then you can add it as you would any other vcpkg port in your `vcpkg.json`: "dependencies": [ { "name": "nakama-sdk" - "features": [, ] }] ``` - -vcpkg does not currently allow us to provide default features per platform, so you must specify your desired transports/features in your own vcpkg.json. - -For an example, look at how our [cocos-2d-x client](https://github.com/heroiclabs/nakama-cocos2d-x.git) does this. Also see our [our built-in transports](#transports) for each platform that we represent with vcpkg features. If you do not specify a transport for the platform, the client will expect you to pass in your own at runtime. diff --git a/cmake/checkPresets.cmake b/cmake/checkPresets.cmake new file mode 100644 index 000000000..9deb1eeb4 --- /dev/null +++ b/cmake/checkPresets.cmake @@ -0,0 +1,9 @@ +if (EXISTS "${CMAKE_SOURCE_DIR}/CMakeUserPresets.json" AND EXISTS "${CMAKE_SOURCE_DIR}/submodules/private/CMakeUserPresets.json") + file(MD5 "${CMAKE_SOURCE_DIR}/CMakeUserPresets.json" LOCAL_USER_PRESETS_MD5) + file(MD5 "${CMAKE_SOURCE_DIR}/submodules/private/CMakeUserPresets.json" PRIVATE_USER_PRESETS_MD5) + if (NOT LOCAL_USER_PRESETS_MD5 STREQUAL PRIVATE_USER_PRESETS_MD5) + message(FATAL_ERROR "CMakeUserPresets.json from private repo was updated, but not copied to the project dir.") + endif() +endif() +unset(LOCAL_USER_PRESETS_MD5) +unset(PRIVATE_USER_PRESETS_MD5) diff --git a/cmake/compilerFlags.cmake b/cmake/compilerFlags.cmake index adafd068c..0806390b7 100644 --- a/cmake/compilerFlags.cmake +++ b/cmake/compilerFlags.cmake @@ -1,7 +1,3 @@ -# This file has 2 purposes: -# - included from toolchain file -# - acts as CMAKE_USER_MAKE_RULES_OVERRIDE to override default compiler flags for vcpkg - # vcpkg doesn't allow us to select MinSizeRel, only Release and Debug are available, so we # set -Os flag in release builds to get smaller binaries if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") @@ -15,26 +11,11 @@ endif() string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG_INIT "${CMAKE_C_FLAGS_DEBUG_INIT}") string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG_INIT "${CMAKE_CXX_FLAGS_DEBUG_INIT}") -# Editing _INIT has effect when this file is used as part of toolchain -string(REPLACE "/Ob1" "/Ob2" CMAKE_CXX_FLAGS_MINSIZEREL_INIT "${CMAKE_CXX_FLAGS_MINSIZEREL_INIT}") -string(REPLACE "/Ob1" "/Ob2" CMAKE_C_FLAGS_MINSIZEREL_INIT "${CMAKE_C_FLAGS_MINSIZEREL_INIT}") - # Editing non _INIT flags has effect when this file is included from CMakeLists.txt directly string(REPLACE "/Ob1" "/Ob2" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}") string(REPLACE "/Ob1" "/Ob2" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}") -# When used as toolchain CMAKE_CXX_COMPILER_ID is still empty (toolchain is loaded too early -# for it it be set) so checks above wont work as expected. To make them work we set -# CMAKE_USER_MAKE_RULES_OVERRIDE so that CMake includes this file again, but -# very late this time. -# Note that all of it should come above include_guard() ,otherwise reinclusion -# wont work. -set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_FILE}") - -# Common compilation flags. Same file used by SDK code and to build vcpkg dependencies. -include_guard() - # Minimize what's visible outside of shared lib set(CMAKE_CXX_VISIBILITY_PRESET hidden) @@ -43,7 +24,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_VISIBILITY_INLINES_HIDDEN ON) if (NOT CMAKE_BUILD_TYPE STREQUAL Debug) - set(CMAKE_INTERPROCEDURAL_OPTIMIZATION FALSE) + set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF) endif() if (NOT MSVC) @@ -52,4 +33,4 @@ if (NOT MSVC) else() string(APPEND CMAKE_C_FLAGS " /Gw /Gy") string(APPEND CMAKE_CXX_FLAGS " /Gw /Gy") -endif() \ No newline at end of file +endif() diff --git a/cmake/libHttpClient/CMakeLists.txt b/cmake/libHttpClient/CMakeLists.txt new file mode 100644 index 000000000..9894787bc --- /dev/null +++ b/cmake/libHttpClient/CMakeLists.txt @@ -0,0 +1,54 @@ +# Upstream libHttpClient stopped offering CMake based builds +# This file recreates same experience by (pooorly) reading upstream .vcxproj +set(LHC_ROOT "${CMAKE_SOURCE_DIR}/submodules/libHttpClient") + +include(CMakePrintHelpers) + +# Reads ClInclude from $1 and returns list of absolute paths in $2 +function(vcxproj_read_file_list) + cmake_path(GET ARGV0 PARENT_PATH BASEDIR) + file(READ "${ARGV0}" RAW) + STRING(REGEX MATCHALL [=[<(ClInclude|ClCompile) Include="[^"]+"]=] CLINCLUDES_RAW "${RAW}") + list(TRANSFORM CLINCLUDES_RAW REPLACE [=[<(ClInclude|ClCompile) Include="\$\(MSBuildThisFileDirectory\)([^"]+)"]=] "\\2" OUTPUT_VARIABLE CLINCLUDES) + foreach (P ${CLINCLUDES}) + cmake_path(ABSOLUTE_PATH P BASE_DIRECTORY "${BASEDIR}" NORMALIZE) + list(APPEND OUT "${P}") + endforeach () + set(${ARGV1} ${OUT} PARENT_SCOPE) +endfunction() + +vcxproj_read_file_list("${LHC_ROOT}/Build/libHttpClient.Common/libHttpClient.Common.vcxitems" COMMON_FILES) +vcxproj_read_file_list("${LHC_ROOT}/Build/libHttpClient.XAsync/libHttpClient.XAsync.vcxitems" XASYNC_FILES) +vcxproj_read_file_list("${LHC_ROOT}/Build/libHttpClient.Win32.Shared/libHttpClient.Win32.Shared.vcxitems" WIN32_SHARED_FILES) +vcxproj_read_file_list("${LHC_ROOT}/Build/libHttpClient.GDK.Shared/libHttpClient.GDK.Shared.vcxitems" GDK_SHARED_FILES) + +if (GDK) + set(FILES ${COMMON_FILES} ${GDK_SHARED_FILES}) +elseif (WIN32) + set(FILES ${COMMON_FILES} ${XASYNC_FILES} ${WIN32_SHARED_FILES}) +else() + message(FATAL_ERROR "libHTTPClient is supported only on Windows-based platforms") +endif() + +find_package(ZLIB REQUIRED) + +add_library(libHttpClient OBJECT ${FILES}) +target_include_directories(libHttpClient + PUBLIC + ${LHC_ROOT}/Include + PRIVATE + ${LHC_ROOT}/Source + ${LHC_ROOT}/Source/Common +) +if (NOT WITH_WS_LIBHTTPC) + target_compile_definitions(libHttpClient PUBLIC "HC_NOWEBSOCKETS") +endif() +target_link_libraries(libHttpClient PRIVATE + ZLIB::ZLIB + "Appnotify.lib" + "winhttp.lib" + "crypt32.lib" +) + +#set_target_properties(libHttpClient PROPERTIES LINKER_LANGUAGE CXX) + diff --git a/cmake/libhttpClient.cmake b/cmake/libhttpClient.cmake new file mode 100644 index 000000000..4528bc2cb --- /dev/null +++ b/cmake/libhttpClient.cmake @@ -0,0 +1,26 @@ +if (LINUX OR APPLE) + find_package(CURL CONFIG REQUIRED) + target_compile_definitions(CURL::libcurl INTERFACE CURL_STRICTER) +endif() + +if (ANDROID) + ## force libhttpclient to build statically + set(WAS_SHARED_LIBS ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS OFF) + set(LIBHTTPCLIENT_SOURCE_SUBDIR "Build/libHttpClient.Android") + add_subdirectory("${CMAKE_SOURCE_DIR}/submodules/libHttpClient/${LIBHTTPCLIENT_SOURCE_SUBDIR}") + set(BUILD_SHARED_LIBS ${WAS_SHARED_LIBS}) + set(LIBHTTPCLIENT_TARGET libHttpClient.Android) +else () + add_subdirectory(cmake/libHttpClient) + set(LIBHTTPCLIENT_TARGET libHttpClient) +endif() + +if (GDK) + include(submodules/devkits/cmake/gdk-targets.cmake) + target_link_libraries(libHttpClient PRIVATE GDK::XCurl) +endif() + +if (NOT WITH_WS_LIBHTTPC) + target_compile_definitions(libHttpClient PRIVATE "HC_NOWEBSOCKETS") +endif() diff --git a/cmake/linkerFlags.cmake b/cmake/linkerFlags.cmake index c01f200fb..7469083cd 100644 --- a/cmake/linkerFlags.cmake +++ b/cmake/linkerFlags.cmake @@ -5,4 +5,6 @@ if(MSVC) ) elseif(CMAKE_CXX_COMPILER_ID MATCHES "^Apple") add_link_options(-Wl,-dead_strip) +else() + add_link_options(-Wl,--gc-sections) endif() diff --git a/cmake/platformSupport.cmake b/cmake/platformSupport.cmake index 963fc9195..b37576338 100644 --- a/cmake/platformSupport.cmake +++ b/cmake/platformSupport.cmake @@ -1,15 +1,13 @@ -# Various platform specific defines +# NDAed platforms might configure it already +if (__PLATFORM_SUPPORT_CONFIGURED) + return() +endif() +# Various platform specific defines if (CMAKE_SYSTEM_NAME STREQUAL Windows OR WindowsDesktop) - set(WindowsDesktop ON) - message("Configuring Windows Desktop build") - # Sets minimual Windows version we are targeting - # https://docs.microsoft.com/en-us/windows/win32/WinProg/using-the-windows-headers - add_compile_definitions(NTDDI_VERSION=NTDDI_WIN7 _WIN32_WINNT=_WIN32_WINNT_WIN7) - set(BUILDWIN32 ON) # libhttpclient + add_compile_definitions(_UNICODE UNICODE) set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_LIBDIR}) # place .dll where .lib is so that multiplatform archives can be created elseif(CMAKE_SYSTEM_NAME STREQUAL Darwin) - set(Darwin) message("Configuring Apple MacOSX build") # when changing, dont forget also set it in {arm64,x64}-osx-heroic vcpkg triplet # NOTE: we can't use CMAKE_SYSTEM_PROCESSOR here because it is always arm64 on M1 silicon for some reason @@ -26,7 +24,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL iOS) message("Configuring Apple iOS build") # Don't forget to edit ./cmake/triplets too! # Value is picked based on https://developer.apple.com/support/app-store/ numbers - set(CMAKE_OSX_DEPLOYMENT_TARGET "11") + set(CMAKE_OSX_DEPLOYMENT_TARGET "12") set(CMAKE_OSX_ARCHITECTURES "arm64") elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") message("Configuring Linux build") @@ -35,3 +33,5 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") find_package(Threads REQUIRED) set(PTHREADS_LIB Threads::Threads) endif() + +set(__PLATFORM_SUPPORT_CONFIGURED ON) diff --git a/cmake/toolchains/msvc/VSWhere.cmake b/cmake/toolchains/msvc/VSWhere.cmake new file mode 100644 index 000000000..c2ea310a9 --- /dev/null +++ b/cmake/toolchains/msvc/VSWhere.cmake @@ -0,0 +1,132 @@ +#---------------------------------------------------------------------------------------------------------------------- +# MIT License +# +# Copyright (c) 2021 Mark Schofield +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#---------------------------------------------------------------------------------------------------------------------- +include_guard() + +#[[==================================================================================================================== + toolchain_validate_vs_files + --------------------------- + + Note: Not supported for consumption outside of the toolchain files. + + Validates the the specified folder exists and contains the specified files. + + toolchain_validate_vs_files( + > + > + ...> + ) + + If the folder or files are missing, then a FATAL_ERROR is reported. +====================================================================================================================]]# +function(toolchain_validate_vs_files) + set(OPTIONS) + set(ONE_VALUE_KEYWORDS FOLDER DESCRIPTION) + set(MULTI_VALUE_KEYWORDS FILES) + + cmake_parse_arguments(PARSE_ARGV 0 VS "${OPTIONS}" "${ONE_VALUE_KEYWORDS}" "${MULTI_VALUE_KEYWORDS}") + + if(NOT EXISTS ${VS_FOLDER}) + message(FATAL_ERROR "Folder not present - ${VS_FOLDER} - ensure that the ${VS_DESCRIPTION} are installed with Visual Studio.") + endif() + + foreach(FILE ${VS_FILES}) + if(NOT EXISTS "${VS_FOLDER}/${FILE}") + message(FATAL_ERROR "File not present - ${VS_FOLDER}/${FILE} - ensure that the ${VS_DESCRIPTION} are installed with Visual Studio.") + endif() + endforeach() +endfunction() + +#[[==================================================================================================================== + findVisualStudio + ---------------- + + Finds a Visual Studio instance, and sets CMake variables based on properties of the found instance. + + findVisualStudio( + [VERSION ] + [PRERELEASE ] + [PRODUCTS ] + [REQUIRES ...] + PROPERTIES + < > + ) +====================================================================================================================]]# +function(findVisualStudio) + set(OPTIONS) + set(ONE_VALUE_KEYWORDS VERSION PRERELEASE PRODUCTS) + set(MULTI_VALUE_KEYWORDS REQUIRES PROPERTIES) + + cmake_parse_arguments(PARSE_ARGV 0 FIND_VS "${OPTIONS}" "${ONE_VALUE_KEYWORDS}" "${MULTI_VALUE_KEYWORDS}") + + find_program(VSWHERE_PATH + NAMES vswhere vswhere.exe + HINTS "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/Installer" + ) + + if(VSWHERE_PATH STREQUAL "VSWHERE_PATH-NOTFOUND") + message(FATAL_ERROR "'vswhere' isn't found.") + endif() + + set(VSWHERE_COMMAND ${VSWHERE_PATH} -latest) + + if(FIND_VS_PRERELEASE) + list(APPEND VSWHERE_COMMAND -prerelease) + endif() + + if(FIND_VS_PRODUCTS) + list(APPEND VSWHERE_COMMAND -products ${FIND_VS_PRODUCTS}) + endif() + + if(FIND_VS_REQUIRES) + list(APPEND VSWHERE_COMMAND -requires ${FIND_VS_REQUIRES}) + endif() + + if(FIND_VS_VERSION) + list(APPEND VSWHERE_COMMAND -version "${FIND_VS_VERSION}") + endif() + + message(VERBOSE "findVisualStudio: VSWHERE_COMMAND = ${VSWHERE_COMMAND}") + + execute_process( + COMMAND ${VSWHERE_COMMAND} + OUTPUT_VARIABLE VSWHERE_OUTPUT + ) + + message(VERBOSE "findVisualStudio: VSWHERE_OUTPUT = ${VSWHERE_OUTPUT}") + + # Matches `VSWHERE_PROPERTY` in the `VSWHERE_OUTPUT` text in the format written by vswhere. + # The matched value is assigned to the variable `VARIABLE_NAME` in the parent scope. + function(getVSWhereProperty VSWHERE_OUTPUT VSWHERE_PROPERTY VARIABLE_NAME) + string(REGEX MATCH "${VSWHERE_PROPERTY}: [^\r\n]*" VSWHERE_VALUE "${VSWHERE_OUTPUT}") + string(REPLACE "${VSWHERE_PROPERTY}: " "" VSWHERE_VALUE "${VSWHERE_VALUE}") + set(${VARIABLE_NAME} "${VSWHERE_VALUE}" PARENT_SCOPE) + endfunction() + + while(FIND_VS_PROPERTIES) + list(POP_FRONT FIND_VS_PROPERTIES VSWHERE_PROPERTY) + list(POP_FRONT FIND_VS_PROPERTIES VSWHERE_CMAKE_VARIABLE) + getVSWhereProperty("${VSWHERE_OUTPUT}" ${VSWHERE_PROPERTY} VSWHERE_VALUE) + set(${VSWHERE_CMAKE_VARIABLE} ${VSWHERE_VALUE} PARENT_SCOPE) + endwhile() +endfunction() diff --git a/cmake/toolchains/msvc/Windows.Kits.cmake b/cmake/toolchains/msvc/Windows.Kits.cmake new file mode 100644 index 000000000..72228f386 --- /dev/null +++ b/cmake/toolchains/msvc/Windows.Kits.cmake @@ -0,0 +1,155 @@ +#---------------------------------------------------------------------------------------------------------------------- +# MIT License +# +# Copyright (c) 2021 Mark Schofield +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#---------------------------------------------------------------------------------------------------------------------- +# +# | CMake Variable | Description | +# |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------| +# | CMAKE_SYSTEM_VERSION | The version of the operating system for which CMake is to build. Defaults to the host version. | +# | CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE | The architecture of the tooling to use. Defaults to 'arm64' on ARM64 systems, otherwise 'x64'. | +# | CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION | The version of the Windows SDK to use. Defaults to the highest installed, that is no higher than CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM | +# | CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM | The maximum version of the Windows SDK to use, for example '10.0.19041.0'. Defaults to nothing | +# | CMAKE_WINDOWS_KITS_10_DIR | The location of the root of the Windows Kits 10 directory. | +# +# The following variables will be set: +# +# | CMake Variable | Description | +# |---------------------------------------------|-------------------------------------------------------------------------------------------------------| +# | CMAKE_MT | The path to the 'mt' tool. | +# | CMAKE_RC_COMPILER | The path to the 'rc' tool. | +# | CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION | The version of the Windows SDK to be used. | +# | MDMERGE_TOOL | The path to the 'mdmerge' tool. | +# | MIDL_COMPILER | The path to the 'midl' compiler. | +# | WINDOWS_KITS_BIN_PATH | The path to the folder containing the Windows Kits binaries. | +# | WINDOWS_KITS_INCLUDE_PATH | The path to the folder containing the Windows Kits include files. | +# | WINDOWS_KITS_LIB_PATH | The path to the folder containing the Windows Kits library files. | +# | WINDOWS_KITS_REFERENCES_PATH | The path to the folder containing the Windows Kits references. | +# +include_guard() + +if(NOT CMAKE_SYSTEM_VERSION) + set(CMAKE_SYSTEM_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) +endif() + +if(NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE) + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL ARM64) + set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE arm64) + else() + set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE x64) + endif() +endif() + +if(NOT CMAKE_WINDOWS_KITS_10_DIR) + get_filename_component(CMAKE_WINDOWS_KITS_10_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;InstallationFolder]" ABSOLUTE CACHE) + if ("${CMAKE_WINDOWS_KITS_10_DIR}" STREQUAL "/registry") + unset(CMAKE_WINDOWS_KITS_10_DIR) + endif() +endif() + +if(NOT CMAKE_WINDOWS_KITS_10_DIR) + message(FATAL_ERROR "Unable to find an installed Windows SDK, and one wasn't specified.") +endif() + +# If a CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION wasn't specified, find the highest installed version that is no higher +# than the host version +if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + file(GLOB WINDOWS_KITS_VERSIONS RELATIVE "${CMAKE_WINDOWS_KITS_10_DIR}/lib" "${CMAKE_WINDOWS_KITS_10_DIR}/lib/*") + list(FILTER WINDOWS_KITS_VERSIONS INCLUDE REGEX "10\\.0\\.") + list(SORT WINDOWS_KITS_VERSIONS COMPARE NATURAL ORDER DESCENDING) + while(WINDOWS_KITS_VERSIONS) + list(POP_FRONT WINDOWS_KITS_VERSIONS CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM) + message(VERBOSE "Windows.Kits: Defaulting version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") + break() + endif() + + if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS_EQUAL CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM) + message(VERBOSE "Windows.Kits: Choosing version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") + break() + endif() + + message(VERBOSE "Windows.Kits: Not suitable: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}") + set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + endwhile() +endif() + +if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + message(FATAL_ERROR "A Windows SDK could not be found.") +endif() + +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION) + +set(WINDOWS_KITS_BIN_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "" FORCE) +set(WINDOWS_KITS_INCLUDE_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/include/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "" FORCE) +set(WINDOWS_KITS_LIB_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "" FORCE) +set(WINDOWS_KITS_REFERENCES_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/References" CACHE PATH "" FORCE) +set(WINDOWS_KITS_PLATFORM_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/Platforms/UAP/${CMAKE_SYSTEM_VERSION}/Platform.xml" CACHE PATH "" FORCE) + +if(NOT EXISTS ${WINDOWS_KITS_BIN_PATH}) + message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} cannot be found: Folder '${WINDOWS_KITS_BIN_PATH}' does not exist.") +endif() + +if(NOT EXISTS ${WINDOWS_KITS_INCLUDE_PATH}) + message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} cannot be found: Folder '${WINDOWS_KITS_INCLUDE_PATH}' does not exist.") +endif() + +if(NOT EXISTS ${WINDOWS_KITS_LIB_PATH}) + message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} cannot be found: Folder '${WINDOWS_KITS_LIB_PATH}' does not exist.") +endif() + +set(CMAKE_MT "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/mt.exe") +set(CMAKE_RC_COMPILER_INIT "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/rc.exe") +set(CMAKE_RC_FLAGS_INIT "/nologo") + +set(MIDL_COMPILER "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/midl.exe") +set(MDMERGE_TOOL "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/mdmerge.exe") + +# Windows SDK +if(CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64) + set(WINDOWS_KITS_TARGET_ARCHITECTURE x64) +elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL ARM) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL ARM64) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL X86)) + set(WINDOWS_KITS_TARGET_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x64) + message(WARNING "CMAKE_SYSTEM_PROCESSOR should be 'AMD64', not 'x64'. WindowsToolchain will stop recognizing 'x64' in a future release.") + set(WINDOWS_KITS_TARGET_ARCHITECTURE x64) +elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL x86)) + message(WARNING "CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR}) should be upper-case. WindowsToolchain will stop recognizing non-upper-case forms in a future release.") + set(WINDOWS_KITS_TARGET_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +else() + message(FATAL_ERROR "Unable identify Windows Kits architecture for CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}") +endif() + +foreach(LANG C CXX RC) + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/ucrt") + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/shared") + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/um") + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/winrt") + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/cppwinrt") +endforeach() + +link_directories(BEFORE "${WINDOWS_KITS_LIB_PATH}/ucrt/${WINDOWS_KITS_TARGET_ARCHITECTURE}") +link_directories(BEFORE "${WINDOWS_KITS_LIB_PATH}/um/${WINDOWS_KITS_TARGET_ARCHITECTURE}") +link_directories(BEFORE "${WINDOWS_KITS_REFERENCES_PATH}/${WINDOWS_KITS_TARGET_ARCHITECTURE}") diff --git a/cmake/toolchains/msvc/Windows.MSVC.toolchain.cmake b/cmake/toolchains/msvc/Windows.MSVC.toolchain.cmake new file mode 100644 index 000000000..ac81c8d9f --- /dev/null +++ b/cmake/toolchains/msvc/Windows.MSVC.toolchain.cmake @@ -0,0 +1,247 @@ +#---------------------------------------------------------------------------------------------------------------------- +# MIT License +# +# Copyright (c) 2021 Mark Schofield +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. +#---------------------------------------------------------------------------------------------------------------------- +# +# This CMake toolchain file configures a CMake, non-'Visual Studio Generator' build to use +# the MSVC compilers and tools. +# +# The following variables can be used to configure the behavior of this toolchain file: +# +# | CMake Variable | Description | +# |---------------------------------------------|--------------------------------------------------------------------------------------------------------------------------| +# | CMAKE_SYSTEM_PROCESSOR | The processor to compiler for. One of 'X86', 'AMD64', 'ARM', 'ARM64'. Defaults to ${CMAKE_HOST_SYSTEM_PROCESSOR}. | +# | CMAKE_SYSTEM_VERSION | The version of the operating system for which CMake is to build. Defaults to the host version. | +# | CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE | The architecture of the tooling to use. Defaults to 'arm64' on ARM64 systems, otherwise 'x64'. | +# | CMAKE_VS_PRODUCTS | One or more Visual Studio Product IDs to consider. Defaults to '*' | +# | CMAKE_VS_VERSION_PRERELEASE | Whether 'prerelease' versions of Visual Studio should be considered. Defaults to 'OFF' | +# | CMAKE_VS_VERSION_RANGE | A verson range for VS instances to find. For example, '[16.0,17.0)' will find versions '16.*'. Defaults to '[16.0,17.0)' | +# | CMAKE_WINDOWS_KITS_10_DIR | The location of the root of the Windows Kits 10 directory. | +# | VS_EXPERIMENTAL_MODULE | Whether experimental module support should be enabled. | +# | VS_INSTALLATION_PATH | The location of the root of the Visual Studio installation. If not specified VSWhere will be used to search for one. | +# | VS_PLATFORM_TOOLSET_VERSION | The version of the MSVC toolset to use. For example, 14.29.30133. Defaults to the highest available. | +# | VS_USE_SPECTRE_MITIGATION_ATLMFC_RUNTIME | Whether the compiler should link with the ATLMFC runtime that uses 'Spectre' mitigations. Defaults to 'OFF'. | +# | VS_USE_SPECTRE_MITIGATION_RUNTIME | Whether the compiler should link with a runtime that uses 'Spectre' mitigations. Defaults to 'OFF'. | +# +# The toolchain file will set the following variables: +# +# | CMake Variable | Description | +# |---------------------------------------------|-------------------------------------------------------------------------------------------------------| +# | CMAKE_C_COMPILER | The path to the C compiler to use. | +# | CMAKE_CXX_COMPILER | The path to the C++ compiler to use. | +# | CMAKE_MT | The path to the 'mt.exe' tool to use. | +# | CMAKE_RC_COMPILER | The path tp the 'rc.exe' tool to use. | +# | CMAKE_SYSTEM_NAME | Windows | +# | CMAKE_VS_PLATFORM_TOOLSET_VERSION | The version of the MSVC toolset being used - e.g. 14.29.30133. | +# | WIN32 | 1 | +# | MSVC | 1 | +# | MSVC_VERSION | The '' version of the C++ compiler being used. For example, '1929' | +# +# Other configuration: +# +# * If the 'CMAKE_CUDA_COMPILER' is set, and 'CMAKE_CUDA_HOST_COMPILER' is not set, and ENV{CUDAHOSTCXX} not defined +# then 'CMAKE_CUDA_HOST_COMPILER' is set to the value of 'CMAKE_CXX_COMPILER'. +# +# Resources: +# +# +cmake_minimum_required(VERSION 3.20) + +include_guard() + +if(NOT (CMAKE_HOST_SYSTEM_NAME STREQUAL Windows)) + return() +endif() + +set(UNUSED ${CMAKE_TOOLCHAIN_FILE}) # Note: only to prevent cmake unused variable warninig +set(CMAKE_SYSTEM_NAME Windows) +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + CMAKE_CROSSCOMPILING + CMAKE_SYSTEM_PROCESSOR + CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE + CMAKE_VS_PRODUCTS + CMAKE_VS_VERSION_PRERELEASE + CMAKE_VS_VERSION_RANGE + VS_INSTALLATION_PATH + VS_INSTALLATION_VERSION + VS_PLATFORM_TOOLSET_VERSION +) +set(CMAKE_CROSSCOMPILING TRUE) +set(WIN32 1) +set(MSVC 1) + +include("${CMAKE_CURRENT_LIST_DIR}/VSWhere.cmake") + +if(NOT CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR ${CMAKE_HOST_SYSTEM_PROCESSOR}) +endif() + +if(NOT CMAKE_VS_VERSION_RANGE) + set(CMAKE_VS_VERSION_RANGE "[16.0,)") +endif() + +if(NOT CMAKE_VS_VERSION_PRERELEASE) + set(CMAKE_VS_VERSION_PRERELEASE OFF) +endif() + +if(NOT CMAKE_VS_PRODUCTS) + set(CMAKE_VS_PRODUCTS "*") +endif() + +if(NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE) + if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL ARM64) + set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE arm64) + else() + set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE x64) + endif() +endif() + +if(NOT VS_USE_SPECTRE_MITIGATION_RUNTIME) + set(VS_USE_SPECTRE_MITIGATION_RUNTIME OFF) +endif() + +# Find Visual Studio +# +if(NOT VS_INSTALLATION_PATH) + findVisualStudio( + VERSION ${CMAKE_VS_VERSION_RANGE} + PRERELEASE ${CMAKE_VS_VERSION_PRERELEASE} + PRODUCTS ${CMAKE_VS_PRODUCTS} + PROPERTIES + installationVersion VS_INSTALLATION_VERSION + installationPath VS_INSTALLATION_PATH + ) +endif() + +message(VERBOSE "VS_INSTALLATION_VERSION = ${VS_INSTALLATION_VERSION}") +message(VERBOSE "VS_INSTALLATION_PATH = ${VS_INSTALLATION_PATH}") + +if(NOT VS_INSTALLATION_PATH) + message(FATAL_ERROR "Unable to find Visual Studio") +endif() + +cmake_path(NORMAL_PATH VS_INSTALLATION_PATH) + +set(VS_MSVC_PATH "${VS_INSTALLATION_PATH}/VC/Tools/MSVC") + +# Use 'VS_PLATFORM_TOOLSET_VERSION' to resolve 'CMAKE_VS_PLATFORM_TOOLSET_VERSION' +# +if(NOT VS_PLATFORM_TOOLSET_VERSION) + if(VS_TOOLSET_VERSION) + message(WARNING "Old versions of WindowsToolchain incorrectly used 'VS_TOOLSET_VERSION' to specify the VS toolset version. This functionality is being deprecated - please use 'VS_PLATFORM_TOOLSET_VERSION' instead.") + set(VS_PLATFORM_TOOLSET_VERSION ${VS_TOOLSET_VERSION}) + else() + file(GLOB VS_PLATFORM_TOOLSET_VERSIONS RELATIVE ${VS_MSVC_PATH} ${VS_MSVC_PATH}/*) + list(SORT VS_PLATFORM_TOOLSET_VERSIONS COMPARE NATURAL ORDER DESCENDING) + list(POP_FRONT VS_PLATFORM_TOOLSET_VERSIONS VS_PLATFORM_TOOLSET_VERSION) + unset(VS_PLATFORM_TOOLSET_VERSIONS) + endif() +endif() + +set(CMAKE_VS_PLATFORM_TOOLSET_VERSION ${VS_PLATFORM_TOOLSET_VERSION}) +set(VS_TOOLSET_PATH "${VS_INSTALLATION_PATH}/VC/Tools/MSVC/${CMAKE_VS_PLATFORM_TOOLSET_VERSION}") + +# Set the tooling variables, include_directories and link_directories +# + +# Map CMAKE_SYSTEM_PROCESSOR values to CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE that identifies the tools that should +# be used to produce code for the CMAKE_SYSTEM_PROCESSOR. +if(CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64) + set(CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE x64) +elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL ARM) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL ARM64) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL X86)) + set(CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x64) + message(WARNING "CMAKE_SYSTEM_PROCESSOR should be 'AMD64', not 'x64'. WindowsToolchain will stop recognizing 'x64' in a future release.") + set(CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE x64) +elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL arm64) + OR (CMAKE_SYSTEM_PROCESSOR STREQUAL x86)) + message(WARNING "CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR}) should be upper-case. WindowsToolchain will stop recognizing non-upper-case forms in a future release.") + set(CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR}) +else() + message(FATAL_ERROR "Unable identify compiler architecture for CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}") +endif() + +set(CMAKE_CXX_COMPILER "${VS_TOOLSET_PATH}/bin/Host${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}/cl.exe") +set(CMAKE_C_COMPILER "${VS_TOOLSET_PATH}/bin/Host${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}/cl.exe") + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL ARM) + set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} /EHsc") +elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + message(WARNING "CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR}) should be upper-case. WindowsToolchain will stop recognizing non-upper-case forms in a future release.") + set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} /EHsc") +endif() + +# Compiler +foreach(LANG C CXX RC) + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${VS_TOOLSET_PATH}/ATLMFC/include") + list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${VS_TOOLSET_PATH}/include") +endforeach() + +if(VS_USE_SPECTRE_MITIGATION_ATLMFC_RUNTIME) + # Ensure that the necessary folder and files are present before adding the 'link_directories' + toolchain_validate_vs_files( + DESCRIPTION "ATLMFC Spectre libraries" + FOLDER "${VS_TOOLSET_PATH}/ATLMFC/lib/spectre/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}" + FILES + atls.lib + ) + link_directories("${VS_TOOLSET_PATH}/ATLMFC/lib/spectre/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}") +else() + link_directories("${VS_TOOLSET_PATH}/ATLMFC/lib/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}") +endif() + +if(VS_USE_SPECTRE_MITIGATION_RUNTIME) + # Ensure that the necessary folder and files are present before adding the 'link_directories' + toolchain_validate_vs_files( + DESCRIPTION "Spectre libraries" + FOLDER "${VS_TOOLSET_PATH}/lib/spectre/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}" + FILES + msvcrt.lib vcruntime.lib vcruntimed.lib + ) + link_directories("${VS_TOOLSET_PATH}/lib/spectre/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}") +else() + link_directories("${VS_TOOLSET_PATH}/lib/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}") +endif() + +link_directories("${VS_TOOLSET_PATH}/lib/x86/store/references") + +# Module support +if(VS_EXPERIMENTAL_MODULE) + set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} /experimental:module") + set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} /stdIfcDir \"${VS_TOOLSET_PATH}/ifc/${CMAKE_VS_PLATFORM_TOOLSET_ARCHITECTURE}\"") +endif() + +# Windows Kits +include("${CMAKE_CURRENT_LIST_DIR}/Windows.Kits.cmake") + +# CUDA support +# +# If a CUDA compiler is specified, and a host compiler wasn't specified, set 'CMAKE_CXX_COMPILER' +# as the host compiler. +if(CMAKE_CUDA_COMPILER) + if((NOT CMAKE_CUDA_HOST_COMPILER) AND (NOT DEFINED ENV{CUDAHOSTCXX})) + set(CMAKE_CUDA_HOST_COMPILER "${CMAKE_CXX_COMPILER}") + endif() +endif() diff --git a/cmake/toolchains/vcpkg-msvc.cmake b/cmake/toolchains/vcpkg-msvc.cmake new file mode 100644 index 000000000..dcec07743 --- /dev/null +++ b/cmake/toolchains/vcpkg-msvc.cmake @@ -0,0 +1,26 @@ +# wrapper toolchain, which translates VCPKG_ vars into CMake vars +if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") + set(CMAKE_SYSTEM_PROCESSOR "AMD64") +elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") + set(CMAKE_SYSTEM_PROCESSOR "ARM64") +else() + message(FATAL_ERROR "Unsupported arch ${VCPKG_TARGET_ARCHITECTURE}") +endif() + +if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION) + set(CMAKE_SYSTEM_VERSION "${VCPKG_CMAKE_SYSTEM_VERSION}" CACHE STRING "" FORCE) + set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION "${VCPKG_CMAKE_SYSTEM_VERSION}") +elseif(NOT DEFINED CMAKE_SYSTEM_VERSION) + message(FATAL_ERROR "BUG: We should align vcpkg dependencies and our project on Windows SDK version. Include triplet vars in main project") +endif() + +list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES + VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE + VCPKG_C_FLAGS VCPKG_CXX_FLAGS + VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG + VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE + VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG + VCPKG_PLATFORM_TOOLSET CMAKE_SYSTEM_VERSION +) + +include("${CMAKE_CURRENT_LIST_DIR}/msvc/Windows.MSVC.toolchain.cmake") diff --git a/cmake/triplets/arm64-ios-heroic.cmake b/cmake/triplets/arm64-ios-heroic.cmake index 4a689f0f2..8353cb0f0 100644 --- a/cmake/triplets/arm64-ios-heroic.cmake +++ b/cmake/triplets/arm64-ios-heroic.cmake @@ -5,7 +5,7 @@ set(VCPKG_CMAKE_SYSTEM_NAME iOS) # HeroicLabs additions to standard triplets: set(VCPKG_BUILD_TYPE release) -set(VCPKG_OSX_DEPLOYMENT_TARGET "11") +set(VCPKG_OSX_DEPLOYMENT_TARGET "12") set(VCPKG_OSX_ARCHITECTURES "arm64") include(${CMAKE_CURRENT_LIST_DIR}/feature-visibility-hidden.cmake) diff --git a/cmake/triplets/x64-iphonesimulator-heroic.cmake b/cmake/triplets/arm64-iphonesimulator-heroic.cmake similarity index 60% rename from cmake/triplets/x64-iphonesimulator-heroic.cmake rename to cmake/triplets/arm64-iphonesimulator-heroic.cmake index 4f519776a..e3f53857e 100644 --- a/cmake/triplets/x64-iphonesimulator-heroic.cmake +++ b/cmake/triplets/arm64-iphonesimulator-heroic.cmake @@ -1,12 +1,12 @@ -set(VCPKG_TARGET_ARCHITECTURE x64) +set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME iOS) -# Heroic Labs additions to standard triplets: +# HeroicLabs additions to standard triplets: set(VCPKG_BUILD_TYPE release) -set(VCPKG_OSX_DEPLOYMENT_TARGET "11") -set(VCPKG_OSX_ARCHITECTURES "x86_64") +set(VCPKG_OSX_DEPLOYMENT_TARGET "12") +set(VCPKG_OSX_ARCHITECTURES "arm64") set(VCPKG_OSX_SYSROOT iphonesimulator) include(${CMAKE_CURRENT_LIST_DIR}/feature-visibility-hidden.cmake) diff --git a/cmake/triplets/arm64-windows-static-heroic.cmake b/cmake/triplets/arm64-windows-static-heroic.cmake index aaa82bc49..e1b3d6114 100644 --- a/cmake/triplets/arm64-windows-static-heroic.cmake +++ b/cmake/triplets/arm64-windows-static-heroic.cmake @@ -1,9 +1,8 @@ set(VCPKG_TARGET_ARCHITECTURE arm64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) -set(CMAKE_GENERATOR Visual Studio 17 2022) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/vcpkg-msvc.cmake") +set(VCPKG_CMAKE_SYSTEM_VERSION "10.0.22621.0") string(APPEND VCPKG_C_FLAGS_RELEASE " /O1 /Ob2 /Gw /Gy") string(APPEND VCPKG_CXX_FLAGS_RELEASE " /O1 /Ob2 /Gw /Gy") - -list(APPEND VCPKG_KEEP_ENV_VARS "PATH" "Path") diff --git a/cmake/triplets/arm64-osx-heroic.cmake b/cmake/triplets/universal-osx-heroic.cmake similarity index 88% rename from cmake/triplets/arm64-osx-heroic.cmake rename to cmake/triplets/universal-osx-heroic.cmake index df4f8ee84..a90cdc7de 100644 --- a/cmake/triplets/arm64-osx-heroic.cmake +++ b/cmake/triplets/universal-osx-heroic.cmake @@ -4,7 +4,7 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_BUILD_TYPE release) set(VCPKG_CMAKE_SYSTEM_NAME Darwin) -set(VCPKG_OSX_ARCHITECTURES arm64) +set(VCPKG_OSX_ARCHITECTURES "arm64;x86_64") # HeroicLabs additions to standard triplets: set(VCPKG_OSX_DEPLOYMENT_TARGET "11") diff --git a/cmake/triplets/x64-linux-heroic.cmake b/cmake/triplets/x64-linux-heroic.cmake index d7f3e2b25..8f9594aef 100644 --- a/cmake/triplets/x64-linux-heroic.cmake +++ b/cmake/triplets/x64-linux-heroic.cmake @@ -4,3 +4,5 @@ set(VCPKG_LIBRARY_LINKAGE static) set(VCPKG_CMAKE_SYSTEM_NAME Linux) set(VCPKG_BUILD_TYPE release) + +include(${CMAKE_CURRENT_LIST_DIR}/feature-visibility-hidden.cmake) diff --git a/cmake/triplets/x64-osx-heroic.cmake b/cmake/triplets/x64-osx-heroic.cmake deleted file mode 100644 index 94de10433..000000000 --- a/cmake/triplets/x64-osx-heroic.cmake +++ /dev/null @@ -1,11 +0,0 @@ -set(VCPKG_TARGET_ARCHITECTURE x64) -set(VCPKG_CRT_LINKAGE dynamic) -set(VCPKG_LIBRARY_LINKAGE static) -set(VCPKG_BUILD_TYPE release) - -set(VCPKG_CMAKE_SYSTEM_NAME Darwin) -set(VCPKG_OSX_ARCHITECTURES x86_64) - -# Heroic Labs additions to standard triplets: -set(VCPKG_OSX_DEPLOYMENT_TARGET "10.15") -include(${CMAKE_CURRENT_LIST_DIR}/feature-visibility-hidden.cmake) \ No newline at end of file diff --git a/cmake/triplets/x64-windows-static-heroic.cmake b/cmake/triplets/x64-windows-static-heroic.cmake index f51a82afd..6b795ed4e 100644 --- a/cmake/triplets/x64-windows-static-heroic.cmake +++ b/cmake/triplets/x64-windows-static-heroic.cmake @@ -1,9 +1,8 @@ set(VCPKG_TARGET_ARCHITECTURE x64) set(VCPKG_CRT_LINKAGE dynamic) set(VCPKG_LIBRARY_LINKAGE static) -set(CMAKE_GENERATOR Visual Studio 17 2022) +set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/../toolchains/vcpkg-msvc.cmake") +set(VCPKG_CMAKE_SYSTEM_VERSION "10.0.22621.0") string(APPEND VCPKG_C_FLAGS_RELEASE " /O1 /Ob2 /Gw /Gy") string(APPEND VCPKG_CXX_FLAGS_RELEASE " /O1 /Ob2 /Gw /Gy") - -list(APPEND VCPKG_KEEP_ENV_VARS "PATH" "Path") diff --git a/cmake/vcpkg-ports/wslay/msvc_compat.patch b/cmake/vcpkg-ports/wslay/msvc_compat.patch new file mode 100644 index 000000000..5286e9d2d --- /dev/null +++ b/cmake/vcpkg-ports/wslay/msvc_compat.patch @@ -0,0 +1,13 @@ +diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt +index 4af972e..92e8091 100644 +--- a/lib/CMakeLists.txt ++++ b/lib/CMakeLists.txt +@@ -8,8 +8,6 @@ set(PACKAGE_VERSION "1.0.1-DEV") + set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/includes) + set(GEN_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/includes) + +-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -pedantic-errors -Wno-long-long") +- + include(CheckIncludeFile) + include(TestBigEndian) + check_include_file("arpa/inet.h" HAVE_ARPA_INET_H) diff --git a/cmake/vcpkg-ports/wslay/msvc_compat2.patch b/cmake/vcpkg-ports/wslay/msvc_compat2.patch new file mode 100644 index 000000000..6269e1b4c --- /dev/null +++ b/cmake/vcpkg-ports/wslay/msvc_compat2.patch @@ -0,0 +1,19 @@ +diff --git a/lib/includes/wslay/wslay.h b/lib/includes/wslay/wslay.h +index 7ab8501..82be717 100644 +--- a/lib/includes/wslay/wslay.h ++++ b/lib/includes/wslay/wslay.h +@@ -79,6 +79,14 @@ enum wslay_io_flags { + WSLAY_MSG_MORE = 1 + }; + ++#ifdef _MSC_VER ++#ifdef _WIN64 ++typedef int64_t ssize_t; ++#else ++typedef int32_t ssize_t; ++#endif ++#endif ++ + /* + * Callback function used by wslay_frame_send() function when it needs + * to send data. The implementation of this function must send at most diff --git a/cmake/vcpkg-ports/wslay/portfile.cmake b/cmake/vcpkg-ports/wslay/portfile.cmake new file mode 100644 index 000000000..2b4813427 --- /dev/null +++ b/cmake/vcpkg-ports/wslay/portfile.cmake @@ -0,0 +1,31 @@ +set(VERSION 1.1.1) + +vcpkg_from_github( + OUT_SOURCE_PATH SOURCE_PATH + REPO tatsuhiro-t/wslay + REF release-${VERSION} + SHA512 b42c66c738a3f33bc7de30e8975f4fb2dc60a8baef44be8d254110c8915e14cdaa4cbdd6b29184a66061fe387ec0948e896cb174a1dd8c85a97b5feedfde162e + HEAD_REF master + PATCHES + msvc_compat.patch + msvc_compat2.patch +) + +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "static" BUILD_STATIC) +string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" BUILD_SHARED) + +vcpkg_cmake_configure( + SOURCE_PATH ${SOURCE_PATH} + OPTIONS + -DWSLAY_STATIC=${BUILD_STATIC} + -DWSLAY_SHARED=${BUILD_SHARED} +) +vcpkg_cmake_install() + +vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT}) + +file(REMOVE_RECURSE + ${CURRENT_PACKAGES_DIR}/debug/share +) + +file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/cmake/vcpkg-ports/wslay/vcpkg.json b/cmake/vcpkg-ports/wslay/vcpkg.json new file mode 100644 index 000000000..177028a18 --- /dev/null +++ b/cmake/vcpkg-ports/wslay/vcpkg.json @@ -0,0 +1,18 @@ +{ + "name": "wslay", + "version": "1.1.1", + "port-version": 6, + "description": "websocket library", + "homepage": "https://tatsuhiro-t.github.io/wslay/", + "license": "MIT", + "dependencies": [ + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } + ] +} diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 836fecadc..0e35d447c 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -1,6 +1,3 @@ -cmake_minimum_required(VERSION 3.22) -project(nakama-sdk-cpp DESCRIPTION "Nakama C++ Client" LANGUAGES CXX) - set(NAKAMA_GIT_TAG "master" CACHE STRING "nakama Git tag to fetch Proto files from") set(NAKAMA_COMMON_GIT_TAG "master" CACHE STRING "nakama-common Git tag to fetch Proto files from") @@ -18,8 +15,8 @@ add_subdirectory(core-rt EXCLUDE_FROM_ALL) add_subdirectory(core-rest EXCLUDE_FROM_ALL) ## for createRtClient() -target_link_libraries(nakama-sdk-core-rest PUBLIC nakama-sdk-core-rt factory) +target_link_libraries(nakama-sdk-core-rest PUBLIC nakama::sdk-core-rt) -if (BUILD_GRPC_CLIENT) +if (WITH_GRPC_CLIENT) add_subdirectory(core-grpc EXCLUDE_FROM_ALL) endif() diff --git a/core/buildProtoFiles.cmake b/core/buildProtoFiles.cmake index b6bcce04f..dac3a1b61 100644 --- a/core/buildProtoFiles.cmake +++ b/core/buildProtoFiles.cmake @@ -1,6 +1,4 @@ # Fetch proto files from nakama and nakama-common and builds them -include(FetchContent) - set(NAKAMA_COMMON ${CMAKE_CURRENT_BINARY_DIR}/nakama-common-master) set(NAKAMA ${CMAKE_CURRENT_BINARY_DIR}/nakama-master) @@ -24,10 +22,7 @@ add_library(nakama-api-proto OBJECT ${NAKAMA_API_PROTO_FILES}) add_library(nakama::api-proto ALIAS nakama-api-proto) target_link_libraries(nakama-api-proto PRIVATE protobuf::libprotobuf) -target_include_directories(nakama-api-proto PUBLIC - $ - $ -) +target_include_directories(nakama-api-proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) protobuf_generate(TARGET nakama-api-proto LANGUAGE cpp @@ -37,7 +32,7 @@ protobuf_generate(TARGET nakama-api-proto message("done generating") -if (BUILD_GRPC_CLIENT) +if (WITH_GRPC_CLIENT) #### apigrpc.proto #### # apigrpc.proto references 'api.proto' using canonical name 'github.com/heroiclabs/nakama-common/api/api.proto' @@ -72,10 +67,7 @@ target_link_libraries(nakama-grpc-proto PUBLIC -Wl,--exclude-libs=ALL gRPC::grpc++ ) -target_include_directories(nakama-grpc-proto PUBLIC - $ - $ - ) +target_include_directories(nakama-grpc-proto PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) install(TARGETS nakama-grpc-proto @@ -107,4 +99,4 @@ protobuf_generate(TARGET nakama-grpc-proto PROTOC_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR} PROTOC_OPTIONS "--grpc_out=${CMAKE_CURRENT_BINARY_DIR}" ) -endif(BUILD_GRPC_CLIENT) +endif(WITH_GRPC_CLIENT) diff --git a/core/common/BaseClient.cpp b/core/common/BaseClient.cpp index bf8ba8cda..f314d2ed0 100644 --- a/core/common/BaseClient.cpp +++ b/core/common/BaseClient.cpp @@ -16,17 +16,17 @@ #include -#include "nakama-cpp/NClientInterface.h" -#include "nakama-cpp/log/NLogger.h" -#include "nakama-cpp/realtime/NWebsocketsFactory.h" -#include "nakama-cpp/NException.h" +#include +#include +#include +#include #include "BaseClient.h" #include "../core-rt/NRtClient.h" namespace Nakama { -#if !defined(WITH_EXTERNAL_WS) && !defined(BUILD_IO_EXTERNAL) +#if defined(HAVE_DEFAULT_RT_TRANSPORT_FACTORY) NRtClientPtr BaseClient::createRtClient() { return createRtClient(createDefaultWebsocket(_platformParams)); diff --git a/core/common/BaseClient.h b/core/common/BaseClient.h index 8fe9a2aca..b464a1b2d 100644 --- a/core/common/BaseClient.h +++ b/core/common/BaseClient.h @@ -32,7 +32,7 @@ namespace Nakama { void setUserData(void* userData) override { _userData = userData; } void* getUserData() const override { return _userData; } -#if !defined(WITH_EXTERNAL_WS) && !defined(BUILD_IO_EXTERNAL) +#ifdef HAVE_DEFAULT_RT_TRANSPORT_FACTORY NRtClientPtr createRtClient() override; #endif diff --git a/core/common/CMakeLists.txt b/core/common/CMakeLists.txt index 3b7791305..110c38f75 100644 --- a/core/common/CMakeLists.txt +++ b/core/common/CMakeLists.txt @@ -19,21 +19,21 @@ file( #set(CMAKE_INCLUDE_CURRENT_DIR ON) #set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) -add_library(nakama-sdk-core-common OBJECT ${srcs}) + add_library(nakama-sdk-core-common OBJECT ${srcs}) + add_library(nakama::sdk-core-common ALIAS nakama-sdk-core-common) target_link_libraries(nakama-sdk-core-common PUBLIC nakama-sdk-interface # required for datahelper nakama::api-proto - $<$:nakama::grpc-proto> + $ PRIVATE protobuf::libprotobuf # because of StrUtil::Base64Encode ) -target_include_directories(nakama-sdk-core-common PUBLIC - $ - $ +target_include_directories(nakama-sdk-core-common + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ) diff --git a/core/core-grpc/CMakeLists.txt b/core/core-grpc/CMakeLists.txt index 1c94d927e..a99d2d5bc 100644 --- a/core/core-grpc/CMakeLists.txt +++ b/core/core-grpc/CMakeLists.txt @@ -12,8 +12,11 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(gRPC CONFIG REQUIRED) add_library(nakama-sdk-core-grpc OBJECT ${srcs}) +add_library(nakama::sdk-core-grpc ALIAS nakama-sdk-core-grpc) target_link_libraries(nakama-sdk-core-grpc - PUBLIC nakama-sdk-interface nakama-grpc-proto - PUBLIC nakama-sdk-core-common - nakama-sdk-core-rt - ) \ No newline at end of file + PUBLIC + nakama::sdk-core-rt + nakama::grpc-proto + nakama::sdk-core-common + nakama::sdk-interface + ) diff --git a/core/core-rest/CMakeLists.txt b/core/core-rest/CMakeLists.txt index 30a98298b..1369364de 100644 --- a/core/core-rest/CMakeLists.txt +++ b/core/core-rest/CMakeLists.txt @@ -1,5 +1,3 @@ -project(nakama-sdk-cpp-core-rest LANGUAGES CXX) - file( GLOB_RECURSE srcs LIST_DIRECTORIES false @@ -19,8 +17,9 @@ target_compile_definitions(nakama-sdk-core-rest PRIVATE RAPIDJSON_HAS_CXX11_RVALUE_REFS=1 ) target_link_libraries(nakama-sdk-core-rest - PUBLIC nakama-sdk-interface + PUBLIC + nakama::sdk-interface + nakama::sdk-core-common PRIVATE rapidjson - nakama-sdk-core-common - nakama-sdk-core-rt + nakama::sdk-core-rt ) diff --git a/core/core-rt/CMakeLists.txt b/core/core-rt/CMakeLists.txt index 8d4a910cb..9d389e907 100644 --- a/core/core-rt/CMakeLists.txt +++ b/core/core-rt/CMakeLists.txt @@ -1,5 +1,3 @@ -project(nakama-cpp-sdk-core-rt LANGUAGES CXX) - file( GLOB_RECURSE srcs LIST_DIRECTORIES false @@ -10,8 +8,12 @@ file( set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(nakama-sdk-core-rt OBJECT ${srcs}) +add_library(nakama::sdk-core-rt ALIAS nakama-sdk-core-rt) target_link_libraries(nakama-sdk-core-rt - PUBLIC nakama-sdk-interface nakama-api-proto - PUBLIC nakama-sdk-core-common - PRIVATE nakama::rtclient-factory # because of BaseClient.cpp + PUBLIC + nakama::sdk-interface + nakama::api-proto + nakama::sdk-core-common + PRIVATE + nakama::sdk-rtclient-factory # because of BaseClient.cpp ) diff --git a/core/src/CMakeLists.txt b/core/src/CMakeLists.txt index 29fd023d9..b4ba5574b 100644 --- a/core/src/CMakeLists.txt +++ b/core/src/CMakeLists.txt @@ -23,9 +23,10 @@ file( ) add_library(nakama-sdk-core-misc OBJECT ${_source_list}) +add_library(nakama::sdk-core-misc ALIAS nakama-sdk-core-misc) target_link_libraries(nakama-sdk-core-misc - PUBLIC nakama-sdk-interface + PUBLIC nakama::sdk-interface ) if(ANDROID) diff --git a/core/src/roots_pem.cpp b/core/src/roots_pem.cpp index 4bded2115..c235bf62e 100644 --- a/core/src/roots_pem.cpp +++ b/core/src/roots_pem.cpp @@ -1,6 +1,6 @@ // file generated by conv_roots_pem.py -#if defined(NAKAMA_SSL_ENABLED) && defined(BUILD_GRPC_CLIENT) +#if defined(NAKAMA_SSL_ENABLED) && defined(WITH_GRPC_CLIENT) #include "roots_pem.h" diff --git a/factory/CMakeLists.txt b/factory/CMakeLists.txt index 3db7fc25c..fcee0e009 100644 --- a/factory/CMakeLists.txt +++ b/factory/CMakeLists.txt @@ -1,18 +1,22 @@ add_library(nakama-sdk-client-factory OBJECT ClientFactory.cpp) -add_library(nakama::client-factory ALIAS nakama-sdk-client-factory) +add_library(nakama::sdk-client-factory ALIAS nakama-sdk-client-factory) target_link_libraries(nakama-sdk-client-factory - PRIVATE nakama-sdk-core-rest nakama-sdk-core-grpc ${HTTP_IMPL_LIB}) - -if (BUILD_GRPC_CLIENT) - target_compile_definitions(nakama-sdk-client-factory PRIVATE BUILD_GRPC_CLIENT) -endif() - -target_compile_definitions(nakama-sdk-client-factory PRIVATE HTTP_COMPILE_DEFINITION) + PRIVATE nakama::sdk-core-rest + $) +target_compile_definitions(nakama-sdk-client-factory PRIVATE + $<$:WITH_GRPC_CLIENT> + $<$:WITH_HTTP_CURL> + $<$:WITH_HTTP_LIBHTTPC> + $<$:WITH_HTTP_CPPREST> +) add_library(nakama-sdk-rtclient-factory OBJECT NWebsocketsFactory.cpp) -add_library(nakama::rtclient-factory ALIAS nakama-sdk-rtclient-factory) - +add_library(nakama::sdk-rtclient-factory ALIAS nakama-sdk-rtclient-factory) target_link_libraries(nakama-sdk-rtclient-factory - PUBLIC nakama-sdk-interface - PRIVATE ${WS_IMPL_LIB} + PUBLIC nakama::sdk-interface) +target_compile_definitions(nakama-sdk-rtclient-factory PRIVATE + $<$:WITH_WS_WSLAY> + $<$:CFG_WSLAY_CURL_IO> + $<$:WITH_WS_LIBHTTPC> + $<$:WITH_WS_CPPREST> ) diff --git a/factory/ClientFactory.cpp b/factory/ClientFactory.cpp index ef796f0ed..b66f0797a 100644 --- a/factory/ClientFactory.cpp +++ b/factory/ClientFactory.cpp @@ -18,26 +18,26 @@ #include "nakama-cpp/log/NLogger.h" #include "nakama-cpp/NClientInterface.h" -#ifdef BUILD_GRPC_CLIENT +#ifdef WITH_GRPC_CLIENT #include "../core/core-grpc/GrpcClient.h" #endif #include "../core/core-rest/RestClient.h" -#ifdef BUILD_HTTP_LIBHTTPCLIENT +#ifdef WITH_HTTP_LIBHTTPC #include "../../impl/httpLibHttpClient/NHttpClientLibHC.h" -#elif defined(BUILD_HTTP_CPPRESTSDK) +#elif defined(WITH_HTTP_CPPREST) #include "../../impl/httpCppRest/NHttpClientCppRest.h" -#elif defined(BUILD_HTTP_CURL) +#elif defined(WITH_HTTP_CURL) #include "../../impl/httpCurl/NHttpClientLibCurl.h" #endif namespace Nakama { -#if !defined(WITH_EXTERNAL_HTTP) || defined(BUILD_GRPC_CLIENT) +#if defined(HAVE_DEFAULT_TRANSPORT_FACTORY) || defined(WITH_GRPC_CLIENT) NClientPtr createDefaultClient(const NClientParameters& parameters) { - #if defined(BUILD_GRPC_CLIENT) + #if defined(WITH_GRPC_CLIENT) return createGrpcClient(parameters); #else return createRestClient(parameters, createDefaultHttpTransport(parameters.platformParams)); @@ -45,7 +45,7 @@ NClientPtr createDefaultClient(const NClientParameters& parameters) } #endif -#if BUILD_GRPC_CLIENT +#ifdef WITH_GRPC_CLIENT NClientPtr createGrpcClient(const NClientParameters& parameters) { @@ -67,16 +67,16 @@ NClientPtr createRestClient(const NClientParameters& parameters, NHttpTransportP return client; } -#ifndef WITH_EXTERNAL_HTTP +#ifndef WITH_PRIVATE_HTTP NHttpTransportPtr createDefaultHttpTransport(const NPlatformParameters& platformParams) { (void)platformParams; // silence unused variable warning on some platforms // Compilation error if no implementation is selected - #if defined(BUILD_HTTP_LIBHTTPCLIENT) + #if defined(WITH_HTTP_LIBHTTPC) return NHttpTransportPtr(new NHttpClientLibHC(platformParams)); - #elif defined(BUILD_HTTP_CPPRESTSDK) + #elif defined(WITH_HTTP_CPPREST) return NHttpTransportPtr(new NHttpClientCppRest(platformParams)); - #elif defined(BUILD_HTTP_CURL) + #elif defined(WITH_HTTP_CURL) return NHttpTransportPtr(new NHttpClientLibCurl(platformParams)); #else #error Could not find default http transport for platform. diff --git a/factory/NWebsocketsFactory.cpp b/factory/NWebsocketsFactory.cpp index 2b788aa1e..3772c6396 100644 --- a/factory/NWebsocketsFactory.cpp +++ b/factory/NWebsocketsFactory.cpp @@ -17,47 +17,34 @@ #include "nakama-cpp/realtime/NWebsocketsFactory.h" #include "nakama-cpp/log/NLogger.h" #include "nakama-cpp/NPlatformParams.h" +// Private builds provide their own factory +#if !defined(WITH_PRIVATE_WS) -#ifdef BUILD_WEBSOCKET_WSLAY -#include "nakama-cpp/realtime/wslay/WslayIOInterface.h" -#endif - -#if defined(BUILD_WEBSOCKET_LIBHTTPCLIENT) +#if defined(WITH_WS_LIBHTTPC) #include "../../impl/wsLibHttpClient/NWebsocketLibHC.h" -#elif defined(BUILD_WEBSOCKET_WSLAY) +#elif defined(WITH_WS_WSLAY) #include "NWebsocketWslay.h" - #if defined(BUILD_CURL_IO) + #if defined(CFG_WSLAY_CURL_IO) #include "WslayIOCurl.h" #endif -#elif defined(BUILD_WEBSOCKET_CPPRESTSDK) +#elif defined(WITH_WS_CPPREST) #include "NWebsocketCppRest.h" #endif namespace Nakama { -#if !defined(WITH_EXTERNAL_WS) && !defined(BUILD_IO_EXTERNAL) - -NRtTransportPtr createDefaultWebsocket(const NPlatformParameters& platformParams) +NRtTransportPtr createDefaultWebsocket([[maybe_unused]] const NPlatformParameters& platformParams) { - (void)platformParams; // silence unused variable warning on some platforms - #if defined(BUILD_WEBSOCKET_LIBHTTPCLIENT) + #if defined(WITH_WS_LIBHTTPC) return NRtTransportPtr(NWebsocketLibHC::New(platformParams)); - #elif defined(BUILD_WEBSOCKET_WSLAY) && defined(BUILD_CURL_IO) + #elif defined(WITH_WS_WSLAY) && defined(CFG_WSLAY_CURL_IO) return NRtTransportPtr(new NWebsocketWslay(std::move(std::unique_ptr(new WslayIOCurl())))); - #elif defined(BUILD_WEBSOCKET_CPPRESTSDK) + #elif defined(WITH_WS_CPPREST) return NRtTransportPtr(new NWebsocketCppRest()); #else #error Could not find default web socket transport or IO for platform. #endif } +} // namespace Nakama #endif - -#ifdef BUILD_WEBSOCKET_WSLAY -NRtTransportPtr createWslayWebsocket(std::unique_ptr io) -{ - return std::make_shared(std::move(io)); -} -#endif - -} // namespace Nakama diff --git a/impl/android/CMakeLists.txt b/impl/android/CMakeLists.txt index e52b403e8..869da7055 100644 --- a/impl/android/CMakeLists.txt +++ b/impl/android/CMakeLists.txt @@ -6,9 +6,7 @@ file( ) add_library(android-ca OBJECT ${srcs}) -target_include_directories(android-ca PUBLIC - "$" - "$") +target_include_directories(android-ca PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) target_link_libraries(android-ca PRIVATE android nakama-sdk-core-misc diff --git a/impl/httpCppRest/CMakeLists.txt b/impl/httpCppRest/CMakeLists.txt index 20cd8982c..e00db89ef 100644 --- a/impl/httpCppRest/CMakeLists.txt +++ b/impl/httpCppRest/CMakeLists.txt @@ -9,9 +9,9 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON) find_package(cpprestsdk CONFIG REQUIRED) add_library(nakama-impl-http-cppRest OBJECT ${srcs}) +add_library(nakama::impl-http-cppRest ALIAS nakama-impl-http-cppRest) target_link_libraries(nakama-impl-http-cppRest PUBLIC nakama-api-proto nakama::sdk-interface PRIVATE cpprestsdk::cpprest ) add_library(nakama::impl-http-cppRest ALIAS nakama-impl-http-cppRest) -set(HTTP_IMPL_LIB nakama-impl-http-cppRest PARENT_SCOPE) diff --git a/impl/httpCurl/CMakeLists.txt b/impl/httpCurl/CMakeLists.txt index 5ec457c39..d4e4e211a 100644 --- a/impl/httpCurl/CMakeLists.txt +++ b/impl/httpCurl/CMakeLists.txt @@ -8,11 +8,10 @@ file( set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(nakama-impl-http-libcurl OBJECT ${srcs}) +add_library(nakama::impl-http-libcurl ALIAS nakama-impl-http-libcurl) target_include_directories(nakama-impl-http-libcurl PRIVATE ${CURL_INCLUDE_DIRS}) target_link_libraries(nakama-impl-http-libcurl PUBLIC nakama-api-proto nakama::sdk-interface ) - -set(HTTP_IMPL_LIB nakama-impl-http-libcurl PARENT_SCOPE) diff --git a/impl/httpCurl/NHttpClientLibCurl.cpp b/impl/httpCurl/NHttpClientLibCurl.cpp index 3326e4f1e..d379bdd25 100644 --- a/impl/httpCurl/NHttpClientLibCurl.cpp +++ b/impl/httpCurl/NHttpClientLibCurl.cpp @@ -279,7 +279,7 @@ void NHttpClientLibCurl::tick() } else { - response->statusCode = response_code; + response->statusCode = static_cast(response_code); if (curl_code != CURLE_OK) { diff --git a/impl/httpLibHttpClient/CMakeLists.txt b/impl/httpLibHttpClient/CMakeLists.txt index 0577a2a67..bb2fed0bf 100644 --- a/impl/httpLibHttpClient/CMakeLists.txt +++ b/impl/httpLibHttpClient/CMakeLists.txt @@ -8,6 +8,7 @@ file( set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(nakama-impl-http-libhttpclient OBJECT ${srcs}) +add_library(nakama::impl-http-libhttpclient ALIAS nakama-impl-http-libhttpclient) if (APPLE) target_compile_definitions(nakama-impl-http-libhttpclient INTERFACE "HC_APPLE_POSIX") @@ -20,4 +21,3 @@ target_link_libraries(nakama-impl-http-libhttpclient # configure include paths PUBLIC ${LIBHTTPCLIENT_TARGET} ) -set(HTTP_IMPL_LIB nakama-impl-http-libhttpclient PARENT_SCOPE) diff --git a/impl/httpLibHttpClient/NHttpClientLibHC.cpp b/impl/httpLibHttpClient/NHttpClientLibHC.cpp index 99c8ffa85..184191f18 100644 --- a/impl/httpLibHttpClient/NHttpClientLibHC.cpp +++ b/impl/httpLibHttpClient/NHttpClientLibHC.cpp @@ -1,10 +1,24 @@ -// -// Created by yamlcoder on 17/03/2022. -// +/* + * Copyright 2022 The Nakama Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "NHttpClientLibHC.h" #include #include -#include "NHttpClientLibHC.h" + namespace Nakama { HC_DEFINE_TRACE_AREA(httpTransportLibHC, HCTraceLevel::Error); @@ -263,4 +277,4 @@ void NHttpClientLibHC::cancelAllRequests() { XTaskQueueDispatch(m_queue.get(), XTaskQueuePort::Completion, 50); } } -} \ No newline at end of file +} diff --git a/impl/httpLibHttpClient/NHttpClientLibHC.h b/impl/httpLibHttpClient/NHttpClientLibHC.h index 55f771110..aae254ec2 100644 --- a/impl/httpLibHttpClient/NHttpClientLibHC.h +++ b/impl/httpLibHttpClient/NHttpClientLibHC.h @@ -16,9 +16,11 @@ #pragma once -#include #include #include + +#include + #include namespace Nakama { diff --git a/impl/wsCppRest/CMakeLists.txt b/impl/wsCppRest/CMakeLists.txt index ddd4acf9b..260954aaf 100644 --- a/impl/wsCppRest/CMakeLists.txt +++ b/impl/wsCppRest/CMakeLists.txt @@ -16,4 +16,3 @@ target_link_libraries(nakama-impl-ws-cppRest PRIVATE cpprestsdk::cpprest OpenSSL::SSL ) add_library(nakama::impl-ws-cppRest ALIAS nakama-impl-ws-cppRest) -set(WS_IMPL_LIB nakama-impl-ws-cppRest PARENT_SCOPE) diff --git a/impl/wsLibHttpClient/CMakeLists.txt b/impl/wsLibHttpClient/CMakeLists.txt index b54a765bf..0a543467a 100644 --- a/impl/wsLibHttpClient/CMakeLists.txt +++ b/impl/wsLibHttpClient/CMakeLists.txt @@ -8,6 +8,7 @@ file( set(CMAKE_INCLUDE_CURRENT_DIR ON) add_library(nakama-impl-ws-libhttpclient OBJECT ${srcs}) +add_library(nakama::impl-ws-libhttpclient ALIAS nakama-impl-ws-libhttpclient) target_link_libraries(nakama-impl-ws-libhttpclient PUBLIC nakama-api-proto nakama::sdk-interface # libhttpclient is OBJECT library, so this link wont create diff --git a/impl/wsLibHttpClient/NWebsocketLibHC.h b/impl/wsLibHttpClient/NWebsocketLibHC.h index 23846e03a..1737f15ee 100644 --- a/impl/wsLibHttpClient/NWebsocketLibHC.h +++ b/impl/wsLibHttpClient/NWebsocketLibHC.h @@ -39,6 +39,7 @@ namespace Nakama { void disconnect() override; bool send(const NBytes& data) override; + bool isConnecting() const override { return false; }; private: explicit NWebsocketLibHC(XTaskQueueHandle q); diff --git a/impl/wsWslay/CMakeLists.txt b/impl/wsWslay/CMakeLists.txt index 6ea3f5585..eace2160b 100644 --- a/impl/wsWslay/CMakeLists.txt +++ b/impl/wsWslay/CMakeLists.txt @@ -1,5 +1,5 @@ file( - GLOB_RECURSE srcs + GLOB srcs LIST_DIRECTORIES false "${CMAKE_CURRENT_SOURCE_DIR}/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp" @@ -7,20 +7,25 @@ file( find_package(wslay CONFIG REQUIRED) add_library(nakama-impl-ws-wslay OBJECT ${srcs}) +add_library(nakama::impl-ws-wslay ALIAS nakama-impl-ws-wslay) -target_link_libraries(nakama-impl-ws-wslay PUBLIC - nakama-api-proto nakama::sdk-interface - nakama-sdk-core-common nakama-sdk-core-misc - wslay - ) - -target_include_directories(nakama-impl-ws-wslay INTERFACE - "$" - "$") +target_link_libraries(nakama-impl-ws-wslay + PUBLIC + nakama::sdk-interface + PRIVATE + nakama::sdk-core-common nakama::sdk-core-misc wslay +) +target_include_directories(nakama-impl-ws-wslay + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} # for WslayIOInterface.h +) -if (BUILD_CURL_IO OR BUILD_CURL_IO_SYSTEM) - target_include_directories(nakama-impl-ws-wslay PRIVATE ${CURL_INCLUDE_DIRS}) +if (CFG_WSLAY_CURL_IO) + # Even though WslayIOCUrl is in this lib, it is a header and gets compiled + # in the factory lib where it #include'd. + # So we need to CMake INTERFACE anything might be required to compile + target_link_libraries(nakama-impl-ws-wslay INTERFACE + CURL::libcurl + nakama::sdk-core-common # for StrUtil.h + ) endif() - -target_compile_definitions(nakama-impl-ws-wslay PUBLIC "WSLAY_NETIO_${WSLAY_NETIO}") diff --git a/impl/wsWslay/NWebsocketWslay.cpp b/impl/wsWslay/NWebsocketWslay.cpp index 609e38390..31b1ad23a 100644 --- a/impl/wsWslay/NWebsocketWslay.cpp +++ b/impl/wsWslay/NWebsocketWslay.cpp @@ -5,7 +5,7 @@ #include "StrUtil.h" #include -#include "nakama-cpp/log/NLogger.h" +#include #include "NWebsocketWslay.h" #include #include @@ -343,7 +343,7 @@ namespace Nakama { } } - bool NWebsocketWslay::isConnecting() + bool NWebsocketWslay::isConnecting() const { return _state == State::Connecting || _state == State::Handshake_Receiving || _state == State::Handshake_Sending; } diff --git a/impl/wsWslay/NWebsocketWslay.h b/impl/wsWslay/NWebsocketWslay.h index f5cabed3f..5e15c5638 100644 --- a/impl/wsWslay/NWebsocketWslay.h +++ b/impl/wsWslay/NWebsocketWslay.h @@ -19,8 +19,8 @@ #include #include #include -#include "nakama-cpp/realtime/NRtTransportInterface.h" -#include +#include +#include "WslayIOInterface.h" namespace Nakama { @@ -47,7 +47,7 @@ class NWebsocketWslay : public NRtTransportInterface bool send(const NBytes& data) override; protected: - bool isConnecting() override; + bool isConnecting() const override; private: static ssize_t recv_callback(wslay_event_context_ptr ctx, uint8_t* data, size_t len, int flags, void* user_data); @@ -74,4 +74,4 @@ class NWebsocketWslay : public NRtTransportInterface std::string::iterator _buf_iter; }; -} \ No newline at end of file +} diff --git a/impl/wsWslay/WslayIOCurl.h b/impl/wsWslay/WslayIOCurl.h index 5b0b37828..7d6b63908 100644 --- a/impl/wsWslay/WslayIOCurl.h +++ b/impl/wsWslay/WslayIOCurl.h @@ -1,10 +1,12 @@ #pragma once +#include "StrUtil.h" +#include "WslayIOInterface.h" +#include + +#include + #include #include -#include -#include -#include "StrUtil.h" -#include "nakama-cpp/realtime/wslay/WslayIOInterface.h" #if __ANDROID__ #include "AndroidCA.h" @@ -152,4 +154,4 @@ class WslayIOCurl : public WslayIOInterface { std::unique_ptr _curl_url; }; -NAKAMA_NAMESPACE_END \ No newline at end of file +NAKAMA_NAMESPACE_END diff --git a/interface/include/nakama-cpp/realtime/wslay/WslayIOInterface.h b/impl/wsWslay/WslayIOInterface.h similarity index 94% rename from interface/include/nakama-cpp/realtime/wslay/WslayIOInterface.h rename to impl/wsWslay/WslayIOInterface.h index d6829587a..d8a757abb 100644 --- a/interface/include/nakama-cpp/realtime/wslay/WslayIOInterface.h +++ b/impl/wsWslay/WslayIOInterface.h @@ -1,6 +1,6 @@ #pragma once -#include "nakama-cpp/URLParts.h" +#include namespace Nakama { @@ -21,4 +21,4 @@ class WslayIOInterface { virtual NetIOAsyncResult connect_tick() = 0; }; -} \ No newline at end of file +} diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index efa16f389..951a05477 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -1,21 +1,9 @@ -cmake_minimum_required(VERSION 3.23) -project(nakama-sdk-core LANGUAGES CXX) include(GNUInstallDirs) -file(GLOB CORE_HEADERS - include/nakama-cpp/* - include/nakama-cpp/data/* - include/nakama-cpp/data/log/* - include/nakama-cpp/data/realtime/* - include/nakama-cpp/data/realtime/rtdata/* +file(GLOB_RECURSE CORE_HEADERS + include/*.h ) -if (WS_IMPL STREQUAL "wslay") - file(GLOB WSLAY_HEADERS include/nakama-cpp/data/realtime/wslay/*) - list(APPEND CORE_HEADERS ${WSLAY_HEADERS}) -endif() - - add_library(nakama-sdk-interface INTERFACE ${CORE_HEADERS}) add_library(nakama::sdk-interface ALIAS nakama-sdk-interface) @@ -23,10 +11,6 @@ add_library(nakama::sdk-interface ALIAS nakama-sdk-interface) set(optional_CONFIG_SELECT_OPTIONAL optional_OPTIONAL_NONSTD) target_compile_definitions(nakama-sdk-interface INTERFACE optional_CONFIG_SELECT_OPTIONAL=${optional_CONFIG_SELECT_OPTIONAL}) -if (FORCE_DLL_IMPORT_EXPORT) - target_compile_definitions(nakama-sdk-interface INTERFACE FORCE_DLL_IMPORT_EXPORT) -endif() - # Create configure file with all configure_file(config.h.in nakama-cpp/config.h) diff --git a/interface/config.h.in b/interface/config.h.in index bf121f447..8ae5dc85b 100644 --- a/interface/config.h.in +++ b/interface/config.h.in @@ -1,6 +1,7 @@ #pragma once #cmakedefine optional_CONFIG_SELECT_OPTIONAL @optional_CONFIG_SELECT_OPTIONAL@ -#define @HTTP_COMPILE_DEFINITION@ -#define @WS_COMPILE_DEFINITION@ -#define @WS_IO_COMPILE_DEFINITION@ +#cmakedefine WITH_GRPC_CLIENT +#cmakedefine HAVE_DEFAULT_TRANSPORT_FACTORY +#cmakedefine HAVE_DEFAULT_RT_TRANSPORT_FACTORY +#cmakedefine FORCE_DLL_IMPORT_EXPORT diff --git a/interface/include/nakama-cpp/ClientFactory.h b/interface/include/nakama-cpp/ClientFactory.h index c37d100ae..2d52d3c15 100644 --- a/interface/include/nakama-cpp/ClientFactory.h +++ b/interface/include/nakama-cpp/ClientFactory.h @@ -63,11 +63,11 @@ NAKAMA_NAMESPACE_BEGIN * * @param parameters the client parameters */ -#if !defined(WITH_EXTERNAL_HTTP) || defined(BUILD_GRPC_CLIENT) +#if defined(HAVE_DEFAULT_TRANSPORT_FACTORY) || defined(WITH_GRPC_CLIENT) NAKAMA_API NClientPtr createDefaultClient(const NClientParameters& parameters); #endif -#ifdef BUILD_GRPC_CLIENT +#ifdef WITH_GRPC_CLIENT /** * Creates the gRPC client to interact with Nakama server. * @@ -87,7 +87,7 @@ NAKAMA_NAMESPACE_BEGIN /** * Creates default HTTP transport using C++ REST SDK. */ -#ifndef WITH_EXTERNAL_HTTP +#ifdef HAVE_DEFAULT_TRANSPORT_FACTORY NAKAMA_API NHttpTransportPtr createDefaultHttpTransport(const NPlatformParameters& platformParams); #endif diff --git a/interface/include/nakama-cpp/NClientInterface.h b/interface/include/nakama-cpp/NClientInterface.h index 9f662875b..4f95c5695 100644 --- a/interface/include/nakama-cpp/NClientInterface.h +++ b/interface/include/nakama-cpp/NClientInterface.h @@ -94,7 +94,7 @@ NAKAMA_NAMESPACE_BEGIN */ virtual void tick() = 0; -#if !defined(WITH_EXTERNAL_WS) && !defined(BUILD_IO_EXTERNAL) +#if defined(HAVE_DEFAULT_RT_TRANSPORT_FACTORY) /** * Create a new real-time client with parameters from client. * @return a new NRtClient instance. diff --git a/interface/include/nakama-cpp/NExport.h b/interface/include/nakama-cpp/NExport.h index 35908c9c5..16723e98b 100644 --- a/interface/include/nakama-cpp/NExport.h +++ b/interface/include/nakama-cpp/NExport.h @@ -18,6 +18,9 @@ #undef NAKAMA_API +// That's where FORCE_DLL_IMPORT_EXPORT might be defined on some platforms +#include + #if defined _WIN32 || defined __CYGWIN__ || defined FORCE_DLL_IMPORT_EXPORT #ifdef NAKAMA_SHARED_LIBRARY_EXPORTS #define NAKAMA_API __declspec(dllexport) diff --git a/interface/include/nakama-cpp/realtime/NRtTransportInterface.h b/interface/include/nakama-cpp/realtime/NRtTransportInterface.h index 2d6a06771..e6dfc4547 100644 --- a/interface/include/nakama-cpp/realtime/NRtTransportInterface.h +++ b/interface/include/nakama-cpp/realtime/NRtTransportInterface.h @@ -90,7 +90,7 @@ NAKAMA_NAMESPACE_BEGIN /** * @return True if connecting to server. */ - virtual bool isConnecting() = 0; + virtual bool isConnecting() const = 0; /** * Close the connection with the server. diff --git a/interface/include/nakama-cpp/realtime/NWebsocketsFactory.h b/interface/include/nakama-cpp/realtime/NWebsocketsFactory.h index 43f1c426e..c41439d06 100644 --- a/interface/include/nakama-cpp/realtime/NWebsocketsFactory.h +++ b/interface/include/nakama-cpp/realtime/NWebsocketsFactory.h @@ -21,23 +21,15 @@ #include #include -#if defined BUILD_WEBSOCKET_WSLAY -#include -#endif - NAKAMA_NAMESPACE_BEGIN /** * Create default websocket transport. * */ -#if !defined(WITH_EXTERNAL_WS) && !defined(BUILD_IO_EXTERNAL) +#ifdef HAVE_DEFAULT_RT_TRANSPORT_FACTORY NAKAMA_API NRtTransportPtr createDefaultWebsocket(const NPlatformParameters& platformParameters); #endif -#if defined BUILD_WEBSOCKET_WSLAY - NAKAMA_API NRtTransportPtr createWslayWebsocket(std::unique_ptr io); -#endif - NAKAMA_NAMESPACE_END diff --git a/nakama-sdk-preconfig.cmake.in b/nakama-sdk-preconfig.cmake.in deleted file mode 100644 index e705c6c7b..000000000 --- a/nakama-sdk-preconfig.cmake.in +++ /dev/null @@ -1 +0,0 @@ -set(NAKAMA_SDK_BUILD_TYPE "@NAKAMA_SDK_BUILD_TYPE@") diff --git a/submodules/devkits b/submodules/devkits new file mode 160000 index 000000000..22b8a08d1 --- /dev/null +++ b/submodules/devkits @@ -0,0 +1 @@ +Subproject commit 22b8a08d15bd0eb95cbb4e146e7718aa7b34c278 diff --git a/submodules/libHttpClient b/submodules/libHttpClient new file mode 160000 index 000000000..9aa521a60 --- /dev/null +++ b/submodules/libHttpClient @@ -0,0 +1 @@ +Subproject commit 9aa521a60cb306ae23970039fbca8ff647bb95e0 diff --git a/submodules/private b/submodules/private new file mode 160000 index 000000000..c261b901a --- /dev/null +++ b/submodules/private @@ -0,0 +1 @@ +Subproject commit c261b901a72800444ba24a1ae653b22ce87b3703 diff --git a/submodules/vcpkg b/submodules/vcpkg new file mode 160000 index 000000000..d07689ef1 --- /dev/null +++ b/submodules/vcpkg @@ -0,0 +1 @@ +Subproject commit d07689ef165f033de5c0710e4f67c193a85373e1 diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json deleted file mode 100644 index 2bc0e9326..000000000 --- a/vcpkg-configuration.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "registries": - [ - { - "kind": "builtin", - "baseline": "b4f29c54450ddfc7efd2989cb9d32158ae291b40", - "packages": [] - }, - { - "kind": "git", - "repository": "https://github.com/heroiclabs/nakama-vcpkg-registry", - "baseline": "8a1b872ce6626dfdba5692ffa8c5170f7e40652c", - "reference": "master", - "packages": ["nakama-sdk", "wslay"] - } - ] -} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index 5f6177c64..252c3cd7c 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,96 +1,78 @@ { - "builtin-baseline": "b4f29c54450ddfc7efd2989cb9d32158ae291b40", - "dependencies": [ - "protobuf", + "version-date": "2024-09-27", + "name": "nakama-sdk", + "builtin-baseline": "d07689ef165f033de5c0710e4f67c193a85373e1", + "dependencies": [ + "protobuf", + "rapidjson", + "optional-lite" + ], + "features": { + "libhttpclient": { + "description": "libhttpclient dependencies", + "dependencies": [ + {"name": "zlib"} + ] + }, + "wslay": { + "description": "Websockets library decoupled from IO and handshakes.", + "dependencies": [ + { + "name": "wslay" + } + ], + "supports": "osx | ios | linux | android" + }, + "logs": { + "description": "Whether or not logs are enabled." + }, + "curl": { + "description": "The libcurl networking library.", + "dependencies": [ { - "name": "rapidjson", - "version>=": "2020-09-14#2" - }, - "optional-lite" - ], - "features": { - "libhttpclient-ws": { - "description": "Websockets library that delegates to other implementations.", - "supports": "windows | android", - "dependencies": [ - { - "name": "websocketpp", - "default-features": false, - "platform": "windows" - }, - { - "name": "asio", - "platform": "windows" - }, - { - "name": "openssl", - "platform": "windows" - } - ] - }, - "libhttpclient-http": { - "description": "HTTP library that delegates to other implementations.", - "supports": "windows | android | osx | ios | linux" - }, - "wslay": { - "description": "Websockets library decoupled from IO and handshakes.", - "dependencies": [ - { - "name": "wslay" - } - ], - "supports": "osx | ios | linux | android" - }, - "logs": { - "description": "Whether or not logs are enabled." - }, - "curl": { - "description": "The libcurl networking library.", - "dependencies": [ - { - "name": "curl", - "default-features": false, - "features": [ - "ssl" - ] - } - ] - }, - "libcxx": { - "description": "An alternative C++ standard library, used by Unreal Engine.", - "dependencies": [ - { - "name": "llvm", - "default-features": false, - "features": [ - "libcxx" - ], - "platform": "linux" - } - ] - }, - "grpc": { - "description": "The grpc networking protocol.", - "dependencies": [ - "grpc" - ] - }, - "cpprestsdk": { - "description": "Maintenance-mode HTTP library.", - "dependencies": [ - { - "name": "cpprestsdk", - "default-features": false, - "features": [ - "websockets" - ], - "platform": "android" - } - ], - "supports": "android" + "name": "curl", + "default-features": false, + "features": [ + "ssl" + ] } + ] }, - "overrides": [ - { "name": "curl", "version": "8.0.1" } - ] + "libcxx": { + "description": "An alternative C++ standard library, used by Unreal Engine.", + "dependencies": [ + { + "name": "llvm", + "default-features": false, + "features": [ + "libcxx" + ], + "platform": "linux" + } + ] + }, + "grpc": { + "description": "The grpc networking protocol.", + "dependencies": [ + "grpc" + ] + }, + "cpprestsdk": { + "description": "Maintenance-mode HTTP library.", + "dependencies": [ + { + "name": "cpprestsdk", + "default-features": false, + "features": [ + "websockets" + ], + "platform": "android" + } + ], + "supports": "android" + } + }, + "overrides": [ + {"name": "protobuf", "version": "3.21.12", "port-version": 4} + ] }