Skip to content

Commit

Permalink
Delegate build environment configuration with QUIC_EXTERNAL_TOOLCHAIN (
Browse files Browse the repository at this point in the history
…#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.
  • Loading branch information
redbaron authored Oct 25, 2024
1 parent 637b164 commit ae542fa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 "")
Expand Down
11 changes: 7 additions & 4 deletions src/inc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion src/platform/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit ae542fa

Please sign in to comment.