Makefile to CMakeLists conversion not working

Hi everyone,
I have a problem and I'm not sure if this is the right way to ask about it.
I'm working on a project whose CMakeLists file is

1
2
3
4
5
6
  cmake_minimum_required(VERSION 2.8)
project( colorTracking )
find_package( OpenCV REQUIRED )
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pthread")
add_executable( colorTracking colorTracking.cpp mavlink_example.h serialUart.cpp serialUart.h)
target_link_libraries( colorTracking ${OpenCV_LIBS}) 


Now, I want to add something to the project. I can build the new code seperately using Make
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Makefile for Basler pylon sample program
.PHONY: all clean
NAME       := Grab
PYLON_ROOT ?= /opt/pylon5
LD         := $(CXX)
CPPFLAGS   := $(shell $(PYLON_ROOT)/bin/pylon-config --cflags)
CXXFLAGS   := #e.g., CXXFLAGS=-g -O0 for debugging
LDFLAGS    := $(shell $(PYLON_ROOT)/bin/pylon-config --libs-rpath)
LDLIBS     := $(shell $(PYLON_ROOT)/bin/pylon-config --libs)
CFLAGS = `pkg-config --cflags opencv`
LIBS = `pkg-config --libs opencv`

all: $(NAME)
$(NAME): $(NAME).o
	$(LD) $(LDFLAGS) $(CFLAGS) -o $@ $^ $(LDLIBS) $(LIBS)
$(NAME).o: $(NAME).cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
clean:
	$(RM) $(NAME).o $(NAME)


I want to build the whole project using cmake. I need to add this makefile in CMakeLists.txt. Here is my try but it's not working

1
2
3
4
5
6
7
8
9
10
cmake_minimum_required(VERSION 2.8)
project( colorTracking )
find_package( OpenCV REQUIRED )
include_directories(/opt/pylon5/include)    # -I flags for compiler
link_directories(/opt/pylon5/lib)           # -L flags for linker
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -std=c++11 -pthread -Wno-unknown-pragmas -L/opt/pylon5/lib -Wl,-E -lpylonbase -lpylonutility -lGenApi_gcc_v3_0_Basler_pylon_v5_0 -lGCBase_gcc_v3_0_Basler_pylon_v5_0")
set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} -I/opt/pylon5/include) #CPPFLAGS
set(CMAKE_SHARED_LINKER_FLAGS -Wl,--enable-new-dtags -Wl,-rpath,/opt/pylon5/lib)
add_executable( colorTracking colorTracking.cpp mavlink_example.h serialUart.cpp serialUart.h)
target_link_libraries( colorTracking ${OpenCV_LIBS})


I still have the following errors:
1
2
3
4
5
6
7
8
9
10
11
12
13
CMakeFiles/colorTracking.dir/colorTracking.cpp.o: In function `main':
colorTracking.cpp:(.text+0x590): undefined reference to `Pylon::CGrabResultPtr::CGrabResultPtr()'
colorTracking.cpp:(.text+0x594): undefined reference to `Pylon::CTlFactory::GetInstance()'
colorTracking.cpp:(.text+0x5a6): undefined reference to `Pylon::CDeviceInfo::CDeviceInfo()'
colorTracking.cpp:(.text+0x5be): undefined reference to `Pylon::CInstantCamera::CInstantCamera(Pylon::IPylonDevice*, Pylon::ECleanup)'
colorTracking.cpp:(.text+0x5e8): undefined reference to `Pylon::CInstantCamera::GetDeviceInfo() const'
colorTracking.cpp:(.text+0x5f6): undefined reference to `Pylon::CDeviceInfo::GetModelName() const'
colorTracking.cpp:(.text+0x61c): undefined reference to `GenICam_3_0_Basler_pylon_v5_0::gcstring::~gcstring()'
colorTracking.cpp:(.text+0x626): undefined reference to `Pylon::CInstantCamera::GetNodeMap()'
colorTracking.cpp:(.text+0x638): undefined reference to `Pylon::CInstantCamera::Open()'
colorTracking.cpp:(.text+0x656): undefined reference to `GenICam_3_0_Basler_pylon_v5_0::gcstring::gcstring(char const*)'
colorTracking.cpp:(.text+0x68c): undefined reference to `GenICam_3_0_Basler_pylon_v5_0::gcstring::~gcstring()'
colorTracking.cpp:(.text+0x6aa): undefined reference to `GenICam_3_0_Basler_pylon_v5_0::gcstring::gcstring(char const*)' 


Can any one please help me getting it to work?
Thanks
Last edited on
Topic archived. No new replies allowed.