From 8566a867f239a9f017ab1150ee44678e3faa1eb7 Mon Sep 17 00:00:00 2001 From: Thad House Date: Fri, 19 Jun 2020 12:46:38 -0700 Subject: [PATCH] Enable building on Azure for Raspberry Pi with a cross compiler (#524) * Allow building with Raspberry Pi Cross Compilers --- .azure/azure-pipelines.ci.yml | 13 ++ .../templates/build-config-user-container.yml | 45 ++++++ CMakeLists.txt | 28 ++-- .../arm-pi-gnueabihf.toolchain.cmake | 98 +++++++++++++ cmake/toolchains/arm.toolchain.cmake | 97 +++++++++++++ cmake/toolchains/gnu.toolchain.cmake | 134 ++++++++++++++++++ scripts/build.ps1 | 10 +- 7 files changed, 416 insertions(+), 9 deletions(-) create mode 100644 .azure/templates/build-config-user-container.yml create mode 100644 cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake create mode 100644 cmake/toolchains/arm.toolchain.cmake create mode 100644 cmake/toolchains/gnu.toolchain.cmake diff --git a/.azure/azure-pipelines.ci.yml b/.azure/azure-pipelines.ci.yml index e27a0180d..fe235ebf3 100644 --- a/.azure/azure-pipelines.ci.yml +++ b/.azure/azure-pipelines.ci.yml @@ -17,6 +17,11 @@ pr: name: 0.$(Date:yyyy).$(Date:MM).$(DayOfMonth).$(Rev:rr).0 +resources: + containers: + - container: raspbian + image: wpilib/raspbian-cross-ubuntu:10-18.04 + # # Builds # @@ -120,6 +125,14 @@ stages: arch: x64 tls: stub extraBuildArgs: -SanitizeAddress + - template: ./templates/build-config-user-container.yml + parameters: + image: ubuntu-latest + platform: linux + arch: arm + tls: openssl + container: raspbian + extraBuildArgs: -DisableLogs -ToolchainFile cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake # # Build Verification Tests diff --git a/.azure/templates/build-config-user-container.yml b/.azure/templates/build-config-user-container.yml new file mode 100644 index 000000000..239ce2ded --- /dev/null +++ b/.azure/templates/build-config-user-container.yml @@ -0,0 +1,45 @@ +# This template contains steps to build MsQuic for a single configuration. + +parameters: + image: '' + platform: '' + arch: '' + tls: '' + container: '' + extraBuildArgs: '' + +jobs: +- job: build_${{ parameters.platform }}_${{ parameters.arch }}_${{ parameters.tls }} + displayName: ${{ parameters.arch }} ${{ parameters.tls }} + pool: + vmImage: ${{ parameters.image }} + + container: ${{ parameters.container }} + + steps: + - checkout: self + submodules: recursive + + - script: | + wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb + sudo dpkg -i packages-microsoft-prod.deb + sudo apt-get update + sudo add-apt-repository universe + sudo apt-get install -y powershell + displayName: Install Powershell + + - task: PowerShell@2 + displayName: Build Source Code (Debug) + inputs: + pwsh: true + filePath: scripts/build.ps1 + arguments: -Arch ${{ parameters.arch }} -Tls ${{ parameters.tls }} -Platform ${{ parameters.platform }} ${{ parameters.extraBuildArgs }} + + - task: PowerShell@2 + displayName: Build Source Code (Release) + inputs: + pwsh: true + filePath: scripts/build.ps1 + arguments: -Config Release -Arch ${{ parameters.arch }} -Tls ${{ parameters.tls }} -Platform ${{ parameters.platform }} ${{ parameters.extraBuildArgs }} + + - template: ./upload-artifacts.yml diff --git a/CMakeLists.txt b/CMakeLists.txt index c99e0c25f..9355aa40a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,14 +244,26 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/inc) if(QUIC_TLS STREQUAL "openssl") # Configure and build OpenSSL. - add_custom_command( - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl - OUTPUT ${QUIC_BUILD_DIR}/openssl/include - OUTPUT ${QUIC_BUILD_DIR}/openssl/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX} - OUTPUT ${QUIC_BUILD_DIR}/openssl/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX} - COMMAND SYSTEM=${CMAKE_HOST_SYSTEM_NAME} ./config enable-tls1_3 --prefix=${QUIC_BUILD_DIR}/openssl - COMMAND make -j$$(nproc) - COMMAND make install_sw) + if (CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + add_custom_command( + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl + OUTPUT ${QUIC_BUILD_DIR}/openssl/include + OUTPUT ${QUIC_BUILD_DIR}/openssl/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX} + OUTPUT ${QUIC_BUILD_DIR}/openssl/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX} + COMMAND SYSTEM=${CMAKE_HOST_SYSTEM_NAME} ./Configure linux-armv4 --cross-compile-prefix=${GNU_MACHINE}${FLOAT_ABI_SUFFIX}- -DL_ENDIAN enable-tls1_3 --prefix=${QUIC_BUILD_DIR}/openssl + COMMAND make clean + COMMAND make -j$$(nproc) + COMMAND make install_sw) + else () + add_custom_command( + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/submodules/openssl + OUTPUT ${QUIC_BUILD_DIR}/openssl/include + OUTPUT ${QUIC_BUILD_DIR}/openssl/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX} + OUTPUT ${QUIC_BUILD_DIR}/openssl/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX} + COMMAND SYSTEM=${CMAKE_HOST_SYSTEM_NAME} ./config enable-tls1_3 --prefix=${QUIC_BUILD_DIR}/openssl + COMMAND make -j$$(nproc) + COMMAND make install_sw) + endif() add_custom_target(OpenSSL DEPENDS ${QUIC_BUILD_DIR}/openssl/include DEPENDS ${QUIC_BUILD_DIR}/openssl/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX} diff --git a/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake b/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake new file mode 100644 index 000000000..f1ae3ecd1 --- /dev/null +++ b/cmake/toolchains/arm-pi-gnueabihf.toolchain.cmake @@ -0,0 +1,98 @@ +set(GCC_COMPILER_VERSION "" CACHE STRING "GCC Compiler version") +set(GNU_MACHINE "arm-raspbian10-linux-gnueabi" CACHE STRING "GNU compiler triple") + +if(COMMAND toolchain_save_config) + return() # prevent recursive call +endif() + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR arm) +else() + #message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/gnu.toolchain.cmake") + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm AND NOT ARM_IGNORE_FP) + set(FLOAT_ABI_SUFFIX "") + if(NOT SOFTFP) + set(FLOAT_ABI_SUFFIX "hf") + endif() +endif() + +if(NOT "x${GCC_COMPILER_VERSION}" STREQUAL "x") + set(__GCC_VER_SUFFIX "-${GCC_COMPILER_VERSION}") +endif() + +if(NOT DEFINED CMAKE_C_COMPILER) + find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_CXX_COMPILER) + find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_LINKER) + find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) +else() + #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") +endif() +if(NOT DEFINED CMAKE_AR) + find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) +else() + #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") +endif() + +if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) + set(ARM_LINUX_SYSROOT /usr/local/sys-root) +endif() + +if(NOT DEFINED CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") + set(CMAKE_C_FLAGS "" CACHE INTERNAL "") + set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc") + endif() + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(ARM_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + set(ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + endif() + set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") +else() + #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") +endif() + +if(USE_NEON) + message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) + set(ENABLE_NEON TRUE) +elseif(USE_VFPV3) + message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) + set(ENABLE_VFPV3 TRUE) +endif() + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) + +if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + +set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} + ARM_LINUX_SYSROOT + ENABLE_NEON + ENABLE_VFPV3 + CUDA_TOOLKIT_ROOT_DIR +) +toolchain_save_config() diff --git a/cmake/toolchains/arm.toolchain.cmake b/cmake/toolchains/arm.toolchain.cmake new file mode 100644 index 000000000..184997fba --- /dev/null +++ b/cmake/toolchains/arm.toolchain.cmake @@ -0,0 +1,97 @@ +if(COMMAND toolchain_save_config) + return() # prevent recursive call +endif() + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) +if(NOT DEFINED CMAKE_SYSTEM_PROCESSOR) + set(CMAKE_SYSTEM_PROCESSOR arm) +else() + #message("CMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}") +endif() + +include("${CMAKE_CURRENT_LIST_DIR}/gnu.toolchain.cmake") + +if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm AND NOT ARM_IGNORE_FP) + set(FLOAT_ABI_SUFFIX "") + if(NOT SOFTFP) + set(FLOAT_ABI_SUFFIX "hf") + endif() +endif() + +if(NOT "x${GCC_COMPILER_VERSION}" STREQUAL "x") + set(__GCC_VER_SUFFIX "-${GCC_COMPILER_VERSION}") +endif() + +if(NOT DEFINED CMAKE_C_COMPILER) + find_program(CMAKE_C_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-gcc${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_C_COMPILER=${CMAKE_C_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_CXX_COMPILER) + find_program(CMAKE_CXX_COMPILER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-g++${__GCC_VER_SUFFIX}) +else() + #message(WARNING "CMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} is defined") +endif() +if(NOT DEFINED CMAKE_LINKER) + find_program(CMAKE_LINKER NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ld) +else() + #message(WARNING "CMAKE_LINKER=${CMAKE_LINKER} is defined") +endif() +if(NOT DEFINED CMAKE_AR) + find_program(CMAKE_AR NAMES ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar${__GCC_VER_SUFFIX} ${GNU_MACHINE}${FLOAT_ABI_SUFFIX}-ar) +else() + #message(WARNING "CMAKE_AR=${CMAKE_AR} is defined") +endif() + +if(NOT DEFINED ARM_LINUX_SYSROOT AND DEFINED GNU_MACHINE) + set(ARM_LINUX_SYSROOT /usr/${GNU_MACHINE}${FLOAT_ABI_SUFFIX}) +endif() + +if(NOT DEFINED CMAKE_CXX_FLAGS) + set(CMAKE_CXX_FLAGS "" CACHE INTERNAL "") + set(CMAKE_C_FLAGS "" CACHE INTERNAL "") + set(CMAKE_SHARED_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_MODULE_LINKER_FLAGS "" CACHE INTERNAL "") + set(CMAKE_EXE_LINKER_FLAGS "" CACHE INTERNAL "") + + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fdata-sections -Wa,--noexecstack -fsigned-char -Wno-psabi") + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(CMAKE_CXX_FLAGS "-mthumb ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "-mthumb ${CMAKE_C_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,nocopyreloc") + endif() + if(CMAKE_SYSTEM_PROCESSOR STREQUAL arm) + set(ARM_LINKER_FLAGS "-Wl,--fix-cortex-a8 -Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + set(ARM_LINKER_FLAGS "-Wl,--no-undefined -Wl,--gc-sections -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now") + endif() + set(CMAKE_SHARED_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") + set(CMAKE_MODULE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${ARM_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") +else() + #message(WARNING "CMAKE_CXX_FLAGS='${CMAKE_CXX_FLAGS}' is defined") +endif() + +if(USE_NEON) + message(WARNING "You use obsolete variable USE_NEON to enable NEON instruction set. Use -DENABLE_NEON=ON instead." ) + set(ENABLE_NEON TRUE) +elseif(USE_VFPV3) + message(WARNING "You use obsolete variable USE_VFPV3 to enable VFPV3 instruction set. Use -DENABLE_VFPV3=ON instead." ) + set(ENABLE_VFPV3 TRUE) +endif() + +set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${ARM_LINUX_SYSROOT}) + +if(EXISTS ${CUDA_TOOLKIT_ROOT_DIR}) + set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${CUDA_TOOLKIT_ROOT_DIR}) +endif() + +set(TOOLCHAIN_CONFIG_VARS ${TOOLCHAIN_CONFIG_VARS} + ARM_LINUX_SYSROOT + ENABLE_NEON + ENABLE_VFPV3 + CUDA_TOOLKIT_ROOT_DIR +) +toolchain_save_config() diff --git a/cmake/toolchains/gnu.toolchain.cmake b/cmake/toolchains/gnu.toolchain.cmake new file mode 100644 index 000000000..cba08e7fb --- /dev/null +++ b/cmake/toolchains/gnu.toolchain.cmake @@ -0,0 +1,134 @@ +cmake_minimum_required(VERSION 2.8) + +# load settings in case of "try compile" +set(TOOLCHAIN_CONFIG_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain.config.cmake") +get_property(__IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE) +if(__IN_TRY_COMPILE) + include("${CMAKE_CURRENT_SOURCE_DIR}/../toolchain.config.cmake" OPTIONAL) # CMAKE_BINARY_DIR is different + macro(toolchain_save_config) + # nothing + endmacro() +else() + macro(toolchain_save_config) + set(__config "#message(\"Load TOOLCHAIN config...\")\n") + get_cmake_property(__variableNames VARIABLES) + set(__vars_list ${ARGN}) + list(APPEND __vars_list + ${TOOLCHAIN_CONFIG_VARS} + CMAKE_SYSTEM_NAME + CMAKE_SYSTEM_VERSION + CMAKE_SYSTEM_PROCESSOR + CMAKE_C_COMPILER + CMAKE_CXX_COMPILER + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + CMAKE_SHARED_LINKER_FLAGS + CMAKE_MODULE_LINKER_FLAGS + CMAKE_EXE_LINKER_FLAGS + CMAKE_SKIP_RPATH + CMAKE_FIND_ROOT_PATH + GCC_COMPILER_VERSION + ) + foreach(__var ${__variableNames}) + foreach(_v ${__vars_list}) + if("x${__var}" STREQUAL "x${_v}") + if(${__var} MATCHES " ") + set(__config "${__config}set(${__var} \"${${__var}}\")\n") + else() + set(__config "${__config}set(${__var} ${${__var}})\n") + endif() + endif() + endforeach() + endforeach() + if(EXISTS "${TOOLCHAIN_CONFIG_FILE}") + file(READ "${TOOLCHAIN_CONFIG_FILE}" __config_old) + endif() + if("${__config_old}" STREQUAL "${__config}") + # nothing + else() + #message("Update TOOLCHAIN config: ${__config}") + file(WRITE "${TOOLCHAIN_CONFIG_FILE}" "${__config}") + endif() + unset(__config) + unset(__config_old) + unset(__vars_list) + unset(__variableNames) + endmacro() +endif() # IN_TRY_COMPILE + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY) + set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +endif() + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE) + set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) +endif() + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE) + set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) +endif() + +if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM) + set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +endif() + +macro(__cmake_find_root_save_and_reset) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(__save_${v} ${${v}}) + set(${v} NEVER) + endforeach() +endmacro() + +macro(__cmake_find_root_restore) + foreach(v + CMAKE_FIND_ROOT_PATH_MODE_LIBRARY + CMAKE_FIND_ROOT_PATH_MODE_INCLUDE + CMAKE_FIND_ROOT_PATH_MODE_PACKAGE + CMAKE_FIND_ROOT_PATH_MODE_PROGRAM + ) + set(${v} ${__save_${v}}) + unset(__save_${v}) + endforeach() +endmacro() + + +# macro to find programs on the host OS +macro(find_host_program) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + endif() + find_program(${ARGN}) + SET(WIN32) + SET(APPLE) + SET(UNIX 1) + __cmake_find_root_restore() +endmacro() + +# macro to find packages on the host OS +macro(find_host_package) + __cmake_find_root_save_and_reset() + if(CMAKE_HOST_WIN32) + SET(WIN32 1) + SET(UNIX) + elseif(CMAKE_HOST_APPLE) + SET(APPLE 1) + SET(UNIX) + endif() + find_package(${ARGN}) + SET(WIN32) + SET(APPLE) + SET(UNIX 1) + __cmake_find_root_restore() +endmacro() + +set(CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries.") diff --git a/scripts/build.ps1 b/scripts/build.ps1 index b67324111..9157b5580 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -15,6 +15,9 @@ This script provides helpers for building msquic. .PARAMETER Tls The TLS library to use. +.PARAMETER ToolchainFile + Toolchain file to use (if cross) + .PARAMETER DisableLogs Disables log collection. @@ -67,6 +70,9 @@ param ( [ValidateSet("schannel", "openssl", "stub", "mitls")] [string]$Tls = "", + [Parameter(Mandatory = $false)] + [string]$ToolchainFile = "", + [Parameter(Mandatory = $false)] [switch]$DisableLogs = $false, @@ -197,7 +203,9 @@ function CMake-Generate { } if ($Platform -eq "uwp") { $Arguments += " -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10 -DQUIC_UWP_BUILD=on -DQUIC_STATIC_LINK_CRT=Off" - + } + if ($ToolchainFile -ne "") { + $Arguments += " ""-DCMAKE_TOOLCHAIN_FILE=" + $ToolchainFile + """" } $Arguments += " ../../.."