Debian Codegraph @

crt/aws-c-common/AWSCRTAndroidTestRunner/app/src/main/cpp/CMakeLists.txt

raw
1 # For more information about using CMake with Android Studio, read the
2 # documentation: https://d.android.com/studio/projects/add-native-code.html
3
4 # Sets the minimum version of CMake required to build the native library.
5
6 cmake_minimum_required(VERSION 3.9...3.31)
7
8 # AWS lib
9 set(path_to_common "${CMAKE_CURRENT_LIST_DIR}/../../../../..")
10 get_filename_component(path_to_common ${path_to_common} ABSOLUTE)
11
12 # This is required in order to append /lib/cmake to each element in CMAKE_PREFIX_PATH
13 set(AWS_MODULE_DIR "/${CMAKE_INSTALL_LIBDIR}/cmake")
14 string(REPLACE ";" "${AWS_MODULE_DIR};" AWS_MODULE_PATH "${CMAKE_PREFIX_PATH}${AWS_MODULE_DIR}")
15 # Append that generated list to the module search path
16 list(APPEND CMAKE_MODULE_PATH ${AWS_MODULE_PATH})
17
18 list(APPEND CMAKE_MODULE_PATH "${path_to_common}/cmake")
19 include(AwsFindPackage)
20 set(IN_SOURCE_BUILD ON)
21 set(BUILD_SHARED_LIBS ON)
22
23 # We will generate our own tests, the tests that are there depend on CTest
24 set(ALLOW_CROSS_COMPILED_TESTS ON)
25 set(BUILD_TESTING ON)
26 add_subdirectory(${path_to_common} ${CMAKE_CURRENT_BINARY_DIR}/aws-c-common)
27 aws_use_package(aws-c-common)
28
29 function(import_tests test_cmakelists)
30 get_property(TEST_CASES GLOBAL PROPERTY AWS_TEST_CASES)
31
32 # Generate Kotlin test classes
33 get_filename_component(testrunner_path "../../androidTest/java/software/amazon/awssdk/crt/awscrtandroidtestrunner" ABSOLUTE)
34 foreach(name IN LISTS TEST_CASES)
35 set(TEST_NAME "${name}")
36 configure_file(
37 "${testrunner_path}/NativeTest.kt.in"
38 "${testrunner_path}/tests/NativeTest_${name}.kt"
39 )
40 endforeach()
41 endfunction()
42
43 file(GLOB test_src "${path_to_common}/tests/*.c")
44 file(GLOB test_logging_src
45 "${path_to_common}/tests/logging/logging_test_utilities.c"
46 "${path_to_common}/tests/logging/test_logger.c")
47 set(test_src ${test_src} ${test_logging_src})
48 import_tests(${path_to_common}/tests/CMakeLists.txt)
49
50 # JNI Lib
51 add_library(native-lib SHARED native-lib.cpp ${test_src})
52 find_library(log-lib log)
53 target_include_directories(native-lib PUBLIC
54 "${path_to_common}/include"
55 "${path_to_common}/tests"
56 "${CMAKE_CURRENT_BINARY_DIR}/aws-c-common/generated/include")
57 target_compile_definitions(native-lib PRIVATE AWS_UNSTABLE_TESTING_API=1)
58 target_link_libraries(native-lib ${log-lib} ${DEP_AWS_LIBS})