Skip to content

Commit

Permalink
Added guard:ehcont for 64bit windows (#99)
Browse files Browse the repository at this point in the history
- Added security flag guard:ehcont for MSVC.
- Updated wininit script to use Visual Studio 2019 as default generator. 
- Re-enabled vcpkg tests now that rapidjson has been updated.
  • Loading branch information
SergioRZMasson authored Jul 19, 2022
1 parent eaccf16 commit 382dea2
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 122 deletions.
242 changes: 121 additions & 121 deletions Build/AzureDevOps/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,85 +62,85 @@ jobs:
testResultsFiles: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test\GLTFSDK.Test.log
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))

# - job: WindowsVcPkg_VS2019

# pool:
# vmImage: 'windows-2019'

# strategy:
# matrix:
# Win32-Release:
# buildPlatform: Win32
# buildConfiguration: Release
# vcpkgTriplet: x86-windows
# Win32-Debug:
# buildPlatform: Win32
# buildConfiguration: Debug
# vcpkgTriplet: x86-windows
# x64-Release:
# buildPlatform: x64
# buildConfiguration: Release
# vcpkgTriplet: x64-windows
# x64-Debug:
# buildPlatform: x64
# buildConfiguration: Debug
# vcpkgTriplet: x64-windows
# ARM-Release:
# buildPlatform: ARM
# buildConfiguration: Release
# vcpkgTriplet: arm-windows
# ARM-Debug:
# buildPlatform: ARM
# buildConfiguration: Debug
# vcpkgTriplet: arm-windows
# ARM64-Release:
# buildPlatform: ARM64
# buildConfiguration: Release
# vcpkgTriplet: arm64-windows
# ARM64-Debug:
# buildPlatform: ARM64
# buildConfiguration: Debug
# vcpkgTriplet: arm64-windows

# workspace:
# clean: all

# variables:
# vcpkgRoot: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"

# steps:
# - powershell: vcpkg install --triplet "$(vcpkgTriplet)" rapidjson gtest
# displayName: Install packages with VcPkg

# - task: CMake@1
# inputs:
# workingDirectory: 'built\Int\cmake_$(buildPlatform)'
# cmakeArgs: '..\..\.. -G "Visual Studio 16 2019" -A "$(buildPlatform)" -DCMAKE_TOOLCHAIN_FILE="$(vcpkgRoot)" -DVCPKG_TARGET_TRIPLET="$(vcpkgTriplet)"'

# - task: CMake@1
# inputs:
# workingDirectory: 'built\Int\cmake_$(buildPlatform)'
# cmakeArgs: '--build . --target install --config $(buildConfiguration) -- /m'

# # copy googletest related dll files
# - task: CopyFiles@2
# inputs:
# sourceFolder: 'built\Int\cmake_$(buildPlatform)\GLTFSDK.Test\$(buildConfiguration)'
# contents: 'gtest*.dll'
# targetFolder: 'built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test'
# overWrite: true
# condition: in(variables['buildPlatform'], 'Win32', 'x64')

# - script: .\GLTFSDK.Test.exe --gtest_output=xml:GLTFSDK.Test.log
# workingDirectory: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test
# displayName: Running Unit Tests
# condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))

# - task: PublishTestResults@2
# inputs:
# testResultsFormat: 'JUnit'
# testResultsFiles: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test\GLTFSDK.Test.log
# condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))
- job: WindowsVcPkg_VS2019

pool:
vmImage: 'windows-2019'

strategy:
matrix:
Win32-Release:
buildPlatform: Win32
buildConfiguration: Release
vcpkgTriplet: x86-windows
Win32-Debug:
buildPlatform: Win32
buildConfiguration: Debug
vcpkgTriplet: x86-windows
x64-Release:
buildPlatform: x64
buildConfiguration: Release
vcpkgTriplet: x64-windows
x64-Debug:
buildPlatform: x64
buildConfiguration: Debug
vcpkgTriplet: x64-windows
ARM-Release:
buildPlatform: ARM
buildConfiguration: Release
vcpkgTriplet: arm-windows
ARM-Debug:
buildPlatform: ARM
buildConfiguration: Debug
vcpkgTriplet: arm-windows
ARM64-Release:
buildPlatform: ARM64
buildConfiguration: Release
vcpkgTriplet: arm64-windows
ARM64-Debug:
buildPlatform: ARM64
buildConfiguration: Debug
vcpkgTriplet: arm64-windows

workspace:
clean: all

variables:
vcpkgRoot: "C:/vcpkg/scripts/buildsystems/vcpkg.cmake"

steps:
- powershell: vcpkg install --triplet "$(vcpkgTriplet)" rapidjson gtest
displayName: Install packages with VcPkg

- task: CMake@1
inputs:
workingDirectory: 'built\Int\cmake_$(buildPlatform)'
cmakeArgs: '..\..\.. -G "Visual Studio 16 2019" -A "$(buildPlatform)" -DCMAKE_TOOLCHAIN_FILE="$(vcpkgRoot)" -DVCPKG_TARGET_TRIPLET="$(vcpkgTriplet)"'

