Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt CMake Project can not build
Forum Updated to NodeBB v4.3 + New Features

Qt CMake Project can not build

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 2 Posters 1.7k Views 1 Watching
  • 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.
  • Z Offline
    Z Offline
    ZeusFa
    wrote on last edited by
    #1

    I opened qt creator and created a cmake project with the following CMakeLists:

    cmake_minimum_required(VERSION 3.5)
    
    project(untitled2 VERSION 0.1 LANGUAGES CXX)
    
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    set(CMAKE_CXX_STANDARD 17)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
    
    set(PROJECT_SOURCES
            main.cpp
            mainwindow.cpp
            mainwindow.h
            mainwindow.ui
    )
    
    if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
        qt_add_executable(untitled2
            MANUAL_FINALIZATION
            ${PROJECT_SOURCES}
        )
    # Define target properties for Android with Qt 6 as:
    #    set_property(TARGET untitled2 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
    #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
    # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
    else()
        if(ANDROID)
            add_library(untitled2 SHARED
                ${PROJECT_SOURCES}
            )
    # Define properties for Android with Qt 5 after find_package() calls as:
    #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
        else()
            add_executable(untitled2
                ${PROJECT_SOURCES}
            )
        endif()
    endif()
    
    target_link_libraries(untitled2 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
    
    set_target_properties(untitled2 PROPERTIES
        MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
        MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
        MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
        MACOSX_BUNDLE TRUE
        WIN32_EXECUTABLE TRUE
    )
    
    install(TARGETS untitled2
        BUNDLE DESTINATION .
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
    )
    
    if(QT_VERSION_MAJOR EQUAL 6)
        qt_finalize_executable(untitled2)
    endif()
    
    

    But could not succeed and obtained this error:

    Running C:\Program Files\CMake\bin\cmake.exe -S C:/Users/jason/Documents/untitled2 -B C:/Users/jason/Documents/build-untitled2-office651-Debug in C:\Users\jason\Documents\build-untitled2-office651-Debug.
    CMake Error at CMakeLists.txt:3 (project):
      Running
    
       'D:/chromium_dev/depot_tools/ninja' '--version'
    
      failed with:
    
       %1 涓嶆槸鏈夋晥鐨Win32 搴旂敤绋嬪簭銆
    
    -- Configuring incomplete, errors occurred!
    CMake process exited with exit code 1.
    
    Elapsed time: 00:00.
    

    Is it because I have chromium's source code installed on my computer at the same time? I remember that since I compiled the Chromium source code, Qt's CMake doesn't work properl

    SGaistS 1 Reply Last reply
    0
    • Z ZeusFa

      I opened qt creator and created a cmake project with the following CMakeLists:

      cmake_minimum_required(VERSION 3.5)
      
      project(untitled2 VERSION 0.1 LANGUAGES CXX)
      
      set(CMAKE_AUTOUIC ON)
      set(CMAKE_AUTOMOC ON)
      set(CMAKE_AUTORCC ON)
      
      set(CMAKE_CXX_STANDARD 17)
      set(CMAKE_CXX_STANDARD_REQUIRED ON)
      
      find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
      find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
      
      set(PROJECT_SOURCES
              main.cpp
              mainwindow.cpp
              mainwindow.h
              mainwindow.ui
      )
      
      if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
          qt_add_executable(untitled2
              MANUAL_FINALIZATION
              ${PROJECT_SOURCES}
          )
      # Define target properties for Android with Qt 6 as:
      #    set_property(TARGET untitled2 APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
      #                 ${CMAKE_CURRENT_SOURCE_DIR}/android)
      # For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
      else()
          if(ANDROID)
              add_library(untitled2 SHARED
                  ${PROJECT_SOURCES}
              )
      # Define properties for Android with Qt 5 after find_package() calls as:
      #    set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
          else()
              add_executable(untitled2
                  ${PROJECT_SOURCES}
              )
          endif()
      endif()
      
      target_link_libraries(untitled2 PRIVATE Qt${QT_VERSION_MAJOR}::Widgets)
      
      set_target_properties(untitled2 PROPERTIES
          MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
          MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
          MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
          MACOSX_BUNDLE TRUE
          WIN32_EXECUTABLE TRUE
      )
      
      install(TARGETS untitled2
          BUNDLE DESTINATION .
          LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
          RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
      )
      
      if(QT_VERSION_MAJOR EQUAL 6)
          qt_finalize_executable(untitled2)
      endif()
      
      

      But could not succeed and obtained this error:

      Running C:\Program Files\CMake\bin\cmake.exe -S C:/Users/jason/Documents/untitled2 -B C:/Users/jason/Documents/build-untitled2-office651-Debug in C:\Users\jason\Documents\build-untitled2-office651-Debug.
      CMake Error at CMakeLists.txt:3 (project):
        Running
      
         'D:/chromium_dev/depot_tools/ninja' '--version'
      
        failed with:
      
         %1 涓嶆槸鏈夋晥鐨Win32 搴旂敤绋嬪簭銆
      
      -- Configuring incomplete, errors occurred!
      CMake process exited with exit code 1.
      
      Elapsed time: 00:00.
      

      Is it because I have chromium's source code installed on my computer at the same time? I remember that since I compiled the Chromium source code, Qt's CMake doesn't work properl

      SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What does the error say ?

      Something that is indeed strange is that the Ninja version used seems not to be the one provided with Qt. This might be the culprit.

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

      Z 1 Reply Last reply
      0
      • SGaistS SGaist

        Hi,

        What does the error say ?

        Something that is indeed strange is that the Ninja version used seems not to be the one provided with Qt. This might be the culprit.

        Z Offline
        Z Offline
        ZeusFa
        wrote on last edited by ZeusFa
        #3

        @SGaist said in Qt CMake Project can not build:

        CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
        CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
        CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
        -- Configuring incomplete, errors occurred!
        CMake Error at qtbase/cmake/QtProcessConfigureArgs.cmake:965 (message):
          CMake exited with code 1.
        
        

        How should I fix it?

        SGaistS 1 Reply Last reply
        0
        • Z ZeusFa

          @SGaist said in Qt CMake Project can not build:

          CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
          CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
          CMake Error: CMAKE_ASM_COMPILER not set, after EnableLanguage
          -- Configuring incomplete, errors occurred!
          CMake Error at qtbase/cmake/QtProcessConfigureArgs.cmake:965 (message):
            CMake exited with code 1.
          
          

          How should I fix it?

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Isn't that a different error that before ?

          Do you have your PATH environment variable changed since you build chromium ?

          Are you using Qt Creator to build your application ?

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

          Z 1 Reply Last reply
          0
          • SGaistS SGaist

            Isn't that a different error that before ?

            Do you have your PATH environment variable changed since you build chromium ?

            Are you using Qt Creator to build your application ?

            Z Offline
            Z Offline
            ZeusFa
            wrote on last edited by
            #5

            @SGaist

            the some error.

            Yes, I modified the Path, but I have now deleted the Path about Chromium
            But this error still exists.

            SGaistS 1 Reply Last reply
            0
            • Z ZeusFa

              @SGaist

              the some error.

              Yes, I modified the Path, but I have now deleted the Path about Chromium
              But this error still exists.

              SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Where did you delete it ?

              Also check the Build part in the Project panel.

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

              Z 1 Reply Last reply
              0
              • SGaistS SGaist

                Where did you delete it ?

                Also check the Build part in the Project panel.

                Z Offline
                Z Offline
                ZeusFa
                wrote on last edited by
                #7

                @SGaist

                see

                27b9a5fd-8135-45df-a40c-5827b0b59f4f-image.png

                Do I need to change here?

                SGaistS 1 Reply Last reply
                0
                • Z ZeusFa

                  @SGaist

                  see

                  27b9a5fd-8135-45df-a40c-5827b0b59f4f-image.png

                  Do I need to change here?

                  SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Check the environment variables. Ninja should work fine, one of the main issue seems to be that it finds the one from chromium rather than the one you installed alongside Qt.

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

                  Z 1 Reply Last reply
                  0
                  • SGaistS SGaist

                    Check the environment variables. Ninja should work fine, one of the main issue seems to be that it finds the one from chromium rather than the one you installed alongside Qt.

                    Z Offline
                    Z Offline
                    ZeusFa
                    wrote on last edited by ZeusFa
                    #9

                    @SGaist So far still not resolved

                    6d2a535a-6464-4ab5-9473-58cdc1e5912b-image.png

                    SGaistS 1 Reply Last reply
                    0
                    • Z ZeusFa

                      @SGaist So far still not resolved

                      6d2a535a-6464-4ab5-9473-58cdc1e5912b-image.png

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @ZeusFa what is in Build Environment ?

                      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

                      • Login

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