Help with CMake for Qt using QGL
-
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.