CMakeLists.txt 45.7 KB
Newer Older
Kitware Robot's avatar
Kitware Robot committed
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
#=============================================================================
# KWSys - Kitware System Library
# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================

# The Kitware System Library is intended to be included in other
# projects.  It is completely configurable in that the library's
# namespace can be configured and the components that are included can
# be selected invididually.

# Typical usage is to import the kwsys directory tree into a
# subdirectory under a parent project and enable the classes that will
# be used.  All classes are disabled by default.  The CMake listfile
# above this one configures the library as follows:
#
#  SET(KWSYS_NAMESPACE foosys)
#  SET(KWSYS_USE_Directory 1)    # Enable Directory class.
#  SUBDIRS(kwsys)
#
# Optional settings are as follows:
#
#  KWSYS_HEADER_ROOT = The directory into which to generate the kwsys headers.
#                      A directory called "${KWSYS_NAMESPACE}" will be
#                      created under this root directory to hold the files.
#
#    Example:
#
#      SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
#      INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
#
#  KWSYS_IOS_FORCE_OLD = Force use of old non-ANSI C++ streams even if
#                        new streams are available.  This may be used
#                        by projects that cannot configure their
#                        streams library.
#    Example:
#
#      SET(KWSYS_IOS_FORCE_OLD 1)
#
#
# Optional settings to setup install rules are as follows:
#
#  KWSYS_INSTALL_BIN_DIR     = The installation target directories into
#  KWSYS_INSTALL_LIB_DIR       which the libraries and headers from
#  KWSYS_INSTALL_INCLUDE_DIR   kwsys should be installed by a "make install".
#                              The values should be specified relative to
#                              the installation prefix and NOT start with '/'.
#  KWSYS_INSTALL_DOC_DIR     = The installation target directory for documentation
#                              such as copyright information.
#
#  KWSYS_INSTALL_COMPONENT_NAME_RUNTIME     = Name of runtime and development
#  KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT   installation components.
#                                             If not given the install rules
#                                             will not be in any component.
#
#  KWSYS_INSTALL_EXPORT_NAME = The EXPORT option value for install(TARGETS) calls.
#
#    Example:
#
#      SET(KWSYS_INSTALL_BIN_DIR bin)
#      SET(KWSYS_INSTALL_LIB_DIR lib)
#      SET(KWSYS_INSTALL_INCLUDE_DIR include)
#      SET(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME Runtime)
#      SET(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT Development)

# Once configured, kwsys should be used as follows from C or C++ code:
#
#  #include <foosys/Directory.hxx>
#   ...
#  foosys::Directory directory;
#

# NOTE: This library is intended for internal use by Kitware-driven
# projects.  In order to keep it simple no attempt will be made to
# maintain backward compatibility when changes are made to KWSys.
# When an incompatible change is made Kitware's projects that use
# KWSys will be fixed, but no notification will necessarily be sent to
# any outside mailing list and no documentation of the change will be
# written.

CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
Kitware Robot's avatar
Kitware Robot committed
88
89
90
IF(POLICY CMP0025)
  CMAKE_POLICY(SET CMP0025 NEW)
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
91
92
93
IF(POLICY CMP0056)
  CMAKE_POLICY(SET CMP0056 NEW)
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
94
95
96
97
98
99
100
101

#-----------------------------------------------------------------------------
# If a namespace is not specified, use "kwsys" and enable testing.
# This should be the case only when kwsys is not included inside
# another project and is being tested.
IF(NOT KWSYS_NAMESPACE)
  SET(KWSYS_NAMESPACE "kwsys")
  SET(KWSYS_STANDALONE 1)
Kitware Robot's avatar
Kitware Robot committed
102
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

#-----------------------------------------------------------------------------
# The project name is that of the specified namespace.
PROJECT(${KWSYS_NAMESPACE})

# Tell CMake how to follow dependencies of sources in this directory.
SET_PROPERTY(DIRECTORY
  PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
  "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>"
  )

# Select library components.
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
  SET(KWSYS_ENABLE_C 1)
  # Enable all components.
  SET(KWSYS_USE_Base64 1)
  SET(KWSYS_USE_Directory 1)
  SET(KWSYS_USE_DynamicLoader 1)
Kitware Robot's avatar
Kitware Robot committed
121
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
122
123
124
125
126
127
128
129
130
131
  SET(KWSYS_USE_Glob 1)
  SET(KWSYS_USE_MD5 1)
  SET(KWSYS_USE_Process 1)
  SET(KWSYS_USE_RegularExpression 1)
  SET(KWSYS_USE_System 1)
  SET(KWSYS_USE_SystemTools 1)
  SET(KWSYS_USE_CommandLineArguments 1)
  SET(KWSYS_USE_FundamentalType 1)
  SET(KWSYS_USE_Terminal 1)
  SET(KWSYS_USE_IOStream 1)
Kitware Robot's avatar
Kitware Robot committed
132
  SET(KWSYS_USE_FStream 1)
Kitware Robot's avatar
Kitware Robot committed
133
134
135
  SET(KWSYS_USE_String 1)
  SET(KWSYS_USE_SystemInformation 1)
  SET(KWSYS_USE_CPU 1)
Kitware Robot's avatar
Kitware Robot committed
136
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
137
138
139
140

# Enforce component dependencies.
IF(KWSYS_USE_SystemTools)
  SET(KWSYS_USE_Directory 1)
Kitware Robot's avatar
Kitware Robot committed
141
142
  SET(KWSYS_USE_FStream 1)
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
143
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
144
145
146
147
IF(KWSYS_USE_Glob)
  SET(KWSYS_USE_Directory 1)
  SET(KWSYS_USE_SystemTools 1)
  SET(KWSYS_USE_RegularExpression 1)
Kitware Robot's avatar
Kitware Robot committed
148
149
  SET(KWSYS_USE_FStream 1)
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
150
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
151
152
IF(KWSYS_USE_Process)
  SET(KWSYS_USE_System 1)
Kitware Robot's avatar
Kitware Robot committed
153
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
154
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
155
156
IF(KWSYS_USE_SystemInformation)
  SET(KWSYS_USE_Process 1)
