CMakeLists.txt 43.9 KB
Newer Older
1
#=============================================================================
2
# KWSys - Kitware System Library
3
# Copyright 2000-2011 Kitware, Inc., Insight Software Consortium
4
#
5 6
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
7
#
8 9 10
# 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.
11 12 13 14
#=============================================================================

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

# Typical usage is to import the kwsys directory tree into a
19 20 21
# 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:
22
#
23 24
#  SET(KWSYS_NAMESPACE foosys)
#  SET(KWSYS_USE_Directory 1)    # Enable Directory class.
25 26 27 28
#  SUBDIRS(kwsys)
#
# Optional settings are as follows:
#
29 30 31
#  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.
32 33 34
#
#    Example:
#
Andy Cedilnik's avatar
Andy Cedilnik committed
35 36
#      SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
#      INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
37
#
38
# Optional settings to setup install rules are as follows:
39 40 41 42 43 44
#
#  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 '/'.
45 46
#  KWSYS_INSTALL_DOC_DIR     = The installation target directory for documentation
#                              such as copyright information.
47 48 49 50 51 52
#
#  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.
#
53 54
#  KWSYS_INSTALL_EXPORT_NAME = The EXPORT option value for install(TARGETS) calls.
#
55 56 57 58 59 60 61
#    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)
62 63 64

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

70 71 72 73 74 75 76 77
# 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.

78
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.3 FATAL_ERROR)
79 80 81
IF(POLICY CMP0025)
  CMAKE_POLICY(SET CMP0025 NEW)
ENDIF()
Matt McCormick's avatar
Matt McCormick committed
82 83 84
IF(POLICY CMP0056)
  CMAKE_POLICY(SET CMP0056 NEW)
ENDIF()
85
SET(CMAKE_LEGACY_CYGWIN_WIN32 0)
86

87 88 89 90
#-----------------------------------------------------------------------------
# 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.
91 92
IF(NOT KWSYS_NAMESPACE)
  SET(KWSYS_NAMESPACE "kwsys")
93
  SET(KWSYS_STANDALONE 1)
94
ENDIF()
95

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

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

106
# Select library components.
107
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
108
  SET(KWSYS_ENABLE_C 1)
109
  # Enable all components.
110
  SET(KWSYS_USE_Base64 1)
111
  SET(KWSYS_USE_Directory 1)
Mathieu Malaterre's avatar
Mathieu Malaterre committed
112
  SET(KWSYS_USE_DynamicLoader 1)
113
  SET(KWSYS_USE_Encoding 1)
Andy Cedilnik's avatar
Andy Cedilnik committed
114
  SET(KWSYS_USE_Glob 1)
115
  SET(KWSYS_USE_MD5 1)
116
  SET(KWSYS_USE_Process 1)
117
  SET(KWSYS_USE_RegularExpression 1)
118
  SET(KWSYS_USE_System 1)
119
  SET(KWSYS_USE_SystemTools 1)
120
  SET(KWSYS_USE_CommandLineArguments 1)
121
  SET(KWSYS_USE_FundamentalType 1)
122
  SET(KWSYS_USE_Terminal 1)
123
  SET(KWSYS_USE_IOStream 1)
124
  SET(KWSYS_USE_FStream 1)
125
  SET(KWSYS_USE_String 1)
126
  SET(KWSYS_USE_SystemInformation 1)
127
  SET(KWSYS_USE_CPU 1)
128
ENDIF()
129 130 131 132

# Enforce component dependencies.
IF(KWSYS_USE_SystemTools)
  SET(KWSYS_USE_Directory 1)
133 134
  SET(KWSYS_USE_FStream 1)
  SET(KWSYS_USE_Encoding 1)
135
ENDIF()
136 137 138 139
IF(KWSYS_USE_Glob)
  SET(KWSYS_USE_Directory 1)
  SET(KWSYS_USE_SystemTools 1)
  SET(KWSYS_USE_RegularExpression 1)
140 141
  SET(KWSYS_USE_FStream 1)
  SET(KWSYS_USE_Encoding 1)
142
ENDIF()
143 144
IF(KWSYS_USE_Process)
  SET(KWSYS_USE_System 1)
145
  SET(KWSYS_USE_Encoding 1)
146
ENDIF()
147 148
IF(KWSYS_USE_SystemInformation)
  SET(KWSYS_USE_Process 1)
149
ENDIF()
150 151
IF(KWSYS_USE_System)
  SET(KWSYS_USE_Encoding 1)
152
ENDIF()
153 154
IF(KWSYS_USE_Directory)
  SET(KWSYS_USE_Encoding 1)
