source: trunk/CMakeLists.txt @ 3938

Last change on this file since 3938 was 3938, checked in by bradbell, 2 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 78ba7f801a6fec0dbdaa887c01ea58a9ccb59817
end hash code: bd9a72f2ccec67a9773cd2ecd536df8fe09860da

commit bd9a72f2ccec67a9773cd2ecd536df8fe09860da
Author: Brad Bell <bradbell@…>
Date: Mon May 22 06:14:34 2017 -0700

  1. Add the cppad_extra_debug option to cmake command.
  2. Advance to cppad-20170522.

commit 8f832650db029dd1df2f302b3e6a7f39cb83078f
Author: Brad Bell <bradbell@…>
Date: Sun May 21 07:16:35 2017 -0700

CMakeLists.txt: change type of cppad_deprecated to BOOL (must be NO).
configure.hpp.in: fix comment about CPPAD_DEPRECATED.
ad_ctor.hpp: remove comment about old use of cppad_deprecated.
cmake.omh: remove description of old deprecated case.

commit 9a0a0705f7c44e5a93c136c3bd1e56ab39bb809f
Author: Brad Bell <bradbell@…>
Date: Sun May 21 06:34:38 2017 -0700

Add test that fails when release.cpp is compiled for release.
CMakeLists.txt: improve command line argument comments.

commit bfbc481d68256d71217a1d9a439bc2b2e07f90c2
Author: Brad Bell <bradbell@…>
Date: Sun May 21 04:15:26 2017 -0700

Advance to cppad-20170521.
check_example.sh: simplify.

commit 163044ceea186505229e59770b263fe00b12726d
Author: Brad Bell <bradbell@…>
Date: Sat May 20 09:07:15 2017 -0700

Create test_more/debug_rel (Under construction).

commit 9d90a176a0fc75faff28c0cb2034218d8a3b2f6a
Author: Brad Bell <bradbell@…>
Date: Sat May 20 07:04:52 2017 -0700

readme.md: add link to new directory structure page.

  • Property svn:keywords set to Id
