source: trunk/CMakeLists.txt @ 3071

Last change on this file since 3071 was 2897, checked in by bradbell, 7 years ago
  1. Add a minimal atomic example called example/atomic/get_started.cpp.
  2. Advance version number in source to today.

optimize.hpp: Avoid warning with signed address type (used for testing).
atomic_base.hpp: Fix documentation, only zero order forward required.
reciprocal.cpp: fix spelling of now.
reverse.hpp: Fix bug in checking for nan during reverse mode.

  • Property svn:keywords set to Id
File size: 12.3 KB
Line 
1# $Id: CMakeLists.txt 2897 2013-09-18 13:05:21Z bradbell $
2# -----------------------------------------------------------------------------
3# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-13 Bradley M. Bell
4#
5# CppAD is distributed under multiple licenses. This distribution is under
6# the terms of the
7#                     Eclipse Public License Version 1.0.
8#
9# A copy of this license is included in the COPYING file of this distribution.
10# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
11# -----------------------------------------------------------------------------
12# =============================================================================
13# Some constants
14# =============================================================================
15# Set the minimum required version of cmake for this project.
16CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
17
18# cppad_version is used by set_version.sh to get the version number.
19SET(cppad_version      "20130918" )
20SET(cppad_url          "http://www.coin-or.org/CppAD" )
21SET(cppad_description  "Differentiation of C++ Algorithms" )
22
23
24# Set name of this project and create the variables
25# cppad_BINARY_DIR and cppad_SOURCE_DIR.
26# project(projectname [CXX] [C] [Java])
27PROJECT(cppad)
28
29# Add this directory to the list of C++ preprocessor include directories
30# for the entire project.
31# include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)
32INCLUDE_DIRECTORIES( ${cppad_SOURCE_DIR} )
33
34
35
36# =============================================================================
37# Some system cmake language extensions
38# =============================================================================
39# CHECK_CXX_SOURCE_COMPILES(source variable)
40# Checks whether the code given in source will compile, link and run and
41# return zero status. You can set
42# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_FLAGS and CMAKE_REQUIRED_INCLUDES
43# accordingly if additional libraries or compiler flags are required.
44INCLUDE(CheckCXXSourceRuns)
45
46# ============================================================================
47# Some local cmake language
48# ============================================================================
49# dos_path_to_unix(dos_path unix_path)
50INCLUDE(cmake/dos_path_to_unix.cmake)
51#
52# add_to_list(variable_list constant_value)
53INCLUDE(cmake/add_to_list.cmake)
54#
55# command_line_arg(variable default type description)
56INCLUDE(cmake/command_line_arg.cmake)
57#
58# optional_package(prefix_variable description)
59INCLUDE(cmake/optional_package.cmake)
60#
61# add_cppad_cxx_flags(target_name)
62INCLUDE(cmake/add_cppad_cxx_flags.cmake)
63# =============================================================================
64# command line arguments
65# =============================================================================
66# cmake_install_datadir
67command_line_arg(cmake_install_datadir share STRING
68        "directory, below prefix, where cmake installs cppad data files"
69)
70# -----------------------------------------------------------------------------
71# cmake_install_includedirs
72command_line_arg(cmake_install_includedirs include STRING
73        "directories, below prefix, where cmake installs include files"
74)
75# -----------------------------------------------------------------------------
76# cmake_install_libdirs
77command_line_arg(cmake_install_libdirs lib STRING
78        "directories, below prefix, where cmake installs library files"
79)
80# -----------------------------------------------------------------------------
81# cmake_install_prefix
82command_line_arg(cmake_install_prefix /usr PATH
83        "cppad install prefix"
84)
85SET(CMAKE_INSTALL_PREFIX "${cmake_install_prefix}"
86        CACHE PATH "value copied from cmake_install_prefix" FORCE
87)
88# -----------------------------------------------------------------------------
89# cmake_install_postfix
90command_line_arg(cmake_install_postfix NOTFOUND STRING
91        "cppad install postfix"
92)
93# -----------------------------------------------------------------------------
94# cppad_cxx_flags
95command_line_arg(cppad_cxx_flags NOTFOUND STRING
96        "extra flags used with cppad source (besides debug and release flags)"
97)
98# -----------------------------------------------------------------------------
99# cppad_documentation
100command_line_arg(cppad_documentation NO BOOL
101        "install cppad documentation"
102)
103# -----------------------------------------------------------------------------
104# External package prefixes
105#
106# adolc_prefix
107optional_package(adolc_prefix "adolc install prefix")
108#
109# eigen_prefix
110optional_package(eigen_prefix "eigen install prefix")
111#
112# fadbad_prefix
113optional_package(fadbad_prefix "fadbad install prefix")
114#
115# ipopt_prefix
116optional_package(ipopt_prefix "ipopt install prefix")
117#
118# sacado_prefix
119optional_package(sacado_prefix "sacado install prefix")
120# =============================================================================
121# automated system configuration
122# =============================================================================
123# cppad_install_includedir
124SET(cppad_install_includedir NOTFOUND)
125FOREACH(dir ${cmake_install_includedirs})
126        IF( NOT cppad_install_includedir )
127                SET(cppad_install_includedir ${dir})
128        ENDIF( NOT cppad_install_includedir )
129ENDFOREACH(dir ${cmake_install_includedirs})
130# -----------------------------------------------------------------------------
131# cppad_install_libdir
132SET(cppad_install_libdir NOTFOUND)
133FOREACH(dir ${cmake_install_libdirs})
134        IF( NOT cppad_install_libdir )
135                SET(cppad_install_libdir ${dir})
136        ENDIF( NOT cppad_install_libdir )
137ENDFOREACH(dir ${cmake_install_libdirs})
138# -----------------------------------------------------------------------------
139# cppad_cxx_flags_sacado
140IF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" )
141        SET(cppad_cxx_flags_sacado "${cppad_cxx_flags} -D HAS_C99_TR1_CMATH" )
142ELSE( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" )
143        SET(cppad_cxx_flags_sacado ${cppad_cxx_flags} )
144ENDIF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" )
145MESSAGE(STATUS "cppad_cxx_flags_sacado = ${cppad_cxx_flags_sacado}")
146# -----------------------------------------------------------------------------
147# cppad_cxx_flags_skip_eigen
148STRING(REGEX REPLACE
149        "(.*)-Wshadow(.*)"         "\\1 \\2"
150        cppad_cxx_flags_eigen "${cppad_cxx_flags}"
151)
152MESSAGE(STATUS "cppad_cxx_flags_eigen = ${cppad_cxx_flags_eigen}")
153# -----------------------------------------------------------------------------
154# cppad_cxx_flags_skip_fadbad
155STRING(REGEX REPLACE
156        "(.*)-Wshadow(.*)"         "\\1 \\2"
157        cppad_cxx_flags_fadbad "${cppad_cxx_flags}"
158)
159MESSAGE(STATUS "cppad_cxx_flags_fadbad = ${cppad_cxx_flags_fadbad}")
160# -----------------------------------------------------------------------------
161# cppad_abs_includedir, cppad_abs_libdir, cppad_abs_datadir, cppad_abs_docdir
162IF ( cmake_install_postfix )
163        SET(cppad_abs_includedir
164"${cmake_install_prefix}/${cppad_install_includedir}/${cmake_install_postfix}"
165                CACHE INTERNAL "cppad install include file directory" FORCE
166        )
167        SET(cppad_abs_libdir
168"${cmake_install_prefix}/${cppad_install_libdir}/${cmake_install_postfix}"
169                CACHE INTERNAL "cppad install library file directory" FORCE
170        )
171        SET(cppad_abs_datadir
172"${cmake_install_prefix}/${cmake_install_datadir}/${cmake_install_postfix}"
173                CACHE INTERNAL "cppad install data file directory" FORCE
174        )
175        SET(cppad_abs_docdir
176"${cmake_install_prefix}/${cmake_install_datadir}/doc/${cmake_install_postfix}"
177                CACHE INTERNAL "cppad install data file directory" FORCE
178        )
179ELSE ( cmake_install_postfix )
180        SET(cppad_abs_includedir
181                "${cmake_install_prefix}/${cppad_install_includedir}"
182                CACHE INTERNAL "cppad install include file directory" FORCE
183        )
184        SET(cppad_abs_libdir
185                "${cmake_install_prefix}/${cppad_install_libdir}"
186                CACHE INTERNAL "cppad install library file directory" FORCE
187        )
188        SET(cppad_abs_datadir
189                "${cmake_install_prefix}/${cmake_install_datadir}"
190                CACHE INTERNAL "cppad install data file directory" FORCE
191        )
192        SET(cppad_abs_docdir
193                "${cmake_install_prefix}/${cmake_install_datadir}/doc"
194                CACHE INTERNAL "cppad install data file directory" FORCE
195        )
196ENDIF ( cmake_install_postfix )
197# -----------------------------------------------------------------------------
198# boost_prefix
199FIND_PACKAGE(Boost)
200IF ( Boost_FOUND )
201        # Extract the Boost prefix from Boost_INCLUDE_DIRS
202        #
203        # convert to using unix directory separator
204        dos_path_to_unix("${Boost_INCLUDE_DIRS}" boost_include_dirs)
205        #
206        # convert to just one directory
207        STRING(REGEX REPLACE
208                "([^ ]+).*" "\\1"
209                boost_include_dir "${boost_include_dirs}"
210        )
211        #
212        # extract part before last backslash
213        STRING(REGEX REPLACE
214                "([^ ]*)/[^/ ]*" "\\1"
215                boost_prefix "${boost_include_dir}"
216        )
217        MESSAGE(STATUS "boost_prefix = ${boost_prefix}")
218        #
219        # add boost include directories
220        FOREACH(dir ${cmake_install_includedirs})
221                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
222                        INCLUDE_DIRECTORIES( ${boost_prefix}/${dir} )
223                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
224                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
225        ENDFOREACH( dir )
226        #
227        # add boost link directories
228        FOREACH(dir ${cmake_install_libdirs})
229                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
230                        LINK_DIRECTORIES( ${boost_prefix}/${dir} )
231                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
232                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
233        ENDFOREACH( dir )
234ENDIF ( Boost_FOUND )
235# -----------------------------------------------------------------------------
236# ipopt_LIBRARIES and ipopt_LIBRARY_DIRS
237IF( ipopt_prefix )
238        FIND_PACKAGE(PkgConfig)
239        IF( NOT PKG_CONFIG_FOUND )
240                MESSAGE(FATAL_ERROR "Using ipopt_prefix but cannot find pkg-config")
241        ENDIF( NOT PKG_CONFIG_FOUND )
242        #
243        # Set the system environment variable PKG_CONFIG_PATH
244        FOREACH(dir ${cmake_install_libdirs})
245                IF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
246                        SET( ENV{PKG_CONFIG_PATH} ${ipopt_prefix}/${dir}/pkgconfig )
247                ENDIF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
248        ENDFOREACH(dir)
249        #
250        # pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
251        # ipopt_LIBRARIES      ... only the libraries (w/o the '-l')
252        # ipopt_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
253        pkg_check_modules(ipopt ipopt)
254        IF( NOT ipopt_FOUND )
255                MESSAGE(FATAL_ERROR
256"For all directories dir in cmake_install_libdirs, cannot find the file
257        ipopt_prefix/dir/pkgconfig/ipopt.pc
258where
259        ipopt_prefix = ${ipopt_prefix}
260        cmake_install_libdirs = ${cmake_install_libdirs}
261"
262                )
263        ENDIF( NOT ipopt_FOUND )
264ENDIF( ipopt_prefix )
265# =============================================================================
266# Currently building tests as normal executables
267# =============================================================================
268# The CMakeLists.txt file in the specified source directory is processed
269# before the current input file continues beyond this command.
270# add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
271#
272# Initialize list of tests as empty
273SET(list_check "")
274#
275ADD_SUBDIRECTORY(cppad)
276ADD_SUBDIRECTORY(pkgconfig)
277#
278ADD_SUBDIRECTORY(compare_c)
279add_to_list(list_check check_compare_c)
280#
281ADD_SUBDIRECTORY(example)
282add_to_list(list_check check_example)
283#
284ADD_SUBDIRECTORY(introduction)
285add_to_list(list_check check_introduction)
286#
287ADD_SUBDIRECTORY(print_for)
288add_to_list(list_check check_print_for)
289#
290ADD_SUBDIRECTORY(test_more)
291add_to_list(list_check check_test_more)
292#
293ADD_SUBDIRECTORY(multi_thread)
294add_to_list(list_check check_multi_thread)
295#
296ADD_SUBDIRECTORY(speed)
297add_to_list(list_check check_speed)
298#
299IF ( ipopt_prefix )
300        ADD_SUBDIRECTORY(cppad_ipopt)
301        add_to_list(list_check check_ipopt_nlp)
302ENDIF( ipopt_prefix )
303#
304ADD_CUSTOM_TARGET(check DEPENDS ${list_check})
305#
306# =============================================================================
307# install procedure
308# =============================================================================
309# install(DIRECTORY dirs... DESTINATION <dir>
310#       [FILE_PERMISSIONS permissions...]
311#       [DIRECTORY_PERMISSIONS permissions...]
312#       [USE_SOURCE_PERMISSIONS] [OPTIONAL]
313#       [CONFIGURATIONS [Debug|Release|...]]
314#       [COMPONENT <component>] [FILES_MATCHING]
315#       [[PATTERN <pattern> | REGEX <regex>]
316#       [EXCLUDE] [PERMISSIONS permissions...]] [...]
317# )
318# Note a trailing / in the source directory name drops the source directory
319# name during the copy.
320#
321# During install copy all ithe cppad include files to
322# ${cppad_abs_includedir}/cppad 
323INSTALL(
324        DIRECTORY "cppad/"
325        DESTINATION ${cppad_abs_includedir}/cppad
326        FILES_MATCHING PATTERN "*.h"
327)
328INSTALL(
329        DIRECTORY "cppad/"
330        DESTINATION ${cppad_abs_includedir}/cppad
331        FILES_MATCHING PATTERN "*.hpp"
332)
333#
334# During install copy doc direcrory to cppad_abs_docdir/cppad-${cppad_version} 
335IF ( cppad_documentation )
336        INSTALL( DIRECTORY "doc/" DESTINATION
337                ${cppad_abs_docdir}/cppad-${cppad_version}
338        )
339ENDIF ( cppad_documentation )
Note: See TracBrowser for help on using the repository browser.