Config.cmake ends in the build folder instead of the devel folder
I'm writing a library which I will use with ROS1 right now and later plan to use with ROS2. Therefore, I used the CMake settings from another project of mine, where I also wrote a library and interfaced it with ROS2.
The problem is, that my ball_tracker-config.cmake
file ends up in build/ball_tracker/cmake
instead of in devel/share/ball_tracker/cmake
(there is no ball_tracker
folder in devel/share
).
The important lines of the CMakeLists.txt
are below
set_target_properties(
${PROJECT_NAME}
PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
include(GNUInstallDirs)
install(
TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}-targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ball_tracker
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(
EXPORT ${PROJECT_NAME}-targets
FILE ${PROJECT_NAME}-targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ball_tracker)
include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_SOURCE_DIR}/cmake/ball_tracker-config.cmake.in
${CMAKE_BINARY_DIR}/cmake/ball_tracker-config.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ball_tracker)
write_basic_package_version_file(
${CMAKE_BINARY_DIR}/cmake/ball_tracker-config-version.cmake
VERSION ${POLY_EXPLORATION_VERSION}
COMPATIBILITY AnyNewerVersion)
install(FILES ${CMAKE_BINARY_DIR}/cmake/ball_tracker-config.cmake
${CMAKE_BINARY_DIR}/cmake/ball_tracker-config-version.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/ball_tracker)
export(
EXPORT ball_tracker-targets
FILE ${CMAKE_BINARY_DIR}/cmake/ball_tracker-targets.cmake
NAMESPACE ${PROJECT_NAME}::)
The full CMakeLists.txt can be found here.
What do I have to change/adapt to get the CMake output files in the devel/share/ball_tracker/cmake
folder?