Skip to content

Commit

Permalink
Allow to use the third party of the os
Browse files Browse the repository at this point in the history
cmake options:
 -DUSE_SYSTEM_CLI11 for CLI11 lib
 -DUSE_SYSTEM_FMT for the fmt lib
 -DUSE_SYSTEM_XXHASH for the xxHash lib
  • Loading branch information
tuxmaster5000 authored and arogge committed Oct 9, 2023
1 parent 5093c91 commit 5671052
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
5 changes: 4 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 @@ -53,6 +53,9 @@ include(CTest)
option(BUILD_UNIVERSAL_CLIENT
"Override build-options to produce a limited, but universal client" OFF
)
option(USE_SYSTEM_CLI11 "Use the CLI11 lib of the operating system" OFF)
option(USE_SYSTEM_FMT "Use the fmt lib of the operating system" OFF)
option(USE_SYSTEM_XXHASH "Use the xxHash lib of the operating system" OFF)
if(BUILD_UNIVERSAL_CLIENT)
if(CMAKE_VERSION VERSION_LESS 3.18.0)
message(
Expand Down
14 changes: 14 additions & 0 deletions core/cmake/BareosFindAllLibraries.cmake
Expand Up @@ -187,4 +187,18 @@ if(ENABLE_JANSSON)
find_package(Jansson)
endif()

if(USE_SYSTEM_CLI11)
find_package(CLI11 "2.2.0" CONFIG REQUIRED)
message(STATUS "Using system CLI11 ${CLI11_VERSION}")
endif()
if(USE_SYSTEM_FMT)
find_package(fmt "6.2.1" CONFIG REQUIRED)
message(STATUS "Using system fmt ${fmt_VERSION}")
endif()
if(USE_SYSTEM_XXHASH)
find_package(PkgConfig REQUIRED)
pkg_search_module(XXHASH REQUIRED IMPORTED_TARGET xxhash>=0.8.1)
message(STATUS "Using system xxHash ${XXHASH_VERSION}")
endif()

include(thread)
20 changes: 15 additions & 5 deletions core/src/lib/CMakeLists.txt
Expand Up @@ -152,11 +152,21 @@ target_compile_definitions(
-DBAREOS_YEAR="${BAREOS_YEAR}"
)

target_link_libraries(
bareos
PRIVATE bareosfastlz ${OPENSSL_LIBRARIES} Threads::Threads ${ZLIB_LIBRARIES}
${LZO2_LIBRARIES} ${CAM_LIBRARIES} CLI11::CLI11 xxHash::xxhash
)
if(NOT USE_SYSTEM_XXHASH)
target_link_libraries(
bareos
PRIVATE bareosfastlz ${OPENSSL_LIBRARIES} Threads::Threads
${ZLIB_LIBRARIES} ${LZO2_LIBRARIES} ${CAM_LIBRARIES} CLI11::CLI11
xxHash::xxhash
)
else()
target_link_libraries(
bareos
PRIVATE bareosfastlz ${OPENSSL_LIBRARIES} Threads::Threads
${ZLIB_LIBRARIES} ${LZO2_LIBRARIES} ${CAM_LIBRARIES} CLI11::CLI11
${XXHASH_LIBRARIES}
)
endif()

if(CMAKE_CXX_FLAGS MATCHES "-fsanitize=address"
AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU"
Expand Down
12 changes: 9 additions & 3 deletions third-party/CMakeLists.txt
Expand Up @@ -19,6 +19,12 @@

message("Entering ${CMAKE_CURRENT_SOURCE_DIR}")

add_subdirectory(CLI11 EXCLUDE_FROM_ALL)
add_subdirectory(fmt EXCLUDE_FROM_ALL)
include(./xxHash.cmake)
if(NOT USE_SYSTEM_CLI11)
add_subdirectory(CLI11 EXCLUDE_FROM_ALL)
endif()
if(NOT USE_SYSTEM_FMT)
add_subdirectory(fmt EXCLUDE_FROM_ALL)
endif()
if(NOT USE_SYSTEM_XXHASH)
include(./xxHash.cmake)
endif()

0 comments on commit 5671052

Please sign in to comment.