Catkin doesn't works with Bison
Hello I'm having issues trying to compile a little program with a CMakeList that uses a Bison/Flex parser.
When I use catkin the system gives me the following error:
####
#### Running command: "make -j2 -l2" in "/home/leontes/Dropbox/ros_ws/build"
####
[ 1%] [BISON][parser] Building parser with bison 3.0.2
Scanning dependencies of target task_executor
make[2]: *** No hay ninguna regla para construir el objetivo «../htn_planner/src/parser.hpp», necesario para «ROSbtp/task_executor/CMakeFiles/task_executor.dir/__/htn_planner/src/lexer.cpp.o». Alto.
make[2]: *** Se espera a que terminen otras tareas....
[ 2%] Building CXX object ROSbtp/task_executor/CMakeFiles/task_executor.dir/__/htn_planner/src/parser.cpp.o
cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ [enabled by default]
In file included from ../htn_planner/yacc/parser.yy:35:0:
/home/leontes/Dropbox/ros_ws/src/ROSbtp/task_executor/../htn_planner/include/sortgoal.hh: In member function ‘bool CriteriaF::operator()(Unifier*, Unifier*) const’:
/home/leontes/Dropbox/ros_ws/src/ROSbtp/task_executor/../htn_planner/include/sortgoal.hh:68:30: warning: variable ‘e’ set but not used [-Wunused-but-set-variable]
criteriacit i = f->begin(), e = f->end();
^
make[1]: *** [ROSbtp/task_executor/CMakeFiles/task_executor.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j2 -l2" failed
Catkin launchs Bison, Bison generates parser.cpp and parser.hpp but catkin insists that theres no rule to build that parser.hpp file. And of course I delete this files catkin not even launchs the compilation.
The CMakeLists that I've writed is this:
cmake_minimum_required(VERSION 2.8.12)
project(task_executor)
find_package(catkin REQUIRED cmake_modules)
catkin_package(
INCLUDE_DIRS include
LIBRARIES ${PROJECT_NAME})
#Set headers directory
include_directories("include" "../htn_planner/include")
#Set source files
file(GLOB SOURCES "../htn_planner/src/*.cpp")
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/../htn_planner/src/parser.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/../htn_planner/src/parser.hpp" "${CMAKE_CURRENT_SOURCE_DIR}/../htn_planner/src/lexer.cpp")
#Build commands for Flex and Bison
find_package(FLEX)
find_package(BISON)
FLEX_TARGET(lexer ../htn_planner/yacc/lexer.ll ../htn_planner/src/lexer.cpp)
BISON_TARGET(parser ../htn_planner/yacc/parser.yy ../htn_planner/src/parser.cpp)
ADD_FLEX_BISON_DEPENDENCY(lexer parser)
#Add a binary executable
add_executable(task_executor nodes/task_executor.cpp ../htn_planner/planner_api/planner_api.cpp ${BISON_parser_OUTPUTS} ${FLEX_lexer_OUTPUTS} ${SOURCES})
target_link_libraries(task_executor readline ${EXTRALIBS} ${PYTHON_EXTRA_LIBS} ${catkin_LIBRARIES})
I don't know what to do, I'm run out of ideas...
Just a note: catkin is essentially CMake. When you write "Catkin launchs Bison [..]", it should really be "CMake launches Bison". This may seem pedantic, but it will make searching for potential solutions much easier, as the CMake community is much larger than that of catkin.
Nope, the problem is with Catkin and how it resolves dependencies and execute the packages. The same Cmakelist (without the catkin directives) works fine when run as a standalone proyect.
Can you try and see whether using absolute paths works? You can prefix the paths to
../htn_planner
with${CMAKE_CURRENT_SOURCE_DIR}
.@Leontes can you expand on why you think it is related to how catkin handles resolving dependencies or "execute the packages"? Based on that I have no idea what may be the source of the issue. I don't see anything in the above CMakeLists.txt which would lead me to believe it is a catkin problem.
On further inspection I think I noticed an issue, and I posted an answer.