dummy handler: LWS_CALLBACK_HTTP_FILE_COMPLETION
[platform/upstream/libwebsockets.git] / plugin-standalone / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.8)
2
3 if(NOT DEFINED CMAKE_BUILD_TYPE)
4         set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
5 endif()
6
7 # This shows one way to build a standalone plugin
8 # outside of lws itself
9
10 project(lws-protocol-plugin-example C)
11
12 set(PACKAGE "lws-protocol-plugin-example")
13 set(CPACK_PACKAGE_NAME "${PACKAGE}")
14 set(CPACK_PACKAGE_VERSION "0.1")
15 set(CPACK_PACKAGE_VENDOR "andy@warmcat.com")
16 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}")
17 set(SOVERSION "1")
18 set(VERSION "0.1")
19
20 set(PLUGIN_NAME "protocol_example_standalone")
21 # space-separated list of sources
22 set(PLUGIN_SRCS protocol_example_standalone.c)
23
24 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")
25
26 message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'")
27
28 # Try to find the current Git hash.
29 find_package(Git)
30 if(GIT_EXECUTABLE)
31         execute_process(
32     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
33     COMMAND "${GIT_EXECUTABLE}" describe
34     OUTPUT_VARIABLE GIT_HASH
35     OUTPUT_STRIP_TRAILING_WHITESPACE
36     )
37         execute_process(
38     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
39     COMMAND "whoami"
40     OUTPUT_VARIABLE GIT_USER
41     OUTPUT_STRIP_TRAILING_WHITESPACE
42     )
43         execute_process(
44     WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
45     COMMAND "hostname"
46     OUTPUT_VARIABLE GIT_HOST
47     OUTPUT_STRIP_TRAILING_WHITESPACE
48     )
49         string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER})
50     set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH})
51     message("Git commit hash: ${LWS_BUILD_HASH}")
52 endif()
53
54 set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
55
56 source_group("Headers Private"   FILES ${PLUGIN_HDR})
57 source_group("Sources"   FILES ${PLUGIN_SRCS})
58 add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
59
60 target_link_libraries(${PLUGIN_NAME} -lwebsockets)
61
62 # Set test app specific defines.
63 set_property(TARGET ${PLUGIN_NAME}
64              PROPERTY COMPILE_DEFINITIONS
65              INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
66 )
67
68 list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
69
70 install(TARGETS ${PLUGINS_LIST}
71         PERMISSIONS  OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ
72         DESTINATION share/libwebsockets-test-server/plugins
73         COMPONENT plugins)