source: trunk/CMakeLists.txt @ 3811

Last change on this file since 3811 was 3811, checked in by bradbell, 4 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: f77cd2e443b8d14f354f97efc4c26369227dfe81
end hash code: 33d1f5b8d837d83c8baf656045d85d8b45f0b297

commit 33d1f5b8d837d83c8baf656045d85d8b45f0b297
Author: Brad Bell <bradbell@…>
Date: Sun Mar 27 04:01:14 2016 -0700

  1. Test non-symmetric reverse mode in eigen_mat_inv (and fix this example).
  2. Advance version to cppad-20160327.

commit 238e214ff36ca835efca615c609576dc8bf5038d
Author: Brad Bell <bradbell@…>
Date: Sat Mar 26 18:10:59 2016 -0700

eigen_mat_inv.hpp: use inverse matrix (since we are computing it).
eigen_mat_mul.hpp: comment seperator.
eigen_mat_inv.cpp: matrix during recording is non-singular.
eigen_mat_inv.cpp: test first and second order forward.

commit fc918b0476cc8ea66abdf2904a71fc93472d279d
Author: Brad Bell <bradbell@…>
Date: Sat Mar 26 16:26:51 2016 -0700

Add test_more/eigen_mat_inv.cpp.


eigen_mat_inv.hpp: fix calculation of vy.
eigen_mat_inv.cpp: fix section title.
CMakeLists.txt: no longer necessary to have special library for eigen tests.
eigen_mat_inv.cpp: Test with non-symmetric matrix.

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