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 "3")
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 "4.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)
52 if (WITHOUT_CLIENT AND WITHOUT_SERVER)
53 message(FATAL_ERROR "Makes no sense to compile without both client or server.")
56 # The base dir where the test-apps look for the SSL certs.
57 set(SSL_CERT_DIR CACHE STRING "")
58 set(SSL_CLIENT_CERT_DIR CACHE STRING "")
60 if ("${SSL_CERT_DIR}" STREQUAL "")
61 set(SSL_CERT_DIR "../share")
64 if ("${SSL_CLIENT_CERT_DIR}" STREQUAL "")
66 set(LWS_OPENSSL_CLIENT_CERTS ".")
68 set(LWS_OPENSSL_CLIENT_CERTS "/etc/pki/tls/certs/")
71 set(LWS_OPENSSL_CLIENT_CERTS "${SSL_CLIENT_CERT_DIR}")
74 set(CYASSL_LIB CACHE STRING "")
75 set(CYASSL_INCLUDE_DIRS CACHE STRING "")
78 if ("${CYASSL_LIB}" STREQUAL "" OR "${CYASSL_INCLUDE_DIRS}" STREQUAL "")
79 message(FATAL_ERROR "You must set CYASSL_LIB and CYASSL_INCLUDE_DIRS when USE_CYASSL is turned on")
83 if (WITHOUT_EXTENSIONS)
84 set(LWS_NO_EXTENSIONS 1)
88 set(LWS_OPENSSL_SUPPORT 1)
95 if (WITHOUT_DAEMONIZE)
96 set(LWS_NO_DAEMONIZE 1)
114 set(LWS_MINGW_SUPPORT 1)
117 include_directories(${PROJECT_BINARY_DIR})
119 include(CheckCSourceCompiles)
121 # Check for different inline keyword versions.
122 foreach(KEYWORD "inline" "__inline__" "__inline")
123 set(CMAKE_REQUIRED_DEFINITIONS "-DKEYWORD=${KEYWORD}")
124 CHECK_C_SOURCE_COMPILES(
128 int main(int argc, char **argv) { a(); return 0; }
134 set(inline __inline__)
135 elseif(HAVE___inline)
140 # Put the libaries and binaries that get built into directories at the
141 # top of the build tree rather than in hard-to-find leaf directories.
142 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
143 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
144 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
146 # So we can include the CMake generated config file only when
147 # building with CMAKE.
148 add_definitions(-DCMAKE_BUILD)
150 include(CheckFunctionExists)
151 include(CheckIncludeFile)
152 include(CheckIncludeFiles)
153 include(CheckLibraryExists)
155 CHECK_FUNCTION_EXISTS(bzero HAVE_BZERO)
156 CHECK_FUNCTION_EXISTS(fork HAVE_FORK)
157 CHECK_FUNCTION_EXISTS(malloc HAVE_MALLOC)
158 CHECK_FUNCTION_EXISTS(memset HAVE_MEMSET)
159 CHECK_FUNCTION_EXISTS(realloc HAVE_REALLOC)
160 CHECK_FUNCTION_EXISTS(socket HAVE_SOCKET)
161 CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
162 CHECK_FUNCTION_EXISTS(vfork HAVE_VFORK)
163 CHECK_FUNCTION_EXISTS(getifaddrs HAVE_GETIFADDRS)
165 if (NOT HAVE_GETIFADDRS)
166 if (WITHOUT_BUILTIN_GETIFADDRS)
167 message(FATAL_ERROR "No getifaddrs was found on the system. Turn off the WITHOUT_BUILTIN_GETIFADDRS compile option to use the supplied BSD version.")
170 set(LWS_BUILTIN_GETIFADDRS 1)
173 CHECK_INCLUDE_FILE(dlfcn.h HAVE_DLFCN_H)
174 CHECK_INCLUDE_FILE(fcntl.h HAVE_FCNTL_H)
175 CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
176 CHECK_INCLUDE_FILE(memory.h HAVE_MEMORY_H)
177 CHECK_INCLUDE_FILE(netinet/in.h HAVE_NETINET_IN_H)
178 CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
179 CHECK_INCLUDE_FILE(stdlib.h HAVE_STDLIB_H)
180 CHECK_INCLUDE_FILE(strings.h HAVE_STRINGS_H)
181 CHECK_INCLUDE_FILE(string.h HAVE_STRING_H)
182 CHECK_INCLUDE_FILE(sys/prctl.h HAVE_SYS_PRCTL_H)
183 CHECK_INCLUDE_FILE(sys/socket.h HAVE_SYS_SOCKET_H)
184 CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
185 CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
186 CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
187 CHECK_INCLUDE_FILE(vfork.h HAVE_VFORK_H)
188 CHECK_INCLUDE_FILE(zlib.h HAVE_ZLIB_H)
190 # TODO: These can be tested if they actually work also...
191 set(HAVE_WORKING_FORK HAVE_FORK)
192 set(HAVE_WORKING_VFORK HAVE_VFORK)
194 CHECK_INCLUDE_FILES("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
196 if (NOT HAVE_SYS_TYPES_H)
198 set(size_t "unsigned int")
202 set(malloc rpl_malloc)
205 if (NOT HAVE_REALLOC)
206 set(realloc rpl_realloc)
209 # Generate the config.h that includes all the compilation settings.
211 ${PROJECT_SOURCE_DIR}/config.h.cmake
212 ${PROJECT_BINARY_DIR}/lws_config.h)
215 # Turn off stupid microsoft security warnings.
216 add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
219 include_directories(${PROJECT_SOURCE_DIR}/lib)
221 # Group headers and sources.
222 # Some IDEs use this for nicer file structure.
224 lib/private-libwebsockets.h
225 ${PROJECT_BINARY_DIR}/lws_config.h
229 ${PROJECT_SOURCE_DIR}/lib/libwebsockets.h
241 if (NOT WITHOUT_CLIENT)
244 lib/client-handshake.c
249 if (NOT WITHOUT_SERVER)
252 lib/server-handshake.c
256 if (NOT WITHOUT_EXTENSIONS)
257 list(APPEND HDR_PRIVATE
258 lib/extension-deflate-frame.h
259 lib/extension-deflate-stream.h
264 lib/extension-deflate-frame.c
265 lib/extension-deflate-stream.c
269 # Add helper files for Windows.
271 set(WIN32_HELPERS_PATH win32port/win32helpers)
273 list(APPEND HDR_PUBLIC
274 ${WIN32_HELPERS_PATH}/websock-w32.h
275 ${WIN32_HELPERS_PATH}/gettimeofday.h
279 ${WIN32_HELPERS_PATH}/gettimeofday.c
283 ${WIN32_HELPERS_PATH}/websock-w32.c
284 ${WIN32_HELPERS_PATH}/gettimeofday.c
287 include_directories(${WIN32_HELPERS_PATH})
290 if (NOT WITHOUT_DAEMONIZE)
298 if (NOT HAVE_GETIFADDRS)
299 list(APPEND HDR_PRIVATE lib/getifaddrs.h)
300 list(APPEND SOURCES lib/getifaddrs.c)
305 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
306 set( CMAKE_C_FLAGS "-Wall -Werror -O4 " )
309 source_group("Headers Private" FILES ${HDR_PRIVATE})
310 source_group("Headers Public" FILES ${HDR_PUBLIC})
311 source_group("Sources" FILES ${SOURCES})
316 add_library(websockets STATIC
320 add_library(websockets_shared SHARED
326 # On Windows libs have the same file ending (.lib)
327 # for both static and shared libraries, so we
328 # need a unique name for the static one.
329 set_target_properties(websockets
331 OUTPUT_NAME websockets_static)
333 # Compile as DLL (export function declarations)
335 TARGET websockets_shared
336 PROPERTY COMPILE_DEFINITIONS
342 # We want the shared lib to be named "libwebsockets"
343 # not "libwebsocket_shared".
344 set_target_properties(websockets_shared
346 OUTPUT_NAME websockets)
348 # Set the so version of the lib.
349 # Equivalent to LDFLAGS=-version-info x:x:x
350 if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
351 foreach(lib websockets websockets_shared)
352 set_target_properties(${lib}
354 SOVERSION ${SOVERSION})
365 # ZLIB (Only needed for deflate extensions).
367 if (NOT WITHOUT_EXTENSIONS)
368 if (WIN32 AND NOT USE_EXTERNAL_ZLIB)
369 message("Using included Zlib version")
371 # Compile ZLib if needed.
372 set(WIN32_ZLIB_PATH "win32port/zlib")
374 ${WIN32_ZLIB_PATH}/adler32.c
375 ${WIN32_ZLIB_PATH}/compress.c
376 ${WIN32_ZLIB_PATH}/crc32.c
377 ${WIN32_ZLIB_PATH}/deflate.c
378 ${WIN32_ZLIB_PATH}/gzclose.c
379 ${WIN32_ZLIB_PATH}/gzio.c
380 ${WIN32_ZLIB_PATH}/gzlib.c
381 ${WIN32_ZLIB_PATH}/gzread.c
382 ${WIN32_ZLIB_PATH}/gzwrite.c
383 ${WIN32_ZLIB_PATH}/infback.c
384 ${WIN32_ZLIB_PATH}/inffast.c
385 ${WIN32_ZLIB_PATH}/inflate.c
386 ${WIN32_ZLIB_PATH}/inftrees.c
387 ${WIN32_ZLIB_PATH}/trees.c
388 ${WIN32_ZLIB_PATH}/uncompr.c
389 ${WIN32_ZLIB_PATH}/zutil.c
392 # Create the library.
393 add_library(ZLIB STATIC ${ZLIB_SRCS})
395 # Set the same variables as find_package would.
396 set(ZLIB_INCLUDE_DIRS ${WIN32_ZLIB_PATH})
397 get_property(ZLIB_LIBRARIES TARGET ZLIB PROPERTY LOCATION)
400 find_package(ZLIB REQUIRED)
403 # Make sure ZLib is compiled before the libs.
404 foreach (lib websockets websockets_shared)
405 add_dependencies(${lib} ZLIB)
408 message("ZLib include dirs: ${ZLIB_INCLUDE_DIRS}")
409 message("ZLib libraries: ${ZLIB_LIBRARIES}")
410 include_directories(${ZLIB_INCLUDE_DIRS})
411 list(APPEND LIB_LIST ${ZLIB_LIBRARIES})
412 endif(NOT WITHOUT_EXTENSIONS)
418 message("Compiling with SSL support")
421 # Use CyaSSL as OpenSSL replacement.
422 # TODO: Add a find_package command for this also.
423 message("CyaSSL include dir: ${CYASSL_INCLUDE_DIRS}")
424 message("CyaSSL libraries: ${CYASSL_LIB}")
426 # Additional to the root directory we need to include
427 # the cyassl/ subdirectory which contains the OpenSSL
428 # compatability layer headers.
429 foreach(inc ${CYASSL_INCLUDE_DIRS})
430 include_directories(${inc} ${inc}/cyassl)
433 list(APPEND ${LIB_LIST} ${CYASSL_LIB})
435 # TODO: Add support for STATIC also.
436 find_package(OpenSSL REQUIRED)
438 message("OpenSSL include dir: ${OPENSSL_INCLUDE_DIR}")
439 message("OpenSSL libraries: ${OPENSSL_LIBRARIES}")
441 include_directories(${OPENSSL_INCLUDE_DIR})
442 list(APPEND LIB_LIST ${OPENSSL_LIBRARIES})
447 # Platform specific libs.
450 list(APPEND LIB_LIST ws2_32.lib)
454 list(APPEND LIB_LIST m)
457 # Setup the linking for all libs.
458 foreach (lib websockets websockets_shared)
459 target_link_libraries(${lib} ${LIB_LIST})
466 if (NOT WITHOUT_TESTAPPS)
468 # Helper function for adding a test app.
470 macro(create_test_app TEST_NAME MAIN_SRC WIN32_SRCS WIN32_HDRS)
472 set(TEST_SRCS ${MAIN_SRC})
476 list(APPEND TEST_SRCS
477 ${WIN32_HELPERS_PATH}/getopt.c
478 ${WIN32_HELPERS_PATH}/getopt_long.c
479 ${WIN32_HELPERS_PATH}/gettimeofday.c
483 ${WIN32_HELPERS_PATH}/getopt.h
484 ${WIN32_HELPERS_PATH}/gettimeofday.h
488 source_group("Headers Private" FILES ${TEST_HDR})
489 source_group("Sources" FILES ${TEST_SRCS})
490 add_executable(${TEST_NAME} ${TEST_SRCS} ${TEST_HDR})
492 if (LINK_TESTAPPS_DYNAMIC)
493 target_link_libraries(${TEST_NAME} websockets_shared)
494 add_dependencies(${TEST_NAME} websockets_shared)
495 else(LINK_TESTAPPS_DYNAMIC)
496 target_link_libraries(${TEST_NAME} websockets)
497 add_dependencies(${TEST_NAME} websockets)
498 endif(LINK_TESTAPPS_DYNAMIC)
500 # Set test app specific defines.
501 set_property(TARGET ${TEST_NAME}
502 PROPERTY COMPILE_DEFINITIONS
503 INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share"
506 # Prefix the binary names with libwebsockets.
507 set_target_properties(${TEST_NAME}
509 OUTPUT_NAME libwebsockets-${TEST_NAME})
511 # Add to the list of tests.
512 list(APPEND TEST_APP_LIST ${TEST_NAME})
515 if (WITH_SSL AND NOT USE_CYASSL)
516 message("Searching for OpenSSL executable and dlls")
517 find_package(OpenSSLbins)
518 message("OpenSSL executable: ${OPENSSL_EXECUTABLE}")
521 if (NOT WITHOUT_SERVER)
525 if (NOT WITHOUT_TEST_SERVER)
526 create_test_app(test-server
527 "test-server/test-server.c"
529 "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
533 # test-server-extpoll
535 if (NOT WITHOUT_TEST_SERVER_EXTPOLL)
536 create_test_app(test-server-extpoll
537 "test-server/test-server.c"
538 "win32port/win32helpers/websock-w32.c"
539 "${WIN32_HELPERS_PATH}/netdb.h;${WIN32_HELPERS_PATH}/strings.h;${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/websock-w32.h")
540 # Set defines for this executable only.
542 TARGET test-server-extpoll
543 PROPERTY COMPILE_DEFINITIONS
545 INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share"
548 # We need to link against winsock code.
550 target_link_libraries(test-server-extpoll ws2_32.lib)
554 # Data files for running the test server.
556 ${PROJECT_SOURCE_DIR}/test-server/favicon.ico
557 ${PROJECT_SOURCE_DIR}/test-server/leaf.jpg
558 ${PROJECT_SOURCE_DIR}/test-server/libwebsockets.org-logo.png
559 ${PROJECT_SOURCE_DIR}/test-server/test.html)
561 # Generate self-signed SSL certs for the test-server.
562 if (WITH_SSL AND OPENSSL_EXECUTABLE)
563 message("Generating SSL Certificates for the test-server...")
565 set(TEST_SERVER_SSL_KEY ${PROJECT_BINARY_DIR}/libwebsockets-test-server.key.pem)
566 set(TEST_SERVER_SSL_CERT ${PROJECT_BINARY_DIR}/libwebsockets-test-server.pem)
569 file(WRITE ${PROJECT_BINARY_DIR}/openssl_input.txt
573 "libwebsockets-test\n"
575 "none@invalid.org\n\n"
578 # The "type" command is a bit picky with paths.
579 file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/openssl_input.txt" OPENSSL_INPUT_WIN_PATH)
582 COMMAND cmd /c type "${OPENSSL_INPUT_WIN_PATH}"
583 COMMAND "${OPENSSL_EXECUTABLE}" req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout "${TEST_SERVER_SSL_KEY}" -out "${TEST_SERVER_SSL_CERT}"
584 RESULT_VARIABLE OPENSSL_RETURN_CODE)
588 if (OPENSSL_RETURN_CODE)
589 message("!!! Failed to generate SSL certificate:\n${OPENSSL_RETURN_CODE} !!!")
593 COMMAND printf "GB\\nErewhon\\nAll around\\nlibwebsockets-test\\n\\nlocalhost\\nnone@invalid.org\\n"
594 COMMAND ${OPENSSL_EXECUTABLE}
595 req -new -newkey rsa:1024 -days 10000 -nodes -x509 -keyout ${TEST_SERVER_SSL_KEY} -out ${TEST_SERVER_SSL_CERT}
599 list(APPEND TEST_SERVER_DATA
600 ${TEST_SERVER_SSL_KEY}
601 ${TEST_SERVER_SSL_CERT})
604 # Copy the file needed to run the server so that the test apps can
605 # reach them from their default output location
606 foreach (TEST_FILE ${TEST_SERVER_DATA})
607 add_custom_command(TARGET test-server
609 COMMAND ${CMAKE_COMMAND} -E make_directory "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server"
610 COMMAND ${CMAKE_COMMAND} -E copy ${TEST_FILE} "$<TARGET_FILE_DIR:test-server>/../share/libwebsockets-test-server" VERBATIM)
612 endif(NOT WITHOUT_SERVER)
614 if (NOT WITHOUT_CLIENT)
618 if (NOT WITHOUT_TEST_CLIENT)
619 create_test_app(test-client
620 "test-server/test-client.c"
628 if (NOT WITHOUT_TEST_FRAGGLE)
629 create_test_app(test-fraggle
630 "test-server/test-fraggle.c"
632 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
638 if (NOT WITHOUT_TEST_PING)
639 create_test_app(test-ping
640 "test-server/test-ping.c"
642 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
647 if (NOT WITHOUT_TEST_ECHO)
648 create_test_app(test-echo
649 "test-server/test-echo.c"
651 "${WIN32_HELPERS_PATH}/unistd.h;${WIN32_HELPERS_PATH}/sys/time.h")
654 endif(NOT WITHOUT_CLIENT)
657 # Copy OpenSSL dlls to the output directory on Windows.
658 # (Otherwise we'll get an error when trying to run)
660 if (WIN32 AND WITH_SSL AND NOT USE_CYASSL)
661 if(OPENSSL_BIN_FOUND)
662 message("OpenSSL dlls found:")
663 message(" Libeay: ${LIBEAY_BIN}")
664 message(" SSLeay: ${SSLEAY_BIN}")
666 foreach(TARGET_BIN ${TEST_APP_LIST})
667 add_custom_command(TARGET ${TARGET_BIN}
669 COMMAND ${CMAKE_COMMAND} -E copy ${LIBEAY_BIN} $<TARGET_FILE_DIR:${TARGET_BIN}> VERBATIM)
671 add_custom_command(TARGET ${TARGET_BIN}
673 COMMAND ${CMAKE_COMMAND} -E copy ${SSLEAY_BIN} $<TARGET_FILE_DIR:${TARGET_BIN}> VERBATIM)
677 endif(NOT WITHOUT_TESTAPPS)
680 # Generate documentation.
681 # TODO: Fix this on Windows.
682 message("Generating API documentation")
683 file(GLOB C_FILES ${PROJECT_SOURCE_DIR}/lib/*.c)
684 execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${PROJECT_BINARY_DIR}/doc/)
687 COMMAND ${PROJECT_SOURCE_DIR}/scripts/kernel-doc -html ${C_FILES} ${HDR_PUBLIC}
688 OUTPUT_FILE ${PROJECT_BINARY_DIR}/doc/libwebsockets-api-doc.html
692 COMMAND ${PROJECT_SOURCE_DIR}/scripts/kernel-doc -text ${C_FILES} ${HDR_PUBLIC}
693 OUTPUT_FILE ${PROJECT_BINARY_DIR}/doc/libwebsockets-api-doc.txt
696 # Generate and install pkgconfig.
697 # (This is not indented, because the tabs will be part of the output)
698 file(WRITE ${PROJECT_BINARY_DIR}/libwebsockets.pc
700 exec_prefix=\${prefix}
701 libdir=\${exec_prefix}/lib${LIB_SUFFIX}
702 includedir=\${prefix}/include
705 Description: Websockets server and client library
706 Version: ${PACKAGE_VERSION}
708 Libs: -L\${libdir} -lwebsockets
709 Cflags: -I\${includedir}"
712 install(FILES ${PROJECT_BINARY_DIR}/libwebsockets.pc
713 DESTINATION lib${LIB_SUFFIX}/pkgconfig)
717 install(FILES ${HDR_PUBLIC}
720 set(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "Header files")
723 install(TARGETS websockets websockets_shared
724 LIBRARY DESTINATION lib${LIB_SUFFIX}
725 ARCHIVE DESTINATION lib${LIB_SUFFIX}
727 set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries")
730 if (NOT WITHOUT_TESTAPPS)
731 install(TARGETS test-client ${TEST_APP_LIST}
732 RUNTIME DESTINATION bin
734 set(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Example Install")
737 # Programs shared files used by the test-server.
738 if (NOT WITHOUT_TESTAPPS AND NOT WITHOUT_SERVER)
739 install(FILES ${TEST_SERVER_DATA}
740 DESTINATION share/libwebsockets-test-server
744 # build subdir is not part of sources
745 set(CPACK_SOURCE_IGNORE_FILES $(CPACK_SOURCE_IGNORE_FILES) ".git" "build" "tgz" "tar.gz")
747 # Most people are more used to "make dist" compared to "make package_source"
748 add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
750 # This must always be last!