1# Copyright 2022 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); you may not 4# use this file except in compliance with the License. You may obtain a copy of 5# the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 12# License for the specific language governing permissions and limitations under 13# the License. 14 15# Netsim - a network simulator for discovery, ranging and communication 16 17project(netsim) 18cmake_minimum_required(VERSION 3.5) 19cmake_policy(SET CMP0079 NEW) 20set(CMAKE_CXX_STANDARD 17) 21set(CMAKE_CXX_STANDARD_REQUIRED True) 22set(CMAKE_POSITION_INDEPENDENT_CODE ON) 23list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") 24 25if(NOT ANDROID_EMULATOR_BUILD) 26 message(STATUS "Building netsim standalone.") 27 include(netsim_dependencies) 28endif() 29 30if(TARGET Rust::Rustc) 31 add_subdirectory(pdl) 32 add_subdirectory(rust) 33else() 34 message(WARNING "Only building client side dependencies.") 35endif() 36 37add_subdirectory(proto) 38add_subdirectory(src) 39 40if(TARGET Rust::Rustc) 41 android_add_executable( 42 TARGET netsim LICENSE Apache-2.0 INSTALL . SRC rust/netsim.cc 43 DEPS netsim-cli-proto-lib netsim-cli-rust-lib) 44 45 android_add_executable( 46 TARGET netsimd 47 LICENSE Apache-2.0 INSTALL . 48 SRC rust/netsimd.cc 49 DEPS grpc++ 50 libbt-rootcanal 51 netsim-cli-proto-lib 52 netsim-daemon 53 netsimd-lib 54 netsimd-proto-lib 55 packet-streamer-proto-lib) 56 57 if(NOT DARWIN_AARCH64 AND NOT DARWIN_X86_64) 58 # Prevent duplicate symbol for cxx Rust crate. 59 target_link_libraries(netsimd PRIVATE -Wl,--allow-multiple-definition) 60 endif() 61 62 android_target_dependency(netsimd linux TCMALLOC_OS_DEPENDENCIES) 63 64 android_add_test( 65 TARGET netsim-test LICENSE Apache-2.0 66 SRC src/util/ini_file_test.cc src/util/os_utils_test.cc 67 src/util/string_utils_test.cc 68 DEPS android-emu-base-headers 69 grpc++ 70 gtest 71 gtest_main 72 libbt-rootcanal 73 netsim-cli-proto-lib 74 netsim-daemon 75 netsim-proto 76 netsimd-lib 77 netsimd-proto-lib 78 protobuf::libprotobuf 79 util-lib) 80 81 target_compile_definitions(netsim-test PUBLIC NETSIM_ANDROID_EMULATOR) 82 target_include_directories(netsim-test PRIVATE src) 83 84 # Link NtDll to netsim executables. 85 if(WIN32) 86 target_link_libraries(netsim PRIVATE ntdll) 87 target_link_libraries(netsimd PRIVATE ntdll) 88 target_link_libraries(netsim-test PRIVATE ntdll) 89 android_license(TARGET "ntdll" LIBNAME None SPDX None LICENSE None 90 LOCAL None) 91 endif() 92endif() 93 94if(NOT NETSIM_EXT) 95 android_add_executable( 96 TARGET netsim-packet-streamer-client 97 LICENSE Apache-2.0 98 SRC src/netsim-packet-streamer-client.cc 99 DEPS grpc++ packet-streamer-client-lib packet-streamer-proto-lib 100 protobuf::libprotobuf) 101endif() 102 103add_subdirectory(ui) 104