From ae542fafa474981d1a8b3319f7eb60190deb45d6 Mon Sep 17 00:00:00 2001 From: Maxim Ivanov Date: Fri, 25 Oct 2024 12:44:09 +0100 Subject: [PATCH] Delegate build environment configuration with QUIC_EXTERNAL_TOOLCHAIN (#4625) Well managed CMake build environments make use of CMAKE_TOOLCHAIN_FILE to configure build environment such as include/lib search paths, system libraries, build flags, etc. This change introduces QUIC_EXTERNAL_TOOLCHAIN build option, which when enabled stops MSQuic CMake scripts from attempting to do CMake toolchain job. QUIC_EXTERNAL_TOOLCHAIN defaults to OFF to preserve original behaviour. --- CMakeLists.txt | 7 ++++++- src/inc/CMakeLists.txt | 11 +++++++---- src/platform/CMakeLists.txt | 5 ++++- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5be2318347..4a6933b97d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,6 +90,7 @@ option(QUIC_STATIC_LINK_CRT "Statically links the C runtime" ON) option(QUIC_STATIC_LINK_PARTIAL_CRT "Statically links the compiler-specific portion of the C runtime" ON) option(QUIC_UWP_BUILD "Build for UWP" OFF) option(QUIC_GAMECORE_BUILD "Build for GameCore" OFF) +option(QUIC_EXTERNAL_TOOLCHAIN "Enable if system libs and include paths are configured by CMake toolchain" OFF) option(QUIC_PGO "Enables profile guided optimizations" OFF) option(QUIC_LINUX_XDP_ENABLED "Enables XDP support" OFF) option(QUIC_SOURCE_LINK "Enables source linking on MSVC" ON) @@ -488,7 +489,11 @@ if(WIN32) endif() if (QUIC_GAMECORE_BUILD) - list(APPEND QUIC_COMMON_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_GAMES QUIC_GAMECORE_BUILD QUIC_RESTRICTED_BUILD) + list(APPEND QUIC_COMMON_DEFINES QUIC_GAMECORE_BUILD QUIC_RESTRICTED_BUILD) + endif() + + if (QUIC_GAMECORE_BUILD AND NOT QUIC_EXTERNAL_TOOLCHAIN) + list(APPEND QUIC_COMMON_DEFINES WINAPI_FAMILY=WINAPI_FAMILY_GAMES) set(CMAKE_CXX_STANDARD_LIBRARIES "") set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "") set(CMAKE_C_STANDARD_LIBRARIES "") diff --git a/src/inc/CMakeLists.txt b/src/inc/CMakeLists.txt index dde47b8252..48edebd1e0 100644 --- a/src/inc/CMakeLists.txt +++ b/src/inc/CMakeLists.txt @@ -42,10 +42,13 @@ if(WIN32) if(QUIC_UWP_BUILD) target_link_libraries(base_link INTERFACE OneCore ws2_32 ntdll) elseif(QUIC_GAMECORE_BUILD) - target_link_options(inc INTERFACE ${Console_LinkOptions}) - target_compile_options(inc INTERFACE ${Console_ArchOptions}) - target_link_directories(inc INTERFACE ${Console_EndpointLibRoot}) - target_link_libraries(base_link INTERFACE xgameplatform ntdll advapi32) + target_link_libraries(base_link INTERFACE ntdll advapi32) + if(NOT QUIC_EXTERNAL_TOOLCHAIN) + target_link_options(inc INTERFACE ${Console_LinkOptions}) + target_compile_options(inc INTERFACE ${Console_ArchOptions}) + target_link_directories(inc INTERFACE ${Console_EndpointLibRoot}) + target_link_libraries(base_link INTERFACE xgameplatform) + endif() else() target_link_libraries(base_link INTERFACE ws2_32 schannel ntdll bcrypt ncrypt crypt32 iphlpapi advapi32) endif() diff --git a/src/platform/CMakeLists.txt b/src/platform/CMakeLists.txt index eca936787c..358b5f0a09 100644 --- a/src/platform/CMakeLists.txt +++ b/src/platform/CMakeLists.txt @@ -132,5 +132,8 @@ if(QUIC_TLS STREQUAL "openssl" OR QUIC_TLS STREQUAL "openssl3") target_link_libraries(platform PUBLIC "-framework CoreFoundation" "-framework Security") endif() elseif(QUIC_TLS STREQUAL "schannel") - target_link_libraries(platform PUBLIC secur32 onecore) + target_link_libraries(platform PUBLIC secur32) + if (NOT QUIC_GAMECORE_BUILD) + target_link_libraries(platform PUBLIC onecore) + endif() endif()