Qt CMake Project can not build
-
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
-
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
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.
-
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.
@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?
-
@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?
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 ?
-
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 ?
-
the some error.
Yes, I modified the Path, but I have now deleted the Path about Chromium
But this error still exists.Where did you delete it ?
Also check the Build part in the Project panel.
-
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.
-
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.