1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

cmake: disable export visibility when building lws static

This is complicated by the fact extern on a function declaration implies
visibility... we have to make LWS_EXTERN empty when building static.

And, setting target_compile_definitions() doesn't work inside macros,
so it has to be set explicitly for the plugins.

Checking the symbol status needs nm -C -D as per

https://stackoverflow.com/questions/37934388/symbol-visibility-not-working-as-expected

after this patch, libwebsockets.a shows no symbols when checked like that and
the static-linked minimal examples only show -U for their other dynamic
imports.

In a handful of cases we use LWS_EXTERN on extern data declarations,
those then need to change to explicit extern.
This commit is contained in:
Andy Green 2020-09-06 11:46:25 +01:00
parent 3be4725388
commit 5c7b5af92a
20 changed files with 166 additions and 129 deletions

View file

@ -93,7 +93,7 @@ typedef unsigned long long lws_intptr_t;
#define LWS_WARN_DEPRECATED
#define LWS_FORMAT(string_index)
#if !defined(LWS_EXTERN)
#if !defined(LWS_EXTERN) && defined(LWS_BUILDING_SHARED)
#ifdef LWS_DLL
#ifdef LWS_INTERNAL
#define LWS_EXTERN extern __declspec(dllexport)
@ -103,6 +103,11 @@ typedef unsigned long long lws_intptr_t;
#endif
#endif
#if !defined(LWS_INTERNAL) && !defined(LWS_EXTERN)
#define LWS_EXTERN
#define LWS_VISIBLE
#endif
#define LWS_INVALID_FILE INVALID_HANDLE_VALUE
#define LWS_SOCK_INVALID (INVALID_SOCKET)
#define LWS_O_RDONLY _O_RDONLY
@ -150,7 +155,6 @@ typedef unsigned long long lws_intptr_t;
#if defined(__FreeBSD__)
#include <sys/signal.h>
#endif
#if defined(__GNUC__)
/* warn_unused_result attribute only supported by GCC 3.4 or later */
@ -160,25 +164,44 @@ typedef unsigned long long lws_intptr_t;
#define LWS_WARN_UNUSED_RESULT
#endif
#if defined(LWS_BUILDING_SHARED)
/* this is only set when we're building lws itself shared */
#define LWS_VISIBLE __attribute__((visibility("default")))
#define LWS_EXTERN extern
#else /* not shared */
#if defined(WIN32) || defined(_WIN32) || defined(__MINGW32__)
#define LWS_VISIBLE
#define LWS_EXTERN extern
#else
/*
* If we explicitly say hidden here, symbols exist as T but
* cannot be imported at link-time.
*/
#define LWS_VISIBLE
#define LWS_EXTERN
#endif
#endif /* not shared */
#define LWS_WARN_DEPRECATED __attribute__ ((deprecated))
#define LWS_FORMAT(string_index) __attribute__ ((format(printf, string_index, string_index+1)))
#else
#else /* not GNUC */
#define LWS_VISIBLE
#define LWS_WARN_UNUSED_RESULT
#define LWS_WARN_DEPRECATED
#define LWS_FORMAT(string_index)
#if !defined(LWS_EXTERN)
#define LWS_EXTERN extern
#endif
#endif
#if defined(__ANDROID__)
#include <netinet/in.h>
#include <unistd.h>
#endif
#endif
#ifndef LWS_EXTERN
#define LWS_EXTERN extern
#endif
#ifdef _WIN32

View file

@ -157,7 +157,7 @@ lws_sspc_proxy_create(struct lws_context *context);
LWS_VISIBLE LWS_EXTERN struct lws_context *
lws_sspc_get_context(struct lws_sspc_handle *h);
LWS_VISIBLE LWS_EXTERN const struct lws_protocols lws_sspc_protocols[];
LWS_VISIBLE extern const struct lws_protocols lws_sspc_protocols[2];
LWS_VISIBLE LWS_EXTERN const char *
lws_sspc_rideshare(struct lws_sspc_handle *h);

View file

