Commit d619296f by xiongziliang

精简

parent a4233bde
......@@ -21,13 +21,15 @@ foreach(SUB_DIR ${SUB_DIR_LIST})
execute_process(COMMAND cp ${HEADER_FILES} ${PROJECT_BINARY_DIR}/include/${CMAKE_PROJECT_NAME}/${SUB_DIR}/ )
endforeach(SUB_DIR ${SUB_DIR_LIST})
set(LINK_LIB_LIST)
#查找openssl是否安装
find_package(OPENSSL QUIET)
find_package(OpenSSL QUIET)
if(OPENSSL_FOUND)
message(STATUS "找到openssl库:\"${OPENSSL_INCLUDE_DIR}\",ENABLE_OPENSSL宏已打开")
include_directories(${OPENSSL_INCLUDE_DIR})
add_definitions(-DENABLE_OPENSSL)
list(APPEND LINK_LIB_LIST ${OPENSSL_LIBRARIES})
endif(OPENSSL_FOUND)
#查找mysql是否安装
......@@ -36,6 +38,7 @@ if(MYSQL_FOUND)
message(STATUS "找到mysqlclient库:\"${MYSQL_INCLUDE_DIR}\",ENABLE_MYSQL宏已打开")
include_directories(${MYSQL_INCLUDE_DIR})
add_definitions(-DENABLE_MYSQL)
list(APPEND LINK_LIB_LIST ${MYSQL_LIBRARIES})
endif(MYSQL_FOUND)
......@@ -45,14 +48,16 @@ if(MP4V2_FOUND)
message(STATUS "找到mp4v2库:\"${MP4V2_INCLUDE_DIR}\",ENABLE_MP4V2宏已打开")
include_directories(${MP4V2_INCLUDE_DIR})
add_definitions(-DENABLE_MP4V2)
list(APPEND LINK_LIB_LIST ${MP4V2_LIBRARIES})
endif(MP4V2_FOUND)
#查找x264是否安装
find_package(X264 QUIET)
if(X264_FOUND)
message(STATUS "找到x264库:\"${X264_INCLUDE_DIRS}\",ENABLE_X264宏已打开")
message(STATUS "找到x264库:\"${X264_INCLUDE_DIR}\",ENABLE_X264宏已打开")
include_directories(${X264_INCLUDE_DIRS})
add_definitions(-DENABLE_X264)
list(APPEND LINK_LIB_LIST ${X264_LIBRARIES})
endif(X264_FOUND)
#查找faac是否安装
......@@ -61,6 +66,7 @@ if(FAAC_FOUND)
message(STATUS "找到faac库:\"${FAAC_INCLUDE_DIR}\",ENABLE_FAAC宏已打开")
include_directories(${FAAC_INCLUDE_DIR})
add_definitions(-DENABLE_FAAC)
list(APPEND LINK_LIB_LIST ${FAAC_LIBRARIES})
endif(FAAC_FOUND)
#查找ZLToolKit是否安装
......@@ -68,9 +74,11 @@ find_package(ZLTOOLKIT QUIET)
if(ZLTOOLKIT_FOUND)
message(STATUS "找到ZLToolKit库:\"${ZLTOOLKIT_INCLUDE_DIR}\"")
include_directories(${ZLTOOLKIT_INCLUDE_DIR}/ZLToolKit)
list(APPEND LINK_LIB_LIST ${ZLTOOLKIT_LIBRARIES})
endif(ZLTOOLKIT_FOUND)
#打印库文件
message(STATUS "将链接依赖库:${LINK_LIB_LIST}")
#开启RTSP/RTMP之间的互相转换,开启HLS
add_definitions(-DENABLE_RTMP2RTSP -DENABLE_RTSP2RTMP -DENABLE_HLS)
......@@ -90,37 +98,7 @@ if(NOT IOS)
add_library(${CMAKE_PROJECT_NAME}_shared SHARED ${SRC_LIST})
set_target_properties(${CMAKE_PROJECT_NAME}_shared PROPERTIES OUTPUT_NAME "${CMAKE_PROJECT_NAME}")
install(TARGETS ${CMAKE_PROJECT_NAME}_shared LIBRARY DESTINATION lib)
#查找mp4v2是否安装
if(MP4V2_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${MP4V2_LIBRARY})
endif(MP4V2_FOUND)
#查找x264是否安装
if(X264_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${X264_LIBRARIES})
endif(X264_FOUND)
#查找faac是否安装
if(FAAC_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${FAAC_LIBRARY})
endif(FAAC_FOUND)
#查找ZLToolKit是否安装
if(ZLTOOLKIT_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${ZLTOOLKIT_LIBRARY})
endif(ZLTOOLKIT_FOUND)
#查找openssl是否安装
if(OPENSSL_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${OPENSSL_LIBRARYS})
endif(OPENSSL_FOUND)
#查找mysql是否安装
if(MYSQL_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${MYSQL_LIBRARYS})
endif(MYSQL_FOUND)
target_link_libraries(${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST})
endif(NOT IOS)
#编译静态库
......
......@@ -9,7 +9,7 @@ find_library(FAAC_LIBRARY
)
set(FAAC_INCLUDE_DIRS ${FAAC_INCLUDE_DIR})
set(MP4V2_LIBRARIES ${FAAC_LIBRARY})
set(FAAC_LIBRARIES ${FAAC_LIBRARY})
include(FindPackageHandleStandardArgs)
......
......@@ -2,6 +2,7 @@
find_package(SDL QUIET)
if(SDL_FOUND)
include_directories(${SDL_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${SDL_LIBRARY})
message(STATUS "找到SDL")
endif(SDL_FOUND)
......@@ -9,6 +10,7 @@ endif(SDL_FOUND)
find_package(AVUTIL QUIET)
if(AVUTIL_FOUND)
include_directories(${AVUTIL_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${AVUTIL_LIBRARIES})
message(STATUS "找到libutil")
endif(AVUTIL_FOUND)
......@@ -16,12 +18,11 @@ endif(AVUTIL_FOUND)
find_package(AVCODEC QUIET)
if(AVCODEC_FOUND)
include_directories(${AVCODEC_INCLUDE_DIR})
list(APPEND LINK_LIB_LIST ${AVCODEC_LIBRARIES})
message(STATUS "找到libavcodec")
endif(AVCODEC_FOUND)
aux_source_directory(. TEST_SRC_LIST)
#如果ffmpeg/libavcodec ffmpeg/libavcodec SDL 都安装了则编译 test_player
if(SDL_FOUND AND AVCODEC_FOUND AND AVUTIL_FOUND)
message(STATUS "test_player被编译")
......@@ -35,43 +36,7 @@ STRING(REGEX REPLACE ".cpp" "" TEST_EXE_NAME ${TEST_SRC})
STRING(REGEX REPLACE "./" "" TEST_EXE_NAME ${TEST_EXE_NAME})
message(STATUS "add test program:${TEST_EXE_NAME}")
add_executable(${TEST_EXE_NAME} ${TEST_SRC})
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared pthread)
#查找mp4v2是否安装
if(MP4V2_FOUND)
target_link_libraries(${TEST_EXE_NAME} ${MP4V2_LIBRARY})
endif(MP4V2_FOUND)
#查找x264是否安装
if(X264_FOUND)
target_link_libraries(${TEST_EXE_NAME} ${X264_LIBRARIES})
endif(X264_FOUND)
#查找faac是否安装
if(FAAC_FOUND)
target_link_libraries(${TEST_EXE_NAME} ${FAAC_LIBRARY})
endif(FAAC_FOUND)
#查找ZLToolKit是否安装
if(ZLTOOLKIT_FOUND)
target_link_libraries(${TEST_EXE_NAME} ${ZLTOOLKIT_LIBRARY})
endif(ZLTOOLKIT_FOUND)
#查找openssl是否安装
if(OPENSSL_FOUND)
target_link_libraries(${TEST_EXE_NAME} ${OPENSSL_LIBRARYS})
endif(OPENSSL_FOUND)
#查找mysql是否安装
if(MYSQL_FOUND)
target_link_libraries(${TEST_EXE_NAME} ${MYSQL_LIBRARYS})
endif(MYSQL_FOUND)
#link test_player
if(TEST_EXE_NAME STREQUAL test_player)
target_link_libraries(${TEST_EXE_NAME} ${SDL_LIBRARY} ${AVCODEC_LIBRARIES} ${AVUTIL_LIBRARIES})
endif(TEST_EXE_NAME STREQUAL test_player)
target_link_libraries(${TEST_EXE_NAME} ${CMAKE_PROJECT_NAME}_shared ${LINK_LIB_LIST} pthread)
endforeach(TEST_SRC ${TEST_SRC_LIST})
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论