Skip to content

Commit ac5f294

Browse files
authored
Make $<INSTALL_INTERFACE... use INCLUDE_INSTALL_DIR, and install headers to include/${PROJECT_NAME} (#2535)
* Make INSTALL_INTERFACE use INCLUDE_INSTALL_DIR Signed-off-by: Shane Loretz <[email protected]> * Install headers to include/${PROJECT_NAME} Signed-off-by: Shane Loretz <[email protected]> * Add option APPEND_PROJECT_NAME_TO_INCLUDEDIR Signed-off-by: Shane Loretz <[email protected]> * Misc fixes Signed-off-by: Shane Loretz <[email protected]> * Unset _include_dir when finished with it Signed-off-by: Shane Loretz <[email protected]>
1 parent dd1c5db commit ac5f294

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

CMakeLists.txt

+12-1
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,19 @@ check_endianness()
9797
###############################################################################
9898
# Installation paths
9999
###############################################################################
100+
option(APPEND_PROJECT_NAME_TO_INCLUDEDIR
101+
"When ON headers are installed to a path ending with a folder called \
102+
${PROJECT_NAME}. This avoids include directory search order issues when \
103+
overriding this package from a merged catkin, ament, or colcon workspace."
104+
OFF)
105+
100106
set(BIN_INSTALL_DIR bin/ CACHE PATH "Installation directory for binaries")
101-
set(INCLUDE_INSTALL_DIR include/ CACHE PATH "Installation directory for C++ headers")
107+
set(_include_dir "include/")
108+
if(APPEND_PROJECT_NAME_TO_INCLUDEDIR)
109+
string(APPEND _include_dir "${PROJECT_NAME}/")
110+
endif()
111+
set(INCLUDE_INSTALL_DIR "${_include_dir}" CACHE PATH "Installation directory for C++ headers")
112+
unset(_include_dir)
102113
set(LIB_INSTALL_DIR lib/ CACHE PATH "Installation directory for libraries")
103114
set(DATA_INSTALL_DIR share/ CACHE PATH "Installation directory for data")
104115
if(WIN32)

src/cpp/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC
416416
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
417417
$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include/${PROJECT_NAME}>
418418
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src/cpp>
419-
$<INSTALL_INTERFACE:include>
419+
$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>
420420
PRIVATE
421421
${Asio_INCLUDE_DIR}
422422
$<$<BOOL:${TINYXML2_INCLUDE_DIR}>:${TINYXML2_INCLUDE_DIR}>

0 commit comments

Comments
 (0)