windows - 在 CLion 中组装 .asm 文件时出现 CMake 问题
问题描述
我正在尝试在 Clion 上运行 .asm 文件,并且我已经为其安装了 NASM,但是我在指定 ASM 编译器时遇到了问题:
CMake Error at CMakeLists.txt:4 (enable_language):
The CMAKE_ASM_NASM_COMPILER:
C:/Users/User/AppData/Local/bin/NASM
is not a full path to an existing compiler tool.
Tell CMake where to find the compiler by setting either the environment
variable "ASM_NASM" or the CMake cache entry CMAKE_ASM_NASM_COMPILER to the
full path to the compiler, or to the compiler name if it is in the PATH.
mingw32-make.exe: *** [Makefile:175: cmake_check_build_system] Error 1
-- The ASM_NASM compiler identification is unknown
-- Found assembler: C:/Users/User/AppData/Local/bin/NASM
-- Configuring incomplete, errors occurred!
问题在于这个“完整路径”,但我不太明白它的含义。这是我的 CMakeLists.txt :
cmake_minimum_required(VERSION 3.17)
project(untitled C)
set(CMAKE_ASM_NASM_COMPILER C:/Users/User/AppData/Local/bin/NASM)
enable_language(ASM_NASM)
set(ASM_SOURCES
test.asm)
set(SOURCES
${ASM_SOURCES})
set_source_files_properties(test.asm PROPERTIES LANGUAGE ASM_NASM)
add_executable(program ${SOURCES})
我在这里也读过类似的问题(但关于 C/C++ 编译器),它们对我的情况并没有真正的帮助。
谢谢你的回答!
解决方案
解决方案(使用Compile ASM 和 C with ASM 进行调试):
cmake_minimum_required(VERSION 3.17)
project(untitled ASM)
enable_language(ASM_NASM)
set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> \
<FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_ASM_NASM_FLAGS "${ASM_NASM_FLAGS} -g")
else()
set(CMAKE_ASM_NASM_FLAGS "${ASM_NASM_FLAGS}")
endif()
set_source_files_properties(test.asm PROPERTIES LANGUAGE ASM_NASM)
add_executable(program test.asm)
推荐阅读
- windows - 管理中心 powershell:应用程序无法正确启动
- javascript - 如何检查脚本是否运行完毕
- javascript - 为什么 toString 总是在严格模式下运行?
- javascript - JS文件未将元素插入HTML文件
- excel - 查找和替换不适用于宏,不适用于一般和文本格式
- python - 将 json 对象转换为 pyspark 数据框
- amazon-web-services - 使用 Elemental MediaPackage 在 aws 上继续观看存储视频的功能
- ruby - 如何在 ruby 中抓取输入框的值?
- android - KOTLIN 中 mvvm 结构中的折线图
- powershell - 使用数组作为哈希表中的键