- pip install mkdocs python-markdown-math --user
- PATH=$PATH:~/.local/bin mkdocs build
- mkdir build && pushd build
- - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_CXX=ON -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF ..
+ - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF ..
- make install -j2 && ctest -j2 --output-on-failure
- rm -rf * ~/.local
- - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_CXX=ON -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-i686-w64-mingw32.cmake ..
+ - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-i686-w64-mingw32.cmake ..
- make install -j2
- rm -rf * ~/.local
- - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_CXX=ON -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..
+ - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_PYTHON=OFF -DNLOPT_OCTAVE=OFF -DNLOPT_GUILE=OFF -DNLOPT_MATLAB=OFF -DCMAKE_TOOLCHAIN_FILE=$PWD/../cmake/toolchain-x86_64-w64-mingw32.cmake ..
- make install -j2
- os: osx
- brew install swig octave || echo "nope"
script:
- mkdir build && pushd build
- - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DNLOPT_CXX=ON -DPYTHON_EXECUTABLE=/usr/bin/python ..
+ - cmake -DCMAKE_INSTALL_PREFIX=~/.local -DPYTHON_EXECUTABLE=/usr/bin/python ..
- make install && ctest --output-on-failure
list (APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
-option (NLOPT_CXX "enable cxx routines" OFF)
+option (NLOPT_CXX "enable cxx routines" ON)
option (BUILD_SHARED_LIBS "Build NLopt as a shared library" ON)
option (NLOPT_PYTHON "build python bindings" ON)
option (NLOPT_OCTAVE "build octave bindings" ON)
option (NLOPT_TESTS "build unit tests" OFF)
endif ()
-set (NLOPT_SUFFIX)
-if (NLOPT_CXX)
- set (NLOPT_SUFFIX _cxx)
-endif ()
-
include (GNUInstallDirs)
# Offer the user the choice of overriding the installation directories
install (FILES ${NLOPT_HEADERS} DESTINATION ${RELATIVE_INSTALL_INCLUDE_DIR})
-set (nlopt_lib nlopt${NLOPT_SUFFIX})
+set (nlopt_lib nlopt)
add_library (${nlopt_lib} ${NLOPT_SOURCES})
target_link_libraries (${nlopt_lib} ${M_LIBRARY})
build_script:
- echo Running cmake...
- cd c:\projects\nlopt
- - cmake -G "%CMAKE_PLATFORM%" -DNLOPT_CXX=ON -DCMAKE_INSTALL_PREFIX="C:\projects\nlopt\install" .
+ - cmake -G "%CMAKE_PLATFORM%" -DCMAKE_INSTALL_PREFIX="C:\projects\nlopt\install" .
- cmake --build . --config %Configuration% --target install
- ctest -C %Configuration% --output-on-failure --timeout 100
NLopt with C++ algorithms
-------------------------
-NLopt, as-is, is callable from C, C++, and Fortran, with optional Matlab and GNU Octave plugins (and even installs an `nlopt.hpp` C++ header file to allow you to call it in a more C++ style). By default, it includes only subroutines written in C (or written in Fortran and converted to C), to simplify linking. If you configure with:
+NLopt, as-is, is callable from C, C++, and Fortran, with optional Matlab and GNU Octave plugins (and even installs an `nlopt.hpp` C++ header file to allow you to call it in a more C++ style). By default, it includes subroutines written in C (or written in Fortran and converted to C) and C++. If you configure with:
```sh
-cmake -DNLOPT_CXX=ON ..
+cmake -DNLOPT_CXX=OFF ..
```
-however, it will also include algorithms implemented in C++ (currently, just the StoGO algorithm), and the resulting library will be called `libnlopt_cxx` and is linked with `-lnlopt_cxx`.
+however, it will disable algorithms implemented in C++ (StoGO and AGS algorithms).
-The `libnlopt_cxx` has the *same* interface as the ordinary NLopt library, and can *still* be called from ordinary C and Fortran programs. However, to use it you must also *link* with the C++ standard libraries. The easiest way to do this is to link with the C++ linker: compile your source files into `.o` object files, and then call the C++ compiler to link these `.o` files with `-lnlopt_cxx` into your executable program.
+The resulting library has the *same* interface as the ordinary NLopt library, and can *still* be called from ordinary C, C++, and Fortran programs. However, one no longer has to link with the C++ standard libraries, which can sometimes be convenient for non-C++ programs, and allows libnlopt to be compatible with multiple C++ compilers simultaneously.
-It is because this linking process is somewhat annoying, and it only adds a single more algorithm (StoGO) to NLopt, that by default we omit StoGO to create a library that does not require the C++ standard libraries to link.
Name: NLopt
Description: nonlinear optimization libary
Version: @NLOPT_VERSION_STRING@
-Libs: -L${libdir} -lnlopt@NLOPT_SUFFIX@
+Libs: -L${libdir} -lnlopt
Libs.private: -lm
Cflags: -I${includedir}