-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
62 lines (48 loc) · 1.37 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
project("Tree Model")
set(EXE_NAME "treemodel")
cmake_minimum_required(VERSION 2.8.11)
# Enable C++11
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
option(QT5_BUILD "Force Qt5 build" ON)
include_directories(${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR})
set(HEADERS
mainwindow.h
treemodel.h
abstracttreeitem.h
abstracttreemodel.h
)
set(SOURCES
main.cpp
mainwindow.cpp
treemodel.cpp
abstracttreeitem.cpp
abstracttreemodel.cpp
)
set(FORMS
mainwindow.ui
)
if(QT5_BUILD)
find_package(Qt5Core REQUIRED)
find_package(Qt5Gui REQUIRED)
find_package(Qt5Widgets REQUIRED)
include_directories(${Qt5Core_INCLUDE_DIRS})
include_directories(${Qt5Gui_INCLUDE_DIRS})
include_directories(${Qt5Widgets_INCLUDE_DIRS})
add_definitions(${Qt5Core_DEFINITIONS})
add_definitions(${Qt5Gui_DEFINITIONS})
add_definitions(${Qt5Widgets_DEFINITIONS})
add_definitions(-DHAVE_QT5)
qt5_wrap_cpp(MOC_SOURCES ${HEADERS})
qt5_wrap_ui(UI_SOURCES ${FORMS})
else()
find_package(Qt4 REQUIRED)
include(${QT_USE_FILE})
qt4_wrap_cpp(MOC_SOURCES ${HEADERS})
qt4_wrap_ui(UI_SOURCES ${FORMS})
endif()
add_executable(${EXE_NAME} WIN32 MACOSX_BUNDLE ${HEADERS} ${SOURCES} ${MOC_SOURCES} ${UI_SOURCES})
if(QT5_BUILD)
target_link_libraries(${EXE_NAME} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES})
else()
target_link_libraries(${EXE_NAME} ${QT_LIBRARIES})
endif()