cmake_minimum_required(VERSION 3.22)
project(htportal_mobile_vpn_core VERSION 0.1.0 LANGUAGES C)

option(HTP_BUILD_N3N "Build the embedded n3n edge" ON)
option(HTP_BUILD_TESTS "Build portable unit tests" ON)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_library(htp_packet_bridge STATIC src/packet_bridge.c)
target_include_directories(htp_packet_bridge PUBLIC include)
target_compile_options(htp_packet_bridge PRIVATE -Wall -Wextra -Wpedantic)

if(HTP_BUILD_N3N)
    include(cmake/N3N.cmake)
endif()

if(HTP_BUILD_TESTS AND NOT ANDROID AND NOT APPLE)
    enable_testing()
    add_executable(packet_bridge_test test/packet_bridge_test.c)
    target_link_libraries(packet_bridge_test PRIVATE htp_packet_bridge)
    add_test(NAME packet_bridge COMMAND packet_bridge_test)

    add_executable(n3n_path_test test/n3n_path_test.c src/n3n_path.c)
    target_include_directories(n3n_path_test PRIVATE include src)
    target_compile_options(n3n_path_test PRIVATE -Wall -Wextra -Wpedantic)
    add_test(NAME n3n_path COMMAND n3n_path_test)
endif()
