I am sorry for being so naive. I tried to understand from this cmake website's link But could not understand. I have a sample cmake file, where an executable is generated by
add_executable(${PROJECT_NAME}_node src/filename.cpp)
Then later it 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 is from ROS so catkin is there. The overall question remains the same. Does someone know, why do we need to install TARGETS/ FILES?
Install directory used by install. If “make install” is invoked or INSTALL is built, this directory is prepended onto all install directories. This variable defaults to /usr/local on UNIX and c:/Program Files on Windows.
cmake: Add `--prefix` option to set CMAKE_INSTALL_PREFIX. Classically the primary way of specifying the install directory is via CMAKE_INSTALL_PREFIX . With the introduction of cmake --install we added --prefix to override the existing CMAKE_INSTALL_PREFIX .
INSTALL
is useful in, at least, two scenarios:
You download some package's source code, generate the binaries, which you want to use in your system. You can INSTALL
them under /usr/bin, for example
You compile some library which you'll use from another product. It will gather the required files (header files, libraries...), and just those, and put them in a known place, no matter where the library compilation expects them.
You could just copy them, but relying on CMake allows the process to be expressed at a higher level.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With