我在windows上安装了CMake,除了gcc和g++编译器之外,我还将变量添加到路径中,但是仍然得到以下错误,请帮助。
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:6 (project):
Running
'nmake' '-?'
failed with:
The system cannot find the file specified
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
See also "C:/Users/DEANHOS/Desktop/peer/cmake tutorial/codeAndTech/sample/CMakeFiles/CMakeOutput.log".
发布于 2021-12-29 19:38:53
这些变量需要在命令行中传递,如下所示:
$ cmake -DCMAKE_CXX_COMPILER=/pathto/g++ -DCMAKE_C_COMPILER=/pathto/gcc /pathto/source
或者在project()
行之前设置为CMakeLists.txt:
set( CMAKE_CXX_COMPILER "/pathto/g++" )
set( CMAKE_C_COMPILER "/pathto/gcc" )
project(mytest)
...
或者将-C <toolchain>
命令作为
# mygcc.cmake
# toolchain file
set( CMAKE_CXX_COMPILER "/pathto/g++" )
set( CMAKE_C_COMPILER "/pathto/gcc" )
$ cmake -C /pathto/mygcc.cmake /pathto/source
https://stackoverflow.com/questions/70524164
复制相似问题