Hi everyone,

I'm trying to implement Hunter as my dependencies manager as it is in the depthai-core project, so before I started the configuration with Hunter my project was working fine with the local dependencies, which in my case are Boost and OpenCV.

I'm getting an error when Hunter tries to parse the Hunter configuration of depthai-core project.

I have depthai-core lib implemented in my project using git submodule and my configuration is

file .gitmodules

[submodule "3rdparty/depthai-core"]
path = 3rdparty/depthai-core
url = https://github.com/luxonis/depthai-core.git
tag = v2.26.0

The error I got

cmake] Call Stack (most recent call first):
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_make_directory.cmake:7 (include)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_save_to_cache.cmake:8 (include)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_download.cmake:26 (include)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_add_package.cmake:49 (include)
[cmake]   3rdparty/depthai-core/cmake/depthaiDependencies.cmake:14 (hunter_add_package)
[cmake]   3rdparty/depthai-core/CMakeLists.txt:170 (include)
[cmake] 
[cmake] 
[cmake] 
[cmake] [hunter ** INTERNAL **] Unexpected empty string
[cmake] [hunter ** INTERNAL **] [Directory:/Users/christian/git/github.com/christiangda/FaceDetector/3rdparty/depthai-core/cmake]
[cmake] 
[cmake] ------------------------------ ERROR -----------------------------
[cmake]     https://hunter.readthedocs.io/en/latest/reference/errors/error.internal.html
[cmake] ------------------------------------------------------------------
[cmake] 
[cmake] CMake Error at /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_error_page.cmake:12 (message):
[cmake] Call Stack (most recent call first):
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_internal_error.cmake:13 (hunter_error_page)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_assert_not_empty_string.cmake:9 (hunter_internal_error)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_get_package_sha1.cmake:26 (hunter_assert_not_empty_string)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_download.cmake:83 (hunter_get_package_sha1)
[cmake]   /Users/christian/.hunter/_Base/Download/Hunter/0.23.322/cb0ea1f/Unpacked/cmake/modules/hunter_add_package.cmake:53 (hunter_download)
[cmake]   3rdparty/depthai-core/cmake/depthaiDependencies.cmake:14 (hunter_add_package)
[cmake]   3rdparty/depthai-core/CMakeLists.txt:170 (include)
[cmake] 
[cmake] 
[cmake] -- Configuring incomplete, errors occurred!

My hunter configuration is:

file cmake/Hunter/config.cmake

hunter_config(
  Boost
  VERSION ${HUNTER_Boost_VERSION}
)

hunter_config(
    OpenCV
    VERSION ${HUNTER_OpenCV_VERSION}
    CMAKE_ARGS
    WITH_FFMPEG=ON
    OPENCV_FFMPEG_USE_FIND_PACKAGE=YES
)

file CMakeLists.txt

cmake_minimum_required(VERSION 3.5)

if(CUSTOM_HUNTER_ENABLED)
  include("cmake/HunterGate.cmake")
  HunterGate(
      URL "https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz"
      SHA1 "cb0ea1f74f4a2c49a807de34885743495fccccbe"
      LOCAL # Local config for dependencies
  )
endif()

# specify the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)
# set(CMAKE_CXX_COMPILE_FEATURES cxx_std_23)
# set(CMAKE_CXX_FLAGS_INIT           "-Wall -std=c++23")
set(CMAKE_CXX_COMPILER             "/usr/bin/clang++")
# set(CMAKE_CXX_FLAGS                "-pedantic -Wextra -Werror -Wno-unused-parameter -Wno-unused-variable -Wunused-but-set-variable -Wno-unused-function -Wno-unused-private-field")
set(CMAKE_CXX_FLAGS                "-Wextra -Wno-unused-parameter -Wno-unused-variable -Wunused-but-set-variable -Wno-unused-function -Wno-unused-private-field")
set(CMAKE_CXX_FLAGS_DEBUG          "-g")
set(CMAKE_CXX_FLAGS_MINSIZEREL     "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE        "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

# this dependency implement hunter package manager
# and hunter declaration must be before project declaration
# Add depthai-core dependency
add_subdirectory(./3rdparty/depthai-core EXCLUDE_FROM_ALL)

project(FaceDetector
      VERSION 0.0.0
      DESCRIPTION "FaceDeterctor is a simple application that uses depthai-core to detect faces in a video stream"
      LANGUAGES C CXX
)

# add version number to the source code
configure_file(src/Config.h.in Config.h)
include_directories("${PROJECT_BINARY_DIR}")

# target_include_directories("${PROJECT_NAME}" PUBLIC
# "${CMAKE_CURRENT_BINARY_DIR}"
# )

# Add OpenCV (brew install opencv first)
if(CUSTOM_HUNTER_ENABLED)
  hunter_add_package(OpenCV)
endif()
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

# Add Boost (brew install boost first)
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)

if(CUSTOM_HUNTER_ENABLED)
    hunter_add_package(Boost COMPONENTS program_options log system log_setup filesystem)
endif()
find_package(Boost 1.74.0 CONFIG REQUIRED
            COMPONENTS
                program_options
                log
                system
                log_setup
                filesystem
            REQUIRED
)
include_directories(${Boost_INCLUDE_DIRS})

# Add the executable
add_executable("${PROJECT_NAME}"
                src/main.cpp

                src/FaceDetector.h
                src/FaceDetector.cpp

                src/FaceAgeGenderDetector.h
                src/FaceAgeGenderDetector.cpp

                src/MetricSender.h
                src/MetricSender.cpp

                src/CmdOptions.h
                src/CmdOptions.cpp
)

# Link the executable to the depthai-core library
target_link_libraries("${PROJECT_NAME}"
              PUBLIC
                depthai::opencv
                "${OpenCV_LIBS}"
                "${Boost_LIBRARIES}"
)

Hi @christiangda
I'm too unfamiliar with CMake shenanigans so I'm attaching a GPT response, hope it helps at least a little:


The error you're encountering indicates that Hunter is having trouble resolving some internal configuration. This can often be due to issues with how the Hunter configuration is set up or how dependencies are specified in your project.

Troubleshooting Steps

  1. Verify Hunter Configuration:
    Ensure that Hunter is correctly configured to handle the dependencies required by depthai-core, Boost, and OpenCV.

  2. Update Hunter Version:
    Sometimes using an older version of Hunter can cause compatibility issues. Consider updating to a newer version of Hunter if available.

  3. Check Hunter Configuration in depthai-core:
    The error may arise from how depthai-core is configured to use Hunter. Make sure the depthaiDependencies.cmake file in depthai-core correctly specifies the required Hunter packages.

  4. Review depthaiDependencies.cmake File:
    Look into the depthaiDependencies.cmake file included in the depthai-core project to ensure it correctly calls hunter_add_package for all necessary dependencies.

Example depthaiDependencies.cmake Adjustment

The error stack trace points to an issue within the depthaiDependencies.cmake file. Ensure it looks something like this:

hunter_add_package(Boost)
find_package(Boost CONFIG REQUIRED)

hunter_add_package(OpenCV)
find_package(OpenCV REQUIRED)

Example CMakeLists.txt Adjustment

Here’s an example of how you can set up your CMakeLists.txt to work with Hunter and your local dependencies:

cmake_minimum_required(VERSION 3.5)

if(CUSTOM_HUNTER_ENABLED)
  include("cmake/HunterGate.cmake")
  HunterGate(
      URL "https://github.com/cpp-pm/hunter/archive/v0.23.322.tar.gz"
      SHA1 "cb0ea1f74f4a2c49a807de34885743495fccccbe"
      LOCAL # Local config for dependencies
  )
endif()

project(FaceDetector
      VERSION 0.0.0
      DESCRIPTION "FaceDeterctor is a simple application that uses depthai-core to detect faces in a video stream"
      LANGUAGES C CXX
)

# specify the C++ standard
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# Set compiler flags
set(CMAKE_CXX_COMPILER "/usr/bin/clang++")
set(CMAKE_CXX_FLAGS "-Wextra -Wno-unused-parameter -Wno-unused-variable -Wunused-but-set-variable -Wno-unused-function -Wno-unused-private-field")
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")

# Hunter configuration
if(CUSTOM_HUNTER_ENABLED)
  hunter_config(
    Boost
    VERSION ${HUNTER_Boost_VERSION}
  )

  hunter_config(
    OpenCV
    VERSION ${HUNTER_OpenCV_VERSION}
    CMAKE_ARGS
    WITH_FFMPEG=ON
    OPENCV_FFMPEG_USE_FIND_PACKAGE=YES
  )
endif()

# Add depthai-core dependency
add_subdirectory(3rdparty/depthai-core EXCLUDE_FROM_ALL)

# Add OpenCV
if(CUSTOM_HUNTER_ENABLED)
  hunter_add_package(OpenCV)
endif()
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})

# Add Boost
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)

if(CUSTOM_HUNTER_ENABLED)
    hunter_add_package(Boost COMPONENTS program_options log system log_setup filesystem)
endif()
find_package(Boost 1.74.0 CONFIG REQUIRED
            COMPONENTS
                program_options
                log
                system
                log_setup
                filesystem
            REQUIRED
)
include_directories(${Boost_INCLUDE_DIRS})

# Add the executable
add_executable("${PROJECT_NAME}"
                src/main.cpp

                src/FaceDetector.h
                src/FaceDetector.cpp

                src/FaceAgeGenderDetector.h
                src/FaceAgeGenderDetector.cpp

                src/MetricSender.h
                src/MetricSender.cpp

                src/CmdOptions.h
                src/CmdOptions.cpp
)

# Link the executable to the depthai-core library
target_link_libraries("${PROJECT_NAME}"
              PUBLIC
                depthai::opencv
                ${OpenCV_LIBS}
                ${Boost_LIBRARIES}
)

Debugging the Issue

  1. Check Hunter Logs:
    Hunter provides logs that can be useful for debugging. Look into these logs for more detailed error messages.

  2. Verbose Output:
    Run CMake with verbose output to get more information on what is happening during the configuration phase:

       cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
  3. Minimal Example:
    Create a minimal example that only includes depthai-core and its dependencies to isolate the problem.

By carefully checking the Hunter configuration and the depthaiDependencies.cmake file, you should be able to resolve the issue and correctly integrate Hunter into your project.

Thanks,
Jaka