0
I’m trying to use cmake to compile a project written in C++, the project builds smoothly if I use an IDE (tested in Qt Creator and Clion), but need to compile by command line, as I’m setting up the environment for a remote build.
D:\Workspace\analytics>cmake . -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="C:\msys32\mingw32" -B build
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
-- Check for working C compiler: C:/msys32/mingw32/bin/gcc.exe
-- Check for working C compiler: C:/msys32/mingw32/bin/gcc.exe -- broken
CMake Error at C:/Program Files/CMake/share/cmake-3.14/Modules/CMakeTestCCompiler.cmake:60 (message):
The C compiler
"C:/msys32/mingw32/bin/gcc.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: D:/Workspace/analytics/build/CMakeFiles/CMakeTmp
Run Build Command(s):C:/msys32/mingw32/bin/mingw32-make.exe cmTC_53d35/fast
C:/msys32/mingw32/bin/mingw32-make.exe -f CMakeFiles\cmTC_53d35.dir\build.make CMakeFiles/cmTC_53d35.dir/build
mingw32-make.exe[1]: Entering directory 'D:/Workspace/analytics/build/CMakeFiles/CMakeTmp'
Building C object CMakeFiles/cmTC_53d35.dir/testCCompiler.c.obj
C:\msys32\mingw32\bin\gcc.exe -o CMakeFiles\cmTC_53d35.dir\testCCompiler.c.obj -c D:\Workspace\analytics\build\CMakeFiles\CMakeTmp\testCCompiler.c
mingw32-make.exe[1]: *** [CMakeFiles\cmTC_53d35.dir\build.make:65: CMakeFiles/cmTC_53d35.dir/testCCompiler.c.obj] Error 1
mingw32-make.exe[1]: Leaving directory 'D:/Workspace/analytics/build/CMakeFiles/CMakeTmp'
mingw32-make.exe: *** [Makefile:120: cmTC_53d35/fast] Error 2
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
See also "D:/Workspace/analytics/build/CMakeFiles/CMakeOutput.log".
See also "D:/Workspace/analytics/build/CMakeFiles/CMakeError.log".
If I set in Windows PATH the Mingw path "C:/msys32/mingw32/bin" the build command works, recognizes the compiler and etc..., but the IDE starts to give error.
If I enter through the MSYS2 console I can compile without problems also
I am trying to compile the project using Windows cmd
cmake . -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="C:\msys32\mingw32" -B build
I tried to pass the compiler path gcc and g++
-DCMAKE_C_COMPILER=C:\msys32\mingw32\bin\gcc.exe
-DCMAKE_CXX_COMPILER=C:\msys32\mingw32\bin\g++.exe
But I didn’t succeed either.
How can I call cmake by command line using MSYS2 Mingw to compile the project without having to configure the Mingw path in Windows PATH?