【问题标题】:CMake problem while assembling .asm files in CLion在 CLion 中组装 .asm 文件时出现 CMake 问题
【发布时间】:2021-03-16 20:08:38
【问题描述】:

我正在尝试在 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++ 编译器),它们对我的情况并没有真正的帮助。

感谢您的回答!

【问题讨论】:

    标签: windows assembly cmake nasm clion


    【解决方案1】:

    解决方案(使用Compile ASM and C with ASM for debugging):

    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)
    

    【讨论】:

      猜你喜欢
      • 2016-03-01
      • 1970-01-01
      • 2021-01-14
      • 1970-01-01
      • 1970-01-01
      • 2011-07-31
      • 1970-01-01
      • 2020-07-25
      • 1970-01-01
      相关资源
      最近更新 更多