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
Related
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.
I have a C++ code base with a large number of projects. Usually I can use CMake to generate the required project files for QtCreator, XCode, Visual Studio, etc. Now I need to compile for Embarcadero, but it does not seem that CMake supports it.
Does CMake support Embarcadero? If not, is there maybe some set of projects that I could generate with CMake and then import into Embarcadero.
For a toy example it may work with the bcc and bcc32c, bcc64 is not supported at all.
Maybe the new "free" compiler will help to change that - the press release seems to imply this.
Personally, I would not put my hopes to high. So far, everything I have seen from the company Embarcadero was just a let down.
You can use CMake's "Borland Makefiles" generator and then use Embarcadero's clang based bcc32c to compile the project. Here's their blog post about it: https://community.embarcadero.com/blogs/entry/using-cmake-with-the-free-embarcadero-c-compiler
I didn't find a way to generate project files for their IDE yet, but I'm wondering if one could use one of the "Visual Studio" generators, then manually change the file extension (considering Embarcadero is using MSBuild). But that's just a wild guess.
According to the current CMake documentation on generators, no CMake does not produce Embarcadero project files. Instead, you could use one of the Makefile generators, and set your IDE to run cmake and make when you execute its "build" command.
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.
I am trying to set up Openscenegraph 3.0.1 with Cmake. I read different blog posts but it doesn't work.
I set up the paths, click compile and selected VS11 (because I have VS 2012) and use native compiler.
Then I directly get this error:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules CMakeCInformation.cmake:37 (get_filename_component):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
CMakeLists.txt:3 (PROJECT)
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Looking for include file pthread.h - not found
Also, more errors with the same stack trace occur. Also also could paste them here if you wish.
Afterwards, CMake tells me "Error in configuration process, project files may be invalid"
your problem isn't in compiler version that you are using; in fact, i'm running OpenSceneGraph 3(and osgEarth) with no problems on VisualStudio 2012.
What it seems to be is a problem with Cmake/CMakeLists.txt itself. Try to build some other projects using cmake, to see whether they work, or try to use a version of CMake that is close to what OpenSceneGraph needs(look at CMAKE_MINIMUM_REQUIRED in main CMakeLists.txt file), although CMake language is meant to be compatible with earlier versions, i dont know if this is always the case.
pthread.h has nothing to do with your problem, DOESN'T EXIST in Windows(except if you are using MinGW to look for some more problems), and is not required by OSG - i think, you configured OpenThreads correctly to not use libs you don't have. Anyway, that's just part of the job CMake does on each build - looks for some random stuff, like whether it can find pthreads.h or not, that give CMake some idea about your environment and don't usually relate to the projects you build with cmake. So just ignore that line about pthread.h
Under normal circumstances, CMake shouldn't be looking for pthread for Windows. Following is the couple of lines in CMake's (2.8) FindThreads.cmake which is used for searching appropriate modules.
...
CHECK_INCLUDE_FILES("pthread.h" CMAKE_HAVE_PTHREAD_H)
if(CMAKE_HAVE_PTHREAD_H)
...
endif()
...
if(CMAKE_SYSTEM MATCHES "Windows")
set(CMAKE_USE_WIN32_THREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
As you can see, first check should fail and roll out till the second check. However, I believe that in your case, CMake somehow finds that pthread.h (maybe you have MinGW as well) This seems to be a simple conflict in your system. Check your system's PATH etc. and try to fix it.
I want to build solution for Visual Studio.
As i know, minumum for it is cmake, zlib, jpeg and freetype.
I build freetype(debug and relise).
Downloaded compiled zlib dll.
(For Visual Studio you will need to build libjpeg with your version of Visual Studio. Download the libjpeg sources from here and unpack them into a working directory. I'll assume you've used C:\Developer\jpeg. Once the sources are unpacked, start a visual studio command prompt and cd into c:\developer\jpeg then run copy jconfig.vc jconfig.h then nmake /f makefile.vc /a) Jpeg done, or i need something more to do with it?
Then i make cmd file:
del cmakecache.txt
set FTDIR=C:\dev\freetype-2.4.5
set FTLIBDIR=C:\dev\freetype-2.4.5\objs\win32\vc2010
set JPEGDIR=C:\dev\jpeg
set ZLIBDIR=C:\developer\zlib128-dll
cmake -G "Visual Studio 10" c:\dev\podofo-0.9.2\ -DCMAKE_INCLUDE_PATH="%FTDIR%\include;%JPEGDIR%\include;%JPEGDIR%;%ZLIBDIR%\include" -DCMAKE_LIBRARY_PATH="%FTLIBDIR%;%FTDIR%\lib;%JPEGDIR%;%JPEGDIR%;%ZLIBDIR%\lib" -DPODOFO_BUILD_SHARED:BOOL=FALSE -DFREETYPE_LIBRARY_NAMES_DEBUG=freetype245MT_D -DFREETYPE_LIBRARY_NAMES_RELEASE=freetype245MT -DCMAKE_BUILD_TYPE=DEBUG
Then i can see that:
-- Looking for strings.h
-- Looking for strings.h - not found
-- Looking for arpa/inet.h
-- Looking for arpa/inet.h - not found
-- Looking for winsock2.h
-- Looking for winsock2.h - found
-- Looking for mem.h
-- Looking for mem.h - not found
-- Looking for ctype.h
-- Looking for ctype.h - found
Maybe problem is this or maybe in jpeg lib.
Instead of using nmake directly, I'd recommend you use cmake-gui for building PoDoFo. Don't write your own build.cmd as this doesn't work in most cases. Note : The method described below uses your method, don't follow it. Use cmake-gui (If you don't know how exactly cmake or nmake works).
Well I will recommend you go to this site and find the references:
Building static podofo with MSVS 2012
Well I guess this should work for Visual Studio 2010. Remember :
Building the prerequisite libraries - This site has also links about how to go on building these libraries. However, I assume you have already built them. However I would recommend building them again according to this tutorial.
Instructions : Do as he says. Don't miss any options regarding preprocessor definitions, runtime libraries and all the parameters same. If you miss anything or do something wrong that will force you to restart from where you started.
Errors : I myself experienced many errors while following the same procedure and this site provides no explanation. Common errors include:
Unresolved externals (either with msvcrt.lib or libcmt.lib). In that case, just go to Linker>Input>Ignore specific libraries and name that library there to just ignore it.
There will be random errors sometimes. I would suggest looking up Stack Overflow itself or MSDN or Google, because after starting off with >2500 errors I was finally able to build a static library.
Last Resort: If everything fails, just contact me (if you are still interested!).