summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2021-06-16 11:33:31 +0200
committerManuel Bentele2021-06-16 11:41:16 +0200
commita04431a3125de160ca082b27ee31fa1e1037cea9 (patch)
tree4abb8f32d467f85702866ff5d5f457b7e5009a37
parent[KERNEL] Add support for Linux kernels without blk-mq (e.g. CentOS 7) (diff)
downloaddnbd3-a04431a3125de160ca082b27ee31fa1e1037cea9.tar.gz
dnbd3-a04431a3125de160ca082b27ee31fa1e1037cea9.tar.xz
dnbd3-a04431a3125de160ca082b27ee31fa1e1037cea9.zip
[BUILD] Add check for stdatomic.h support
-rw-r--r--cmake/FindStdatomic.cmake14
-rw-r--r--src/fuse/CMakeLists.txt4
-rw-r--r--src/server/CMakeLists.txt1
-rw-r--r--src/shared/CMakeLists.txt4
4 files changed, 23 insertions, 0 deletions
diff --git a/cmake/FindStdatomic.cmake b/cmake/FindStdatomic.cmake
new file mode 100644
index 0000000..d7ee9b8
--- /dev/null
+++ b/cmake/FindStdatomic.cmake
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (C) 2021 Manuel Bentele <development@manuel-bentele.de>
+#
+
+find_file(Stdatomic_INCLUDE_FILE
+ NAMES stdatomic.h
+ HINTS ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES})
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Stdatomic
+ FOUND_VAR Stdatomic_FOUND
+ REQUIRED_VARS Stdatomic_INCLUDE_FILE
+ FAIL_MESSAGE "Compiler does not support atomic operations!")
diff --git a/src/fuse/CMakeLists.txt b/src/fuse/CMakeLists.txt
index e4c8de9..be062f0 100644
--- a/src/fuse/CMakeLists.txt
+++ b/src/fuse/CMakeLists.txt
@@ -6,6 +6,10 @@ project(dnbd3-fuse
find_package(Fuse REQUIRED)
+# find atomic library required by dnbd3-fuse
+find_package(Stdatomic REQUIRED)
+find_package(Libatomic REQUIRED)
+
# add compile option to enable enhanced POSIX pthread features
add_definitions(-D_GNU_SOURCE)
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index 1db5f06..9a1e1c4 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -11,6 +11,7 @@ if(NOT JANSSON_FOUND)
endif(NOT JANSSON_FOUND)
# find atomic library required by the dnbd3-server
+find_package(Stdatomic REQUIRED)
find_package(Libatomic REQUIRED)
# add compile option to enable enhanced POSIX features
diff --git a/src/shared/CMakeLists.txt b/src/shared/CMakeLists.txt
index b280b77..a1bd49a 100644
--- a/src/shared/CMakeLists.txt
+++ b/src/shared/CMakeLists.txt
@@ -4,6 +4,10 @@ cmake_minimum_required(VERSION 3.10)
project(dnbd3-shared
LANGUAGES C)
+# find atomic library required by dnbd3-shared
+find_package(Stdatomic REQUIRED)
+find_package(Libatomic REQUIRED)
+
# add compile option to get POLLRDHUP support for signals
add_definitions(-D_GNU_SOURCE)