Imported Upstream version 2.1.0
[platform/upstream/expat.git] / CMakeLists.txt
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
3 \r
4 project(expat)\r
5 \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.1.0")\r
10 set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")\r
11 set(PACKAGE_TARNAME "${PACKAGE_NAME}")\r
12 \r
13 option(BUILD_tools "build the xmlwf tool for expat library" ON)\r
14 option(BUILD_examples "build the examples for expat library" ON)\r
15 option(BUILD_tests "build the tests for expat library" ON)\r
16 option(BUILD_shared "build a shared expat library" ON)\r
17 \r
18 # configuration options\r
19 set(XML_CONTEXT_BYTES 1024 CACHE STRING "Define to specify how much context to retain around the current parse point")\r
20 option(XML_DTD "Define to make parameter entity parsing functionality available" ON)\r
21 option(XML_NS "Define to make XML Namespaces functionality available" ON)\r
22 \r
23 if(XML_DTD)\r
24     set(XML_DTD 1)\r
25 else(XML_DTD)\r
26     set(XML_DTD 0)\r
27 endif(XML_DTD)\r
28 if(XML_NS)\r
29     set(XML_NS 1)\r
30 else(XML_NS)\r
31     set(XML_NS 0)\r
32 endif(XML_NS)\r
33 \r
34 if(BUILD_tests)\r
35     enable_testing()\r
36 endif(BUILD_tests)\r
37 \r
38 include(ConfigureChecks.cmake)\r
39 \r
40 include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/lib)\r
41 if(MSVC)\r
42     add_definitions(-D_CRT_SECURE_NO_WARNINGS -wd4996)\r
43 endif(MSVC)\r
44 \r
45 set(expat_SRCS\r
46     lib/xmlparse.c\r
47     lib/xmlrole.c\r
48     lib/xmltok.c \r
49     lib/xmltok_impl.c \r
50     lib/xmltok_ns.c\r
51 )\r
52 \r
53 if(WIN32 AND BUILD_shared)\r
54     set(expat_SRCS ${expat_SRCS} lib/libexpat.def)\r
55 endif(WIN32 AND BUILD_shared)\r
56 \r
57 if(BUILD_shared)\r
58     set(_SHARED SHARED)\r
59 else(BUILD_shared)\r
60     set(_SHARED STATIC)\r
61 endif(BUILD_shared)\r
62 \r
63 add_library(expat ${_SHARED} ${expat_SRCS})\r
64 \r
65 install(TARGETS expat RUNTIME DESTINATION bin\r
66                       LIBRARY DESTINATION lib\r
67                       ARCHIVE DESTINATION lib)\r
68 \r
69 set(prefix ${CMAKE_INSTALL_PREFIX})\r
70 set(exec_prefix "\${prefix}/bin")\r
71 set(libdir "\${prefix}/lib")\r
72 set(includedir "\${prefix}/include")\r
73 configure_file(expat.pc.in ${CMAKE_CURRENT_BINARY_DIR}/expat.pc)\r
74 \r
75 install(FILES lib/expat.h lib/expat_external.h DESTINATION include)\r
76 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/expat.pc DESTINATION lib/pkgconfig)\r
77 \r
78 \r
79 \r
80 if(BUILD_tools AND NOT WINCE)\r
81     set(xmlwf_SRCS\r
82         xmlwf/xmlwf.c\r
83         xmlwf/xmlfile.c\r
84         xmlwf/codepage.c\r
85         xmlwf/readfilemap.c\r
86     )\r
87 \r
88     add_executable(xmlwf ${xmlwf_SRCS})\r
89     target_link_libraries(xmlwf expat)\r
90     install(TARGETS xmlwf DESTINATION bin)\r
91     install(FILES doc/xmlwf.1 DESTINATION share/man/man1)\r
92 endif(BUILD_tools AND NOT WINCE)\r
93 \r
94 if(BUILD_examples)\r
95     add_executable(elements examples/elements.c)\r
96     target_link_libraries(elements expat)\r
97 \r
98     add_executable(outline examples/outline.c)\r
99     target_link_libraries(outline expat)\r
100 endif(BUILD_examples)\r
101 \r
102 if(BUILD_tests)\r
103     ## these are unittests that can be run on any platform\r
104     add_executable(runtests tests/runtests.c tests/chardata.c tests/minicheck.c)\r
105     target_link_libraries(runtests expat)\r
106     add_test(runtests runtests)\r
107 \r
108     add_executable(runtestspp tests/runtestspp.cpp tests/chardata.c tests/minicheck.c)\r
109     target_link_libraries(runtestspp expat)\r
110     add_test(runtestspp runtestspp)\r
111 endif(BUILD_tests)\r