-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
80 lines (69 loc) · 2.44 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
cmake_minimum_required(VERSION 3.15.0)
project(shuio VERSION 0.1.0 LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT DEFINED CMAKE_BUILD_TYPE)
# 如果没有设置 CMAKE_BUILD_TYPE,则默认设置为 Release
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE}/)
include(CTest)
enable_testing()
add_library(shuio STATIC "")
target_include_directories(shuio PUBLIC ${CMAKE_SOURCE_DIR})
if(WIN32)
target_compile_options(shuio PUBLIC /wd4819)
target_sources(shuio PRIVATE
shuio/shuio.h
shuio/shu_stream.h
shuio/shu_socket.h
shuio/shu_loop.h
shuio/shu_common.h
shuio/shu_client.h
shuio/shu_buffer.h
shuio/shu_acceptor.h
shuio/win32/shu_acceptor.cpp
shuio/win32/shu_common.cpp
shuio/win32/win32_detail.cpp
shuio/win32/shu_socket.cpp
shuio/win32/shu_client.cpp
shuio/win32/shu_stream.cpp
shuio/win32/shu_loop.cpp
shuio/win32/shu_buffer.cpp
)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
endif()
else()
target_link_libraries(shuio PUBLIC uring)
target_sources(shuio PRIVATE
shuio/shuio.h
shuio/shu_stream.h
shuio/shu_socket.h
shuio/shu_loop.h
shuio/shu_common.h
shuio/shu_client.h
shuio/shu_buffer.h
shuio/shu_acceptor.h
shuio/linux/shu_acceptor.cpp
shuio/linux/shu_common.cpp
shuio/linux/linux_detail.cpp
shuio/linux/shu_socket.cpp
shuio/linux/shu_client.cpp
shuio/linux/shu_stream.cpp
shuio/linux/shu_loop.cpp
shuio/linux/shu_buffer.cpp
)
if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
elseif("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -g")
endif()
endif(WIN32)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
include(CPack)
add_subdirectory(example)