Including ipopt code in my ROS project with cmakelist.txt

Hi,

I am trying to include the ipopt code in my ROS project but do not know what to do in my Cmakefile.txt document.

First I start with what I have done so far:

I downloaded the ipopt and third party code, and afterwards compiled it as described here: https://www.coin-or.org/Ipopt/documentation/node10.html

On the other end I am setting up a ROS project where I want to use the ipopt solver in. ROS is using an own build engine (catkin_make) which is however pretty similar to the standard cmake.

In the ipopt/build directory there are examples how to interface ipopt from c++ which is working but using a makefile. However I don't know how to translate into my cmakelist.txt.

My guess would be that I have to add another find_package("Correct package name of ipopt" REQUIRED) as well as target_link_libraries(executableName ${ipopt_LIBRARIES}). But I don#t have a clue how the package name is nor what has to be definer for ipopt_Libraries and how to it.

Every help would appreciated.


FYI: The Makefile of the example looks like this:

# CHANGEME: This should be the name of your executable
EXE = test

# CHANGEME: Here is the name of all object files corresponding to the source
# code that you wrote in order to define the problem statement
OBJS = hs071_main.o \
hs071_nlp.o

# CHANGEME: Additional libraries
ADDLIBS =

# CHANGEME: Additional flags for compilation (e.g., include flags)
ADDINCFLAGS =

##########################################################################
# Usually, you don't have to change anything below. Note that if you #
# change certain compiler options, you might have to recompile Ipopt. #
##########################################################################

# C++ Compiler command
CXX = g++

# C++ Compiler options
CXXFLAGS = -O3 -pipe -DNDEBUG -Wparentheses -Wreturn-type -Wcast-qual -Wall -Wpointer-arith -Wwrite-strings -Wconversion -Wno-unknown-pragmas -Wno-long-long -DIPOPT_BUILD

# additional C++ Compiler options for linking
CXXLINKFLAGS = -Wl,--rpath -Wl,/home/moritz/Downloads/CoinIpopt/build/lib

# Include directories (we use the CYGPATH_W variables to allow compilation with Windows compilers)
INCL = `PKG_CONFIG_PATH=/home/moritz/Downloads/CoinIpopt/build/lib64/pkgconfig:/home/moritz/Downloads/CoinIpopt/build/lib/pkgconfig:/home/moritz/Downloads/CoinIpopt/build/share/pkgconfig:/home/moritz/catkin_ws/devel/lib/pkgconfig:/opt/ros/lunar/lib/pkgconfig:/opt/ros/lunar/lib/x86_64-linux-gnu/pkgconfig pkg-config --cflags ipopt` $(ADDINCFLAGS)
#INCL = -I`$(CYGPATH_W) /home/moritz/Downloads/CoinIpopt/build/include/coin` $(ADDINCFLAGS)

# Linker flags
LIBS = `PKG_CONFIG_PATH=/home/moritz/Downloads/CoinIpopt/build/lib64/pkgconfig:/home/moritz/Downloads/CoinIpopt/build/lib/pkgconfig:/home/moritz/Downloads/CoinIpopt/build/share/pkgconfig:/home/moritz/catkin_ws/devel/lib/pkgconfig:/opt/ros/lunar/lib/pkgconfig:/opt/ros/lunar/lib/x86_64-linux-gnu/pkgconfig pkg-config --libs ipopt`
##LIBS = -link -libpath:`$(CYGPATH_W) /home/moritz/Downloads/CoinIpopt/build/lib` libipopt.lib -llapack -lblas -lm -ldl
#LIBS = -L/home/moritz/Downloads/CoinIpopt/build/lib -lipopt -llapack -lblas -lm -ldl

# The following is necessary under cygwin, if native compilers are used
CYGPATH_W = echo

all: $(EXE)

.SUFFIXES: .cpp .c .o .obj

$(EXE): $(OBJS)
bla=;\
for file in $(OBJS); do bla="$$bla `$(CYGPATH_W) $$file`"; done; \
$(CXX) $(CXXLINKFLAGS) $(CXXFLAGS) -o $@ $$bla $(ADDLIBS) $(LIBS)

clean:
rm -rf $(EXE) $(OBJS) ipopt.out

.cpp.o:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ $<


.cpp.obj:
$(CXX) $(CXXFLAGS) $(INCL) -c -o $@ `$(CYGPATH_W) '$<'`
Topic archived. No new replies allowed.