CMakeLists.txt 48.1 KB
Newer Older
1 2
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing#kwsys for details.
3 4 5

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

# Typical usage is to import the kwsys directory tree into a
10 11 12
# 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:
13
#
14 15
#  SET(KWSYS_NAMESPACE foosys)
#  SET(KWSYS_USE_Directory 1)    # Enable Directory class.
16 17 18 19
#  SUBDIRS(kwsys)
#
# Optional settings are as follows:
#
20 21 22
#  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.
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#  KWSYS_SPLIT_OBJECTS_FROM_INTERFACE
#                    = Instead of creating a single ${KWSYS_NAMESPACE} library
#                      target, create three separate targets:
#                        ${KWSYS_NAMESPACE}
#                          - An INTERFACE library only containing usage
#                            requirements.
#                        ${KWSYS_NAMESPACE}_objects
#                          - An OBJECT library for the built kwsys objects.
#                            Note: This is omitted from the install rules
#                        ${KWSYS_NAMESPACE}_private
#                          - An INTERFACE library combining both that is
#                            appropriate for use with PRIVATE linking in
#                            target_link_libraries. Because of how interface
#                            properties propagate, this target is not suitable
#                            for use with PUBLIC or INTERFACE linking.
38
#  KWSYS_ALIAS_TARGET = The name of an alias target to create to the actual target.
39 40 41
#
#    Example:
#
Andy Cedilnik's avatar
Andy Cedilnik committed
42 43
#      SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
#      INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
44
#
45 46 47 48
#  KWSYS_CXX_STANDARD         = A value for CMAKE_CXX_STANDARD within KWSys.
#                               Set to empty string to use no default value.
#  KWSYS_CXX_COMPILE_FEATURES = target_compile_features arguments for KWSys.
#
49
# Optional settings to setup install rules are as follows:
50 51 52 53 54 55
#
#  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 '/'.
56 57
#  KWSYS_INSTALL_DOC_DIR     = The installation target directory for documentation
#                              such as copyright information.
58 59 60 61 62 63
#
#  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.
#
64 65
#  KWSYS_INSTALL_EXPORT_NAME = The EXPORT option value for install(TARGETS) calls.
#
66 67 68 69 70 71 72
#    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)
73 74 75

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

81 82 83 84 85 86 87 88
# 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.

89
CMAKE_MINIMUM_REQUIRED(VERSION 3.1 FATAL_ERROR)
90 91 92
FOREACH(p
    CMP0056 # CMake 3.2, Honor link flags in try_compile() source-file signature.
    CMP0063 # CMake 3.3, Honor visibility properties for all target types.
93
    CMP0067 # CMake 3.8, Honor language standard in try_compile source-file signature.
94
    CMP0069 # CMake 3.9, INTERPROCEDURAL_OPTIMIZATION is enforced when enabled.
95 96 97 98 99
    )
  IF(POLICY ${p})
    CMAKE_POLICY(SET ${p} NEW)
  ENDIF()
ENDFOREACH()
100

101 102 103 104
#-----------------------------------------------------------------------------
# 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.
105 106
IF(NOT KWSYS_NAMESPACE)
  SET(KWSYS_NAMESPACE "kwsys")
107
  SET(KWSYS_STANDALONE 1)
108
ENDIF()
109

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

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

120 121 122
if(KWSYS_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD "${KWSYS_CXX_STANDARD}")
elseif(NOT DEFINED CMAKE_CXX_STANDARD AND NOT DEFINED KWSYS_CXX_STANDARD)
123 124 125 126 127 128 129 130
  if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
     AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"
     AND "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU"
    )
    set(CMAKE_CXX_STANDARD 14)
  else()
    set(CMAKE_CXX_STANDARD 11)
  endif()
131 132
endif()

133
# Select library components.
134
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
135
  SET(KWSYS_ENABLE_C 1)
136
  # Enable all components.
137
  SET(KWSYS_USE_Base64 1)
138
  SET(KWSYS_USE_Directory 1)
139
  SET(KWSYS_USE_DynamicLoader 1)
140
  SET(KWSYS_USE_Encoding 1)
Andy Cedilnik's avatar
Andy Cedilnik committed
141
  SET(KWSYS_USE_Glob 1)
142
  SET(KWSYS_USE_MD5 1)
143
  SET(KWSYS_USE_Process 1)
144
  SET(KWSYS_USE_RegularExpression 1)
