Starting from foreach
documentation and this piece of code:
foreach (p INCLUDE CMAKE)
set (var INSTALL_${p}_DIR)
if (NOT IS_ABSOLUTE "${${var}}")
set (${var} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif ()
endforeach ()
This make variables INSTALL_INCLUDE_DIR and INSTALL_CMAKE_DIR absolute paths. So, they are not the place where all the include files are collected.
In the main CMakeLists.txt it doesn't seem anything is done with headers. A subdirectory websocketapp is added, which contains a short CMakeLists.txt:
init_target("websocketpp")
final_target ()
Those are custom macros defined in cmake/CMakeHelpers.cmake
(included by the main CMakeLists.txt). The key is in final_target()
macro (final_target)
if ("${TARGET_LIB_TYPE}" STREQUAL "EXECUTABLE")
install (TARGETS ${TARGET_NAME}
RUNTIME DESTINATION "bin"
CONFIGURATIONS ${CMAKE_CONFIGURATION_TYPES})
endif ()
# install headers, directly from current source dir and look for subfolders with headers
file (GLOB_RECURSE TARGET_INSTALL_HEADERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.hpp)
foreach (hppfile ${TARGET_INSTALL_HEADERS})
get_filename_component (currdir ${hppfile} PATH)
install (FILES ${hppfile} DESTINATION "include/${TARGET_NAME}/${currdir}")
endforeach()
endmacro ()
The last part of the macro add to the install target all headers file, found with a globbing expression
.
Said this, there is not really a standard way to do this kind of operation, so you'll see plenty of different approaches across different projects. There is also a war of religion if source files (as header files) should be explicitly listed or found through a globbing expressions, see Specify source files globally with GLOB?.