谷甚论VSCode+Qt
  • 板块灌水区
  • 楼主AMIRIOX無暝
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/7/18 21:54
  • 上次更新2023/11/6 22:52:12
查看原帖
谷甚论VSCode+Qt
320697
AMIRIOX無暝楼主2020/7/18 21:54

由于一些原因(防止引战),我打算使用vscodeQt的代码,

GoogleGoogle了一下是可行的 初步推测是cmakeqmake啥的,

但我CMake不熟练,也不了解qt的编译流程和原理, 于是只好上网上抄, 但是改了改还是没啥用,CMakeLists.txt和报错信息在下方

求问:

  • 如果上面的方案可行,应该怎么改才能避免errorerror?
  • 如何使用vscode写qt并正常调试和编译?

CMakeLists:

cmake_minimum_required(VERSION 3.10)
# your project name
project("RemoteControl")
add_compile_options(-g -O0 
                    # -Wno-unused-parameter
                    -static)
                    # -shared)
# find includes in the corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# run moc automatically
# set(CMAKE_AUTOMOC ON)
# run uic automatically
# set(CMAKE_AUTOUIC ON)
# run rcc automatically
# set (CMAKE_AUTORCC ON)
message("Looking for Qt...")
# Qt modules (https://doc.qt.io/qt-5/qtmodules.html) you're using in your application
find_package(Qt5 REQUIRED Widgets Core Gui Charts Gamepad)
if (${Qt5_FOUND})
    message("Found Qt " ${Qt5_VERSION})
else()
    message("Couldn't find Qt")
endif()
link_libraries(
    Qt5::Core
    Qt5::Widgets
    Qt5::Gui
    Qt5::Charts
    Qt5::Gamepad
    )
qt5_wrap_ui(ui_list 
    "ui/mainwindow.ui"
    "ui/videowindow.ui"
    )
qt5_wrap_cpp(moc_list
    "inc/chart.h"
    "inc/mainwindow.h"
    "inc/qFlightInstruments.h"
    "inc/videowindow.h"
)
qt5_add_resources(qrc_list 
    "assets.qrc")
# check and search moudles
find_package(PkgConfig REQUIRED)
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(LIBSERIALPORT REQUIRED libserialport)
pkg_search_module(LIBVLC_CORE REQUIRED libVLCQtCore)
pkg_search_module(LIBVLC_WIDGETS REQUIRED libVLCQtWidgets)
include_directories(
    ${GLIB_INCLUDE_DIRS} ${LIBSERIALPORT_INCLUDE_DIRS} 
    ${LIBVL_CCORE_INCLUDE_DIRS} ${LIBVLC_WIDGETS_INCLUDE_DIRS} 
    )
link_libraries(
    ${GLIB_LDFLAGS} ${LIBSERIALPORT_LDFLAGS} 
    ${LIBVLC_CORE_LDFLAGS} ${LIBVLC_WIDGETS_LDFLAGS} 
    )
ADD_SUBDIRECTORY(ardusub_api)
link_libraries(ardusub_static)
# link_libraries(ardusub_shared)
# add include dir
include_directories("ardusub_api/mavlink_c_library_v2")
include_directories("inc")
# your source files
set(src_list
    "src/chart.cpp"
    "src/control.cpp"
    "src/joystick.cpp"
    "src/main.cpp"
    "src/mainwindow.cpp"
    "src/qFlightInstruments.cpp"
    "src/timer.cpp"
    "src/video.cpp"
    "src/videowindow.cpp"
)
# name of the .exe file, window flag and the list of things to compile
# add_executable(${CMAKE_PROJECT_NAME} WIN32 ${sources})
add_executable(${CMAKE_PROJECT_NAME} ${src_list} ${ui_list} ${moc_list} ${qrc_list})

报错信息:

dell@DESKTOP-U3UU1NF MINGW64 /d/CppProjects/RemoteControl/framework
$ cmake .
-- Building for: Visual Studio 16 2019
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.18363.
-- The C compiler identification is MSVC 19.24.28314.0
-- The CXX compiler identification is MSVC 19.24.28314.0
-- Check for working C compiler: D:/visualstudio/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: D:/visualstudio/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: D:/visualstudio/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: D:/visualstudio/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe - works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Looking for Qt...
Found Qt 5.12.1
-- Found PkgConfig: D:/pkgconfig/bin/pkg-config.exe (found version "") 
-- Checking for one of the modules 'glib-2.0'
CMake Error at D:/packages/cmake/share/cmake-3.17/Modules/FindPkgConfig.cmake:711 (message):
  None of the required 'glib-2.0' found
Call Stack (most recent call first):
  CMakeLists.txt:45 (pkg_search_module)


-- Checking for one of the modules 'libserialport'
CMake Error at D:/packages/cmake/share/cmake-3.17/Modules/FindPkgConfig.cmake:711 (message):
  None of the required 'libserialport' found
Call Stack (most recent call first):
  CMakeLists.txt:46 (pkg_search_module)


-- Checking for one of the modules 'libVLCQtCore'
CMake Error at D:/packages/cmake/share/cmake-3.17/Modules/FindPkgConfig.cmake:711 (message):
  None of the required 'libVLCQtCore' found
Call Stack (most recent call first):
  CMakeLists.txt:47 (pkg_search_module)


-- Checking for one of the modules 'libVLCQtWidgets'
CMake Error at D:/packages/cmake/share/cmake-3.17/Modules/FindPkgConfig.cmake:711 (message):
  None of the required 'libVLCQtWidgets' found
Call Stack (most recent call first):
  CMakeLists.txt:48 (pkg_search_module)


CMake Error at CMakeLists.txt:57 (ADD_SUBDIRECTORY):
  ADD_SUBDIRECTORY given source "ardusub_api" which is not an existing
  directory.

-- Configuring incomplete, errors occurred!
See also "D:/CppProjects/RemoteControl/framework/CMakeFiles/CMakeOutput.log".
2020/7/18 21:54
加载中...