webui/CMakeLists.txt

59 lines
1.5 KiB
CMake
Raw Normal View History

cmake_minimum_required(VERSION 3.10)
# Project name
project(WebUILibrary)
# Set C++ standard
set(CMAKE_CXX_STANDARD 11)
# Variables for library names, source files, etc.
set(WEBUI_OUT_LIB_NAME "webui-2")
# Conditional compilation for TLS
option(WEBUI_USE_TLS "Enable TLS support" OFF)
if(WEBUI_USE_TLS)
2025-01-06 13:23:56 +08:00
find_package(OpenSSL REQUIRED)
set(WEBUI_OUT_LIB_NAME "webui-2-secure")
endif()
# Source files (already filled)
set(SOURCE_FILES
2025-01-06 13:23:56 +08:00
src/civetweb/civetweb.c
src/webui.c
)
2025-01-06 13:23:56 +08:00
# Library targets
add_library(webui ${SOURCE_FILES})
target_include_directories(webui PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<INSTALL_INTERFACE:include>)
target_compile_definitions(webui PUBLIC NDEBUG NO_CACHING NO_CGI USE_WEBSOCKET)
2025-01-06 13:23:56 +08:00
if(BUILD_SHARED_LIBS AND WIN32)
target_compile_definitions(webui PRIVATE CIVETWEB_DLL_EXPORTS PUBLIC CIVETWEB_DLL_IMPORTS)
endif()
if(WEBUI_USE_TLS)
2025-01-06 13:25:59 +08:00
target_compile_definitions(webui PUBLIC WEBUI_TLS NO_SSL_DL OPENSSL_API_1_1)
2025-01-06 13:23:56 +08:00
target_link_libraries(webui PRIVATE OpenSSL::SSL OpenSSL::Crypto)
else()
target_compile_definitions(webui PUBLIC NO_SSL)
endif()
set_target_properties(webui PROPERTIES
OUTPUT_NAME ${WEBUI_OUT_LIB_NAME}
2025-01-06 13:23:56 +08:00
PREFIX "")
# Install headers
install(FILES include/webui.h include/webui.hpp DESTINATION include)
# Install targets
2025-01-06 13:23:56 +08:00
install(TARGETS webui
EXPORT webui
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
2025-01-06 13:23:56 +08:00
install(EXPORT webui
FILE webui-config.cmake
NAMESPACE webui::
DESTINATION share/webui
)