commit:     59469f50e1204c1c4e344a18d88ba24b439898c7
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Fri May 16 05:00:07 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Fri May 16 05:00:34 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=59469f50

sci-libs/nlopt: add 2.10.0

Closes: https://bugs.gentoo.org/952038
Closes: https://bugs.gentoo.org/952677
Closes: https://bugs.gentoo.org/955929
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sci-libs/nlopt/Manifest                         |   1 +
 sci-libs/nlopt/files/nlopt-2.10.0-cxx.patch     | 172 ++++++++++++++++++++++++
 sci-libs/nlopt/files/nlopt-2.10.0-libm-pc.patch |  25 ++++
 sci-libs/nlopt/files/nlopt-2.10.0-libm.patch    |  48 +++++++
 sci-libs/nlopt/nlopt-2.10.0.ebuild              | 128 ++++++++++++++++++
 5 files changed, 374 insertions(+)

diff --git a/sci-libs/nlopt/Manifest b/sci-libs/nlopt/Manifest
index 91292448e091..e19b276b548c 100644
--- a/sci-libs/nlopt/Manifest
+++ b/sci-libs/nlopt/Manifest
@@ -1 +1,2 @@
+DIST nlopt-2.10.0.tar.gz 2065021 BLAKE2B 
dba4446c8603f22048158b9cfabe6afae55372f9034fdc5b8e31c748a1fed294889a2af4a07a9d36e11c4b36e5c016df7c92bb61f9399ef0f1048070fc0f9894
 SHA512 
7668db6997ba141ee1759f222bad23a7854aa17962470653ddb5824c25100b50f52c462441f0cc12a62e2322ff084c7f7b7fab09471b0acb13a861d7f7575655
 DIST nlopt-2.7.1.tar.gz 2044180 BLAKE2B 
6d459f94a26ee6dd7f72c73c48992bd047150aa525bc4ad088c8516127afc5c7843f6fbb6726c2f845271b87934c13e0892a063362ab50df51f92e81979111fb
 SHA512 
e23cb522fc696010574c14b72be85acc0f8ccf0bf208bf2b8789c57d6c5a6e6d419ee10330581518b1c1567018ae909b626ce7761d4fbd5bf112916871e420e2

