From 4deb9c41b88d53247c7929de660e0cafe8d8d25c Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Tue, 16 Jan 2024 15:53:26 +0100 Subject: cmQtAutoGenInitializer: Improve Const-correctness --- Source/cmQtAutoGenInitializer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 50b0ebe..cccc606 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -70,7 +70,7 @@ unsigned int GetParallelCPUCount() return count; } -std::string FileProjectRelativePath(cmMakefile* makefile, +std::string FileProjectRelativePath(cmMakefile const* makefile, std::string const& fileName) { std::string res; -- cgit v0.12 From d0bedb217046e4fb79bff2c24b581d97451d0fd4 Mon Sep 17 00:00:00 2001 From: Orkun Tokdemir Date: Fri, 26 Jan 2024 12:17:14 +0100 Subject: Autogen: Forward dependencies when both Makefile and DEPFILE are used Since commit ebc9e448b3 (Autogen: Add depfile support for Makefiles, 2023-09-07, v3.28.0-rc1~101^2~1) CMake does not generate the correct dependency graph when both `Makefile` and `DEPFILE` are used. The build of `_autogen_timestamp_deps` fails due to missing dependencies. To tackle that problem, forward target dependencies to both `_autogen_timestamp_deps` and `_autogen` instead of just `_autogen`. Fixes: #25600 --- Source/cmQtAutoGenInitializer.cxx | 11 ++++++++++- Tests/QtAutogen/AutogenTimestampDeps/CMakeLists.txt | 11 +++++++++++ Tests/QtAutogen/AutogenTimestampDeps/ProjectInfo.hpp.in | 6 ++++++ .../AutogenTimestampDeps/cmake/UpdateProjectInfo.cmake | 2 ++ Tests/QtAutogen/AutogenTimestampDeps/src/CMakeLists.txt | 4 ++++ Tests/QtAutogen/AutogenTimestampDeps/src/main.cpp | 5 +++++ Tests/QtAutogen/Tests.cmake | 1 + 7 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 Tests/QtAutogen/AutogenTimestampDeps/CMakeLists.txt create mode 100644 Tests/QtAutogen/AutogenTimestampDeps/ProjectInfo.hpp.in create mode 100644 Tests/QtAutogen/AutogenTimestampDeps/cmake/UpdateProjectInfo.cmake create mode 100644 Tests/QtAutogen/AutogenTimestampDeps/src/CMakeLists.txt create mode 100644 Tests/QtAutogen/AutogenTimestampDeps/src/main.cpp diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index cccc606..66544d0 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1369,7 +1369,6 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() std::vector dependencies( this->AutogenTarget.DependFiles.begin(), this->AutogenTarget.DependFiles.end()); - if (useDepfile) { // Create a custom command that generates a timestamp file and // has a depfile assigned. The depfile is created by JobDepFilesMergeT. @@ -1408,6 +1407,16 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() cc->SetEscapeOldStyle(false); cmTarget* timestampTarget = this->LocalGen->AddUtilityCommand( timestampTargetName, true, std::move(cc)); + auto const isMake = + this->GlobalGen->GetName().find("Make") != std::string::npos; + if (this->AutogenTarget.DependOrigin && isMake) { + for (BT> const& depName : + this->GenTarget->GetUtilities()) { + timestampTarget->AddUtility(depName.Value.first, false, + this->Makefile); + } + } + this->LocalGen->AddGeneratorTarget( cm::make_unique(timestampTarget, this->LocalGen)); diff --git a/Tests/QtAutogen/AutogenTimestampDeps/CMakeLists.txt b/Tests/QtAutogen/AutogenTimestampDeps/CMakeLists.txt new file mode 100644 index 0000000..3470a02 --- /dev/null +++ b/Tests/QtAutogen/AutogenTimestampDeps/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.28) +project(AutogenTimestampDeps) +include("../AutogenCoreTest.cmake") + +set(CMAKE_AUTOMOC ON) + +add_custom_target(ProjectInfo + COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/UpdateProjectInfo.cmake + BYPRODUCTS ${CMAKE_BINARY_DIR}/ProjectInfo.hpp) + +add_subdirectory(src) diff --git a/Tests/QtAutogen/AutogenTimestampDeps/ProjectInfo.hpp.in b/Tests/QtAutogen/AutogenTimestampDeps/ProjectInfo.hpp.in new file mode 100644 index 0000000..abaa66c --- /dev/null +++ b/Tests/QtAutogen/AutogenTimestampDeps/ProjectInfo.hpp.in @@ -0,0 +1,6 @@ +#ifndef PROJECTINFO_HPP +#define PROJECTINFO_HPP + +extern int VersionMajor; + +#endif // PROJECTINFO_HPP diff --git a/Tests/QtAutogen/AutogenTimestampDeps/cmake/UpdateProjectInfo.cmake b/Tests/QtAutogen/AutogenTimestampDeps/cmake/UpdateProjectInfo.cmake new file mode 100644 index 0000000..8dd8d55 --- /dev/null +++ b/Tests/QtAutogen/AutogenTimestampDeps/cmake/UpdateProjectInfo.cmake @@ -0,0 +1,2 @@ + +configure_file(${CMAKE_CURRENT_LIST_DIR}/../ProjectInfo.hpp.in ${CMAKE_BINARY_DIR}/ProjectInfo.hpp @ONLY) diff --git a/Tests/QtAutogen/AutogenTimestampDeps/src/CMakeLists.txt b/Tests/QtAutogen/AutogenTimestampDeps/src/CMakeLists.txt new file mode 100644 index 0000000..e931248 --- /dev/null +++ b/Tests/QtAutogen/AutogenTimestampDeps/src/CMakeLists.txt @@ -0,0 +1,4 @@ +add_executable(Exe main.cpp ${CMAKE_BINARY_DIR}/ProjectInfo.hpp) +add_dependencies(Exe ProjectInfo) +target_include_directories(Exe PRIVATE ${CMAKE_BINARY_DIR}) +target_link_libraries(Exe PRIVATE ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/AutogenTimestampDeps/src/main.cpp b/Tests/QtAutogen/AutogenTimestampDeps/src/main.cpp new file mode 100644 index 0000000..f3c4c4b --- /dev/null +++ b/Tests/QtAutogen/AutogenTimestampDeps/src/main.cpp @@ -0,0 +1,5 @@ +#include "ProjectInfo.hpp" +int main(int argc, char* argv[]) +{ + return 0; +} diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake index d676abd..80f7329 100644 --- a/Tests/QtAutogen/Tests.cmake +++ b/Tests/QtAutogen/Tests.cmake @@ -2,6 +2,7 @@ ADD_AUTOGEN_TEST(AutogenOriginDependsOff autogenOriginDependsOff) ADD_AUTOGEN_TEST(AutogenOriginDependsOn) ADD_AUTOGEN_TEST(AutogenTargetDepends) +ADD_AUTOGEN_TEST(AutogenTimestampDeps) ADD_AUTOGEN_TEST(AutoMocGeneratedFile) ADD_AUTOGEN_TEST(Complex QtAutogen) ADD_AUTOGEN_TEST(GlobalAutogenSystemUseInclude) -- cgit v0.12