Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Cannot build with cmake, qtcreator and MSVC 2019
QtWS25 Last Chance

Cannot build with cmake, qtcreator and MSVC 2019

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
10 Posts 3 Posters 8.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    Kiruahxh
    wrote on 25 Oct 2020, 20:57 last edited by
    #1

    Hello,

    I just wanted to try the new QtCreator cmake support; I have Visual Studio 2019 installed with its C++ compiler.
    I am testing with the latest tools (Windows 10, Qt 5.15.1, VS 2019 16.7.6, Qt creator 4.13.2).
    However, I am not able to build a freshly created "Qt widgets application" project.

    CMake is well detected (initially QtCreator wanted to use by default an old version of CMake installed on my system and crashed: but why ??).
    My Qt kit seems to be okay, but I don't manage to find a working CMake generator.
    I chose Visual Studio 16 2019 and build the project, I have the following error message :
    MSBUILD : error MSB1009: Le fichier projet n'existe pas. (the project file doesn't exists)
    Commutateur : all.vcxproj

    If I just execute CMake, a build directory is created with "ALL_BUILD.vcxproj" and "untitled5.vcxproj" files, but no "all.vcxproj" file...

    I don't know which generator should work on my system (none work for now), and why the "visual studio 2019" generator doesn't work...
    Please help!

    qtcreator-kit.PNG

    1 Reply Last reply
    0
    • J Offline
      J Offline
      JohanSolo
      wrote on 26 Oct 2020, 16:03 last edited by
      #2

      You should show us your CMakeLists.txt file... is there a top-level project defined?

      `They did not know it was impossible, so they did it.'
      -- Mark Twain

      1 Reply Last reply
      0
      • K Offline
        K Offline
        Kiruahxh
        wrote on 28 Oct 2020, 20:20 last edited by
        #3
        cmake_minimum_required(VERSION 3.5)
        
        project(test_c_make LANGUAGES CXX)
        
        set(CMAKE_INCLUDE_CURRENT_DIR ON)
        
        set(CMAKE_AUTOUIC ON)
        set(CMAKE_AUTOMOC ON)
        set(CMAKE_AUTORCC ON)
        
        set(CMAKE_CXX_STANDARD 11)
        set(CMAKE_CXX_STANDARD_REQUIRED ON)
        
        # QtCreator supports the following variables for Android, which are identical to qmake Android variables.
        # Check http://doc.qt.io/qt-5/deployment-android.html for more information.
        # They need to be set before the find_package(Qt5 ...) call.
        
        #if(ANDROID)
        #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
        #    if (ANDROID_ABI STREQUAL "armeabi-v7a")
        #        set(ANDROID_EXTRA_LIBS
        #            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libcrypto.so
        #            ${CMAKE_CURRENT_SOURCE_DIR}/path/to/libssl.so)
        #    endif()
        #endif()
        
        find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
        find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
        
        if(ANDROID)
          add_library(test_c_make SHARED
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
          )
        else()
          add_executable(test_c_make
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
          )
        endif()
        
        target_link_libraries(test_c_make PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
        
        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 28 Oct 2020, 20:23 last edited by
          #4

          Hi,

          How old were these versions of CMake ?
          Do they appear in your PATH ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • K Offline
            K Offline
            Kiruahxh
            wrote on 28 Oct 2020, 20:26 last edited by Kiruahxh
            #5

            I still have another CMake installation in C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin
            It is 32 bits version 3.17 (very close to the 34bits, 3.18 version shipped with QtCreator).
            In fact I don't have this entry in the PATH environment variable window of Windows. But I have it in QtCreator in the project view...
            This CMake installation is not even listed in tools > options > kits > CMake.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              Kiruahxh
              wrote on 28 Oct 2020, 20:49 last edited by Kiruahxh 11 Jan 2020, 08:53
              #6

              The microsoft CMake doesn't seem to be called.
              If I run CMake manually from the Qt console, I have the same error:

              "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build . --target all
              MSBUILD : error MSB1009: Project file does not exist
              Commutateur : all.vcxproj
              

              However, if I change the target it succeeds:

              "C:\Qt\Tools\CMake_64\bin\cmake.exe" --build . --target ALL_BUILD
              

              So, if I go to project tab > build > ALL_BUILD, it compiles fine.
              I also managed to make Ninja build work. Fine!

              I don't know CMake enough: is ALL_BUILD a standard target ?
              I am using a QtCreator generated CMakeLists.txt.

              1 Reply Last reply
              0
              • J Offline
                J Offline
                JohanSolo
                wrote on 29 Oct 2020, 08:14 last edited by
                #7

                IIRC ALL_BUILD is a standard target when you create a solution from cmake. Now, did you produced NMake makefiles ? Because I don't see any Release/Debug switch (default is Debug IIRC).
                Since the --target comes after the . in the call, it is directly forwarded to the actual build engine, and therefore must be a target, hence the search for all.vcxproj. From the command-line, if you want to build everything, just call cmake --build ., the default behaviour is to build everything.

                `They did not know it was impossible, so they did it.'
                -- Mark Twain

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kiruahxh
                  wrote on 29 Oct 2020, 14:44 last edited by
                  #8

                  With "Visual Studio 16 2019" generator, QtCreator tries to use the all target by default (which doesn't exists) instead of ALL_BUILD.
                  With "Ninja" generator, QtCreator uses the all target by default which is OK.
                  When in debug mode, QtCreator doesn't use a Release/Debug switch (but doesn't need to...).

                  In my opinion, QtCreator shouldn't propose the all target with "Visual Studio 16 2019" generator, since it doesn't exists

                  1 Reply Last reply
                  0
                  • K Offline
                    K Offline
                    Kiruahxh
                    wrote on 29 Oct 2020, 23:47 last edited by Kiruahxh
                    #9

                    I installed other Visual C++ extensions from Visual Studio installer (MFC & memory sanitizer), and I cannot build with CMake again.

                    
                    Running C:\Qt\Tools\CMake_64\bin\cmake.exe -S C:/dev/untitled3 -B C:/Users/Nicolas/AppData/Local/Temp/QtCreator-VjKhJz/qtc-cmake-hherMDxz in C:\Users\Nicolas\AppData\Local\Temp\QtCreator-VjKhJz\qtc-cmake-hherMDxz.
                    -- Selecting Windows SDK version 10.0.17763.0 to target Windows 10.0.18363.
                    CMake Error at CMakeLists.txt:3 (project):
                      Failed to run MSBuild command:
                    
                        C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/MSBuild/Current/Bin/MSBuild.exe
                    
                      to get the value of VCTargetsPath:
                    
                        Microsoft (R) Build Engine version 16.7.0+b89cb5fde pour .NET Framework
                        Copyright (C) Microsoft Corporation. Tous droits réservés.
                        
                        La génération a démarré 30/10/2020 00:41:15.
                        Projet "C:\Users\Nicolas\AppData\Local\Temp\QtCreator-VjKhJz\qtc-cmake-hherMDxz\CMakeFiles\3.18.3\VCTargetsPath.vcxproj" sur le noud 1 (cibles par défaut).
                        C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3293,5): error MSB4184: impossible d'évaluer l'expression "[System.IO.Path]::Combine(obj\<unsupported>\Debug\, .NETFramework,Version=v4.0.AssemblyAttributes.cpp)". Caractères non conformes dans le chemin d'accès. [C:\Users\Nicolas\AppData\Local\Temp\QtCreator-VjKhJz\qtc-cmake-hherMDxz\CMakeFiles\3.18.3\VCTargetsPath.vcxproj]
                        Génération du projet "C:\Users\Nicolas\AppData\Local\Temp\QtCreator-VjKhJz\qtc-cmake-hherMDxz\CMakeFiles\3.18.3\VCTargetsPath.vcxproj" terminée (cibles par défaut) -- ÉCHEC.
                        
                        ÉCHEC de la build.
                        
                        "C:\Users\Nicolas\AppData\Local\Temp\QtCreator-VjKhJz\qtc-cmake-hherMDxz\CMakeFiles\3.18.3\VCTargetsPath.vcxproj" (cible par défaut) (1) ->
                          C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(3293,5): error MSB4184: impossible d'évaluer l'expression "[System.IO.Path]::Combine(obj\<unsupported>\Debug\, .NETFramework,Version=v4.0.AssemblyAttributes.cpp)". Caractères non conformes dans le chemin d'accès. [C:\Users\Nicolas\AppData\Local\Temp\QtCreator-VjKhJz\qtc-cmake-hherMDxz\CMakeFiles\3.18.3\VCTargetsPath.vcxproj]
                        
                            0 Avertissement(s)
                            1 Erreur(s)
                        Temps écoulé 00:00:00.08
                        
                      Exit code: 1
                    
                    -- Configuring incomplete, errors occurred!
                    See also "C:/Users/Nicolas/AppData/Local/Temp/QtCreator-VjKhJz/qtc-cmake-hherMDxz/CMakeFiles/CMakeOutput.log".
                    CMake process exited with exit code 1.
                    Elapsed time: 00:00.
                    

                    impossible d'évaluer l'expression "[System.IO.Path]::Combine(obj<unsupported>\Debug, .NETFramework,Version=v4.0.AssemblyAttributes.cpp)". Caractères non conformes dans le chemin d'accès.
                    = cannot evaluate expression XXX. Invalid caracters in the access path.

                    It seems that command line encoding errors prevents the build to succeed.
                    I see no difference wether I check "Force UTF-8 MSVC compiler output".

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      Kiruahxh
                      wrote on 30 Oct 2020, 23:05 last edited by Kiruahxh 11 Jan 2020, 08:58
                      #10

                      Okay, found it.

                      The error is with the "<unsupported>" keyword that should not be here.
                      In tools > options > Kits > Desktop Qt XXX > CMake Generator > Platform & Toolset, the string "<unsupported>" has appeared.
                      These fields should be cleared.
                      These fields content has been automatically copied to : project tab > CMake > Initial CMake parameters ; fields -A<unsupported> and -T<unsupported> that should be removed.
                      Once the fields are cleared, I have to do :

                      • Compile > Clear CMake configuration
                      • Compile > Execute CMake
                      • Build All Projects
                      • If a build error happens (non existing project file or target) : project tab > build steps > build > targets > choose the right target
                      • Build All Projects

                      Then it works, with encoding errors but it builds normally! (enjoy)

                      I opened new tickets in the Qt bug tracker :

                      • Cannot build a new project with CMake and MSVC without modifying the target
                      • Value <unsupported> should not appear in CMake platform & Toolset
                      • Bad encoding in CMake compilation output and problems panel on Windows
                      1 Reply Last reply
                      0

                      4/10

                      28 Oct 2020, 20:23

                      • Login

                      • Login or register to search.
                      4 out of 10
                      • First post
                        4/10
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved