Using CMake to Configure CppAD
Keywords: using cmake to configure cppad makefile install prefix postfix include directories lib datadir documentation package compile flags profile maximum number threads sparsity internal structure vector sets memory usage tape ctor implicit explicit the program command build directory cmake_verbose_makefile generator cppad_prefix cppad_postfix cmake_install_includedirs cmake_install_libdirs cmake_install_datadir cmake_install_docdir package_prefix cppad_cxx_flags c++11 cppad_profile_flag eigen fadbad cppad_testvector cppad_max_num_threads cppad_sparse_list cppad_tape_id_type cstdint cppad_tape_addr_type cppad_deprecated

| Prev | Next |  |  |  |  |  |

Using CMake to Configure CppAD
The CMake Program
The cmake program enables one to create a single set of scripts, called `CMakeLists.txt`, that can be used to test and install a program on Unix, Microsoft, or Apple operating systems. For example, one can use it to automatically generate Microsoft project files.
CMake Command
The command below assumes that `cmake` is in your execution path with version greater than or equal 2.8. If not, you can put the path to the version of `cmake` in font the command. Only the `cmake` command and the path to the distribution directory (`..` at the end of the command below) are required. In other words, the first and last lines below are required and all of the other lines are optional.
Build Directory
Create a `build` subdirectory of the distribution directory , change into the `build` directory, and execute the following command: `
cmake \
-D CMAKE_VERBOSE_MAKEFILE=cmake_verbose_makefile \
-G generator \
\
-D cppad_prefix=cppad_prefix \
-D cppad_postfix=cppad_postfix \
\
-D cmake_install_includedirs=cmake_install_includedirs \
-D cmake_install_libdirs=cmake_install_libdirs \
\
-D cmake_install_datadir=cmake_install_datadir \
-D cmake_install_docdir=cmake_install_docdir \
\
-D adolc_prefix=adolc_prefix \
-D colpack_prefix=colpack_prefix \
-D eigen_prefix=eigen_prefix \
-D fadbad_prefix=fadbad_prefix \
-D ipopt_prefix=ipopt_prefix \
-D sacado_prefix=sacado_prefix \
\
-D cppad_cxx_flags=cppad_cxx_flags \
-D cppad_profile_flag=cppad_profile_flag \
\
-D cppad_testvector=cppad_testvector \
-D cppad_max_num_threads=cppad_max_num_threads \
-D cppad_sparse_list=cppad_sparse_list \
-D cppad_tape_id_type=cppad_tape_id_type \
-D cppad_tape_addr_type=cppad_tape_addr_type \
-D cppad_deprecated=cppad_deprecated \
\
..
`
cmake_verbose_makefile
This value should be either `YES` or `NO`. The default value, when it is not present, is `NO`. If it is `YES`, then the output of the `make` commands will include all of the files and flags used to run the compiler and linker. This can be useful for seeing how to compile and link your own applications.
generator
The CMake program is capable of generating different kinds of files. Below is a table with a few of the possible files

`generator` | Description
`"Unix Makefiles"` | make files for unix operating system
`"NMake Makefiles"` | make files for Visual Studio

Other generator choices are available; see the cmake generators documentation.
cppad_prefix
This is the top level absolute path below which all of the CppAD files are installed by the command `
make install
` For example, if `cppad_prefix` is `/usr`, `cmake_install_includedirs` is `include`, and `cppad_postfix` is not specified, the file `cppad.hpp` is installed in the location `
/usr/include/cppad/cppad.hpp
` The default value for `cppad_prefix` is `/usr`.
cppad_postfix
This is the bottom level relative path below which all of the CppAD files are installed. For example, if `cppad_prefix` is `/usr`, `cmake_install_includedirs` is `include`, and `cppad_postfix` is `coin`, the file `cppad.hpp` is installed in the location `
/usr/include/coin/cppad/cppad.hpp
` The default value for `cppad_postfix` is empty; i.e, there is no bottom level relative directory for the installed files.
cmake_install_includedirs
This is one directory, or a list of directories separated by spaces or by semi-colons. This first entry in the list is the middle level relative path below which the CppAD include files are installed. The entire list is used for searching for include files. For example, if `cppad_prefix` is `/usr`, `cmake_install_includedirs` is `include`, and `cppad_postfix` is not specified, the file `cppad.hpp` is installed in the location `
/usr/include/cppad/cppad.hpp
` The default value for this directory list is `include`.
cmake_install_libdirs
This is one directory, or a list of directories separated by spaces or by semi-colons. This first entry in the list is the middle level relative path below which the CppAD library files are installed. The entire list is used for searching for library files. For example, if `cppad_prefix` is `/usr`, `cmake_install_libdirs` is `lib`, `cppad_postfix` is not specified, and `ipopt_prefix` is specified, the file `libcppad_ipopt.a` is installed in the location `
/usr/lib/libcppad_ipopt.a
` The default value for this directory list is `lib`.
cmake_install_datadir
This is the middle level relative path below which the CppAD data files are installed. For example, if `cppad_prefix` is `/usr`, `cmake_install_datadir` is `share`, and `cppad_postfix` is not specified, the pkgconfig file `cppad.pc` is installed in the location `
/usr/share/pkgconfig/cppad.pc
` The default value for `cmake_install_datadir` is `share`.
cmake_install_docdir
This is the middle level relative path below which the CppAD documentation files are installed. For example, if `cppad_prefix` is `/usr`, `cmake_install_docdir` is `share/doc`, and `cppad_postfix` is not specified, the file `cppad.xml` is installed in the location `
/usr/share/doc/cppad/cppad.xml
` There is no default value for `cmake_install_docdir` . If it is not specified, the documentation files are not installed.
package_prefix
Each of these packages corresponds to optional CppAD examples, that can be compiled and tested if the corresponding prefix is provided:

