How to find and link CUDA libraries using CMake 3.15? - c++

I'm using CMake 3.15-rc3 on my Unix-like system.
I need to link a program I'm building with several of the CUDA libraries, including cublas, cufft, cusolver, curand, nppicc, nppial, nppist, nppidei, nppig, nppitc, npps.
Based on what I found online, I need to do something like this:
add_executable(test benchmark.cpp)
find_package(CUDALibs)
target_link_libraries(test CUDA::cudart CUDA::cublas CUDA::cufft CUDA::cusolver CUDA::curand CUDA::nppicc CUDA::nppial CUDA::nppist CUDA::nppidei CUDA::nppig CUDA::nppitc CUDA::npps)
When I run make I get the following error:
CMake Warning at CMakeLists.txt:27 (find_package):
By not providing "FindCUDALibs.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "CUDALibs",
but CMake did not find one.
Could not find a package configuration file provided by "CUDALibs" with any
of the following names:
CUDALibsConfig.cmake
cudalibs-config.cmake
Add the installation prefix of "CUDALibs" to CMAKE_PREFIX_PATH or set
"CUDALibs_DIR" to a directory containing one of the above files. If
"CUDALibs" provides a separate development package or SDK, be sure it has
been installed.
So looks like I need a CUDALibsConfig.cmake file. Where do I get this file and how to I tell cmake to use it?
If I use the following it works:
find_package(CUDA REQUIRED)
target_link_libraries(run_benchmarks tf libmxnet.so ${CUDA_LIBRARIES} ${CUDA_cusparse_LIBRARY} ${CUDA_cublas_LIBRARY} ${CUDA_npp_LIBRARY})
But according to this find_package(cuda) is deprecated, so I want to learn the proper usage.
Edit
I tried what was suggested in one of the responses.
I added CUDA to the project LANGUAGES:
project(
test_project
DESCRIPTION "Test project"
LANGUAGES CXX CUDA
)
And then I used find_package( FindCUDAToolkit REQUIRED)
However, when I run cmake I get the following errors:
 nchafni   dev  …  sample_code  benchmarks  build  1  cmake ..
-- The CXX compiler identification is GNU 7.5.0
-- The CUDA compiler identification is NVIDIA 10.1.243
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working CUDA compiler: /usr/local/cuda-10.1/bin/nvcc
-- Check for working CUDA compiler: /usr/local/cuda-10.1/bin/nvcc -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
CMake Error at CMakeLists.txt:17 (find_package):
By not providing "FindFindCUDAToolkit.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"FindCUDAToolkit", but CMake did not find one.
Could not find a package configuration file provided by "FindCUDAToolkit"
with any of the following names:
FindCUDAToolkitConfig.cmake
findcudatoolkit-config.cmake
Add the installation prefix of "FindCUDAToolkit" to CMAKE_PREFIX_PATH or
set "FindCUDAToolkit_DIR" to a directory containing one of the above files.
If "FindCUDAToolkit" provides a separate development package or SDK, be
sure it has been installed.
-- Configuring incomplete, errors occurred!
What am I missing?

