Update CMake projects to require 3.20 or later (#18)

This commit is contained in:
Chuck Walbourn 2022-12-09 15:31:45 -08:00 коммит произвёл GitHub
Родитель aa45b831e7
Коммит 66c576245e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
13 изменённых файлов: 62 добавлений и 106 удалений

Просмотреть файл

@ -175,12 +175,12 @@ set(MGCToolPath "${Console_SdkRoot}/bin")
# _WINDOWS
# Standard Debug vs. Release preprocessor definitions
# (automatically defined by MSVC and MSVC-like compilers)
# _DEBUG (Debug)
# NDEBUG (Release without asserts)
set(Console_Defines "$<$<CONFIG:DEBUG>:_DEBUG>" "$<$<CONFIG:RELEASE>:NDEBUG>")
# Build as Unicode (see UTF-8 Everywhere article's Win32 recommendations)
set(Console_Defines ${Console_Defines} _UNICODE UNICODE)
set(Console_Defines _UNICODE UNICODE)
# GDK for Desktop preprocessor definitions
set(Console_Defines ${Console_Defines} _GAMING_DESKTOP WINAPI_FAMILY=WINAPI_FAMILY_DESKTOP_APP)

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required (VERSION 3.20)
project(CMakeExampleDesktop
DESCRIPTION "CMake example for a Microsoft GDK Gaming.Desktop.x64 project"
@ -87,25 +87,16 @@ add_custom_command(TARGET mgccompile
add_dependencies(${PROJECT_NAME} mgccompile shaders)
# Use Warning Level 4
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# If not using typeid or dynamic_cast, we can disable RTTI to save binary size
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${Console_Defines})
# Recommended compiler switches:
# /EHsc (C++ exception handling)
# /fp:fast (Fast floating-point optimizations)
# /GR (RTTI): if not using typeid or dynamic_cast, we can disable RTTI to save binary size using /GR-
# /GS (buffer security check)
# /Gy (enable function-level linking)
# /Zi (Debug Information Format)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /GS /Gy)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /GR- /fp:fast /GS /Gy)
target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs} Xbox::XSAPI Xbox::XCurl)
# uuid.lib if using Windows Imaging Component (WIC) or other COM objects
@ -117,9 +108,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs} Xbox::XSAPI Xbox::
# /Yupch.h (Use Precompiled Header File)
# /Fp (Name .pch file)
# /FI (Name Force Include File)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
target_precompile_headers(${PROJECT_NAME} PRIVATE ../pch.h )
endif()
target_precompile_headers(${PROJECT_NAME} PRIVATE ../pch.h )
target_link_options(${PROJECT_NAME} PRIVATE ${Console_LinkOptions})

Двоичные данные
Samples/Tools/CMakeExample/Readme.docx

Двоичный файл не отображается.

Просмотреть файл

@ -249,12 +249,12 @@ set(MGCToolPath "${Console_SdkRoot}/bin")
# _WINDOWS
# Standard Debug vs. Release preprocessor definitions
# (automatically defined by MSVC and MSVC-like compilers)
# _DEBUG (Debug)
# NDEBUG (Release without asserts)
set(Console_Defines "$<$<CONFIG:DEBUG>:_DEBUG>" "$<$<CONFIG:RELEASE>:NDEBUG>")
# Build as Unicode (see UTF-8 Everywhere article's Win32 recommendations)
set(Console_Defines ${Console_Defines} _UNICODE UNICODE)
set(Console_Defines _UNICODE UNICODE)
# Game Core on Xbox preprocessor definitions
set(Console_Defines ${Console_Defines} WIN32_LEAN_AND_MEAN _GAMING_XBOX WINAPI_FAMILY=WINAPI_FAMILY_GAMES)

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required (VERSION 3.20)
project(CMakeExampleScarlett
DESCRIPTION "CMake example for a Microsoft GDK Gaming.Xbox.Scarlett.x64 project"
@ -72,25 +72,16 @@ add_custom_command(TARGET mgccompile
add_dependencies(${PROJECT_NAME} mgccompile shaders)
# Use Warning Level 4
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# If not using typeid or dynamic_cast, we can disable RTTI to save binary size
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${Console_Defines})
# Recommended compiler switches:
# /EHsc (C++ exception handling)
# /fp:fast (Fast floating-point optimizations)
# /GR (RTTI): if not using typeid or dynamic_cast, we can disable RTTI to save binary size using /GR-
# /GS (buffer security check)
# /Gy (enable function-level linking)
# /Zi (Debug Information Format)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /GS /Gy)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /GR- /fp:fast /GS /Gy)
target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs} Xbox::XSAPI Xbox::XCurl)
# uuid.lib if using Windows Imaging Component (WIC)
@ -102,9 +93,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs} Xbox::XSAPI Xbox::
# /Yupch.h (Use Precompiled Header File)
# /Fp (Name .pch file)
# /FI (Name Force Include File)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
target_precompile_headers(${PROJECT_NAME} PRIVATE ../pch.h )
endif()
target_precompile_headers(${PROJECT_NAME} PRIVATE ../pch.h )
target_link_options(${PROJECT_NAME} PRIVATE ${Console_LinkOptions})

