Skip to content

Conversation

@ntonnaett
Copy link

@ntonnaett ntonnaett commented Oct 23, 2024

Hive failed to build for me on Linux. So I'm working on making the build process more convenient for Linux users. I changed to the recommended model for using dependencies that utilizes FetchContent but first tries to find dependencies with find_package. I did this only for common libraries (fmt, googletest).

I'm not sure how the header only usage of fmt was supposed to work. I added the FMT_HEADER_ONLY variable and removed the linking step that shouldn't be necessary.

I'm wondering if the find_package step should be disabled on Mac and Windows.

I'm opening this PR now so I can get input early on how to make these changes without disrupting your workflow.

@ntonnaett ntonnaett marked this pull request as draft October 23, 2024 07:56
@christophe-calmejane
Copy link
Collaborator

Hi, thanks a lot for that, I'll need to take a look when I get a chance. My idea for linux was to create an AppImage (through Docker) in order to guarantee it will compile correctly everywhere. Currently there is already a docker setup which I use to validate compilation, but I'd be happy to take advantage of new CMake features.

GIT_TAG 0c9fce2ffefecfdce794e1859584e25877b7b592 # release-11.0.2
FIND_PACKAGE_ARGS NAMES fmt
)
FetchContent_MakeAvailable(fmt)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on the documentation, when using FIND_PACKAGE_ARGS, CMake will first try to find the library using find_package which is not something desired. If a newer (or older) version is installed somewhere on the system, it will be used instead of the one explicitly defined and validated by the project. Not a controlled environment.

Copy link
Author

Choose a reason for hiding this comment

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

You can still disable this behavior with FETCHCONTENT_TRY_FIND_PACKAGE_MODE in your controlled environment. But I don't have your controlled environment and avdecc just doesn't compile for me because fmt is outdated. When I want to get Hive into Fedora I'm not allowed to bundle every dependency. Dependencies -- even static libraries -- need to be tracked and there is always only one version in the repositories.

I think the best approach to get what most people expect is to set FETCHCONTENT_TRY_FIND_PACKAGE_MODE to NEVER on macOS and Windows. On Linux everybody expects build systems to get their dependencies from the system. If you build an application with Flatpak it would automatically use FetchContent because the dependencies are missing. So it would work out-of-the-box.

Copy link
Author

Choose a reason for hiding this comment

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

I added that to gen_cmake.sh for all platforms. First I thought I set it in the CMakeLists.txt but the documentation says that the variable is meant to be set by the user.

Copy link
Collaborator

Choose a reason for hiding this comment

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

If your goal is to create Fedora packages for avdecc and Hive, maybe there is more we can do, as I don't know what will be the effect of FMT_INSTALL here.
I'm thinking of a more generic approach to all these dependencies, something like we see in configure scripts (and actually something very close to what you propose here).
But I need to run many more tests to be sure it will not disrupt all the existing ways of building the projects (including all OSes, Docker, CI, ...)

Copy link
Author

Choose a reason for hiding this comment

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

Could you elaborate on your idea?

@sonarqubecloud
Copy link

sonarqubecloud bot commented Mar 7, 2025

@ntonnaett ntonnaett changed the base branch from main to dev August 15, 2025 21:09
@sonarqubecloud
Copy link

endif()
if(CMAKE_SYSTEM_NAME MATCHES "Linux")
find_package(PkgConfig REQUIRED)
pkg_check_modules(PCAP REQUIRED IMPORTED_TARGET GLOBAL libpcap)
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is IMPORTED_TARGET and GLOBAL used for here?
You don't use the generated name PkgConfig::PCAP anywhere, right?

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.

2 participants