145
  SET(KWSYS_USE_System 1)
146
  SET(KWSYS_USE_SystemTools 1)
147
  SET(KWSYS_USE_CommandLineArguments 1)
148
  SET(KWSYS_USE_Terminal 1)
149
  SET(KWSYS_USE_IOStream 1)
150
  SET(KWSYS_USE_FStream 1)
151
  SET(KWSYS_USE_String 1)
152
  SET(KWSYS_USE_SystemInformation 1)
153
  SET(KWSYS_USE_ConsoleBuf 1)
154
ENDIF()
155 156 157 158

# Enforce component dependencies.
IF(KWSYS_USE_SystemTools)
  SET(KWSYS_USE_Directory 1)
159 160
  SET(KWSYS_USE_FStream 1)
  SET(KWSYS_USE_Encoding 1)
161
ENDIF()
162 163 164 165
IF(KWSYS_USE_Glob)
  SET(KWSYS_USE_Directory 1)
  SET(KWSYS_USE_SystemTools 1)
  SET(KWSYS_USE_RegularExpression 1)
166 167
  SET(KWSYS_USE_FStream 1)
  SET(KWSYS_USE_Encoding 1)
168
ENDIF()
169 170
IF(KWSYS_USE_Process)
  SET(KWSYS_USE_System 1)
171
  SET(KWSYS_USE_Encoding 1)
172
ENDIF()
173 174
IF(KWSYS_USE_SystemInformation)
  SET(KWSYS_USE_Process 1)
175
ENDIF()
176 177
IF(KWSYS_USE_System)
  SET(KWSYS_USE_Encoding 1)
178
ENDIF()
179 180
IF(KWSYS_USE_Directory)
  SET(KWSYS_USE_Encoding 1)
181
ENDIF()
182 183 184
IF(KWSYS_USE_DynamicLoader)
  SET(KWSYS_USE_Encoding 1)
ENDIF()
185 186
IF(KWSYS_USE_FStream)
  SET(KWSYS_USE_Encoding 1)
187
ENDIF()
188 189 190
IF(KWSYS_USE_ConsoleBuf)
  SET(KWSYS_USE_Encoding 1)
ENDIF()
191

192 193 194
# Specify default 8 bit encoding for Windows
IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
  SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
195
ENDIF()
196

197 198
# Enable testing if building standalone.
IF(KWSYS_STANDALONE)
199
  INCLUDE(Dart)
200 201 202
  MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
  IF(BUILD_TESTING)
    ENABLE_TESTING()
203 204
  ENDIF()
ENDIF()
205

206 207 208 209 210
# Choose default shared/static build if not specified.
IF(NOT DEFINED KWSYS_BUILD_SHARED)
  SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
ENDIF()

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

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

218 219 220 221 222 223 224
# 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}")
225
ENDIF()
226 227 228
IF(NOT KWSYS_INSTALL_LIB_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
    "${KWSYS_LIBRARY_INSTALL_DIR}")
229
ENDIF()
230 231 232
IF(NOT KWSYS_INSTALL_BIN_DIR)
  STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
    "${KWSYS_LIBRARY_INSTALL_DIR}")
233
ENDIF()
234 235 236 237 238 239 240

# 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}
    )
241
ENDIF()
242

243 244
# Setup library install rules.
SET(KWSYS_INSTALL_LIBRARY_RULE)
245
SET(KWSYS_INSTALL_NAMELINK_RULE)
246 247 248 249 250 251
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}
252
    LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_SKIP
253 254 255
    )
  # Assign the shared library to the runtime component.
  IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
256
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
257
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
258
      )
259
  ENDIF()
260 261 262 263 264 265 266 267 268 269 270
  IF(KWSYS_BUILD_SHARED)
    SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
      LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR} NAMELINK_ONLY
      )
    # Assign the namelink to the development component.
    IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
      SET(KWSYS_INSTALL_NAMELINK_RULE ${KWSYS_INSTALL_NAMELINK_RULE}
        COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
        )
    ENDIF()
  ENDIF()
271

272 273 274 275 276 277
  # 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)
278
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
279
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
280
      )
281 282
  ENDIF()
ENDIF()
283 284 285 286 287 288 289
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)
290
    SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
291
      COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
292
      )
293 294
  ENDIF()
ENDIF()
295

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

300 301 302 303 304
# 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
305
    ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
306
ENDIF()
307

308 309 310 311 312 313 314 315
# 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()

