file(GENERATE): Use permissions of input file if present.
This commit is contained in:
parent
db3cfc3376
commit
81afbbc09b
|
@ -36,7 +36,7 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
|
void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
|
||||||
cmCompiledGeneratorExpression* inputExpression,
|
cmCompiledGeneratorExpression* inputExpression,
|
||||||
std::map<std::string, std::string> &outputFiles)
|
std::map<std::string, std::string> &outputFiles, mode_t perm)
|
||||||
{
|
{
|
||||||
std::string rawCondition = this->Condition->GetInput();
|
std::string rawCondition = this->Condition->GetInput();
|
||||||
if (!rawCondition.empty())
|
if (!rawCondition.empty())
|
||||||
|
@ -83,11 +83,16 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
|
||||||
cmGeneratedFileStream fout(outputFileName.c_str());
|
cmGeneratedFileStream fout(outputFileName.c_str());
|
||||||
fout.SetCopyIfDifferent(true);
|
fout.SetCopyIfDifferent(true);
|
||||||
fout << outputContent;
|
fout << outputContent;
|
||||||
|
if (fout.Close() && perm)
|
||||||
|
{
|
||||||
|
cmSystemTools::SetPermissions(outputFileName.c_str(), perm);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGeneratorExpressionEvaluationFile::Generate()
|
void cmGeneratorExpressionEvaluationFile::Generate()
|
||||||
{
|
{
|
||||||
|
mode_t perm = 0;
|
||||||
std::string inputContent;
|
std::string inputContent;
|
||||||
if (this->InputIsContent)
|
if (this->InputIsContent)
|
||||||
{
|
{
|
||||||
|
@ -95,6 +100,7 @@ void cmGeneratorExpressionEvaluationFile::Generate()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
cmSystemTools::GetPermissions(this->Input.c_str(), perm);
|
||||||
cmsys::ifstream fin(this->Input.c_str());
|
cmsys::ifstream fin(this->Input.c_str());
|
||||||
if(!fin)
|
if(!fin)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +137,7 @@ void cmGeneratorExpressionEvaluationFile::Generate()
|
||||||
for(std::vector<std::string>::const_iterator li = allConfigs.begin();
|
for(std::vector<std::string>::const_iterator li = allConfigs.begin();
|
||||||
li != allConfigs.end(); ++li)
|
li != allConfigs.end(); ++li)
|
||||||
{
|
{
|
||||||
this->Generate(*li, inputExpression.get(), outputFiles);
|
this->Generate(*li, inputExpression.get(), outputFiles, perm);
|
||||||
if(cmSystemTools::GetFatalErrorOccured())
|
if(cmSystemTools::GetFatalErrorOccured())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
private:
|
private:
|
||||||
void Generate(const std::string& config,
|
void Generate(const std::string& config,
|
||||||
cmCompiledGeneratorExpression* inputExpression,
|
cmCompiledGeneratorExpression* inputExpression,
|
||||||
std::map<std::string, std::string> &outputFiles);
|
std::map<std::string, std::string> &outputFiles, mode_t perm);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const std::string Input;
|
const std::string Input;
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
0
|
|
@ -0,0 +1 @@
|
||||||
|
^$
|
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
file(GENERATE
|
||||||
|
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/output_script.sh"
|
||||||
|
INPUT "${CMAKE_CURRENT_SOURCE_DIR}/input_script.sh"
|
||||||
|
)
|
|
@ -35,3 +35,21 @@ unset(RunCMake_TEST_NO_CLEAN)
|
||||||
if (NOT timestamp_after STREQUAL timestamp)
|
if (NOT timestamp_after STREQUAL timestamp)
|
||||||
message(SEND_ERROR "WriteIfDifferent changed output file.")
|
message(SEND_ERROR "WriteIfDifferent changed output file.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if (UNIX AND EXISTS /bin/sh)
|
||||||
|
set(RunCMake_TEST_NO_CLEAN ON)
|
||||||
|
run_cmake(CarryPermissions)
|
||||||
|
execute_process(
|
||||||
|
COMMAND "${RunCMake_BINARY_DIR}/CarryPermissions-build/output_script.sh"
|
||||||
|
OUTPUT_VARIABLE script_output
|
||||||
|
RESULT_VARIABLE script_result
|
||||||
|
ERROR_VARIABLE script_error
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
if (script_result)
|
||||||
|
message(SEND_ERROR "Generated script did not execute correctly: [${script_result}]\n${script_output}\n====\n${script_error}")
|
||||||
|
endif()
|
||||||
|
if (NOT script_output STREQUAL SUCCESS)
|
||||||
|
message(SEND_ERROR "Generated script did not execute correctly:\n${script_output}\n====\n${script_error}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
echo "$<$<STREQUAL:foo,foo>:SUCCESS>"
|
Loading…
Reference in New Issue