Skip to content

Commit

Permalink
Merge pull request #1441
Browse files Browse the repository at this point in the history
Allow to use the third-party libraries of the OS instead of the bundled ones
  • Loading branch information
BareosBot committed Oct 9, 2023
2 parents 5093c91 + 7665de5 commit b1d9417
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -104,6 +104,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
- python: adapt for new Python module versions [PR #1546]
- tools: fix tools not starting up on windows [PR #1549]
- dird: `list jobs`: add `level` keyword and accept a list of job levels [PR #1548]
- Allow to use the third-party libraries of the OS instead of the bundled ones [PR #1441]

### Removed
- remove no longer used pkglists [PR #1335]
Expand Down Expand Up @@ -214,6 +215,7 @@ and since Bareos version 20 this project adheres to [Semantic Versioning](https:
[PR #1437]: https://github.com/bareos/bareos/pull/1437
[PR #1439]: https://github.com/bareos/bareos/pull/1439
[PR #1440]: https://github.com/bareos/bareos/pull/1440
[PR #1441]: https://github.com/bareos/bareos/pull/1441
[PR #1445]: https://github.com/bareos/bareos/pull/1445
[PR #1447]: https://github.com/bareos/bareos/pull/1447
[PR #1448]: https://github.com/bareos/bareos/pull/1448
Expand Down
3 changes: 2 additions & 1 deletion CMakeLists.txt
@@ -1,6 +1,6 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2019-2022 Bareos GmbH & Co. KG
# Copyright (C) 2019-2023 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of version three of the GNU Affero General Public
Expand Down Expand Up @@ -119,6 +119,7 @@ if(NOT hostname)
endif()

if(BUILD_BAREOS_BINARIES)
project(bareos C CXX)
add_subdirectory(third-party EXCLUDE_FROM_ALL)
add_subdirectory(core)
if(ENABLE_WEBUI)
Expand Down
98 changes: 98 additions & 0 deletions cmake/FindxxHash.cmake
@@ -0,0 +1,98 @@
# BAREOS® - Backup Archiving REcovery Open Sourced
#
# Copyright (C) 2023-2023 Bareos GmbH & Co. KG
#
# This program is Free Software; you can redistribute it and/or modify it under
# the terms of version three of the GNU Affero General Public License as
# published by the Free Software Foundation and included in the file LICENSE.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

#[=======================================================================[.rst:
FindxxHash
-----------

Find xxHash headers and libraries.
`
IMPORTED Targets
^^^^^^^^^^^^^^^^

The following :prop_tgt:`IMPORTED` targets may be defined:

``xxHash::xxhash``
xxHash library.

Result variables
^^^^^^^^^^^^^^^^

This module will set the following variables in your project:

``XXHASH_FOUND``
True if xxHash found.
``XXHASH_INCLUDE_DIRS``
Where to find xxhash.h.
``XXHASH_LIBRARIES``
List of libraries when using xxHash.
``XXHASH_VERSION_STRING``
The version of xxHash found.
``HAVE_XXHASH``
1 if xxHash found.

#]=======================================================================]

find_package(PkgConfig QUIET)
pkg_check_modules(PC_XXHASH QUIET libxxhash)

find_path(
XXHASH_INCLUDE_DIR
NAMES xxhash.h
HINTS ${PC_XXHASH_INCLUDEDIR} ${PC_XXHASH_INCLUDE_DIRS}
)

find_library(
XXHASH_LIBRARY
NAMES xxhash libxxhash
HINTS ${PC_XXHASH_LIBDIR} ${PC_XXHASH_LIBRARY_DIRS}
)

if(PC_XXHASH_VERSION)
set(XXHASH_VERSION_STRING ${PC_XXHASH_VERSION})
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
xxHash
REQUIRED_VARS XXHASH_LIBRARY XXHASH_INCLUDE_DIR
VERSION_VAR XXHASH_VERSION_STRING
)

if(XXHASH_FOUND)
set(XXHASH_LIBRARIES ${XXHASH_LIBRARY})
set(XXHASH_INCLUDE_DIRS ${XXHASH_INCLUDE_DIR})
set(HAVE_XXHASH 1)
endif()

mark_as_advanced(XXHASH_INCLUDE_DIR XXHASH_LIBRARY)

if(XXHASH_FOUND AND NOT TARGET xxHash::xxhash)
add_library(xxHash::xxhash UNKNOWN IMPORTED)
set_target_properties(
xxHash::xxhash PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"${XXHASH_INCLUDE_DIRS}"
)
set_target_properties(
xxHash::xxhash PROPERTIES INTERFACE_COMPILE_OPTIONS "${XXHASH_DEFINITIONS}"
)
set_property(
TARGET xxHash::xxhash
APPEND
PROPERTY IMPORTED_LOCATION "${XXHASH_LIBRARY}"
)
endif()
30 changes: 27 additions & 3 deletions third-party/CMakeLists.txt
Expand Up @@ -19,6 +19,30 @@

message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

add_subdirectory(CLI11 EXCLUDE_FROM_ALL)
add_subdirectory(fmt EXCLUDE_FROM_ALL)
include(./xxHash.cmake)
option(USE_SYSTEM_CLI11 "Use the CLI11 lib of the operating system" OFF)
if(USE_SYSTEM_CLI11)
find_package(CLI11 "2.2.0" CONFIG REQUIRED)
set_target_properties(CLI11::CLI11 PROPERTIES IMPORTED_GLOBAL TRUE)
message(STATUS "Using system CLI11 ${CLI11_VERSION}")
else()
add_subdirectory(CLI11 EXCLUDE_FROM_ALL)
endif()

option(USE_SYSTEM_FMT "Use the fmt lib of the operating system" OFF)
if(USE_SYSTEM_FMT)
find_package(fmt "6.2.1" CONFIG REQUIRED)
set_target_properties(fmt::fmt-header-only PROPERTIES IMPORTED_GLOBAL TRUE)
set_target_properties(fmt::fmt PROPERTIES IMPORTED_GLOBAL TRUE)
message(STATUS "Using system fmt ${fmt_VERSION}")
else()
add_subdirectory(fmt EXCLUDE_FROM_ALL)
endif()

option(USE_SYSTEM_XXHASH "Use the xxHash lib of the operating system" OFF)
if(USE_SYSTEM_XXHASH)
find_package(xxHash REQUIRED)
set_target_properties(xxHash::xxhash PROPERTIES IMPORTED_GLOBAL TRUE)
message(STATUS "Using system xxHash ${XXHASH_VERSION}")
else()
include(./xxHash.cmake)
endif()

0 comments on commit b1d9417

Please sign in to comment.