0

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

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • In this answer: [Why doesn't "CMAKE\_MAKE\_PROGRAM" variable take effect?](https://stackoverflow.com/questions/49103936/why-doesnt-cmake-make-program-variable-take-effect), see that you need to set `CMAKE_MAKE_PROGRAM` as a *cache* variable, not a regular CMake variable. – Kevin Apr 08 '20 at 18:51
  • @squareskittles I tried the `set(CMAKE_MAKE_PROGRAM mingw32-make CACHE FILEPATH "" FORCE)` but it did not work. – Foad S. Farimani Apr 08 '20 at 19:09
  • What do you mean by "*it did not work*"? Do you get the same error message as shown in your question post? Also, to be safe, you should use the *full* path to the make program when setting this variable. – Kevin Apr 08 '20 at 19:12
  • @squareskittles yes the exact same error. I tried the full path too. see the **P.S.2.** – Foad S. Farimani Apr 08 '20 at 19:13
  • I'm also noticing that you have the generator set to `"Unix Makefiles"`. If you are using MinGW, you should re-run CMake from scratch, with the generator set to `"MinGW Makefiles"` instead. – Kevin Apr 08 '20 at 19:42
  • @squareskittles I tried the `MinGW` and `MSYS` generators as well, but I got the error `CMake Error: Could not create named generator MinGW/MSYS MakeFiles` – Foad S. Farimani Apr 08 '20 at 19:49
  • @squareskittles I also tried `Ninja` generators and got the `The Ninja generator does not support Fortran using Ninja version` error. – Foad S. Farimani Apr 08 '20 at 19:51
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/211246/discussion-between-squareskittles-and-foad). – Kevin Apr 08 '20 at 19:53
  • @squareskittles Do you mind if use comments? I don't like SO chats at all. – Foad S. Farimani Apr 08 '20 at 20:14
  • 1
    The error is peculiar. Can you provide some background information about your development environment? What OS are you using? The MinGW path you use appears to be a Unix path? Why is that? – Kevin Apr 08 '20 at 20:22
  • @squareskittles sorry for the late reply. went for dinner. I have provided the code in the **P.S.1.**. The Operating system is obviously Windows, I thought that would be a given with MSYS2/MinGW. I'm running the abovve commands in MSYS2 terminal. – Foad S. Farimani Apr 08 '20 at 22:41

1 Answers1

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.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193