summaryrefslogtreecommitdiff
path: root/qpid/extras/dispatch/CMakeLists.txt
blob: ae0e126be776e4376ca2380688da934c9225d024 (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
167
168
169
170
##
## Licensed to the Apache Software Foundation (ASF) under one
## or more contributor license agreements.  See the NOTICE file
## distributed with this work for additional information
## regarding copyright ownership.  The ASF licenses this file
## to you under the Apache License, Version 2.0 (the
## "License"); you may not use this file except in compliance
## with the License.  You may obtain a copy of the License at
##
##   http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing,
## software distributed under the License is distributed on an
## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
## KIND, either express or implied.  See the License for the
## specific language governing permissions and limitations
## under the License.
##

project(qpid-dispatch C)

cmake_minimum_required(VERSION 2.6)
include(CheckLibraryExists)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckIncludeFiles)
include(FindPythonInterp)
include(FindPythonLibs)

enable_testing()
include (CTest)

if (NOT PYTHONLIBS_FOUND)
     message(FATAL_ERROR "Python Development Libraries are needed.")
endif (NOT PYTHONLIBS_FOUND)

set (SO_VERSION_MAJOR 0)
set (SO_VERSION_MINOR 1)
set (SO_VERSION "${SO_VERSION_MAJOR}.${SO_VERSION_MINOR}")

if (NOT DEFINED LIB_SUFFIX)
    get_property(LIB64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
    if ("${LIB64}" STREQUAL "TRUE" AND ${CMAKE_SIZEOF_VOID_P} STREQUAL "8")
        set(LIB_SUFFIX 64)
    else()
        set(LIB_SUFFIX "")
    endif()
endif()

set(INCLUDE_INSTALL_DIR include CACHE PATH "Include file directory")
set(LIB_INSTALL_DIR "lib${LIB_SUFFIX}" CACHE PATH "Library object file directory")
set(SYSCONF_INSTALL_DIR etc CACHE PATH "System read only configuration directory")
set(SHARE_INSTALL_DIR share CACHE PATH "Shared read only data directory")
set(MAN_INSTALL_DIR share/man CACHE PATH "Manpage directory")

# determine the location for installing the python packages
if (PYTHONLIBS_FOUND)
    execute_process(COMMAND ${PYTHON_EXECUTABLE}
                    -c "from distutils.sysconfig import get_python_lib; print get_python_lib(False)"
                    OUTPUT_VARIABLE PYTHON_SITELIB_PACKAGES
                    OUTPUT_STRIP_TRAILING_WHITESPACE)
endif (PYTHONLIBS_FOUND)

include_directories(
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_SOURCE_DIR}/src
    ${proton_include}
    ${PYTHON_INCLUDE_PATH}
    )

##
## Find dependencies
##
find_library(proton_lib qpid-proton)
find_library(pthread_lib pthread)
find_library(rt_lib rt)
find_path(proton_include proton/driver.h)

set(CMAKE_C_FLAGS "-pthread -Wall -Werror -std=gnu99")
set(CATCH_UNDEFINED "-Wl,--no-undefined")

##
## Build the Multi-Threaded Server Library
##
set(server_SOURCES
    src/agent.c
    src/alloc.c
    src/buffer.c
    src/compose.c
    src/config.c
    src/container.c
    src/dispatch.c
    src/hash.c
    src/iovec.c
    src/iterator.c
    src/log.c
    src/message.c
    src/parse.c
    src/posix/threading.c
    src/python_embedded.c
    src/router_node.c
    src/server.c
    src/timer.c
    src/work_queue.c
    )

add_library(qpid-dispatch SHARED ${server_SOURCES})
target_link_libraries(qpid-dispatch ${proton_lib} ${pthread_lib} ${rt_lib} ${PYTHON_LIBRARIES})
set_target_properties(qpid-dispatch PROPERTIES
                      VERSION "${SO_VERSION}"
                      SOVERSION "${SO_VERSION_MAJOR}"
                      LINK_FLAGS "${CATCH_UNDEFINED}"
                      )
install(TARGETS qpid-dispatch
        LIBRARY DESTINATION ${LIB_INSTALL_DIR})
file(GLOB headers "include/qpid/dispatch/*.h")
install(FILES ${headers} DESTINATION ${INCLUDE_INSTALL_DIR}/qpid/dispatch)
install(FILES include/qpid/dispatch.h DESTINATION ${INCLUDE_INSTALL_DIR}/qpid)
install(FILES etc/qpid-dispatch.conf DESTINATION ${SYSCONF_INSTALL_DIR})

##
## Python modules installation
##
set(PYTHON_STUBS_SOURCES
    python/qpid/dispatch/stubs/__init__.py
    python/qpid/dispatch/stubs/ioadapter.py
    python/qpid/dispatch/stubs/logadapter.py
)

set(PYTHON_ROUTER_SOURCES
    python/qpid/dispatch/router/link.py
    python/qpid/dispatch/router/router_engine.py
    python/qpid/dispatch/router/__init__.py
    python/qpid/dispatch/router/adapter.py
    python/qpid/dispatch/router/mobile.py
    python/qpid/dispatch/router/node.py
    python/qpid/dispatch/router/routing.py
    python/qpid/dispatch/router/data.py
    python/qpid/dispatch/router/configuration.py
    python/qpid/dispatch/router/neighbor.py
    python/qpid/dispatch/router/path.py
    python/qpid/dispatch/router/binding.py
)

set(PYTHON_CONFIG_SOURCES
    python/qpid/dispatch/config/parser.py
    python/qpid/dispatch/config/__init__.py
    python/qpid/dispatch/config/schema.py
    python/qpid/dispatch/__init__.py
)

install(FILES ${PYTHON_STUBS_SOURCES}
        DESTINATION ${PYTHON_SITELIB_PACKAGES}/qpid/dispatch/stubs)

install(FILES ${PYTHON_ROUTER_SOURCES}
        DESTINATION ${PYTHON_SITELIB_PACKAGES}/qpid/dispatch/router)

install(FILES ${PYTHON_CONFIG_SOURCES}
        DESTINATION ${PYTHON_SITELIB_PACKAGES}/qpid/dispatch/config)

install(FILES python/qpid/__init__.py
        DESTINATION ${PYTHON_SITELIB_PACKAGES}/qpid)

install(FILES python/qpid/dispatch/__init__.py
        DESTINATION ${PYTHON_SITELIB_PACKAGES}/qpid/dispatch)
##
## Build Tests
##
add_subdirectory(router)
add_subdirectory(tests)