I have a modular boot loader i'm toying with. I felt it would be more of a pain setting it up to use gas than to port nasm to cmake. It seems not to be that way. NAsm is unable to find the include file. What am I missing?
The entire code can be found in This Github Repo
Here is the project layout:
.
├── CMakeLists.txt
└── Failing_module
├── CMakeLists.txt
├── Print.inc
└── Stage1
└── Stage1.asm
./CMakeLists.txt:
cmake_minimum_required(VERSION 3.6)
project(fails C ASM_NASM)
add_subdirectory(Failing_module)
Failing_module/CMakeLists.txt:
enable_language(ASM_NASM)
set(CMAKE_ASM_NASM_OBJECT_FORMAT bin)
set(module_SRCS Stage1/Stage1.asm)
set(CMAKE_NASM_LINK_EXECUTABLE nasm)
add_executable(Stage1.bin ${module_SRCS})
set_target_properties(Stage1.bin PROPERTIES LINKER_LANGUAGE NASM)
install(TARGETS Stage1.bin DESTINATION bin)
Failing_module/Stage1/Stage1.asm:
bits 16
jmp main
%include "Print.inc"
msgHello db "Hello World", 0x00
main:
mov s, msgHello
call Print
Failing_module/Print.inc
Print:
lodsb
or al, al
jz PrintDone
mov ah, 0x0E
int 0x10
jmp Print
PrintDone:
ret
The output of cmake is the following:
Failing_module/Stage1/Stage1.asm:6: fatal: unable to open include file `Print.inc'
make[2]: *** [Failing_module/CMakeFiles/Stage1.bin.dir/build.make:63: Failing_module/CMakeFiles/Stage1.bin.dir/Stage1/Stage1.asm.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:86: Failing_module/CMakeFiles/Stage1.bin.dir/all] Error 2
make: *** [Makefile:128: all] Error 2
EDIT Should compile by manual means now. This makes it a SSCCE
I believe the problem here is that some strictness in CMake interacts poorly with a flaw in NASM. CMake insists that search paths (such as %include
paths) do not have a trailing slash. nasm
insists that search paths (given with a -I
option) do have a trailing slash. CMake won't be changed; its developers do not regard this as a CMake bug. They are right: nasm
should not insist that include paths have a trailing slash. The nasm
fault has been known for several years.
I managed to work around this issue by hiding the search path as a normal compile option:
add_compile_options(-I ${CMAKE_CURRENT_SOURCE_DIR}/ )
add_library( my_lib STATIC "my_source.asm" )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With