@ -154,6 +154,7 @@ if (LWS_WITH_STATIC)
set_target_properties(websockets PROPERTIES LINKER_LANGUAGE C)
list(APPEND LWS_LIBRARIES websockets)
target_include_directories(websockets PRIVATE ${LWS_LIB_BUILD_INC_PATHS})
target_compile_definitions(websockets PRIVATE LWS_BUILDING_STATIC)
if (WIN32)
# Windows uses the same .lib ending for static libraries and shared
@ -174,6 +175,7 @@ if (LWS_WITH_SHARED)
set_target_properties(websockets_shared PROPERTIES LINKER_LANGUAGE C)
list(APPEND LWS_LIBRARIES websockets_shared)
target_include_directories(websockets_shared PRIVATE ${LWS_LIB_BUILD_INC_PATHS})
target_compile_definitions(websockets_shared PRIVATE LWS_BUILDING_SHARED)
# We want the shared lib to be named "libwebsockets"
# not "libwebsocket_shared".

View file

@ -22,7 +22,6 @@
* IN THE SOFTWARE.
*/
#include <libwebsockets.h>
#include "private-lib-core.h"
struct lws *

View file

@ -1086,11 +1086,11 @@ lws_change_pollfd(struct lws *wsi, int _and, int _or);
#if defined(LWS_WITH_SERVER)
int _lws_vhost_init_server(const struct lws_context_creation_info *info,
struct lws_vhost *vhost);
LWS_EXTERN struct lws_vhost *
struct lws_vhost *
lws_select_vhost(struct lws_context *context, int port, const char *servername);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_parse_ws(struct lws *wsi, unsigned char **buf, size_t len);
LWS_EXTERN void
void
lws_server_get_canonical_hostname(struct lws_context *context,
const struct lws_context_creation_info *info);
#else

View file

