PDA

View Full Version : Qt Cmake configuration has no path to a C++ compiler set.



Shubby
11th May 2017, 16:41
The warning I get is: "Qt CMake configuration has no path to a C++ compiler set, even though the kit has a valid tool chain."

I am not sure how to change the CMake configuration so that it has a path to the compiler.
I do have a C++ compiler installed as it works with VS but Qt seems to run into some problem.

This is a screen shot of what appears as the warning: https://i.stack.imgur.com/ETET6.jpg

This is the error I get trying to run anything:

jom: C:\Users\User\Desktop\inv\build-Invaders-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\game.obj] Error 1
'cl' is not recognized as an internal or external command,
operable program or batch file.
jom: C:\Users\User\Desktop\inv\build-Invaders-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\spaceship.obj] Error 1
'cl' is not recognized as an internal or external command,
operable program or batch file.
jom: C:\Users\User\Desktop\inv\build-Invaders-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\laserbeam.obj] Error 1
'cl' is not recognized as an internal or external command,
operable program or batch file.
'cl' is not recognized as an internal or external command,
operable program or batch file.
jom: C:\Users\User\Desktop\inv\build-Invaders-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\config.obj] Error 1
jom: C:\Users\User\Desktop\inv\build-Invaders-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile.Debug [debug\iofile.obj] Error 1
jom: C:\Users\User\Desktop\inv\build-Invaders-Desktop_Qt_5_8_0_MSVC2015_64bit-Debug\Makefile [debug] Error 2
17:06:30: The process "D:\Qt\Tools\QtCreator\bin\jom.exe" exited with code 2.
Error while building/deploying project Invaders (kit: Desktop Qt 5.8.0 MSVC2015_64bit)
The kit Desktop Qt 5.8.0 MSVC2015_64bit has configuration issues which might be the root cause for this problem.
When executing step "Make"

d_stranz
12th May 2017, 20:43
Run CMake from within a Visual Studio command prompt window: Windows Start Menu -> Programs -> Visual Studio 2015 -> Visual Studios Tools -> Windows Desktop Comand Prompts -> whatever is appropriate. These are just Windows BAT files that set up the environment paths and C++ compiler options to allow them to be called from the command line or programs like CMake.

I have several BAT files the I link to from my Desktop that execute the appropriate VS BAT file and then CD to the directory where my CMake project lives. For example, this "BuildProject.BAT" file lives at the top level of my CMake project and is called with these command line arguments:



C:\> BuildProject [clean] [Win32 | Win64] [Release | Debug]


where all arguments are optional. The project builds to an out-of-source directories ("build" and "install") that have subdirectories according to the bitness and build type.

If you call it with no arguments, it will rebuild anything that has changed since the last build, except the CMake Makefiles.

If you call it with the argument "clean", it will erase everything in the output directories and rebuild everything from scratch, including regenerating the Makefiles from the CMakeLists.txt inputs. It will build Win32 Release, Win32 Debug, Win64 Release, and Win64 Debug.

If you call it this way:


BuildProject foo Win32 Release

it won't clean (anything other than "clean" as the first argument works) and will build only the 32-bit Release version. You can put "foo" to substitute for any of the three arguments and it will perform the default:

arg 1 = foo: no clean, just build
arg 2 = foo: builds both 32- and 64 bit versions
arg 3 = foo: builds both Release and Debug versions

so you can have things like:


BuildProject clean foo Release <-- cleans, then builds 32- and 64-bit Release versions
BuildProject foo Win32 foo <-- builds 32-bit Release and Debug versions after source changes
BuildProject clean Win64 Release <-- cleans, then builds only 64-bit Release version
BuildProject foo foo foo <-- identical to BuildProject (with no arguments)


Here's the BuildProject.bat file. Note that it also has a variable (vsversion) that lets me customize it for the Visual Studio version I want to use:


@echo off

REM Clean, generate, and build Windows 32- and 64-bit debug and release
REM versions of the project DLLs and executables

REM Change for a different Visual Studio version. 12.0 = MSVC 2013, 14.0 = MSVC 2015, etc.
set vsversion=12.0

if "%1" == "clean" (
echo -- Cleaning
if EXIST install\libs\Windows rd /s /q install\libs\Windows
if EXIST install\Include rd /s /q install\Include
if EXIST build\Win32 rd /s /q build\Win32
if EXIST build\Win64 rd /s /q build\Win64
echo -- Cleaning done
echo --
)

set bitness=Win32 Win64
if "%2" == "Win32" (
set bitness=Win32
)

if "%2" == "Win64" (
set bitness=Win64
)

set build=Release Debug
if "%3" == "Release" (
set build=Release
)

if "%3" == "Debug" (
set build=Debug
)

REM This is required in order for "machine" and "arch" to be evaluated within the loops
setlocal EnableDelayedExpansion
for %%M in ( %build% ) do (
for %%W in ( %bitness% ) do (
REM and this ensures that any environment changes made by vcvarsall are scoped
REM by the inner loop

setlocal
if %%W == Win32 (
set machine=x86
set arch=x86
) else (
set machine=amd64
set arch=x64
)

echo -- Starting %%W %%M
if NOT EXIST build\%%W\%%M mkdir build\%%W\%%M
cd build\%%W\%%M
call "%ProgramFiles(x86)%\Microsoft Visual Studio %vsversion%\VC\vcvarsall" !machine!
echo -- Generating %%W %%M
cmake -G"NMake Makefiles" -DCMAKE_TOOLCHAIN_FILE=windows_toolchain.cmake -DBUILD_TYPE=%%M -DTARGET_ARCH=!arch! ..\..\..
echo -- Building %%W %%M
cmake --build . 2>&1 >build.log
echo -- Installing %%W %%M
cmake -P cmake_install.cmake
echo -- Finished %%W %%M
cd ..\..\..
endlocal
)
)


The windows_toolchain.cmake sets up some CMake options for building my particular project:



# target operating system
set (CMAKE_SYSTEM_NAME Windows)
set (WINDOWS true)

set (CMAKE_BUILD_TYPE ${BUILD_TYPE} CACHE STRING "Choose the type of build" FORCE)
set (CMAKE_CXX_FLAGS "/D WIN32 /EHsc /D UNICODE /D _UNICODE /D _WINDLL /D XERCES_STATIC_LIBRARY")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )