From 45ac9d117f3f2dd35cd51afc279e1f3aab6f158f Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Mon, 27 Jan 2025 05:04:59 -0700 Subject: [PATCH 01/19] First version of cppad-mixed (passes conda build on linux) --- recipes/cppad-mixed/bld.bat | 26 +++++++++++++ recipes/cppad-mixed/build.sh | 44 +++++++++++++++++++++ recipes/cppad-mixed/conda-build.log | 17 +++++++++ recipes/cppad-mixed/meta.yaml | 59 +++++++++++++++++++++++++++++ 4 files changed, 146 insertions(+) create mode 100644 recipes/cppad-mixed/bld.bat create mode 100755 recipes/cppad-mixed/build.sh create mode 100644 recipes/cppad-mixed/conda-build.log create mode 100644 recipes/cppad-mixed/meta.yaml diff --git a/recipes/cppad-mixed/bld.bat b/recipes/cppad-mixed/bld.bat new file mode 100644 index 0000000000000..d67d32c87bfb0 --- /dev/null +++ b/recipes/cppad-mixed/bld.bat @@ -0,0 +1,26 @@ +mkdir build +cd build + +:: cmake +cmake -S %SRCDIR% -B . ^ + -G "NMake Makefiles" ^ + -D CMAKE_BUILD_TYPE=Release ^ + -D cmake_install_prefix=%LIBRARY_PREFIX% ^ + -D cmake_libdir=lib ^ + -D ldlt_cholmod=yes ^ + -D optimize_cppad_function=yes ^ + -D for_hes_sparsity=yes +if errorlevel 1 exit 1 + +:: build +cmake --build . --config Release +if errorlevel 1 exit 1 + +:: check +cmake --build . --config Release --target check +if errorlevel 1 exit 1 + +:: install +cmake --build . --config Release --target install +if errorlevel 1 exit 1 + diff --git a/recipes/cppad-mixed/build.sh b/recipes/cppad-mixed/build.sh new file mode 100755 index 0000000000000..8c1361a8e3432 --- /dev/null +++ b/recipes/cppad-mixed/build.sh @@ -0,0 +1,44 @@ +#! /bin/sh +# +# PKG_CONFIG_PATH +if [ ! -d "$PKG_CONFIG_PATH" ] +then + echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" + echo 'Environment setting for PKG_CONFIG_PATH does not exist' + PKG_CONFIG_PATH='' +fi +for dir in lib share +do + PKG_CONFIG_PATH+=":$BUILD_PREFIX/$dir/pkgconfig" +done +echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" +# +# extra_cxx_flags +extra_cxx_flags='-Wpedantic -std=c++11 -Wall -Wshadow -Wconversion' +if [[ "${target_platform}" == osx-* ]]; then + # https://conda-forge.org/docs/maintainer/knowledge_base.html# + # newer-c-features-with-old-sdk + extra_cxx_flags="${extra_cxx_flags} -D_LIBCPP_DISABLE_AVAILABILITY" +fi +# +# build +mkdir build && cd build +# +# cmake +cmake -S $SRC_DIR -B . \ + -G 'Unix Makefiles' \ + -D CMAKE_CROSSCOMPILING=$CONDA_BUILD_CROSS_COMPILATION \ + -D CMAKE_CROSSCOMPILING_EMULATOR=$CONDA_BUILD_CROSS_COMPILATION \ + -D CMAKE_BUILD_TYPE=Release \ + -D cmake_install_prefix="$PREFIX" \ + -D extra_cxx_flags="$extra_cxx_flags" \ + -D cmake_libdir=lib \ + -D ldlt_cholmod=yes \ + -D optimize_cppad_function=yes \ + -D for_hes_sparsity=yes +# +# check +make -j4 check +# +# install +make install diff --git a/recipes/cppad-mixed/conda-build.log b/recipes/cppad-mixed/conda-build.log new file mode 100644 index 0000000000000..d90416ce16aa2 --- /dev/null +++ b/recipes/cppad-mixed/conda-build.log @@ -0,0 +1,17 @@ +/home/bradbell/.conda/envs/build_env/lib/python3.11/site-packages/conda_build/cli/main_build.py:520: FutureWarning: The default `pkg_format` of '.tar.bz2' is deprecated and will be removed in 25.1. + +The new default `pkg_format` value will be '.conda'. If you want to keep using `.tar.bz2`, consider: +- Setting `conda_build.pkg_format: 'tar.bz2' in your condarc file. +- Using `--pkg-format=tar.bz2` in the CLI. + + deprecated.topic( +ERROR: Glob /home/bradbell/repo/staged-recipes.git/recipes/cppad-mixed/recipes/cppad-mixed did not match in root_dir /home/bradbell/repo/staged-recipes.git/recipes/cppad-mixed +Traceback (most recent call last): + File "/home/bradbell/.conda/envs/build_env/bin/conda-build", line 11, in + sys.exit(execute()) + ^^^^^^^^^ + File "/home/bradbell/.conda/envs/build_env/lib/python3.11/site-packages/conda_build/cli/main_build.py", line 648, in execute + api.build( + File "/home/bradbell/.conda/envs/build_env/lib/python3.11/site-packages/conda_build/api.py", line 207, in build + raise ValueError( +ValueError: No valid recipes found for input: ['recipes/cppad-mixed'] diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml new file mode 100644 index 0000000000000..2984c75220313 --- /dev/null +++ b/recipes/cppad-mixed/meta.yaml @@ -0,0 +1,59 @@ +{% set name = "cppad-mixed" %} +{% set version = "2025.0.1" %} + +package: + name: {{ name }} + version: {{ version }} + +source: + url: https://github.com/bradbell/cppad_mixed/archive/{{ version }}.tar.gz + sha256: 9cb39c79118dd67bc7c22f781aa7fbe9a6792b85d335929bad3ec92a016bf0b4 + +build: + number: 0 + # No ABI policy, let's be conservative + run_exports: + - {{ pin_subpackage(name, max_pin='x.x') }} + +requirements: + build: + - gnuconfig # [unix] + - {{ compiler('c') }} + - {{ stdlib("c") }} + - {{ compiler('cxx') }} + - pkg-config + - cmake + - gsl + - eigen + - suitesparse + - ipopt + - cppad + +test: + commands: + # + # cppad_mixed.hpp + - if not exist %PREFIX%\\Library\\include\\cppad\\mixed\\cppad_mixed.hpp exit 1 # [win] + - test -f ${PREFIX}/include/cppad/mixed/cppad_mixed.hpp # [not win] + # + # cppad_mixed.pd + - if not exist %PREFIX%\\Library\\share\\pkgconfig\\cppad_mixed.pc exit 1 # [win] + - test -f ${PREFIX}/share/pkgconfig/cppad_mixed.pc # [not_win] + # + # cppad_mixed library + - test -f ${PREFIX}/lib/libcppad_mixed.so # [linux] + - test -f ${PREFIX}/lib/libcppad_mixed.dylib # [osx] + - if not exist %PREFIX%\\Library\\lib\\cppad_mixed.lib exit 1 # [win] + +about: + home: https://cppad-mixed.readthedocs.io/stable-2025 + license: EPL-2.0 OR GPL-2.0-or-later + license_file: agpl-3.0.txt + summary: C++ Laplace Approximation of Mixed Effects Models + + dev_url: https://github.com/bradbell/cppad_mixed + doc_url: https://cppad-mixed.readthedocs.io/stable-2025/ + +extra: + recipe-maintainers: + - bradbell From ebbc82ea6ea8b53480fad8214039ba662b8a68a0 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Mon, 27 Jan 2025 05:26:40 -0700 Subject: [PATCH 02/19] First verison of cppad-mixed that passes conda build on windows. --- recipes/cppad-mixed/CMakeLists.patch | 75 ++++++++++++++++++++++++++++ recipes/cppad-mixed/bld.bat | 7 ++- recipes/cppad-mixed/meta.yaml | 2 + 3 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 recipes/cppad-mixed/CMakeLists.patch diff --git a/recipes/cppad-mixed/CMakeLists.patch b/recipes/cppad-mixed/CMakeLists.patch new file mode 100644 index 0000000000000..48c3bed6e9552 --- /dev/null +++ b/recipes/cppad-mixed/CMakeLists.patch @@ -0,0 +1,75 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 37a99042..4ab1342d 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -50,6 +50,10 @@ MACRO( required_definition variable type docstring ) + SET( ${variable}_01 0 ) + ENDIF( ${variable} ) + ENDIF( ${type} STREQUAL "BOOL" ) ++ IF( ${type} STREQUAL "PATH" ) ++ CMAKE_PATH(SET ${variable} "${${variable}}" ) ++ MESSAGE( STATUS "${variable} = ${${variable}}" ) ++ ENDIF( ${type} STREQUAL "PATH" ) + ENDMACRO( required_definition ) + # ---------------------------------------------------------------------------- + # optional_definition( variable type docstring ) +@@ -220,7 +224,7 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) + SET(suitesparse_suffix "${suffix}") + ENDIF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) + ENDFOREACH(suffix "include" "include/suitesparse") +-ENDIF( NOT ( "${brew_prefix}" STREQUAL "" ) ) ++ENDIF( NOT "${brew_prefix}" STREQUAL "" ) + FOREACH(prefix + /usr + /usr/local +@@ -229,6 +233,7 @@ FOREACH(prefix + ${cmake_install_prefix} + ) + FOREACH(suffix "include" "include/suitesparse") ++# ---------------------------------------------------------------------------- + IF( EXISTS "${prefix}/${suffix}/cholmod.h" ) + IF( suitesparse_prefix ) + SET(same "yes") +@@ -271,22 +276,29 @@ SET(suitesparse_LIBRARIES + # suitesparse_LIBRARY_DIRS + SET(suitesparse_LIBRARY_DIRS "NOTFOUND") + FOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) +- SET(both "${suitesparse_prefix}/${suffix}") +- SET(globbing_expression "${both}/libcholmod.*") +- FILE(GLOB match_1 ${globbing_expression}) +- IF( match_1 ) +- SET(suitesparse_LIBRARY_DIRS "${both}") +- ELSE( match_1 ) +- SET(globbing_expression "${both}/*/libcholmod.*") +- FILE(GLOB match_2 ${globbing_expression}) +- IF( match_2 ) +- SET(suitesparse_LIBRARY_DIRS "${both}") +- ENDIF( match_2 ) +- ENDIF( match_1 ) ++ SET(libdir "${suitesparse_prefix}/${suffix}") ++ FOREACH(name "libcholmod" "cholmod") ++ SET(globbing_expression "${libdir}/${name}.*") ++ FILE(GLOB match_1 ${globbing_expression}) ++ IF( match_1 ) ++ SET(suitesparse_LIBRARY_DIRS "${libdir}") ++ ELSE( match_1 ) ++ SET(globbing_expression "${libdir}/*/${name}.*") ++ FILE(GLOB match_2 ${globbing_expression}) ++ IF( match_2 ) ++ SET(suitesparse_LIBRARY_DIRS "${libdir}") ++ MESSAGE(FATAL_ERROR ++ "Report this error as a cppad-mixed issue. The search results" ++ "seem to be incorrect and never get used because the true" ++ "libdir is ${libdir}/* where * is the match found by GLOB" ++ ) ++ ENDIF( match_2 ) ++ ENDIF( match_1 ) ++ ENDFOREACH(name "libcholmod" "cholmod") + ENDFOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) + IF( NOT suitesparse_LIBRARY_DIRS ) + MESSAGE(FATAL_ERROR +- "Cannot find libcholmod.* in ${suitesparse_prefix}/libdir" ++ "Cannot find cholmod library in ${suitesparse_prefix}/libdir" + " where libdir is lib, lib64, or cmake_libdir" + ) + ENDIF( NOT suitesparse_LIBRARY_DIRS ) diff --git a/recipes/cppad-mixed/bld.bat b/recipes/cppad-mixed/bld.bat index d67d32c87bfb0..05ed323ea073e 100644 --- a/recipes/cppad-mixed/bld.bat +++ b/recipes/cppad-mixed/bld.bat @@ -1,11 +1,14 @@ mkdir build cd build +echo SRC_DIR = %SRC_DIR% +echo BUILD_PREFIX = %BUILD_PREFIX% :: cmake -cmake -S %SRCDIR% -B . ^ +cmake -S %SRC_DIR% -B . ^ -G "NMake Makefiles" ^ -D CMAKE_BUILD_TYPE=Release ^ - -D cmake_install_prefix=%LIBRARY_PREFIX% ^ + -D cmake_install_prefix="%BUILD_PREFIX%\Library" ^ + -D extra_cxx_flags="" ^ -D cmake_libdir=lib ^ -D ldlt_cholmod=yes ^ -D optimize_cppad_function=yes ^ diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 2984c75220313..df1dfaf1df9cb 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -8,6 +8,8 @@ package: source: url: https://github.com/bradbell/cppad_mixed/archive/{{ version }}.tar.gz sha256: 9cb39c79118dd67bc7c22f781aa7fbe9a6792b85d335929bad3ec92a016bf0b4 + patches: + - CMakeLists.patch build: number: 0 From 891e1ce997c72db84be5e7dbeaedd038a6a17a26 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Mon, 27 Jan 2025 05:41:31 -0700 Subject: [PATCH 03/19] cppad-mixed: fix license SPDX Idenfifier. --- recipes/cppad-mixed/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index df1dfaf1df9cb..51a630f90eddd 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -49,7 +49,7 @@ test: about: home: https://cppad-mixed.readthedocs.io/stable-2025 - license: EPL-2.0 OR GPL-2.0-or-later + license: AGPL-3.0-or-later license_file: agpl-3.0.txt summary: C++ Laplace Approximation of Mixed Effects Models From 9aa3bce14d7b915e69a81cee0ac3c1b69ef5f27d Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Mon, 27 Jan 2025 09:56:56 -0700 Subject: [PATCH 04/19] cppad-mixed: clean up. CMakeLists.patch: add cmake_search_prefix optional argument bld.bat: use cmake_search_prefix. build.sh: simplify PKG_CONFIG_PATH setting. meta.yaml: correct output file testing. --- recipes/cppad-mixed/CMakeLists.patch | 75 ++++++++++++++++++++++++---- recipes/cppad-mixed/bld.bat | 9 ++-- recipes/cppad-mixed/build.sh | 14 ++---- recipes/cppad-mixed/meta.yaml | 18 +++++-- 4 files changed, 90 insertions(+), 26 deletions(-) diff --git a/recipes/cppad-mixed/CMakeLists.patch b/recipes/cppad-mixed/CMakeLists.patch index 48c3bed6e9552..d4a17f96e69dc 100644 --- a/recipes/cppad-mixed/CMakeLists.patch +++ b/recipes/cppad-mixed/CMakeLists.patch @@ -1,8 +1,18 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 37a99042..4ab1342d 100644 +index 37a99042..d8db5445 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -50,6 +50,10 @@ MACRO( required_definition variable type docstring ) +@@ -12,7 +12,8 @@ + # -D cmake_libdir=value \ + # -D ldlt_cholmod=value \ + # -D optimize_cppad_function=value \ +-# -D for_hes_sparsity=value ++# -D for_hes_sparsity=value \ ++# optional variables: -D cmake_search_prefix=value + # ============================================================================ + # Macro definitions + # ============================================================================ +@@ -50,6 +51,10 @@ MACRO( required_definition variable type docstring ) SET( ${variable}_01 0 ) ENDIF( ${variable} ) ENDIF( ${type} STREQUAL "BOOL" ) @@ -13,24 +23,71 @@ index 37a99042..4ab1342d 100644 ENDMACRO( required_definition ) # ---------------------------------------------------------------------------- # optional_definition( variable type docstring ) -@@ -220,7 +224,7 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) +@@ -75,6 +80,10 @@ MACRO( optional_definition variable type docstring ) + SET( ${variable}_01 0 ) + ENDIF( ${variable} ) + ENDIF( ${type} STREQUAL "BOOL" ) ++ IF( ${type} STREQUAL "PATH" ) ++ CMAKE_PATH(SET ${variable} "${${variable}}" ) ++ MESSAGE( STATUS "${variable} = ${${variable}}" ) ++ ENDIF( ${type} STREQUAL "PATH" ) + ENDMACRO( optional_definition ) + # ============================================================================ + CMAKE_MINIMUM_REQUIRED(VERSION 3.0) +@@ -127,6 +136,9 @@ required_definition(optimize_cppad_function BOOL + required_definition(for_hes_sparsity BOOL + "use forward (reverse) method for computing Hessian w.r.t. random effects" + ) ++optional_definition( cmake_search_prefix PATH ++ "another prefix used when searching for installed tools" ++) + # ---------------------------------------------------------------------------- + MESSAGE(STATUS "END:") + # ---------------------------------------------------------------------------- +@@ -198,13 +210,9 @@ ENDIF( cppad_mixed_has_nullptr_flag ) + MESSAGE(STATUS "cppad_mixed_has_nullptr = ${cppad_mixed_has_nullptr_01}") + # ---------------------------------------------------------------------------- + # no pkg-config for SuiteSparse so explicitly set following values: +-# suitesparse_LIBRARY_DIRS +-# suitesparse_INCLUDE_DIRS +-# suitesparse_LIBRARIES + # + # suitesparse_prefix + # suitesparse_suffix +-# suitesparse_in_cholmod_include_01 + SET(suitesparse_prefix "NOTFOUND") + SET(suitesparse_suffix "NOTFOUND") + EXECUTE_PROCESS( +@@ -220,13 +228,17 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) SET(suitesparse_suffix "${suffix}") ENDIF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) ENDFOREACH(suffix "include" "include/suitesparse") -ENDIF( NOT ( "${brew_prefix}" STREQUAL "" ) ) +ENDIF( NOT "${brew_prefix}" STREQUAL "" ) ++IF( NOT cmake_search_prefix ) ++ SET(cmake_search_prefix "" ) ++ENDIF( NOT cmake_search_prefix ) FOREACH(prefix /usr /usr/local -@@ -229,6 +233,7 @@ FOREACH(prefix - ${cmake_install_prefix} + /opt/local + /usr/local/opt/suitesparse +- ${cmake_install_prefix} ++ ${cmake_install_prefix} ++ ${cmake_search_prefix} ) FOREACH(suffix "include" "include/suitesparse") -+# ---------------------------------------------------------------------------- IF( EXISTS "${prefix}/${suffix}/cholmod.h" ) - IF( suitesparse_prefix ) - SET(same "yes") -@@ -271,22 +276,29 @@ SET(suitesparse_LIBRARIES +@@ -263,7 +275,7 @@ ELSE( ${suitesparse_suffix} STREQUAL "include" ) + SET(suitesparse_INCLUDE_DIRS "${suitesparse_prefix}/include/suitesparse" ) + ENDIF( ${suitesparse_suffix} STREQUAL "include" ) + # +-# set suitesparse_LIBRARIES ++# suitesparse_LIBRARIES + SET(suitesparse_LIBRARIES + "cholmod;amd;camd;colamd;ccolamd;suitesparseconfig" + ) +@@ -271,22 +283,29 @@ SET(suitesparse_LIBRARIES # suitesparse_LIBRARY_DIRS SET(suitesparse_LIBRARY_DIRS "NOTFOUND") FOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) diff --git a/recipes/cppad-mixed/bld.bat b/recipes/cppad-mixed/bld.bat index 05ed323ea073e..a69d6dc7d0511 100644 --- a/recipes/cppad-mixed/bld.bat +++ b/recipes/cppad-mixed/bld.bat @@ -1,13 +1,15 @@ mkdir build cd build -echo SRC_DIR = %SRC_DIR% -echo BUILD_PREFIX = %BUILD_PREFIX% +:: PKG_CONFIG_PATH +echo PKG_CONFIG_PATH=%PKG_CONFIG_PATH% + :: cmake cmake -S %SRC_DIR% -B . ^ -G "NMake Makefiles" ^ -D CMAKE_BUILD_TYPE=Release ^ - -D cmake_install_prefix="%BUILD_PREFIX%\Library" ^ + -D cmake_install_prefix="%PREFIX%\Library" ^ + -D cmake_search_prefix="%BUILD_PREFIX%\Library" ^ -D extra_cxx_flags="" ^ -D cmake_libdir=lib ^ -D ldlt_cholmod=yes ^ @@ -27,3 +29,4 @@ if errorlevel 1 exit 1 cmake --build . --config Release --target install if errorlevel 1 exit 1 +echo 'bld.bat: OK' diff --git a/recipes/cppad-mixed/build.sh b/recipes/cppad-mixed/build.sh index 8c1361a8e3432..a3382094e9ca1 100755 --- a/recipes/cppad-mixed/build.sh +++ b/recipes/cppad-mixed/build.sh @@ -1,16 +1,8 @@ #! /bin/sh # # PKG_CONFIG_PATH -if [ ! -d "$PKG_CONFIG_PATH" ] -then - echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" - echo 'Environment setting for PKG_CONFIG_PATH does not exist' - PKG_CONFIG_PATH='' -fi -for dir in lib share -do - PKG_CONFIG_PATH+=":$BUILD_PREFIX/$dir/pkgconfig" -done +PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig" +PKG_CONFIG_PATH+=":$BUILD_PREFIX/share/pkgconfig" echo "PKG_CONFIG_PATH=$PKG_CONFIG_PATH" # # extra_cxx_flags @@ -42,3 +34,5 @@ make -j4 check # # install make install +# +echo 'build.sh: OK' diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 51a630f90eddd..eb873bfe752c3 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -1,3 +1,13 @@ +# conda-verify warnings: +# +# [C2115] Found duplicate build requirements: ... +# This warning lists two copies of 'vs2017_win-64' but meta.yaml does not +# specify this requriement (it is comming automatially). +# +# [C2122] Found invalid license family "AGPL-3.0-or-later" +# This is a valid SPDX license identifier; see +# https://spdx.org/licenses/AGPL-3.0-or-later.html +# {% set name = "cppad-mixed" %} {% set version = "2025.0.1" %} @@ -38,14 +48,14 @@ test: - if not exist %PREFIX%\\Library\\include\\cppad\\mixed\\cppad_mixed.hpp exit 1 # [win] - test -f ${PREFIX}/include/cppad/mixed/cppad_mixed.hpp # [not win] # - # cppad_mixed.pd - - if not exist %PREFIX%\\Library\\share\\pkgconfig\\cppad_mixed.pc exit 1 # [win] - - test -f ${PREFIX}/share/pkgconfig/cppad_mixed.pc # [not_win] + # cppad_mixed.pc + - if not exist %PREFIX%\\Library\\lib\\pkgconfig\\cppad_mixed.pc exit 1 # [win] + - test -f ${PREFIX}/lib/pkgconfig/cppad_mixed.pc # [not_win] # # cppad_mixed library + - if not exist %PREFIX%\\Library\\lib\\cppad_mixed.lib exit 1 # [win] - test -f ${PREFIX}/lib/libcppad_mixed.so # [linux] - test -f ${PREFIX}/lib/libcppad_mixed.dylib # [osx] - - if not exist %PREFIX%\\Library\\lib\\cppad_mixed.lib exit 1 # [win] about: home: https://cppad-mixed.readthedocs.io/stable-2025 From 69e01a8b7e7d84068f348d7d9e24535ec4bda045 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Tue, 28 Jan 2025 04:13:33 -0700 Subject: [PATCH 05/19] cppad-mixed: Fix osx cannot find cholmod and unix does not have make. --- recipes/cppad-mixed/CMakeLists.patch | 62 +++++++++++++++++----------- recipes/cppad-mixed/build.sh | 1 + recipes/cppad-mixed/meta.yaml | 2 +- 3 files changed, 41 insertions(+), 24 deletions(-) diff --git a/recipes/cppad-mixed/CMakeLists.patch b/recipes/cppad-mixed/CMakeLists.patch index d4a17f96e69dc..5f09f0493a5bb 100644 --- a/recipes/cppad-mixed/CMakeLists.patch +++ b/recipes/cppad-mixed/CMakeLists.patch @@ -1,8 +1,8 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 37a99042..d8db5445 100644 +index 37a99042..25675cca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt -@@ -12,7 +12,8 @@ +@@ -12,13 +12,21 @@ # -D cmake_libdir=value \ # -D ldlt_cholmod=value \ # -D optimize_cppad_function=value \ @@ -12,7 +12,20 @@ index 37a99042..d8db5445 100644 # ============================================================================ # Macro definitions # ============================================================================ -@@ -50,6 +51,10 @@ MACRO( required_definition variable type docstring ) ++# ++# print_variable(variable) + MACRO(print_variable variable) + MESSAGE(STATUS "${variable}=${${variable}}" ) + ENDMACRO(print_variable variable) ++# ++# trace_line_in_file(${CMAKE_CURRENT_LIST_LINE}, ${CMAKE_CURRENT_LIST_FILE} ) ++MACRO(trace_line_in_file line file) ++MESSAGE(STATUS "Line ${line} in ${file}") ++ENDMACRO( ) + # ---------------------------------------------------------------------------- + # required_definition( variable type docstring ) + # +@@ -50,6 +58,10 @@ MACRO( required_definition variable type docstring ) SET( ${variable}_01 0 ) ENDIF( ${variable} ) ENDIF( ${type} STREQUAL "BOOL" ) @@ -23,7 +36,7 @@ index 37a99042..d8db5445 100644 ENDMACRO( required_definition ) # ---------------------------------------------------------------------------- # optional_definition( variable type docstring ) -@@ -75,6 +80,10 @@ MACRO( optional_definition variable type docstring ) +@@ -75,11 +87,15 @@ MACRO( optional_definition variable type docstring ) SET( ${variable}_01 0 ) ENDIF( ${variable} ) ENDIF( ${type} STREQUAL "BOOL" ) @@ -34,7 +47,13 @@ index 37a99042..d8db5445 100644 ENDMACRO( optional_definition ) # ============================================================================ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) -@@ -127,6 +136,9 @@ required_definition(optimize_cppad_function BOOL + PROJECT(cppad_mixed) +-SET(cppad_mixed_version "2025.0.1") ++SET(cppad_mixed_version "2025.1.28") + INCLUDE_DIRECTORIES( ${cppad_mixed_SOURCE_DIR}/include ) + INCLUDE(CheckCXXSourceRuns) + MESSAGE(STATUS "BEGIN:") +@@ -127,6 +143,9 @@ required_definition(optimize_cppad_function BOOL required_definition(for_hes_sparsity BOOL "use forward (reverse) method for computing Hessian w.r.t. random effects" ) @@ -44,7 +63,7 @@ index 37a99042..d8db5445 100644 # ---------------------------------------------------------------------------- MESSAGE(STATUS "END:") # ---------------------------------------------------------------------------- -@@ -198,13 +210,9 @@ ENDIF( cppad_mixed_has_nullptr_flag ) +@@ -198,13 +217,9 @@ ENDIF( cppad_mixed_has_nullptr_flag ) MESSAGE(STATUS "cppad_mixed_has_nullptr = ${cppad_mixed_has_nullptr_01}") # ---------------------------------------------------------------------------- # no pkg-config for SuiteSparse so explicitly set following values: @@ -58,12 +77,21 @@ index 37a99042..d8db5445 100644 SET(suitesparse_prefix "NOTFOUND") SET(suitesparse_suffix "NOTFOUND") EXECUTE_PROCESS( -@@ -220,13 +228,17 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) +@@ -212,7 +227,7 @@ EXECUTE_PROCESS( + OUTPUT_VARIABLE brew_prefix + OUTPUT_STRIP_TRAILING_WHITESPACE + ) +-IF( NOT "${brew_prefix}" STREQUAL "" ) ++IF( FALSE ) + FOREACH(suffix "include" "include/suitesparse") + IF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) + MESSAGE(STATUS "Using ${brew_prefix}/${suffix}/cholmod.h" ) +@@ -220,13 +235,17 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) SET(suitesparse_suffix "${suffix}") ENDIF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) ENDFOREACH(suffix "include" "include/suitesparse") -ENDIF( NOT ( "${brew_prefix}" STREQUAL "" ) ) -+ENDIF( NOT "${brew_prefix}" STREQUAL "" ) ++ENDIF( ) +IF( NOT cmake_search_prefix ) + SET(cmake_search_prefix "" ) +ENDIF( NOT cmake_search_prefix ) @@ -72,13 +100,12 @@ index 37a99042..d8db5445 100644 /usr/local /opt/local /usr/local/opt/suitesparse -- ${cmake_install_prefix} -+ ${cmake_install_prefix} + ${cmake_install_prefix} + ${cmake_search_prefix} ) FOREACH(suffix "include" "include/suitesparse") IF( EXISTS "${prefix}/${suffix}/cholmod.h" ) -@@ -263,7 +275,7 @@ ELSE( ${suitesparse_suffix} STREQUAL "include" ) +@@ -263,7 +282,7 @@ ELSE( ${suitesparse_suffix} STREQUAL "include" ) SET(suitesparse_INCLUDE_DIRS "${suitesparse_prefix}/include/suitesparse" ) ENDIF( ${suitesparse_suffix} STREQUAL "include" ) # @@ -87,7 +114,7 @@ index 37a99042..d8db5445 100644 SET(suitesparse_LIBRARIES "cholmod;amd;camd;colamd;ccolamd;suitesparseconfig" ) -@@ -271,22 +283,29 @@ SET(suitesparse_LIBRARIES +@@ -271,22 +290,18 @@ SET(suitesparse_LIBRARIES # suitesparse_LIBRARY_DIRS SET(suitesparse_LIBRARY_DIRS "NOTFOUND") FOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) @@ -109,17 +136,6 @@ index 37a99042..d8db5445 100644 + FILE(GLOB match_1 ${globbing_expression}) + IF( match_1 ) + SET(suitesparse_LIBRARY_DIRS "${libdir}") -+ ELSE( match_1 ) -+ SET(globbing_expression "${libdir}/*/${name}.*") -+ FILE(GLOB match_2 ${globbing_expression}) -+ IF( match_2 ) -+ SET(suitesparse_LIBRARY_DIRS "${libdir}") -+ MESSAGE(FATAL_ERROR -+ "Report this error as a cppad-mixed issue. The search results" -+ "seem to be incorrect and never get used because the true" -+ "libdir is ${libdir}/* where * is the match found by GLOB" -+ ) -+ ENDIF( match_2 ) + ENDIF( match_1 ) + ENDFOREACH(name "libcholmod" "cholmod") ENDFOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) diff --git a/recipes/cppad-mixed/build.sh b/recipes/cppad-mixed/build.sh index a3382094e9ca1..b4c45fbda12fd 100755 --- a/recipes/cppad-mixed/build.sh +++ b/recipes/cppad-mixed/build.sh @@ -23,6 +23,7 @@ cmake -S $SRC_DIR -B . \ -D CMAKE_CROSSCOMPILING_EMULATOR=$CONDA_BUILD_CROSS_COMPILATION \ -D CMAKE_BUILD_TYPE=Release \ -D cmake_install_prefix="$PREFIX" \ + -D cmake_search_prefix="$BUILD_PREFIX" \ -D extra_cxx_flags="$extra_cxx_flags" \ -D cmake_libdir=lib \ -D ldlt_cholmod=yes \ diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index eb873bfe752c3..f45808073f0d4 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -29,10 +29,10 @@ build: requirements: build: - - gnuconfig # [unix] - {{ compiler('c') }} - {{ stdlib("c") }} - {{ compiler('cxx') }} + - make # [not win] - pkg-config - cmake - gsl From 3c283ad99f4d8cbee7185bd5639745bf26c05352 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Tue, 28 Jan 2025 09:16:22 -0700 Subject: [PATCH 06/19] cppad-mixed: 1. Move some requirements from build to host. 2 remove conda-bulild.log (added by mistake) --- recipes/cppad-mixed/build.sh | 3 ++- recipes/cppad-mixed/conda-build.log | 17 ----------------- recipes/cppad-mixed/meta.yaml | 3 ++- 3 files changed, 4 insertions(+), 19 deletions(-) delete mode 100644 recipes/cppad-mixed/conda-build.log diff --git a/recipes/cppad-mixed/build.sh b/recipes/cppad-mixed/build.sh index b4c45fbda12fd..37a4b13bcbbc4 100755 --- a/recipes/cppad-mixed/build.sh +++ b/recipes/cppad-mixed/build.sh @@ -10,8 +10,9 @@ extra_cxx_flags='-Wpedantic -std=c++11 -Wall -Wshadow -Wconversion' if [[ "${target_platform}" == osx-* ]]; then # https://conda-forge.org/docs/maintainer/knowledge_base.html# # newer-c-features-with-old-sdk - extra_cxx_flags="${extra_cxx_flags} -D_LIBCPP_DISABLE_AVAILABILITY" + extra_cxx_flags+=" -D_LIBCPP_DISABLE_AVAILABILITY" fi +extra_cxx_flags+=' -Wno-sign-conversion' # # build mkdir build && cd build diff --git a/recipes/cppad-mixed/conda-build.log b/recipes/cppad-mixed/conda-build.log deleted file mode 100644 index d90416ce16aa2..0000000000000 --- a/recipes/cppad-mixed/conda-build.log +++ /dev/null @@ -1,17 +0,0 @@ -/home/bradbell/.conda/envs/build_env/lib/python3.11/site-packages/conda_build/cli/main_build.py:520: FutureWarning: The default `pkg_format` of '.tar.bz2' is deprecated and will be removed in 25.1. - -The new default `pkg_format` value will be '.conda'. If you want to keep using `.tar.bz2`, consider: -- Setting `conda_build.pkg_format: 'tar.bz2' in your condarc file. -- Using `--pkg-format=tar.bz2` in the CLI. - - deprecated.topic( -ERROR: Glob /home/bradbell/repo/staged-recipes.git/recipes/cppad-mixed/recipes/cppad-mixed did not match in root_dir /home/bradbell/repo/staged-recipes.git/recipes/cppad-mixed -Traceback (most recent call last): - File "/home/bradbell/.conda/envs/build_env/bin/conda-build", line 11, in - sys.exit(execute()) - ^^^^^^^^^ - File "/home/bradbell/.conda/envs/build_env/lib/python3.11/site-packages/conda_build/cli/main_build.py", line 648, in execute - api.build( - File "/home/bradbell/.conda/envs/build_env/lib/python3.11/site-packages/conda_build/api.py", line 207, in build - raise ValueError( -ValueError: No valid recipes found for input: ['recipes/cppad-mixed'] diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index f45808073f0d4..adce1f0a7ef44 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -35,8 +35,9 @@ requirements: - make # [not win] - pkg-config - cmake - - gsl - eigen + host: + - gsl - suitesparse - ipopt - cppad From c11af49171c4b23d980da9bc6e5da44b8764e6eb Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Tue, 28 Jan 2025 10:19:24 -0700 Subject: [PATCH 07/19] cppad-mixed: requirements: change suitesparse->libcholmod move cppad host->build --- recipes/cppad-mixed/meta.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index adce1f0a7ef44..267aca2f74dd0 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -32,15 +32,17 @@ requirements: - {{ compiler('c') }} - {{ stdlib("c") }} - {{ compiler('cxx') }} - - make # [not win] - pkg-config - cmake - eigen + - cppad + - make # [not win] host: - gsl - - suitesparse + - libcholmod - ipopt - - cppad + - libopenblas # [linux] + test: commands: From 4e22c8aa1f0ab4587441e42575b94bb43a6e2573 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 05:16:59 -0700 Subject: [PATCH 08/19] cppad-mixed: run_test.py: Test installed version (Linux only) --- recipes/cppad-mixed/build.sh | 10 ++-- recipes/cppad-mixed/meta.yaml | 13 +++-- recipes/cppad-mixed/run_test.py | 89 +++++++++++++++++++++++++++++++++ 3 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 recipes/cppad-mixed/run_test.py diff --git a/recipes/cppad-mixed/build.sh b/recipes/cppad-mixed/build.sh index 37a4b13bcbbc4..411ff87429a72 100755 --- a/recipes/cppad-mixed/build.sh +++ b/recipes/cppad-mixed/build.sh @@ -1,4 +1,6 @@ -#! /bin/sh +#! /usr/bin/env bash +set -e -u +echo "build.sh: Start" # # PKG_CONFIG_PATH PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig" @@ -20,8 +22,6 @@ mkdir build && cd build # cmake cmake -S $SRC_DIR -B . \ -G 'Unix Makefiles' \ - -D CMAKE_CROSSCOMPILING=$CONDA_BUILD_CROSS_COMPILATION \ - -D CMAKE_CROSSCOMPILING_EMULATOR=$CONDA_BUILD_CROSS_COMPILATION \ -D CMAKE_BUILD_TYPE=Release \ -D cmake_install_prefix="$PREFIX" \ -D cmake_search_prefix="$BUILD_PREFIX" \ @@ -35,6 +35,6 @@ cmake -S $SRC_DIR -B . \ make -j4 check # # install -make install +make -j4 install # -echo 'build.sh: OK' +echo 'build.sh: Done: OK' diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 267aca2f74dd0..cefc83cf36259 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -32,19 +32,24 @@ requirements: - {{ compiler('c') }} - {{ stdlib("c") }} - {{ compiler('cxx') }} - - pkg-config - cmake - - eigen - - cppad - make # [not win] host: + - pkg-config + - eigen + - cppad - gsl - libcholmod - ipopt - libopenblas # [linux] - + test: + # run_test.py uses clang++ + - clang++ test: + source_files: + # run_test.py assumes this file is in the temporary test directory. + - example/user/no_random.cpp commands: # # cppad_mixed.hpp diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py new file mode 100644 index 0000000000000..92999cbfe3c71 --- /dev/null +++ b/recipes/cppad-mixed/run_test.py @@ -0,0 +1,89 @@ +#! /usr/bin/env python +# +# example_file +# This file must be in the test.sources of meta.yaml +example_file = 'example/user/no_random.cpp' +# +# cxx_compiler +# This compiler is requires for testing in meta.yaml +cxx_compiler = 'clang++' +# +# imports +import sys +import os +import subprocess +import platform +# +def main() : + # + # example_file + assert example_file[-4 :] == '.cpp' + # + # prefix + prefix = os.environ['PREFIX'] + print( f'prefix = {prefix}' , flush = True ) + # + # env + env = os.environ + env['LD_LIBRARY_PATH'] = f'{prefix}/lib' + # + # system + system = platform.system() + assert system in [ 'Linux', 'Darwin', 'Windows' ] + # + if system != 'Linux' : + print( f'run_test.py: Skiping {system} system' ) + return + # + # example_function + start = example_file.rfind('/') + 1 + example_function = example_file[start : -4] + '_xam' + # + # eigen_cflags + command = [ 'pkg-config', 'eigen3', '--cflags' ] + print( " ".join( command ) , flush = True ) + result = subprocess.run(command, + check = True , capture_output = True, encoding = 'utf-8' + ) + eigen_cflags = result.stdout.strip().split() + # + # main.cpp + data = ''' +# include +# include +extern bool EXAMPLE_FUNCTION(void); + +int main(void) +{ if( ! EXAMPLE_FUNCTION() ) + { std::cout << "EXAMPLE_FUNCTION: Error" << std::endl; + std::exit(1); + } + std::cout << "EXAMPLE_FUNCTION: OK" << std::endl; + std::exit(0); +} +''' + data = data.replace( 'EXAMPLE_FUNCTION', example_function ) + with open('main.cpp', 'w') as fobj : + fobj.write(data) + # + # main + command = [ cxx_compiler, 'main.cpp', example_file ] + command += eigen_cflags + command += [ + '-I', f'{prefix}/include', + '-L', f'{prefix}/lib', + '-lcppad_mixed', + '-o', 'main' + ] + print( " ".join( command ) , flush = True ) + subprocess.run(command, check = True , env = env) + # + # main + command = [ './main' ] + print( " ".join( command ), flush = True ) + subprocess.run(command, check = True ) + # + print( 'run_test.py: OK' ) +# +if __name__ == "__main__" : + main() From b7dae803a3fbc8af3baee2e94159072769daf84d Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 06:13:32 -0700 Subject: [PATCH 09/19] cppad-mixed: meta.yaml: add pkg-config and eigen to test requirements. --- recipes/cppad-mixed/meta.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index cefc83cf36259..b46b9b320caa3 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -43,8 +43,13 @@ requirements: - ipopt - libopenblas # [linux] test: - # run_test.py uses clang++ - - clang++ + # run_test.py uses + # clang++: to compile a program + # pkg-cofig: to find eigen include files + # eigen: has inclue files used by the program + - pkg-config + - eigen + - clang test: source_files: From 83528bf5a42625acf8656ed91334cc40d6409a10 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 07:44:19 -0700 Subject: [PATCH 10/19] cppad-mixed: copy Eigen's source from the internet (to get it in test environment). --- recipes/cppad-mixed/meta.yaml | 9 +------ recipes/cppad-mixed/run_test.py | 45 ++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index b46b9b320caa3..3854dc73e2f2b 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -42,14 +42,7 @@ requirements: - libcholmod - ipopt - libopenblas # [linux] - test: - # run_test.py uses - # clang++: to compile a program - # pkg-cofig: to find eigen include files - # eigen: has inclue files used by the program - - pkg-config - - eigen - - clang + - clang # run_test.py using clang to compile a test program test: source_files: diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index 92999cbfe3c71..52182e9595058 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -8,6 +8,9 @@ # This compiler is requires for testing in meta.yaml cxx_compiler = 'clang++' # +# eigen_version +eigen_version = '3.4.0' +# # imports import sys import os @@ -16,16 +19,21 @@ # def main() : # - # example_file - assert example_file[-4 :] == '.cpp' + # eigen-version + # The eigen include files are in the build environment, but not the + # test environment, so we make a separate copy of its source. + url = 'https://gitlab.com/libeigen/eigen/-/archive' + url += f'/{eigen_version}/eigen-{eigen_version}.tar.gz' + command = [ 'curl', '-LJO', url ] + print( " ".join( command ) ) + result = subprocess.run(command, check = True) + command = [ 'tar' , '-xzf', f'eigen-{eigen_version}.tar.gz' ] + print( ' '.join(command) ) + subprocess.run( command , check = True) # # prefix prefix = os.environ['PREFIX'] - print( f'prefix = {prefix}' , flush = True ) - # - # env - env = os.environ - env['LD_LIBRARY_PATH'] = f'{prefix}/lib' + print( f'prefix = {prefix}' ) # # system system = platform.system() @@ -35,18 +43,13 @@ def main() : print( f'run_test.py: Skiping {system} system' ) return # + # example_file + assert example_file[-4 :] == '.cpp' + # # example_function start = example_file.rfind('/') + 1 example_function = example_file[start : -4] + '_xam' # - # eigen_cflags - command = [ 'pkg-config', 'eigen3', '--cflags' ] - print( " ".join( command ) , flush = True ) - result = subprocess.run(command, - check = True , capture_output = True, encoding = 'utf-8' - ) - eigen_cflags = result.stdout.strip().split() - # # main.cpp data = ''' # include @@ -67,20 +70,22 @@ def main() : fobj.write(data) # # main - command = [ cxx_compiler, 'main.cpp', example_file ] - command += eigen_cflags - command += [ + env = os.environ + env['LD_LIBRARY_PATH'] = f'{prefix}/lib' + command = [ + cxx_compiler, 'main.cpp', example_file , + '-I', f'eigen-{eigen_version}', '-I', f'{prefix}/include', '-L', f'{prefix}/lib', '-lcppad_mixed', '-o', 'main' ] - print( " ".join( command ) , flush = True ) + print( " ".join( command ) ) subprocess.run(command, check = True , env = env) # # main command = [ './main' ] - print( " ".join( command ), flush = True ) + print( " ".join( command ) ) subprocess.run(command, check = True ) # print( 'run_test.py: OK' ) From 19460e1354a209ccb03f9959e3a21435de2e5f23 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 09:07:25 -0700 Subject: [PATCH 11/19] cppad-mixed: run_test.py: if compile error, print message. --- recipes/cppad-mixed/run_test.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index 52182e9595058..1a8bf3b02c658 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -81,7 +81,15 @@ def main() : '-o', 'main' ] print( " ".join( command ) ) - subprocess.run(command, check = True , env = env) + result = subprocess.run( + command, capture_output = True , encoding = 'utf-8', env = env + ) + if result.stdout != None : + print( result.stdout ) + if result.returncode != 0 : + print( result.stderr ) + print( 'run_test.py: Error' ) + return # # main command = [ './main' ] From afe608420da1413b8d830e90b440caa9106f74af Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 12:37:15 -0700 Subject: [PATCH 12/19] cppad_mixed: run_test.py: Improve error messaging. --- recipes/cppad-mixed/run_test.py | 66 ++++++++++++++++++++------------- 1 file changed, 41 insertions(+), 25 deletions(-) diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index 1a8bf3b02c658..d38efe3ad7cff 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -17,24 +17,40 @@ import subprocess import platform # -def main() : - # - # eigen-version - # The eigen include files are in the build environment, but not the - # test environment, so we make a separate copy of its source. - url = 'https://gitlab.com/libeigen/eigen/-/archive' - url += f'/{eigen_version}/eigen-{eigen_version}.tar.gz' - command = [ 'curl', '-LJO', url ] +# system_command +def system_command(command) : print( " ".join( command ) ) - result = subprocess.run(command, check = True) - command = [ 'tar' , '-xzf', f'eigen-{eigen_version}.tar.gz' ] - print( ' '.join(command) ) - subprocess.run( command , check = True) + try : + result = subprocess.run( + command, + check = False, + capture_output = True , + encoding = 'utf-8', + env = os.environ + ) + # + except subprocess.CalledProcessErrror as e : + if e.stdout != None and e.stdout != "" : + print( e.stdout ) + sys.exit( e.stderr ) + # + if result.stdout != None and result.stdout != "" : + print( result.stdout ) + if result.returncode != 0 : + sys.exit( result.stderr ) + return result.stdout +# +# main +def main() : # # prefix prefix = os.environ['PREFIX'] print( f'prefix = {prefix}' ) # + # path + path = os.environ['PATH'] + print( f'path = {path}' ) + # # system system = platform.system() assert system in [ 'Linux', 'Darwin', 'Windows' ] @@ -43,6 +59,17 @@ def main() : print( f'run_test.py: Skiping {system} system' ) return # + # clang++ + system_command( [ 'which', 'clang++'] ) + # + # eigen-version + # The eigen include files are in the build environment, but not the + # test environment, so we make a separate copy of its source. + url = 'https://gitlab.com/libeigen/eigen/-/archive' + url += f'/{eigen_version}/eigen-{eigen_version}.tar.gz' + system_command( [ 'curl', '-LJO', url ] ) + system_command( [ 'tar' , '-xzf', f'eigen-{eigen_version}.tar.gz' ] ) + # # example_file assert example_file[-4 :] == '.cpp' # @@ -80,21 +107,10 @@ def main() : '-lcppad_mixed', '-o', 'main' ] - print( " ".join( command ) ) - result = subprocess.run( - command, capture_output = True , encoding = 'utf-8', env = env - ) - if result.stdout != None : - print( result.stdout ) - if result.returncode != 0 : - print( result.stderr ) - print( 'run_test.py: Error' ) - return + system_command( command ) # # main - command = [ './main' ] - print( " ".join( command ) ) - subprocess.run(command, check = True ) + system_command( [ './main' ] ) # print( 'run_test.py: OK' ) # From c28e56b81434e6f372900e04a70488581ec67608 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 14:26:18 -0700 Subject: [PATCH 13/19] cppad-mixed: use test.requirements section of meta.yaml. --- recipes/cppad-mixed/meta.yaml | 3 +++ recipes/cppad-mixed/run_test.py | 23 ++++------------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 3854dc73e2f2b..3f836b8ff96bc 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -45,6 +45,9 @@ requirements: - clang # run_test.py using clang to compile a test program test: + requires: + - {{ compiler('cxx') }} + - eigen source_files: # run_test.py assumes this file is in the temporary test directory. - example/user/no_random.cpp diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index d38efe3ad7cff..f446766d19898 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -4,10 +4,6 @@ # This file must be in the test.sources of meta.yaml example_file = 'example/user/no_random.cpp' # -# cxx_compiler -# This compiler is requires for testing in meta.yaml -cxx_compiler = 'clang++' -# # eigen_version eigen_version = '3.4.0' # @@ -47,9 +43,9 @@ def main() : prefix = os.environ['PREFIX'] print( f'prefix = {prefix}' ) # - # path - path = os.environ['PATH'] - print( f'path = {path}' ) + # cxx_compiler + cxx_compiler = os.environ['CXX'] + print( f'cxx_compiler = {cxx_compiler}' ) # # system system = platform.system() @@ -59,17 +55,6 @@ def main() : print( f'run_test.py: Skiping {system} system' ) return # - # clang++ - system_command( [ 'which', 'clang++'] ) - # - # eigen-version - # The eigen include files are in the build environment, but not the - # test environment, so we make a separate copy of its source. - url = 'https://gitlab.com/libeigen/eigen/-/archive' - url += f'/{eigen_version}/eigen-{eigen_version}.tar.gz' - system_command( [ 'curl', '-LJO', url ] ) - system_command( [ 'tar' , '-xzf', f'eigen-{eigen_version}.tar.gz' ] ) - # # example_file assert example_file[-4 :] == '.cpp' # @@ -101,8 +86,8 @@ def main() : env['LD_LIBRARY_PATH'] = f'{prefix}/lib' command = [ cxx_compiler, 'main.cpp', example_file , - '-I', f'eigen-{eigen_version}', '-I', f'{prefix}/include', + '-I', f'{prefix}/include/eigen3', '-L', f'{prefix}/lib', '-lcppad_mixed', '-o', 'main' From 00820e748f1f97fa2ee054fc8d2a7378b9d81441 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 14:41:33 -0700 Subject: [PATCH 14/19] cppad-mixed: run_test.py: Remove dead code. --- recipes/cppad-mixed/run_test.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index f446766d19898..0f69ac85bab1f 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -82,8 +82,6 @@ def main() : fobj.write(data) # # main - env = os.environ - env['LD_LIBRARY_PATH'] = f'{prefix}/lib' command = [ cxx_compiler, 'main.cpp', example_file , '-I', f'{prefix}/include', From 2682d009ad838ca30453334511d1860e90980440 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 30 Jan 2025 17:27:08 -0700 Subject: [PATCH 15/19] cppad-mixed: meta.yaml: test: using $CC instead of clang to test. --- recipes/cppad-mixed/meta.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 3f836b8ff96bc..09926e87b739b 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -42,7 +42,6 @@ requirements: - libcholmod - ipopt - libopenblas # [linux] - - clang # run_test.py using clang to compile a test program test: requires: From e765c0fda13fc09c57ad7b25243eacb2c5d8c5eb Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Fri, 31 Jan 2025 05:45:41 -0700 Subject: [PATCH 16/19] cppad-mixed: Test and fix Darwin (MacOS). --- recipes/cppad-mixed/CMakeLists.patch | 64 ++++++++++++++++++++++------ recipes/cppad-mixed/run_test.py | 7 ++- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/recipes/cppad-mixed/CMakeLists.patch b/recipes/cppad-mixed/CMakeLists.patch index 5f09f0493a5bb..004eb3e51819c 100644 --- a/recipes/cppad-mixed/CMakeLists.patch +++ b/recipes/cppad-mixed/CMakeLists.patch @@ -1,5 +1,5 @@ diff --git a/CMakeLists.txt b/CMakeLists.txt -index 37a99042..25675cca 100644 +index 37a99042..89893e99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,13 +12,21 @@ @@ -36,7 +36,7 @@ index 37a99042..25675cca 100644 ENDMACRO( required_definition ) # ---------------------------------------------------------------------------- # optional_definition( variable type docstring ) -@@ -75,11 +87,15 @@ MACRO( optional_definition variable type docstring ) +@@ -75,6 +87,10 @@ MACRO( optional_definition variable type docstring ) SET( ${variable}_01 0 ) ENDIF( ${variable} ) ENDIF( ${type} STREQUAL "BOOL" ) @@ -47,13 +47,7 @@ index 37a99042..25675cca 100644 ENDMACRO( optional_definition ) # ============================================================================ CMAKE_MINIMUM_REQUIRED(VERSION 3.0) - PROJECT(cppad_mixed) --SET(cppad_mixed_version "2025.0.1") -+SET(cppad_mixed_version "2025.1.28") - INCLUDE_DIRECTORIES( ${cppad_mixed_SOURCE_DIR}/include ) - INCLUDE(CheckCXXSourceRuns) - MESSAGE(STATUS "BEGIN:") -@@ -127,6 +143,9 @@ required_definition(optimize_cppad_function BOOL +@@ -127,33 +143,43 @@ required_definition(optimize_cppad_function BOOL required_definition(for_hes_sparsity BOOL "use forward (reverse) method for computing Hessian w.r.t. random effects" ) @@ -63,7 +57,49 @@ index 37a99042..25675cca 100644 # ---------------------------------------------------------------------------- MESSAGE(STATUS "END:") # ---------------------------------------------------------------------------- -@@ -198,13 +217,9 @@ ENDIF( cppad_mixed_has_nullptr_flag ) + # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling + # ++# CMAKE_SKIP_BUILD_RPATH + # use, i.e. don't skip the full RPATH for the build tree +-set(CMAKE_SKIP_BUILD_RPATH FALSE) ++SET(CMAKE_SKIP_BUILD_RPATH FALSE) + # ++# CMAKE_BUILD_WITH_INSTALL_RPATH + # when building, don't use the install RPATH already + # (but later on when installing) +-set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) +-# +-set(CMAKE_INSTALL_RPATH "${cmake_install_prefix}/${cmake_libdir}") ++SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) + # ++# CMAKE_INSTAL_RPATH_USE_LINK_PATH + # add the automatically determined parts of the RPATH + # which point to directories outside the build tree to the install RPATH +-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) ++SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + # +-# the RPATH to be used when installing, but only if it's not a system directory +-list(FIND ++# isSyatemDir ++# is this RPATH choice a system directory ++LIST(FIND + CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES + "${cmake_install_prefix}/${cmake_libdir}" + isSystemDir + ) ++# ++# CMAKE_INSTALL_RPATH ++# the RPATH to be used when installing, but only if it's not a system directory ++SET(CMAKE_INSTALL_RPATH "") + if("${isSystemDir}" STREQUAL "-1") +- set(CMAKE_INSTALL_RPATH "${dismod_at_pefix}/${cmake_libdir}") ++ SET(CMAKE_INSTALL_RPATH "${cmake_install_prefix}/${cmake_libdir}") + endif("${isSystemDir}" STREQUAL "-1") ++print_variable( CMAKE_INSTALL_RPATH ) + # ---------------------------------------------------------------------------- + # check compiler flags + # +@@ -198,13 +224,9 @@ ENDIF( cppad_mixed_has_nullptr_flag ) MESSAGE(STATUS "cppad_mixed_has_nullptr = ${cppad_mixed_has_nullptr_01}") # ---------------------------------------------------------------------------- # no pkg-config for SuiteSparse so explicitly set following values: @@ -77,7 +113,7 @@ index 37a99042..25675cca 100644 SET(suitesparse_prefix "NOTFOUND") SET(suitesparse_suffix "NOTFOUND") EXECUTE_PROCESS( -@@ -212,7 +227,7 @@ EXECUTE_PROCESS( +@@ -212,7 +234,7 @@ EXECUTE_PROCESS( OUTPUT_VARIABLE brew_prefix OUTPUT_STRIP_TRAILING_WHITESPACE ) @@ -86,7 +122,7 @@ index 37a99042..25675cca 100644 FOREACH(suffix "include" "include/suitesparse") IF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) MESSAGE(STATUS "Using ${brew_prefix}/${suffix}/cholmod.h" ) -@@ -220,13 +235,17 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) +@@ -220,13 +242,17 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) SET(suitesparse_suffix "${suffix}") ENDIF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) ENDFOREACH(suffix "include" "include/suitesparse") @@ -105,7 +141,7 @@ index 37a99042..25675cca 100644 ) FOREACH(suffix "include" "include/suitesparse") IF( EXISTS "${prefix}/${suffix}/cholmod.h" ) -@@ -263,7 +282,7 @@ ELSE( ${suitesparse_suffix} STREQUAL "include" ) +@@ -263,7 +289,7 @@ ELSE( ${suitesparse_suffix} STREQUAL "include" ) SET(suitesparse_INCLUDE_DIRS "${suitesparse_prefix}/include/suitesparse" ) ENDIF( ${suitesparse_suffix} STREQUAL "include" ) # @@ -114,7 +150,7 @@ index 37a99042..25675cca 100644 SET(suitesparse_LIBRARIES "cholmod;amd;camd;colamd;ccolamd;suitesparseconfig" ) -@@ -271,22 +290,18 @@ SET(suitesparse_LIBRARIES +@@ -271,22 +297,18 @@ SET(suitesparse_LIBRARIES # suitesparse_LIBRARY_DIRS SET(suitesparse_LIBRARY_DIRS "NOTFOUND") FOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index 0f69ac85bab1f..6fd48f7e924e8 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -4,9 +4,6 @@ # This file must be in the test.sources of meta.yaml example_file = 'example/user/no_random.cpp' # -# eigen_version -eigen_version = '3.4.0' -# # imports import sys import os @@ -51,7 +48,7 @@ def main() : system = platform.system() assert system in [ 'Linux', 'Darwin', 'Windows' ] # - if system != 'Linux' : + if system == 'Windows' : print( f'run_test.py: Skiping {system} system' ) return # @@ -84,9 +81,11 @@ def main() : # main command = [ cxx_compiler, 'main.cpp', example_file , + '-D', 'NDEBUG', '-I', f'{prefix}/include', '-I', f'{prefix}/include/eigen3', '-L', f'{prefix}/lib', + f'-Wl,-rpath,{prefix}/lib', '-lcppad_mixed', '-o', 'main' ] From 9ec98258ce3db9abdebe8f97f291d08cb42e1124 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Sat, 1 Feb 2025 08:52:52 -0700 Subject: [PATCH 17/19] cppad-mixed: run_test.py: use cmake to figure out how link and run in all cases. --- recipes/cppad-mixed/bld.bat | 4 ++ recipes/cppad-mixed/meta.yaml | 2 + recipes/cppad-mixed/run_test.py | 101 ++++++++++++++++++++++++-------- 3 files changed, 84 insertions(+), 23 deletions(-) diff --git a/recipes/cppad-mixed/bld.bat b/recipes/cppad-mixed/bld.bat index a69d6dc7d0511..ad736eeb7dcf4 100644 --- a/recipes/cppad-mixed/bld.bat +++ b/recipes/cppad-mixed/bld.bat @@ -1,3 +1,7 @@ +:: echo +echo off + +:: build mkdir build cd build diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 09926e87b739b..b52760bcbe821 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -46,6 +46,8 @@ requirements: test: requires: - {{ compiler('cxx') }} + - pkg-config + - cmake - eigen source_files: # run_test.py assumes this file is in the temporary test directory. diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index 6fd48f7e924e8..7724b3e0da4bc 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -11,15 +11,18 @@ import platform # # system_command +# 1. print the command before executing it +# 2. double check for errors during the command +# 3 print any error message that is returned before aborting def system_command(command) : print( " ".join( command ) ) try : result = subprocess.run( command, - check = False, + check = False, capture_output = True , - encoding = 'utf-8', - env = os.environ + encoding = 'utf-8', + env = os.environ ) # except subprocess.CalledProcessErrror as e : @@ -34,23 +37,34 @@ def system_command(command) : return result.stdout # # main +# Put this code in a function so as to not polute the file namespace def main() : # - # prefix - prefix = os.environ['PREFIX'] - print( f'prefix = {prefix}' ) - # - # cxx_compiler - cxx_compiler = os.environ['CXX'] - print( f'cxx_compiler = {cxx_compiler}' ) + print( 'run_test.py: Start' ) # # system system = platform.system() assert system in [ 'Linux', 'Darwin', 'Windows' ] + print( f'system = {system}' ) # + # prefix, os.environ['PKG_CONFIG_PATH'] + prefix = os.environ['PREFIX'] if system == 'Windows' : - print( f'run_test.py: Skiping {system} system' ) - return + prefix = f'{prefix}\\Library' + os.environ['PKG_CONFIG_PATH'] = f'{prefix}\\lib\\pkgconfig' + os.environ['PKG_CONFIG_PATH'] += f':{prefix}\\share\\pkgconfig' + else : + os.environ['PKG_CONFIG_PATH'] = f'{prefix}/lib/pkgconfig' + os.environ['PKG_CONFIG_PATH'] += f':{prefix}/share/pkgconfig' + prefix = prefix.replace( '\\' , '/' ) + # + # cppad_mixed_lib + path_dict = { + 'Linux' : f'{prefix}/lib/libcppad_mixed.so' , + 'Darwin' : f'{prefix}/lib/libcppad_mixed.so' , + 'Windows' : f'{prefix}/Library/lib/cppad_mixed.lib' + } + cppad_mixed_lib = path_dict[system] # # example_file assert example_file[-4 :] == '.cpp' @@ -60,6 +74,7 @@ def main() : example_function = example_file[start : -4] + '_xam' # # main.cpp + # Create C++ program that runs the example fucntion and check its result data = ''' # include # include @@ -78,23 +93,63 @@ def main() : with open('main.cpp', 'w') as fobj : fobj.write(data) # - # main + # CMakeLists.txt + # Create a project that compiles, links, and runs the C++ program. + data = ''' +cmake_minimum_required( VERSION 3.10 ) +project( check_install ) +# +# include_directories +# link_directories +find_package(PkgConfig) +pkg_check_modules( cppad_mixed QUIET cppad_mixed ) +if( cppad_mixed_FOUND ) + message(STATUS "Found cppad_mixed.pc file") +else( ) + message(STATUS + "Cannot find *.pc file for cppad_mixed or a package it requires" + ) + message(FATAL_ERROR "PKG_CONFIG_PATH=$ENV{PKG_CONFIG_PATH}") +endif( ) +include_directories( SYSTEM ${cppad_mixed_INCLUDE_DIRS} ) +link_directories( ${cppad_mixed_LIBRARY_DIRS} ) +# +# check_main +add_executable( main main.cpp EXAMPLE_FILE ) +target_link_libraries(main ${cppad_mixed_LIBRARIES} ) +add_custom_target(check_main main) +''' + data = data.replace( 'PREFIX', prefix ) + data = data.replace( 'EXAMPLE_FILE', example_file ) + data = data.replace( 'CPPAD_MIXED_LIB', cppad_mixed_lib ) + with open('CMakeLists.txt', 'w') as fobj : + fobj.write(data) + # + # build + os.mkdir('build') + os.chdir('build') + # + # cmake command = [ - cxx_compiler, 'main.cpp', example_file , - '-D', 'NDEBUG', - '-I', f'{prefix}/include', - '-I', f'{prefix}/include/eigen3', - '-L', f'{prefix}/lib', - f'-Wl,-rpath,{prefix}/lib', - '-lcppad_mixed', - '-o', 'main' + 'cmake', + '-S', '..' , + '-B', '.' , + '-D', 'CMAKE_BUILD_TYPE=Release' , ] system_command( command ) # - # main - system_command( [ './main' ] ) + # check_main + command = [ + 'cmake', + '--build', '.', + '--config', 'Release', + '--target', 'check_main' + ] + system_command( command ) # print( 'run_test.py: OK' ) # +# +# python main if __name__ == "__main__" : main() From ae4dfc9117c059fbcd9302329d5695f970f74769 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Sat, 1 Feb 2025 11:22:32 -0700 Subject: [PATCH 18/19] cppad-mixed: Linux and osx should have make during test. --- recipes/cppad-mixed/meta.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index b52760bcbe821..98f71d1d7daef 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -49,6 +49,7 @@ test: - pkg-config - cmake - eigen + - make # [not win] source_files: # run_test.py assumes this file is in the temporary test directory. - example/user/no_random.cpp From 7e3745a5a2ef69f21c18f92968f30bb79dfcc7ba Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Sun, 2 Feb 2025 11:17:10 -0700 Subject: [PATCH 19/19] cppad-mixed: Advance to 2025.0.2 to avoid Patching CMakeLists.txt --- recipes/cppad-mixed/CMakeLists.patch | 184 --------------------------- recipes/cppad-mixed/bld.bat | 5 +- recipes/cppad-mixed/meta.yaml | 14 +- recipes/cppad-mixed/run_test.py | 36 +++--- 4 files changed, 32 insertions(+), 207 deletions(-) delete mode 100644 recipes/cppad-mixed/CMakeLists.patch diff --git a/recipes/cppad-mixed/CMakeLists.patch b/recipes/cppad-mixed/CMakeLists.patch deleted file mode 100644 index 004eb3e51819c..0000000000000 --- a/recipes/cppad-mixed/CMakeLists.patch +++ /dev/null @@ -1,184 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index 37a99042..89893e99 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -12,13 +12,21 @@ - # -D cmake_libdir=value \ - # -D ldlt_cholmod=value \ - # -D optimize_cppad_function=value \ --# -D for_hes_sparsity=value -+# -D for_hes_sparsity=value \ -+# optional variables: -D cmake_search_prefix=value - # ============================================================================ - # Macro definitions - # ============================================================================ -+# -+# print_variable(variable) - MACRO(print_variable variable) - MESSAGE(STATUS "${variable}=${${variable}}" ) - ENDMACRO(print_variable variable) -+# -+# trace_line_in_file(${CMAKE_CURRENT_LIST_LINE}, ${CMAKE_CURRENT_LIST_FILE} ) -+MACRO(trace_line_in_file line file) -+MESSAGE(STATUS "Line ${line} in ${file}") -+ENDMACRO( ) - # ---------------------------------------------------------------------------- - # required_definition( variable type docstring ) - # -@@ -50,6 +58,10 @@ MACRO( required_definition variable type docstring ) - SET( ${variable}_01 0 ) - ENDIF( ${variable} ) - ENDIF( ${type} STREQUAL "BOOL" ) -+ IF( ${type} STREQUAL "PATH" ) -+ CMAKE_PATH(SET ${variable} "${${variable}}" ) -+ MESSAGE( STATUS "${variable} = ${${variable}}" ) -+ ENDIF( ${type} STREQUAL "PATH" ) - ENDMACRO( required_definition ) - # ---------------------------------------------------------------------------- - # optional_definition( variable type docstring ) -@@ -75,6 +87,10 @@ MACRO( optional_definition variable type docstring ) - SET( ${variable}_01 0 ) - ENDIF( ${variable} ) - ENDIF( ${type} STREQUAL "BOOL" ) -+ IF( ${type} STREQUAL "PATH" ) -+ CMAKE_PATH(SET ${variable} "${${variable}}" ) -+ MESSAGE( STATUS "${variable} = ${${variable}}" ) -+ ENDIF( ${type} STREQUAL "PATH" ) - ENDMACRO( optional_definition ) - # ============================================================================ - CMAKE_MINIMUM_REQUIRED(VERSION 3.0) -@@ -127,33 +143,43 @@ required_definition(optimize_cppad_function BOOL - required_definition(for_hes_sparsity BOOL - "use forward (reverse) method for computing Hessian w.r.t. random effects" - ) -+optional_definition( cmake_search_prefix PATH -+ "another prefix used when searching for installed tools" -+) - # ---------------------------------------------------------------------------- - MESSAGE(STATUS "END:") - # ---------------------------------------------------------------------------- - # https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling - # -+# CMAKE_SKIP_BUILD_RPATH - # use, i.e. don't skip the full RPATH for the build tree --set(CMAKE_SKIP_BUILD_RPATH FALSE) -+SET(CMAKE_SKIP_BUILD_RPATH FALSE) - # -+# CMAKE_BUILD_WITH_INSTALL_RPATH - # when building, don't use the install RPATH already - # (but later on when installing) --set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) --# --set(CMAKE_INSTALL_RPATH "${cmake_install_prefix}/${cmake_libdir}") -+SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) - # -+# CMAKE_INSTAL_RPATH_USE_LINK_PATH - # add the automatically determined parts of the RPATH - # which point to directories outside the build tree to the install RPATH --set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -+SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) - # --# the RPATH to be used when installing, but only if it's not a system directory --list(FIND -+# isSyatemDir -+# is this RPATH choice a system directory -+LIST(FIND - CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES - "${cmake_install_prefix}/${cmake_libdir}" - isSystemDir - ) -+# -+# CMAKE_INSTALL_RPATH -+# the RPATH to be used when installing, but only if it's not a system directory -+SET(CMAKE_INSTALL_RPATH "") - if("${isSystemDir}" STREQUAL "-1") -- set(CMAKE_INSTALL_RPATH "${dismod_at_pefix}/${cmake_libdir}") -+ SET(CMAKE_INSTALL_RPATH "${cmake_install_prefix}/${cmake_libdir}") - endif("${isSystemDir}" STREQUAL "-1") -+print_variable( CMAKE_INSTALL_RPATH ) - # ---------------------------------------------------------------------------- - # check compiler flags - # -@@ -198,13 +224,9 @@ ENDIF( cppad_mixed_has_nullptr_flag ) - MESSAGE(STATUS "cppad_mixed_has_nullptr = ${cppad_mixed_has_nullptr_01}") - # ---------------------------------------------------------------------------- - # no pkg-config for SuiteSparse so explicitly set following values: --# suitesparse_LIBRARY_DIRS --# suitesparse_INCLUDE_DIRS --# suitesparse_LIBRARIES - # - # suitesparse_prefix - # suitesparse_suffix --# suitesparse_in_cholmod_include_01 - SET(suitesparse_prefix "NOTFOUND") - SET(suitesparse_suffix "NOTFOUND") - EXECUTE_PROCESS( -@@ -212,7 +234,7 @@ EXECUTE_PROCESS( - OUTPUT_VARIABLE brew_prefix - OUTPUT_STRIP_TRAILING_WHITESPACE - ) --IF( NOT "${brew_prefix}" STREQUAL "" ) -+IF( FALSE ) - FOREACH(suffix "include" "include/suitesparse") - IF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) - MESSAGE(STATUS "Using ${brew_prefix}/${suffix}/cholmod.h" ) -@@ -220,13 +242,17 @@ IF( NOT "${brew_prefix}" STREQUAL "" ) - SET(suitesparse_suffix "${suffix}") - ENDIF( EXISTS "${brew_prefix}/${suffix}/cholmod.h" ) - ENDFOREACH(suffix "include" "include/suitesparse") --ENDIF( NOT ( "${brew_prefix}" STREQUAL "" ) ) -+ENDIF( ) -+IF( NOT cmake_search_prefix ) -+ SET(cmake_search_prefix "" ) -+ENDIF( NOT cmake_search_prefix ) - FOREACH(prefix - /usr - /usr/local - /opt/local - /usr/local/opt/suitesparse - ${cmake_install_prefix} -+ ${cmake_search_prefix} - ) - FOREACH(suffix "include" "include/suitesparse") - IF( EXISTS "${prefix}/${suffix}/cholmod.h" ) -@@ -263,7 +289,7 @@ ELSE( ${suitesparse_suffix} STREQUAL "include" ) - SET(suitesparse_INCLUDE_DIRS "${suitesparse_prefix}/include/suitesparse" ) - ENDIF( ${suitesparse_suffix} STREQUAL "include" ) - # --# set suitesparse_LIBRARIES -+# suitesparse_LIBRARIES - SET(suitesparse_LIBRARIES - "cholmod;amd;camd;colamd;ccolamd;suitesparseconfig" - ) -@@ -271,22 +297,18 @@ SET(suitesparse_LIBRARIES - # suitesparse_LIBRARY_DIRS - SET(suitesparse_LIBRARY_DIRS "NOTFOUND") - FOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) -- SET(both "${suitesparse_prefix}/${suffix}") -- SET(globbing_expression "${both}/libcholmod.*") -- FILE(GLOB match_1 ${globbing_expression}) -- IF( match_1 ) -- SET(suitesparse_LIBRARY_DIRS "${both}") -- ELSE( match_1 ) -- SET(globbing_expression "${both}/*/libcholmod.*") -- FILE(GLOB match_2 ${globbing_expression}) -- IF( match_2 ) -- SET(suitesparse_LIBRARY_DIRS "${both}") -- ENDIF( match_2 ) -- ENDIF( match_1 ) -+ SET(libdir "${suitesparse_prefix}/${suffix}") -+ FOREACH(name "libcholmod" "cholmod") -+ SET(globbing_expression "${libdir}/${name}.*") -+ FILE(GLOB match_1 ${globbing_expression}) -+ IF( match_1 ) -+ SET(suitesparse_LIBRARY_DIRS "${libdir}") -+ ENDIF( match_1 ) -+ ENDFOREACH(name "libcholmod" "cholmod") - ENDFOREACH(suffix "lib" "lib64" "${cmake_libdir}" ) - IF( NOT suitesparse_LIBRARY_DIRS ) - MESSAGE(FATAL_ERROR -- "Cannot find libcholmod.* in ${suitesparse_prefix}/libdir" -+ "Cannot find cholmod library in ${suitesparse_prefix}/libdir" - " where libdir is lib, lib64, or cmake_libdir" - ) - ENDIF( NOT suitesparse_LIBRARY_DIRS ) diff --git a/recipes/cppad-mixed/bld.bat b/recipes/cppad-mixed/bld.bat index ad736eeb7dcf4..fd4ee6423765c 100644 --- a/recipes/cppad-mixed/bld.bat +++ b/recipes/cppad-mixed/bld.bat @@ -6,7 +6,10 @@ mkdir build cd build :: PKG_CONFIG_PATH -echo PKG_CONFIG_PATH=%PKG_CONFIG_PATH% +set PKG_CONFIG_PATH=^ +%BUILD_PREIX%\Library\lib\pkgconfig;^ +%BUILD_PREIX%\Library\share\pkgconfig; +ehco PKG_CONFIG_PATH=%PKG_CONFIG_PATH% :: cmake cmake -S %SRC_DIR% -B . ^ diff --git a/recipes/cppad-mixed/meta.yaml b/recipes/cppad-mixed/meta.yaml index 98f71d1d7daef..f5982aac9eacf 100644 --- a/recipes/cppad-mixed/meta.yaml +++ b/recipes/cppad-mixed/meta.yaml @@ -9,7 +9,7 @@ # https://spdx.org/licenses/AGPL-3.0-or-later.html # {% set name = "cppad-mixed" %} -{% set version = "2025.0.1" %} +{% set version = "2025.0.2" %} package: name: {{ name }} @@ -17,9 +17,10 @@ package: source: url: https://github.com/bradbell/cppad_mixed/archive/{{ version }}.tar.gz - sha256: 9cb39c79118dd67bc7c22f781aa7fbe9a6792b85d335929bad3ec92a016bf0b4 - patches: - - CMakeLists.patch + # 2025.0.1 + # sha256: 9cb39c79118dd67bc7c22f781aa7fbe9a6792b85d335929bad3ec92a016bf0b4 + sha256: a5b8ddd1dc029b4e2f2a168599308c4c4f88b04b39f735709d8f6a986e13ec2e + # build: number: 0 @@ -46,10 +47,11 @@ requirements: test: requires: - {{ compiler('cxx') }} - - pkg-config - cmake - - eigen - make # [not win] + - pkg-config + - eigen + - libcholmod source_files: # run_test.py assumes this file is in the temporary test directory. - example/user/no_random.cpp diff --git a/recipes/cppad-mixed/run_test.py b/recipes/cppad-mixed/run_test.py index 7724b3e0da4bc..5b673ccfa169d 100644 --- a/recipes/cppad-mixed/run_test.py +++ b/recipes/cppad-mixed/run_test.py @@ -60,9 +60,9 @@ def main() : # # cppad_mixed_lib path_dict = { - 'Linux' : f'{prefix}/lib/libcppad_mixed.so' , - 'Darwin' : f'{prefix}/lib/libcppad_mixed.so' , - 'Windows' : f'{prefix}/Library/lib/cppad_mixed.lib' + 'Linux' : 'libcppad_mixed.so' , + 'Darwin' : 'libcppad_mixed.so' , + 'Windows' : 'cppad_mixed.lib' } cppad_mixed_lib = path_dict[system] # @@ -102,26 +102,30 @@ def main() : # include_directories # link_directories find_package(PkgConfig) -pkg_check_modules( cppad_mixed QUIET cppad_mixed ) -if( cppad_mixed_FOUND ) - message(STATUS "Found cppad_mixed.pc file") -else( ) - message(STATUS - "Cannot find *.pc file for cppad_mixed or a package it requires" - ) - message(FATAL_ERROR "PKG_CONFIG_PATH=$ENV{PKG_CONFIG_PATH}") -endif( ) -include_directories( SYSTEM ${cppad_mixed_INCLUDE_DIRS} ) -link_directories( ${cppad_mixed_LIBRARY_DIRS} ) +foreach(pkg gsl eigen3 ipopt cppad cppad_mixed) + pkg_check_modules( ${pkg} QUIET ${pkg} ) + if( ${pkg}_FOUND ) + message(STATUS "Found ${pkg}.pc file") + else( ) + message(STATUS + "Cannot find *.pc file for ${pkg} or a package it requires" + ) + message(FATAL_ERROR "PKG_CONFIG_PATH=$ENV{PKG_CONFIG_PATH}") + endif( ) + include_directories( SYSTEM ${${pkg}_INCLUDE_DIRS} ) + link_directories( ${${pkg}_LIBRARY_DIRS} ) +endforeach( ) +# +# Kludge: CHOLMOD.pc is missing on conda-forge windows install +include_directories( SYSTEM PREFIX/include/suitesparse ) # # check_main add_executable( main main.cpp EXAMPLE_FILE ) target_link_libraries(main ${cppad_mixed_LIBRARIES} ) add_custom_target(check_main main) ''' - data = data.replace( 'PREFIX', prefix ) data = data.replace( 'EXAMPLE_FILE', example_file ) - data = data.replace( 'CPPAD_MIXED_LIB', cppad_mixed_lib ) + data = data.replace( 'PREFIX', prefix ) with open('CMakeLists.txt', 'w') as fobj : fobj.write(data) #