1
1
#
2
2
# Cmake configuration file for liblcb.
3
3
# Just add: include(liblcb/CMakeLists.txt) in CMakeLists.txt to use this lib.
4
+ # To enable tests: -DENABLE_LIBLCB_TESTS=1
4
5
#
5
6
6
7
############################# INITIAL SECTION ##########################
7
- cmake_minimum_required (VERSION 3.10 )
8
+ cmake_minimum_required (VERSION 3.20 )
8
9
9
10
############################# OPTIONS SECTION ##########################
10
11
@@ -13,8 +14,20 @@ cmake_minimum_required(VERSION 3.10)
13
14
include (CheckIncludeFiles)
14
15
include (CheckFunctionExists)
15
16
include (CheckSymbolExists)
17
+ include (CheckCCompilerFlag)
18
+
19
+ find_library (PTHREAD_LIBRARY pthread)
20
+ list (APPEND CMAKE_REQUIRED_LIBRARIES ${PTHREAD_LIBRARY} )
16
21
17
22
############################# MACRO SECTION ############################
23
+ macro (try_c_flag prop flag)
24
+ # Try flag once on the C compiler
25
+ check_c_compiler_flag("-Werror ${flag} " C_FLAG_${prop} )
26
+ if (C_FLAG_${prop} )
27
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${flag} " )
28
+ endif ()
29
+ endmacro ()
30
+
18
31
macro (chk_include_files incfile prop)
19
32
string (TOUPPER HAVE_${prop} __tmp)
20
33
check_include_files(${incfile} ${__tmp} )
@@ -49,15 +62,17 @@ message(STATUS "liblcb configuring...")
49
62
# Platform specific configuration.
50
63
if (CMAKE_SYSTEM_NAME MATCHES "^.*BSD$|DragonFly" )
51
64
add_definitions (-D_BSD_SOURCE -DFREEBSD)
52
- include_directories ("/usr/local/include/ " )
65
+ include_directories ("/usr/local/include" )
53
66
endif ()
54
67
55
68
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" )
56
69
add_definitions (-D_BSD_SOURCE -DDARWIN)
70
+ include_directories ("/usr/local/include" )
57
71
endif ()
58
72
if (APPLE )
59
73
# For IPV6_PKTINFO.
60
74
add_definitions (-D__APPLE_USE_RFC_3542)
75
+ include_directories ("/usr/local/include" )
61
76
endif ()
62
77
63
78
@@ -93,13 +108,18 @@ chk_symbol_exists(sys/socket.h SOCK_CLOEXEC)
93
108
chk_symbol_exists(sys/socket.h SOCK_NONBLOCK)
94
109
95
110
# Disable some warnings.
96
- try_c_flag(W_NO_UNUSED_RESULT "-Wno-unused-result" )
111
+ try_c_flag(WSWITCHDEFAULT "-Wno-switch-default" )
112
+ try_c_flag(WUNUSED_RESULT "-Wno-unused-result" )
113
+ try_c_flag(WUNSAFE_BUFFER_USAGE "-Wno-unsafe-buffer-usage" )
97
114
98
115
99
116
message (STATUS "liblcb configuring done!" )
100
117
101
118
################################ SUBDIRS SECTION #######################
102
119
120
+ if (ENABLE_LIBLCB_TESTS)
121
+ add_subdirectory ("${CMAKE_CURRENT_LIST_DIR} /tests" )
122
+ endif ()
103
123
104
124
############################ TARGETS SECTION ###########################
105
125
0 commit comments