Qt CMake project cannot be build outside QtCreator
-
I am trying to build an old CMake Qt project using command line on Windows with MinGW. The project get configured and build without any issues using QtCreator. However, when I try to build it manually with regular command line (using exact commands that QtCreator uses) it fails. Matter of fact it fails at CMake configurations.
PS C:\> C:\Qt\Tools\CMake_64\bin\cmake.exe -S C:/project_orange/src -B C:/project_orange/build -GNinja "-DCMAKE_BUILD_TYPE:STRING=Debug" "-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=C:/Qt/Tools/QtCreator/share/qtcreator/package-manager/auto-setup.cmake" "-DQT_QMAKE_EXECUTABLE:STRING=C:/Qt/5.5/mingw492_32/bin/qmake.exe" "-DCMAKE_PREFIX_PATH:STRING=C:/Qt/5.5/mingw492_32" "-DCMAKE_C_COMPILER:STRING=C:/Qt/Tools/mingw492_32/bin/gcc.exe" "-DCMAKE_CXX_COMPILER:STRING=C:/Qt/Tools/mingw492_32/bin/g++.exe" "-DCMAKE_MAKE_PROGRAM:STRING=C:/Qt/Tools/Ninja/ninja.exe" -- The C compiler identification is unknown -- The CXX compiler identification is unknown -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Check for working C compiler: C:/Qt/Tools/mingw492_32/bin/gcc.exe -- Check for working C compiler: C:/Qt/Tools/mingw492_32/bin/gcc.exe - broken CMake Error at C:/Qt/Tools/CMake_64/share/cmake-3.21/Modules/CMakeTestCCompiler.cmake:69 (message): The C compiler "C:/Qt/Tools/mingw492_32/bin/gcc.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/project_orange/build/CMakeFiles/CMakeTmp Run Build Command(s):C:/Qt/Tools/Ninja/ninja.exe cmTC_83ec3 && [1/2] Building C object CMakeFiles\cmTC_83ec3.dir\testCCompiler.c.obj FAILED: CMakeFiles/cmTC_83ec3.dir/testCCompiler.c.obj C:\Qt\Tools\mingw492_32\bin\gcc.exe -o CMakeFiles\cmTC_83ec3.dir\testCCompiler.c.obj -c C:\project_orange\build\CMakeFiles\CMakeTmp\testCCompiler.c ninja: build stopped: subcommand failed. CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:5 (project) -- Configuring incomplete, errors occurred! See also "C:/project_orange/build/CMakeFiles/CMakeOutput.log". See also "C:/project_orange/build/CMakeFiles/CMakeError.log".
Strange enough, if I open a terminal using QtCreator (Projects> Build Environment> Open Terminal), same command would work. This made me believe that I might be missing some environment variables. So, using a normal command line, I set all the Environment variables listed in Build Environment section by QtCreator manually and then ran same command. Unfortunately this leads to the same error output. I believe QtCreator is doing something on the background witch is not visible.
Can anyone explain what is happening and how to fix this?