live555编译:增加CMake支持

  最近研究live555,看了网上的编译方法太过麻烦,所以自己给它增加了CMake构建工程的方法,以方便大家参考学习。大家可以按照以下步骤来做,或者直接从github下载我上传的版本https://github.com/JeroZeng/live555

  1. 下载安装cmake:http://www.cmake.org
  2. 下载源码:http://www.live555.com/liveMedia/public/
  3. 下载好源码后解压得到一个live文件夹,里面包含所有的源码,在live文件夹下创建CMakeLists.txt文件,并将以下内容复制到CMakeLists.txt文件

  CMakeLists.txt内容如下: 

cmake_minimum_required(VERSION 2.8)

project(live555)

include_directories(${CMAKE_SOURCE_DIR}/BasicUsageEnvironment/include)
include_directories(${CMAKE_SOURCE_DIR}/groupsock/include)
include_directories(${CMAKE_SOURCE_DIR}/liveMedia/include)
include_directories(${CMAKE_SOURCE_DIR}/UsageEnvironment/include)

if(MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
endif()

file(GLOB BasicUsageEnvironmentFiles
	BasicUsageEnvironment/*.cpp)
add_library(BasicUsageEnvironment
			${BasicUsageEnvironmentFiles})
			
file(GLOB groupsockfiles
	groupsock/*.cpp groupsock/*.c)
add_library(groupsock ${groupsockfiles})

file(GLOB liveMediaFiles
		liveMedia/*.hh liveMedia/*.cpp liveMedia/*.c)	
add_library(liveMedia ${liveMediaFiles})

file(GLOB UsageEnvironmentFiles 
    UsageEnvironment/*.cpp)
add_library(UsageEnvironment ${UsageEnvironmentFiles})

file(GLOB mediaServerFiles
	mediaServer/*.hh mediaServer/*.cpp)
add_executable(mediaServer ${mediaServerFiles})
if(MSVC)
	target_link_libraries(mediaServer ws2_32.lib)
endif()
target_link_libraries(mediaServer  
			BasicUsageEnvironment groupsock
			UsageEnvironment liveMedia)

  4. 在live目录下新建一个build文件夹

    a. 如果是windows用户,在build目录下新建一个批处理文件make-solutions.bat,用记事本打开make-solutions.bat文件,根据vs版本在里面添加以下内容

      vs2013:cmake -G "Visual Studio 12" .. && cmake-gui ..

      vs2012:cmake -G "Visual Studio 11" .. && cmake-gui ..

      vs2010:cmake -G "Visual Studio 10" .. && cmake-gui ..

      vs2008:cmake -G "Visual Studio 9 2008" .. && cmake-gui ..

      然后双击.bat文件就能生成vs版本工程

    b: 如果是linux用户,在build目录下运行:cmake -G "Unix Makefiles" ..  即可生成makefile文件

posted on 2015-09-05 17:58  JeroZeng  阅读(1702)  评论(0编辑  收藏  举报