未设置CMake编译器

sqxo8psd  于 2023-02-23  发布在  其他
关注(0)|答案(3)|浏览(266)

CMake错误:未在EnableLanguage之后设置CMAKE_Project_COMPILER
写入cmake ..后出现此错误
这是我的CMakeLists.txt

set(CMAKE_CXX_COMPILER "C:/mingw64/bin/g++")
set(CMAKE_C_COMPILER "C:/mingw64/bin/gcc")

project(CXX Project)

add_subdirectory(glfw/)

add_executable(${PROJECT_NAME} Main.cpp)
target_include_directories(${PROJECT_NAME} PUBLIC glfw)
target_link_libraries(${PROJECT_NAME} PUBLIC glfw)```

And this is my Complete Error
PS C:\Users\david\Documents\Idle\Project\build> cmake ..
CMake Error at CMakeLists.txt:6 (project):
  Running

   'nmake' '-?'

  failed with:

   Das System kann die angegebene Datei nicht finden

CMake Error: CMAKE_Project_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/david/Documents/Idle/Project/build/CMakeFiles/CMakeOutput.log".
bvpmtnay

bvpmtnay1#

您使用the project command的方式不对。它应该是

project(Project CXX)

这就是为什么CMake正在寻找CMAKE_Project_COMPILER而不是CMAKE_CXX_COMPILER

jq6vz3qz

jq6vz3qz2#

正如您在错误消息cmake正在尝试为nmake生成生成文件,该生成文件是Visual Studio生成系统。您尝试安装的是基于makefile的带有mingw的生成系统。因此,您应直接指定生成器:

cmake .. -G "MinGW Makefiles"
kxkpmulp

kxkpmulp3#

对于“CMake错误:在启用语言”“之后未设置CMAKE_Project_COMPILER
另一个可能的问题是,我们需要在c:\users\xxx中执行cmake,但无法在c:\xxxx中执行

相关问题