From 000a9965fdeaf0cd1340abf13218907ec7bd4536 Mon Sep 17 00:00:00 2001 From: Brad Bell Date: Thu, 25 Apr 2024 06:09:18 -0700 Subject: [PATCH] master: The configure and cmake scripts better detect when eigen or sacado not supported. --- CMakeLists.txt | 45 ++++++++++++++++++++--------------- appendix/whats_new/2024.xrst | 8 +++++++ bin/run_configure.sh | 32 ++++++++++++++++--------- configure | 46 ++++++++++++++++++++++++++++++------ user_guide.xrst | 2 +- 5 files changed, 95 insertions(+), 38 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 62d3caf4f..3edc05b66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ IF( POLICY CMP0054 ) ENDIF( POLICY CMP0054 ) # # cppad_version is used by version.sh to get the version number. -SET(cppad_version "20240424") +SET(cppad_version "20240425") SET(cppad_url "https://coin-or.github.io/CppAD" ) SET(cppad_description "Differentiation of C++ Algorithms" ) IF( NOT DEFINED CMAKE_BUILD_TYPE) @@ -319,37 +319,44 @@ SET(CMAKE_INSTALL_PREFIX "${cppad_prefix}" ) # ----------------------------------------------------------------------------- # Optional package information +# cppad_has_{package}, {package}_LINK_LIBRARIES, package INCLUDE_DIRECTORIES +# +# system_include SET(system_include TRUE) # -# eigen -IF( ${include_eigen} ) - IF( NOT ${use_cplusplus_2014_ok} ) - MESSAGE(FATAL_ERROR "include eigen is true but c++14 not supported") - ENDIF( ) - pkgconfig_info(eigen ${system_include}) - IF( DEFINED eigen_prefix ) - MESSAGE(FATAL_ERROR "include_eigen is true and eigen_prefix is defined") - ENDIF( ) -ELSE( ) - prefix_info(eigen ${system_include} ) -ENDIF( ) +# package = eigen +pkgconfig_info(eigen ${system_include}) # -# adolc +# package = adolc pkgconfig_info(adolc ${system_include}) # -# ipopt +# package = ipopt pkgconfig_info(ipopt ${system_include}) # -# colpack_prefix +# package = colpack prefix_info(colpack ${system_include} ) # -# sacado_prefix +# package = sacado prefix_info(sacado ${system_include} ) # -# fadbad_prefix +# package = fadbad prefix_info(fadbad ${system_include} ) # -# include_cpapdcg +# check eigen +IF( ${cppad_has_eigen} ) + IF( NOT ${use_cplusplus_2014_ok} ) + MESSAGE(FATAL_ERROR "include_eigen is true but c++14 not supported") + ENDIF( ) +ENDIF( ) +# +# check sacado +IF( ${cppad_has_sacado} ) + IF( NOT ${use_cplusplus_2017_ok} ) + MESSAGE(FATAL_ERROR "sacado_prefix is defined but c++17 not supported") + ENDIF( ) +ENDIF( ) +# +# package = cppadcg SET( include_cppadcg FALSE CACHE BOOL "include cppadcg" ) IF( include_cppadcg ) # diff --git a/appendix/whats_new/2024.xrst b/appendix/whats_new/2024.xrst index 276ed610c..b6acf91b9 100644 --- a/appendix/whats_new/2024.xrst +++ b/appendix/whats_new/2024.xrst @@ -28,6 +28,14 @@ Release Notes for 2024 mm-dd ***** +04-25 +===== +The :ref:`configure-name` script was changed to detect when +the eigen package is requested and the compiler is not c++14 or greater. +The :ref:`configure-name` and :ref:`cmake-name` scripts +were changed to detect when +the sacado package is requested and the compiler is not c++17 or greater. + 04-20 ===== The ``# include`` commands were missing at the top of diff --git a/bin/run_configure.sh b/bin/run_configure.sh index e5565a3fc..2a7a3dd57 100755 --- a/bin/run_configure.sh +++ b/bin/run_configure.sh @@ -1,8 +1,9 @@ -#! /bin/bash -e +#! /usr/bin/env bash # SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later # SPDX-FileCopyrightText: Bradley M. Bell -# SPDX-FileContributor: 2003-23 Bradley M. Bell +# SPDX-FileContributor: 2003-24 Bradley M. Bell # ---------------------------------------------------------------------------- +set -e -u if [ ! -e "bin/run_configure.sh" ] then echo "bin/run_configure.sh: must be executed from its parent directory" @@ -11,7 +12,7 @@ fi # ----------------------------------------------------------------------------- with_clang='' cpp_standard='c++17' -while [ "$1" != '' ] +while [ "$#" != '0' ] do if [ "$1" == '--help' ] then @@ -68,20 +69,27 @@ testvector='cppad' cppad_cxx_flags="-std=$cpp_standard -Wall -pedantic-errors -Wshadow" cppad_cxx_flags="$cppad_cxx_flags -Wfloat-conversion -Wconversion" # -# --------------------------------------------------------------------------- -if [ ! -e build ] +# eigen_prefix, scaado_prefix +cxx_standard_year=$(echo $cpp_standard | sed -e 's|c++||') +if [ "$cxx_standard_year" -lt 14 ] then - echo_eval mkdir build + eigen_prefix='' +else + eigen_prefix="EIGEN_DIR=$prefix" fi -echo_eval cd build -if [ -e CMakeCache.txt ] +if [ "$cxx_standard_year" -lt 17 ] then - echo_eval rm CMakeCache.txt + scaado_prefix='' +else + scaado_prefix="SACADO_DIR=$prefix" fi -if [ -e CMakeFiles ] +# +# --------------------------------------------------------------------------- +if [ ! -e build ] then - echo_eval rm -r CMakeFiles + echo_eval mkdir build fi +echo_eval cd build # ----------------------------------------------------------------------------- ../configure \ --prefix=$prefix \ @@ -95,6 +103,8 @@ fi FADBAD_DIR=$prefix \ SACADO_DIR=$prefix \ IPOPT_DIR=$prefix \ + $eigen_prefix \ + $scaado_prefix \ TAPE_ADDR_TYPE=size_t \ TAPE_ID_TYPE=size_t # ---------------------------------------------------------------------------- diff --git a/configure b/configure index 270463eba..63d877599 100755 --- a/configure +++ b/configure @@ -399,6 +399,10 @@ set -e -u # # {xrst_end configure} # ---------------------------------------------------------------------------- +function print_variable { + echo "$1 = ${!1}" +} +# ---------------------------------------------------------------------------- # # --help if echo " $* " | grep ' --help ' > /dev/null @@ -557,6 +561,29 @@ else fi fi # +# cxx_standard_year +if echo $cxx_flags | grep 'std=c++' > /dev/null +then + cxx_standard_year=$(echo $cxx_flags | sed -e 's|.*std=c++\([0-9]*\).*|\1|') + print_variable cxx_standard_year + if [ "$cxx_standard_year" -lt 14 ] + then + if [ "$eigen_dir" != 'NOTFOUND' ] + then + echo 'Eigen requires c++14 or greater' + exit 1 + fi + fi + if [ "$cxx_standard_year" -lt 17 ] + then + if [ "$sacado_dir" != 'NOTFOUND' ] + then + echo 'Sacado requires c++17 or greater' + exit 1 + fi + fi +fi +# # cmake_cxx_compiler cmake_cxx_compiler='' if [ "$enable_msvc" == 'yes' ] @@ -634,13 +661,18 @@ if [ -d '/usr/lib64' ] then cmake_install_libdirs='lib64;lib' fi -# -# CMakeCache.txt -if [ -e CMakeCache.txt ] -then - rm CMakeCache.txt -fi -echo +list=' + build.ninja + CMakeCache.txt + CMakeFiles +' +for name in $list +do + if [ -e "$name" ] + then + echo_eval rm -r $name + fi +done echo cmake \ -U .+ \ -S "$source_dir" \ diff --git a/user_guide.xrst b/user_guide.xrst index c68e9d3ce..f50aa0c03 100644 --- a/user_guide.xrst +++ b/user_guide.xrst @@ -13,7 +13,7 @@ {xrst_comment BEGIN: Before changing see new_release.sh and check_version.sh} -cppad-20240424: CppAD User's Manual +cppad-20240425: CppAD User's Manual ################################### .. image:: {xrst_dir coin.png}