316 317 318 319
#-----------------------------------------------------------------------------
# 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}")
320
ENDIF()
321

322 323 324 325 326 327 328 329 330 331
#-----------------------------------------------------------------------------
# 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")
332
    ENDIF()
333 334
    IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
      SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
335 336
    ENDIF()
  ENDIF()
337 338
  IF(CMAKE_SYSTEM MATCHES "HP-UX")
    SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
339 340 341 342 343 344 345
    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()
346 347
  ENDIF()
ENDIF()
348 349 350 351 352 353 354 355 356
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()
357

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

363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395
# 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()

396 397 398 399
IF(KWSYS_USE_Encoding)
  # Look for type size helper macros.
  KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING
    "Checking whether wstring is available" DIRECT)
400
ENDIF()
401

402 403
IF(KWSYS_USE_IOStream)
  # Determine whether iostreams support long long.
404
  IF(KWSYS_CXX_HAS_LONG_LONG)
405 406 407 408
    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)
409
  ELSE()
410 411
    SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
    SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
412
  ENDIF()
413 414 415 416 417 418 419 420 421
  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()
422
ENDIF()
423

424 425
IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
  SET(KWSYS_NAME_IS_KWSYS 1)
426
ELSE()
427
  SET(KWSYS_NAME_IS_KWSYS 0)
428
ENDIF()
429

Brad King's avatar
Brad King committed
430 431 432
IF(KWSYS_BUILD_SHARED)
  SET(KWSYS_BUILD_SHARED 1)
  SET(KWSYS_LIBRARY_TYPE SHARED)
433
ELSE()
Brad King's avatar
Brad King committed
434 435
  SET(KWSYS_BUILD_SHARED 0)
  SET(KWSYS_LIBRARY_TYPE STATIC)
436
ENDIF()
Brad King's avatar
Brad King committed
437

438 439 440 441
if(NOT DEFINED KWSYS_BUILD_PIC)
  set(KWSYS_BUILD_PIC 0)
endif()

442 443 444
#-----------------------------------------------------------------------------
# Configure some implementation details.

445 446 447 448
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)
449 450 451 452 453
IF(KWSYS_USE_Process)
  KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC
    "Checking whether C compiler has clock_gettime" DIRECT)
ENDIF()

454
SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c System.c PROPERTIES
455
  COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T} -DKWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC=${KWSYS_C_HAS_CLOCK_GETTIME_MONOTONIC}"
456 457
  )

458 459 460 461 462
IF(DEFINED KWSYS_PROCESS_USE_SELECT)
  GET_PROPERTY(ProcessUNIX_FLAGS SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS)
  SET_PROPERTY(SOURCE ProcessUNIX.c PROPERTY COMPILE_FLAGS "${ProcessUNIX_FLAGS} -DKWSYSPE_USE_SELECT=${KWSYSPE_USE_SELECT}")
ENDIF()

463 464 465 466 467 468 469 470 471 472 473
IF(KWSYS_USE_DynamicLoader)
  GET_PROPERTY(KWSYS_SUPPORTS_SHARED_LIBS GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
  IF(KWSYS_SUPPORTS_SHARED_LIBS)
    SET(KWSYS_SUPPORTS_SHARED_LIBS 1)
  ELSE()
    SET(KWSYS_SUPPORTS_SHARED_LIBS 0)
  ENDIF()
  SET_PROPERTY(SOURCE DynamicLoader.cxx APPEND PROPERTY COMPILE_DEFINITIONS
    KWSYS_SUPPORTS_SHARED_LIBS=${KWSYS_SUPPORTS_SHARED_LIBS})
ENDIF()

474
IF(KWSYS_USE_SystemTools)
475 476 477 478 479 480 481 482
  if (NOT DEFINED KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
    set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
  endif ()
  if (KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP)
    set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 1)
  else ()
    set(KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP 0)
  endif ()
483 484 485 486 487 488
  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)
489 490 491 492
  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)
493 494 495 496
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIM
    "Checking whether CXX compiler struct stat has st_mtim member" DIRECT)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_STAT_HAS_ST_MTIMESPEC
    "Checking whether CXX compiler struct stat has st_mtimespec member" DIRECT)
497 498 499 500 501 502
  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}
503 504
    KWSYS_CXX_STAT_HAS_ST_MTIM=${KWSYS_CXX_STAT_HAS_ST_MTIM}
    KWSYS_CXX_STAT_HAS_ST_MTIMESPEC=${KWSYS_CXX_STAT_HAS_ST_MTIMESPEC}
505
    )
506 507 508 509 510 511 512 513 514 515
  IF(NOT WIN32)
    IF(KWSYS_STANDALONE)
      OPTION(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES "If true, Windows paths will be supported on Unix as well" ON)
    ENDIF()
    IF(KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES)
      SET_PROPERTY(SOURCE SystemTools.cxx testSystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
        KWSYS_SYSTEMTOOLS_SUPPORT_WINDOWS_SLASHES
        )
    ENDIF()
  ENDIF()
516 517 518 519 520 521 522 523

  # Disable getpwnam for static linux builds since it depends on shared glibc
  GET_PROPERTY(SHARED_LIBS_SUPPORTED GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
  IF(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT SHARED_LIBS_SUPPORTED)
    SET_PROPERTY(SOURCE SystemTools.cxx APPEND PROPERTY COMPILE_DEFINITIONS
      HAVE_GETPWNAM=0
      )
  ENDIF()
524
ENDIF()
525

526
IF(KWSYS_USE_SystemInformation)
527 528
  SET_PROPERTY(SOURCE SystemInformation.cxx APPEND PROPERTY
    COMPILE_DEFINITIONS SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P})
529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
  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()
551 552 553 554 555 556 557
  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()
558 559 560 561 562 563 564
  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()
565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589
  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()
590 591 592 593 594 595
  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")
596
    MARK_AS_ADVANCED(EXECINFO_LIB)
597 598 599 600 601 602
    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
603
      # can be used with this compiler
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652
      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()
653 654 655 656 657 658 659 660 661 662 663 664 665 666
  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()
667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
  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()
687 688 689 690 691 692 693 694 695

  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()
696 697
ENDIF()

698 699 700 701 702
IF(KWSYS_USE_FStream)
  KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H
    "Checking whether <ext/stdio_filebuf.h> is available" DIRECT)
ENDIF()

703 704
#-----------------------------------------------------------------------------
# Choose a directory for the generated headers.
705 706
IF(NOT KWSYS_HEADER_ROOT)
  SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
707
ENDIF()
708
SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
709
INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
710

711 712 713 714 715 716 717 718
#-----------------------------------------------------------------------------
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}
      )
719
  ENDIF()
720 721 722 723 724

  # 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})
725
ENDIF()
726

727 728 729 730
#-----------------------------------------------------------------------------
# Build a list of classes and headers we need to implement the
# selected components.  Initialize with required components.
SET(KWSYS_CLASSES)
731
SET(KWSYS_H_FILES Configure SharedForward)
732 733 734 735 736 737 738
SET(KWSYS_HXX_FILES Configure String)

IF(NOT CMake_SOURCE_DIR)
  SET(KWSYS_HXX_FILES ${KWSYS_HXX_FILES}
    hashtable hash_fun hash_map hash_set
    )
ENDIF()
739 740

# Add selected C++ classes.
741
SET(cppclasses
742
  Directory DynamicLoader Encoding Glob RegularExpression SystemTools
743
  CommandLineArguments IOStream FStream SystemInformation ConsoleBuf
744
  )
745 746
FOREACH(cpp ${cppclasses})
  IF(KWSYS_USE_${cpp})
747
    # Use the corresponding class.
748
    SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
749 750

    # Load component-specific CMake code.
751
    IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
752
      INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
753 754 755
    ENDIF()
  ENDIF()
ENDFOREACH()
756 757

# Add selected C components.
758
FOREACH(c
759
    Process Base64 Encoding MD5 Terminal System String
760
    )
761
  IF(KWSYS_USE_${c})
762
    # Use the corresponding header file.
763
    SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
764 765

    # Load component-specific CMake code.
766
    IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
767
      INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
768 769 770
    ENDIF()
  ENDIF()
ENDFOREACH()
771

772 773 774
#-----------------------------------------------------------------------------
# Build a list of sources for the library based on components that are
# included.
775 776
SET(KWSYS_C_SRCS)
SET(KWSYS_CXX_SRCS)
777 778 779

# Add the proper sources for this platform's Process implementation.
IF(KWSYS_USE_Process)
780
  IF(NOT UNIX)
781 782
    # Use the Windows implementation.
    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c)
783
  ELSE()
784
    # Use the UNIX implementation.
785
    SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
786 787
  ENDIF()
