librats 2.3.0 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/native-src/CMakeLists.txt +43 -6
- package/package.json +1 -1
|
@@ -492,21 +492,58 @@ if(WIN32)
|
|
|
492
492
|
target_link_libraries(rats ws2_32 iphlpapi bcrypt advapi32)
|
|
493
493
|
endif()
|
|
494
494
|
|
|
495
|
-
|
|
495
|
+
# Android can be built two ways, and only one of them sets CMake's ANDROID variable:
|
|
496
|
+
# through the NDK's android.toolchain.cmake (sets ANDROID / ANDROID_PLATFORM), or by
|
|
497
|
+
# simply pointing CC/CXX at the NDK's <triple><api>-clang wrappers, which is what the
|
|
498
|
+
# Android CI does. The compiler is the only thing that knows in both cases, so ask it
|
|
499
|
+
# rather than trusting a toolchain-file-only variable.
|
|
500
|
+
if(NOT ANDROID)
|
|
501
|
+
check_cxx_source_compiles("
|
|
502
|
+
#ifndef __ANDROID__
|
|
503
|
+
#error not android
|
|
504
|
+
#endif
|
|
505
|
+
int main() { return 0; }
|
|
506
|
+
" RATS_TARGET_IS_ANDROID)
|
|
507
|
+
else()
|
|
508
|
+
set(RATS_TARGET_IS_ANDROID TRUE)
|
|
509
|
+
endif()
|
|
510
|
+
|
|
511
|
+
if(RATS_TARGET_IS_ANDROID)
|
|
496
512
|
# The logger routes console output through __android_log_print, because an app's
|
|
497
|
-
# stdout/stderr go nowhere on Android.
|
|
498
|
-
|
|
499
|
-
|
|
513
|
+
# stdout/stderr go nowhere on Android. This is used from librats/util/logger.h,
|
|
514
|
+
# i.e. from consumers of the static library too, so the dependency is PUBLIC.
|
|
515
|
+
# Only search for it when the NDK toolchain file configured a sysroot to search;
|
|
516
|
+
# with a bare NDK clang, find_library would look at host paths, so let the driver
|
|
517
|
+
# resolve -llog out of its own sysroot instead.
|
|
518
|
+
if(ANDROID)
|
|
519
|
+
find_library(log-lib log)
|
|
520
|
+
target_link_libraries(rats ${log-lib})
|
|
521
|
+
else()
|
|
522
|
+
target_link_libraries(rats log)
|
|
523
|
+
endif()
|
|
500
524
|
|
|
525
|
+
# API level: from the toolchain file when it set one, otherwise from the compiler.
|
|
501
526
|
if(DEFINED ANDROID_PLATFORM)
|
|
502
527
|
string(REGEX REPLACE "android-" "" ANDROID_API_LEVEL ${ANDROID_PLATFORM})
|
|
503
528
|
math(EXPR ANDROID_API_LEVEL "${ANDROID_API_LEVEL}")
|
|
504
529
|
message(STATUS "Android API level detected: ${ANDROID_API_LEVEL}")
|
|
530
|
+
if(ANDROID_API_LEVEL LESS 24)
|
|
531
|
+
set(RATS_ANDROID_NEEDS_IFADDRS TRUE)
|
|
532
|
+
endif()
|
|
505
533
|
else()
|
|
506
|
-
|
|
534
|
+
check_cxx_source_compiles("
|
|
535
|
+
#include <android/api-level.h>
|
|
536
|
+
#if __ANDROID_API__ < 24
|
|
537
|
+
#error too old
|
|
538
|
+
#endif
|
|
539
|
+
int main() { return 0; }
|
|
540
|
+
" RATS_ANDROID_API_24_OR_NEWER)
|
|
541
|
+
if(NOT RATS_ANDROID_API_24_OR_NEWER)
|
|
542
|
+
set(RATS_ANDROID_NEEDS_IFADDRS TRUE)
|
|
543
|
+
endif()
|
|
507
544
|
endif()
|
|
508
545
|
|
|
509
|
-
if(
|
|
546
|
+
if(RATS_ANDROID_NEEDS_IFADDRS)
|
|
510
547
|
target_sources(rats PRIVATE ${PROJECT_SOURCE_DIR}/3rdparty/android/ifaddrs-android.c)
|
|
511
548
|
target_include_directories(rats
|
|
512
549
|
PRIVATE
|