92 lines
2.5 KiB
CMake
92 lines
2.5 KiB
CMake
# ------------------------------
|
|
# cmake config / project
|
|
# ------------------------------
|
|
include(FetchContent)
|
|
|
|
cmake_minimum_required(VERSION 4.1.0)
|
|
|
|
project(tinymitm LANGUAGES CXX)
|
|
|
|
# ------------------------------
|
|
# options
|
|
# ------------------------------
|
|
option(TINYMITM_TEST "Add test project" OFF)
|
|
option(TINYMITM_LOGS "Add log sink supoprt" OFF)
|
|
|
|
if (TINYMITM_TEST)
|
|
set(TINYMITM_LOGS ON CACHE BLOOL "" FORCE)
|
|
endif()
|
|
|
|
if (TINYMITM_LOGS)
|
|
add_compile_definitions(TINYMITM_LOGS)
|
|
endif()
|
|
|
|
# ---------------------
|
|
# external dependencies
|
|
# ---------------------
|
|
FetchContent_Declare(
|
|
seallib
|
|
GIT_REPOSITORY https://git.neru.rip/neru/seallib
|
|
GIT_TAG 648ae78ac807125b3c31423daa687fe4c78f73f8
|
|
)
|
|
|
|
FetchContent_Declare(
|
|
wolfssl
|
|
GIT_REPOSITORY https://github.com/wolfSSL/wolfssl
|
|
GIT_TAG eecb8cc601f7b3987917e3ff1fa2212d5927d405
|
|
)
|
|
|
|
# seallib config
|
|
set(SEALLIB_EVENTS ON CACHE BOOL "" FORCE)
|
|
if (TINYMITM_LOGS)
|
|
set(SEALLIB_LOG ON CACHE BOOL "" FORCE)
|
|
endif()
|
|
FetchContent_GetProperties(seallib)
|
|
FetchContent_MakeAvailable(seallib)
|
|
|
|
# wolfssl config
|
|
set(WOLFSSL_ALPN ON CACHE BOOL "" FORCE)
|
|
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
|
|
|
FetchContent_GetProperties(wolfssl)
|
|
FetchContent_MakeAvailable(wolfssl)
|
|
|
|
target_compile_definitions(wolfssl PUBLIC
|
|
-DWOLFSSL_ALT_NAMES
|
|
-DWOLFSSL_ALPN
|
|
)
|
|
|
|
# ---------------------
|
|
# warnings
|
|
# ---------------------
|
|
add_library(tinymitm-warnings INTERFACE)
|
|
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
|
target_compile_options(tinymitm-warnings INTERFACE /W4 /WX)
|
|
else()
|
|
target_compile_options(tinymitm-warnings INTERFACE -Wall -Wextra -Werror)
|
|
endif()
|
|
|
|
# ------------------------------
|
|
# proxy
|
|
# ------------------------------
|
|
file(GLOB_RECURSE TINYMITM_SOURCES CONFIGURE_DEPENDS "src/proxy/*.cpp" "src/proxy/*.h")
|
|
add_library(tinymitm STATIC ${TINYMITM_SOURCES})
|
|
target_include_directories(tinymitm PUBLIC src/proxy)
|
|
target_compile_features(tinymitm PUBLIC cxx_std_20)
|
|
target_link_libraries(tinymitm PRIVATE tinymitm-warnings)
|
|
target_link_libraries(tinymitm PUBLIC seallib wolfssl)
|
|
set_target_properties(tinymitm PROPERTIES CXX_EXTENSIONS OFF)
|
|
|
|
# ------------------------------
|
|
# test
|
|
# ------------------------------
|
|
if (TINYMITM_TEST)
|
|
file(GLOB_RECURSE TINYMITM_TEST_SOURCES CONFIGURE_DEPENDS "src/test/*.h" "src/test/*.cpp")
|
|
add_executable(tinymitm-test ${TINYMITM_TEST_SOURCES})
|
|
target_include_directories(tinymitm-test PRIVATE "src/test")
|
|
target_link_libraries(tinymitm-test PRIVATE tinymitm-warnings tinymitm)
|
|
|
|
if(WIN32)
|
|
target_link_libraries(tinymitm-test PRIVATE wininet)
|
|
endif()
|
|
endif() |