75 lines
3.9 KiB
CMake
75 lines
3.9 KiB
CMake
|
|
cmake_minimum_required(VERSION 3.22.1)
|
||
|
|
project("iperf3jni")
|
||
|
|
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# Paths
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# CMAKE_SOURCE_DIR here is android/app/src/main/cpp/
|
||
|
|
set(IPERF_SRC_DIR ${CMAKE_SOURCE_DIR}/iperf)
|
||
|
|
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# Generate iperf_config.h from our Android template, into cpp/iperf/
|
||
|
|
# (iperf.h uses #include "iperf_config.h" which resolves relative to its dir)
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
configure_file(
|
||
|
|
${IPERF_SRC_DIR}/iperf_config_android.h
|
||
|
|
${IPERF_SRC_DIR}/iperf_config.h
|
||
|
|
)
|
||
|
|
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# Shared library: iperf3jni
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
add_library(iperf3jni SHARED
|
||
|
|
|
||
|
|
# JNI bridge (directly in cpp/)
|
||
|
|
iperf_jni.c
|
||
|
|
|
||
|
|
# iperf3 source files (in cpp/iperf/)
|
||
|
|
iperf/iperf_api.c
|
||
|
|
iperf/iperf_client_api.c
|
||
|
|
iperf/iperf_util.c
|
||
|
|
iperf/iperf_udp.c
|
||
|
|
iperf/iperf_tcp.c
|
||
|
|
iperf/iperf_server_api.c
|
||
|
|
iperf/iperf_sctp.c
|
||
|
|
iperf/iperf_error.c
|
||
|
|
iperf/iperf_time.c
|
||
|
|
iperf/iperf_locale.c
|
||
|
|
iperf/iperf_pthread.c
|
||
|
|
iperf/iperf_auth.c
|
||
|
|
iperf/net.c
|
||
|
|
iperf/timer.c
|
||
|
|
iperf/units.c
|
||
|
|
iperf/cjson.c
|
||
|
|
iperf/dscp.c
|
||
|
|
iperf/tcp_info.c
|
||
|
|
)
|
||
|
|
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# Include directories - iperf/ FIRST so "iperf_config.h" resolves there
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
target_include_directories(iperf3jni PRIVATE
|
||
|
|
${IPERF_SRC_DIR} # for iperf headers (iperf_config.h, iperf.h, etc.)
|
||
|
|
${CMAKE_SOURCE_DIR} # for JNI includes
|
||
|
|
)
|
||
|
|
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# Compile definitions
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
target_compile_definitions(iperf3jni PRIVATE
|
||
|
|
HAVE_PTHREAD
|
||
|
|
__ANDROID__
|
||
|
|
# Disable the main() entry point — we're a shared lib, not a standalone binary
|
||
|
|
IPERF_JNI_BUILD=1
|
||
|
|
)
|
||
|
|
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
# Link libraries
|
||
|
|
# ──────────────────────────────────────────────────────────────────
|
||
|
|
find_package(Threads REQUIRED)
|
||
|
|
target_link_libraries(iperf3jni
|
||
|
|
Threads::Threads
|
||
|
|
log
|
||
|
|
android
|
||
|
|
)
|