From 14d125f2d8d83860096a3be01893d44415a26d8a Mon Sep 17 00:00:00 2001 From: Chuck Walbourn Date: Thu, 13 Jun 2024 15:53:08 -0700 Subject: [PATCH] CMake improvements for multi-config generators (#457) --- build/CompilerAndLinker.cmake | 6 ++++-- build/DirectXTK-GitHub-CMake-Dev17.yml | 16 ++++++++-------- build/DirectXTK-GitHub-CMake.yml | 16 ++++++++-------- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/build/CompilerAndLinker.cmake b/build/CompilerAndLinker.cmake index 2a6e864e..d53ab583 100644 --- a/build/CompilerAndLinker.cmake +++ b/build/CompilerAndLinker.cmake @@ -85,7 +85,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") if(CMAKE_INTERPROCEDURAL_OPTIMIZATION) message(STATUS "Building using Whole Program Optimization") - list(APPEND COMPILER_SWITCHES /Gy /Gw) + list(APPEND COMPILER_SWITCHES $<$>:/Gy /Gw>) endif() if(OpenMP_CXX_FOUND) @@ -116,7 +116,9 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES "MSVC") endif() if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 19.35) - list(APPEND COMPILER_SWITCHES /Zc:checkGwOdr) + if(CMAKE_INTERPROCEDURAL_OPTIMIZATION) + list(APPEND COMPILER_SWITCHES $<$>:/Zc:checkGwOdr>) + endif() if(NOT (DEFINED XBOX_CONSOLE_TARGET)) list(APPEND COMPILER_SWITCHES $<$:/Zc:templateScope>) diff --git a/build/DirectXTK-GitHub-CMake-Dev17.yml b/build/DirectXTK-GitHub-CMake-Dev17.yml index 09bb39a0..69c14584 100644 --- a/build/DirectXTK-GitHub-CMake-Dev17.yml +++ b/build/DirectXTK-GitHub-CMake-Dev17.yml @@ -72,7 +72,7 @@ jobs: displayName: 'CMake (MSVC): Config x64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC): Build x64 Debug' inputs: @@ -87,7 +87,7 @@ jobs: displayName: 'CMake (MSVC): Config x86' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A Win32 -B out2 -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A Win32 -B out2 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC): Build x86 Debug' inputs: @@ -102,7 +102,7 @@ jobs: displayName: 'CMake (MSVC): Config ARM64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out3 -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out3 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC): Build ARM64 Debug' inputs: @@ -117,7 +117,7 @@ jobs: displayName: 'CMake (UWP): Config x64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out4 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out4 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=10.0' - task: CMake@1 displayName: 'CMake (UWP): Build x64' inputs: @@ -152,7 +152,7 @@ jobs: displayName: 'CMake (Win10): Config' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out8 -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN10=ON -DBUILD_TOOLS=OFF' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out8 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN10=ON -DBUILD_TOOLS=OFF' - task: CMake@1 displayName: 'CMake (Win10): Build' inputs: @@ -183,7 +183,7 @@ jobs: displayName: 'CMake (MSVC Spectre): Config x64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out10 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out10 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC Spectre): Build x64 Debug' inputs: @@ -198,7 +198,7 @@ jobs: displayName: 'CMake (MSVC Spectre): Config ARM64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out11 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out11 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC Spectre): Build ARM64 Debug' inputs: @@ -213,7 +213,7 @@ jobs: displayName: 'CMake (NO_WCHAR_T): Config' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out12 -DNO_WCHAR_T=ON -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out12 -DNO_WCHAR_T=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)' - task: CMake@1 displayName: 'CMake (NO_WCHAR_T): Build' inputs: diff --git a/build/DirectXTK-GitHub-CMake.yml b/build/DirectXTK-GitHub-CMake.yml index 466941b3..6a895b7f 100644 --- a/build/DirectXTK-GitHub-CMake.yml +++ b/build/DirectXTK-GitHub-CMake.yml @@ -72,7 +72,7 @@ jobs: displayName: 'CMake (MSVC): Config x64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC): Build x64 Debug' inputs: @@ -87,7 +87,7 @@ jobs: displayName: 'CMake (MSVC): Config x86' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A Win32 -B out2 -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A Win32 -B out2 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC): Build x86 Debug' inputs: @@ -102,7 +102,7 @@ jobs: displayName: 'CMake (MSVC): Config ARM64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out3 -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out3 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC): Build ARM64 Debug' inputs: @@ -117,7 +117,7 @@ jobs: displayName: 'CMake (UWP): Config x64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out4 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out4 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=10.0' - task: CMake@1 displayName: 'CMake (UWP): Build x64' inputs: @@ -152,7 +152,7 @@ jobs: displayName: 'CMake (Win10): Config' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out8 -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN10=ON -DBUILD_TOOLS=OFF' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out8 -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN10=ON -DBUILD_TOOLS=OFF' - task: CMake@1 displayName: 'CMake (Win10): Build' inputs: @@ -183,7 +183,7 @@ jobs: displayName: 'CMake (MSVC Spectre): Config x64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out10 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out10 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC Spectre): Build x64 Debug' inputs: @@ -198,7 +198,7 @@ jobs: displayName: 'CMake (MSVC Spectre): Config ARM64' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out11 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' + cmakeArgs: '-G "$(VS_GENERATOR)" -A ARM64 -B out11 -DENABLE_SPECTRE_MITIGATION=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN10_SDK) -DBUILD_XAUDIO_WIN8=ON -DBUILD_TOOLS=ON' - task: CMake@1 displayName: 'CMake (MSVC Spectre): Build ARM64 Debug' inputs: @@ -213,7 +213,7 @@ jobs: displayName: 'CMake (NO_WCHAR_T): Config' inputs: cwd: '$(Build.SourcesDirectory)' - cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out12 -DNO_WCHAR_T=ON -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)' + cmakeArgs: '-G "$(VS_GENERATOR)" -A x64 -B out12 -DNO_WCHAR_T=ON -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON -DCMAKE_SYSTEM_VERSION=$(WIN11_SDK)' - task: CMake@1 displayName: 'CMake (NO_WCHAR_T): Build' inputs: