1d4afb5ceSopenharmony_ci#
2d4afb5ceSopenharmony_ci# libwebsockets - small server side websockets and web server implementation
3d4afb5ceSopenharmony_ci#
4d4afb5ceSopenharmony_ci# Copyright (C) 2010 - 2020 Andy Green <andy@warmcat.com>
5d4afb5ceSopenharmony_ci#
6d4afb5ceSopenharmony_ci# Permission is hereby granted, free of charge, to any person obtaining a copy
7d4afb5ceSopenharmony_ci# of this software and associated documentation files (the "Software"), to
8d4afb5ceSopenharmony_ci# deal in the Software without restriction, including without limitation the
9d4afb5ceSopenharmony_ci# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10d4afb5ceSopenharmony_ci# sell copies of the Software, and to permit persons to whom the Software is
11d4afb5ceSopenharmony_ci# furnished to do so, subject to the following conditions:
12d4afb5ceSopenharmony_ci#
13d4afb5ceSopenharmony_ci# The above copyright notice and this permission notice shall be included in
14d4afb5ceSopenharmony_ci# all copies or substantial portions of the Software.
15d4afb5ceSopenharmony_ci#
16d4afb5ceSopenharmony_ci# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17d4afb5ceSopenharmony_ci# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18d4afb5ceSopenharmony_ci# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19d4afb5ceSopenharmony_ci# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20d4afb5ceSopenharmony_ci# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21d4afb5ceSopenharmony_ci# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22d4afb5ceSopenharmony_ci# IN THE SOFTWARE.
23d4afb5ceSopenharmony_ci#
24d4afb5ceSopenharmony_ci
25d4afb5ceSopenharmony_ciinclude_directories(.)
26d4afb5ceSopenharmony_ci
27d4afb5ceSopenharmony_cimacro(add_subdir_include_dirs arg1)
28d4afb5ceSopenharmony_ci	add_subdirectory(${arg1})
29d4afb5ceSopenharmony_ci	list(APPEND LWS_LIB_BUILD_INC_PATHS ${_CMAKE_INC_LIST}) 
30d4afb5ceSopenharmony_ciendmacro()
31d4afb5ceSopenharmony_ci
32d4afb5ceSopenharmony_ciset(LWS_LIB_INCLUDES "")
33d4afb5ceSopenharmony_ci
34d4afb5ceSopenharmony_ci#
35d4afb5ceSopenharmony_ci# Plat specific build items
36d4afb5ceSopenharmony_ci#
37d4afb5ceSopenharmony_ci
38d4afb5ceSopenharmony_ciif (LWS_PLAT_FREERTOS)
39d4afb5ceSopenharmony_ci	add_subdir_include_dirs(plat/freertos)
40d4afb5ceSopenharmony_ci	if (ESP_PLATFORM)
41d4afb5ceSopenharmony_ci		list(APPEND LWS_ESP_IDF_DIRS
42d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/freertos/include
43d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_hw_support/include/soc/
44d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_common/include
45d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_timer/include
46d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/soc/include
47d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/soc/src/esp32/include
48d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/port/esp32/include
49d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/lwip/src/include
50d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/port/esp32/include
51d4afb5ceSopenharmony_ci		    ${CMAKE_BINARY_DIR}/config
52d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_rom/include
53d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_system/include
54d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/include/apps/sntp
55d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/soc/soc/esp32/include
56d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/heap/include
57d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/mbedtls/mbedtls/include
58d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/mbedtls/port/include
59d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_wifi/include
60d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_event/include
61d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_netif/include
62d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp_eth/include
63d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/driver/include
64d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/soc/soc/include
65d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/tcpip_adapter/include
66d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/include/apps
67d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/nvs_flash/include
68d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/esp32/include
69d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/spi_flash/include
70d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/mdns/include
71d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/lwip/src/include/lwip
72d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/lwip/src/include
73d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/lwip/lwip/src/include/lwip
74d4afb5ceSopenharmony_ci		    $ENV{IDF_PATH}/components/newlib/platform_include )
75d4afb5ceSopenharmony_ci
76d4afb5ceSopenharmony_ci		    include_directories(${LWS_ESP_IDF_DIRS})
77d4afb5ceSopenharmony_ci
78d4afb5ceSopenharmony_ci		    list(APPEND CMAKE_REQUIRED_INCLUDES ${LWS_ESP_IDF_DIRS})
79d4afb5ceSopenharmony_ci	endif()
80d4afb5ceSopenharmony_ci
81d4afb5ceSopenharmony_ci	
82d4afb5ceSopenharmony_cielse()
83d4afb5ceSopenharmony_ci	if (LWS_PLAT_OPTEE)
84d4afb5ceSopenharmony_ci		add_subdir_include_dirs(plat/optee)
85d4afb5ceSopenharmony_ci	else()
86d4afb5ceSopenharmony_ci		if (WIN32)
87d4afb5ceSopenharmony_ci			add_subdir_include_dirs(plat/windows)
88d4afb5ceSopenharmony_ci		else()
89d4afb5ceSopenharmony_ci			add_subdir_include_dirs(plat/unix)
90d4afb5ceSopenharmony_ci		endif()
91d4afb5ceSopenharmony_ci	endif()
92d4afb5ceSopenharmony_ciendif()
93d4afb5ceSopenharmony_ci
94d4afb5ceSopenharmony_ciif (LIB_LIST)
95d4afb5ceSopenharmony_ci	set(CMAKE_REQUIRED_LIBRARIES ${LIB_LIST} ${CMAKE_REQUIRED_LIBRARIES})
96d4afb5ceSopenharmony_ciendif()
97d4afb5ceSopenharmony_ci
98d4afb5ceSopenharmony_ciif (LWS_WITH_ZLIB)
99d4afb5ceSopenharmony_ci	if (LWS_WITH_BUNDLED_ZLIB)
100d4afb5ceSopenharmony_ci		if (WIN32)
101d4afb5ceSopenharmony_ci			# it's trying to delete internal zlib entry
102d4afb5ceSopenharmony_ci			LIST(REMOVE_AT CMAKE_REQUIRED_LIBRARIES 0 )
103d4afb5ceSopenharmony_ci		endif()
104d4afb5ceSopenharmony_ci	endif()
105d4afb5ceSopenharmony_ciendif()
106d4afb5ceSopenharmony_ci
107d4afb5ceSopenharmony_ci
108d4afb5ceSopenharmony_ci# ideally we want to use pipe2()
109d4afb5ceSopenharmony_ci
110d4afb5ceSopenharmony_ciCHECK_C_SOURCE_COMPILES("
111d4afb5ceSopenharmony_ci	#ifndef _GNU_SOURCE
112d4afb5ceSopenharmony_ci	#define _GNU_SOURCE
113d4afb5ceSopenharmony_ci	#endif
114d4afb5ceSopenharmony_ci	#include <unistd.h>
115d4afb5ceSopenharmony_ci	int main(void) {
116d4afb5ceSopenharmony_ci		int fd[2];
117d4afb5ceSopenharmony_ci		return pipe2(fd, 0);
118d4afb5ceSopenharmony_ci	}" LWS_HAVE_PIPE2)
119d4afb5ceSopenharmony_ci
120d4afb5ceSopenharmony_ci# tcp keepalive needs this on linux to work practically... but it only exists
121d4afb5ceSopenharmony_ci# after kernel 2.6.37
122d4afb5ceSopenharmony_ci
123d4afb5ceSopenharmony_ciCHECK_C_SOURCE_COMPILES("#include <netinet/tcp.h>\nint main(void) { return TCP_USER_TIMEOUT; }\n" LWS_HAVE_TCP_USER_TIMEOUT)
124d4afb5ceSopenharmony_ciset(LWS_PUBLIC_INCLUDES "")
125d4afb5ceSopenharmony_ciif (LWS_WITH_TLS)
126d4afb5ceSopenharmony_ci	add_subdir_include_dirs(tls)
127d4afb5ceSopenharmony_ciendif()
128d4afb5ceSopenharmony_ci
129d4afb5ceSopenharmony_ci# Generate the lws_config.h that includes all the private compilation settings.
130d4afb5ceSopenharmony_ciconfigure_file(
131d4afb5ceSopenharmony_ci       "${PROJECT_SOURCE_DIR}/cmake/lws_config_private.h.in"
132d4afb5ceSopenharmony_ci       "${PROJECT_BINARY_DIR}/lws_config_private.h")
133d4afb5ceSopenharmony_ci
134d4afb5ceSopenharmony_ciadd_subdir_include_dirs(core)
135d4afb5ceSopenharmony_ciadd_subdir_include_dirs(misc)
136d4afb5ceSopenharmony_ciadd_subdir_include_dirs(system)
137d4afb5ceSopenharmony_ci
138d4afb5ceSopenharmony_ciif (LWS_WITH_DRIVERS)
139d4afb5ceSopenharmony_ci	add_subdir_include_dirs(drivers)
140d4afb5ceSopenharmony_ciendif()
141d4afb5ceSopenharmony_ci
142d4afb5ceSopenharmony_ciif (LWS_WITH_NETWORK)
143d4afb5ceSopenharmony_ci	add_subdir_include_dirs(core-net)
144d4afb5ceSopenharmony_ci	if (LWS_WITH_ABSTRACT)
145d4afb5ceSopenharmony_ci		add_subdir_include_dirs(abstract)
146d4afb5ceSopenharmony_ci	endif()
147d4afb5ceSopenharmony_ci	add_subdir_include_dirs(roles)
148d4afb5ceSopenharmony_ciendif()
149d4afb5ceSopenharmony_ci
150d4afb5ceSopenharmony_ciif (LWS_WITH_JOSE)
151d4afb5ceSopenharmony_ci	add_subdir_include_dirs(jose)
152d4afb5ceSopenharmony_ciendif()
153d4afb5ceSopenharmony_ciif (LWS_WITH_COSE)
154d4afb5ceSopenharmony_ci	add_subdir_include_dirs(cose)
155d4afb5ceSopenharmony_ciendif()
156d4afb5ceSopenharmony_ci
157d4afb5ceSopenharmony_ci
158d4afb5ceSopenharmony_ciif (LWS_WITH_SECURE_STREAMS)
159d4afb5ceSopenharmony_ci	add_subdir_include_dirs(secure-streams)
160d4afb5ceSopenharmony_ciendif()
161d4afb5ceSopenharmony_ci
162d4afb5ceSopenharmony_ciadd_subdir_include_dirs(event-libs)
163d4afb5ceSopenharmony_ci
164d4afb5ceSopenharmony_ciif (LWS_WITH_STATIC)
165d4afb5ceSopenharmony_ci    if (LWS_STATIC_PIC)
166d4afb5ceSopenharmony_ci        set(CMAKE_POSITION_INDEPENDENT_CODE ON)
167d4afb5ceSopenharmony_ci    endif()
168d4afb5ceSopenharmony_ci
169d4afb5ceSopenharmony_ci	add_library(websockets STATIC ${SOURCES})# ${HDR_PUBLIC})
170d4afb5ceSopenharmony_ci	set_target_properties(websockets PROPERTIES LINKER_LANGUAGE C)
171d4afb5ceSopenharmony_ci	list(APPEND LWS_LIBRARIES websockets)
172d4afb5ceSopenharmony_ci	target_include_directories(websockets INTERFACE
173d4afb5ceSopenharmony_ci		$<INSTALL_INTERFACE:${LWS_INSTALL_INCLUDE_DIR}>
174d4afb5ceSopenharmony_ci		$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
175d4afb5ceSopenharmony_ci		$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
176d4afb5ceSopenharmony_ci	)
177d4afb5ceSopenharmony_ci	target_include_directories(websockets PRIVATE ${LWS_LIB_BUILD_INC_PATHS})
178d4afb5ceSopenharmony_ci	target_compile_definitions(websockets PRIVATE LWS_BUILDING_STATIC)
179d4afb5ceSopenharmony_ci	target_include_directories(websockets PUBLIC ${LWS_PUBLIC_INCLUDES})
180d4afb5ceSopenharmony_ci	set(LWS_PUBLIC_INCLUDES ${LWS_PUBLIC_INCLUDES} PARENT_SCOPE)
181d4afb5ceSopenharmony_ci
182d4afb5ceSopenharmony_ci	if (WIN32)
183d4afb5ceSopenharmony_ci		# Windows uses the same .lib ending for static libraries and shared
184d4afb5ceSopenharmony_ci		# library linker files, so rename the static library.
185d4afb5ceSopenharmony_ci		set_target_properties(websockets
186d4afb5ceSopenharmony_ci			PROPERTIES
187d4afb5ceSopenharmony_ci			OUTPUT_NAME websockets_static)
188d4afb5ceSopenharmony_ci	endif()
189d4afb5ceSopenharmony_ci	
190d4afb5ceSopenharmony_ciendif()
191d4afb5ceSopenharmony_ci
192d4afb5ceSopenharmony_ciif (LWS_WITH_SHARED)
193d4afb5ceSopenharmony_ci	if (NOT RESOURCES)
194d4afb5ceSopenharmony_ci		set(RESOURCES "")
195d4afb5ceSopenharmony_ci	endif()
196d4afb5ceSopenharmony_ci	
197d4afb5ceSopenharmony_ci	add_library(websockets_shared SHARED ${SOURCES} ${RESOURCES})# ${HDR_PUBLIC})
198d4afb5ceSopenharmony_ci	set_target_properties(websockets_shared PROPERTIES LINKER_LANGUAGE C)
199d4afb5ceSopenharmony_ci	list(APPEND LWS_LIBRARIES websockets_shared)
200d4afb5ceSopenharmony_ci	target_include_directories(websockets_shared INTERFACE
201d4afb5ceSopenharmony_ci		$<INSTALL_INTERFACE:${LWS_INSTALL_INCLUDE_DIR}>
202d4afb5ceSopenharmony_ci		$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>
203d4afb5ceSopenharmony_ci		$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/../include>
204d4afb5ceSopenharmony_ci	)
205d4afb5ceSopenharmony_ci	target_include_directories(websockets_shared PRIVATE ${LWS_LIB_BUILD_INC_PATHS})
206d4afb5ceSopenharmony_ci	target_compile_definitions(websockets_shared PRIVATE LWS_BUILDING_SHARED)
207d4afb5ceSopenharmony_ci	target_include_directories(websockets_shared PUBLIC ${LWS_PUBLIC_INCLUDES})
208d4afb5ceSopenharmony_ci	set(LWS_PUBLIC_INCLUDES ${LWS_PUBLIC_INCLUDES} PARENT_SCOPE)
209d4afb5ceSopenharmony_ci
210d4afb5ceSopenharmony_ci	# We want the shared lib to be named "libwebsockets"
211d4afb5ceSopenharmony_ci	# not "libwebsocket_shared".
212d4afb5ceSopenharmony_ci	set_target_properties(websockets_shared
213d4afb5ceSopenharmony_ci		PROPERTIES
214d4afb5ceSopenharmony_ci		OUTPUT_NAME websockets)
215d4afb5ceSopenharmony_ci
216d4afb5ceSopenharmony_ci	if (WIN32)
217d4afb5ceSopenharmony_ci		# Compile as DLL (export function declarations)
218d4afb5ceSopenharmony_ci		set_property(
219d4afb5ceSopenharmony_ci			TARGET websockets_shared
220d4afb5ceSopenharmony_ci			PROPERTY COMPILE_DEFINITIONS
221d4afb5ceSopenharmony_ci			LWS_DLL
222d4afb5ceSopenharmony_ci			LWS_INTERNAL)
223d4afb5ceSopenharmony_ci	endif()
224d4afb5ceSopenharmony_ci
225d4afb5ceSopenharmony_ci	if (APPLE)
226d4afb5ceSopenharmony_ci		set_property(TARGET websockets_shared PROPERTY MACOSX_RPATH YES)
227d4afb5ceSopenharmony_ci	endif()
228d4afb5ceSopenharmony_ci
229d4afb5ceSopenharmony_ci	if (UNIX AND LWS_WITH_PLUGINS_API)
230d4afb5ceSopenharmony_ci		set (CMAKE_POSITION_INDEPENDENT_CODE ON)
231d4afb5ceSopenharmony_ci		if (NOT((${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD") OR
232d4afb5ceSopenharmony_ci		   (${CMAKE_SYSTEM_NAME} MATCHES "OpenBSD") OR
233d4afb5ceSopenharmony_ci		   (${CMAKE_SYSTEM_NAME} MATCHES "QNX")))
234d4afb5ceSopenharmony_ci		   if (LWS_WITH_SHARED)
235d4afb5ceSopenharmony_ci				target_link_libraries(websockets_shared dl)
236d4afb5ceSopenharmony_ci			endif()
237d4afb5ceSopenharmony_ci		endif()
238d4afb5ceSopenharmony_ci	endif()
239d4afb5ceSopenharmony_ci
240d4afb5ceSopenharmony_ciendif()
241d4afb5ceSopenharmony_ci
242d4afb5ceSopenharmony_ci#
243d4afb5ceSopenharmony_ci# expose the library private include dirs to plugins, test apps etc that are
244d4afb5ceSopenharmony_ci# part of the lib build but different targets 
245d4afb5ceSopenharmony_ci#
246d4afb5ceSopenharmony_ci
247d4afb5ceSopenharmony_ciif (LWS_WITH_SHARED)
248d4afb5ceSopenharmony_ci	get_target_property(LWS_LIB_INCLUDES websockets_shared INCLUDE_DIRECTORIES)
249d4afb5ceSopenharmony_cielse()
250d4afb5ceSopenharmony_ci	get_target_property(LWS_LIB_INCLUDES websockets INCLUDE_DIRECTORIES)
251d4afb5ceSopenharmony_ciendif()
252d4afb5ceSopenharmony_ci
253d4afb5ceSopenharmony_ci
254d4afb5ceSopenharmony_ci# Set the so version of the lib.
255d4afb5ceSopenharmony_ci# Equivalent to LDFLAGS=-version-info x:x:x
256d4afb5ceSopenharmony_ci
257d4afb5ceSopenharmony_ciif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
258d4afb5ceSopenharmony_ci	foreach(lib ${LWS_LIBRARIES})
259d4afb5ceSopenharmony_ci		set_target_properties(${lib}
260d4afb5ceSopenharmony_ci			PROPERTIES
261d4afb5ceSopenharmony_ci			SOVERSION ${SOVERSION})
262d4afb5ceSopenharmony_ci	endforeach()
263d4afb5ceSopenharmony_ciendif()
264d4afb5ceSopenharmony_ci
265d4afb5ceSopenharmony_ci
266d4afb5ceSopenharmony_ci# Setup the linking for all libs.
267d4afb5ceSopenharmony_ciforeach (lib ${LWS_LIBRARIES})
268d4afb5ceSopenharmony_ci	target_link_libraries(${lib} ${LIB_LIST})
269d4afb5ceSopenharmony_ciendforeach()
270d4afb5ceSopenharmony_ci
271d4afb5ceSopenharmony_ci#
272d4afb5ceSopenharmony_ci# These will be available to parent projects including libwebsockets
273d4afb5ceSopenharmony_ci# using add_subdirectory()
274d4afb5ceSopenharmony_ci#
275d4afb5ceSopenharmony_ciset(LIBWEBSOCKETS_LIBRARIES ${LWS_LIBRARIES} CACHE STRING "Libwebsocket libraries")
276d4afb5ceSopenharmony_ciif (LWS_WITH_STATIC)
277d4afb5ceSopenharmony_ci	set(LIBWEBSOCKETS_LIBRARIES_STATIC websockets CACHE STRING "Libwebsocket static library")
278d4afb5ceSopenharmony_ciendif()
279d4afb5ceSopenharmony_ciif (LWS_WITH_SHARED)
280d4afb5ceSopenharmony_ci	set(LIBWEBSOCKETS_LIBRARIES_SHARED websockets_shared CACHE STRING "Libwebsocket shared library")
281d4afb5ceSopenharmony_ciendif()
282d4afb5ceSopenharmony_ci
283d4afb5ceSopenharmony_ci# Install libs and headers.
284d4afb5ceSopenharmony_ciinstall(TARGETS ${LWS_LIBRARIES}
285d4afb5ceSopenharmony_ci		EXPORT LibwebsocketsTargets
286d4afb5ceSopenharmony_ci		LIBRARY DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT core
287d4afb5ceSopenharmony_ci		ARCHIVE DESTINATION "${LWS_INSTALL_LIB_DIR}${LIB_SUFFIX}" COMPONENT core
288d4afb5ceSopenharmony_ci		RUNTIME DESTINATION "${LWS_INSTALL_BIN_DIR}" COMPONENT core # Windows DLLs
289d4afb5ceSopenharmony_ci		PUBLIC_HEADER DESTINATION "${LWS_INSTALL_INCLUDE_DIR}" COMPONENT dev)
290d4afb5ceSopenharmony_ci		
291d4afb5ceSopenharmony_ci	#set(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries" PARENT_SCOPE)
292d4afb5ceSopenharmony_ciset(CPACK_COMPONENT_DEV_DISPLAY_NAME "Development files" PARENT_SCOPE)
293d4afb5ceSopenharmony_ci
294d4afb5ceSopenharmony_ci
295d4afb5ceSopenharmony_ciif (UNIX OR MINGW)
296d4afb5ceSopenharmony_ci
297d4afb5ceSopenharmony_ci# figure out pkfcfg required libs here
298d4afb5ceSopenharmony_ci
299d4afb5ceSopenharmony_ciset(lws_requires "")
300d4afb5ceSopenharmony_ciif (LWS_HAVE_LIBCAP)
301d4afb5ceSopenharmony_ci	if (NOT lws_requires STREQUAL "")
302d4afb5ceSopenharmony_ci		set(lws_requires "${lws_requires},libcap")
303d4afb5ceSopenharmony_ci	else()
304d4afb5ceSopenharmony_ci		set(lws_requires "libcap")
305d4afb5ceSopenharmony_ci	endif()
306d4afb5ceSopenharmony_ciendif()
307d4afb5ceSopenharmony_ci
308d4afb5ceSopenharmony_ci
309d4afb5ceSopenharmony_ci# Generate and install pkgconfig.
310d4afb5ceSopenharmony_ci# (This is not indented, because the tabs will be part of the output)
311d4afb5ceSopenharmony_cifile(WRITE "${PROJECT_BINARY_DIR}/libwebsockets.pc"
312d4afb5ceSopenharmony_ci"prefix=\"${CMAKE_INSTALL_PREFIX}\"
313d4afb5ceSopenharmony_ciexec_prefix=\${prefix}
314d4afb5ceSopenharmony_cilibdir=\${exec_prefix}/lib${LIB_SUFFIX}
315d4afb5ceSopenharmony_ciincludedir=\${prefix}/include
316d4afb5ceSopenharmony_ci
317d4afb5ceSopenharmony_ciName: libwebsockets
318d4afb5ceSopenharmony_ciDescription: Websockets server and client library
319d4afb5ceSopenharmony_ciVersion: ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
320d4afb5ceSopenharmony_ci
321d4afb5ceSopenharmony_ciLibs: -L\${libdir} -lwebsockets
322d4afb5ceSopenharmony_ciCflags: -I\${includedir}
323d4afb5ceSopenharmony_ci"
324d4afb5ceSopenharmony_ci)
325d4afb5ceSopenharmony_ciif (NOT ${lws_requires} STREQUAL "")
326d4afb5ceSopenharmony_ci        file(APPEND "${PROJECT_BINARY_DIR}/libwebsockets.pc" "Requires: ${lws_requires}")
327d4afb5ceSopenharmony_ciendif()
328d4afb5ceSopenharmony_ci
329d4afb5ceSopenharmony_ci
330d4afb5ceSopenharmony_ci	install(FILES "${PROJECT_BINARY_DIR}/libwebsockets.pc"
331d4afb5ceSopenharmony_ci		DESTINATION lib${LIB_SUFFIX}/pkgconfig)
332d4afb5ceSopenharmony_ci
333d4afb5ceSopenharmony_cifile(WRITE "${PROJECT_BINARY_DIR}/libwebsockets_static.pc"
334d4afb5ceSopenharmony_ci"prefix=\"${CMAKE_INSTALL_PREFIX}\"
335d4afb5ceSopenharmony_ciexec_prefix=\${prefix}
336d4afb5ceSopenharmony_cilibdir=\${exec_prefix}/lib${LIB_SUFFIX}
337d4afb5ceSopenharmony_ciincludedir=\${prefix}/include
338d4afb5ceSopenharmony_ci
339d4afb5ceSopenharmony_ciName: libwebsockets_static
340d4afb5ceSopenharmony_ciDescription: Websockets server and client static library
341d4afb5ceSopenharmony_ciVersion: ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}
342d4afb5ceSopenharmony_ci
343d4afb5ceSopenharmony_ciLibs: -L\${libdir} -l:libwebsockets${CMAKE_STATIC_LIBRARY_SUFFIX}
344d4afb5ceSopenharmony_ciLibs.private:
345d4afb5ceSopenharmony_ciCflags: -I\${includedir}
346d4afb5ceSopenharmony_ci"
347d4afb5ceSopenharmony_ci)
348d4afb5ceSopenharmony_ci
349d4afb5ceSopenharmony_ciif (NOT ${lws_requires} STREQUAL "")
350d4afb5ceSopenharmony_ci        file(APPEND "${PROJECT_BINARY_DIR}/libwebsockets_static.pc" "Requires: ${lws_requires}")
351d4afb5ceSopenharmony_ciendif()
352d4afb5ceSopenharmony_ci
353d4afb5ceSopenharmony_ci
354d4afb5ceSopenharmony_ci	install(FILES "${PROJECT_BINARY_DIR}/libwebsockets_static.pc"
355d4afb5ceSopenharmony_ci		DESTINATION lib${LIB_SUFFIX}/pkgconfig)
356d4afb5ceSopenharmony_ci
357d4afb5ceSopenharmony_ciendif(UNIX OR MINGW)
358d4afb5ceSopenharmony_ci
359d4afb5ceSopenharmony_ci
360d4afb5ceSopenharmony_ci# Keep explicit parent scope exports at end
361d4afb5ceSopenharmony_ci#
362d4afb5ceSopenharmony_ci
363d4afb5ceSopenharmony_ciexport_to_parent_intermediate()
364d4afb5ceSopenharmony_ciif (DEFINED LWS_PLAT_UNIX)
365d4afb5ceSopenharmony_ci	set(LWS_PLAT_UNIX ${LWS_PLAT_UNIX} PARENT_SCOPE)
366d4afb5ceSopenharmony_ci	if (ILLUMOS)
367d4afb5ceSopenharmony_ci		add_definitions("-D__illumos__")
368d4afb5ceSopenharmony_ci	endif()
369d4afb5ceSopenharmony_ciendif()
370d4afb5ceSopenharmony_ciset(LWS_HAVE_MBEDTLS_NET_SOCKETS ${LWS_HAVE_MBEDTLS_NET_SOCKETS} PARENT_SCOPE)
371d4afb5ceSopenharmony_ciset(LWS_HAVE_MBEDTLS_SSL_NEW_SESSION_TICKET ${LWS_HAVE_MBEDTLS_SSL_NEW_SESSION_TICKET} PARENT_SCOPE)
372d4afb5ceSopenharmony_ciset(LWS_HAVE_mbedtls_ssl_conf_alpn_protocols ${LWS_HAVE_mbedtls_ssl_conf_alpn_protocols} PARENT_SCOPE)
373d4afb5ceSopenharmony_ciset(TEST_SERVER_SSL_KEY "${TEST_SERVER_SSL_KEY}" PARENT_SCOPE)
374d4afb5ceSopenharmony_ciset(TEST_SERVER_SSL_CERT "${TEST_SERVER_SSL_CERT}" PARENT_SCOPE)
375d4afb5ceSopenharmony_ciset(TEST_SERVER_DATA ${TEST_SERVER_DATA} PARENT_SCOPE)
376d4afb5ceSopenharmony_ciset(LWS_HAVE_PIPE2 ${LWS_HAVE_PIPE2} PARENT_SCOPE)
377d4afb5ceSopenharmony_ciset(LWS_LIBRARIES ${LWS_LIBRARIES} PARENT_SCOPE)
378d4afb5ceSopenharmony_ciif (DEFINED WIN32_HELPERS_PATH)
379d4afb5ceSopenharmony_ci	set(WIN32_HELPERS_PATH ${WIN32_HELPERS_PATH} PARENT_SCOPE)
380d4afb5ceSopenharmony_ciendif()
381d4afb5ceSopenharmony_ciif (DEFINED HDR_PRIVATE)
382d4afb5ceSopenharmony_ciset(HDR_PRIVATE ${HDR_PRIVATE} PARENT_SCOPE)
383d4afb5ceSopenharmony_ciendif()
384d4afb5ceSopenharmony_ciif (DEFINED ZLIB_FOUND)
385d4afb5ceSopenharmony_ci	set(ZLIB_FOUND ${ZLIB_FOUND} PARENT_SCOPE)
386d4afb5ceSopenharmony_ciendif()
387d4afb5ceSopenharmony_ciif (DEFINED LIB_LIST_AT_END)
388d4afb5ceSopenharmony_ciset(LIB_LIST_AT_END ${LIB_LIST_AT_END} PARENT_SCOPE)
389d4afb5ceSopenharmony_ciendif()
390d4afb5ceSopenharmony_ciset(USE_WOLFSSL ${USE_WOLFSSL} PARENT_SCOPE)
391d4afb5ceSopenharmony_ciset(LWS_DEPS_LIB_PATHS ${LWS_DEPS_LIB_PATHS} PARENT_SCOPE)
392d4afb5ceSopenharmony_ci
393