Kitware Robot's avatar
Kitware Robot committed
157
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
158
159
IF(KWSYS_USE_System)
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
160
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
161
162
IF(KWSYS_USE_Directory)
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
163
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
164
165
IF(KWSYS_USE_FStream)
  SET(KWSYS_USE_Encoding 1)
Kitware Robot's avatar
Kitware Robot committed
166
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
167
168
169
170

# Setup the large file support default.
IF(KWSYS_LFS_DISABLE)
  SET(KWSYS_LFS_REQUESTED 0)
Kitware Robot's avatar
Kitware Robot committed
171
ELSE()
Kitware Robot's avatar
Kitware Robot committed
172
  SET(KWSYS_LFS_REQUESTED 1)
Kitware Robot's avatar
Kitware Robot committed
173
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
174

Kitware Robot's avatar
Kitware Robot committed
175
176
177
# Specify default 8 bit encoding for Windows
IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
  SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
Kitware Robot's avatar
Kitware Robot committed
178
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
179

Kitware Robot's avatar
Kitware Robot committed
180
181
182
183
184
185
# Enable testing if building standalone.
IF(KWSYS_STANDALONE)
  INCLUDE(Dart)
  MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
  IF(BUILD_TESTING)
    ENABLE_TESTING()
Kitware Robot's avatar
Kitware Robot committed
186
187
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202

# Include helper macros.
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
INCLUDE(CheckTypeSize)

# Do full dependency headers.
INCLUDE_REGULAR_EXPRESSION("^.*$")

# Use new KWSYS_INSTALL_*_DIR variable names to control installation.
# Take defaults from the old names.  Note that there was no old name
# for the bin dir, so we take the old lib dir name so DLLs will be
# installed in a compatible way for old code.
IF(NOT KWSYS_INSTALL_INCLUDE_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR
    "${KWSYS_HEADER_INSTALL_DIR}")
Kitware Robot's avatar
Kitware Robot committed
203
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
204
205
206
IF(NOT KWSYS_INSTALL_LIB_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
    "${KWSYS_LIBRARY_INSTALL_DIR}")
Kitware Robot's avatar
Kitware Robot committed
207
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
208
209
210
IF(NOT KWSYS_INSTALL_BIN_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
    "${KWSYS_LIBRARY_INSTALL_DIR}")
Kitware Robot's avatar
Kitware Robot committed
211
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
212
213
214
215
216
217
218

# Setup header install rules.
SET(KWSYS_INSTALL_INCLUDE_OPTIONS)
IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
  SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS}
    COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
    )
Kitware Robot's avatar
Kitware Robot committed
219
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235

# Setup library install rules.
SET(KWSYS_INSTALL_LIBRARY_RULE)
IF(KWSYS_INSTALL_LIB_DIR)
  IF(KWSYS_INSTALL_EXPORT_NAME)
    LIST(APPEND KWSYS_INSTALL_LIBRARY_RULE EXPORT ${KWSYS_INSTALL_EXPORT_NAME})
  ENDIF()
  # Install the shared library to the lib directory.
  SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
    LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR}
    )
  # Assign the shared library to the runtime component.
  IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
      )
Kitware Robot's avatar
Kitware Robot committed
236
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
237
238
239
240
241
242
243
244
245
246

  # Install the archive to the lib directory.
  SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
    ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR}
    )
  # Assign the archive to the development component.
  IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
      )
Kitware Robot's avatar
Kitware Robot committed
247
248
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
249
250
251
252
253
254
255
256
257
258
IF(KWSYS_INSTALL_BIN_DIR)
  # Install the runtime library to the bin directory.
  SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
    RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR}
    )
  # Assign the runtime library to the runtime component.
  IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
      )
Kitware Robot's avatar
Kitware Robot committed
259
260
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
261
262
263
264
265
266
267
268
269
270

# Do not support old KWSYS_*a_INSTALL_DIR variable names.
SET(KWSYS_HEADER_INSTALL_DIR)
SET(KWSYS_LIBRARY_INSTALL_DIR)

# Generated source files will need this header.
STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
  KWSYS_IN_SOURCE_BUILD)
IF(NOT KWSYS_IN_SOURCE_BUILD)
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
Kitware Robot's avatar
Kitware Robot committed
271
    ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
Kitware Robot's avatar
Kitware Robot committed
272
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
273
274
275
276
277
278
279
280
281
282
283
284
285

# Select plugin module file name convention.
IF(NOT KWSYS_DynamicLoader_PREFIX)
  SET(KWSYS_DynamicLoader_PREFIX ${CMAKE_SHARED_MODULE_PREFIX})
ENDIF()
IF(NOT KWSYS_DynamicLoader_SUFFIX)
  SET(KWSYS_DynamicLoader_SUFFIX ${CMAKE_SHARED_MODULE_SUFFIX})
ENDIF()

#-----------------------------------------------------------------------------
# We require ANSI support from the C compiler.  Add any needed flags.
IF(CMAKE_ANSI_CFLAGS)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
Kitware Robot's avatar
Kitware Robot committed
286
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
287
288
289
290
291
292
293
294
295
296
297

#-----------------------------------------------------------------------------
# Adjust compiler flags for some platforms.
IF(NOT CMAKE_COMPILER_IS_GNUCXX)
  IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
    STRING(REGEX MATCH "-timplicit_local"
      KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}")
    STRING(REGEX MATCH "-no_implicit_include"
      KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}")
    IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
Kitware Robot's avatar
Kitware Robot committed
298
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
299
300
    IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
Kitware Robot's avatar
Kitware Robot committed
301
302
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
303
304
  IF(CMAKE_SYSTEM MATCHES "HP-UX")
    SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
Kitware Robot's avatar
Kitware Robot committed
305
306
307
308
309
310
311
    IF(CMAKE_CXX_COMPILER_ID MATCHES "HP")
      # it is known that version 3.85 fails and 6.25 works without these flags
      IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
        # use new C++ library and improved template support
        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
      ENDIF()
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
312
313
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332

#-----------------------------------------------------------------------------
# Configure Large File Support.
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDIO
  "Checking whether header cstdio is available" DIRECT)
