cc343edb创建于 3月12日历史提交
cmake_minimum_required(VERSION 3.22.1)

# Usually this file is called from run_tests.sh which requires the $ANDROID_NDK variable to be set so there's no need
# to set it here. Comments below are left in intentionally in case they're useful in future.
# This may work on Mac OS.
# set(ANDROID_NDK $ENV{HOME}/Library/Android/sdk/ndk-bundle)
# This may work on Linux.
# set(ANDROID_NDK $ENV{HOME}/Android/sdk/ndk-bundle)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -std=c++17 -DOBOE_SUPPRESS_LOG_SPAM")

# Include GoogleTest library
set(GOOGLETEST_ROOT ${ANDROID_NDK}/sources/third_party/googletest CACHE PATH "Path to GoogleTest root")
add_library(gtest STATIC ${GOOGLETEST_ROOT}/src/gtest_main.cc ${GOOGLETEST_ROOT}/src/gtest-all.cc)
target_include_directories(gtest PRIVATE ${GOOGLETEST_ROOT})
target_include_directories(gtest PUBLIC ${GOOGLETEST_ROOT}/include)

# Include Oboe sources
set (OBOE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/..)
add_subdirectory(${OBOE_DIR} ./oboe-bin)
include_directories(
		${OBOE_DIR}/include
		${OBOE_DIR}/src
		)

# Platform-independent tests
set(TEST_SOURCES
		testAudioClock.cpp
		testFlowgraph.cpp
		testResampler.cpp
		testUtilities.cpp
		testStreamStates.cpp
		)

# Android-specific tests
if(OBOE_ANDROID_PLATFORM)
	list(APPEND TEST_SOURCES
		testAAudio.cpp
		testFullDuplexStream.cpp
		testReturnStop.cpp
		testReturnStopDeadlock.cpp
		testStreamClosedMethods.cpp
		testStreamOpen.cpp
		testStreamStop.cpp
		testStreamWaitState.cpp
		testXRunBehaviour.cpp
		)
endif()

if (OBOE_OHOS_PLATFORM)
    add_definitions(-D__OHOS_PLATFORM__)
    list(APPEND TEST_SOURCES
        testOHAudio.cpp
        )
endif()

# Build the test binary
add_executable(testOboe ${TEST_SOURCES})

target_link_libraries(testOboe gtest oboe)
target_link_options(testOboe PRIVATE "-Wl,-z,max-page-size=16384")