1 cmake_minimum_required(VERSION 2.8)
2 include(CheckCSourceCompiles)
4 set(SAMP lws-minimal-http-server-basicauth)
5 set(SRCS minimal-http-server-basicauth.c)
7 # If we are being built as part of lws, confirm current build config supports
8 # reqconfig, else skip building ourselves.
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.
13 MACRO(require_lws_config reqconfig _val result)
15 if (DEFINED ${reqconfig})
25 if (${_val} EQUAL ${rq})
31 if (LWS_WITH_MINIMAL_EXAMPLES AND NOT ${SAME})
33 message("${SAMP}: skipping as lws being built without ${reqconfig}")
35 message("${SAMP}: skipping as lws built with ${reqconfig}")
39 if (LWS_WITH_MINIMAL_EXAMPLES)
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)
46 set(HAS_${reqconfig} 1)
48 if ((HAS_${reqconfig} AND ${_val}) OR (NOT HAS_${reqconfig} AND NOT ${_val}))
56 message(FATAL_ERROR "This project requires lws must have been configured with ${reqconfig}")
58 message(FATAL_ERROR "Lws configuration of ${reqconfig} is incompatible with this project")
65 require_lws_config(LWS_ROLE_H1 1 requirements)
66 require_lws_config(LWS_WITHOUT_SERVER 0 requirements)
69 add_executable(${SAMP} ${SRCS})
71 if (websockets_shared)
72 target_link_libraries(${SAMP} websockets_shared)
73 add_dependencies(${SAMP} websockets_shared)
75 target_link_libraries(${SAMP} websockets)