source: trunk/CMakeLists.txt @ 3788

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

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: c4559d5e01e1b0f09943490dd84449557eced25d
end hash code: 431e0a227dbfe6172d265d9d79a2b5b258c5bc18

commit 431e0a227dbfe6172d265d9d79a2b5b258c5bc18
Author: Brad Bell <bradbell@…>
Date: Tue Feb 9 07:41:29 2016 -0700

  1. Change package.sh to automatically update version on (master branch only).
  2. Change version.sh copy to check and change.

commit a14455414810cfe3c3e4bca90090defc2528a353
Author: Brad Bell <bradbell@…>
Date: Tue Feb 9 06:19:54 2016 -0700

Change check_verbatim to check_srcfile
because all but one of the verbatim commands were changed to srcfile commands.


check_include_omh.sh: old check that file names did not change case (for cygwin development).

commit 4ce45b796b57629332ab46d8ae6df94e0a1ed998
Author: Brad Bell <bradbell@…>
Date: Tue Feb 9 06:04:57 2016 -0700

batch_edit.sh to change $verbatim and $codep to $srcfile and $srccode.


det_by_minor.c: remove some invisible white space.

commit 56553b88c9623c30d2222425a9640b95ce4c8281
Author: Brad Bell <bradbell@…>
Date: Mon Feb 8 18:01:49 2016 -0700

check_jenkins.sh: jenkins.sh no longer takes an argument.
jenkins.sh: fix name of script in error message.

commit 3b8a208cfc7e8ef3c928c17eb291aa3b90ff0050
Author: Brad Bell <bradbell@…>
Date: Mon Feb 8 07:57:02 2016 -0700

new_release.sh: track branches in comments, back to master at OK end, first check of response.

commit 442b7cbc45c022776e8257d3c3404dccdd06c420
Author: Brad Bell <bradbell@…>
Date: Mon Feb 8 06:01:11 2016 -0700

  1. Advance to release 20160000.1.
  2. Check using master version of new_release.sh.
  3. Make sure auto-tools version up to date.
  4. Ask user if doing further testing before commiting new release.

commit f7bdd1f48e72feb05d604da63914022809f45c28
Author: Brad Bell <bradbell@…>
Date: Sun Feb 7 07:59:41 2016 -0700

Add shared library version number to cppad_lib; i.e., cppad_lib.yyyy.mmdd.rel

commit a4c716552e3ad05b337aea58b643c9ad1cbcd4ac
Author: Brad Bell <bradbell@…>
Date: Sun Feb 7 05:25:39 2016 -0700

Make cppad_lib libarary conditional on colpack_prefix being specified.

commit 5e8890eb8de8b0cde146a6ed59c391d7c355ff24
Author: Brad Bell <bradbell@…>
Date: Tue Jan 26 10:49:37 2016 -0700

vector.hpp: fix The -> This.

commit e4e5442b069d7b00e197c31616da32eee20460b3
Merge: c4559d5 ed28b89
Author: Brad Bell <bradbell@…>
Date: Tue Jan 26 09:47:58 2016 -0700

Merge pull request #14 from barak/master


fix spelling in description of cppad_profile_flag on cmake command line

commit ed28b899c9fedab52a578aa7dd73818638081fe6
Author: Barak A. Pearlmutter <barak+git@…>
Date: Tue Jan 26 16:24:32 2016 +0000

typo

  • Property svn:keywords set to Id
