CMake error while building MultiTarget-tracker library - c++

I'm trying to build Multitarget-tracker using CMake in windows. Initially I had this warning below:
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
Call Stack (most recent call first):
CMakeLists.txt:57 (find_package)
I manually pointed out the directory of build version of OpenCV library and tried to build. I referred this link while building. I now get this warning:
CMake Warning at CMakeLists.txt:23 (FIND_PACKAGE):
Found package configuration file:
C:/OpenCV/opencv/build/x86/vc12/lib/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
I tried to check the OpenCV_FOUND variable, but after I press 'configure' again, it automatically unchecks.

You're not supposed to check OpenCV_FOUND manually: it's a variable set by OpenCVConfig.cmake to tell CMake if OpenCV was found or not.
The fact it was set to FALSE is the sign your installation of OpenCV is not valid according to the package. Installing OpenCV properly is the solution.

Related

Cmake not able to find CGAL library(installed using vcpkg)

This is the error message:
CMake Error at D:/dev/vcpkg/scripts/buildsystems/vcpkg.cmake:788 (_find_package):
By not providing "FindCGAL.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CGAL", but
CMake did not find one.
Could not find a package configuration file provided by "CGAL" with any of
the following names:
CGALConfig.cmake
cgal-config.cmake
Add the installation prefix of "CGAL" to CMAKE_PREFIX_PATH or set
"CGAL_DIR" to a directory containing one of the above files. If "CGAL"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:16 (find_package)
I am trying to use the vcpkg toolchain file when building the project in Cmake; so all my installed libraries are available for Cmake but it is not working.

CMake can't find protobuf when compiling Google's protobuf example

I am trying to solve this problem for 2 days now with no luck. I've read an endless number of threads allover the web and tried a lot of suggestions but so far with no luck.
I'm doing this on Windows 10 with VS2017 and most recent VS Code installed. I installed protobuf with vcpkg install protobuf:
The package protobuf:x64-windows provides CMake targets:
find_package(protobuf CONFIG REQUIRED)
target_link_libraries(main PRIVATE protobuf::libprotoc protobuf::libprotobuf protobuf::libprotobuf-lite)
I downloaded Google's example code and extracted it on my drive. The .PROTO file compiles without a problem:
d:\protobuf-3.12.2\examples>protoc -I=d:\protobuf-3.12.2\examples --cpp_out=d:\protobuf-3.12.2\examples d:\protobuf-3.12.2\examples\addressbook.proto
and creates the two files "addressbook.pb.cc" and "addressbook.pb.h" as expected.
Now when I try to compile the project in Visual Studio Code it constantly fails no matter how I modify the CMakeLists.txt file. As mentioned I went through dozens of threads regarding this problem and tried a lot with no luck.
Update 29.05.2020
I checked that protobuf is installed just once and indeed the demo package also included a full protobuf installation. I removed this extra demo package and un-/installed protobuf with vcpgk. I then compiled the .proto file with protoc (which is in my path) and got the two files "addressbook.pb.cc" and "addressbook.pb.h".
Then I tried to compile the project again, this time using the CMakeLists.txt that came with the demo.
The relevant part seems to be right in the beginning:
# Minimum CMake required
cmake_minimum_required(VERSION 2.8.12)
# Project
project(protobuf-examples)
# Find required protobuf package
find_package(protobuf CONFIG REQUIRED)
if(protobuf_VERBOSE)
message(STATUS "Using Protocol Buffers ${Protobuf_VERSION}")
endif()
set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
Compiling this gives me:
[main] Building folder: examples
[main] Configuring folder: examples
[cms-client] Configuring using the "Visual Studio 15 2017" CMake generator with platform "x64" and toolset "host=x64"
[cmake] Selecting Windows SDK version 10.0.17763.0 to target Windows
...
[cmake] CMake Error at CMakeLists.txt:8 (find_package):
[cmake] Could not find a package configuration file provided by "protobuf" with any
[cmake] of the following names:
[cmake]
[cmake] protobufConfig.cmake
[cmake] protobuf-config.cmake
[cmake]
[cmake] Add the installation prefix of "protobuf" to CMAKE_PREFIX_PATH or set
[cmake] "protobuf_DIR" to a directory containing one of the above files. If
[cmake] "protobuf" provides a separate development package or SDK, be sure it has
[cmake] been installed.
[cmake]
[cmake]
[cmake] Configuring incomplete, errors occurred!
[cmake] See also "d:/vcpkg/buildtrees/protobuf/src/v3.12.0-8ba83cbbdb/examples/build/CMakeFiles/CMakeOutput.log".
[cms-driver] Error during CMake configure: [cmake-server] Configuration failed.
The file protobuf-config.cmake can be found multiple times in the protobuf folder:
D:\vcpkg\buildtrees\protobuf\<BUILDCFG>\share\protobuf\protobuf-config.cmake
D:\vcpkg\installed\<BUILDCFG>\share\protobuf\protobuf-config.cmake
D:\vcpkg\packages\<BUILDCFG>\share\protobuf\protobuf-config.cmake
What could be the cause that CMake can't locate these files?
Fair warning I am no expert.
I ran in to a similar problem in my own build trying to get Boost working and I think it has to do with your environment variables and how you have your Visual Studio setup. While you are setting crucial things such as
SET(PROTOBUF_INCLUDE_DIR "d:/vcpkg/packages/protobuf_x64-windows/include/")
The actual find_package(protobuf CONFIG REQUIRED) throws these settings out the window. Once it finds that config file it only cares about what the config file is finding, I think this is the cause of how your first MESSAGE has the right one, and then your 2nd one doesn't find one.
Are you positive you only have one installation of protobuf on your machine?
It appears to be finding this "used as include directory in directory D:/protobuf-3.12.2/examples"
yet you are trying to find "D:/vcpkg/packages/protobuf_x64-windows" no?
Try adding a "-DCMAKE_PREFIX_PATH="d:/vcpkg/packages/protobuf_x64-windows" to your CMake options in Visual Studio
Good luck and sorry if this doesn't help, I'm relatively new to programming but its worth a try.
in this thread fraser solved the problem but if you need to develop according to protobuf CMake config and find_package command in CMake for finding protobuf libraries. your protobuf library must be compiled with CMake and do not use configure routine .
after compile protobuf with CMake , a config file named protobuf-config.cmake will be generated into the prefix/lib/CMake/protobuf directory.
If the problem is in finding the protobuf installation then your protobuf path isn't on the Environment Variables try adding that to your path and let me know in case if it is there.
Will glad to help you more in case this doesn't work

Why I can't build opencv WITH_QT?

I've installed Qt5.12 on my Windows 7 x64. And CMake 3.16.
I want to build OpenCV-4.1.2. So in cmake I've checked WITH_QT and specified QT5_DIR as: C:\\Qt\\5.12.6 and then I click Configure. But I get this error:
CMake Error at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
Could not find a package configuration file provided by "Qt5" with any of
the following names:
Qt5Config.cmake
qt5-config.cmake
Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR"
to a directory containing one of the above files. If "Qt5" provides a
separate development package or SDK, be sure it has been installed.
Call Stack (most recent call first):
CMakeLists.txt:669 (include)"
I've finally figured it out: I've made a search inside the Qt directory for Qt5Config.cmake and found it in: "C:\Qt\5.12.6\msvc2017_64\lib\cmake\Qt5".
Now I specify this directory in CMake and click configure. Everything works fine. Thank you guys.

Compiling with CMake and ITK error