adolc_prefix | Including the ADOL-C Examples and Tests
colpack_prefix | Including the ColPack Sparsity Calculations
eigen_prefix | Including the Eigen Examples and Tests
fadbad_prefix | Including the FADBAD Speed Tests
ipopt_prefix | Including the cppad_ipopt Library and Tests
sacado_prefix | Including the Sacado Speed Tests

cppad_cxx_flags
This specifies the addition compiler flags, besides the debug and release flags, that are used when compiling the CppAD examples and tests. The default value for these flags is the empty string `""`. These flags must be valid for the C++ compiler on your system. For example, if you are using `g++` you could specify `

         -D cppad_cxx_flags="-Wall -ansi -pedantic-errors -std=c++11 -Wshadow"

`
C++11
In order for the compiler to take advantage of features that are new in C++11, the `cppad_cxx_flags` must enable these features. The compiler may still be used with a flag that disables the new features (unless it is a Microsoft compiler; i.e., `_MSC_VER` is defined).
cppad_profile_flag
This specifies an addition compiler and link flag that is used for profiling the speed tests. A profile version of the speed test is only build when this argument is present.
Eigen and Fadbad
The packages eigen and fadbad currently generate a lot of shadowed variable warnings. If the `-Wshadow` flag is present, it is automatically removed when compiling examples and test that use these packages.
cppad_testvector
See Choosing the CppAD Test Vector Template Class.
cppad_max_num_threads
The value `cppad_max_num_threads` must be greater than or equal to four; i.e., `max_num_threads >= 4` . The current default value for `cppad_max_num_threads` is 48, but it may change in future versions of CppAD. The value `cppad_max_num_threads` in turn specifies the default value for the preprocessor symbol CPPAD_MAX_NUM_THREADS .
cppad_sparse_list
There are two possible values for this option, `YES` and `NO`. This affect the internal data structure used to store a sparsity pattern when the users version of the sparsity pattern is a vector of `std::set<size_t>`. If `cppad_sparse_list` is `NO` the vectors of standard sets are also used internally. If `cppad_sparse_list` is `YES`, a special sparse list structure is used instead. This should affect the speed and memory required by the sparse_jacobian , sparse_hessian , and sparse drivers The default value for `cppad_sparse_list` is `YES`
cppad_tape_id_type
The type `cppad_tape_id_type` is used for identifying different tapes. The valid values for this type are `unsigned char`, `unsigned short int`, `unsigned int`, and `size_t`. The smaller the value of `sizeof(cppad_tape_id_type)` , the less memory is used. On the other hand, the value `
std::numeric_limits<cppad_tape_id_type>::max()
` must be larger than the maximum number of tapes used by one thread times CPPAD_MAX_NUM_THREADS .
cstdint
If all of the following `cstdint` types are defined, they can also be used as the value of `cppad_tape_addr_type` : `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`.
cppad_tape_addr_type
The type `cppad_tape_addr_type` is used for address in the AD recordings (tapes). The valid values for this argument are `unsigned char`, `unsigned short int`, `unsigned int`, `size_t`. The smaller the value of `sizeof(cppad_tape_addr_type)` , the less memory is used. On the other hand, the value `
std::numeric_limits<cppad_tape_addr_type>::max()
` must be larger than any of the following: size_op , size_op_arg , size_par , size_par , size_par .
cstdint
If all of the following `cstdint` types are defined, they can also be used as the value of `cppad_tape_addr_type` : `uint8_t`, `uint16_t`, `uint32_t`, `uint64_t`.
cppad_deprecated
The default value for `cppad_deprecated` is `NO`. If it is `YES`, then all the CppAD deprecated features are included in the installation . Otherwise, some of the deprecated features may be excluded from the installation. (The intention here is to exclude more deprecated features as time marches on.)

Input File: omh/install/cmake.omh