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