在Windows 10上,安装了msys2,这是mingw的一个变种,我安装了一个带有gcc工具链的cmake和所有标准工具,比如make。
g ++的版本是6.2,make是4.2.1。两者都在路径中。
当我使用cmake构建时:
cmake .
它尝试使用nmake和cl构建。所以不知何故,因为我在Windows上cmake正在尝试使用visual studio工具链。
export CMAKE_CXX_COMPILER=g++
无济于事。错误是:
-- Building for: NMake Makefiles
-- The C compiler identification is unknown
-- The CXX compiler identification is Clang 3.8.0
-- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe
CMake Error: Generator: execution of make failed. Make command was: "nmake" "/NOLOGO" "cmTC_87e5f\fast"
-- Check for working C compiler: D:/msys64/mingw64/bin/clang++.exe -- broken
CMake Error at D:/msys64/mingw64/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "D:/msys64/mingw64/bin/clang++.exe" is not able to compile a
simple test program.
It fails with the following output:
Change Dir: D:/git/CSP/CMakeFiles/CMakeTmp
Run Build Command:"nmake" "/NOLOGO" "cmTC_87e5f\fast"
Generator: execution of make failed. Make command was: "nmake" "/NOLOGO"
"cmTC_87e5f\fast"
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "D:/git/CSP/CMakeFiles/CMakeOutput.log".
See also "D:/git/CSP/CMakeFiles/CMakeError.log".
答案 0 :(得分:1)
要使用MSYS2工具链,您需要明确指定构建系统生成器,即
cmake -G 'MSYS Makefiles' .
另外请注意,分离应用程序是一种很好的做法。源文件和cmake
生成的文件,例如
mkdir build
cd build
cmake -G 'MSYS Makefiles' ..