• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1project(minimal-secure-streams-metadata)
2cmake_minimum_required(VERSION 2.8)
3include(CheckCSourceCompiles)
4
5set(SAMP lws-minimal-secure-streams-metadata)
6
7# If we are being built as part of lws, confirm current build config supports
8# reqconfig, else skip building ourselves.
9#
10# If we are being built externally, confirm installed lws was configured to
11# support reqconfig, else error out with a helpful message about the problem.
12#
13MACRO(require_lws_config reqconfig _val result)
14
15	if (DEFINED ${reqconfig})
16	if (${reqconfig})
17		set (rq 1)
18	else()
19		set (rq 0)
20	endif()
21	else()
22		set(rq 0)
23	endif()
24
25	if (${_val} EQUAL ${rq})
26		set(SAME 1)
27	else()
28		set(SAME 0)
29	endif()
30
31	if (LWS_WITH_MINIMAL_EXAMPLES AND NOT ${SAME})
32		if (${_val})
33			message("${SAMP}: skipping as lws being built without ${reqconfig}")
34		else()
35			message("${SAMP}: skipping as lws built with ${reqconfig}")
36		endif()
37		set(${result} 0)
38	else()
39		if (LWS_WITH_MINIMAL_EXAMPLES)
40			set(MET ${SAME})
41		else()
42			CHECK_C_SOURCE_COMPILES("#include <libwebsockets.h>\nint main(void) {\n#if defined(${reqconfig})\n return 0;\n#else\n fail;\n#endif\n return 0;\n}\n" HAS_${reqconfig})
43			if (NOT DEFINED HAS_${reqconfig} OR NOT HAS_${reqconfig})
44				set(HAS_${reqconfig} 0)
45			else()
46				set(HAS_${reqconfig} 1)
47			endif()
48			if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val}))
49				set(MET 1)
50			else()
51				set(MET 0)
52			endif()
53		endif()
54		if (NOT MET)
55			if (${_val})
56				message(FATAL_ERROR "This project requires lws must have been configured with ${reqconfig}")
57			else()
58				message(FATAL_ERROR "Lws configuration of ${reqconfig} is incompatible with this project")
59			endif()
60		endif()
61	endif()
62ENDMACRO()
63
64
65set(requirements 1)
66require_lws_config(LWS_ROLE_H1 1 requirements)
67require_lws_config(LWS_WITHOUT_CLIENT 0 requirements)
68require_lws_config(LWS_WITH_SECURE_STREAMS 1 requirements)
69
70if (requirements)
71	add_executable(${SAMP} minimal-secure-streams.c)
72
73	if (websockets_shared)
74		target_link_libraries(${SAMP} websockets_shared)
75		add_dependencies(${SAMP} websockets_shared)
76	else()
77		target_link_libraries(${SAMP} websockets)
78	endif()
79
80	if (LWS_WITH_SECURE_STREAMS_PROXY_API)
81		add_compile_options(-DLWS_SS_USE_SSPC)
82
83		add_executable(${SAMP}-client minimal-secure-streams.c)
84		if (websockets_shared)
85			target_link_libraries(${SAMP}-client websockets_shared)
86			add_dependencies(${SAMP}-client websockets_shared)
87		else()
88			target_link_libraries(${SAMP}-client websockets)
89		endif()
90	endif()
91
92endif()
93