summaryrefslogtreecommitdiff
path: root/libkolabxml/CMakeLists.txt
blob: 69965da3a16c3db06dbbef16b91c8aac74ab4dd1 (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
project(kolabxmlbindings)

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()

include( ../cmake/modules/FindKolabInternal.cmake )

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
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
    )
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(lib)
if (QT4_FOUND)
    add_subdirectory(tests)
else()
    message("Qt libraries have not been found, not building tests")
endif()