commit:     814b6b0d056d858c629720ca1a97400688d2542f
Author:     Adrian Grigo <agrigo2001 <AT> yahoo <DOT> com <DOT> au>
AuthorDate: Tue Dec  8 03:19:22 2020 +0000
Commit:     Andreas Sturmlechner <asturm <AT> gentoo <DOT> org>
CommitDate: Sat Dec 12 17:58:23 2020 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=814b6b0d

dev-util/cmake: Backport FPHSA fix

Changes to Find Package Handle Standard Args in 3.19.0 result in
an error when compiling openvdb-7.1.0.

This is a known problem in cmake and the fix has been merged into
3.19.2 upstream.

See https://gitlab.kitware.com/cmake/cmake/-/issues/21505

To produce the bug:
emerge dev-util/cmake-3.19.0 or 3.19.1 (the bug not exist in <= 3.18)
emerge media-gfx/openvdb-7.1.0-r1

Compilation fails with
find_package_check_version(): Cannot be used outside a 'Find Module'

To fix the bug:
Apply the patch provided in this bug fix to cmake, then repeat the
above steps and compilation of openvdb succeeds.

The patch ensures that the CMAKE_FPHSA_PACKAGE_NAME package is made
available outside find_package.

Thanks to Dennis Schridde for finding the upstream fix, produced by
Marc Chevrier.

* committer-comment: use Gentoo bug ref; git format-patch 14ecf9c2f

Signed-off-by: Adrian Grigo <agrigo2001 <AT> yahoo.com.au>
Closes: https://bugs.gentoo.org/755743
Package-Manager: Portage-3.0.9, Repoman-3.0.2
Closes: https://github.com/gentoo/gentoo/pull/18560
Signed-off-by: Andreas Sturmlechner <asturm <AT> gentoo.org>

 dev-util/cmake/cmake-3.19.1-r1.ebuild              |  1 +
 ...ake-3.19.1-use-FPHSA-outside-find_package.patch | 40 ++++++++++++++++++++++
 2 files changed, 41 insertions(+)

diff --git a/dev-util/cmake/cmake-3.19.1-r1.ebuild 
b/dev-util/cmake/cmake-3.19.1-r1.ebuild
index 97f173f95a8..2726694149e 100644
--- a/dev-util/cmake/cmake-3.19.1-r1.ebuild
+++ b/dev-util/cmake/cmake-3.19.1-r1.ebuild
@@ -70,6 +70,7 @@ PATCHES=(
 
        # upstream fixes (can usually be removed with a version bump)
        "${FILESDIR}"/${P}-fix-spurious-include-target.patch # bug 759271
+       "${FILESDIR}"/${P}-use-FPHSA-outside-find_package.patch # bug 755743
 )
 
 cmake_src_bootstrap() {

diff --git 
a/dev-util/cmake/files/cmake-3.19.1-use-FPHSA-outside-find_package.patch 
b/dev-util/cmake/files/cmake-3.19.1-use-FPHSA-outside-find_package.patch
new file mode 100644
index 00000000000..8cde769ce8f
--- /dev/null
+++ b/dev-util/cmake/files/cmake-3.19.1-use-FPHSA-outside-find_package.patch
@@ -0,0 +1,40 @@
+From 14ecf9c2f6edfae4033d9311f79d79d0d07fc1cf Mon Sep 17 00:00:00 2001
+From: Marc Chevrier <[email protected]>
+Date: Wed, 25 Nov 2020 16:36:12 +0100
+Subject: [PATCH] FPHSA: ensure it can be used outside 'find_package'
+
+Fixes: #21505
+---
+ Modules/FindPackageHandleStandardArgs.cmake | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/Modules/FindPackageHandleStandardArgs.cmake 
b/Modules/FindPackageHandleStandardArgs.cmake
+index 7af017136d..7e172779e4 100644
+--- a/Modules/FindPackageHandleStandardArgs.cmake
++++ b/Modules/FindPackageHandleStandardArgs.cmake
+@@ -275,8 +275,10 @@ function(FIND_PACKAGE_CHECK_VERSION version result)
+     unset (${FPCV_RESULT_MESSAGE_VARIABLE} PARENT_SCOPE)
+   endif()
+ 
+-  if (CMAKE_FIND_PACKAGE_NAME)
+-    set (package ${CMAKE_FIND_PACKAGE_NAME})
++  if (_CMAKE_FPHSA_PACKAGE_NAME)
++    set (package "${_CMAKE_FPHSA_PACKAGE_NAME}")
++  elseif (CMAKE_FIND_PACKAGE_NAME)
++    set (package "${CMAKE_FIND_PACKAGE_NAME}")
+   else()
+     message (FATAL_ERROR "find_package_check_version(): Cannot be used 
outside a 'Find Module'")
+   endif()
+@@ -436,6 +438,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME 
_FIRST_ARG)
+       "will be used.")
+   endif()
+ 
++  # to propagate package name to FIND_PACKAGE_CHECK_VERSION
++  set(_CMAKE_FPHSA_PACKAGE_NAME "${_NAME}")
++
+   # now that we collected all arguments, process them
+ 
+   if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG")
+-- 
+GitLab
+

Reply via email to