1 # This file is copyrighted under the BSD-license for buildsystem files of KDE
\r
2 # copyright 2010, Patrick Spendrin <ps_ml@gmx.de>
\r
6 cmake_minimum_required(VERSION 2.6)
\r
7 set(PACKAGE_BUGREPORT "expat-bugs@libexpat.org")
\r
8 set(PACKAGE_NAME "expat")
\r
9 set(PACKAGE_VERSION "2.2.5")
\r
10 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
\r
11 set(PACKAGE_TARNAME "${PACKAGE_NAME}")
\r
14 set(BUILD_tools_default OFF)
\r
16 set(BUILD_tools_default ON)
\r
18 if(MSVC OR NOT BUILD_tools_default)
\r
19 set(BUILD_doc_default OFF)
\r
21 find_program(DOCBOOK_TO_MAN NAMES docbook2x-man docbook2man docbook-to-man)
\r
23 set(BUILD_doc_default ON)
\r
25 set(BUILD_doc_default OFF)
\r
29 option(BUILD_tools "build the xmlwf tool for expat library" ${BUILD_tools_default})
\r
30 option(BUILD_examples "build the examples for expat library" ON)
\r
31 option(BUILD_tests "build the tests for expat library" ON)
\r
32 option(BUILD_shared "build a shared expat library" ON)
\r
33 option(BUILD_doc "build man page for xmlwf" ${BUILD_doc_default})
\r
34 option(USE_libbsd "utilize libbsd (for arc4random_buf)" OFF)
\r
35 option(INSTALL "install expat files in cmake install target" ON)
\r
38 find_library(LIB_BSD NAMES bsd)
\r
40 message(FATAL_ERROR "USE_libbsd option is enabled, but libbsd was not found")
\r
42 set(HAVE_LIBBSD TRUE)
\r
46 # configuration options
\r
47 set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point")
\r
48 option(XML_DTD "Define to make parameter entity parsing functionality available" ON)
\r
49 option(XML_NS "Define to make XML Namespaces functionality available" ON)
\r
51 option(XML_DEV_URANDOM "Define to include code reading entropy from `/dev/urandom'." ON)
\r
53 add_definitions(-DXML_DEV_URANDOM)
\r
72 include(${CMAKE_CURRENT_LIST_DIR}/ConfigureChecks.cmake)
\r
74 set(EXTRA_COMPILE_FLAGS)
\r
75 if(FLAG_NO_STRICT_ALIASING)
\r
76 set(EXTRA_COMPILE_FLAGS "${EXTRA_COMPILE_FLAGS} -fno-strict-aliasing")
\r
78 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_COMPILE_FLAGS}")
\r
79 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_COMPILE_FLAGS}")
\r
81 include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib)
\r
83 add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996)
\r
86 set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Add a suffix, usually d on Windows")
\r
101 set(expat_SRCS ${expat_SRCS} lib/libexpat.def)
\r
104 set(_SHARED STATIC)
\r
106 add_definitions(-DXML_STATIC)
\r
108 endif(BUILD_shared)
\r
110 add_library(expat ${_SHARED} ${expat_SRCS})
\r
112 target_link_libraries(expat ${LIB_BSD})
\r
115 set(LIBCURRENT 7) # sync
\r
116 set(LIBREVISION 7) # with
\r
117 set(LIBAGE 6) # configure.ac!
\r
118 math(EXPR LIBCURRENT_MINUS_AGE "${LIBCURRENT} - ${LIBAGE}")
\r
121 set_property(TARGET expat PROPERTY VERSION ${LIBCURRENT_MINUS_AGE}.${LIBAGE}.${LIBREVISION})
\r
122 set_property(TARGET expat PROPERTY SOVERSION ${LIBCURRENT_MINUS_AGE})
\r
123 set_property(TARGET expat PROPERTY NO_SONAME ${NO_SONAME})
\r
126 macro(expat_install)
\r
132 expat_install(TARGETS expat RUNTIME DESTINATION bin
\r
133 LIBRARY DESTINATION lib
\r
134 ARCHIVE DESTINATION lib)
\r
136 set(prefix ${CMAKE_INSTALL_PREFIX})
\r
137 set(exec_prefix "\${prefix}/bin")
\r
138 set(libdir "\${prefix}/lib")
\r
139 set(includedir "\${prefix}/include")
\r
140 configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc)
\r
142 expat_install(FILES lib/expat.h lib/expat_external.h DESTINATION include)
\r
143 expat_install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig)
\r
150 xmlwf/readfilemap.c
\r
153 add_executable(xmlwf ${xmlwf_SRCS})
\r
154 set_property(TARGET xmlwf PROPERTY RUNTIME_OUTPUT_DIRECTORY xmlwf)
\r
155 target_link_libraries(xmlwf expat)
\r
156 expat_install(TARGETS xmlwf DESTINATION bin)
\r
158 add_custom_command(TARGET expat PRE_BUILD COMMAND "${DOCBOOK_TO_MAN}" "${PROJECT_SOURCE_DIR}/doc/xmlwf.xml" && mv "XMLWF.1" "${PROJECT_SOURCE_DIR}/doc/xmlwf.1")
\r
159 expat_install(FILES "${PROJECT_SOURCE_DIR}/doc/xmlwf.1" DESTINATION share/man/man1)
\r
164 add_executable(elements examples/elements.c)
\r
165 set_property(TARGET elements PROPERTY RUNTIME_OUTPUT_DIRECTORY examples)
\r
166 target_link_libraries(elements expat)
\r
168 add_executable(outline examples/outline.c)
\r
169 set_property(TARGET outline PROPERTY RUNTIME_OUTPUT_DIRECTORY examples)
\r
170 target_link_libraries(outline expat)
\r
171 endif(BUILD_examples)
\r
174 ## these are unittests that can be run on any platform
\r
175 add_executable(runtests tests/runtests.c tests/chardata.c tests/structdata.c tests/minicheck.c tests/memcheck.c)
\r
176 set_property(TARGET runtests PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
\r
177 target_link_libraries(runtests expat)
\r
178 add_test(runtests tests/runtests)
\r
180 add_executable(runtestspp tests/runtestspp.cpp tests/chardata.c tests/structdata.c tests/minicheck.c tests/memcheck.c)
\r
181 set_property(TARGET runtestspp PROPERTY RUNTIME_OUTPUT_DIRECTORY tests)
\r
182 target_link_libraries(runtestspp expat)
\r
183 add_test(runtestspp tests/runtestspp)
\r