Prev | Next |
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.
build
, a subdirectory of the
distribution directory
,
change into the build
.
cmake
command is
cmake ..
This assumes that you are starting in the build
directory
(so that ..
refers to the distribution directory).
The command also 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.
It is suggested that you should start with the simple version of the
cmake command above and then add options one at a time.
CMake Warning at /usr/share/cmake-3.10/Modules/FindBoost.cmake:567 (message):
Imported targets and dependency information not available for Boost version
(all versions older than 1.33)
...
This is not a problem because CppAD will automatically exclude the
examples and tests that use boost.
Newer version of cmake; e.g., 3.13.4, do not generate this warning
(when boost is not present on your system).
cmake \
-D CMAKE_VERBOSE_MAKEFILE=cmake_verbose_makefile \
-D CMAKE_BUILD_TYPE=cmake_build_type \
-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 cmake_defined_ok=cmake_defined_ok \
-D cmake_needs_dot_slash=cmake_needs_dot_slash \
\
-D include_adolc=true_or_false \
-D include_eigen=true_or_false \
-D include_ipopt=true_or_false \
-D include_cppadcg=true_or_false \
\
-D eigen_prefix=eigen_prefix
-D colpack_prefix=colpack_prefix \
-D fadbad_prefix=fadbad_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_tape_id_type=cppad_tape_id_type \
-D cppad_tape_addr_type=cppad_tape_addr_type \
-D cppad_debug_which=cppad_debug_which \
\
..
mingw-64
and g++
,
the following seems to work:
Use pacman
to install
make
, gcc
, and mingw-w64-x86_64-cmake
.
where cmake.exe
to see if cmake.exe
comes with your version of Visual Studio.
If not, download and install the win64-x64 version of
cmake
.
Make sure you select the box that adds cmake
to your execution path.
rmdir /S build mkdir build cd build cmake ^ -G "NMake Makefiles"^ -D cppad_cxx_flags="/MP /EHs /EHc /std:c++17 /Zc:__cplusplus"^ .. nmake check
cppad_lib
. There are problems using a DLL for cppad_lib
because Windows makes separate copies of static class member functions,
one for library and one for the rest of the program.
mkdir build
cd build
../configure CC=cl CXX=cl CXX_FLAGS="-DEBUG"
make test
An optimized versions was tested using
../configure CXX=cl CC=cl CXX_FLAGS="-DNDEBUG -O2 -EHsc"
make test
The commands above need to be run a Dos window,
that has the vcvarsall.bat
settings,
extend path that includes the msys2
bin directory,
and was running the bash shell inside the Doc window.
It is highly recommended that you use the cmake
commands above,
an not ../configure
, when building with Visual Studio.
grep
program,
and store the output in cmake.log
, you can get a list of
all the test options with the command:
grep 'make check' cmake.log
true
or false
.
The default value, when it is not present, is NO
.
If it is true
, 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.
Debug
,
Release
,
RelWithDebInfo
,
MinSizeRel
.
If this value is specified,
cppad_debug_which
must not be the empty string.
true
or false
.
The default value, when it is not present, is false
.
If you get an error saying that an executable program could not be found,
try setting this to true.
CMake gets confused on some systems and needs ./
in front
of the name of the executable corresponding to a cmake
ADD_CUSTOM_COMMAND
. For example, in the github actions version of
using msys2 in ci
.
generator
| Description |
"Unix Makefiles" | make files for unix operating system |
"NMake Makefiles" | make files for Visual Studio |
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 the value of
CMAKE_INSTALL_PREFIX
; see the cmake documentation.
(Before 2019-10-02 the default value was /usr
; see
the heading 10-02 on whats_new_19
.)
cppad_prefix
is /usr
,
cmake_install_includedirs
is include
, and
cppad_postfix
is coin-or
,
the file cppad.hpp
is installed in the location
/usr/include/coin-or/cppad/cppad.hpp
The default value for
cppad_postfix
is empty; i.e,
there is no bottom level relative directory for the installed files.
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
.
lib
.
cppad_prefix
is /usr
,
cmake_install_libdirs
is lib
,
cppad_postfix
is not specified,
the CppAD library is installed in
/usr/lib/libcppad_lib.ext.major.release
Here
major
is the major library version number,
release
is the release number for this version,
and
ext
is the extension for shared libraries on this system.
If
yyyymmdd
is the CppAD version
number,
the major CppAD library version number is
major = dd - 1 + 31 * ( mm - 1 + 12 * ( yyyy - 2019) )
If there is no release
for this version of CppAD,
the CppAD library is installed in
/usr/lib/libcppad_lib.ext.major
The Mac is special,
ext
is dylib
and comes
at the end of the file name for that system.
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
.
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.
CMakeCache.txt
file.
If it is false, some checks will be made to make sure
certain variables are not defined twice.
The default value for
cmake_defined_ok
is true.
include_adolc=true
is in the command line.
include_eigen=true
is on the command line.
In addition, the sparse2eigen
utility will be installed.
include_ipopt=true
is on the command line.
In addition, ipopt_solve
and cppad_ipopt_nlp
will be installed.
include_cppadcg=true
is on the command line.
Warning :
Do not use this option when installing cppad because
the cppadcg package depends on cppad and using this option
makes cppad depend on cppadcg.
This option, and the script get_cppadcg.sh
are only intended
for testing purposes.
include_eigen
is true
(because pkg-config
will be used to determine this information).
pkg-config
files
corresponding to optional CppAD examples.
If a prefix listed below is on the command line,
the corresponding examples will be compiled and run:
colpack_prefix | Enabling Colpack Sparsity Calculations |
fadbad_prefix | Including Fadbad Speed Tests |
sacado_prefix | Including Sacado Speed Tests |
CMAKE_CXX_FLAGS_DEBUG
and
CMAKE_CXX_FLAGS_RELEASE
.
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++17 -Wshadow"
cppad_cxx_flags
must enable these features.
cppad_cxx_flags
.
See also the
CPPAD_DEBUG_AND_RELEASE
compiler flag (which should not be included in
cppad_cxx_flags
).
-Wno-bitwise-instead-of-logical
in
cppad_cxx_flags
.
cd build/speed/profile
make check_speed_profile
./speed_profile test seed option_list
gprof -b speed_profile | sed -f gprof.sed
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_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
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
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_text
,
size_VecAD
.
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_debug_which
be one of the following:
cppad_debug_which
|
CMAKE_BUILD_TYPE
|
debug_all |
Debug |
debug_none |
Release |
debug_even | not specified |
debug_odd | not specified |
empty string | not changed |
CMAKE_BUILD_TYPE
is specified on the command line,
then
cppad_debug_which
must be the empty string (its default value).