mtm
(mtm)
March 5, 2021, 8:13pm
1
Hi guys,
In Linux I always write Makefiles by hand since it is way easier. I gave cmake it a try in Windows, and here is the result:
I added
add_library(opencv_world451d STATIC IMPORTED)
set_property(TARGET opencv_world451d PROPERTY IMPORTED_LOCATION “C:\opt\opencv\build\x64\vc15\lib”)
target_include_directories( opencv_world451d “C:\opt\opencv\build\include”)
in code I have
#include “opencv2/core.hpp”
and the result is:
|Error (active)|E1696|cannot open source file “opencv2/core.hpp”|CMakeProject1.exe
I tried also using the simpler version
include_directories( “C:\opt\opencv\build\include”)
I tried with and without quotes etc… The result is always the same. So frustrating…
Any idea ?
ben.boeckel
(Ben Boeckel (Kitware))
March 5, 2021, 10:01pm
2
This is normally a filepath and not a directory. You also want this to be the .dll
and IMPORTED_IMPLIB
to be the .lib
file.
You’re missing an INTERFACE
here.
ben.boeckel
(Ben Boeckel (Kitware))
March 5, 2021, 10:01pm
3
Also, I would recommend using /
rather than Windows \
separators as the latter are escape characters in CMake strings, so you need \\
in the CMake source for that to work.
mtm
(mtm)
March 6, 2021, 11:11pm
4
Hi Ben,
Thank you for your reply.
So, I modified it to:
add_library(opencv_world451d STATIC IMPORTED)
set_property(TARGET opencv_world451d PROPERTY IMPORTED_IMPLIB “C:/opt/opencv/build/x64/vc15/lib/opencv_world451d.lib”)
target_include_directories( opencv_world451d INTERFACE “C:/opt/opencv/build/include”)
still can not find the includes. The VS output tab is of no help since there seems to not pass paths to ninja as a command line. Any idea what is still wrong? Any hint to get some debugging info from cmake ? Tnx.
ben.boeckel
(Ben Boeckel (Kitware))
March 7, 2021, 10:18pm
5
You could set INTERFACE_INCLUDE_DIRECTORIES
directly though I’d have expected the target_include_directories
to work.