NLopt uses a CMake script to copy a C enum into a C++ enum.

Here we create the same effect by patching the source file directly.
Separately (in a unit test), we cross-check that this patch and the
CMake script both produce consistent results.

--- src/api/nlopt-in.hpp.orig
+++ src/api/nlopt-in.hpp
@@ -46,6 +46,68 @@
   // nlopt::* namespace versions of the C enumerated types
   //          AUTOMATICALLY GENERATED, DO NOT EDIT
   // GEN_ENUMS_HERE
+  enum algorithm {
+    GN_DIRECT = 0,
+    GN_DIRECT_L,
+    GN_DIRECT_L_RAND,
+    GN_DIRECT_NOSCAL,
+    GN_DIRECT_L_NOSCAL,
+    GN_DIRECT_L_RAND_NOSCAL,
+    GN_ORIG_DIRECT,
+    GN_ORIG_DIRECT_L,
+    GD_STOGO,
+    GD_STOGO_RAND,
+    LD_LBFGS_NOCEDAL,
+    LD_LBFGS,
+    LN_PRAXIS,
+    LD_VAR1,
+    LD_VAR2,
+    LD_TNEWTON,
+    LD_TNEWTON_RESTART,
+    LD_TNEWTON_PRECOND,
+    LD_TNEWTON_PRECOND_RESTART,
+    GN_CRS2_LM,
+    GN_MLSL,
+    GD_MLSL,
+    GN_MLSL_LDS,
+    GD_MLSL_LDS,
+    LD_MMA,
+    LN_COBYLA,
+    LN_NEWUOA,
+    LN_NEWUOA_BOUND,
+    LN_NELDERMEAD,
+    LN_SBPLX,
+    LN_AUGLAG,
+    LD_AUGLAG,
+    LN_AUGLAG_EQ,
+    LD_AUGLAG_EQ,
+    LN_BOBYQA,
+    GN_ISRES,
+    AUGLAG,
+    AUGLAG_EQ,
+    G_MLSL,
+    G_MLSL_LDS,
+    LD_SLSQP,
+    LD_CCSAQ,
+    GN_ESCH,
+    GN_AGS,
+    NUM_ALGORITHMS        /* not an algorithm, just the number of them */
+  };
+  enum result {
+    FAILURE = -1,         /* generic failure code */
+    INVALID_ARGS = -2,
+    OUT_OF_MEMORY = -3,
+    ROUNDOFF_LIMITED = -4,
+    FORCED_STOP = -5,
+    NUM_FAILURES = -6,    /* not a result, just the number of possible failures */
+    SUCCESS = 1,          /* generic success code */
+    STOPVAL_REACHED = 2,
+    FTOL_REACHED = 3,
+    XTOL_REACHED = 4,
+    MAXEVAL_REACHED = 5,
+    MAXTIME_REACHED = 6,
+    NUM_RESULTS           /* not a result, just the number of possible successes */
+  };
   //////////////////////////////////////////////////////////////////////

   typedef nlopt_func func; // nlopt::func synoynm
