Set CMAKE_MAKE_PROGRAM to mingw32-make from inside the CMakeLists.txt

血红的双手。 提交于 2021-01-29 13:17:29

问题


Following this post, if I run cmake .. inside my build folder with no options I get the error:

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.
CMake Error: CMAKE_Fortran_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

which I can solve by running

cmake .. -D CMAKE_MAKE_PROGRAM:PATH=/mingw64/bin/mingw32-make

However, I want to set the CMAKE_MAKE_PROGRAM from inside the CMakeLists.txt file. I tried the

if(MSYS)
  set(CMAKE_MAKE_PROGRAM /mingw64/bin/mingw32-make)
endif(MSYS)

but it doesn't work. I would appreciate it if you could help me know how I can resolve this problem.

P.S.1. Here is the code.

P.S.2. I tried the

set(CMAKE_MAKE_PROGRAM /mingw64/bin/mingw32-makemingw32-make CACHE FILEPATH "" FORCE)

as suggested in the comments but it did not help.

P.S.3. My operating system is Windows 10 version 1909, and I'm running the above commands in MSYS2 terminal MSYS_NT-10.0-18363


回答1:


Ok, I think I solved the problem. From here, I needed to install the MSYS2's make:

pacman -S make

This seems like a trend too me. I have recently had several problems in MSYS2 which have been resolved by removing the MinGW package and replacing it with the MSYS2 package. So it tells me that when working inside MSYS2 I should favor MSYS2 packages if they are available.



来源:https://stackoverflow.com/questions/61107756/set-cmake-make-program-to-mingw32-make-from-inside-the-cmakelists-txt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!