-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
145 lines (118 loc) · 2.77 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
cmake_minimum_required(VERSION 3.0)
# set the project name
project(qtmmlwidget-qt5 VERSION 2.4.2)
# specify the C++ standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# Set QTMMLWIDGET_STATIC to TRUE to compile a static library
if (NOT DEFINED QTMMLWIDGET_STATIC)
set(QTMMLWIDGET_STATIC FALSE)
endif()
# Set QTMMLWIDGET_BUILD_EXAMPLE to FALSE to avoid building the example
if (NOT DEFINED QTMMLWIDGET_BUILD_EXAMPLE)
set(QTMMLWIDGET_BUILD_EXAMPLE TRUE)
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_AUTOUIC ON)
if(CMAKE_VERSION VERSION_LESS "3.7.0")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
find_package(Qt5 COMPONENTS Xml Gui Widgets REQUIRED)
set(qtmmlwidget_LIB_SOURCES
src/QtMmlDocument
src/QtMmlWidget
src/qtmmlwidget.cpp
src/qtmmlwidget.h
)
if (QTMMLWIDGET_STATIC)
# Static library
add_library(qtmmlwidget STATIC ${qtmmlwidget_LIB_SOURCES})
target_compile_definitions(qtmmlwidget
PUBLIC
QT_QTMMLWIDGET_LIBRARY_STATIC
)
else()
# Dynamic library
add_library(qtmmlwidget SHARED ${qtmmlwidget_LIB_SOURCES})
# Put the import library along with dll
set_target_properties(qtmmlwidget PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
endif()
# Handle visibility symbols
target_compile_definitions(qtmmlwidget
PRIVATE
QT_QTMMLWIDGET_LIBRARY_BUILD
)
target_link_libraries(qtmmlwidget
PUBLIC # These are part of the API
Qt5::Xml
Qt5::Gui
Qt5::Widgets
)
target_include_directories(qtmmlwidget
SYSTEM INTERFACE
${CMAKE_CURRENT_SOURCE_DIR}/src
)
# Enable warnings
if (MSVC)
# warning level 4
target_compile_options(qtmmlwidget
PRIVATE
/W4
)
else()
# warning level 4
target_compile_options(qtmmlwidget
PRIVATE
-Wall -Wextra
)
endif()
# Disable unnecessary warnings
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
target_compile_options(qtmmlwidget
PRIVATE
-Wno-shadow
-Wno-format-security
-Wno-conversion
-Wno-redundant-decls
-Wno-cast-qual
-Wno-zero-as-null-pointer-constant
-Wno-unused-macros
-Wno-implicit-fallthrough
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(qtmmlwidget
PRIVATE
-Wno-unreachable-code
)
endif()
endif()
# --- Example
set(qtmmlwidget_EXAMPLE_SOURCES
example/filebrowser.cpp
example/filebrowser.h
example/main.cpp
example/mainwindow.cpp
example/mainwindow.h
example/example.qrc
)
if (QTMMLWIDGET_BUILD_EXAMPLE)
add_executable(qtmmlwidget_example ${qtmmlwidget_EXAMPLE_SOURCES})
target_link_libraries(qtmmlwidget_example
PRIVATE
qtmmlwidget
)
if (MSVC)
# warning level 4
target_compile_options(qtmmlwidget_example
PRIVATE
/W4
)
else()
# warning level 4
target_compile_options(qtmmlwidget_example
PRIVATE
-Wall -Wextra
)
endif()
endif()