From ccc989e78397571f5c6077c1c3fe01d7118ee19e Mon Sep 17 00:00:00 2001
From: Elias Pipping <elias.pipping@fu-berlin.de>
Date: Thu, 27 Feb 2014 21:51:37 +0000
Subject: [PATCH] Add and use ENABLE_IPOPT

Ipopt is now no longer automatically enabled when found, while
any program that is passed IPOPT_CPPFLAGS will continue to use it.

[[Imported from SVN: r12962]]
---
 dune/solvers/iterationsteps/mmgstep.cc       | 4 ++--
 dune/solvers/iterationsteps/multigridstep.cc | 4 ++--
 m4/ipopt.m4                                  | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/dune/solvers/iterationsteps/mmgstep.cc b/dune/solvers/iterationsteps/mmgstep.cc
index dd59802e..68f9a17c 100644
--- a/dune/solvers/iterationsteps/mmgstep.cc
+++ b/dune/solvers/iterationsteps/mmgstep.cc
@@ -4,7 +4,7 @@
 #include <dune/solvers/computeenergy.hh>
 
 
-#ifdef HAVE_IPOPT
+#if HAVE_IPOPT
 #include <dune/solvers/solvers/quadraticipopt.hh>
 #endif
 
@@ -37,7 +37,7 @@ preprocess()
         dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->hasObstacle_ = &(*hasObstacle_)[0];
         dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->obstacles_   = &(*obstacles_)[0];
         
-#ifdef HAVE_IPOPT
+#if HAVE_IPOPT
     } else if (typeid(*this->basesolver_) == typeid(QuadraticIPOptSolver<MatrixType,VectorType>)) {
 
         QuadraticIPOptSolver<MatrixType,VectorType>* ipoptBaseSolver = dynamic_cast<QuadraticIPOptSolver<MatrixType,VectorType>*> (this->basesolver_);
diff --git a/dune/solvers/iterationsteps/multigridstep.cc b/dune/solvers/iterationsteps/multigridstep.cc
index 0c2f09f1..890a290b 100644
--- a/dune/solvers/iterationsteps/multigridstep.cc
+++ b/dune/solvers/iterationsteps/multigridstep.cc
@@ -5,7 +5,7 @@
 #include <dune/solvers/common/genericvectortools.hh>
 #include "blockgsstep.hh"
 
-#ifdef HAVE_IPOPT
+#if HAVE_IPOPT
 #include <dune/solvers/solvers/quadraticipopt.hh>
 #endif
 
@@ -166,7 +166,7 @@ void MultigridStep<MatrixType, VectorType, BitVectorType>::preprocess()
         dynamic_cast<SmootherType*>(loopBaseSolver->iterationStep_)->ignoreNodes_ = ignoreNodesHierarchy_[0];
         
     }
-#ifdef HAVE_IPOPT
+#if HAVE_IPOPT
     else if (typeid(*this->basesolver_) == typeid(QuadraticIPOptSolver<MatrixType,VectorType>)) {
 
         QuadraticIPOptSolver<MatrixType,VectorType>* ipoptBaseSolver = dynamic_cast<QuadraticIPOptSolver<MatrixType,VectorType>*> (this->basesolver_);
diff --git a/m4/ipopt.m4 b/m4/ipopt.m4
index 2829d00f..985c794d 100644
--- a/m4/ipopt.m4
+++ b/m4/ipopt.m4
@@ -42,7 +42,7 @@ AS_IF([test x$with_ipopt != xno], [
     dnl For some strange reason, PKG_CHECK_MODULES puts the stuff we would expect
     dnl in IPOPT_CPPFLAGS (namely, -I<path>)in IPOPT_CFLAGS with ipopt 3.10.1.
     dnl We therefore copy it by hand
-    IPOPT_CPPFLAGS="$IPOPT_CFLAGS"
+    IPOPT_CPPFLAGS="$IPOPT_CFLAGS -DENABLE_IPOPT"
     
     LDFLAGS="$LDFLAGS $IPOPT_LDFLAGS"
     CPPFLAGS="$CPPFLAGS $IPOPT_CPPFLAGS"
@@ -56,7 +56,7 @@ AS_IF([test x$HAVE_IPOPT = x1], [
   AC_SUBST(IPOPT_LIBS, $IPOPT_LIBS)
   AC_SUBST(IPOPT_LDFLAGS, $IPOPT_LDFLAGS)
   AC_SUBST(IPOPT_CPPFLAGS, $IPOPT_CPPFLAGS)
-  AC_DEFINE(HAVE_IPOPT, 1, [Define to 1 if IPOpt library is found])
+  AC_DEFINE(HAVE_IPOPT, [ENABLE_IPOPT], [Define to ENABLE_IPOPT if IPOpt library is found])
 
   # add to global list
   DUNE_PKG_LDFLAGS="$DUNE_PKG_LDFLAGS $IPOPT_LDFLAGS"
-- 
GitLab