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:
- 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. ....
- 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"
- 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?