ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Makefile to CMakeLists.txt (ROS, Eclipse)

asked 2013-08-04 03:32:57 -0600

mozcelikors gravatar image

updated 2014-01-28 17:17:32 -0600

ngrennan gravatar image

Hello there,

I'm using a developement board that has its own libraries. I have installed ROS on it and now I need to use publish/subscribe by including its libraries to the CMakeLists.txt of the package. I have to also note that I use Eclipse for compilation, so the CMakeLists.txt is in that form. Here is the Makefile of hardware library that I want to use in CMakeLists.txt:

DIR=$(shell pwd)/../

INCS = -I.\
        -I$(DIR) \
        -I$(DIR)/hardware \
        -I$(DIR)/hardware/environment \
        -I$(DIR)/hardware/environment/cores \
        -I$(DIR)/hardware/environment/cores/environment \
        -I$(DIR)/hardware/environment/variants \
        -I$(DIR)/hardware/environment/variants/sunxi \
        -I$(DIR)/libraries \
        -I$(DIR)/libraries/Serial \
        -I$(DIR)/libraries/SPI \
    -I$(DIR)/libraries/Wire \
    -I$(DIR)/libraries/LiquidCrystal \
    -I$(DIR)/Basibos/include
LIBS=../libenvironment.a
TARGET=../output/test

OBJS = BasibosAnaProgram

all: 
    @mkdir -p $(TARGET)
    for i in $(OBJS); do echo "$(CXX) $(INCS) $$i.cpp -o $(TARGET)/$$i $(LIBS)"; done
    @for i in $(OBJS); do $(CXX) $(INCS) $$i.cpp -o $(TARGET)/$$i $(LIBS); done

clean:
    @for i in $(OBJS); do rm -f $(TARGET)/$$i; done

And here is the example CMakeLists.txt that Makefile should be included:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)

rosbuild_init()

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_add_library(${PROJECT_NAME} src/Basibos.cpp)
rosbuild_add_library(${PROJECT_NAME} src/HedefeGitme.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Konum.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Robot.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Sonar.cpp)
rosbuild_add_library(${PROJECT_NAME} src/Zaman.cpp)
rosbuild_add_library(${PROJECT_NAME} src/XMLAyiklayici.cpp)

rosbuild_add_executable(srctest RobotKontrol.cpp)

target_link_libraries(srctest ${PROJECT_NAME})

I'm stuck and can't go forward without help. Any help will be greately appreciated. Thanks in advance

edit retag flag offensive close merge delete

Comments

1
vonovak gravatar image vonovak  ( 2013-08-04 09:19:46 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-08-04 09:20:48 -0600

vonovak gravatar image

updated 2013-08-04 09:31:57 -0600

the CMakeLists.txt is not influenced by eclipse

you should be able to build the library (libenvironment.a if I see correctly) with the makefile that you have, and then use find_package(YOUR_LIB) in your CMakeLists.txt (there is no need to build the library every time you build your project)

see cmake help on how to include libraries

edit flag offensive delete link more

Comments

I will try that and get back to you. Thanks

mozcelikors gravatar image mozcelikors  ( 2013-08-04 09:47:56 -0600 )edit

How can I use libenvironment.a file in find_package function?

mozcelikors gravatar image mozcelikors  ( 2013-08-04 10:23:37 -0600 )edit

you probably need to write your own find module. don't worry, it's not a big deal. everything is described in the help page i linked to. to sketch the outline: create FindLIBENVIRONMENT.cmake and put it in a dir in ur package inside of the file use FIND_PATH to find the dir with the library's header file add the dir path to CMAKE_MODULE_PATH

vonovak gravatar image vonovak  ( 2013-08-04 10:36:42 -0600 )edit

that describes finding a library from header files, but I have .a extensioned file. I presume it is like .so

mozcelikors gravatar image mozcelikors  ( 2013-08-04 10:39:37 -0600 )edit
vonovak gravatar image vonovak  ( 2013-08-04 10:41:28 -0600 )edit

There is too many arguments that will probably not be useful. Can you help me writing this module and attach to your answer. for example the lib is located at ~/libenvironment.a

mozcelikors gravatar image mozcelikors  ( 2013-08-04 10:45:07 -0600 )edit

sorry, u have the figure that one by yourself... I've got work of my own, you see.

vonovak gravatar image vonovak  ( 2013-08-04 10:52:26 -0600 )edit

okay I've written a FindEnvironment.cmake and moved it to /usr/share/cmake-2.8/Modules/ and now that file cannot be found and it suggests me to make a config.cmake file. (which indicates that Find<>.cmake is not found) What should I do?

mozcelikors gravatar image mozcelikors  ( 2013-08-04 11:59:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2013-08-04 03:32:57 -0600

Seen: 2,380 times

Last updated: Aug 04 '13