Created
January 18, 2015 02:39
-
-
Save michalpelka/be3b8b4c949f579209ef to your computer and use it in GitHub Desktop.
QT 5 Basic CMAKE
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 2.8.3) | |
project(testproject) | |
# Find includes in corresponding build directories | |
set(CMAKE_INCLUDE_CURRENT_DIR ON) | |
set(CMAKE_AUTOMOC ON) | |
# Find the QtWidgets library | |
find_package(Qt5Widgets) | |
# Add the include directories for the Qt 5 Widgets module to | |
# the compile lines. | |
set(UI_FILES | |
mainwindow.ui | |
) | |
qt5_wrap_ui(UI_HEADERS ${UI_FILES}) | |
include_directories(${Qt5Widgets_INCLUDE_DIRS}) | |
# 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}") | |
# Tell CMake to create the helloworld executable | |
add_executable(helloworld main.cpp mainwindow.cpp ${UI_FILES}) | |
#Link the helloworld executable to the Qt 5 widgets library. | |
target_link_libraries(helloworld Qt5::Widgets) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment