0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-04-28 22:52:30 +00:00
netdata_netdata/packaging/cmake/Modules/NetdataDlib.cmake
Austin S. Hemmelgarn e1ab60c2cb
Properly integrate dlib into our build system. (#20086)
* Properly integrate dlib into our build system.

- Use the current latest version of dlib (v19.24.8). This fixes a number
  of warnings in the dlib code that are spilling over into our build
  output. This also is required for the other changes, as the version of
  dlib we were using was still expecting CMake versions earlier than
  3.0.
- Use dlib's CMake build infrastructure instead of their crazy shared
  source thing. This gives us much better integration into our build
  system, enables us to suppress warnings on a per-source-file level,
  and also means that warnings will be much better localized. In theory
  it should also marginally improve build times, though this likely
  won’t be visible for any native builds.
- Use CMake's FetchContent for dlib instead of a git submodule. This
  gives us smaller source tarballs and better decouples our sources from
  our dependencies, as well as making it marginally easier to work wtih
  our git repository due to having one less submodule.

* Disable all of dlib’s external dependencies.

We weren’t using any of them anyway, and this both speeds up the build
and resolves errors on some systems.

* Allow usage of local dlib sources for builds.
2025-04-09 12:50:16 -04:00

57 lines
1.7 KiB
CMake

# SPDX-License-Identifier: GPL-3.0-or-later
# Functions and macros for handling of dlib
function(netdata_bundle_dlib)
include(FetchContent)
include(NetdataFetchContentExtra)
message(STATUS "Preparing vendored copy of dlib")
if(NETDATA_DLIB_SOURCE_PATH)
set(FETCHCONTENT_SOURCE_DIR_DLIB "${NETDATA_DLIB_SOURCE_PATH}")
message(STATUS "Using local dlib source: ${NETDATA_DLIB_SOURCE_DIR}")
endif()
set(FETCHCONTENT_FULLY_DISCONNECTED Off)
set(repo https://github.com/davisking/dlib.git)
set(tag 636c0bcd1e4f428d167699891bc12b404d2d1b41) # v19.24.8
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(DLIB_NO_GUI_SUPPORT ON)
set(DLIB_JPEG_SUPPORT OFF)
set(DLIB_LINK_WITH_SQLITE3 OFF)
set(DLIB_USE_BLAS OFF)
set(DLIB_USE_LAPACK OFF)
set(DLIB_USE_CUDA OFF)
set(DLIB_PNG_SUPPORT OFF)
set(DLIB_GIF_SUPPORT OFF)
set(DLIB_WEBP_SUPPORT OFF)
set(DLIB_JXL_SUPPORT OFF)
set(DLIB_USE_MKL_FFT OFF)
set(DLIB_USE_FFMPEG OFF)
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.28)
FetchContent_Declare(dlib
GIT_REPOSITORY ${repo}
GIT_TAG ${tag}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
EXCLUDE_FROM_ALL
)
else()
FetchContent_Declare(dlib
GIT_REPOSITORY ${repo}
GIT_TAG ${tag}
CMAKE_ARGS ${NETDATA_CMAKE_PROPAGATE_TOOLCHAIN_ARGS}
)
endif()
FetchContent_MakeAvailable_NoInstall(dlib)
message(STATUS "Finished preparing vendored copy of JSON-C")
endfunction()
function(netdata_add_dlib_to_target _target)
get_target_property(NETDATA_DLIB_INCLUDE_DIRS dlib INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${_target} PRIVATE ${NETDATA_DLIB_INCLUDE_DIRS})
target_link_libraries(${_target} PRIVATE dlib)
endfunction()