I couldn't understand the CMake documentation for install. I have a sample CMake file, where an executable is generated by
add_executable(${PROJECT_NAME}_node src/filename.cpp)
Then later installed by the following command:
install(TARGETS ${PROJECT_NAME}_node ${PROJECT_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION} )
This CMake instance is from ROS, so catkin is there. The overall question remains the same. Why do we need to install TARGETS/ FILES?
You don't need to use the INSTALL
function of catkin.
The INSTALL function will just copy your final BINARY
,LIBRARY
, etc. to a safer place (for example, the main ROS package space located at /opt/ros/<your-version>/share,lib,include
) to keep the build workspace less crowded and to keep files safe, in case your workspace got corrupted.