git: 3232c7579ef0 - main - biology/avida: Fix CMake version

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Sun, 06 Sep 2026 16:18:06 UTC
The branch main has been updated by fuz:

URL: https://cgit.FreeBSD.org/ports/commit/?id=3232c7579ef06aa9302e9d3f253cb8ae78cbf765

commit 3232c7579ef06aa9302e9d3f253cb8ae78cbf765
Author:     Florian Limberger <flo@purplekraken.com>
AuthorDate: 2026-09-05 17:00:21 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2026-09-06 16:17:01 +0000

    biology/avida: Fix CMake version
    
    Convert REINPLACE_CMD calls to proper patches where possible, apply the
    REINPLACE in the pre-configure target to not mess up make makepatch.
    
    Event:          Berlin Hackathon 202609
---
 biology/avida/Makefile                             |  8 +---
 biology/avida/files/patch-CMakeLists.txt           | 10 +++++
 .../avida/files/patch-avida-core_CMakeLists.txt    | 50 ++++++++++++++++++++++
 ...-avida-core_source_main_cPopulationInterface.cc | 22 ++++++++++
 biology/avida/files/patch-libs_apto_CMakeLists.txt | 23 ++++++++++
 .../files/patch-libs_tcmalloc-1.4_CMakeLists.txt   | 32 ++++++++++++++
 6 files changed, 138 insertions(+), 7 deletions(-)

diff --git a/biology/avida/Makefile b/biology/avida/Makefile
index 2ccbec94bf4f..b408452c6694 100644
--- a/biology/avida/Makefile
+++ b/biology/avida/Makefile
@@ -40,13 +40,7 @@ DATA_FILES=	analyze.cfg avida.cfg default-gx.org \
 
 OPTIONS_DEFINE=	DOCS
 
-post-patch:
-	@${FIND} ${WRKSRC} -name "CMakeLists.txt" | ${XARGS} \
-		${REINPLACE_CMD} -e \
-		's|-O[0-9]|| ; \
-		 s| pthread| -pthread|'
-	@${REINPLACE_CMD} -e '/long long int/s|std::abs|llabs|' \
-		${WRKSRC}/avida-core/source/main/cPopulationInterface.cc
+pre-configure:
 	@${REINPLACE_CMD} -e '/__PPC__/s|linux|${OPSYS}|' \
 		${WRKSRC}/libs/tcmalloc-1.4/src/atomicops.h
 