find_package(CUDA) is deprecated for the case of programs written in CUDA / compiled with a CUDA compiler (e.g. NVCC). The documentation page says (emphasis mine):
It is no longer necessary to use this module or call find_package(CUDA) for
compiling CUDA code. Instead, list CUDA among the languages named in
the top-level call to the project() command, or call the
enable_language() command with CUDA. Then one can add CUDA (.cu)
sources to programs directly in calls to add_library() and
add_executable().
But find_package(CUDA) was not really deprecated - as of CMake version 3.15 - for C++ code which simply uses CUDA-enabled/CUDA-bundled/CUDA-utilizing libraries.
In CMake 3.17, a new macro/command was introduced: FindCUDAToolkit() (and this, find_package(CUDAToolkit). You can't use that with your version of CMake; find_package(CUDA) will do just fine, even if it's a bit clunky and outdated.
Edit: It is actually very easy to upgrade to a newer CMake version: KitWare offer binary releases which have very little dependencies. On a Linux system they would be:
linux-vdso.so.1
libdl.so.2
librt.so.1
libpthread.so.0
libm.so.6
libc.so.6
/lib64/ld-linux-x86-64.so.2
... and you would be hard-pressed to find a system without these. Also, even when installed under an arbitrary path, CMake will be able to differentiate between its version of shared files and whatever the system version of CMake uses. So - no reason to stick with the old version.

The documentation you linked says that you need to add CUDA to the list of languages in your project() command. And to find CUDA libraries it says to use FindCUDAToolkit module, not that CUDALibs.

Related

Using vcpkg to install RTABMap with VSCode as editor

I want to install RTABMap with vcpkg and then use VSCode as editor to include RTABMap into my C++ project. I installed RTABMap as described on their wiki with vcpkg install rtabmap:x64-windows (i also tried the x86 triplet) and then wanted to use it in my project. To get started I wrote the following cmake file based on an example from their repository:
cmake_minimum_required(VERSION 3.5)
project(RTABMap_Test VERSION 0.1.0)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}")
find_package(RTABMap REQUIRED)
find_package(OpenCV REQUIRED)
set(INCLUDE_DIRS
${RTABMap_INCLUDE_DIRS}
${OpenCV_INCLUDE_DIRS}
)
set(LIBRARIES
${RTABMap_LIBRARIES}
${OpenCV_LIBRARIES}
)
include_directories(${INCLUDE_DIRS})
add_executable(RTABMap_Test main.cpp)
target_link_libraries(RTABMap_Test ${LIBRARIES})
and the following main.cpp file:
#include <rtabmap/core/Rtabmap.h>
int main(void) {
return 0;
}
The cmake settings in VSCode are as follows:
"cmake.configureSettings": {
"CMAKE_TOOLCHAIN_FILE": "G:/.vcpkg/scripts/buildsystems/vcpkg.cmake",
"VCPKG_TARGET_TRIPLET": "x64-windows"
}
However, when I run CMake: Build from VSCode, cmake fails with the following message:
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.32.31332.0
-- The CXX compiler identification is MSVC 19.32.31332.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.32.31326/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning at G:/.vcpkg/installed/x64-windows/share/rtabmap/RTABMapConfig.cmake:78 (MESSAGE):
Asked for "gui" module but RTABMap hasn't been built with gui support.
Call Stack (most recent call first):
G:/.vcpkg/scripts/buildsystems/vcpkg.cmake:843 (_find_package)
CMakeLists.txt:6 (find_package)
-- Found RTABMap: RTABMap_CORE_RELEASE-NOTFOUND;RTABMap_UTILITE_RELEASE-NOTFOUND;optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib
-- Found Protobuf: G:/.vcpkg/installed/x64-windows/tools/protobuf/protoc.exe (found version "3.21.12.0")
-- Looking for pthread.h
-- Looking for pthread.h - not found
-- Found Threads: TRUE
-- Found TIFF: optimized;G:/.vcpkg/installed/x64-windows/lib/tiff.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/tiffd.lib (found version "4.5.0")
-- Found HDF5: hdf5::hdf5-shared (found version "1.12.2")
-- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found suitable version "1.2.13", minimum required is "1")
-- Found JPEG: optimized;G:/.vcpkg/installed/x64-windows/lib/jpeg.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/jpeg.lib (found version "62")
-- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found version "1.2.13")
-- Found PNG: optimized;G:/.vcpkg/installed/x64-windows/lib/libpng16.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/libpng16d.lib (found version "1.6.39")
-- Found GIF: optimized;G:/.vcpkg/installed/x64-windows/lib/gif.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/gif.lib (found version "5.2.1")
-- Found LibArchive: G:/.vcpkg/installed/x64-windows/debug/lib/archive.lib (found version "3.6.2")
-- Found OpenCV: G:/.vcpkg/installed/x64-windows (found version "4.7.0")
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
RTABMap_CORE_RELEASE
linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test
RTABMap_UTILITE_RELEASE
linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
On the other hand, when I run cmake . -DCMAKE_TOOLCHAIN_FILE=G:/.vcpkg/scripts/buildsystems/vcpkg.cmake I get this error:
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
CMake Warning at G:/.vcpkg/installed/x64-windows/share/rtabmap/RTABMapConfig.cmake:78 (MESSAGE):
Asked for "gui" module but RTABMap hasn't been built with gui support.
Call Stack (most recent call first):
G:/.vcpkg/scripts/buildsystems/vcpkg.cmake:843 (_find_package)
CMakeLists.txt:6 (find_package)
-- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found suitable version "1.2.13", minimum required is "1")
-- Found ZLIB: optimized;G:/.vcpkg/installed/x64-windows/lib/zlib.lib;debug;G:/.vcpkg/installed/x64-windows/debug/lib/zlibd.lib (found version "1.2.13")
-- Configuring done
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
RTABMap_CORE_RELEASE
linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test
RTABMap_UTILITE_RELEASE
linked by target "RTABMap_Test" in directory G:/FKIE/rtabmap_test
-- Generating done
CMake Generate step failed. Build files cannot be regenerated correctly.
The two missing variables are set in the RTABMapConfig.cmake.in located at the root directory of the RTABMap repository and used by the CMakeLists.txt, so I assume that I don't have to set them manually, meaning -- as far as I can tell -- when vcpkg installs RTABMap it doesn't properly configure RTABMap.
What to do?
I had to write this as an answer due to character limitation. It's however more of a hint on what to look at rather then how to fix it.
Let's take a look at how RTABMapConfig.cmake is generated via the precursor file RTABMapConfig.cmake.in:
Lines 18-21:
find_library(RTABMap_CORE_RELEASE NAMES rtabmap_core NO_DEFAULT_PATH HINTS #CONF_LIB_DIR#)
find_library(RTABMap_CORE_DEBUG NAMES rtabmap_cored NO_DEFAULT_PATH HINTS #CONF_LIB_DIR#)
IF(RTABMap_CORE_DEBUG AND RTABMap_CORE_RELEASE)
#...
Not ideal for a .cmake.in but I'm not going to judge that. All that I'm going to say is that parts of the code rely on certain variables being set. The same variables that were "NOT FOUND" in your generation i.e. this line in the generation step:
-- [...] RTABMap_CORE_RELEASE-NOTFOUND [...]
If you would traverse the .cmake.in file down you would notice the same for the other "NOT FOUND" variable.
Later on we have:
Line 47:
set(RTABMap_LIBRARIES ${RTABMap_CORE} ${RTABMap_UTILITE})
Which is (as you probably know by now) empty.
Conclusion and possible solutions:
The RTABMapConfig.cmake can't find the proper libraries (if they exist) this can be caused either by the fact that during the vcpkg install phase something went wrong and the libraries weren't built OR the RTABMapConfig.cmake was poorly generated and needs to be fixed (the paths to the core and utilite libraries specifically)
Check if something like rtabmap_core.lib exists and if not - compilation failed and you need to reinstall rtabmap
If ad1) isn't the case then open up the RTABMapConfig.cmake and look at the paths to these libraries - fix them if needed.
EDIT: If I were you I would open up an issue on vcpkg's github.

CMake issues -- Could not find a package configuration file provided by "OpenCV"

I am having an issue building a project using Cmake, which I have never done before. I am new to C++ and the concept of Cmake and Makefiles. I am trying to recreate some results from some code off of GitHub. The instructions/files can be found here if you would like to take a more detailed look:
https://github.com/jan-dufek/Fotokite
So basically there are four steps he lists to do:
1-)Install CMake:
https://cmake.org
2-) In Terminal, change directory into the root directory of the project and run the following command to generate makefile:
cmake .
3-) Compile the project:
make
4-) Run:
./Fotokite
Basically I am stuck on the 2nd step right now because I keep getting the following error in my terminal after navigating to the folder and running "cmake .".
The C compiler identification is AppleClang 11.0.3.11030032
The CXX compiler identification is AppleClang 11.0.3.11030032
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
Detecting C compile features
Detecting C compile features - done
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OpenCV", but
CMake did not find one.
Could not find a package configuration file provided by "OpenCV" with any
of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
I have OpenCV downloaded onto my Desktop as well, and I tried incorporating the path into the Cmake file but still am not having any luck.
Here is also the Cmakelists.txt:
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
project(Fotokite)
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
file(GLOB SOURCES
*.h
*.hpp
*.cpp
)
list(FILTER SOURCES EXCLUDE REGEX "main.*.cpp")
list(FILTER SOURCES EXCLUDE REGEX "Visualization.*")
foreach (FILE "" Takeoff GoToWaypoint ExecutePath Land)
add_executable(Fotokite${FILE} ${SOURCES} main${FILE}.cpp)
target_link_libraries(Fotokite${FILE} ${OpenCV_LIBS} pthread)
endforeach(FILE)
First time posting on this website so sorry if something is unclear, if so I can provide more details! Looking forward to your responses.
The following error message details the cause of the issue:
CMake Error at CMakeLists.txt:5 (find_package): By not providing
"FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has asked CMake
to find a package configuration file provided by "OpenCV", but CMake
did not find one.
Could not find a package configuration file provided by "OpenCV" with
any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If
"OpenCV" provides a separate development package or SDK, be sure it
has been installed.
What this means is that when the call to find_package is made, CMake has two modes to finding dependencies, “Module” mode and “Config” mode. Module mode means that somewhere on CMakes modules path it can find a file called FindOpenCV.cmake. By default CMake ships with lots of preprepared find modules, however, it does not ship with one for OpenCV by default. In this case, you could add it your self (just google for FindOpenCV.cmake and you'll find examples) however this in the wrong approach, I'll explain why.
When you produce a library build using CMake, if you expect to have downstream clients who will depend on your library then you should make it easy to use. CMake supports this through “Config” mode. When you write a library using CMake as part of the install step (this is the step that can be run to package a library into an installable set of files and folder structure after building). You can see an example of how to set this up for a project here: https://gitlab.kitware.com/cmake/community/-/wikis/doc/tutorials/How-to-create-a-ProjectConfig.cmake-file. At this point you don't need to know how to do this, just that libraries should do this because they have the information to export targets for a library correctly. If they don't then it become necessary for users to access a library in “Module” mode, which involved creating a find<library>.cmake which instruction detailing how to locate the file.
However, OpenCV using CMake does thankfully correctly create and install a OpenCVConfig.cmake file allowing users to use “Config” mode to access it. There issue here then seems that you have not installed OpenCV into one of the standard system install directories which “Config” mode searched by default. The list of search locations is detailed here: https://cmake.org/cmake/help/v3.19/command/find_package.html. To fix this you can pass in the PATH parameter to find_package so that it looks in additional locations:
find_package(OpenCV REQUIRED PATH <location to OpenCV installation>)
I have seen similar issue while using buildroot to build something.
when I check the log, found
>>> xxxxxx Configuring
>>> xxxxxx Installing to target
xxxxxxxxxxxxxx DESTDIR= xxxxxxxxxxxxxxx
please take a close look at the DESTDIR variable. it might be impacted by "FOO_INSTALL_STAGING = YES" command in xxx.mk file.

C++11 activation with <target_compile_feature> or <set (CMAKE_CXX_STANDARD)>

I'm using a Python library, named PyPHS, specialized in physical modeling.
To save computation during the simulation, it implements a C++ code generation feature. It uses CMake to generate an executable of a particular simulation.
It is implemented in C++ 11.
Issue
In the CMakeLists.txt file, the C++ 11 feature is activated by the following line:
target_compile_features(<project_name> PUBLIC cxx_std_11)
On my computer (CMake 3.5.1 & Ubuntu 16.04.4 Xenial Xerus), CMake throws an error: this feature is unknown:
-- The CXX compiler identification is GNU 5.4.0
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:31 (target_compile_features):
target_compile_features specified unknown feature "cxx_std_11" for target
"dampedosc".
```
-- Configuring incomplete, errors occurred!
See also "/home/victorw/git/vocal-phs/python/output/dampedosc/CMakeFiles/CMakeOutput.log".
This error has not been encountered on other installs (Debian 8, Mac OSX or windows 7)
Fix
I’ve changed the CMakeLists.txt template. Here is the link to the commit, on my own fork of PyPHS.
I’ve replaced the target_compile_features(<project_name> PUBLIC cxx_std_11) by set (CMAKE_CXX_STANDARD 11)
Question
What is the difference between the two commands?
What are your insights on this matter? Did I forget to mention some information?
Thank you for your answers!
The cxx_std_11 compiler meta-feature is not available in your version of CMake. it was introduced in 3.8, so this would explain the error, CMake 3.8 release notes.
The difference between the two is that target_compile_features() can request specific features for a specific target. CMake will automatically apply the appropriate standard to the specified target. If you on the other hand set CMAKE_CXX_STANDARD, then the requested standard, if supported by CMake, is applied project wide (for all targets).
As mentioned, you can as of CMake 3.8 request an entire standard using target_compile_features(), in which case the only difference from setting CMAKE_CXX_STANDARD is that the standard is only applied to the specified target (read below).
Note that if you invoke target_compile_features with PRIVATE scope, then the requested features/standard will apply only to the specified target, if instead PUBLIC is set, then the requested features/standard will also be applied to any target that depend on that target.

Building cpp-netlib with CMake

I've downloaded the cpp-netlib source, extracted it to a folder and for some reason I'm completely lost. I read the documentation carefully, it states I have to download CMake as well, which I did. Then I set the source directory and build directories, and upon clicking the "Generate" button I got this output:
The CXX compiler identification is MSVC 19.0.23506.0
Check for working C compiler using: Visual Studio 14 2015
Check for working C compiler using: Visual Studio 14 2015 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 14 2015
Check for working CXX compiler using: Visual Studio 14 2015 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.5/Modules/FindBoost.cmake:1657 (message):
Unable to find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the root
directory containing Boost or BOOST_INCLUDEDIR to the directory containing
Boost's headers.
Call Stack (most recent call first):
CMakeLists.txt:49 (find_package)
Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR)
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
CMake Error at CMakeLists.txt:131 (export):
export given target "cppnetlib-client-connections" which is not built by
this project.
Configuring incomplete, errors occurred!
See also "C:/Users/Nick/Documents/cpp-netlib/cpp-netlib-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/Nick/Documents/cpp-netlib/cpp-netlib-build/CMakeFiles/CMakeError.log"
It couldn't find the Boost libraries, and that's where I'm stuck. I installed boost, but I have no idea where to set "BOOST_ROOT". I did some research on that, tried to use the command line with the -DBOOST_ROOT option like so:
c:\Program Files>cmake -DBOOST_ROOT=/boost/boost_1_55_0
But it gives me the following error:
CMake Error: The source directory "C:/Program Files" does not appear to contain
CMakeLists.txt.
Specify --help for usage, or press the help button on the CMake GUI.
I'm really unsure as to what to do now and I feel this isn't the end of my problems... Is there anything obvious I'm missing?
You need to either run cmake from the source tree (which would contain CMakeLists.txt), or, more typically, run it from a build folder and tell it where the source tree is.
A common case would be creating a build folder next to the source tree and running cmake ../sourcedir.
You seem to have initially been using a gui; surely that provides a means to set the BOOST_ROOT variable?
Alternatively, if you just put boost in the VC++ include/lib paths (either in the vc dirs, or by setting %INCLUDE%/%LIB%), you probably would not need BOOST_ROOT. Same for OpenSSL.

Run ArUco example using Cmake

I am new to Cmake and to build projects using it. I have not used this tool before and hence have less knowledge on how it works.
I am trying to get the examples of the ArUco library run. But the README provided by the ArUco library suggests to use the Cmake to run them. I have Windows 8.1 and Visual studio 2013 and I have also downloaded and installed the Cmake3.4.0 .
After installing it I searched for examples or tutorials on Cmake, and found a few video tutorials that showed how to compile programs using cmake. But while followed the same steps I got errors. Error is as shown
I went through different questions posted in the forum but didn't find an answer. I am not sure I need to set Environment variables and paths. Some suggestions on this would be really helpful.
Thank you very much for the help.
Error:
The C compiler identification is MSVC 18.0.40629.0
The CXX compiler identification is MSVC 18.0.40629.0
Check for working C compiler using: Visual Studio 12 2013
Check for working C compiler using: Visual Studio 12 2013 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 12 2013
Check for working CXX compiler using: Visual Studio 12 2013 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "Findaruco.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "aruco", but
CMake did not find one.
Could not find a package configuration file provided by "aruco" with any of
the following names:
arucoConfig.cmake<br/>
aruco-config.cmake<br/>
Add the installation prefix of "aruco" to CMAKE_PREFIX_PATH or set
"aruco_DIR" to a directory containing one of the above files. If "aruco"
provides a separate development package or SDK, be sure it has been
installed.
Configuring incomplete, errors occurred!
See also "E:/../aruco_testproject/build/CMakeFiles/CMakeOutput.log".
I had the same issue on Mac, hope Windows users find this useful too.
Most probably you did't install aruco. Go to the aruco source folder that you dowloaded (ie ~/Downloads/aruco-2.0.14) and run following commands
cmake .
make
make install
Then you will be able to build aruco_testproject
cmake .
make
Hope this helps
Actually its pretty clear whats goin wrong. CMake cant find certain packages.
Quick and dirty solution
One solution is to do what the error message suggests:
Go into the specific CMakeLists.txt file and set the aruco_Dir variable like that
set( auruco_Dir /PATH/TO/ARUCO/WHERE/AURUCOCONFIG.CMAKE/IS/LOCATED/AS/WELL )
The true way
A better approach is to provide the Findaruco.cmake module in the CMAKE_MODULE_PATH. This is called module because it integrates with CMake's find_package mechanism (https://cmake.org/cmake/help/v3.0/command/find_package.html, Last accessed at 11.12.2015) and provides the central information about where aruco can be found in your file system. (Aruco is just exemplary here. Same goes for any other module)
What is this good for, why do I need find_packageand those modules?
Answer is simple. You have only one central place to manage and not many. Imagine the location of your pacjage changes. Do you want to fix every single CMakeLists.txt file referencing this package?
Its like basic programming paradigms
Dont repeat yourself
Dont hardcode anything