SET(KWSYS_LFS_AVAILABLE 0)
IF(KWSYS_LFS_REQUESTED)
  # Large File Support is requested.
  SET(KWSYS_LFS_REQUESTED 1)

  # Check for large file support.
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
    -DKWSYS_CXX_HAS_CSTDIO=${KWSYS_CXX_HAS_CSTDIO})
  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
    "Checking for Large File Support" DIRECT)
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)

  IF(KWSYS_LFS_WORKS)
    SET(KWSYS_LFS_AVAILABLE 1)
Kitware Robot's avatar
Kitware Robot committed
333
334
  ENDIF()
ELSE()
Kitware Robot's avatar
Kitware Robot committed
335
336
  # Large File Support is not requested.
  SET(KWSYS_LFS_REQUESTED 0)
Kitware Robot's avatar
Kitware Robot committed
337
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
338
339
340
341
342
343
344
345
346
347
348

#-----------------------------------------------------------------------------
# Configure the standard library header wrappers based on compiler's
# capabilities and parent project's request.  Enforce 0/1 as only
# possible values for configuration into Configure.hxx.

KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
  "Checking whether STL classes are in std namespace" DIRECT)

IF(KWSYS_IOS_FORCE_OLD)
  SET(KWSYS_IOS_USE_ANSI 0)
Kitware Robot's avatar
Kitware Robot committed
349
ELSE()
Kitware Robot's avatar
Kitware Robot committed
350
351
  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI
    "Checking whether ANSI stream headers are available" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
352
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
353
354
355
356
357
358

IF(KWSYS_IOS_USE_ANSI)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD
    "Checking whether ANSI streams are in std namespace" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM
    "Checking whether ANSI string stream is available" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
359
ELSE()
Kitware Robot's avatar
Kitware Robot committed
360
361
  SET(KWSYS_IOS_HAVE_STD 0)
  SET(KWSYS_IOS_USE_SSTREAM 0)
Kitware Robot's avatar
Kitware Robot committed
362
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
363
364
365
366

IF(KWSYS_IOS_USE_SSTREAM)
  SET(KWSYS_IOS_USE_STRSTREAM_H 0)
  SET(KWSYS_IOS_USE_STRSTREA_H 0)
Kitware Robot's avatar
Kitware Robot committed
367
ELSE()
Kitware Robot's avatar
Kitware Robot committed
368
369
370
371
  KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H
    "Checking whether strstream.h is available" DIRECT)
  IF(KWSYS_IOS_USE_STRSTREAM_H)
    SET(KWSYS_IOS_USE_STRSTREA_H 0)
Kitware Robot's avatar
Kitware Robot committed
372
  ELSE()
Kitware Robot's avatar
Kitware Robot committed
373
374
    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H
      "Checking whether strstrea.h is available" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
375
376
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
377
378
379
380
381
382
383
384
385
386
387
388
389

KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDDEF
  "Checking whether header cstddef is available" DIRECT)

SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
  -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD})
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR
  "Checking whether stl string has operator!= for char*" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS
  "Checking whether stl has iterator_traits" DIRECT)
IF(KWSYS_STL_HAS_ITERATOR_TRAITS)
  SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0)
  SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
Kitware Robot's avatar
Kitware Robot committed
390
ELSE()
Kitware Robot's avatar
Kitware Robot committed
391
392
393
394
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY
    "Checking whether stl has old iterator_category" DIRECT)
  IF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
    SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
Kitware Robot's avatar
Kitware Robot committed
395
  ELSE()
Kitware Robot's avatar
Kitware Robot committed
396
397
    KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY
      "Checking whether stl has internal __iterator_category" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
398
399
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
400
401
402
403
404
405
406
407
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE
  "Checking whether stl has standard template allocator" DIRECT)
IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
  SET(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE 0)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND
    "Checking for rebind member of stl allocator" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
    "Checking for non-standard argument to stl allocator<>::max_size" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
408
ELSE()
Kitware Robot's avatar
Kitware Robot committed
409
410
411
412
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE
    "Checking whether stl has old non-template allocator" DIRECT)
  SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0)
  SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0)
Kitware Robot's avatar
Kitware Robot committed
413
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
414
415
416
417
418
419
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS
  "Checking whether stl containers support allocator objects." DIRECT)
IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
  # ANSI streams always have string operators.
  SET(KWSYS_STL_STRING_HAVE_OSTREAM 1)
  SET(KWSYS_STL_STRING_HAVE_ISTREAM 1)
Kitware Robot's avatar
Kitware Robot committed
420
ELSE()
Kitware Robot's avatar
Kitware Robot committed
421
422
423
424
425
  # There may not be string operators for old streams.
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM
    "Checking whether stl string has ostream operator<<" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM
    "Checking whether stl string has istream operator>>" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
426
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
  -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
  -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD})
KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_BINARY
  "Checking whether ios has binary openmode" DIRECT)
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)

KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS
  "Checking whether \"<>\" is needed for template friends" INVERT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_MEMBER_TEMPLATES
  "Checking for member template support" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_FULL_SPECIALIZATION
  "Checking for standard template specialization syntax" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
  "Checking whether argument dependent lookup is supported" DIRECT)

IF(UNIX)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
    "Checking whether struct stat has st_mtim member" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
446
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
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

# Check existence and uniqueness of long long and __int64.
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
  "Checking whether C++ compiler has 'long long'" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS___INT64
  "Checking whether C++ compiler has '__int64'" DIRECT)
IF(KWSYS_CXX_HAS___INT64)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_AND___INT64
    "Checking whether long and __int64 are the same type" DIRECT)
  IF(KWSYS_CXX_HAS_LONG_LONG)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_LONG_AND___INT64
      "Checking whether long long and __int64 are the same type" DIRECT)
  ENDIF()
ENDIF()

# Enable the "long long" type if it is available.  It is standard in
# C99 and C++03 but not in earlier standards.
IF(KWSYS_CXX_HAS_LONG_LONG)
  SET(KWSYS_USE_LONG_LONG 1)
ELSE()
  SET(KWSYS_USE_LONG_LONG 0)
ENDIF()

# Enable the "__int64" type if it is available and unique.  It is not
# standard.
SET(KWSYS_USE___INT64 0)
IF(KWSYS_CXX_HAS___INT64)
  IF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
    IF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
      SET(KWSYS_USE___INT64 1)
    ENDIF()
  ENDIF()
ENDIF()

