mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-23 21:37:53 +08:00
45 lines
1.4 KiB
CMake
45 lines
1.4 KiB
CMake
|
cmake_minimum_required(VERSION 3.13)
|
||
|
project(uSockets C CXX)
|
||
|
|
||
|
option(INSTALL_HEADERS "Install header files" ON)
|
||
|
|
||
|
# To enable this feature, OpenSSL 1.1+ is required and is currently disabled due to issue 4267
|
||
|
if (CMAKE_USE_OPENSSL)
|
||
|
find_package(OpenSSL REQUIRED)
|
||
|
set(USE_OPENSSL "-DUSE_OPENSSL -DLIBUS_USE_OPENSSL")
|
||
|
#set(OPENSSL_LIB "OpenSSL::SSL OpenSSL::Crypto")
|
||
|
list(APPEND CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||
|
else()
|
||
|
set(NOT_USE_OPENSSL "-DLIBUS_NO_SSL")
|
||
|
endif()
|
||
|
|
||
|
find_package(unofficial-libuv CONFIG REQUIRED)
|
||
|
find_path(LIBUV_INCLUDE_DIR uv.h)
|
||
|
find_library(LIBUV_LIBRARY NAMES libuv)
|
||
|
include_directories(APPEND "${CMAKE_CURRENT_LIST_DIR}/src")
|
||
|
|
||
|
file(GLOB SOURCES src/*.c src/eventing/*.c)
|
||
|
|
||
|
add_library(uSockets ${SOURCES})
|
||
|
|
||
|
if (${LIBUS_USE_LIBUV})
|
||
|
target_compile_definitions(uSockets PRIVATE -DLIBUS_USE_LIBUV)
|
||
|
endif()
|
||
|
|
||
|
target_compile_definitions(uSockets PRIVATE ${NOT_USE_OPENSSL} ${USE_OPENSSL})
|
||
|
target_include_directories(uSockets PUBLIC ${OPENSSL_INCLUDE_DIR} ${LIBUV_INCLUDE_DIR} )
|
||
|
target_link_libraries(uSockets PUBLIC ${OPENSSL_LIBRARIES} ${LIBUV_LIBRARY})
|
||
|
|
||
|
install(TARGETS uSockets
|
||
|
RUNTIME DESTINATION bin
|
||
|
ARCHIVE DESTINATION lib
|
||
|
LIBRARY DESTINATION lib
|
||
|
)
|
||
|
|
||
|
if(INSTALL_HEADERS)
|
||
|
file(GLOB HEADERS src/*.h)
|
||
|
install(FILES ${HEADERS} DESTINATION include)
|
||
|
file(GLOB HEADERS src/interfaces/*.h)
|
||
|
install(FILES ${HEADERS} DESTINATION include/interfaces)
|
||
|
endif()
|