mirror of
https://github.com/webui-dev/webui.git
synced 2024-10-03 17:39:51 +03:00
Add CMake build system
New CMakeLists.txt to let users build the libraries using CMake Build CivetWeb and then use it to build WebUI
This commit is contained in:
parent
2a5f0c98fb
commit
328705360a
77
CMakeLists.txt
Normal file
77
CMakeLists.txt
Normal file
@ -0,0 +1,77 @@
|
||||
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")
|
||||
|
||||
# Platform and compiler specific settings
|
||||
if(WIN32)
|
||||
|
||||
# Windows specific compiler flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DNO_SSL")
|
||||
|
||||
# Add Windows specific source files or flags here
|
||||
# Example: set(SOURCE_FILES ${SOURCE_FILES} additional_windows_sources.c)
|
||||
|
||||
elseif(UNIX)
|
||||
# Linux specific settings
|
||||
|
||||
# Linux specific compiler flags
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DNO_SSL -w")
|
||||
|
||||
# Add Linux specific source files or flags here
|
||||
# Example: set(SOURCE_FILES ${SOURCE_FILES} additional_linux_sources.c)
|
||||
endif()
|
||||
|
||||
# Conditional compilation for TLS
|
||||
option(WEBUI_USE_TLS "Enable TLS support" OFF)
|
||||
if(WEBUI_USE_TLS)
|
||||
# Add definitions and libraries for TLS
|
||||
add_definitions(-DWEBUI_TLS)
|
||||
|
||||
if(WIN32)
|
||||
# Windows TLS settings
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /DWEBUI_TLS /DNO_SSL_DL /DOPENSSL_API_1_1")
|
||||
# Specify the TLS library for Windows, if needed
|
||||
# Example: target_link_libraries(webui_static PRIVATE ssl crypto)
|
||||
else()
|
||||
# Linux TLS settings
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DWEBUI_TLS -DNO_SSL_DL -DOPENSSL_API_1_1")
|
||||
# Specify the TLS library for Linux, if needed
|
||||
# Example: target_link_libraries(webui_static PRIVATE ssl crypto)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Include directories
|
||||
include_directories(include bridge)
|
||||
add_subdirectory(src/civetweb)
|
||||
|
||||
# Source files (already filled)
|
||||
set(SOURCE_FILES
|
||||
src/webui.c
|
||||
bridge/webui_bridge.h
|
||||
)
|
||||
|
||||
# Library targets (static and dynamic)
|
||||
add_library(webui_static STATIC ${SOURCE_FILES})
|
||||
set_target_properties(webui_static PROPERTIES
|
||||
OUTPUT_NAME ${WEBUI_OUT_LIB_NAME}-static
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/dist")
|
||||
target_link_libraries(webui_static PRIVATE civetweb)
|
||||
|
||||
add_library(webui_dynamic SHARED ${SOURCE_FILES})
|
||||
set_target_properties(webui_dynamic PROPERTIES
|
||||
OUTPUT_NAME ${WEBUI_OUT_LIB_NAME}
|
||||
PREFIX ""
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/dist")
|
||||
target_link_libraries(webui_dynamic PRIVATE civetweb)
|
||||
|
||||
# Install targets
|
||||
install(TARGETS webui_static webui_dynamic
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib)
|
29
src/civetweb/CMakeLists.txt
Normal file
29
src/civetweb/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
project(civetweb)
|
||||
|
||||
# Source files
|
||||
set(SOURCE_FILES
|
||||
civetweb.c
|
||||
civetweb.h
|
||||
handle_form.inl
|
||||
match.inl
|
||||
md5.inl
|
||||
response.inl
|
||||
sha1.inl
|
||||
sort.inl
|
||||
)
|
||||
|
||||
# The C API library
|
||||
add_library(civetweb ${SOURCE_FILES})
|
||||
|
||||
# Include directories
|
||||
target_include_directories(civetweb PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
# Link libraries
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(civetweb Threads::Threads)
|
||||
|
||||
# If on Windows, link with WinSock
|
||||
if(WIN32)
|
||||
target_link_libraries(civetweb ws2_32)
|
||||
endif()
|
Loading…
Reference in New Issue
Block a user