chiark / gitweb /
Enable CXX by default (#198)
authorJulien Schueller <schueller@phimeca.com>
Mon, 30 Jul 2018 14:11:41 +0000 (16:11 +0200)
committerSteven G. Johnson <stevenj@mit.edu>
Mon, 30 Jul 2018 14:11:41 +0000 (10:11 -0400)
* Enable CXX by default

It's silly not to provide all algorithms by default,
c++ compiler are easy to find these days, worst case it can still be disabled

Also remove lib suffix

* Update doc

.travis.yml
CMakeLists.txt
appveyor.yml
doc/docs/NLopt_Installation.md
nlopt.pc.in

index 221d3de09731ddc6b4f0d73e0c9b3dd2e2e934e8..55c7f6ab3594b8fa83d7ca855550b8195f50b6f0 100644 (file)
@@ -23,13 +23,13 @@ matrix:
         - 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
@@ -39,5 +39,5 @@ matrix:
         - 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
index d9fb57bcd0bf5a33211784e92f6f2adf5b125746..f34bd5d353208b9aea822959dc5172e5a04b001d 100644 (file)
@@ -37,7 +37,7 @@ set(SO_PATCH 0)
 
 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)
@@ -52,11 +52,6 @@ else ()
   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
@@ -226,7 +221,7 @@ endif ()
 
 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})
 
index 4a09c821756dd2015f654380cc0e9e5f0231fee6..3fa6abaf44c1172a63dfdfb8f5eb3e79003e2b12 100644 (file)
@@ -17,6 +17,6 @@ install:
 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
index 61c455b61b260d3e02b9a6e76e2c056f9666d79e..ab68b3e5a7ccc16dda50920e091eb7c8fc61324c 100644 (file)
@@ -142,14 +142,13 @@ Note, however, that if you do this then Guile may not know where to load the `nl
 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.
index 81616df2a2df5383255f7b54987bb0691a734da3..8d46f071fd3a9d07cfa7f2b120fa763809dc80b4 100644 (file)
@@ -6,6 +6,6 @@ includedir=${prefix}/include
 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}