为什么nasm找不到cmake的include语句
我有一个正在使用的模块化引导加载程序.我觉得将其设置为使用气体比将nasm移植到cmake更加痛苦.似乎不是那样.NAsm无法找到包含文件.我想念什么?
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?
完整代码可在此Github存储库
这是项目布局:
.
├── CMakeLists.txt
└── Failing_module
├── CMakeLists.txt
├── Print.inc
└── Stage1
└── Stage1.asm
./CMakeLists.txt:
./CMakeLists.txt:
cmake_minimum_required(VERSION 3.6)
project(fails C ASM_NASM)
add_subdirectory(Failing_module)
Failing_module/CMakeLists.txt:
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:
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
Failing_module/Print.inc
Print:
lodsb
or al, al
jz PrintDone
mov ah, 0x0E
int 0x10
jmp Print
PrintDone:
ret
cmake的输出如下:
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 现在应通过手动方式进行编译.这使其成为SSCCE
EDIT Should compile by manual means now. This makes it a SSCCE
我相信这里的问题是CMake中的某些严格性与NASM中的缺陷相互作用不佳.CMake坚称搜索路径(例如%include
路径)不带斜杠. nasm
坚持认为搜索路径(带 -I
选项)的末尾有斜杠.CMake不会被更改;其开发人员不会将其视为CMake错误.它们是正确的: nasm
不应该坚持包含路径带有斜杠. nasm
故障已经有好几年了
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" )