[CMake] library usage

Werner Smekal smekal at iap.tuwien.ac.at
Tue May 12 02:58:03 EDT 2009


Hi Simon,

scan through the documentation of cmake

http://www.cmake.org/cmake/help/cmake2.6docs.html

especially the commands part:

http://www.cmake.org/cmake/help/cmake2.6docs.html#section_Commands

In order to add include directories use include_directories

http://www.cmake.org/cmake/help/ 
cmake2.6docs.html#command:include_directories

in order to link to libraries use target_link_libraries

http://www.cmake.org/cmake/help/ 
cmake2.6docs.html#command:target_link_libraries

But in order to add packages like OpenCV to your project it's best to  
let CMake do it for you. Unfortunately cmake doesn't provide a  
FindOpenCV.cmake file for you, but a quick search on the internet  
shows that there is already such a package available:

http://eris.liralab.it/wiki/CMake_and_FIND_PACKAGE

or here:

http://code.google.com/p/touchlib/source/browse/trunk/CMakeModules/FindOpenCV.cmake

The wiki is also a good source for help and how to start a project:

http://www.cmake.org/Wiki/CMake

There are also tutorials.

HTH,
Werner

On 12.05.2009, at 03:33, Simon Friedberger wrote:

> Hello listmembers,
>
> I have just spent the better part of today trying to convert my old
> Makefile to a CMakeLists.txt and failed miserably. I may have made  
> some
> major mistakes since this is my first such effort.
>
> I could not figure out how to include libraries correctly so in the  
> end
> I tried to create the behavior of the old Makefile with cmake and not
> even that worked.
>
> Hence I posted my old Makefile, CMakeLists.txt and linker error at
> http://pastebin.com/m15d2b496
> http://pastebin.com/m23dda234
> http://pastebin.com/m20d3aae7
>
> It would be nice if somebody could take a look at it and give me a
> pointer to what might be wrong.
>
> In the long run an example how to include shared and/or static  
> libraries
> would be preferable of course. If you like I can also post my attempts
> in that direction.
>
> Best
> Simon
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake

--
Dr. Werner Smekal
Institut fuer Allgemeine Physik
Technische Universitaet Wien
Wiedner Hauptstr 8-10
A-1040 Wien
Austria

email: smekal at iap.tuwien.ac.at
web: http://www.iap.tuwien.ac.at/~smekal
phone: +43-(0)1-58801-13463 (office), +43-(0)1-58801-13469 (laboratory)
fax: +43-(0)1-58801-13499



More information about the CMake mailing list