CMake Error: CMAKE_Project_COMPILER not set, after EnableLanguage
I Get this Error after writing cmake ..
This is my 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".
CodePudding user response:
You're using the project
command in the wrong way. It should be
project(Project CXX)
That's why CMake is looking for CMAKE_Project_COMPILER
instead of CMAKE_CXX_COMPILER
.
CodePudding user response:
As you can see in your error message cmake
is trying to generate build files for nmake
, the visual studio build system. What you are trying to setup is a makefile
based build system with mingw
. Therefore you should specify the generator directly:
cmake .. -G "MinGW Makefiles"