summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorEvgeny Fimochkin <fimochkin@gmail.com>2017-01-27 12:31:50 (GMT)
committerBrad King <brad.king@kitware.com>2017-02-07 18:20:52 (GMT)
commit5ba2c9e5e08cb391c366065210a95a46ac74f310 (patch)
tree649d1bbb4922c4a195f7284c5eee0aba51d3f004 /Source
parent0f4dae0a4da92af5079eb730443ec188b3b46f8e (diff)
downloadCMake-5ba2c9e5e08cb391c366065210a95a46ac74f310.zip
CMake-5ba2c9e5e08cb391c366065210a95a46ac74f310.tar.gz
CMake-5ba2c9e5e08cb391c366065210a95a46ac74f310.tar.bz2
VS: Add support for ASM_NASM language
Fixes: #16469
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx14
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h2
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx1
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h2
-rw-r--r--Source/cmVS10NASMFlagTable.h50
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx105
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h9
-rw-r--r--Source/cmVisualStudio10ToolsetOptions.cxx1
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h1
9 files changed, 184 insertions, 1 deletions
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index e27615a..b64ae26 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -13,6 +13,7 @@
#include "cmVS10LibFlagTable.h"
#include "cmVS10LinkFlagTable.h"
#include "cmVS10MASMFlagTable.h"
+#include "cmVS10NASMFlagTable.h"
#include "cmVS10RCFlagTable.h"
#include "cmVisualStudioSlnData.h"
#include "cmVisualStudioSlnParser.h"
@@ -113,6 +114,7 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
this->DefaultLibFlagTable = cmVS10LibFlagTable;
this->DefaultLinkFlagTable = cmVS10LinkFlagTable;
this->DefaultMasmFlagTable = cmVS10MASMFlagTable;
+ this->DefaultNasmFlagTable = cmVS10NASMFlagTable;
this->DefaultRcFlagTable = cmVS10RCFlagTable;
this->Version = VS10;
}
@@ -354,6 +356,13 @@ void cmGlobalVisualStudio10Generator::Generate()
void cmGlobalVisualStudio10Generator::EnableLanguage(
std::vector<std::string> const& lang, cmMakefile* mf, bool optional)
{
+ for (std::vector<std::string>::const_iterator it = lang.begin();
+ it != lang.end(); ++it) {
+ if (*it == "ASM_NASM") {
+ this->NasmEnabled = true;
+ }
+ }
+ this->AddPlatformDefinitions(mf);
cmGlobalVisualStudio8Generator::EnableLanguage(lang, mf, optional);
}
@@ -663,3 +672,8 @@ cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetMasmFlagTable() const
return (table != CM_NULLPTR) ? table : this->DefaultMasmFlagTable;
}
+
+cmIDEFlagTable const* cmGlobalVisualStudio10Generator::GetNasmFlagTable() const
+{
+ return this->DefaultNasmFlagTable;
+}
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 5bfaf38..3fc62ec 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -96,6 +96,7 @@ public:
cmIDEFlagTable const* GetLibFlagTable() const;
cmIDEFlagTable const* GetLinkFlagTable() const;
cmIDEFlagTable const* GetMasmFlagTable() const;
+ cmIDEFlagTable const* GetNasmFlagTable() const;
protected:
virtual void Generate();
@@ -125,6 +126,7 @@ protected:
cmIDEFlagTable const* DefaultLibFlagTable;
cmIDEFlagTable const* DefaultLinkFlagTable;
cmIDEFlagTable const* DefaultMasmFlagTable;
+ cmIDEFlagTable const* DefaultNasmFlagTable;
cmIDEFlagTable const* DefaultRcFlagTable;
bool SystemIsWindowsCE;
bool SystemIsWindowsPhone;
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 602666e..65a0bde 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -47,6 +47,7 @@ cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false;
this->MasmEnabled = false;
+ this->NasmEnabled = false;
if (platformName.empty()) {
this->DefaultPlatformName = "Win32";
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 62194c3..1f96cc6 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -95,6 +95,7 @@ public:
/** Is the Microsoft Assembler enabled? */
bool IsMasmEnabled() const { return this->MasmEnabled; }
+ bool IsNasmEnabled() const { return this->NasmEnabled; }
// Encoding for Visual Studio files
virtual std::string Encoding();
@@ -163,6 +164,7 @@ protected:
std::string GeneratorPlatform;
std::string DefaultPlatformName;
bool MasmEnabled;
+ bool NasmEnabled;
private:
char* IntelProjectVersion;
diff --git a/Source/cmVS10NASMFlagTable.h b/Source/cmVS10NASMFlagTable.h
new file mode 100644
index 0000000..b91af92
--- /dev/null
+++ b/Source/cmVS10NASMFlagTable.h
@@ -0,0 +1,50 @@
+static cmVS7FlagTable cmVS10NASMFlagTable[] = {
+
+ // Enum Properties
+ { "Outputswitch", "fwin32", "", "0", 0 },
+ { "Outputswitch", "fwin", "", "0", 0 },
+ { "Outputswitch", "fwin64", "", "1", 0 },
+ { "Outputswitch", "felf", "", "2", 0 },
+ { "Outputswitch", "felf32", "", "2", 0 },
+ { "Outputswitch", "felf64", "", "3", 0 },
+
+ { "ErrorReportingFormat", "Xgnu", "", "-Xgnu GNU format: Default format",
+ 0 },
+ { "ErrorReportingFormat", "Xvc", "",
+ "-Xvc Style used by Microsoft Visual C++", 0 },
+
+ // Bool Properties
+ { "TreatWarningsAsErrors", "Werror", "", "true", 0 },
+ { "GenerateDebugInformation", "g", "", "true", 0 },
+ { "floatunderflow", "w+float-underflow", "", "true", 0 },
+ { "macrodefaults", "w-macro-defaults", "", "true", 0 },
+ { "user", "w-user", "%warning directives (default on)", "true", 0 },
+ { "floatoverflow", "w-float-overflow", "", "true", 0 },
+ { "floatdenorm", "w+float-denorm", "", "true", 0 },
+ { "numberoverflow", "w-number-overflow", "", "true", 0 },
+ { "macroselfref", "w+macro-selfref", "", "true", 0 },
+ { "floattoolong", "w-float-toolong", "", "true", 0 },
+ { "orphanlabels", "w-orphan-labels", "", "true", 0 },
+ { "tasmmode", "t", "", "true", 0 },
+
+ // Bool Properties With Argument
+
+ // String List Properties
+ { "PreprocessorDefinitions", "D", "Preprocessor Definitions", "",
+ cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+ { "UndefinePreprocessorDefinitions", "U",
+ "Undefine Preprocessor Definitions", "",
+ cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+ { "IncludePaths", "I", "Include Paths", "",
+ cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+ { "AssembledCodeListingFile", "l",
+ "Generates an assembled code listing file.", "",
+ cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable },
+
+ // String Properties
+ // Skip [Inputs] - no command line Switch.
+ // Skip [CommandLineTemplate] - no command line Switch.
+ // Skip [ExecutionDescription] - no command line Switch.
+ // Skip [AdditionalOptions] - no command line Switch.
+ { 0, 0, 0, 0, 0 }
+};
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 2e6c19b..a7edc95 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -10,6 +10,7 @@
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
+#include "cmSystemTools.h"
#include "cmVisualStudioGeneratorOptions.h"
#include "windows.h"
@@ -207,6 +208,9 @@ void cmVisualStudio10TargetGenerator::Generate()
if (!this->ComputeMasmOptions()) {
return;
}
+ if (!this->ComputeNasmOptions()) {
+ return;
+ }
if (!this->ComputeLinkOptions()) {
return;
}
@@ -454,6 +458,21 @@ void cmVisualStudio10TargetGenerator::Generate()
"BuildCustomizations\\masm.props\" />\n",
2);
}
+ if (this->GlobalGenerator->IsNasmEnabled()) {
+ // Always search in the standard modules location.
+ std::string propsTemplate =
+ GetCMakeFilePath("Templates/MSBuild/nasm.props.in");
+
+ std::string propsLocal;
+ propsLocal += this->DefaultArtifactDir;
+ propsLocal += "\\nasm.props";
+ this->ConvertToWindowsSlash(propsLocal);
+ this->Makefile->ConfigureFile(propsTemplate.c_str(), propsLocal.c_str(),
+ false, true, true);
+ std::string import = std::string("<Import Project=\"") +
+ cmVS10EscapeXML(propsLocal) + "\" />\n";
+ this->WriteString(import.c_str(), 2);
+ }
this->WriteString("</ImportGroup>\n", 1);
this->WriteString("<ImportGroup Label=\"PropertySheets\">\n", 1);
{
@@ -509,6 +528,13 @@ void cmVisualStudio10TargetGenerator::Generate()
"BuildCustomizations\\masm.targets\" />\n",
2);
}
+ if (this->GlobalGenerator->IsNasmEnabled()) {
+ std::string nasmTargets =
+ GetCMakeFilePath("Templates/MSBuild/nasm.targets");
+ std::string import = "<Import Project=\"";
+ import += cmVS10EscapeXML(nasmTargets) + "\" />\n";
+ this->WriteString(import.c_str(), 2);
+ }
this->WriteString("</ImportGroup>\n", 1);
if (csproj == this->ProjectType) {
for (std::vector<std::string>::const_iterator i =
@@ -1719,6 +1745,8 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
tool = "ClCompile";
} else if (lang == "ASM_MASM" && this->GlobalGenerator->IsMasmEnabled()) {
tool = "MASM";
+ } else if (lang == "ASM_NASM" && this->GlobalGenerator->IsNasmEnabled()) {
+ tool = "NASM";
} else if (lang == "RC") {
tool = "ResourceCompile";
} else if (lang == "CSharp") {
@@ -2431,6 +2459,71 @@ void cmVisualStudio10TargetGenerator::WriteMasmOptions(
this->WriteString("</MASM>\n", 2);
}
+bool cmVisualStudio10TargetGenerator::ComputeNasmOptions()
+{
+ if (!this->GlobalGenerator->IsNasmEnabled()) {
+ return true;
+ }
+ for (std::vector<std::string>::const_iterator i =
+ this->Configurations.begin();
+ i != this->Configurations.end(); ++i) {
+ if (!this->ComputeNasmOptions(*i)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool cmVisualStudio10TargetGenerator::ComputeNasmOptions(
+ std::string const& configName)
+{
+ cmGlobalVisualStudio10Generator* gg =
+ static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
+ CM_AUTO_PTR<Options> pOptions(new Options(
+ this->LocalGenerator, Options::NasmCompiler, gg->GetNasmFlagTable()));
+ Options& nasmOptions = *pOptions;
+
+ std::string CONFIG = cmSystemTools::UpperCase(configName);
+ std::string configFlagsVar = std::string("CMAKE_ASM_NASM_FLAGS_") + CONFIG;
+ std::string flags =
+ std::string(this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_FLAGS")) +
+ std::string(" -f") + std::string(this->Makefile->GetSafeDefinition(
+ "CMAKE_ASM_NASM_OBJECT_FORMAT")) +
+ std::string(" ") +
+ std::string(this->Makefile->GetSafeDefinition(configFlagsVar));
+ nasmOptions.Parse(flags.c_str());
+ this->NasmOptions[configName] = pOptions.release();
+ return true;
+}
+
+void cmVisualStudio10TargetGenerator::WriteNasmOptions(
+ std::string const& configName, std::vector<std::string> includes)
+{
+ if (!this->GlobalGenerator->IsNasmEnabled()) {
+ return;
+ }
+ this->WriteString("<NASM>\n", 2);
+
+ Options& nasmOptions = *(this->NasmOptions[configName]);
+ for (size_t i = 0; i < includes.size(); i++) {
+ includes[i] += "\\";
+ }
+
+ nasmOptions.AppendFlag("IncludePaths", includes);
+ nasmOptions.AppendFlag("IncludePaths", "%(IncludePaths)");
+ nasmOptions.OutputFlagMap(*this->BuildFileStream, " ");
+ nasmOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
+ nasmOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ "\n", "ASM_NASM");
+
+ // Preprocessor definitions and includes are shared with clOptions.
+ Options& clOptions = *(this->ClOptions[configName]);
+ clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
+ "\n", "ASM_NASM");
+
+ this->WriteString("</NASM>\n", 2);
+}
+
void cmVisualStudio10TargetGenerator::WriteLibOptions(
std::string const& config)
{
@@ -3062,6 +3155,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups()
// output rc compile flags <ResourceCompile></ResourceCompile>
this->WriteRCOptions(*i, includes);
this->WriteMasmOptions(*i, includes);
+ this->WriteNasmOptions(*i, includes);
}
// output midl flags <Midl></Midl>
this->WriteMidlOptions(*i, includes);
@@ -3988,3 +4082,14 @@ bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const
CloseHandle(h);
return true;
}
+
+std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
+ const char* relativeFilePath) const
+{
+ // Always search in the standard modules location.
+ std::string path = cmSystemTools::GetCMakeRoot() + "/";
+ path += relativeFilePath;
+ this->ConvertToWindowsSlash(path);
+
+ return path;
+}
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 45464c0..0ebb4e4 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -51,7 +51,7 @@ private:
};
std::string ConvertPath(std::string const& path, bool forceRelative);
- void ConvertToWindowsSlash(std::string& s);
+ static void ConvertToWindowsSlash(std::string& s);
void WriteString(const char* line, int indentLevel);
void WriteProjectConfigurations();
void WriteProjectConfigurationValues();
@@ -102,6 +102,11 @@ private:
bool ComputeMasmOptions(std::string const& config);
void WriteMasmOptions(std::string const& config,
std::vector<std::string> const& includes);
+ bool ComputeNasmOptions();
+ bool ComputeNasmOptions(std::string const& config);
+ void WriteNasmOptions(std::string const& config,
+ std::vector<std::string> includes);
+
bool ComputeLinkOptions();
bool ComputeLinkOptions(std::string const& config);
bool ComputeLibOptions();
@@ -146,6 +151,7 @@ private:
OptionsMap ClOptions;
OptionsMap RcOptions;
OptionsMap MasmOptions;
+ OptionsMap NasmOptions;
OptionsMap LinkOptions;
std::string PathToProjectFile;
std::string ProjectFileExtension;
@@ -177,6 +183,7 @@ private:
typedef std::map<std::string, ToolSources> ToolSourceMap;
ToolSourceMap Tools;
+ std::string GetCMakeFilePath(const char* name) const;
};
#endif
diff --git a/Source/cmVisualStudio10ToolsetOptions.cxx b/Source/cmVisualStudio10ToolsetOptions.cxx
index afca216..0f15ec4 100644
--- a/Source/cmVisualStudio10ToolsetOptions.cxx
+++ b/Source/cmVisualStudio10ToolsetOptions.cxx
@@ -11,6 +11,7 @@
#include "cmVS10LibFlagTable.h"
#include "cmVS10LinkFlagTable.h"
#include "cmVS10MASMFlagTable.h"
+#include "cmVS10NASMFlagTable.h"
#include "cmVS10RCFlagTable.h"
#include "cmVS11CLFlagTable.h"
#include "cmVS11CSharpFlagTable.h"
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index ab6b8cc..3a53ff5 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -27,6 +27,7 @@ public:
Compiler,
ResourceCompiler,
MasmCompiler,
+ NasmCompiler,
Linker,
FortranCompiler,
CSharpCompiler