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. Help with CMake for Qt using QGL
Forum Updated to NodeBB v4.3 + New Features

Help with CMake for Qt using QGL

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.3k 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.
  • K Offline
    K Offline
    knowNothing
    wrote on last edited by
    #1

    I am using Ubuntu 12.10 and I need to create a cmake for my simple qt project using qgl. Also, I am using Qt5.0.1.

    Here is my CMakeLists.txt file:
    @
    CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
    PROJECT(RobotsGUI)

    #configure_file(
    #"${PROJECT_SOURCE_DIR}/RobotsGUI.h.in"
    #"${PROJECT_BINARY_DIR}/RobotsGUI.h"
    #)

    #include_directories("${PROJECT_BINARY_DIR}")

    add_executable(RobotsGUI main.cpp)

    Find includes in corresponding build directories

    set(CMAKE_INCLUDE_CURRENT_DIR ON)

    Instruct CMake to run moc automatically when needed.

    set(CMAKE_AUTOMOC ON)
    SET(CMAKE_BUILD_TYPE Release)
    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/opt/Qt5.0.1/5.0.1/gcc_64/lib/cmake/Qt5OpenGL)

    Find includes in corresponding build directories

    set(CMAKE_INCLUDE_CURRENT_DIR ON)

    Tell CMake to create the helloworld executable

    #add_executable(RobotsGUI main.cpp)

    Use the Widgets module from Qt 5.

    #qt5_use_modules(RobotsGUI Widgets)

    SET(CMAKE_CXX_FLAGS "-Wall")

    #QT5 Handling
    #find_package(Qt5Core)
    get_target_property(QtCore_location Qt5::Core LOCATION)

    #FIND_PACKAGE(Qt5Widgets)
    #find_package(Qt5Declarative)
    #INCLUDE(${Qt5Declarative_USE_FILE})

    #qt5_use_modules(RobotsGUI Widgets QtOPENGL)

    get_target_property(QtCore_location Qt5::Core LOCATION)

    #comes after you find it
    #INCLUDE(${QT_USE_FILE})

    #include for each module used.
    #INCLUDE(${Qt5Widgets_INCLUDE_DIRS},${Qt5Widgets_LIBRARIES}, ${Qt5Declarative_INCLUDE_DIRS},${Qt5Declarative_LIBRARIES})

    SET(RobotsGUI_SOURCES glwidget.cpp main.cpp mainwindow.cpp)
    SET(RobotsGUI_HEADERS glwidget.h mainwindow.h)
    SET(RobotsGUI_FORMS mainwindow.ui)
    SET(QT_USE_QTOPENGL TRUE)

    #QT5_WRAP_CPP(RobotsGUI_HEADERS_MOC ${RobotsGUI_HEADERS})
    #QT5_WRAP_UI(RobotsGUI_FORMS_HEADERS ${RobotsGUI_FORMS})

    INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
    INCLUDE_DIRECTORIES( . )

    Use the compile definitions defined in the Qt 5 Widgets module

    add_definitions(${Qt5Widgets_DEFINITIONS})

    Add compiler flags for building executables (-fPIE)

    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS}")

    ADD_DEFINITIONS($ {QT_DEFINITIONS})

    #ADD_EXECUTABLE(RobotsGUI ${RobotsGUI_SOURCES}

    ${RobotsGUI_HEADERS_MOC}

    ${RobotsGUI_FORMS_HEADERS})

    #qt5_generate_moc(main.cpp main.moc)
    #add_executable(RobotsGUI main.cpp main.moc)

    #TARGET_LINK_LIBRARIES(${Qt5Widgets_LIBRARIES} ${QT_LIBRARIES})
    INSTALL_TARGETS( /bin RobotsGUI)
    @
    As you see I commented out many statements, because they gave me trouble. I am a complete novice on cmake and found most of the code online. Another thing, all include statements are not found.
    Could you help me fixing some things out? Is there a software to automatically create CMake files?

    Thank you.

    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