2 Star 1 Fork 0

漆夜/flexible-network

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 2.39 KB
一键复制 编辑 原始数据 按行查看 历史
周于双 提交于 2022-03-10 17:39 . 功能修改
cmake_minimum_required(VERSION 2.8)
project(flexible-network)
set(CMAKE_CXX_STANDARD 11)
option(debug "build debug version" OFF)
option(build_static "build static library/application." OFF)
if (UNIX)
set(CMAKE_C_FLAGS "-fPIC -Wall -pthread")
set(CMAKE_CXX_FLAGS "-fPIC -Wall -pthread -Wno-unused")
if (debug)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb2")
else()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
endif()
message(STATUS "${PROJECT_NAME}-CFLAGS: ${CMAKE_C_FLAGS}")
message(STATUS "${PROJECT_NAME}-CXXFLAGS: ${CMAKE_CXX_FLAGS}")
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
INCLUDE_DIRECTORIES(/usr/local/include)
LINK_LIBRARIES(/usr/local/lib)
endif()
INCLUDE_DIRECTORIES(.)
if (NOT build_static)
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
find_package(Boost COMPONENTS system filesystem regex thread)
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
else()
find_package(Boost 1.67 COMPONENTS system filesystem regex thread)
endif()
else()
set(Boost_LIBRARIES libboost_system.a libboost_filesystem.a libboost_regex.a libboost_thread.a)
endif()
set (TRANSPORT "transport/BaseTransport.cpp" "transport/TcpTransport.cpp")
if (UNIX)
set (TRANSPORT ${TRANSPORT} "transport/UnixSocketTransport.cpp")
endif()
#aux_source_directory(transport TRANSPORT)
aux_source_directory(protocol PROTOCOL)
aux_source_directory(factory FACTORY)
aux_source_directory(listener LISTENER)
add_executable(${PROJECT_NAME}-client "main.cpp" ${TRANSPORT} ${PROTOCOL} ${FACTORY} ${LISTENER})
if (build_static)
add_library(${PROJECT_NAME} STATIC ${TRANSPORT} ${PROTOCOL} ${FACTORY} ${LISTENER})
else()
add_library(${PROJECT_NAME} SHARED ${TRANSPORT} ${PROTOCOL} ${FACTORY} ${LISTENER})
endif()
if (UNIX)
if (APPLE)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} pthread)
else (APPLE)
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES} pthread rt)
endif(APPLE)
else()
target_link_libraries(${PROJECT_NAME} ${Boost_LIBRARIES})
endif(UNIX)
# using compiled library.
target_link_libraries(${PROJECT_NAME}-client ${PROJECT_NAME})
SET(LIBRARY_OUTPUT_PATH lib)
if (NOT build_static)
install(TARGETS ${PROJECT_NAME} LIBRARY DESTINATION lib)
endif()
install(TARGETS ${PROJECT_NAME}-client RUNTIME DESTINATION .)
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/www.evangerlion.com/flexible-network.git
git@gitee.com:www.evangerlion.com/flexible-network.git
www.evangerlion.com
flexible-network
flexible-network
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385