Просмотреть файл

@ -249,12 +249,12 @@ set(MGCToolPath "${Console_SdkRoot}/bin")
# _WINDOWS
# Standard Debug vs. Release preprocessor definitions
# (automatically defined by MSVC and MSVC-like compilers)
# _DEBUG (Debug)
# NDEBUG (Release without asserts)
set(Console_Defines "$<$<CONFIG:DEBUG>:_DEBUG>" "$<$<CONFIG:RELEASE>:NDEBUG>")
# Build as Unicode (see UTF-8 Everywhere article's Win32 recommendations)
set(Console_Defines ${Console_Defines} _UNICODE UNICODE)
set(Console_Defines _UNICODE UNICODE)
# Game Core on Xbox preprocessor definitions
set(Console_Defines ${Console_Defines} WIN32_LEAN_AND_MEAN _GAMING_XBOX WINAPI_FAMILY=WINAPI_FAMILY_GAMES)

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required (VERSION 3.20)
project(CMakeExampleXboxOne
DESCRIPTION "CMake example for a Microsoft GDK Gaming.Xbox.XboxOne.x64 project"
@ -72,25 +72,16 @@ add_custom_command(TARGET mgccompile
add_dependencies(${PROJECT_NAME} mgccompile shaders)
# Use Warning Level 4
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# If not using typeid or dynamic_cast, we can disable RTTI to save binary size
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
target_compile_definitions(${PROJECT_NAME} PRIVATE ${Console_Defines})
# Recommended compiler switches:
# /EHsc (C++ exception handling)
# /fp:fast (Fast floating-point optimizations)
# /GR (RTTI): if not using typeid or dynamic_cast, we can disable RTTI to save binary size using /GR-
# /GS (buffer security check)
# /Gy (enable function-level linking)
# /Zi (Debug Information Format)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /GS /Gy)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /GR- /fp:fast /GS /Gy)
target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs} Xbox::XSAPI Xbox::XCurl)
# uuid.lib if using Windows Imaging Component (WIC)
@ -102,9 +93,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs} Xbox::XSAPI Xbox::
# /Yupch.h (Use Precompiled Header File)
# /Fp (Name .pch file)
# /FI (Name Force Include File)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
target_precompile_headers(${PROJECT_NAME} PRIVATE ../pch.h )
endif()
target_precompile_headers(${PROJECT_NAME} PRIVATE ../pch.h )
target_link_options(${PROJECT_NAME} PRIVATE ${Console_LinkOptions})

Просмотреть файл