ENDIF()
788

789
# Add selected C sources.
790
FOREACH(c Base64 Encoding MD5 Terminal System String)
791
  IF(KWSYS_USE_${c})
792 793 794 795 796
    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()
797 798
  ENDIF()
ENDFOREACH()
799

800 801 802
# 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.
803 804 805 806 807
  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()
808

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

  # Create an install target for the header.
815 816
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
817 818
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
819 820
  ENDIF()
ENDFOREACH()
821

822 823 824 825
# 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
826
                 @ONLY IMMEDIATE)
827
  SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)
828 829

  # Create an install target for the header.
830 831
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
832 833
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
834 835
  ENDIF()
ENDFOREACH()
836

837 838 839 840
# 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
841
                 @ONLY IMMEDIATE)
842
  SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)
843

844
  # Create an install target for the header.
845 846
  IF(KWSYS_INSTALL_INCLUDE_DIR)
    INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
847 848
      DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
      ${KWSYS_INSTALL_INCLUDE_OPTIONS})
849 850
  ENDIF()
ENDFOREACH()
851

852 853
#-----------------------------------------------------------------------------
# Add the library with the configured name and list of sources.
854
IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
855 856 857 858 859 860 861 862
  IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
    SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
    SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE}_objects)
    SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE}_private)
    SET(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_INTERFACE} ${KWSYS_TARGET_LINK})
    SET(KWSYS_LINK_DEPENDENCY INTERFACE)
    ADD_LIBRARY(${KWSYS_TARGET_OBJECT} OBJECT
      ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
863
    IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
864 865 866 867 868 869 870 871 872
      SET_PROPERTY(TARGET ${KWSYS_TARGET_OBJECT} PROPERTY
        POSITION_INDEPENDENT_CODE TRUE)
    ENDIF()
    ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} INTERFACE)
    ADD_LIBRARY(${KWSYS_TARGET_LINK} INTERFACE)
    TARGET_LINK_LIBRARIES(${KWSYS_TARGET_LINK} INTERFACE
      ${KWSYS_TARGET_INTERFACE})
    TARGET_SOURCES(${KWSYS_TARGET_LINK} INTERFACE
      $<TARGET_OBJECTS:${KWSYS_TARGET_OBJECT}>)
873 874
    target_compile_features(${KWSYS_TARGET_OBJECT} PRIVATE ${KWSYS_CXX_COMPILE_FEATURES})
    target_compile_features(${KWSYS_TARGET_INTERFACE} INTERFACE ${KWSYS_CXX_COMPILE_FEATURES})
875 876 877 878 879 880 881 882
  ELSE()
    SET(KWSYS_TARGET_INTERFACE ${KWSYS_NAMESPACE})
    SET(KWSYS_TARGET_OBJECT ${KWSYS_NAMESPACE})
    SET(KWSYS_TARGET_LINK ${KWSYS_NAMESPACE})
    set(KWSYS_TARGET_INSTALL ${KWSYS_TARGET_LINK})
    SET(KWSYS_LINK_DEPENDENCY PUBLIC)
    ADD_LIBRARY(${KWSYS_TARGET_INTERFACE} ${KWSYS_LIBRARY_TYPE}
      ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
883
    target_compile_features(${KWSYS_TARGET_INTERFACE} PUBLIC ${KWSYS_CXX_COMPILE_FEATURES})
884
  ENDIF()
885 886 887
  if (KWSYS_ALIAS_TARGET)
    add_library(${KWSYS_ALIAS_TARGET} ALIAS ${KWSYS_TARGET_INTERFACE})
  endif ()
888 889 890 891 892 893
  SET_TARGET_PROPERTIES(${KWSYS_TARGET_OBJECT} PROPERTIES
    C_CLANG_TIDY ""
    CXX_CLANG_TIDY ""
    C_INCLUDE_WHAT_YOU_USE ""
    CXX_INCLUDE_WHAT_YOU_USE ""
    LABELS "${KWSYS_LABELS_LIB}")
894 895
  IF(KWSYS_USE_DynamicLoader)
    IF(UNIX)
896 897
      TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
        ${CMAKE_DL_LIBS})
898 899
    ENDIF()
  ENDIF()
900

901 902
  IF(KWSYS_USE_SystemInformation)
    IF(WIN32)
903
      TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} ws2_32)