File size: 13.6 KB
Line 
1# -----------------------------------------------------------------------------
2# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-17 Bradley M. Bell
3#
4# CppAD is distributed under multiple licenses. This distribution is under
5# the terms of the
6#                     Eclipse Public License Version 1.0.
7#
8# A copy of this license is included in the COPYING file of this distribution.
9# Please visit http://www.coin-or.org/CppAD/ for information on other licenses.
10# -----------------------------------------------------------------------------
11# =============================================================================
12# Some constants
13# =============================================================================
14# Suppress warnging that WIN32 not defined on cygwin
15SET(CMAKE_LEGACY_CYGWIN_WIN32 0) # remove when version below >= 2.8.4
16#
17# Set the minimum required version of cmake for this project.
18# see http://www.cmake.org/pipermail/cmake/2013-January/053213.html
19CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
20#
21# cppad_version is used by set_version.sh to get the version number.
22SET(cppad_version      "20170522" )
23SET(cppad_url          "http://www.coin-or.org/CppAD" )
24SET(cppad_description  "Differentiation of C++ Algorithms" )
25#
26# Set name of this project and create the variables
27# cppad_BINARY_DIR and cppad_SOURCE_DIR.
28# project(projectname [CXX] [C] [Java])
29PROJECT(cppad)
30#
31# Add this directory to the list of C++ preprocessor include directories
32# for the entire project.
33# include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)
34INCLUDE_DIRECTORIES( ${cppad_SOURCE_DIR} )
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(package description)
59INCLUDE(cmake/optional_package.cmake)
60#
61# add_cppad_cxx_flags(target_name)
62INCLUDE(cmake/add_cppad_cxx_flags.cmake)
63#
64# check_source_runs(source variable)
65INCLUDE(cmake/check_source_runs.cmake)
66#
67# assert(variable)
68INCLUDE(cmake/assert.cmake)
69#
70# print_variable(variable)
71INCLUDE(cmake/print_variable.cmake)
72# =============================================================================
73# command line arguments
74# =============================================================================
75# cmake_install_datadir
76command_line_arg(cmake_install_datadir share STRING
77        "directory, below prefix, where cmake installs cppad data files"
78)
79# -----------------------------------------------------------------------------
80# cmake_install_docdir
81command_line_arg(cmake_install_docdir NOTFOUND STRING
82        "directory, below prefix, where cmake installs cppad documentation files"
83)
84# -----------------------------------------------------------------------------
85# cmake_install_includedirs
86command_line_arg(cmake_install_includedirs include STRING
87        "directories, below prefix, where cmake installs include files"
88)
89# -----------------------------------------------------------------------------
90# cmake_install_libdirs
91command_line_arg(cmake_install_libdirs lib STRING
92        "directories, below prefix, where cmake installs library files"
93)
94# -----------------------------------------------------------------------------
95# cppad_prefix
96command_line_arg(cppad_prefix /usr PATH
97        "cppad install prefix"
98)
99SET(CMAKE_INSTALL_PREFIX "${cppad_prefix}"
100        CACHE PATH "value copied from cppad_prefix" FORCE
101)
102IF( cppad_has_cmake_install )
103        MESSAGE(FATAL_ERROR
104                "cmake_install_prefix has been changed to cppad_prefix"
105        )
106ENDIF( cppad_has_cmake_install )
107# -----------------------------------------------------------------------------
108# cppad_postfix
109command_line_arg(cppad_postfix NOTFOUND STRING
110        "cppad install postfix"
111)
112IF( cmake_install_postfix )
113        MESSAGE(FATAL_ERROR
114                "cmake_install_postfix has been changed to cppad_postfix"
115        )
116ENDIF( cmake_install_postfix )
117# -----------------------------------------------------------------------------
118# cppad_cxx_flags
119command_line_arg(cppad_cxx_flags NOTFOUND STRING
120        "compile flags used with cppad (besides debug, release, and profile flags)"
121)
122# -----------------------------------------------------------------------------
123# cppad_profile_flag
124command_line_arg(cppad_profile_flag NOTFOUND STRING
125        "compile flag used to compile and link a profile version of a program"
126)
127# -----------------------------------------------------------------------------
128# External package prefixes with warnings
129SET(system_include FALSE)
130#
131# adolc_prefix
132optional_package(adolc ${system_include} "adolc install prefix")
133#
134# colpack_prefix
135optional_package(colpack ${system_include} "colpack install prefix")
136#
137# ipopt_prefix
138optional_package(ipopt ${system_include} "ipopt install prefix")
139#
140# sacado_prefix
141optional_package(sacado ${system_include} "sacado install prefix")
142# -----------------------------------------------------------------------------
143# External package prefixes without warnings
144SET(system_include TRUE)
145#
146# eigen_prefix
147optional_package(eigen ${system_include} "eigen install prefix")
148#
149# fadbad_prefix
150optional_package(fadbad ${system_include} "fadbad install prefix")
151# -----------------------------------------------------------------------------
152# cppad_testvector
153command_line_arg(cppad_testvector cppad STRING
154        "Namespace of vector used for testing, one of: boost, cppad, eigen, std"
155)
156#
157# cppad_max_num_threads
158command_line_arg(cppad_max_num_threads 48 STRING
159        "maximum number of threads that CppAD can use use"
160)
161# cppad_sparse_list
162IF( cppad_sparse_list )
163        MESSAGE(FATAL_ERROR
164                "cppad_sparse_list = ${cppad_sparse_list}"
165                ": this command line argument has been removed"
166        )
167ENDIF( cppad_sparse_list )
168#
169# cppad_tape_id_type
170command_line_arg(cppad_tape_id_type "unsigned int" STRING
171        "type used to identify different tapes, size must be <= sizeof(size_t)"
172)
173#
174# cppad_tape_addr_type
175command_line_arg(cppad_tape_addr_type "unsigned int" STRING
176"type used to identify variables on one tape, size must be <= sizeof(size_t)"
177)
178#
179# cppad_deprecated
180command_line_arg(cppad_deprecated NO BOOL
181        "this symbol must be NO and is not currently being used"
182)
183IF( cppad_deprecated )
184        MESSAGE(FATAL_ERROR "cppad_deprecated must be NO" )
185ENDIF( cppad_deprecated )
186#
187# cppad_extra_debug
188command_line_arg(cppad_extra_debug NO BOOL
189        "if this is true, and NDEBUG is not defined, do extra cppad debugging"
190)
191# =============================================================================
192# cppad_has_colpack, colpack_libs, cppad_lib
193#
194IF( cppad_has_colpack )
195        SET(cppad_has_colpack 1)
196        SET( colpack_libs "ColPack" )
197        SET( cppad_lib "cppad_lib" )
198ELSE( cppad_has_colpack )
199        SET(cppad_has_colpack 0)
200        SET( colpack_libs "" )
201        SET( cppad_lib "" )
202ENDIF( cppad_has_colpack )
203# =============================================================================
204# automated system configuration
205# =============================================================================
206# CMAKE_CXX_FLAGS
207# remove Visual Studio C++ warning level if specified in cppad_cxx_flags
208IF ( cppad_cxx_flags MATCHES "/W[0-9]" )
209        STRING( REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
210ENDIF ( cppad_cxx_flags MATCHES "/W[0-9]" )
211print_variable(CMAKE_CXX_FLAGS)
212# -----------------------------------------------------------------------------
213# set cppad_abs_${middle_name} for middle_name equal to:
214#       includedir, liddir, datadir, docdir
215FOREACH(middle_names includedirs libdirs datadir docdir)
216        STRING(REGEX REPLACE "dirs" "dir" middle_name ${middle_names})
217        SET(middle_value NOTFOUND)
218        FOREACH(dir ${cmake_install_${middle_names}})
219                IF( NOT middle_value )
220                        SET(middle_value ${dir})
221                ENDIF( NOT middle_value )
222        ENDFOREACH(dir ${cmake_install_${middle_names}})
223        #
224        SET(tmp "${cppad_prefix}/${middle_value}" )
225        IF ( cppad_postfix )
226                SET(cppad_abs_${middle_name} ${tmp}/${cppad_postfix})
227        ELSE ( cppad_postfix )
228                SET(cppad_abs_${middle_name} ${tmp})
229        ENDIF ( cppad_postfix )
230ENDFOREACH(middle_names includedirs libdirs datadir docdir)
231# -----------------------------------------------------------------------------
232# boost_prefix
233FIND_PACKAGE(Boost)
234SET(cppad_has_boost 0)
235IF ( Boost_FOUND )
236        SET(cppad_has_boost 1)
237        #
238        # Extract the Boost prefix from Boost_INCLUDE_DIRS
239        #
240        # convert to using unix directory separator
241        dos_path_to_unix("${Boost_INCLUDE_DIRS}" boost_include_dirs)
242        #
243        # convert to just one directory
244        STRING(REGEX REPLACE
245                "([^ ]+).*" "\\1"
246                boost_include_dir "${boost_include_dirs}"
247        )
248        #
249        # extract part before last backslash
250        STRING(REGEX REPLACE
251                "([^ ]*)/[^/ ]*" "\\1"
252                boost_prefix "${boost_include_dir}"
253        )
254        print_variable(boost_prefix)
255        #
256        # add boost include directories
257        FOREACH(dir ${cmake_install_includedirs})
258                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
259                        INCLUDE_DIRECTORIES( ${boost_prefix}/${dir} )
260                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
261                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
262        ENDFOREACH( dir )
263        #
264        # add boost link directories
265        FOREACH(dir ${cmake_install_libdirs})
266                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
267                        LINK_DIRECTORIES( ${boost_prefix}/${dir} )
268                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
269                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
270        ENDFOREACH( dir )
271ENDIF ( Boost_FOUND )
272# -----------------------------------------------------------------------------
273# ipopt_LIBRARIES and ipopt_LIBRARY_DIRS
274IF( cppad_has_ipopt )
275        FIND_PACKAGE(PkgConfig)
276        IF( NOT PKG_CONFIG_FOUND )
277                MESSAGE(FATAL_ERROR "Using ipopt_prefix but cannot find pkg-config")
278        ENDIF( NOT PKG_CONFIG_FOUND )
279        #
280        # Set the system environment variable PKG_CONFIG_PATH
281        FOREACH(dir ${cmake_install_libdirs})
282                IF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
283                        SET( ENV{PKG_CONFIG_PATH} ${ipopt_prefix}/${dir}/pkgconfig )
284                ENDIF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
285        ENDFOREACH(dir)
286        #
287        # pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
288        # ipopt_LIBRARIES      ... only the libraries (w/o the '-l')
289        # ipopt_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
290        pkg_check_modules(ipopt ipopt)
291        IF( NOT ipopt_FOUND )
292                MESSAGE(FATAL_ERROR
293"For all directories dir in cmake_install_libdirs, cannot find the file
294        ipopt_prefix/dir/pkgconfig/ipopt.pc
295where
296        ipopt_prefix = ${ipopt_prefix}
297        cmake_install_libdirs = ${cmake_install_libdirs}
298"
299                )
300        ENDIF( NOT ipopt_FOUND )
301ENDIF( cppad_has_ipopt )
302# =============================================================================
303# Currently building tests as normal executables
304# =============================================================================
305# The CMakeLists.txt file in the specified source directory is processed
306# before the current input file continues beyond this command.
307# add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
308#
309# Initialize list of tests as empty
310SET(check_depends "")
311#
312# directories with no check depends entries
313ADD_SUBDIRECTORY(cppad)
314ADD_SUBDIRECTORY(pkgconfig)
315IF( cppad_has_colpack )
316        ADD_SUBDIRECTORY(cppad_lib)
317ENDIF( cppad_has_colpack )
318#
319IF( NOT ( "${check_depends}" STREQUAL "" ) )
320        MESSAGE(FATAL_ERROR "Error in CMakeLists.txt scripts")
321ENDIF( NOT ( "${check_depends}" STREQUAL "" ) )
322#
323# directories with check depends entries
324ADD_SUBDIRECTORY(example)
325ADD_SUBDIRECTORY(introduction)
326ADD_SUBDIRECTORY(test_more)
327ADD_SUBDIRECTORY(speed)
328IF( cppad_has_ipopt )
329        ADD_SUBDIRECTORY(cppad_ipopt)
330ENDIF( cppad_has_ipopt )
331#
332ADD_CUSTOM_TARGET(check DEPENDS ${check_depends})
333MESSAGE(STATUS "make check: avialable")
334# ============================================================================
335# Copy a file to another location and modify its contents.
336# configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY])
337CONFIGURE_FILE(
338        ${CMAKE_CURRENT_SOURCE_DIR}/bin/test_one.sh.in
339        ${CMAKE_CURRENT_SOURCE_DIR}/bin/test_one.sh
340)
341# =============================================================================
342# install procedure
343# =============================================================================
344# install(DIRECTORY dirs... DESTINATION <dir>
345#       [FILE_PERMISSIONS permissions...]
346#       [DIRECTORY_PERMISSIONS permissions...]
347#       [USE_SOURCE_PERMISSIONS] [OPTIONAL]
348#       [CONFIGURATIONS [Debug|Release|...]]
349#       [COMPONENT <component>] [FILES_MATCHING]
350#       [[PATTERN <pattern> | REGEX <regex>]
351#       [EXCLUDE] [PERMISSIONS permissions...]] [...]
352# )
353# Note a trailing / in the source directory name drops the source directory
354# name during the copy.
355#
356# During install copy all the cppad include files to
357# ${cppad_abs_includedir}/cppad
358INSTALL(
359        DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/"
360        DESTINATION ${cppad_abs_includedir}/cppad
361        FILES_MATCHING PATTERN "*.hpp"
362)
363#
364# During install copy doc direcrory to cppad_abs_docdir/cppad
365IF ( cmake_install_docdir )
366        INSTALL( DIRECTORY "doc/" DESTINATION ${cppad_abs_docdir}/cppad )
367ENDIF ( cmake_install_docdir )
368#
369IF( ${cppad_deprecated} )
370        STRING( TOLOWER "${cppad_deprecated}" temp )
371        IF( "${temp}" STREQUAL "yes" )
372                MESSAGE(FATAL_ERROR
373                "cppad_deprecated = YES has been removed; see whats_new 2017-02-10."
374                )
375        ENDIF( "${temp}" STREQUAL "yes" )
376        MESSAGE(FATAL_ERROR
377                "cppad_deprecated = ${cppad_deprecated} not a valid choice"
378        )
379ENDIF( ${cppad_deprecated} )
Note: See TracBrowser for help on using the repository browser.