From 51752fa14bebb6d026b36dc18e4562f93caa96b5 Mon Sep 17 00:00:00 2001 From: Liu Dongmiao Date: Tue, 12 Mar 2024 06:48:08 +0000 Subject: [PATCH] libevent2: make cmake use relative imported path libevent2's cmake use absolute path, then cmake cannot find it when cross compiling: ``` -- Found libevent include directory: /builder/staging_dir/target-mips_24kc_musl/usr/include -- Found libevent component: /builder/staging_dir/target-mips_24kc_musl/usr/lib/libevent_core.so -- Found libevent component: /builder/staging_dir/target-mips_24kc_musl/usr/lib/libevent_extra.so -- Found libevent component: /builder/staging_dir/target-mips_24kc_musl/usr/lib/libevent_openssl.so -- Found libevent 2.1.12 in /builder/staging_dir/target-mips_24kc_musl/usr CMake Error at /builder/staging_dir/target-mips_24kc_musl/usr/lib/cmake/libevent/LibeventTargets-shared.cmake:102 (message): The imported target "libevent::core" references the file "/usr/lib/libevent_core-2.1.so.7.0.1" but this file does not exist. Possible reasons include: * The file was deleted, renamed, or moved to another location. * An install or uninstall procedure did not complete successfully. * The installation package was faulty and contained "/builder/staging_dir/target-mips_24kc_musl/usr/lib/cmake/libevent/LibeventTargets-shared.cmake" but not all the files it references. Call Stack (most recent call first): /builder/staging_dir/target-mips_24kc_musl/usr/lib/cmake/libevent/LibeventConfig.cmake:168 (include) CMakeLists.txt:34 (find_package) ``` This patch make cmake use relative imported path, so it can find libevent. Signed-off-by: Liu Dongmiao --- package/libs/libevent2/Makefile | 2 +- .../patches/001-relative-cmake.patch | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 package/libs/libevent2/patches/001-relative-cmake.patch diff --git a/package/libs/libevent2/Makefile b/package/libs/libevent2/Makefile index 92602607ae..e0a080d60e 100644 --- a/package/libs/libevent2/Makefile +++ b/package/libs/libevent2/Makefile @@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=libevent2 PKG_VERSION:=2.1.12 -PKG_RELEASE:=1 +PKG_RELEASE:=2 PKG_SOURCE:=libevent-$(PKG_VERSION)-stable.tar.gz PKG_SOURCE_URL:=https://github.com/libevent/libevent/releases/download/release-$(PKG_VERSION)-stable diff --git a/package/libs/libevent2/patches/001-relative-cmake.patch b/package/libs/libevent2/patches/001-relative-cmake.patch new file mode 100644 index 0000000000..38dc187df6 --- /dev/null +++ b/package/libs/libevent2/patches/001-relative-cmake.patch @@ -0,0 +1,58 @@ +From 81c6b8823c1b58d7837e827bb1098aa5f9e5956b Mon Sep 17 00:00:00 2001 +From: "Jeremy W. Murphy" +Date: Tue, 16 May 2023 05:07:36 +1000 +Subject: [PATCH] cmake: Only use relative paths for install DESTINATION option + (#1405) + +As described in #1404, the explicit use of CMAKE_INSTALL_PREFIX conflicts with using command-line --prefix. + +This simply removes all explicit use of CMAKE_INSTALL_PREFIX. + +Otherwise this path will be duplicated: + + $ cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=inst .. + $ DESTDIR=inst ninja install + ... + -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/util.h + -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/ws.h + ... + +Fixes: #1404 +Co-authored-by: Jeremy Murphy +--- + CMakeLists.txt | 3 +-- + cmake/AddEventLibrary.cmake | 4 ++-- + 2 files changed, 3 insertions(+), 4 deletions(-) + +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -1452,8 +1452,7 @@ endif() + # Installation preparation. + # + +-set(EVENT_INSTALL_CMAKE_DIR +- "${CMAKE_INSTALL_PREFIX}/lib/cmake/libevent") ++set(EVENT_INSTALL_CMAKE_DIR "lib/cmake/libevent") + + export(PACKAGE libevent) + +--- a/cmake/AddEventLibrary.cmake ++++ b/cmake/AddEventLibrary.cmake +@@ -31,7 +31,7 @@ macro(generate_pkgconfig LIB_NAME) + configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY) + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc" +- DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig" ++ DESTINATION "lib/pkgconfig" + ) + endmacro() + +@@ -150,7 +150,7 @@ macro(add_event_library LIB_NAME) + set_target_properties( + "${LIB_NAME}_shared" PROPERTIES + OUTPUT_NAME "${LIB_NAME}-${EVENT_PACKAGE_RELEASE}.${CURRENT_MINUS_AGE}" +- INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" ++ INSTALL_NAME_DIR "lib" + LINK_FLAGS "-compatibility_version ${COMPATIBILITY_VERSION} -current_version ${COMPATIBILITY_VERSION}.${EVENT_ABI_LIBVERSION_REVISION}") + else() + math(EXPR CURRENT_MINUS_AGE "${EVENT_ABI_LIBVERSION_CURRENT}-${EVENT_ABI_LIBVERSION_AGE}") -- 2.30.2