Introduce "generator expressions" to add_test()
[cmake.git] / CMakeLists.txt
blob9f76a8d4e961343b8fa3fbb89ceb15515f0d45e5
1 CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5 FATAL_ERROR)
2 PROJECT(CMake)
3 IF(COMMAND CMAKE_POLICY)
4   CMAKE_POLICY(SET CMP0003 NEW)
5 ENDIF(COMMAND CMAKE_POLICY)
7 MARK_AS_ADVANCED(CMAKE_BACKWARDS_COMPATIBILITY)
9 # Allow empty endif() and such with CMake 2.4.
10 SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS 1)
12 IF(NOT ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 2.4)
13   # Since the built CMake will install itself instead of the
14   # generating CMake, tell it that the install rules were generated
15   # by CMake 2.4.
16   INSTALL(CODE "SET(CMAKE_INSTALL_SELF_2_4 1)")
17 ENDIF()
19 #-----------------------------------------------------------------------
20 # a macro to deal with system libraries, implemented as a macro
21 # simply to improve readability of the main script
22 #-----------------------------------------------------------------------
23 MACRO(CMAKE_HANDLE_SYSTEM_LIBRARIES)
24   # Options have dependencies.
25   INCLUDE(CMakeDependentOption)
27   # Optionally use system xmlrpc.  We no longer build or use it by default.
28   OPTION(CTEST_USE_XMLRPC "Enable xmlrpc submission method in CTest." OFF)
29   MARK_AS_ADVANCED(CTEST_USE_XMLRPC)
31   # Allow the user to enable/disable all system utility library options
32   # by setting CMAKE_USE_SYSTEM_LIBRARIES on the command line.
33   IF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
34     SET(CMAKE_USE_SYSTEM_LIBRARIES_USER 1)
35   ENDIF(DEFINED CMAKE_USE_SYSTEM_LIBRARIES)
36   IF(CMAKE_USE_SYSTEM_LIBRARIES)
37     SET(CMAKE_USE_SYSTEM_LIBRARIES ON)
38   ELSE(CMAKE_USE_SYSTEM_LIBRARIES)
39     SET(CMAKE_USE_SYSTEM_LIBRARIES OFF)
40   ENDIF(CMAKE_USE_SYSTEM_LIBRARIES)
41   IF(CMAKE_USE_SYSTEM_LIBRARIES_USER)
42     SET(CMAKE_USE_SYSTEM_CURL "${CMAKE_USE_SYSTEM_LIBRARIES}"
43       CACHE BOOL "Use system-installed curl" FORCE)
44     SET(CMAKE_USE_SYSTEM_EXPAT "${CMAKE_USE_SYSTEM_LIBRARIES}"
45       CACHE BOOL "Use system-installed expat" FORCE)
46     SET(CMAKE_USE_SYSTEM_ZLIB "${CMAKE_USE_SYSTEM_LIBRARIES}"
47       CACHE BOOL "Use system-installed zlib" FORCE)
48   ENDIF(CMAKE_USE_SYSTEM_LIBRARIES_USER)
50   # Optionally use system utility libraries.
51   CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_CURL "Use system-installed curl"
52     ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CTEST_USE_XMLRPC" ON)
53   CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_EXPAT "Use system-installed expat"
54     ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CTEST_USE_XMLRPC" ON)
55   CMAKE_DEPENDENT_OPTION(CMAKE_USE_SYSTEM_ZLIB "Use system-installed zlib"
56     ${CMAKE_USE_SYSTEM_LIBRARIES} "NOT CMAKE_USE_SYSTEM_CURL" ON)
58   # There is currently no option for system tar because the upstream
59   # libtar does not have our modifications to allow reentrant
60   # object-oriented use of the library.
61   # OPTION(CMAKE_USE_SYSTEM_TAR    "Use system-installed tar"   OFF)
63   # Mention to the user what system libraries are being used.
64   FOREACH(util CURL EXPAT XMLRPC ZLIB)
65     IF(CMAKE_USE_SYSTEM_${util})
66       MESSAGE(STATUS "Using system-installed ${util}")
67     ENDIF(CMAKE_USE_SYSTEM_${util})
68   ENDFOREACH(util)
70   # Inform utility library header wrappers whether to use system versions.
71   CONFIGURE_FILE(${CMake_SOURCE_DIR}/Utilities/cmThirdParty.h.in
72     ${CMake_BINARY_DIR}/Utilities/cmThirdParty.h
73     @ONLY)
75 ENDMACRO(CMAKE_HANDLE_SYSTEM_LIBRARIES)
79 #-----------------------------------------------------------------------
80 # a macro to check for MFC and setup to build the MFC Dialog
81 # simply to improve readability of the main script
82 #-----------------------------------------------------------------------
83 MACRO(CMAKE_TEST_FOR_MFC)
84   SET(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
85   IF(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
86     SET(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
87   ENDIF(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
88   
89   IF(CMAKE_BUILD_ON_VISUAL_STUDIO)
90     IF("CMake_HAVE_MFC" MATCHES "^CMake_HAVE_MFC$")
91       SET(CHECK_INCLUDE_FILE_VAR "afxwin.h")
92       CONFIGURE_FILE(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
93         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
94       MESSAGE(STATUS "Looking for MFC")
95       TRY_COMPILE(CMake_HAVE_MFC
96         ${CMAKE_BINARY_DIR}
97         ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx
98         CMAKE_FLAGS
99         -DCMAKE_MFC_FLAG:STRING=2
100         -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL
101         OUTPUT_VARIABLE OUTPUT)
102       IF(CMake_HAVE_MFC)
103         MESSAGE(STATUS "Looking for MFC - found")
104         SET(CMake_HAVE_MFC 1 CACHE INTERNAL "Have MFC?")
105         FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
106           "Determining if MFC exists passed with the following output:\n"
107           "${OUTPUT}\n\n")
108       ELSE(CMake_HAVE_MFC)
109         MESSAGE(STATUS "Looking for MFC - not found")
110         SET(CMake_HAVE_MFC 0 CACHE INTERNAL "Have MFC?")
111         FILE(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
112           "Determining if MFC exists failed with the following output:\n"
113           "${OUTPUT}\n\n")
114       ENDIF(CMake_HAVE_MFC)
115     ENDIF("CMake_HAVE_MFC" MATCHES "^CMake_HAVE_MFC$")
116     
117     IF(CMake_HAVE_MFC)
118       OPTION(BUILD_MFCDialog "Whether to build the CMakeSetup MFC dialog." ON)
119     ELSE(CMake_HAVE_MFC)
120       SET(BUILD_MFCDialog 0)
121     ENDIF(CMake_HAVE_MFC)
122   ELSE(CMAKE_BUILD_ON_VISUAL_STUDIO)
123     SET(BUILD_MFCDialog 0)
124   ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO)
125 ENDMACRO(CMAKE_TEST_FOR_MFC)
129 #-----------------------------------------------------------------------
130 # a macro to determine the generator and ctest executable to use
131 # for testing. Simply to improve readability of the main script.
132 #-----------------------------------------------------------------------
133 MACRO(CMAKE_SETUP_TESTING)
134   IF (NOT DART_ROOT)
135     SET(MAKEPROGRAM ${CMAKE_MAKE_PROGRAM})
136   ENDIF (NOT DART_ROOT)
137   
138   IF(BUILD_TESTING)
139     SET(CMAKE_TEST_GENERATOR "" CACHE STRING 
140       "Generator used when running tests")
141     SET(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH 
142       "Generator used when running tests")
143     IF(NOT CMAKE_TEST_GENERATOR)
144       SET(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
145       SET(CMAKE_TEST_MAKEPROGRAM "${MAKEPROGRAM}")
146     ELSE(NOT CMAKE_TEST_GENERATOR)
147       SET(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
148     ENDIF(NOT CMAKE_TEST_GENERATOR)
149     
150     # Are we testing with the MSVC compiler?
151     SET(CMAKE_TEST_MSVC 0)
152     IF(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
153       SET(CMAKE_TEST_MSVC 1)
154     ELSE(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
155       IF("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
156           "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
157         SET(CMAKE_TEST_MSVC 1)
158       ENDIF("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
159         "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
160     ENDIF(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
161     
162     SET(CMAKE_TEST_SYSTEM_LIBRARIES 0)
163     FOREACH(util CURL EXPAT XMLRPC ZLIB)
164       IF(CMAKE_USE_SYSTEM_${util})
165         SET(CMAKE_TEST_SYSTEM_LIBRARIES 1)
166       ENDIF(CMAKE_USE_SYSTEM_${util})
167     ENDFOREACH(util)
168     
169     # This variable is set by cmake, however to
170     # test cmake we want to make sure that
171     # the ctest from this cmake is used for testing
172     # and not the ctest from the cmake building and testing
173     # cmake.
174     SET(CMAKE_CTEST_COMMAND "${EXECUTABLE_OUTPUT_PATH}/ctest")
175     SET(CMAKE_CMAKE_COMMAND "${EXECUTABLE_OUTPUT_PATH}/cmake")
176   ENDIF(BUILD_TESTING)
178   # configure some files for testing
179   CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/Templates/CTestScript.cmake.in"
180     "${CMAKE_CURRENT_BINARY_DIR}/CTestScript.cmake"
181     @ONLY)  
182   CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
183     ${CMake_BINARY_DIR}/Tests/.NoDartCoverage)
184   CONFIGURE_FILE(${CMake_SOURCE_DIR}/Tests/.NoDartCoverage
185     ${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
186   CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
187     ${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
188   CONFIGURE_FILE(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
189     ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
190   IF(BUILD_TESTING AND DART_ROOT)
191     CONFIGURE_FILE(${CMake_SOURCE_DIR}/CMakeLogo.gif 
192       ${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
193   ENDIF(BUILD_TESTING AND DART_ROOT)
194   MARK_AS_ADVANCED(DART_ROOT)
195   MARK_AS_ADVANCED(CURL_TESTING)
196 ENDMACRO(CMAKE_SETUP_TESTING)
200 #-----------------------------------------------------------------------
201 # a macro to build the utilities used by CMake
202 # Simply to improve readability of the main script.
203 #-----------------------------------------------------------------------
204 MACRO (CMAKE_BUILD_UTILITIES)
205   #---------------------------------------------------------------------
206   # Create the kwsys library for CMake.
207   SET(KWSYS_NAMESPACE cmsys)
208   SET(KWSYS_USE_SystemTools 1)
209   SET(KWSYS_USE_Directory 1)
210   SET(KWSYS_USE_RegularExpression 1)
211   SET(KWSYS_USE_Base64 1)
212   SET(KWSYS_USE_MD5 1)
213   SET(KWSYS_USE_Process 1)
214   SET(KWSYS_USE_CommandLineArguments 1)
215   SET(KWSYS_HEADER_ROOT ${CMake_BINARY_DIR}/Source)
216   SUBDIRS(Source/kwsys)
217   
218   #---------------------------------------------------------------------
219   # Setup third-party libraries.
220   # Everything in the tree should be able to include files from the
221   # Utilities directory.
222   INCLUDE_DIRECTORIES(
223     ${CMake_BINARY_DIR}/Utilities
224     ${CMake_SOURCE_DIR}/Utilities
225     )
226   
227   # check for the use of system libraries versus builtin ones
228   # (a macro defined in this file)
229   CMAKE_HANDLE_SYSTEM_LIBRARIES()
230   
231   #---------------------------------------------------------------------
232   # Build zlib library for Curl, CMake, and CTest.
233   SET(CMAKE_ZLIB_HEADER "cm_zlib.h")
234   IF(CMAKE_USE_SYSTEM_ZLIB)
235     FIND_PACKAGE(ZLIB)
236     IF(NOT ZLIB_FOUND)
237       MESSAGE(FATAL_ERROR 
238         "CMAKE_USE_SYSTEM_ZLIB is ON but a zlib is not found!")
239     ENDIF(NOT ZLIB_FOUND)
240     SET(CMAKE_ZLIB_INCLUDES ${ZLIB_INCLUDE_DIR})
241     SET(CMAKE_ZLIB_LIBRARIES ${ZLIB_LIBRARIES})
242   ELSE(CMAKE_USE_SYSTEM_ZLIB)
243     SET(CMAKE_ZLIB_INCLUDES)
244     SET(CMAKE_ZLIB_LIBRARIES cmzlib)
245     SUBDIRS(Utilities/cmzlib)
246   ENDIF(CMAKE_USE_SYSTEM_ZLIB)
247   
248   #---------------------------------------------------------------------
249   # Build Curl library for CTest.
250   IF(CMAKE_USE_SYSTEM_CURL)
251     FIND_PACKAGE(CURL)
252     IF(NOT CURL_FOUND)
253       MESSAGE(FATAL_ERROR 
254         "CMAKE_USE_SYSTEM_CURL is ON but a curl is not found!")
255     ENDIF(NOT CURL_FOUND)
256     SET(CMAKE_CURL_INCLUDES ${CURL_INCLUDE_DIRS})
257     SET(CMAKE_CURL_LIBRARIES ${CURL_LIBRARIES})
258   ELSE(CMAKE_USE_SYSTEM_CURL)
259     SET(CURL_SPECIAL_ZLIB_H ${CMAKE_ZLIB_HEADER})
260     SET(CURL_SPECIAL_LIBZ_INCLUDES ${CMAKE_ZLIB_INCLUDES})
261     SET(CURL_SPECIAL_LIBZ ${CMAKE_ZLIB_LIBRARIES})
262     OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" FALSE)
263     IF(NOT CMAKE_BUILD_CURL_SHARED)
264       ADD_DEFINITIONS(-DCURL_STATICLIB)
265     ENDIF(NOT CMAKE_BUILD_CURL_SHARED)
266     SET(CMAKE_CURL_INCLUDES)
267     SET(CMAKE_CURL_LIBRARIES cmcurl)
268     SUBDIRS(Utilities/cmcurl)
269   ENDIF(CMAKE_USE_SYSTEM_CURL)
271   #---------------------------------------------------------------------
272   # Build Tar library for CTest.
273   SET(CMTAR_ZLIB_HEADER ${CMAKE_ZLIB_HEADER})
274   SET(CMTAR_ZLIB_LIBRARIES ${CMAKE_ZLIB_LIBRARIES})
275   SET(CMTAR_ZLIB_INCLUDE_DIRS ${CMAKE_ZLIB_INCLUDES})
276   SET(CMAKE_TAR_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmtar)
277   SET(CMAKE_TAR_LIBRARIES cmtar)
278   SUBDIRS(Utilities/cmtar)
279   
280   #---------------------------------------------------------------------
281   # Build Compress library for CTest.
282   SET(CMAKE_COMPRESS_INCLUDES 
283     "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
284   SET(CMAKE_COMPRESS_LIBRARIES "cmcompress")
285   SUBDIRS(Utilities/cmcompress)
286   
287   #---------------------------------------------------------------------
288   # Build expat library for CMake and CTest.
289   IF(CMAKE_USE_SYSTEM_EXPAT)
290     FIND_PACKAGE(EXPAT)
291     IF(NOT EXPAT_FOUND)
292       MESSAGE(FATAL_ERROR
293         "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!")
294     ENDIF(NOT EXPAT_FOUND)
295     SET(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS})
296     SET(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
297   ELSE(CMAKE_USE_SYSTEM_EXPAT)
298     SET(CMAKE_EXPAT_INCLUDES)
299     SET(CMAKE_EXPAT_LIBRARIES cmexpat)
300     SUBDIRS(Utilities/cmexpat)
301   ENDIF(CMAKE_USE_SYSTEM_EXPAT)
302   
303   #---------------------------------------------------------------------
304   # Build XMLRPC library for CMake and CTest.
305   IF(CTEST_USE_XMLRPC)
306     FIND_PACKAGE(XMLRPC QUIET REQUIRED libwww-client)
307     IF(NOT XMLRPC_FOUND)
308       MESSAGE(FATAL_ERROR
309         "CTEST_USE_XMLRPC is ON but xmlrpc is not found!")
310     ENDIF(NOT XMLRPC_FOUND)
311     SET(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
312     SET(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
313   ENDIF(CTEST_USE_XMLRPC)
314   
315   #---------------------------------------------------------------------
316   # Use curses?
317   IF (UNIX)
318     # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
319     IF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
320       SET(CURSES_NEED_NCURSES TRUE)
321       FIND_PACKAGE(Curses QUIET)
322       IF (CURSES_LIBRARY)
323         OPTION(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
324       ELSE (CURSES_LIBRARY)
325         MESSAGE("Curses libraries were not found. Curses GUI for CMake will not be built.")
326         SET(BUILD_CursesDialog 0)
327       ENDIF (CURSES_LIBRARY)
328     ELSE(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
329       SET(BUILD_CursesDialog 0)
330     ENDIF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
331   ELSE (UNIX)
332     SET(BUILD_CursesDialog 0)
333   ENDIF (UNIX)
334   IF(BUILD_CursesDialog)
335     SUBDIRS(Source/CursesDialog/form)
336   ENDIF(BUILD_CursesDialog)
337 ENDMACRO (CMAKE_BUILD_UTILITIES)
341 #-----------------------------------------------------------------------
342 # The main section of the CMakeLists file
344 #-----------------------------------------------------------------------
345 # The CMake version number.
346 SET(CMake_VERSION_MAJOR 2)
347 SET(CMake_VERSION_MINOR 7)
348 SET(CMake_VERSION_PATCH 0)
350 # We use odd minor numbers for development versions.
351 # Use a date for the development patch level.
352 IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
353   INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
354   SET(CMake_VERSION_PATCH
355     "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
356     )
357 ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
359 SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
360 SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}")
362 # Include the standard Dart testing module
363 ENABLE_TESTING()
364 INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
366 # where to write the resulting executables and libraries
367 SET(BUILD_SHARED_LIBS OFF)
368 SET(EXECUTABLE_OUTPUT_PATH ${CMake_BINARY_DIR}/bin CACHE INTERNAL 
369   "Where to put the executables for CMake")
370 SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL 
371   "Where to put the libraries for CMake")
372 INCLUDE_REGULAR_EXPRESSION("^.*$")
374 # The CMake executables usually do not need any rpath to run in the build or
375 # install tree.
376 SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
378 SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}" CACHE STRING
379   "Install location for data (relative to prefix).")
380 SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION}" CACHE STRING
381   "Install location for documentation (relative to prefix).")
382 SET(CMAKE_MAN_DIR "/man" CACHE STRING
383   "Install location for man pages (relative to prefix).")
384 MARK_AS_ADVANCED(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
385 STRING(REGEX REPLACE "^/" "" CMake_DATA_DEST "${CMAKE_DATA_DIR}")
387 # include special compile flags for some compilers
388 INCLUDE(CompileFlags.cmake)
390 # no clue why we are testing for this here
391 INCLUDE(CheckSymbolExists)
392 CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
393 CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
395 # build the utilities (a macro defined in this file) 
396 CMAKE_BUILD_UTILITIES()
398 # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
399 # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
400 # which isn't in the default linker search path. So without RPATH ccmake 
401 # doesn't run and the build doesn't succeed since ccmake is executed for
402 # generating the documentation.
403 IF(BUILD_CursesDialog)
404   GET_FILENAME_COMPONENT(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
405   SET(CURSES_NEED_RPATH FALSE)
406   IF(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
407     SET(CURSES_NEED_RPATH TRUE)
408   ENDIF(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
409 ENDIF(BUILD_CursesDialog)
411 IF(BUILD_QtDialog)
412   IF(APPLE)
413     SET(CMAKE_BUNDLE_NAME
414       "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}")
415     SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
416     # make sure CMAKE_INSTALL_PREFIX ends in /
417     STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
418     MATH(EXPR LEN "${LEN} -1" )
419     STRING(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
420     IF(NOT "${ENDCH}" STREQUAL "/")
421       SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
422     ENDIF(NOT "${ENDCH}" STREQUAL "/")
423     SET(CMAKE_INSTALL_PREFIX 
424       "${CMAKE_INSTALL_PREFIX}${CMAKE_BUNDLE_NAME}.app/Contents")
425   ENDIF(APPLE)
426   
427   SET(QT_NEED_RPATH FALSE)
428   IF(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
429     SET(QT_NEED_RPATH TRUE)
430   ENDIF(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
431 ENDIF(BUILD_QtDialog)
434 # The same might be true on other systems for other libraries.
435 # Then only enable RPATH if we have are building at least with cmake 2.4, 
436 # since this one has much better RPATH features than cmake 2.2.
437 # The executables are then built with the RPATH for the libraries outside
438 # the build tree, which is both the build and the install RPATH.
439 IF (UNIX)
440   IF(   CMAKE_USE_SYSTEM_CURL   OR  CMAKE_USE_SYSTEM_ZLIB
441         OR  CMAKE_USE_SYSTEM_EXPAT  OR  CTEST_USE_XMLRPC  OR  CURSES_NEED_RPATH  OR  QT_NEED_RPATH)
442     SET(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
443     SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
444     SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
445   ENDIF(CMAKE_USE_SYSTEM_CURL   OR  CMAKE_USE_SYSTEM_ZLIB
446         OR  CMAKE_USE_SYSTEM_EXPAT  OR  CTEST_USE_XMLRPC  OR  CURSES_NEED_RPATH  OR  QT_NEED_RPATH)
447 ENDIF (UNIX)
450 # should we build the MFC dialog? (a macro defined in this file)
451 CMAKE_TEST_FOR_MFC()
453 # add the uninstall support
454 CONFIGURE_FILE(
455   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
456   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
457   @ONLY)
458 ADD_CUSTOM_TARGET(uninstall
459   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
461 INCLUDE (CMakeCPack.cmake)
463 # setup some Testing support (a macro defined in this file)
464 CMAKE_SETUP_TESTING()
465 CONFIGURE_FILE(
466   "${CMAKE_CURRENT_SOURCE_DIR}/DartLocal.conf.in"
467   "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
468   COPYONLY)
470 OPTION(CMAKE_STRICT   
471   "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF)
472 MARK_AS_ADVANCED(CMAKE_STRICT)
475 # build the remaining subdirectories
476 SUBDIRS(Source)
477 SUBDIRS(Utilities)
478 SUBDIRS(Tests)
480 # add a test
481 ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" 
482   --system-information  -G "${CMAKE_TEST_GENERATOR}" )
484 # Install script directories.
485 INSTALL(
486   DIRECTORY Modules Templates
487   DESTINATION "${CMake_DATA_DEST}"
488   FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
489   DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
490                         GROUP_READ GROUP_EXECUTE
491                         WORLD_READ WORLD_EXECUTE
492   PATTERN "*.sh.in" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
493                                 GROUP_READ GROUP_EXECUTE
494                                 WORLD_READ WORLD_EXECUTE
495   PATTERN "CVS" EXCLUDE
496   )
498 #-----------------------------------------------------------------------
499 # End of the main section of the CMakeLists file
500 #-----------------------------------------------------------------------