From 762cf43bb673ca65087a66d3961280e851a93655 Mon Sep 17 00:00:00 2001 From: Manuel Bentele Date: Fri, 30 Oct 2020 07:46:55 +0100 Subject: [BUILD] add build options to enable/disable build of dnbd3 components --- CMakeLists.txt | 9 +++++---- README.md | 5 ++++- src/CMakeLists.txt | 12 ++++++++++-- src/fuse/CMakeLists.txt | 2 ++ src/server/CMakeLists.txt | 1 + 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4dcbcef..6a9eda5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,11 +12,14 @@ project(dnbd3 # define project options to define build configuration OPTION(DNBD3_KERNEL_MODULE "Build the dnbd3 Linux kernel module" ON) +OPTION(DNBD3_CLIENT_FUSE "Enable build of dnbd3-fuse" ON) +OPTION(DNBD3_SERVER "Enable build of dnbd3-server" ON) OPTION(DNBD3_SERVER_FUSE "Enable FUSE-Integration for dnbd3-server" OFF) OPTION(DNBD3_SERVER_AFL "Build dnbd3-server for usage with afl-fuzz" OFF) OPTION(DNBD3_SERVER_DEBUG_LOCKS "Add lock debugging code to dnbd3-server" OFF) OPTION(DNBD3_SERVER_DEBUG_THREADS "Add thread debugging code to dnbd3-server" OFF) OPTION(DNBD3_RELEASE_HARDEN "Compile dnbd3 programs in Release build with code hardening options" OFF) +OPTION(DNBD3_PACKAGE_DOCKER "Enable packaging of Docker image" OFF) # set supported build configurations set(CMAKE_CONFIGURATION_TYPES Debug Release) @@ -30,8 +33,6 @@ endif(NOT CMAKE_BUILD_TYPE) # search for required packages find_package(Git REQUIRED) find_package(Threads REQUIRED) -find_package(Fuse REQUIRED) -find_package(Jansson REQUIRED) # include project version and build type related macros include(Version) @@ -193,7 +194,7 @@ if(CMAKE_BUILD_TYPE MATCHES Release) DEPENDS package_source_main) # include target to make docker image - if(NOT DNBD3_KERNEL_MODULE) + if(NOT DNBD3_KERNEL_MODULE AND DNBD3_PACKAGE_DOCKER) find_package(Docker REQUIRED) include(DockerImage) set(DOCKER_FILE ${CMAKE_SOURCE_DIR}/pkg/docker/Dockerfile) @@ -201,7 +202,7 @@ if(CMAKE_BUILD_TYPE MATCHES Release) set(PACKAGE_FILE ${CPACK_PACKAGE_NAME}_${REPOSITORY_VERSION_FULL}_${CMAKE_SYSTEM_PROCESSOR}.deb) set(DOCKER_IMAGE ${CPACK_PACKAGE_NAME}_${REPOSITORY_VERSION_FULL}_${CMAKE_SYSTEM_PROCESSOR}_ubuntu-20-04_docker.tar) add_docker_image(docker-ubuntu-20-04 ${DOCKER_IMAGE} ${DOCKER_FILE} ${DOCKER_TAG} ${PACKAGE_FILE} ${CMAKE_BINARY_DIR}) - endif(NOT DNBD3_KERNEL_MODULE) + endif(NOT DNBD3_KERNEL_MODULE AND DNBD3_PACKAGE_DOCKER) endif(CMAKE_BUILD_TYPE MATCHES Release) # add all dnbd3 related projects from the source code directory diff --git a/README.md b/README.md index c023371..da246f3 100644 --- a/README.md +++ b/README.md @@ -95,11 +95,14 @@ A build of the dnbd3 components can be configured and customized by the followin | `KERNEL_BUILD_DIR` | PATH | {`a` .. `z`, `A` .. `Z`, `/`, `_`, `-`} | /lib/modules/`uname -r`/build | Path to Linux kernel modules to compile against. | | `KERNEL_INSTALL_DIR` | PATH | {`a` .. `z`, `A` .. `Z`, `/`, `_`, `-`} | /lib/modules/`uname -r`/extra | Path to install Linux kernel modules. | | `DNBD3_KERNEL_MODULE` | OPTION | {`ON`, `OFF`} | `ON` | Build the dnbd3 Linux kernel module. | +| `DNBD3_CLIENT_FUSE` | OPTION | {`ON`, `OFF`} | `ON` | Enable build of dnbd3-fuse. | +| `DNBD3_SERVER` | OPTION | {`ON`, `OFF`} | `ON` | Enable build of dnbd3-server. | | `DNBD3_SERVER_FUSE` | OPTION | {`ON`, `OFF`} | `OFF` | Enable FUSE-Integration for dnbd3-server. | | `DNBD3_SERVER_AFL` | OPTION | {`ON`, `OFF`} | `OFF` | Build dnbd3-server for usage with afl-fuzz. | | `DNBD3_SERVER_DEBUG_LOCKS` | OPTION | {`ON`, `OFF`} | `OFF` | Add lock debugging code to dnbd3-server. | | `DNBD3_SERVER_DEBUG_THREADS` | OPTION | {`ON`, `OFF`} | `OFF` | Add thread debugging code to dnbd3-server. | | `DNBD3_RELEASE_HARDEN` | OPTION | {`ON`, `OFF`} | `OFF` | Compile dnbd3 programs in Release build with code hardening options. | +| `DNBD3_PACKAGE_DOCKER` | OPTION | {`ON`, `OFF`} | `OFF` | Enable packaging of Docker image. | A value from the range of appropriate values can be assigend to each configuration variable by executing CMake once with the following command pattern: @@ -144,7 +147,7 @@ This target creates compressed archives (\*_source.tar.gz and \*_source.zip) con ### Docker image -A docker image of the built dnbd3 components can be created in the `Release` build configuration with the option `DNBD3_KERNEL_MODULE=OFF`. The image is based on Ubuntu 20.04 and starts the embedded dnbd3-server automatically. +A docker image of the built dnbd3 components can be created in the `Release` build configuration with the option `DNBD3_PACKAGE_DOCKER=ON` and `DNBD3_KERNEL_MODULE=OFF`. The image is based on Ubuntu 20.04 and a created docker container from it starts the embedded dnbd3-server automatically. Before the image is built, make sure that your docker daemon runs and you are a member of the `docker` group to access the docker deamon without any super user privileges. Then, build the docker image by calling the following Make target: diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1a7d583..d14b023 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,10 +5,18 @@ project(dnbd3-src LANGUAGES C) add_subdirectory(bench) + if(DNBD3_KERNEL_MODULE) add_subdirectory(client) add_subdirectory(kernel) endif(DNBD3_KERNEL_MODULE) -add_subdirectory(fuse) -add_subdirectory(server) + +if(DNBD3_CLIENT_FUSE) + add_subdirectory(fuse) +endif(DNBD3_CLIENT_FUSE) + +if(DNBD3_SERVER) + add_subdirectory(server) +endif(DNBD3_SERVER) + add_subdirectory(shared) diff --git a/src/fuse/CMakeLists.txt b/src/fuse/CMakeLists.txt index e0b6e43..19ba371 100644 --- a/src/fuse/CMakeLists.txt +++ b/src/fuse/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.10) project(dnbd3-fuse LANGUAGES C) +find_package(Fuse 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 ff8009f..b535535 100644 --- a/src/server/CMakeLists.txt +++ b/src/server/CMakeLists.txt @@ -58,6 +58,7 @@ target_include_directories(dnbd3-server PRIVATE ${JANSSON_INCLUDE_DIR}) target_link_libraries(dnbd3-server dnbd3-version dnbd3-build dnbd3-shared ${CMAKE_THREAD_LIBS_INIT} ${JANSSON_LIBRARIES}) if(DNBD3_SERVER_FUSE) + find_package(Fuse REQUIRED) # include Fuse headers and link with Fuse library target_compile_options(dnbd3-server PRIVATE DNBD3_SERVER_FUSE) target_include_directories(dnbd3-server PRIVATE ${FUSE_INCLUDE_DIRS}) -- cgit v1.2.3-55-g7522