Skip to content

Instantly share code, notes, and snippets.

@ariscop
Created August 25, 2018 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariscop/5604b774aae96859d76277270f2c8bea to your computer and use it in GitHub Desktop.
Save ariscop/5604b774aae96859d76277270f2c8bea to your computer and use it in GitHub Desktop.
From f114131ec986a3ff7f7668df1a31fb60daf980a6 Mon Sep 17 00:00:00 2001
From: Andrew Cook <ariscop@gmail.com>
Date: Sun, 11 Mar 2018 13:18:36 +1100
Subject: [PATCH] Reactos changes
---
Source/CMakeLists.txt | 12 ++
Source/CMakeVersionCompute.cmake | 1 +
Source/cmGeneratorTarget.h | 5 +-
Source/cmGlobalNinjaGenerator.cxx | 24 ++-
Source/cmGlobalNinjaGenerator.h | 1 +
Source/cmLocalGenerator.cxx | 22 ++-
Source/cmLocalGenerator.h | 1 -
Source/cmMakefileTargetGenerator.cxx | 53 ++++--
Source/cmNinjaNormalTargetGenerator.cxx | 4 +-
Source/cmNinjaTargetGenerator.cxx | 178 ++++++++++++++++-----
Source/cmNinjaTargetGenerator.h | 4 +
Source/cmSourceFile.cxx | 19 +++
Source/cmVS10CLFlagTable.h | 2 +-
Source/cmVS10LinkFlagTable.h | 4 +
Source/cmVS11CLFlagTable.h | 2 +-
Source/cmVS11LinkFlagTable.h | 4 +
Source/cmVS12CLFlagTable.h | 2 +-
Source/cmVS12LinkFlagTable.h | 4 +
Source/cmVS14CLFlagTable.h | 2 +-
Source/cmVS14LinkFlagTable.h | 4 +
Source/cmVisualStudio10TargetGenerator.cxx | 25 +++
Tests/CMakeLists.txt | 1 +
Tests/SourceFileProperties/CMakeLists.txt | 80 +++++++++
23 files changed, 386 insertions(+), 68 deletions(-)
create mode 100644 Tests/SourceFileProperties/CMakeLists.txt
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 8a83c3e3d..1f13e6a2e 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -496,6 +496,9 @@ set(SRCS ${SRCS}
if(WIN32 AND NOT CYGWIN)
set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501)
add_executable(cmcldeps cmcldeps.cxx)
+ if(MSVC)
+ set_property(TARGET cmcldeps APPEND_STRING PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE,5.01")
+ endif()
target_link_libraries(cmcldeps CMakeLib)
install(TARGETS cmcldeps DESTINATION bin)
endif()
@@ -673,14 +676,23 @@ endif()
# Build CMake executable
add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h)
+if(MSVC)
+ set_property(TARGET cmake APPEND_STRING PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE,5.01")
+endif()
target_link_libraries(cmake CMakeLib)
# Build CTest executable
add_executable(ctest ctest.cxx)
+if(MSVC)
+ set_property(TARGET ctest APPEND_STRING PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE,5.01")
+endif()
target_link_libraries(ctest CTestLib)
# Build CPack executable
add_executable(cpack CPack/cpack.cxx)
+if(MSVC)
+ set_property(TARGET cpack APPEND_STRING PROPERTY LINK_FLAGS "/SUBSYSTEM:CONSOLE,5.01")
+endif()
target_link_libraries(cpack CPackLib)
# Curses GUI
diff --git a/Source/CMakeVersionCompute.cmake b/Source/CMakeVersionCompute.cmake
index 496d6cf1a..15d8734bc 100644
--- a/Source/CMakeVersionCompute.cmake
+++ b/Source/CMakeVersionCompute.cmake
@@ -15,6 +15,7 @@ set(CMake_VERSION ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_
if(CMake_VERSION_RC)
set(CMake_VERSION ${CMake_VERSION}-rc${CMake_VERSION_RC})
endif()
+set(CMake_VERSION_SOURCE "ReactOS")
if(CMake_VERSION_SOURCE)
set(CMake_VERSION ${CMake_VERSION}-${CMake_VERSION_SOURCE})
endif()
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 2083b8858..c77acc60c 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -132,13 +132,16 @@ public:
mutable std::set<std::string> ExpectedResxHeaders;
mutable std::vector<cmSourceFile const*> ResxSources;
};
+
+ mutable std::map<cmSourceFile const*, std::string> Objects;
+
+
private:
friend class cmTargetTraceDependencies;
struct SourceEntry { std::vector<cmSourceFile*> Depends; };
typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
SourceEntriesType SourceEntries;
- mutable std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 3c07be114..4c7503c34 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -246,6 +246,27 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
/*generator*/ false);
}
+void cmGlobalNinjaGenerator::AddNoopCommandRule()
+{
+ cmLocalGenerator *lg = this->LocalGenerators[0];
+ cmMakefile* mfRoot = lg->GetMakefile();
+
+ std::string cmd = lg->ConvertToOutputFormat(mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
+ cmLocalGenerator::SHELL);
+ cmd += " -E echo_append";
+
+ this->AddRule("NOOP_COMMAND",
+ cmd,
+ "NOOP",
+ "Rule for running noop command.",
+ /*depfile*/ "",
+ /*deptype*/ "",
+ /*rspfile*/ "",
+ /*rspcontent*/ "",
+ /*restat*/ "1",
+ /*generator*/ false);
+}
+
void
cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
const std::string& description,
@@ -263,6 +284,7 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
#endif
this->AddCustomCommandRule();
+ this->AddNoopCommandRule();
cmNinjaVars vars;
vars["COMMAND"] = cmd;
@@ -1063,7 +1085,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
this->WritePhonyBuild(os,
"",
deps,
- deps);
+ cmNinjaDeps());
}
}
}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 3d443d8ed..5192a8be4 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -251,6 +251,7 @@ public:
bool HasRule(const std::string& name);
void AddCustomCommandRule();
+ void AddNoopCommandRule();
void AddMacOSXContentRule();
bool HasCustomCommandOutput(const std::string &output) {
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index dd4a8f880..402cf9136 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -875,13 +875,6 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
return replaceValues.ObjectDir;
}
}
- if(replaceValues.ObjectFileDir)
- {
- if(variable == "OBJECT_FILE_DIR")
- {
- return replaceValues.ObjectFileDir;
- }
- }
if(replaceValues.Objects)
{
if(variable == "OBJECTS")
@@ -3302,6 +3295,21 @@ cmLocalGenerator
std::string const& dir_max,
bool* hasSourceExtension)
{
+ // A specified OBJECT_LOCATION overwrites the generated file name
+ if (const char* location = source.GetProperty("OBJECT_LOCATION"))
+ {
+ std::string fullPath;
+ if (cmSystemTools::FileIsFullPath(location))
+ {
+ fullPath = location;
+ }
+ else
+ {
+ fullPath = this->Convert(location, FULL);
+ }
+ return this->Convert(fullPath.c_str(), HOME_OUTPUT);
+ }
+
// Construct the object file name using the full path to the source
// file which is its only unique identification.
const char* fullPath = source.GetFullPath().c_str();
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index d64ae0f80..defb3a7ee 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -271,7 +271,6 @@ public:
const char* Output;
const char* Object;
const char* ObjectDir;
- const char* ObjectFileDir;
const char* Flags;
const char* ObjectsQuoted;
const char* SONameFlag;
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 4ece016bf..45de1eb0f 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -192,7 +192,14 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
- this->ExternalObjects.push_back((*si)->GetFullPath());
+ if (const char* path = (*si)->GetProperty("OBJECT_LOCATION"))
+ {
+ this->Objects.push_back(path);
+ }
+ else
+ {
+ this->ExternalObjects.push_back((*si)->GetFullPath());
+ }
}
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources, config);
@@ -437,12 +444,21 @@ void cmMakefileTargetGenerator
return;
}
- // Get the full path name of the object file.
- std::string const& objectName = this->GeneratorTarget
- ->GetObjectName(&source);
- std::string obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
- obj += "/";
- obj += objectName;
+ std::string obj;
+ if (source.GetProperty("OBJECT_LOCATION"))
+ {
+ // path is already absolute or HOME_OUTPUT relative
+ obj = this->GeneratorTarget->Objects[&source];
+ }
+ else
+ {
+ // Get the full path name of the object file.
+ std::string const& objectName = this->GeneratorTarget
+ ->GetObjectName(&source);
+ obj = this->LocalGenerator->GetTargetDirectory(*this->Target);
+ obj += "/";
+ obj += objectName;
+ }
// Avoid generating duplicate rules.
if(this->ObjectFiles.find(obj) == this->ObjectFiles.end())
@@ -468,7 +484,10 @@ void cmMakefileTargetGenerator
(this->LocalGenerator->ConvertToFullPath(dir).c_str());
// Save this in the target's list of object files.
- this->Objects.push_back(obj);
+ if (!source.GetPropertyAsBool("EXTERNAL_SOURCE"))
+ {
+ this->Objects.push_back(obj);
+ }
this->CleanFiles.push_back(obj);
// TODO: Remove
@@ -687,11 +706,6 @@ cmMakefileTargetGenerator
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str();
- std::string objectFileDir = cmSystemTools::GetFilenamePath(obj);
- objectFileDir = this->Convert(objectFileDir,
- cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::SHELL);
- vars.ObjectFileDir = objectFileDir.c_str();
vars.Flags = flags.c_str();
std::string definesString = "$(";
@@ -756,8 +770,7 @@ cmMakefileTargetGenerator
// Check for extra outputs created by the compilation.
std::vector<std::string> outputs(1, relativeObj);
- if(const char* extra_outputs_str =
- source.GetProperty("OBJECT_OUTPUTS"))
+ if(const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS"))
{
// Register these as extra files to clean.
cmSystemTools::ExpandListArgument(extra_outputs_str, outputs);
@@ -765,6 +778,16 @@ cmMakefileTargetGenerator
outputs.begin() + 1, outputs.end());
}
+ if(const char* object_location_str = source.GetProperty("OBJECT_LOCATION"))
+ {
+ if (relativeObj != object_location_str)
+ {
+ cmSystemTools::ExpandListArgument(object_location_str, outputs);
+ this->CleanFiles.insert(this->CleanFiles.end(),
+ outputs.begin() + 1, outputs.end());
+ }
+ }
+
// Write the rule.
this->WriteMakeRule(*this->BuildFileStream, 0, outputs,
depends, commands, false);
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index c352c1a59..847037f4c 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -502,7 +502,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
vars["FLAGS"] = t;
}
- else
+ else if (targetType == cmTarget::SHARED_LIBRARY || targetType == cmTarget::MODULE_LIBRARY)
{
std::string t = vars["ARCH_FLAGS"];
localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
@@ -706,7 +706,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
// Add aliases for the file name and the target name.
+#ifdef __REACTOS__
globalGen.AddTargetAlias(this->TargetNameOut, &target);
+#endif
globalGen.AddTargetAlias(this->GetTargetName(), &target);
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index cfd8937c6..d3b40be22 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -121,27 +121,41 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
}
}
+static void EscapeTargetForVariable(std::string& name)
+{
+ // '.' is not allowed in variable names, so escape them.
+ cmSystemTools::ReplaceString(name, ".", "_");
+ // '+' is not allowed in variable names, so escape them.
+ cmSystemTools::ReplaceString(name, "+", "_");
+}
+
std::string
cmNinjaTargetGenerator::OrderDependsTargetForTarget()
{
- return "cmake_order_depends_target_" + this->GetTargetName();
+ std::string targetName = this->GetTargetName();
+ EscapeTargetForVariable(targetName);
+ return targetName + "_orderdeps";
}
-// TODO: Most of the code is picked up from
-// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink),
-// void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
-// Refactor it.
std::string
-cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
- const std::string& language)
+cmNinjaTargetGenerator::FlagVariableForTarget(std::string const& lang)
{
- // TODO: Fortran support.
- // // Fortran-specific flags computed for this target.
- // if(*l == "Fortran")
- // {
- // this->AddFortranFlags(flags);
- // }
+ std::string targetName = this->GetTargetName();
+ EscapeTargetForVariable(targetName);
+ return targetName + "_" + lang + "_flags";
+}
+std::string
+cmNinjaTargetGenerator::DefineVariableForTarget(std::string const& lang)
+{
+ std::string targetName = this->GetTargetName();
+ EscapeTargetForVariable(targetName);
+ return targetName + "_" + lang + "_defines";
+}
+
+std::string
+cmNinjaTargetGenerator::ComputeFlagsForTarget(const std::string& language)
+{
bool hasLangCached = this->LanguageFlags.count(language) != 0;
std::string& languageFlags = this->LanguageFlags[language];
if(!hasLangCached)
@@ -189,7 +203,47 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
this->GetConfigName());
}
- std::string flags = languageFlags;
+ return languageFlags;
+}
+
+std::string
+cmNinjaTargetGenerator::ComputeDefinesForTarget(const std::string& language)
+{
+ std::set<std::string> targetDefines;
+
+ // Add the export symbol definition for shared library objects.
+ if(const char* exportMacro = this->Target->GetExportMacro())
+ {
+ this->LocalGenerator->AppendDefines(targetDefines, exportMacro);
+ }
+
+ // Add preprocessor definitions for this target and configuration.
+ this->LocalGenerator->AddCompileDefinitions(targetDefines, this->Target,
+ this->GetConfigName());
+
+ std::string targetDefinesString;
+ this->LocalGenerator->JoinDefines(targetDefines, targetDefinesString,
+ language);
+
+ return targetDefinesString;
+}
+
+// TODO: Most of the code is picked up from
+// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink),
+// void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
+// Refactor it.
+std::string
+cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
+ const std::string& language)
+{
+ // TODO: Fortran support.
+ // // Fortran-specific flags computed for this target.
+ // if(*l == "Fortran")
+ // {
+ // this->AddFortranFlags(flags);
+ // }
+
+ std::string flags = "$" + this->FlagVariableForTarget(language);
// Add source file specific flags.
this->LocalGenerator->AppendFlags(flags,
@@ -223,15 +277,6 @@ ComputeDefines(cmSourceFile const* source, const std::string& language)
{
std::set<std::string> defines;
- // Add the export symbol definition for shared library objects.
- if(const char* exportMacro = this->Target->GetExportMacro())
- {
- this->LocalGenerator->AppendDefines(defines, exportMacro);
- }
-
- // Add preprocessor definitions for this target and configuration.
- this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
- this->GetConfigName());
this->LocalGenerator->AppendDefines
(defines,
source->GetProperty("COMPILE_DEFINITIONS"));
@@ -243,7 +288,7 @@ ComputeDefines(cmSourceFile const* source, const std::string& language)
source->GetProperty(defPropName));
}
- std::string definesString;
+ std::string definesString = "$" + this->DefineVariableForTarget(language);
this->LocalGenerator->JoinDefines(defines, definesString,
language);
@@ -286,6 +331,12 @@ std::string
cmNinjaTargetGenerator
::GetObjectFilePath(cmSourceFile const* source) const
{
+ if (source->GetProperty("OBJECT_LOCATION"))
+ {
+ // path is already absolute or HOME_OUTPUT relative
+ return this->GeneratorTarget->Objects[source];
+ }
+
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if(!path.empty())
path += "/";
@@ -324,8 +375,11 @@ std::string cmNinjaTargetGenerator::GetTargetName() const
bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
{
cmMakefile* mf = this->GetMakefile();
- if (mf->GetDefinition("MSVC_C_ARCHITECTURE_ID") ||
- mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
+ const std::string cId = mf->GetDefinition("CMAKE_C_COMPILER_ID")
+ ? mf->GetSafeDefinition("CMAKE_C_COMPILER_ID")
+ : mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
+
+ if (cId == "MSVC")
{
std::string pdbPath;
std::string compilePdbPath;
@@ -387,7 +441,6 @@ cmNinjaTargetGenerator
vars.TargetPDB = "$TARGET_PDB";
vars.TargetCompilePDB = "$TARGET_COMPILE_PDB";
vars.ObjectDir = "$OBJECT_DIR";
- vars.ObjectFileDir = "$OBJECT_FILE_DIR";
cmMakefile* mf = this->GetMakefile();
@@ -522,7 +575,14 @@ cmNinjaTargetGenerator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
- this->Objects.push_back(this->GetSourceFilePath(*si));
+ if (const char* path = (*si)->GetProperty("OBJECT_LOCATION"))
+ {
+ this->Objects.push_back(this->ConvertToNinjaPath(path));
+ }
+ else
+ {
+ this->Objects.push_back(this->GetSourceFilePath(*si));
+ }
}
cmNinjaDeps orderOnlyDeps;
@@ -556,8 +616,32 @@ cmNinjaTargetGenerator
cmNinjaDeps(),
orderOnlyDeps);
}
+
+ std::set<std::string> langs;
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ si = objectSources.begin(); si != objectSources.end(); ++si)
+ {
+ langs.insert((*si)->GetLanguage());
+ }
+
+ cmNinjaVars targetVars;
+ for (std::set<std::string>::const_iterator l = langs.begin();
+ l != langs.end(); ++l)
+ {
+ targetVars[this->FlagVariableForTarget(*l)] =
+ this->ComputeFlagsForTarget(*l);
+ targetVars[this->DefineVariableForTarget(*l)] =
+ this->ComputeDefinesForTarget(*l);
+ }
+
+ for(cmNinjaVars::const_iterator i = targetVars.begin();
+ i != targetVars.end(); ++i)
+ cmGlobalNinjaGenerator::WriteVariable(this->GetBuildFileStream(),
+ i->first, i->second, "", 0);
+ this->GetBuildFileStream() << std::endl;
+
for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si)
{
@@ -584,8 +668,10 @@ cmNinjaTargetGenerator
cmNinjaDeps outputs;
std::string objectFileName = this->GetObjectFilePath(source);
outputs.push_back(objectFileName);
+
// Add this object to the list of object files.
- this->Objects.push_back(objectFileName);
+ if (!source->GetPropertyAsBool("EXTERNAL_SOURCE"))
+ this->Objects.push_back(objectFileName);
cmNinjaDeps explicitDeps;
std::string sourceFileName;
@@ -640,10 +726,6 @@ cmNinjaTargetGenerator
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
ConvertToNinjaPath(objectDir),
cmLocalGenerator::SHELL);
- std::string objectFileDir = cmSystemTools::GetFilenamePath(objectFileName);
- vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(objectFileDir),
- cmLocalGenerator::SHELL);
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars);
@@ -672,7 +754,6 @@ cmNinjaTargetGenerator
compileObjectVars.Source = escapedSourceFileName.c_str();
compileObjectVars.Object = objectFileName.c_str();
compileObjectVars.ObjectDir = objectDir.c_str();
- compileObjectVars.ObjectFileDir = objectFileDir.c_str();
compileObjectVars.Flags = vars["FLAGS"].c_str();
compileObjectVars.Defines = vars["DEFINES"].c_str();
@@ -710,10 +791,31 @@ cmNinjaTargetGenerator
cmSystemTools::ExpandListArgument(objectOutputs, outputList);
std::transform(outputList.begin(), outputList.end(), outputList.begin(),
MapToNinjaPath());
- this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
- "Additional output files.",
- outputList,
- outputs);
+ this->GetGlobalGenerator()->WriteBuild(this->GetBuildFileStream(),
+ "Additional output files.",
+ "NOOP_COMMAND",
+ outputList,
+ outputs,
+ cmNinjaDeps(),
+ cmNinjaDeps(),
+ cmNinjaVars());
+ }
+
+ if(const char* objectLocationStr = source->GetProperty("OBJECT_LOCATION")) {
+ std::string objectLocation =
+ this->GetLocalGenerator()
+ ->Convert(objectLocationStr, cmLocalGenerator::HOME_OUTPUT);
+ if (std::find(outputs.begin(), outputs.end(), objectLocation)
+ == outputs.end()) {
+ std::vector<std::string> outputList;
+ cmSystemTools::ExpandListArgument(objectLocation, outputList);
+ std::transform(outputList.begin(), outputList.end(), outputList.begin(),
+ MapToNinjaPath());
+ this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
+ "Location output file.",
+ outputList,
+ outputs);
+ }
}
}
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 5733fde4c..9b86b9d6a 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -75,8 +75,12 @@ protected:
void AddFeatureFlags(std::string& flags, const std::string& lang);
std::string OrderDependsTargetForTarget();
+ std::string FlagVariableForTarget(std::string const& lang);
+ std::string DefineVariableForTarget(std::string const& lang);
std::string ComputeOrderDependsForTarget();
+ std::string ComputeFlagsForTarget(const std::string& language);
+ std::string ComputeDefinesForTarget(const std::string& language);
/**
* Compute the flags for compilation of object files for a given @a language.
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 684747591..f91e92228 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -399,3 +399,22 @@ void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
this->CustomCommand = cc;
delete old;
}
+
+
+
+/*
+ //TODO
+
+ cm->DefineProperty
+ ("EXTERNAL_SOURCE", cmProperty::SOURCE_FILE,
+ "If set to true then this is a source file.",
+ "If this property is set to true then file is a source file"
+ "and will be compiled but it will not be linked into the target");
+
+
+ cm->DefineProperty
+ ("OBJECT_LOCATION", cmProperty::SOURCE_FILE,
+ "Path to output file name.",
+ "The output will be created at the given path."
+ "A relative path is interpreted as relative to CMAKE_BINARY_DIR.");
+*/
diff --git a/Source/cmVS10CLFlagTable.h b/Source/cmVS10CLFlagTable.h
index a7b1b3651..dc0075eb8 100644
--- a/Source/cmVS10CLFlagTable.h
+++ b/Source/cmVS10CLFlagTable.h
@@ -247,7 +247,7 @@ static cmVS7FlagTable cmVS10CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yc",
"Precompiled Header Name",
- "", cmVS7FlagTable::UserValueRequired},
+ "", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yu",
"Precompiled Header Name",
"", cmVS7FlagTable::UserValueRequired},
diff --git a/Source/cmVS10LinkFlagTable.h b/Source/cmVS10LinkFlagTable.h
index f6b758d05..785f6a348 100644
--- a/Source/cmVS10LinkFlagTable.h
+++ b/Source/cmVS10LinkFlagTable.h
@@ -235,9 +235,11 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] =
{"Version", "VERSION:",
"Version",
"", cmVS7FlagTable::UserValue},
+#if 0
{"SpecifySectionAttributes", "SECTION:",
"Specify Section Attributes",
"", cmVS7FlagTable::UserValue},
+#endif
{"MSDOSStubFileName", "STUB:",
"MS-DOS Stub File Name",
"", cmVS7FlagTable::UserValue},
@@ -288,9 +290,11 @@ static cmVS7FlagTable cmVS10LinkFlagTable[] =
{"ImportLibrary", "IMPLIB:",
"Import Library",
"", cmVS7FlagTable::UserValue},
+#if 0
{"MergeSections", "MERGE:",
"Merge Sections",
"", cmVS7FlagTable::UserValue},
+#endif
{"LinkKeyFile", "KEYFILE:",
"Key File",
"", cmVS7FlagTable::UserValue},
diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h
index a61ab1609..e1ce9da15 100644
--- a/Source/cmVS11CLFlagTable.h
+++ b/Source/cmVS11CLFlagTable.h
@@ -265,7 +265,7 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yc",
"Precompiled Header Name",
- "", cmVS7FlagTable::UserValueRequired},
+ "", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yu",
"Precompiled Header Name",
"", cmVS7FlagTable::UserValueRequired},
diff --git a/Source/cmVS11LinkFlagTable.h b/Source/cmVS11LinkFlagTable.h
index 0f641e40e..12f8ef52e 100644
--- a/Source/cmVS11LinkFlagTable.h
+++ b/Source/cmVS11LinkFlagTable.h
@@ -264,9 +264,11 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] =
{"Version", "VERSION:",
"Version",
"", cmVS7FlagTable::UserValue},
+#if 0
{"SpecifySectionAttributes", "SECTION:",
"Specify Section Attributes",
"", cmVS7FlagTable::UserValue},
+#endif
{"MSDOSStubFileName", "STUB:",
"MS-DOS Stub File Name",
"", cmVS7FlagTable::UserValue},
@@ -326,9 +328,11 @@ static cmVS7FlagTable cmVS11LinkFlagTable[] =
{"ImportLibrary", "IMPLIB:",
"Import Library",
"", cmVS7FlagTable::UserValue},
+#if 0
{"MergeSections", "MERGE:",
"Merge Sections",
"", cmVS7FlagTable::UserValue},
+#endif
{"LinkKeyFile", "KEYFILE:",
"Key File",
"", cmVS7FlagTable::UserValue},
diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h
index 0a7916f1b..fa0283ce3 100644
--- a/Source/cmVS12CLFlagTable.h
+++ b/Source/cmVS12CLFlagTable.h
@@ -271,7 +271,7 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yc",
"Precompiled Header Name",
- "", cmVS7FlagTable::UserValueRequired},
+ "", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yu",
"Precompiled Header Name",
"", cmVS7FlagTable::UserValueRequired},
diff --git a/Source/cmVS12LinkFlagTable.h b/Source/cmVS12LinkFlagTable.h
index e5a570e7c..3871a24eb 100644
--- a/Source/cmVS12LinkFlagTable.h
+++ b/Source/cmVS12LinkFlagTable.h
@@ -264,9 +264,11 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] =
{"Version", "VERSION:",
"Version",
"", cmVS7FlagTable::UserValue},
+#if 0
{"SpecifySectionAttributes", "SECTION:",
"Specify Section Attributes",
"", cmVS7FlagTable::UserValue},
+#endif
{"MSDOSStubFileName", "STUB:",
"MS-DOS Stub File Name",
"", cmVS7FlagTable::UserValue},
@@ -326,9 +328,11 @@ static cmVS7FlagTable cmVS12LinkFlagTable[] =
{"ImportLibrary", "IMPLIB:",
"Import Library",
"", cmVS7FlagTable::UserValue},
+#if 0
{"MergeSections", "MERGE:",
"Merge Sections",
"", cmVS7FlagTable::UserValue},
+#endif
{"LinkKeyFile", "KEYFILE:",
"Key File",
"", cmVS7FlagTable::UserValue},
diff --git a/Source/cmVS14CLFlagTable.h b/Source/cmVS14CLFlagTable.h
index 422f47b43..2c63a342d 100644
--- a/Source/cmVS14CLFlagTable.h
+++ b/Source/cmVS14CLFlagTable.h
@@ -273,7 +273,7 @@ static cmVS7FlagTable cmVS14CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yc",
"Precompiled Header Name",
- "", cmVS7FlagTable::UserValueRequired},
+ "", cmVS7FlagTable::UserValue},
{"PrecompiledHeaderFile", "Yu",
"Precompiled Header Name",
"", cmVS7FlagTable::UserValueRequired},
diff --git a/Source/cmVS14LinkFlagTable.h b/Source/cmVS14LinkFlagTable.h
index 6d81d125f..19da3ee11 100644
--- a/Source/cmVS14LinkFlagTable.h
+++ b/Source/cmVS14LinkFlagTable.h
@@ -264,9 +264,11 @@ static cmVS7FlagTable cmVS14LinkFlagTable[] =
{"Version", "VERSION:",
"Version",
"", cmVS7FlagTable::UserValue},
+#if 0
{"SpecifySectionAttributes", "SECTION:",
"Specify Section Attributes",
"", cmVS7FlagTable::UserValue},
+#endif
{"MSDOSStubFileName", "STUB:",
"MS-DOS Stub File Name",
"", cmVS7FlagTable::UserValue},
@@ -326,9 +328,11 @@ static cmVS7FlagTable cmVS14LinkFlagTable[] =
{"ImportLibrary", "IMPLIB:",
"Import Library",
"", cmVS7FlagTable::UserValue},
+#if 0
{"MergeSections", "MERGE:",
"Merge Sections",
"", cmVS7FlagTable::UserValue},
+#endif
{"LinkKeyFile", "KEYFILE:",
"Key File",
"", cmVS7FlagTable::UserValue},
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index a286049cb..d74544b80 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -677,6 +677,16 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
this->WriteNsightTegraConfigurationValues(*i);
}
+ // ReactOS: empty default includes
+ if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING"))
+ {
+ this->WriteString("<IncludePath />\n", 2);
+ this->WriteString("<ReferencePath />\n", 2);
+ this->WriteString("<LibraryPath />\n", 2);
+ this->WriteString("<LibraryWPath />\n", 2);
+ this->WriteString("<SourcePath />\n", 2);
+ }
+
this->WriteString("</PropertyGroup>\n", 1);
}
}
@@ -713,6 +723,8 @@ void cmVisualStudio10TargetGenerator
{
this->WriteString("<CharacterSet>Unicode</CharacterSet>\n", 2);
}
+ else this->WriteString("<CharacterSet>NotSet</CharacterSet>\n", 2);
+#if 0
else if (this->Target->GetType() <= cmTarget::MODULE_LIBRARY &&
this->ClOptions[config]->UsingSBCS())
{
@@ -722,6 +734,7 @@ void cmVisualStudio10TargetGenerator
{
this->WriteString("<CharacterSet>MultiByte</CharacterSet>\n", 2);
}
+#endif
if(const char* toolset = gg->GetPlatformToolset())
{
std::string pts = "<PlatformToolset>";
@@ -1869,7 +1882,10 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
if(this->MSTools)
{
clOptions.FixExceptionHandlingDefault();
+ clOptions.AddFlag("RuntimeLibrary", "");
+#if 0
clOptions.AddFlag("PrecompiledHeader", "NotUsing");
+#endif
std::string asmLocation = configName + "/";
clOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
}
@@ -2342,10 +2358,12 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
}
}
}
+#if 0
else
{
linkOptions.AddFlag("SubSystem", "Windows");
}
+#endif
}
else
{
@@ -2364,10 +2382,12 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
}
}
}
+#if 0
else
{
linkOptions.AddFlag("SubSystem", "Console");
};
+#endif
}
if(const char* stackVal =
@@ -2387,12 +2407,16 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
std::string pdb = this->Target->GetPDBDirectory(config.c_str());
pdb += "/";
pdb += targetNamePDB;
+#if 0
std::string imLib = this->Target->GetDirectory(config.c_str(), true);
imLib += "/";
imLib += targetNameImport;
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
+#endif
linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
+ linkOptions.AddFlag("RandomizedBaseAddress", "");
+ linkOptions.AddFlag("DataExecutionPrevention", "");
// A Windows Runtime component uses internal .NET metadata,
// so does not have an import library.
@@ -2451,6 +2475,7 @@ cmVisualStudio10TargetGenerator::WriteLinkOptions(std::string const& config)
this->WriteString("<Link>\n", 2);
linkOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
+ linkOptions.AddFlag("EnableUAC", "");
linkOptions.OutputFlagMap(*this->BuildFileStream, " ");
this->WriteString("</Link>\n", 2);
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 7e7aa2ec8..b585e4de3 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -262,6 +262,7 @@ if(BUILD_TESTING)
if(NOT CMake_TEST_EXTERNAL_CMAKE)
ADD_TEST_MACRO(LoadCommand LoadedCommand)
endif()
+ ADD_TEST_MACRO(SourceFileProperties SourceFileProperties)
ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
ADD_TEST_MACRO(LinkLanguage LinkLanguage)
ADD_TEST_MACRO(LinkLine LinkLine)
diff --git a/Tests/SourceFileProperties/CMakeLists.txt b/Tests/SourceFileProperties/CMakeLists.txt
new file mode 100644
index 000000000..553ac6693
--- /dev/null
+++ b/Tests/SourceFileProperties/CMakeLists.txt
@@ -0,0 +1,80 @@
+cmake_minimum_required (VERSION 2.8)
+
+project (SourceFileProperties)
+
+
+
+# linking with external would fail because of two main() definitions
+set(src ${CMAKE_CURRENT_BINARY_DIR}/src)
+file(WRITE ${src}1.cpp "int main() { return 0; }\n")
+file(WRITE ${src}2.cpp "int main() { return 0; }\n")
+
+set_source_files_properties(${src}2.cpp PROPERTIES EXTERNAL_SOURCE TRUE)
+
+add_executable(SourceFileProperties ${src}1.cpp ${src}2.cpp)
+
+
+
+# build with manual set object file name
+file(WRITE ${src}3.cpp "int main() { return 0; }\n")
+set(obj ${CMAKE_CURRENT_BINARY_DIR}/object_location${CMAKE_C_OUTPUT_EXTENSION})
+
+set_source_files_properties(${src}3.cpp PROPERTIES OBJECT_LOCATION ${obj})
+
+add_executable(SourceFileProperties2 ${src}3.cpp)
+
+
+
+# ensure the defined object filenname was used
+set_source_files_properties(external_object PROPERTIES
+ EXTERNAL_OBJECT TRUE
+ GENERATED TRUE
+ OBJECT_LOCATION ${obj}
+ LANGUAGE CXX)
+
+add_executable(SourceFileProperties3 external_object)
+
+
+
+
+###########################################
+# Precompiled header like tests
+
+set(all_headers ${CMAKE_CURRENT_BINARY_DIR}/all_headers.h)
+set(gch ${all_headers}.gch)
+
+file(WRITE ${all_headers} "#include <string>\n")
+file(WRITE ${src}4.cpp "std::string foo() { return std::string(); }\n")
+
+
+if(NOT MSVC)
+
+ set_source_files_properties(${all_headers} PROPERTIES
+ HEADER_FILE_ONLY FALSE
+ LANGUAGE CXX
+ EXTERNAL_SOURCE TRUE
+ OBJECT_LOCATION ${gch})
+
+ set_source_files_properties(${src}4.cpp PROPERTIES
+ COMPILE_FLAGS "-Winvalid-pch -include ${all_headers}"
+ OBJECT_DEPENDS ${gch})
+
+ set(pch_support ${all_headers})
+
+else()
+
+ file(WRITE ${all_headers}.cpp "#include \"${all_headers}\"\n")
+
+ set_source_files_properties(${all_headers}.cpp PROPERTIES
+ COMPILE_FLAGS "/Yc\"${all_headers}\" /Fp${gch}"
+ OBJECT_OUTPUTS ${gch})
+
+ set_source_files_properties(${src}4.cpp PROPERTIES
+ COMPILE_FLAGS "/FI${all_headers} /Yu${all_headers} /Fp${gch}"
+ OBJECT_DEPENDS ${gch})
+
+ set(pch_support ${all_headers}.cpp)
+
+endif()
+
+add_library(test_with_pch ${src}4.cpp ${pch_support})
--
2.17.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment