cmakedlibcmake-gui

How can I add dlib in cmake with findpackage?


This is my cmakelists.txt:

project( WolframMachine )                                    
cmake_minimum_required(VERSION 3.1)
set (CMAKE_CXX_STANDARD 11)
set(CMAKE_SUPPRESS_REGENERATION true)
include(ExternalProject)
set(Boost_INCLUDE_DIR "C:/boost_1_66_0")
set(Boost_LIBRARY_DIR "C:/boost_1_66_0/lib64-msvc-14.0")
SET("OpenCV_DIR" "C:/opencv-3.4.1/build")
SET(dlib_DIR "C:/dlib-19.13/")  # <============ DLIB
find_package( OpenCV COMPONENTS core imgproc highgui aruco optflow plot REQUIRED )
find_package(dlib REQUIRED)  # <============ DLIB
add_subdirectory(dlibtest)

Running cmake-gui gives me following:

enter image description here

setting dlib_DIR manually doesn't help. How can I fix this?

UPD: tried other dlib_DIR values with no success:

SET(dlib_DIR "C:/dlib-19.13/build/dlib/CMakeFiles/Export/lib/cmake/dlib")

gives same error:

enter image description here

and setting

SET(dlib_DIR "C:/dlib-19.13/build/dlib/config")

gives another meaningless error:

enter image description here


Solution

  • It looks like dlib was not designed to add it with find_package. What you have to do is to add it as subdirectory:

    add_subdirectory(C:/dlib-19.13 dlib_build)
    

    and also add resulting libs to your binary:

    target_link_libraries( ${CUR_PROJECT_NAME} ${OpenCV_LIBS} ${Boost_LIBRARIES} dlib::dlib)
    # ---------------------------------------------------------------------------^^^^^^^^^^