From 7a56efa96bc077e477bbaa7d56849c0ac1fa2efa Mon Sep 17 00:00:00 2001 From: Alberto Miranda Date: Wed, 7 Oct 2020 20:41:17 +0200 Subject: [PATCH] Add yaml-cpp as a dependency --- CMake/FindYAMLCpp.cmake | 109 ++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 3 ++ README.md | 2 + 3 files changed, 114 insertions(+) create mode 100644 CMake/FindYAMLCpp.cmake diff --git a/CMake/FindYAMLCpp.cmake b/CMake/FindYAMLCpp.cmake new file mode 100644 index 000000000..a3e058929 --- /dev/null +++ b/CMake/FindYAMLCpp.cmake @@ -0,0 +1,109 @@ +## +# Copyright 2018-2020, Barcelona Supercomputing Center (BSC), Spain +# Copyright 2015-2020, Johannes Gutenberg Universitaet Mainz, Germany +# +# This software was partially supported by the +# EC H2020 funded project NEXTGenIO (Project ID: 671951, www.nextgenio.eu). +# +# This software was partially supported by the +# ADA-FS project under the SPPEXA project funded by the DFG. +# +# SPDX-License-Identifier: MIT +## + +#[=======================================================================[.rst: +FindYAMLCpp +--------- + +Find yaml-cpp include dirs and libraries. + +Use this module by invoking find_package with the form:: + + find_package(YAMLCpp + [version] [EXACT] # Minimum or EXACT version e.g. 0.6.2 + [REQUIRED] # Fail with error if yaml-cpp is not found + ) + +Imported Targets +^^^^^^^^^^^^^^^^ + +This module provides the following imported targets, if found: + +``YAMLCpp::YAMLCpp`` + The YAMLCpp library + +Result Variables +^^^^^^^^^^^^^^^^ + +This will define the following variables: + +``YAMLCpp_FOUND`` + True if the system has the YAMLCpp library. +``YAMLCpp_VERSION`` + The version of the YAMLCpp library which was found. +``YAMLCpp_INCLUDE_DIRS`` + Include directories needed to use YAMLCpp. +``YAMLCpp_LIBRARIES`` + Libraries needed to link to YAMLCpp. + +Cache Variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``YAMLCpp_INCLUDE_DIR`` + The directory containing ``yaml.h``. +``YAMLCpp_LIBRARY`` + The path to the YAMLCpp library. + +#]=======================================================================] + +# yaml-cpp already provides a config file, but sadly it doesn't define +# a target with the appropriate properties. Fortunately, it also provides a +# pkg-config .pc file that we can use to fetch the required library properties +# and wrap them neatly into the 'YAMLCpp' target we provide +find_package(PkgConfig) +pkg_check_modules(PC_YAMLCpp QUIET yaml-cpp) + +find_path(YAMLCpp_INCLUDE_DIR + NAMES yaml-cpp/yaml.h + PATHS ${PC_YAMLCpp_INCLUDE_DIRS} + PATH_SUFFIXES YAMLCpp +) + +find_library(YAMLCpp_LIBRARY + NAMES yaml-cpp + PATHS ${PC_YAMLCpp_LIBRARY_DIRS} +) + +mark_as_advanced( + YAMLCpp_INCLUDE_DIR + YAMLCpp_LIBRARY +) + +set(YAMLCpp_VERSION ${PC_YAMLCpp_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(YAMLCpp + FOUND_VAR YAMLCpp_FOUND + REQUIRED_VARS + YAMLCpp_LIBRARY + YAMLCpp_INCLUDE_DIR + VERSION_VAR YAMLCpp_VERSION +) + +if(YAMLCpp_FOUND) + set(YAMLCpp_LIBRARIES ${YAMLCpp_LIBRARY}) + set(YAMLCpp_INCLUDE_DIRS ${YAMLCpp_INCLUDE_DIR}) + set(YAMLCpp_DEFINITIONS ${PC_YAMLCpp_CFLAGS_OTHER}) +endif() + +if(YAMLCpp_FOUND AND NOT TARGET YAMLCpp::YAMLCpp) + add_library(YAMLCpp::YAMLCpp UNKNOWN IMPORTED) + set_target_properties(YAMLCpp::YAMLCpp PROPERTIES + IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" + IMPORTED_LOCATION "${YAMLCpp_LIBRARY}" + INTERFACE_COMPILE_DEFINITIONS "${PC_YAMLCpp_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${YAMLCpp_INCLUDE_DIR}" +) +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 2f3a2a190..7a30a9dae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,9 @@ find_package(Threads REQUIRED) find_package(Date REQUIRED) +# yaml-cpp is required for reading configuration files +find_package(YAMLCpp 0.6.2 REQUIRED) + option(CREATE_CHECK_PARENTS "Check parent directory existance before creating child node" ON) message(STATUS "[gekkofs] Create checks parents: ${CREATE_CHECK_PARENTS}") diff --git a/README.md b/README.md index 96c439c45..9c66d29c0 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ to I/O, which reduces interferences and improves performance. - lz4: `sudo apt-get install liblz4-dev` - uuid: `sudo apt-get install uuid-dev` - capstone: `sudo apt-get install libcapstone-dev` +- yaml-cpp: `sudo apt-get install libyaml-dev` ### CentOS/Red Hat - Dependencies @@ -40,6 +41,7 @@ to I/O, which reduces interferences and improves performance. - lz4: `sudo yum install lz4 lz4-devel` - uuid: `sudo yum install libuuid-devel` - capstone: `sudo yum install capstone capstone-devel` +- yaml-cpp: `sudo yum install yaml-cpp-devel` # Usage -- GitLab