CMake/Tests/RunCMake/GeneratorInstance/DefaultInstance.cmake
Brad King 5ce0f03cce VS: Add a variable to report the Visual Studio version build number
VS 2017 and above come with a Visual Studio Installer tool that tracks
four-component Visual Studio version numbers.  We already detect the VS
version number because it is needed to make some generation decisions.
Provide the number to projects in a `CMAKE_VS_VERSION_BUILD_NUMBER`
variable so they can use it similarly.

Fixes: #24230
2022-12-07 17:49:04 -05:00

17 lines
680 B
CMake

if("x${CMAKE_GENERATOR_INSTANCE}" STREQUAL "x")
message(FATAL_ERROR "CMAKE_GENERATOR_INSTANCE is empty but should have a value.")
elseif("x${CMAKE_GENERATOR_INSTANCE}" MATCHES [[\\]])
message(FATAL_ERROR
"CMAKE_GENERATOR_INSTANCE is\n"
" ${CMAKE_GENERATOR_INSTANCE}\n"
"which contains a backslash.")
elseif(NOT IS_DIRECTORY "${CMAKE_GENERATOR_INSTANCE}")
message(FATAL_ERROR
"CMAKE_GENERATOR_INSTANCE is\n"
" ${CMAKE_GENERATOR_INSTANCE}\n"
"which is not an existing directory.")
endif()
file(WRITE "${CMAKE_BINARY_DIR}/instance.txt" "${CMAKE_GENERATOR_INSTANCE}")
message(STATUS "CMAKE_VS_VERSION_BUILD_NUMBER='${CMAKE_VS_VERSION_BUILD_NUMBER}'")