VirtualBox

source: vbox/trunk/src/libs/libxml2-2.9.14/CMakeLists.txt@ 102654

Last change on this file since 102654 was 95312, checked in by vboxsync, 2 years ago

libs/{curl,libxml2}: OSE export fixes, bugref:8515

File size: 23.8 KB
Line 
1cmake_minimum_required(VERSION 3.15)
2
3file(STRINGS "configure.ac" CONFIGURE_AC_LINES)
4foreach(line ${CONFIGURE_AC_LINES})
5 if(line MATCHES [[^m4_define\(\[(MAJOR_VERSION|MINOR_VERSION|MICRO_VERSION)\],[ \t]*([0-9]+)\)$]])
6 set(LIBXML_${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
7 elseif(line MATCHES "^(LIBXML_MAJOR_VERSION|LIBXML_MINOR_VERSION|LIBXML_MICRO_VERSION)=([0-9]+)$")
8 set(${CMAKE_MATCH_1} ${CMAKE_MATCH_2})
9 endif()
10endforeach()
11set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
12
13project(libxml2 VERSION ${VERSION} LANGUAGES C)
14
15include(CheckCSourceCompiles)
16include(CheckFunctionExists)
17include(CheckIncludeFiles)
18include(CheckLibraryExists)
19include(CheckStructHasMember)
20include(CheckSymbolExists)
21include(CMakePackageConfigHelpers)
22include(GNUInstallDirs)
23
24option(BUILD_SHARED_LIBS "Build shared libraries" ON)
25set(LIBXML2_WITH_AUTOMATA ON)
26option(LIBXML2_WITH_C14N "Add the Canonicalization support" ON)
27option(LIBXML2_WITH_CATALOG "Add the Catalog support" ON)
28option(LIBXML2_WITH_DEBUG "Add the debugging module" ON)
29option(LIBXML2_WITH_DOCB "Add Docbook SGML support" ON)
30set(LIBXML2_WITH_EXPR ON)
31option(LIBXML2_WITH_FTP "Add the FTP support" ON)
32option(LIBXML2_WITH_HTML "Add the HTML support" ON)
33option(LIBXML2_WITH_HTTP "Add the HTTP support" ON)
34option(LIBXML2_WITH_ICONV "Add ICONV support" ON)
35option(LIBXML2_WITH_ICU "Add ICU support" OFF)
36option(LIBXML2_WITH_ISO8859X "Add ISO8859X support if no iconv" ON)
37option(LIBXML2_WITH_LEGACY "Add deprecated APIs for compatibility" ON)
38option(LIBXML2_WITH_LZMA "Use liblzma" ON)
39option(LIBXML2_WITH_MEM_DEBUG "Add the memory debugging module" OFF)
40option(LIBXML2_WITH_MODULES "Add the dynamic modules support" ON)
41option(LIBXML2_WITH_OUTPUT "Add the serialization support" ON)
42option(LIBXML2_WITH_PATTERN "Add the xmlPattern selection interface" ON)
43option(LIBXML2_WITH_PROGRAMS "Build programs" ON)
44option(LIBXML2_WITH_PUSH "Add the PUSH parser interfaces" ON)
45option(LIBXML2_WITH_PYTHON "Build Python bindings" ON)
46option(LIBXML2_WITH_READER "Add the xmlReader parsing interface" ON)
47option(LIBXML2_WITH_REGEXPS "Add Regular Expressions support" ON)
48option(LIBXML2_WITH_RUN_DEBUG "Add the runtime debugging module" OFF)
49option(LIBXML2_WITH_SAX1 "Add the older SAX1 interface" ON)
50option(LIBXML2_WITH_SCHEMAS "Add Relax-NG and Schemas support" ON)
51option(LIBXML2_WITH_SCHEMATRON "Add Schematron support" ON)
52option(LIBXML2_WITH_TESTS "Build tests" ON)
53option(LIBXML2_WITH_THREADS "Add multithread support" ON)
54option(LIBXML2_WITH_THREAD_ALLOC "Add per-thread memory" OFF)
55option(LIBXML2_WITH_TREE "Add the DOM like tree manipulation APIs" ON)
56set(LIBXML2_WITH_TRIO OFF)
57set(LIBXML2_WITH_UNICODE ON)
58option(LIBXML2_WITH_VALID "Add the DTD validation support" ON)
59option(LIBXML2_WITH_WRITER "Add the xmlWriter saving interface" ON)
60option(LIBXML2_WITH_XINCLUDE "Add the XInclude support" ON)
61option(LIBXML2_WITH_XPATH "Add the XPATH support" ON)
62option(LIBXML2_WITH_XPTR "Add the XPointer support" ON)
63option(LIBXML2_WITH_ZLIB "Use libz" ON)
64set(LIBXML2_XMLCONF_WORKING_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Working directory for XML Conformance Test Suite")
65
66if(LIBXML2_WITH_ICONV)
67 find_package(Iconv REQUIRED)
68endif()
69
70if(LIBXML2_WITH_ICU)
71 find_package(ICU REQUIRED COMPONENTS data i18n uc)
72endif()
73
74if(LIBXML2_WITH_LZMA)
75 find_package(LibLZMA REQUIRED)
76endif()
77
78if(LIBXML2_WITH_PYTHON)
79 check_include_files(unistd.h HAVE_UNISTD_H)
80 check_symbol_exists(F_GETFL fcntl.h HAVE_F_GETFL)
81 if(HAVE_UNISTD_H AND HAVE_F_GETFL)
82 find_package(Python COMPONENTS Interpreter Development REQUIRED)
83 else()
84 find_package(Python2 COMPONENTS Interpreter Development REQUIRED)
85 add_library(Python::Python ALIAS Python2::Python)
86 set(Python_EXECUTABLE ${Python2_EXECUTABLE})
87 set(Python_SITEARCH ${Python2_SITEARCH})
88 endif()
89 set(LIBXML2_PYTHON_INSTALL_DIR ${Python_SITEARCH} CACHE PATH "Python bindings install directory")
90endif()
91
92if(LIBXML2_WITH_THREADS)
93 find_package(Threads REQUIRED)
94endif()
95
96if(LIBXML2_WITH_ZLIB)
97 find_package(ZLIB REQUIRED)
98endif()
99
100foreach(VARIABLE IN ITEMS WITH_AUTOMATA WITH_C14N WITH_CATALOG WITH_DEBUG WITH_DOCB WITH_EXPR WITH_FTP WITH_HTML WITH_HTTP WITH_ICONV WITH_ICU WITH_ISO8859X WITH_LEGACY WITH_LZMA WITH_MEM_DEBUG WITH_MODULES WITH_OUTPUT WITH_PATTERN WITH_PUSH WITH_READER WITH_REGEXPS WITH_RUN_DEBUG WITH_SAX1 WITH_SCHEMAS WITH_SCHEMATRON WITH_THREADS WITH_THREAD_ALLOC WITH_TREE WITH_TRIO WITH_UNICODE WITH_VALID WITH_WRITER WITH_XINCLUDE WITH_XPATH WITH_XPTR WITH_ZLIB)
101 if(LIBXML2_${VARIABLE})
102 set(${VARIABLE} 1)
103 else()
104 set(${VARIABLE} 0)
105 endif()
106endforeach()
107
108set(LIBXML_VERSION ${VERSION})
109set(LIBXML_VERSION_EXTRA "")
110math(EXPR LIBXML_VERSION_NUMBER "
111 ${LIBXML_MAJOR_VERSION} * 10000 +
112 ${LIBXML_MINOR_VERSION} * 100 +
113 ${LIBXML_MICRO_VERSION}
114")
115
116set(MODULE_EXTENSION "${CMAKE_SHARED_LIBRARY_SUFFIX}")
117
118set(PACKAGE "libxml2")
119set(PACKAGE_BUGREPORT "xml@gnome.org")
120set(PACKAGE_NAME "libxml2")
121set(PACKAGE_STRING "libxml2 ${VERSION}")
122set(PACKAGE_TARNAME "libxml2")
123set(PACKAGE_URL "https://gitlab.gnome.org/GNOME/libxml2")
124set(PACKAGE_VERSION ${VERSION})
125
126if(LIBLZMA_FOUND)
127 list(APPEND CMAKE_REQUIRED_LIBRARIES LibLZMA::LibLZMA)
128endif()
129
130if(Threads_FOUND)
131 list(APPEND CMAKE_REQUIRED_LIBRARIES Threads::Threads)
132endif()
133
134if(ZLIB_FOUND)
135 list(APPEND CMAKE_REQUIRED_LIBRARIES ZLIB::ZLIB)
136endif()
137
138if(MSVC)
139 configure_file(include/win32config.h config.h COPYONLY)
140else()
141 check_c_source_compiles("
142 void __attribute__((destructor))
143 f(void) {}
144 int main(void) { return 0; }
145 " HAVE_ATTRIBUTE_DESTRUCTOR)
146 if(HAVE_ATTRIBUTE_DESTRUCTOR)
147 set(ATTRIBUTE_DESTRUCTOR "__attribute__((destructor))")
148 endif()
149 check_c_source_compiles("
150 #include <netdb.h>
151 int main() { (void) gethostbyname((const char*) \"\"); return 0; }
152 " GETHOSTBYNAME_ARG_CAST_CONST)
153 if(NOT GETHOSTBYNAME_ARG_CAST_CONST)
154 set(GETHOSTBYNAME_ARG_CAST "(char *)")
155 else()
156 set(GETHOSTBYNAME_ARG_CAST "/**/")
157 endif()
158 check_include_files(arpa/inet.h HAVE_ARPA_INET_H)
159 check_include_files(arpa/nameser.h HAVE_ARPA_NAMESER_H)
160 check_struct_has_member("struct sockaddr_storage" ss_family "sys/socket.h;sys/types.h" HAVE_SS_FAMILY)
161 check_struct_has_member("struct sockaddr_storage" __ss_family "sys/socket.h;sys/types.h" HAVE_BROKEN_SS_FAMILY)
162 if(HAVE_BROKEN_SS_FAMILY)
163 set(ss_family __ss_family)
164 endif()
165 check_function_exists(class HAVE_CLASS)
166 check_include_files(ctype.h HAVE_CTYPE_H)
167 check_include_files(dlfcn.h HAVE_DLFCN_H)
168 check_library_exists(dl dlopen "" HAVE_DLOPEN)
169 check_include_files(dl.h HAVE_DL_H)
170 check_include_files(errno.h HAVE_ERRNO_H)
171 check_include_files(fcntl.h HAVE_FCNTL_H)
172 check_include_files(float.h HAVE_FLOAT_H)
173 check_function_exists(fpclass HAVE_FPCLASS)
174 check_function_exists(fprintf HAVE_FPRINTF)
175 check_function_exists(ftime HAVE_FTIME)
176 check_function_exists(getaddrinfo HAVE_GETADDRINFO)
177 check_function_exists(gettimeofday HAVE_GETTIMEOFDAY)
178 check_include_files(inttypes.h HAVE_INTTYPES_H)
179 check_function_exists(isascii HAVE_ISASCII)
180 check_library_exists(history append_history "" HAVE_LIBHISTORY)
181 check_library_exists(readline readline "" HAVE_LIBREADLINE)
182 check_include_files(limits.h HAVE_LIMITS_H)
183 check_function_exists(localtime HAVE_LOCALTIME)
184 check_include_files(malloc.h HAVE_MALLOC_H)
185 check_include_files(math.h HAVE_MATH_H)
186 check_function_exists(mmap HAVE_MMAP)
187 check_function_exists(munmap HAVE_MUNMAP)
188 check_include_files(netdb.h HAVE_NETDB_H)
189 check_include_files(netinet/in.h HAVE_NETINET_IN_H)
190 check_include_files(poll.h HAVE_POLL_H)
191 check_function_exists(printf HAVE_PRINTF)
192 check_include_files(pthread.h HAVE_PTHREAD_H)
193 check_function_exists(putenv HAVE_PUTENV)
194 check_function_exists(rand HAVE_RAND)
195 check_function_exists(rand_r HAVE_RAND_R)
196 check_include_files(resolv.h HAVE_RESOLV_H)
197 check_library_exists(dld shl_load "" HAVE_SHLLOAD)
198 check_include_files(signal.h HAVE_SIGNAL_H)
199 check_function_exists(snprintf HAVE_SNPRINTF)
200 check_function_exists(sprintf HAVE_SPRINTF)
201 check_function_exists(srand HAVE_SRAND)
202 check_function_exists(sscanf HAVE_SSCANF)
203 check_function_exists(stat HAVE_STAT)
204 check_include_files(stdarg.h HAVE_STDARG_H)
205 check_include_files(stdint.h HAVE_STDINT_H)
206 check_include_files(stdlib.h HAVE_STDLIB_H)
207 check_function_exists(strftime HAVE_STRFTIME)
208 check_include_files(strings.h HAVE_STRINGS_H)
209 check_include_files(string.h HAVE_STRING_H)
210 check_include_files(sys/mman.h HAVE_SYS_MMAN_H)
211 check_include_files(sys/select.h HAVE_SYS_SELECT_H)
212 check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
213 check_include_files(sys/stat.h HAVE_SYS_STAT_H)
214 check_include_files(sys/timeb.h HAVE_SYS_TIMEB_H)
215 check_include_files(sys/time.h HAVE_SYS_TIME_H)
216 check_include_files(sys/types.h HAVE_SYS_TYPES_H)
217 check_function_exists(time HAVE_TIME)
218 check_include_files(time.h HAVE_TIME_H)
219 check_include_files(unistd.h HAVE_UNISTD_H)
220 check_function_exists(va_copy HAVE_VA_COPY)
221 check_function_exists(vfprintf HAVE_VFPRINTF)
222 check_function_exists(vsnprintf HAVE_VSNPRINTF)
223 check_function_exists(vsprintf HAVE_VSPRINTF)
224 check_function_exists(__va_copy HAVE___VA_COPY)
225 check_c_source_compiles("
226 #include <stdlib.h>
227 #include <iconv.h>
228 extern
229 #ifdef __cplusplus
230 \"C\"
231 #endif
232 #if defined(__STDC__) || defined(__cplusplus)
233 size_t iconv(iconv_t cd, char** inbuf, size_t* inbytesleft, char** outbuf, size_t* outbytesleft);
234 #else
235 size_t iconv();
236 #endif
237 int main() { return 0; }
238 " ICONV_CONST_TEST)
239 if(NOT ICONV_CONST_TEST)
240 set(ICONV_CONST "const")
241 endif()
242 set(LT_OBJDIR ".libs/")
243 check_c_source_compiles("
244 #include <sys/socket.h>
245 #include <sys/types.h>
246 int main() { (void) send(1, (const char*) \"\", 1, 1); return 0; }
247 " SEND_ARG2_CAST_CONST)
248 if(NOT SEND_ARG2_CAST_CONST)
249 set(SEND_ARG2_CAST "(char *)")
250 else()
251 set(SEND_ARG2_CAST "/**/")
252 endif()
253 check_include_files("float.h;stdarg.h;stdlib.h;string.h" STDC_HEADERS)
254 check_c_source_compiles("
255 #include <stdarg.h>
256 void a(va_list* ap) {};
257 int main() { va_list ap1, ap2; a(&ap1); ap2 = (va_list) ap1; return 0; }
258 " VA_LIST_IS_ARRAY_TEST)
259 if(VA_LIST_IS_ARRAY_TEST)
260 set(VA_LIST_IS_ARRAY FALSE)
261 else()
262 set(VA_LIST_IS_ARRAY TRUE)
263 endif()
264 check_c_source_compiles("
265 #include <stddef.h>
266 #include <sys/socket.h>
267 #include <sys/types.h>
268 int main() { (void) getsockopt(1, 1, 1, NULL, (socklen_t*) NULL); return 0; }
269 " XML_SOCKLEN_T_SOCKLEN_T)
270 if(XML_SOCKLEN_T_SOCKLEN_T)
271 set(XML_SOCKLEN_T socklen_t)
272 else()
273 check_c_source_compiles("
274 #include <stddef.h>
275 #include <sys/socket.h>
276 #include <sys/types.h>
277 int main() { (void) getsockopt(1, 1, 1, NULL, (size_t*) NULL); return 0; }
278 " XML_SOCKLEN_T_SIZE_T)
279 if(XML_SOCKLEN_T_SIZE_T)
280 set(XML_SOCKLEN_T size_t)
281 else()
282 check_c_source_compiles("
283 #include <stddef.h>
284 #include <sys/socket.h>
285 #include <sys/types.h>
286 int main() { (void) getsockopt (1, 1, 1, NULL, (int*) NULL); return 0; }
287 " XML_SOCKLEN_T_INT)
288 set(XML_SOCKLEN_T int)
289 endif()
290 endif()
291 configure_file(config.h.cmake.in config.h)
292endif()
293
294set(
295 LIBXML2_HDRS
296 include/libxml/c14n.h
297 include/libxml/catalog.h
298 include/libxml/chvalid.h
299 include/libxml/debugXML.h
300 include/libxml/dict.h
301 include/libxml/DOCBparser.h
302 include/libxml/encoding.h
303 include/libxml/entities.h
304 include/libxml/globals.h
305 include/libxml/hash.h
306 include/libxml/HTMLparser.h
307 include/libxml/HTMLtree.h
308 include/libxml/list.h
309 include/libxml/nanoftp.h
310 include/libxml/nanohttp.h
311 include/libxml/parser.h
312 include/libxml/parserInternals.h
313 include/libxml/pattern.h
314 include/libxml/relaxng.h
315 include/libxml/SAX.h
316 include/libxml/SAX2.h
317 include/libxml/schemasInternals.h
318 include/libxml/schematron.h
319 include/libxml/threads.h
320 include/libxml/tree.h
321 include/libxml/uri.h
322 include/libxml/valid.h
323 include/libxml/xinclude.h
324 include/libxml/xlink.h
325 include/libxml/xmlIO.h
326 include/libxml/xmlautomata.h
327 include/libxml/xmlerror.h
328 include/libxml/xmlexports.h
329 include/libxml/xmlmemory.h
330 include/libxml/xmlmodule.h
331 include/libxml/xmlreader.h
332 include/libxml/xmlregexp.h
333 include/libxml/xmlsave.h
334 include/libxml/xmlschemas.h
335 include/libxml/xmlschemastypes.h
336 include/libxml/xmlstring.h
337 include/libxml/xmlunicode.h
338 include/libxml/xmlwriter.h
339 include/libxml/xpath.h
340 include/libxml/xpathInternals.h
341 include/libxml/xpointer.h
342)
343
344set(
345 LIBXML2_SRCS
346 buf.c
347 c14n.c
348 catalog.c
349 chvalid.c
350 debugXML.c
351 dict.c
352 encoding.c
353 entities.c
354 error.c
355 globals.c
356 hash.c
357 HTMLparser.c
358 HTMLtree.c
359 legacy.c
360 list.c
361 nanoftp.c
362 nanohttp.c
363 parser.c
364 parserInternals.c
365 pattern.c
366 relaxng.c
367 SAX.c
368 SAX2.c
369 schematron.c
370 threads.c
371 tree.c
372 uri.c
373 valid.c
374 xinclude.c
375 xlink.c
376 xmlIO.c
377 xmlmemory.c
378 xmlmodule.c
379 xmlreader.c
380 xmlregexp.c
381 xmlsave.c
382 xmlschemas.c
383 xmlschemastypes.c
384 xmlstring.c
385 xmlunicode.c
386 xmlwriter.c
387 xpath.c
388 xpointer.c
389 xzlib.c
390)
391
392if(WIN32)
393 list(APPEND LIBXML2_SRCS win32/libxml2.rc)
394 file(
395 WRITE
396 ${CMAKE_CURRENT_BINARY_DIR}/rcVersion.h
397 "#define LIBXML_MAJOR_VERSION ${LIBXML_MAJOR_VERSION}\n"
398 "#define LIBXML_MINOR_VERSION ${LIBXML_MINOR_VERSION}\n"
399 "#define LIBXML_MICRO_VERSION ${LIBXML_MICRO_VERSION}\n"
400 "#define LIBXML_DOTTED_VERSION \"${VERSION}\"\n"
401 )
402endif()
403
404if(LIBXML2_WITH_SAX1)
405 list(APPEND LIBXML2_SRCS DOCBparser.c)
406endif()
407
408if(LIBXML2_WITH_TRIO)
409 list(APPEND LIBXML2_SRCS trio.c triostr.c)
410endif()
411
412add_library(LibXml2 ${LIBXML2_HDRS} ${LIBXML2_SRCS})
413add_library(LibXml2::LibXml2 ALIAS LibXml2)
414
415if(NOT BUILD_SHARED_LIBS)
416 target_compile_definitions(LibXml2 INTERFACE LIBXML_STATIC)
417 set(XML_CFLAGS "-DLIBXML_STATIC")
418endif()
419
420if(LIBXML2_WITH_THREADS)
421 target_compile_definitions(LibXml2 PRIVATE _REENTRANT)
422 if(WIN32)
423 target_compile_definitions(LibXml2 PRIVATE HAVE_WIN32_THREADS)
424 endif()
425endif()
426
427target_include_directories(
428 LibXml2
429 PUBLIC
430 $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
431 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
432 $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/${CMAKE_INSTALL_INCLUDEDIR}/libxml2>
433)
434
435if(HAVE_DLOPEN)
436 target_link_libraries(LibXml2 PRIVATE dl)
437 set(MODULE_PLATFORM_LIBS "-ldl")
438endif()
439
440if(HAVE_SHLLOAD)
441 target_link_libraries(LibXml2 PRIVATE dld)
442 set(MODULE_PLATFORM_LIBS "-ldld")
443endif()
444
445if(UNIX)
446 target_link_libraries(LibXml2 PRIVATE m)
447 set(M_LIBS "-lm")
448endif()
449
450if(WIN32)
451 target_link_libraries(LibXml2 PRIVATE ws2_32)
452 set(WIN32_EXTRA_LIBADD "-lws2_32")
453endif()
454
455if(LIBXML2_WITH_ICONV)
456 target_link_libraries(LibXml2 PUBLIC Iconv::Iconv)
457 if(NOT Iconv_IS_BUILT_IN)
458 set(ICONV_LIBS "-liconv")
459 endif()
460endif()
461
462if(LIBXML2_WITH_ICU)
463 target_link_libraries(LibXml2 PRIVATE ICU::data ICU::i18n ICU::uc)
464 if(WIN32)
465 set(ICU_LIBS "-licudt -licuin -licuuc")
466 else()
467 set(ICU_LIBS "-licudata -licui18n -licuuc")
468 endif()
469endif()
470
471if(LIBXML2_WITH_LZMA)
472 target_link_libraries(LibXml2 PRIVATE LibLZMA::LibLZMA)
473 set(LZMA_LIBS "-llzma")
474endif()
475
476if(LIBXML2_WITH_THREADS)
477 target_link_libraries(LibXml2 PRIVATE Threads::Threads)
478 set(THREAD_LIBS ${CMAKE_THREAD_LIBS_INIT})
479endif()
480
481if(LIBXML2_WITH_ZLIB)
482 target_link_libraries(LibXml2 PRIVATE ZLIB::ZLIB)
483 set(Z_LIBS "-lz")
484endif()
485
486set_target_properties(
487 LibXml2
488 PROPERTIES
489 IMPORT_PREFIX lib
490 OUTPUT_NAME xml2
491 POSITION_INDEPENDENT_CODE ON
492 PREFIX lib
493 VERSION ${PROJECT_VERSION}
494)
495
496if(MSVC)
497 if(BUILD_SHARED_LIBS)
498 set_target_properties(
499 LibXml2
500 PROPERTIES
501 DEBUG_POSTFIX d
502 )
503 else()
504 set_target_properties(
505 LibXml2
506 PROPERTIES
507 DEBUG_POSTFIX sd
508 MINSIZEREL_POSTFIX s
509 RELEASE_POSTFIX s
510 RELWITHDEBINFO_POSTFIX s
511 )
512 endif()
513endif()
514
515install(FILES ${LIBXML2_HDRS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
516
517install(
518 TARGETS LibXml2
519 EXPORT LibXml2
520 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development
521 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT runtime NAMELINK_COMPONENT development
522 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT runtime
523)
524
525if(MSVC AND BUILD_SHARED_LIBS)
526 install(FILES $<TARGET_PDB_FILE:LibXml2> DESTINATION ${CMAKE_INSTALL_BINDIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
527endif()
528
529if(LIBXML2_WITH_PROGRAMS)
530 set(
531 PROGRAMS
532 xmlcatalog
533 xmllint
534 )
535 foreach(PROGRAM ${PROGRAMS})
536 add_executable(${PROGRAM} ${PROGRAM}.c)
537 add_executable(LibXml2::${PROGRAM} ALIAS ${PROGRAM})
538 target_link_libraries(${PROGRAM} LibXml2)
539 if(HAVE_LIBHISTORY)
540 target_link_libraries(${PROGRAM} history)
541 endif()
542 if(HAVE_LIBREADLINE)
543 target_link_libraries(${PROGRAM} readline)
544 endif()
545 install(TARGETS ${PROGRAM} EXPORT LibXml2 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT programs)
546 endforeach()
547endif()
548
549if(LIBXML2_WITH_TESTS)
550 enable_testing()
551 set(
552 TESTS
553 runxmlconf
554 runsuite
555 testapi
556 testAutomata
557 testC14N
558 testchar
559 testdict
560 testHTML
561 testModule
562 testlimits
563 testReader
564 testrecurse
565 testRegexp
566 testRelax
567 testSAX
568 testSchemas
569 testURI
570 testXPath
571 )
572 foreach(TEST ${TESTS})
573 add_executable(${TEST} ${TEST}.c)
574 target_link_libraries(${TEST} LibXml2)
575 endforeach()
576 if(EXISTS ${LIBXML2_XMLCONF_WORKING_DIR}/xmlconf/xmlconf.xml)
577 add_test(NAME runxmlconf COMMAND runxmlconf WORKING_DIRECTORY ${LIBXML2_XMLCONF_WORKING_DIR})
578 endif()
579 if(NOT WIN32)
580 add_test(NAME testapi COMMAND testapi)
581 endif()
582 add_test(NAME testchar COMMAND testchar)
583 add_test(NAME testdict COMMAND testdict)
584 add_test(NAME testrecurse COMMAND testrecurse WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
585 if(Threads_FOUND)
586 set(
587 TESTS_THREADS
588 runtest
589 testThreads
590 )
591 foreach(TEST ${TESTS_THREADS})
592 add_executable(${TEST} ${TEST}.c)
593 if(WIN32)
594 target_compile_definitions(${TEST} PRIVATE HAVE_WIN32_THREADS)
595 endif()
596 target_link_libraries(${TEST} LibXml2 Threads::Threads)
597 endforeach()
598 add_test(NAME runtest COMMAND runtest --out ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
599 add_test(NAME testThreads COMMAND testThreads WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
600 endif()
601endif()
602
603if(LIBXML2_WITH_PYTHON)
604 execute_process(
605 COMMAND
606 ${Python_EXECUTABLE}
607 ${CMAKE_CURRENT_SOURCE_DIR}/python/generator.py
608 ${CMAKE_CURRENT_SOURCE_DIR}/doc/libxml2-api.xml
609 ${CMAKE_CURRENT_SOURCE_DIR}/python/libxml2-python-api.xml
610 WORKING_DIRECTORY
611 ${CMAKE_CURRENT_BINARY_DIR}
612 )
613 file(READ python/libxml.py LIBXML_PY)
614 file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in "${LIBXML_PY}")
615 file(READ ${CMAKE_CURRENT_BINARY_DIR}/libxml2class.py LIBXML2CLASS_PY)
616 file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in "${LIBXML2CLASS_PY}")
617 configure_file(${CMAKE_CURRENT_BINARY_DIR}/libxml2.py.in libxml2.py COPYONLY)
618 add_library(
619 LibXml2Mod
620 libxml2-py.c
621 libxml2-py.h
622 python/libxml.c
623 python/libxml_wrap.h
624 python/types.c
625 )
626 target_include_directories(
627 LibXml2Mod
628 PUBLIC
629 $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/python>
630 )
631 target_link_libraries(LibXml2Mod LibXml2 Python::Python)
632 set_target_properties(
633 LibXml2Mod
634 PROPERTIES
635 IMPORT_PREFIX lib
636 OUTPUT_NAME xml2mod
637 PREFIX lib
638 VERSION ${PROJECT_VERSION}
639 )
640 install(
641 TARGETS LibXml2Mod
642 ARCHIVE DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT development
643 LIBRARY DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime NAMELINK_COMPONENT development
644 RUNTIME DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime
645 )
646 if(MSVC AND BUILD_SHARED_LIBS)
647 install(FILES $<TARGET_PDB_FILE:LibXml2Mod> DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} CONFIGURATIONS Debug RelWithDebInfo COMPONENT debug)
648 endif()
649 install(FILES python/drv_libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
650 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2.py DESTINATION ${LIBXML2_PYTHON_INSTALL_DIR} COMPONENT runtime)
651endif()
652
653install(FILES libxml.3 DESTINATION ${CMAKE_INSTALL_MANDIR}/man3 COMPONENT documentation)
654install(FILES doc/xmlcatalog.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
655install(FILES doc/xmllint.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 COMPONENT documentation)
656install(DIRECTORY doc/ DESTINATION ${CMAKE_INSTALL_DATADIR}/doc/libxml2 COMPONENT documentation PATTERN Makefile.* EXCLUDE)
657
658configure_package_config_file(
659 libxml2-config.cmake.cmake.in libxml2-config.cmake
660 INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
661)
662
663install(
664 FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config.cmake
665 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
666 COMPONENT development
667)
668
669write_basic_package_version_file(
670 ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
671 VERSION ${PROJECT_VERSION}
672 COMPATIBILITY ExactVersion
673)
674
675install(
676 FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml2-config-version.cmake
677 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
678 COMPONENT development
679)
680
681install(
682 EXPORT LibXml2
683 DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/libxml2-${PROJECT_VERSION}
684 NAMESPACE LibXml2::
685 FILE libxml2-export.cmake
686 COMPONENT development
687)
688
689configure_file(include/libxml/xmlversion.h.in libxml/xmlversion.h)
690install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlversion.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libxml2/libxml COMPONENT development)
691
692if(LIBXML2_WITH_PYTHON)
693 set(prefix "${CMAKE_INSTALL_PREFIX}")
694 configure_file(python/setup.py.in setup.py @ONLY)
695endif()
696
697set(XML_INCLUDEDIR "-I\${includedir}/libxml2")
698set(XML_LIBDIR "-L\${libdir}")
699set(XML_LIBS "-lxml2")
700set(XML_PRIVATE_LIBS "${Z_LIBS} ${LZMA_LIBS} ${THREAD_LIBS} ${ICONV_LIBS} ${ICU_LIBS} ${M_LIBS}")
701
702file(RELATIVE_PATH PACKAGE_RELATIVE_PATH "${CMAKE_INSTALL_FULL_LIBDIR}/pkgconfig" "${CMAKE_INSTALL_PREFIX}")
703string(REGEX REPLACE "/$" "" PACKAGE_RELATIVE_PATH "${PACKAGE_RELATIVE_PATH}")
704
705set(prefix "\${pcfiledir}/${PACKAGE_RELATIVE_PATH}")
706set(exec_prefix "\${prefix}")
707set(libdir "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
708set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
709configure_file(libxml-2.0.pc.in libxml-2.0.pc @ONLY)
710install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libxml-2.0.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig COMPONENT development)
711
712set(prefix "\$(cd \"\$(dirname \"\$0\")\"; pwd -P)/..")
713configure_file(xml2-config.in xml2-config @ONLY)
714install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/xml2-config DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT development)
715
716set(XML_INCLUDEDIR "-I${CMAKE_INSTALL_FULL_INCLUDEDIR}/libxml2")
717set(XML_LIBDIR "-L${CMAKE_INSTALL_FULL_LIBDIR}")
718configure_file(xml2Conf.sh.in xml2Conf.sh @ONLY)
719install(FILES ${CMAKE_CURRENT_BINARY_DIR}/xml2Conf.sh DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT development)
720
721set(CPACK_COMPONENT_DEVELOPMENT_DEPENDS runtime)
722set(CPACK_COMPONENT_PROGRAMS_DEPENDS runtime)
723set(CPACK_DEB_COMPONENT_INSTALL ON)
724set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_DEPENDS "${PACKAGE_TARNAME}")
725set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_NAME "${PACKAGE_TARNAME}-dev")
726set(CPACK_DEBIAN_DEVELOPMENT_PACKAGE_SECTION "libdevel")
727set(CPACK_DEBIAN_PACKAGE_HOMEPAGE ${PACKAGE_URL})
728set(CPACK_DEBIAN_PACKAGE_NAME ${PACKAGE_TARNAME})
729set(CPACK_DEBIAN_PACKAGE_SECTION "devel")
730set(CPACK_DEBIAN_PROGRAMS_PACKAGE_DEPENDS "${PACKAGE_TARNAME}")
731set(CPACK_DEBIAN_PROGRAMS_PACKAGE_NAME "${PACKAGE_TARNAME}-utils")
732set(CPACK_DEBIAN_PROGRAMS_PACKAGE_SECTION "utils")
733set(CPACK_DEBIAN_RUNTIME_PACKAGE_NAME ${PACKAGE_TARNAME})
734set(CPACK_DEBIAN_RUNTIME_PACKAGE_RECOMMENDS "${PACKAGE_TARNAME}-utils")
735set(CPACK_DEBIAN_RUNTIME_PACKAGE_SECTION "libs")
736set(CPACK_NSIS_PACKAGE_NAME ${PACKAGE_STRING})
737set(CPACK_NSIS_URL_INFO_ABOUT ${PACKAGE_URL})
738set(CPACK_PACKAGE_CONTACT ${PACKAGE_BUGREPORT})
739set(CPACK_PACKAGE_DISPLAY_NAME ${PACKAGE_STRING})
740set(CPACK_PACKAGE_INSTALL_DIRECTORY "${PACKAGE_TARNAME}-${PACKAGE_VERSION}")
741set(CPACK_PACKAGE_NAME ${PACKAGE_TARNAME})
742set(CPACK_PACKAGE_VERSION ${PACKAGE_VERSION})
743set(CPACK_PACKAGE_VERSION_MAJOR ${LIBXML_MAJOR_VERSION})
744set(CPACK_PACKAGE_VERSION_MINOR ${LIBXML_MINOR_VERSION})
745set(CPACK_PACKAGE_VERSION_PATCH ${LIBXML_MICRO_VERSION})
746set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/Copyright)
747set(CPACK_RPM_COMPONENT_INSTALL ON)
748set(CPACK_RPM_development_PACKAGE_NAME "${PACKAGE_NAME}-devel")
749set(CPACK_RPM_development_PACKAGE_REQUIRES "${PACKAGE_NAME}")
750set(CPACK_RPM_PACKAGE_GROUP "Development/Libraries")
751set(CPACK_RPM_PACKAGE_NAME ${PACKAGE_TARNAME})
752set(CPACK_RPM_PACKAGE_URL ${PACKAGE_URL})
753set(CPACK_RPM_programs_PACKAGE_NAME "${PACKAGE_NAME}-utils")
754set(CPACK_RPM_programs_PACKAGE_REQUIRES "${PACKAGE_NAME}")
755set(CPACK_RPM_runtime_PACKAGE_NAME "${PACKAGE_NAME}")
756set(CPACK_RPM_runtime_PACKAGE_SUGGESTS "${PACKAGE_NAME}-utils")
757
758include(CPack)
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette