Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
CMake
CMake
Commits
ecdc1985
Commit
ecdc1985
authored
May 01, 2014
by
Brad King
Committed by
Kitware Robot
May 01, 2014
Browse files
Options
Browse Files
Download
Plain Diff
Merge topic 'file-generate-if-different'
42e1cd13
file(GENERATE): Only write the file if content is different.
parents
dc8505ca
42e1cd13
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
12 deletions
+37
-12
Source/cmGeneratorExpressionEvaluationFile.cxx
Source/cmGeneratorExpressionEvaluationFile.cxx
+3
-12
Tests/RunCMake/File_Generate/RunCMakeTest.cmake
Tests/RunCMake/File_Generate/RunCMakeTest.cmake
+27
-0
Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
+1
-0
Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
+1
-0
Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
+5
-0
No files found.
Source/cmGeneratorExpressionEvaluationFile.cxx
View file @
ecdc1985
...
...
@@ -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
();
}
//----------------------------------------------------------------------------
...
...
Tests/RunCMake/File_Generate/RunCMakeTest.cmake
View file @
ecdc1985
...
...
@@ -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
()
Tests/RunCMake/File_Generate/WriteIfDifferent-result.txt
0 → 100644
View file @
ecdc1985
0
Tests/RunCMake/File_Generate/WriteIfDifferent-stderr.txt
0 → 100644
View file @
ecdc1985
^$
Tests/RunCMake/File_Generate/WriteIfDifferent.cmake
0 → 100644
View file @
ecdc1985
file
(
GENERATE
OUTPUT output_file.txt
CONTENT
"123"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment