CMake 错误:CMake 无法找到与“Unix Makefiles”对应的构建程序。 CMAKE_MAKE_PROGRAM 未设置

Posted

技术标签:

【中文标题】CMake 错误:CMake 无法找到与“Unix Makefiles”对应的构建程序。 CMAKE_MAKE_PROGRAM 未设置【英文标题】:CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles". CMAKE_MAKE_PROGRAM is not set 【发布时间】:2019-11-29 06:42:39 【问题描述】:

我正在使用 linaro-aarch64-2018.05 在 windows 10 x64 上进行交叉编译以创建环境,c++11 cmake 版本 3.1.6 当我用

生成文件时
set GENMAKE_DIR=genmake-cv22-win-Linaro-aarch64
set VERSION=cv22-win-Linaro-aarch64
set CROSSMAKETOOL=cs-make-2013.11-33.exe

..\genmake-tools-win32\genMakefiles-win32.bat

和 工具链文件

##--- target system
set(CMAKE_SYSTEM_NAME Linux)        #--- Name of the OS CMake is building for. (uname -s)
set(CMAKE_SYSTEM_VERSION 4.9.0)     #--- OS version CMake is building for. (uname -r)
set(CMAKE_SYSTEM_PROCESSOR unknown) #--- The name of the CPU CMake is building for. (uname -p)

##--- crosstool path 
set(CROSSTOOL_DIR c:/arm-linux/linaro-aarch64-2018.05)
set(CROSSTOOL_NAME aarch64-linux-gnu)
set(CROSSTOOL_VER 7.1.1)
#set(OS_DIR d:/s2-sdk/ambarella/kernel/linux)

##--- crosstool compiler
set(CMAKE_C_COMPILER $CROSSTOOL_DIR/bin/$CROSSTOOL_NAME-gcc.exe)
set(CMAKE_CXX_COMPILER $CROSSTOOL_DIR/bin/$CROSSTOOL_NAME-g++.exe)

#--- where is the target environment.
set(CMAKE_FIND_ROOT_PATH $CROSSTOOL_DIR)

##--- search for programs in the build host directories.
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
#--- for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRATY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

当我在 Windows 7 下一切都很好,但是当我切换到 Windows 10 时 错误出现了 日志:

D:\Project\frdatabase\genmake-cv22-win-Linaro-aarch64>copy ..\genmake-tools-win32\make-console.bat     ..\build
copy an file

D:\Project\frdatabase\genmake-cv22-win-Linaro-aarch64>copy ..\genmake-tools-win32\sh.exe
        ..\build\
copy an file

D:\Project\frdatabase\genmake-cv22-win-Linaro-aarch64>copy ..\genmake-tools-win32\cs-make-2013.11-33.exe        ..\build\make.exe
copy an file

D:\Project\frdatabase\genmake-cv22-win-Linaro-aarch64>cd ..\build

D:\Project\frdatabase\build>cmake -DCMAKE_TOOLCHAIN_FILE=toolchain-cv22-win-Linaro-aarch64.cmake -G"Unix Makefiles"  ../trunk
CMake Error: CMake was unable to find a build program corresponding to "Unix Makefiles".  CMAKE_MAKE_PROGRAM is not set.  You probably need to select a different build tool.
-- Configuring incomplete, errors occurred!
See also "D:/Project/frdatabase/build/CMakeFiles/CMakeOutput.log".

D:\Project\frdatabase\build>cd ..\genmake-cv22-win-Linaro-aarch64

D:\Project\frdatabase\genmake-cv22-win-Linaro-aarch64>pause

Cmake 输出:

The target system is: Linux - 4.9.0 - unknown
The host system is: Windows - 10.0.18362 - AMD64

互联网上有很多类似的错误,但他们都没有使用正确的品牌,但我很确定我使用了正确的错误,因为我也是从使用 Windows 10 的同事那里得到的

【问题讨论】:

【参考方案1】:

问题在于cmake的版本 3.16.0有这个问题,但是3.10.3下可以编译。

【讨论】:

以上是关于CMake 错误:CMake 无法找到与“Unix Makefiles”对应的构建程序。 CMAKE_MAKE_PROGRAM 未设置的主要内容,如果未能解决你的问题,请参考以下文章

CMake:生成忽略错误的 Unix Makefile

在Windows 10上的CLion / CMake中“无法找到SFML”错误?

即使已安装 CMake 也无法找到 gRPC 库(mac)

在 macOS 上使用 Ninja 进行 CMake GUI

cmake无法找到vs2015的c compiler

Cmake 无法在 Homebrew 中找到 boost_pyhton 库