• ROS1 Qt5 CMake基本配置


    ##############################################################################
    # CMake
    ##############################################################################
    
    cmake_minimum_required(VERSION 3.10)
    project(test_project VERSION 0.1)
    
    set(CMAKE_INCLUDE_CURRENT_DIR ON)
    set(CMAKE_CXX_STANDARD 11)
    set(CMAKE_CXX_STANDARD_REQUIRED ON)
    
    
    
    ##############################################################################
    # Catkin
    ##############################################################################
    
    find_package(catkin REQUIRED COMPONENTS
      qt_build # qt_build provides the qt cmake glue
      roscpp
      sensor_msgs
      cv_bridge
      rosbag
      camera_image_msgs
    )
    
    include_directories(
      include
      ${catkin_INCLUDE_DIRS}
    )
    
    catkin_package(
      CATKIN_DEPENDS qt_build roscpp sensor_msgs cv_bridge rosbag camera_image_msgs
    )
    
    
    
    ##############################################################################
    # Qt Environment
    ##############################################################################
    set(CMAKE_AUTOUIC ON)
    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTORCC ON)
    
    # set(CMAKE_PREFIX_PATH "/home/dengjh/Qt/5.15.2/gcc_64")
    
    set(ModuleList 
        Core
        Gui
        Widgets
        Network
        Concurrent
    )
    
    foreach(QtModule ${ModuleList}) 
        # set(Qt5${QtModule}_DIR ${CMAKE_PREFIX_PATH}/lib/cmake/Qt5${QtModule})
        set(Qt5${QtModule}_DIR /home/dengjh/Qt/5.15.2/gcc_64/lib/cmake/Qt5${QtModule})
        set(QT_LIBRARIES ${QT_LIBRARIES} Qt5::${QtModule})
    endforeach()
    
    find_package(Qt5 REQUIRED ${ModuleList})
    
    
    file(GLOB QT_FORMS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ui/*.ui)
    file(GLOB QT_RESOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} resources/*.qrc)
    file(GLOB_RECURSE QT_MOC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS ui/*.h include/*.hpp *.h)
    
    QT5_ADD_RESOURCES(QT_RESOURCES_CPP ${QT_RESOURCES})
    QT5_WRAP_UI(QT_FORMS_HPP ${QT_FORMS})
    QT5_WRAP_CPP(QT_MOC_HPP ${QT_MOC})
    
    
    
    ##############################################################################
    # Sources
    ##############################################################################
    
    file(GLOB_RECURSE QT_SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS ui/*.cpp src/*.cpp *.cc *.cxx )
    
    
    
    ##############################################################################
    # Binaries
    ##############################################################################
    
    add_executable(${PROJECT_NAME} ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
    
    add_dependencies(${PROJECT_NAME}
      ${catkin_EXPORTED_TARGETS}
    )
    
    target_link_libraries(${PROJECT_NAME} ${QT_LIBRARIES} ${catkin_LIBRARIES})
    
    install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
    
    
    #############################################################################
    # DEBUG or RELEASE
    #############################################################################
    
    # 如果要生成debug版本
    # SET(CMAKE_BUILD_TYPE "Debug")
    # 如果要生成release版本
    # SET(CMAKE_BUILD_TYPE "Release")
    # 添加的支持debug和release支持
    # SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
    # SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")

     Qt CMake官方教程:https://doc.qt.io/qt-5/cmake-get-started.html

  • 相关阅读:
    HDU1069:Monkey and Banana(DP+贪心)
    hdu 4497 GCD and LCM(2013 ACM-ICPC吉林通化全国邀请赛——题目重现)
    vb6.0 倒计时
    硬盘分区表
    踽踽独行的岁月,感谢与你的相遇
    每天学点Linux:二
    windows下Qt Creator5.1.0编写程序以及调用OpenCV库
    【每周一译】愚蠢的指标:Java中使用最多的关键字
    centos 7 没有ifconfig 命令
    About stats collected
  • 原文地址:https://www.cnblogs.com/djh5520/p/16013614.html
Copyright © 2020-2023  润新知