source: trunk/CMakeLists.txt @ 3320

Last change on this file since 3320 was 3320, checked in by bradbell, 6 years ago
  1. g++ 4.8.2 has shadow warnings by default, but eigen and fadbad do not

these warnings, so supress then in these cases.

  1. Move check that arguments come before result into on place,

CPPAD_ASSERT_ARG_BEFORE_RESULT (only one argument case so far).

main.cpp: fix shadowing of index variable.
CMakeLists.txt: adapt to change in teuchos library name.
sparse_jacobian.cpp: fix a shadowed variable.
check_svn_id.sh: ignore svn_commit.sh.
gpl_license.sh: ignore svn_commit.sh.

  • Property svn:keywords set to Id
File size: 13.4 KB
RevLine 
[2512]1# $Id: CMakeLists.txt 3320 2014-09-11 23:06:21Z bradbell $
2# -----------------------------------------------------------------------------
[3088]3# CppAD: C++ Algorithmic Differentiation: Copyright (C) 2003-14 Bradley M. Bell
[2512]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# -----------------------------------------------------------------------------
[2683]12# =============================================================================
[2594]13# Some constants
[2683]14# =============================================================================
[2594]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.
[2897]19SET(cppad_version      "20130918" )
[2594]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
[2770]29# Add this directory to the list of C++ preprocessor include directories
30# for the entire project.
[2594]31# include_directories([AFTER|BEFORE] [SYSTEM] dir1 dir2 ...)
32INCLUDE_DIRECTORIES( ${cppad_SOURCE_DIR} )
[2770]33
34
35
[2683]36# =============================================================================
[2770]37# Some system cmake language extensions
[2683]38# =============================================================================
[2550]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)
[2770]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)
[2683]54#
[2770]55# command_line_arg(variable default type description)
56INCLUDE(cmake/command_line_arg.cmake)
[2553]57#
[2771]58# optional_package(prefix_variable description)
59INCLUDE(cmake/optional_package.cmake)
[2563]60#
[2772]61# add_cppad_cxx_flags(target_name)
62INCLUDE(cmake/add_cppad_cxx_flags.cmake)
[3118]63#
64# sources_libs_define(prefix_name sources libs define)
65INCLUDE(cmake/sources_libs_define.cmake)
[2683]66# =============================================================================
[2553]67# command line arguments
[2683]68# =============================================================================
[2553]69# cmake_install_datadir
70command_line_arg(cmake_install_datadir share STRING
[2592]71        "directory, below prefix, where cmake installs cppad data files"
[2553]72)
[2683]73# -----------------------------------------------------------------------------
[3089]74# cmake_install_docdir
75command_line_arg(cmake_install_docdir "" STRING
76        "directory, below prefix, where cmake installs cppad documentation files"
77)
78# -----------------------------------------------------------------------------
[2592]79# cmake_install_includedirs
80command_line_arg(cmake_install_includedirs include STRING
81        "directories, below prefix, where cmake installs include files"
[2553]82)
[2683]83# -----------------------------------------------------------------------------
[2592]84# cmake_install_libdirs
85command_line_arg(cmake_install_libdirs lib STRING
86        "directories, below prefix, where cmake installs library files"
[2553]87)
[2683]88# -----------------------------------------------------------------------------
89# cmake_install_prefix
[2568]90command_line_arg(cmake_install_prefix /usr PATH
[2553]91        "cppad install prefix"
92)
[2568]93SET(CMAKE_INSTALL_PREFIX "${cmake_install_prefix}"
94        CACHE PATH "value copied from cmake_install_prefix" FORCE
[2534]95)
[2683]96# -----------------------------------------------------------------------------
97# cmake_install_postfix
[2568]98command_line_arg(cmake_install_postfix NOTFOUND STRING
[2553]99        "cppad install postfix"
100)
[2683]101# -----------------------------------------------------------------------------
[2752]102# cppad_cxx_flags
103command_line_arg(cppad_cxx_flags NOTFOUND STRING
[2762]104        "extra flags used with cppad source (besides debug and release flags)"
[2752]105)
106# -----------------------------------------------------------------------------
[2683]107# cppad_documentation
[3089]108command_line_arg(cppad_documentation "" STRING
109        "install cppad documentation: use camke_install_docdir instead"
[2560]110)
[3089]111STRING(COMPARE NOTEQUAL "${cppad_documentation}" "" cppad_documentation_error)
112IF( cppad_documentation_error )
113        MESSAGE(FATAL_ERROR
114"cppad_documentation is no longer an option, use cmake_install_docdir instead"
115        )
116ENDIF( cppad_documentation_error )
[2683]117# -----------------------------------------------------------------------------
[2534]118# External package prefixes
119#
[2516]120# adolc_prefix
[2520]121optional_package(adolc_prefix "adolc install prefix")
[2550]122#
[3116]123# colpack_prefix
124optional_package(colpack_prefix "colpack install prefix")
125#
[2520]126# eigen_prefix
127optional_package(eigen_prefix "eigen install prefix")
[2550]128#
[2527]129# fadbad_prefix
130optional_package(fadbad_prefix "fadbad install prefix")
[2550]131#
[2522]132# ipopt_prefix
133optional_package(ipopt_prefix "ipopt install prefix")
[2550]134#
[2527]135# sacado_prefix
136optional_package(sacado_prefix "sacado install prefix")
[3116]137# -----------------------------------------------------------------------------
138# cppad_has_colpack
139#
140IF( colpack_prefix )
141        SET(cppad_has_colpack 1)
142ELSE( colpack_prefix )
143        SET(cppad_has_colpack 0)
144ENDIF( colpack_prefix )
[2683]145# =============================================================================
[2513]146# automated system configuration
[2683]147# =============================================================================
[2592]148# cppad_install_includedir
149SET(cppad_install_includedir NOTFOUND)
150FOREACH(dir ${cmake_install_includedirs})
151        IF( NOT cppad_install_includedir )
152                SET(cppad_install_includedir ${dir})
153        ENDIF( NOT cppad_install_includedir )
154ENDFOREACH(dir ${cmake_install_includedirs})
[2683]155# -----------------------------------------------------------------------------
[2592]156# cppad_install_libdir
157SET(cppad_install_libdir NOTFOUND)
158FOREACH(dir ${cmake_install_libdirs})
159        IF( NOT cppad_install_libdir )
160                SET(cppad_install_libdir ${dir})
161        ENDIF( NOT cppad_install_libdir )
162ENDFOREACH(dir ${cmake_install_libdirs})
[2683]163# -----------------------------------------------------------------------------
[2765]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.*" )
170MESSAGE(STATUS "cppad_cxx_flags_sacado = ${cppad_cxx_flags_sacado}")
[2762]171# -----------------------------------------------------------------------------
[2772]172# cppad_cxx_flags_skip_eigen
[2561]173STRING(REGEX REPLACE
[3320]174        "(.*)-Wshadow(.*)"         "\\1-Wno-shadow\\2"
[2772]175        cppad_cxx_flags_eigen "${cppad_cxx_flags}"
[2561]176)
[2772]177MESSAGE(STATUS "cppad_cxx_flags_eigen = ${cppad_cxx_flags_eigen}")
[2683]178# -----------------------------------------------------------------------------
[2772]179# cppad_cxx_flags_skip_fadbad
180STRING(REGEX REPLACE
[3320]181        "(.*)-Wshadow(.*)"         "\\1-Wno-shadow\\2"
[2772]182        cppad_cxx_flags_fadbad "${cppad_cxx_flags}"
183)
184MESSAGE(STATUS "cppad_cxx_flags_fadbad = ${cppad_cxx_flags_fadbad}")
185# -----------------------------------------------------------------------------
[2595]186# cppad_abs_includedir, cppad_abs_libdir, cppad_abs_datadir, cppad_abs_docdir
[3089]187#
188# cppad_abs_docdir is not used if cmake_install_docdir is ""
189#
[2568]190IF ( cmake_install_postfix )
[2595]191        SET(cppad_abs_includedir
[2592]192"${cmake_install_prefix}/${cppad_install_includedir}/${cmake_install_postfix}"
[2532]193                CACHE INTERNAL "cppad install include file directory" FORCE
194        )
[2595]195        SET(cppad_abs_libdir
196"${cmake_install_prefix}/${cppad_install_libdir}/${cmake_install_postfix}"
[2564]197                CACHE INTERNAL "cppad install library file directory" FORCE
198        )
[2595]199        SET(cppad_abs_datadir
[2568]200"${cmake_install_prefix}/${cmake_install_datadir}/${cmake_install_postfix}"
[2560]201                CACHE INTERNAL "cppad install data file directory" FORCE
202        )
[2595]203        SET(cppad_abs_docdir
[3089]204"${cmake_install_prefix}/${cmake_install_docdir}/${cmake_install_postfix}"
[2560]205                CACHE INTERNAL "cppad install data file directory" FORCE
206        )
[2568]207ELSE ( cmake_install_postfix )
[2595]208        SET(cppad_abs_includedir
[2592]209                "${cmake_install_prefix}/${cppad_install_includedir}"
[2564]210                CACHE INTERNAL "cppad install include file directory" FORCE
[2532]211        )
[2595]212        SET(cppad_abs_libdir
213                "${cmake_install_prefix}/${cppad_install_libdir}"
[2564]214                CACHE INTERNAL "cppad install library file directory" FORCE
215        )
[2595]216        SET(cppad_abs_datadir
[2568]217                "${cmake_install_prefix}/${cmake_install_datadir}"
[2564]218                CACHE INTERNAL "cppad install data file directory" FORCE
[2532]219        )
[2595]220        SET(cppad_abs_docdir
[3089]221                "${cmake_install_prefix}/${cmake_install_docdir}"
[2564]222                CACHE INTERNAL "cppad install data file directory" FORCE
[2560]223        )
[2568]224ENDIF ( cmake_install_postfix )
[2683]225# -----------------------------------------------------------------------------
226# boost_prefix
227FIND_PACKAGE(Boost)
228IF ( Boost_FOUND )
229        # Extract the Boost prefix from Boost_INCLUDE_DIRS
230        #
231        # convert to using unix directory separator
232        dos_path_to_unix("${Boost_INCLUDE_DIRS}" boost_include_dirs)
233        #
234        # convert to just one directory
235        STRING(REGEX REPLACE
236                "([^ ]+).*" "\\1"
237                boost_include_dir "${boost_include_dirs}"
238        )
239        #
240        # extract part before last backslash
241        STRING(REGEX REPLACE
242                "([^ ]*)/[^/ ]*" "\\1"
243                boost_prefix "${boost_include_dir}"
244        )
245        MESSAGE(STATUS "boost_prefix = ${boost_prefix}")
246        #
247        # add boost include directories
248        FOREACH(dir ${cmake_install_includedirs})
249                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
250                        INCLUDE_DIRECTORIES( ${boost_prefix}/${dir} )
251                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
252                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
253        ENDFOREACH( dir )
254        #
255        # add boost link directories
256        FOREACH(dir ${cmake_install_libdirs})
257                IF( IS_DIRECTORY ${boost_prefix}/${dir} )
258                        LINK_DIRECTORIES( ${boost_prefix}/${dir} )
259                        MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
260                ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
261        ENDFOREACH( dir )
262ENDIF ( Boost_FOUND )
263# -----------------------------------------------------------------------------
264# ipopt_LIBRARIES and ipopt_LIBRARY_DIRS
265IF( ipopt_prefix )
266        FIND_PACKAGE(PkgConfig)
267        IF( NOT PKG_CONFIG_FOUND )
268                MESSAGE(FATAL_ERROR "Using ipopt_prefix but cannot find pkg-config")
269        ENDIF( NOT PKG_CONFIG_FOUND )
270        #
271        # Set the system environment variable PKG_CONFIG_PATH
272        FOREACH(dir ${cmake_install_libdirs})
273                IF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
274                        SET( ENV{PKG_CONFIG_PATH} ${ipopt_prefix}/${dir}/pkgconfig )
275                ENDIF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
276        ENDFOREACH(dir)
277        #
278        # pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
279        # ipopt_LIBRARIES      ... only the libraries (w/o the '-l')
280        # ipopt_LIBRARY_DIRS   ... the paths of the libraries (w/o the '-L')
281        pkg_check_modules(ipopt ipopt)
282        IF( NOT ipopt_FOUND )
283                MESSAGE(FATAL_ERROR
284"For all directories dir in cmake_install_libdirs, cannot find the file
285        ipopt_prefix/dir/pkgconfig/ipopt.pc
286where
287        ipopt_prefix = ${ipopt_prefix}
288        cmake_install_libdirs = ${cmake_install_libdirs}
289"
290                )
291        ENDIF( NOT ipopt_FOUND )
292ENDIF( ipopt_prefix )
293# =============================================================================
[2525]294# Currently building tests as normal executables
[2683]295# =============================================================================
[2514]296# The CMakeLists.txt file in the specified source directory is processed
297# before the current input file continues beyond this command.
298# add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
[2534]299#
[2564]300# Initialize list of tests as empty
[3119]301SET(check_depends "")
[2564]302#
[2550]303ADD_SUBDIRECTORY(cppad)
[2564]304ADD_SUBDIRECTORY(pkgconfig)
305#
[2580]306ADD_SUBDIRECTORY(compare_c)
[3119]307add_to_list(check_depends check_compare_c)
[2580]308#
[2514]309ADD_SUBDIRECTORY(example)
[3119]310add_to_list(check_depends check_example)
[2564]311#
[2683]312ADD_SUBDIRECTORY(introduction)
[3119]313add_to_list(check_depends check_introduction)
[2683]314#
[2518]315ADD_SUBDIRECTORY(print_for)
[3119]316add_to_list(check_depends check_print_for)
[2564]317#
[2519]318ADD_SUBDIRECTORY(test_more)
[3119]319add_to_list(check_depends check_test_more)
[2564]320#
321ADD_SUBDIRECTORY(multi_thread)
[3119]322add_to_list(check_depends check_multi_thread)
[2564]323#
[2526]324ADD_SUBDIRECTORY(speed)
[3119]325add_to_list(check_depends check_speed)
[2564]326#
[2522]327IF ( ipopt_prefix )
[2525]328        ADD_SUBDIRECTORY(cppad_ipopt)
[3119]329        add_to_list(check_depends check_cppad_ipopt)
[2522]330ENDIF( ipopt_prefix )
[2534]331#
[3119]332ADD_CUSTOM_TARGET(check DEPENDS ${check_depends})
[2534]333#
[2683]334# =============================================================================
[2513]335# install procedure
[2683]336# =============================================================================
[2511]337# install(DIRECTORY dirs... DESTINATION <dir>
338#       [FILE_PERMISSIONS permissions...]
339#       [DIRECTORY_PERMISSIONS permissions...]
340#       [USE_SOURCE_PERMISSIONS] [OPTIONAL]
341#       [CONFIGURATIONS [Debug|Release|...]]
342#       [COMPONENT <component>] [FILES_MATCHING]
343#       [[PATTERN <pattern> | REGEX <regex>]
344#       [EXCLUDE] [PERMISSIONS permissions...]] [...]
345# )
[2560]346# Note a trailing / in the source directory name drops the source directory
347# name during the copy.
348#
[3309]349# During install copy all the cppad include files to
[2614]350# ${cppad_abs_includedir}/cppad 
351INSTALL(
352        DIRECTORY "cppad/"
353        DESTINATION ${cppad_abs_includedir}/cppad
354        FILES_MATCHING PATTERN "*.h"
355)
356INSTALL(
357        DIRECTORY "cppad/"
358        DESTINATION ${cppad_abs_includedir}/cppad
359        FILES_MATCHING PATTERN "*.hpp"
360)
[3116]361INSTALL(
[3309]362        FILES "cppad/local/cppad_colpack.cpp"
363        DESTINATION ${cppad_abs_datadir}/cppad
[3116]364)
[2560]365#
[3088]366# During install copy doc direcrory to cppad_abs_docdir/cppad
[3089]367STRING( COMPARE NOTEQUAL "${cmake_install_docdir}" "" cppad_documentation )
[2560]368IF ( cppad_documentation )
[3088]369        INSTALL( DIRECTORY "doc/" DESTINATION ${cppad_abs_docdir}/cppad )
[2560]370ENDIF ( cppad_documentation )
Note: See TracBrowser for help on using the repository browser.