Xcode: ReRunCMake even if files disappeared (#15992)
This commit is contained in:
parent
b19bc31277
commit
111cd67919
|
@ -593,19 +593,28 @@ void cmGlobalXCodeGenerator::CreateReRunCMakeFile(
|
|||
cmGeneratedFileStream makefileStream
|
||||
(this->CurrentReRunCMakeMakefile.c_str());
|
||||
makefileStream.SetCopyIfDifferent(true);
|
||||
makefileStream << "# Generated by CMake, DO NOT EDIT\n";
|
||||
makefileStream << "# Generated by CMake, DO NOT EDIT\n\n";
|
||||
|
||||
makefileStream << "empty:= \n";
|
||||
makefileStream << "space:= $(empty) $(empty)\n";
|
||||
makefileStream << "spaceplus:= $(empty)\\ $(empty)\n\n";
|
||||
|
||||
for(std::vector<std::string>::const_iterator i = lfiles.begin();
|
||||
i != lfiles.end(); ++i)
|
||||
{
|
||||
makefileStream << "TARGETS += $(subst $(space),$(spaceplus),$(wildcard "
|
||||
<< this->ConvertToRelativeForMake(i->c_str())
|
||||
<< "))\n";
|
||||
}
|
||||
|
||||
std::string checkCache = root->GetBinaryDirectory();
|
||||
checkCache += "/";
|
||||
checkCache += cmake::GetCMakeFilesDirectoryPostSlash();
|
||||
checkCache += "cmake.check_cache";
|
||||
makefileStream << this->ConvertToRelativeForMake(checkCache.c_str())
|
||||
<< ": ";
|
||||
for(std::vector<std::string>::const_iterator i = lfiles.begin();
|
||||
i != lfiles.end(); ++i)
|
||||
{
|
||||
makefileStream << "\\\n" << this->ConvertToRelativeForMake(i->c_str());
|
||||
}
|
||||
makefileStream << "\n\t" <<
|
||||
|
||||
makefileStream << "\n" << this->ConvertToRelativeForMake(checkCache.c_str())
|
||||
<< ": $(TARGETS)\n";
|
||||
makefileStream << "\t" <<
|
||||
this->ConvertToRelativeForMake(cmSystemTools::GetCMakeCommand().c_str())
|
||||
<< " -H" << this->ConvertToRelativeForMake(
|
||||
root->GetSourceDirectory())
|
||||
|
|
|
@ -40,3 +40,42 @@ if(NOT RunCMake_GENERATOR MATCHES "Visual Studio [67]|Xcode")
|
|||
endif()
|
||||
|
||||
run_BuildDepends(Custom-Always)
|
||||
|
||||
function(run_ReGeneration)
|
||||
# test re-generation of project even if CMakeLists.txt files disappeared
|
||||
|
||||
# Use a single build tree for a few tests without cleaning.
|
||||
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/regenerate-project-build)
|
||||
set(RunCMake_TEST_SOURCE_DIR ${RunCMake_BINARY_DIR}/regenerate-project-source)
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
|
||||
set(ProjectHeader [=[
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(Regenerate-Project NONE)
|
||||
]=])
|
||||
|
||||
# create project with subdirectory
|
||||
file(WRITE "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" "${ProjectHeader}"
|
||||
"add_subdirectory(mysubdir)")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}/mysubdir")
|
||||
file(WRITE "${RunCMake_TEST_SOURCE_DIR}/mysubdir/CMakeLists.txt" "# empty")
|
||||
|
||||
run_cmake(Regenerate-Project)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay})
|
||||
|
||||
# now we delete the subdirectory and adjust the CMakeLists.txt
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}/mysubdir")
|
||||
file(WRITE "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" "${ProjectHeader}")
|
||||
|
||||
run_cmake_command(Regenerate-Project-Directory-Removed
|
||||
${CMAKE_COMMAND} --build "${RunCMake_TEST_BINARY_DIR}")
|
||||
|
||||
unset(RunCMake_TEST_BINARY_DIR)
|
||||
unset(RunCMake_TEST_SOURCE_DIR)
|
||||
unset(RunCMake_TEST_NO_CLEAN)
|
||||
endfunction()
|
||||
|
||||
if(RunCMake_GENERATOR STREQUAL "Xcode")
|
||||
run_ReGeneration(regenerate-project)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue