source: trunk/cppad/CMakeLists.txt

Last change on this file was 3973, checked in by bradbell, 3 years ago

merge to branch: trunk
from repository: https://github.com/coin-or/CppAD
start hash code: 90a7032d84ca92c1a716bddae1db9246e83777fd
end hash code: f7e5f730689a2db27807225c0193183c611ad798

commit f7e5f730689a2db27807225c0193183c611ad798
Author: Brad Bell <bradbell@…>
Date: Wed Aug 30 06:22:08 2017 -0700

whats_new_17.omh: User's view of recent changes.

commit b77b9a418efffac5aa731c4d4f39729015616a78
Author: Brad Bell <bradbell@…>
Date: Wed Aug 30 05:48:35 2017 -0700

No longer using cppad_size_t_not_unsigned_int.

commit 38d4c09cf892e1f935873900e1bb930dee224d5e
Author: Brad Bell <bradbell@…>
Date: Wed Aug 30 05:33:20 2017 -0700

Advance to cppad-20170830.

commit d90698210c05d84d8df304da0344b9a893d67f6b
Author: Brad Bell <bradbell@…>
Date: Wed Aug 30 05:29:58 2017 -0700

  1. Adapt autotools to new is_pod.hpp file that gets build during configuration.
  2. Change autotools testing to use new version of eigen.
  3. Remove scacado from list of packages tested by autotools install.

commit f6aeaf02b3b11e3b9141b2ddf272967e1a306cc1
Author: Brad Bell <bradbell@…>
Date: Tue Aug 29 05:37:30 2017 -0700

Advance to cppad-20170829.

commit 356671b7d110b37360024834aa0a59ba196b4e64
Author: Brad Bell <bradbell@…>
Date: Tue Aug 29 05:35:32 2017 -0700

  1. Remove configure.hpp from distribution (built during configuration).
  2. Add is_pod.hpp to source files built during configuration.
  3. Remove references to cppad/deprecated directory and *.h (no longer exist)
  • Property svn:keywords set to Id
