summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
blob: 5f67c3273eb5fb2cf25a0c7852e16d8c14ba3f36 (plain)
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
project(libkolabxml)


cmake_minimum_required(VERSION 2.6)

# only available from cmake-2.8.0
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 7)
    cmake_policy(SET CMP0012 NEW)
endif()

# only available from cmake-2.8.4
if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 7 AND
    ${CMAKE_PATCH_VERSION} GREATER 3)
    cmake_policy(SET CMP0017 NEW)
endif()

set (KOLABXML_VERSION_MAJOR 0)
set (KOLABXML_VERSION_MINOR 3)
set (KOLABXML_VERSION_RELEASE 0)
set (KOLABXML_VERSION "${KOLABXML_VERSION_MAJOR}.${KOLABXML_VERSION_MINOR}.${KOLABXML_VERSION_RELEASE}" )
set (KOLABXML_VERSION_STRING ${CMAKE_PROJECT_NAME}-${KOLABXML_VERSION})
set (KOLAB_FORMAT_VERSION "3.0dev1")

configure_file(libkolabxml-version.h.cmake "${CMAKE_BINARY_DIR}/libkolabxml-version.h" @ONLY)


set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules")
include( cmake/modules/FindKolabInternal.cmake )

add_subdirectory(cmake/modules)

set(Boost_USE_MULTITHREADED ON)
find_package(Boost REQUIRED COMPONENTS thread)
if (Boost_FOUND)
    message("Found boost in ${Boost_INCLUDE_DIRS}")
    include_directories(${Boost_INCLUDE_DIRS})
endif (Boost_FOUND)

if (${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION} VERSION_LESS 1.42)
    find_library(UUID NAMES ossp-uuid)
    if(UUID)
        message("uuid found")
    else (UUID)
        message(FATAL_ERROR "uuid NOT found!")
    endif(UUID)
endif()

find_package(Qt4)
find_program( XSDCXX xsdcxx /usr/bin/)
if(XSDCXX)
    message("xsd code generator found")
else (XSDCXX)
    message(FATAL_ERROR
    "xsd code generator NOT found!")
endif(XSDCXX)

find_library(XERCES_C NAMES xerces-c xerces-c_2)
if(XERCES_C)
    message("xerces found")
else (XERCES_C)
    message(FATAL_ERROR
    "xerces NOT found!")
endif(XERCES_C)

find_program(SWIG swig /usr/bin/)
if(SWIG)
    set(SWIG_FOUND ON)
    message("SWIG found")
endif(SWIG)

set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" ) 

# set( CMAKE_VERBOSE_MAKEFILE on )

set(CMAKE_BUILD_TYPE Debug)

set(CMAKE_BUILD_DIR ${CMAKE_SOURCE_DIR}/build)
file(MAKE_DIRECTORY ${CMAKE_BUILD_DIR}/bindings)

set( SCHEMA_DIR ${CMAKE_SOURCE_DIR}/schemas )

# Generate bindings

set( SCHEMAS
    ${SCHEMA_DIR}/ical/kolabformat-xcal.xsd
    ${SCHEMA_DIR}/ical/iCalendar-params.xsd
    ${SCHEMA_DIR}/ical/iCalendar-props.xsd
    ${SCHEMA_DIR}/ical/iCalendar-valtypes.xsd
    ${SCHEMA_DIR}/xCard.xsd
    ${SCHEMA_DIR}/kolabformat-xcard.xsd
    ${SCHEMA_DIR}/kolabformat.xsd
)

set( SCHEMA_SOURCEFILES  
    ${CMAKE_BUILD_DIR}/bindings/kolabformat.cxx
    ${CMAKE_BUILD_DIR}/bindings/xCard.cxx
    ${CMAKE_BUILD_DIR}/bindings/kolabformat-xcal.cxx
    ${CMAKE_BUILD_DIR}/bindings/kolabformat-xcard.cxx
    ${CMAKE_BUILD_DIR}/bindings/iCalendar-params.cxx
    ${CMAKE_BUILD_DIR}/bindings/iCalendar-props.cxx
    ${CMAKE_BUILD_DIR}/bindings/iCalendar-valtypes.cxx
#     bindings/iCalendar-link-extension.cxx
#     bindings/iCalendar-bw-extensions.cxx
#     bindings/iCalendar-ms-extensions.cxx
)

#xsdcxx cxx-tree --generate-xml-schema --generate-serialization --custom-type date_time --hxx-epilogue '#include "bindings/customtypes/xml-schema-custom.hxx"' xml-schema.xsd
# --generate-inline --extern-xml-schema xml-schema.xsd
# --cxx-suffix .cpp --hxx-suffix .h   
add_custom_command(OUTPUT ${SCHEMA_SOURCEFILES}
    COMMAND ${XSDCXX} cxx-tree --generate-polymorphic --generate-serialization  --namespace-map http://kolab.org=KolabXSD --root-element icalendar --root-element vcards --root-element note --output-dir ${CMAKE_BUILD_DIR}/bindings ${SCHEMAS}
    COMMENT "Generating XSD bindings"
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    DEPENDS ${SCHEMAS}
    VERBATIM
    )

# Compile Schemas
find_program(XSDBIN_FOUND xsdbin)

if (XSDBIN_FOUND)
    add_custom_command(OUTPUT kolabformat-xcal-schema.cxx
            COMMAND ${XSDBIN_FOUND} --verbose --array-name iCalendar_schema --output-dir ${CMAKE_BUILD_DIR} ${SCHEMAS}
            COMMENT "Compiling Kolab XSD schema"
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
            DEPENDS ${SCHEMAS} 
            VERBATIM
        )
else (XSDBIN_FOUND)
    add_executable(xsdbin compiled/xsdbin.cxx)
    target_link_libraries(xsdbin ${XERCES_C})

    add_custom_command(OUTPUT kolabformat-xcal-schema.cxx
            COMMAND ${CMAKE_BUILD_DIR}/xsdbin --verbose --array-name iCalendar_schema --output-dir ${CMAKE_BUILD_DIR} ${SCHEMAS}
            COMMENT "Compiling Kolab XSD schema"
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
            DEPENDS ${SCHEMAS} xsdbin
            VERBATIM
        )
endif (XSDBIN_FOUND)

set( SCHEMA_SOURCEFILES ${SCHEMA_SOURCEFILES} ${CMAKE_BUILD_DIR}/kolabformat-xcal-schema.cxx)

# ---------

SET_SOURCE_FILES_PROPERTIES(${SCHEMA_SOURCEFILES} PROPERTIES GENERATED 1)
ADD_CUSTOM_TARGET(generate_bindings ALL DEPENDS ${SCHEMA_SOURCEFILES})

include_directories( ./ )
include_directories( compiled )
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )

add_subdirectory(src)

if (QT4_FOUND)
    add_subdirectory(tests)
else()
    message("Qt libraries have not been found, not building tests")
endif()

set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${KOLABXML_VERSION})
#make dist requires a tag with ${ARCHIVE_NAME} (e.g. libkolabxml-0.2.0)
add_custom_target(dist
    COMMAND git archive --prefix=${ARCHIVE_NAME}/ ${ARCHIVE_NAME}
        | bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})