904 905 906 907 908
      # link in dbghelp.dll for symbol lookup if MSVC 1800 or later
      # Note that the dbghelp runtime is part of MS Windows OS
      IF(MSVC_VERSION AND NOT MSVC_VERSION VERSION_LESS 1800)
        TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY} dbghelp)
      ENDIF()
909
      IF(KWSYS_SYS_HAS_PSAPI)
910 911
        TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
          Psapi)
912 913 914 915
      ENDIF()
    ELSEIF(UNIX)
      IF (EXECINFO_LIB AND KWSYS_CXX_HAS_BACKTRACE)
        # backtrace on FreeBSD is not in libc
916 917
        TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
          ${EXECINFO_LIB})
918 919 920
      ENDIF()
      IF (KWSYS_CXX_HAS_DLADDR)
        # for symbol lookup using dladdr
921 922
        TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
          ${CMAKE_DL_LIBS})
923
      ENDIF()
924
      IF (CMAKE_SYSTEM_NAME STREQUAL "SunOS")
925 926
        TARGET_LINK_LIBRARIES(${KWSYS_TARGET_INTERFACE} ${KWSYS_LINK_DEPENDENCY}
          socket)
927
      ENDIF()
928
    ENDIF()
929
  ENDIF()
930

931 932
  # Apply user-defined target properties to the library.
  IF(KWSYS_PROPERTIES_CXX)
933 934 935 936 937 938 939
    SET_TARGET_PROPERTIES(${KWSYS_TARGET_INTERFACE} PROPERTIES
      ${KWSYS_PROPERTIES_CXX})
  ENDIF()

  # Set up include usage requirement
  IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
    TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
940
      $<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>)
941 942 943 944
    IF(KWSYS_INSTALL_INCLUDE_DIR)
      TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_INTERFACE} INTERFACE
        $<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
    ENDIF()
945
  ENDIF()
946

947
  # Create an install target for the library.
948
  IF(KWSYS_INSTALL_LIBRARY_RULE)
949
    INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_LIBRARY_RULE})
950
  ENDIF()
951 952 953
  IF(KWSYS_INSTALL_NAMELINK_RULE)
    INSTALL(TARGETS ${KWSYS_TARGET_INSTALL} ${KWSYS_INSTALL_NAMELINK_RULE})
  ENDIF()
954
ENDIF()
955 956 957

# Add a C-only library if requested.
IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
958 959 960 961 962 963 964 965
 IF(KWSYS_SPLIT_OBJECTS_FROM_INTERFACE)
    SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
    SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c_objects)
    SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c_private)
    SET(KWSYS_TARGET_C_INSTALL
      ${KWSYS_TARGET_C_INTERFACE} ${KWSYS_TARGET_C_LINK})
    SET(KWSYS_LINK_DEPENDENCY INTERFACE)
    ADD_LIBRARY(${KWSYS_TARGET_C_OBJECT} OBJECT ${KWSYS_C_SRCS})
966
    IF(KWSYS_BUILD_SHARED OR KWSYS_BUILD_PIC)
967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986
      SET_PROPERTY(TARGET ${KWSYS_TARGET_C_OBJECT} PROPERTY
        POSITION_INDEPENDENT_CODE TRUE)
    ENDIF()
    ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} INTERFACE)
    ADD_LIBRARY(${KWSYS_TARGET_C_LINK} INTERFACE)
    TARGET_LINK_LIBRARIES(${KWSYS_TARGET_C_LINK} INTERFACE
      ${KWSYS_TARGET_C_INTERFACE})
    TARGET_SOURCES(${KWSYS_TARGET_C_LINK} INTERFACE
      $<TARGET_OBJECTS:${KWSYS_TARGET_C_OBJECT}>)
  ELSE()
    SET(KWSYS_TARGET_C_INTERFACE ${KWSYS_NAMESPACE}_c)
    SET(KWSYS_TARGET_C_OBJECT ${KWSYS_NAMESPACE}_c)
    SET(KWSYS_TARGET_C_LINK ${KWSYS_NAMESPACE}_c)
    SET(KWSYS_TARGET_C_INSTALL ${KWSYS_TARGET_C_LINK})
    SET(KWSYS_LINK_DEPENDENCY PUBLIC)
    ADD_LIBRARY(${KWSYS_TARGET_C_INTERFACE} ${KWSYS_LIBRARY_TYPE}
      ${KWSYS_C_SRCS})
  ENDIF()
  SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_OBJECT} PROPERTIES
    LABELS "${KWSYS_LABELS_LIB}")
987

988 989
  # Apply user-defined target properties to the library.
  IF(KWSYS_PROPERTIES_C)
990 991 992 993 994 995 996
    SET_TARGET_PROPERTIES(${KWSYS_TARGET_C_INTERFACE} PROPERTIES
      ${KWSYS_PROPERTIES_C})
  ENDIF()

  # Set up include usage requirement
  IF(COMMAND TARGET_INCLUDE_DIRECTORIES)
    TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
997
      $<BUILD_INTERFACE:${KWSYS_HEADER_ROOT}>)
998 999 1000 1001
    IF(KWSYS_INSTALL_INCLUDE_DIR)
      TARGET_INCLUDE_DIRECTORIES(${KWSYS_TARGET_C_INTERFACE} INTERFACE
        $<INSTALL_INTERFACE:${KWSYS_INSTALL_INCLUDE_DIR}>)
    ENDIF()
1002
  ENDIF()
1003

1004
  # Create an install target for the library.
1005
  IF(KWSYS_INSTALL_LIBRARY_RULE)
1006
    INSTALL(TARGETS ${KWSYS_TARGET_C_INSTALL})
1007 1008
  ENDIF()
ENDIF()
1009

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

1014
# Disable deprecation warnings for standard C functions.
1015 1016
IF(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "Intel" OR
   (CMAKE_C_COMPILER_ID STREQUAL "Clang"  AND "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC"))))
1017 1018 1019 1020 1021 1022 1023 1024
  ADD_DEFINITIONS(
    -D_CRT_NONSTDC_NO_DEPRECATE
    -D_CRT_SECURE_NO_DEPRECATE
    -D_CRT_SECURE_NO_WARNINGS
    -D_SCL_SECURE_NO_DEPRECATE
    )
ENDIF()

1025 1026 1027 1028 1029
IF(WIN32)
  # Help enforce the use of wide Windows apis.
  ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
ENDIF()

1030 1031 1032 1033
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")
1034
ENDIF()
1035

1036 1037
IF(KWSYS_USE_Encoding)
  # Set default 8 bit encoding in "EndcodingC.c".
1038
  SET_PROPERTY(SOURCE EncodingC.c EncodingCXX.cxx APPEND PROPERTY COMPILE_DEFINITIONS
1039
    KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
1040
ENDIF()
1041

1042 1043
#-----------------------------------------------------------------------------
# Setup testing if not being built as part of another project.
1044
IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
1045
  IF(BUILD_TESTING)
1046
    # Compute the location of executables.
1047 1048 1049
    SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
    IF(EXECUTABLE_OUTPUT_PATH)
      SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
1050
    ENDIF()
1051

1052 1053
    # C tests
    SET(KWSYS_C_TESTS
1054 1055
      testEncode.c
      testTerminal.c
1056
      )
1057
    IF(KWSYS_STANDALONE)
1058
      SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail.c)
1059
    ENDIF()
1060 1061 1062 1063 1064
    CREATE_TEST_SOURCELIST(
      KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
      ${KWSYS_C_TESTS}
      )
    ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
1065
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
1066
    TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_TARGET_C_LINK})
1067 1068
    FOREACH(testfile ${KWSYS_C_TESTS})
      get_filename_component(test "${testfile}" NAME_WE)
1069
      ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
1070
      SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
1071
    ENDFOREACH()
1072 1073

    # C++ tests
1074
    IF(NOT WATCOM AND NOT CMake_SOURCE_DIR)
1075
      SET(KWSYS_CXX_TESTS
1076
        testHashSTL.cxx
1077
        )
1078
    ENDIF()
1079
    SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
1080 1081 1082 1083 1084
      testConfigure.cxx
      testSystemTools.cxx
      testCommandLineArguments.cxx
      testCommandLineArguments1.cxx
      testDirectory.cxx
1085
      )
1086 1087
    IF(KWSYS_STL_HAS_WSTRING)
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
1088
        testEncoding.cxx
1089
        )
1090
    ENDIF()
1091 1092
    IF(KWSYS_USE_FStream)
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
1093
        testFStream.cxx
1094
        )
1095
    ENDIF()
1096 1097
    IF(KWSYS_USE_ConsoleBuf)
      ADD_EXECUTABLE(testConsoleBufChild testConsoleBufChild.cxx)
1098 1099
      SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_CLANG_TIDY "")
      SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_CLANG_TIDY "")
