From e55fe2c2e3679af80516c4d7eedaed4953068ece Mon Sep 17 00:00:00 2001 From: Daniel Black Date: Wed, 18 Dec 2024 15:25:10 +1100 Subject: [PATCH] MDEV-32686 Use Red Hat package notes in compilation This tests the compile using a spec file. This spec file is defined by environment variables. If the spec file doesn't exist (SLES/OpenSUSE), isn't supported (e.g. clang), or has incorrect environment variables the linker flag won't be used. Stripping output avoid gcc ICE bug https://bugzilla.redhat.com/show_bug.cgi?id=2336272 Launcher used to make env variables show up in the build step rather than just the configure step. --- cmake/cpack_rpm.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/cmake/cpack_rpm.cmake b/cmake/cpack_rpm.cmake index 5e8966ec7bb..3ffd83078be 100644 --- a/cmake/cpack_rpm.cmake +++ b/cmake/cpack_rpm.cmake @@ -2,6 +2,8 @@ IF(RPM) MESSAGE(STATUS "CPackRPM building with RPM configuration: ${RPM}") +INCLUDE(check_linker_flag) + SET(CPACK_GENERATOR "RPM") SET(CPACK_RPM_PACKAGE_DEBUG 1) SET(CPACK_PACKAGING_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}) @@ -52,6 +54,19 @@ SET(CPACK_PACKAGE_RELOCATABLE FALSE) SET(CPACK_RPM_PACKAGE_GROUP "Applications/Databases") SET(CPACK_RPM_PACKAGE_URL ${CPACK_PACKAGE_URL}) +# The spec file depends on environment variables +SET(ENV{RPM_PACKAGE_NAME} ${CPACK_RPM_PACKAGE_NAME}) +EXECUTE_PROCESS(COMMAND rpm --eval ${CPACK_RPM_PACKAGE_RELEASE} OUTPUT_VARIABLE RPM_PACKAGE_RELEASE_EXPANDED) +STRING(STRIP "${RPM_PACKAGE_RELEASE_EXPANDED}" RPM_PACKAGE_RELEASE_EXPANDED) +SET(ENV{RPM_PACKAGE_RELEASE} ${RPM_PACKAGE_RELEASE_EXPANDED}) +SET(ENV{RPM_ARCH} ${CMAKE_SYSTEM_PROCESSOR}) +SET(ENV{RPM_PACKAGE_VERSION} ${SERVER_VERSION}) +MY_CHECK_AND_SET_LINKER_FLAG("-specs=/usr/lib/rpm/redhat/redhat-package-notes") +IF(HAVE_LINK_FLAG__specs_/usr/lib/rpm/redhat/redhat_package_notes) + SET(CMAKE_CXX_LINKER_LAUNCHER "env;RPM_PACKAGE_NAME=$ENV{RPM_PACKAGE_NAME};RPM_ARCH=$ENV{RPM_ARCH};RPM_PACKAGE_VERSION=$ENV{RPM_PACKAGE_VERSION};RPM_PACKAGE_RELEASE=$ENV{RPM_PACKAGE_RELEASE}") + SET(CMAKE_C_LINKER_LAUNCHER ${CMAKE_CXX_LINKER_LAUNCHER}) +ENDIF() + SET(CPACK_RPM_shared_PACKAGE_VENDOR "MariaDB Corporation Ab") SET(CPACK_RPM_shared_PACKAGE_LICENSE "LGPLv2.1")