Try to find libwebsockets on the host system

This commit is contained in:
heinrich5991 2018-02-14 12:55:04 +01:00
parent e9bc42a63c
commit 38b96791f6
2 changed files with 48 additions and 37 deletions

View file

@ -282,6 +282,13 @@ find_package(PythonInterp)
find_package(SDL2)
find_package(Threads)
find_package(Wavpack)
if(WEBSOCKETS)
find_package(Websockets)
else()
set(WEBSOCKETS_LIBRARIES)
set(WEBSOCKETS_INCLUDE_DIRS)
endif()
if(TARGET_OS AND TARGET_OS STREQUAL "mac")
find_program(DMG dmg)
@ -338,6 +345,9 @@ show_dependency_status("PythonInterp" PYTHONINTERP)
show_dependency_status("SDL2" SDL2)
show_dependency_status("Wavpack" WAVPACK)
show_dependency_status("Zlib" ZLIB)
if(WEBSOCKETS)
show_dependency_status("Websockets" WEBSOCKETS)
endif()
if(NOT(PYTHONINTERP_FOUND))
message(SEND_ERROR "You must install Python to compile DDNet")
@ -347,6 +357,10 @@ if(MYSQL AND NOT(MYSQL_FOUND))
message(SEND_ERROR "You must install MySQL to compile the DDNet server with MySQL support")
endif()
if(WEBSOCKETS AND NOT(WEBSOCKETS_FOUND))
message(SEND_ERROR "You must install libwebsockets to compile the DDNet server with websocket support")
endif()
if(CLIENT AND NOT(CURL_FOUND))
message(SEND_ERROR "You must install Curl to compile the DDNet client")
endif()
@ -664,45 +678,10 @@ add_library(md5 EXCLUDE_FROM_ALL OBJECT ${DEP_MD5_SRC})
set(DEP_MD5 $<TARGET_OBJECTS:md5>)
list(APPEND TARGETS_DEP md5)
if(WEBSOCKETS)
set_glob(DEP_WEBSOCKETS_SRC GLOB src/engine/external/libwebsockets
alloc.c
base64-decode.c
config.h
context.c
extension-deflate-frame.c
extension-deflate-frame.h
extension-deflate-stream.c
extension-deflate-stream.h
extension.c
getifaddrs.h
handshake.c
huftable.h
lextable-strings.h
lextable.h
libwebsockets.c
libwebsockets.h
lws-plat-unix.c
output.c
parsers.c
pollfd.c
private-libwebsockets.h
server-handshake.c
server.c
service.c
sha-1.c
)
add_library(websockets EXCLUDE_FROM_ALL OBJECT ${DEP_WEBSOCKETS_SRC})
list(APPEND TARGETS_DEP websockets)
set(DEP_WEBSOCKETS $<TARGET_OBJECTS:websockets>)
else()
set(DEP_WEBSOCKETS)
endif()
set(DEPS ${DEP_MD5} ${DEP_WEBSOCKETS} ${ZLIB_DEP})
set(DEPS ${DEP_MD5} ${ZLIB_DEP})
# Libraries
set(LIBS ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES} ${PLATFORM_LIBS})
set(LIBS ${CMAKE_THREAD_LIBS_INIT} ${WEBSOCKETS_LIBRARIES} ${ZLIB_LIBRARIES} ${PLATFORM_LIBS})
# Targets
add_library(engine-shared EXCLUDE_FROM_ALL OBJECT ${ENGINE_INTERFACE} ${ENGINE_SHARED} ${ENGINE_GENERATED_SHARED} ${BASE})
@ -1511,6 +1490,7 @@ foreach(target ${TARGETS_OWN})
target_compile_definitions(${target} PRIVATE GLEW_STATIC)
if(WEBSOCKETS)
target_compile_definitions(${target} PRIVATE CONF_WEBSOCKETS)
target_include_directories(${target} PRIVATE ${WEBSOCKETS_INCLUDE_DIRS})
endif()
if(MYSQL)
target_compile_definitions(${target} PRIVATE CONF_SQL)

View file

@ -0,0 +1,31 @@
if(NOT CMAKE_CROSSCOMPILING)
find_package(PkgConfig QUIET)
pkg_check_modules(PC_WEBSOCKETS libwebsockets)
endif()
set_extra_dirs_lib(WEBSOCKETS websockets)
find_library(WEBSOCKETS_LIBRARY
NAMES websockets
HINTS ${HINTS_WEBSOCKETS_LIBDIR} ${PC_WEBSOCKETS_LIBDIR} ${PC_WEBSOCKETS_LIBRARY_DIRS}
PATHS ${PATHS_WEBSOCKETS_LIBDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
set_extra_dirs_include(WEBSOCKETS websockets "${WEBSOCKETS_LIBRARY}")
find_path(WEBSOCKETS_INCLUDEDIR
NAMES libwebsockets.h
HINTS ${HINTS_WEBSOCKETS_INCLUDEDIR} ${PC_WEBSOCKETS_INCLUDEDIR} ${PC_WEBSOCKETS_INCLUDE_DIRS}
PATHS ${PATHS_WEBSOCKETS_INCLUDEDIR}
${CROSSCOMPILING_NO_CMAKE_SYSTEM_PATH}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Websockets DEFAULT_MSG WEBSOCKETS_LIBRARY WEBSOCKETS_INCLUDEDIR)
mark_as_advanced(WEBSOCKETS_LIBRARY WEBSOCKETS_INCLUDEDIR)
if(WEBSOCKETS_FOUND)
set(WEBSOCKETS_LIBRARIES ${WEBSOCKETS_LIBRARY})
set(WEBSOCKETS_INCLUDE_DIRS ${WEBSOCKETS_INCLUDEDIR})
is_bundled(WEBSOCKETS_BUNDLED "${WEBSOCKETS_LIBRARY}")
endif()