mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-09 23:30:35 -06:00
This matches the behavior of NMake, Ninja and older Visual Studio generators. Fixes: #13130
29 lines
1006 B
CMake
29 lines
1006 B
CMake
macro(ensure_link_version projectFile expected)
|
|
if(NOT EXISTS "${projectFile}")
|
|
set(RunCMake_TEST_FAILED "Project file ${projectFile} does not exist.")
|
|
return()
|
|
endif()
|
|
|
|
file(STRINGS "${projectFile}" lines)
|
|
set(version "")
|
|
foreach(line IN LISTS lines)
|
|
if(line MATCHES "<Link>")
|
|
set(in_link TRUE)
|
|
elseif(line MATCHES "</Link>")
|
|
if(NOT version STREQUAL "${expected}")
|
|
set(RunCMake_TEST_FAILED "<Version> not found or incorrect: ${version} vs ${expected}")
|
|
return()
|
|
endif()
|
|
set(in_link FALSE)
|
|
set(version "")
|
|
elseif(in_link AND line MATCHES "<Version>([^<]+)</Version>")
|
|
set(version ${CMAKE_MATCH_1})
|
|
endif()
|
|
endforeach()
|
|
endmacro()
|
|
|
|
ensure_link_version("${RunCMake_TEST_BINARY_DIR}/app-C.vcxproj" 0.1)
|
|
ensure_link_version("${RunCMake_TEST_BINARY_DIR}/app-CXX.vcxproj" 1.0)
|
|
ensure_link_version("${RunCMake_TEST_BINARY_DIR}/lib-C.vcxproj" 65535.65535)
|
|
ensure_link_version("${RunCMake_TEST_BINARY_DIR}/lib-CXX.vcxproj" "")
|