IF(KWSYS_USE_FundamentalType)
  # Look for type size helper macros.
  KWSYS_PLATFORM_INFO_TEST(C KWSYS_C_TYPE_MACROS
    "Checking for C type size macros")
  SET(macro_regex ".*INFO:macro\\[([^]]*)\\].*")
  FOREACH(info ${KWSYS_C_TYPE_MACROS})
    IF("${info}" MATCHES "${macro_regex}")
      STRING(REGEX REPLACE "${macro_regex}" "\\1" macro "${info}")
      SET(KWSYS_C_HAS_MACRO_${macro} 1)
    ENDIF()
  ENDFOREACH()

  # Determine type sizes at preprocessing time if possible, and
  # otherwise fall back to a try-compile.
  SET(KWSYS_C_TYPE_NAME_CHAR      "char")
  SET(KWSYS_C_TYPE_NAME_SHORT     "short")
  SET(KWSYS_C_TYPE_NAME_INT       "int")
  SET(KWSYS_C_TYPE_NAME_LONG      "long")
  SET(KWSYS_C_TYPE_NAME_LONG_LONG "long long")
  SET(KWSYS_C_TYPE_NAME___INT64   "__int64")
  FOREACH(type CHAR SHORT INT LONG LONG_LONG __INT64)
    IF(KWSYS_C_HAS_MACRO___SIZEOF_${type}__)
      # Use __SIZEOF_${type}__ macro.
      SET(KWSYS_SIZEOF_${type} TRUE)
      SET(KWSYS_C_CODE_SIZEOF_${type} "#define ${KWSYS_NAMESPACE}_SIZEOF_${type} __SIZEOF_${type}__")
    ELSEIF(KWSYS_C_HAS_MACRO___${type}_MAX__)
      # Use __${type}_MAX__ macro.
      SET(KWSYS_SIZEOF_${type} TRUE)
      SET(KWSYS_C_CODE_SIZEOF_${type} "#if __${type}_MAX__ == 0x7f
# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 1
#elif __${type}_MAX__ == 0x7fff
# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 2
#elif __${type}_MAX__ == 0x7fffffff
# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 4
#elif __${type}_MAX__>>32 == 0x7fffffff
# define ${KWSYS_NAMESPACE}_SIZEOF_${type} 8
#else
# error \"Cannot determine sizeof(${KWSYS_C_TYPE_NAME_${type}}).\"
#endif")
    ELSE()
      # Configure a hard-coded type size.
      CHECK_TYPE_SIZE("${KWSYS_C_TYPE_NAME_${type}}" KWSYS_SIZEOF_${type})
      IF(NOT KWSYS_SIZEOF_${type})
        SET(KWSYS_SIZEOF_${type} 0)
      ENDIF()
      SET(KWSYS_C_CODE_SIZEOF_${type}
        "#define ${KWSYS_NAMESPACE}_SIZEOF_${type} ${KWSYS_SIZEOF_${type}}")
    ENDIF()
  ENDFOREACH()

  IF(KWSYS_USE___INT64)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
      "Checking whether unsigned __int64 can convert to double" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
534
  ELSE()
Kitware Robot's avatar
Kitware Robot committed
535
    SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1)
Kitware Robot's avatar
Kitware Robot committed
536
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
537
538
539
540

  # Check signedness of "char" type.
  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
    "Checking whether char is signed" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
541
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
542

Kitware Robot's avatar
Kitware Robot committed
543
544
545
546
IF(KWSYS_USE_Encoding)
  # Look for type size helper macros.
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING
    "Checking whether wstring is available" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
547
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
548

Kitware Robot's avatar
Kitware Robot committed
549
550
IF(KWSYS_USE_IOStream)
  # Determine whether iostreams support long long.
Kitware Robot's avatar
Kitware Robot committed
551
552
553
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
    -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
    -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD})
Kitware Robot's avatar
Kitware Robot committed
554
555
556
557
558
559
560
561
562
  IF(KWSYS_CXX_HAS_LONG_LONG)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM_LONG_LONG
      "Checking if istream supports long long" DIRECT)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG
      "Checking if ostream supports long long" DIRECT)
  ELSE()
    SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
    SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
563
564
565
566
567
568
569
570
571
572
  IF(KWSYS_CXX_HAS___INT64)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM___INT64
      "Checking if istream supports __int64" DIRECT)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM___INT64
      "Checking if ostream supports __int64" DIRECT)
  ELSE()
    SET(KWSYS_IOS_HAS_ISTREAM___INT64 0)
    SET(KWSYS_IOS_HAS_OSTREAM___INT64 0)
  ENDIF()
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
Kitware Robot's avatar
Kitware Robot committed
573
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
574
575
576

IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
  SET(KWSYS_NAME_IS_KWSYS 1)
Kitware Robot's avatar
Kitware Robot committed
577
ELSE()
Kitware Robot's avatar
Kitware Robot committed
578
  SET(KWSYS_NAME_IS_KWSYS 0)
Kitware Robot's avatar
Kitware Robot committed
579
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
580
581
582
583

# Choose default shared/static build if not specified.
IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
  SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
Kitware Robot's avatar
Kitware Robot committed
584
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
585
586
587
588

IF(KWSYS_BUILD_SHARED)
  SET(KWSYS_BUILD_SHARED 1)
  SET(KWSYS_LIBRARY_TYPE SHARED)
Kitware Robot's avatar
Kitware Robot committed
589
ELSE()
Kitware Robot's avatar
Kitware Robot committed
590
591
  SET(KWSYS_BUILD_SHARED 0)
  SET(KWSYS_LIBRARY_TYPE STATIC)
Kitware Robot's avatar
Kitware Robot committed
592
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611

#-----------------------------------------------------------------------------
# Configure some implementation details.

KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T
  "Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT)
KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T
  "Checking whether C compiler has ssize_t in unistd.h" DIRECT)
SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES
  COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}"
  )

IF(KWSYS_USE_SystemTools)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_SETENV
    "Checking whether CXX compiler has setenv" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UNSETENV
    "Checking whether CXX compiler has unsetenv" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H
    "Checking whether CXX compiler has environ in stdlib.h" DIRECT)
