summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-10-17 10:41:43 -0400
committerBrad King <brad.king@kitware.com>2019-10-17 10:41:43 -0400
commit6dedb9742094470196698a5009441e3860e61f2a (patch)
tree722cf5b830ffe47f3d76cd2e9ec00b57d78ff0f0
parent7aab792716bb647aac2b5802e6e21148471a0c79 (diff)
parent797689ab35c6f1edc37b120804e348b03ce7b161 (diff)
downloadcmake-6dedb9742094470196698a5009441e3860e61f2a.tar.gz
Merge branch 'pch-makefile-depends' into release-3.16
Merge-request: !3928
-rw-r--r--Source/cmMakefileTargetGenerator.cxx27
-rw-r--r--Source/cmMakefileTargetGenerator.h5
-rw-r--r--Tests/BuildDepends/CMakeLists.txt16
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt6
-rw-r--r--Tests/BuildDepends/Project/zot.cxx5
-rw-r--r--Tests/BuildDepends/Project/zot_pch.cxx6
6 files changed, 38 insertions, 27 deletions
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 51804d2873..767f4e0aa8 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -423,25 +423,17 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Create the directory containing the object file. This may be a
// subdirectory under the target's directory.
- std::string dir = cmSystemTools::GetFilenamePath(obj);
- cmSystemTools::MakeDirectory(this->LocalGenerator->ConvertToFullPath(dir));
+ {
+ std::string dir = cmSystemTools::GetFilenamePath(obj);
+ cmSystemTools::MakeDirectory(this->LocalGenerator->ConvertToFullPath(dir));
+ }
// Save this in the target's list of object files.
this->Objects.push_back(obj);
this->CleanFiles.insert(obj);
- // TODO: Remove
- // std::string relativeObj
- //= this->LocalGenerator->GetHomeRelativeOutputPath();
- // relativeObj += obj;
-
- // we compute some depends when writing the depend.make that we will also
- // use in the build.make, same with depMakeFile
std::vector<std::string> depends;
- // generate the build rule file
- this->WriteObjectBuildFile(obj, lang, source, depends);
-
// The object file should be checked for dependency integrity.
std::string objFullPath =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/', obj);
@@ -450,12 +442,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
cmSystemTools::CollapseFullPath(source.GetFullPath());
this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
objFullPath, srcFullPath);
-}
-void cmMakefileTargetGenerator::WriteObjectBuildFile(
- std::string& obj, const std::string& lang, cmSourceFile const& source,
- std::vector<std::string>& depends)
-{
this->LocalGenerator->AppendRuleDepend(depends,
this->FlagFileNameFull.c_str());
this->LocalGenerator->AppendRuleDepends(depends,
@@ -471,10 +458,14 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
const std::string pchSource =
this->GeneratorTarget->GetPchSource(config, lang);
if (!pchSource.empty() && !source.GetProperty("SKIP_PRECOMPILE_HEADERS")) {
- depends.push_back(this->GeneratorTarget->GetPchHeader(config, lang));
+ std::string const& pchHeader =
+ this->GeneratorTarget->GetPchHeader(config, lang);
+ depends.push_back(pchHeader);
if (source.GetFullPath() != pchSource) {
depends.push_back(this->GeneratorTarget->GetPchFile(config, lang));
}
+ this->LocalGenerator->AddImplicitDepends(this->GeneratorTarget, lang,
+ objFullPath, pchHeader);
}
std::string relativeObj =
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index f4641284e4..7b9c7a5ffe 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -91,11 +91,6 @@ protected:
// write the rules for an object
void WriteObjectRuleFiles(cmSourceFile const& source);
- // write the build rule for an object
- void WriteObjectBuildFile(std::string& obj, const std::string& lang,
- cmSourceFile const& source,
- std::vector<std::string>& depends);
-
// write the depend.make file for an object
void WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends);
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 39a5131fed..c1ad17cd35 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -62,6 +62,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
"static const char* zot_macro_dir = \"zot_macro_dir\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
"static const char* zot_macro_tgt = \"zot_macro_tgt\";\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_pch.hxx
+ "#ifndef ZOT_PCH_HXX\n"
+ "#define ZOT_PCH_HXX\n"
+ "static const char* zot_pch = \"zot_pch\";\n"
+ "#endif\n"
+ )
file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
"#define link_depends_no_shared_lib_value 1\n")
@@ -155,7 +161,7 @@ execute_process(COMMAND ${zot} OUTPUT_VARIABLE out RESULT_VARIABLE runResult)
string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("Run result: ${runResult} Output: \"${out}\"")
-set(VALUE_UNCHANGED "[zot] [zot_custom] [zot_macro_dir] [zot_macro_tgt] ")
+set(VALUE_UNCHANGED "[zot] [zot_custom] [zot_macro_dir] [zot_macro_tgt] [zot_pch] ")
if("${out}" STREQUAL "${VALUE_UNCHANGED}")
message("Worked!")
else()
@@ -245,6 +251,12 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_dir.hxx
"static const char* zot_macro_dir = \"zot_macro_dir changed\";\n")
file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_macro_tgt.hxx
"static const char* zot_macro_tgt = \"zot_macro_tgt changed\";\n")
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/zot_pch.hxx
+ "#ifndef ZOT_PCH_HXX\n"
+ "#define ZOT_PCH_HXX\n"
+ "static const char* zot_pch = \"zot_pch changed\";\n"
+ "#endif\n"
+ )
file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_lib.h
"#define link_depends_no_shared_lib_value 0\n")
@@ -326,7 +338,7 @@ string(REGEX REPLACE "[\r\n]" " " out "${out}")
message("Run result: ${runResult} Output: \"${out}\"")
set(VALUE_CHANGED
- "[zot changed] [zot_custom changed] [zot_macro_dir changed] [zot_macro_tgt changed] "
+ "[zot changed] [zot_custom changed] [zot_macro_dir changed] [zot_macro_tgt changed] [zot_pch changed] "
)
if("${out}" STREQUAL "${VALUE_CHANGED}")
message("Worked!")
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 3f41b26d09..833880098c 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -93,6 +93,12 @@ add_executable(zot zot.cxx ${CMAKE_CURRENT_BINARY_DIR}/zot.hxx
zot_macro_dir.cxx zot_macro_tgt.cxx)
add_dependencies(zot zot_custom)
+add_library(zot_pch zot_pch.cxx)
+target_link_libraries(zot zot_pch)
+if(NOT CMAKE_OSX_ARCHITECTURES MATCHES "[;$]")
+ target_precompile_headers(zot_pch PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/zot_pch.hxx)
+endif()
+
# Test the #include line macro transformation rule support.
set_property(
TARGET zot
diff --git a/Tests/BuildDepends/Project/zot.cxx b/Tests/BuildDepends/Project/zot.cxx
index faee7d3cec..2d08c4b78d 100644
--- a/Tests/BuildDepends/Project/zot.cxx
+++ b/Tests/BuildDepends/Project/zot.cxx
@@ -4,11 +4,12 @@
const char* zot_macro_dir_f();
const char* zot_macro_tgt_f();
+const char* zot_pch_f();
int main()
{
- printf("[%s] [%s] [%s] [%s]\n", zot, zot_custom, zot_macro_dir_f(),
- zot_macro_tgt_f());
+ printf("[%s] [%s] [%s] [%s] [%s]\n", zot, zot_custom, zot_macro_dir_f(),
+ zot_macro_tgt_f(), zot_pch_f());
fflush(stdout);
return 0;
}
diff --git a/Tests/BuildDepends/Project/zot_pch.cxx b/Tests/BuildDepends/Project/zot_pch.cxx
new file mode 100644
index 0000000000..d9d04c7fad
--- /dev/null
+++ b/Tests/BuildDepends/Project/zot_pch.cxx
@@ -0,0 +1,6 @@
+#include <zot_pch.hxx>
+
+const char* zot_pch_f()
+{
+ return zot_pch;
+}