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.
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.
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
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.
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 '/'.
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>
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
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)
115 #-----------------------------------------------------------------------------
116 # The project name is that of the specified namespace.
117 PROJECT(${KWSYS_NAMESPACE})
119 # Select library components.
120 IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
121 SET(KWSYS_ENABLE_C 1)
123 # Enable all components.
124 SET(KWSYS_USE_Base64 1)
125 SET(KWSYS_USE_Directory 1)
126 SET(KWSYS_USE_DynamicLoader 1)
127 SET(KWSYS_USE_Glob 1)
129 SET(KWSYS_USE_Process 1)
130 SET(KWSYS_USE_RegularExpression 1)
131 SET(KWSYS_USE_Registry 1)
132 SET(KWSYS_USE_System 1)
133 SET(KWSYS_USE_SystemTools 1)
134 SET(KWSYS_USE_CommandLineArguments 1)
135 SET(KWSYS_USE_FundamentalType 1)
136 SET(KWSYS_USE_Terminal 1)
137 SET(KWSYS_USE_IOStream 1)
138 SET(KWSYS_USE_DateStamp 1)
139 SET(KWSYS_USE_String 1)
140 SET(KWSYS_USE_SystemInformation 1)
142 ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
144 # Setup the large file support default.
145 IF(KWSYS_LFS_DISABLE)
146 SET(KWSYS_LFS_REQUESTED 0)
147 ELSE(KWSYS_LFS_DISABLE)
148 SET(KWSYS_LFS_REQUESTED 1)
149 ENDIF(KWSYS_LFS_DISABLE)
151 # Enable testing if building standalone.
154 MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
158 ENDIF(KWSYS_STANDALONE)
160 # Include helper macros.
161 INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
162 INCLUDE(CheckTypeSize)
164 # Do full dependency headers.
165 INCLUDE_REGULAR_EXPRESSION("^.*$")
167 # Choose which kind of install commands to use.
169 # Use new KWSYS_INSTALL_*_DIR variable names to control installation.
170 # Take defaults from the old names. Note that there was no old name
171 # for the bin dir, so we take the old lib dir name so DLLs will be
172 # installed in a compatible way for old code.
173 IF(NOT KWSYS_INSTALL_INCLUDE_DIR)
174 STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR
175 "${KWSYS_HEADER_INSTALL_DIR}")
176 ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR)
177 IF(NOT KWSYS_INSTALL_LIB_DIR)
178 STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
179 "${KWSYS_LIBRARY_INSTALL_DIR}")
180 ENDIF(NOT KWSYS_INSTALL_LIB_DIR)
181 IF(NOT KWSYS_INSTALL_BIN_DIR)
182 STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
183 "${KWSYS_LIBRARY_INSTALL_DIR}")
184 ENDIF(NOT KWSYS_INSTALL_BIN_DIR)
186 # Setup header install rules.
187 SET(KWSYS_INSTALL_INCLUDE_OPTIONS)
188 IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
189 SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS}
190 COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
192 ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
194 # Setup library install rules.
195 SET(KWSYS_INSTALL_LIBRARY_RULE)
196 IF(KWSYS_INSTALL_LIB_DIR)
197 # Install the shared library to the lib directory.
198 SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
199 LIBRARY DESTINATION ${KWSYS_INSTALL_LIB_DIR}
201 # Assign the shared library to the runtime component.
202 IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
203 SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
204 COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
206 ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
208 # Install the archive to the lib directory.
209 SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
210 ARCHIVE DESTINATION ${KWSYS_INSTALL_LIB_DIR}
212 # Assign the archive to the development component.
213 IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
214 SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
215 COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
217 ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
218 ENDIF(KWSYS_INSTALL_LIB_DIR)
219 IF(KWSYS_INSTALL_BIN_DIR)
220 # Install the runtime library to the bin directory.
221 SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
222 RUNTIME DESTINATION ${KWSYS_INSTALL_BIN_DIR}
224 # Assign the runtime library to the runtime component.
225 IF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
226 SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
227 COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
229 ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
230 ENDIF(KWSYS_INSTALL_BIN_DIR)
232 # Do not support old KWSYS_*_INSTALL_DIR variable names.
233 SET(KWSYS_HEADER_INSTALL_DIR)
234 SET(KWSYS_LIBRARY_INSTALL_DIR)
236 ELSE(COMMAND INSTALL)
237 # Use old KWSYS_*_INSTALL_DIR variable names.
238 # Take defaults from the new names.
239 IF(KWSYS_INSTALL_LIB_DIR)
240 IF(NOT KWSYS_LIBRARY_INSTALL_DIR)
241 SET(KWSYS_LIBRARY_INSTALL_DIR "/${KWSYS_INSTALL_LIB_DIR}")
242 ENDIF(NOT KWSYS_LIBRARY_INSTALL_DIR)
243 ENDIF(KWSYS_INSTALL_LIB_DIR)
244 IF(KWSYS_INSTALL_INCLUDE_DIR)
245 IF(NOT KWSYS_HEADER_INSTALL_DIR)
246 SET(KWSYS_HEADER_INSTALL_DIR "/${KWSYS_INSTALL_INCLUDE_DIR}")
247 ENDIF(NOT KWSYS_HEADER_INSTALL_DIR)
248 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
250 # Do not support new KWSYS_INSTALL_*_DIR variable names.
251 SET(KWSYS_INSTALL_BIN_DIR)
252 SET(KWSYS_INSTALL_INCLUDE_DIR)
253 SET(KWSYS_INSTALL_LIB_DIR)
254 ENDIF(COMMAND INSTALL)
256 # Work-around for CMake 1.6.7 bug in custom command dependencies when
257 # there is no executable output path.
258 IF(NOT EXECUTABLE_OUTPUT_PATH)
259 SET(EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}" CACHE PATH
260 "Output directory for executables.")
261 ENDIF(NOT EXECUTABLE_OUTPUT_PATH)
263 # Generated source files will need this header.
264 STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
265 KWSYS_IN_SOURCE_BUILD)
266 IF(NOT KWSYS_IN_SOURCE_BUILD)
267 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
268 ${PROJECT_BINARY_DIR}/kwsysPrivate.h COPY_ONLY IMMEDIATE)
269 ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
271 #-----------------------------------------------------------------------------
272 # We require ANSI support from the C compiler. Add any needed flags.
273 IF(CMAKE_ANSI_CFLAGS)
274 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
275 ENDIF(CMAKE_ANSI_CFLAGS)
277 #-----------------------------------------------------------------------------
278 # Adjust compiler flags for some platforms.
279 IF(NOT CMAKE_COMPILER_IS_GNUCXX)
280 IF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
281 STRING(REGEX MATCH "-timplicit_local"
282 KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL "${CMAKE_CXX_FLAGS}")
283 STRING(REGEX MATCH "-no_implicit_include"
284 KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}")
285 IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
286 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
287 ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
288 IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
289 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
290 ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
291 ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
292 IF(CMAKE_SYSTEM MATCHES "HP-UX")
293 SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
294 ENDIF(CMAKE_SYSTEM MATCHES "HP-UX")
295 ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
297 #-----------------------------------------------------------------------------
298 # Configure Large File Support.
299 SET(KWSYS_LFS_AVAILABLE 0)
300 IF(KWSYS_LFS_REQUESTED)
301 # Large File Support is requested.
302 SET(KWSYS_LFS_REQUESTED 1)
304 # Check for large file support.
305 KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_LFS_WORKS
306 "Checking for Large File Support" DIRECT)
309 SET(KWSYS_LFS_AVAILABLE 1)
310 ENDIF(KWSYS_LFS_WORKS)
311 ELSE(KWSYS_LFS_REQUESTED)
312 # Large File Support is not requested.
313 SET(KWSYS_LFS_REQUESTED 0)
314 ENDIF(KWSYS_LFS_REQUESTED)
316 #-----------------------------------------------------------------------------
317 # Configure the standard library header wrappers based on compiler's
318 # capabilities and parent project's request. Enforce 0/1 as only
319 # possible values for configuration into Configure.hxx.
321 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
322 "Checking whether STL classes are in std namespace" DIRECT)
324 IF(KWSYS_IOS_FORCE_OLD)
325 SET(KWSYS_IOS_USE_ANSI 0)
326 ELSE(KWSYS_IOS_FORCE_OLD)
327 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI
328 "Checking whether ANSI stream headers are available" DIRECT)
329 ENDIF(KWSYS_IOS_FORCE_OLD)
331 IF(KWSYS_IOS_USE_ANSI)
332 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD
333 "Checking whether ANSI streams are in std namespace" DIRECT)
334 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM
335 "Checking whether ANSI string stream is available" DIRECT)
336 ELSE(KWSYS_IOS_USE_ANSI)
337 SET(KWSYS_IOS_HAVE_STD 0)
338 SET(KWSYS_IOS_USE_SSTREAM 0)
339 ENDIF(KWSYS_IOS_USE_ANSI)
341 IF(KWSYS_IOS_USE_SSTREAM)
342 SET(KWSYS_IOS_USE_STRSTREAM_H 0)
343 SET(KWSYS_IOS_USE_STRSTREA_H 0)
344 ELSE(KWSYS_IOS_USE_SSTREAM)
345 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H
346 "Checking whether strstream.h is available" DIRECT)
347 IF(KWSYS_IOS_USE_STRSTREAM_H)
348 SET(KWSYS_IOS_USE_STRSTREA_H 0)
349 ELSE(KWSYS_IOS_USE_STRSTREAM_H)
350 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H
351 "Checking whether strstrea.h is available" DIRECT)
352 ENDIF(KWSYS_IOS_USE_STRSTREAM_H)
353 ENDIF(KWSYS_IOS_USE_SSTREAM)
355 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDDEF
356 "Checking whether header cstddef is available" DIRECT)
358 SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
359 -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD})
360 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR
361 "Checking whether stl string has operator!= for char*" DIRECT)
362 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS
363 "Checking whether stl has iterator_traits" DIRECT)
364 IF(KWSYS_STL_HAS_ITERATOR_TRAITS)
365 SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0)
366 SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
367 ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS)
368 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY
369 "Checking whether stl has old iterator_category" DIRECT)
370 IF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
371 SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
372 ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY)
373 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY
374 "Checking whether stl has internal __iterator_category" DIRECT)
375 ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
376 ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS)
377 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE
378 "Checking whether stl has standard template allocator" DIRECT)
379 IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
380 SET(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE 0)
381 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND
382 "Checking for rebind member of stl allocator" DIRECT)
383 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
384 "Checking for non-standard argument to stl allocator<>::max_size" DIRECT)
385 ELSE(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
386 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE
387 "Checking whether stl has old non-template allocator" DIRECT)
388 SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0)
389 SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0)
390 ENDIF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
391 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS
392 "Checking whether stl containers support allocator objects." DIRECT)
393 IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
394 # ANSI streams always have string operators.
395 SET(KWSYS_STL_STRING_HAVE_OSTREAM 1)
396 SET(KWSYS_STL_STRING_HAVE_ISTREAM 1)
397 ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
398 # There may not be string operators for old streams.
399 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM
400 "Checking whether stl string has ostream operator<<" DIRECT)
401 KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM
402 "Checking whether stl string has istream operator>>" DIRECT)
403 ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
404 SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
406 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS
407 "Checking whether \"<>\" is needed for template friends" INVERT)
408 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_MEMBER_TEMPLATES
409 "Checking for member template support" DIRECT)
410 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_FULL_SPECIALIZATION
411 "Checking for standard template specialization syntax" DIRECT)
412 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
413 "Checking whether argument dependent lookup is supported" DIRECT)
416 KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
417 "Checking whether struct stat has st_mtim member" DIRECT)
420 IF(KWSYS_USE_FundamentalType)
421 # Determine type sizes.
422 CHECK_TYPE_SIZE("char" KWSYS_SIZEOF_CHAR)
423 CHECK_TYPE_SIZE("short" KWSYS_SIZEOF_SHORT)
424 CHECK_TYPE_SIZE("int" KWSYS_SIZEOF_INT)
425 CHECK_TYPE_SIZE("long" KWSYS_SIZEOF_LONG)
426 CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG)
427 CHECK_TYPE_SIZE("__int64" KWSYS_SIZEOF___INT64)
428 IF(NOT KWSYS_SIZEOF_LONG_LONG)
429 SET(KWSYS_SIZEOF_LONG_LONG 0)
430 ENDIF(NOT KWSYS_SIZEOF_LONG_LONG)
431 IF(NOT KWSYS_SIZEOF___INT64)
432 SET(KWSYS_SIZEOF___INT64 0)
433 ENDIF(NOT KWSYS_SIZEOF___INT64)
435 # Check uniqueness of types.
436 IF(KWSYS_SIZEOF___INT64)
437 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_AND___INT64
438 "Checking whether long and __int64 are the same type" DIRECT)
439 IF(KWSYS_SIZEOF_LONG_LONG)
440 KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_SAME_LONG_LONG_AND___INT64
441 "Checking whether long long and __int64 are the same type" DIRECT)
442 ENDIF(KWSYS_SIZEOF_LONG_LONG)
443 ENDIF(KWSYS_SIZEOF___INT64)
445 # Enable the "long long" type if it is available. It is standard in
446 # C99 and C++03 but not in earlier standards.
447 IF(KWSYS_SIZEOF_LONG_LONG)
448 SET(KWSYS_USE_LONG_LONG 1)
449 ELSE(KWSYS_SIZEOF_LONG_LONG)
450 SET(KWSYS_USE_LONG_LONG 0)
451 ENDIF(KWSYS_SIZEOF_LONG_LONG)
453 # Enable the "__int64" type if it is available and unique. It is not
455 SET(KWSYS_USE___INT64 0)
456 IF(KWSYS_SIZEOF___INT64)
457 IF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
458 IF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
459 SET(KWSYS_USE___INT64 1)
460 ENDIF(NOT KWSYS_CXX_SAME_LONG_LONG_AND___INT64)
461 ENDIF(NOT KWSYS_CXX_SAME_LONG_AND___INT64)
462 ENDIF(KWSYS_SIZEOF___INT64)
463 IF(KWSYS_USE___INT64)
464 KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
465 "Checking whether unsigned __int64 can convert to double" DIRECT)
466 ELSE(KWSYS_USE___INT64)
467 SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1)
468 ENDIF(KWSYS_USE___INT64)
470 # Check signedness of "char" type.
471 KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
472 "Checking whether char is signed" DIRECT)
473 ENDIF(KWSYS_USE_FundamentalType)
475 IF(KWSYS_USE_IOStream)
476 # Determine whether iostreams support long long.
477 CHECK_TYPE_SIZE("long long" KWSYS_SIZEOF_LONG_LONG)
478 IF(KWSYS_SIZEOF_LONG_LONG)
479 SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
480 -DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
481 -DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD})
482 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_ISTREAM_LONG_LONG
483 "Checking if istream supports long long" DIRECT)
484 KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAS_OSTREAM_LONG_LONG
485 "Checking if ostream supports long long" DIRECT)
486 SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
487 ELSE(KWSYS_SIZEOF_LONG_LONG)
488 SET(KWSYS_IOS_HAS_ISTREAM_LONG_LONG 0)
489 SET(KWSYS_IOS_HAS_OSTREAM_LONG_LONG 0)
490 ENDIF(KWSYS_SIZEOF_LONG_LONG)
491 ENDIF(KWSYS_USE_IOStream)
493 IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
494 SET(KWSYS_NAME_IS_KWSYS 1)
495 ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$")
496 SET(KWSYS_NAME_IS_KWSYS 0)
497 ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$")
499 # Choose default shared/static build if not specified.
500 IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
501 SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
502 ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
504 IF(KWSYS_BUILD_SHARED)
505 SET(KWSYS_BUILD_SHARED 1)
506 SET(KWSYS_LIBRARY_TYPE SHARED)
507 ELSE(KWSYS_BUILD_SHARED)
508 SET(KWSYS_BUILD_SHARED 0)
509 SET(KWSYS_LIBRARY_TYPE STATIC)
510 ENDIF(KWSYS_BUILD_SHARED)
512 #-----------------------------------------------------------------------------
513 # Choose a directory for the generated headers.
514 IF(NOT KWSYS_HEADER_ROOT)
515 SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
516 ENDIF(NOT KWSYS_HEADER_ROOT)
517 SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
518 INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
520 #-----------------------------------------------------------------------------
521 # Create STL header wrappers to block warnings in the STL headers and
522 # give standard names by which they may be included.
523 SET(KWSYS_STL_HEADER_EXTRA_string 1)
543 # Configure the header wrapper.
544 SET(KWSYS_STL_HEADER "${header}")
545 IF(KWSYS_STL_HEADER_EXTRA_${header})
546 SET(KWSYS_STL_HEADER_EXTRA
547 "#define ${KWSYS_NAMESPACE}_stl_${header}_including_hxx\n# include <${KWSYS_NAMESPACE}/stl/${header}.hxx>\n#undef ${KWSYS_NAMESPACE}_stl_${header}_including_hxx\n")
548 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl_${header}.hxx.in
549 ${KWSYS_HEADER_DIR}/stl/${header}.hxx
551 IF(KWSYS_INSTALL_INCLUDE_DIR)
552 INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx
553 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
554 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
555 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
556 IF(KWSYS_HEADER_INSTALL_DIR)
557 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl
558 FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx)
559 ENDIF(KWSYS_HEADER_INSTALL_DIR)
560 ELSE(KWSYS_STL_HEADER_EXTRA_${header})
561 SET(KWSYS_STL_HEADER_EXTRA "")
562 ENDIF(KWSYS_STL_HEADER_EXTRA_${header})
563 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in
564 ${KWSYS_HEADER_DIR}/stl/${header}
567 # Create an install target for the header wrapper.
568 IF(KWSYS_INSTALL_INCLUDE_DIR)
569 INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}
570 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
571 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
572 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
573 IF(KWSYS_HEADER_INSTALL_DIR)
574 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/stl
575 FILES ${KWSYS_HEADER_DIR}/stl/${header})
576 ENDIF(KWSYS_HEADER_INSTALL_DIR)
579 # Provide cstddef header.
580 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in
581 ${KWSYS_HEADER_DIR}/cstddef
583 IF(KWSYS_INSTALL_INCLUDE_DIR)
584 INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef
585 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
586 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
587 IF(KWSYS_HEADER_INSTALL_DIR)
588 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
589 FILES ${KWSYS_HEADER_DIR}/cstddef)
590 ENDIF(KWSYS_HEADER_INSTALL_DIR)
591 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
593 #-----------------------------------------------------------------------------
594 # Create streams header wrappers to give standard names by which they
596 FOREACH(header iostream fstream sstream iosfwd)
597 # Configure the header wrapper.
598 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_ios_${header}.h.in
599 ${KWSYS_HEADER_DIR}/ios/${header}
602 # Create an install target for the header wrapper.
603 IF(KWSYS_INSTALL_INCLUDE_DIR)
604 INSTALL(FILES ${KWSYS_HEADER_DIR}/ios/${header}
605 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios
606 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
607 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
608 IF(KWSYS_HEADER_INSTALL_DIR)
609 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}/ios
610 FILES ${KWSYS_HEADER_DIR}/ios/${header})
611 ENDIF(KWSYS_HEADER_INSTALL_DIR)
614 #-----------------------------------------------------------------------------
615 # Build a list of classes and headers we need to implement the
616 # selected components. Initialize with required components.
618 SET(KWSYS_H_FILES Configure SharedForward)
619 SET(KWSYS_HXX_FILES Configure String
620 hashtable hash_fun hash_map hash_set
624 # Enforce component dependencies.
625 IF(KWSYS_USE_SystemTools)
626 SET(KWSYS_USE_Directory 1)
627 ENDIF(KWSYS_USE_SystemTools)
629 SET(KWSYS_USE_Directory 1)
630 SET(KWSYS_USE_SystemTools 1)
631 SET(KWSYS_USE_RegularExpression 1)
632 ENDIF(KWSYS_USE_Glob)
633 IF(KWSYS_USE_Process)
634 SET(KWSYS_USE_System 1)
635 ENDIF(KWSYS_USE_Process)
637 # Add selected C++ classes.
639 Directory DynamicLoader Glob RegularExpression SystemTools
640 CommandLineArguments Registry IOStream SystemInformation
642 FOREACH(cpp ${cppclasses})
644 # Use the corresponding class.
645 SET(KWSYS_CLASSES ${KWSYS_CLASSES} ${cpp})
647 # Load component-specific CMake code.
648 IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
649 INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
650 ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
651 ENDIF(KWSYS_USE_${cpp})
654 # Add selected C components.
656 Process Base64 FundamentalType MD5 Terminal System DateStamp String CPU
659 # Use the corresponding header file.
660 SET(KWSYS_H_FILES ${KWSYS_H_FILES} ${c})
662 # Load component-specific CMake code.
663 IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
664 INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
665 ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
666 ENDIF(KWSYS_USE_${c})
669 #-----------------------------------------------------------------------------
670 # Build a list of sources for the library based on components that are
675 # Add the proper sources for this platform's Process implementation.
676 IF(KWSYS_USE_Process)
678 # Use the Windows implementation. We need the encoded forwarding executable.
679 SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c
680 ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c)
681 SET_SOURCE_FILES_PROPERTIES(
682 ${PROJECT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
683 PROPERTIES GENERATED 1)
685 # Use the UNIX implementation.
686 SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
688 # Help ProcessUNIX.c compile properly on all platforms.
689 KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_PTRDIFF_T
690 "Checking whether C compiler has ptrdiff_t in stddef.h" DIRECT)
691 KWSYS_PLATFORM_C_TEST(KWSYS_C_HAS_SSIZE_T
692 "Checking whether C compiler has ssize_t in unistd.h" DIRECT)
693 SET_SOURCE_FILES_PROPERTIES(ProcessUNIX.c PROPERTIES
694 COMPILE_FLAGS "-DKWSYS_C_HAS_PTRDIFF_T=${KWSYS_C_HAS_PTRDIFF_T} -DKWSYS_C_HAS_SSIZE_T=${KWSYS_C_HAS_SSIZE_T}"
697 ENDIF(KWSYS_USE_Process)
699 # Add selected C sources.
700 FOREACH(c Base64 MD5 Terminal System String)
702 SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ${c}.c)
703 ENDIF(KWSYS_USE_${c})
706 # Configure headers of C++ classes and construct the list of sources.
707 FOREACH(c ${KWSYS_CLASSES})
708 # Add this source to the list of source files for the library.
709 SET(KWSYS_CXX_SRCS ${KWSYS_CXX_SRCS} ${c}.cxx)
711 # Configure the header for this class.
712 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${c}.hxx.in ${KWSYS_HEADER_DIR}/${c}.hxx
715 # Create an install target for the header.
716 IF(KWSYS_INSTALL_INCLUDE_DIR)
717 INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
718 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
719 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
720 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
721 IF(KWSYS_HEADER_INSTALL_DIR)
722 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
723 FILES ${KWSYS_HEADER_DIR}/${c}.hxx)
724 ENDIF(KWSYS_HEADER_INSTALL_DIR)
727 # Configure C headers.
728 FOREACH(h ${KWSYS_H_FILES})
729 # Configure the header into the given directory.
730 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.h.in ${KWSYS_HEADER_DIR}/${h}.h
733 # Create an install target for the header.
734 IF(KWSYS_INSTALL_INCLUDE_DIR)
735 INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
736 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
737 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
738 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
739 IF(KWSYS_HEADER_INSTALL_DIR)
740 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
741 FILES ${KWSYS_HEADER_DIR}/${h}.h)
742 ENDIF(KWSYS_HEADER_INSTALL_DIR)
745 # Configure other C++ headers.
746 FOREACH(h ${KWSYS_HXX_FILES})
747 # Configure the header into the given directory.
748 CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/${h}.hxx.in ${KWSYS_HEADER_DIR}/${h}.hxx
751 # Create an install target for the header.
752 IF(KWSYS_INSTALL_INCLUDE_DIR)
753 INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
754 DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
755 ${KWSYS_INSTALL_INCLUDE_OPTIONS})
756 ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
757 IF(KWSYS_HEADER_INSTALL_DIR)
758 INSTALL_FILES(${KWSYS_HEADER_INSTALL_DIR}/${KWSYS_NAMESPACE}
759 FILES ${KWSYS_HEADER_DIR}/${h}.hxx)
760 ENDIF(KWSYS_HEADER_INSTALL_DIR)
763 #-----------------------------------------------------------------------------
764 # Add the library with the configured name and list of sources.
765 IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
766 ADD_LIBRARY(${KWSYS_NAMESPACE} ${KWSYS_LIBRARY_TYPE}
767 ${KWSYS_C_SRCS} ${KWSYS_CXX_SRCS})
768 IF(KWSYS_USE_DynamicLoader)
770 TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
772 ENDIF(KWSYS_USE_DynamicLoader)
774 IF(KWSYS_USE_SystemInformation AND WIN32)
775 TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ws2_32)
776 ENDIF(KWSYS_USE_SystemInformation AND WIN32)
778 # Apply user-defined target properties to the library.
779 IF(KWSYS_PROPERTIES_CXX)
780 SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
781 ${KWSYS_PROPERTIES_CXX}
783 ENDIF(KWSYS_PROPERTIES_CXX)
785 # Create an install target for the library.
786 IF(KWSYS_INSTALL_LIBRARY_RULE)
787 INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE})
788 ENDIF(KWSYS_INSTALL_LIBRARY_RULE)
789 IF(KWSYS_LIBRARY_INSTALL_DIR)
790 INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE})
791 ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
792 ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
794 # Add a C-only library if requested.
795 IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
796 ADD_LIBRARY(${KWSYS_NAMESPACE}_c ${KWSYS_LIBRARY_TYPE} ${KWSYS_C_SRCS})
798 # Apply user-defined target properties to the library.
799 IF(KWSYS_PROPERTIES_C)
800 SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
801 ${KWSYS_PROPERTIES_C}
803 ENDIF(KWSYS_PROPERTIES_C)
805 # Create an install target for the library.
806 IF(KWSYS_INSTALL_LIBRARY_RULE)
807 INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE})
808 ENDIF(KWSYS_INSTALL_LIBRARY_RULE)
809 IF(KWSYS_LIBRARY_INSTALL_DIR)
810 INSTALL_TARGETS(${KWSYS_LIBRARY_INSTALL_DIR} ${KWSYS_NAMESPACE}_c)
811 ENDIF(KWSYS_LIBRARY_INSTALL_DIR)
812 ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
814 # For building kwsys itself, we use a macro defined on the command
815 # line to configure the namespace in the C and C++ source files.
816 ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
818 #-----------------------------------------------------------------------------
819 # Process execution on windows needs to build a forwarding executable
820 # that works around a Win9x bug. We encode the executable into a C
821 # file and build it into the library. Win9x platforms reproduce the
822 # executable into a temporary directory when it is needed.
823 IF(KWSYS_USE_Process)
825 # Build the forwarding executable itself and a program that will
826 # encode it into a C file.
827 ADD_EXECUTABLE(${KWSYS_NAMESPACE}ProcessFwd9x ProcessFwd9x.c)
828 ADD_EXECUTABLE(${KWSYS_NAMESPACE}EncodeExecutable EncodeExecutable.c)
830 # Construct the location of the executable to be encoded.
831 SET(BIN_DIR ${CMAKE_CURRENT_BINARY_DIR})
832 IF(EXECUTABLE_OUTPUT_PATH)
833 SET(BIN_DIR ${EXECUTABLE_OUTPUT_PATH})
834 ENDIF(EXECUTABLE_OUTPUT_PATH)
836 SET(CFG_INTDIR "/${CMAKE_CFG_INTDIR}")
837 IF(CMAKE_BUILD_TOOL MATCHES "make")
839 ENDIF(CMAKE_BUILD_TOOL MATCHES "make")
841 # Take advantage of a better custom command syntax if possible.
842 SET(CMD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}EncodeExecutable.exe)
843 SET(FWD ${BIN_DIR}${CFG_INTDIR}/${KWSYS_NAMESPACE}ProcessFwd9x.exe)
844 IF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
846 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
848 ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
849 ${KWSYS_NAMESPACE} ProcessFwd9x
850 DEPENDS ${CMD} ${FWD})
851 ELSE("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
853 TARGET ${KWSYS_NAMESPACE}
854 SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/ProcessFwd9x.c
856 ARGS ${FWD} ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
857 ${KWSYS_NAMESPACE} ProcessFwd9x
858 OUTPUTS ${CMAKE_CURRENT_BINARY_DIR}/${KWSYS_NAMESPACE}ProcessFwd9xEnc.c
859 DEPENDS ${CMD} ${FWD})
860 ENDIF("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 1.6)
862 # Make sure build occurs in proper order.
863 ADD_DEPENDENCIES(${KWSYS_NAMESPACE} ${KWSYS_NAMESPACE}ProcessFwd9x
864 ${KWSYS_NAMESPACE}EncodeExecutable)
866 ENDIF(KWSYS_USE_Process)
868 #-----------------------------------------------------------------------------
869 # Setup testing if not being built as part of another project.
870 IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
872 # Compute the location of executables.
873 SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
874 IF(EXECUTABLE_OUTPUT_PATH)
875 SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
876 ENDIF(EXECUTABLE_OUTPUT_PATH)
883 IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
884 SET(KWSYS_C_TESTS ${KWSYS_C_TESTS} testFail)
885 ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
886 CREATE_TEST_SOURCELIST(
887 KWSYS_C_TEST_SRCS ${KWSYS_NAMESPACE}TestsC.c
890 ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsC ${KWSYS_C_TEST_SRCS})
891 TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsC ${KWSYS_NAMESPACE}_c)
892 FOREACH(test ${KWSYS_C_TESTS})
893 ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
903 SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
907 testCommandLineArguments
908 testCommandLineArguments1
910 IF(KWSYS_USE_SystemInformation)
911 SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation)
912 ENDIF(KWSYS_USE_SystemInformation)
913 IF(KWSYS_USE_DynamicLoader)
914 SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader)
915 # If kwsys contains the DynamicLoader, need extra library
916 ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
917 ENDIF(KWSYS_USE_DynamicLoader)
918 CREATE_TEST_SOURCELIST(
919 KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
922 ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_CXX_TEST_SRCS})
923 TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestsCxx ${KWSYS_NAMESPACE})
924 SET(TEST_SYSTEMTOOLS_BIN_FILE
925 "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.bin")
926 SET(TEST_SYSTEMTOOLS_SRC_FILE
927 "${CMAKE_CURRENT_SOURCE_DIR}/testSystemTools.cxx")
929 ${PROJECT_SOURCE_DIR}/testSystemTools.h.in
930 ${PROJECT_BINARY_DIR}/testSystemTools.h)
931 INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR})
934 CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
935 "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
936 SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
937 ENDIF(CTEST_TEST_KWSYS)
939 SET(KWSYS_TEST_ARGS_testCommandLineArguments
940 --another-bool-variable
943 -SSS ken brad bill andy
944 --some-bool-variable=true
945 --some-double-variable12.5
946 --some-int-variable 14
947 "--some-string-variable=test string with space"
948 --some-multi-argument 5 1 8 3 7 1 3 9 7 1
949 -N 12.5 -SS=andy -N 1.31 -N 22
950 -SS=bill -BBtrue -SS=brad
958 SET(KWSYS_TEST_ARGS_testCommandLineArguments1
967 FOREACH(test ${KWSYS_CXX_TESTS})
968 ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
972 ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
973 TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c)
975 SET(KWSYS_TEST_PROCESS_7 7)
977 FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7})
978 ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
981 # Configure some test properties.
982 IF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
983 # We expect test to fail
984 SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES WILL_FAIL ON)
985 GET_TEST_PROPERTY(kwsys.testFail WILL_FAIL wfv)
986 SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES FAIL_REGULAR_EXPRESSION "ERROR_NOT_VALGRIND;FAIL;Test failed")
987 SET_TESTS_PROPERTIES(kwsys.testRegistry PROPERTIES PASS_REGULAR_EXPRESSION "Test passed")
988 SET_TESTS_PROPERTIES(kwsys.testFail PROPERTIES MEASUREMENT "Some Key=Some Value")
989 MESSAGE(STATUS "GET_TEST_PROPERTY returned: ${wfv}")
990 ENDIF(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY AND KWSYS_STANDALONE)
992 ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)