blob: 2740c5a8e47267e245df26955d1232a77fbfa151 [file] [log] [blame]
Joakim Soderberg08e434e2013-02-01 14:52:53 +01001cmake_minimum_required(VERSION 2.6)
2
3project(libwebsockets)
4
5set(PACKAGE "libwebsockets")
6set(PACKAGE_VERSION "1.1")
7set(PACKAGE_BUGREPORT "andy@warmcat.com")
8set(PACKAGE_NAME "${PACKAGE}")
9set(PACKAGE_STRING "${PACKAGE} ${PACKAGE_VERSION}")
10set(PACKAGE_TARNAME "${PACKAGE}")
11set(PACKAGE_URL "http://libwebsockets.org")
12set(VERSION "{PACKAGE_VERSION}")
13
Joakim Soderberg4c531232013-02-06 15:26:58 +090014set(LWS_LIBRARY_VERSION ${PACKAGE_VERSION})
15
16# Try to find the current Git hash.
17find_package(Git)
18if(GIT_EXECUTABLE)
19 execute_process(
20 COMMAND "${GIT_EXECUTABLE}" log -n 1 --pretty=%h
21 OUTPUT_VARIABLE GIT_HASH
22 OUTPUT_STRIP_TRAILING_WHITESPACE
23 )
24
25 set(LWS_BUILD_HASH ${GIT_HASH})
26 message("Git commit hash: ${LWS_BUILD_HASH}")
27endif()
28
Joakim Soderbergadd39262013-02-06 15:25:26 +090029option(WITH_SSL "Include SSL support (default OpenSSL, CyaSSL if USE_CYASSL is set)" ON)
Joakim Soderberg4c531232013-02-06 15:26:58 +090030option(USE_EXTERNAL_ZLIB "Search the system for ZLib instead of using the included one (on Windows)" OFF)
Joakim Soderberg08e434e2013-02-01 14:52:53 +010031option(USE_CYASSL "Use CyaSSL replacement for OpenSSL" OFF)
32option(WITH_BUILTIN_GETIFADDRS "Use BSD getifaddrs implementation from libwebsockets... default is your libc provides it" OFF)
Joakim Soderbergadd39262013-02-06 15:25:26 +090033option(WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF)
34option(WITHOUT_CLIENT "Don't build the client part of the library" OFF)
35option(WITHOUT_SERVER "Don't build the server part of the library" OFF)
Joakim Söderberg68e8d732013-02-06 15:27:39 +090036option(WITHOUT_SERVER_EXTPOLL "Don't build a server version that uses external poll" OFF)
Joakim Soderbergadd39262013-02-06 15:25:26 +090037option(WITH_LIBCRYPTO "Use libcrypto MD5 and SHA1 implementations" ON)
38option(WITHOUT_PING "Don't build the ping test application" OFF)
39option(WITHOUT_DEBUG "Don't compile debug related code" OFF)
Joakim Soderbergd2edfec2013-02-06 15:27:27 +090040option(WITHOUT_EXTENSIONS "Don't compile with extensions" OFF)
41option(WITH_LATENCY "Build latency measuring code into the library" OFF)
42option(WITHOUT_DAEMONIZE "Don't build the daemonization api" OFF)
Joakim Soderbergadd39262013-02-06 15:25:26 +090043
Joakim Soderbergd2edfec2013-02-06 15:27:27 +090044# The base dir where the SSL dirs should be looked for.
45set(SSL_CERT_DIR CACHE STRING "")
46set(SSL_CLIENT_CERT_DIR CACHE STRING "")
47
48if ("${SSL_CERT_DIR}" STREQUAL "")
49 set(SSL_CERT_DIR ".")
50endif()
51
52if ("${SSL_CLIENT_CERT_DIR}" STREQUAL "")
53 set(LWS_OPENSSL_CLIENT_CERTS ".")
54else()
55 set(LWS_OPENSSL_CLIENT_CERTS "${SSL_CLIENT_CERT_DIR}")
56endif()
57
58set(CYASSL_LIB CACHE STRING "")
59set(CYASSL_INCLUDE_DIRS CACHE STRING "")
Joakim Soderberg08e434e2013-02-01 14:52:53 +010060
Joakim Soderbergadd39262013-02-06 15:25:26 +090061if (USE_CYASSL)
Joakim Soderbergd2edfec2013-02-06 15:27:27 +090062 if ("${CYASSL_LIB}" STREQUAL "" OR "${CYASSL_INCLUDE_DIRS}" STREQUAL "")
Joakim Soderberge9a42112013-02-06 15:29:59 +090063 message(FATAL_ERROR "You must set CYASSL_LIB and CYASSL_INCLUDE_DIRS when USE_CYASSL is turned on")
Joakim Soderbergadd39262013-02-06 15:25:26 +090064 endif()
65endif()
66
Joakim Soderbergd2edfec2013-02-06 15:27:27 +090067if (WITHOUT_EXTENSIONS)
68 set(LWS_NO_EXTENSIONS 1)
69endif()
70
71if (WITH_SSL)
72 set(LWS_OPENSSL_SUPPORT 1)
73endif()
74
75if (WITH_LATENCY)
76 set(LWS_LATENCY 1)
77endif()
78
79if (WITHOUT_DAEMONIZE)
80 set(LWS_NO_DAEMONIZE 1)
81endif()
82
Joakim Soderberge9a42112013-02-06 15:29:59 +090083if (WITHOUT_SERVER)
84 set(LWS_NO_SERVER 1)
85endif()
86
87if (WITHOUT_CLIENT)
88 set(LWS_NO_CLIENT 1)
89endif()
90
Joakim Soderbergd2edfec2013-02-06 15:27:27 +090091if (MINGW)
92 set(LWS_MINGW_SUPPORT 1)
93endif()
94
Joakim Soderberg08e434e2013-02-01 14:52:53 +010095set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
96include_directories(${PROJECT_BINARY_DIR})
97
Joakim Soderberg4f4a38b2013-02-06 15:28:07 +090098include(CheckCSourceCompiles)
99
100# Check for different inline keyword versions.
101foreach(KEYWORD "inline" "__inline__" "__inline")
102 set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}")
103 CHECK_C_SOURCE_COMPILES(
104 "
105 #include <stdio.h>
106 KEYWORD void a() {}
107 int main(int argc, char **argv) { a(); return 0; }
108 " HAVE_${KEYWORD})
109endforeach()
110
111if (NOT HAVE_inline)
112 if (HAVE___inline__)
113 set(inline __inline__)
114 elseif(HAVE___inline)
115 set(inline __inline)
116 endif()
117endif()
118
Joakim Soderberg4c531232013-02-06 15:26:58 +0900119# Put the libaries and binaries that get built into directories at the
120# top of the build tree rather than in hard-to-find leaf directories.
121SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
122SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
123SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
124
125# So we can include the CMake generated config file only when
126# building with CMAKE.
127add_definitions(-DCMAKE_BUILD)
128
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100129include(CheckFunctionExists)
130include(CheckIncludeFile)
131include(CheckIncludeFiles)
132include(CheckLibraryExists)
133
134CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
135CHECK_FUNCTION_EXISTS(fork HAVE_FORK)
136CHECK_FUNCTION_EXISTS(malloc HAVE_MALLOC)
137CHECK_FUNCTION_EXISTS(memset HAVE_MEMSET)
138CHECK_FUNCTION_EXISTS(realloc HAVE_REALLOC)
139CHECK_FUNCTION_EXISTS(socket HAVE_SOCKET)
140CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
141CHECK_FUNCTION_EXISTS(vfork HAVE_VFORK)
142CHECK_FUNCTION_EXISTS(getifaddrs HAVE_GETIFADDRS)
143
Joakim Soderbergd2edfec2013-02-06 15:27:27 +0900144if (WITH_BUILTIN_GETIFADDRS)
145 if (HAVE_GETIFADDRS)
146 warning("getifaddrs already exists on the system, are you sure you want to build using the BSD version? (This is normally only needed on systems running uclibc)")
147 endif()
148 set(LWS_BUILTIN_GETIFADDRS 1)
Joakim Soderberg4c531232013-02-06 15:26:58 +0900149endif()
150
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100151CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
152CHECK_INCLUDE_FILE(fcntl.h HAVE_FCNTL_H)
153CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
154CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H)
155CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_IN_H)
156CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
157CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
158CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
159CHECK_INCLUDE_FILE(string.h HAVE_STRING_H)
160CHECK_INCLUDE_FILE(sys/prctl.h HAVE_SYS_PRCTL_H)
161CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
162CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
163CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
164CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
165CHECK_INCLUDE_FILE(vfork.h HAVE_VFORK_H)
166CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
167
168# TODO: These can be tested if they actually work also...
169set(HAVE_WORKING_FORK HAVE_FORK)
170set(HAVE_WORKING_VFORK HAVE_VFORK)
171
172CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
173
174if (NOT HAVE_SYS_TYPES_H)
175 set(pid_t int)
176 set(size_t "unsigned int")
177endif()
178
179if (NOT HAVE_MALLOC)
180 set(malloc rpl_malloc)
181endif()
182
183if (NOT HAVE_REALLOC)
184 set(realloc rpl_realloc)
185endif()
186
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100187# Generate the config.h that includes all the compilation settings.
188configure_file(
189 ${PROJECT_SOURCE_DIR}/config.h.cmake
Joakim Soderberg4c531232013-02-06 15:26:58 +0900190 ${PROJECT_BINARY_DIR}/lws_config.h)
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100191
192set(LIB_LIST)
193
194if (MSVC)
195 # Turn off stupid microsoft security warnings.
196 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
197endif()
198
Joakim Soderberg4c531232013-02-06 15:26:58 +0900199include_directories(${PROJECT_SOURCE_DIR}/lib)
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100200
Joakim Soderbergadd39262013-02-06 15:25:26 +0900201# Group headers and sources.
202# Some IDEs use this for nicer file structure.
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100203set(HDR_PRIVATE
Joakim Soderbergadd39262013-02-06 15:25:26 +0900204 lib/private-libwebsockets.h
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100205 lib/extension-deflate-frame.h
Joakim Soderberg4c531232013-02-06 15:26:58 +0900206 lib/extension-deflate-stream.h
207 ${PROJECT_BINARY_DIR}/lws_config.h
208 )
Joakim Soderbergadd39262013-02-06 15:25:26 +0900209
210set(HDR_PUBLIC
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100211 lib/libwebsockets.h
212 )
213
214set(SOURCES
215 lib/base64-decode.c
216 lib/client.c
217 lib/client-handshake.c
218 lib/client-parser.c
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100219 lib/extension.c
Joakim Soderbergadd39262013-02-06 15:25:26 +0900220 lib/extension-deflate-frame.c
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100221 lib/extension-deflate-stream.c
222 lib/handshake.c
223 lib/libwebsockets.c
224 lib/minilex.c
225 lib/output.c
226 lib/parsers.c
227 lib/server.c
228 lib/server-handshake.c
229 lib/sha-1.c
230 )
231
Joakim Soderbergadd39262013-02-06 15:25:26 +0900232# Add helper files for Windows.
233if (WIN32)
Joakim Soderberg4c531232013-02-06 15:26:58 +0900234 set(WIN32_HELPERS_PATH win32port/win32helpers)
Joakim Soderbergadd39262013-02-06 15:25:26 +0900235
236 list(APPEND HDR_PRIVATE
237 ${WIN32_HELPERS_PATH}/websock-w32.h
238 ${WIN32_HELPERS_PATH}/gettimeofday.h
239 )
240
241 list(APPEND SOURCES
242 ${WIN32_HELPERS_PATH}/websock-w32.c
243 ${WIN32_HELPERS_PATH}/gettimeofday.c
244 )
Joakim Soderberg4c531232013-02-06 15:26:58 +0900245
246 include_directories(${WIN32_HELPERS_PATH})
247else()
248 # Unix.
Joakim Soderbergd2edfec2013-02-06 15:27:27 +0900249 if (NOT WITHOUT_DAEMONIZE)
250 list(APPEND SOURCES
251 lib/daemonize.c
252 )
253 endif()
Joakim Soderbergadd39262013-02-06 15:25:26 +0900254endif()
255
256if (UNIX)
257 if (!WITH_BUILTIN_GETIFADDRS)
258 list(APPEND HDR_PRIVATE lib/getifaddrs.h)
259 list(APPEND SOURCES lib/getifaddrs.c)
260 endif()
261endif()
262
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100263source_group("Headers Private" FILES ${HDR_PRIVATE})
264source_group("Headers Public" FILES ${HDR_PUBLIC})
265source_group("Sources" FILES ${SOURCES})
266
Joakim Soderbergadd39262013-02-06 15:25:26 +0900267#
268# Create the lib.
269#
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900270add_library(websockets STATIC
Joakim Soderbergadd39262013-02-06 15:25:26 +0900271 ${HDR_PRIVATE}
272 ${HDR_PUBLIC}
273 ${SOURCES})
274
275#
276# Find libraries.
277#
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100278
279#
280# ZLIB.
281#
Joakim Soderberg4c531232013-02-06 15:26:58 +0900282if (WIN32 AND NOT USE_EXTERNAL_ZLIB)
283 message("Using included Zlib version")
284
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100285 # Compile ZLib if needed.
Joakim Soderberg4c531232013-02-06 15:26:58 +0900286 set(WIN32_ZLIB_PATH "win32port/zlib")
287 set(ZLIB_SRCS
288 ${WIN32_ZLIB_PATH}/adler32.c
289 ${WIN32_ZLIB_PATH}/compress.c
290 ${WIN32_ZLIB_PATH}/crc32.c
291 ${WIN32_ZLIB_PATH}/deflate.c
292 ${WIN32_ZLIB_PATH}/gzclose.c
293 ${WIN32_ZLIB_PATH}/gzio.c
294 ${WIN32_ZLIB_PATH}/gzlib.c
295 ${WIN32_ZLIB_PATH}/gzread.c
296 ${WIN32_ZLIB_PATH}/gzwrite.c
297 ${WIN32_ZLIB_PATH}/infback.c
298 ${WIN32_ZLIB_PATH}/inffast.c
299 ${WIN32_ZLIB_PATH}/inflate.c
300 ${WIN32_ZLIB_PATH}/inftrees.c
301 ${WIN32_ZLIB_PATH}/trees.c
302 ${WIN32_ZLIB_PATH}/uncompr.c
303 ${WIN32_ZLIB_PATH}/zutil.c
304 )
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100305
Joakim Soderberg4c531232013-02-06 15:26:58 +0900306 # Create the library.
Joakim Soderbergd2edfec2013-02-06 15:27:27 +0900307 add_library(ZLIB STATIC ${ZLIB_SRCS})
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100308
Joakim Soderberg4c531232013-02-06 15:26:58 +0900309 # Set the same variables as find_package would.
310 set(ZLIB_INCLUDE_DIRS ${WIN32_ZLIB_PATH})
311 get_property(ZLIB_LIBRARIES TARGET zlib PROPERTY LOCATION)
312 set(ZLIB_FOUND 1)
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100313else()
Joakim Soderbergd2edfec2013-02-06 15:27:27 +0900314 find_package(ZLIB REQUIRED)
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100315endif()
316
Joakim Soderberg4c531232013-02-06 15:26:58 +0900317message("ZLib include dirs: ${ZLIB_INCLUDE_DIRS}")
318message("ZLib libraries: ${ZLIB_LIBRARIES}")
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100319include_directories(${ZLIB_INCLUDE_DIRS})
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900320target_link_libraries(websockets ${ZLIB_LIBRARIES})
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100321
322#
323# OpenSSL
324#
325if (WITH_SSL)
Joakim Soderberg4c531232013-02-06 15:26:58 +0900326 message("Compiling with SSL support")
327
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100328 if (USE_CYASSL)
329 # Use CyaSSL as OpenSSL replacement.
330 set(OPENSSL_LIBRARIES ${CYASSL_LIB})
Joakim Soderbergb378ce92013-02-06 15:29:18 +0900331 set(OPENSSL_INCLUDE_DIR ${CYASSL_INCLUDE_DIRS})
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100332 set(OPENSSL_FOUND 1)
333 else()
334 # TODO: Add support for STATIC also.
335 find_package(OpenSSL REQUIRED)
Joakim Soderberg4c531232013-02-06 15:26:58 +0900336
337 # TODO: Find OpenSSL binaries and copy them to the output directories for the test-apps so that they can be run out of the box.
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100338 endif()
Joakim Soderbergadd39262013-02-06 15:25:26 +0900339
Joakim Soderberg4c531232013-02-06 15:26:58 +0900340 message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
341 message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
Joakim Soderbergadd39262013-02-06 15:25:26 +0900342 include_directories(${OPENSSL_INCLUDE_DIR})
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900343 target_link_libraries(websockets ${OPENSSL_LIBRARIES})
Joakim Soderberg4c531232013-02-06 15:26:58 +0900344endif(WITH_SSL)
345
346#
347# Platform specific libs.
348#
349if (WIN32)
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900350 target_link_libraries(websockets ws2_32.lib)
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100351endif()
352
Joakim Soderberg4c531232013-02-06 15:26:58 +0900353if (UNIX)
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900354 target_link_libraries(websockets m)
Joakim Soderberg4c531232013-02-06 15:26:58 +0900355endif()
Joakim Soderberg08e434e2013-02-01 14:52:53 +0100356
Joakim Soderberg4c531232013-02-06 15:26:58 +0900357#
358# Test applications
359#
360if (NOT WITHOUT_TESTAPPS)
361 #
362 # Helper function for adding a test app.
363 #
364 function(create_test_app TEST_NAME MAIN_SRC WIN32_SRCS WIN32_HDRS)
365
Joakim Soderberg4c531232013-02-06 15:26:58 +0900366 set(TEST_SRCS ${MAIN_SRC})
367 set(TEST_HDR)
368
369 if (WIN32)
370 list(APPEND TEST_SRCS
371 ${WIN32_HELPERS_PATH}/getopt.c
372 ${WIN32_HELPERS_PATH}/getopt_long.c
373 ${WIN32_HELPERS_PATH}/gettimeofday.c
374 ${WIN32_SRCS})
375
376 list(APPEND TEST_HDR
377 ${WIN32_HELPERS_PATH}/getopt.h
378 ${WIN32_HELPERS_PATH}/gettimeofday.h
379 ${WIN32_HDRS})
380 endif(WIN32)
381
382 source_group("Headers" FILES ${TEST_HDR})
383 source_group("Sources" FILES ${TEST_SRCS})
384 add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR})
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900385 target_link_libraries(${TEST_NAME} websockets)
Joakim Soderbergd2edfec2013-02-06 15:27:27 +0900386
387 set_property(
388 TARGET ${TEST_NAME}
389 PROPERTY COMPILE_DEFINITIONS INSTALL_DATADIR="${SSL_CERT_DIR}"
390 )
Joakim Soderberg4c531232013-02-06 15:26:58 +0900391 endfunction()
392
393 #
394 # test-client
395 #
396 if (NOT WITHOUT_CLIENT)
397 create_test_app(test-client
398 "test-server/test-client.c"
399 ""
400 "")
Joakim Soderberge9a42112013-02-06 15:29:59 +0900401 endif()
Joakim Soderberg4c531232013-02-06 15:26:58 +0900402
403 #
404 # test-server
405 #
406 if (NOT WITHOUT_SERVER)
407 create_test_app(test-server
408 "test-server/test-server.c"
409 ""
410 "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
Joakim Soderberge9a42112013-02-06 15:29:59 +0900411 endif()
Joakim Soderberg4c531232013-02-06 15:26:58 +0900412
413 #
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900414 # test-server-extpoll
415 #
Joakim Soderberge9a42112013-02-06 15:29:59 +0900416 if (NOT WITHOUT_SERVER AND NOT WITHOUT_SERVER_EXTPOLL)
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900417 create_test_app(test-server-extpoll
418 "test-server/test-server.c"
419 ""
420 "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
421
422 # Set defines for this executable only.
423 set_property(
424 TARGET test-server-extpoll
425 PROPERTY COMPILE_DEFINITIONS EXTERNAL_POLL INSTALL_DATADIR="${SSL_CERT_DIR}"
426 )
Joakim Soderberge9a42112013-02-06 15:29:59 +0900427 endif()
Joakim Söderberg68e8d732013-02-06 15:27:39 +0900428
429 #
Joakim Soderberg4c531232013-02-06 15:26:58 +0900430 # test-fraggle
431 #
432 if (NOT WITHOUT_FRAGGLE)
433 create_test_app(test-fraggle
434 "test-server/test-fraggle.c"
435 ""
436 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
Joakim Soderberge9a42112013-02-06 15:29:59 +0900437 endif()
Joakim Soderberg4c531232013-02-06 15:26:58 +0900438
439 #
440 # test-ping
441 #
442 if (NOT WITHOUT_PING)
443 create_test_app(test-ping
444 "test-server/test-ping.c"
445 ""
446 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
Joakim Soderberge9a42112013-02-06 15:29:59 +0900447 endif()
Joakim Soderberg4c531232013-02-06 15:26:58 +0900448
449 #
450 # Copy OpenSSL dlls to the output directory on Windows.
451 # (Otherwise we'll get an error when trying to run)
452 #
453 if (WIN32 AND WITH_SSL AND NOT USE_CYASSL)
454
455 message("Searching for OpenSSL dlls")
456 find_package(OpenSSLbins)
457
458 if(OPENSSL_BIN_FOUND)
459 message("OpenSSL dlls found, copying to output directory")
460 message("Libeay: ${LIBEAY_BIN}")
461 message("SSLeay: ${SSLEAY_BIN}")
462
463 foreach(TARGET_BIN
464 test-client
465 test-server
466 test-fraggle
467 test-echo
468 test-ping
469 )
470 add_custom_command(TARGET ${TARGET_BIN}
471 POST_BUILD
472 COMMAND ${CMAKE_COMMAND} -E copy ${LIBEAY_BIN} $<TARGET_FILE_DIR:${TARGET_BIN}> VERBATIM)
473
474 add_custom_command(TARGET ${TARGET_BIN}
475 POST_BUILD
476 COMMAND ${CMAKE_COMMAND} -E copy ${SSLEAY_BIN} $<TARGET_FILE_DIR:${TARGET_BIN}> VERBATIM)
477 endforeach()
478 endif()
479 endif()
480endif(NOT WITHOUT_TESTAPPS)