catkin build with install fails after changes in a header file
I have a ROS melodic workspace where I'm compiling with catkin tools.
Catkin is initialize to build in a separate directory and to create an install space:
catkin config -s /root/src/my_ws/src --install --cmake-args "-DCMAKE_BUILD_TYPE=Debug"
I then build the entire workspace with
catkin build
which works fine.
I have a problem when I make a change in a header file that is also installed.
E.g. I have a catkin package with the following structure
.
├── CMakeLists.txt
├── include
│ └── my_lib
│ ├── MyLib.hpp
├── package.xml
├── README.md
├── src
│ └── MyLib.cpp
In that CMakeLists.txt
I have
install(
DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp"
)
If I now make a change in MyLib.hpp
and MyLib.cpp
, catkin build
will fail until I do a catkin clean
. The reason appears to be that the MyLib.hpp
file in the install/
space is used to compile MyLib.cpp
, i.e. the order of operations is wrong.
Is there something I need to do differently in my CMakeLists.txt
or is this a bug?
I noticed that
MyLib.hpp
never gets updated in theinstall/
space if I make a non-breaking change and re-build.