Skip to content

Commit

Permalink
Add back support for relocatable packages
Browse files Browse the repository at this point in the history
  • Loading branch information
mrexodia committed Aug 17, 2024
1 parent 5e6807b commit 7f87c20
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -837,11 +837,27 @@ source_group("Include\\LoongArch" FILES ${HEADERS_LOONGARCH})

## installation
if(CAPSTONE_INSTALL)
include("GNUInstallDirs")
include(GNUInstallDirs)

install(FILES ${HEADERS_COMMON} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/capstone)
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)
install(FILES ${CMAKE_BINARY_DIR}/capstone.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

Expand Down
4 changes: 2 additions & 2 deletions capstone-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@PACKAGE_INIT@

set_and_check(capstone_INCLUDE_DIR "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
set_and_check(capstone_LIB_DIR "@CMAKE_INSTALL_FULL_LIBDIR@")
set_and_check(capstone_INCLUDE_DIR "@CAPSTONE_CMAKE_INSTALL_INCLUDEDIR@")
set_and_check(capstone_LIB_DIR "@CAPSTONE_CMAKE_INSTALL_LIBDIR@")

include("${CMAKE_CURRENT_LIST_DIR}/capstone-targets.cmake")
4 changes: 2 additions & 2 deletions capstone.pc.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=@CAPSTONE_PKGCONFIG_INSTALL_LIBDIR@
includedir=@CAPSTONE_PKGCONFIG_INSTALL_INCLUDEDIR@

Name: capstone
Description: Capstone disassembly engine
Expand Down
8 changes: 4 additions & 4 deletions cmake_uninstall.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ foreach(file ${files})
endif()
endforeach()

message(STATUS "Uninstalling @CMAKE_INSTALL_FULL_INCLUDEDIR@/capstone")
file(REMOVE_RECURSE @CMAKE_INSTALL_FULL_INCLUDEDIR@/capstone)
message(STATUS "Uninstalling @CAPSTONE_CMAKE_INSTALL_INCLUDEDIR@/capstone")
file(REMOVE_RECURSE @CAPSTONE_CMAKE_INSTALL_INCLUDEDIR@/capstone)

message(STATUS "Uninstalling @CMAKE_INSTALL_FULL_LIBDIR@/cmake/capstone")
file(REMOVE_RECURSE @CMAKE_INSTALL_FULL_LIBDIR@/cmake/capstone)
message(STATUS "Uninstalling @CAPSTONE_CMAKE_INSTALL_LIBDIR@/cmake/capstone")
file(REMOVE_RECURSE @CAPSTONE_CMAKE_INSTALL_LIBDIR@/cmake/capstone)

0 comments on commit 7f87c20

Please sign in to comment.