Kitware Robot's avatar
Kitware Robot committed
612
613
614
615
616
617
618
619
620
621
622
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMES
    "Checking whether CXX compiler has utimes" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_UTIMENSAT
    "Checking whether CXX compiler has utimensat" DIRECT)
  SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
    KWSYS_CXX_HAS_SETENV=${KWSYS_CXX_HAS_SETENV}
    KWSYS_CXX_HAS_UNSETENV=${KWSYS_CXX_HAS_UNSETENV}
    KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H=${KWSYS_CXX_HAS_ENVIRON_IN_STDLIB_H}
    KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
    KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
    )
Kitware Robot's avatar
Kitware Robot committed
623
624
625
ENDIF()

IF(KWSYS_USE_SystemInformation)
Kitware Robot's avatar
Kitware Robot committed
626
627
  SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
    COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
Kitware Robot's avatar
Kitware Robot committed
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
  IF(NOT CYGWIN)
    INCLUDE(CheckIncludeFiles)
    CHECK_INCLUDE_FILES("sys/types.h;ifaddrs.h" KWSYS_SYS_HAS_IFADDRS_H)
    IF(KWSYS_SYS_HAS_IFADDRS_H)
      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
        COMPILE_DEFINITIONS KWSYS_SYS_HAS_IFADDRS_H=1)
    ENDIF()
  ENDIF()
  IF(WIN32)
    INCLUDE(CheckSymbolExists)
    SET(CMAKE_REQUIRED_LIBRARIES Psapi)
    CHECK_SYMBOL_EXISTS(GetProcessMemoryInfo "windows.h;psapi.h" KWSYS_SYS_HAS_PSAPI)
    UNSET(CMAKE_REQUIRED_LIBRARIES)
    IF(KWSYS_SYS_HAS_PSAPI)
      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
        COMPILE_DEFINITIONS KWSYS_SYS_HAS_PSAPI=1)
      IF(MSVC70 OR MSVC71)
        # Suppress LNK4089: all references to 'PSAPI.DLL' discarded by /OPT:REF
        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /IGNORE:4089")
      ENDIF()
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
650
651
652
653
654
655
656
657
658
659
660
661
662
663
  IF(CMAKE_SYSTEM MATCHES "HP-UX")
    CHECK_INCLUDE_FILES("sys/mpctl.h" KWSYS_SYS_HAS_MPCTL_H)
    IF(KWSYS_SYS_HAS_MPCTL_H)
      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
        COMPILE_DEFINITIONS KWSYS_SYS_HAS_MPCTL_H=1)
    ENDIF()
  ENDIF()
  IF(CMAKE_SYSTEM MATCHES "BSD")
    CHECK_INCLUDE_FILES("machine/cpu.h" KWSYS_SYS_HAS_MACHINE_CPU_H)
    IF(KWSYS_SYS_HAS_MACHINE_CPU_H)
      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
        COMPILE_DEFINITIONS KWSYS_SYS_HAS_MACHINE_CPU_H=1)
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
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
  IF(KWSYS_LFS_AVAILABLE AND NOT KWSYS_LFS_DISABLE)
    SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_HAS_LFS=1)
  ENDIF()
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_RLIMIT64
    "Checking whether CXX compiler has rlimit64" DIRECT)
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
  IF(KWSYS_CXX_HAS_RLIMIT64)
    SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_CXX_HAS_RLIMIT64=1)
  ENDIF()
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ATOL
    "Checking whether CXX compiler has atol" DIRECT)
  IF(KWSYS_CXX_HAS_ATOL)
    SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_CXX_HAS_ATOL=1)
  ENDIF()
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ATOLL
    "Checking whether CXX compiler has atoll" DIRECT)
  IF(KWSYS_CXX_HAS_ATOLL)
    SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_CXX_HAS_ATOLL=1)
  ENDIF()
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS__ATOI64
    "Checking whether CXX compiler has _atoi64" DIRECT)
  IF(KWSYS_CXX_HAS__ATOI64)
    SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_CXX_HAS__ATOI64=1)
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
692
693
694
695
696
697
  IF(UNIX)
    INCLUDE(CheckIncludeFileCXX)
    # check for simple stack trace
    # usually it's in libc but on FreeBSD
    # it's in libexecinfo
    FIND_LIBRARY(EXECINFO_LIB "execinfo")
Kitware Robot's avatar
Kitware Robot committed
698
    MARK_AS_ADVANCED(EXECINFO_LIB)
Kitware Robot's avatar
Kitware Robot committed
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
    IF (NOT EXECINFO_LIB)
      SET(EXECINFO_LIB "")
    ENDIF()
    CHECK_INCLUDE_FILE_CXX("execinfo.h" KWSYS_CXX_HAS_EXECINFOH)
    IF (KWSYS_CXX_HAS_EXECINFOH)
      # we have the backtrace header check if it
      # can be used  with this compiler
      SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${EXECINFO_LIB})
      KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BACKTRACE
         "Checking whether backtrace works with this C++ compiler" DIRECT)
      SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES)
      IF (KWSYS_CXX_HAS_BACKTRACE)
        # backtrace is supported by this system and compiler.
        # now check for the more advanced capabilities.
        SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
          COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_BACKTRACE=1)
        # check for symbol lookup using dladdr
        CHECK_INCLUDE_FILE_CXX("dlfcn.h" KWSYS_CXX_HAS_DLFCNH)
        IF (KWSYS_CXX_HAS_DLFCNH)
          # we have symbol lookup libraries and headers
          # check if they can be used with this compiler
          SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES ${CMAKE_DL_LIBS})
            KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_DLADDR
            "Checking whether dladdr works with this C++ compiler" DIRECT)
          SET(KWSYS_PLATFORM_CXX_TEST_LINK_LIBRARIES)
          IF (KWSYS_CXX_HAS_DLADDR)
            # symbol lookup is supported by this system
            # and compiler.
            SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
              COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP=1)
          ENDIF()
        ENDIF()
        # c++ demangling support
        # check for cxxabi headers
        CHECK_INCLUDE_FILE_CXX("cxxabi.h" KWSYS_CXX_HAS_CXXABIH)
        IF (KWSYS_CXX_HAS_CXXABIH)
          # check if cxxabi can be used with this
          # system and compiler.
          KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CXXABI
            "Checking whether cxxabi works with this C++ compiler" DIRECT)
          IF (KWSYS_CXX_HAS_CXXABI)
            # c++ demangle using cxxabi is supported with
            # this system and compiler
            SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
              COMPILE_DEFINITIONS KWSYS_SYSTEMINFORMATION_HAS_CPP_DEMANGLE=1)
          ENDIF()
        ENDIF()
        # basic backtrace works better with release build
        # don't bother with advanced features for release
        SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
          COMPILE_DEFINITIONS_DEBUG KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1)
        SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
          COMPILE_DEFINITIONS_RELWITHDEBINFO KWSYS_SYSTEMINFORMATION_HAS_DEBUG_BUILD=1)
      ENDIF()
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
755
756
757
758
759
760
761
762
763
764
765
766
767
768
  IF(BORLAND)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM
      "Checking whether Borland CXX compiler supports assembler instructions" DIRECT)
    IF(KWSYS_CXX_HAS_BORLAND_ASM)
      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
        COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM=1)
      KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_BORLAND_ASM_CPUID
        "Checking whether Borland CXX compiler supports CPUID assembler instruction" DIRECT)
      IF(KWSYS_CXX_HAS_BORLAND_ASM_CPUID)
        SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
          COMPILE_DEFINITIONS KWSYS_CXX_HAS_BORLAND_ASM_CPUID=1)
      ENDIF()
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
  IF(KWSYS_USE___INT64)
    SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_USE___INT64=1)
  ENDIF()
  IF(KWSYS_USE_LONG_LONG)
    SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_USE_LONG_LONG=1)
  ENDIF()
  IF(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
    SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_IOS_HAS_OSTREAM_LONG_LONG=1)
  ENDIF()
  IF(KWSYS_IOS_HAS_OSTREAM___INT64)
    SET_PROPERTY(SOURCE SystemInformation.cxx testSystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_IOS_HAS_OSTREAM___INT64=1)
  ENDIF()
  IF(KWSYS_BUILD_SHARED)
    SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
      COMPILE_DEFINITIONS KWSYS_BUILD_SHARED=1)
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
789
790
791
792
793
794
795
796
797

  IF(UNIX AND NOT CYGWIN)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_GETLOADAVG
      "Checking whether CXX compiler has getloadavg" DIRECT)
    IF(KWSYS_CXX_HAS_GETLOADAVG)
      SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
        COMPILE_DEFINITIONS KWSYS_CXX_HAS_GETLOADAVG=1)
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
798
799
800
801
802
803
ENDIF()

#-----------------------------------------------------------------------------
# Choose a directory for the generated headers.
IF(NOT KWSYS_HEADER_ROOT)
  SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
Kitware Robot's avatar
Kitware Robot committed
804
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
805
806
807
808
809
810
811
812
813
814
815
SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})

#-----------------------------------------------------------------------------
IF(KWSYS_INSTALL_DOC_DIR)
  # Assign the license to the runtime component since it must be
  # distributed with binary forms of this software.
  IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
    SET(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS}
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
      )
Kitware Robot's avatar
Kitware Robot committed
816
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
817
818
819
820
821

  # Install the license under the documentation directory.
  INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt
    DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE}
    ${KWSYS_INSTALL_LICENSE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
822
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858

#-----------------------------------------------------------------------------
# Create STL header wrappers to block warnings in the STL headers and
# give standard names by which they may be included.
SET(KWSYS_STL_HEADER_EXTRA_string 1)
FOREACH(header
  algorithm
  deque
  exception
  functional
  iterator
  list
  map
  memory
  new
  numeric
  queue
  set
  stack
  stdexcept
  string
  utility
  vector
  )
  # Configure the header wrapper.
  SET(KWSYS_STL_HEADER "${header}")
  IF(KWSYS_STL_HEADER_EXTRA_${header})
    SET(KWSYS_STL_HEADER_EXTRA
      "#define ${KWSYS_NAMESPACE}_stl_${header}_including_hxx\n# include <${KWSYS_NAMESPACE}/stl/${header}.hxx>\n#undef ${KWSYS_NAMESPACE}_stl_${header}_including_hxx\n")
    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl_${header}.hxx.in
                   ${KWSYS_HEADER_DIR}/stl/${header}.hxx
                   @ONLY IMMEDIATE)
    IF(KWSYS_INSTALL_INCLUDE_DIR)
      INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx
        DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
        ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
859
860
    ENDIF()
  ELSE()
Kitware Robot's avatar
Kitware Robot committed
861
    SET(KWSYS_STL_HEADER_EXTRA "")
Kitware Robot's avatar
Kitware Robot committed
862
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
863
864
865
866
867
868
869
870
871
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in
                 ${KWSYS_HEADER_DIR}/stl/${header}
                 @ONLY IMMEDIATE)

  # Create an install target for the header wrapper.
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
872
873
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
874
875
876
877
878
879
880
881
882

# Provide cstddef header.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in
               ${KWSYS_HEADER_DIR}/cstddef
               @ONLY IMMEDIATE)
IF(KWSYS_INSTALL_INCLUDE_DIR)
  INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef
    DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
    ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
883
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898

#-----------------------------------------------------------------------------
# Create streams header wrappers to give standard names by which they
# may be included.
FOREACH(header iostream fstream sstream iosfwd)
  # Configure the header wrapper.
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_ios_${header}.h.in
                 ${KWSYS_HEADER_DIR}/ios/${header}
                 @ONLY IMMEDIATE)

  # Create an install target for the header wrapper.
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/ios/${header}
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
899
900
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
901
902
903
904
905
906
907
908
909
910
911
912
913

#-----------------------------------------------------------------------------
# Build a list of classes and headers we need to implement the
# selected components.  Initialize with required components.
SET(KWSYS_CLASSES)
SET(KWSYS_H_FILES Configure SharedForward)
SET(KWSYS_HXX_FILES Configure String
  hashtable hash_fun hash_map hash_set
  auto_ptr
  )

# Add selected C++ classes.
SET(cppclasses
Kitware Robot's avatar
Kitware Robot committed
914
915
  Directory DynamicLoader Encoding Glob RegularExpression SystemTools
  CommandLineArguments IOStream FStream SystemInformation
Kitware Robot's avatar
Kitware Robot committed
916
917
918
919
920
921
922
923
924
  )
