From 5ba2c9e5e08cb391c366065210a95a46ac74f310 Mon Sep 17 00:00:00 2001 From: Evgeny Fimochkin Date: Fri, 27 Jan 2017 19:31:50 +0700 Subject: VS: Add support for ASM_NASM language Fixes: #16469 --- Help/release/dev/vs-nasm.rst | 5 ++ Modules/CMakeDetermineASMCompiler.cmake | 8 ++ Modules/CMakeDetermineASM_NASMCompiler.cmake | 17 ++++- Source/cmGlobalVisualStudio10Generator.cxx | 14 ++++ Source/cmGlobalVisualStudio10Generator.h | 2 + Source/cmGlobalVisualStudio7Generator.cxx | 1 + Source/cmGlobalVisualStudio7Generator.h | 2 + Source/cmVS10NASMFlagTable.h | 50 ++++++++++++ Source/cmVisualStudio10TargetGenerator.cxx | 105 +++++++++++++++++++++++++ Source/cmVisualStudio10TargetGenerator.h | 9 ++- Source/cmVisualStudio10ToolsetOptions.cxx | 1 + Source/cmVisualStudioGeneratorOptions.h | 1 + Templates/MSBuild/nasm.props.in | 17 +++++ Templates/MSBuild/nasm.targets | 41 ++++++++++ Templates/MSBuild/nasm.xml | 110 +++++++++++++++++++++++++++ Tests/CMakeLists.txt | 7 +- Tests/VSNASM/CMakeLists.txt | 10 +++ Tests/VSNASM/foo.asm | 7 ++ Tests/VSNASM/include/foo-proc.asm | 7 ++ Tests/VSNASM/main.c | 5 ++ 20 files changed, 415 insertions(+), 4 deletions(-) create mode 100644 Help/release/dev/vs-nasm.rst create mode 100644 Source/cmVS10NASMFlagTable.h create mode 100644 Templates/MSBuild/nasm.props.in create mode 100644 Templates/MSBuild/nasm.targets create mode 100644 Templates/MSBuild/nasm.xml create mode 100644 Tests/VSNASM/CMakeLists.txt create mode 100644 Tests/VSNASM/foo.asm create mode 100644 Tests/VSNASM/include/foo-proc.asm create mode 100644 Tests/VSNASM/main.c diff --git a/Help/release/dev/vs-nasm.rst b/Help/release/dev/vs-nasm.rst new file mode 100644 index 0000000..bb082a4 --- /dev/null +++ b/Help/release/dev/vs-nasm.rst @@ -0,0 +1,5 @@ +vs-nasm +------- + +* :ref:`Visual Studio Generators` for VS 2010 and above learned to support + the ``ASM_NASM`` language when ``nasm`` is installed. diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake index 4162726..66bf14b 100644 --- a/Modules/CMakeDetermineASMCompiler.cmake +++ b/Modules/CMakeDetermineASMCompiler.cmake @@ -92,6 +92,14 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_ARMCC ) set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_ARMCC "(ARM Compiler)|(ARM Assembler)") + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS NASM) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_NASM "-v") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_NASM "(NASM version)") + + list(APPEND CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDORS YASM) + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_FLAGS_YASM "--version") + set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_REGEX_YASM "(yasm)") + include(CMakeDetermineCompilerId) CMAKE_DETERMINE_COMPILER_ID_VENDOR(ASM${ASM_DIALECT}) diff --git a/Modules/CMakeDetermineASM_NASMCompiler.cmake b/Modules/CMakeDetermineASM_NASMCompiler.cmake index 4c8e422..dd75310 100644 --- a/Modules/CMakeDetermineASM_NASMCompiler.cmake +++ b/Modules/CMakeDetermineASM_NASMCompiler.cmake @@ -7,8 +7,21 @@ set(CMAKE_ASM_NASM_COMPILER_LIST nasm yasm) if(NOT CMAKE_ASM_NASM_COMPILER) - find_program(CMAKE_ASM_NASM_COMPILER nasm - "$ENV{ProgramFiles}/NASM") + set(_CMAKE_ENV_VARX86 "ProgramFiles(x86)") + set(_CMAKE_ASM_NASM_COMPILER_PATHS + "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]" + "$ENV{ProgramFiles}/NASM" + "$ENV{${ENV_VARX86}}/NASM" + "$ENV{LOCALAPPDATA}/NASM" + ) + find_program(CMAKE_ASM_NASM_COMPILER + NAMES ${CMAKE_ASM_NASM_COMPILER_LIST} + PATHS ${_CMAKE_ASM_NASM_COMPILER_PATHS} + NO_DEFAULT_PATH + DOC "NASM compiler" + ) + unset(_CMAKE_ENV_VARX86) + unset(_CMAKE_ASM_NASM_COMPILER_PATHS) endif() # Load the generic DetermineASM compiler file with the DIALECT set properly: 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 const& lang, cmMakefile* mf, bool optional) { + for (std::vector::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("\n"; + this->WriteString(import.c_str(), 2); + } this->WriteString("\n", 1); this->WriteString("\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 = "\n"; + this->WriteString(import.c_str(), 2); + } this->WriteString("\n", 1); if (csproj == this->ProjectType) { for (std::vector::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("\n", 2); } +bool cmVisualStudio10TargetGenerator::ComputeNasmOptions() +{ + if (!this->GlobalGenerator->IsNasmEnabled()) { + return true; + } + for (std::vector::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(this->GlobalGenerator); + CM_AUTO_PTR 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 includes) +{ + if (!this->GlobalGenerator->IsNasmEnabled()) { + return; + } + this->WriteString("\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("\n", 2); +} + void cmVisualStudio10TargetGenerator::WriteLibOptions( std::string const& config) { @@ -3062,6 +3155,7 @@ void cmVisualStudio10TargetGenerator::WriteItemDefinitionGroups() // output rc compile flags this->WriteRCOptions(*i, includes); this->WriteMasmOptions(*i, includes); + this->WriteNasmOptions(*i, includes); } // output midl flags 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 const& includes); + bool ComputeNasmOptions(); + bool ComputeNasmOptions(std::string const& config); + void WriteNasmOptions(std::string const& config, + std::vector 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 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 diff --git a/Templates/MSBuild/nasm.props.in b/Templates/MSBuild/nasm.props.in new file mode 100644 index 0000000..3443108 --- /dev/null +++ b/Templates/MSBuild/nasm.props.in @@ -0,0 +1,17 @@ + + + + Midl + CustomBuild + + + + $(IntDir)%(FileName).obj + 0 + @CMAKE_ASM_NASM_COMPILER@ + 0 + "%(CompilerNasm)" [AllOptions] [AdditionalOptions] "%(FullPath)" + Assembling %(Filename)%(Extension) + + + diff --git a/Templates/MSBuild/nasm.targets b/Templates/MSBuild/nasm.targets new file mode 100644 index 0000000..eeeb613 --- /dev/null +++ b/Templates/MSBuild/nasm.targets @@ -0,0 +1,41 @@ + + + + + + _NASM + + + + + $(ComputeLinkInputsTargets); + ComputeNASMOutput; + + + $(ComputeLibInputsTargets); + ComputeNASMOutput; + + + + $(MSBuildThisFileDirectory)$(MSBuildThisFileName).xml + + + + + + + + @(NASM, '|') + + + + + + + + + + + + + diff --git a/Templates/MSBuild/nasm.xml b/Templates/MSBuild/nasm.xml new file mode 100644 index 0000000..92f8548 --- /dev/null +++ b/Templates/MSBuild/nasm.xml @@ -0,0 +1,110 @@ + + + + + + + + + + General + + + + + Preprocessing Options + + + + + Assembler Options + + + + + Advanced + + + + + Command Line + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Execute Before + + + Specifies the targets for the build customization to run before. + + + + + + + + + + + Execute After + + + Specifies the targets for the build customization to run after. + + + + + + + + + + + + + Additional Options + + + Additional Options + + + + + + + diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 4945b31..910ff39 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2043,7 +2043,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release set(reg_wp81 "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\WindowsPhone\\v8.1;InstallationFolder]") select_wince_sdk(reg_wince wince_sdk) set(reg_tegra "[HKEY_LOCAL_MACHINE\\SOFTWARE\\NVIDIA Corporation\\Nsight Tegra;sdkRoot]") - foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra) + set(reg_nasm "[HKEY_CURRENT_USER\\SOFTWARE\\nasm]") + foreach(reg vs10 vs11 vs12 vs14 ws80 ws81 ws10_0 wp80 wp81 wince tegra nasm) get_filename_component(r "${reg_${reg}}" ABSOLUTE) if(IS_DIRECTORY "${r}") set(${reg} 1) @@ -2134,6 +2135,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release endif() endif() + if(CMAKE_GENERATOR MATCHES "Visual Studio ([^789]|[789][0-9])" AND nasm) + ADD_TEST_MACRO(VSNASM VSNASM) + endif() + if (CMake_TEST_GreenHillsMULTI) macro(add_test_GhsMulti name primaryTarget bspName) add_test(NAME GhsMulti.${name} COMMAND ${CMAKE_CTEST_COMMAND} diff --git a/Tests/VSNASM/CMakeLists.txt b/Tests/VSNASM/CMakeLists.txt new file mode 100644 index 0000000..c2e29df --- /dev/null +++ b/Tests/VSNASM/CMakeLists.txt @@ -0,0 +1,10 @@ +cmake_minimum_required(VERSION 2.8.12) +project(VSNASM C ASM_NASM) +if(CMAKE_SIZEOF_VOID_P EQUAL 8) + add_definitions(-DTESTx64) + string(APPEND CMAKE_ASM_NASM_FLAGS " -DTEST2x64") +else() + add_definitions(-DTESTi386) +endif() +include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +add_executable(VSNASM main.c foo.asm) diff --git a/Tests/VSNASM/foo.asm b/Tests/VSNASM/foo.asm new file mode 100644 index 0000000..aba0673 --- /dev/null +++ b/Tests/VSNASM/foo.asm @@ -0,0 +1,7 @@ +section .text +%ifdef TEST2x64 +global foo +%else +global _foo +%endif +%include "foo-proc.asm" diff --git a/Tests/VSNASM/include/foo-proc.asm b/Tests/VSNASM/include/foo-proc.asm new file mode 100644 index 0000000..450a791 --- /dev/null +++ b/Tests/VSNASM/include/foo-proc.asm @@ -0,0 +1,7 @@ +%ifdef TESTx64 +foo: +%else +_foo: +%endif + mov eax, 0 + ret diff --git a/Tests/VSNASM/main.c b/Tests/VSNASM/main.c new file mode 100644 index 0000000..18ddb78 --- /dev/null +++ b/Tests/VSNASM/main.c @@ -0,0 +1,5 @@ +extern int foo(void); +int main(void) +{ + return foo(); +} -- cgit v0.12