How use external header file and codes in ROS CmakeList

asked 2022-06-30 15:44:48 -0600

farhad-bat gravatar image

updated 2022-06-30 20:53:12 -0600

I explained my question in stack overflow with more detail: 'https://stackoverflow.com/questions/72823620/use-sdk-libraries-header-files-etc-during-creating-a-c-ros-package'

Hello,

I am writing a ROS node with C++. My code uses an SDK. I do not know how to add it to my ROS node. I do not know how to modify Cmakelist.txt in order to use that.

In the SDK folder, there is an EXAMPLE folder. examples of SDK use Make files for building not CMake file.

Examples in the SDK use this make file, but I do not know how to convert them into CMakeList.txt

#
CC = g++
LD = $(CC)

ifndef ARCH
ARCH    := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/x86-64/)
endif

LU_LDFLAGS = -lm -lpthread -lstdc++

PROG = livePreview
VERSION = 0.1

LUMENERA_SDK := /home/farhad-bat/lumenera_camera/lucam-sdk_2.4.3.94/api/

INCLUDES = $(LUMENERA_SDK)/include
CFLAGS = -DVERSION=\"$(VERSION)\" -I$(INCLUDES) -g
CFLAGS += -DLUMENERA_LINUX_API
OBJS = 
ALL_INCLUDES =

all lu: $(PROG)

clean:
    rm -f $(PROG) *.o *.core core *.bak *~

livePreview: verify_environment livePreview.o Camera.o
    $(LD) livePreview.o Camera.o `pkg-config --libs opencv` -llucamapi $(LU_LDFLAGS) -o $@

verify_environment:
    @if test "$(LUMENERA_SDK)" = "" ; then \
        echo "LUMENERA_SDK environment variable is not set!"; \
        exit 1; \
    fi
Camera.o: Camera.cpp $(INCLUDES)/lucamapi.h
    $(CC) $(CFLAGS) -c Camera.cpp 

livePreview.o: livePreview.cpp $(INCLUDES)/lucamapi.h
    $(CC) $(CFLAGS) -c livePreview.cpp

Best,

edit retag flag offensive close merge delete