diff --git a/biology/avida/files/patch-CMakeLists.txt b/biology/avida/files/patch-CMakeLists.txt
new file mode 100644
index 000000000000..4ce1a0f8ad4d
--- /dev/null
+++ b/biology/avida/files/patch-CMakeLists.txt
@@ -0,0 +1,10 @@
+--- CMakeLists.txt.orig	2026-09-06 00:28:25 UTC
++++ CMakeLists.txt
+@@ -1,6 +1,6 @@ PROJECT(avida-main)
+ PROJECT(avida-main)
+ 
+-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
++CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
+ 
+ # Final software is built directly into the work subdirectory.
+ SET(EXECUTABLE_OUTPUT_PATH
diff --git a/biology/avida/files/patch-avida-core_CMakeLists.txt b/biology/avida/files/patch-avida-core_CMakeLists.txt
new file mode 100644
index 000000000000..a6e897a2e067
--- /dev/null
+++ b/biology/avida/files/patch-avida-core_CMakeLists.txt
@@ -0,0 +1,50 @@
+--- avida-core/CMakeLists.txt.orig	2012-09-29 03:33:31 UTC
++++ avida-core/CMakeLists.txt
+@@ -1,6 +1,6 @@ PROJECT(AVIDA)
+ PROJECT(AVIDA)
+ 
+-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
++CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
+ 
+ 
+ IF(COMMAND cmake_policy)
+@@ -75,10 +75,10 @@ IF(UNIX)
+     "-Os ${COMPILER_WARNING_FLAGS} -DNDEBUG"
+     CACHE STRING "Flags used by the compiler during release minsize builds." FORCE)
+   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
+-    "-O2 -g ${COMPILER_OPTIMIZATION_FLAGS} ${COMPILER_WARNING_FLAGS} -DDEBUG"
++    " -g ${COMPILER_OPTIMIZATION_FLAGS} ${COMPILER_WARNING_FLAGS} -DDEBUG"
+     CACHE STRING "Flags used by the compiler during release builds." FORCE)
+   SET(CMAKE_CXX_FLAGS_RELEASE
+-    "-O3 ${COMPILER_OPTIMIZATION_FLAGS} ${COMPILER_WARNING_FLAGS} -DNDEBUG"
++    " ${COMPILER_OPTIMIZATION_FLAGS} ${COMPILER_WARNING_FLAGS} -DNDEBUG"
+     CACHE STRING "Flags used by the compiler during release builds." FORCE)
+ ENDIF(UNIX)
+ 
+@@ -408,7 +408,7 @@ IF(AVD_CMDLINE)
+     LIST(APPEND AVIDA_CMDLINE_LIBS tcmalloc-1.4)
+   ENDIF(AVD_ENABLE_TCMALLOC)  
+   IF(NOT MSVC)
+-    LIST(APPEND AVIDA_CMDLINE_LIBS pthread)
++    LIST(APPEND AVIDA_CMDLINE_LIBS -pthread)
+   ENDIF(NOT MSVC)
+   TARGET_LINK_LIBRARIES(avida ${AVIDA_CMDLINE_LIBS})
+   
+@@ -464,7 +464,7 @@ IF(AVD_GUI_NCURSES)
+     
+     SET(AVIDA_VIEWER_LIBS avidacore aptostatic ${NCURSES_LIBRARY})
+     IF(NOT MSVC)
+-      LIST(APPEND AVIDA_VIEWER_LIBS pthread)
++      LIST(APPEND AVIDA_VIEWER_LIBS -pthread)
+     ENDIF(NOT MSVC)
+     IF(AVD_ENABLE_TCMALLOC)
+       LIST(APPEND AVIDA_VIEWER_LIBS tcmalloc-1.4)
+@@ -512,7 +512,7 @@ IF(AVD_GUI_PROTOTYPE_TEXT)
+     
+     SET(AVIDA_TEXT_VIEWER_LIBS avidacore ${NCURSES_LIBRARY})
+     IF(NOT MSVC)
+-      LIST(APPEND AVIDA_TEXT_VIEWER_LIBS pthread)
++      LIST(APPEND AVIDA_TEXT_VIEWER_LIBS -pthread)
+     ENDIF(NOT MSVC)
+     IF(AVD_ENABLE_TCMALLOC)
+       LIST(APPEND AVIDA_TEXT_VIEWER_LIBS tcmalloc-1.4)
diff --git a/biology/avida/files/patch-avida-core_source_main_cPopulationInterface.cc b/biology/avida/files/patch-avida-core_source_main_cPopulationInterface.cc
new file mode 100644
index 000000000000..dbceb83bbda9
--- /dev/null
+++ b/biology/avida/files/patch-avida-core_source_main_cPopulationInterface.cc
@@ -0,0 +1,22 @@
+--- avida-core/source/main/cPopulationInterface.cc.orig	2026-09-06 13:22:43 UTC
++++ avida-core/source/main/cPopulationInterface.cc
+@@ -903,8 +903,8 @@ void cPopulationInterface::CreateLinkByXY(int x, int y
+ 	// cell coordinate.  the problem is that a 2s-complement int can hold a negative
+ 	// number whose absolute value is too large for the int to hold.  when this happens,
+ 	// abs returns the value unmodified.
+-	int cellx = std::abs(static_cast<long long int>(x)) % deme->GetWidth();
+-	int celly = std::abs(static_cast<long long int>(y)) % deme->GetHeight();
++	int cellx = llabs(static_cast<long long int>(x)) % deme->GetWidth();
++	int celly = llabs(static_cast<long long int>(y)) % deme->GetHeight();
+ 	assert(cellx >= 0);
+ 	assert(cellx < deme->GetWidth());
+ 	assert(celly >= 0);
+@@ -921,7 +921,7 @@ void cPopulationInterface::CreateLinkByIndex(int idx, 
+ 	// cell coordinate.  the problem is that a 2s-complement int can hold a negative
+ 	// number whose absolute value is too large for the int to hold.  when this happens,
+ 	// abs returns the value unmodified.
+-	int that_cell = std::abs(static_cast<long long int>(idx)) % deme->GetSize();
++	int that_cell = llabs(static_cast<long long int>(idx)) % deme->GetSize();
+ 	assert(that_cell >= 0);
+ 	assert(that_cell < deme->GetSize());
+ 	deme->GetNetwork().Connect(*this_cell, deme->GetCell(that_cell), weight);
diff --git a/biology/avida/files/patch-libs_apto_CMakeLists.txt b/biology/avida/files/patch-libs_apto_CMakeLists.txt
new file mode 100644
index 000000000000..e1e623244b38
--- /dev/null
+++ b/biology/avida/files/patch-libs_apto_CMakeLists.txt
@@ -0,0 +1,23 @@
+--- libs/apto/CMakeLists.txt.orig	2012-09-29 03:33:38 UTC
++++ libs/apto/CMakeLists.txt
+@@ -1,6 +1,6 @@ PROJECT(APTO CXX)
+ PROJECT(APTO CXX)
+ 
+-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
++CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
+ 
+ # Default location for installed software/configs/ docs is the build directory.
+ SET(CMAKE_INSTALL_PREFIX
+@@ -32,10 +32,10 @@ IF(UNIX)
+     "-Os -DNDEBUG"
+     CACHE STRING "Flags used by the compiler during release minsize builds." FORCE)
+   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
+-    "-O3 -g -DDEBUG"
++    " -g -DDEBUG"
+     CACHE STRING "Flags used by the compiler during release builds." FORCE)
+   SET(CMAKE_CXX_FLAGS_RELEASE
+-    "-O3 -DNDEBUG"
++    " -DNDEBUG"
+     CACHE STRING "Flags used by the compiler during release builds." FORCE)
+ ENDIF(UNIX)
+ 
diff --git a/biology/avida/files/patch-libs_tcmalloc-1.4_CMakeLists.txt b/biology/avida/files/patch-libs_tcmalloc-1.4_CMakeLists.txt
new file mode 100644
index 000000000000..bd9b539151c7
--- /dev/null
+++ b/biology/avida/files/patch-libs_tcmalloc-1.4_CMakeLists.txt
@@ -0,0 +1,32 @@
+--- libs/tcmalloc-1.4/CMakeLists.txt.orig	2012-09-29 03:33:39 UTC
++++ libs/tcmalloc-1.4/CMakeLists.txt
+@@ -1,6 +1,6 @@ PROJECT(TCMALLOC CXX)
+ PROJECT(TCMALLOC CXX)
+ 
+-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
++CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
+ 
+ # Default location for installed software/configs/ docs is the build directory.
+ SET(CMAKE_INSTALL_PREFIX
+@@ -32,10 +32,10 @@ IF(UNIX)
+     "-Os -DNDEBUG"
+     CACHE STRING "Flags used by the compiler during release minsize builds." FORCE)
+   SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO
+-    "-O3 -g -DDEBUG"
++    " -g -DDEBUG"
+     CACHE STRING "Flags used by the compiler during release builds." FORCE)
+   SET(CMAKE_CXX_FLAGS_RELEASE
+-    "-O3 -DNDEBUG"
++    " -DNDEBUG"
+     CACHE STRING "Flags used by the compiler during release builds." FORCE)
+ ENDIF(UNIX)
+ 
+@@ -76,7 +76,7 @@ IF(NOT MSVC)
+ 
+ ADD_LIBRARY(tcmalloc-1.4 STATIC ${TCMALLOC_SOURCES})
+ IF(NOT MSVC)
+-  TARGET_LINK_LIBRARIES(tcmalloc-1.4 pthread)
++  TARGET_LINK_LIBRARIES(tcmalloc-1.4 -pthread)
+ ENDIF(NOT MSVC)
+ INSTALL(TARGETS tcmalloc-1.4 DESTINATION ${CMAKE_INSTALL_PREFIX}/lib)
+ SET(tcmalloc_BUILT 1 CACHE INTERNAL "")