Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- set(CMAKE_GENERATOR "Unix Makefiles")
- message("generator is set to ${CMAKE_GENERATOR}")
- cmake_minimum_required(VERSION 2.8)
- project(cmake_qt_test)
- include (CMakeForceCompiler)
- find_package(PkgConfig REQUIRED)
- pkg_check_modules(QTCORE REQUIRED Qt5Core)
- # pkg_check_modules(QTGUI REQUIRED Qt5Gui)
- pkg_check_modules(QTWIDGETS REQUIRED Qt5Widgets)
- find_package(Qt5Widgets)
- #include_directories(${PROJECT_SOURCE_DIR} ${QTWIDGETS_INCLUDE_DIRS} ${QTCORE_INCLUDE_DIRS})
- #message("Qt5 Core include directory is set to ${QTCORE_INCLUDE_DIRS}")
- ## message("Qt5 GUI include directory is set to ${QTGUI_INCLUDE_DIRS}")
- #message("Qt5 Core include directory is set to ${QTWIDGETS_INCLUDE_DIRS}")
- #get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
- #message("all project include directories: ${inc_dirs}")
- #target_link_libraries(${PROJECT_NAME} m ${QTWIDGETS_LIBRARIES} ${QTCORE_LIBRARIES})
- # Instruct CMake to run moc automatically when needed.
- set(CMAKE_AUTOMOC ON)
- #set_target_properties(${PROJECT_NAME} PROPERTIES AUTOMOC TRUE)
- #set (MOC_HEADERS mainwindow.h)
- #set(CMAKE_AUTOUIC ON)
- #set(UIS mainwindow.ui)
- set(CMAKE_INCLUDE_CURRENT_DIR ON)
- qt5_wrap_cpp(mainwindow_moc mainwindow.h)
- qt5_wrap_ui(mainwindow_gui mainwindow.ui)
- add_library(mainwindow ${mainwindow_moc} ${mainwindow_gui})
- qt5_use_modules(mainwindow Widgets)
- add_executable(${PROJECT_NAME} "main.cpp" mainwindow)
- qt5_use_modules(${PROJECT_NAME} Core Gui Widgets)
- SET(CMAKE_POSITION_INDEPENDENT_CODE ON)
- SET (CMAKE_CXX_FLAGS "-fPIC")
- # Add -O0 to remove optimizations when using gcc
- IF(CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
- set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0")
- ENDIF(CMAKE_COMPILER_IS_GNUCC)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement