0

I write program in NASM and want use the cmake as a build engine.

At now I use it in the following way:

execute_process (
    COMMAND C:/NASM/x32/nasm.exe -f bin launch.asm -o ${CMAKE_CURRENT_BINARY_DIR}/Launch
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
)

But there are one issue: the build of the launch.asm happens all time even if it dont change. How to avoid it and hav build only if launch.as changed?

UPD1: as write vre below I make following cmake file -

CMAKE_MINIMUM_REQUIRED(VERSION 3.12.0)
project(Launch LANGUAGES ASM_NASM)

enable_language(ASM_NASM)
SET(ASM_DIALECT "-NASM")
set(CMAKE_ASM_NASM_FLAGS "-f bin")

add_executable(${PROJECT_NAME} launch.asm)
set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE NASM) 

I generate sources with following strings:

cmake .. -G"Visual Studio 15 2017"
cmake --build . --target ALL_BUILD

And I receive issues:

  1. When I generate source - there are appears following errors:

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_EXE_LINKER_FLAGS

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_EXE_LINKER_FLAGS_DEBUG

CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. ....

  1. NASM launch incorrectly - I want generate bin, but there are add win32

_NASM: Assembling launch.asm cmd.exe /D /C "C:\Users\AeroSun\AppData\Local\Temp\tmp0a9e10beedeb4b9986b66e79724488ee.cmd" "C:/NASM/x64/nasm.exe" -o Launch.dir\Debug\launch.obj -fwin32 -DCMAKE_INTDIR="Debug" -f bin "L:\DevProj\Astra\src\Ker nel\Launch\Ix86x64\launch.asm"

  1. Finally it generate .obj file and break on linkage step, but I need just bin file

Launch.dir\Debug\launch.obj : fatal error LNK1107

So the main question - can cmake work with assembler? If so is exist somewhere minimal workable example?

funnydman
  • 9,083
  • 4
  • 40
  • 55
AeroSun
  • 2,401
  • 2
  • 23
  • 46
  • 1
    ASM supported in CMake needs to be enabled. Try to add ASM to your project command `project(you_name_it LANGUAGES ASM)` and create an executable by `add_executable(Launch launch.asm)` in your CMakeLists.txt file. – vre Jan 04 '19 at 16:21
  • @vre, I update the initial post. I tried your suggestion - but it not works :( Do you have some minimal example? – AeroSun Jan 05 '19 at 12:01
  • Maybe this would work? https://stackoverflow.com/a/49134624/3857942 – Michael Petch Jan 08 '19 at 14:17

0 Answers0