FOREACH(cpp ${cppclasses})
  IF(KWSYS_USE_${cpp})
    # Use the corresponding class.
    SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})

    # Load component-specific CMake code.
    IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
      INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
Kitware Robot's avatar
Kitware Robot committed
925
926
927
    ENDIF()
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
928
929
930

# Add selected C components.
FOREACH(c
Kitware Robot's avatar
Kitware Robot committed
931
    Process Base64 Encoding FundamentalType MD5 Terminal System String CPU
Kitware Robot's avatar
Kitware Robot committed
932
933
934
935
936
937
938
939
    )
  IF(KWSYS_USE_${c})
    # Use the corresponding header file.
    SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})

    # Load component-specific CMake code.
    IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
      INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
Kitware Robot's avatar
Kitware Robot committed
940
941
942
    ENDIF()
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
943
944
945
946
947
948
949
950
951
952

#-----------------------------------------------------------------------------
# Build a list of sources for the library based on components that are
# included.
SET(KWSYS_C_SRCS)
SET(KWSYS_CXX_SRCS)

# Add the proper sources for this platform's Process implementation.
IF(KWSYS_USE_Process)
  IF(NOT UNIX)
Kitware Robot's avatar
Kitware Robot committed
953
954
    # Use the Windows implementation.
    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c)
Kitware Robot's avatar
Kitware Robot committed
955
  ELSE()
Kitware Robot's avatar
Kitware Robot committed
956
957
    # Use the UNIX implementation.
    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
Kitware Robot's avatar
Kitware Robot committed
958
959
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
960
961

# Add selected C sources.
Kitware Robot's avatar
Kitware Robot committed
962
FOREACH(c Base64 Encoding MD5 Terminal System String)
Kitware Robot's avatar
Kitware Robot committed
963
  IF(KWSYS_USE_${c})
Kitware Robot's avatar
Kitware Robot committed
964
965
966
967
968
    IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}C.c)
      LIST(APPEND KWSYS_C_SRCS ${c}C.c)
    ELSE()
      LIST(APPEND KWSYS_C_SRCS ${c}.c)
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
969
970
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
971
972
973
974

# Configure headers of C++ classes and construct the list of sources.
FOREACH(c ${KWSYS_CLASSES})
  # Add this source to the list of source files for the library.
Kitware Robot's avatar
Kitware Robot committed
975
976
977
978
979
  IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
    LIST(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
  ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx)
    LIST(APPEND KWSYS_CXX_SRCS ${c}.cxx)
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
980
981
982
983
984
985
986
987
988
989
990

  # Configure the header for this class.
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
                 @ONLY IMMEDIATE)
  SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${c}.hxx)

  # Create an install target for the header.
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
991
992
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005

# Configure C headers.
FOREACH(h ${KWSYS_H_FILES})
  # Configure the header into the given directory.
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
                 @ONLY IMMEDIATE)
  SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)

  # Create an install target for the header.
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
1006
1007
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020

# Configure other C++ headers.
FOREACH(h ${KWSYS_HXX_FILES})
  # Configure the header into the given directory.
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
                 @ONLY IMMEDIATE)
  SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)

  # Create an install target for the header.
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
Kitware Robot's avatar
Kitware Robot committed
1021
1022
  ENDIF()
ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032

#-----------------------------------------------------------------------------
# Add the library with the configured name and list of sources.
IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
  ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE}
    ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
  SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB})
  IF(KWSYS_USE_DynamicLoader)
    IF(UNIX)
      TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
Kitware Robot's avatar
Kitware Robot committed
1033
1034
    ENDIF()
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1035

Kitware Robot's avatar
Kitware Robot committed
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
  IF(KWSYS_USE_SystemInformation)
    IF(WIN32)
      TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32)
      IF(KWSYS_SYS_HAS_PSAPI)
        TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} Psapi)
      ENDIF()
    ELSEIF(UNIX)
      IF (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE)
        # backtrace on FreeBSD is not in libc
        TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${EXECINFO_LIB})
      ENDIF()
      IF (KWSYS_CXX_HAS_DLADDR)
        # for symbol lookup using dladdr
        TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
      ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1051
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1052
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1053
1054
1055
1056
1057
1058

  # Apply user-defined target properties to the library.
  IF(KWSYS_PROPERTIES_CXX)
    SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
      ${KWSYS_PROPERTIES_CXX}
      )
Kitware Robot's avatar
Kitware Robot committed
1059
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1060
1061
1062
1063

  # Create an install target for the library.
  IF(KWSYS_INSTALL_LIBRARY_RULE)
    INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE})
Kitware Robot's avatar
Kitware Robot committed
1064
1065
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076

# Add a C-only library if requested.
IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
  ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS})
  SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}_c PROPERTY LABELS ${KWSYS_LABELS_LIB})

  # Apply user-defined target properties to the library.
  IF(KWSYS_PROPERTIES_C)
    SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
      ${KWSYS_PROPERTIES_C}
      )
Kitware Robot's avatar
Kitware Robot committed
1077
  ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1078
1079
1080
1081

  # Create an install target for the library.
  IF(KWSYS_INSTALL_LIBRARY_RULE)
    INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE})
Kitware Robot's avatar
Kitware Robot committed
1082
1083
  ENDIF()
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1084
1085
1086
1087
1088

# For building kwsys itself, we use a macro defined on the command
# line to configure the namespace in the C and C++ source files.
ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")

Kitware Robot's avatar
Kitware Robot committed
1089
# Disable deprecation warnings for standard C functions.
Kitware Robot's avatar
Kitware Robot committed
1090
IF(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel"))
Kitware Robot's avatar
Kitware Robot committed
1091
1092
1093
1094
1095
1096
1097
1098
  ADD_DEFINITIONS(
    -D_CRT_NONSTDC_NO_DEPRECATE
    -D_CRT_SECURE_NO_DEPRECATE
    -D_CRT_SECURE_NO_WARNINGS
    -D_SCL_SECURE_NO_DEPRECATE
    )
ENDIF()

Kitware Robot's avatar
Kitware Robot committed
1099
1100
1101
1102
1103
IF(WIN32)
  # Help enforce the use of wide Windows apis.
  ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
ENDIF()

Kitware Robot's avatar
Kitware Robot committed
1104
1105
1106
1107
IF(KWSYS_USE_String)
  # Activate code in "String.c".  See the comment in the source.
  SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
    COMPILE_FLAGS "-DKWSYS_STRING_C")
