ZLMediaKit/tests/CMakeLists.txt

83 lines
2.4 KiB
CMake
Raw Normal View History

2019-04-16 17:25:19 +08:00
execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/ssl.p12 ${EXECUTABLE_OUTPUT_PATH}/)
2019-04-01 10:37:11 +08:00
#查找SDL2是否安装
2018-04-17 21:38:13 +08:00
find_package(SDL2 QUIET)
if (SDL2_FOUND)
include_directories(${SDL2_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${SDL2_LIBRARY})
2019-04-04 11:30:57 +08:00
message(STATUS "found library:${SDL2_LIBRARY}")
2018-04-17 21:38:13 +08:00
endif (SDL2_FOUND)
2017-05-08 18:03:43 +08:00
find_package(PkgConfig QUIET)
2017-05-08 18:03:43 +08:00
#查找ffmpeg/libutil是否安装
if(PKG_CONFIG_FOUND)
pkg_check_modules(AVUTIL QUIET IMPORTED_TARGET libavutil)
if(AVUTIL_FOUND)
2020-08-01 10:16:28 +08:00
include_directories(${AVUTIL_INCLUDE_DIR})
link_directories(${AVUTIL_LIBRARY_DIRS})
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
message(STATUS "found library:${AVUTIL_LIBRARIES}")
endif()
else()
find_package(AVUTIL QUIET)
if(AVUTIL_FOUND)
include_directories(${AVUTIL_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
message(STATUS "found library:${AVUTIL_LIBRARIES}")
endif()
2017-12-01 11:42:49 +08:00
endif()
2017-05-08 18:03:43 +08:00
#查找ffmpeg/libavcodec是否安装
if(PKG_CONFIG_FOUND)
pkg_check_modules(AVCODEC QUIET IMPORTED_TARGET libavcodec)
if(AVCODEC_FOUND)
2020-08-01 10:16:28 +08:00
include_directories(${AVCODEC_INCLUDE_DIR})
link_directories(${AVCODEC_LIBRARY_DIRS})
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
message(STATUS "found library:${AVCODEC_LIBRARIES}")
endif()
else()
find_package(AVCODEC QUIET)
if(AVCODEC_FOUND)
include_directories(${AVCODEC_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
message(STATUS "found library:${AVCODEC_LIBRARIES}")
endif()
2017-12-01 11:42:49 +08:00
endif()
2017-05-08 18:03:43 +08:00
2017-05-02 23:43:10 +08:00
aux_source_directory(. TEST_SRC_LIST)
2017-05-08 18:03:43 +08:00
#如果ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译 test_player
2018-04-17 21:38:13 +08:00
if(SDL2_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND)
2017-08-09 18:39:30 +08:00
else()
2018-04-17 21:38:13 +08:00
message(STATUS "test_player ingored, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil")
2017-12-01 11:42:49 +08:00
list(REMOVE_ITEM TEST_SRC_LIST ./test_player.cpp)
2017-08-09 18:39:30 +08:00
endif()
2017-06-03 10:52:49 +08:00
2017-12-01 11:42:49 +08:00
foreach(TEST_SRC ${TEST_SRC_LIST})
STRING(REGEX REPLACE "^\\./|\\.c[a-zA-Z0-9_]*$" "" TEST_EXE_NAME ${TEST_SRC})
2018-03-21 15:13:33 +08:00
message(STATUS "add test:${TEST_EXE_NAME}")
2017-12-01 11:42:49 +08:00
add_executable(${TEST_EXE_NAME} ${TEST_SRC})
2019-05-31 12:14:51 +08:00
if(WIN32)
set_target_properties(${TEST_EXE_NAME} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
endif(WIN32)
2019-04-01 13:30:00 +08:00
target_link_libraries(${TEST_EXE_NAME} ${LINK_LIB_LIST})
2017-12-01 11:42:49 +08:00
endforeach()
2017-05-08 18:03:43 +08:00
2019-07-28 20:55:37 +08:00
if(MSVC AND SDL2_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND)
2019-07-26 22:56:17 +08:00
set_target_properties(test_player PROPERTIES LINK_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS" )
2019-07-28 20:55:37 +08:00
endif()
2017-05-08 18:03:43 +08:00