155
ENDIF()
156 157
IF(KWSYS_USE_FStream)
  SET(KWSYS_USE_Encoding 1)
158
ENDIF()
159

Brad King's avatar
Brad King committed
160 161 162
# Setup the large file support default.
IF(KWSYS_LFS_DISABLE)
  SET(KWSYS_LFS_REQUESTED 0)
163
ELSE()
Brad King's avatar
Brad King committed
164
  SET(KWSYS_LFS_REQUESTED 1)
165
ENDIF()
Brad King's avatar
Brad King committed
166

167 168 169
# Specify default 8 bit encoding for Windows
IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
  SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
170
ENDIF()
171

172 173
# Enable testing if building standalone.
IF(KWSYS_STANDALONE)
174
  INCLUDE(Dart)
175 176 177
  MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
  IF(BUILD_TESTING)
    ENABLE_TESTING()
178 179
  ENDIF()
ENDIF()
180

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

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

188 189 190 191 192 193 194
# 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}")
195
ENDIF()
196 197 198
IF(NOT KWSYS_INSTALL_LIB_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
    "${KWSYS_LIBRARY_INSTALL_DIR}")
199
ENDIF()
200 201 202
IF(NOT KWSYS_INSTALL_BIN_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
    "${KWSYS_LIBRARY_INSTALL_DIR}")
203
ENDIF()
204 205 206 207 208 209 210

# 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}
    )
211
ENDIF()
212

213 214 215 216 217 218 219 220 221 222 223 224
# 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)
225
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
226
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
227
      )
228
  ENDIF()
229

230 231 232 233 234 235
  # 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)
236
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
237
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
238
      )
239 240
  ENDIF()
ENDIF()
241 242 243 244 245 246 247
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)
248
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
249
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
250
      )
251 252
  ENDIF()
ENDIF()
253

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

258 259 260 261 262
# 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
263
    ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
264
ENDIF()
265

266 267 268 269 270 271 272 273
# 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()

274 275 276 277
#-----------------------------------------------------------------------------
# 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}")
278
ENDIF()
279

280 281 282 283 284 285 286 287 288 289
#-----------------------------------------------------------------------------
# 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")
290
    ENDIF()
291 292
    IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
293 294
    ENDIF()
  ENDIF()
295 296
  IF(CMAKE_SYSTEM MATCHES "HP-UX")
    SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
297 298 299 300 301 302 303
    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()
304 305
  ENDIF()
ENDIF()
306 307 308 309 310 311 312 313 314
IF(KWSYS_STANDALONE)
  IF(CMAKE_CXX_COMPILER_ID STREQUAL SunPro)
    IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.13)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++03")
    ELSE()
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -library=stlport4")
    ENDIF()
  ENDIF()
ENDIF()
315

316 317
#-----------------------------------------------------------------------------
# Configure Large File Support.
318 319
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDIO
  "Checking whether header cstdio is available" DIRECT)
320 321 322 323 324 325
SET(KWSYS_LFS_AVAILABLE 0)
IF(KWSYS_LFS_REQUESTED)
  # Large File Support is requested.
  SET(KWSYS_LFS_REQUESTED 1)

  # Check for large file support.
326 327
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
    -DKWSYS_CXX_HAS_CSTDIO=${KWSYS_CXX_HAS_CSTDIO})
328 329
  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
    "Checking for Large File Support" DIRECT)
330
  SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
331 332 333

  IF(KWSYS_LFS_WORKS)
    SET(KWSYS_LFS_AVAILABLE 1)
334 335
  ENDIF()
ELSE()
336 337
  # Large File Support is not requested.
  SET(KWSYS_LFS_REQUESTED 0)
338
ENDIF()
339

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

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

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

351 352
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
  -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD})
353 354
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR
  "Checking whether stl string has operator!= for char*" DIRECT)
355 356 357 358 359
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)
360
ELSE()
361 362 363 364
  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)
365
  ELSE()
366 367
    KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY
      "Checking whether stl has internal __iterator_category" DIRECT)
368 369
  ENDIF()
ENDIF()
370 371 372 373
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)
374 375 376 377
  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)
378
ELSE()
379 380 381 382
  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)
383
ENDIF()
384 385
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS
  "Checking whether stl containers support allocator objects." DIRECT)
386
IF(NOT WATCOM)
387 388 389
  # ANSI streams always have string operators.
  SET(KWSYS_STL_STRING_HAVE_OSTREAM 1)
  SET(KWSYS_STL_STRING_HAVE_ISTREAM 1)
