Skip to content

Commit

Permalink
Fix header file installation paths to respect CMAKE_INSTALL_INCLUDEDIR
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
otegami committed Jun 11, 2024
1 parent a5c8a2c commit 0073acf
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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)
Expand Down

0 comments on commit 0073acf

Please sign in to comment.