This commit is contained in:
xiongziliang 2017-05-11 22:10:12 +08:00
parent a4233bdeb8
commit d619296fe5
3 changed files with 17 additions and 74 deletions

View File

@ -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)
#

View File

@ -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)

View File

@ -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})