Skip to content

Commit 9d57567

Browse files
committed
Chat screenshots
1 parent 2cee9b4 commit 9d57567

10 files changed

Lines changed: 712 additions & 42 deletions

CMakePresets.json

Lines changed: 39 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builds/cmake/VSWhere.cmake

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
#----------------------------------------------------------------------------------------------------------------------
2+
# MIT License
3+
#
4+
# Copyright (c) 2021 Mark Schofield
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
#----------------------------------------------------------------------------------------------------------------------
24+
include_guard()
25+
26+
#[[====================================================================================================================
27+
toolchain_validate_vs_files
28+
---------------------------
29+
30+
Note: Not supported for consumption outside of the toolchain files.
31+
32+
Validates the the specified folder exists and contains the specified files.
33+
34+
toolchain_validate_vs_files(
35+
<DESCRIPTION <description>>
36+
<FOLDER <folder>>
37+
<FILES <file>...>
38+
)
39+
40+
If the folder or files are missing, then a FATAL_ERROR is reported.
41+
====================================================================================================================]]#
42+
function(toolchain_validate_vs_files)
43+
set(OPTIONS)
44+
set(ONE_VALUE_KEYWORDS FOLDER DESCRIPTION)
45+
set(MULTI_VALUE_KEYWORDS FILES)
46+
47+
cmake_parse_arguments(PARSE_ARGV 0 VS "${OPTIONS}" "${ONE_VALUE_KEYWORDS}" "${MULTI_VALUE_KEYWORDS}")
48+
49+
if(NOT EXISTS ${VS_FOLDER})
50+
message(FATAL_ERROR "Folder not present - ${VS_FOLDER} - ensure that the ${VS_DESCRIPTION} are installed with Visual Studio.")
51+
endif()
52+
53+
foreach(FILE ${VS_FILES})
54+
if(NOT EXISTS "${VS_FOLDER}/${FILE}")
55+
message(FATAL_ERROR "File not present - ${VS_FOLDER}/${FILE} - ensure that the ${VS_DESCRIPTION} are installed with Visual Studio.")
56+
endif()
57+
endforeach()
58+
endfunction()
59+
60+
#[[====================================================================================================================
61+
findVisualStudio
62+
----------------
63+
64+
Finds a Visual Studio instance, and sets CMake variables based on properties of the found instance.
65+
66+
findVisualStudio(
67+
[VERSION <version range>]
68+
[PRERELEASE <ON|OFF>]
69+
[PRODUCTS <products>]
70+
[REQUIRES <vs component>...]
71+
PROPERTIES
72+
<<vswhere property> <cmake variable>>
73+
)
74+
====================================================================================================================]]#
75+
function(findVisualStudio)
76+
set(OPTIONS)
77+
set(ONE_VALUE_KEYWORDS VERSION PRERELEASE PRODUCTS)
78+
set(MULTI_VALUE_KEYWORDS REQUIRES PROPERTIES)
79+
80+
cmake_parse_arguments(PARSE_ARGV 0 FIND_VS "${OPTIONS}" "${ONE_VALUE_KEYWORDS}" "${MULTI_VALUE_KEYWORDS}")
81+
82+
find_program(VSWHERE_PATH
83+
NAMES vswhere vswhere.exe
84+
HINTS "$ENV{ProgramFiles\(x86\)}/Microsoft Visual Studio/Installer"
85+
)
86+
87+
if(VSWHERE_PATH STREQUAL "VSWHERE_PATH-NOTFOUND")
88+
message(FATAL_ERROR "'vswhere' isn't found.")
89+
endif()
90+
91+
set(VSWHERE_COMMAND ${VSWHERE_PATH} -latest)
92+
93+
if(FIND_VS_PRERELEASE)
94+
list(APPEND VSWHERE_COMMAND -prerelease)
95+
endif()
96+
97+
if(FIND_VS_PRODUCTS)
98+
list(APPEND VSWHERE_COMMAND -products ${FIND_VS_PRODUCTS})
99+
endif()
100+
101+
if(FIND_VS_REQUIRES)
102+
list(APPEND VSWHERE_COMMAND -requires ${FIND_VS_REQUIRES})
103+
endif()
104+
105+
if(FIND_VS_VERSION)
106+
list(APPEND VSWHERE_COMMAND -version "${FIND_VS_VERSION}")
107+
endif()
108+
109+
message(VERBOSE "findVisualStudio: VSWHERE_COMMAND = ${VSWHERE_COMMAND}")
110+
111+
execute_process(
112+
COMMAND ${VSWHERE_COMMAND}
113+
OUTPUT_VARIABLE VSWHERE_OUTPUT
114+
)
115+
116+
message(VERBOSE "findVisualStudio: VSWHERE_OUTPUT = ${VSWHERE_OUTPUT}")
117+
118+
# Matches `VSWHERE_PROPERTY` in the `VSWHERE_OUTPUT` text in the format written by vswhere.
119+
# The matched value is assigned to the variable `VARIABLE_NAME` in the parent scope.
120+
function(getVSWhereProperty VSWHERE_OUTPUT VSWHERE_PROPERTY VARIABLE_NAME)
121+
string(REGEX MATCH "${VSWHERE_PROPERTY}: [^\r\n]*" VSWHERE_VALUE "${VSWHERE_OUTPUT}")
122+
string(REPLACE "${VSWHERE_PROPERTY}: " "" VSWHERE_VALUE "${VSWHERE_VALUE}")
123+
set(${VARIABLE_NAME} "${VSWHERE_VALUE}" PARENT_SCOPE)
124+
endfunction()
125+
126+
while(FIND_VS_PROPERTIES)
127+
list(POP_FRONT FIND_VS_PROPERTIES VSWHERE_PROPERTY)
128+
list(POP_FRONT FIND_VS_PROPERTIES VSWHERE_CMAKE_VARIABLE)
129+
getVSWhereProperty("${VSWHERE_OUTPUT}" ${VSWHERE_PROPERTY} VSWHERE_VALUE)
130+
set(${VSWHERE_CMAKE_VARIABLE} ${VSWHERE_VALUE} PARENT_SCOPE)
131+
endwhile()
132+
endfunction()

