CMakeLists.txt 10.2 KB
Newer Older
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 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372
############################################################################
# CMakeLists.txt
# Copyright (C) 2014  Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
############################################################################

cmake_minimum_required(VERSION 2.8)
project(XML2 C)


set(LIBXML_MAJOR_VERSION 2)
set(LIBXML_MINOR_VERSION 8)
set(LIBXML_MICRO_VERSION 0)
set(VERSION "${LIBXML_MAJOR_VERSION}.${LIBXML_MINOR_VERSION}.${LIBXML_MICRO_VERSION}")
set(LIBXML_VERSION_NUMBER 208000)


include(CMakeDependentOption)

option(ENABLE_STATIC "Build static library (default is shared library)." NO)
option(ENABLE_C14N "Add the Canonicalization support." NO)
option(ENABLE_CATALOG "Add the Catalog support." NO)
option(ENABLE_DEBUG "Add the debugging module." NO)
option(ENABLE_DOCBOOK "Add Docbook SGML support." NO)
option(ENABLE_FEXCEPTIONS "Add GCC flag -fexceptions for C++ exceptions." NO)
option(ENABLE_FTP "Add the FTP support." NO)
option(ENABLE_HISTORY "Add history support to xmllint shell" NO)
option(ENABLE_HTML "Add the HTML support." NO)
option(ENABLE_HTTP "Add the HTTP support." NO)
option(ENABLE_ICONV "Add ICONV support." NO)
option(ENABLE_ICU "Add ICU support." NO)
option(ENABLE_ISO8859X "Add ISO8859X support if no iconv." NO)
option(ENABLE_LEGACY "Add deprecated APIs for compatibility." NO)
option(ENABLE_MEM_DEBUG "Add the memory debugging module." NO)
option(ENABLE_OUTPUT "Add the serialization support." YES)
option(ENABLE_PATTERN "Add the xmlPattern selection interface." YES)
option(ENABLE_PUSH "Add the PUSH parser interfaces." YES)
cmake_dependent_option(ENABLE_READER "Add the xmlReader parsing interface." YES "ENABLE_PUSH" NO)
option(ENABLE_REGEXPS "Add Regular Expressions support." YES)
option(ENABLE_RUN_DEBUG "Add the runtime debugging module." NO)
option(ENABLE_SAX1 "Add the older SAX1 interface." YES)
cmake_dependent_option(ENABLE_SCHEMAS "Add Relax-NG and Schemas support." YES "ENABLE_PATTERN;ENABLE_REGEXPS" NO)
cmake_dependent_option(ENABLE_SCHEMATRON "Add Schematron support." NO "ENABLE_PATTERN;ENABLE_XPATH" NO)
option(ENABLE_THREADS "Add multithread support." NO)
option(ENABLE_THREAD_ALLOC "Add per-thread memory." NO)
option(ENABLE_TREE "Add the DOM like tree manipulation APIs." YES)
option(ENABLE_VALID "Add the DTD validation support." NO)
cmake_dependent_option(ENABLE_WRITER "Add the xmlWriter saving interface." YES "ENABLE_PUSH;ENABLE_OUTPUT" NO)
option(ENABLE_XINCLUDE "Add the XInclude support." NO)
option(ENABLE_XPATH "Add the XPATH support." YES)
cmake_dependent_option(ENABLE_XPTR "Add the XPointer support." NO "ENABLE_XPATH" NO)
option(ENABLE_MODULES "Add the dynamic modules support." NO)


list(APPEND CMAKE_MODULE_PATH ${CMAKE_PREFIX_PATH}/share/cmake/Modules)

if(MSVC)
	list(APPEND CMAKE_REQUIRED_INCLUDES ${CMAKE_PREFIX_PATH}/include/MSVC)
endif()

include(CheckIncludeFile)
include(CheckSymbolExists)