@ -570,7 +570,7 @@ lws_vhost_destroy1(struct lws_vhost *vh);
#if defined(LWS_PLAT_FREERTOS)
LWS_EXTERN int
int
lws_find_string_in_file(const char *filename, const char *str, int stringlen);
#endif
@ -587,22 +587,22 @@ struct lws_buflist {
size_t pos;
};
LWS_EXTERN char *
char *
lws_strdup(const char *s);
LWS_EXTERN int log_level;
extern int log_level;
LWS_EXTERN int
int
lws_b64_selftest(void);
#ifndef LWS_NO_DAEMONIZE
LWS_EXTERN pid_t get_daemonize_pid();
pid_t get_daemonize_pid();
#else
#define get_daemonize_pid() (0)
#endif
LWS_EXTERN void lwsl_emit_stderr(int level, const char *line);
void lwsl_emit_stderr(int level, const char *line);
#if !defined(LWS_WITH_TLS)
#define LWS_SSL_ENABLED(context) (0)
@ -657,13 +657,13 @@ lws_vhost_unlock(struct lws_vhost *vhost)
#define lws_pt_stats_unlock(_a) (void)(_a)
#endif
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_read_no_ssl(struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_write_no_ssl(struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_ssl_pending_no_ssl(struct lws *wsi);
int
@ -688,10 +688,10 @@ lws_find_mount(struct lws *wsi, const char *uri_ptr, int uri_len);
/*
* custom allocator
*/
LWS_EXTERN void *
void *
lws_realloc(void *ptr, size_t size, const char *reason);
LWS_EXTERN void * LWS_WARN_UNUSED_RESULT
void * LWS_WARN_UNUSED_RESULT
lws_zalloc(size_t size, const char *reason);
#ifdef LWS_PLAT_OPTEE
@ -716,17 +716,17 @@ lws_vfs_select_fops(const struct lws_plat_file_ops *fops, const char *vfs_path,
/* lws_plat_ */
LWS_EXTERN int
int
lws_plat_context_early_init(void);
LWS_EXTERN void
void
lws_plat_context_early_destroy(struct lws_context *context);
LWS_EXTERN void
void
lws_plat_context_late_destroy(struct lws_context *context);
LWS_EXTERN int
int
lws_plat_init(struct lws_context *context,
const struct lws_context_creation_info *info);
LWS_EXTERN int
int
lws_plat_drop_app_privileges(struct lws_context *context, int actually_drop);
#if defined(LWS_WITH_UNIX_SOCK) && !defined(WIN32)
@ -740,11 +740,11 @@ lws_plat_ntpclient_config(struct lws_context *context);
int
lws_plat_ifname_to_hwaddr(int fd, const char *ifname, uint8_t *hwaddr, int len);
LWS_EXTERN int
int
lws_check_byte_utf8(unsigned char state, unsigned char c);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_check_utf8(unsigned char *state, unsigned char *buf, size_t len);
LWS_EXTERN int alloc_file(struct lws_context *context, const char *filename,
int alloc_file(struct lws_context *context, const char *filename,
uint8_t **buf, lws_filepos_t *amount);
void lws_msleep(unsigned int);

View file

@ -42,6 +42,7 @@ macro(create_evlib_plugin PLUGIN_NAME MAIN_SRC PLUGIN_HDR EVLIB)
target_link_libraries(websockets-${PLUGIN_NAME} websockets_shared ${EVLIB})
add_dependencies(websockets-${PLUGIN_NAME} websockets_shared)
target_compile_definitions(websockets-${PLUGIN_NAME} PRIVATE LWS_BUILDING_SHARED)
target_include_directories(websockets-${PLUGIN_NAME} PRIVATE
${PLUGIN_INCLUDE} ${LWS_LIB_BUILD_INC_PATHS})

View file

@ -36,11 +36,10 @@
* of libwebsockets
*/
#include <libwebsockets.h>
#include "private-lib-core.h"
#include <stdio.h>
#include <string.h>
#include "private-lib-core.h"
static const char encode_orig[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz0123456789+/";

View file

@ -29,7 +29,6 @@
#define _DARWIN_C_SOURCE
#endif
#include <libwebsockets.h>
#include "private-lib-core.h"
#include <string.h>
#include <stdio.h>

View file

@ -22,7 +22,6 @@
* IN THE SOFTWARE.
*/
#include <libwebsockets.h>
#include "private-lib-core.h"
#include <string.h>
#include <stdio.h>

View file

@ -22,7 +22,6 @@
* IN THE SOFTWARE.
*/
#include <libwebsockets.h>
#include "private-lib-core.h"
struct lws_ring *

View file

@ -32,7 +32,6 @@
* implemented by Jun-ichiro itojun Itoh <itojun@itojun.org>
*/
#include <libwebsockets.h>
#include "private-lib-core.h"
#ifdef LWS_HAVE_SYS_TYPES_H

View file

@ -322,58 +322,58 @@ struct _lws_h2_related {
int
lws_h2_rst_stream(struct lws *wsi, uint32_t err, const char *reason);
struct lws * lws_h2_get_nth_child(struct lws *wsi, int n);
LWS_EXTERN void lws_h2_init(struct lws *wsi);
LWS_EXTERN int
void lws_h2_init(struct lws *wsi);
int
lws_h2_settings(struct lws *nwsi, struct http2_settings *settings,
unsigned char *buf, int len);
LWS_EXTERN int
int
lws_h2_parser(struct lws *wsi, unsigned char *in, lws_filepos_t inlen,
lws_filepos_t *inused);
LWS_EXTERN int
int
lws_h2_do_pps_send(struct lws *wsi);
LWS_EXTERN int
int
lws_h2_frame_write(struct lws *wsi, int type, int flags, unsigned int sid,
unsigned int len, unsigned char *buf);
LWS_EXTERN struct lws *
struct lws *
lws_wsi_mux_from_id(struct lws *wsi, unsigned int sid);
LWS_EXTERN int
int
lws_hpack_interpret(struct lws *wsi, unsigned char c);
LWS_EXTERN int
int
lws_add_http2_header_by_name(struct lws *wsi,
const unsigned char *name,
const unsigned char *value, int length,
unsigned char **p, unsigned char *end);
LWS_EXTERN int
int
lws_add_http2_header_by_token(struct lws *wsi,
enum lws_token_indexes token,
const unsigned char *value, int length,
unsigned char **p, unsigned char *end);
LWS_EXTERN int
int
lws_add_http2_header_status(struct lws *wsi,
unsigned int code, unsigned char **p,
unsigned char *end);
LWS_EXTERN void
void
lws_hpack_destroy_dynamic_header(struct lws *wsi);
LWS_EXTERN int
int
lws_hpack_dynamic_size(struct lws *wsi, int size);
LWS_EXTERN int
int
lws_h2_goaway(struct lws *wsi, uint32_t err, const char *reason);
LWS_EXTERN int
int
lws_h2_tx_cr_get(struct lws *wsi);
LWS_EXTERN void
void
lws_h2_tx_cr_consume(struct lws *wsi, int consumed);
LWS_EXTERN int
int
lws_hdr_extant(struct lws *wsi, enum lws_token_indexes h);
LWS_EXTERN void
void
lws_pps_schedule(struct lws *wsi, struct lws_h2_protocol_send *pss);
LWS_EXTERN const struct http2_settings lws_h2_defaults;
LWS_EXTERN int
extern const struct http2_settings lws_h2_defaults;
int
lws_h2_ws_handshake(struct lws *wsi);
LWS_EXTERN int lws_h2_issue_preface(struct lws *wsi);
LWS_EXTERN int
int lws_h2_issue_preface(struct lws *wsi);
int
lws_h2_client_handshake(struct lws *wsi);
LWS_EXTERN struct lws *
struct lws *
lws_wsi_h2_adopt(struct lws *parent_wsi, struct lws *wsi);
int
lws_handle_POLLOUT_event_h2(struct lws *wsi);

View file

@ -24,7 +24,7 @@
* lws_genhash provides a hash / hmac abstraction api in lws that works the
* same whether you are using openssl or mbedtls hash functions underneath.
*/
#include "libwebsockets.h"
#include <private-lib-core.h>
#include <openssl/obj_mac.h>
/*
* Care: many openssl apis return 1 for success. These are translated to the

View file

@ -134,9 +134,9 @@ typedef X509 lws_tls_x509;
#include "private-network.h"
#endif
LWS_EXTERN int
int
lws_context_init_ssl_library(const struct lws_context_creation_info *info);
LWS_EXTERN void
void
lws_context_deinit_ssl_library(struct lws_context *context);
#define LWS_SSL_ENABLED(vh) (vh && vh->tls.use_ssl)
@ -147,25 +147,24 @@ struct lws_ec_valid_curves {
const char *jwa_name; /* list terminates with NULL jwa_name */
};
LWS_EXTERN enum lws_tls_extant
enum lws_tls_extant
lws_tls_use_any_upgrade_check_extant(const char *name);
LWS_EXTERN int openssl_websocket_private_data_index;
extern int openssl_websocket_private_data_index;
LWS_EXTERN void
void
lws_tls_err_describe_clear(void);
LWS_EXTERN int
int
lws_tls_openssl_cert_info(X509 *x509, enum lws_tls_cert_info type,
union lws_tls_cert_info_results *buf, size_t len);
LWS_EXTERN int
int
lws_tls_check_all_cert_lifetimes(struct lws_context *context);
LWS_EXTERN int
int
lws_tls_alloc_pem_to_der_file(struct lws_context *context, const char *filename,
const char *inbuf, lws_filepos_t inlen,
uint8_t **buf, lws_filepos_t *amount);
LWS_EXTERN char *
char *
lws_ssl_get_error_string(int status, int ret, char *buf, size_t len);
int
@ -179,7 +178,7 @@ lws_gencrypto_destroy_elements(struct lws_gencrypto_keyelem *el, int m);
struct lws_gencrypto_keyelem;
struct lws_ec_curves;
LWS_EXTERN const struct lws_ec_curves lws_ec_curves[4];
extern const struct lws_ec_curves lws_ec_curves[4];
const struct lws_ec_curves *
lws_genec_curve(const struct lws_ec_curves *table, const char *name);
LWS_VISIBLE void

View file

@ -78,52 +78,52 @@ struct lws_lws_tls {
};
LWS_EXTERN void
void
lws_context_init_alpn(struct lws_vhost *vhost);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_read(struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_ssl_capable_write(struct lws *wsi, unsigned char *buf, int len);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_ssl_pending(struct lws *wsi);
LWS_EXTERN int LWS_WARN_UNUSED_RESULT
int LWS_WARN_UNUSED_RESULT
lws_server_socket_service_ssl(struct lws *new_wsi, lws_sockfd_type accept_fd,
char is_pollin);
LWS_EXTERN int
int
lws_ssl_close(struct lws *wsi);
LWS_EXTERN void
void
lws_ssl_SSL_CTX_destroy(struct lws_vhost *vhost);
LWS_EXTERN void
void
lws_ssl_context_destroy(struct lws_context *context);
void
__lws_ssl_remove_wsi_from_buffered_list(struct lws *wsi);
LWS_VISIBLE void
lws_ssl_remove_wsi_from_buffered_list(struct lws *wsi);
LWS_EXTERN int
int
lws_ssl_client_bio_create(struct lws *wsi);
LWS_EXTERN int
int
lws_ssl_client_connect1(struct lws *wsi, char *errbuf, int len);
LWS_EXTERN int
int
lws_ssl_client_connect2(struct lws *wsi, char *errbuf, int len);
LWS_EXTERN int
int
lws_tls_fake_POLLIN_for_buffered(struct lws_context_per_thread *pt);
LWS_EXTERN int
int
lws_gate_accepts(struct lws_context *context, int on);
LWS_EXTERN void
void
lws_ssl_bind_passphrase(lws_tls_ctx *ssl_ctx, int is_client,
const struct lws_context_creation_info *info);
LWS_EXTERN void
void
lws_ssl_info_callback(const lws_tls_conn *ssl, int where, int ret);
LWS_EXTERN int
int
lws_tls_server_certs_load(struct lws_vhost *vhost, struct lws *wsi,
const char *cert, const char *private_key,
const char *mem_cert, size_t len_mem_cert,
const char *mem_privkey, size_t mem_privkey_len);
LWS_EXTERN enum lws_tls_extant
enum lws_tls_extant
lws_tls_generic_cert_checks(struct lws_vhost *vhost, const char *cert,
const char *private_key);
#if defined(LWS_WITH_SERVER)
LWS_EXTERN int
int
lws_context_init_server_ssl(const struct lws_context_creation_info *info,
struct lws_vhost *vhost);
void
@ -133,35 +133,35 @@ lws_tls_generic_cert_checks(struct lws_vhost *vhost, const char *cert,
#define lws_tls_acme_sni_cert_destroy(_a)
#endif
LWS_EXTERN void
void
lws_ssl_destroy(struct lws_vhost *vhost);
/*
* lws_tls_ abstract backend implementations
*/
LWS_EXTERN int
int
lws_tls_server_client_cert_verify_config(struct lws_vhost *vh);
LWS_EXTERN int
int
lws_tls_server_vhost_backend_init(const struct lws_context_creation_info *info,
struct lws_vhost *vhost, struct lws *wsi);
LWS_EXTERN int
int
lws_tls_server_new_nonblocking(struct lws *wsi, lws_sockfd_type accept_fd);
LWS_EXTERN enum lws_ssl_capable_status
enum lws_ssl_capable_status
lws_tls_server_accept(struct lws *wsi);
LWS_EXTERN enum lws_ssl_capable_status
enum lws_ssl_capable_status
lws_tls_server_abort_connection(struct lws *wsi);
LWS_EXTERN enum lws_ssl_capable_status
enum lws_ssl_capable_status
__lws_tls_shutdown(struct lws *wsi);
LWS_EXTERN enum lws_ssl_capable_status
enum lws_ssl_capable_status
lws_tls_client_connect(struct lws *wsi, char *errbuf, int len);
LWS_EXTERN int
int
lws_tls_client_confirm_peer_cert(struct lws *wsi, char *ebuf, int ebuf_len);
LWS_EXTERN int
int
lws_tls_client_create_vhost_context(struct lws_vhost *vh,
const struct lws_context_creation_info *info,
const char *cipher_list,
@ -176,16 +176,16 @@ lws_tls_client_create_vhost_context(struct lws_vhost *vh,
unsigned int key_mem_len);
LWS_EXTERN lws_tls_ctx *
lws_tls_ctx *
lws_tls_ctx_from_wsi(struct lws *wsi);
LWS_EXTERN int
int
lws_ssl_get_error(struct lws *wsi, int n);
LWS_EXTERN int
int
lws_context_init_client_ssl(const struct lws_context_creation_info *info,
struct lws_vhost *vhost);
LWS_EXTERN void
void
lws_ssl_info_callback(const lws_tls_conn *ssl, int where, int ret);
int

View file

@ -42,25 +42,27 @@ if (LWS_WITH_LWSWS)
source_group("Headers Private" FILES ${LWSWS_HDR})
source_group("Sources" FILES ${LWSWS_SRCS})
add_executable("lwsws" ${LWSWS_SRCS} ${LWSWS_HDR})
add_executable(lwsws ${LWSWS_SRCS} ${LWSWS_HDR})
if (LWS_WITH_SHARED)
target_link_libraries("lwsws" websockets_shared ${LIB_LIST_AT_END})
add_dependencies("lwsws" websockets_shared)
target_link_libraries(lwsws websockets_shared ${LIB_LIST_AT_END})
add_dependencies(lwsws websockets_shared)
else()
target_link_libraries("lwsws" websockets ${LIB_LIST_AT_END})
add_dependencies("lwsws" websockets)
target_link_libraries(lwsws websockets ${LIB_LIST_AT_END})
add_dependencies(lwsws websockets)
endif()
target_include_directories("lwsws" PRIVATE "${LWS_LIB_INCLUDES}" ${LWS_LIB_BUILD_INC_PATHS})
target_include_directories(lwsws PRIVATE "${LWS_LIB_INCLUDES}" ${LWS_LIB_BUILD_INC_PATHS})
# Set test app specific defines.
set_property(TARGET "lwsws"
set_property(TARGET lwsws
PROPERTY COMPILE_DEFINITIONS
INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/share"
)
install(TARGETS lwsws
RUNTIME DESTINATION "${LWS_INSTALL_BIN_DIR}" COMPONENT lwsws )
target_compile_definitions(lwsws PRIVATE LWS_BUILDING_SHARED)
endif (LWS_WITH_LWSWS)

View file

@ -57,6 +57,7 @@ set(CMAKE_C_FLAGS "-fPIC ${CMAKE_C_FLAGS}")
source_group("Headers Private" FILES ${PLUGIN_HDR})
source_group("Sources" FILES ${PLUGIN_SRCS})
add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
target_compile_definitions(${PLUGIN_NAME} PRIVATE LWS_BUILDING_SHARED)
target_link_libraries(${PLUGIN_NAME} -lwebsockets ${LIBWEBSOCKETS_DEP_LIBS})

View file

@ -58,31 +58,19 @@ if (LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
source_group("Headers Private" FILES ${PLUGIN_HDR})
source_group("Sources" FILES ${PLUGIN_SRCS})
add_library(${PLUGIN_NAME} SHARED ${PLUGIN_SRCS} ${PLUGIN_HDR})
foreach(libpath ${LWS_DEP_LIB_PATHS})
target_link_directories(${TEST_NAME} ${libpath})
endforeach()
target_link_libraries(${PLUGIN_NAME} websockets_shared)
add_dependencies(${PLUGIN_NAME} websockets_shared)
target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDE} ${LWS_LIB_BUILD_INC_PATHS})
# Set test app specific defines.
# doesn't work inside macro :-O
# target_compile_definitions(${PLUGIN_NAME} PRIVATE LWS_BUILDING_SHARED)
target_include_directories(${PLUGIN_NAME} PRIVATE ${PLUGIN_INCLUDE}
${LWS_LIB_BUILD_INC_PATHS})
set_property(TARGET ${PLUGIN_NAME}
PROPERTY COMPILE_DEFINITIONS
INSTALL_DATADIR="${CMAKE_INSTALL_PREFIX}/plugins"
)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# SET_TARGET_PROPERTIES(${PLUGIN_NAME}
# PROPERTIES COMPILE_FLAGS ${CMAKE_C_FLAGS})
# set_target_properties(${PLUGIN_NAME}
# PROPERTIES
# OUTPUT_NAME ${PLUGIN_NAME})
list(APPEND PLUGINS_LIST ${PLUGIN_NAME})
endmacro()
@ -90,50 +78,73 @@ if (LWS_WITH_PLUGINS AND LWS_WITH_SHARED)
if (LWS_ROLE_WS)
create_plugin(protocol_dumb_increment ""
"protocol_dumb_increment.c" "" "")
target_compile_definitions(protocol_dumb_increment PRIVATE LWS_BUILDING_SHARED)
create_plugin(protocol_lws_mirror ""
"protocol_lws_mirror.c" "" "")
target_compile_definitions(protocol_lws_mirror PRIVATE LWS_BUILDING_SHARED)
create_plugin(protocol_lws_status ""
"protocol_lws_status.c" "" "")
target_compile_definitions(protocol_lws_status PRIVATE LWS_BUILDING_SHARED)
if (NOT WIN32)
create_plugin(protocol_lws_raw_test ""
"protocol_lws_raw_test.c" "" "")
target_compile_definitions(protocol_lws_raw_test PRIVATE LWS_BUILDING_SHARED)
if (UNIX AND LWS_HAVE_PTHREAD_H)
create_plugin(protocol_deaddrop ""
"deaddrop/protocol_lws_deaddrop.c" "" "")
target_compile_definitions(protocol_deaddrop PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
if (LWS_WITH_SERVER_STATUS)
create_plugin(protocol_lws_server_status ""
"protocol_lws_server_status.c" "" "")
target_compile_definitions(protocol_lws_server_status PRIVATE LWS_BUILDING_SHARED)
endif()
if (NOT LWS_WITHOUT_CLIENT)
create_plugin(protocol_client_loopback_test ""
"protocol_client_loopback_test.c" "" "")
target_compile_definitions(protocol_client_loopback_test PRIVATE LWS_BUILDING_SHARED)
endif()
endif(LWS_ROLE_WS)
create_plugin(protocol_post_demo ""
"protocol_post_demo.c" "" "")
target_compile_definitions(protocol_post_demo PRIVATE LWS_BUILDING_SHARED)
if (LWS_ROLE_RAW_PROXY)
create_plugin(protocol_lws_raw_proxy ""
"raw-proxy/protocol_lws_raw_proxy.c" "" "")
target_compile_definitions(protocol_lws_raw_proxy PRIVATE LWS_BUILDING_SHARED)
endif()
if (LWS_WITH_FTS)
create_plugin(protocol_fulltext_demo ""
"protocol_fulltext_demo.c" "" "")
target_compile_definitions(protocol_fulltext_demo PRIVATE LWS_BUILDING_SHARED)
endif()
if (LWS_WITH_SSL)
create_plugin(protocol_lws_ssh_base "ssh-base/include"
"ssh-base/sshd.c;ssh-base/telnet.c;ssh-base/kex-25519.c" "ssh-base/crypto/chacha.c;ssh-base/crypto/ed25519.c;ssh-base/crypto/fe25519.c;ssh-base/crypto/ge25519.c;ssh-base/crypto/poly1305.c;ssh-base/crypto/sc25519.c;ssh-base/crypto/smult_curve25519_ref.c" "")
target_compile_definitions(protocol_lws_ssh_base PRIVATE LWS_BUILDING_SHARED)
create_plugin(protocol_lws_sshd_demo "ssh-base/include" "protocol_lws_sshd_demo.c" "" "")
target_compile_definitions(protocol_lws_sshd_demo PRIVATE LWS_BUILDING_SHARED)
include_directories("${PROJECT_SOURCE_DIR}/plugins/ssh-base/include")
endif()
@ -143,6 +154,7 @@ endif()
if (LWS_WITH_ACME)
create_plugin(protocol_lws_acme_client ""
"acme-client/protocol_lws_acme_client.c" "" "")
target_compile_definitions(protocol_lws_acme_client PRIVATE LWS_BUILDING_SHARED)
endif()
endif(LWS_WITH_PLUGINS AND LWS_WITH_SHARED)

View file

@ -132,6 +132,7 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2))
""
""
"")
target_compile_definitions(test-server PRIVATE LWS_BUILDING_SHARED)
if (LWS_WITH_CGI AND LWS_WITH_TLS)
create_test_app(test-sshd "test-sshd.c"
@ -141,7 +142,7 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2))
""
"")
target_include_directories(test-sshd PRIVATE "${PROJECT_SOURCE_DIR}/plugins/ssh-base/include")
target_compile_definitions(test-sshd PRIVATE LWS_BUILDING_SHARED)
endif()
endif()
@ -157,6 +158,7 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2))
""
""
"")
target_compile_definitions(test-server-extpoll PRIVATE LWS_BUILDING_SHARED)
# Set defines for this executable only.
set_property(
TARGET test-server-extpoll
@ -180,6 +182,7 @@ if ((LWS_ROLE_H1 OR LWS_ROLE_H2))
""
""
"")
target_compile_definitions(test-lejp PRIVATE LWS_BUILDING_STATIC)
endif()
# Data files for running the test server.