Ask Your Question
0

Config.cmake ends in the build folder instead of the devel folder

asked 2021-07-20 02:49:58 -0600

Andreas Ziegler gravatar image

updated 2021-07-20 02:51:23 -0600

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2021-07-20 05:04:34 -0600

Andreas Ziegler gravatar image

Apparently the problem was that I named the executable ${PROJECT_NAME}_node. After renaming it to ${PROJECT_NAME} everything seems fine.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2021-07-20 02:49:58 -0600

Seen: 24 times

Last updated: Jul 20