File: CMakeLists.txt

package info (click to toggle)
libwebsockets 2.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 5,424 kB
  • ctags: 4,865
  • sloc: ansic: 33,281; perl: 1,656; sh: 872; cpp: 226; makefile: 77; awk: 5
file content (78 lines) | stat: -rw-r--r-- 2,301 bytes parent folder | download | duplicates (2)
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
cmake_minimum_required(VERSION 2.8)

if(NOT DEFINED CMAKE_BUILD_TYPE)
	set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type")
endif()

# This shows one way to build a standalone plugin
# outside of lws itself

project(lws-protocol-plugin-example C)

set(PACKAGE "lws-protocol-plugin-example")
set(CPACK_PACKAGE_NAME "${PACKAGE}")
set(CPACK_PACKAGE_VERSION "0.1")
set(CPACK_PACKAGE_VENDOR "andy@warmcat.com")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE} ${PACKAGE_VERSION}")
set(SOVERSION "1")
set(VERSION "0.1")


set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/")

message(STATUS "CMAKE_TOOLCHAIN_FILE='${CMAKE_TOOLCHAIN_FILE}'")

# Try to find the current Git hash.
find_package(Git)
if(GIT_EXECUTABLE)
	execute_process(
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    COMMAND "${GIT_EXECUTABLE}" describe
    OUTPUT_VARIABLE GIT_HASH
    OUTPUT_STRIP_TRAILING_WHITESPACE
    )
	execute_process(
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    COMMAND "whoami"
    OUTPUT_VARIABLE GIT_USER
    OUTPUT_STRIP_TRAILING_WHITESPACE
    )
	execute_process(
    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
    COMMAND "hostname"
    OUTPUT_VARIABLE GIT_HOST
    OUTPUT_STRIP_TRAILING_WHITESPACE
    )
	string(REGEX REPLACE "([^\\])[\\]([^\\])" "\\1\\\\\\\\\\2" GIT_USER ${GIT_USER})
    set(LWS_BUILD_HASH ${GIT_USER}@${GIT_HOST}-${GIT_HASH})
    message("Git commit hash: ${LWS_BUILD_HASH}")
endif()

set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")

macro(create_plugin PLUGIN_NAME MAIN_SRC)
	set(PLUGIN_SRCS ${MAIN_SRC})
	
	source_group("Headers Private"   FILES ${PLUGIN_HDR})
	source_group("Sources"   FILES ${PLUGIN_SRCS})
	add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
	
	target_link_libraries(${PLUGIN_NAME} -lwebsockets)
	
	# Set test app specific defines.
	set_property(TARGET ${PLUGIN_NAME}
		     PROPERTY COMPILE_DEFINITIONS
		     INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
	)
	
	list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
endmacro()


create_plugin(protocol_example_standalone
	      "protocol_example_standalone.c")

install(TARGETS ${PLUGINS_LIST}
	PERMISSIONS  OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE OWNER_READ GROUP_READ WORLD_READ
	DESTINATION share/libwebsockets-test-server/plugins
	COMPONENT plugins)