diff --git a/sci-libs/nlopt/files/nlopt-2.10.0-cxx.patch 
b/sci-libs/nlopt/files/nlopt-2.10.0-cxx.patch
new file mode 100644
index 000000000000..613ba6ff681d
--- /dev/null
+++ b/sci-libs/nlopt/files/nlopt-2.10.0-cxx.patch
@@ -0,0 +1,172 @@
+https://github.com/stevengj/nlopt/commit/a5426ead8d8478c46201c21860e789e47f15c5a3
+
+From a5426ead8d8478c46201c21860e789e47f15c5a3 Mon Sep 17 00:00:00 2001
+From: Julien Schueller <[email protected]>
+Date: Mon, 24 Feb 2025 15:59:52 +0100
+Subject: [PATCH] CMake: Assume working c++ compiler (#597)
+
+---
+ CMakeLists.txt          | 19 +++----------------
+ src/swig/CMakeLists.txt |  6 +++---
+ test/CMakeLists.txt     | 38 ++++++++++++++++++--------------------
+ 3 files changed, 24 insertions(+), 39 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index c0a84de3..39b01441 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -77,8 +77,6 @@ endif ()
+ include (CheckIncludeFiles)
+ include (CheckFunctionExists)
+ include (CheckTypeSize)
+-include (CheckCCompilerFlag)
+-include (CheckCXXSymbolExists)
+ include (CheckCSourceCompiles)
+ 
+ 
#==============================================================================
+@@ -140,20 +138,6 @@ if (WITH_THREADLOCAL AND NOT DEFINED THREADLOCAL)
+   endforeach()
+ endif ()
+ 
+-
+-if (NLOPT_CXX OR NLOPT_PYTHON OR NLOPT_GUILE OR NLOPT_OCTAVE OR NLOPT_JAVA)
+-  check_cxx_symbol_exists (__cplusplus ciso646 SYSTEM_HAS_CXX)
+-  if (SYSTEM_HAS_CXX)
+-    set (CMAKE_CXX_STANDARD 11) # set the standard to C++11 but do not 
require it
+-
+-    if (NLOPT_CXX)
+-      set (CMAKE_CXX_STANDARD_REQUIRED ON) # if we build C++ API, we do need 
C++11
+-    endif ()
+-  else()
+-    message (FATAL_ERROR "The compiler doesn't support CXX.")
+-  endif ()
+-endif ()
+-
+ 
#==============================================================================
+ # CREATE nlopt_config.h
+ 
#==============================================================================
+@@ -260,6 +244,9 @@ if (M_LIBRARY)
+ endif ()
+ set_target_properties (${nlopt_lib} PROPERTIES SOVERSION ${SO_MAJOR})
+ set_target_properties (${nlopt_lib} PROPERTIES VERSION 
"${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}")
++if (NLOPT_CXX)
++  target_compile_features (${nlopt_lib} PUBLIC cxx_lambdas)
++endif ()
+ 
+ 
#==============================================================================
+ # INCLUDE DIRECTORIES
+diff --git a/src/swig/CMakeLists.txt b/src/swig/CMakeLists.txt
+index a48b8b3b..e8248e9e 100644
+--- a/src/swig/CMakeLists.txt
++++ b/src/swig/CMakeLists.txt
+@@ -21,7 +21,7 @@ endif ()
+ include_directories (${NLOPT_PRIVATE_INCLUDE_DIRS})
+ set_source_files_properties (nlopt.i PROPERTIES CPLUSPLUS ON)
+ 
+-if (Python_NumPy_FOUND)
++if (Python_NumPy_FOUND AND NLOPT_CXX)
+ 
+   set (SWIG_MODULE_nlopt_python_EXTRA_DEPS nlopt-python.i numpy.i 
generate-cpp)
+ 
+@@ -46,7 +46,7 @@ if (Python_NumPy_FOUND)
+ endif ()
+ 
+ 
+-if (GUILE_FOUND)
++if (GUILE_FOUND AND NLOPT_CXX)
+ 
+   set (SWIG_MODULE_nlopt_guile_EXTRA_DEPS nlopt-guile.i generate-cpp)
+   set (CMAKE_SWIG_FLAGS -scmstub)
+@@ -74,7 +74,7 @@ if (GUILE_FOUND)
+ endif ()
+ 
+ 
+-if (JNI_FOUND AND Java_FOUND AND SWIG_FOUND)
++if (JNI_FOUND AND Java_FOUND AND SWIG_FOUND AND NLOPT_CXX)
+ 
+   include (UseJava)
+ 
+diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
+index f66d2805..0edf5e87 100644
+--- a/test/CMakeLists.txt
++++ b/test/CMakeLists.txt
+@@ -1,28 +1,26 @@
+ add_custom_target (tests)
+ 
+ macro(NLOPT_add_cpp_test test_name)
+-  add_executable (${test_name} ${test_name}.cxx)
+-  target_link_libraries (${test_name} ${nlopt_lib})
+-  add_dependencies (tests ${test_name})
+-  target_include_directories (${test_name} PRIVATE 
${NLOPT_PRIVATE_INCLUDE_DIRS})
+-  foreach(arg IN ITEMS ${ARGN})
+-    add_test (NAME check_${test_name}_${arg} COMMAND ${test_name} ${arg})
+-    if (CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
+-      set_tests_properties (check_${test_name}_${arg}
+-        PROPERTIES ENVIRONMENT 
"PATH=${PROJECT_BINARY_DIR}\\${CMAKE_BUILD_TYPE};$ENV{PATH}")  # to load dll
+-    endif ()
+-  endforeach()
++  if (NLOPT_CXX)
++    add_executable (${test_name} ${test_name}.cxx)
++    target_link_libraries (${test_name} ${nlopt_lib})
++    add_dependencies (tests ${test_name})
++    target_include_directories (${test_name} PRIVATE 
${NLOPT_PRIVATE_INCLUDE_DIRS})
++    foreach(arg IN ITEMS ${ARGN})
++      add_test (NAME check_${test_name}_${arg} COMMAND ${test_name} ${arg})
++      if (CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
++        set_tests_properties (check_${test_name}_${arg}
++          PROPERTIES ENVIRONMENT 
"PATH=${PROJECT_BINARY_DIR}\\${CMAKE_BUILD_TYPE};$ENV{PATH}")  # to load dll
++      endif ()
++    endforeach()
++  endif ()
+ endmacro()
+ 
+ NLOPT_add_cpp_test(t_tutorial 24 25 31 40)
+ NLOPT_add_cpp_test(cpp_functor 0)
+ NLOPT_add_cpp_test(t_fbound 0)
+ NLOPT_add_cpp_test(t_except 1 0)
+-
+ NLOPT_add_cpp_test(t_bounded 0 1 2 3 4 5 6 7 8 19 35 42 43)
+-if (NOT NLOPT_CXX)
+-  set_tests_properties (check_t_bounded_8 check_t_bounded_43 PROPERTIES 
DISABLED TRUE)
+-endif ()
+ 
+ # have to add timer.c and mt19937ar.c as symbols are declared extern
+ set (testopt_sources testfuncs.c testfuncs.h testopt.c 
${PROJECT_SOURCE_DIR}/src/util/timer.c 
${PROJECT_SOURCE_DIR}/src/util/mt19937ar.c)
+@@ -67,7 +65,7 @@ foreach (algo_index RANGE 28) # 42
+   endforeach ()
+ endforeach ()
+ 
+-if (Python_NumPy_FOUND AND (SWIG_FOUND OR (EXISTS 
${PROJECT_SOURCE_DIR}/src/swig/nlopt-python.cpp)))
++if (TARGET nlopt_python)
+   set (PYINSTALLCHECK_ENVIRONMENT 
"LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/src/swig"
+                                   
"PYTHONPATH=$<SHELL_PATH:${PROJECT_BINARY_DIR}/src/swig/python;${PROJECT_BINARY_DIR}/src/swig>"
+       )
+@@ -85,7 +83,7 @@ endif ()
+ # The binding itself should also compile with more ancient Java versions that
+ # have already reached their end of life, but it is not worth uglifying the 
test
+ # code for them, because people will then cargo-cult the legacy boilerplate.
+-if (JNI_FOUND AND Java_FOUND AND SWIG_FOUND AND NOT Java_VERSION VERSION_LESS 
1.8)
++if (TARGET nlopt_java AND NOT Java_VERSION VERSION_LESS 1.8)
+   include (UseJava)
+   add_jar (t_java SOURCES t_java.java INCLUDE_JARS nlopt_jar ENTRY_POINT 
t_java)
+   get_property (t_java_jar TARGET t_java PROPERTY JAR_FILE)
+@@ -100,15 +98,15 @@ if (JNI_FOUND AND Java_FOUND AND SWIG_FOUND AND NOT 
Java_VERSION VERSION_LESS 1.
+   endforeach()
+ endif ()
+ 
+-if (OCTAVE_FOUND)
++if (TARGET nlopt_optimize)
+   add_test (NAME test_octave COMMAND ${OCTAVE_EXECUTABLE} 
${CMAKE_CURRENT_SOURCE_DIR}/t_octave.m ${PROJECT_SOURCE_DIR}/src/octave 
${PROJECT_BINARY_DIR}/src/octave)
+ endif ()
+ 
+-if (MATLAB_FOUND)
++if (TARGET nlopt_optimize-mex)
+   add_test (NAME test_matlab COMMAND ${Matlab_MAIN_PROGRAM} -nodesktop 
-nosplash  -r "addpath('${PROJECT_SOURCE_DIR}/src/octave'); 
addpath('${PROJECT_BINARY_DIR}/src/octave'); try; 
run('${CMAKE_CURRENT_SOURCE_DIR}/t_matlab.m'); catch; exit(1); end; quit")
+ endif ()
+ 
+-if (GUILE_FOUND AND (SWIG_FOUND OR (EXISTS 
${PROJECT_SOURCE_DIR}/src/swig/nlopt-guile.cpp)))
++if (TARGET nlopt_guile)
+   set (GUILECHECK_ENVIRONMENT "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/src/swig"
+                               
"GUILE_LOAD_PATH=$<SHELL_PATH:${PROJECT_BINARY_DIR}/src/swig/guile;${PROJECT_BINARY_DIR}/src/swig>"
+                               "GUILE_AUTO_COMPILE=0")
+

diff --git a/sci-libs/nlopt/files/nlopt-2.10.0-libm-pc.patch 
b/sci-libs/nlopt/files/nlopt-2.10.0-libm-pc.patch
new file mode 100644
index 000000000000..a37371693cd8
--- /dev/null
+++ b/sci-libs/nlopt/files/nlopt-2.10.0-libm-pc.patch
@@ -0,0 +1,25 @@
+https://github.com/stevengj/nlopt/commit/bb608c3466baf5330cf57e659b259d1d87869ff1
+
+From bb608c3466baf5330cf57e659b259d1d87869ff1 Mon Sep 17 00:00:00 2001
+From: Julien Schueller <[email protected]>
+Date: Mon, 24 Feb 2025 16:09:37 +0100
+Subject: [PATCH] CMake: Fix pkgconfig file
+
+---
+ CMakeLists.txt | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 39b01441..a7f65733 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -106,7 +106,7 @@ check_type_size ("unsigned long" SIZEOF_UNSIGNED_LONG)
+ 
+ find_library(M_LIBRARY m)
+ if (M_LIBRARY)
+-  set (LIBS_PRIVATE "-l${M_LIBRARY}")
++  set (LIBS_PRIVATE "-lm")
+ endif()
+ 
+ if (NOT DEFINED HAVE_FPCLASSIFY)
+

diff --git a/sci-libs/nlopt/files/nlopt-2.10.0-libm.patch 
b/sci-libs/nlopt/files/nlopt-2.10.0-libm.patch
new file mode 100644
index 000000000000..28368de08f06
--- /dev/null
+++ b/sci-libs/nlopt/files/nlopt-2.10.0-libm.patch
@@ -0,0 +1,48 @@
+https://github.com/stevengj/nlopt/commit/e45da76243191febe447e3173e5d23e05fc84ee4
+
+From e45da76243191febe447e3173e5d23e05fc84ee4 Mon Sep 17 00:00:00 2001
+From: Julien Schueller <[email protected]>
+Date: Mon, 24 Feb 2025 15:02:22 +0100
+Subject: [PATCH] CMake: Detect libm with find_library (#596)
+
+---
+ CMakeLists.txt | 11 +++++------
+ 1 file changed, 5 insertions(+), 6 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index e5d9c67c..c0a84de3 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -80,8 +80,6 @@ include (CheckTypeSize)
+ include (CheckCCompilerFlag)
+ include (CheckCXXSymbolExists)
+ include (CheckCSourceCompiles)
+-include (CheckCXXCompilerFlag)
+-include (CheckLibraryExists)
+ 
+ 
#==============================================================================
+ # COMPILATION CHECKINGS and CONFIGURATION GENERATION
+@@ -108,9 +106,8 @@ set (HAVE_UINT32_T ${SIZEOF_UINT32_T})
+ check_type_size ("unsigned int" SIZEOF_UNSIGNED_INT)
+ check_type_size ("unsigned long" SIZEOF_UNSIGNED_LONG)
+ 
+-check_library_exists ("m" sqrt "" HAVE_LIBM)
+-if (HAVE_LIBM)
+-  set (M_LIBRARY m)
++find_library(M_LIBRARY m)
++if (M_LIBRARY)
+   set (LIBS_PRIVATE "-l${M_LIBRARY}")
+ endif()
+ 
+@@ -258,7 +255,9 @@ if (NLOPT_LUKSAN)
+   target_include_directories(${nlopt_lib} PRIVATE src/algs/luksan)
+   target_compile_definitions (${nlopt_lib} PRIVATE NLOPT_LUKSAN)
+ endif ()
+-target_link_libraries (${nlopt_lib} ${M_LIBRARY})
++if (M_LIBRARY)
++  target_link_libraries (${nlopt_lib} ${M_LIBRARY})
++endif ()
+ set_target_properties (${nlopt_lib} PROPERTIES SOVERSION ${SO_MAJOR})
+ set_target_properties (${nlopt_lib} PROPERTIES VERSION 
"${SO_MAJOR}.${SO_MINOR}.${SO_PATCH}")
+ 
+

diff --git a/sci-libs/nlopt/nlopt-2.10.0.ebuild 
b/sci-libs/nlopt/nlopt-2.10.0.ebuild
new file mode 100644
index 000000000000..38e80afc3e4e
--- /dev/null
+++ b/sci-libs/nlopt/nlopt-2.10.0.ebuild
@@ -0,0 +1,128 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+GUILE_COMPAT=( 2-2 3-0 )
+PYTHON_COMPAT=( python3_{11..14} )
+FORTRAN_NEEDED="test"
+
+inherit python-r1 cmake guile-single fortran-2
+
+DESCRIPTION="Non-linear optimization library"
+HOMEPAGE="https://github.com/stevengj/nlopt";
+SRC_URI="https://github.com/stevengj/nlopt/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="LGPL-2.1 MIT"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 ~ppc ~ppc64 ~riscv ~x86 ~amd64-linux ~x86-linux"
+IUSE="cxx guile octave python test"
+REQUIRED_USE="guile? ( ${GUILE_REQUIRED_USE} ) python? ( 
${PYTHON_REQUIRED_USE} )"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+       guile? ( ${GUILE_DEPS} )
+       octave? ( >=sci-mathematics/octave-6:= )
+       python? (
+               ${PYTHON_DEPS}
+               dev-python/numpy[${PYTHON_USEDEP}]
+       )
+"
+DEPEND="${RDEPEND}"
+BDEPEND="python? ( dev-lang/swig )"
+
+PATCHES=(
+       "${FILESDIR}"/${P}-libm.patch
+       "${FILESDIR}"/${P}-cxx.patch
+       "${FILESDIR}"/${P}-libm-pc.patch
+)
+
+pkg_setup() {
+       use guile && guile-single_pkg_setup
+       fortran-2_pkg_setup
+}
+
+src_prepare() {
+       cmake_src_prepare
+
+       use guile && guile_bump_sources
+       use python && python_copy_sources
+}
+
+src_configure() {
+       # MATLAB detection causes problems (as in bug #826774) if we don't
+       # explicitly disable it.
+       local mycmakeargs=(
+               -DNLOPT_CXX=$(usex cxx)
+               -DNLOPT_FORTRAN=$(usex test)
+               -DNLOPT_GUILE=$(usex guile)
+               -DNLOPT_JAVA=OFF
+               -DNLOPT_OCTAVE=$(usex octave)
+               -DNLOPT_MATLAB=OFF
+               -DNLOPT_PYTHON=OFF
+               -DNLOPT_SWIG=$(usex python)
+               -DNLOPT_TESTS=$(usex test)
+       )
+
+       cmake_src_configure
+
+       if use python; then
+               python_configure() {
+                       local mycmakeargs=(
+                               ${mycmakeargs[@]}
+                               -DNLOPT_PYTHON=ON
+                               -DINSTALL_PYTHON_DIR="$(python_get_sitedir)"
+                       )
+
+                       cmake_src_configure
+               }
+
+               python_foreach_impl run_in_build_dir python_configure
+       fi
+}
+
+src_compile() {
+       cmake_src_compile
+
+       if use python; then
+               python_foreach_impl run_in_build_dir cmake_src_compile
+       fi
+}
+
+src_test() {
+       do_test() {
+               cd "${BUILD_DIR}"/test || die
+
+               local a f
+               for a in {1..$(usex cxx 9 7)}; do
+                       for f in {5..9}; do
+                               ./testopt -a $a -o $f || die "algorithm $a 
function $f failed"
+                       done
+               done
+       }
+
+       do_test
+
+       if use python; then
+               python_foreach_impl run_in_build_dir do_test
+       fi
+}
+
+nlopt_install() {
+       cmake_src_install
+       python_optimize
+}
+
+src_install() {
+       cmake_src_install
+
+       guile_unstrip_ccache
+       if use python; then
+               python_foreach_impl run_in_build_dir nlopt_install
+       fi
+
+       local r
+       for r in */README; do
+               newdoc ${r} README.$(dirname ${r})
+       done
+}

Reply via email to