check_include_file(inttypes.h HAVE_INTTYPES_H)
check_include_file(memory.h HAVE_MEMORY_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stdlib.h HAVE_STDLIB_H)
check_include_file(strings.h HAVE_STRINGS_H)
check_include_file(string.h HAVE_STRING_H)
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(poll.h HAVE_POLL_H)
check_include_file(sys/poll.h HAVE_SYS_POLL_H)
check_include_file(sys/uio.h HAVE_SYS_UIO_H)
check_include_file(fcntl.h HAVE_FCNTL_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(sys/shm.h HAVE_SYS_SHM_H)
check_include_file(windows.h HAVE_WINDOWS_H)
check_include_file(dlfcn.h HAVE_DLFCN_H)
check_include_file(alloca.h HAVE_ALLOCA_H)
check_include_file(ctype.h HAVE_CTYPE_H)
check_include_file(dirent.h HAVE_DIRENT_H)
check_include_file(errno.h HAVE_ERRNO_H)
check_include_file(malloc.h HAVE_MALLOC_H)
check_include_file(stdarg.h HAVE_STDARG_H)
check_include_file(time.h HAVE_TIME_H)
check_include_file(ansidecl.h HAVE_ANSIDECL_H)
check_include_file(ieeefp.h HAVE_IEEEFP_H)
check_include_file(nan.h HAVE_NAN_H)
check_include_file(math.h HAVE_MATH_H)
check_include_file(limits.h HAVE_LIMITS_H)
check_include_file(fp_class.h HAVE_FP_CLASS_H)
check_include_file(float.h HAVE_FLOAT_H)
check_include_file(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_file(netinet/in.h HAVE_NETINET_IN_H)
check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
check_include_file(netdb.h HAVE_NETDB_H)
check_include_file(sys/select.h HAVE_SYS_SELECT_H)
check_include_file(sys/mman.h HAVE_SYS_MMAN_H)
check_include_file(sys/timeb.h HAVE_SYS_TIMEB_H)
check_include_file(signal.h HAVE_SIGNAL_H)
check_include_file(arpa/nameser.h HAVE_ARPA_NAMESER_H)
check_include_file(resolv.h HAVE_RESOLV_H)
check_include_file(dl.h HAVE_DL_H)
if(HAVE_STDARG_H)
	check_symbol_exists(va_copy stdarg.h HAVE_VA_COPY)
	if(NOT HAVE_VA_COPY)
		check_symbol_exists(__va_copy stdarg.h HAVE___VA_COPY)
	endif()
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
add_definitions("-DHAVE_CONFIG_H")

set(WITH_TRIO 0)
if(ENABLE_THREADS)
	set(WITH_THREADS 1)
else()
	set(WITH_THREADS 0)
endif()
if(ENABLE_THREAD_ALLOC)
	set(WITH_THREAD_ALLOC 1)
else()
	set(WITH_THREAD_ALLOC 0)
endif()
if(ENABLE_TREE)
	set(WITH_TREE 1)
else()
	set(WITH_TREE 0)
endif()
if(ENABLE_OUTPUT)
	set(WITH_OUTPUT 1)
else()
	set(WITH_OUTPUT 0)
endif()
if(ENABLE_PUSH)
	set(WITH_PUSH 1)
else()
	set(WITH_PUSH 0)
endif()
if(ENABLE_READER)
	set(WITH_READER 1)
else()
	set(WITH_READER 0)
endif()
if(ENABLE_PATTERN)
	set(WITH_PATTERN 1)
else()
	set(WITH_PATTERN 0)
endif()
if(ENABLE_WRITER)
	set(WITH_WRITER 1)
else()
	set(WITH_WRITER 0)
endif()
if(ENABLE_SAX1)
	set(WITH_SAX1 1)
else()
	set(WITH_SAX1 0)
endif()
if(ENABLE_FTP)
	set(WITH_FTP 1)
else()
	set(WITH_FTP 0)
endif()
if(ENABLE_HTTP)
	set(WITH_HTTP 1)
else()
	set(WITH_HTTP 0)
endif()
if(ENABLE_VALID)
	set(WITH_VALID 1)
else()
	set(WITH_VALID 0)
endif()
if(ENABLE_HTML)
	set(WITH_HTML 1)
else()
	set(WITH_HTML 0)
endif()
if(ENABLE_LEGACY)
	set(WITH_LEGACY 1)
else()
	set(WITH_LEGACY 0)
endif()
if(ENABLE_C14N)
	set(WITH_C14N 1)
else()
	set(WITH_C14N 0)
endif()
if(ENABLE_CATALOG)
	set(WITH_CATALOG 1)
else()
	set(WITH_CATALOG 0)
endif()
if(ENABLE_DOCBOOK)
	set(WITH_DOCB 1)
else()
	set(WITH_DOCB 0)
endif()
if(ENABLE_XPATH)
	set(WITH_XPATH 1)
else()
	set(WITH_XPATH 0)
endif()
if(ENABLE_XPTR)
	set(WITH_XPTR 1)
else()
	set(WITH_XPTR 0)
endif()
if(ENABLE_XINCLUDE)
	set(WITH_XINCLUDE 1)
else()
	set(WITH_XINCLUDE 0)
endif()
if(ENABLE_ICONV)
	set(WITH_ICONV 1)
else()
	set(WITH_ICONV 0)
endif()
if(ENABLE_ICU)
	set(WITH_ICU 1)
else()
	set(WITH_ICU 0)
endif()
if(ENABLE_ISO8859X)
	set(WITH_ISO8859X 1)
else()
	set(WITH_ISO8859X 0)
endif()
if(ENABLE_DEBUG)
	set(WITH_DEBUG 1)
else()
	set(WITH_DEBUG 0)
endif()
if(ENABLE_MEM_DEBUG)
	set(WITH_MEM_DEBUG 1)
else()
	set(WITH_MEM_DEBUG 0)
endif()
if(ENABLE_RUN_DEBUG)
	set(WITH_RUN_DEBUG 1)
else()
	set(WITH_RUN_DEBUG 0)
endif()
if(ENABLE_REGEXPS)
	set(WITH_REGEXPS 1)
else()
	set(WITH_REGEXPS 0)
endif()
if(ENABLE_SCHEMAS)
	set(WITH_SCHEMAS 1)
else()
	set(WITH_SCHEMAS 0)
endif()
if(ENABLE_SCHEMATRON)
	set(WITH_SCHEMATRON 1)
else()
	set(WITH_SCHEMATRON 0)
endif()
if(ENABLE_MODULES)
	set(WITH_MODULES 1)
else()
	set(WITH_MODULES 0)
endif()
set(WITH_ZLIB 0)
set(WITH_LZMA 0)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/libxml/xmlversion.h.in ${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlversion.h @ONLY)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlversion.h PROPERTIES GENERATED ON)

include_directories(
	include
	${CMAKE_CURRENT_BINARY_DIR}
)

if(MSVC)
	include_directories(${CMAKE_PREFIX_PATH}/include/MSVC)
endif()


set(SOURCE_FILES
	buf.c
	c14n.c
	catalog.c
	chvalid.c
	debugXML.c
	dict.c
	DOCBparser.c
	encoding.c
	entities.c
	error.c
	globals.c
	hash.c
	HTMLparser.c
	HTMLtree.c
	legacy.c
	list.c
	nanoftp.c
	nanohttp.c
	parser.c
	parserInternals.c
	pattern.c
	relaxng.c
	SAX2.c
	SAX.c
	schematron.c
	threads.c
	tree.c
	uri.c
	valid.c
	xinclude.c
	xlink.c
	xmlIO.c
	xmlmemory.c
	xmlmodule.c
	xmlreader.c
	xmlregexp.c
	xmlsave.c
	xmlschemas.c
	xmlschemastypes.c
	xmlstring.c
	xmlunicode.c
	xmlwriter.c
	xpath.c
	xpointer.c
	xzlib.c
)

if(ENABLE_STATIC)
	add_library(xml2 STATIC ${SOURCE_FILES})
else()
	add_library(xml2 SHARED ${SOURCE_FILES})
	set_target_properties(xml2 PROPERTIES VERSION 2 LINKER_LANGUAGE C)
	if(MSVC)
		if(CMAKE_BUILD_TYPE STREQUAL "Debug")
			install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/xml2.pdb
				DESTINATION bin
				PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
			)
		endif()
	else()
		target_link_libraries(xml2 m)
	endif()
endif()
if(MSVC)
	string(REPLACE " " ";" GENERATOR_LIST "${CMAKE_GENERATOR}")
	list(GET GENERATOR_LIST 2 VS_VERSION)
	if(VS_VERSION LESS "14")
		target_compile_definitions(xml2 PRIVATE "snprintf=_snprintf")
	endif()
elseif(NOT APPLE)
	set_target_properties(xml2 PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libxml2.syms")
endif()
Ghislain MARY's avatar
Ghislain MARY committed
373 374

if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
	target_compile_options(xml2 PRIVATE "/FIuniversal_windows_port.h")
endif()

install(TARGETS xml2
	RUNTIME DESTINATION bin
	LIBRARY DESTINATION lib
	ARCHIVE DESTINATION lib
	PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)

file(GLOB HEADER_FILES "include/libxml/*.h")

install(FILES ${HEADER_FILES} ${CMAKE_CURRENT_BINARY_DIR}/libxml/xmlversion.h
	DESTINATION include/libxml2/libxml
	PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)