Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use the third-party libraries of the OS instead of the bundled ones #1441

Merged
merged 5 commits into from
Oct 9, 2023

Conversation

tuxmaster5000
Copy link
Contributor

@tuxmaster5000 tuxmaster5000 commented Apr 12, 2023

Add the following CMake options to allow to use the third party libs of the OS.
For example on RHEL 9 and Fedora 36

cmake options:
-DUSE_SYSTEM_CLI11 for CLI11 lib
-DUSE_SYSTEM_FMT for the fmt lib
-USE_SYSTEM_XXHASH for the xxHash lib

Thank you for contributing to the Bareos Project!

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

Make sure you check/merge the PR using devtools/pr-tool to have some simple automated checks run and a proper changelog record added.

General
  • Is the PR title usable as CHANGELOG entry?
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Required backport PRs have been created
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently your changes as they are cannot be built.
Please fix the problems and consolidate the changes into once place.

Maybe it is also a good idea to rename the options USE_BUNDLED_XYZ and default them to ON instead.

find_package(CLI11 "2.2.0" CONFIG REQUIRED)
message(STATUS "Using system CLI11 ${CLI11_VERSION}")
endif()
find_package(fmt "6.2.1" CONFIG REQUIRED)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that should have gone into the if, doesn't it?

endif()
if(USE_SYSTEM_XXHASH)
find_package(PkgConfig REQUIRED)
pkg_search_module(XXHASH REQUIRED IMPORTED_TARGET xxhash>=0.8.1 )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't find the installed xxhash on my RHEL 8 or RHEL 9 machines.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting on my systems it will work.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you build your own xxhash packages? Did you patch the pkgconfig files for that?
Because on my machine it is "libxxhash" and not "xxhash".

$ lsb_release -d
Description:	Red Hat Enterprise Linux release 8.8 (Ootpa)
$ rpm -q xxhash-devel
xxhash-devel-0.8.1-3.el8.x86_64
$ pkg-config --list-all | grep xxhash
libxxhash                      xxhash - extremely fast hash algorithm

Comment on lines 154 to 166
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 PkgConfig:: XXHASH
)
endif()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PkgConfig:: XXHASH does not work.

Also, please just create an alias named xxHash::xxhash that points to PkgConfig::XXHASH instead of duplicating the whole call to target_link_libraries().

Comment on lines 22 to 48
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()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you scatter your changes into several files.
The options from the topmost CMakeLists.txt could have been in here and so could have been the additions to core/cmake/BareosFindAllLibraries.cmake.

Please fix the issues I mentioned above and consolidate the changes into one place.

@arogge arogge changed the title Allow to use the third party of the os system instead of the bundled one Allow to use the third-party libraries of the OS instead of the bundled ones May 25, 2023
@arogge
Copy link
Member

arogge commented Aug 21, 2023

Is there any chance you're going to address the issues that are still left?

@tuxmaster5000
Copy link
Contributor Author

What do you mean? GH is becoming so confusing when adding comments direct to the lines.

@arogge
Copy link
Member

arogge commented Aug 23, 2023

@tuxmaster5000
Copy link
Contributor Author

Hi @arogge ,
Yes you are right with the lib name. The PR was not in sync with my internal git.
And the second must be done, because the "include(./xxHash.cmake)" must be removed when using it from the os, because it don't support cmake.

@arogge
Copy link
Member

arogge commented Aug 30, 2023

Hi!
I took the liberty to add two commits:

  • I created a cmake find-module to search xxHash.
  • I moved all other required changes into third-party/CMakeLists.txt

Could you check if it is still usable for you like this?

@tuxmaster5000
Copy link
Contributor Author

Very strange, when using your patch fmt can' be found. It fails with:

CMake Error at third-party/CMakeLists.txt:33 (find_package):
Could not find a package configuration file provided by "fmt" (requested
version 6.2.1) with any of the following names:

fmtConfig.cmake
fmt-config.cmake

Add the installation prefix of "fmt" to CMAKE_PREFIX_PATH or set "fmt_DIR"
to a directory containing one of the above files. If "fmt" provides a
separate development package or SDK, be sure it has been installed.

-- Configuring incomplete, errors occurred!

@arogge
Copy link
Member

arogge commented Sep 18, 2023

That is indeed pretty weird.
I just retried on RHEL 8 with -DENBALE_SYSTEM_FMT=ON and with packages fmt-6.2.1-1.el8.x86_64 and fmt-devel-6.2.1-1.el8.x86_64 installed, which worked perfectly.

Could you tell me what system image with which fmt packages you used when it failed like you described above, so I can reproduce the problem?

@tuxmaster5000
Copy link
Contributor Author

Ah, then we have tested different setups. On RHEL-8 your modification works(also on my side), but it will fail's on RHEL-9, Fedora-37 and Fedora-38 .

@arogge
Copy link
Member

arogge commented Sep 28, 2023

I had a hard time understanding what went wrong here, but I think I got it now.
Turns our in the third-party directory C/C++ was not enabled and thus /usr/lib64 was not searched.
However, that should have failed on RHEL8, too.

Nevertheless, it works for me on RHEL9 now, so I hope it works for you on Fedora 37 and 38, too. Could you please confirm?

@tuxmaster5000
Copy link
Contributor Author

Hi,
thanks for your work.
Now it will work for RHEL-7 up to 9 and for Fedora-37.
On Fedora-38 it will fails with an gcc error, but is another bug, where I have seen here PR's for it.
So I think, this PR it now ready :)

tuxmaster5000 and others added 4 commits October 9, 2023 10:40
cmake options:
 -DUSE_SYSTEM_CLI11 for CLI11 lib
 -DUSE_SYSTEM_FMT for the fmt lib
 -DUSE_SYSTEM_XXHASH for the xxHash lib
When C/C++ languages are not enabled, the find_package module will not
look into arch-specific locations (e.g. /usr/lib64/cmake/) failing to
detect software that is installed into these locations.
@BareosBot BareosBot merged commit b1d9417 into bareos:master Oct 9, 2023
@tuxmaster5000 tuxmaster5000 deleted the system-libs branch October 10, 2023 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants