mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 05:40:54 -06:00
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
This commit is contained in:
20
Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
Normal file
20
Tests/RunCMake/XcodeProject/ExplicitCMakeLists-check.cmake
Normal file
@@ -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()
|
||||
2
Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake
Normal file
2
Tests/RunCMake/XcodeProject/ExplicitCMakeLists.cmake
Normal file
@@ -0,0 +1,2 @@
|
||||
enable_language(CXX)
|
||||
add_executable(foo foo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
|
||||
@@ -4,6 +4,8 @@ if(XCODE_VERSION VERSION_GREATER_EQUAL 9)
|
||||
set(IOS_DEPLOYMENT_TARGET "-DCMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET=10")
|
||||
endif()
|
||||
|
||||
run_cmake(ExplicitCMakeLists)
|
||||
|
||||
run_cmake(XcodeFileType)
|
||||
run_cmake(XcodeAttributeLocation)
|
||||
run_cmake(XcodeAttributeGenex)
|
||||
|
||||
Reference in New Issue
Block a user