mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-07 14:20:06 -06:00
Since commit v3.11.0-rc1~467^2 (VS,Xcode: Add CMakeLists.txt sources without mutating targets, 2017-10-18) we do not add `CMakeLists.txt` to target sources but instead generate references to them directly. This broke projects that explicitly specify their `CMakeLists.txt` file as a source file because the explicit entry is no longer consolidated with the generated one. Teach the relevant generators to avoid duplicating `CMakeLists.txt` source references and add test cases. Fixes: #17828
26 lines
808 B
CMake
26 lines
808 B
CMake
set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj")
|
|
if(NOT EXISTS "${vcProjectFile}")
|
|
set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.")
|
|
return()
|
|
endif()
|
|
|
|
set(foundCMakeLists 0)
|
|
file(STRINGS "${vcProjectFile}" lines)
|
|
foreach(line IN LISTS lines)
|
|
if(line MATCHES "<([A-Za-z0-9_]+) +Include=.*CMakeLists.txt")
|
|
set(rule "${CMAKE_MATCH_1}")
|
|
if(NOT rule STREQUAL "CustomBuild")
|
|
set(RunCMake_TEST_FAILED "CMakeLists.txt referenced as ${rule} instead of CustomBuild")
|
|
return()
|
|
endif()
|
|
if(foundCMakeLists)
|
|
set(RunCMake_TEST_FAILED "CMakeLists.txt referenced multiple times")
|
|
return()
|
|
endif()
|
|
set(foundCMakeLists 1)
|
|
endif()
|
|
endforeach()
|
|
if(NOT foundCMakeLists)
|
|
set(RunCMake_TEST_FAILED "CMakeLists.txt not referenced")
|
|
endif()
|