b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | From 81c6b8823c1b58d7837e827bb1098aa5f9e5956b Mon Sep 17 00:00:00 2001 |
| 2 | From: "Jeremy W. Murphy" <jeremy.william.murphy@gmail.com> |
| 3 | Date: Tue, 16 May 2023 05:07:36 +1000 |
| 4 | Subject: [PATCH] cmake: Only use relative paths for install DESTINATION option |
| 5 | (#1405) |
| 6 | |
| 7 | As described in #1404, the explicit use of CMAKE_INSTALL_PREFIX conflicts with using command-line --prefix. |
| 8 | |
| 9 | This simply removes all explicit use of CMAKE_INSTALL_PREFIX. |
| 10 | |
| 11 | Otherwise this path will be duplicated: |
| 12 | |
| 13 | $ cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=inst .. |
| 14 | $ DESTDIR=inst ninja install |
| 15 | ... |
| 16 | -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/util.h |
| 17 | -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/ws.h |
| 18 | ... |
| 19 | |
| 20 | Fixes: #1404 |
| 21 | Co-authored-by: Jeremy Murphy <jeremymu@blackmagicdesign.com> |
| 22 | --- |
| 23 | CMakeLists.txt | 3 +-- |
| 24 | cmake/AddEventLibrary.cmake | 4 ++-- |
| 25 | 2 files changed, 3 insertions(+), 4 deletions(-) |
| 26 | |
| 27 | --- a/CMakeLists.txt |
| 28 | +++ b/CMakeLists.txt |
| 29 | @@ -1452,8 +1452,7 @@ endif() |
| 30 | # Installation preparation. |
| 31 | # |
| 32 | |
| 33 | -set(EVENT_INSTALL_CMAKE_DIR |
| 34 | - "${CMAKE_INSTALL_PREFIX}/lib/cmake/libevent") |
| 35 | +set(EVENT_INSTALL_CMAKE_DIR "lib/cmake/libevent") |
| 36 | |
| 37 | export(PACKAGE libevent) |
| 38 | |
| 39 | --- a/cmake/AddEventLibrary.cmake |
| 40 | +++ b/cmake/AddEventLibrary.cmake |
| 41 | @@ -31,7 +31,7 @@ macro(generate_pkgconfig LIB_NAME) |
| 42 | configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY) |
| 43 | install( |
| 44 | FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc" |
| 45 | - DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" |
| 46 | + DESTINATION "lib/pkgconfig" |
| 47 | ) |
| 48 | endmacro() |
| 49 | |
| 50 | @@ -150,7 +150,7 @@ macro(add_event_library LIB_NAME) |
| 51 | set_target_properties( |
| 52 | "${LIB_NAME}_shared" PROPERTIES |
| 53 | OUTPUT_NAME "${LIB_NAME}-${EVENT_PACKAGE_RELEASE}.${CURRENT_MINUS_AGE}" |
| 54 | - INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" |
| 55 | + INSTALL_NAME_DIR "lib" |
| 56 | LINK_FLAGS "-compatibility_version ${COMPATIBILITY_VERSION} -current_version ${COMPATIBILITY_VERSION}.${EVENT_ABI_LIBVERSION_REVISION}") |
| 57 | else() |
| 58 | math(EXPR CURRENT_MINUS_AGE "${EVENT_ABI_LIBVERSION_CURRENT}-${EVENT_ABI_LIBVERSION_AGE}") |