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
6cmake_minimum_required(VERSION 3.4.1)
7
8# Require C++17 compiler with no extensions
9set(CMAKE_CXX_STANDARD 17)
10set(CMAKE_CXX_STANDARD_REQUIRED ON)
11set(CMAKE_CXX_EXTENSIONS OFF)
12
13link_directories(${CMAKE_CURRENT_LIST_DIR}/..)
14
15# Creates and names a library, sets it as either STATIC
16# or SHARED, and provides the relative paths to its source code.
17# You can define multiple libraries, and CMake builds them for you.
18# Gradle automatically packages shared libraries with your APK.
19
20add_library( # Sets the name of the library.
21        native-lib
22        # Sets the library as a shared library.
23        SHARED
24        # Provides a relative path to your source file(s).
25        src/main/cpp/native-lib.cpp
26        src/main/cpp/DuplexEngine.cpp
27        )
28
29# Compile with warnings for safety
30if(MSVC)
31    target_compile_options(native-lib PRIVATE /W4 /WX)
32else()
33    target_compile_options(native-lib PRIVATE -Wall -Wextra -pedantic)
34endif()
35
36target_compile_options(native-lib PRIVATE -Ofast)
37
38# Searches for a specified prebuilt library and stores the path as a
39# variable. Because CMake includes system libraries in the search path by
40# default, you only need to specify the name of the public NDK library
41# you want to add. CMake verifies that the library exists before
42# completing its build.
43
44find_library( # Sets the name of the path variable.
45        log-lib
46        # Specifies the name of the NDK library that
47        # you want CMake to locate.
48        log)
49
50
51### INCLUDE OBOE LIBRARY ###
52
53# Set the path to the Oboe library directory
54set (OBOE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
55
56# Add the Oboe library as a subproject. Since Oboe is an out-of-tree source library we must also
57# specify a binary directory
58add_subdirectory(${OBOE_DIR} ./oboe-bin)
59
60# Specify the path to the Oboe header files and the source.
61include_directories(
62    ${OBOE_DIR}/include
63    ${OBOE_DIR}/src
64)
65
66### END OBOE INCLUDE SECTION ###
67
68
69# Specifies libraries CMake should link to your target library. You
70# can link multiple libraries, such as libraries you define in this
71# build script, prebuilt third-party libraries, or system libraries.
72
73target_link_libraries( # Specifies the target library.
74        native-lib
75        oboe
76        # Links the target library to the log library
77        # included in the NDK.
78        ${log-lib})
79
80