builds/cmake/Windows.Kits.cmake

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
#----------------------------------------------------------------------------------------------------------------------
2+
# MIT License
3+
#
4+
# Copyright (c) 2021 Mark Schofield
5+
#
6+
# Permission is hereby granted, free of charge, to any person obtaining a copy
7+
# of this software and associated documentation files (the "Software"), to deal
8+
# in the Software without restriction, including without limitation the rights
9+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
# copies of the Software, and to permit persons to whom the Software is
11+
# furnished to do so, subject to the following conditions:
12+
#
13+
# The above copyright notice and this permission notice shall be included in all
14+
# copies or substantial portions of the Software.
15+
#
16+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22+
# SOFTWARE.
23+
#----------------------------------------------------------------------------------------------------------------------
24+
#
25+
# | CMake Variable | Description |
26+
# |-----------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
27+
# | CMAKE_SYSTEM_VERSION | The version of the operating system for which CMake is to build. Defaults to the host version. |
28+
# | CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE | The architecture of the tooling to use. Defaults to 'arm64' on ARM64 systems, otherwise 'x64'. |
29+
# | CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION | The version of the Windows SDK to use. Defaults to the highest installed, that is no higher than CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM |
30+
# | CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM | The maximum version of the Windows SDK to use, for example '10.0.19041.0'. Defaults to nothing |
31+
# | CMAKE_WINDOWS_KITS_10_DIR | The location of the root of the Windows Kits 10 directory. |
32+
#
33+
# The following variables will be set:
34+
#
35+
# | CMake Variable | Description |
36+
# |---------------------------------------------|-------------------------------------------------------------------------------------------------------|
37+
# | CMAKE_MT | The path to the 'mt' tool. |
38+
# | CMAKE_RC_COMPILER | The path to the 'rc' tool. |
39+
# | CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION | The version of the Windows SDK to be used. |
40+
# | MDMERGE_TOOL | The path to the 'mdmerge' tool. |
41+
# | MIDL_COMPILER | The path to the 'midl' compiler. |
42+
# | WINDOWS_KITS_BIN_PATH | The path to the folder containing the Windows Kits binaries. |
43+
# | WINDOWS_KITS_INCLUDE_PATH | The path to the folder containing the Windows Kits include files. |
44+
# | WINDOWS_KITS_LIB_PATH | The path to the folder containing the Windows Kits library files. |
45+
# | WINDOWS_KITS_REFERENCES_PATH | The path to the folder containing the Windows Kits references. |
46+
#
47+
include_guard()
48+
49+
if(NOT CMAKE_SYSTEM_VERSION)
50+
set(CMAKE_SYSTEM_VERSION ${CMAKE_HOST_SYSTEM_VERSION})
51+
endif()
52+
53+
if(NOT CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE)
54+
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL ARM64)
55+
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE arm64)
56+
else()
57+
set(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE x64)
58+
endif()
59+
endif()
60+
61+
if(NOT CMAKE_WINDOWS_KITS_10_DIR)
62+
get_filename_component(CMAKE_WINDOWS_KITS_10_DIR "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;InstallationFolder]" ABSOLUTE CACHE)
63+
if ("${CMAKE_WINDOWS_KITS_10_DIR}" STREQUAL "/registry")
64+
unset(CMAKE_WINDOWS_KITS_10_DIR)
65+
endif()
66+
endif()
67+
68+
if(NOT CMAKE_WINDOWS_KITS_10_DIR)
69+
message(FATAL_ERROR "Unable to find an installed Windows SDK, and one wasn't specified.")
70+
endif()
71+
72+
# If a CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION wasn't specified, find the highest installed version that is no higher
73+
# than the host version
74+
if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
75+
file(GLOB WINDOWS_KITS_VERSIONS RELATIVE "${CMAKE_WINDOWS_KITS_10_DIR}/lib" "${CMAKE_WINDOWS_KITS_10_DIR}/lib/*")
76+
list(FILTER WINDOWS_KITS_VERSIONS INCLUDE REGEX "10\\.0\\.")
77+
list(SORT WINDOWS_KITS_VERSIONS COMPARE NATURAL ORDER DESCENDING)
78+
while(WINDOWS_KITS_VERSIONS)
79+
list(POP_FRONT WINDOWS_KITS_VERSIONS CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
80+
if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM)
81+
message(VERBOSE "Windows.Kits: Defaulting version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
82+
break()
83+
endif()
84+
85+
if(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION VERSION_LESS_EQUAL CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION_MAXIMUM)
86+
message(VERBOSE "Windows.Kits: Choosing version: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
87+
break()
88+
endif()
89+
90+
message(VERBOSE "Windows.Kits: Not suitable: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
91+
set(CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
92+
endwhile()
93+
endif()
94+
95+
if(NOT CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION)
96+
message(FATAL_ERROR "A Windows SDK could not be found.")
97+
endif()
98+
99+
set(WINDOWS_KITS_BIN_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "" FORCE)
100+
set(WINDOWS_KITS_INCLUDE_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/include/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "" FORCE)
101+
set(WINDOWS_KITS_LIB_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/lib/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}" CACHE PATH "" FORCE)
102+
set(WINDOWS_KITS_REFERENCES_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/References" CACHE PATH "" FORCE)
103+
set(WINDOWS_KITS_PLATFORM_PATH "${CMAKE_WINDOWS_KITS_10_DIR}/Platforms/UAP/${CMAKE_SYSTEM_VERSION}/Platform.xml" CACHE PATH "" FORCE)
104+
105+
if(NOT EXISTS ${WINDOWS_KITS_BIN_PATH})
106+
message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} cannot be found: Folder '${WINDOWS_KITS_BIN_PATH}' does not exist.")
107+
endif()
108+
109+
if(NOT EXISTS ${WINDOWS_KITS_INCLUDE_PATH})
110+
message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} cannot be found: Folder '${WINDOWS_KITS_INCLUDE_PATH}' does not exist.")
111+
endif()
112+
113+
if(NOT EXISTS ${WINDOWS_KITS_LIB_PATH})
114+
message(FATAL_ERROR "Windows SDK ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION} cannot be found: Folder '${WINDOWS_KITS_LIB_PATH}' does not exist.")
115+
endif()
116+
117+
set(CMAKE_MT "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/mt.exe")
118+
set(CMAKE_RC_COMPILER_INIT "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/rc.exe")
119+
set(CMAKE_RC_FLAGS_INIT "/nologo")
120+
121+
set(MIDL_COMPILER "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/midl.exe")
122+
set(MDMERGE_TOOL "${WINDOWS_KITS_BIN_PATH}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}/mdmerge.exe")
123+
124+
# Windows SDK
125+
if(CMAKE_SYSTEM_PROCESSOR STREQUAL AMD64)
126+
set(WINDOWS_KITS_TARGET_ARCHITECTURE x64)
127+
elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL ARM)
128+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL ARM64)
129+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL X86))
130+
set(WINDOWS_KITS_TARGET_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
131+
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL x64)
132+
message(WARNING "CMAKE_SYSTEM_PROCESSOR should be 'AMD64', not 'x64'. WindowsToolchain will stop recognizing 'x64' in a future release.")
133+
set(WINDOWS_KITS_TARGET_ARCHITECTURE x64)
134+
elseif((CMAKE_SYSTEM_PROCESSOR STREQUAL arm)
135+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL arm64)
136+
OR (CMAKE_SYSTEM_PROCESSOR STREQUAL x86))
137+
message(WARNING "CMAKE_SYSTEM_PROCESSOR (${CMAKE_SYSTEM_PROCESSOR}) should be upper-case. WindowsToolchain will stop recognizing non-upper-case forms in a future release.")
138+
set(WINDOWS_KITS_TARGET_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
139+
else()
140+
message(FATAL_ERROR "Unable identify Windows Kits architecture for CMAKE_SYSTEM_PROCESSOR ${CMAKE_SYSTEM_PROCESSOR}")
141+
endif()
142+
143+
foreach(LANG C CXX RC ASM_MASM)
144+
list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/ucrt")
145+
list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/shared")
146+
list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/um")
147+
list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/winrt")
148+
list(APPEND CMAKE_${LANG}_STANDARD_INCLUDE_DIRECTORIES "${WINDOWS_KITS_INCLUDE_PATH}/cppwinrt")
149+
endforeach()
150+
151+
link_directories("${WINDOWS_KITS_LIB_PATH}/ucrt/${WINDOWS_KITS_TARGET_ARCHITECTURE}")
152+
link_directories("${WINDOWS_KITS_LIB_PATH}/um/${WINDOWS_KITS_TARGET_ARCHITECTURE}")
153+
link_directories("${WINDOWS_KITS_REFERENCES_PATH}/${WINDOWS_KITS_TARGET_ARCHITECTURE}")

0 commit comments

Comments
 (0)