aboutsummaryrefslogtreecommitdiff
path: root/nearby/presence/CMakeLists.txt
blob: d2a251bcef8c5579bb4a0e702560db44c677ae1b (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
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.14)

project(NearbyProtocol)

# required for designated initializers on MSVC
set(CMAKE_CXX_STANDARD 17)

# root directory of repo
set(BETO_CORE_ROOT ${CMAKE_SOURCE_DIR}/../..)

# location of external third_party dependencies
set(THIRD_PARTY_DIR ${BETO_CORE_ROOT}/third_party)

set(CMAKE_C_FLAGS_DEBUG "-DDEBUG")
set(CMAKE_CXX_FLAGS_DEBUG "-DDEBUG")
if (UNIX)
    set(CMAKE_C_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}")
    set(CMAKE_CXX_FLAGS_DEBUG "-g ${CMAKE_C_FLAGS_DEBUG}")
endif ()

find_package(OpenSSL REQUIRED)
if (OPENSSL_FOUND)
    message(STATUS "OpenSSL Found: ${OPENSSL_VERSION}")
    message(STATUS "OpenSSL Include: ${OPENSSL_INCLUDE_DIR}")
    message(STATUS "OpenSSL Libraries: ${OPENSSL_LIBRARIES}")
endif ()

if (MSVC)
    add_compile_options(-W4 -O1 -MD)
endif ()

if (ENABLE_TESTS)
    message(STATUS "Enabling workspace wide tests")

    # Setup GoogleTest
    include(FetchContent)
    FetchContent_Declare(
            googletest
            GIT_REPOSITORY https://github.com/google/googletest.git
            GIT_TAG release-1.12.1
    )
    FetchContent_MakeAvailable(googletest)
    enable_testing()
    include(GoogleTest)

    # Include google benchmark
    add_subdirectory(${THIRD_PARTY_DIR}/benchmark ${THIRD_PARTY_DIR}/benchmark/build)

    # Setup jsoncpp
    set(JSONCPP_DIR ${THIRD_PARTY_DIR}/jsoncpp)
    include_directories(${JSONCPP_DIR})
    add_library(
            jsoncpp
            ${JSONCPP_DIR}/jsoncpp.cpp
    )
endif ()

# Add these compile options for our own code, not needed for the above deps
if (UNIX)
    add_compile_options(-Wall -Wextra -Wimplicit-fallthrough -Wextra-semi
            -Wno-missing-field-initializers -Wno-unused-parameter -Wno-psabi
            -Wshadow
            -Wsign-compare)
endif()


add_subdirectory(np_cpp_ffi)
add_subdirectory(ldt_np_c_sample)

if (ENABLE_FUZZ)
    message(STATUS "Building fuzzers")
    add_subdirectory(ldt_np_adv_ffi_fuzz)
endif ()