1100 1101
      SET_PROPERTY(TARGET testConsoleBufChild PROPERTY C_INCLUDE_WHAT_YOU_USE "")
      SET_PROPERTY(TARGET testConsoleBufChild PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
1102
      SET_PROPERTY(TARGET testConsoleBufChild PROPERTY LABELS ${KWSYS_LABELS_EXE})
1103
      TARGET_LINK_LIBRARIES(testConsoleBufChild ${KWSYS_TARGET_LINK})
1104
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
1105
        testConsoleBuf.cxx
1106 1107
        )
      IF("x${CMAKE_CXX_COMPILER_ID}" STREQUAL "xMSVC" AND
1108
         CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "19.0.23506")
1109 1110 1111 1112 1113
        set_property(SOURCE testConsoleBuf.cxx testConsoleBufChild.cxx PROPERTY COMPILE_FLAGS /utf-8)
      ENDIF()
      SET_PROPERTY(SOURCE testConsoleBuf.cxx APPEND PROPERTY COMPILE_DEFINITIONS
        KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
    ENDIF()
Bill Hoffman's avatar
Bill Hoffman committed
1114
    IF(KWSYS_USE_SystemInformation)
1115
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation.cxx)
1116
    ENDIF()
1117
    IF(KWSYS_USE_DynamicLoader)
1118
      SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader.cxx)
1119 1120
      # If kwsys contains the DynamicLoader, need extra library
      ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
1121
      SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
1122
      ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_TARGET_INTERFACE})
1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136

      if (WIN32)
        # Windows tests supported flags.
        add_library(${KWSYS_NAMESPACE}TestDynloadImpl SHARED testDynloadImpl.c)
        set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY LABELS ${KWSYS_LABELS_LIB})
        set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY DEFINE_SYMBOL BUILDING_TestDynloadImpl)
        set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadImpl PROPERTY RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynloaddir")
        add_dependencies(${KWSYS_NAMESPACE}TestDynloadImpl ${KWSYS_TARGET_INTERFACE})
        add_library(${KWSYS_NAMESPACE}TestDynloadUse MODULE testDynloadUse.c)
        set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadUse PROPERTY LABELS ${KWSYS_LABELS_LIB})
        set_property(TARGET ${KWSYS_NAMESPACE}TestDynloadUse PROPERTY LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/dynloaddir")
        add_dependencies(${KWSYS_NAMESPACE}TestDynloadUse ${KWSYS_TARGET_INTERFACE})
        target_link_libraries(${KWSYS_NAMESPACE}TestDynloadUse PRIVATE ${KWSYS_NAMESPACE}TestDynloadImpl)
      endif ()
1137
    ENDIF()
1138 1139 1140 1141 1142
    CREATE_TEST_SOURCELIST(
      KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
      ${KWSYS_CXX_TESTS}
      )
    ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
1143 1144
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_CLANG_TIDY "")
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_CLANG_TIDY "")
1145 1146
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY C_INCLUDE_WHAT_YOU_USE "")
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY CXX_INCLUDE_WHAT_YOU_USE "")
1147
    SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
1148
    TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_TARGET_LINK})
1149 1150 1151

    SET(TEST_SYSTEMTOOLS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
    SET(TEST_SYSTEMTOOLS_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
1152 1153 1154 1155 1156
    CONFIGURE_FILE(
      ${PROJECT_SOURCE_DIR}/testSystemTools.h.in
      ${PROJECT_BINARY_DIR}/testSystemTools.h)
    INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})

1157 1158 1159 1160
    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")
1161
    ENDIF()
1162 1163

    SET(KWSYS_TEST_ARGS_testCommandLineArguments
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174
      --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
1175
      -BBtrue
1176 1177 1178 1179
      -BBfalse
      -SS=ken
      -A
      -C=test
1180 1181 1182
      --long2 hello
      )
    SET(KWSYS_TEST_ARGS_testCommandLineArguments1
1183 1184 1185 1186 1187 1188
      --ignored
      -n 24
      --second-ignored
      "-m=test value"
      third-ignored
      -p
1189 1190
      some junk at the end
      )
1191 1192
    FOREACH(testfile ${KWSYS_CXX_TESTS})
      get_filename_component(test "${testfile}" NAME_WE)
1193
      ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
1194
      SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
1195
    ENDFOREACH()
1196 1197 1198

    # Process tests.
    ADD_EXECUTABLE(${KWSYS_NAMESPACE