1 原cmakelists.txt
cmake_minimum_required (VERSION 2.8.12)
project (test)
set(CMAKE_GENERATOR "MinGW Makefiles")
set(CMAKE_MAKE_PROGRAM "F:/x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64/bin/make.exe") #注意这里
set(CMAKE_C_COMPILER "F:/x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "F:/x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe")
add_executable(tt
tt.cc)
这里一直报错如下
CMake Error: CMake was unable to find a build program corresponding to "MinGW Makefiles". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
原来是因为 CMake 在默认情况下期望使用 mingw32-make.exe 作为 MinGW 的构建程序。
因为之前为了方便顺手把mingw32-make.exe改名成make.exe了。。
所以把make.exe名字改回来,问题解决
cmake_minimum_required (VERSION 2.8.12)
project (test)
set(CMAKE_GENERATOR "MinGW Makefiles")
set(CMAKE_MAKE_PROGRAM "F:/x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64/bin/mingw32-make.exe")
set(CMAKE_C_COMPILER "F:/x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "F:/x86_64-8.1.0-release-posix-seh-rt_v6-rev0/mingw64/bin/g++.exe")
add_executable(tt
tt.cc)
太坑了。。