6

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

Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206

3 Answers3

1

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)
# ---------------------------------------------------------------------------^^^^^^^^^^
Stepan Yakovenko
  • 8,670
  • 28
  • 113
  • 206
  • DLib works fine with `find_package`. We use it in our project and it works fine. Our `CMakeLists.txt` contains the following 3 lines: `find_package(DLIB REQUIRED)`, `include_directories(${DLIB_INCLUDE_DIRECTORY})`, `target_link_libraries(your_project ${DLIB_LIBRARIES} dlib)`. – nada Feb 27 '19 at 09:21
  • This solution suggested by Dlib and used in examples/CMakeLists.txt. The only problem is whenever you clean your project, Dlib will be cleaned also and it should be compiled again! – ma.mehralian Oct 02 '19 at 06:55
1

Here are the steps I followered,

For installing the dlib, change the link to the desired version

wget http://dlib.net/files/dlib-19.6.tar.bz2 
tar xvf dlib-19.6.tar.bz2
cd dlib-19.6/
mkdir build
cd build
cmake ..
cmake --build . --config Release
sudo make install
sudo ldconfig

In your project,

find_package(dlib REQUIRED)

target_link_libraries(try_convex  dlib::dlib)
GPrathap
  • 7,336
  • 7
  • 65
  • 83
0

Can you try these in top level CMakeLists.txt?

SET(dlib_ROOT "C:/dlib-19.13/")

or

SET(dlib_DIR "C:/dlib-19.13/" CACHE STRING "")
arun
  • 72
  • 8
  • Setting the dlib path manually is really not the correct way. If dlib was installed correctly, cmake would find it. If you are using Windows: MSYS2 supports dlib + cmake out of the box. – nada Feb 27 '19 at 09:28