summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-13 12:49:37 (GMT)
committerBrad King <brad.king@kitware.com>2018-04-13 13:41:06 (GMT)
commit8480c2afc09d3e976e4eff69081f41d812fb35cb (patch)
treefbf745cf6dfa05a24fe707a8644ca589ce2c2a42 /Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
parent61fd4c742013a7f9139db190f936703b656540ff (diff)
downloadCMake-8480c2afc09d3e976e4eff69081f41d812fb35cb.zip
CMake-8480c2afc09d3e976e4eff69081f41d812fb35cb.tar.gz
CMake-8480c2afc09d3e976e4eff69081f41d812fb35cb.tar.bz2
Restore support for explicitly referenced CMakeLists.txt sources
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
Diffstat (limited to 'Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake')
-rw-r--r--Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake20
1 files changed, 20 insertions, 0 deletions
diff --git a/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
new file mode 100644
index 0000000..3073e0b
--- /dev/null
+++ b/Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
@@ -0,0 +1,20 @@
+set(xcProjectFile "${RunCMake_TEST_BINARY_DIR}/ExplicitCMakeLists.xcodeproj/project.pbxproj")
+if(NOT EXISTS "${xcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${xcProjectFile} does not exist.")
+ return()
+endif()
+
+set(foundCMakeLists 0)
+file(STRINGS "${xcProjectFile}" lines)
+foreach(line IN LISTS lines)
+ if(line MATCHES "PBXBuildFile.*fileRef.*CMakeLists.txt")
+ 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()