File size: 12.8 KB
Line 
1# $Id: CMakeLists.txt 3788 2016-02-09 15:50:06Z 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      "20160209" )
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
127#
128# adolc_prefix
129optional_package(adolc_prefix "adolc install prefix")
130#
131# colpack_prefix
132optional_package(colpack_prefix "colpack install prefix")
133#
134# eigen_prefix
135optional_package(eigen_prefix "eigen install prefix")
136#
137# fadbad_prefix
138optional_package(fadbad_prefix "fadbad install prefix")
139#
140# ipopt_prefix
141optional_package(ipopt_prefix "ipopt install prefix")
142#
143# sacado_prefix
144optional_package(sacado_prefix "sacado install prefix")
145# -----------------------------------------------------------------------------
146# cppad_has_colpack, colpack_libs, cppad_lib
147#
148IF( colpack_prefix )
149        SET(cppad_has_colpack 1)
150        SET( colpack_libs "ColPack" )
151        SET( cppad_lib "cppad_lib" )
152ELSE( colpack_prefix )
153        SET(cppad_has_colpack 0)
154        SET( colpack_libs "" )
155        SET( cppad_lib "" )
156ENDIF( colpack_prefix )
157# =============================================================================
158# automated system configuration
159# =============================================================================
160# cppad_cxx_flags_sacado
161IF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" )
162        SET(cppad_cxx_flags_sacado "${cppad_cxx_flags} -D HAS_C99_TR1_CMATH" )
163ELSE( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" )
164        SET(cppad_cxx_flags_sacado ${cppad_cxx_flags} )
165ENDIF( ${cppad_cxx_flags} MATCHES ".*-std=c[+][+]11.*" )
166IF( sacado_prefix )
167        MESSAGE(STATUS "cppad_cxx_flags_sacado = ${cppad_cxx_flags_sacado}")
168ENDIF( sacado_prefix )
169# -----------------------------------------------------------------------------
170# cppad_cxx_flags_eigen
171STRING(REGEX REPLACE
172        "(.*)-Wshadow(.*)"         "\\1-Wno-shadow -Wno-deprecated-declarations\\2"
173        cppad_cxx_flags_eigen "${cppad_cxx_flags}"
174)
175IF( eigen_prefix )
176        MESSAGE(STATUS "cppad_cxx_flags_eigen = ${cppad_cxx_flags_eigen}")
177ENDIF( eigen_prefix )
178# -----------------------------------------------------------------------------
179# cppad_cxx_flags_fadbad
180STRING(REGEX REPLACE
181        "(.*)-Wshadow(.*)"         "\\1-Wno-shadow\\2"
182        cppad_cxx_flags_fadbad "${cppad_cxx_flags}"
183)
184IF( fadbad_prefix )
185        MESSAGE(STATUS "cppad_cxx_flags_fadbad = ${cppad_cxx_flags_fadbad}")
186ENDIF( fadbad_prefix )
187# -----------------------------------------------------------------------------
188# CMAKE_CXX_FLAGS
189# remove Visual Studio C++ warning level if specified in cppad_cxx_flags
190IF ( cppad_cxx_flags MATCHES "/W[0-9]" )
191        STRING( REGEX REPLACE "/W[0-9]" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
192ENDIF ( cppad_cxx_flags MATCHES "/W[0-9]" )
193MESSAGE(STATUS "CMAKE_CXX_FLAGS = ${CMAKE_CXX_FLAGS}")
194# -----------------------------------------------------------------------------
195# set cppad_abs_${middle_name} for middle_name equal to:
196#       includedir, liddir, datadir, docdir
197FOREACH(middle_names includedirs libdirs datadir docdir)
198        STRING(REGEX REPLACE "dirs" "dir" middle_name ${middle_names})
199        SET(middle_value NOTFOUND)
200        FOREACH(dir ${cmake_install_${middle_names}})
201                IF( NOT middle_value )
202                        SET(middle_value ${dir})
203                ENDIF( NOT middle_value )
204        ENDFOREACH(dir ${cmake_install_${middle_names}})
205        #
206        SET(tmp "${cppad_prefix}/${middle_value}" )
207        IF ( cppad_postfix )
208                SET(cppad_abs_${middle_name} ${tmp}/${cppad_postfix})
209        ELSE ( cppad_postfix )
210                SET(cppad_abs_${middle_name} ${tmp})
211        ENDIF ( cppad_postfix )
212ENDFOREACH(middle_names includedirs libdirs datadir docdir)
213# -----------------------------------------------------------------------------
214# boost_prefix
215FIND_PACKAGE(Boost)
216IF ( Boost_FOUND )
217        # Extract the Boost prefix from Boost_INCLUDE_DIRS
218        #
219        # convert to using unix directory separator
220        dos_path_to_unix("${Boost_INCLUDE_DIRS}" boost_include_dirs)
221        #
222        # convert to just one directory
223        STRING(REGEX REPLACE
224                "([^ ]+).*" "\\1"
225                boost_include_dir "${boost_include_dirs}"
226        )
227        #
228        # extract part before last backslash
229        STRING(REGEX REPLACE
230                "([^ ]*)/[^/ ]*" "\\1"
231                boost_prefix "${boost_include_dir}"
232        )
233        MESSAGE(STATUS "boost_prefix = ${boost_prefix}")
234        #
235        # add boost include directories
236        FOREACH(dir ${cmake_install_includedirs})
237                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
238                        INCLUDE_DIRECTORIES( ${boost_prefix}/${dir} )
239                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
240                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
241        ENDFOREACH( dir )
242        #
243        # add boost link directories
244        FOREACH(dir ${cmake_install_libdirs})
245                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
246                        LINK_DIRECTORIES( ${boost_prefix}/${dir} )
247                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
248                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
249        ENDFOREACH( dir )
250ENDIF ( Boost_FOUND )
251# -----------------------------------------------------------------------------
252# ipopt_LIBRARIES and ipopt_LIBRARY_DIRS
253IF( ipopt_prefix )
254        FIND_PACKAGE(PkgConfig)
255        IF( NOT PKG_CONFIG_FOUND )
256                MESSAGE(FATAL_ERROR "Using ipopt_prefix but cannot find pkg-config")
257        ENDIF( NOT PKG_CONFIG_FOUND )
258        #
259        # Set the system environment variable PKG_CONFIG_PATH
260        FOREACH(dir ${cmake_install_libdirs})
261                IF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
262                        SET( ENV{PKG_CONFIG_PATH} ${ipopt_prefix}/${dir}/pkgconfig )
263                ENDIF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
264        ENDFOREACH(dir)
265        #
266        # pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
267        # ipopt_LIBRARIES      ... only the libraries (w/o the '-l')
268        # ipopt_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
269        pkg_check_modules(ipopt ipopt)
270        IF( NOT ipopt_FOUND )
271                MESSAGE(FATAL_ERROR
272"For all directories dir in cmake_install_libdirs, cannot find the file
273        ipopt_prefix/dir/pkgconfig/ipopt.pc
274where
275        ipopt_prefix = ${ipopt_prefix}
276        cmake_install_libdirs = ${cmake_install_libdirs}
277"
278                )
279        ENDIF( NOT ipopt_FOUND )
280ENDIF( ipopt_prefix )
281# =============================================================================
282# Currently building tests as normal executables
283# =============================================================================
284# The CMakeLists.txt file in the specified source directory is processed
285# before the current input file continues beyond this command.
286# add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
287#
288# Initialize list of tests as empty
289SET(check_depends "")
290#
291ADD_SUBDIRECTORY(cppad)
292ADD_SUBDIRECTORY(pkgconfig)
293IF( colpack_prefix )
294        ADD_SUBDIRECTORY(cppad_lib)
295ENDIF( colpack_prefix)
296#
297ADD_SUBDIRECTORY(compare_c)
298add_to_list(check_depends check_compare_c)
299#
300ADD_SUBDIRECTORY(example)
301add_to_list(check_depends check_example)
302#
303ADD_SUBDIRECTORY(introduction)
304add_to_list(check_depends check_introduction)
305#
306ADD_SUBDIRECTORY(print_for)
307add_to_list(check_depends check_print_for)
308#
309ADD_SUBDIRECTORY(test_more)
310add_to_list(check_depends check_test_more)
311#
312ADD_SUBDIRECTORY(multi_thread)
313add_to_list(check_depends check_multi_thread)
314#
315ADD_SUBDIRECTORY(speed)
316add_to_list(check_depends check_speed)
317#
318IF ( ipopt_prefix )
319        ADD_SUBDIRECTORY(cppad_ipopt)
320        add_to_list(check_depends check_cppad_ipopt)
321ENDIF( ipopt_prefix )
322#
323ADD_CUSTOM_TARGET(check DEPENDS ${check_depends})
324#
325# =============================================================================
326# install procedure
327# =============================================================================
328# install(DIRECTORY dirs... DESTINATION <dir>
329#       [FILE_PERMISSIONS permissions...]
330#       [DIRECTORY_PERMISSIONS permissions...]
331#       [USE_SOURCE_PERMISSIONS] [OPTIONAL]
332#       [CONFIGURATIONS [Debug|Release|...]]
333#       [COMPONENT <component>] [FILES_MATCHING]
334#       [[PATTERN <pattern> | REGEX <regex>]
335#       [EXCLUDE] [PERMISSIONS permissions...]] [...]
336# )
337# Note a trailing / in the source directory name drops the source directory
338# name during the copy.
339#
340# During install copy all the cppad include files to
341# ${cppad_abs_includedir}/cppad
342INSTALL(
343        DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/"
344        DESTINATION ${cppad_abs_includedir}/cppad
345        FILES_MATCHING PATTERN "*.hpp"
346)
347#
348# During install copy doc direcrory to cppad_abs_docdir/cppad
349IF ( cmake_install_docdir )
350        INSTALL( DIRECTORY "doc/" DESTINATION ${cppad_abs_docdir}/cppad )
351ENDIF ( cmake_install_docdir )
352#
353IF( ${cppad_deprecated} )
354        # During install copy deprecated include files
355        INSTALL(
356                DIRECTORY "${CMAKE_SOURCE_DIR}/cppad/deprecated/"
357                DESTINATION ${cppad_abs_includedir}/cppad
358        )
359ENDIF( ${cppad_deprecated} )
Note: See TracBrowser for help on using the repository browser.