forked from zeromq/czmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
202 lines (183 loc) · 6.26 KB
/
CMakeLists.txt
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#################################################################
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Please read the README.txt file in the model directory. #
#################################################################
########################################################################
# Project setup
########################################################################
cmake_minimum_required(VERSION 2.8)
project(czmq)
enable_language(C)
enable_testing()
set(CZMQ_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(CZMQ_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
########################################################################
# determine version
########################################################################
foreach(which MAJOR MINOR PATCH)
file(STRINGS "${CZMQ_SOURCE_DIR}/include/czmq.h" CZMQ_VERSION_STRING REGEX "#define CZMQ_VERSION_${which}")
string(REGEX MATCH "#define CZMQ_VERSION_${which} ([0-9_]+)" CZMQ_REGEX_MATCH "${CZMQ_VERSION_STRING}")
if (NOT CZMQ_REGEX_MATCH)
message(FATAL_ERROR "failed to parse CZMQ_VERSION_${which} from czmq.h")
endif()
set(CZMQ_${which}_VERSION ${CMAKE_MATCH_1})
endforeach(which)
set(CZMQ_VERSION ${CZMQ_MAJOR_VERSION}.${CZMQ_MINOR_VERSION}.${CZMQ_PATCH_VERSION})
########################################################################
# platform.h
########################################################################
include(CheckIncludeFile)
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H)
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H)
CHECK_INCLUDE_FILE("net/if_media.h" HAVE_NET_IF_MEDIA_H)
include(CheckFunctionExists)
CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS)
CHECK_FUNCTION_EXISTS("freeifaddrs" HAVE_FREEIFADDRS)
file(WRITE ${CZMQ_BINARY_DIR}/platform.h.in "
#cmakedefine HAVE_LINUX_WIRELESS_H
#cmakedefine HAVE_NET_IF_H
#cmakedefine HAVE_NET_IF_MEDIA_H
#cmakedefine HAVE_GETIFADDRS
#cmakedefine HAVE_FREEIFADDRS
")
configure_file(${CZMQ_BINARY_DIR}/platform.h.in ${CZMQ_BINARY_DIR}/platform.h)
#The MSVC C compiler is too out of date,
#so the sources have to be compiled as c++
if (MSVC)
enable_language(CXX)
file(GLOB sources ${CZMQ_SOURCE_DIR}/src/*.c)
set_source_files_properties(${sources} PROPERTIES LANGUAGE CXX)
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi)
endif()
# required libraries for mingw
if (MINGW)
set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi)
endif()
########################################################################
# zeromq depedency
########################################################################
list(APPEND CMAKE_MODULE_PATH ${CZMQ_SOURCE_DIR})
find_package(ZeroMQ REQUIRED)
########################################################################
# includes
########################################################################
set (czmq_headers
include/czmq.h
include/czmq_prelude.h
include/zactor.h
include/zauth.h
include/zbeacon.h
include/zcert.h
include/zcertstore.h
include/zchunk.h
include/zclock.h
include/zconfig.h
include/zdigest.h
include/zdir.h
include/zdir_patch.h
include/zfile.h
include/zframe.h
include/zhash.h
include/zlist.h
include/zlog.h
include/zloop.h
include/zmsg.h
include/zpoller.h
include/zproxy.h
include/zrex.h
include/zsock.h
include/zsock_monitor.h
include/zsock_option.h
include/zstr.h
include/zsys.h
include/zuuid.h
include/zctx.h
include/zmonitor.h
include/zmutex.h
include/zsocket.h
include/zsockopt.h
include/zthread.h
)
source_group ("Header Files" FILES ${czmq_headers})
install(FILES ${czmq_headers} DESTINATION include)
########################################################################
# library
########################################################################
include_directories(${CZMQ_BINARY_DIR})
include_directories(${CZMQ_SOURCE_DIR}/include)
include_directories(${ZEROMQ_INCLUDE_DIRS})
set (czmq_sources
src/zactor.c
src/zauth.c
src/zbeacon.c
src/zcert.c
src/zcertstore.c
src/zchunk.c
src/zclock.c
src/zconfig.c
src/zdigest.c
src/zdir.c
src/zdir_patch.c
src/zfile.c
src/zframe.c
src/zhash.c
src/zlist.c
src/zlog.c
src/zloop.c
src/zmsg.c
src/zpoller.c
src/zproxy.c
src/zrex.c
src/zsock.c
src/zsock_monitor.c
src/zsock_option.c
src/zstr.c
src/zsys.c
src/zuuid.c
src/zctx.c
src/zmonitor.c
src/zmutex.c
src/zsocket.c
src/zsockopt.c
src/zthread.c
)
source_group ("Source Files" FILES ${czmq_sources})
add_library(czmq SHARED ${czmq_sources})
set_target_properties(czmq PROPERTIES DEFINE_SYMBOL "LIBCZMQ_EXPORTS")
target_link_libraries(czmq ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES})
install(TARGETS czmq
LIBRARY DESTINATION lib${LIB_SUFFIX} # .so file
ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file
RUNTIME DESTINATION bin # .dll file
)
########################################################################
# pkgconfig
########################################################################
set(VERSION "${CZMQ_VERSION}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
set(libdir "\${prefix}/lib${LIB_SUFFIX}")
set(includedir "\${prefix}/include")
configure_file(
${CZMQ_SOURCE_DIR}/src/libczmq.pc.in
${CZMQ_BINARY_DIR}/libczmq.pc
@ONLY)
install(
FILES ${CZMQ_BINARY_DIR}/libczmq.pc
DESTINATION lib${LIB_SUFFIX}/pkgconfig
)
########################################################################
# tests
########################################################################
add_executable(czmq_selftest ${CZMQ_SOURCE_DIR}/src/czmq_selftest.c)
target_link_libraries(czmq_selftest czmq ${ZEROMQ_LIBRARIES})
add_test(czmq_selftest czmq_selftest)
########################################################################
# summary
########################################################################
message(STATUS "version: ${CZMQ_VERSION}")
message(STATUS "install: ${CMAKE_INSTALL_PREFIX}")
#################################################################
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY #
# Please read the README.txt file in the model directory. #
#################################################################