mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 16:32:14 -06:00
Makefiles: Re-run CMake if file configured in subdirectory is missing
Add files configured by all subdirectories to `CMAKE_MAKEFILE_PRODUCTS` rather than just those from the top level. Fixes: #19719
This commit is contained in:
@@ -343,19 +343,18 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
|
||||
const std::string& binDir = lg.GetBinaryDirectory();
|
||||
|
||||
// CMake must rerun if a byproduct is missing.
|
||||
{
|
||||
cmakefileStream << "# Byproducts of CMake generate step:\n"
|
||||
<< "set(CMAKE_MAKEFILE_PRODUCTS\n";
|
||||
for (std::string const& outfile : lg.GetMakefile()->GetOutputFiles()) {
|
||||
cmakefileStream << "# Byproducts of CMake generate step:\n"
|
||||
<< "set(CMAKE_MAKEFILE_PRODUCTS\n";
|
||||
|
||||
// add in any byproducts and all the directory information files
|
||||
std::string tmpStr;
|
||||
for (const auto& localGen : this->LocalGenerators) {
|
||||
for (std::string const& outfile :
|
||||
localGen->GetMakefile()->GetOutputFiles()) {
|
||||
cmakefileStream << " \""
|
||||
<< lg.MaybeConvertToRelativePath(binDir, outfile)
|
||||
<< "\"\n";
|
||||
}
|
||||
}
|
||||
|
||||
// add in all the directory information files
|
||||
std::string tmpStr;
|
||||
for (const auto& localGen : this->LocalGenerators) {
|
||||
tmpStr = cmStrCat(localGen->GetCurrentBinaryDirectory(),
|
||||
"/CMakeFiles/CMakeDirectoryInformation.cmake");
|
||||
cmakefileStream << " \""
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
message("Running CMake on RerunCMake") # write to stderr if cmake reruns
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ConfigureFileInput.txt.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ConfigureFileOutput.txt"
|
||||
@ONLY
|
||||
)
|
||||
add_subdirectory(RerunCMake)
|
||||
# make sure CMakeCache.txt is newer than ConfigureFileOutput.txt
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
|
||||
|
||||
5
Tests/RunCMake/configure_file/RerunCMake/CMakeLists.txt
Normal file
5
Tests/RunCMake/configure_file/RerunCMake/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ConfigureFileInput.txt.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/ConfigureFileOutput.txt"
|
||||
@ONLY
|
||||
)
|
||||
@@ -22,7 +22,7 @@ if(RunCMake_GENERATOR MATCHES "Make")
|
||||
set(RunCMake_TEST_NO_CLEAN 1)
|
||||
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
|
||||
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
|
||||
set(in_conf "${RunCMake_TEST_BINARY_DIR}/ConfigureFileInput.txt.in")
|
||||
set(in_conf "${RunCMake_TEST_BINARY_DIR}/RerunCMake/ConfigureFileInput.txt.in")
|
||||
file(WRITE "${in_conf}" "1")
|
||||
|
||||
message(STATUS "RerunCMake: first configuration...")
|
||||
@@ -42,7 +42,7 @@ if(RunCMake_GENERATOR MATCHES "Make")
|
||||
run_cmake_command(RerunCMake-nowork ${CMAKE_COMMAND} --build .)
|
||||
|
||||
message(STATUS "RerunCMake: remove configure_file output...")
|
||||
file(REMOVE "${RunCMake_TEST_BINARY_DIR}/ConfigureFileOutput.txt")
|
||||
file(REMOVE "${RunCMake_TEST_BINARY_DIR}/RerunCMake/ConfigureFileOutput.txt")
|
||||
run_cmake_command(RerunCMake-rerun ${CMAKE_COMMAND} --build .)
|
||||
run_cmake_command(RerunCMake-nowork ${CMAKE_COMMAND} --build .)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user