390
ELSE()
391 392 393 394 395
  # 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)
396
ENDIF()
397

398 399 400 401 402 403
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)
404 405
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
  "Checking whether argument dependent lookup is supported" DIRECT)
406

407 408 409
IF(UNIX)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
    "Checking whether struct stat has st_mtim member" DIRECT)
410
ENDIF()
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
# 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()

445
IF(KWSYS_USE_FundamentalType)
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
  # 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()
494 495 496 497

  IF(KWSYS_USE___INT64)
    KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
      "Checking whether unsigned __int64 can convert to double" DIRECT)
498
  ELSE()
499
    SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1)
500
  ENDIF()
501 502

  # Check signedness of "char" type.
503 504
  KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
    "Checking whether char is signed" DIRECT)
505
ENDIF()
506

507 508 509 510
IF(KWSYS_USE_Encoding)
  # Look for type size helper macros.
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING
    "Checking whether wstring is available" DIRECT)
511
ENDIF()
512

513 514
IF(KWSYS_USE_IOStream)
  # Determine whether iostreams support long long.
515
  IF(KWSYS_CXX_HAS_LONG_LONG)
516 517 518 519
    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)
520
  ELSE()
521 522
    SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
    SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
523
  ENDIF()
524 525 526 527 528 529 530 531 532
  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()
533
ENDIF()
534

535 536
IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
  SET(KWSYS_NAME_IS_KWSYS 1)
537
ELSE()
538
  SET(KWSYS_NAME_IS_KWSYS 0)
539
ENDIF()
540

Brad King's avatar
Brad King committed
541 542 543
# Choose default shared/static build if not specified.
IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
  SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
544
ENDIF()
Brad King's avatar
Brad King committed
545 546 547 548

IF(KWSYS_BUILD_SHARED)
  SET(KWSYS_BUILD_SHARED 1)
  SET(KWSYS_LIBRARY_TYPE SHARED)
549
ELSE()
Brad King's avatar
Brad King committed
550 551
  SET(KWSYS_BUILD_SHARED 0)
  SET(KWSYS_LIBRARY_TYPE STATIC)
552
ENDIF()
Brad King's avatar
Brad King committed
553

554 555 556
#-----------------------------------------------------------------------------
# Configure some implementation details.

557 558 559 560 561 562 563 564
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}"
  )

565 566 567 568 569 570 571
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)
572 573 574 575
  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)
576 577 578 579
  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}
580 581
    KWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES}
    KWSYS_CXX_HAS_UTIMENSAT=${KWSYS_CXX_HAS_UTIMENSAT}
582
    )
583
ENDIF()
584

585
IF(KWSYS_USE_SystemInformation)
586 587
  SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
    COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
588 589 590 591 592
  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
593
        COMPILE_DEFINITIONS KWSYS_SYS_HAS_IFADDRS_H=1)
594 595
    ENDIF()
  ENDIF()
596 597 598 599 600 601 602
  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
603
        COMPILE_DEFINITIONS KWSYS_SYS_HAS_PSAPI=1)
604
      IF(MSVC70 OR MSVC71)
605 606
        # Suppress LNK4089: all references to 'PSAPI.DLL' discarded by /OPT:REF
        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /IGNORE:4089")
607 608 609
      ENDIF()
    ENDIF()
  ENDIF()
610 611 612 613 614 615 616
  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()
617 618 619 620 621 622 623
  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()
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
  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()
652 653 654 655 656 657
  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")
658
    MARK_AS_ADVANCED(EXECINFO_LIB)
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 713 714
    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()
715 716 717 718 719 720 721 722 723 724 725 726 727 728
  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()
729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748
  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()
749 750 751 752 753 754 755 756 757

  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()
758 759
ENDIF()

760 761
#-----------------------------------------------------------------------------
# Choose a directory for the generated headers.
762 763
IF(NOT KWSYS_HEADER_ROOT)
  SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
764
ENDIF()
765
SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
766
INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
767

768 769 770 771 772 773 774 775
#-----------------------------------------------------------------------------
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}
      )
776
  ENDIF()
777 778 779 780 781

  # 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})
782
ENDIF()
783

784 785 786
#-----------------------------------------------------------------------------
# Create STL header wrappers to block warnings in the STL headers and
# give standard names by which they may be included.
787
SET(KWSYS_STL_HEADER_EXTRA_string 1)
788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806
FOREACH(header
  algorithm
  deque
  exception
  functional
  iterator
  list
  map
  memory
  new
  numeric
  queue
  set
  stack
  stdexcept
  string
  utility
  vector
  )