Kitware Robot's avatar
Kitware Robot committed
1108
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1109

Kitware Robot's avatar
Kitware Robot committed
1110
1111
1112
1113
IF(KWSYS_USE_Encoding)
  # Set default 8 bit encoding in "EndcodingC.c".
  SET_PROPERTY(SOURCE EncodingC.c APPEND PROPERTY COMPILE_DEFINITIONS
    KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
Kitware Robot's avatar
Kitware Robot committed
1114
ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1115

Kitware Robot's avatar
Kitware Robot committed
1116
1117
1118
1119
1120
1121
1122
1123
#-----------------------------------------------------------------------------
# Setup testing if not being built as part of another project.
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
  IF(BUILD_TESTING)
    # Compute the location of executables.
    SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
    IF(EXECUTABLE_OUTPUT_PATH)
      SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
Kitware Robot's avatar
Kitware Robot committed
1124
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143

    # C tests
    SET(KWSYS_C_TESTS
      testEncode
      testTerminal
      )
    IF(KWSYS_STANDALONE)
      SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail)
    ENDIF()
    CREATE_TEST_SOURCELIST(
      KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
      ${KWSYS_C_TESTS}
      )
    ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
    TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c)
    FOREACH(test ${KWSYS_C_TESTS})
      ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
      SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
Kitware Robot's avatar
Kitware Robot committed
1144
    ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
1145
1146
1147
1148
1149
1150
1151

    # C++ tests
    IF(NOT WATCOM)
      SET(KWSYS_CXX_TESTS
        testAutoPtr
        testHashSTL
        )
Kitware Robot's avatar
Kitware Robot committed
1152
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1153
1154
1155
1156
1157
1158
    SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
      testIOS
      testSystemTools
      testCommandLineArguments
      testCommandLineArguments1
      )
Kitware Robot's avatar
Kitware Robot committed
1159
1160
1161
1162
    IF(KWSYS_STL_HAS_WSTRING)
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
        testEncoding
        )
Kitware Robot's avatar
Kitware Robot committed
1163
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1164
1165
1166
1167
    IF(KWSYS_USE_FStream)
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
        testFStream
        )
Kitware Robot's avatar
Kitware Robot committed
1168
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1169
1170
    IF(KWSYS_USE_SystemInformation)
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation)
Kitware Robot's avatar
Kitware Robot committed
1171
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1172
1173
1174
1175
1176
1177
    IF(KWSYS_USE_DynamicLoader)
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader)
      # If kwsys contains the DynamicLoader, need extra library
      ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
      SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
      ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE})
Kitware Robot's avatar
Kitware Robot committed
1178
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1179
1180
1181
1182
1183
1184
1185
    CREATE_TEST_SOURCELIST(
      KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
      ${KWSYS_CXX_TESTS}
      )
    ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
    TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE})
Kitware Robot's avatar
Kitware Robot committed
1186
1187
1188

    SET(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
    SET(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
Kitware Robot's avatar
Kitware Robot committed
1189
1190
1191
1192
1193
1194
1195
1196
1197
    CONFIGURE_FILE(
      ${PROJECT_SOURCE_DIR}/testSystemTools.h.in
      ${PROJECT_BINARY_DIR}/testSystemTools.h)
    INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})

    IF(CTEST_TEST_KWSYS)
      CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
        "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
      SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
Kitware Robot's avatar
Kitware Robot committed
1198
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230

    SET(KWSYS_TEST_ARGS_testCommandLineArguments
      --another-bool-variable
      --long3=opt
      --set-bool-arg1
      -SSS ken brad bill andy
      --some-bool-variable=true
      --some-double-variable12.5
      --some-int-variable 14
      "--some-string-variable=test string with space"
      --some-multi-argument 5 1 8 3 7 1 3 9 7 1
      -N 12.5 -SS=andy -N 1.31 -N 22
      -SS=bill -BBtrue -SS=brad
      -BBtrue
      -BBfalse
      -SS=ken
      -A
      -C=test
      --long2 hello
      )
    SET(KWSYS_TEST_ARGS_testCommandLineArguments1
      --ignored
      -n 24
      --second-ignored
      "-m=test value"
      third-ignored
      -p
      some junk at the end
      )
    FOREACH(test ${KWSYS_CXX_TESTS})
      ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
      SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
Kitware Robot's avatar
Kitware Robot committed
1231
    ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
1232
1233
1234
1235
1236
1237
1238

    # Process tests.
    ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
    TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c)
    IF(NOT CYGWIN)
      SET(KWSYS_TEST_PROCESS_7 7)
Kitware Robot's avatar
Kitware Robot committed
1239
    ENDIF()
Kitware Robot's avatar
Kitware Robot committed
1240
1241
1242
1243
    FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7})
      ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
      SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
      SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
Kitware Robot's avatar
Kitware Robot committed
1244
    ENDFOREACH()
Kitware Robot's avatar
Kitware Robot committed
1245
1246

    # Some Apple compilers produce bad optimizations in this source.
Kitware Robot's avatar
Kitware Robot committed
1247
    IF(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$")
Kitware Robot's avatar
Kitware Robot committed
1248
      SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0)
Kitware Robot's avatar
Kitware Robot committed
1249
1250
1251
    ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL")
      # Tell IBM XL not to warn about our test infinite loop
      SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS -qsuppress=1500-010)
Kitware Robot's avatar
Kitware Robot committed
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
    ENDIF()

    # Test SharedForward
    CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
                   ${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE)
    ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward
                   ${PROJECT_BINARY_DIR}/testSharedForward.c)
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE})
    ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestSharedForward ${KWSYS_NAMESPACE}_c)
    ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1)
    SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST})

    # Configure some test properties.
    IF(KWSYS_STANDALONE)
      # We expect test to fail
      SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON)
      GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv)
      SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
      MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
    ENDIF()

    # Suppress known consistent failures on buggy systems.
    IF(KWSYS_TEST_BOGUS_FAILURES)
      SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON)
    ENDIF()

Kitware Robot's avatar
Kitware Robot committed
1278
1279
  ENDIF()
ENDIF()