2012-03-05 09:38:22 -05:00
|
|
|
# This file is copyrighted under the BSD-license for buildsystem files of KDE
|
|
|
|
# copyright 2010, Patrick Spendrin <ps_ml@gmx.de>
|
|
|
|
|
|
|
|
project(expat)
|
|
|
|
|
|
|
|
cmake_minimum_required(VERSION 2.6)
|
|
|
|
set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org")
|
|
|
|
set(PACKAGE_NAME "expat")
|
2017-07-12 12:58:20 -04:00
|
|
|
set(PACKAGE_VERSION "2.2.2")
|
2012-03-05 09:38:22 -05:00
|
|
|
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)
|
|
|
|
option(BUILD_shared "build a shared expat library" ON)
|
2016-08-15 12:07:34 -04:00
|
|
|
option(BUILD_doc "build man page for xmlwf" ON)
|
2016-11-20 12:09:13 -05:00
|
|
|
option(INSTALL "install expat files in cmake install target" ON)
|
2012-03-05 09:38:22 -05:00
|
|
|
|
|
|
|
# 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)
|
|
|
|
|
2016-10-26 13:55:47 -04:00
|
|
|
include(${CMAKE_CURRENT_LIST_DIR}/ConfigureChecks.cmake)
|
2012-03-05 09:38:22 -05:00
|
|
|
|
2016-08-12 09:45:05 -04:00
|
|
|
set(EXTRA_LINK_AND_COMPILE_FLAGS "-fno-strict-aliasing")
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_LINK_AND_COMPILE_FLAGS}")
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_LINK_AND_COMPILE_FLAGS}")
|
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_LINK_AND_COMPILE_FLAGS}")
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${EXTRA_LINK_AND_COMPILE_FLAGS}")
|
|
|
|
|
2016-11-02 08:11:07 -04:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
2012-03-05 09:38:22 -05:00
|
|
|
if(MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996)
|
|
|
|
endif(MSVC)
|
2016-03-28 12:08:58 -04:00
|
|
|
if(WIN32)
|
2016-05-14 12:56:36 -04:00
|
|
|
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Add a suffix, usually d on Windows")
|
2016-03-28 12:08:58 -04:00
|
|
|
endif(WIN32)
|
2012-03-05 09:38:22 -05:00
|
|
|
|
|
|
|
set(expat_SRCS
|
|
|
|
lib/xmlparse.c
|
|
|
|
lib/xmlrole.c
|
2016-11-20 12:10:01 -05:00
|
|
|
lib/xmltok.c
|
|
|
|
lib/xmltok_impl.c
|
2012-03-05 09:38:22 -05:00
|
|
|
lib/xmltok_ns.c
|
|
|
|
)
|
|
|
|
|
|
|
|
if(BUILD_shared)
|
|
|
|
set(_SHARED SHARED)
|
2016-03-12 11:09:47 -05:00
|
|
|
if(WIN32)
|
|
|
|
set(expat_SRCS ${expat_SRCS} lib/libexpat.def)
|
|
|
|
endif(WIN32)
|
2012-03-05 09:38:22 -05:00
|
|
|
else(BUILD_shared)
|
|
|
|
set(_SHARED STATIC)
|
2016-03-12 11:12:25 -05:00
|
|
|
if(WIN32)
|
|
|
|
add_definitions(-DXML_STATIC)
|
|
|
|
endif(WIN32)
|
2012-03-05 09:38:22 -05:00
|
|
|
endif(BUILD_shared)
|
|
|
|
|
|
|
|
add_library(expat ${_SHARED} ${expat_SRCS})
|
2016-06-05 09:41:12 -04:00
|
|
|
|
|
|
|
set(LIBCURRENT 7) # sync
|
2017-07-12 12:59:39 -04:00
|
|
|
set(LIBREVISION 4) # with
|
2016-06-05 09:41:12 -04:00
|
|
|
set(LIBAGE 6) # configure.ac!
|
|
|
|
math(EXPR LIBCURRENT_MINUS_AGE "${LIBCURRENT} - ${LIBAGE}")
|
|
|
|
|
2016-06-20 12:47:11 -04:00
|
|
|
if(NOT WIN32)
|
|
|
|
set_property(TARGET expat PROPERTY VERSION ${LIBCURRENT_MINUS_AGE}.${LIBAGE}.${LIBREVISION})
|
|
|
|
set_property(TARGET expat PROPERTY SOVERSION ${LIBCURRENT_MINUS_AGE})
|
|
|
|
set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME})
|
|
|
|
endif(NOT WIN32)
|
2012-03-05 09:38:22 -05:00
|
|
|
|
2016-10-26 15:48:34 -04:00
|
|
|
macro(expat_install)
|
2016-11-20 12:09:13 -05:00
|
|
|
if(INSTALL)
|
2016-10-26 15:48:34 -04:00
|
|
|
install(${ARGN})
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
expat_install(TARGETS expat RUNTIME DESTINATION bin
|
2012-03-05 09:38:22 -05:00
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib)
|
|
|
|
|
|
|
|
set(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
set(exec_prefix "\${prefix}/bin")
|
|
|
|
set(libdir "\${prefix}/lib")
|
|
|
|
set(includedir "\${prefix}/include")
|
|
|
|
configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc)
|
|
|
|
|
2016-10-26 15:48:34 -04:00
|
|
|
expat_install(FILES lib/expat.h lib/expat_external.h DESTINATION include)
|
|
|
|
expat_install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig)
|
2012-03-05 09:38:22 -05:00
|
|
|
|
|
|
|
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})
|
2016-03-02 10:36:32 -05:00
|
|
|
set_property(TARGET xmlwf PROPERTY RUNTIME_OUTPUT_DIRECTORY xmlwf)
|
2012-03-05 09:38:22 -05:00
|
|
|
target_link_libraries(xmlwf expat)
|
2016-10-26 15:48:34 -04:00
|
|
|
expat_install(TARGETS xmlwf DESTINATION bin)
|
2016-08-15 12:57:06 -04:00
|
|
|
if(BUILD_doc AND NOT MSVC)
|
2016-08-15 12:39:28 -04:00
|
|
|
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
|
|
|
|
set(make_command "$(MAKE)")
|
|
|
|
else()
|
|
|
|
set(make_command "make")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
add_custom_command(TARGET expat PRE_BUILD COMMAND "${make_command}" -C "${PROJECT_SOURCE_DIR}/doc" xmlwf.1)
|
2016-10-26 15:48:34 -04:00
|
|
|
expat_install(FILES "${PROJECT_SOURCE_DIR}/doc/xmlwf.1" DESTINATION share/man/man1)
|
2016-08-15 12:07:34 -04:00
|
|
|
endif()
|
2012-03-05 09:38:22 -05:00
|
|
|
endif(BUILD_tools AND NOT WINCE)
|
|
|
|
|
|
|
|
if(BUILD_examples)
|
|
|
|
add_executable(elements examples/elements.c)
|
2016-03-02 10:36:32 -05:00
|
|
|
set_property(TARGET elements PROPERTY RUNTIME_OUTPUT_DIRECTORY examples)
|
2012-03-05 09:38:22 -05:00
|
|
|
target_link_libraries(elements expat)
|
|
|
|
|
|
|
|
add_executable(outline examples/outline.c)
|
2016-03-02 10:36:32 -05:00
|
|
|
set_property(TARGET outline PROPERTY RUNTIME_OUTPUT_DIRECTORY examples)
|
2012-03-05 09:38:22 -05:00
|
|
|
target_link_libraries(outline expat)
|
|
|
|
endif(BUILD_examples)
|
|
|
|
|
|
|
|
if(BUILD_tests)
|
|
|
|
## these are unittests that can be run on any platform
|
2017-04-25 18:01:56 -04:00
|
|
|
add_executable(runtests tests/runtests.c tests/chardata.c tests/minicheck.c tests/memcheck.c)
|
2016-03-02 10:36:32 -05:00
|
|
|
set_property(TARGET runtests PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
|
2012-03-05 09:38:22 -05:00
|
|
|
target_link_libraries(runtests expat)
|
2016-03-02 10:36:32 -05:00
|
|
|
add_test(runtests tests/runtests)
|
2012-03-05 09:38:22 -05:00
|
|
|
|
2017-04-25 18:01:56 -04:00
|
|
|
add_executable(runtestspp tests/runtestspp.cpp tests/chardata.c tests/minicheck.c tests/memcheck.c)
|
2016-03-02 10:36:32 -05:00
|
|
|
set_property(TARGET runtestspp PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
|
2012-03-05 09:38:22 -05:00
|
|
|
target_link_libraries(runtestspp expat)
|
2016-03-02 10:36:32 -05:00
|
|
|
add_test(runtestspp tests/runtestspp)
|
2012-03-05 09:38:22 -05:00
|
|
|
endif(BUILD_tests)
|