[Cmake-commits] CMake branch, next, updated. v3.0.0-rc4-2617-g18c8fa2
Stephen Kelly
steveire at gmail.com
Wed Apr 30 09:18:59 EDT 2014
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".
The branch, next has been updated
via 18c8fa2115b239e0acb81937b6ce86e868c8d086 (commit)
via 42e1cd137c0eff0297adaea5b34abca0da254eba (commit)
from fa5e9c0e4e0f79a70f161989d5b8fa808cb3cd0c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18c8fa2115b239e0acb81937b6ce86e868c8d086
commit 18c8fa2115b239e0acb81937b6ce86e868c8d086
Merge: fa5e9c0 42e1cd1
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Wed Apr 30 09:18:58 2014 -0400
Commit: CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Wed Apr 30 09:18:58 2014 -0400
Merge topic 'file-generate-if-different' into next
42e1cd13 file(GENERATE): Only write the file if content is different.
http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42e1cd137c0eff0297adaea5b34abca0da254eba
commit 42e1cd137c0eff0297adaea5b34abca0da254eba
Author: Stephen Kelly <steveire at gmail.com>
AuthorDate: Fri Apr 25 20:11:05 2014 +0200
Commit: Stephen Kelly <steveire at gmail.com>
CommitDate: Wed Apr 30 15:18:13 2014 +0200
file(GENERATE): Only write the file if content is different.
No policy is used to control this behavior for now.
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 95a946a..01d31d3 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -13,6 +13,7 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmMakefile.h"
+#include "cmGeneratedFileStream.h"
#include <cmsys/FStream.hxx>
#include <assert.h>
@@ -79,19 +80,9 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent;
- cmsys::ofstream fout(outputFileName.c_str());
-
- if(!fout)
- {
- cmOStringStream e;
- e << "Evaluation file \"" << outputFileName << "\" cannot be written.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
- return;
- }
-
+ cmGeneratedFileStream fout(outputFileName.c_str());
+ fout.SetCopyIfDifferent(true);
fout << outputContent;
-
- fout.close();
}
//----------------------------------------------------------------------------
diff --git a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
index f07431c..f23fa19 100644
--- a/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+++ b/Tests/RunCMake/File_Generate/RunCMakeTest.cmake
@@ -8,3 +8,30 @@ run_cmake(EmptyCondition1)
run_cmake(EmptyCondition2)
run_cmake(BadCondition)
run_cmake(DebugEvaluate)
+
+set(timeformat "%Y%j%H%M%S")
+
+file(REMOVE "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt")
+set(RunCMake_TEST_FILE "WriteIfDifferent")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/WriteIfDifferent-build")
+run_cmake(WriteIfDifferent-prepare)
+unset(RunCMake_TEST_FILE)
+unset(RunCMake_TEST_BINARY_DIR)
+file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp ${timeformat})
+if(NOT timestamp)
+ message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
+endif()
+
+execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 1)
+
+set(RunCMake_TEST_NO_CLEAN ON)
+run_cmake(WriteIfDifferent)
+file(TIMESTAMP "${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt" timestamp_after ${timeformat})
+if(NOT timestamp_after)
+ message(SEND_ERROR "Could not get timestamp for \"${RunCMake_BINARY_DIR}/WriteIfDifferent-build/output_file.txt\"")
+endif()
+unset(RunCMake_TEST_NO_CLEAN)
+
+if (NOT timestamp_after STREQUAL timestamp)
+ message(SEND_ERROR "WriteIfDifferent changed output file.")
+endif()
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt b/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
new file mode 100644
index 0000000..d1d832a
--- /dev/null
+++ b/Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
@@ -0,0 +1,5 @@
+
+file(GENERATE
+ OUTPUT output_file.txt
+ CONTENT "123"
+)
-----------------------------------------------------------------------
Summary of changes:
hooks/post-receive
--
CMake
More information about the Cmake-commits
mailing list