807 808
  # Configure the header wrapper.
  SET(KWSYS_STL_HEADER "${header}")
809 810 811 812 813 814
  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)
815 816
    IF(KWSYS_INSTALL_INCLUDE_DIR)
      INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx
817 818
        DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
        ${KWSYS_INSTALL_INCLUDE_OPTIONS})
819 820
    ENDIF()
  ELSE()
821
    SET(KWSYS_STL_HEADER_EXTRA "")
822
  ENDIF()
823
  CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in
824
                 ${KWSYS_HEADER_DIR}/stl/${header}
825
                 @ONLY IMMEDIATE)
826

827
  # Create an install target for the header wrapper.
828 829
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}
830 831
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
832 833
  ENDIF()
ENDFOREACH()
834

835 836 837 838
# Provide cstddef header.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in
               ${KWSYS_HEADER_DIR}/cstddef
               @ONLY IMMEDIATE)
839 840 841 842
IF(KWSYS_INSTALL_INCLUDE_DIR)
  INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef
    DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
    ${KWSYS_INSTALL_INCLUDE_OPTIONS})
843
ENDIF()
844

845 846 847 848
#-----------------------------------------------------------------------------
# Build a list of classes and headers we need to implement the
# selected components.  Initialize with required components.
SET(KWSYS_CLASSES)
849
SET(KWSYS_H_FILES Configure SharedForward)
850 851 852 853
SET(KWSYS_HXX_FILES Configure String
  hashtable hash_fun hash_map hash_set
  auto_ptr
  )
854 855

# Add selected C++ classes.
856
SET(cppclasses
857
  Directory DynamicLoader Encoding Glob RegularExpression SystemTools
858
  CommandLineArguments IOStream FStream SystemInformation
859
  )
860 861
FOREACH(cpp ${cppclasses})
  IF(KWSYS_USE_${cpp})
862
    # Use the corresponding class.
863
    SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
864 865

    # Load component-specific CMake code.
866
    IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
867
      INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
868 869 870
    ENDIF()
  ENDIF()
ENDFOREACH()
871 872

# Add selected C components.
873
FOREACH(c
874
    Process Base64 Encoding FundamentalType MD5 Terminal System String CPU
875
    )
876
  IF(KWSYS_USE_${c})
877
    # Use the corresponding header file.
878
    SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
879 880

    # Load component-specific CMake code.
881
    IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
882
      INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
883 884 885
    ENDIF()
  ENDIF()
ENDFOREACH()
886

887 888 889
#-----------------------------------------------------------------------------
# Build a list of sources for the library based on components that are
# included.
890 891
SET(KWSYS_C_SRCS)
SET(KWSYS_CXX_SRCS)
892 893 894

# Add the proper sources for this platform's Process implementation.
IF(KWSYS_USE_Process)
895
  IF(NOT UNIX)
896 897
    # Use the Windows implementation.
    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c)
898
  ELSE()
899
    # Use the UNIX implementation.
900
    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
901 902
  ENDIF()
ENDIF()
903

904
# Add selected C sources.
905
FOREACH(c Base64 Encoding MD5 Terminal System String)
906
  IF(KWSYS_USE_${c})
907 908 909 910 911
    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()
912 913
  ENDIF()
ENDFOREACH()
Andy Cedilnik's avatar
Andy Cedilnik committed
914

915 916 917
# 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.
918 919
  IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}CXX.cxx)
    LIST(APPEND KWSYS_CXX_SRCS ${c}CXX.cxx)
920
  ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${c}.cxx)
921 922
    LIST(APPEND KWSYS_CXX_SRCS ${c}.cxx)
  ENDIF()
923

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

  # Create an install target for the header.
930 931
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
932 933
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
934 935
  ENDIF()
ENDFOREACH()
936

937 938 939 940
# 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
941
                 @ONLY IMMEDIATE)
942
  SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)
943 944

  # Create an install target for the header.
945 946
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
947 948
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
949 950
  ENDIF()
ENDFOREACH()
951

952 953 954 955
# 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
956
                 @ONLY IMMEDIATE)
957
  SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)
958

959
  # Create an install target for the header.
960 961
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
962 963
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
964 965
  ENDIF()
ENDFOREACH()
966

967 968
#-----------------------------------------------------------------------------
# Add the library with the configured name and list of sources.
969 970 971
IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
  ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE}
    ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
972
  SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB})
973 974
  IF(KWSYS_USE_DynamicLoader)
    IF(UNIX)
975
      TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
976 977
    ENDIF()
  ENDIF()
978

</