-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
246 lines (209 loc) · 15 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
#
# QSuperMacros CMake script by Olivier Le Doeuff
#
## CMAKE INPUT
#
# - QSUPERMACROS_TARGET : Name of the library target. Default : "QSuperMacros"
# - QSUPERMACROS_PROJECT : Name of the project. Default : "QSuperMacros"
# - QSUPERMACROS_BUILD_SHARED : Build shared library [ON OFF]. Default: OFF.
# - QSUPERMACROS_BUILD_STATIC : Build static library [ON OFF]. Default: ON.
# - QSUPERMACROS_USE_NAMESPACE : If the library compile with a namespace. Default: OFF.
# - QSUPERMACROS_NAMESPACE : Namespace for the library. Only relevant if QSUPERMACROS_USE_NAMESPACE is ON. Default: "Qsm".
# - QSUPERMACROS_BUILD_DOC : Build the QSuperMacros Doc [ON OFF]. Default: OFF.
# - QSUPERMACROS_DOXYGEN_BT_REPOSITORY : Repository of DoxygenBt. Default : "https://github.com/OlivierLDff/DoxygenBootstrapped.git"
# - QSUPERMACROS_DOXYGEN_BT_TAG : Git Tag of DoxygenBt. Default : "v1.3.1"
#
## NAMING CONVENTION
#
# - QSUPERMACROS_USE_QT_PREFIX : Use Qt-ish internal attribute prefix m_attribute [ON OFF]. Default = OFF.
# - QSUPERMACROS_USE_QT_GETTERS : Use Qt-ish Getter naming convention attribute() [ON OFF]. Default = OFF.
# - QSUPERMACROS_USE_QT_SETTERS : Use Qt-ish Setter naming convention setAttribute [ON OFF]. Default = OFF.
# - QSUPERMACROS_USE_QT_RESETS : Use Qt-ish Setter naming convention resetAttribute [ON OFF]. Default = OFF.
# - QSUPERMACROS_USE_QT_SIGNALS : Use Qt-ish signal naming convention attributeChanged. It is really recommended to leave this option ON because QML Connections don't handle signals starting with Capital Letter [ON OFF]. Default = ON.
#
## CMAKE OUTPUT
#
# - QSUPERMACROS_TARGET : Output target to link to. Default: QSuperMacros
# - QSUPERMACROS_VERSION : Version of QSuperMacros
#
#
## VERSION
# - 1.0.0 : 06/12/2018 : Initial Work
# - 1.1.0 : 12/12/2018 : Reset functions
# - 1.2.0 : 08/2019 : Virtual getter and setter possibility + examples
# ┌──────────────────────────────────────────────────────────────────┐
# │ CMAKE PROPERTIES │
# └──────────────────────────────────────────────────────────────────┘
CMAKE_MINIMUM_REQUIRED( VERSION 3.1.0 )
# ┌──────────────────────────────────────────────────────────────────┐
# │ PROJECT SETTINGS │
# └──────────────────────────────────────────────────────────────────┘
SET( QSUPERMACROS_TARGET "QSuperMacros" CACHE STRING "Target Name" )
SET( QSUPERMACROS_PROJECT "QSuperMacros" CACHE STRING "Project Name")
SET( QSUPERMACROS_BUILD_SHARED OFF CACHE BOOL "Build shared lib for QSuperMacros" )
IF(NOT QSUPERMACROS_BUILD_SHARED)
SET( QSUPERMACROS_BUILD_STATIC ON CACHE BOOL "Build static lib for QSuperMacros" )
ELSE(NOT QSUPERMACROS_BUILD_SHARED)
SET( QSUPERMACROS_BUILD_STATIC OFF CACHE BOOL "Build static lib for QSuperMacros" )
ENDIF(NOT QSUPERMACROS_BUILD_SHARED)
SET( QSUPERMACROS_USE_NAMESPACE ON CACHE BOOL "If the library compile with a namespace.")
SET( QSUPERMACROS_NAMESPACE "Qsm" CACHE STRING "Namespace for the library. Only relevant if QSUPERMACROS_USE_NAMESPACE is ON")
SET( QSUPERMACROS_FOLDER_PREFIX "Qsm" CACHE STRING "Folder of target")
SET( QSUPERMACROS_BUILD_DOC OFF CACHE BOOL "Build QSuperMacros Doc with Doxygen" )
IF(QSUPERMACROS_BUILD_DOC)
SET( QSUPERMACROS_DOXYGEN_BT_REPOSITORY "https://github.com/OlivierLDff/DoxygenBootstrappedCMake.git" CACHE STRING "Repository of DoxygenBt" )
SET( QSUPERMACROS_DOXYGEN_BT_TAG v1.3.2 CACHE STRING "Git Tag of DoxygenBt" )
ENDIF(QSUPERMACROS_BUILD_DOC)
SET( QSUPERMACROS_USE_QT_PREFIX OFF CACHE BOOL "Use Qt-ish internal attribute prefix m_attribute [ON OFF]" )
SET( QSUPERMACROS_USE_QT_GETTERS ON CACHE BOOL "Use Qt-ish Getter naming convention attribute() [ON OFF]" )
SET( QSUPERMACROS_USE_QT_GETTERS_GET OFF CACHE BOOL "Use Getter naming convention getAttribute() [ON OFF]" )
SET( QSUPERMACROS_USE_QT_SETTERS ON CACHE BOOL "Use Qt-ish Setter naming convention setAttribute [ON OFF]" )
SET( QSUPERMACROS_USE_QT_RESETS ON CACHE BOOL "Use Qt-ish Reset naming convention resetAttribute [ON OFF]" )
SET( QSUPERMACROS_USE_QT_SIGNALS ON CACHE BOOL "Use Qt-ish signal naming convention attributeChanged. It is really recommended to leave this option ON because QML Connections don't handle signals starting with Capital Letter [ON OFF]" )
PROJECT( ${QSUPERMACROS_PROJECT} )
SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)
# ┌──────────────────────────────────────────────────────────────────┐
# │ QT5 CMAKE │
# └──────────────────────────────────────────────────────────────────┘
#required by Qt5
set (CMAKE_CXX_STANDARD 11)
FIND_PACKAGE(Qt5Core CONFIG REQUIRED)
FIND_PACKAGE(Qt5Qml CONFIG REQUIRED)
# ┌──────────────────────────────────────────────────────────────────┐
# │ VERSION │
# └──────────────────────────────────────────────────────────────────┘
# Project version must be set here
SET(QSUPERMACROS_VERSION_MAJOR 1)
SET(QSUPERMACROS_VERSION_MINOR 3)
SET(QSUPERMACROS_VERSION_PATCH 0)
SET(QSUPERMACROS_VERSION ${QSUPERMACROS_VERSION_MAJOR}.${QSUPERMACROS_VERSION_MINOR}.${QSUPERMACROS_VERSION_PATCH} CACHE STRING "Version")
IF( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git" )
EXECUTE_PROCESS(
COMMAND git rev-parse --short HEAD
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
OUTPUT_VARIABLE QSUPERMACROS_VERSION_TAG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
ELSE()
SET( QSUPERMACROS_VERSION_TAG 00000000 )
ENDIF()
SET( QSUPERMACROS_VERSION_TAG_HEX 0x${QSUPERMACROS_VERSION_TAG})
# ┌──────────────────────────────────────────────────────────────────┐
# │ STATUS │
# └──────────────────────────────────────────────────────────────────┘
MESSAGE( STATUS "------ ${QSUPERMACROS_TARGET} Configuration v${QSUPERMACROS_VERSION} ------" )
MESSAGE( STATUS "QSUPERMACROS_TARGET : ${QSUPERMACROS_TARGET}" )
MESSAGE( STATUS "QSUPERMACROS_PROJECT : ${QSUPERMACROS_PROJECT}" )
MESSAGE( STATUS "QSUPERMACROS_VERSION : ${QSUPERMACROS_VERSION}" )
MESSAGE( STATUS "QSUPERMACROS_VERSION_TAG_HEX : ${QSUPERMACROS_VERSION_TAG_HEX}" )
MESSAGE( STATUS "QSUPERMACROS_BUILD_SHARED : ${QSUPERMACROS_BUILD_SHARED}" )
MESSAGE( STATUS "QSUPERMACROS_BUILD_STATIC : ${QSUPERMACROS_BUILD_STATIC}" )
MESSAGE( STATUS "QSUPERMACROS_USE_NAMESPACE : ${QSUPERMACROS_USE_NAMESPACE}" )
IF(QSUPERMACROS_USE_NAMESPACE)
MESSAGE( STATUS "QSUPERMACROS_NAMESPACE : ${QSUPERMACROS_NAMESPACE}" )
ENDIF(QSUPERMACROS_USE_NAMESPACE)
MESSAGE( STATUS "QSUPERMACROS_BUILD_DOC : ${QSUPERMACROS_BUILD_DOC}" )
IF(QSUPERMACROS_BUILD_DOC)
MESSAGE( STATUS "QSUPERMACROS_DOXYGEN_BT_REPOSITORY : ${QSUPERMACROS_DOXYGEN_BT_REPOSITORY}" )
MESSAGE( STATUS "QSUPERMACROS_DOXYGEN_BT_TAG : ${QSUPERMACROS_DOXYGEN_BT_TAG}" )
ENDIF(QSUPERMACROS_BUILD_DOC)
MESSAGE( STATUS "QSUPERMACROS_USE_QT_PREFIX : ${QSUPERMACROS_USE_QT_PREFIX}" )
MESSAGE( STATUS "QSUPERMACROS_USE_QT_GETTERS : ${QSUPERMACROS_USE_QT_GETTERS}" )
MESSAGE( STATUS "QSUPERMACROS_USE_QT_GETTERS_GET : ${QSUPERMACROS_USE_QT_GETTERS_GET}" )
MESSAGE( STATUS "QSUPERMACROS_USE_QT_SETTERS : ${QSUPERMACROS_USE_QT_SETTERS}" )
MESSAGE( STATUS "QSUPERMACROS_USE_QT_RESETS : ${QSUPERMACROS_USE_QT_RESETS}" )
MESSAGE( STATUS "QSUPERMACROS_USE_QT_SIGNALS : ${QSUPERMACROS_USE_QT_SIGNALS}" )
MESSAGE( STATUS "------ ${QSUPERMACROS_TARGET} End Configuration ------" )
IF((QSUPERMACROS_BUILD_SHARED AND QSUPERMACROS_BUILD_STATIC) OR (NOT QSUPERMACROS_BUILD_SHARED AND NOT QSUPERMACROS_BUILD_STATIC))
MESSAGE( FATAL_ERROR "Set either Build shared or build static to ON, can't build both at once" )
ENDIF((QSUPERMACROS_BUILD_SHARED AND QSUPERMACROS_BUILD_STATIC) OR (NOT QSUPERMACROS_BUILD_SHARED AND NOT QSUPERMACROS_BUILD_STATIC))
# ┌──────────────────────────────────────────────────────────────────┐
# │ SOURCES │
# └──────────────────────────────────────────────────────────────────┘
SET( QSUPERMACROS_SRCS
# Main
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlAutoPropertyHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlConstRefPropertyHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlEnumClassHelper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlHelpersCommon.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlListPropertyHelper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlPtrPropertyHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlSingletonHelper.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QQmlVarPropertyHelpers.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QJsonImportExport.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/QJsonImportExport.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QSuperMacros.h
${CMAKE_CURRENT_SOURCE_DIR}/src/QSuperMacros.cpp
)
# ┌──────────────────────────────────────────────────────────────────┐
# │ TARGET │
# └──────────────────────────────────────────────────────────────────┘
IF(QSUPERMACROS_BUILD_SHARED)
IF( MSVC )
INCLUDE (GenerateExportHeader)
ENDIF( MSVC )
ADD_LIBRARY( ${QSUPERMACROS_TARGET} SHARED ${QSUPERMACROS_SRCS} )
IF( MSVC )
GENERATE_EXPORT_HEADER( ${QSUPERMACROS_TARGET}
BASE_NAME ${QSUPERMACROS_TARGET}
EXPORT_MACRO_NAME ${QSUPERMACROS_TARGET}_EXPORT
EXPORT_FILE_NAME ${QSUPERMACROS_TARGET}_Export.h
STATIC_DEFINE ${QSUPERMACROS_TARGET}_BUILT_AS_STATIC
)
ENDIF( MSVC )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PRIVATE -DQSUPERMACROS_SHARED )
ELSE()
ADD_LIBRARY( ${QSUPERMACROS_TARGET} STATIC ${QSUPERMACROS_SRCS} )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_STATIC )
ENDIF()
TARGET_INCLUDE_DIRECTORIES( ${QSUPERMACROS_TARGET} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PRIVATE -DQSUPERMACROS_VERSION_MAJOR=${QSUPERMACROS_VERSION_MAJOR} )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PRIVATE -DQSUPERMACROS_VERSION_MINOR=${QSUPERMACROS_VERSION_MINOR} )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PRIVATE -DQSUPERMACROS_VERSION_PATCH=${QSUPERMACROS_VERSION_PATCH} )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PRIVATE -DQSUPERMACROS_VERSION_TAG=${QSUPERMACROS_VERSION_TAG} )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PRIVATE -DQSUPERMACROS_VERSION_TAG_HEX=${QSUPERMACROS_VERSION_TAG_HEX} )
IF(QSUPERMACROS_USE_NAMESPACE)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_NAMESPACE )
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_NAMESPACE=${QSUPERMACROS_NAMESPACE} )
ENDIF(QSUPERMACROS_USE_NAMESPACE)
IF(QSUPERMACROS_USE_QT_PREFIX)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_QT_PREFIX )
ENDIF(QSUPERMACROS_USE_QT_PREFIX)
IF(QSUPERMACROS_USE_QT_GETTERS)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_QT_GETTERS )
ENDIF(QSUPERMACROS_USE_QT_GETTERS)
IF(QSUPERMACROS_USE_QT_GETTERS_GET)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_QT_GETTERS_GET )
ENDIF(QSUPERMACROS_USE_QT_GETTERS_GET)
IF(QSUPERMACROS_USE_QT_SETTERS)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_QT_SETTERS )
ENDIF(QSUPERMACROS_USE_QT_SETTERS)
IF(QSUPERMACROS_USE_QT_RESETS)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_QT_RESETS )
ENDIF(QSUPERMACROS_USE_QT_RESETS)
IF(QSUPERMACROS_USE_QT_SIGNALS)
TARGET_COMPILE_DEFINITIONS( ${QSUPERMACROS_TARGET} PUBLIC -DQSUPERMACROS_USE_QT_SIGNALS )
ENDIF(QSUPERMACROS_USE_QT_SIGNALS)
if(QSUPERMACROS_FOLDER_PREFIX)
set_target_properties(${QSUPERMACROS_TARGET} PROPERTIES FOLDER ${QSUPERMACROS_FOLDER_PREFIX})
endif()
qt5_use_modules( ${QSUPERMACROS_TARGET} Core Qml )
# ┌──────────────────────────────────────────────────────────────────┐
# │ DOXYGEN │
# └──────────────────────────────────────────────────────────────────┘
IF(QSUPERMACROS_BUILD_DOC)
SET( DOXYGEN_BOOTSTRAP_COMPANY OlivierLDff )
SET( DOXYGEN_BOOTSTRAP_PUBLISHER OlivierLDff )
SET( DOXYGEN_BOOTSTRAP_PROJECT_NAME ${QSUPERMACROS_TARGET} )
SET( DOXYGEN_BOOTSTRAP_PROJECT_VERSION ${QSUPERMACROS_VERSION} )
SET( DOXYGEN_BOOTSTRAP_PROJECT_BRIEF "Additional data models aimed to bring more power to QML applications by using useful C++ models in back-end." )
SET( DOXYGEN_BOOTSTRAP_PROJECT_LOGO )
SET( DOXYGEN_BOOTSTRAP_OUTPUT_DIRECTORY "Docs" )
SET( DOXYGEN_BOOTSTRAP_SRC_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/src )
SET( DOXYGEN_BOOTSTRAP_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md )
SET( DOXYGEN_TARGET_PREFIX "" )
SET( DOXYGEN_TARGET_SUFFIX "Doc" )
SET( DOXYGEN_BT_REPOSITORY ${QSUPERMACROS_DOXYGEN_BT_REPOSITORY} )
SET( DOXYGEN_BT_TAG ${QSUPERMACROS_DOXYGEN_BT_TAG} )
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/cmake/BuildDoxygenBt.cmake)
ENDIF(QSUPERMACROS_BUILD_DOC)