@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required (VERSION 3.20)
project(CMakeGDKExample
DESCRIPTION "CMake example for a Microsoft GDK Gaming.*.x64 project"
@ -63,11 +63,6 @@ foreach(FILE VertexShader.hlsl PixelShader.hlsl)
VERBATIM)
endforeach(FILE)
# Use Warning Level 4
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
add_executable(${PROJECT_NAME} WIN32 ${GAME_SOURCES} ${GAME_ASSETS})
add_dependencies(${PROJECT_NAME} shaders)
@ -83,10 +78,11 @@ target_compile_definitions(${PROJECT_NAME} PRIVATE _UNICODE UNICODE)
# Recommended compiler switches:
# /EHsc (C++ exception handling)
# /fp:fast (Fast floating-point optimizations)
# /GR (RTTI): if not using typeid or dynamic_cast, we can disable RTTI to save binary size using /GR-
# /GS (buffer security check)
# /Gy (enable function-level linking)
# /Zi (Debug Information Format)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /GS /Gy)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /GR- /fp:fast /GS /Gy)
# /permissive- (C++ conformance mode enabled)
# /Zc:__cplusplus (Enable updated __cplusplus macro)
@ -118,9 +114,7 @@ elseif(CMAKE_VS_PLATFORM_NAME MATCHES "Gaming.Xbox.*.x64")
endif()
endif()
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16")
target_precompile_headers(${PROJECT_NAME} PRIVATE pch.h)
endif()
target_precompile_headers(${PROJECT_NAME} PRIVATE pch.h)
add_custom_command(
TARGET ${PROJECT_NAME} POST_BUILD
@ -128,9 +122,7 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_BINARY_DIR}/PixelShader.cso $<TARGET_FILE_DIR:${PROJECT_NAME}>
)
if (${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18")
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_SOLUTION_DEPLOY ON)
endif()
set_property(TARGET ${PROJECT_NAME} PROPERTY VS_SOLUTION_DEPLOY ON)
# Extension libraries
# Xbox.Services.API.C Xbox.XCurl.API Xbox.Game.Chat.2.Cpp.API PlayFab.Multiplayer.Cpp PlayFab.Party.Cpp PlayFab.PartyXboxLive.Cpp

Двоичные данные
Samples/Tools/CMakeGDKExample/Readme.docx

Двоичный файл не отображается.

Просмотреть файл

@ -39,20 +39,30 @@ endif()
if (NOT DEFINED VCInstallDir)
set(GDK_VS_EDITIONS "Community" "Professional" "Enterprise" "Preview" "BuildTools")
foreach(vsedition IN LISTS GDK_VS_EDITIONS)
set(VCInstallDir "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/2019/${vsedition}/VC")
if(EXISTS ${VCInstallDir})
break()
endif()
endforeach()
if (NOT EXISTS ${VCInstallDir})
if (MSVC_TOOLSET_VERSION MATCHES "143")
foreach(vsedition IN LISTS GDK_VS_EDITIONS)
set(VCInstallDir "$ENV{ProgramFiles}/Microsoft Visual Studio/2022/${vsedition}/VC")
if(EXISTS ${VCInstallDir})
break()
endif()
endforeach()
else()
foreach(vsedition IN LISTS GDK_VS_EDITIONS)
set(VCInstallDir "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/2019/${vsedition}/VC")
if(EXISTS ${VCInstallDir})
break()
endif()
endforeach()
if (NOT EXISTS ${VCInstallDir})
foreach(vsedition IN LISTS GDK_VS_EDITIONS)
set(VCInstallDir "$ENV{ProgramFiles}/Microsoft Visual Studio/2022/${vsedition}/VC")
if(EXISTS ${VCInstallDir})
break()
endif()
endforeach()
endif()
endif()
endif()
@ -237,9 +247,9 @@ endif()
set(Console_Defines ${Console_Defines} _CONSOLE)
# Standard Debug vs. Release preprocessor definitions
# (automatically defined by MSVC and MSVC-like compilers)
# _DEBUG (Debug)
# NDEBUG (Release without asserts)
set(Console_Defines "$<$<CONFIG:DEBUG>:_DEBUG>" "$<$<CONFIG:RELEASE>:NDEBUG>")
# Build as Unicode (see UTF-8 Everywhere article's Win32 recommendations)
set(Console_Defines ${Console_Defines} _UNICODE UNICODE)

Просмотреть файл

@ -5,7 +5,7 @@
# Use of Direct3D is not supported, and the resulting EXE is not supported for retail.
#
cmake_minimum_required (VERSION 3.13)
cmake_minimum_required (VERSION 3.20)
project(CMakeXboxConsoleApp
DESCRIPTION "CMake example for a Microsoft GDK 'console' project"
@ -37,23 +37,14 @@ add_executable(${PROJECT_NAME} Main.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC ${Console_SdkIncludeRoot})
target_link_directories(${PROJECT_NAME} PUBLIC ${VC_OneCore_LibPath} PUBLIC ${Console_SdkLibPath})
# Use Warning Level 4
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# If not using typeid or dynamic_cast, we can disable RTTI to save binary size
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# Visual C++ console projects set this symbol
target_compile_definitions(${PROJECT_NAME} PRIVATE _CONSOLE)
# See the CMakeExample for more information
target_compile_definitions(${PROJECT_NAME} PRIVATE ${Console_Defines})
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /GS /Gy ${Console_ArchOptions})
# If not using typeid or dynamic_cast, we can disable RTTI to save binary size
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /W4 /GR- /GS /Gy ${Console_ArchOptions})
target_link_libraries(${PROJECT_NAME} PRIVATE ${Console_Libs})
# optional extension libraries: Xbox::XSAPI Xbox::XCurl Xbox::GameChat2 Xbox::PlayFabMultiplayer Xbox::PlayFabParty Xbox::PlayFabPartyLIVE

