From 0073acfad652973ac03489712744d93c3e833873 Mon Sep 17 00:00:00 2001 From: otegami Date: Wed, 8 May 2024 21:01:53 +0800 Subject: [PATCH] Fix header file installation paths to respect `CMAKE_INSTALL_INCLUDEDIR` Previously, header files were installed uniformly under the include directory, ignoring the specified paths. This change ensures header files are installed in the appropriate directories under `CMAKE_INSTALL_INCLUDEDIR`. --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 03d76d8b8..e51d0bcff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -253,6 +253,10 @@ IF (NOT DEFINED CMAKE_INSTALL_LIBDIR) SET(CMAKE_INSTALL_LIBDIR lib) ENDIF () +IF (NOT CMAKE_INSTALL_INCLUDEDIR) + SET(CMAKE_INSTALL_INCLUDEDIR include) +ENDIF () + IF (MSGPACK_BUILD_EXAMPLES) ADD_SUBDIRECTORY (example) ENDIF () @@ -271,12 +275,14 @@ INSTALL (TARGETS ${MSGPACK_INSTALLTARGETS} EXPORT msgpack-c-targets ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) FOREACH (file ${msgpack-c_common_HEADERS}) - GET_FILENAME_COMPONENT (dir ${file} PATH) - INSTALL (FILES ${file} DESTINATION ${dir}) + GET_FILENAME_COMPONENT(dir ${file} DIRECTORY) + STRING(REPLACE "include" "${CMAKE_INSTALL_INCLUDEDIR}" header_path ${dir}) + INSTALL (FILES ${file} DESTINATION ${header_path}) ENDFOREACH () FOREACH (file ${msgpack-c_configured_HEADERS}) - GET_FILENAME_COMPONENT (dir ${file} PATH) - INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION ${dir}) + GET_FILENAME_COMPONENT(dir ${file} DIRECTORY) + STRING(REPLACE "include" "${CMAKE_INSTALL_INCLUDEDIR}" header_path ${dir}) + INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION ${header_path}) ENDFOREACH () IF (NOT MSVC) INSTALL (FILES ${CMAKE_CURRENT_BINARY_DIR}/msgpack-c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)