summaryrefslogtreecommitdiff
path: root/Source/cmGeneratorExpressionEvaluationFile.cxx
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2014-11-04 23:24:54 +0100
committerStephen Kelly <steveire@gmail.com>2014-11-12 22:36:45 +0100
commitb80557c7bdf12f9e924ac8b010d547ce4561848e (patch)
tree67b5bc2ed5509a7ab116bfa16e8757324c651ad3 /Source/cmGeneratorExpressionEvaluationFile.cxx
parent0019d54b6e4bfde7ef1c211a1c5e5bab194381b2 (diff)
downloadcmake-b80557c7bdf12f9e924ac8b010d547ce4561848e.tar.gz
file(GENERATE): Evaluate early to allow generating source files
The evaluation files must be known before cmTargetTraceDependencies attempts to find them, but we must actually generate the files after cmTargetTraceDependencies, as that can add to target SOURCES. The limitation is that the generated output name must not depend on the SOURCES of a target if the generated file is used by that target. Mark the output files as GENERATED so that trace dependencies does not expect them to already exist in the filesystem. Move the invokation of ForceLinkerLanguage in the Generate logic to after the generated file names are known. ForceLinkerLanguage tries to determine the sources of a target (in order to determine an already-known language) and otherwise fails to get information about the generated file. Test that the output of file(GENERATE) can be used as a target source file and that accessing the target SOURCES in the name of the output file is an error. Accessing the TARGET_OBJECTS would be a similar error if it was legal to use that generator expression in this context. That is not currently possible and is a different error condition, so test the current error output as a reminder to change the expected output if that becomes possible in the future. Test that generated rule files resulting from cmTargetTraceDependencies appear in the SOURCES generated in the output file.
Diffstat (limited to 'Source/cmGeneratorExpressionEvaluationFile.cxx')
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx17
1 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index 3a8dc4843d..1a101ddf67 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -13,6 +13,9 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmMakefile.h"
+#include "cmLocalGenerator.h"
+#include "cmGlobalGenerator.h"
+#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include <cmsys/FStream.hxx>
@@ -90,6 +93,20 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
}
//----------------------------------------------------------------------------
+void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
+ std::string const& config)
+{
+ std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config);
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(name);
+ sf->SetProperty("GENERATED", "1");
+
+ cmGlobalGenerator *gg
+ = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+ gg->SetFilenameTargetDepends(sf,
+ this->OutputFileExpr->GetSourceSensitiveTargets());
+}
+
+//----------------------------------------------------------------------------
void cmGeneratorExpressionEvaluationFile::Generate()
{
mode_t perm = 0;