On Fri, Oct 7, 2011 at 6:00 PM, Tim Coddington <tim.codding...@rteamworks.com> wrote: > 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. >
Something like the following: cmake_minimum_required(VERSION 2.8) PROJECT(MYProjectName) FIND_PACKAGE(MRPT REQUIRED hwdrivers slam) include(${MRPT_USE_FILE}) # Set your files and resources here SET(${PROJECT_NAME}_SRC ./src/file3.cpp ./src/file4.cpp ./src/main.cpp ) SET(${PROJECT_NAME}_HDR ./src/file1.h ./src/file2.h ./src/file3.h ./src/file4.h ) include_directories(src) ADD_EXECUTABLE( ${PROJECT_NAME} ${${PROJECT_NAME}_SRC} ${${PROJECT_NAME}_HDR}) TARGET_LINK_LIBRARIES( ${PROJECT_NAME} ${MRPT_LIBRARIES) -- 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