Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / kwsys / CMakeLists.txt
blob40dad9c05d1dff657060e4191e69cc13377e8fbc
1 #=============================================================================
3 #  Program:   KWSys - Kitware System Library
4 #  Module:    $RCSfile: CMakeLists.txt,v $
6 #  Copyright (c) Kitware, Inc., Insight Consortium.  All rights reserved.
7 #  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 #     This software is distributed WITHOUT ANY WARRANTY; without even
10 #     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11 #     PURPOSE.  See the above copyright notices for more information.
13 #=============================================================================
15 # The Kitware System Library is intended to be included in other
16 # projects.  It is completely configurable in that the library's
17 # namespace can be configured and the components that are included can
18 # be selected invididually.
20 # Typical usage is to import the kwsys directory tree into a
21 # subdirectory under a parent project and enable the classes that will
22 # be used.  All classes are disabled by default.  The CMake listfile
23 # above this one configures the library as follows:
25 #  SET(KWSYS_NAMESPACE foosys)
26 #  SET(KWSYS_USE_Directory 1)    # Enable Directory class.
27 #  SUBDIRS(kwsys)
29 # Optional settings are as follows:
31 #  KWSYS_HEADER_ROOT = The directory into which to generate the kwsys headers.
32 #                      A directory called "${KWSYS_NAMESPACE}" will be
33 #                      created under this root directory to hold the files.
35 #    Example:
37 #      SET(KWSYS_HEADER_ROOT ${PROJECT_BINARY_DIR})
38 #      INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
40 #  KWSYS_IOS_FORCE_OLD = Force use of old non-ANSI C++ streams even if
41 #                        new streams are available.  This may be used
42 #                        by projects that cannot configure their
43 #                        streams library.
44 #    Example:
46 #      SET(KWSYS_IOS_FORCE_OLD 1)
49 # Optional settings to setup install rules work in one of two ways.
50 # The modern way utilizes the CMake 2.4 INSTALL command.  Settings
51 # for this mode are as follows:
53 #  KWSYS_INSTALL_BIN_DIR     = The installation target directories into
54 #  KWSYS_INSTALL_LIB_DIR       which the libraries and headers from
55 #  KWSYS_INSTALL_INCLUDE_DIR   kwsys should be installed by a "make install".
56 #                              The values should be specified relative to
57 #                              the installation prefix and NOT start with '/'.
59 #  KWSYS_INSTALL_COMPONENT_NAME_RUNTIME     = Name of runtime and development
60 #  KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT   installation components.
61 #                                             If not given the install rules
62 #                                             will not be in any component.
64 #    Example:
66 #      SET(KWSYS_INSTALL_BIN_DIR bin)
67 #      SET(KWSYS_INSTALL_LIB_DIR lib)
68 #      SET(KWSYS_INSTALL_INCLUDE_DIR include)
69 #      SET(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME Runtime)
70 #      SET(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT Development)
72 # The old way uses the original CMake INSTALL_* commands.  Settings
73 # for this mode are as follows:
75 #  KWSYS_LIBRARY_INSTALL_DIR = The installation target directories into
76 #  KWSYS_HEADER_INSTALL_DIR    which the libraries and headers from
77 #                              kwsys should be installed by a "make install".
78 #                              The values should be specified relative to
79 #                              the installation prefix and start with a '/'.
80 #    Example:
82 #      SET(KWSYS_LIBRARY_INSTALL_DIR /lib)
83 #      SET(KWSYS_HEADER_INSTALL_DIR /include)
85 # The modern way will be used whenever the INSTALL command is
86 # available.  If the settings are not available the old names will be
87 # used to construct them.  The old way will be used whenever the
88 # INSTALL command is not available.  If the settings are not available
89 # the new names will be used to construct them.
91 # Once configured, kwsys should be used as follows from C or C++ code:
93 #  #include <foosys/Directory.hxx>
94 #   ...
95 #  foosys::Directory directory;
98 # NOTE: This library is intended for internal use by Kitware-driven
99 # projects.  In order to keep it simple no attempt will be made to
100 # maintain backward compatibility when changes are made to KWSys.
101 # When an incompatible change is made Kitware's projects that use
102 # KWSys will be fixed, but no notification will necessarily be sent to
103 # any outside mailing list and no documentation of the change will be
104 # written.
106 #-----------------------------------------------------------------------------
107 # If a namespace is not specified, use "kwsys" and enable testing.
108 # This should be the case only when kwsys is not included inside
109 # another project and is being tested.
110 IF(NOT KWSYS_NAMESPACE)
111   SET(KWSYS_NAMESPACE "kwsys")
112   SET(KWSYS_STANDALONE 1)
113 ENDIF(NOT KWSYS_NAMESPACE)
114 IF(KWSYS_STANDALONE)
115   CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
116   IF(COMMAND CMAKE_POLICY)
117     CMAKE_POLICY(SET CMP0003 NEW)
118   ENDIF(COMMAND CMAKE_POLICY)
119 ENDIF(KWSYS_STANDALONE)
121 #-----------------------------------------------------------------------------
122 # The project name is that of the specified namespace.
123 PROJECT(${KWSYS_NAMESPACE})
125 # Some properties we set only with CMake 2.6 and above.
126 IF(COMMAND SET_PROPERTY)
127   MACRO(KWSYS_SET_PROPERTY)
128     SET_PROPERTY(${ARGV})
129   ENDMACRO(KWSYS_SET_PROPERTY)
130 ELSE(COMMAND SET_PROPERTY)
131   MACRO(KWSYS_SET_PROPERTY)
132   ENDMACRO(KWSYS_SET_PROPERTY)
133 ENDIF(COMMAND SET_PROPERTY)
135 # Tell CMake how to follow dependencies of sources in this directory.
136 IF(COMMAND SET_PROPERTY)
137   SET_PROPERTY(DIRECTORY
138     PROPERTY IMPLICIT_DEPENDS_INCLUDE_TRANSFORM
139     "KWSYS_HEADER(%)=<${KWSYS_NAMESPACE}/%>"
140     )
141 ENDIF(COMMAND SET_PROPERTY)
143 # Select library components.
144 IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
145   SET(KWSYS_ENABLE_C 1)
147   # Enable all components.
148   SET(KWSYS_USE_Base64 1)
149   SET(KWSYS_USE_Directory 1)
150   SET(KWSYS_USE_DynamicLoader 1)
151   SET(KWSYS_USE_Glob 1)
152   SET(KWSYS_USE_MD5 1)
153   SET(KWSYS_USE_Process 1)
154   SET(KWSYS_USE_RegularExpression 1)
155   SET(KWSYS_USE_Registry 1)
156   SET(KWSYS_USE_System 1)
157   SET(KWSYS_USE_SystemTools 1)
158   SET(KWSYS_USE_CommandLineArguments 1)
159   SET(KWSYS_USE_FundamentalType 1)
160   SET(KWSYS_USE_Terminal 1)
161   SET(KWSYS_USE_IOStream 1)
162   SET(KWSYS_USE_DateStamp 1)
163   SET(KWSYS_USE_String 1)
164   SET(KWSYS_USE_SystemInformation 1)
165   SET(KWSYS_USE_CPU 1)
166 ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
168 # Enforce component dependencies.
169 IF(KWSYS_USE_SystemTools)
170   SET(KWSYS_USE_Directory 1)
171 ENDIF(KWSYS_USE_SystemTools)
172 IF(KWSYS_USE_Glob)
173   SET(KWSYS_USE_Directory 1)
174   SET(KWSYS_USE_SystemTools 1)
175   SET(KWSYS_USE_RegularExpression 1)
176 ENDIF(KWSYS_USE_Glob)
177 IF(KWSYS_USE_Process)
178   SET(KWSYS_USE_System 1)
179 ENDIF(KWSYS_USE_Process)
180 IF(KWSYS_USE_SystemInformation)
181   SET(KWSYS_USE_FundamentalType 1)
182   SET(KWSYS_USE_Process 1)
183 ENDIF(KWSYS_USE_SystemInformation)
185 # Setup the large file support default.
186 IF(KWSYS_LFS_DISABLE)
187   SET(KWSYS_LFS_REQUESTED 0)
188 ELSE(KWSYS_LFS_DISABLE)
189   SET(KWSYS_LFS_REQUESTED 1)
190 ENDIF(KWSYS_LFS_DISABLE)
192 # Enable testing if building standalone.
193 IF(KWSYS_STANDALONE)
194   INCLUDE(Dart)
195   MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
196   IF(BUILD_TESTING)
197     ENABLE_TESTING()
198   ENDIF(BUILD_TESTING)
199 ENDIF(KWSYS_STANDALONE)
201 # Include helper macros.
202 INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
203 INCLUDE(CheckTypeSize)
205 # Do full dependency headers.
206 INCLUDE_REGULAR_EXPRESSION("^.*$")
208 # Choose which kind of install commands to use.
209 IF(COMMAND INSTALL)
210   # Use new KWSYS_INSTALL_*_DIR variable names to control installation.
211   # Take defaults from the old names.  Note that there was no old name
212   # for the bin dir, so we take the old lib dir name so DLLs will be
213   # installed in a compatible way for old code.
214   IF(NOT KWSYS_INSTALL_INCLUDE_DIR)
215     STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR
216       "${KWSYS_HEADER_INSTALL_DIR}")
217   ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR)
218   IF(NOT KWSYS_INSTALL_LIB_DIR)
219     STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
220       "${KWSYS_LIBRARY_INSTALL_DIR}")
221   ENDIF(NOT KWSYS_INSTALL_LIB_DIR)
222   IF(NOT KWSYS_INSTALL_BIN_DIR)
223     STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
224       "${KWSYS_LIBRARY_INSTALL_DIR}")
225   ENDIF(NOT KWSYS_INSTALL_BIN_DIR)
227   # Setup header install rules.
228   SET(KWSYS_INSTALL_INCLUDE_OPTIONS)
229   IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
230     SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS}
231       COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
232       )
233   ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
235   # Setup library install rules.
236   SET(KWSYS_INSTALL_LIBRARY_RULE)
237   IF(KWSYS_INSTALL_LIB_DIR)
238     # Install the shared library to the lib directory.
239     SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
240       LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR}
241       )
242     # Assign the shared library to the runtime component.
243     IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
244       SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
245         COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
246         )
247     ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
249     # Install the archive to the lib directory.
250     SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
251       ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR}
252       )
253     # Assign the archive to the development component.
254     IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
255       SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
256         COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
257         )
258     ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
259   ENDIF(KWSYS_INSTALL_LIB_DIR)
260   IF(KWSYS_INSTALL_BIN_DIR)
261     # Install the runtime library to the bin directory.
262     SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
263       RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR}
264       )
265     # Assign the runtime library to the runtime component.
266     IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
267       SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
268         COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
269         )
270     ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
271   ENDIF(KWSYS_INSTALL_BIN_DIR)
273   # Do not support old KWSYS_*_INSTALL_DIR variable names.
274   SET(KWSYS_HEADER_INSTALL_DIR)
275   SET(KWSYS_LIBRARY_INSTALL_DIR)
277 ELSE(COMMAND INSTALL)
278   # Use old KWSYS_*_INSTALL_DIR variable names.
279   # Take defaults from the new names.
280   IF(KWSYS_INSTALL_LIB_DIR)
281     IF(NOT KWSYS_LIBRARY_INSTALL_DIR)
282       SET(KWSYS_LIBRARY_INSTALL_DIR "/${KWSYS_INSTALL_LIB_DIR}")
283     ENDIF(NOT KWSYS_LIBRARY_INSTALL_DIR)
284   ENDIF(KWSYS_INSTALL_LIB_DIR)
285   IF(KWSYS_INSTALL_INCLUDE_DIR)
286     IF(NOT KWSYS_HEADER_INSTALL_DIR)
287       SET(KWSYS_HEADER_INSTALL_DIR "/${KWSYS_INSTALL_INCLUDE_DIR}")
288     ENDIF(NOT KWSYS_HEADER_INSTALL_DIR)
289   ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
291   # Do not support new KWSYS_INSTALL_*_DIR variable names.
292   SET(KWSYS_INSTALL_BIN_DIR)
293   SET(KWSYS_INSTALL_INCLUDE_DIR)
294   SET(KWSYS_INSTALL_LIB_DIR)
295 ENDIF(COMMAND INSTALL)
297 # Work-around for CMake 1.6.7 bug in custom command dependencies when
298 # there is no executable output path.
299 IF(NOT EXECUTABLE_OUTPUT_PATH)
300   SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}" CACHE PATH
301       "Output directory for executables.")
302 ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
304 # Generated source files will need this header.
305 STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
306   KWSYS_IN_SOURCE_BUILD)
307 IF(NOT KWSYS_IN_SOURCE_BUILD)
308   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
309     ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
310 ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
312 #-----------------------------------------------------------------------------
313 # We require ANSI support from the C compiler.  Add any needed flags.
314 IF(CMAKE_ANSI_CFLAGS)
315   SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
316 ENDIF(CMAKE_ANSI_CFLAGS)
318 #-----------------------------------------------------------------------------
319 # Adjust compiler flags for some platforms.
320 IF(NOT CMAKE_COMPILER_IS_GNUCXX)
321   IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
322     STRING(REGEX MATCH "-timplicit_local"
323       KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}")
324     STRING(REGEX MATCH "-no_implicit_include"
325       KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}")
326     IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
327       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
328     ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
329     IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
330       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
331     ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
332   ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
333   IF(CMAKE_SYSTEM MATCHES "HP-UX")
334     SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
335   ENDIF(CMAKE_SYSTEM MATCHES "HP-UX")
336 ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
338 #-----------------------------------------------------------------------------
339 # Configure Large File Support.
340 SET(KWSYS_LFS_AVAILABLE 0)
341 IF(KWSYS_LFS_REQUESTED)
342   # Large File Support is requested.
343   SET(KWSYS_LFS_REQUESTED 1)
345   # Check for large file support.
346   KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
347     "Checking for Large File Support" DIRECT)
349   IF(KWSYS_LFS_WORKS)
350     SET(KWSYS_LFS_AVAILABLE 1)
351   ENDIF(KWSYS_LFS_WORKS)
352 ELSE(KWSYS_LFS_REQUESTED)
353   # Large File Support is not requested.
354   SET(KWSYS_LFS_REQUESTED 0)
355 ENDIF(KWSYS_LFS_REQUESTED)
357 #-----------------------------------------------------------------------------
358 # Configure the standard library header wrappers based on compiler's
359 # capabilities and parent project's request.  Enforce 0/1 as only
360 # possible values for configuration into Configure.hxx.
362 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
363   "Checking whether STL classes are in std namespace" DIRECT)
365 IF(KWSYS_IOS_FORCE_OLD)
366   SET(KWSYS_IOS_USE_ANSI 0)
367 ELSE(KWSYS_IOS_FORCE_OLD)
368   KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI
369     "Checking whether ANSI stream headers are available" DIRECT)
370 ENDIF(KWSYS_IOS_FORCE_OLD)
372 IF(KWSYS_IOS_USE_ANSI)
373   KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD
374     "Checking whether ANSI streams are in std namespace" DIRECT)
375   KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM
376     "Checking whether ANSI string stream is available" DIRECT)
377 ELSE(KWSYS_IOS_USE_ANSI)
378   SET(KWSYS_IOS_HAVE_STD 0)
379   SET(KWSYS_IOS_USE_SSTREAM 0)
380 ENDIF(KWSYS_IOS_USE_ANSI)
382 IF(KWSYS_IOS_USE_SSTREAM)
383   SET(KWSYS_IOS_USE_STRSTREAM_H 0)
384   SET(KWSYS_IOS_USE_STRSTREA_H 0)
385 ELSE(KWSYS_IOS_USE_SSTREAM)
386   KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H
387     "Checking whether strstream.h is available" DIRECT)
388   IF(KWSYS_IOS_USE_STRSTREAM_H)
389     SET(KWSYS_IOS_USE_STRSTREA_H 0)
390   ELSE(KWSYS_IOS_USE_STRSTREAM_H)
391     KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H
392       "Checking whether strstrea.h is available" DIRECT)
393   ENDIF(KWSYS_IOS_USE_STRSTREAM_H)
394 ENDIF(KWSYS_IOS_USE_SSTREAM)
396 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDDEF
397   "Checking whether header cstddef is available" DIRECT)
399 SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
400   -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD})
401 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR
402   "Checking whether stl string has operator!= for char*" DIRECT)
403 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS
404   "Checking whether stl has iterator_traits" DIRECT)
405 IF(KWSYS_STL_HAS_ITERATOR_TRAITS)
406   SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0)
407   SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
408 ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS)
409   KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY
410     "Checking whether stl has old iterator_category" DIRECT)
411   IF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
412     SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
413   ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY)
414     KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY
415       "Checking whether stl has internal __iterator_category" DIRECT)
416   ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
417 ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS)
418 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE
419   "Checking whether stl has standard template allocator" DIRECT)
420 IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
421   SET(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE 0)
422   KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND
423     "Checking for rebind member of stl allocator" DIRECT)
424   KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
425     "Checking for non-standard argument to stl allocator<>::max_size" DIRECT)
426 ELSE(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
427   KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE
428     "Checking whether stl has old non-template allocator" DIRECT)
429   SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0)
430   SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0)
431 ENDIF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
432 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS
433   "Checking whether stl containers support allocator objects." DIRECT)
434 IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
435   # ANSI streams always have string operators.
436   SET(KWSYS_STL_STRING_HAVE_OSTREAM 1)
437   SET(KWSYS_STL_STRING_HAVE_ISTREAM 1)
438 ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
439   # There may not be string operators for old streams.
440   KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM
441     "Checking whether stl string has ostream operator<<" DIRECT)
442   KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM
443     "Checking whether stl string has istream operator>>" DIRECT)
444 ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
445 SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
447 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS
448   "Checking whether \"<>\" is needed for template friends" INVERT)
449 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_MEMBER_TEMPLATES
450   "Checking for member template support" DIRECT)
451 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_FULL_SPECIALIZATION
452   "Checking for standard template specialization syntax" DIRECT)
453 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
454   "Checking whether argument dependent lookup is supported" DIRECT)
456 IF(UNIX)
457   KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
458     "Checking whether struct stat has st_mtim member" DIRECT)
459 ENDIF(UNIX)
461 IF(KWSYS_USE_FundamentalType)
462   # Determine type sizes.
463   CHECK_TYPE_SIZE("char"      KWSYS_SIZEOF_CHAR)
464   CHECK_TYPE_SIZE("short"     KWSYS_SIZEOF_SHORT)
465   CHECK_TYPE_SIZE("int"       KWSYS_SIZEOF_INT)
466   CHECK_TYPE_SIZE("long"      KWSYS_SIZEOF_LONG)
467   CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG)
468   CHECK_TYPE_SIZE("__int64"   KWSYS_SIZEOF___INT64)
469   IF(NOT KWSYS_SIZEOF_LONG_LONG)
470     SET(KWSYS_SIZEOF_LONG_LONG 0)
471   ENDIF(NOT KWSYS_SIZEOF_LONG_LONG)
472   IF(NOT KWSYS_SIZEOF___INT64)
473     SET(KWSYS_SIZEOF___INT64 0)
474   ENDIF(NOT KWSYS_SIZEOF___INT64)
476   # Check uniqueness of types.
477   IF(KWSYS_SIZEOF___INT64)
478     KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_AND___INT64
479       "Checking whether long and __int64 are the same type" DIRECT)
480     IF(KWSYS_SIZEOF_LONG_LONG)
481       KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_LONG_AND___INT64
482         "Checking whether long long and __int64 are the same type" DIRECT)
483     ENDIF(KWSYS_SIZEOF_LONG_LONG)
484   ENDIF(KWSYS_SIZEOF___INT64)
486   # Enable the "long long" type if it is available.  It is standard in
487   # C99 and C++03 but not in earlier standards.
488   IF(KWSYS_SIZEOF_LONG_LONG)
489     SET(KWSYS_USE_LONG_LONG 1)
490   ELSE(KWSYS_SIZEOF_LONG_LONG)
491     SET(KWSYS_USE_LONG_LONG 0)
492   ENDIF(KWSYS_SIZEOF_LONG_LONG)
494   # Enable the "__int64" type if it is available and unique.  It is not
495   # standard.
496   SET(KWSYS_USE___INT64 0)
497   IF(KWSYS_SIZEOF___INT64)
498     IF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
499       IF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
500         SET(KWSYS_USE___INT64 1)
501       ENDIF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
502     ENDIF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
503   ENDIF(KWSYS_SIZEOF___INT64)
504   IF(KWSYS_USE___INT64)
505     KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
506       "Checking whether unsigned __int64 can convert to double" DIRECT)
507   ELSE(KWSYS_USE___INT64)
508     SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1)
509   ENDIF(KWSYS_USE___INT64)
511   # Check signedness of "char" type.
512   KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
513     "Checking whether char is signed" DIRECT)
514 ENDIF(KWSYS_USE_FundamentalType)
516 IF(KWSYS_USE_IOStream)
517   # Determine whether iostreams support long long.
518   CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG)
519   IF(KWSYS_SIZEOF_LONG_LONG)
520     SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
521       -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
522       -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD})
523     KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM_LONG_LONG
524       "Checking if istream supports long long" DIRECT)
525     KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG
526       "Checking if ostream supports long long" DIRECT)
527     SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
528   ELSE(KWSYS_SIZEOF_LONG_LONG)
529     SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
530     SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
531   ENDIF(KWSYS_SIZEOF_LONG_LONG)
532 ENDIF(KWSYS_USE_IOStream)
534 IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
535   SET(KWSYS_NAME_IS_KWSYS 1)
536 ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$")
537   SET(KWSYS_NAME_IS_KWSYS 0)
538 ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$")
540 # Choose default shared/static build if not specified.
541 IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
542   SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
543 ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
545 IF(KWSYS_BUILD_SHARED)
546   SET(KWSYS_BUILD_SHARED 1)
547   SET(KWSYS_LIBRARY_TYPE SHARED)
548 ELSE(KWSYS_BUILD_SHARED)
549   SET(KWSYS_BUILD_SHARED 0)
550   SET(KWSYS_LIBRARY_TYPE STATIC)
551 ENDIF(KWSYS_BUILD_SHARED)
553 #-----------------------------------------------------------------------------
554 # Choose a directory for the generated headers.
555 IF(NOT KWSYS_HEADER_ROOT)
556   SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
557 ENDIF(NOT KWSYS_HEADER_ROOT)
558 SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
559 INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
561 #-----------------------------------------------------------------------------
562 # Create STL header wrappers to block warnings in the STL headers and
563 # give standard names by which they may be included.
564 SET(KWSYS_STL_HEADER_EXTRA_string 1)
565 FOREACH(header
566   algorithm
567   deque
568   exception
569   functional
570   iterator
571   list
572   map
573   memory
574   new
575   numeric
576   queue
577   set
578   stack
579   stdexcept
580   string
581   utility
582   vector
583   )
584   # Configure the header wrapper.
585   SET(KWSYS_STL_HEADER "${header}")
586   IF(KWSYS_STL_HEADER_EXTRA_${header})
587     SET(KWSYS_STL_HEADER_EXTRA
588       "#define ${KWSYS_NAMESPACE}_stl_${header}_including_hxx\n# include <${KWSYS_NAMESPACE}/stl/${header}.hxx>\n#undef ${KWSYS_NAMESPACE}_stl_${header}_including_hxx\n")
589     CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl_${header}.hxx.in
590                    ${KWSYS_HEADER_DIR}/stl/${header}.hxx
591                    @ONLY IMMEDIATE)
592     IF(KWSYS_INSTALL_INCLUDE_DIR)
593       INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx
594         DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
595         ${KWSYS_INSTALL_INCLUDE_OPTIONS})
596     ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
597     IF(KWSYS_HEADER_INSTALL_DIR)
598       INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl
599         FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx)
600     ENDIF(KWSYS_HEADER_INSTALL_DIR)
601   ELSE(KWSYS_STL_HEADER_EXTRA_${header})
602     SET(KWSYS_STL_HEADER_EXTRA "")
603   ENDIF(KWSYS_STL_HEADER_EXTRA_${header})
604   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in
605                  ${KWSYS_HEADER_DIR}/stl/${header}
606                  @ONLY IMMEDIATE)
608   # Create an install target for the header wrapper.
609   IF(KWSYS_INSTALL_INCLUDE_DIR)
610     INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}
611       DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
612       ${KWSYS_INSTALL_INCLUDE_OPTIONS})
613   ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
614   IF(KWSYS_HEADER_INSTALL_DIR)
615     INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl
616       FILES ${KWSYS_HEADER_DIR}/stl/${header})
617   ENDIF(KWSYS_HEADER_INSTALL_DIR)
618 ENDFOREACH(header)
620 # Provide cstddef header.
621 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in
622                ${KWSYS_HEADER_DIR}/cstddef
623                @ONLY IMMEDIATE)
624 IF(KWSYS_INSTALL_INCLUDE_DIR)
625   INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef
626     DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
627     ${KWSYS_INSTALL_INCLUDE_OPTIONS})
628   IF(KWSYS_HEADER_INSTALL_DIR)
629     INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
630       FILES ${KWSYS_HEADER_DIR}/cstddef)
631   ENDIF(KWSYS_HEADER_INSTALL_DIR)
632 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
634 #-----------------------------------------------------------------------------
635 # Create streams header wrappers to give standard names by which they
636 # may be included.
637 FOREACH(header iostream fstream sstream iosfwd)
638   # Configure the header wrapper.
639   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_ios_${header}.h.in
640                  ${KWSYS_HEADER_DIR}/ios/${header}
641                  @ONLY IMMEDIATE)
643   # Create an install target for the header wrapper.
644   IF(KWSYS_INSTALL_INCLUDE_DIR)
645     INSTALL(FILES ${KWSYS_HEADER_DIR}/ios/${header}
646       DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios
647       ${KWSYS_INSTALL_INCLUDE_OPTIONS})
648   ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
649   IF(KWSYS_HEADER_INSTALL_DIR)
650     INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/ios
651       FILES ${KWSYS_HEADER_DIR}/ios/${header})
652   ENDIF(KWSYS_HEADER_INSTALL_DIR)
653 ENDFOREACH(header)
655 #-----------------------------------------------------------------------------
656 # Build a list of classes and headers we need to implement the
657 # selected components.  Initialize with required components.
658 SET(KWSYS_CLASSES)
659 SET(KWSYS_H_FILES Configure SharedForward)
660 SET(KWSYS_HXX_FILES Configure String
661   hashtable hash_fun hash_map hash_set
662   auto_ptr
663   )
665 # Add selected C++ classes.
666 SET(cppclasses
667   Directory DynamicLoader Glob RegularExpression SystemTools
668   CommandLineArguments Registry IOStream SystemInformation
669   )
670 FOREACH(cpp ${cppclasses})
671   IF(KWSYS_USE_${cpp})
672     # Use the corresponding class.
673     SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
675     # Load component-specific CMake code.
676     IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
677       INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
678     ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
679   ENDIF(KWSYS_USE_${cpp})
680 ENDFOREACH(cpp)
682 # Add selected C components.
683 FOREACH(c
684     Process Base64 FundamentalType MD5 Terminal System DateStamp String CPU
685     )
686   IF(KWSYS_USE_${c})
687     # Use the corresponding header file.
688     SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
690     # Load component-specific CMake code.
691     IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
692       INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
693     ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
694   ENDIF(KWSYS_USE_${c})
695 ENDFOREACH(c)
697 #-----------------------------------------------------------------------------
698 # Build a list of sources for the library based on components that are
699 # included.
700 SET(KWSYS_C_SRCS)
701 SET(KWSYS_CXX_SRCS)
703 # Add the proper sources for this platform's Process implementation.
704 IF(KWSYS_USE_Process)
705   IF(NOT UNIX)
706     # Use the Windows implementation.  We need the encoded forwarding executable.
707     SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c
708       ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c)
709     SET_SOURCE_FILES_PROPERTIES(
710       ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
711       PROPERTIES GENERATED 1)
712   ELSE(NOT UNIX)
713     # Use the UNIX implementation.
714     SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
716     # Help ProcessUNIX.c compile properly on all platforms.
717     KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T
718       "Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT)
719     KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T
720       "Checking whether C compiler has ssize_t in unistd.h" DIRECT)
721     SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c PROPERTIES
722       COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}"
723       )
724   ENDIF(NOT UNIX)
725 ENDIF(KWSYS_USE_Process)
727 # Add selected C sources.
728 FOREACH(c Base64 MD5 Terminal System String)
729   IF(KWSYS_USE_${c})
730     SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${c}.c)
731   ENDIF(KWSYS_USE_${c})
732 ENDFOREACH(c)
734 # Configure headers of C++ classes and construct the list of sources.
735 FOREACH(c ${KWSYS_CLASSES})
736   # Add this source to the list of source files for the library.
737   SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${c}.cxx)
739   # Configure the header for this class.
740   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
741                  @ONLY IMMEDIATE)
742   SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${c}.hxx)
744   # Create an install target for the header.
745   IF(KWSYS_INSTALL_INCLUDE_DIR)
746     INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
747       DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
748       ${KWSYS_INSTALL_INCLUDE_OPTIONS})
749   ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
750   IF(KWSYS_HEADER_INSTALL_DIR)
751     INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
752                   FILES  ${KWSYS_HEADER_DIR}/${c}.hxx)
753   ENDIF(KWSYS_HEADER_INSTALL_DIR)
754 ENDFOREACH(c)
756 # Configure C headers.
757 FOREACH(h ${KWSYS_H_FILES})
758   # Configure the header into the given directory.
759   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
760                  @ONLY IMMEDIATE)
761   SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${KWSYS_HEADER_DIR}/${h}.h)
763   # Create an install target for the header.
764   IF(KWSYS_INSTALL_INCLUDE_DIR)
765     INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
766       DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
767       ${KWSYS_INSTALL_INCLUDE_OPTIONS})
768   ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
769   IF(KWSYS_HEADER_INSTALL_DIR)
770     INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
771                   FILES  ${KWSYS_HEADER_DIR}/${h}.h)
772   ENDIF(KWSYS_HEADER_INSTALL_DIR)
773 ENDFOREACH(h)
775 # Configure other C++ headers.
776 FOREACH(h ${KWSYS_HXX_FILES})
777   # Configure the header into the given directory.
778   CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
779                  @ONLY IMMEDIATE)
780   SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${KWSYS_HEADER_DIR}/${h}.hxx)
782   # Create an install target for the header.
783   IF(KWSYS_INSTALL_INCLUDE_DIR)
784     INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
785       DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
786       ${KWSYS_INSTALL_INCLUDE_OPTIONS})
787   ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
788   IF(KWSYS_HEADER_INSTALL_DIR)
789     INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
790                   FILES  ${KWSYS_HEADER_DIR}/${h}.hxx)
791   ENDIF(KWSYS_HEADER_INSTALL_DIR)
792 ENDFOREACH(h)
794 #-----------------------------------------------------------------------------
795 # Add the library with the configured name and list of sources.
796 IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
797   ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE}
798     ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
799   KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE} PROPERTY LABELS ${KWSYS_LABELS_LIB})
800   IF(KWSYS_USE_DynamicLoader)
801     IF(UNIX)
802       TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
803     ENDIF(UNIX)
804   ENDIF(KWSYS_USE_DynamicLoader)
805   
806   IF(KWSYS_USE_SystemInformation AND WIN32)
807     TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32)
808   ENDIF(KWSYS_USE_SystemInformation AND WIN32)
810   # Apply user-defined target properties to the library.
811   IF(KWSYS_PROPERTIES_CXX)
812     SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
813       ${KWSYS_PROPERTIES_CXX}
814       )
815   ENDIF(KWSYS_PROPERTIES_CXX)
817   # Create an install target for the library.
818   IF(KWSYS_INSTALL_LIBRARY_RULE)
819     INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE})
820   ENDIF(KWSYS_INSTALL_LIBRARY_RULE)
821   IF(KWSYS_LIBRARY_INSTALL_DIR)
822     INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE})
823   ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
824 ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
826 # Add a C-only library if requested.
827 IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
828   ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS})
829   KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}_c PROPERTY LABELS ${KWSYS_LABELS_LIB})
831   # Apply user-defined target properties to the library.
832   IF(KWSYS_PROPERTIES_C)
833     SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
834       ${KWSYS_PROPERTIES_C}
835       )
836   ENDIF(KWSYS_PROPERTIES_C)
838   # Create an install target for the library.
839   IF(KWSYS_INSTALL_LIBRARY_RULE)
840     INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE})
841   ENDIF(KWSYS_INSTALL_LIBRARY_RULE)
842   IF(KWSYS_LIBRARY_INSTALL_DIR)
843     INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE}_c)
844   ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
845 ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
847 # For building kwsys itself, we use a macro defined on the command
848 # line to configure the namespace in the C and C++ source files.
849 ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
851 #-----------------------------------------------------------------------------
852 # Process execution on windows needs to build a forwarding executable
853 # that works around a Win9x bug.  We encode the executable into a C
854 # file and build it into the library.  Win9x platforms reproduce the
855 # executable into a temporary directory when it is needed.
856 IF(KWSYS_USE_Process)
857   IF(NOT UNIX)
858     # Build the forwarding executable itself and a program that will
859     # encode it into a C file.
860     ADD_EXECUTABLE(${KWSYS_NAMESPACE}ProcessFwd9x ProcessFwd9x.c)
861     ADD_EXECUTABLE(${KWSYS_NAMESPACE}EncodeExecutable EncodeExecutable.c)
862     KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}ProcessFwd9x PROPERTY LABELS ${KWSYS_LABELS_EXE})
863     KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}EncodeExecutable PROPERTY LABELS ${KWSYS_LABELS_EXE})
865     # Construct the location of the executable to be encoded.
866     SET(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
867     IF(EXECUTABLE_OUTPUT_PATH)
868       SET(BIN_DIR ${EXECUTABLE_OUTPUT_PATH})
869     ENDIF(EXECUTABLE_OUTPUT_PATH)
871     SET(CFG_INTDIR "/${CMAKE_CFG_INTDIR}")
872     IF(CMAKE_BUILD_TOOL MATCHES "make")
873       SET(CFG_INTDIR "")
874     ENDIF(CMAKE_BUILD_TOOL MATCHES "make")
876     # Take advantage of a better custom command syntax if possible.
877     SET(CMD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}EncodeExecutable.exe)
878     SET(FWD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}ProcessFwd9x.exe)
879     IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
880       ADD_CUSTOM_COMMAND(
881         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
882         COMMAND ${CMD}
883         ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
884              ${KWSYS_NAMESPACE} ProcessFwd9x
885         DEPENDS ${CMD} ${FWD})
886     ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
887       ADD_CUSTOM_COMMAND(
888         TARGET ${KWSYS_NAMESPACE}
889         SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/ProcessFwd9x.c
890         COMMAND ${CMD}
891         ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
892              ${KWSYS_NAMESPACE} ProcessFwd9x
893         OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
894         DEPENDS ${CMD} ${FWD})
895     ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
897     # Make sure build occurs in proper order.
898     ADD_DEPENDENCIES(${KWSYS_NAMESPACE} ${KWSYS_NAMESPACE}ProcessFwd9x
899                      ${KWSYS_NAMESPACE}EncodeExecutable)
900   ENDIF(NOT UNIX)
901 ENDIF(KWSYS_USE_Process)
903 #-----------------------------------------------------------------------------
904 # Setup testing if not being built as part of another project.
905 IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
906   IF(BUILD_TESTING)
907     # Compute the location of executables.
908     SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
909     IF(EXECUTABLE_OUTPUT_PATH)
910       SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
911     ENDIF(EXECUTABLE_OUTPUT_PATH)
913     # C tests
914     SET(KWSYS_C_TESTS
915       testEncode
916       testTerminal
917       )
918     IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
919       SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail)
920     ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
921     CREATE_TEST_SOURCELIST(
922       KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
923       ${KWSYS_C_TESTS}
924       )
925     ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
926     KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsC PROPERTY LABELS ${KWSYS_LABELS_EXE})
927     TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c)
928     FOREACH(test ${KWSYS_C_TESTS})
929       ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
930       KWSYS_SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
931     ENDFOREACH(test)
933     # C++ tests
934     IF(NOT WATCOM)
935       SET(KWSYS_CXX_TESTS
936         testAutoPtr
937         testHashSTL
938         )
939     ENDIF(NOT WATCOM)
940     SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
941       testRegistry
942       testIOS
943       testSystemTools
944       testCommandLineArguments
945       testCommandLineArguments1
946       )
947     IF(KWSYS_USE_SystemInformation)
948       SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation)
949     ENDIF(KWSYS_USE_SystemInformation)
950     IF(KWSYS_USE_DynamicLoader)
951       SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader)
952       # If kwsys contains the DynamicLoader, need extra library
953       ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
954       KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
955     ENDIF(KWSYS_USE_DynamicLoader)
956     CREATE_TEST_SOURCELIST(
957       KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
958       ${KWSYS_CXX_TESTS}
959       )
960     ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
961     KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestsCxx PROPERTY LABELS ${KWSYS_LABELS_EXE})
962     TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE})
963     SET(TEST_SYSTEMTOOLS_BIN_FILE
964       "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.bin")
965     SET(TEST_SYSTEMTOOLS_SRC_FILE
966       "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.cxx")
967     CONFIGURE_FILE(
968       ${PROJECT_SOURCE_DIR}/testSystemTools.h.in
969       ${PROJECT_BINARY_DIR}/testSystemTools.h)
970     INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
972     IF(CTEST_TEST_KWSYS)
973       CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
974         "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
975       SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
976     ENDIF(CTEST_TEST_KWSYS)
978     SET(KWSYS_TEST_ARGS_testCommandLineArguments
979       --another-bool-variable
980       --long3=opt
981       --set-bool-arg1
982       -SSS ken brad bill andy
983       --some-bool-variable=true
984       --some-double-variable12.5
985       --some-int-variable 14
986       "--some-string-variable=test string with space"
987       --some-multi-argument 5 1 8 3 7 1 3 9 7 1
988       -N 12.5 -SS=andy -N 1.31 -N 22
989       -SS=bill -BBtrue -SS=brad
990       -BBtrue
991       -BBfalse
992       -SS=ken
993       -A
994       -C=test
995       --long2 hello
996       )
997     SET(KWSYS_TEST_ARGS_testCommandLineArguments1
998       --ignored
999       -n 24
1000       --second-ignored
1001       "-m=test value"
1002       third-ignored
1003       -p
1004       some junk at the end
1005       )
1006     FOREACH(test ${KWSYS_CXX_TESTS})
1007       ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
1008       KWSYS_SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
1009     ENDFOREACH(test)
1011     # Process tests.
1012     ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
1013     KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestProcess PROPERTY LABELS ${KWSYS_LABELS_EXE})
1014     TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c)
1015     IF(NOT CYGWIN)
1016       SET(KWSYS_TEST_PROCESS_7 7)
1017     ENDIF(NOT CYGWIN)
1018     FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7})
1019       ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
1020       KWSYS_SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
1021     ENDFOREACH(n)
1023     # Test SharedForward
1024     CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/testSharedForward.c.in
1025                    ${PROJECT_BINARY_DIR}/testSharedForward.c @ONLY IMMEDIATE)
1026     ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestSharedForward
1027                    ${PROJECT_BINARY_DIR}/testSharedForward.c)
1028     KWSYS_SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestSharedForward PROPERTY LABELS ${KWSYS_LABELS_EXE})
1029     ADD_TEST(kwsys.testSharedForward ${EXEC_DIR}/${KWSYS_NAMESPACE}TestSharedForward 1)
1030     KWSYS_SET_PROPERTY(TEST kwsys.testSharedForward PROPERTY LABELS ${KWSYS_LABELS_TEST})
1032     # Configure some test properties.
1033     IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
1034       # We expect test to fail
1035       SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON)
1036       GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv)
1037       SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR_NOT_VALGRIND;FAIL;Test failed")
1038       SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES PASS_REGULAR_EXPRESSION "Test passed")
1039       SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
1040       MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
1041     ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
1042   ENDIF(BUILD_TESTING)
1043 ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)