Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CMakeLists.txt example
cmake_minimum_required(VERSION 2.6)
project (foo)
#FXN_VERSION是为网友FXN定制的版本,增加了一些特殊功能,如果您不需要,可以去掉-DFXN_VERSION选项(默认不开启)
#-DFXN_VERSION
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -g -Wall -O0 -Wno-unused-variable -pthread")
link_directories(
${PROJECT_SOURCE_DIR}/lib
/usr/lib64/mysql/
)
find_library(MYSQL_LIB libmysqlclient.so /usr/lib64/mysql/)
set(net_srcs
base/Timestamp.cpp
)
set(database_srcs
database/DatabaseMysql.cpp
)
set(mysql_srcs
mysql/MysqlManager.cpp
)
set(json_srcs
jsoncpp-0.5.0/json_reader.cpp
)
set(zlib_srcs
zlib1.2.11/zutil.c
zlib1.2.11/uncompr.c
)
set(utils_srcs
utils/StringUtil.cpp
)
set(chatserver_srcs
chatserversrc/main.cpp
chatserversrc/BussinessLogic.cpp)
set(fileserver_srcs
fileserversrc/TcpSession.cpp)
set(imgserver_srcs
imgserversrc/main.cpp
fileserversrc/TcpSession.cpp)
add_executable(chatserver ${net_srcs} ${json_srcs} ${chatserver_srcs} ${mysql_srcs} ${database_srcs} ${zlib_srcs} ${utils_srcs})
#光包含库目录是没用的,还必须使用TARGET_LINK_LIBRARIES链接该库
TARGET_LINK_LIBRARIES(chatserver mysqlclient)
add_executable(fileserver ${net_srcs} ${fileserver_srcs} ${utils_srcs})
TARGET_LINK_LIBRARIES(fileserver)
add_executable(imgserver ${net_srcs} ${imgserver_srcs} ${utils_srcs})
TARGET_LINK_LIBRARIES(imgserver)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment