git: 731a0cba8469 - main - devel/cmake: prefer python3 over versioned python3.x

From: Adriaan de Groot <adridg_at_FreeBSD.org>
Date: Sun, 10 Apr 2022 15:42:50 UTC
The branch main has been updated by adridg:

URL: https://cgit.FreeBSD.org/ports/commit/?id=731a0cba8469ce33d4406f735afac00f6914e158

commit 731a0cba8469ce33d4406f735afac00f6914e158
Author:     Adriaan de Groot <adridg@FreeBSD.org>
AuthorDate: 2022-04-10 15:34:55 +0000
Commit:     Adriaan de Groot <adridg@FreeBSD.org>
CommitDate: 2022-04-10 15:34:55 +0000

    devel/cmake: prefer python3 over versioned python3.x
    
    Depending on which mechanism is used to find Python (Python3
    in particular, since there's only one Python2 version left),
    either python3 is found -- installed by the python3 metaport,
    and presumed to be the "preferred / default Python3 version" --
    of a versioned python3. Asking for, say, Python 3.6 will get
    you whatever python3 points at -- assuming it is newer than 3.6 --
    or, with the other mechanism, the newest python (e.g. highest
    installed version). Those are not necessarily the same.
    
    Switch the new mechanism to preferring python3; there's a
    knob in CMake itself for that, we just need to set it in
    the FreeBSD config-file.
    
    PR:             252277
---
 devel/cmake/Makefile                                   |  1 +
 devel/cmake/files/patch-Modules_Platform_FreeBSD.cmake | 12 ++++++++++++
 2 files changed, 13 insertions(+)

diff --git a/devel/cmake/Makefile b/devel/cmake/Makefile
index 69095886dc8d..476f5a689af4 100644
--- a/devel/cmake/Makefile
+++ b/devel/cmake/Makefile
@@ -3,6 +3,7 @@
 PORTNAME=	cmake
 # Remember to update devel/cmake-doc and devel/cmake-gui as well.
 DISTVERSION=	3.22.2
+PORTREVISION=	1
 CATEGORIES=	devel
 MASTER_SITES=	https://github.com/Kitware/CMake/releases/download/v${DISTVERSION}/ \
 		https://www.cmake.org/files/v${PORTVERSION}/
diff --git a/devel/cmake/files/patch-Modules_Platform_FreeBSD.cmake b/devel/cmake/files/patch-Modules_Platform_FreeBSD.cmake
new file mode 100644
index 000000000000..a34d8d0de404
--- /dev/null
+++ b/devel/cmake/files/patch-Modules_Platform_FreeBSD.cmake
@@ -0,0 +1,12 @@
+--- Modules/Platform/FreeBSD.cmake.orig	2022-04-10 15:22:59 UTC
++++ Modules/Platform/FreeBSD.cmake
+@@ -26,4 +26,9 @@ foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
+   set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
+ endforeach()
+ 
++# Prefer python3 (installed by the python3 metaport) over the
++# highest-versioned Python3 interpreter, when asked for a non-exact
++# Python3 version.
++set(Python3_FIND_UNVERSIONED_NAMES FIRST)
++
+ include(Platform/UnixPaths)