- task: CMake@1
inputs:
workingDirectory: 'built\Int\cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration) -- /m'

# copy googletest related dll files
- task: CopyFiles@2
inputs:
sourceFolder: 'built\Int\cmake_$(buildPlatform)\GLTFSDK.Test\$(buildConfiguration)'
contents: 'gtest*.dll'
targetFolder: 'built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test'
overWrite: true
condition: in(variables['buildPlatform'], 'Win32', 'x64')

- script: .\GLTFSDK.Test.exe --gtest_output=xml:GLTFSDK.Test.log
workingDirectory: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test
displayName: Running Unit Tests
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))

- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: built\Out\windows_$(buildPlatform)\$(buildConfiguration)\GLTFSDK.Test\GLTFSDK.Test.log
condition: and(succeeded(), in(variables['buildPlatform'], 'Win32', 'x64'))

- job: MacOS

Expand Down Expand Up @@ -180,50 +180,50 @@ jobs:
testResultsFormat: 'JUnit'
testResultsFiles: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test/GLTFSDK.Test.log

# - job: MacOSVcPkg
- job: MacOSVcPkg

# pool:
# vmImage: 'macOS-10.15'
pool:
vmImage: 'macOS-10.15'

# strategy:
# matrix:
# macOS-Release:
# buildPlatform: macOS
# buildConfiguration: Release
# vcpkgTriplet: x64-osx
# macOS-Debug:
# buildPlatform: macOS
# buildConfiguration: Debug
# vcpkgTriplet: x64-osx

# workspace:
# clean: all

# steps:
# - task: Bash@3
# inputs:
# targetType: 'inline'
# script: vcpkg install --triplet "$(vcpkgTriplet)" rapidjson gtest
# displayName: Install packages with VcPkg

# - task: CMake@1
# inputs:
# workingDirectory: 'built/Int/cmake_$(buildPlatform)'
# cmakeArgs: '../../.. -G Xcode -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake'

# - task: CMake@1
# inputs:
# workingDirectory: 'built/Int/cmake_$(buildPlatform)'
# cmakeArgs: '--build . --target install --config $(buildConfiguration)'

# - script: ./GLTFSDK.Test --gtest_output=xml:GLTFSDK.Test.log
# workingDirectory: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test
# displayName: Running Unit Tests

# - task: PublishTestResults@2
# inputs:
# testResultsFormat: 'JUnit'
# testResultsFiles: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test/GLTFSDK.Test.log
strategy:
matrix:
macOS-Release:
buildPlatform: macOS
buildConfiguration: Release
vcpkgTriplet: x64-osx
macOS-Debug:
buildPlatform: macOS
buildConfiguration: Debug
vcpkgTriplet: x64-osx

workspace:
clean: all

steps:
- task: Bash@3
inputs:
targetType: 'inline'
script: vcpkg install --triplet "$(vcpkgTriplet)" rapidjson gtest
displayName: Install packages with VcPkg

- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '../../.. -G Xcode -DCMAKE_TOOLCHAIN_FILE=/usr/local/share/vcpkg/scripts/buildsystems/vcpkg.cmake'

- task: CMake@1
inputs:
workingDirectory: 'built/Int/cmake_$(buildPlatform)'
cmakeArgs: '--build . --target install --config $(buildConfiguration)'

- script: ./GLTFSDK.Test --gtest_output=xml:GLTFSDK.Test.log
workingDirectory: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test
displayName: Running Unit Tests

- task: PublishTestResults@2
inputs:
testResultsFormat: 'JUnit'
testResultsFiles: built/Out/$(buildPlatform)/$(buildConfiguration)/GLTFSDK.Test/GLTFSDK.Test.log

- job: iOS

Expand Down
2 changes: 1 addition & 1 deletion Build/Scripts/wininit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function GeneratePlatform($platform, $path)
try
{
$argList = @(
"-G", "Visual Studio 15 2017",
"-G", "Visual Studio 16 2019",
"-A", "$platform"
)

Expand Down
5 changes: 5 additions & 0 deletions GLTFSDK/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ if (MSVC)
# Set warning level to 4 (/W4)
target_compile_options(GLTFSDK PRIVATE "/Zi;/W4;/EHsc")

if((MSVC_VERSION GREATER 1920) AND (CMAKE_SIZEOF_VOID_P EQUAL 8))
target_compile_options(GLTFSDK PRIVATE "$<$<CONFIG:RELEASE>:/guard:ehcont>")
target_link_options(GLTFSDK PRIVATE "$<$<CONFIG:RELEASE>:/guard:ehcont>")
endif()

# Make sure that all PDB files on Windows are installed to the output folder with the libraries. By default, only the debug build does this.
set_target_properties(GLTFSDK PROPERTIES COMPILE_PDB_NAME "GLTFSDK" COMPILE_PDB_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_DIRECTORY}")
endif()
Expand Down

0 comments on commit 382dea2

Please sign in to comment.