]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | # |
2 | # This file is open source software, licensed to you under the terms | |
3 | # of the Apache License, Version 2.0 (the "License"). See the NOTICE file | |
4 | # distributed with this work for additional information regarding copyright | |
5 | # ownership. You may not use this file except in compliance with the License. | |
6 | # | |
7 | # You may obtain a copy of the License at | |
8 | # | |
9 | # http://www.apache.org/licenses/LICENSE-2.0 | |
10 | # | |
11 | # Unless required by applicable law or agreed to in writing, | |
12 | # software distributed under the License is distributed on an | |
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | |
14 | # KIND, either express or implied. See the License for the | |
15 | # specific language governing permissions and limitations | |
16 | # under the License. | |
17 | # | |
18 | ||
19 | # | |
20 | # Copyright (C) 2022 ScyllaDB | |
21 | # | |
22 | ||
23 | find_package (PkgConfig REQUIRED) | |
24 | ||
25 | pkg_check_modules (PC_URING QUIET liburing) | |
26 | ||
27 | find_library (URING_LIBRARY | |
28 | NAMES uring | |
29 | HINTS | |
30 | ${PC_URING_LIBDIR} | |
31 | ${PC_URING_LIBRARY_DIRS}) | |
32 | ||
33 | find_path (URING_INCLUDE_DIR | |
34 | NAMES liburing.h | |
35 | HINTS | |
36 | ${PC_URING_INCLUDEDIR} | |
37 | ${PC_URING_INCLUDE_DIRS}) | |
38 | ||
39 | if (URING_INCLUDE_DIR) | |
40 | include (CheckStructHasMember) | |
41 | include (CMakePushCheckState) | |
42 | cmake_push_check_state (RESET) | |
43 | list(APPEND CMAKE_REQUIRED_INCLUDES ${URING_INCLUDE_DIR}) | |
44 | CHECK_STRUCT_HAS_MEMBER ("struct io_uring" features liburing.h | |
45 | HAVE_IOURING_FEATURES LANGUAGE CXX) | |
46 | cmake_pop_check_state () | |
47 | endif () | |
48 | ||
49 | mark_as_advanced ( | |
50 | URING_LIBRARY | |
51 | URING_INCLUDE_DIR | |
52 | HAVE_IOURING_FEATURES) | |
53 | ||
54 | include (FindPackageHandleStandardArgs) | |
55 | ||
56 | find_package_handle_standard_args (LibUring | |
57 | REQUIRED_VARS | |
58 | URING_LIBRARY | |
59 | URING_INCLUDE_DIR | |
60 | HAVE_IOURING_FEATURES | |
61 | VERSION_VAR PC_URING_VERSION) | |
62 | ||
63 | if (LibUring_FOUND) | |
64 | set (URING_LIBRARIES ${URING_LIBRARY}) | |
65 | set (URING_INCLUDE_DIRS ${URING_INCLUDE_DIR}) | |
66 | if (NOT (TARGET URING::uring)) | |
67 | add_library (URING::uring UNKNOWN IMPORTED) | |
68 | ||
69 | set_target_properties (URING::uring | |
70 | PROPERTIES | |
71 | IMPORTED_LOCATION ${URING_LIBRARY} | |
72 | INTERFACE_INCLUDE_DIRECTORIES ${URING_INCLUDE_DIRS}) | |
73 | endif () | |
74 | endif () |