Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

QtCreator fails on trivial hello-world CMakeLists.txt



  • Hi,

    I'm trying to open a simple project with a trivial CMakeLists.txt, and get the following error:

    Running "C:\Program Files\CMake\bin\cmake.exe -E server "--pipe=\\.\pipe\{f2fb29e4-a968-4294-ac39-f3f8aeab77b5}" --experimental" in C:\Users\Projects\build-Desktop_Qt_5_12_0_MSVC2017_64bit-Default.
    Starting to parse CMake project.
    The C compiler identification is MSVC 19.16.27025.1
    The CXX compiler identification is MSVC 19.16.27025.1
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe
    Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe -- broken
    CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/CMakeTestCCompiler.cmake:52 (message):
      The C compiler
    
        "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/VC/Tools/MSVC/14.16.27023/bin/Hostx64/x64/cl.exe"
    
      is not able to compile a simple test program.
    
      It fails with the following output:
    
        Change Dir: C:/Users/Projects/build-Desktop_Qt_5_12_0_MSVC2017_64bit-Default/CMakeFiles/CMakeTmp
        
        Run Build Command:"nmake" "/nologo" "cmTC_de233\fast"
        	"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\nmake.exe" -f CMakeFiles\cmTC_de233.dir\build.make /nologo -L                  CMakeFiles\cmTC_de233.dir\build
        Building C object CMakeFiles/cmTC_de233.dir/testCCompiler.c.obj
        	C:\PROGRA~2\MIB055~1\2017\ENTERP~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\cl.exe @C:\Users\Patrik\AppData\Local\Temp\nmBCE4.tmp
        testCCompiler.c
        Linking C executable cmTC_de233.exe
        	"C:\Program Files\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_de233.dir --manifests  -- C:\PROGRA~2\MIB055~1\2017\ENTERP~1\VC\Tools\MSVC\1416~1.270\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_de233.dir\objects1.rsp @C:\Users\Patrik\AppData\Local\Temp\nmBD42.tmp
        RC Pass 1: command "rc /foCMakeFiles\cmTC_de233.dir/manifest.res CMakeFiles\cmTC_de233.dir/manifest.rc" failed (exit code 0) with the following output:
        The system cannot find the file specifiedNMAKE : fatal error U1077: '"C:\Program Files\CMake\bin\cmake.exe"' : return code '0xffffffff'
        Stop.
        NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\VC\Tools\MSVC\14.16.27023\bin\Hostx64\x64\nmake.exe"' : return code '0x2'
        Stop.
        
    
      
    
      CMake will not be able to correctly generate this project.
    Call Stack (most recent call first):
      CMakeLists.txt:3 (project)
    
    
    Configuring incomplete, errors occurred!
    See also "C:/Users/Projects/build-Desktop_Qt_5_12_0_MSVC2017_64bit-Default/CMakeFiles/CMakeOutput.log".
    See also "C:/Users/Projects/build-Desktop_Qt_5_12_0_MSVC2017_64bit-Default/CMakeFiles/CMakeError.log".
    CMake Project parsing failed.
    

    The CMakeLists.txt is basically as simple as it can get:

    cmake_minimum_required(VERSION 3.12.0)
    
    project(hw)
    
    # Find includes in corresponding build directories
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    # Instruct CMake to run moc automatically when needed
    set(CMAKE_AUTOMOC ON)
    # Create code from a list of Qt designer ui files
    set(CMAKE_AUTOUIC ON)
    
    # Find the QtWidgets library
    find_package(Qt5Widgets CONFIG REQUIRED)
    
    # Populate a CMake variable with the sources
    set(helloworld_SRCS
        MainWindow.ui
        MainWindow.cpp
        main.cpp
    )
    # Tell CMake to create the hw executable
    add_executable(hw WIN32 ${helloworld_SRCS})
    # Use the Widgets module from Qt 5
    target_link_libraries(hw Qt5::Widgets)
    

    I have played around with the CMake settings in "Kits=>Qt", and tried many different "Generator" and "Extra generator" settings.

    Thank you very much for any help or hint.


  • Lifetime Qt Champion

    @Jimmy03

    I don't think you can continue here before https://forum.qt.io/topic/97693/qt-creator-4-8-not-detecting-vs-2017-in-kits is solved...



  • Indeed, solving the other problem made this one go away. Thanks!



  • Hi
    I have the similar problem. I cannot build any simple application with CMake and MSVC.
    CMake works with MinGW also there is no problem with compiling application with QMake and MSVC.
    If I try to build new application with CMake I get an error:

    C:\apps\CMake\share\cmake-3.16\Modules\CMakeTestCXXCompiler.cmake:53: ошибка: The C++ compiler "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.16.27023/bin/HostX64/x64/cl.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: C:/Users/Tasik/AppData/Local/Temp/QtCreator-CpgOkw/qtc-cmake-XePfArFD/CMakeFiles/CMakeTmp Run Build Command(s):jom /nologo cmTC_05580\fast && Can't find the file Generator: execution of make failed. Make command was: jom /nologo cmTC_05580\fast &&

    I have both QtCreator copiled with MSVC x32 and MSVC x64 and there is no difference in behavior when compiling apps in this case... Here is the properties of the project.
    CMake.jpg



  • I added path to the jom.exe (which in the C:\Qt\Tools\qtcreator-4.10.2\bin) to the Windows path variable and that problem was solved.


Log in to reply