首页 > 解决方案 > 尝试通过 CMake 构建项目时出错

问题描述

我正在尝试通过 CMake 构建项目,几天前这个过程运行良好,但今天我在命令后收到错误 cmake -G "NMake Makefiles" ..

CMake Error at CMakeLists.txt:8 (project):
  Running

   'nmake' '-?'

  failed with:

   The system cannot find the specified file 


-- Configuring incomplete, errors occurred!

我正在使用 Visual Studio Code,项目文件夹的名称是“ADC_read”,我的 CMakeLists.txt 文件是:

# Set minimum required version of CMake
cmake_minimum_required(VERSION 3.12)

# Include build functions from Pico SDK
include($ENV{PICO_SDK_PATH}/external/pico_sdk_import.cmake)

# Set name of project (as PROJECT_NAME) and C/C   standards
project(ADC_read C CXX ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)

# Creates a pico-sdk subdirectory in our project for the libraries
pico_sdk_init()

# Tell CMake where to find the executable source file
add_executable(${PROJECT_NAME} 
    main.c
)

# Create map/bin/hex/uf2 files
pico_add_extra_outputs(${PROJECT_NAME})

# Link to pico_stdlib (gpio, time, etc. functions)
target_link_libraries(${PROJECT_NAME} 
    pico_stdlib adc_read hardware_adc
)


# Enable usb output, disable uart output
pico_enable_stdio_usb(${PROJECT_NAME} 1)
pico_enable_stdio_uart(${PROJECT_NAME} 0)

有谁知道哪里有问题?

==========================% 编辑 %===================== ========== 半解决...

所以我仍然无法从Visual Studio Code构建项目(VSC 找不到 nmake),但是从VS 命令提示符构建项目工作正常,所以我会坚持下去。

标签: cmake

解决方案


推荐阅读