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. Unable to include directories in CMake
Forum Updated to NodeBB v4.3 + New Features

Unable to include directories in CMake

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
2 Posts 1 Posters 3.6k 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.
  • G Offline
    G Offline
    ghkraju
    wrote on last edited by ghkraju
    #1

    Hi, I am trying to write a CMakeLists.txt for one of my project. Details about the versions are as follows:

    Qt 5.5.1 (Ubuntu 16.04 distro Version)
    CMake 3.5.1

    cmake_minimum_required(VERSION 2.8.3)

    project(aps_ros)

    find_package(catkin REQUIRED COMPONENTS rviz roscpp)

    find_package(VTK REQUIRED)

    catkin_package()

    set(VTK_INCLUDE_DIRS /usr/local/include/vtk-7.0/)
    set(VTK_LIBRARY_DIRS /usr/local/lib)
    set(CMAKE_INCLUDE_CURRENT_DIR ON)

    set(QT_INCLUDES /usr/include/x86_64-linux-gnu/qt5/)
    set(QT_LIBRARIES /usr/lib/x86_64-linux-gnu)

    include_directories(${catkin_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${QT_INCLUDES} ${QT_INCLUDES}/QtCore)

    link_directories(${catkin_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS})

    set(CMAKE_AUTOMOC ON)
    set(CMAKE_AUTOUIC ON)

    if(rviz_QT_VERSION VERSION_LESS "5")
    message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
    find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
    include(${QT_USE_FILE})
    else()
    message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
    find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Gui OpenGL Widgets)
    endif()

    add_definitions(-DQT_THREAD_SUPPORT)

    set(HEADER_FILES configdialog.h vwidget.h loggerwidget.h mainwindow.h)
    set(SOURCE_FILES configdialog.cpp vwidget.cpp loggerwidget.cpp mainwindow.cpp main.cpp)
    set(WINDOW_FORMS configdialog.ui mainwindow.ui)

    qt5_wrap_ui(MOC_UI_FILES ${WINDOW_FORMS})

    qt5_wrap_cpp(SRC_FILES ${SOURCE_FILES})

    add_executable(aps ${SRC_FILES} ${MOC_UI_FILES} ${HEADER_FILES})

    target_link_libraries(aps Qt5::Core Qt5::Widgets Qt5::Gui ${catkin_LIBRARIES} ${VTK_LIBRARIES} ${MOC_UI_FILES})

    install(TARGETS aps DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})

    /***********************************************

    I am receiving the following error:

    [ 84%] Linking CXX executable /home/hemanth/viz_ws/devel/lib/aps_ros/aps
    ui_configdialog.h:12:27: fatal error: QtCore/QVariant: No such file or directory
    compilation terminated.
    ui_mainwindow.h:12:27: fatal error: QtCore/QVariant: No such file or directory
    compilation terminated.
    APS_ROS/CMakeFiles/aps.dir/build.make:418: recipe for target '/home/hemanth/viz_ws/devel/lib/aps_ros/aps' failed
    make[2]: *** [/home/hemanth/viz_ws/devel/lib/aps_ros/aps] Error 1
    CMakeFiles/Makefile2:3236: recipe for target 'APS_ROS/CMakeFiles/aps.dir/all' failed
    make[1]: *** [APS_ROS/CMakeFiles/aps.dir/all] Error 2
    Makefile:138: recipe for target 'all' failed
    make: *** [all] Error 2
    Invoking "make -j4 -l4" failed

    Any suggestions on how to correct this issue?

    Thanks in advance..!!!

    1 Reply Last reply
    0
    • G Offline
      G Offline
      ghkraju
      wrote on last edited by
      #2

      I have solved the issue by searching in internet. May be this could help to solve if you face any issues:
      (This CMakeLists.txt is used for a project in Qt and integrates ROS functionalities in it)

      Please do let me know, if you have any queries.....

      ## First start with some standard catkin stuff.
      cmake_minimum_required(VERSION 2.8.3)
      
      project(aps_ros)
      
      # Set mandatory compiler c++ standard support
      set(CPP_STD "11")
      if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
        include(CheckCXXCompilerFlag)
        CHECK_CXX_COMPILER_FLAG("-std=c++${CPP_STD}" COMPILER_SUPPORTS_CXX${CPP_STD})
        if(COMPILER_SUPPORTS_CXX${CPP_STD})
          set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CPP_STD}")
        else()
          message(FATAL_ERROR "ERROR: The compiler ${CMAKE_CXX_COMPILER} has no C++${CPP_STD} support.\n"
                              "Please use a different C++ compiler.")
        endif()
      endif()
      
      
      find_package(catkin REQUIRED COMPONENTS rviz roscpp)
      
      find_package(VTK REQUIRED)
      
      catkin_package()
      set(CMAKE_INCLUDE_PATH /usr/include/x86_64-linux-gnu/qt5/)
      set(VTK_INCLUDE_DIRS /usr/local/include/vtk-7.0/)
      set(VTK_LIBRARY_DIRS /usr/local/lib)
      set(CMAKE_INCLUDE_CURRENT_DIR ON)
      
      
      ## This setting causes Qt's "MOC" generation to happen automatically.
      ##set(CMAKE_AUTOMOC ON)
      ##set(CMAKE_AUTOUIC ON)
      
      ## This plugin includes Qt widgets, so we must include Qt.
      ## We'll use the version that rviz used so they are compatible.
      if(rviz_QT_VERSION VERSION_LESS "5")
        message(STATUS "Using Qt4 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
        find_package(Qt4 ${rviz_QT_VERSION} EXACT REQUIRED QtCore QtGui)
        ## pull in all required include dirs, define QT_LIBRARIES, etc.
        include(${QT_USE_FILE})
      else()
        message(STATUS "Using Qt5 based on the rviz_QT_VERSION: ${rviz_QT_VERSION}")
      message( STATUS "-----> Current Qt Installation Path : " ${QTDIR})
        find_package(Qt5 ${rviz_QT_VERSION} EXACT REQUIRED Core Widgets)
      	##find_package(Qt5Core)
      	##find_package(Qt5Gui)
      	##find_package(Qt5Widgets)
      	##find_package(Qt5OpenGL)
        ## make target_link_libraries(${QT_LIBRARIES}) pull in all required dependencies
        set(QT_LIBRARIES Qt5::Widgets Qt5::Core)	
        ##include(${QT_USE_FILE})
        ##include(${VTK_USE_FILE})
      endif()
      
      ## I prefer the Qt signals and slots to avoid defining "emit", "slots",
      ## etc because they can conflict with boost signals, so define QT_NO_KEYWORDS here.
      ##add_definitions(-DQT_NO_KEYWORDS)
      add_definitions(${QT_DEFINITIONS})
      
      
      include_directories(${catkin_INCLUDE_DIRS} ${VTK_INCLUDE_DIRS} ${CMAKE_BINARY_DIR})
      
      link_directories(${catkin_LIBRARY_DIRS} ${VTK_LIBRARY_DIRS})
      
      set(HEADER_FILES 
      		include/configdialog.h 
      		include/vwidget.h 
      		include/loggerwidget.h 
      		include/mainwindow.h
      		include/rosvizwidget.h)
      set(SOURCES 
      		sources/configdialog.cpp 
      		sources/vwidget.cpp 
      		sources/loggerwidget.cpp 
      		sources/rosvizwidget.cpp
      		sources/mainwindow.cpp 
      		sources/main.cpp)
      set(WINDOW_FORMS 
      		windows/configdialog.ui 
      		windows/mainwindow.ui)
      
      qt5_wrap_ui(UI_HEADERS ${WINDOW_FORMS})
      
      qt5_wrap_cpp(MOC_SRCS ${HEADER_FILES})
      
      add_executable(aps ${SOURCES} ${MOC_SRCS} ${UI_HEADERS})
      
      target_include_directories(
        aps
          PUBLIC
            ${CMAKE_CURRENT_SOURCE_DIR}/include
          PRIVATE
            # NOTHING YET
      )
      
      ## Link external libraries here
      target_link_libraries(aps ${QT_LIBRARIES} ${catkin_LIBRARIES} ${VTK_LIBRARIES})
      
      ## Install
      install(TARGETS aps DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION})
      
      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