summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-10 14:54:39 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-10 14:54:55 (GMT)
commitbbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84 (patch)
tree15f339e1582ed553aa10f9a3299a7473df844c53 /Source
parent05d5c66ff853f88e6dbe43bbddd18dd8babaa427 (diff)
parentff5028c5318c5d404390d8114d9453fc81fa9a33 (diff)
downloadCMake-bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84.zip
CMake-bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84.tar.gz
CMake-bbf48c494ad28d1c8ac5aa6e4cecb35c2cbf1b84.tar.bz2
Merge topic 'windows-auto-export-incremental-build'
ff5028c531 Windows: Prevent auto exports to be regenerated on every build Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3750
Diffstat (limited to 'Source')
-rw-r--r--Source/cmcmd.cxx33
1 files changed, 25 insertions, 8 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index a79a2ff..e6dd99a 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -562,19 +562,36 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
"objlistfile [-nm=nm-path]\n";
return 1;
}
- FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+");
- if (!fout) {
- std::cerr << "could not open output .def file: " << args[2].c_str()
- << "\n";
- return 1;
- }
cmsys::ifstream fin(args[3].c_str(), std::ios::in | std::ios::binary);
if (!fin) {
std::cerr << "could not open object list file: " << args[3].c_str()
<< "\n";
return 1;
}
- std::string file;
+ std::vector<std::string> files;
+ {
+ std::string file;
+ cmFileTime outTime;
+ bool outValid = outTime.Load(args[2]);
+ while (cmSystemTools::GetLineFromStream(fin, file)) {
+ files.push_back(file);
+ if (outValid) {
+ cmFileTime inTime;
+ outValid = inTime.Load(file) && inTime.Older(outTime);
+ }
+ }
+ if (outValid) {
+ // The def file already exists and all input files are older than the
+ // existing def file.
+ return 0;
+ }
+ }
+ FILE* fout = cmsys::SystemTools::Fopen(args[2].c_str(), "w+");
+ if (!fout) {
+ std::cerr << "could not open output .def file: " << args[2].c_str()
+ << "\n";
+ return 1;
+ }
bindexplib deffile;
if (args.size() >= 5) {
auto a = args[4];
@@ -585,7 +602,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args)
std::cerr << "unknown argument: " << a << "\n";
}
}
- while (cmSystemTools::GetLineFromStream(fin, file)) {
+ for (auto const& file : files) {
std::string const& ext = cmSystemTools::GetFilenameLastExtension(file);
if (cmSystemTools::LowerCase(ext) == ".def") {
if (!deffile.AddDefinitionFile(file.c_str())) {