1# Copyright (c) 2022-2022 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14############################### 15# find python3 16find_package (Python3 COMPONENTS Interpreter) 17 18IF(Python3_FOUND) 19 SET(PYTHON ${Python3_EXECUTABLE}) 20ELSE() 21 MESSAGE(FATAL_ERROR "No Python interpreter found") 22ENDIF(Python3_FOUND) 23 24############################### 25# definitions 26 27set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) 28 29IF(UNIX OR MINGW) 30ADD_DEFINITIONS( 31 -g -ggdb 32) 33IF(UNIX) 34ADD_LINK_OPTIONS( 35 -rdynamic 36) 37ELSE() 38ADD_LINK_OPTIONS( 39 -Wl,--export-all-symbols 40) 41ENDIF(UNIX) 42ENDIF(UNIX OR MINGW) 43 44ADD_DEFINITIONS(-D__STDC_FORMAT_MACROS -DHST_WORKING_DIR="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}") 45 46IF(CMAKE_CL_64) 47 ADD_DEFINITIONS(-DWIN64) 48ENDIF(CMAKE_CL_64) 49 50IF(MSVC) 51 ADD_DEFINITIONS( -D_CRT_SECURE_NO_WARNINGS /source-charset:utf-8) 52ENDIF(MSVC) 53 54set(TOP_DIR ${CMAKE_SOURCE_DIR}) 55 56ADD_DEFINITIONS( 57 -D__STDC_FORMAT_MACROS 58 -DHST_PLUGIN_PATH="./" 59) 60if (WIN32) 61 add_definitions( -DHST_PLUGIN_FILE_TAIL=".dll" ) 62else() 63 add_definitions( -DHST_PLUGIN_FILE_TAIL=".so" ) 64endif() 65 66############################### 67# includes 68 69INCLUDE_DIRECTORIES(BEFORE 70 ${TOP_DIR}/3rdparty/testngpp2/include 71 ${TOP_DIR}/demo/system_tests 72 ${TOP_DIR}/histreamer/engine 73 ${TOP_DIR}/histreamer/engine/scene/standard 74 ${TOP_DIR}/histreamer/engine/plugin 75 ${TOP_DIR}/3rdparty/ohos 76 ${TOP_DIR}/3rdparty/debug) 77IF(MSVC) 78#INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/include/msinttypes) 79ENDIF(MSVC) 80 81############################### 82# Generate Test Suite cxx files 83 84SET(TEST_SUITES_DIR ${TOP_DIR}/histreamer/tests/st/gen_testsuites) 85SET(TEST_GENERATOR ${TOP_DIR}/3rdparty/testngpp2/generator/testngppgen.py) 86SET(TEST_SUITE_PREFIX st_) 87 88SET(TESTSUITE_ENTRY ${TEST_SUITES_DIR}/AllTestSuites.cxx) 89SET(TESTSUITE_SRCS ${TESTSUITE_ENTRY}) 90 91SET(UT_CASE_DIR ${TOP_DIR}/histreamer/tests/st) 92file(GLOB_RECURSE UT_CASES_PATH ${UT_CASE_DIR}/*.h) # find all testcase .h files 93 94FOREACH(CASE_PATH ${UT_CASES_PATH}) 95 96GET_FILENAME_COMPONENT(CASE ${CASE_PATH} NAME_WE) 97 98SET(INPUT_H ${UT_CASE_DIR}/${CASE}.h) 99SET(OUTPUT_CXX ${TEST_SUITES_DIR}/st_${CASE}.cxx) 100 101SET(TESTSUITE_SRCS ${TESTSUITE_SRCS} ${OUTPUT_CXX}) 102 103ADD_CUSTOM_COMMAND( 104 OUTPUT ${OUTPUT_CXX} ${TESTSUITE_ENTRY} 105 COMMAND ${PYTHON} ${TEST_GENERATOR} -d ${TEST_SUITES_DIR} -p ${TEST_SUITE_PREFIX} ${INPUT_H} 106 DEPENDS ${INPUT_H} 107) 108 109ENDFOREACH() 110 111############################### 112# src files 113SET(TEST_PLUGIN_SRCS 114 ${TOP_DIR}/histreamer/engine/plugin/core/plugin_manager.cpp 115 ${TOP_DIR}/histreamer/engine/plugin/core/plugin_register.cpp 116 ${TOP_DIR}/histreamer/engine/plugin/core/muxer.cpp 117 ${TOP_DIR}/histreamer/engine/plugin/core/source.cpp 118 ${TOP_DIR}/histreamer/engine/plugin/core/demuxer.cpp 119 ${TOP_DIR}/histreamer/engine/plugin/core/base.cpp 120 ${TOP_DIR}/histreamer/engine/plugin/core/audio_sink.cpp 121 ${TOP_DIR}/histreamer/engine/plugin/core/codec.cpp 122 ${TOP_DIR}/histreamer/engine/plugin/core/video_sink.cpp 123 ${TOP_DIR}/histreamer/engine/plugin/core/plugin_core_utils.cpp 124 ${TOP_DIR}/histreamer/engine/plugin/core/plugin_wrapper.cpp 125 ${TOP_DIR}/histreamer/engine/plugin/core/output_sink.cpp 126 ${TOP_DIR}/histreamer/engine/plugin/core/plugin_meta.cpp 127 ${TOP_DIR}/histreamer/engine/foundation/osal/filesystem/file_system.cpp 128 ${TOP_DIR}/histreamer/engine/foundation/osal/thread/mutex.cpp 129 ${TOP_DIR}/histreamer/engine/foundation/osal/thread/scoped_lock.cpp) 130 131############################### 132# dependencies 133if (MINGW) 134 set(ffmpeg_lib_path ${TOP_DIR}/3rdparty/ffmpeg/windows/lib) 135 set(sdl_lib_path ${TOP_DIR}/3rdparty/SDL2.0/windows/lib/x64) 136 set(curl_lib_path ${TOP_DIR}/3rdparty/curl/lib/windows) 137else () 138 if (${OHOS_LITE}) 139 set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++11 -Wall") 140 else() 141 set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++17 -Wall") 142 endif() 143 set(ffmpeg_lib_path ${TOP_DIR}/3rdparty/ffmpeg/linux/lib) 144 set(sdl_lib_path ${TOP_DIR}/3rdparty/SDL2.0/linux/lib) 145 set(curl_lib_path ${TOP_DIR}/3rdparty/curl/lib/linux) 146 set(z_lib_path /usr/lib/x86_64-linux-gnu) 147endif () 148 149link_directories( 150 ${ffmpeg_lib_path} 151 ${sdl_lib_path} 152 ${curl_lib_path} 153 ${z_lib_path} 154) 155 156file(GLOB OSAL_THREAD_SRCS ${TOP_DIR}/histreamer/engine/foundation/osal/thread/*.cpp) 157if (${OHOS_LITE}) 158 # only for lite stream source player 159 set(TEST_HELPER_SRCS 160 ${TOP_DIR}/histreamer/tests/st/helper/lite_player.cpp 161 ${TOP_DIR}/histreamer/tests/st/helper/lite_stream_player.cpp 162 ${TOP_DIR}/histreamer/tests/st/helper/lite_audio_recorder.cpp 163 ${OSAL_THREAD_SRCS} 164 ${TOP_DIR}/histreamer/engine/scene/common/data_stream.cpp 165 ${TOP_DIR}/histreamer/engine/scene/common/data_stream_impl.cpp 166 ) 167else() 168 set(TEST_HELPER_SRCS 169 ${TOP_DIR}/histreamer/tests/st/helper/std_player.cpp 170 ${OSAL_THREAD_SRCS} 171 ${TOP_DIR}/histreamer/engine/foundation/osal/utils/util.cpp 172 ${TOP_DIR}/histreamer/tests/st/helper/std_audio_recorder.cpp 173 ) 174endif () 175 176set(TEST_HELPER_SRCS 177 ${TEST_HELPER_SRCS} 178 ${TOP_DIR}/3rdparty/debug/crashdump/common/crash_handler_register.cpp 179 ${TOP_DIR}/histreamer/tests/st/helper/main.cpp 180 ) 181 182############################### 183# targets 184link_directories(${TOP_DIR}/3rdparty/testngpp2/lib) 185 186ADD_EXECUTABLE(histreamer_st ${TESTSUITE_SRCS} ${TEST_HELPER_SRCS} ${3RDPARTY_SRCS} ${TEST_PLUGIN_SRCS}) 187 188IF(UNIX) 189TARGET_LINK_LIBRARIES(histreamer_st 190 ${TOP_DIR}/3rdparty/testngpp2/lib/libtestngpp.a 191 dl 192 histreamer 193 pthread 194 ${ffmpeg_lib_path}/libavformat.a 195 ${ffmpeg_lib_path}/libavcodec.a 196 ${ffmpeg_lib_path}/libavdevice.a 197 ${ffmpeg_lib_path}/libavfilter.a 198 ${ffmpeg_lib_path}/libavutil.a 199 ${ffmpeg_lib_path}/libswscale.a 200 ${ffmpeg_lib_path}/libswresample.a 201 ${ffmpeg_lib_path}/liblzma.a 202 curl 203 SDL2-2.0 204 z 205 ) 206ELSE() 207TARGET_LINK_LIBRARIES(histreamer_st testngpp2 histreamer) 208ENDIF() 209