MinGW paths from Qt, import CMake project on windows

I have a cmake managed code that compiles fine from the commandline

cmake_minimum_required(VERSION 3.13)

set(CMAKE_PROJECT_NAME "testProject")



set(BIN_PATH "binAPP")
set(TMP_BUILD "tmpBuild")
set(LIB_PATH "theLib")
set(APP_PATH "app")


add_subdirectory(${LIB_PATH} ${BUILD_TEMP_PATH}/${LIB_PATH})

add_subdirectory(${APP_PATH} "${BUILD_TEMP_PATH}/${APP_PATH}")

cmake -G “MinGW Makefiles” …
– The C compiler identification is GNU 8.1.0
– The CXX compiler identification is GNU 8.1.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/Qt/Tools/mingw810_64/bin/gcc.exe - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/Qt/Tools/mingw810_64/bin/g++.exe - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
– Configuring done
– Generating done
– Build files have been written to: C:/Users/maldonadolopez/Documents/ApAlDesarrollo_PRG/test_v4/Build

But when I try to import it into eclipse under windows (under linux works), I get the next error report:

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_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

If I add the next code I get the same error:

set(CMAKE_C_COMPILER "C:/Qt/Tools/mingw810_64/bin/gcc.exe")
set(CMAKE_CXX_COMPILER "C:/Qt/Tools/mingw810_64/bin/g++.exe")

(I would like to use the MinGW from QtCreator, so I added C:\Qt\5.15.2\mingw81_64\bin & C:\Qt\Tools\mingw810_64\bin to windows PATH variable)
I think it is an eclipse path problem, but I’m not sure, and I don’t know how should I configure the eclipse paths.
Any help please?

Thanks in advance.

PD: I don’t want to generate the eclipse project from commandline with cmake “Eclipse CDT4 - MinGW Makefiles”, but direct import from eclipse plugin under the GUI

This sounds like an Eclipse issue to me. The non-IDE (VS and Xcode) generators expect the compiler to be available in the environment. You might need to either tell Eclipse about how to provide such an environment to CMake when it runs it or run Eclipse from within a MinGW-aware environment.

Setting the compiler like that is not supported at all in any case. You need to do it via -D on the command line or via a toolchain file if CMake’s not going to find it with its default search procedure.

Thank you Ben

I had similar problems on Windows in the past, independently of Eclipse. It was even a different build tool (ninja). Ninja was in the PATH, but for some reason CMake didn’t find it. As a workaround, I had to set a CMake variable explicitly, CMAKE_MAKE_PROGRAM if I remember correctly. I can double check if it helps.