1 set(XML_SOURCES 2 # src/c14n.c 3 # src/catalog.c 4 src/buf.c 5 src/chvalid.c 6 # src/debugXML.c 7 src/dict.c 8 # src/DOCBparser.c 9 src/encoding.c 10 src/entities.c 11 src/error.c 12 src/globals.c 13 src/hash.c 14 src/HTMLparser.c 15 src/HTMLtree.c 16 # src/legacy.c 17 src/list.c 18 # src/nanoftp.c 19 # src/nanohttp.c 20 src/parser.c 21 src/parserInternals.c 22 src/pattern.c 23 # src/relaxng.c 24 src/SAX2.c 25 # src/SAX.c 26 # src/schematron.c 27 src/threads.c 28 src/tree.c 29 src/uri.c 30 src/valid.c 31 # src/xinclude.c 32 # src/xlink.c 33 src/xmlIO.c 34 src/xmlmemory.c 35 src/xmlreader.c 36 # src/xmlregexp.c 37 # src/xmlmodule.c 38 src/xmlsave.c 39 # src/xmlschemas.c 40 # src/xmlschemastypes.c 41 # src/xmlunicode.c 42 src/xmlwriter.c 43 src/xpath.c 44 # src/xpointer.c 45 src/xmlstring.c 46 ) 47 48 set(LIBXML2_LIBRARIES XMLJava) 49 50 if (WIN32) 51 set(XML_PLATFORM_INCLUDE_DIRECTORY win32) 52 set(XML_COMPILE_OPTIONS 53 "/wd4018" # Signed/unsigned mismatch in comparison. 54 "/wd4267" # TODO(brucedawson): http://crbug.com/554200 fix C4267 55 "/wd4311" # and C4311 warnings. 56 ) 57 elseif (APPLE) 58 set(XML_PLATFORM_INCLUDE_DIRECTORY mac) 59 set(XML_COMPILE_OPTIONS 60 # encoding.c cast from `const unsigned char*` to `unsigned short*` 61 "-Wno-cast-align" 62 63 # xmlIO.c, __MVS__ define is not set 64 "-Wno-undef" 65 66 # xmlIO.c 67 "-Wno-unused-parameter" 68 69 # Following flags are taken from Chromium libxml BUILD.gn 70 # libxml passes `const unsigned char*` through `const char*`. 71 "-Wno-pointer-sign" 72 73 # pattern.c and uri.c both have an intentional `for (...);` / 74 # `while(...);` loop. I submitted a patch to move the `'` to its own 75 # line, but until that's landed suppress the warning: 76 "-Wno-empty-body" 77 78 # debugXML.c compares array 'arg' to NULL. 79 "-Wno-tautological-pointer-compare" 80 81 # threads.c attempts to forward declare a pthread_equal which doesn't 82 # match the prototype in pthreads.h 83 "-Wno-ignored-attributes" 84 85 # libxml casts from int to long to void*. 86 "-Wno-int-to-void-pointer-cast" 87 88 # libxml passes a volatile LPCRITICAL_SECTION* to a function expecting 89 # a void* volatile*. 90 "-Wno-incompatible-pointer-types" 91 92 # trio_is_special_quantity and trio_is_negative are only 93 # used with certain preprocessor defines set. 94 "-Wno-unused-function" 95 96 # Comparison between xmlElementType and xmlXPathTypeVal. 97 # TODO(hans): See if we can fix upstream (http://crbug.com/763944). 98 "-Wno-enum-compare" 99 ) 100 elseif (UNIX AND NOT APPLE) 101 set(XML_PLATFORM_INCLUDE_DIRECTORY linux) 102 set(XML_COMPILE_OPTIONS 103 # TODO: 104 # Following warnings are seen only with GCC 4.9.4. Remove once 105 # we move to latest GCC 106 "-Wno-unused-function" 107 "-Wno-unused-parameter" 108 "-Wno-unused-variable" 109 "-Wno-unused-but-set-variable" 110 "-Wno-suggest-attribute=format" 111 "-Wno-sign-compare" 112 "-Wno-enum-compare" 113 114 # xmlIO.c, __MVS__ define is not set 115 "-Wno-undef" 116 117 # Following flags are taken from Chromium libxml BUILD.gn 118 # gcc spits out a bunch of warnings about passing too many arguments to 119 # __xmlSimpleError. 120 "-Wno-format-extra-args" 121 ) 122 endif () 123 124 if (UNIX) 125 set(XML_DEFINES "_REENTRANT") 126 endif () 127 128 add_library(XMLJava STATIC ${XML_SOURCES}) 129 130 if (XML_DEFINES) 131 target_compile_definitions(XMLJava PRIVATE ${XML_DEFINES}) 132 endif () 133 134 target_compile_definitions(XMLJava PUBLIC "LIBXML_STATIC") 135 target_compile_options(XMLJava PRIVATE ${XML_COMPILE_OPTIONS}) 136 target_link_libraries(XMLJava PUBLIC icuuc) 137 # Export to other moduels who uses libxml 138 target_include_directories(XMLJava 139 PUBLIC "src/include" 140 PUBLIC "${XML_PLATFORM_INCLUDE_DIRECTORY}/include" 141 PRIVATE "${XML_PLATFORM_INCLUDE_DIRECTORY}" 142 )