用cmake编译gtk程序:gupnp-media-server

转载时请注明出处和作者联系方式:http://blog.csdn.net/mimepp
作者联系方式:YU TAO <yut616 at sohu dot com>

用cmake编译gtk程序:gupnp-media-server

用cmake来编译gupnp的media server,这里做个笔记。

可以参考本人的另外一篇blog:
http://blog.csdn.net/mimepp/archive/2008/06/01/2501081.aspx

1、获得gupnp代码
svn co http://svn.o-hand.com/repos/gupnp/trunk gupnp_svn

2、编写CMakeList.txt
在gupnp_svn目录下建立CMakeList.txt文件

project (GMS)

set (TOP_DIR "")

include (UsePkgConfig)

PKGCONFIG (gtk+-2.0 NOT_USED NOT_USED GTK2_LINK_FLAGS GTK2_INCLUDES)
PKGCONFIG (libglade-2.0 NOT_USED NOT_USED GLADE2_LINK_FLAGS GLADE2_INCLUDES)
PKGCONFIG (libsoup-2.4 NOT_USED NOT_USED SOUP2_4_LINK_FLAGS SOUP2_4_INCLUDES)
PKGCONFIG (dbus-glib-1 NOT_USED NOT_USED DBUS_GLIB_LINK_FLAGS DBUS_GLIB_INCLUDES)
PKGCONFIG (gconf-2.0 NOT_USED NOT_USED GCONF2_LINK_FLAGS GCONF2_INCLUDES)
PKGCONFIG (uuid NOT_USED NOT_USED UUID_LINK_FLAGS UUID_INCLUDES)

string (REGEX REPLACE "-I" "" BUILD_INCLUDES_STRING "${GTK2_INCLUDES} ${GLADE2_INCLUDES} ${SOUP2_4_INCLUDES} ${DBUS_GLIB_INCLUDES} ${GCONF2_INCLUDES} ${UUID_INCLUDES}")
SEPARATE_ARGUMENTS(BUILD_INCLUDES_STRING)

string (REGEX REPLACE "-l" "" BUILD_LINK_STRING "${GTK2_LINK_FLAGS} ${GLADE2_LINK_FLAGS} ${SOUP2_4_LINK_FLAGS} ${DBUS_GLIB_LINK_FLAGS} ${GCONF2_LINK_FLAGS} ${UUID_LINK_FLAGS}")
SEPARATE_ARGUMENTS(BUILD_LINK_STRING)

#message (STATUS "/ninclude string: /n" ${BUILD_INCLUDES_STRING} "/nlink string: /n" ${BUILD_LINK_STRING})

# libgssdp
set (GSSDP_DIR ${TOP_DIR}gssdp)
set (GSSDP_LIB_DIR ${TOP_DIR}gssdp/libgssdp)
set (GSSDP_LIB gssdp)

include_directories (${BUILD_INCLUDES_STRING} ${GSSDP_DIR})
aux_source_directory (${GSSDP_LIB_DIR} GSSDP_LIB_FILE)
add_library (${GSSDP_LIB} SHARED ${GSSDP_LIB_FILE})

# libgupnp
set (GUPNP_DIR ${TOP_DIR}gupnp)
set (GUPNP_LIB_DIR ${TOP_DIR}gupnp/libgupnp)
set (GUPNP_LIB gupnp)

include_directories (${BUILD_INCLUDES_STRING} ${GUPNP_DIR})
aux_source_directory (${GUPNP_LIB_DIR} GUPNP_LIB_FILE)
add_library (${GUPNP_LIB} SHARED ${GUPNP_LIB_FILE})

# libgupnp-av
set (GUPNP_AV_DIR ${TOP_DIR}gupnp-av)
set (GUPNP_AV_LIB_DIR ${TOP_DIR}gupnp-av/libgupnp-av)
set (GUPNP_AV_LIB gupnp-av)

include_directories (${BUILD_INCLUDES_STRING} ${GUPNP_AV_DIR})
aux_source_directory (${GUPNP_AV_LIB_DIR} GUPNP_AV_LIB_FILE)
add_library (${GUPNP_AV_LIB} SHARED ${GUPNP_AV_LIB_FILE})

# gms
set (GMS_DIR ${TOP_DIR}gupnp-media-server/src)
set (GMS_BIN gupnp-media-server)

add_definitions (-DDATA_DIR='"${GMS_BIN}"')
aux_source_directory (${GMS_DIR} GMS_FILE)
message (${GMS_FILE})
add_executable (${GMS_BIN} ${GMS_FILE})
target_link_libraries (${GMS_BIN} ${GSSDP_LIB} ${GUPNP_LIB} ${GUPNP_AV_LIB} ${BUILD_LINK_STRING})

3、建立编译目录
gupnp_svn#mkdir build

4、编译
gupnp_svn#cd build
gupnp_svn#cmake ../
gupnp_svn#make

5、运行

gupnp_svn# cd build/
gupnp_svn/build# mkdir run
gupnp_svn/build# cd run/
gupnp_svn/build/run# mkdir -p gupnp-media-server/xml/
gupnp_svn/build/run# cp ../../gupnp_svn/gupnp-media-server/data/xml/description.xml gupnp-media-server/xml/
gupnp_svn/build/run# ../gupnp-media-server

** (process:12155): WARNING **: Failed to get SCPD: Not Found
The initial event message will not be sent.

** (process:12155): WARNING **: Error autoconnecting signals: Not Found

** (process:12155): WARNING **: Failed to get SCPD: Not Found
The initial event message will not be sent.

** (process:12155): WARNING **: Error autoconnecting signals: Not Found

你可能感兴趣的:(用cmake编译gtk程序:gupnp-media-server)