summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Bentele2020-11-23 07:52:28 +0100
committerManuel Bentele2020-11-23 07:52:28 +0100
commit1baa63afc6f321e27fbeab81e31965432fb5bc2d (patch)
tree1267a9adcef02e69d452ff1f3c5df61131dd6bc3
parent[BUILD] add CMake find package search to find 'libatomic' automatically (diff)
downloaddnbd3-1baa63afc6f321e27fbeab81e31965432fb5bc2d.tar.gz
dnbd3-1baa63afc6f321e27fbeab81e31965432fb5bc2d.tar.xz
dnbd3-1baa63afc6f321e27fbeab81e31965432fb5bc2d.zip
[BUILD] update search paths for 'libatomic' to support build on FreeBSD
-rw-r--r--README.md5
-rw-r--r--cmake/FindLibatomic.cmake7
-rw-r--r--src/server/CMakeLists.txt2
3 files changed, 11 insertions, 3 deletions
diff --git a/README.md b/README.md
index 954fbe9..8e7e1df 100644
--- a/README.md
+++ b/README.md
@@ -97,6 +97,7 @@ Note that `afl` is not available on CentOS 8 and should be built from the [origi
```shell
pkg install git \
cmake \
+ gcc \
pkgconf \
fusefs-libs \
jansson \
@@ -138,6 +139,10 @@ A value from the range of appropriate values can be assigend to each configurati
cmake -D<VARIABLE>=<VALUE> [-D ...] ../.
```
+> **Note that the default compiler on FreeBSD 12.1 is clang/llvm and should be changed to gcc by appending the set CMake compiler configuration variable -DCMAKE_C_COMPILER=gcc to the CMake configuration command.**
+
+
+### Cross-Compiling
With the help of CMake, it is also possible to cross-compile the dnbd3 components for a Linux target architecture other than the compiling Linux host architecture. This repository is shipped with two CMake toolchain files to cross-compile all components for the following two Linux target architectures if necessary.
> **Note that all used header files (eg. Linux kernel headers) and libraries (eg. jansson, fuse) for the target architecture are installed and set up properly, so that the cross-compiler can find and use them.**
diff --git a/cmake/FindLibatomic.cmake b/cmake/FindLibatomic.cmake
index f827eae..4f7dea2 100644
--- a/cmake/FindLibatomic.cmake
+++ b/cmake/FindLibatomic.cmake
@@ -13,15 +13,18 @@ set(Libatomic_VERSION ${PKG_Libatomic_VERSION})
find_path(Libatomic_INCLUDE_DIR
NAMES stdatomic.h
- HINTS ${PKG_Libatomic_INCLUDE_DIRS})
+ HINTS ${CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES}
+ ${PKG_Libatomic_INCLUDE_DIRS})
find_library(Libatomic_LIBRARY
NAMES atomic
- HINTS ${PKG_Libatomic_LIBRARY_DIRS})
+ HINTS ${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}
+ ${PKG_Libatomic_LIBRARY_DIRS})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libatomic
FOUND_VAR Libatomic_FOUND
REQUIRED_VARS Libatomic_LIBRARY
+ Libatomic_INCLUDE_DIR
VERSION_VAR Libatomic_VERSION
FAIL_MESSAGE "Library 'atomic' is not available! Please install this required library!")
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index c56cc9f..a5bd660 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -58,7 +58,7 @@ add_executable(dnbd3-server ${CMAKE_CURRENT_SOURCE_DIR}/altservers.c
${CMAKE_CURRENT_SOURCE_DIR}/uplink.c
${CMAKE_CURRENT_SOURCE_DIR}/urldecode.c)
target_include_directories(dnbd3-server PRIVATE ${JANSSON_INCLUDE_DIR})
-target_link_libraries(dnbd3-server dnbd3-version dnbd3-build dnbd3-shared atomic ${CMAKE_THREAD_LIBS_INIT} ${JANSSON_LIBRARIES})
+target_link_libraries(dnbd3-server dnbd3-version dnbd3-build dnbd3-shared Libatomic::Libatomic ${CMAKE_THREAD_LIBS_INIT} ${JANSSON_LIBRARIES})
if(DNBD3_SERVER_FUSE)
find_package(Fuse REQUIRED)