CMakeLists.txt 1.68 KB
Newer Older
1
execute_process(COMMAND cp ${CMAKE_CURRENT_SOURCE_DIR}/ssl.p12 ${EXECUTABLE_OUTPUT_PATH}/)
2 3

#查找SDL2是否安装
xiongziliang committed
4 5 6 7
find_package(SDL2 QUIET)
if (SDL2_FOUND)
    include_directories(${SDL2_INCLUDE_DIR})
    list(APPEND LINK_LIB_LIST ${SDL2_LIBRARY})
8
    message(STATUS "found library:${SDL2_LIBRARY}")
xiongziliang committed
9
endif (SDL2_FOUND)
xzl committed
10 11 12 13

#查找ffmpeg/libutil是否安装
find_package(AVUTIL QUIET)
if(AVUTIL_FOUND)
14 15
    include_directories(${AVUTIL_INCLUDE_DIR})
    list(APPEND  LINK_LIB_LIST ${AVUTIL_LIBRARIES})
16
    message(STATUS "found library:${AVUTIL_LIBRARIES}")
17
endif()
xzl committed
18 19 20 21

#查找ffmpeg/libavcodec是否安装
find_package(AVCODEC QUIET)
if(AVCODEC_FOUND)
22 23
    include_directories(${AVCODEC_INCLUDE_DIR})
    list(APPEND  LINK_LIB_LIST ${AVCODEC_LIBRARIES})
24
    message(STATUS "found library:${AVCODEC_LIBRARIES}")
25
endif()
xzl committed
26

27
aux_source_directory(. TEST_SRC_LIST)
xzl committed
28
#如果ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译 test_player
xiongziliang committed
29
if(SDL2_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND)
30
else()
xiongziliang committed
31
    message(STATUS "test_player ingored, please install sdl2 ffmpeg/libavcodec ffmpeg/libavutil")
32
    list(REMOVE_ITEM TEST_SRC_LIST ./test_player.cpp)
33
endif()
34

35 36
foreach(TEST_SRC ${TEST_SRC_LIST})
    STRING(REGEX REPLACE "^\\./|\\.c[a-zA-Z0-9_]*$" "" TEST_EXE_NAME ${TEST_SRC})
37
    message(STATUS "add test:${TEST_EXE_NAME}")
38
    add_executable(${TEST_EXE_NAME} ${TEST_SRC})
39 40 41 42 43

	if(WIN32)
		set_target_properties(${TEST_EXE_NAME} PROPERTIES COMPILE_FLAGS ${VS_FALGS} )
	endif(WIN32)

xiongziliang committed
44
    target_link_libraries(${TEST_EXE_NAME} ${LINK_LIB_LIST})
45
endforeach()
xzl committed
46

xiongziliang committed
47
if(MSVC AND SDL2_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND)
48
    set_target_properties(test_player PROPERTIES LINK_FLAGS "/SAFESEH:NO /SUBSYSTEM:WINDOWS" )
xiongziliang committed
49
endif()
xzl committed
50 51 52 53 54 55 56 57 58 59 60 61