I'm trying to compile some code from here using CMake and ITK but I'm running into an error.
In CMake I select the source folder at /utilities/ITKImageSeriesToVolume and the build folder at /utilities/ITKImageSeriesToVolume/build. This however gives me an error:
CMake Error at CMakeLists.txt:42 (find_package):
By not providing "FindITK.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "ITK", but
CMake did not find one.
Could not find a package configuration file provided by "ITK" with any of
the following names:
ITKConfig.cmake
itk-config.cmake
Add the installation prefix of "ITK" to CMAKE_PREFIX_PATH or set "ITK_DIR"
to a directory containing one of the above files. If "ITK" provides a
separate development package or SDK, be sure it has been installed.
I have tried to set a CMAKE_PREFIX_PATH environment variable that points to the root folder of ITK containing ITKConfig.cmake but get the same error.
Hoping someone can help, thanks in advance.
EDIT: After setting ITK_DIR to the root ITK folder I get:
CMake Error at D:/Apps/InsightToolkit/ITK/ITKConfig.cmake:48 (include):
include could not find load file:
D:/Apps/InsightToolkit/Build/ITKTargets.cmake
Call Stack (most recent call first):
CMakeLists.txt:42 (find_package)
CMake Error at D:/Apps/InsightToolkit/Source/CMake/ITKModuleAPI.cmake:56 (message):
No such module: "ITKDoubleConversion"
Call Stack (most recent call first):
D:/Apps/InsightToolkit/Source/CMake/ITKModuleAPI.cmake:26 (itk_module_load)
D:/Apps/InsightToolkit/Source/CMake/ITKModuleAPI.cmake:84 (_itk_module_config_recurse)
D:/Apps/InsightToolkit/ITK/ITKConfig.cmake:68 (itk_module_config)
CMakeLists.txt:42 (find_package)
It has a simple fix as mentioned in the ERROR
"Add the installation prefix of "ITK" to CMAKE_PREFIX_PATH or set "ITK_DIR"
to a directory containing one of the above files. If "ITK" provides a
separate development package or SDK, be sure it has been installed."
Make sure your point the CMAKE_PREFIX_PATH and ITK to your ITK Build Directory. This is assuming you have already build ITK using Cmake atleast once.
Steps
1) Create ITK source folder.
2) Create ITK build folder.
3) Run CMake and select source and build folders.
4) Select respective compiler, and if there are any compiler issues refer this discussion.
5) Configure and generate cmake.
6) Open the build files in build folder with respective IDE (use .sln file if visual studio compilers are used).
7) Build all once on visual studio.
8) Now for your new project use same steps and point CMAKE_PREFIX_PATH and ITK to your ITK Build Directory.
And everything should work.
Good Luck!!!
Your ITK build seems to be partly broken. Can you try re-building it? If that does not help, see whether ITK_USE_SYSTEM_DOUBLECONVERSION is ON. That means not to build DoubleConversion library which comes with ITK but to use the one already present on the system. If it is not present, you have a problem.
Also, unless ITK_BUILD_DEFAULT_MODULES is ON, you have to specifically turn on each module or module group you want to be compiled. In that case, turn on ITKDoubleConversion, and any additional modules which that code requires.

qt creator opencv windows cmake error

I want to configure and then generate opencv library for qt creator to link them.
I opened cmake 3.1.0 and typed in the source and build path.
source:
C:/Users/Philipp_Laptop/Downloads/opencv/sources
build: C:/opencv-mingw
Then I configured the mingw-compiler with the path:
C:/Qt/Tools/mingw482_32/bin/gcc.exe
C:/Qt/Tools/mingw482_32/bin/g++.exe
After successful configure i set the with_Qt option.
I configured it twice and it shows me the following error:
Detected version of GNU GCC: 48 (408)
CMake Warning (dev) at cmake/OpenCVUtils.cmake:261 (if):
Policy CMP0054 is not set: Only interpret if() arguments as variables or
keywords when unquoted. Run "cmake --help-policy CMP0054" for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.
Quoted variables like "WIN32" will no longer be dereferenced when the
policy is set to NEW. Since the policy is not set the OLD behavior will be
used.
Call Stack (most recent call first):
CMakeLists.txt:127 (OCV_OPTION)
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Warning at cmake/OpenCVFindLibsGUI.cmake:18 (find_package):
By not providing "FindQt5Core.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Core", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5Core" with any
of the following names:
Qt5CoreConfig.cmake
qt5core-config.cmake
Add the installation prefix of "Qt5Core" to CMAKE_PREFIX_PATH or set
"Qt5Core_DIR" to a directory containing one of the above files. If
"Qt5Core" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:447 (include)
CMake Warning at cmake/OpenCVFindLibsGUI.cmake:19 (find_package):
By not providing "FindQt5Gui.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Gui", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5Gui" with any
of the following names:
Qt5GuiConfig.cmake
qt5gui-config.cmake
Add the installation prefix of "Qt5Gui" to CMAKE_PREFIX_PATH or set
"Qt5Gui_DIR" to a directory containing one of the above files. If "Qt5Gui"
provides a separate development package or SDK, be sure it has been
installed.
Call Stack (most recent call first):
CMakeLists.txt:447 (include)
CMake Warning at cmake/OpenCVFindLibsGUI.cmake:20 (find_package):
By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Widgets", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Widgets" with
any of the following names:
Qt5WidgetsConfig.cmake
qt5widgets-config.cmake
Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
"Qt5Widgets_DIR" to a directory containing one of the above files. If
"Qt5Widgets" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:447 (include)
CMake Warning at cmake/OpenCVFindLibsGUI.cmake:21 (find_package):
By not providing "FindQt5Test.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Test", but
CMake did not find one.
Could not find a package configuration file provided by "Qt5Test" with any
of the following names:
Qt5TestConfig.cmake
qt5test-config.cmake
Add the installation prefix of "Qt5Test" to CMAKE_PREFIX_PATH or set
"Qt5Test_DIR" to a directory containing one of the above files. If
"Qt5Test" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
CMakeLists.txt:447 (include)
CMake Warning at cmake/OpenCVFindLibsGUI.cmake:22 (find_package):
By not providing "FindQt5Concurrent.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"Qt5Concurrent", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Concurrent"
with any of the following names:
Qt5ConcurrentConfig.cmake
qt5concurrent-config.cmake
Add the installation prefix of "Qt5Concurrent" to CMAKE_PREFIX_PATH or set
"Qt5Concurrent_DIR" to a directory containing one of the above files. If
"Qt5Concurrent" provides a separate development package or SDK, be sure it
has been installed.
Call Stack (most recent call first):
CMakeLists.txt:447 (include)
Looking for Q_WS_X11
Looking for Q_WS_X11 - not found
Looking for Q_WS_WIN
Looking for Q_WS_WIN - found
Looking for Q_WS_QWS
Looking for Q_WS_QWS - not found
Looking for Q_WS_MAC
Looking for Q_WS_MAC - not found
Found OpenGL: opengl32
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:138 (message):
Could NOT find Qt4 (missing: QT_MOC_EXECUTABLE QT_RCC_EXECUTABLE
QT_QTTEST_LIBRARY QT_UIC_EXECUTABLE) (found version "4.8.6")
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindPackageHandleStandardArgs.cmake:374 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.1/Modules/FindQt4.cmake:1331 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/OpenCVFindLibsGUI.cmake:34 (find_package)
CMakeLists.txt:447 (include)
Configuring incomplete, errors occurred!
See also "C:/opencv-mingw/CMakeFiles/CMakeOutput.log".
See also "C:/opencv-mingw/CMakeFiles/CMakeError.log".
I used CMake GUI under Windows for this so I'll refer to this approach.
Let's start from problems related to CMAKE_PREFIX_PATH not defined.
To solve this you simply have to press ADD on the CMAKE GUI and add the variable of type PATH named CMAKE_PREFIX_PATH with value C:/Bin/Qt/5.3/mingw482_32/lib/cmake/ but using your own installation of Qt5. The directory you point now contains all modules you need: Qt5 directory, Qt5AxBase...
At this point you press configure and you should have QT_QMAKE_EXECUTABLE not valid. You need to set it properly, in my case: C:/Bin/Qt/5.3/mingw482_32/bin/qmake.exe.
Then press configuration again and see if some error is still present (you have others error I never saw but maybe they are consequence of the previous ones), in my case this solved all issues and the build proceeded.
The MINGW configuration seems to be fine: I did slightly different just putting the bin MINGW path in PAT variable as first entry and using the default compiler from CMAKE (but your solution is as valid as my one).