aboutsummaryrefslogtreecommitdiff
path: root/cmake/netsim_dependencies.cmake
blob: ae83310d33fa88c4525aeecc3847de449657993a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
set(BLUETOOTH_EMULATION True)
set(AOSP ${CMAKE_CURRENT_LIST_DIR}/../../..)
set(EXTERNAL ${AOSP}/external)
set(EXTERNAL_QEMU ${EXTERNAL}/qemu)
set(ANDROID_QEMU2_TOP_DIR ${EXTERNAL_QEMU})

if(NOT DEFINED ANDROID_TARGET_TAG)
  message(
    WARNING
      "You should invoke the cmake generator with a proper toolchain from ${EXTERNAL_QEMU}/android/build/cmake, "
      "Trying to infer toolchain, this might not work.")
  list(APPEND CMAKE_MODULE_PATH "${EXTERNAL_QEMU}/android/build/cmake/")
  include(toolchain)
  _get_host_tag(TAG)
  toolchain_configure_tags(${TAG})
endif()

include(android)
include(prebuilts)
prebuilt(Threads)

if(Rust_COMPILER OR OPTION_ENABLE_SYSTEM_RUST)
  if(OPTION_ENABLE_SYSTEM_RUST)
    message(STATUS "Attempting to use the system rust compiler")
    use_system_rust_toolchain()
  endif()

  enable_vendorized_crates("${EXTERNAL_QEMU}/android/third_party/rust/crates")
  add_subdirectory(${EXTERNAL_QEMU}/android/build/cmake/corrosion corrosion)
  ensure_rust_version_is_compliant()
endif()

set(_gRPC_RE2_INCLUDE_DIR "${EXTERNAL_QEMU}/android/third_party/re2")
set(_gRPC_RE2_LIBRARIES re2)
set(NETSIM_EXT TRUE)

# Let's bin place everything in the root, with the shared libs in the right
# place
set(DBG_INFO ${CMAKE_BINARY_DIR}/build/debug_info)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib64)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/archives)
set(CMAKE_PDB_OUTPUT_DIRECTORY ${DBG_INFO})
# Feeling courageous? Set this to $ANDROID_SDK_ROOT
if(DARWIN_X86_64 OR DARWIN_AARCH64)
  set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/distribution/emulator)
  set(CMAKE_INSTALL_CODESIGN ${CMAKE_BINARY_DIR}/distribution/_codesign)
else()
  set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/distribution/emulator)
endif()

# First make the protobuf and dependencies available to gRPC
add_subdirectory(${EXTERNAL}/qemu/android/third_party/protobuf protobuf)

add_subdirectory(${AOSP}/hardware/google/aemu/base aemu-base)
add_subdirectory(${AOSP}/hardware/google/aemu/host-common host-common)
add_subdirectory(${AOSP}/packages/modules/Bluetooth/tools/rootcanal rootcanal)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/abseil-cpp abseil-cpp)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/boringssl boringssl)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/google-benchmark
                 google-benchmark)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/hostapd hostapd)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/libslirp libslirp)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/googletest/ gtest)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/lz4 lz4)
add_subdirectory(${EXTERNAL_QEMU}/android/third_party/re2 re2)
add_subdirectory(${EXTERNAL}/cares cares)
add_subdirectory(${EXTERNAL}/glib/glib glib2)
add_subdirectory(${EXTERNAL}/grpc/emulator grpc)
add_subdirectory(${EXTERNAL}/qemu/android/android-emu-base android-emu-base)
add_subdirectory(${EXTERNAL}/qemu/android/android-net/android android-emu-net)
add_subdirectory(${EXTERNAL}/qemu/android-qemu2-glue/netsim
                 android-wifi-service)
add_subdirectory(${EXTERNAL}/qemu/android/emu/base emu-base)
add_subdirectory(${EXTERNAL}/qemu/android/emu/utils android-emu-utils)
add_subdirectory(${EXTERNAL}/webrtc/third_party/jsoncpp jsoncpp)

if(NOT TARGET gfxstream-snapshot.headers)
  # Fake dependency to satisfy linker
  add_library(gfxstream-snapshot.headers INTERFACE)
endif()

if(CMAKE_BUILD_TYPE MATCHES DEBUG)
  # This will help you find issues.
  set(CMAKE_C_FLAGS "-fsanitize=address -fno-omit-frame-pointer -g3 -O0")
  set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address")
endif()

if(LINUX_X86_64)
  # Our linux headers are from 2013, and do not define newer socket options.
  # (b/156635589)
  target_compile_options(grpc PRIVATE -DSO_REUSEPORT=15)
  target_compile_options(grpc_unsecure PRIVATE -DSO_REUSEPORT=15)
endif()

# Testing
enable_testing()
include(GoogleTest)