Просмотреть файл

@ -3,10 +3,11 @@
#
# This is a development only tool. It is not supported for use on retail kits.
cmake_minimum_required (VERSION 3.15)
cmake_minimum_required (VERSION 3.20)
project(xbcompress
DESCRIPTION "Microsoft SZDD/KWAJ-style compression tool for Windows & Xbox"
HOMEPAGE_URL "https://github.com/microsoft/DirectXTK12/wiki/Compressing-assets"
LANGUAGES CXX)
if(NOT WIN32)
@ -30,19 +31,9 @@ set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_executable(${PROJECT_NAME} compresstool.cpp)
# Use Warning Level 4
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/W3 " "/W4 " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
# Disable RTTI
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/GR " "/GR- " CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
target_compile_definitions(${PROJECT_NAME} PRIVATE _CONSOLE _UNICODE UNICODE _WIN32_WINNT=0x0A00)
target_compile_options(${PROJECT_NAME} PRIVATE /fp:fast /GS /Gy)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /GR- /fp:fast /GS /Gy)
# Don't link with kernel32.lib, etc.
set(CMAKE_CXX_STANDARD_LIBRARIES "")

Просмотреть файл

@ -343,15 +343,20 @@ namespace
PrintLogo();
wprintf(L"Usage: %ls%ls <options> <files>\n", fname, ext);
wprintf(L"\n");
wprintf(L" -r wildcard filename search is recursive\n");
wprintf(L" -u uncompress files rather than compress\n");
wprintf(L" -z compress with MSZIP rather than LZMS\n");
wprintf(L" -l force output filename to lower case\n");
wprintf(L" -y overwrite existing output file (if any)\n");
wprintf(L" -nologo suppress copyright message\n");
wprintf(L" -timing Display elapsed processing time\n");
wprintf(L" -flist <filename> use text file with a list of input files (one per line)\n\n");
static const wchar_t* const s_usage =
L"\n"
L" -r wildcard filename search is recursive\n"
L" -u uncompress files rather than compress\n"
L" -z compress with MSZIP rather than LZMS\n"
L" -l force output filename to lower case\n"
L" -y overwrite existing output file (if any)\n"
L" -nologo suppress copyright message\n"
L" -timing Display elapsed processing time\n"
L" -flist <filename> use text file with a list of input files (one per line)\n"
"\n";
wprintf(L"%ls", s_usage);
}
const wchar_t* GetErrorDesc(HRESULT hr)
@ -696,7 +701,7 @@ namespace
auto_delete_file delonfail(hFile.get());
DWORD bytesWritten;
if (!WriteFile(hFile.get(), expandedData.get(), fileSize, &bytesWritten, nullptr))
if (!WriteFile(hFile.get(), expandedData.get(), static_cast<DWORD>(fileSize), &bytesWritten, nullptr))
return HRESULT_FROM_WIN32(GetLastError());
if (bytesWritten != fileSize)