initial commit

This commit is contained in:
2025-08-05 15:53:44 +08:00
commit 09dc02ae52
553 changed files with 137665 additions and 0 deletions

1028
cmake/ios.toolchain.cmake Executable file

File diff suppressed because it is too large Load Diff

87
cmake/libhvConfig.cmake Executable file
View File

@@ -0,0 +1,87 @@
include(SelectLibraryConfigurations)
find_path(libhv_INCLUDE_DIRS hv/hv.h)
message("libhv_INCLUDE_DIRS: " ${libhv_INCLUDE_DIRS})
find_library(libhv_LIBRARY_RELEASE NAMES hv PATHS "${CMAKE_CURRENT_LIST_DIR}/../../lib" NO_DEFAULT_PATH)
find_library(libhv_LIBRARY_DEBUG NAMES hv PATHS "${CMAKE_CURRENT_LIST_DIR}/../../debug/lib" NO_DEFAULT_PATH)
select_library_configurations(libhv)
if(NOT libhv_LIBRARY)
set(libhv_FOUND FALSE)
set(LIBHV_FOUND FALSE)
return()
endif()
if(WIN32)
find_file(libhv_LIBRARY_RELEASE_DLL NAMES hv.dll PATHS "${CMAKE_CURRENT_LIST_DIR}/../../bin" NO_DEFAULT_PATH)
find_file(libhv_LIBRARY_DEBUG_DLL NAMES hv.dll PATHS "${CMAKE_CURRENT_LIST_DIR}/../../debug/bin" NO_DEFAULT_PATH)
endif()
# Manage Release Windows shared
if(EXISTS "${libhv_LIBRARY_RELEASE_DLL}")
add_library(libhv SHARED IMPORTED)
set_target_properties(libhv PROPERTIES
IMPORTED_CONFIGURATIONS Release
IMPORTED_LOCATION_RELEASE "${libhv_LIBRARY_RELEASE_DLL}"
IMPORTED_IMPLIB_RELEASE "${libhv_LIBRARY_RELEASE}"
INTERFACE_INCLUDE_DIRECTORIES "${libhv_INCLUDE_DIRS}"
)
endif()
# Manage Debug Windows shared
if(EXISTS "${libhv_LIBRARY_DEBUG_DLL}")
if(EXISTS "${libhv_LIBRARY_RELEASE_DLL}")
#message("Debug mode")
set_target_properties(libhv PROPERTIES
IMPORTED_CONFIGURATIONS "Release;Debug"
IMPORTED_LOCATION_RELEASE "${libhv_LIBRARY_RELEASE_DLL}"
IMPORTED_IMPLIB_RELEASE "${libhv_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG "${libhv_LIBRARY_DEBUG_DLL}"
IMPORTED_IMPLIB_DEBUG "${libhv_LIBRARY_DEBUG}"
INTERFACE_INCLUDE_DIRECTORIES "${libhv_INCLUDE_DIRS}"
)
else()
add_library(libhv SHARED IMPORTED)
set_target_properties(libhv PROPERTIES
IMPORTED_CONFIGURATIONS Debug
IMPORTED_LOCATION_DEBUG "${libhv_LIBRARY_DEBUG_DLL}"
IMPORTED_IMPLIB_DEBUG "${libhv_LIBRARY_DEBUG}"
INTERFACE_INCLUDE_DIRECTORIES "${libhv_INCLUDE_DIRS}"
)
endif()
endif()
# Manage Release Windows static and Linux shared/static
if((NOT EXISTS "${libhv_LIBRARY_RELEASE_DLL}") AND (EXISTS "${libhv_LIBRARY_RELEASE}"))
add_library(libhv UNKNOWN IMPORTED)
set_target_properties(libhv PROPERTIES
IMPORTED_CONFIGURATIONS Release
IMPORTED_LOCATION_RELEASE "${libhv_LIBRARY_RELEASE}"
INTERFACE_INCLUDE_DIRECTORIES "${libhv_INCLUDE_DIRS}"
)
endif()
# Manage Debug Windows static and Linux shared/static
if((NOT EXISTS "${libhv_LIBRARY_DEBUG_DLL}") AND (EXISTS "${libhv_LIBRARY_DEBUG}"))
if(EXISTS "${libhv_LIBRARY_RELEASE}")
set_target_properties(libhv PROPERTIES
IMPORTED_CONFIGURATIONS "Release;Debug"
IMPORTED_LOCATION_RELEASE "${libhv_LIBRARY_RELEASE}"
IMPORTED_LOCATION_DEBUG "${libhv_LIBRARY_DEBUG}"
INTERFACE_INCLUDE_DIRECTORIES "${libhv_INCLUDE_DIRS}"
)
else()
add_library(libhv UNKNOWN IMPORTED)
set_target_properties(libhv PROPERTIES
IMPORTED_CONFIGURATIONS Debug
IMPORTED_LOCATION_DEBUG "${libhv_LIBRARY_DEBUG}"
INTERFACE_INCLUDE_DIRECTORIES "${libhv_INCLUDE_DIRS}"
)
endif()
endif()
set(libhv_FOUND TRUE)
set(LIBHV_FOUND TRUE)

