The compiler is telling that the messages (.../message.h) being not found. See my CMakeLists.txt below
cmake_minimum_required(VERSION 2.8.3)
project(my_package)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED
COMPONENTS cv_bridge
image_transport
roscpp
#rospy
sensor_msgs
std_msgs
message_generation
genmsg
external_package
)
find_package(nodelet REQUIRED)
#----
add_message_files( FILES
my_message1.msg
my_message2.msg
)
generate_messages( DEPENDENCIES
std_msgs sensor_msgs
)
catkin_package(
CATKIN_DEPENDS message_runtime std_msgs sensor_msgs roscpp cv_bridge image_transport
)
#****** EXTRA PACKAGES
find_package(LAPACK REQUIRED)
find_package(BLAS REQUIRED)
find_package( PkgConfig REQUIRED)
FIND_PACKAGE(Boost)
find_package( OpenCV )
include_directories(${catkin_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} )
SET(MY_FLAG ok) # OR no!!
if(MY_FLAG)
#**** exe files
set(exefiles
file1
file2
)
foreach(file ${exefiles})
add_executable(${file} ${CMAKE_CURRENT_SOURCE_DIR}/pathToExeFiles/${file}.cpp )
endforeach(file)
#****** Lib & link
include_directories(${SRC}/pathToMyLib)
set(MY_LIB
lib1
lib2
libn
)
endif(MY_FLAG)
foreach(file ${exefiles})
target_link_libraries(${file2link}
${MY_LIB}
${MY_LIB}
${MY_LIB}
${catkin_LIBRARIES}
${Boost_LIBRARIES}
${gsl_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES}
${OpenCV_LIBRARIES}
)
add_dependencies(${file} external_package_generate_messages_cpp ${${my_package}_EXPORTED_TARGETS})
endforeach(file)
ADD_SUBDIRECTORY(src)
However, am able to compile with the following trick. I first set My_FLAG
to flase and compile. Next, I set it back to true and compile again. By doing so it works fine. But... I could guess there should be a more elegant/professional/straightforward solution. Am so far not able to detect the cause of this problem. Any solution please?
I think the issue is related to the order of the dependencies... Which? No idea...