mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-11-12 14:57:20 +00:00
[build] msquic: add static network dependency
This commit is contained in:
@@ -3,6 +3,8 @@ if (EXISTS "${PROJECT_TOP}/.git" AND (
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/gui/cimplot/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/LGMP/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/LGProtocol/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/MsQuic/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/MsQuic/submodules/xdp-for-windows/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/PureSpice/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/gui/cimgui/imgui/.git") OR
|
||||
(NOT EXISTS "${PROJECT_TOP}/repos/gui/cimplot/implot/.git") OR
|
||||
|
||||
44
cmake/MsQuic.Static.targets
Normal file
44
cmake/MsQuic.Static.targets
Normal file
@@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<LGMsQuicSourceDir>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)..\repos\MsQuic'))</LGMsQuicSourceDir>
|
||||
<LGMsQuicBuildDir>$([MSBuild]::NormalizeDirectory('$(MSBuildProjectDirectory)\$(IntDir)MsQuic'))</LGMsQuicBuildDir>
|
||||
<LGMsQuicArchitecture Condition="'$(Platform)'=='Win32'">Win32</LGMsQuicArchitecture>
|
||||
<LGMsQuicArchitecture Condition="'$(Platform)'=='x64'">x64</LGMsQuicArchitecture>
|
||||
<LGMsQuicLibrary>$(LGMsQuicBuildDir)bin\$(LGBaseConfiguration)\msquic.lib</LGMsQuicLibrary>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>$(LGMsQuicSourceDir)src\inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>QUIC_BUILD_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>$(LGMsQuicLibrary);ws2_32.lib;schannel.lib;secur32.lib;OneCore.lib;wbemuuid.lib;winmm.lib;ntdll.lib;bcrypt.lib;ncrypt.lib;crypt32.lib;iphlpapi.lib;advapi32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Target
|
||||
Name="ConfigureLGMsQuic"
|
||||
BeforeTargets="ClCompile"
|
||||
Inputs="$(LGMsQuicSourceDir)CMakeLists.txt;$(MSBuildThisFileFullPath)"
|
||||
Outputs="$(LGMsQuicBuildDir)CMakeCache.txt">
|
||||
<Error
|
||||
Condition="!Exists('$(LGMsQuicSourceDir)CMakeLists.txt')"
|
||||
Text="The MsQuic submodule is not initialized. Run git submodule update --init --recursive." />
|
||||
<Error
|
||||
Condition="'$(LGMsQuicArchitecture)'==''"
|
||||
Text="Static MsQuic does not support the $(Platform) platform in this project." />
|
||||
<MakeDir Directories="$(LGMsQuicBuildDir)" />
|
||||
<Exec
|
||||
Command="cmake -S "$(LGMsQuicSourceDir)" -B "$(LGMsQuicBuildDir)" -G "Visual Studio 17 2022" -A "$(LGMsQuicArchitecture)" -T v143 -DCMAKE_SYSTEM_VERSION="$(WindowsTargetPlatformVersion)" -DQUIC_BUILD_SHARED=OFF -DQUIC_BUILD_TOOLS=OFF -DQUIC_BUILD_TEST=OFF -DQUIC_BUILD_PERF=OFF -DQUIC_TLS_LIB=schannel -DQUIC_ENABLE_LOGGING=OFF -DQUIC_STATIC_LINK_CRT=OFF -DQUIC_STATIC_LINK_PARTIAL_CRT=OFF -DQUIC_SOURCE_LINK=OFF -DQUIC_PDBALTPATH=OFF -DQUIC_EMBED_GIT_HASH=OFF" />
|
||||
</Target>
|
||||
<Target
|
||||
Name="BuildLGMsQuic"
|
||||
BeforeTargets="Link"
|
||||
DependsOnTargets="ConfigureLGMsQuic">
|
||||
<Exec
|
||||
Command="cmake --build "$(LGMsQuicBuildDir)" --config "$(LGBaseConfiguration)" --target msquic_lib --parallel" />
|
||||
<Error
|
||||
Condition="!Exists('$(LGMsQuicLibrary)')"
|
||||
Text="The static MsQuic build did not produce $(LGMsQuicLibrary)." />
|
||||
</Target>
|
||||
</Project>
|
||||
164
cmake/MsQuic.cmake
Normal file
164
cmake/MsQuic.cmake
Normal file
@@ -0,0 +1,164 @@
|
||||
include(ExternalProject)
|
||||
|
||||
function(lg_add_static_msquic)
|
||||
if(TARGET msquic::msquic)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
message(FATAL_ERROR
|
||||
"The in-tree static MsQuic target is only available on Windows")
|
||||
endif()
|
||||
|
||||
if(CMAKE_VERSION VERSION_LESS 3.20)
|
||||
message(FATAL_ERROR
|
||||
"The in-tree static MsQuic target requires CMake 3.20 or newer")
|
||||
endif()
|
||||
|
||||
set(LG_MSQUIC_SOURCE_DIR "${PROJECT_TOP}/repos/MsQuic")
|
||||
set(LG_MSQUIC_BINARY_DIR "${CMAKE_BINARY_DIR}/MsQuic")
|
||||
set(LG_MSQUIC_SYSTEM_LIBRARIES
|
||||
ws2_32
|
||||
schannel
|
||||
secur32
|
||||
onecore
|
||||
wbemuuid
|
||||
winmm
|
||||
ntdll
|
||||
bcrypt
|
||||
ncrypt
|
||||
crypt32
|
||||
iphlpapi
|
||||
advapi32
|
||||
)
|
||||
set(LG_MSQUIC_CMAKE_ARGS
|
||||
"-DQUIC_BUILD_SHARED=OFF"
|
||||
"-DQUIC_BUILD_TOOLS=OFF"
|
||||
"-DQUIC_BUILD_TEST=OFF"
|
||||
"-DQUIC_BUILD_PERF=OFF"
|
||||
"-DQUIC_TLS_LIB=schannel"
|
||||
"-DQUIC_ENABLE_LOGGING=OFF"
|
||||
"-DQUIC_STATIC_LINK_CRT=OFF"
|
||||
"-DQUIC_STATIC_LINK_PARTIAL_CRT=OFF"
|
||||
"-DQUIC_SOURCE_LINK=OFF"
|
||||
"-DQUIC_PDBALTPATH=OFF"
|
||||
"-DQUIC_EMBED_GIT_HASH=OFF"
|
||||
)
|
||||
|
||||
if(NOT EXISTS "${LG_MSQUIC_SOURCE_DIR}/CMakeLists.txt")
|
||||
message(FATAL_ERROR
|
||||
"The MsQuic submodule is not initialized; run "
|
||||
"git submodule update --init --recursive")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(LG_MSQUIC_DEBUG_LIBRARY
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Debug/msquic.lib")
|
||||
set(LG_MSQUIC_BUILD_CONFIG "$<CONFIG>")
|
||||
set(LG_MSQUIC_BUILD_COMMAND
|
||||
"${CMAKE_COMMAND}" --build <BINARY_DIR>
|
||||
--config ${LG_MSQUIC_BUILD_CONFIG}
|
||||
--target msquic_lib
|
||||
--parallel
|
||||
)
|
||||
elseif(MINGW)
|
||||
if(NOT MINGW64_TRIPLE)
|
||||
set(MINGW64_TRIPLE x86_64-w64-mingw32)
|
||||
endif()
|
||||
|
||||
if(CMAKE_FIND_ROOT_PATH)
|
||||
list(GET CMAKE_FIND_ROOT_PATH 0 LG_MSQUIC_MINGW_ROOT)
|
||||
else()
|
||||
set(LG_MSQUIC_MINGW_ROOT "/usr/${MINGW64_TRIPLE}")
|
||||
endif()
|
||||
|
||||
set(LG_MSQUIC_DEBUG_LIBRARY
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Release/msquic.lib")
|
||||
find_program(LG_MSQUIC_CLANG_CL clang-cl REQUIRED)
|
||||
find_program(LG_MSQUIC_LLVM_LIB llvm-lib REQUIRED)
|
||||
find_program(LG_MSQUIC_MINGW_GCC
|
||||
NAMES "${MINGW64_TRIPLE}-gcc" x86_64-w64-mingw32-gcc
|
||||
REQUIRED)
|
||||
find_program(LG_MSQUIC_WINDRES
|
||||
NAMES "${MINGW64_TRIPLE}-windres" x86_64-w64-mingw32-windres
|
||||
REQUIRED)
|
||||
|
||||
# MsQuic's Windows sources use the CL command-line ABI and its monolithic
|
||||
# archive rule uses lib.exe syntax. Compile those sources with clang-cl,
|
||||
# while targeting the same MinGW-w64 ABI and import libraries as the
|
||||
# surrounding client build.
|
||||
set(LG_MSQUIC_IMPORT_DIR "${LG_MSQUIC_BINARY_DIR}/mingw-imports")
|
||||
file(MAKE_DIRECTORY "${LG_MSQUIC_IMPORT_DIR}")
|
||||
|
||||
foreach(LG_MSQUIC_SYSTEM_LIBRARY
|
||||
onecore
|
||||
secur32
|
||||
wbemuuid
|
||||
winmm)
|
||||
string(TOUPPER "${LG_MSQUIC_SYSTEM_LIBRARY}"
|
||||
LG_MSQUIC_SYSTEM_LIBRARY_UPPER)
|
||||
find_library(LG_MSQUIC_${LG_MSQUIC_SYSTEM_LIBRARY_UPPER}_LIBRARY
|
||||
NAMES "${LG_MSQUIC_SYSTEM_LIBRARY}"
|
||||
PATHS "${LG_MSQUIC_MINGW_ROOT}/lib"
|
||||
NO_DEFAULT_PATH
|
||||
REQUIRED)
|
||||
configure_file(
|
||||
"${LG_MSQUIC_${LG_MSQUIC_SYSTEM_LIBRARY_UPPER}_LIBRARY}"
|
||||
"${LG_MSQUIC_IMPORT_DIR}/${LG_MSQUIC_SYSTEM_LIBRARY}.lib"
|
||||
COPYONLY)
|
||||
endforeach()
|
||||
|
||||
list(APPEND LG_MSQUIC_CMAKE_ARGS
|
||||
"-DCMAKE_BUILD_TYPE=RelWithDebInfo"
|
||||
"-DCMAKE_TOOLCHAIN_FILE=${PROJECT_TOP}/cmake/toolchains/msquic-clangcl-mingw64.cmake"
|
||||
"-DMSQUIC_MINGW_TRIPLE=${MINGW64_TRIPLE}"
|
||||
"-DMSQUIC_MINGW_ROOT=${LG_MSQUIC_MINGW_ROOT}"
|
||||
"-DMSQUIC_CLANG_CL=${LG_MSQUIC_CLANG_CL}"
|
||||
"-DMSQUIC_LLVM_LIB=${LG_MSQUIC_LLVM_LIB}"
|
||||
"-DMSQUIC_MINGW_GCC=${LG_MSQUIC_MINGW_GCC}"
|
||||
"-DMSQUIC_WINDRES=${LG_MSQUIC_WINDRES}"
|
||||
"-DHAS_SPECTRE=OFF"
|
||||
"-DHAS_GUARDCF=OFF"
|
||||
)
|
||||
set(LG_MSQUIC_BUILD_COMMAND
|
||||
"${CMAKE_COMMAND}" -E env "LIB=${LG_MSQUIC_IMPORT_DIR}"
|
||||
"${CMAKE_COMMAND}" --build <BINARY_DIR>
|
||||
--target msquic_lib
|
||||
--parallel
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR
|
||||
"Static MsQuic on Windows requires MSVC or the MinGW-w64 "
|
||||
"clang-cl cross-build toolchain")
|
||||
endif()
|
||||
|
||||
ExternalProject_Add(lg_msquic_build
|
||||
SOURCE_DIR "${LG_MSQUIC_SOURCE_DIR}"
|
||||
BINARY_DIR "${LG_MSQUIC_BINARY_DIR}"
|
||||
DOWNLOAD_COMMAND ""
|
||||
UPDATE_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
CMAKE_ARGS ${LG_MSQUIC_CMAKE_ARGS}
|
||||
BUILD_COMMAND ${LG_MSQUIC_BUILD_COMMAND}
|
||||
BUILD_BYPRODUCTS
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Debug/msquic.lib"
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Release/msquic.lib"
|
||||
)
|
||||
|
||||
add_library(lg_msquic STATIC IMPORTED GLOBAL)
|
||||
set_target_properties(lg_msquic PROPERTIES
|
||||
IMPORTED_CONFIGURATIONS "Debug;Release;RelWithDebInfo;MinSizeRel"
|
||||
IMPORTED_LOCATION_DEBUG "${LG_MSQUIC_DEBUG_LIBRARY}"
|
||||
IMPORTED_LOCATION_RELEASE
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Release/msquic.lib"
|
||||
IMPORTED_LOCATION_RELWITHDEBINFO
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Release/msquic.lib"
|
||||
IMPORTED_LOCATION_MINSIZEREL
|
||||
"${LG_MSQUIC_BINARY_DIR}/bin/Release/msquic.lib"
|
||||
INTERFACE_COMPILE_DEFINITIONS QUIC_BUILD_STATIC
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${LG_MSQUIC_SOURCE_DIR}/src/inc"
|
||||
INTERFACE_LINK_LIBRARIES "${LG_MSQUIC_SYSTEM_LIBRARIES}"
|
||||
)
|
||||
add_dependencies(lg_msquic lg_msquic_build)
|
||||
add_library(msquic::msquic ALIAS lg_msquic)
|
||||
endfunction()
|
||||
138
cmake/toolchains/msquic-clangcl-mingw64.cmake
Normal file
138
cmake/toolchains/msquic-clangcl-mingw64.cmake
Normal file
@@ -0,0 +1,138 @@
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_PROCESSOR AMD64)
|
||||
|
||||
set(MSQUIC_MINGW_TRIPLE x86_64-w64-mingw32 CACHE STRING
|
||||
"MinGW-w64 target triple")
|
||||
set(MSQUIC_MINGW_ROOT "/usr/${MSQUIC_MINGW_TRIPLE}" CACHE PATH
|
||||
"MinGW-w64 target root")
|
||||
set(MSQUIC_CLANG_CL clang-cl CACHE FILEPATH
|
||||
"clang-cl used to build the static MsQuic archive")
|
||||
set(MSQUIC_LLVM_LIB llvm-lib CACHE FILEPATH
|
||||
"llvm-lib used to create the static MsQuic archive")
|
||||
set(MSQUIC_WINDRES "${MSQUIC_MINGW_TRIPLE}-windres" CACHE FILEPATH
|
||||
"MinGW-w64 resource compiler")
|
||||
set(MSQUIC_MINGW_GCC "${MSQUIC_MINGW_TRIPLE}-gcc" CACHE FILEPATH
|
||||
"MinGW-w64 compiler used to locate compatibility headers")
|
||||
|
||||
if(NOT MSQUIC_CLANG_RESOURCE_DIR)
|
||||
execute_process(
|
||||
COMMAND "${MSQUIC_CLANG_CL}" /clang:-print-resource-dir
|
||||
RESULT_VARIABLE MSQUIC_CLANG_RESOURCE_RESULT
|
||||
OUTPUT_VARIABLE MSQUIC_CLANG_RESOURCE_ROOT
|
||||
ERROR_VARIABLE MSQUIC_CLANG_RESOURCE_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT MSQUIC_CLANG_RESOURCE_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"Unable to locate the clang resource headers: "
|
||||
"${MSQUIC_CLANG_RESOURCE_ERROR}")
|
||||
endif()
|
||||
|
||||
set(MSQUIC_CLANG_RESOURCE_DIR
|
||||
"${MSQUIC_CLANG_RESOURCE_ROOT}/include" CACHE PATH
|
||||
"clang resource headers used by the MsQuic cross-build")
|
||||
endif()
|
||||
|
||||
if(NOT MSQUIC_MINGW_GCC_INCLUDE)
|
||||
execute_process(
|
||||
COMMAND "${MSQUIC_MINGW_GCC}" -print-file-name=include
|
||||
RESULT_VARIABLE MSQUIC_MINGW_GCC_INCLUDE_RESULT
|
||||
OUTPUT_VARIABLE MSQUIC_MINGW_GCC_INCLUDE
|
||||
ERROR_VARIABLE MSQUIC_MINGW_GCC_INCLUDE_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT MSQUIC_MINGW_GCC_INCLUDE_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"Unable to locate the MinGW-w64 compiler headers: "
|
||||
"${MSQUIC_MINGW_GCC_INCLUDE_ERROR}")
|
||||
endif()
|
||||
|
||||
set(MSQUIC_MINGW_GCC_INCLUDE "${MSQUIC_MINGW_GCC_INCLUDE}" CACHE PATH
|
||||
"MinGW-w64 compiler headers used by the MsQuic cross-build")
|
||||
endif()
|
||||
|
||||
if(NOT MSQUIC_MINGW_GCC_INCLUDE_FIXED)
|
||||
execute_process(
|
||||
COMMAND "${MSQUIC_MINGW_GCC}" -print-file-name=include-fixed
|
||||
RESULT_VARIABLE MSQUIC_MINGW_GCC_FIXED_RESULT
|
||||
OUTPUT_VARIABLE MSQUIC_MINGW_GCC_INCLUDE_FIXED
|
||||
ERROR_VARIABLE MSQUIC_MINGW_GCC_FIXED_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT MSQUIC_MINGW_GCC_FIXED_RESULT EQUAL 0)
|
||||
message(FATAL_ERROR
|
||||
"Unable to locate the fixed MinGW-w64 compiler headers: "
|
||||
"${MSQUIC_MINGW_GCC_FIXED_ERROR}")
|
||||
endif()
|
||||
|
||||
set(MSQUIC_MINGW_GCC_INCLUDE_FIXED
|
||||
"${MSQUIC_MINGW_GCC_INCLUDE_FIXED}" CACHE PATH
|
||||
"Fixed MinGW-w64 compiler headers used by the MsQuic cross-build")
|
||||
endif()
|
||||
|
||||
foreach(MSQUIC_REQUIRED_INCLUDE
|
||||
"${MSQUIC_MINGW_ROOT}/include"
|
||||
"${MSQUIC_CLANG_RESOURCE_DIR}"
|
||||
"${MSQUIC_MINGW_GCC_INCLUDE}")
|
||||
if(NOT IS_DIRECTORY "${MSQUIC_REQUIRED_INCLUDE}")
|
||||
message(FATAL_ERROR
|
||||
"Required MsQuic cross-build headers are missing: "
|
||||
"${MSQUIC_REQUIRED_INCLUDE}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(CMAKE_C_COMPILER "${MSQUIC_CLANG_CL}")
|
||||
set(CMAKE_CXX_COMPILER "${MSQUIC_CLANG_CL}")
|
||||
set(CMAKE_C_COMPILER_TARGET "${MSQUIC_MINGW_TRIPLE}")
|
||||
set(CMAKE_CXX_COMPILER_TARGET "${MSQUIC_MINGW_TRIPLE}")
|
||||
set(CMAKE_AR "${MSQUIC_LLVM_LIB}")
|
||||
set(CMAKE_RC_COMPILER "${MSQUIC_WINDRES}")
|
||||
|
||||
set(MSQUIC_COMPAT_HEADER
|
||||
"${CMAKE_CURRENT_LIST_DIR}/msquic-mingw-compat.h")
|
||||
set(MSQUIC_CLANG_CL_OPTIONS
|
||||
"/clang:-nostdinc"
|
||||
"/clang:-isystem"
|
||||
"/clang:${MSQUIC_MINGW_ROOT}/include"
|
||||
"/clang:-isystem"
|
||||
"/clang:${MSQUIC_CLANG_RESOURCE_DIR}"
|
||||
"/clang:-isystem"
|
||||
"/clang:${MSQUIC_MINGW_GCC_INCLUDE}")
|
||||
|
||||
if(IS_DIRECTORY "${MSQUIC_MINGW_GCC_INCLUDE_FIXED}")
|
||||
list(APPEND MSQUIC_CLANG_CL_OPTIONS
|
||||
"/clang:-isystem"
|
||||
"/clang:${MSQUIC_MINGW_GCC_INCLUDE_FIXED}")
|
||||
endif()
|
||||
|
||||
list(APPEND MSQUIC_CLANG_CL_OPTIONS
|
||||
"/clang:-fms-extensions"
|
||||
"/clang:-Wno-unknown-pragmas"
|
||||
"/clang:-Wno-microsoft-anon-tag"
|
||||
"/clang:-Wno-missing-field-initializers"
|
||||
"/clang:-Wno-sign-compare"
|
||||
"/clang:-Wno-int-conversion"
|
||||
"/clang:-Wno-unused-function"
|
||||
"/clang:-Wno-incompatible-pointer-types"
|
||||
"/FI${MSQUIC_COMPAT_HEADER}")
|
||||
list(JOIN MSQUIC_CLANG_CL_OPTIONS " " MSQUIC_CLANG_CL_FLAGS)
|
||||
|
||||
set(CMAKE_C_FLAGS "${MSQUIC_CLANG_CL_FLAGS}" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS "${MSQUIC_CLANG_CL_FLAGS}" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_DEBUG "/clang:-O0 /Zi" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "/clang:-O0 /Zi" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELEASE "/clang:-O3 /DNDEBUG" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "/clang:-O3 /DNDEBUG" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
"/clang:-O2 /Zi /DNDEBUG" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
||||
"/clang:-O2 /Zi /DNDEBUG" CACHE STRING "" FORCE)
|
||||
set(CMAKE_C_FLAGS_MINSIZEREL "/clang:-Os /DNDEBUG" CACHE STRING "" FORCE)
|
||||
set(CMAKE_CXX_FLAGS_MINSIZEREL
|
||||
"/clang:-Os /DNDEBUG" CACHE STRING "" FORCE)
|
||||
|
||||
set(CMAKE_USER_MAKE_RULES_OVERRIDE
|
||||
"${CMAKE_CURRENT_LIST_DIR}/msquic-clangcl-rules.cmake")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH "${MSQUIC_MINGW_ROOT}")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
21
cmake/toolchains/msquic-clangcl-rules.cmake
Normal file
21
cmake/toolchains/msquic-clangcl-rules.cmake
Normal file
@@ -0,0 +1,21 @@
|
||||
set(CMAKE_DEPFILE_FLAGS_C
|
||||
"-clang:-MD -clang:-MT<DEP_TARGET> -clang:-MF<DEP_FILE>")
|
||||
set(CMAKE_DEPFILE_FLAGS_CXX
|
||||
"-clang:-MD -clang:-MT<DEP_TARGET> -clang:-MF<DEP_FILE>")
|
||||
|
||||
set(CMAKE_C_COMPILE_OBJECT
|
||||
"<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB> /c -- <SOURCE>")
|
||||
set(CMAKE_CXX_COMPILE_OBJECT
|
||||
"<CMAKE_CXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB> /c -- <SOURCE>")
|
||||
set(CMAKE_C_CREATE_STATIC_LIBRARY
|
||||
"<CMAKE_AR> /nologo <LINK_FLAGS> /out:<TARGET> <OBJECTS>")
|
||||
set(CMAKE_CXX_CREATE_STATIC_LIBRARY
|
||||
"<CMAKE_AR> /nologo <LINK_FLAGS> /out:<TARGET> <OBJECTS>")
|
||||
|
||||
set(CMAKE_STATIC_LIBRARY_PREFIX "")
|
||||
set(CMAKE_STATIC_LIBRARY_SUFFIX ".lib")
|
||||
set(CMAKE_IMPORT_LIBRARY_PREFIX "")
|
||||
set(CMAKE_IMPORT_LIBRARY_SUFFIX ".lib")
|
||||
|
||||
set(CMAKE_C_USE_RESPONSE_FILE_FOR_OBJECTS 1)
|
||||
set(CMAKE_CXX_USE_RESPONSE_FILE_FOR_OBJECTS 1)
|
||||
322
cmake/toolchains/msquic-mingw-compat.h
Normal file
322
cmake/toolchains/msquic-mingw-compat.h
Normal file
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* Looking Glass
|
||||
* Copyright © 2017-2026 The Looking Glass Authors
|
||||
* https://looking-glass.io
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation; either version 2 of the License, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., 59
|
||||
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _H_LG_MSQUIC_MINGW_COMPAT_
|
||||
#define _H_LG_MSQUIC_MINGW_COMPAT_
|
||||
|
||||
#ifndef FORCEINLINE
|
||||
#define FORCEINLINE __inline__ __attribute__((__always_inline__))
|
||||
#endif
|
||||
|
||||
#ifndef EXTERN_C_START
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN_C_START extern "C" {
|
||||
#define EXTERN_C_END }
|
||||
#else
|
||||
#define EXTERN_C_START
|
||||
#define EXTERN_C_END
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#include <mswsock.h>
|
||||
#include <mstcpip.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#undef UNREFERENCED_PARAMETER
|
||||
#define UNREFERENCED_PARAMETER(parameter) ((void)(parameter))
|
||||
|
||||
#undef DBG_UNREFERENCED_LOCAL_VARIABLE
|
||||
#define DBG_UNREFERENCED_LOCAL_VARIABLE(variable) ((void)(variable))
|
||||
|
||||
#ifndef _Interlocked_operand_
|
||||
#define _Interlocked_operand_
|
||||
#endif
|
||||
|
||||
#ifndef DECLSPEC_ALLOCATOR
|
||||
#define DECLSPEC_ALLOCATOR
|
||||
#endif
|
||||
|
||||
#ifndef FAST_FAIL_INVALID_REFERENCE_COUNT
|
||||
#define FAST_FAIL_INVALID_REFERENCE_COUNT 14
|
||||
#endif
|
||||
|
||||
#ifndef PASSIVE_LEVEL
|
||||
#define PASSIVE_LEVEL 0
|
||||
#endif
|
||||
|
||||
#ifndef IFI_UNSPECIFIED
|
||||
#define IFI_UNSPECIFIED 0
|
||||
#endif
|
||||
|
||||
#ifndef __kernel_entry
|
||||
#define __kernel_entry
|
||||
#endif
|
||||
|
||||
#ifndef __noop
|
||||
#define __noop(expression) ((void)(0 && (expression)))
|
||||
#endif
|
||||
|
||||
#ifndef __annotation
|
||||
#define __annotation(...) ((void)0)
|
||||
#endif
|
||||
|
||||
#ifndef __analysis_assert
|
||||
#define __analysis_assert(expression) ((void)(0 && (expression)))
|
||||
#endif
|
||||
|
||||
#ifndef InterlockedAnd8
|
||||
#define InterlockedAnd8 _InterlockedAnd8
|
||||
#endif
|
||||
|
||||
#ifndef InterlockedOr8
|
||||
#define InterlockedOr8 _InterlockedOr8
|
||||
#endif
|
||||
|
||||
#ifndef InterlockedIncrementNoFence64
|
||||
#define InterlockedIncrementNoFence64 _InterlockedIncrement64
|
||||
#endif
|
||||
|
||||
#ifndef InterlockedDecrementRelease64
|
||||
#define InterlockedDecrementRelease64 _InterlockedDecrement64
|
||||
#endif
|
||||
|
||||
#ifndef InterlockedCompareExchangeNoFence64
|
||||
#define InterlockedCompareExchangeNoFence64 _InterlockedCompareExchange64
|
||||
#endif
|
||||
|
||||
#ifndef ReadNoFence64
|
||||
#define ReadNoFence64(target) (*(volatile __int64 *)(target))
|
||||
#endif
|
||||
|
||||
#ifndef ReadPointerNoFence
|
||||
#define ReadPointerNoFence(target) (*(void * volatile *)(target))
|
||||
#endif
|
||||
|
||||
#ifndef ReadUInt32Acquire
|
||||
#define ReadUInt32Acquire(source) \
|
||||
__atomic_load_n((source), __ATOMIC_ACQUIRE)
|
||||
#endif
|
||||
|
||||
#ifndef WriteUInt32Release
|
||||
#define WriteUInt32Release(destination, value) \
|
||||
__atomic_store_n((destination), (value), __ATOMIC_RELEASE)
|
||||
#endif
|
||||
|
||||
#ifndef WSA_FLAG_REGISTERED_IO
|
||||
#define WSA_FLAG_REGISTERED_IO 0x100
|
||||
#endif
|
||||
|
||||
#ifndef SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER
|
||||
#define SIO_GET_MULTIPLE_EXTENSION_FUNCTION_POINTER _WSAIORW(IOC_WS2, 36)
|
||||
#endif
|
||||
|
||||
#ifndef SIO_QUERY_RSS_PROCESSOR_INFO
|
||||
#define SIO_QUERY_RSS_PROCESSOR_INFO _WSAIOR(IOC_WS2, 37)
|
||||
|
||||
typedef struct _SOCKET_PROCESSOR_AFFINITY
|
||||
{
|
||||
PROCESSOR_NUMBER Processor;
|
||||
USHORT NumaNodeId;
|
||||
USHORT Reserved;
|
||||
}
|
||||
SOCKET_PROCESSOR_AFFINITY, *PSOCKET_PROCESSOR_AFFINITY;
|
||||
#endif
|
||||
|
||||
#ifndef SIO_QUERY_RSS_SCALABILITY_INFO
|
||||
#define SIO_QUERY_RSS_SCALABILITY_INFO _WSAIOR(IOC_VENDOR, 210)
|
||||
|
||||
typedef struct _RSS_SCALABILITY_INFO
|
||||
{
|
||||
BOOLEAN RssEnabled;
|
||||
}
|
||||
RSS_SCALABILITY_INFO, *PRSS_SCALABILITY_INFO;
|
||||
#endif
|
||||
|
||||
#ifndef GAA_FLAG_SKIP_DNS_INFO
|
||||
#define GAA_FLAG_SKIP_DNS_INFO 0x0800
|
||||
#endif
|
||||
|
||||
#ifndef WSAID_MULTIPLE_RIO
|
||||
#define WSAID_MULTIPLE_RIO \
|
||||
{ 0x8509e081, 0x96dd, 0x4005, \
|
||||
{ 0xb1, 0x65, 0x9e, 0x2e, 0xe8, 0xc7, 0x9e, 0x3f } }
|
||||
#endif
|
||||
|
||||
#ifndef RIO_INVALID_CQ
|
||||
typedef struct RIO_BUFFERID_t *RIO_BUFFERID, **PRIO_BUFFERID;
|
||||
typedef struct RIO_CQ_t *RIO_CQ, **PRIO_CQ;
|
||||
typedef struct RIO_RQ_t *RIO_RQ, **PRIO_RQ;
|
||||
|
||||
typedef struct _RIORESULT
|
||||
{
|
||||
LONG Status;
|
||||
ULONG BytesTransferred;
|
||||
ULONGLONG SocketContext;
|
||||
ULONGLONG RequestContext;
|
||||
}
|
||||
RIORESULT, *PRIORESULT;
|
||||
|
||||
typedef struct _RIO_BUF
|
||||
{
|
||||
RIO_BUFFERID BufferId;
|
||||
ULONG Offset;
|
||||
ULONG Length;
|
||||
}
|
||||
RIO_BUF, *PRIO_BUF;
|
||||
|
||||
#define RIO_MSG_DONT_NOTIFY 0x00000001
|
||||
#define RIO_MSG_DEFER 0x00000002
|
||||
#define RIO_MSG_WAITALL 0x00000004
|
||||
#define RIO_MSG_COMMIT_ONLY 0x00000008
|
||||
|
||||
#define RIO_INVALID_BUFFERID ((RIO_BUFFERID)(ULONG_PTR)0xFFFFFFFF)
|
||||
#define RIO_INVALID_CQ ((RIO_CQ)0)
|
||||
#define RIO_INVALID_RQ ((RIO_RQ)0)
|
||||
#define RIO_MAX_CQ_SIZE 0x08000000
|
||||
#define RIO_CORRUPT_CQ 0xFFFFFFFF
|
||||
|
||||
typedef struct _RIO_CMSG_BUFFER
|
||||
{
|
||||
ULONG TotalLength;
|
||||
}
|
||||
RIO_CMSG_BUFFER, *PRIO_CMSG_BUFFER;
|
||||
|
||||
#define RIO_CMSG_BASE_SIZE WSA_CMSGHDR_ALIGN(sizeof(RIO_CMSG_BUFFER))
|
||||
|
||||
typedef BOOL (WINAPI *LPFN_RIORECEIVE)(
|
||||
RIO_RQ, PRIO_BUF, ULONG, DWORD, PVOID);
|
||||
typedef BOOL (WINAPI *LPFN_RIORECEIVEEX)(
|
||||
RIO_RQ, PRIO_BUF, ULONG, PRIO_BUF, PRIO_BUF, PRIO_BUF, PRIO_BUF,
|
||||
DWORD, PVOID);
|
||||
typedef BOOL (WINAPI *LPFN_RIOSEND)(
|
||||
RIO_RQ, PRIO_BUF, ULONG, DWORD, PVOID);
|
||||
typedef BOOL (WINAPI *LPFN_RIOSENDEX)(
|
||||
RIO_RQ, PRIO_BUF, ULONG, PRIO_BUF, PRIO_BUF, PRIO_BUF, PRIO_BUF,
|
||||
DWORD, PVOID);
|
||||
typedef VOID (WINAPI *LPFN_RIOCLOSECOMPLETIONQUEUE)(RIO_CQ);
|
||||
|
||||
typedef enum _RIO_NOTIFICATION_COMPLETION_TYPE
|
||||
{
|
||||
RIO_EVENT_COMPLETION = 1,
|
||||
RIO_IOCP_COMPLETION = 2,
|
||||
}
|
||||
RIO_NOTIFICATION_COMPLETION_TYPE, *PRIO_NOTIFICATION_COMPLETION_TYPE;
|
||||
|
||||
typedef struct _RIO_NOTIFICATION_COMPLETION
|
||||
{
|
||||
RIO_NOTIFICATION_COMPLETION_TYPE Type;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
HANDLE EventHandle;
|
||||
BOOL NotifyReset;
|
||||
}
|
||||
Event;
|
||||
struct
|
||||
{
|
||||
HANDLE IocpHandle;
|
||||
PVOID CompletionKey;
|
||||
PVOID Overlapped;
|
||||
}
|
||||
Iocp;
|
||||
};
|
||||
}
|
||||
RIO_NOTIFICATION_COMPLETION, *PRIO_NOTIFICATION_COMPLETION;
|
||||
|
||||
typedef RIO_CQ (WINAPI *LPFN_RIOCREATECOMPLETIONQUEUE)(
|
||||
DWORD, PRIO_NOTIFICATION_COMPLETION);
|
||||
typedef RIO_RQ (WINAPI *LPFN_RIOCREATEREQUESTQUEUE)(
|
||||
SOCKET, ULONG, ULONG, ULONG, ULONG, RIO_CQ, RIO_CQ, PVOID);
|
||||
typedef ULONG (WINAPI *LPFN_RIODEQUEUECOMPLETION)(
|
||||
RIO_CQ, PRIORESULT, ULONG);
|
||||
typedef VOID (WINAPI *LPFN_RIODEREGISTERBUFFER)(RIO_BUFFERID);
|
||||
typedef INT (WINAPI *LPFN_RIONOTIFY)(RIO_CQ);
|
||||
typedef RIO_BUFFERID (WINAPI *LPFN_RIOREGISTERBUFFER)(PCHAR, DWORD);
|
||||
typedef BOOL (WINAPI *LPFN_RIORESIZECOMPLETIONQUEUE)(RIO_CQ, DWORD);
|
||||
typedef BOOL (WINAPI *LPFN_RIORESIZEREQUESTQUEUE)(RIO_RQ, DWORD, DWORD);
|
||||
|
||||
typedef struct _RIO_EXTENSION_FUNCTION_TABLE
|
||||
{
|
||||
DWORD cbSize;
|
||||
LPFN_RIORECEIVE RIOReceive;
|
||||
LPFN_RIORECEIVEEX RIOReceiveEx;
|
||||
LPFN_RIOSEND RIOSend;
|
||||
LPFN_RIOSENDEX RIOSendEx;
|
||||
LPFN_RIOCLOSECOMPLETIONQUEUE RIOCloseCompletionQueue;
|
||||
LPFN_RIOCREATECOMPLETIONQUEUE RIOCreateCompletionQueue;
|
||||
LPFN_RIOCREATEREQUESTQUEUE RIOCreateRequestQueue;
|
||||
LPFN_RIODEQUEUECOMPLETION RIODequeueCompletion;
|
||||
LPFN_RIODEREGISTERBUFFER RIODeregisterBuffer;
|
||||
LPFN_RIONOTIFY RIONotify;
|
||||
LPFN_RIOREGISTERBUFFER RIORegisterBuffer;
|
||||
LPFN_RIORESIZECOMPLETIONQUEUE RIOResizeCompletionQueue;
|
||||
LPFN_RIORESIZEREQUESTQUEUE RIOResizeRequestQueue;
|
||||
}
|
||||
RIO_EXTENSION_FUNCTION_TABLE, *PRIO_EXTENSION_FUNCTION_TABLE;
|
||||
#endif
|
||||
|
||||
#ifndef IN6ADDR_SETV4MAPPED
|
||||
static inline void lgMsQuicSetV4MappedAddress(
|
||||
SOCKADDR_IN6 *address,
|
||||
const IN_ADDR *ipv4,
|
||||
SCOPE_ID scope,
|
||||
USHORT port)
|
||||
{
|
||||
memset(address, 0, sizeof(*address));
|
||||
address->sin6_family = AF_INET6;
|
||||
address->sin6_port = port;
|
||||
address->sin6_scope_struct = scope;
|
||||
address->sin6_addr.s6_bytes[10] = 0xff;
|
||||
address->sin6_addr.s6_bytes[11] = 0xff;
|
||||
memcpy(&address->sin6_addr.s6_bytes[12], ipv4, sizeof(*ipv4));
|
||||
}
|
||||
|
||||
#define IN6ADDR_SETV4MAPPED(address, ipv4, scope, port) \
|
||||
lgMsQuicSetV4MappedAddress((address), (ipv4), (scope), (port))
|
||||
#endif
|
||||
|
||||
#ifndef IN6_GET_ADDR_V4MAPPED
|
||||
#define IN6_GET_ADDR_V4MAPPED(address) (&(address)->s6_bytes[12])
|
||||
#endif
|
||||
|
||||
#ifndef IN6ADDR_ISV4MAPPED
|
||||
#define IN6ADDR_ISV4MAPPED(address) \
|
||||
IN6_IS_ADDR_V4MAPPED(&(address)->sin6_addr)
|
||||
#endif
|
||||
|
||||
#ifndef IN4_IS_ADDR_LOOPBACK
|
||||
#define IN4_IS_ADDR_LOOPBACK(address) \
|
||||
(((const unsigned char *)&(address)->s_addr)[0] == 127)
|
||||
#endif
|
||||
|
||||
#ifndef PIN_PKTINFO
|
||||
typedef IN_PKTINFO *PIN_PKTINFO;
|
||||
#endif
|
||||
|
||||
#ifndef PIN6_PKTINFO
|
||||
typedef IN6_PKTINFO *PIN6_PKTINFO;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user