From 24bcad5bace42f4ec8ce8d3bc5994581918f81c5 Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 26 Jan 2023 12:57:53 -0500 Subject: VS: Honor compile options for ASM_NASM The Ninja and Makefile generators honor `target_compile_options` and friends for ASM_NASM `.asm` sources. Teach the VS generator to honor them too for consistency. Issue: #24289 --- Source/cmVisualStudio10TargetGenerator.cxx | 2 ++ Templates/MSBuild/nasm.targets | 2 +- Tests/VSNASM/CMakeLists.txt | 2 ++ Tests/VSNASM/foo.asm | 6 +++++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 857b289..c88679c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -3930,6 +3930,8 @@ bool cmVisualStudio10TargetGenerator::ComputeNasmOptions( this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, cmBuildStep::Compile, "ASM_NASM", configName); + this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, + "ASM_NASM", configName); flags += " -f"; flags += this->Makefile->GetSafeDefinition("CMAKE_ASM_NASM_OBJECT_FORMAT"); nasmOptions.Parse(flags); diff --git a/Templates/MSBuild/nasm.targets b/Templates/MSBuild/nasm.targets index eeeb613..ba12085 100644 --- a/Templates/MSBuild/nasm.targets +++ b/Templates/MSBuild/nasm.targets @@ -30,7 +30,7 @@ - + diff --git a/Tests/VSNASM/CMakeLists.txt b/Tests/VSNASM/CMakeLists.txt index 821d022..a038ddd 100644 --- a/Tests/VSNASM/CMakeLists.txt +++ b/Tests/VSNASM/CMakeLists.txt @@ -18,3 +18,5 @@ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm" "${BAR_ASM_CONTENTS}") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) add_executable(VSNASM main.c foo.asm "${CMAKE_CURRENT_BINARY_DIR}/bar baz.asm") +target_compile_definitions(VSNASM PRIVATE DEF_FOO) +target_compile_options(VSNASM PRIVATE "$<$:-t>") diff --git a/Tests/VSNASM/foo.asm b/Tests/VSNASM/foo.asm index aba0673..cbfe14b 100644 --- a/Tests/VSNASM/foo.asm +++ b/Tests/VSNASM/foo.asm @@ -1,7 +1,11 @@ +%ifndef DEF_FOO +%error "DEF_FOO incorrectly not defined" +%endif section .text %ifdef TEST2x64 global foo %else global _foo %endif -%include "foo-proc.asm" +;TASM compatibility mode allows 'include' instead of '%include' +include "foo-proc.asm" -- cgit v0.12