-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
executable file
·57 lines (43 loc) · 1.67 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
# CMakeList.txt: CppNet 的 CMake 项目,在此处包括源代码并定义
# 项目特定的逻辑。
#
cmake_minimum_required (VERSION 3.8)
project ("CppNet")
set (CMAKE_CXX_COMPILER "clang++")
set (CMAKE_CXX_STANDARD 11)
IF(CMAKE_BUILD_TYPE MATCHES Debug)
message("Debug build.")
set (CMAKE_BUILD_TYPE Debug)
set (CMAKE_CXX_FLAGS_DEBUG "-W -g")
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
set (CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")
ELSEIF(CMAKE_BUILD_TYPE MATCHES Release)
message("Release build.")
set (CMAKE_CXX_FLAGS_RELEASE)
ELSE()
message("Some other build type.")
ENDIF()
find_package(Threads)
include_directories(include)
file(GLOB SRC_LIST "src/*")
file(GLOB INC_LIST "include/*")
macro(target_public_headers TARGET)
set_target_properties(${TARGET} PROPERTIES PUBLIC_HEADER "${ARGN}")
endmacro()
add_library(cppnet ${SRC_LIST})
target_link_libraries(cppnet ${CMAKE_THREAD_LIBS_INIT})
target_public_headers(cppnet ${INC_LIST})
add_library(cppnet_shared SHARED ${SRC_LIST})
target_link_libraries(cppnet_shared ${CMAKE_THREAD_LIBS_INIT})
target_public_headers(cppnet_shared ${INC_LIST})
INSTALL(TARGETS cppnet
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
INSTALL(TARGETS cppnet_shared
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include
)
add_subdirectory(samples)
# TODO: 如有需要,请添加测试并安装目标。