forked from cutelyst/cutelee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
284 lines (226 loc) · 10.1 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
cmake_minimum_required(VERSION 3.10)
project(Cutelee VERSION 6.0.0 LANGUAGES CXX)
# Workaround for http://public.kitware.com/Bug/view.php?id=12301
if (MINGW)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build,
options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release
RelWithDebInfo MinSizeRel Coverage." FORCE)
endif()
endif()
include(GNUInstallDirs)
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.6.0 COMPONENTS Core REQUIRED)
option(BUILD_SHARED_LIBS "Build in shared lib mode" ON)
option( BUILD_TEMPLATES "Build the Cutelee template library" TRUE )
option( BUILD_TEXTDOCUMENT "Build the Cutelee textdocument library" TRUE )
option( BUILD_MAIN_PLUGINS "Build the Cutelee Templates plugins" TRUE )
option( BUILD_I18N_PLUGIN "Build the Cutelee Templates i18n plugin" TRUE )
option( BUILD_TESTS "Build the Cutelee tests" TRUE )
if (BUILD_TESTS)
enable_testing()
endif()
set(Cutelee_MODULE_DIR ${CMAKE_SOURCE_DIR}/cmake/modules)
list(APPEND CMAKE_MODULE_PATH ${Cutelee_MODULE_DIR})
include(GenerateExportHeader)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
# create coverage build type
set(CMAKE_CONFIGURATION_TYPES ${CMAKE_CONFIGURATION_TYPES} Coverage )
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo" "Coverage")
endif()
if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
set(CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -fprofile-arcs -ftest-coverage")
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-long-long -std=iso9899:1990 -Wundef -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security -Wmissing-format-attribute -fno-common")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-check-new -fno-common -pedantic-errors")
if (NOT APPLE)
set ( CMAKE_SHARED_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined ${CMAKE_SHARED_LINKER_FLAGS}")
set ( CMAKE_MODULE_LINKER_FLAGS "-Wl,--fatal-warnings -Wl,--no-undefined ${CMAKE_MODULE_LINKER_FLAGS}")
endif ()
endif()
add_definitions(
-DQT_NO_KEYWORDS
-DQT_NO_CAST_TO_ASCII
-DQT_NO_CAST_FROM_ASCII
-DQT_STRICT_ITERATORS
-DQT_NO_URL_CAST_FROM_STRING
-DQT_NO_CAST_FROM_BYTEARRAY
-DQT_USE_QSTRINGBUILDER
-DQT_NO_SIGNALS_SLOTS_KEYWORDS
-DQT_USE_FAST_OPERATOR_PLUS
-DQT_DISABLE_DEPRECATED_BEFORE=0x050c00
)
# Always include the source and build directories in the include path
# to save doing so manually in every subdirectory.
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
set(CMAKE_AUTOMOC ON)
set(Cutelee_MIN_PLUGIN_VERSION 0)
set(Cutelee_MAJOR_MINOR_VERSION_STRING "${Cutelee_VERSION_MAJOR}.${Cutelee_VERSION_MINOR}" )
set (LIB_SUFFIX "" CACHE STRING "Define suffix of library directory name (eg. '64')")
set( LIB_INSTALL_DIR lib${LIB_SUFFIX} )
set( PLUGIN_INSTALL_DIR ${LIB_INSTALL_DIR}/cutelee/${Cutelee_MAJOR_MINOR_VERSION_STRING} )
# set up RPATH/install_name_dir
set( CMAKE_INSTALL_NAME_DIR ${CMAKE_INSTALL_PREFIX}/${LIB_INSTALL_DIR})
set( CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set( CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
include("${Cutelee_MODULE_DIR}/CuteleeMacros.cmake")
if (BUILD_TEMPLATES)
add_subdirectory(templates)
endif()
if (BUILD_TEXTDOCUMENT)
add_subdirectory(textdocument)
endif()
set(CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}" )
configure_file(
"${Cutelee_MODULE_DIR}/CuteleeConfig.cmake.in"
"${CMAKE_BINARY_DIR}/Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}Config.cmake"
@ONLY
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${CMAKE_BINARY_DIR}/Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}ConfigVersion.cmake"
VERSION ${Cutelee_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(FILES
"${CMAKE_BINARY_DIR}/Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}Config.cmake"
"${CMAKE_BINARY_DIR}/Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}ConfigVersion.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}"
COMPONENT Common
)
install(FILES
"${Cutelee_MODULE_DIR}/CuteleeMacros.cmake"
RENAME "Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}Macros.cmake"
DESTINATION "${CMAKECONFIG_INSTALL_DIR}/"
COMPONENT Common
)
install(EXPORT cutelee_targets
DESTINATION ${CMAKECONFIG_INSTALL_DIR}
FILE "Cutelee${Cutelee_VERSION_MAJOR}Qt${QT_VERSION_MAJOR}Targets.cmake"
NAMESPACE Cutelee::
COMPONENT Common
)
# Add support for an uninstall target
configure_file(
"${Cutelee_MODULE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
@ONLY)
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
if (BUILD_DOCS)
find_package(Doxygen REQUIRED dot)
if (DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND)
message (STATUS "Doxygen and dot found. make docs target is available")
# Add support for a docs target
# Available from http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
set(STLTAGFILE "${CMAKE_SOURCE_DIR}/scripts/libstdc++.tag=http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen")
find_file(qtcore_tag_file
qtcore.tags
HINTS
"/usr/share/qt5/doc/qtcore"
)
set(QTTAGFILE "${qtcore_tag_file}=https://doc.qt.io/qt-5/")
set(TAGFILES "${QTTAGFILE} ${STLTAGFILE}")
set(DOCS_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
configure_file(
"${Cutelee_MODULE_DIR}/Doxyfile.in"
"${CMAKE_CURRENT_BINARY_DIR}/Doxyfile"
@ONLY)
# Add support for a Qt assistant docs target
# qttags.tag is too big to distribute with Cutelee. Get it
# from http://api.kde.org/kdereview-api/kdereview.tar.gz for example.
if(EXISTS ${qtcore_tag_file})
set(DOCS_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/qtdocs")
# Available from http://steveire.com/libstdc++-longnames.tag
# Also recommended: http://www.steveire.com/libstdc++-v3.qch
set(STLTAGFILE "${CMAKE_SOURCE_DIR}/scripts/libstdc++-longnames.tag=qthelp://org.gnu.libstdcxx/libstdc++-v3/")
set(QTTAGFILE "${qtcore_tag_file}=qthelp://org.qt-project.qtcore/qtcore/")
set(TAGFILES "${QTTAGFILE} ${STLTAGFILE}")
set(GENERATE_QHP "yes")
configure_file(
"${Cutelee_MODULE_DIR}/Doxyfile.in"
"${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt"
@ONLY)
endif()
set( DOCS_ARGS ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile" )
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt")
set(DOCS_ARGS ${DOCS_ARGS} COMMAND ${DOXYGEN_EXECUTABLE} "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.qt" )
endif()
add_custom_target(docs
${DOCS_ARGS}
)
endif()
endif()
find_package(LCov)
if(LCOV_FOUND)
get_property(UNITTESTS GLOBAL PROPERTY TEST_COVERAGE)
set(coverageDir ${CMAKE_BINARY_DIR})
set(coverage_ARGS)
foreach(_testpath ${UNITTESTS})
list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} -z -d ${coverageDir})
get_filename_component(_test ${_testpath} NAME)
list(APPEND coverage_ARGS COMMAND ${_testpath})
list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} -c -t ${_test} -d ${coverageDir} -o ${CMAKE_BINARY_DIR}/test_${_test}.info)
set(infoFiles ${infoFiles} -a ${CMAKE_BINARY_DIR}/test_${_test}.info)
endforeach()
list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} ${infoFiles} -o test_all.info)
# For an unknown reason lcov does not work with absolute paths such as ${CMAKE_BINARY_DIR}
file(RELATIVE_PATH relBinaryDir / ${CMAKE_BINARY_DIR})
find_package(QT NAMES Qt6 Qt5 COMPONENTS Core REQUIRED)
find_package(Qt${QT_VERSION_MAJOR} 5.6.0 COMPONENTS Core REQUIRED)
get_property(qmake_loc TARGET Qt5::qmake PROPERTY LOCATION)
execute_process(COMMAND "${qmake_loc}" -query QT_INSTALL_HEADERS
RESULT_VARIABLE return_code
OUTPUT_VARIABLE output
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_STRIP_TRAILING_WHITESPACE)
if(return_code)
message(FATAL_ERROR "Problem")
endif()
file(TO_CMAKE_PATH "${output}" output)
file(RELATIVE_PATH relQtDir / ${output})
set(Qt4_exclude -r test_all.info *${relQtDir}*)
list(APPEND coverage_ARGS COMMAND ${LCOV_EXECUTABLE} -r test_all.info *${relBinaryDir}*
-r test_all.info *pluginpointer*
-r test_all.info *usr/include*
${Qt4_exclude}
-o test_all.info
)
list(APPEND coverage_ARGS COMMAND ${CMAKE_COMMAND} -E remove_directory coverage)
list(APPEND coverage_ARGS COMMAND ${GENHTML_EXECUTABLE} -o coverage/ -s --demangle-cpp -f test_all.info --prefix ${CMAKE_SOURCE_DIR})
add_custom_target(coverage
${coverage_ARGS}
)
endif()
find_package(Cccc)
if (CCCC_FOUND)
macro(append_target_sources target)
if (TARGET ${target})
get_target_property(_tar_files ${target} SOURCES)
foreach(f ${_tar_files})
if(IS_ABSOLUTE f)
list(APPEND target_files ${f})
else()
list(APPEND target_files ${${target}_SOURCE_DIR}/${f})
endif()
endforeach()
endif()
endmacro()
append_target_sources(Cutelee_Templates)
append_target_sources(Cutelee_TextDocument)
append_target_sources(cutelee_defaultfilters)
append_target_sources(cutelee_defaulttags)
append_target_sources(cutelee_loadertags)
append_target_sources(cutelee_i18ntags)
set(cccc_ARGS ${CCCC_EXECUTABLE} ${target_files} --outdir=${CMAKE_BINARY_DIR}/cccc --html_outfile=${CMAKE_BINARY_DIR}/cccc/index.html)
add_custom_target(cccc
${cccc_ARGS}
)
endif()
include(CPackConfig)