65
cmake/utils.cmake Executable file
View File

@@ -0,0 +1,65 @@
include(CheckIncludeFiles)
macro(check_header header)
string(TOUPPER ${header} str1)
string(REGEX REPLACE "[/.]" "_" str2 ${str1})
set(str3 HAVE_${str2})
check_include_files(${header} ${str3})
if (${str3})
set(${str3} 1)
else()
set(${str3} 0)
endif()
endmacro()
include(CheckSymbolExists)
macro(check_function function header)
string(TOUPPER ${function} str1)
set(str2 HAVE_${str1})
check_symbol_exists(${function} ${header} ${str2})
if (${str2})
set(${str2} 1)
else()
set(${str2} 0)
endif()
endmacro()
macro(list_source_directories srcs)
unset(tmp)
foreach(dir ${ARGN})
aux_source_directory(${dir} tmp)
endforeach()
set(${srcs} ${tmp})
list(FILTER ${srcs} EXCLUDE REGEX ".*_test\\.c")
endmacro()
macro(glob_headers_and_sources files)
unset(tmp)
foreach(dir ${ARGN})
file(GLOB tmp ${dir}/*.h ${dir}/*.c ${dir}/*.hpp ${dir}/*.cpp)
list(APPEND ${files} ${tmp})
endforeach()
list(FILTER ${files} EXCLUDE REGEX ".*_test\\.c")
endmacro()
macro(aux_target_directory srcs)
#1
unset(tmp)
include_directories(${ARGV1})
file(GLOB tmp ${ARGV1}/*.c)
list(APPEND ${srcs} ${tmp})
#2
if(${ARGC} GREATER 2)
unset(tmp)
include_directories(${ARGV1}/${ARGV2})
file(GLOB tmp ${ARGV1}/${ARGV2}/*.c)
list(APPEND ${srcs} ${tmp})
endif()
#3
if(${ARGC} GREATER 3)
unset(tmp)
include_directories(${ARGV1}/${ARGV2}/${ARGV3})
file(GLOB tmp ${ARGV1}/${ARGV2}/${ARGV3}/*.c)
list(APPEND ${srcs} ${tmp})
endif()
endmacro()

17
cmake/vars.cmake Executable file
View File

@@ -0,0 +1,17 @@
# see Makefile.vars
set(LIBHV_PATH "third_party/libhv")
set(LIBHV_HEADERS
${LIBHV_PATH}
${LIBHV_PATH}/base
${LIBHV_PATH}/ssl
${LIBHV_PATH}/event
${LIBHV_PATH}/util
${LIBHV_PATH}/cpputil
${LIBHV_PATH}/evpp
${LIBHV_PATH}/protocol
${LIBHV_PATH}/http
${LIBHV_PATH}/http/client
${LIBHV_PATH}/http/server
${LIBHV_PATH}/mqtt
)