Add back support for relocatable packages (#2431)

This commit is contained in:
Duncan Ogilvie 2024-08-17 17:54:12 +02:00 committed by GitHub
parent 5e6807bab9
commit f38d56b692
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 25 additions and 9 deletions

View File

@ -837,11 +837,27 @@ source_group("Include\\LoongArch" FILES ${HEADERS_LOONGARCH})
## installation ## installation
if(CAPSTONE_INSTALL) if(CAPSTONE_INSTALL)
include("GNUInstallDirs") include(GNUInstallDirs)
install(FILES ${HEADERS_COMMON} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone) install(FILES ${HEADERS_COMMON} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone)
install(FILES ${HEADERS_INC} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone/inc) install(FILES ${HEADERS_INC} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone/inc)
# Support absolute installation paths (discussion: https://github.com/NixOS/nixpkgs/issues/144170)
if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
set(CAPSTONE_PKGCONFIG_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
set(CAPSTONE_CMAKE_INSTALL_LIBDIR ${CMAKE_INSTALL_LIBDIR})
else()
set(CAPSTONE_PKGCONFIG_INSTALL_LIBDIR "\${prefix}/${CMAKE_INSTALL_LIBDIR}")
set(CAPSTONE_CMAKE_INSTALL_LIBDIR "\${PACKAGE_PREFIX_DIR}/${CMAKE_INSTALL_LIBDIR}")
endif()
if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
set(CAPSTONE_PKGCONFIG_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
set(CAPSTONE_CMAKE_INSTALL_INCLUDEDIR ${CMAKE_INSTALL_INCLUDEDIR})
else()
set(CAPSTONE_PKGCONFIG_INSTALL_INCLUDEDIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
set(CAPSTONE_CMAKE_INSTALL_INCLUDEDIR "\${PACKAGE_PREFIX_DIR}/${CMAKE_INSTALL_INCLUDEDIR}")
endif()
configure_file(capstone.pc.in ${CMAKE_BINARY_DIR}/capstone.pc @ONLY) configure_file(capstone.pc.in ${CMAKE_BINARY_DIR}/capstone.pc @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/capstone.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) install(FILES ${CMAKE_BINARY_DIR}/capstone.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

View File

@ -1,6 +1,6 @@
@PACKAGE_INIT@ @PACKAGE_INIT@
set_and_check(capstone_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@") set_and_check(capstone_INCLUDE_DIR "@CAPSTONE_CMAKE_INSTALL_INCLUDEDIR@")
set_and_check(capstone_LIB_DIR "@CMAKE_INSTALL_FULL_LIBDIR@") set_and_check(capstone_LIB_DIR "@CAPSTONE_CMAKE_INSTALL_LIBDIR@")
include("${CMAKE_CURRENT_LIST_DIR}/capstone-targets.cmake") include("${CMAKE_CURRENT_LIST_DIR}/capstone-targets.cmake")

View File

@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@ prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix} exec_prefix=${prefix}
libdir=@CMAKE_INSTALL_FULL_LIBDIR@ libdir=@CAPSTONE_PKGCONFIG_INSTALL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@ includedir=@CAPSTONE_PKGCONFIG_INSTALL_INCLUDEDIR@
Name: capstone Name: capstone
Description: Capstone disassembly engine Description: Capstone disassembly engine

View File

@ -13,8 +13,8 @@ foreach(file ${files})
endif() endif()
endforeach() endforeach()
message(STATUS "Uninstalling @CMAKE_INSTALL_FULL_INCLUDEDIR@/capstone") message(STATUS "Uninstalling @CAPSTONE_CMAKE_INSTALL_INCLUDEDIR@/capstone")
file(REMOVE_RECURSE @CMAKE_INSTALL_FULL_INCLUDEDIR@/capstone) file(REMOVE_RECURSE @CAPSTONE_CMAKE_INSTALL_INCLUDEDIR@/capstone)
message(STATUS "Uninstalling @CMAKE_INSTALL_FULL_LIBDIR@/cmake/capstone") message(STATUS "Uninstalling @CAPSTONE_CMAKE_INSTALL_LIBDIR@/cmake/capstone")
file(REMOVE_RECURSE @CMAKE_INSTALL_FULL_LIBDIR@/cmake/capstone) file(REMOVE_RECURSE @CAPSTONE_CMAKE_INSTALL_LIBDIR@/cmake/capstone)