• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/include
74        ${TOP_DIR}/histreamer/engine/scene/standard
75        ${TOP_DIR}/histreamer/engine/plugin
76        ${TOP_DIR}/3rdparty/ohos
77        ${TOP_DIR}/3rdparty/debug)
78IF(MSVC)
79#INCLUDE_DIRECTORIES(BEFORE ${CMAKE_SOURCE_DIR}/include/msinttypes)
80ENDIF(MSVC)
81
82###############################
83# Generate Test Suite cxx files
84
85SET(TEST_SUITES_DIR ${TOP_DIR}/histreamer/tests/st/gen_testsuites)
86SET(TEST_GENERATOR ${TOP_DIR}/3rdparty/testngpp2/generator/testngppgen.py)
87SET(TEST_SUITE_PREFIX st_)
88
89SET(TESTSUITE_ENTRY ${TEST_SUITES_DIR}/AllTestSuites.cxx)
90SET(TESTSUITE_SRCS ${TESTSUITE_ENTRY})
91
92SET(UT_CASE_DIR ${TOP_DIR}/histreamer/tests/st)
93file(GLOB_RECURSE UT_CASES_PATH ${UT_CASE_DIR}/*.h) # find all testcase .h files
94
95FOREACH(CASE_PATH ${UT_CASES_PATH})
96
97GET_FILENAME_COMPONENT(CASE ${CASE_PATH} NAME_WE)
98
99SET(INPUT_H ${UT_CASE_DIR}/${CASE}.h)
100SET(OUTPUT_CXX ${TEST_SUITES_DIR}/st_${CASE}.cxx)
101
102SET(TESTSUITE_SRCS ${TESTSUITE_SRCS} ${OUTPUT_CXX})
103
104ADD_CUSTOM_COMMAND(
105  OUTPUT ${OUTPUT_CXX} ${TESTSUITE_ENTRY}
106  COMMAND ${PYTHON} ${TEST_GENERATOR} -d ${TEST_SUITES_DIR} -p ${TEST_SUITE_PREFIX} ${INPUT_H}
107  DEPENDS ${INPUT_H}
108)
109
110ENDFOREACH()
111
112###############################
113# src files
114SET(TEST_PLUGIN_SRCS
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/foundation/osal/filesystem/file_system.cpp
127        ${TOP_DIR}/histreamer/engine/foundation/osal/thread/mutex.cpp
128        ${TOP_DIR}/histreamer/engine/foundation/osal/thread/scoped_lock.cpp)
129
130###############################
131# dependencies
132if (MINGW)
133    set(ffmpeg_lib_path ${TOP_DIR}/3rdparty/ffmpeg/windows/lib)
134    set(sdl_lib_path ${TOP_DIR}/3rdparty/SDL2.0/windows/lib/x64)
135    set(curl_lib_path ${TOP_DIR}/3rdparty/curl/lib/windows)
136else ()
137    if (${OHOS_LITE})
138        set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++11 -Wall")
139    else()
140        set(CMAKE_CXX_FLAGS "-g -ggdb3 -O0 -std=c++17 -Wall")
141    endif()
142    set(ffmpeg_lib_path ${TOP_DIR}/3rdparty/ffmpeg/linux/lib)
143    set(sdl_lib_path ${TOP_DIR}/3rdparty/SDL2.0/linux/lib)
144    set(curl_lib_path ${TOP_DIR}/3rdparty/curl/lib/linux)
145    set(z_lib_path /usr/lib/x86_64-linux-gnu)
146endif ()
147
148link_directories(
149        ${ffmpeg_lib_path}
150        ${sdl_lib_path}
151        ${curl_lib_path}
152        ${z_lib_path}
153)
154
155file(GLOB OSAL_THREAD_SRCS ${TOP_DIR}/histreamer/engine/foundation/osal/thread/*.cpp)
156if (${OHOS_LITE})
157    # only for lite stream source player
158    set(TEST_HELPER_SRCS
159            ${TOP_DIR}/histreamer/tests/st/helper/lite_player.cpp
160            ${TOP_DIR}/histreamer/tests/st/helper/lite_stream_player.cpp
161            ${TOP_DIR}/histreamer/tests/st/helper/lite_audio_recorder.cpp
162            ${OSAL_THREAD_SRCS}
163            ${TOP_DIR}/histreamer/engine/scene/common/data_stream.cpp
164            ${TOP_DIR}/histreamer/engine/scene/common/data_stream_impl.cpp
165            )
166else()
167    set(TEST_HELPER_SRCS
168            ${TOP_DIR}/histreamer/tests/st/helper/media_data_source_imp.cpp
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