[CMake] simple cmake example

Tim Coddington tim.coddington at rteamworks.com
Fri Oct 7 18:00:18 EDT 2011


Hi
   I recently started working with open source code that uses cmake for
build.  I've been able to make do since most of the CMakeLists.txt files
are provided or specific instructions are given.

   I'm about to embark on my first contribution to build a driver for an
IMU and I want to build an example that is very similar to mine but it's
been "extracted" from an existing code tree, i.e. current CMakeLists.txt
files would port easily.

   I'm having problems constructing what should be a relatively
straightforward CMakeLists.txt file for the extracted code that I want
to run in isolation.  I've been reading tutorials, etc but I don't seem
to get it.  Please consider
taking my general C++ example described below and tell me what (exactly)
the CMakeLists.txt should look.  

[Ubuntu 11.04, cmake 2.8.3, C++ code]

Given:
Top level directory "proj/" and subdir "proj/src"

The proj/ directory shall contain the parent CMakeLists.txt and
proj/src shall contain a child CMakeLists.txt (if
necessary/appropriate).

The src/ directory contains these source related files:

file1.h       >> header only no associated cpp file
file2.h       >> header only " 
file3.h    
file3.cpp
file4.h
file4.cpp
main.cpp

In addition to standard references, some of these files depend on
external library which is found with the FIND_PACKAGE(MRPT REQUIRED
hwdrivers slam)    [note: these libraries come from Mobile Robot
Programming Toolkit]   

Please tell me what the two (or one) CMakeLists.txt file(s) should
contain in order to build this code.

Thanks






More information about the CMake mailing list