# This file is copyrighted under the BSD-license for buildsystem files of KDE # copyright 2010, Patrick Spendrin project(expat) cmake_minimum_required(VERSION 3.1) set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org") set(PACKAGE_NAME "expat") set(PACKAGE_VERSION "2.1.0") set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}") set(PACKAGE_TARNAME "${PACKAGE_NAME}") option(BUILD_tools "build the xmlwf tool for expat library" ON) option(BUILD_examples "build the examples for expat library" ON) option(BUILD_tests "build the tests for expat library" ON) # configuration options set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point") option(XML_DTD "Define to make parameter entity parsing functionality available" ON) option(XML_NS "Define to make XML Namespaces functionality available" ON) if(XML_DTD) set(XML_DTD 1) else(XML_DTD) set(XML_DTD 0) endif(XML_DTD) if(XML_NS) set(XML_NS 1) else(XML_NS) set(XML_NS 0) endif(XML_NS) if(BUILD_tests) enable_testing() endif(BUILD_tests) #SJR 28may12: Explicitly look up homegrown stdint.h because Visual Studio does not support C99. if (MSVC) find_path (STDINT_INCLUDE_DIR c99/stdint.h) if (NOT STDINT_INCLUDE_DIR) MESSAGE (FATAL_ERROR "Could not find stdint.h") else () MESSAGE (STATUS "Found stdint.h in " ${STDINT_INCLUDE_DIR}/c99) include_directories (${STDINT_INCLUDE_DIR}/c99) endif (NOT STDINT_INCLUDE_DIR) endif (MSVC) #BEGIN verbatim copy from ConfigureChecks.cmake include(CheckIncludeFile) include(CheckIncludeFiles) include(CheckFunctionExists) include(CheckSymbolExists) include(TestBigEndian) check_include_file("dlfcn.h" HAVE_DLFCN_H) check_include_file("fcntl.h" HAVE_FCNTL_H) 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("unistd.h" HAVE_UNISTD_H) check_function_exists("getpagesize" HAVE_GETPAGESIZE) check_function_exists("bcopy" HAVE_BCOPY) check_symbol_exists("memmove" "string.h" HAVE_MEMMOVE) check_function_exists("mmap" HAVE_MMAP) #/* Define to 1 if you have the ANSI C header files. */ check_include_files("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS) test_big_endian(WORDS_BIGENDIAN) #/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */ if(WORDS_BIGENDIAN) set(BYTEORDER 4321) else(WORDS_BIGENDIAN) set(BYTEORDER 1234) endif(WORDS_BIGENDIAN) if(HAVE_SYS_TYPES_H) check_symbol_exists("off_t" "sys/types.h" OFF_T) check_symbol_exists("size_t" "sys/types.h" SIZE_T) else(HAVE_SYS_TYPES_H) set(OFF_T "long") set(SIZE_T "unsigned") endif(HAVE_SYS_TYPES_H) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/expat/expat_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/expat_config.h) add_definitions(-DHAVE_EXPAT_CONFIG_H) #END verbatim copy from ConfigureChecks.cmake if(MSVC) add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996) endif(MSVC) set(expat_SRCS lib/xmlparse.c lib/xmlrole.c lib/xmltok.c lib/xmltok_impl.c lib/xmltok_ns.c ) if(WIN32 AND BUILD_SHARED_LIBS) set(expat_SRCS ${expat_SRCS} lib/libexpat.def) endif(WIN32 AND BUILD_SHARED_LIBS) add_library(expat ${expat_SRCS}) target_include_directories (expat PUBLIC $ $ $) if (NOT BUILD_SHARED_LIBS) target_compile_definitions (expat PUBLIC XML_STATIC) endif (NOT BUILD_SHARED_LIBS) install(TARGETS expat EXPORT expat-config RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) install(EXPORT expat-config DESTINATION cmake) set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}/bin") set(libdir "\${prefix}/lib") set(includedir "\${prefix}/include") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/expat/expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc) install(FILES lib/expat.h lib/expat_external.h DESTINATION include) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig) if(BUILD_tools AND NOT WINCE) set(xmlwf_SRCS xmlwf/xmlwf.c xmlwf/xmlfile.c xmlwf/codepage.c xmlwf/readfilemap.c ) add_executable(xmlwf ${xmlwf_SRCS}) target_link_libraries(xmlwf expat) install(TARGETS xmlwf DESTINATION bin) install(FILES doc/xmlwf.1 DESTINATION share/man/man1) endif(BUILD_tools AND NOT WINCE) if(BUILD_examples) add_executable(elements examples/elements.c) target_link_libraries(elements expat) add_executable(outline examples/outline.c) target_link_libraries(outline expat) endif(BUILD_examples) if(BUILD_tests) ## these are unittests that can be run on any platform add_executable(runtests tests/runtests.c tests/chardata.c tests/minicheck.c) target_link_libraries(runtests expat) add_test(runtests runtests) add_executable(runtestspp tests/runtestspp.cpp tests/chardata.c tests/minicheck.c) target_link_libraries(runtestspp expat) add_test(runtestspp runtestspp) endif(BUILD_tests)