chiark / gitweb /
Update documentation with cmake instructions
authorJulien Schueller <schueller@phimeca.com>
Sun, 27 Aug 2017 12:07:24 +0000 (14:07 +0200)
committerJulien Schueller <schueller@phimeca.com>
Sun, 27 Aug 2017 12:07:24 +0000 (14:07 +0200)
doc/docs/NLopt_Installation.md
doc/docs/NLopt_release_notes.md

index ba24fe039423bbe33a87cc9068aa0c7e889bc590..7de4164c7cf5d037254726348926f93743804107 100644 (file)
@@ -4,10 +4,10 @@
 
 The installation of NLopt is fairly standard and straightforward, at least on Unix-like systems (GNU/Linux is fine). It doesn't require any particular packages to be installed except for a C compiler, although you need to have [Octave](https://en.wikipedia.org/wiki/GNU_Octave) and/or Matlab installed if you want to install the Octave and/or Matlab plugins, respectively.
 
-In particular, NLopt uses the standard [Autoconf](https://en.wikipedia.org/wiki/GNU_Autoconf) `configure` script, which means that you compile it via:
+In particular, NLopt uses the standard [CMake](https://cmake.org/) `cmake` build system, which means that you compile it via:
 
 ```
-./configure
+cmake .
 make
 ```
 
@@ -19,19 +19,19 @@ make install
 ```
 
 
-By default, this installs the NLopt static library (`libnlopt.a`) in `/usr/local/lib` and the NLopt header file (`nlopt.h`) in `/usr/local/include`, as well manual pages and a few other files.
+By default, this installs the NLopt shared library (`libnlopt.so`) in `/usr/local/lib` and the NLopt header file (`nlopt.h`) in `/usr/local/include`, as well manual pages and a few other files.
 
 In the following, we describe a few details of this installation process, including how to change the installation location.
 
 Changing the installation directory
 -----------------------------------
 
-You may wish to install NLopt in a directory other than `/usr/local`, especially if you do not have administrator access to your machine. You can do this using the `--prefix` argument to the `configure` script.
+You may wish to install NLopt in a directory other than `/usr/local`, especially if you do not have administrator access to your machine. You can do this using the `CMAKE_INSTALL_PREFIX` variable of the `cmake` utility.
 
 For example, suppose that you want to install into the `install` subdirectory of your home directory (`$HOME`). You would do:
 
 ```
-./configure --prefix=$HOME/install
+cmake -DCMAKE_INSTALL_PREFIX=$HOME/install
 make
 make install
 ```
@@ -46,21 +46,7 @@ cc -I$HOME/install/include myprogram.c -L$HOME/install/lib -lnlopt -lm -o
 
 See also below for how to change the installation directories for Octave, Matlab, and Guile plugins, if you are installing those.
 
-Note also that the `--prefix` flag will change the location where the Python plugins are installed, so you may need to change the [Python module search path](http://docs.python.org/tutorial/modules.html#the-module-search-path) via the `PYTHONPATH` environment variable.
-
-Shared libraries
-----------------
-
-By default, NLopt compiles as a static library. This means that each program you link to NLopt will make a separate copy of the library, which wastes a little disk space. The alternative is to compile NLopt as a shared library (also called a dynamic-link library). While more efficient in terms of disk space etcetera, shared libraries require a bit more care to install properly, which is why we don't install them by default.
-
-Compiling NLopt as a shared library is easy. Just add `--enable-shared` to the `configure` flags, as in:
-
-```
-./configure --enable-shared
-```
-
-
-Then you run `make` and `make` `install` as usual.
+Note also that the `-DCMAKE_INSTALL_PREFIX` flag will change the location where the Python plugins are installed, so you may need to change the [Python module search path](http://docs.python.org/tutorial/modules.html#the-module-search-path) via the `PYTHONPATH` environment variable.
 
 However, at this point you need to tell the operating system where to find the shared library, so that the runtime linker works properly. There are at least two ways to do this. First, you can use the `LD_LIBRARY_PATH` environment variable. For example, if you installed into the `/foo/bar` directory, so that the library is in `/foo/bar/lib`, then you would do
 
@@ -80,6 +66,21 @@ in [csh](https://en.wikipedia.org/wiki/csh) or [w:tcsh](https://en.wikipedia.org
 
 Alternatively, in GNU/Linux systems, you can add the library directory to the system-wide file `/etc/ld.so.conf` and then (as root) run `/sbin/ldconfig`. [Category:NLopt](index.md)
 
+Static libraries
+----------------
+
+By default, NLopt compiles as a shared library (also called a dynamic-link library). The alternative is to compile NLopt as a static library.
+
+Compiling NLopt as a static library is easy. Just add `-DBUILD_SHARED_LIBS=OFF` to the `cmake` flags, as in:
+
+```
+cmake -DBUILD_SHARED_LIBS=OFF .
+```
+
+
+Then you run `make` and `make` `install` as usual.
+
+
 Octave and Matlab plugins
 -------------------------
 
@@ -87,9 +88,9 @@ When you compile NLopt using the above commands, it will automatically compile p
 
 ### Matlab
 
-In particular, for Matlab plugins to be installed, you should to have the Matlab `mex` compiler command in your [Unix PATH](http://kb.iu.edu/data/acar.html). Alternatively, you can specify the explicit path to the `mex` by passing a `MEX` variable to `configure`, via:
+In particular, for Matlab plugins to be installed, you should to have the Matlab `mex` compiler command in your [Unix PATH](http://kb.iu.edu/data/acar.html). Alternatively, you can specify the explicit path to the `mex` by passing a `MEX` variable to `cmake`, via:
 
-`./configure MEX=`*`/path/to/mex`*
+`cmake -DMEX_COMPILER=`*`/path/to/mex`* .
 
 Some versions of Matlab also require that you compile NLopt as a shared library in order to produce a Matlab plugin; see below.
 
@@ -103,20 +104,19 @@ to install the Matlab plugins in directory *dir*. In this case, however, when yo
 
 For the Octave plugins to be installed, you need to have the Octave `mkoctfile` program in your PATH. `mkoctfile` is Octave's equivalent of `mex`. If you are using a GNU/Linux system, and you installed Octave using one of the precompiled packages for your distribution, then you probably need to install a *separate package* to get `mkoctfile`. For example, on Debian you need to install the `octave-headers` package, and on Redhat you need the `octave-devel` package.
 
-By default, the compiled Octave plugins (`.oct` files) are installed into the systemwide `site/oct` directory (usually something like `/usr/lib/octave/2.1.73/site/oct/i486-pc-linux-gnu`), and the .m script files are installed into the systemwide `site/m` directory (usually something like `/usr/share/octave/2.1.73/site/m/`). You can change these defaults by passing `OCT_INSTALL_DIR` and `M_INSTALL_DIR`, respectively, to the configure script, via:
+By default, the compiled Octave plugins (`.oct` files) are installed into the octave extension binary directory relatively to the installation prefix (usually something like `/usr/local/lib/octave/2.1.73/site/oct/i486-pc-linux-gnu`), and the .m script files are installed into the site extension directory relatively the the installation prefix (usually something like `/usr/local/share/octave/2.1.73/site/m/`). You can change these defaults by passing `INSTALL_OCT_DIR` and `INSTALL_M_DIR`, respectively, to the cmake script, via:
 
-`./configure OCT_INSTALL_DIR=`*`octdir`*` M_INSTALL_DIR=`*`mdir`*
+`cmake -DINSTALL_OCT_DIR=`*`octdir`*` -DINSTALL_M_DIR=`*`mdir`* .
 
-(If you only pass `OCT_INSTALL_DIR`, the default `M_INSTALL_DIR=$OCT_INSTALL_DIR`.) In this case, however you will either need to run Octave in the directory where these files are installed or explicitly add those directories to the Octave path (see the Octave `path` command).
 
 Python plugins
 --------------
 
 If [Python](https://en.wikipedia.org/wiki/Python_(programming_language)) is installed on your machine, and you configured NLopt as a shared library (see above), then NLopt will automatically compile and install a Python `nlopt` module. You also need [NumPy](https://en.wikipedia.org/wiki/NumPy) to be installed, as NLopt's Python interface uses NumPy array types.
 
-To specify a particular version or location of Python, use the `PYTHON` variable to set the name of the `python` executable:
+To specify a particular version or location of Python, use the `PYTHON_EXECUTABLE` variable to set the name of the `python` executable:
 
-`./configure PYTHON=`*`python`*
+`cmake -DPYTHON_EXECUTABLE=`*`python`*
 
 GNU Guile plugins
 -----------------
@@ -125,15 +125,13 @@ If [Guile](https://en.wikipedia.org/wiki/GNU_Guile) is installed on your machine
 
 Note that many GNU/Linux distributions come with only the Guile program and shared libraries pre-installed; to compile the NLopt plugin you will also need the Guile programming header files, which are usually in a `guile-dev` or `guile-devel` package that you must install separately.
 
-If you want to specify a particular version or a nonstandard location of Guile, you should use the `GUILE_CONFIG` and `GUILE` variables to specify the locations of the `guile-config` and `guile` programs:
-
-`./configure GUILE=`*`guile`*` GUILE_CONFIG=`*`guile-config`*
+If you want to specify a particular version or a nonstandard location of Guile, you should use the `GUILE_CONFIG_EXECUTABLE` and `GUILE_EXECUTABLE` variables to specify the locations of the `guile-config` and `guile` programs:
 
-(The `configure` script uses these programs to determine the compiler flags and installation directories for Guile plugins.)
+`cmake -DGUILE_EXECUTABLE=`*`guile`*` GUILE_CONFIG_EXECUTABLE=`*`guile-config`*
 
-By default, the Guile plugin is installed into the system-wide site directory (the value of the `(%site-dir)` function in Guile), typically something like `/usr/share/guile/site`. If you want to install somewhere else (e.g. if you do not have administrator access), you can specify a different directory by setting `GUILE_INSTALL_DIR` on the `configure` command line:
+(The `cmake` script uses these programs to determine the compiler flags and installation directories for Guile plugins.)
 
-`./configure GUILE_INSTALL_DIR=`*`dir`*
+By default, the Guile plugin is installed in the guile extension directory defined relatively to the installation prefix.
 
 Note, however, that if you do this then Guile may not know where to load the `nlopt` module from. You can [update the Guile load path](http://www.gnu.org/software/guile/manual/html_node/Build-Config.html) by changing the `%load-path` variable in Guile or using the `GUILE_LOAD_PATH` environment variable.
 
@@ -143,7 +141,7 @@ 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:
 
 ```
-./configure --with-cxx
+cmake -DWITH_CXX=ON .
 ```
 
 
index 6876c368e9bebcd7957e713abd389d102044c2bb..c46801af583a2536faa5df6b6919e0ee4f780bef 100644 (file)
@@ -4,6 +4,13 @@
 
 Here, we describe what has changed between releases of the [NLopt](index.md) package. You can also refer to the `NEWS` file in the Meep package (or the `ChangeLog` file for a more detailed listing).
 
+NLopt 2.5.0
+-----------
+
+<small>TBA</small>
+
+-   Using CMake build system instead of autotools
+
 NLopt 2.4.2
 -----------