blob: 0d4d036ef1256c15276d06364133f292e0383676 (
plain)
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
|
add_definitions(-Dlibical_ical_EXPORTS)
# build ical-glib-src-generator
add_executable(ical-glib-src-generator
tools/generator.c
tools/generator.h
tools/xml-parser.c
tools/xml-parser.h
)
target_compile_options(ical-glib-src-generator PUBLIC ${GLIB_CFLAGS} ${LIBXML_CFLAGS} -DG_LOG_DOMAIN=\"src-generator\")
target_link_libraries(ical-glib-src-generator ${GLIB_LIBRARIES} ${LIBXML_LIBRARIES})
install(
TARGETS ical-glib-src-generator
EXPORT IcalGlibSrcGenerator
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/libical
)
install(
EXPORT IcalGlibSrcGenerator
NAMESPACE native-
DESTINATION ${LIB_INSTALL_DIR}/cmake/LibIcal
)
list(APPEND API_FILES
api/i-cal-array.xml
api/i-cal-attach.xml
api/i-cal-comp-iter.xml
api/i-cal-component.xml
api/i-cal-datetimeperiod.xml
api/i-cal-derived-parameter.xml
api/i-cal-derived-property.xml
api/i-cal-derived-value.xml
api/i-cal-duration.xml
api/i-cal-enums.xml
api/i-cal-error.xml
api/i-cal-geo.xml
api/i-cal-memory.xml
api/i-cal-mime.xml
api/i-cal-parameter.xml
api/i-cal-parser.xml
api/i-cal-period.xml
api/i-cal-property.xml
api/i-cal-recur-iterator.xml
api/i-cal-recurrence.xml
api/i-cal-recur.xml
api/i-cal-reqstat.xml
api/i-cal-restriction.xml
api/i-cal-time-span.xml
api/i-cal-time.xml
api/i-cal-timezone.xml
api/i-cal-trigger.xml
api/i-cal-unknowntokenhandling.xml
api/i-cal-value.xml
)
list(APPEND LIBICAL_GLIB_HEADERS
${CMAKE_CURRENT_BINARY_DIR}/libical-glib.h
${CMAKE_CURRENT_BINARY_DIR}/i-cal-object.h
${CMAKE_CURRENT_BINARY_DIR}/i-cal-forward-declarations.h
)
# add the command to generate the source code from the api files
foreach(file IN LISTS API_FILES)
string(REPLACE "api/" "${CMAKE_CURRENT_SOURCE_DIR}/api/" xml_file_fullpath ${file})
string(REPLACE "api/" "${CMAKE_CURRENT_BINARY_DIR}/" bin_file ${file})
string(REGEX REPLACE ".xml$" ".h" h_file ${bin_file})
string(REGEX REPLACE ".xml$" ".c" c_file ${bin_file})
list(APPEND LIBICAL_GLIB_SOURCES ${h_file} ${c_file})
list(APPEND LIBICAL_GLIB_HEADERS ${h_file})
list(APPEND xml_files ${xml_file_fullpath})
endforeach()
if(CMAKE_CROSSCOMPILING)
# import native ical-glib-src-generator when cross-compiling
set(IMPORT_ICAL_GLIB_SRC_GENERATOR "ICAL_GLIB_SRC_GENERATOR-NOTFOUND"
CACHE FILEPATH
"Path to exported ical-glib-src-generator target from native build"
)
include(${IMPORT_ICAL_GLIB_SRC_GENERATOR})
set(ical-glib-src-generator_EXE native-ical-glib-src-generator)
else()
set(ical-glib-src-generator_EXE ical-glib-src-generator)
endif()
add_custom_command (
OUTPUT ${LIBICAL_GLIB_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/libical-glib-private.h ${CMAKE_CURRENT_BINARY_DIR}/i-cal-forward-declarations.h
COMMAND ${ical-glib-src-generator_EXE} "${CMAKE_CURRENT_SOURCE_DIR}/tools" "${CMAKE_CURRENT_SOURCE_DIR}/api"
DEPENDS ${ical-glib-src-generator_EXE} ${xml_files}
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/i-cal-object.c.in
${CMAKE_CURRENT_BINARY_DIR}/i-cal-object.c
COPYONLY
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/i-cal-object.h.in
${CMAKE_CURRENT_BINARY_DIR}/i-cal-object.h
COPYONLY
)
list(APPEND LIBICAL_GLIB_SOURCES
${CMAKE_CURRENT_BINARY_DIR}/libical-glib-private.h
${CMAKE_CURRENT_BINARY_DIR}/i-cal-object.c
${CMAKE_CURRENT_BINARY_DIR}/i-cal-object.h
)
include_directories(
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/src
${CMAKE_SOURCE_DIR}/src
${CMAKE_BINARY_DIR}/src/libical
${CMAKE_SOURCE_DIR}/src/libical
)
add_library(ical-glib ${LIBRARY_TYPE} ${LIBICAL_GLIB_SOURCES})
add_dependencies(ical-glib ical-header)
target_compile_options(ical-glib PRIVATE ${GLIB_CFLAGS})
target_compile_definitions(ical-glib PRIVATE -DG_LOG_DOMAIN="libical-glib" -DLIBICAL_GLIB_COMPILATION)
target_link_libraries(ical-glib PRIVATE ical ${GLIB_LIBRARIES})
if(NOT SHARED_ONLY AND NOT STATIC_ONLY)
add_library(ical-glib-static STATIC ${LIBICAL_GLIB_SOURCES})
add_dependencies(ical-glib-static ical-header)
target_compile_options(ical-glib-static PUBLIC ${GLIB_CFLAGS} -DG_LOG_DOMAIN="libical-glib" -DLIBICAL_GLIB_COMPILATION)
target_link_libraries(ical-glib-static ${GLIB_LIBRARIES})
endif()
# GObject Introspection
if(HAVE_INTROSPECTION)
# extract only file names without path for introspection
foreach(file IN LISTS LIBICAL_GLIB_SOURCES)
string(REPLACE "${CMAKE_CURRENT_BINARY_DIR}/" "" plain_file ${file})
list(APPEND LIBICAL_GLIB_GIR_SOURCES ${plain_file})
endforeach()
include(GObjectIntrospectionMacros)
set(LIBICAL_GLIB_GIR_VERSION_STRING "${LIBICAL_LIB_MAJOR_VERSION}.0")
set(LIB_VERSION "${LIBICAL_LIB_MAJOR_VERSION}_0")
set(GObjectIntrospection_GIRS)
set(GObjectIntrospection_SCANNER_FLAGS)
set(GObjectIntrospection_SCANNER_ARGS)
set(GObjectIntrospection_COMPILER_ARGS)
set(GObjectIntrospection_SCANNER_ARGS
--add-include-path=${CMAKE_CURRENT_BINARY_DIR}
--add-include-path=${CMAKE_CURRENT_SOURCE_DIR}
--add-include-path=${CMAKE_BINARY_DIR}/src
--add-include-path=${CMAKE_BINARY_DIR}/src/libical
--add-include-path=${CMAKE_SOURCE_DIR}/src
--add-include-path=${CMAKE_SOURCE_DIR}/src/libical
--library-path=${LIBRARY_OUTPUT_PATH}
--identifier-prefix=ICal
--pkg-export libical-glib
--c-include=libical-glib/libical-glib.h
--cflags-begin
-I${CMAKE_BINARY_DIR}/src
-I${CMAKE_BINARY_DIR}/src/libical
-I${CMAKE_BINARY_DIR}/src/libical-glib
-I${LIBRARY_OUTPUT_PATH}
-I${CMAKE_SOURCE_DIR}/src
-I${CMAKE_SOURCE_DIR}/src/libical
--cflags-end
--verbose
)
set(ICalGLib_${LIB_VERSION}_gir "ICalGLib")
set(ICalGLib_${LIB_VERSION}_gir_SCANNERFLAGS "--warn-all")
set(ICalGLib_${LIB_VERSION}_gir_VERSION ${LIBICAL_GLIB_GIR_VERSION_STRING})
set(ICalGLib_${LIB_VERSION}_gir_LIBRARY "ICalGLib")
set(ICalGLib_${LIB_VERSION}_gir_INCLUDES GObject-2.0 GLib-2.0)
set(ICalGLib_${LIB_VERSION}_gir_CFLAGS ${_includes} ${GLIB_CFLAGS} -DLIBICAL_GLIB_COMPILATION -I${CMAKE_CURRENT_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR} -I${CMAKE_BINARY_DIR}/src/libical -I${CMAKE_SOURCE_DIR}/src/libical -I${CMAKE_BINARY_DIR}/src/libical-glib)
set(ICalGLib_${LIB_VERSION}_gir_LIBS ical-glib)
set(ICalGLib_${LIB_VERSION}_gir_FILES ${LIBICAL_GLIB_GIR_SOURCES})
list(APPEND GObjectIntrospection_GIRS ICalGLib-${LIBICAL_GLIB_GIR_VERSION_STRING}.gir)
gir_add_introspections(GObjectIntrospection_GIRS)
endif()
if(ICAL_GLIB_VAPI)
add_custom_target(vala ALL)
set(gir_fullname ${CMAKE_BINARY_DIR}/src/libical-glib/ICalGLib-${LIBICAL_GLIB_GIR_VERSION_STRING}.gir)
set(metadata_fullname ${CMAKE_CURRENT_BINARY_DIR}/ICalGLib-${LIBICAL_GLIB_GIR_VERSION_STRING}.metadata)
set(vapi_file ${CMAKE_CURRENT_BINARY_DIR}/libical-glib.vapi)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/ICalGLib.metadata.in
${metadata_fullname}
@ONLY
)
add_custom_command(OUTPUT ${vapi_file}
COMMAND ${VAPIGEN}
--vapidir=${CMAKE_CURRENT_SOURCE_DIR}
--vapidir=${CMAKE_CURRENT_BINARY_DIR}
--girdir=${CMAKE_BINARY_DIR}/src/libical-glib
--pkg gio-2.0
--library libical-glib
--metadatadir=${CMAKE_CURRENT_SOURCE_DIR}
--metadatadir=${CMAKE_CURRENT_BINARY_DIR}
${gir_fullname}
DEPENDS
${gir_fullname}
${metadata_fullname}
)
add_custom_target(valafile DEPENDS ${vapi_file})
add_dependencies(vala valafile)
install(FILES ${vapi_file} DESTINATION ${SHARE_INSTALL_DIR}/vala/vapi)
endif()
if(MSVC)
set_target_properties(ical-glib PROPERTIES PREFIX "lib")
if(NOT SHARED_ONLY AND NOT STATIC_ONLY)
set_target_properties(ical-glib-static PROPERTIES PREFIX "lib")
endif()
else()
if(NOT SHARED_ONLY AND NOT STATIC_ONLY)
set_target_properties(ical-glib-static PROPERTIES OUTPUT_NAME "ical-glib")
endif()
endif()
if(NOT ANDROID)
set_target_properties(ical-glib PROPERTIES
VERSION ${LIBICAL_LIB_VERSION_STRING}
SOVERSION ${LIBICAL_LIB_MAJOR_VERSION}
)
endif()
set_target_properties(ical-glib PROPERTIES CLEAN_DIRECT_OUTPUT 1)
if(NOT SHARED_ONLY AND NOT STATIC_ONLY)
set_target_properties(ical-glib-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
endif()
install(
TARGETS ical-glib
EXPORT icalTargets
DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}
)
if(NOT SHARED_ONLY AND NOT STATIC_ONLY)
install(
TARGETS ical-glib-static
EXPORT icalTargets
DESTINATION ${INSTALL_TARGETS_DEFAULT_ARGS}
)
endif()
########### install files ###############
install(FILES ${LIBICAL_GLIB_HEADERS}
DESTINATION ${INCLUDE_INSTALL_DIR}/libical-glib
)
########### create and install pkg-config file #########
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
if(IS_ABSOLUTE ${LIB_INSTALL_DIR})
set(libdir "${LIB_INSTALL_DIR}")
else()
set(libdir "\${exec_prefix}/${LIB_INSTALL_DIR}")
endif()
if(IS_ABSOLUTE ${INCLUDE_INSTALL_DIR})
set(includedir "${INCLUDE_INSTALL_DIR}")
else()
set(includedir "\${prefix}/include")
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/libical-glib.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libical-glib.pc
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libical-glib.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
|