set(CMAKE_C_STANDARD 99)
endif()
-set(LIBWEBSOCKETS_MIN_VERSION 1.7.0)
set(SOURCE_FILES src/server.c src/http.c src/protocol.c src/terminal.c src/utils.c)
-find_package(OpenSSL REQUIRED)
-find_package(ZLIB REQUIRED)
-find_package(Libwebsockets ${LIBWEBSOCKETS_MIN_VERSION} QUIET)
+include(FindPackageHandleStandardArgs)
-find_package(PkgConfig)
+find_path(LIBUV_INCLUDE_DIR NAMES uv.h)
+find_library(LIBUV_LIBRARY NAMES uv libuv)
+find_package_handle_standard_args(LIBUV REQUIRED_VARS LIBUV_LIBRARY LIBUV_INCLUDE_DIR)
+mark_as_advanced(LIBUV_INCLUDE_DIR LIBUV_LIBRARY)
+if(LIBUV_FOUND)
+ SET(LIBUV_INCLUDE_DIRS "${LIBUV_INCLUDE_DIR}")
+ SET(LIBUV_LIBRARIES "${LIBUV_LIBRARY}")
+endif()
-if(NOT Libwebsockets_FOUND)
- pkg_check_modules(PC_LIBWEBSOCKETS REQUIRED libwebsockets>=${LIBWEBSOCKETS_MIN_VERSION})
- find_path(LIBWEBSOCKETS_INCLUDE_DIRS libwebsockets.h HINTS ${PC_LIBWEBSOCKETS_INCLUDEDIR})
- find_library(LIBWEBSOCKETS_LIBRARIES NAMES websockets libwebsockets HINTS ${PC_LIBWEBSOCKETS_LIBDIR})
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(LIBWEBSOCKETS DEFAULT_MSG LIBWEBSOCKETS_LIBRARIES LIBWEBSOCKETS_INCLUDE_DIRS)
- mark_as_advanced(LIBWEBSOCKETS_INCLUDE_DIRS LIBWEBSOCKETS_LIBRARIES)
+find_path(JSON-C_INCLUDE_DIR NAMES json.h PATH_SUFFIXES json-c)
+find_library(JSON-C_LIBRARY NAMES json-c)
+find_package_handle_standard_args(JSON-C REQUIRED_VARS JSON-C_INCLUDE_DIR JSON-C_LIBRARY)
+mark_as_advanced(JSON-C_INCLUDE_DIR JSON-C_LIBRARY)
+if(JSON-C_FOUND)
+ SET(JSON-C_INCLUDE_DIRS "${JSON-C_INCLUDE_DIR}")
+ SET(JSON-C_LIBRARIES "${JSON-C_LIBRARY}")
endif()
-pkg_check_modules(PC_JSON-C REQUIRED json-c)
-find_path(JSON-C_INCLUDE_DIRS json.h HINTS ${PC_JSON-C_INCLUDEDIR} PATH_SUFFIXES json-c json)
-find_library(JSON-C_LIBRARIES NAMES json-c libjson-c HINTS ${PC_JSON-C_LIBDIR})
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(JSON-C DEFAULT_MSG JSON-C_LIBRARIES JSON-C_INCLUDE_DIRS)
-mark_as_advanced(JSON-C_INCLUDE_DIRS JSON-C_LIBRARIES)
+find_package(OpenSSL REQUIRED)
+find_package(ZLIB REQUIRED)
+find_package(Libwebsockets 1.7.0 QUIET)
-pkg_check_modules(PC_LIBUV REQUIRED libuv>=1.0.0)
-find_path(LIBUV_INCLUDE_DIRS NAMES uv.h HINTS ${PC_LIBUV_INCLUDEDIR})
-find_library(LIBUV_LIBRARIES NAMES uv libuv HINTS ${PC_LIBUV_LIBDIR})
-find_package_handle_standard_args(LIBUV DEFAULT_MSG LIBUV_LIBRARIES LIBUV_INCLUDE_DIRS)
-mark_as_advanced(LIBUV_INCLUDE_DIRS LIBUV_LIBRARIES)
+if(NOT Libwebsockets_FOUND)
+ find_path(LIBWEBSOCKETS_INCLUDE_DIR NAMES libwebsockets.h)
+ find_library(LIBWEBSOCKETS_LIBRARY NAMES websockets)
+ find_package_handle_standard_args(Libwebsockets REQUIRED_VARS LIBWEBSOCKETS_LIBRARY LIBWEBSOCKETS_INCLUDE_DIR)
+ mark_as_advanced(LIBWEBSOCKETS_INCLUDE_DIR LIBWEBSOCKETS_LIBRARY)
+ if(Libwebsockets_FOUND)
+ SET(LIBWEBSOCKETS_INCLUDE_DIRS "${LIBWEBSOCKETS_INCLUDE_DIR}")
+ SET(LIBWEBSOCKETS_LIBRARIES "${LIBWEBSOCKETS_LIBRARY}")
+ endif()
+endif()
set(INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR} ${ZLIB_INCLUDE_DIR} ${LIBWEBSOCKETS_INCLUDE_DIRS} ${JSON-C_INCLUDE_DIRS} ${LIBUV_INCLUDE_DIRS})
set(LINK_LIBS ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARIES} ${LIBWEBSOCKETS_LIBRARIES} ${JSON-C_LIBRARIES} ${LIBUV_LIBRARIES})