1 cmake_minimum_required(VERSION 2.6)
5 set(PACKAGE "libwebsockets")
6 set(CPACK_PACKAGE_NAME "${PACKAGE}")
7 set(CPACK_PACKAGE_VERSION_MAJOR "1")
8 set(CPACK_PACKAGE_VERSION_MINOR "2")
9 set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}")
10 set(CPACK_PACKAGE_VENDOR "andy@warmcat.com")
11 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}")
12 set(SOVERSION "3.0.0")
13 set(CPACK_SOURCE_GENERATOR "TGZ")
14 set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
15 set(VERSION "${CPACK_PACKAGE_VERSION}")
17 set(LWS_LIBRARY_VERSION ${CPACK_PACKAGE_VERSION})
18 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
20 # Try to find the current Git hash.
24 COMMAND "${GIT_EXECUTABLE}" log -n 1 --pretty=%h
25 OUTPUT_VARIABLE GIT_HASH
26 OUTPUT_STRIP_TRAILING_WHITESPACE
29 set(LWS_BUILD_HASH ${GIT_HASH})
30 message("Git commit hash: ${LWS_BUILD_HASH}")
33 option(WITH_SSL "Include SSL support (default OpenSSL, CyaSSL if USE_CYASSL is set)" ON)
34 option(USE_EXTERNAL_ZLIB "Search the system for ZLib instead of using the included one (on Windows)" OFF)
35 option(USE_CYASSL "Use CyaSSL replacement for OpenSSL. When settings this, you also need to specify CYASSL_LIB and CYASSL_INCLUDE_DIRS" OFF)
36 option(WITHOUT_BUILTIN_GETIFADDRS "Don't use BSD getifaddrs implementation from libwebsockets if it is missing (this will result in a compilation error) ... Default is your libc provides it. On some systems such as uclibc it doesn't exist." OFF)
37 option(WITHOUT_CLIENT "Don't build the client part of the library" OFF)
38 option(WITHOUT_SERVER "Don't build the server part of the library" OFF)
39 #option(WITH_LIBCRYPTO "Use libcrypto MD5 and SHA1 implementations" ON)
40 option(LINK_TESTAPPS_DYNAMIC "Link the test apps to the shared version of the library. Default is to link statically" OFF)
41 option(WITHOUT_TESTAPPS "Don't build the libwebsocket-test-apps" OFF)
42 option(WITHOUT_TEST_SERVER "Don't build the test server" OFF)
43 option(WITHOUT_TEST_SERVER_EXTPOLL "Don't build the test server version that uses external poll" OFF)
44 option(WITHOUT_TEST_PING "Don't build the ping test application" OFF)
45 option(WITHOUT_TEST_CLIENT "Don't build the client test application" OFF)
46 option(WITHOUT_TEST_FRAGGLE "Don't build the ping test application" OFF)
47 option(WITHOUT_DEBUG "Don't compile debug related code" OFF)
48 option(WITHOUT_EXTENSIONS "Don't compile with extensions" OFF)
49 option(WITH_LATENCY "Build latency measuring code into the library" OFF)
50 option(WITHOUT_DAEMONIZE "Don't build the daemonization api" OFF)
51 option(WITH_SD_DAEMON "Build support for systemd based socket activation" OFF)
53 if (WITHOUT_CLIENT AND WITHOUT_SERVER)
54 message(FATAL_ERROR "Makes no sense to compile without both client or server.")
57 # The base dir where the test-apps look for the SSL certs.
58 set(SSL_CERT_DIR CACHE STRING "")
59 set(SSL_CLIENT_CERT_DIR CACHE STRING "")
61 if ("${SSL_CERT_DIR}" STREQUAL "")
62 set(SSL_CERT_DIR "../share")
65 if ("${SSL_CLIENT_CERT_DIR}" STREQUAL "")
67 set(LWS_OPENSSL_CLIENT_CERTS ".")
69 set(LWS_OPENSSL_CLIENT_CERTS "/etc/pki/tls/certs/")
72 set(LWS_OPENSSL_CLIENT_CERTS "${SSL_CLIENT_CERT_DIR}")
75 set(CYASSL_LIB CACHE STRING "")
76 set(CYASSL_INCLUDE_DIRS CACHE STRING "")
79 if ("${CYASSL_LIB}" STREQUAL "" OR "${CYASSL_INCLUDE_DIRS}" STREQUAL "")
80 message(FATAL_ERROR "You must set CYASSL_LIB and CYASSL_INCLUDE_DIRS when USE_CYASSL is turned on")
84 if (WITHOUT_EXTENSIONS)
85 set(LWS_NO_EXTENSIONS 1)
89 set(LWS_OPENSSL_SUPPORT 1)
96 if (WITHOUT_DAEMONIZE)
97 set(LWS_NO_DAEMONIZE 1)
115 set(LWS_MINGW_SUPPORT 1)
118 include_directories(${PROJECT_BINARY_DIR})
120 include(CheckCSourceCompiles)
122 # Check for different inline keyword versions.
123 foreach(KEYWORD "inline" "__inline__" "__inline")
124 set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}")
125 CHECK_C_SOURCE_COMPILES(
129 int main(int argc, char **argv) { a(); return 0; }
135 set(inline __inline__)
136 elseif(HAVE___inline)
141 # Put the libaries and binaries that get built into directories at the
142 # top of the build tree rather than in hard-to-find leaf directories.
143 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
144 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
145 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
147 # So we can include the CMake generated config file only when
148 # building with CMAKE.
149 add_definitions(-DCMAKE_BUILD)
151 include(CheckFunctionExists)
152 include(CheckIncludeFile)
153 include(CheckIncludeFiles)
154 include(CheckLibraryExists)
156 CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
157 CHECK_FUNCTION_EXISTS(fork HAVE_FORK)
158 CHECK_FUNCTION_EXISTS(malloc HAVE_MALLOC)
159 CHECK_FUNCTION_EXISTS(memset HAVE_MEMSET)
160 CHECK_FUNCTION_EXISTS(realloc HAVE_REALLOC)
161 CHECK_FUNCTION_EXISTS(socket HAVE_SOCKET)
162 CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
163 CHECK_FUNCTION_EXISTS(vfork HAVE_VFORK)
164 CHECK_FUNCTION_EXISTS(getifaddrs HAVE_GETIFADDRS)
166 if (NOT HAVE_GETIFADDRS)
167 if (WITHOUT_BUILTIN_GETIFADDRS)
168 message(FATAL_ERROR "No getifaddrs was found on the system. Turn off the WITHOUT_BUILTIN_GETIFADDRS compile option to use the supplied BSD version.")
171 set(LWS_BUILTIN_GETIFADDRS 1)
174 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
175 CHECK_INCLUDE_FILE(fcntl.h HAVE_FCNTL_H)
176 CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
177 CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H)
178 CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_IN_H)
179 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
180 CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
181 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
182 CHECK_INCLUDE_FILE(string.h HAVE_STRING_H)
183 CHECK_INCLUDE_FILE(sys/prctl.h HAVE_SYS_PRCTL_H)
184 CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
185 CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
186 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
187 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
188 CHECK_INCLUDE_FILE(vfork.h HAVE_VFORK_H)
189 CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
191 # TODO: These can be tested if they actually work also...
192 set(HAVE_WORKING_FORK HAVE_FORK)
193 set(HAVE_WORKING_VFORK HAVE_VFORK)
195 CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
197 if (NOT HAVE_SYS_TYPES_H)
199 set(size_t "unsigned int")
203 set(malloc rpl_malloc)
206 if (NOT HAVE_REALLOC)
207 set(realloc rpl_realloc)
210 # Generate the config.h that includes all the compilation settings.
212 ${PROJECT_SOURCE_DIR}/config.h.cmake
213 ${PROJECT_BINARY_DIR}/lws_config.h)
216 # Turn off stupid microsoft security warnings.
217 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
220 include_directories(${PROJECT_SOURCE_DIR}/lib)
222 # Group headers and sources.
223 # Some IDEs use this for nicer file structure.
225 lib/private-libwebsockets.h
226 ${PROJECT_BINARY_DIR}/lws_config.h
230 ${PROJECT_SOURCE_DIR}/lib/libwebsockets.h
242 if (NOT WITHOUT_CLIENT)
245 lib/client-handshake.c
250 if (NOT WITHOUT_SERVER)
253 lib/server-handshake.c
257 if (NOT WITHOUT_EXTENSIONS)
258 list(APPEND HDR_PRIVATE
259 lib/extension-deflate-frame.h
260 lib/extension-deflate-stream.h
265 lib/extension-deflate-frame.c
266 lib/extension-deflate-stream.c
270 # Add helper files for Windows.
272 set(WIN32_HELPERS_PATH win32port/win32helpers)
274 list(APPEND HDR_PRIVATE
275 ${WIN32_HELPERS_PATH}/websock-w32.h
276 ${WIN32_HELPERS_PATH}/gettimeofday.h
280 ${WIN32_HELPERS_PATH}/gettimeofday.c
284 ${WIN32_HELPERS_PATH}/websock-w32.c
285 ${WIN32_HELPERS_PATH}/gettimeofday.c
288 include_directories(${WIN32_HELPERS_PATH})
291 if (NOT WITHOUT_DAEMONIZE)
299 if (NOT HAVE_GETIFADDRS)
300 list(APPEND HDR_PRIVATE lib/getifaddrs.h)
301 list(APPEND SOURCES lib/getifaddrs.c)
305 source_group("Headers Private" FILES ${HDR_PRIVATE})
306 source_group("Headers Public" FILES ${HDR_PUBLIC})
307 source_group("Sources" FILES ${SOURCES})
312 add_library(websockets STATIC
316 add_library(websockets_shared SHARED
322 # On Windows libs have the same file ending (.lib)
323 # for both static and shared libraries, so we
324 # need a unique name for the static one.
325 set_target_properties(websockets
327 OUTPUT_NAME websockets_static)
329 # Compile as DLL (export function declarations)
331 TARGET websockets_shared
332 PROPERTY COMPILE_DEFINITIONS
338 # We want the shared lib to be named "libwebsockets"
339 # not "libwebsocket_shared".
340 set_target_properties(websockets_shared
342 OUTPUT_NAME websockets)
344 # Set the so version of the lib.
345 # Equivalent to LDFLAGS=-version-info 3:0:0
346 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
347 foreach(lib websockets websockets_shared)
348 set_target_properties(${lib}
350 SOVERSION ${SOVERSION})
361 # SD_DAEMON (Only needed if systemd socket activation is desired.)
364 find_package(PkgConfig)
365 pkg_check_modules(SD_DAEMON REQUIRED libsystemd-daemon)
367 include_directories(${SD_DAEMON_INCLUDE_DIRS})
368 list(APPEND LIB_LIST ${SD_DAEMON_LIBRARIES})
369 add_definitions(${SD_DAEMON_CFLAGS_OTHER})
370 add_definitions(-DHAVE_SYSTEMD_DAEMON)
374 # ZLIB (Only needed for deflate extensions).
376 if (NOT WITHOUT_EXTENSIONS)
377 if (WIN32 AND NOT USE_EXTERNAL_ZLIB)
378 message("Using included Zlib version")
380 # Compile ZLib if needed.
381 set(WIN32_ZLIB_PATH "win32port/zlib")
383 ${WIN32_ZLIB_PATH}/adler32.c
384 ${WIN32_ZLIB_PATH}/compress.c
385 ${WIN32_ZLIB_PATH}/crc32.c
386 ${WIN32_ZLIB_PATH}/deflate.c
387 ${WIN32_ZLIB_PATH}/gzclose.c
388 ${WIN32_ZLIB_PATH}/gzio.c
389 ${WIN32_ZLIB_PATH}/gzlib.c
390 ${WIN32_ZLIB_PATH}/gzread.c
391 ${WIN32_ZLIB_PATH}/gzwrite.c
392 ${WIN32_ZLIB_PATH}/infback.c
393 ${WIN32_ZLIB_PATH}/inffast.c
394 ${WIN32_ZLIB_PATH}/inflate.c
395 ${WIN32_ZLIB_PATH}/inftrees.c
396 ${WIN32_ZLIB_PATH}/trees.c
397 ${WIN32_ZLIB_PATH}/uncompr.c
398 ${WIN32_ZLIB_PATH}/zutil.c
401 # Create the library.
402 add_library(ZLIB STATIC ${ZLIB_SRCS})
404 # Set the same variables as find_package would.
405 set(ZLIB_INCLUDE_DIRS ${WIN32_ZLIB_PATH})
406 get_property(ZLIB_LIBRARIES TARGET ZLIB PROPERTY LOCATION)
409 find_package(ZLIB REQUIRED)
412 # Make sure ZLib is compiled before the libs.
413 foreach (lib websockets websockets_shared)
414 add_dependencies(${lib} ZLIB)
417 message("ZLib include dirs: ${ZLIB_INCLUDE_DIRS}")
418 message("ZLib libraries: ${ZLIB_LIBRARIES}")
419 include_directories(${ZLIB_INCLUDE_DIRS})
420 list(APPEND LIB_LIST ${ZLIB_LIBRARIES})
421 endif(NOT WITHOUT_EXTENSIONS)
427 message("Compiling with SSL support")
430 # Use CyaSSL as OpenSSL replacement.
431 # TODO: Add a find_package command for this also.
432 message("CyaSSL include dir: ${CYASSL_INCLUDE_DIRS}")
433 message("CyaSSL libraries: ${CYASSL_LIB}")
435 # Additional to the root directory we need to include
436 # the cyassl/ subdirectory which contains the OpenSSL
437 # compatability layer headers.
438 foreach(inc ${CYASSL_INCLUDE_DIRS})
439 include_directories(${inc} ${inc}/cyassl)
442 list(APPEND ${LIB_LIST} ${CYASSL_LIB})
444 # TODO: Add support for STATIC also.
445 find_package(OpenSSL REQUIRED)
447 message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
448 message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
450 include_directories(${OPENSSL_INCLUDE_DIR})
451 list(APPEND LIB_LIST ${OPENSSL_LIBRARIES})
456 # Platform specific libs.
459 list(APPEND LIB_LIST ws2_32.lib)
463 list(APPEND LIB_LIST m)
466 # Setup the linking for all libs.
467 foreach (lib websockets websockets_shared)
468 target_link_libraries(${lib} ${LIB_LIST})
475 if (NOT WITHOUT_TESTAPPS)
477 # Helper function for adding a test app.
479 macro(create_test_app TEST_NAME MAIN_SRC WIN32_SRCS WIN32_HDRS)
481 set(TEST_SRCS ${MAIN_SRC})
485 list(APPEND TEST_SRCS
486 ${WIN32_HELPERS_PATH}/getopt.c
487 ${WIN32_HELPERS_PATH}/getopt_long.c
488 ${WIN32_HELPERS_PATH}/gettimeofday.c
492 ${WIN32_HELPERS_PATH}/getopt.h
493 ${WIN32_HELPERS_PATH}/gettimeofday.h
497 source_group("Headers Private" FILES ${TEST_HDR})
498 source_group("Sources" FILES ${TEST_SRCS})
499 add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR})
501 if (LINK_TESTAPPS_DYNAMIC)
502 target_link_libraries(${TEST_NAME} websockets_shared)
503 add_dependencies(${TEST_NAME} websockets_shared)
505 target_link_libraries(${TEST_NAME} websockets)
506 add_dependencies(${TEST_NAME} websockets)
509 # Set test app specific defines.
510 set_property(TARGET ${TEST_NAME}
511 PROPERTY COMPILE_DEFINITIONS
512 INSTALL_DATADIR="${SSL_CERT_DIR}"
515 # Prefix the binary names with libwebsockets.
516 set_target_properties(${TEST_NAME}
518 OUTPUT_NAME libwebsockets-${TEST_NAME})
520 # Add to the list of tests.
521 list(APPEND TEST_APP_LIST ${TEST_NAME})
524 if (WITH_SSL AND NOT USE_CYASSL)
525 message("Searching for OpenSSL executable and dlls")
526 find_package(OpenSSLbins)
527 message("OpenSSL executable: ${OPENSSL_EXECUTABLE}")
530 if (NOT WITHOUT_SERVER)
534 if (NOT WITHOUT_TEST_SERVER)
535 create_test_app(test-server
536 "test-server/test-server.c"
538 "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
542 # test-server-extpoll
544 if (NOT WITHOUT_TEST_SERVER_EXTPOLL)
545 create_test_app(test-server-extpoll
546 "test-server/test-server.c"
547 "win32port/win32helpers/websock-w32.c"
548 "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
549 # Set defines for this executable only.
551 TARGET test-server-extpoll
552 PROPERTY COMPILE_DEFINITIONS
554 INSTALL_DATADIR="${SSL_CERT_DIR}"
557 # We need to link against winsock code.
559 target_link_libraries(test-server-extpoll ws2_32.lib)
563 # Data files for running the test server.
565 ${PROJECT_SOURCE_DIR}/test-server/favicon.ico
566 ${PROJECT_SOURCE_DIR}/test-server/leaf.jpg
567 ${PROJECT_SOURCE_DIR}/test-server/libwebsockets.org-logo.png
568 ${PROJECT_SOURCE_DIR}/test-server/test.html)
570 # Generate self-signed SSL certs for the test-server.
571 if (WITH_SSL AND OPENSSL_EXECUTABLE)
572 message("Generating SSL Certificates for the test-server...")
574 set(TEST_SERVER_SSL_KEY ${PROJECT_BINARY_DIR}/libwebsockets-test-server.key.pem)
575 set(TEST_SERVER_SSL_CERT ${PROJECT_BINARY_DIR}/libwebsockets-test-server.pem)
578 file(WRITE ${PROJECT_BINARY_DIR}/openssl_input.txt
582 "libwebsockets-test\n"
584 "none@invalid.org\n\n"
587 # The "type" command is a bit picky with paths.
588 file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/openssl_input.txt" OPENSSL_INPUT_WIN_PATH)
591 COMMAND cmd /c type "${OPENSSL_INPUT_WIN_PATH}"
592 COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}"
593 RESULT_VARIABLE OPENSSL_RETURN_CODE)
597 if (OPENSSL_RETURN_CODE)
598 message("!!! Failed to generate SSL certificate:\n${OPENSSL_RETURN_CODE} !!!")
602 COMMAND printf "GB\\nErewhon\\nAll around\\nlibwebsockets-test\\n\\nlocalhost\\nnone@invalid.org\\n"
603 COMMAND ${OPENSSL_EXECUTABLE}
604 req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout ${TEST_SERVER_SSL_KEY} -out ${TEST_SERVER_SSL_CERT}
608 list(APPEND TEST_SERVER_DATA
609 ${TEST_SERVER_SSL_KEY}
610 ${TEST_SERVER_SSL_CERT})
613 # Copy the file needed to run the server so that the test apps can
614 # reach them from their default output location
615 foreach (TEST_FILE ${TEST_SERVER_DATA})
616 add_custom_command(TARGET test-server
618 COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server"
619 COMMAND ${CMAKE_COMMAND} -E copy ${TEST_FILE} "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server" VERBATIM)
621 endif(NOT WITHOUT_SERVER)
623 if (NOT WITHOUT_CLIENT)
627 if (NOT WITHOUT_TEST_CLIENT)
628 create_test_app(test-client
629 "test-server/test-client.c"
637 if (NOT WITHOUT_TEST_FRAGGLE)
638 create_test_app(test-fraggle
639 "test-server/test-fraggle.c"
641 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
647 if (NOT WITHOUT_TEST_PING)
648 create_test_app(test-ping
649 "test-server/test-ping.c"
651 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
653 endif(NOT WITHOUT_CLIENT)
656 # Copy OpenSSL dlls to the output directory on Windows.
657 # (Otherwise we'll get an error when trying to run)
659 if (WIN32 AND WITH_SSL AND NOT USE_CYASSL)
660 if(OPENSSL_BIN_FOUND)
661 message("OpenSSL dlls found:")
662 message(" Libeay: ${LIBEAY_BIN}")
663 message(" SSLeay: ${SSLEAY_BIN}")
665 foreach(TARGET_BIN ${TEST_APP_LIST})
666 add_custom_command(TARGET ${TARGET_BIN}
668 COMMAND ${CMAKE_COMMAND} -E copy ${LIBEAY_BIN} $<TARGET_FILE_DIR:${TARGET_BIN}> VERBATIM)
670 add_custom_command(TARGET ${TARGET_BIN}
672 COMMAND ${CMAKE_COMMAND} -E copy ${SSLEAY_BIN} $<TARGET_FILE_DIR:${TARGET_BIN}> VERBATIM)
676 endif(NOT WITHOUT_TESTAPPS)
679 # Generate documentation.
680 # TODO: Fix this on Windows.
681 message("Generating API documentation")
682 file(GLOB C_FILES ${PROJECT_SOURCE_DIR}/lib/*.c)
683 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/doc/)
686 COMMAND ${PROJECT_SOURCE_DIR}/scripts/kernel-doc -html ${C_FILES} ${HDR_PUBLIC}
687 OUTPUT_FILE ${PROJECT_BINARY_DIR}/doc/libwebsockets-api-doc.html
691 COMMAND ${PROJECT_SOURCE_DIR}/scripts/kernel-doc -text ${C_FILES} ${HDR_PUBLIC}
692 OUTPUT_FILE ${PROJECT_BINARY_DIR}/doc/libwebsockets-api-doc.txt
695 # Generate and install pkgconfig.
696 # (This is not indented, because the tabs will be part of the output)
697 file(WRITE ${PROJECT_BINARY_DIR}/libwebsockets.pc
699 exec_prefix=\${prefix}
700 libdir=\${exec_prefix}/lib${LIB_SUFFIX}
701 includedir=\${prefix}/include
704 Description: Websockets server and client library
705 Version: ${PACKAGE_VERSION}
707 Libs: -L\${libdir} -lwebsockets
708 Cflags: -I\${includedir}"
711 install(FILES ${PROJECT_BINARY_DIR}/libwebsockets.pc
712 DESTINATION lib${LIB_SUFFIX}/pkgconfig)
716 install(FILES ${HDR_PUBLIC}
719 set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header files")
722 install(TARGETS websockets websockets_shared
723 LIBRARY DESTINATION lib${LIB_SUFFIX}
724 ARCHIVE DESTINATION lib${LIB_SUFFIX}
726 set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
729 if (NOT WITHOUT_TESTAPPS)
730 install(TARGETS test-client ${TEST_APP_LIST}
731 RUNTIME DESTINATION bin
733 set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example Install")
736 # Programs shared files used by the test-server.
737 if (NOT WITHOUT_TESTAPPS AND NOT WITHOUT_SERVER)
738 install(FILES ${TEST_SERVER_DATA}
739 DESTINATION share/libwebsockets-test-server
743 # Most people are more used to "make dist" compared to "make package_source"
744 add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
746 # This must always be last!