File size: 8.2 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# Configure the CppAD include file directory
12# -----------------------------------------------------------------------------
13# check_match
14MACRO(check_match match_variable match_constant output_variable)
15        STRING(COMPARE EQUAL ${${match_variable}} ${match_constant} match_flag )
16        IF( match_flag )
17                SET(${output_variable} 1)
18        ELSE( match_flag )
19                SET(${output_variable} 0)
20        ENDIF( match_flag )
21        print_variable(${output_variable})
22ENDMACRO(check_match)
23# -----------------------------------------------------------------------------
24# cppad_compiler_is_gnucxx
25IF( CMAKE_COMPILER_IS_GNUCXX )
26        SET( cppad_compiler_is_gnucxx 1 )
27ELSE( CMAKE_COMPILER_IS_GNUCXX )
28        SET( cppad_compiler_is_gnucxx 0 )
29ENDIF( CMAKE_COMPILER_IS_GNUCXX )
30# -----------------------------------------------------------------------------
31# cppad_boostvector, cppad_cppadvector, cppad_eigenvector, cppad_stdvector
32#
33check_match(cppad_testvector boost cppad_boostvector)
34check_match(cppad_testvector cppad cppad_cppadvector)
35check_match(cppad_testvector eigen cppad_eigenvector)
36check_match(cppad_testvector std   cppad_stdvector)
37IF( NOT cppad_boostvector )
38IF( NOT cppad_cppadvector )
39IF( NOT cppad_eigenvector )
40IF( NOT cppad_stdvector )
41MESSAGE(FATAL_ERROR
42"cppad_testvector not one of following: boost, cppad, eigen, std."
43)
44ENDIF( NOT cppad_stdvector )
45ENDIF( NOT cppad_eigenvector )
46ENDIF( NOT cppad_cppadvector )
47ENDIF( NOT cppad_boostvector )
48
49IF( cppad_boostvector )
50        # FIND_PACKAGE(Boost) done by ../CMakeLists.txt
51        IF( NOT Boost_FOUND )
52                MESSAGE(FATAL_ERROR
53"cppad_testvector == boost but cannot find boost include files"
54                )
55        ENDIF( NOT Boost_FOUND )
56ENDIF( cppad_boostvector )
57#
58IF( cppad_eigenvector )
59        IF( NOT eigen_prefix )
60                MESSAGE(FATAL_ERROR
61"cppad_testvector == eigen but eigen_prefix is not specified"
62                )
63        ENDIF( NOT eigen_prefix )
64ENDIF( cppad_eigenvector )
65# =============================================================================
66# Begin C++11 features
67#
68SET(cppad_cplusplus_201100_ok 1)
69# -----------------------------------------------------------------------------
70# cppad_has_signed_long_long
71#
72SET(source "
73int main(void)
74{       signed long long value = 0;
75        return int(value);
76}"
77)
78check_source_runs("${source}" cppad_has_signed_long_long )
79IF( NOT cppad_has_signed_long_long )
80        SET(cppad_cplusplus_201100_ok 0)
81ENDIF( NOT cppad_has_signed_long_long )
82# -----------------------------------------------------------------------------
83# cppad_has_rvalue
84#
85SET(source "
86int main(void)
87{       int&& value = 1 + 2;
88        if( value != 3 )
89                return 1;
90        return 0;
91}"
92)
93check_source_runs("${source}" cppad_has_rvalue)
94IF( NOT cppad_has_rvalue )
95        SET(cppad_cplusplus_201100_ok 0)
96ENDIF( NOT cppad_has_rvalue )
97# -----------------------------------------------------------------------------
98# cppad_has_nullptr
99#
100SET(source "
101int main(void)
102{       char *c = nullptr;
103        return 0;
104}"
105)
106check_source_runs("${source}" cppad_has_nullptr)
107IF( NOT cppad_has_nullptr )
108        SET(cppad_cplusplus_201100_ok 0)
109ENDIF( NOT cppad_has_nullptr )
110# -----------------------------------------------------------------------------
111# cppad_has_long_long
112#
113SET(source "
114template <class T> inline bool is_pod(void)  { return false; }
115template <>  inline bool is_pod<signed long long>(void) { return true;  }
116template <>  inline bool is_pod<unsigned long long>(void) { return true;  }
117int main(void)
118{       return 0; }
119"
120)
121check_source_runs("${source}" cppad_has_long_long)
122IF( NOT cppad_has_long_long )
123        SET(cppad_cplusplus_201100_ok 0)
124ENDIF( NOT cppad_has_long_long )
125# -----------------------------------------------------------------------------
126# cppad_compiler_has_erf
127# cppad_compiler_has_asinh
128# cppad_compiler_has_acosh
129# cppad_compiler_has_atanh
130# cppad_compiler_has_expm1
131#
132SET(source_template "
133# include <cmath>
134int main(void)
135{       std::c11_function(0.0);
136        return 0;
137}
138"
139)
140FOREACH(c11_function erf asinh acosh atanh expm1 log1p)
141        STRING(REPLACE "c11_function" ${c11_function} source "${source_template}" )
142        # really only checking if program compiles
143        check_source_runs("${source}" cppad_compiler_has_${c11_function} )
144        IF( NOT cppad_compiler_has_${c11_function} )
145                SET(cppad_cplusplus_201100_ok 0)
146        ENDIF( NOT cppad_compiler_has_${c11_function} )
147ENDFOREACH(c11_function)
148# -----------------------------------------------------------------------------
149# cppad_has_steady_clock
150#
151SET(source "
152# include <chrono>
153# include <thread>
154# include <iostream>
155int main(void)
156{       std::chrono::time_point<std::chrono::steady_clock> start, end;
157    start = std::chrono::steady_clock::now();
158        std::this_thread::sleep_for( std::chrono::milliseconds(1) );
159    end   = std::chrono::steady_clock::now();
160    std::chrono::duration<double> difference = end - start;
161        double elapsed_seconds = difference.count();
162        if( elapsed_seconds >= 0.9e-3 ) // 1e-3 = one millisecond
163                return 0;
164        return 1;
165}
166"
167)
168check_source_runs("${source}" cppad_has_steady_clock)
169IF( NOT cppad_has_steady_clock )
170        SET(cppad_cplusplus_201100_ok 0)
171ENDIF( NOT cppad_has_steady_clock )
172# =============================================================================
173# End C++11 features
174#
175print_variable(cppad_cplusplus_201100_ok)
176# -----------------------------------------------------------------------------
177# cppad_has_gettimeofday
178#
179SET(source "
180# include<sys/time.h>
181int main(void)
182{       struct timeval time;
183        gettimeofday(&time, 0);
184        return 0;
185}"
186)
187check_source_runs("${source}" cppad_has_gettimeofday)
188# -----------------------------------------------------------------------------
189# cppad_tape_addr_type, cppad_tape_id_type
190#
191FOREACH(cmake_var cppad_tape_id_type cppad_tape_addr_type )
192        SET(source "
193# include <limits>
194int main(void)
195{       bool is_unsigned = ! std::numeric_limits<${${cmake_var}}>::is_signed;
196        return int(! is_unsigned);
197}
198"
199        )
200        check_source_runs("${source}" ${cmake_var}_is_unsigned)
201        IF( ${cmake_var}_is_unsigned STREQUAL 0  )
202                MESSAGE(STATUS
203"Warning: using a signed ${cmake_var} is for CppAD developers only !"
204        )
205        ENDIF( ${cmake_var}_is_unsigned STREQUAL 0  )
206ENDFOREACH( cmake_var )
207# -----------------------------------------------------------------------------
208# check that cppad_max_num_threads is >= 4
209#
210SET(CMAKE_REQUIRED_INCLUDES  "")
211SET(CMAKE_REQUIRED_LIBRARIES "")
212SET(CMAKE_REQUIRED_FLAGS     )
213SET(source "
214int main(void)
215{       const char* number = \"${cppad_max_num_threads}\";
216        int value = 0;
217        while( *number == ' ' )
218                number++;
219        while( '0' <= *number && *number <= '9' )
220        {       value = 10 * value + (int)(*number - '0');
221                number++;
222        }
223        while( *number == ' ' )
224                number++;
225        if( *number != char(0) )
226                return 1;
227        if( value < 4 )
228                return 1;
229        return 0;
230}
231" )
232# Using CHECK_CXX_SOURCE_RUNS directly (instead of check_source_runs).
233CHECK_CXX_SOURCE_RUNS("${source}" cppad_max_num_threads_is_integer_ge_4)
234IF( NOT cppad_max_num_threads_is_integer_ge_4 )
235        MESSAGE(FATAL_ERROR
236        "cppad_max_num_threads is not an integer greater than or equal 4"
237        )
238ENDIF( NOT cppad_max_num_threads_is_integer_ge_4 )
239# -----------------------------------------------------------------------------
240# cppad_has_mkstemp
241#
242SET(source "
243# include <stdlib.h>
244# include <unistd.h>
245int main(void)
246{
247        char pattern[] = \"/tmp/fileXXXXXX\";
248        int fd = mkstemp(pattern);
249        return 0;
250}
251" )
252check_source_runs("${source}" cppad_has_mkstemp )
253# -----------------------------------------------------------------------------
254# cppad_has_tmpname_s
255#
256SET(source "
257# include <stdio.h>
258int main(void)
259{       char filename[L_tmpnam_s ];
260        if( tmpnam_s(filename, L_tmpnam_s ) != 0 )
261                return 1;
262        return 0;
263}
264" )
265check_source_runs("${source}" cppad_has_tmpnam_s )
266# -----------------------------------------------------------------------------
267# configure.hpp
268CONFIGURE_FILE(
269        ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp.in
270        ${CMAKE_CURRENT_SOURCE_DIR}/configure.hpp
271)
272# -----------------------------------------------------------------------------
273# configure files in local subdirectory
274ADD_SUBDIRECTORY(local)
Note: See TracBrowser for help on using the repository browser.