summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx16
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h4
-rw-r--r--Source/cmQtAutoGenInitializer.cxx28
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx255
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h10
-rw-r--r--Source/cmake.cxx23
-rw-r--r--Source/cmakemain.cxx2
7 files changed, 57 insertions, 281 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index dec0858..29eeb5a 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1286,22 +1286,6 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
return makeCommands;
}
-bool cmGlobalVisualStudio10Generator::IsInSolution(
- const cmGeneratorTarget* gt) const
-{
- return gt->IsInBuildSystem() &&
- !(this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 &&
- gt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET);
-}
-
-bool cmGlobalVisualStudio10Generator::IsDepInSolution(
- const std::string& targetName) const
-{
- return !targetName.empty() &&
- !(this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 &&
- targetName == CMAKE_CHECK_BUILD_SYSTEM_TARGET);
-}
-
bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
{
if (this->DefaultPlatformToolset == "v100") {
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 12fd7a8..4977a84 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -118,10 +118,6 @@ public:
return this->WindowsTargetPlatformVersion;
}
- bool IsInSolution(const cmGeneratorTarget* gt) const override;
-
- bool IsDepInSolution(const std::string& targetName) const override;
-
/** Return true if building for WindowsCE */
bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 1514a8a..40f3ab5 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -909,7 +909,6 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// The reason is that their file names might be discovered from source files
// at generation time.
if (this->MocOrUicEnabled()) {
- std::unordered_set<std::string> addedFiles;
for (const auto& sf : this->Makefile->GetSourceFiles()) {
// sf->GetExtension() is only valid after sf->ResolveFullPath() ...
// Since we're iterating over source files that might be not in the
@@ -951,28 +950,25 @@ bool cmQtAutoGenInitializer::InitScanFiles()
cmExpandedList(uicOpts));
}
- auto uiHeaderFileName = cmStrCat(
- "ui_"_s, cmSystemTools::GetFilenameWithoutLastExtension(fullPath),
- ".h"_s);
+ auto uiHeaderRelativePath = cmSystemTools::RelativePath(
+ this->LocalGen->GetCurrentSourceDirectory(),
+ cmSystemTools::GetFilenamePath(fullPath));
- // .ui files with the same base name will conflict. Yield an error.
- {
- auto insertResult = addedFiles.insert(uiHeaderFileName);
- if (!insertResult.second) {
- this->Makefile->IssueMessage(
- MessageType::FATAL_ERROR,
- cmStrCat("More than one .ui file with the name "_s,
- cmSystemTools::GetFilenameName(fullPath),
- " was found in the sources for target "_s,
- this->GenTarget->GetName(), "."));
- }
+ // Avoid creating a path containing adjacent slashes
+ if (!uiHeaderRelativePath.empty() &&
+ uiHeaderRelativePath.back() != '/') {
+ uiHeaderRelativePath += '/';
}
+ auto uiHeaderFilePath = cmStrCat(
+ '/', uiHeaderRelativePath, "ui_"_s,
+ cmSystemTools::GetFilenameWithoutLastExtension(fullPath), ".h"_s);
+
ConfigString uiHeader;
std::string uiHeaderGenex;
this->ConfigFileNamesAndGenex(
uiHeader, uiHeaderGenex, cmStrCat(this->Dir.Build, "/include"_s),
- cmStrCat("/"_s, uiHeaderFileName));
+ uiHeaderFilePath);
this->Uic.UiHeaders.emplace_back(
std::make_pair(uiHeader, uiHeaderGenex));
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index c79331c..9f3d620 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -50,24 +50,6 @@
#include "cmValue.h"
#include "cmVisualStudioGeneratorOptions.h"
-namespace {
-std::string getProjectFileExtension(VsProjectType projectType)
-{
- switch (projectType) {
- case VsProjectType::csproj:
- return ".csproj";
- case VsProjectType::proj:
- return ".proj";
- case VsProjectType::vcxproj:
- return ".vcxproj";
- // Valid inputs shouldn't reach here. This default is needed so that all
- // paths return value (C4715).
- default:
- return "";
- }
-}
-}
-
struct cmIDEFlagTable;
static void ConvertToWindowsSlash(std::string& s);
@@ -253,6 +235,31 @@ static bool cmVS10IsTargetsFile(std::string const& path)
return cmSystemTools::Strucmp(ext.c_str(), ".targets") == 0;
}
+static VsProjectType computeProjectType(cmGeneratorTarget const* t)
+{
+ if (t->IsCSharpOnly()) {
+ return VsProjectType::csproj;
+ }
+ return VsProjectType::vcxproj;
+}
+
+static std::string computeProjectFileExtension(VsProjectType projectType)
+{
+ switch (projectType) {
+ case VsProjectType::csproj:
+ return ".csproj";
+ case VsProjectType::proj:
+ return ".proj";
+ default:
+ return ".vcxproj";
+ }
+}
+
+static std::string computeProjectFileExtension(cmGeneratorTarget const* t)
+{
+ return computeProjectFileExtension(computeProjectType(t));
+}
+
cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg)
: GeneratorTarget(target)
@@ -347,10 +354,10 @@ std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
void cmVisualStudio10TargetGenerator::Generate()
{
- this->ProjectType = this->ComputeProjectType(this->GeneratorTarget);
+ this->ProjectType = computeProjectType(this->GeneratorTarget);
this->Managed = this->ProjectType == VsProjectType::csproj;
const std::string ProjectFileExtension =
- getProjectFileExtension(this->ProjectType);
+ computeProjectFileExtension(this->ProjectType);
if (this->ProjectType == VsProjectType::csproj &&
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
@@ -411,12 +418,10 @@ void cmVisualStudio10TargetGenerator::Generate()
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
BuildFileStream.write(magic, 3);
- if (this->ProjectType == VsProjectType::proj) {
- this->WriteZeroCheckProj(BuildFileStream);
- } else if (this->ProjectType == VsProjectType::csproj &&
- this->GeneratorTarget->IsDotNetSdkTarget() &&
- this->GlobalGenerator->GetVersion() >=
- cmGlobalVisualStudioGenerator::VSVersion::VS16) {
+ if (this->ProjectType == VsProjectType::csproj &&
+ this->GeneratorTarget->IsDotNetSdkTarget() &&
+ this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VSVersion::VS16) {
this->WriteSdkStyleProjectFile(BuildFileStream);
} else {
this->WriteClassicMsBuildProjectFile(BuildFileStream);
@@ -961,45 +966,6 @@ void cmVisualStudio10TargetGenerator::WriteSdkStyleProjectFile(
this->WriteProjectReferences(e0);
}
-void cmVisualStudio10TargetGenerator::WriteZeroCheckProj(
- cmGeneratedFileStream& BuildFileStream)
-{
- // ZERO_CHECK.proj is an XML file without any imports or targets. This is a
- // ProjectReference for other targets and therefore, it needs to follow the
- // ProjectReference protocol as documented here:
- // https://github.com/dotnet/msbuild/blob/main/documentation/ProjectReference-Protocol.md
- //
- // We implement MSBuild target Build from WriteCustomCommand which calls
- // WriteZeroCheckBuildTarget after setting up the command generator. MSBuild
- // target Clean is a no-op as we do all the work for ZERO_CHECK on Build.
- // MSBuild target GetTargetPath is needed and is no-op.
- // MSBuild targets GetNativeManifest and GetCopyToOutputDirectoryItems are
- // needed for MSBuild versions below 15.7 and are no-op. MSBuild target
- // BeforeBuild is needed for supporting GLOBs.
- BuildFileStream << "<?xml version=\"1.0\" encoding=\""
- << this->GlobalGenerator->Encoding() << "\"?>";
- {
- Elem e0(BuildFileStream, "Project");
- e0.Attribute("DefaultTargets", "Build");
- e0.Attribute("ToolsVersion", this->GlobalGenerator->GetToolsVersion());
- e0.Attribute("xmlns",
- "http://schemas.microsoft.com/developer/msbuild/2003");
-
- this->WriteCustomCommands(e0);
-
- for (const char* targetName :
- { "Clean", "GetTargetPath", "GetNativeManifest",
- "GetCopyToOutputDirectoryItems" }) {
- {
- Elem e1(e0, "Target");
- e1.Attribute("Name", targetName);
- }
- }
-
- this->WriteZeroCheckBeforeBuildTarget(e0);
- }
-}
-
void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
{
e1.Attribute("Label", "Globals");
@@ -1719,16 +1685,11 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
}
}
}
- if (this->ProjectType == VsProjectType::proj) {
- this->WriteZeroCheckBuildTarget(e0, command, source);
- return;
- }
-
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::unique_ptr<Elem> spe1;
std::unique_ptr<Elem> spe2;
- if (this->ProjectType == VsProjectType::vcxproj) {
+ if (this->ProjectType != VsProjectType::csproj) {
spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild");
this->WriteSource(*spe2, source);
@@ -1926,7 +1887,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
// Write out group file
std::string path = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->Name,
- this->ComputeProjectFileExtension(this->GeneratorTarget), ".filters");
+ computeProjectFileExtension(this->GeneratorTarget), ".filters");
cmGeneratedFileStream fout(path);
fout.SetCopyIfDifferent(true);
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
@@ -3081,134 +3042,6 @@ void cmVisualStudio10TargetGenerator::OutputLinkIncremental(
}
}
-void cmVisualStudio10TargetGenerator::WriteZeroCheckBuildTarget(
- cmVisualStudio10TargetGenerator::Elem& e0, const cmCustomCommand& command,
- const cmSourceFile* source)
-{
- cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
-
- Elem e1(e0, "Target");
- e1.Attribute("Name", "Build");
-
- std::string noConfig{};
- cmCustomCommandGenerator ccg{ command, noConfig, lg, true };
- std::string comment = lg->ConstructComment(ccg);
- comment = cmVS10EscapeComment(comment);
- std::string script = lg->ConstructScript(ccg);
- bool symbolic = false;
- // input files for custom command
- std::stringstream additional_inputs;
- {
- const char* sep = "";
- if (this->ProjectType == VsProjectType::proj) {
- // List explicitly the path to primary input.
- std::string sourceFullPath = source->GetFullPath();
- ConvertToWindowsSlash(sourceFullPath);
- additional_inputs << sourceFullPath;
- sep = ";";
- }
-
- // Avoid listing an input more than once.
- std::set<std::string> unique_inputs;
- // The source is either implicitly an input or has been added above.
- unique_inputs.insert(source->GetFullPath());
-
- for (std::string const& d : ccg.GetDepends()) {
- std::string dep;
- if (lg->GetRealDependency(d, noConfig, dep)) {
- if (!unique_inputs.insert(dep).second) {
- // already listed
- continue;
- }
- ConvertToWindowsSlash(dep);
- additional_inputs << sep << dep;
- sep = ";";
- if (!symbolic) {
- if (cmSourceFile* sf = this->Makefile->GetSource(
- dep, cmSourceFileLocationKind::Known)) {
- symbolic = sf->GetPropertyAsBool("SYMBOLIC");
- }
- }
- }
- }
- }
- // output files for custom command
- std::stringstream outputs;
- {
- const char* sep = "";
- for (std::string const& o : ccg.GetOutputs()) {
- std::string out = o;
- ConvertToWindowsSlash(out);
- outputs << sep << out;
- sep = ";";
- if (!symbolic) {
- if (cmSourceFile* sf =
- this->Makefile->GetSource(o, cmSourceFileLocationKind::Known)) {
- symbolic = sf->GetPropertyAsBool("SYMBOLIC");
- }
- }
- }
- }
- script += lg->FinishConstructScript(this->ProjectType);
-
- e1.Attribute("Inputs", cmVS10EscapeAttr(additional_inputs.str()));
- e1.Attribute("Outputs", cmVS10EscapeAttr(outputs.str()));
-
- e1.SetHasElements();
-
- if (!comment.empty()) {
- Elem(e1, "Message").Attribute("Text", comment);
- }
- Elem(e1, "Exec").Attribute("Command", script);
-}
-
-void cmVisualStudio10TargetGenerator::WriteZeroCheckBeforeBuildTarget(
- cmVisualStudio10TargetGenerator::Elem& e0)
-{
- const auto& commands = this->GeneratorTarget->GetPreBuildCommands();
- if (commands.empty()) {
- return;
- }
-
- {
- Elem e1(e0, "Target");
- e1.Attribute("Name", "BeforeBuild");
- e1.Attribute("BeforeTargets", "Build");
-
- cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
- std::string script;
- const char* pre = "";
- std::string comment;
- for (cmCustomCommand const& cc : commands) {
- cmCustomCommandGenerator ccg(cc, std::string{}, lg);
- if (!ccg.HasOnlyEmptyCommandLines()) {
- comment += pre;
- comment += lg->ConstructComment(ccg);
- script += pre;
- pre = "\n";
- script += lg->ConstructScript(ccg);
- }
- }
-
- if (script.empty()) {
- return;
- }
-
- script += lg->FinishConstructScript(this->ProjectType);
- comment = cmVS10EscapeComment(comment);
- std::string strippedComment = comment;
- strippedComment.erase(
- std::remove(strippedComment.begin(), strippedComment.end(), '\t'),
- strippedComment.end());
-
- e1.SetHasElements();
- if (!comment.empty() && !strippedComment.empty()) {
- Elem(e1, "Message").Attribute("Text", comment);
- }
- Elem(e1, "Exec").Attribute("Command", script);
- }
-}
-
std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes(
std::string const& config, std::string const& lang) const
{
@@ -4720,7 +4553,7 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
path = *p;
} else {
path = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', dt->GetName(),
- this->ComputeProjectFileExtension(dt));
+ computeProjectFileExtension(dt));
}
ConvertToWindowsSlash(path);
Elem e2(e1, "ProjectReference");
@@ -5574,26 +5407,6 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
return path;
}
-std::string cmVisualStudio10TargetGenerator::ComputeProjectFileExtension(
- cmGeneratorTarget const* t) const
-{
- return getProjectFileExtension(this->ComputeProjectType(t));
-}
-
-VsProjectType cmVisualStudio10TargetGenerator::ComputeProjectType(
- cmGeneratorTarget const* t) const
-{
- if (this->GlobalGenerator->GetVersion() >=
- cmGlobalVisualStudioGenerator::VSVersion::VS16 &&
- t->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
- return VsProjectType::proj;
- }
- if (t->IsCSharpOnly()) {
- return VsProjectType::csproj;
- }
- return VsProjectType::vcxproj;
-}
-
void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1)
{
if (this->GlobalGenerator->IsUtf8EncodingSupported()) {
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 7a0b8da..8d777a3 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -264,13 +264,6 @@ private:
void WriteClassicMsBuildProjectFile(cmGeneratedFileStream& BuildFileStream);
void WriteSdkStyleProjectFile(cmGeneratedFileStream& BuildFileStream);
- void WriteZeroCheckProj(cmGeneratedFileStream& BuildFileStream);
- void WriteZeroCheckBuildTarget(cmVisualStudio10TargetGenerator::Elem& e0,
- const cmCustomCommand& command,
- const cmSourceFile* source);
- void WriteZeroCheckBeforeBuildTarget(
- cmVisualStudio10TargetGenerator::Elem& e0);
-
void WriteCommonPropertyGroupGlobals(
cmVisualStudio10TargetGenerator::Elem& e1);
@@ -282,7 +275,4 @@ private:
void ParseSettingsProperty(const std::string& settingsPropertyValue,
ConfigToSettings& toolSettings);
std::string GetCMakeFilePath(const char* name) const;
-
- std::string ComputeProjectFileExtension(cmGeneratorTarget const* t) const;
- VsProjectType ComputeProjectType(cmGeneratorTarget const* t) const;
};
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index e6fa219..1c1cab3 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -405,9 +405,6 @@ void cmake::PrintPresetEnvironment()
// Parse the args
bool cmake::SetCacheArgs(const std::vector<std::string>& args)
{
- auto findPackageMode = false;
- auto seenScriptOption = false;
-
auto DefineLambda = [](std::string const& entry, cmake* state) -> bool {
std::string var;
std::string value;
@@ -498,10 +495,10 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
GetProjectCommandsInScriptMode(state->GetState());
// Documented behavior of CMAKE{,_CURRENT}_{SOURCE,BINARY}_DIR is to be
// set to $PWD for -P mode.
+ state->SetWorkingMode(SCRIPT_MODE);
state->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
state->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory());
state->ReadListFile(args, path);
- seenScriptOption = true;
return true;
};
@@ -565,12 +562,12 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
"No install directory specified for --install-prefix",
CommandArgument::Values::One, PrefixLambda },
CommandArgument{ "--find-package", CommandArgument::Values::Zero,
- CommandArgument::setToTrue(findPackageMode) },
+ IgnoreAndTrueLambda },
};
for (decltype(args.size()) i = 1; i < args.size(); ++i) {
std::string const& arg = args[i];
- if (arg == "--" && seenScriptOption) {
+ if (arg == "--" && this->GetWorkingMode() == SCRIPT_MODE) {
// Stop processing CMake args and avoid possible errors
// when arbitrary args are given to CMake script.
break;
@@ -585,7 +582,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
}
- if (findPackageMode) {
+ if (this->GetWorkingMode() == FIND_PACKAGE_MODE) {
return this->FindPackage(args);
}
@@ -790,7 +787,6 @@ void cmake::SetArgs(const std::vector<std::string>& args)
bool haveToolset = false;
bool havePlatform = false;
bool haveBArg = false;
- bool scriptMode = false;
std::string possibleUnknownArg;
std::string extraProvidedPath;
#if !defined(CMAKE_BOOTSTRAP)
@@ -873,7 +869,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
CommandArgument{ "-P", "-P must be followed by a file name.",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No,
- CommandArgument::setToTrue(scriptMode) },
+ IgnoreAndTrueLambda },
CommandArgument{ "-D", "-D must be followed with VAR=VALUE.",
CommandArgument::Values::One,
CommandArgument::RequiresSeparator::No,
@@ -1165,7 +1161,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
// iterate each argument
std::string const& arg = args[i];
- if (scriptMode && arg == "--") {
+ if (this->GetWorkingMode() == SCRIPT_MODE && arg == "--") {
// Stop processing CMake args and avoid possible errors
// when arbitrary args are given to CMake script.
break;
@@ -1211,12 +1207,12 @@ void cmake::SetArgs(const std::vector<std::string>& args)
}
}
- if (!extraProvidedPath.empty() && !scriptMode) {
+ if (!extraProvidedPath.empty() && this->GetWorkingMode() == NORMAL_MODE) {
this->IssueMessage(MessageType::WARNING,
cmStrCat("Ignoring extra path from command line:\n \"",
extraProvidedPath, "\""));
}
- if (!possibleUnknownArg.empty() && !scriptMode) {
+ if (!possibleUnknownArg.empty() && this->GetWorkingMode() != SCRIPT_MODE) {
cmSystemTools::Error(cmStrCat("Unknown argument ", possibleUnknownArg));
cmSystemTools::Error("Run 'cmake --help' for all supported options.");
exit(1);
@@ -1800,7 +1796,8 @@ void cmake::SetHomeDirectoryViaCommandLine(std::string const& path)
}
auto prev_path = this->GetHomeDirectory();
- if (prev_path != path && !prev_path.empty()) {
+ if (prev_path != path && !prev_path.empty() &&
+ this->GetWorkingMode() == NORMAL_MODE) {
this->IssueMessage(MessageType::WARNING,
cmStrCat("Ignoring extra path from command line:\n \"",
prev_path, "\""));
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 97c275e..f931e9d 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -207,7 +207,7 @@ int do_cmake(int ac, char const* const* av)
#ifndef CMAKE_BOOTSTRAP
cmDocumentation doc;
doc.addCMakeStandardDocSections();
- if (doc.CheckOptions(ac, av)) {
+ if (doc.CheckOptions(ac, av, "--")) {
// Construct and print requested documentation.
cmake hcm(cmake::RoleInternal, cmState::Unknown);
hcm.SetHomeDirectory("");