-
Notifications
You must be signed in to change notification settings - Fork 132
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
Support using non-hunter version of bzip2, zlib and libarchive if HUNTER_ENABLED is OFF #1050
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,17 +36,44 @@ endif() | |
# If library was build as static, find all dependencies | ||
if(NOT CONFIG_MODE OR (CONFIG_MODE AND NOT DEPTHAI_SHARED_LIBS)) | ||
|
||
# BZip2 (for bspatch) | ||
find_package(BZip2 ${_QUIET} CONFIG REQUIRED) | ||
|
||
# FP16 for conversions | ||
find_package(FP16 ${_QUIET} CONFIG REQUIRED) | ||
|
||
# libarchive for firmware packages | ||
find_package(archive_static ${_QUIET} CONFIG REQUIRED) | ||
find_package(lzma ${_QUIET} CONFIG REQUIRED) | ||
# ZLIB for compressing Apps | ||
find_package(ZLIB CONFIG REQUIRED) | ||
# Some packages have different package names depending on which | ||
# version is installed, if we are using hunter we want to make sure to | ||
# use the hunter/luxonis fork, otherwise we try using the hunter/luxonis | ||
# fork and if that can't be found we found the regular version | ||
if(DEPTHAI_HUNTER_ENABLED) | ||
# BZip2 (for bspatch) | ||
find_package(BZip2 ${_QUIET} CONFIG REQUIRED) | ||
|
||
# libarchive for firmware packages | ||
find_package(archive_static ${_QUIET} CONFIG REQUIRED) | ||
find_package(lzma ${_QUIET} CONFIG REQUIRED) | ||
|
||
# ZLIB for compressing Apps | ||
find_package(ZLIB CONFIG REQUIRED) | ||
else() | ||
# BZip2 (for bspatch) | ||
find_package(BZip2 ${_QUIET} CONFIG) | ||
if(NOT BZip2_FOUND) | ||
find_package(BZip2 ${_QUIET} REQUIRED) | ||
endif() | ||
|
||
# libarchive for firmware packages | ||
find_package(archive_static ${_QUIET} CONFIG) | ||
if(archive_static_FOUND) | ||
find_package(lzma ${_QUIET} CONFIG REQUIRED) | ||
else() | ||
find_package(LibArchive ${_QUIET} REQUIRED) | ||
endif() | ||
|
||
# ZLIB for compressing Apps | ||
find_package(ZLIB CONFIG) | ||
if(NOT ZLIB_FOUND) | ||
find_package(ZLIB REQUIRED) | ||
endif() | ||
Comment on lines
+71
to
+75
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are these performed twice? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To give the precedence to hunter/luxonis fork of ZLIB and BZip2 (if they are installed) that install cmake config files. By default, if one calls There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this case, as Hunter is already disabled, just be I haven't seen this differentiation yet - was there some issues without doing it that way? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not strictly related to Hunter. To explain a bit, imagine if you are on Ubuntu 24.04 and you install ZLIB via apt (but you can see the same behaviour with conda, with vcpkg, with spack):
If you try to put the following content in a CMakeLists.txt: cmake_minimum_required(VERSION 3.16)
# Set the project name
project(FindZLIBExample)
# Find the ZLIB library without CONFIG
# This works in Ubuntu 24.04 with apt dependencies
find_package(ZLIB REQUIRED)
# Find the ZLIB library with CONFIG
# This does **not** work in Ubuntu 24.04 with apt dependencies as ZLIB does not install a CMake config file
find_package(ZLIB CONFIG REQUIRED) and then your try to configure it (calling
The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the insight - I was not aware these two paths differ |
||
endif() | ||
|
||
# spdlog for library and device logging | ||
find_package(spdlog ${_QUIET} CONFIG REQUIRED) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When have these become available in "upstream CMake"?
Before/after our specified "minimal CMake version"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, here a recap based on CMake docs:
So to actually get BZip2 or LibArchive non-Hunter dependencies to work, one needs a CMake version that is newer then the documented minimum (CMake 3.17, relased in March 2020).
How do you prefer to proceed? We could just have an error message if
HUNTER_ENABLED
isOFF
and CMake version < 3.17, but that would break compilation for people that are settingHUNTER_ENABLED
toOFF
and then installingBZip2
andLibArchive
from Hunter/luxonis fork, for which CMake 3.12/3.17 is not needed.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets see if we can just include the corresponding
FindX.cmake
in to our codebase undercmake/
folder and we rely on that instead. (as I think those are just CMake helpers at the end of the day)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kind of related to #1050 (comment) . Just to understand, you propose to take the
FindZLIB.cmake
from CMake (i.e. https://github.com/Kitware/CMake/blame/master/Modules/FindZLIB.cmake, copy it to depthai-core, modify it to (optionally) find the ZLIB config installed by Hunter's fork of zlib, and then just usefind_package(ZLIB REQUIRED)
withoutCONFIG
? I typically avoid to vendor files from CMake as they tend to become outdated over time w.r.t. to the upstream version, introducing hard to debug failures and maintenance burden.To make an example exactly with ZLIB, one of the reason I had to build
depthai-core
withHUNTER_ENABLED=FALSE
and could not use something like #1021 is that otherwise Hunter forced me to use its own vendored FindZLIB (see https://github.com/cpp-pm/hunter/blob/93329a1bf921d55a7d113288573d19580fe08f09/cmake/find/FindZLIB.cmake#L2) that was shadowing theFindZLIB
from upstream cmake, without providing the same functionality (in particular, the Hunter'sFindZLIB
wanted to usefind_package(ZLIB CONFIG)
, that has stated in #1050 (comment) does not work with non-Hunter ZLIB.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having said that, if instead you prefer to keep a local
FindZLIB.cmake
I would be happy to do that.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd make sense to include & later on we can "skip" it from including these if version of CMake is adequate, etc...
But LGTM on not tweaking it to also cover Hunter. So I'd just target having a version agnostic (or lower cmake version), that would support FindZLIB, et al