1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712
|
# SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
# SPDX-FileCopyrightText: Bradley M. Bell <bradbell@seanet.com>
# SPDX-FileContributor: 2003-26 Bradley M. Bell
# ----------------------------------------------------------------------------
# =============================================================================
# Some constants
# =============================================================================
#
# Set the minimum required version of cmake for this project.
# see https://cmake.org//pipermail/cmake/2013-January/053213.html
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
#
# Use the version of BoostConfig.cmake provided by boost.
IF( POLICY CMP0167 )
CMAKE_POLICY(SET CMP0167 NEW)
ENDIF( POLICY CMP0167 )
#
# Only interpret if() arguments as variables or keywords when unquoted.
IF( POLICY CMP0054 )
CMAKE_POLICY(SET CMP0054 NEW)
ENDIF( POLICY CMP0054 )
#
# cppad_version is used by version.sh to get the version number.
SET(cppad_version "20260000.0")
SET(cppad_url "https://coin-or.github.io/CppAD" )
SET(cppad_description "Differentiation of C++ Algorithms" )
IF( NOT DEFINED CMAKE_BUILD_TYPE)
SET(CMAKE_BUILD_TYPE "NOTFOUND")
ENDIF( NOT DEFINED CMAKE_BUILD_TYPE)
#
# Set name of this project and create the variables
# cppad_BINARY_DIR and cppad_SOURCE_DIR.
# project(projectname [CXX] [C] [Java])
PROJECT(cppad)
#
# Add the include sub-directory to the list of C++ preprocessor
# include directories for the entire project. The SYSTEM flag is not included
# so warnings will be geenreated for this directory.
INCLUDE_DIRECTORIES( ${cppad_SOURCE_DIR}/include )
#
# =============================================================================
# Some system cmake language extensions
# =============================================================================
# CHECK_CXX_SOURCE_COMPILES(source variable)
# Checks whether the code given in source will compile, link and run and
# return zero status. You can set
# CMAKE_REQUIRED_LIBRARIES, CMAKE_REQUIRED_FLAGS and CMAKE_REQUIRED_INCLUDES
# accordingly if additional libraries or compiler flags are required.
INCLUDE(CheckCXXSourceCompiles)
# ============================================================================
# Some local cmake language
# ============================================================================
# assert_value_in_set(value element_1 ... element_n)
INCLUDE(cmake/assert_value_in_set.cmake)
#
# dos_path_to_unix(dos_path unix_path)
INCLUDE(cmake/dos_path_to_unix.cmake)
#
# add_to_list(variable_list constant_value)
INCLUDE(cmake/add_to_list.cmake)
#
# command_line_arg(variable default type description)
INCLUDE(cmake/command_line_arg.cmake)
#
# prefix_info(package description)
INCLUDE(cmake/prefix_info.cmake)
#
# compile_source_test(source variable)
INCLUDE(cmake/compile_source_test.cmake)
#
# assert(variable)
INCLUDE(cmake/assert.cmake)
#
# print_variable(variable)
INCLUDE(cmake/print_variable.cmake)
#
# set_compile_flags( program_name debug_which source_list)
INCLUDE(cmake/set_compile_flags.cmake)
#
# pkgconfig_info(name, system)
INCLUDE(cmake/pkgconfig_info.cmake)
#
# eigen_info()
INCLUDE(cmake/eigen_info.cmake)
#
# add_check_executable(parent_target short_name)
INCLUDE(cmake/add_check_executable.cmake)
# =============================================================================
# command line arguments
# =============================================================================
# Arguments that are no longer used
#
IF( debug_which )
MESSAGE(FATAL_ERROR
"Using debug_which, use cppad_debug_which or CMAKE_BUILD_TYPE instead"
)
ENDIF( debug_which )
#
IF( cppad_sparse_list )
MESSAGE(FATAL_ERROR
"cppad_sparse_list has been removed from cmake command"
)
ENDIF( cppad_sparse_list )
#
IF( cppad_deprecated )
MESSAGE(FATAL_ERROR "cppad_deprecated has been removed from cmake command" )
ENDIF( cppad_deprecated )
#
IF( cmake_install_prefix )
MESSAGE(FATAL_ERROR
"cmake_install_prefix has been changed to cppad_prefix"
)
ENDIF( cmake_install_prefix )
#
IF( cmake_install_postfix )
MESSAGE(FATAL_ERROR
"cmake_install_postfix has been changed to cppad_postfix"
)
ENDIF( cmake_install_postfix )
#
FOREACH(pkg adolc eigen ipopt cppadcg)
IF( ${pkg}_prefix )
MESSAGE(FATAL_ERROR
"-D ${pkg}_prefix=value has been changed to -D include_${pkg}=true"
)
ENDIF( ${pkg}_prefix )
ENDFOREACH(pkg adolc eigen ipopt cppadcg)
#
IF( cmake_needs_dot_slash )
MESSAGE(FATAL_ERROR
"cmake_needs_dot_slash was removed; see release notes for 2023-06-01"
)
ENDIF( cmake_needs_dot_slash )
#
IF( include_eigen )
MESSAGE(FATAL_ERROR
"include_eigen was removed; see release notes for 2024-10-02"
)
ENDIF( )
# -----------------------------------------------------------------------------
# Current Arguments
#
# cmake_install_datadir
command_line_arg(cmake_install_datadir share STRING
"directory, below prefix, where cmake installs cppad data files"
)
#
# cmake_install_docdir
command_line_arg(cmake_install_docdir NOTFOUND STRING
"directory, below prefix, where cmake installs cppad documentation files"
)
#
# cmake_install_includedirs
command_line_arg(cmake_install_includedirs include STRING
"directories, below prefix, where cmake installs include files"
)
#
# cmake_install_libdirs
command_line_arg(cmake_install_libdirs "lib;lib64" STRING
"directories, below prefix, where cmake installs library files"
)
#
# cmake_defined_ok
command_line_arg(cmake_defined_ok TRUE BOOL
"If false, check that some symbols only get defined once"
"If true, you can use CMakeCache.txt to store previous settings"
)
#
# cppad_prefix
command_line_arg(cppad_prefix "${CMAKE_INSTALL_PREFIX}" PATH
"cppad install prefix"
)
#
# cppad_postfix
command_line_arg(cppad_postfix NOTFOUND STRING
"cppad install postfix"
)
#
# cppad_cxx_flags
command_line_arg(cppad_cxx_flags "" STRING
"compile flags used with cppad (besides debug, release, and profile flags)"
)
#
# cppad_link_flags
command_line_arg(cppad_link_flags "" STRING
"additional linker flags)"
)
#
# cppad_profile_flag
command_line_arg(cppad_profile_flag NOTFOUND STRING
"compile flag used to compile and link a profile version of a program"
)
#
# cppad_testvector
command_line_arg(cppad_testvector cppad STRING
"Namespace of vector used for testing, one of: boost, cppad, eigen, std"
)
assert_value_in_set(cppad_testvector boost cppad eigen std)
#
# cppad_max_num_threads
command_line_arg(cppad_max_num_threads 48 STRING
"maximum number of threads that CppAD can use use"
)
IF( "${cppad_max_num_threads}" LESS "4" )
MESSAGE(FATAL_ERROR
"cppad_max_num_threads is not an integer greater than or equal 4"
)
ENDIF( "${cppad_max_num_threads}" LESS "4" )
#
# cppad_tape_id_type
command_line_arg(cppad_tape_id_type "unsigned int" STRING
"type used to identify different tapes, size must be <= sizeof(size_t)"
)
#
# cppad_tape_addr_type
command_line_arg(cppad_tape_addr_type "unsigned int" STRING
"type used to identify variables on one tape, size must be <= sizeof(size_t)"
)
#
# cppad_debug_and_release
command_line_arg(cppad_debug_and_release TRUE BOOL
"If true the cppad library and tests will be able to mix debug and release"
)
#
# cppad_static_lib
STRING( REGEX MATCH "^MSYS" is_msys "${CMAKE_SYSTEM_NAME}" )
STRING( REGEX MATCH "^CYGWIN" is_cygwin "${CMAKE_SYSTEM_NAME}" )
STRING( REGEX MATCH "^Windows" is_windows "${CMAKE_SYSTEM_NAME}" )
IF( is_msys OR is_cygwin OR is_windows )
SET(default_cppad_static_lib TRUE)
ELSE( )
SET(default_cppad_static_lib FALSE)
ENDIF( )
#
# cppad_static_lib
command_line_arg(cppad_static_lib ${default_cppad_static_lib} BOOL
"If true (false) the cppad library will be static (shared)"
)
# ----------------------------------------------------------------------------
#
# Ensure c++11 support
SET(CMAKE_REQUIRED_DEFINITIONS "")
SET(CMAKE_REQUIRED_FLAGS "${cppad_cxx_flags}")
SET(CMAKE_REQUIRED_INCLUDES "")
SET(CMAKE_REQUIRED_LIBRARIES "")
SET(source "
int main(void)
{ static_assert( __cplusplus >= 201103 , \"c++11 is supported\" );
return 0;
}"
)
compile_source_test(${cmake_defined_ok} "${source}" minimal_cplusplus )
IF( NOT minimal_cplusplus )
MESSAGE(STATUS "setting C++ standard to 2011")
SET(CMAKE_CXX_STANDARD 11)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
ENDIF( NOT minimal_cplusplus )
#
# use_cplusplus_2014_ok
SET(source "
int main(void)
{ static_assert( __cplusplus >= 201302L , \"c++17 is supported\" );
return 0;
}"
)
compile_source_test(${cmake_defined_ok} "${source}" use_cplusplus_2014_ok )
#
# use_cplusplus_2017_ok
SET(source "
int main(void)
{ static_assert( __cplusplus >= 201703L , \"c++17 is supported\" );
return 0;
}"
)
compile_source_test(${cmake_defined_ok} "${source}" use_cplusplus_2017_ok )
# ----------------------------------------------------------------------------
#
# cppad_debug_and_release_01
IF (cppad_debug_and_release )
SET(cppad_debug_and_release_01 1 )
ELSE (cppad_debug_and_release )
SET(cppad_debug_and_release_01 0 )
ENDIF ( )
#
# cppad_debug_which
# CMAKE_BUILD_TYPE
SET(debug_even_or_odd FALSE)
IF( NOT ${cppad_debug_which} STREQUAL "" )
assert_value_in_set(
cppad_debug_which debug_even debug_odd debug_all debug_none
)
ENDIF( NOT ${cppad_debug_which} STREQUAL "" )
IF( CMAKE_BUILD_TYPE )
IF( NOT ${cppad_debug_which} STREQUAL "" )
print_variable(CMAKE_BUILD_TYPE)
print_variable(cppad_debug_which)
MESSAGE(FATAL_ERROR
"Both CMAKE_BUILD_TYPE and cppad_debug_which specified"
)
ENDIF( )
STRING( TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower )
IF(cmake_build_type_lower MATCHES debug)
SET(cppad_debug_which "debug_all")
ELSEIF(cmake_build_type_lower MATCHES release)
SET(cppad_debug_which "debug_none")
ELSEIF(cmake_build_type_lower MATCHES relwithdebInfo)
SET(cppad_debug_which "debug_none")
ELSEIF(cmake_build_type_lower MATCHES minsizerel)
SET(cppad_debug_which "debug_none")
ELSE( )
MESSAGE(FATAL_ERROR
"Unknown CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}"
)
ENDIF( )
ELSE( ) # CMAKE_BUILD_TYPE
IF( "${cppad_debug_which}" STREQUAL debug_all)
SET(CMAKE_BUILD_TYPE Debug)
ELSEIF( "${cppad_debug_which}" STREQUAL debug_none)
SET(CMAKE_BUILD_TYPE Release)
ELSEIF( "${cppad_debug_which}" STREQUAL debug_odd)
SET(CMAKE_BUILD_TYPE Debug)
SET(debug_even_or_odd TRUE)
ELSEIF( "${cppad_debug_which}" STREQUAL debug_even)
SET(CMAKE_BUILD_TYPE Release)
SET(debug_even_or_odd TRUE)
ENDIF( "${cppad_debug_which}" STREQUAL debug_all)
ENDIF( ) # CMAKE_BUILD_TYPE
IF( debug_even_or_odd )
IF ( NOT cppad_debug_and_release )
MESSAGE(FATAL_ERROR
"cppad_debug_and_release is false and cppad_debug_which = ${cppad_debug_which}"
)
ENDIF ( NOT cppad_debug_and_release )
IF( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
MESSAGE(FATAL_ERROR
"Cannot have cppad_debug_which equal ${cppad_debug_which} on Windows."
)
ENDIF( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" )
ENDIF( debug_even_or_odd )
print_variable(CMAKE_SYSTEM_NAME)
print_variable(cppad_debug_which)
print_variable(CMAKE_BUILD_TYPE)
MESSAGE(STATUS "make check: available")
# -----------------------------------------------------------------------------
# CMAKE_INSTALL_PREFIX
SET(CMAKE_INSTALL_PREFIX "${cppad_prefix}"
CACHE PATH "value copied from cppad_prefix" FORCE
)
# -----------------------------------------------------------------------------
# Optional package information
# cppad_has_{package}, {package}_LINK_LIBRARIES, package INCLUDE_DIRECTORIES
#
# system_include
SET(system_include TRUE)
#
# package = eigen
eigen_info()
#
# package = adolc
pkgconfig_info(adolc ${system_include})
#
# package = ipopt
pkgconfig_info(ipopt ${system_include})
#
# package = colpack
prefix_info(colpack ${system_include} )
#
# package = sacado
prefix_info(sacado ${system_include} )
#
# package = fadbad
prefix_info(fadbad ${system_include} )
#
# check sacado
IF( ${cppad_has_sacado} )
IF( NOT ${use_cplusplus_2017_ok} )
MESSAGE(FATAL_ERROR "sacado_prefix is defined but c++17 not supported")
ENDIF( )
ENDIF( )
#
# package = cppadcg
SET( include_cppadcg FALSE CACHE BOOL "include cppadcg" )
IF( include_cppadcg )
#
# cppad_has_cppadcg
SET(cppad_has_cppadcg 1)
#
# Assume bin/get_cppadcg.sh puts include files in this directory
SET(cppadcg_include_dir "${CMAKE_BINARY_DIR}/prefix/include" )
print_variable(cppadcg_include_dir)
INCLUDE_DIRECTORIES( SYSTEM ${cppadcg_include_dir})
ELSE( )
# cppad_has_cppadcg
SET(cppad_has_cppadcg 0)
ENDIF( include_cppadcg )
#
# package = xrst
SET( include_doc FALSE CACHE BOOL "include documentation")
IF( include_doc )
#
# xrst_path
FIND_PROGRAM( xrst_path xrst )
IF( "${xrst_path}" STREQUAL "xrst_path-NOTFOUND" )
MESSAGE(FATAL_ERROR
"include_doc is true and cannot find xrst in system path"
)
ENDIF( )
#
# processor_count
INCLUDE(ProcessorCount)
ProcessorCount(processor_count)
IF( processor_count EQUAL 0 )
SET(processor_count 1)
ENDIF( )
#
# see
# https://discourse.cmake.org/t/how-to-install-a-generated-directory/1267
#
# doc_dir
SET(doc_dir "${CMAKE_SOURCE_DIR}/build/html")
#
# doc_user
ADD_CUSTOM_TARGET(doc_user ALL
COMMAND xrst
--group_list default app
--local_toc
--html_theme sphinx_rtd_theme
--number_jobs ${processor_count}
--index_page_name user_guide
--suppress_spell_warnings
--config_file "${CMAKE_SOURCE_DIR}/xrst.toml"
)
#
# doc_dev
ADD_CUSTOM_TARGET(doc_dev
COMMAND xrst
--group_list default app dev
--local_toc
--html_theme sphinx_rtd_theme
--number_jobs ${processor_count}
--index_page_name user_guide
--suppress_spell_warnings
--config_file "${CMAKE_SOURCE_DIR}/xrst.toml"
)
ENDIF( include_doc )
# =============================================================================
# cppad_lib
# Perhaps in the future cppad_lib will depend on cmake header only flag ?
SET( cppad_lib "cppad_lib" )
LINK_DIRECTORIES( ${cppad_BINARY_DIR}/cppad_lib )
# =============================================================================
# colpack_libs
#
IF( cppad_has_colpack )
SET( colpack_libs "ColPack" )
ELSE( cppad_has_colpack )
SET( colpack_libs "" )
ENDIF( cppad_has_colpack )
# =============================================================================
# automated system configuration
# =============================================================================
# CMAKE_CXX_FLAGS
IF( "${cppad_debug_which}" STREQUAL "debug_all" )
print_variable(CMAKE_CXX_FLAGS_DEBUG)
ELSEIF( "${cppad_debug_which}" STREQUAL "debug_none" )
print_variable(CMAKE_CXX_FLAGS_RELEASE)
ELSE( "${cppad_debug_which}" )
print_variable(CMAKE_CXX_FLAGS_DEBUG)
print_variable(CMAKE_CXX_FLAGS_RELEASE)
ENDIF( "${cppad_debug_which}" STREQUAL "debug_all" )
# -----------------------------------------------------------------------------
# cppad_abs_includedir, cppad_abs_libdir, cppad_abs_datadir, cppad_abs_docdir
#
# for dir_types = includedirs, libdirs, datadir, docdir
FOREACH(dir_types includedirs libdirs datadir docdir)
# set dir_type = dir_types with "dirs" -> "dir"
STRING(REGEX REPLACE "dirs" "dir" dir_type ${dir_types})
#
# set dir_name to first directory in cmake_install_${dir_types}
SET(dir_name NOTFOUND)
FOREACH(dir ${cmake_install_${dir_types}})
IF( NOT dir_name )
SET(dir_name ${dir})
ENDIF( NOT dir_name )
ENDFOREACH(dir ${cmake_install_${dir_types}})
#
# set cppad_abs_${dir_type}
SET(cppad_abs_${dir_type} "${cppad_prefix}/${dir_name}" )
#
# check if we need to add a postfix to it
IF( cppad_postfix )
SET(cppad_abs_${dir_type} ${cppad_abs_${dir_type}}/${cppad_postfix} )
ENDIF( cppad_postfix )
ENDFOREACH(dir_types includedirs libdirs datadir docdir)
# ----------------------------------------------------------------------------
# https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/RPATH-handling
#
# CMAKE_SKIP_BUILD_RPATH
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
#
# CMAKE_BUILD_WITH_INSTALL_RPATH
# when building shared libraries, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
#
# CMAKE_INSTAL_RPATH_USE_LINK_PATH
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
#
# isSystemDir
# is this RPATH choice a system directory
LIST(FIND
CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
"${cppad_abs_libdir}"
isSystemDir
)
#
# CMAKE_INSTALL_RPATH
# the RPATH to be used when installing, but only if it's not a system directory
SET(CMAKE_INSTALL_RPATH "")
if("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${cppad_abs_libdir}")
endif("${isSystemDir}" STREQUAL "-1")
print_variable( CMAKE_INSTALL_RPATH )
# -----------------------------------------------------------------------------
# cppad_link_flags_has_m32
STRING( FIND "${cppad_link_flags}" "-m32" index)
IF( "${index}" STREQUAL "-1" )
SET(cppad_link_flags_has_m32 0)
ELSE ( )
SET(cppad_link_flags_has_m32 1)
ENDIF( )
# -----------------------------------------------------------------------------
# OpenMP_CXX_FOUND, OpenMP_CXX_FLAGS
IF( cppad_link_flags_has_m32 )
SET(OpenMP_CXX_FOUND FALSE)
MESSAGE(STATUS
"Skipping OpenMP because -m32 is in cppad_link_flags"
)
ELSEIF( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
SET(OpenMP_CXX_FOUND FALSE)
MESSAGE(STATUS
"Skipping OpenMP on Darwin (Mac) systems. 2DO: fix this"
)
ELSE( )
FIND_PACKAGE(OpenMP)
ENDIF( )
# -----------------------------------------------------------------------------
# Boost_Found, cppad_has_boost
# Only need components for object libraries, not include libraries.
IF( cppad_link_flags_has_m32 )
MESSAGE(STATUS
"Skipping Boost because -m32 is in cppad_link_flags"
)
SET( Boost_FOUND 0)
SET(cppad_has_boost 0)
ELSE ( )
SET(CMAKE_REQUIRED_FLAGS "") # 2DO: why is this necessary with clang ?
FIND_PACKAGE(Boost COMPONENTS thread)
SET(CMAKE_REQUIRED_FLAGS "${cppad_cxx_flags}")
ENDIF( )
IF ( Boost_FOUND )
SET(cppad_has_boost 1)
#
# Extract the Boost prefix from Boost_INCLUDE_DIRS
#
# convert to using unix directory separator
dos_path_to_unix("${Boost_INCLUDE_DIRS}" boost_include_dirs)
#
# convert to just one directory
STRING(REGEX REPLACE
"([^ ]+).*" "\\1"
boost_include_dir "${boost_include_dirs}"
)
#
# extract part before last backslash
STRING(REGEX REPLACE
"([^ ]*)/[^/ ]*" "\\1"
boost_prefix "${boost_include_dir}"
)
print_variable(boost_prefix)
#
# add boost include directories
FOREACH(dir ${cmake_install_includedirs})
IF( IS_DIRECTORY ${boost_prefix}/${dir} )
INCLUDE_DIRECTORIES( ${boost_prefix}/${dir} )
MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
ENDFOREACH( dir )
#
# add boost link directories
FOREACH(dir ${cmake_install_libdirs})
IF( IS_DIRECTORY ${boost_prefix}/${dir} )
LINK_DIRECTORIES( ${boost_prefix}/${dir} )
MESSAGE(STATUS "Found ${boost_prefix}/${dir}")
ENDIF( IS_DIRECTORY ${boost_prefix}/${dir} )
ENDFOREACH( dir )
ENDIF ( Boost_FOUND )
# -----------------------------------------------------------------------------
# ipopt_LIBRARIES and ipopt_LIBRARY_DIRS
IF( cppad_has_ipopt )
#
# Set the system environment variable PKG_CONFIG_PATH
FOREACH(dir ${cmake_install_libdirs})
IF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
SET( ENV{PKG_CONFIG_PATH} ${ipopt_prefix}/${dir}/pkgconfig )
ENDIF(EXISTS "${ipopt_prefix}/${dir}/pkgconfig/ipopt.pc")
ENDFOREACH(dir)
#
# pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
# ipopt_LIBRARIES ... only the libraries (w/o the '-l')
# ipopt_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
pkg_check_modules(ipopt ipopt)
IF( NOT ipopt_FOUND )
MESSAGE(FATAL_ERROR
"For all directories dir in cmake_install_libdirs, cannot find the file
ipopt_prefix/dir/pkgconfig/ipopt.pc
where
ipopt_prefix = ${ipopt_prefix}
cmake_install_libdirs = ${cmake_install_libdirs}
"
)
ENDIF( NOT ipopt_FOUND )
ENDIF( cppad_has_ipopt )
# =============================================================================
# Currently building tests as normal executables
# =============================================================================
# The CMakeLists.txt file in the specified source directory is processed
# before the current input file continues beyond this command.
# add_subdirectory(source_dir [binary_dir] [EXCLUDE_FROM_ALL])
#
#
# is_cppad_lib_dynamic
IF( cppad_static_lib )
SET(is_cppad_lib_dynamic 0)
ELSE( )
SET(is_cppad_lib_dynamic 1)
ENDIF( )
print_variable(is_cppad_lib_dynamic)
#
# CMAKE_EXE_LINKER_FLAGS
SET(CMAKE_EXE_LINKER_FLAGS "${cppad_link_flags}" )
#
# Initialize list of tests as empty
SET(check_depends "")
#
# directories with no check depends entries
ADD_SUBDIRECTORY(include/cppad)
ADD_SUBDIRECTORY(pkgconfig)
ADD_SUBDIRECTORY(cppad_lib)
#
IF( NOT ( "${check_depends}" STREQUAL "" ) )
MESSAGE(FATAL_ERROR "Error in CMakeLists.txt scripts")
ENDIF( NOT ( "${check_depends}" STREQUAL "" ) )
#
# directories with check depends entries
ADD_SUBDIRECTORY(val_graph)
ADD_SUBDIRECTORY(example)
ADD_SUBDIRECTORY(introduction)
ADD_SUBDIRECTORY(test_more)
ADD_SUBDIRECTORY(speed)
IF( cppad_has_ipopt )
ADD_SUBDIRECTORY(cppad_ipopt)
ENDIF( cppad_has_ipopt )
#
# check, test
ADD_CUSTOM_TARGET(check DEPENDS ${check_depends})
ADD_CUSTOM_TARGET(test DEPENDS ${check_depends})
# ============================================================================
# Copy a file to another location and modify its contents.
# configure_file(InputFile OutputFile [COPYONLY] [ESCAPE_QUOTES] [@ONLY])
CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/bin/test_one.sh.in
${CMAKE_CURRENT_SOURCE_DIR}/bin/test_one.sh
)
# =============================================================================
# install procedure
# =============================================================================
# install(DIRECTORY dirs... DESTINATION <dir>
# [FILE_PERMISSIONS permissions...]
# [DIRECTORY_PERMISSIONS permissions...]
# [USE_SOURCE_PERMISSIONS] [OPTIONAL]
# [CONFIGURATIONS [Debug|Release|...]]
# [COMPONENT <component>] [FILES_MATCHING]
# [[PATTERN <pattern> | REGEX <regex>]
# [EXCLUDE] [PERMISSIONS permissions...]] [...]
# )
# Note a trailing / in the source directory name drops the source directory
# name during the copy.
#
# During install copy all the cppad include files to
# ${cppad_abs_includedir}/cppad
INSTALL(
DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/cppad/"
DESTINATION ${cppad_abs_includedir}/cppad
FILES_MATCHING PATTERN "*.hpp" PATTERN "xrst" EXCLUDE
)
#
# During install copy doc direcrory to cppad_abs_docdir/cppad
IF ( cmake_install_docdir AND include_doc )
INSTALL(
DIRECTORY "${CMAKE_SOURCE_DIR}/build/html/"
DESTINATION ${cppad_abs_docdir}/cppad
)
ENDIF ( cmake_install_docdir AND include_doc )
# =============================================================================
# uninstall procedure
# =============================================================================
ADD_CUSTOM_TARGET(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cppad_uninstall.cmake)
|