diff --git a/CMakeLists.txt b/CMakeLists.txt index a8e7173e1ab..fde733fdf5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,8 +97,19 @@ check_endianness() ############################################################################### # Installation paths ############################################################################### +option(APPEND_PROJECT_NAME_TO_INCLUDEDIR + "When ON headers are installed to a path ending with a folder called \ + ${PROJECT_NAME}. This avoids include directory search order issues when \ + overriding this package from a merged catkin, ament, or colcon workspace." + OFF) + set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries") -set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for C++ headers") +set(_include_dir "include/") +if(APPEND_PROJECT_NAME_TO_INCLUDEDIR) + string(APPEND _include_dir "${PROJECT_NAME}/") +endif() +set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for C++ headers") +unset(_include_dir) set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries") set(DATA_INSTALL_DIR share/ CACHE PATH "Installation directory for data") if(WIN32) diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt index 31c948ecca2..e9dd4a18400 100644 --- a/src/cpp/CMakeLists.txt +++ b/src/cpp/CMakeLists.txt @@ -416,7 +416,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC $ $ $ - $ + $ PRIVATE ${Asio_INCLUDE_DIR} $<$:${TINYXML2_INCLUDE_DIR}>