STYLE: suppress warnings for borland
[cmake.git] / CMakeLists.txt
blob9267f42ecc692e14d7d54eee360d5c4b220cb86b
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     OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" FALSE)
270     IF(NOT CMAKE_BUILD_CURL_SHARED)
271       ADD_DEFINITIONS(-DCURL_STATICLIB)
272     ENDIF(NOT CMAKE_BUILD_CURL_SHARED)
273     SET(CMAKE_CURL_INCLUDES)
274     SET(CMAKE_CURL_LIBRARIES cmcurl)
275     IF(CMAKE_USE_NEW_CURL)
276       # for cmake never build examples
277       SET(CURL_SKIP_EXAMPLES TRUE)
278       ADD_SUBDIRECTORY(Utilities/cmcurl-7.19.0)
279     ELSE(CMAKE_USE_NEW_CURL)
280       SUBDIRS(Utilities/cmcurl)
281     ENDIF(CMAKE_USE_NEW_CURL)
282   ENDIF(CMAKE_USE_SYSTEM_CURL)
284   #---------------------------------------------------------------------
285   # Build Tar library for CTest.
286   SET(CMTAR_ZLIB_HEADER ${CMAKE_ZLIB_HEADER})
287   SET(CMTAR_ZLIB_LIBRARIES ${CMAKE_ZLIB_LIBRARIES})
288   SET(CMTAR_ZLIB_INCLUDE_DIRS ${CMAKE_ZLIB_INCLUDES})
289   SET(CMAKE_TAR_INCLUDES ${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmtar)
290   SET(CMAKE_TAR_LIBRARIES cmtar)
291   SUBDIRS(Utilities/cmtar)
292   
293   #---------------------------------------------------------------------
294   # Build Compress library for CTest.
295   SET(CMAKE_COMPRESS_INCLUDES 
296     "${CMAKE_CURRENT_BINARY_DIR}/Utilities/cmcompress")
297   SET(CMAKE_COMPRESS_LIBRARIES "cmcompress")
298   SUBDIRS(Utilities/cmcompress)
299   
300   #---------------------------------------------------------------------
301   # Build expat library for CMake and CTest.
302   IF(CMAKE_USE_SYSTEM_EXPAT)
303     FIND_PACKAGE(EXPAT)
304     IF(NOT EXPAT_FOUND)
305       MESSAGE(FATAL_ERROR
306         "CMAKE_USE_SYSTEM_EXPAT is ON but a expat is not found!")
307     ENDIF(NOT EXPAT_FOUND)
308     SET(CMAKE_EXPAT_INCLUDES ${EXPAT_INCLUDE_DIRS})
309     SET(CMAKE_EXPAT_LIBRARIES ${EXPAT_LIBRARIES})
310   ELSE(CMAKE_USE_SYSTEM_EXPAT)
311     SET(CMAKE_EXPAT_INCLUDES)
312     SET(CMAKE_EXPAT_LIBRARIES cmexpat)
313     SUBDIRS(Utilities/cmexpat)
314   ENDIF(CMAKE_USE_SYSTEM_EXPAT)
315   
316   #---------------------------------------------------------------------
317   # Build XMLRPC library for CMake and CTest.
318   IF(CMAKE_USE_SYSTEM_XMLRPC)
319     FIND_PACKAGE(XMLRPC QUIET REQUIRED libwww-client)
320     IF(NOT XMLRPC_FOUND)
321       MESSAGE(FATAL_ERROR
322         "CMAKE_USE_SYSTEM_XMLRPC is ON but a xmlrpc is not found!")
323     ENDIF(NOT XMLRPC_FOUND)
324     SET(CMAKE_XMLRPC_INCLUDES ${XMLRPC_INCLUDE_DIRS})
325     SET(CMAKE_XMLRPC_LIBRARIES ${XMLRPC_LIBRARIES})
326   ELSE(CMAKE_USE_SYSTEM_XMLRPC)
327     SET(CMAKE_XMLRPC_INCLUDES)
328     SET(CMAKE_XMLRPC_LIBRARIES cmXMLRPC)
329     SUBDIRS(Utilities/cmxmlrpc)
330   ENDIF(CMAKE_USE_SYSTEM_XMLRPC)
331   
332   #---------------------------------------------------------------------
333   # Use curses?
334   IF (UNIX)
335     # there is a bug in the Syllable libraries which makes linking ccmake fail, Alex
336     IF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
337       SET(CURSES_NEED_NCURSES TRUE)
338       FIND_PACKAGE(Curses QUIET)
339       IF (CURSES_LIBRARY)
340         OPTION(BUILD_CursesDialog "Build the CMake Curses Dialog ccmake" ON)
341       ELSE (CURSES_LIBRARY)
342         MESSAGE("Curses libraries were not found. Curses GUI for CMake will not be built.")
343         SET(BUILD_CursesDialog 0)
344       ENDIF (CURSES_LIBRARY)
345     ELSE(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
346       SET(BUILD_CursesDialog 0)
347     ENDIF(NOT "${CMAKE_SYSTEM_NAME}" MATCHES syllable)
348   ELSE (UNIX)
349     SET(BUILD_CursesDialog 0)
350   ENDIF (UNIX)
351   IF(BUILD_CursesDialog)
352     SUBDIRS(Source/CursesDialog/form)
353   ENDIF(BUILD_CursesDialog)
354 ENDMACRO (CMAKE_BUILD_UTILITIES)
358 #-----------------------------------------------------------------------
359 # The main section of the CMakeLists file
361 #-----------------------------------------------------------------------
362 # The CMake version number.
363 SET(CMake_VERSION_MAJOR 2)
364 SET(CMake_VERSION_MINOR 7)
365 SET(CMake_VERSION_PATCH 0)
367 # We use odd minor numbers for development versions.
368 # Use a date for the development patch level.
369 IF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
370   INCLUDE(${CMake_SOURCE_DIR}/Source/kwsys/kwsysDateStamp.cmake)
371   SET(CMake_VERSION_PATCH
372     "${KWSYS_DATE_STAMP_YEAR}${KWSYS_DATE_STAMP_MONTH}${KWSYS_DATE_STAMP_DAY}"
373     )
374 ENDIF("${CMake_VERSION_MINOR}" MATCHES "[13579]$")
376 SET(CMake_VERSION "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
377 SET(CMake_VERSION_FULL "${CMake_VERSION}.${CMake_VERSION_PATCH}")
379 # Include the standard Dart testing module
380 ENABLE_TESTING()
381 INCLUDE (${CMAKE_ROOT}/Modules/Dart.cmake)
383 # where to write the resulting executables and libraries
384 SET(BUILD_SHARED_LIBS OFF)
385 SET(EXECUTABLE_OUTPUT_PATH ${CMake_BINARY_DIR}/bin CACHE INTERNAL 
386   "Where to put the executables for CMake")
387 SET(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL 
388   "Where to put the libraries for CMake")
389 INCLUDE_REGULAR_EXPRESSION("^.*$")
391 # The CMake executables usually do not need any rpath to run in the build or
392 # install tree.
393 SET(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
395 SET(CMAKE_DATA_DIR "/share/cmake-${CMake_VERSION}" CACHE STRING
396   "Install location for data (relative to prefix).")
397 SET(CMAKE_DOC_DIR "/doc/cmake-${CMake_VERSION}" CACHE STRING
398   "Install location for documentation (relative to prefix).")
399 SET(CMAKE_MAN_DIR "/man" CACHE STRING
400   "Install location for man pages (relative to prefix).")
401 MARK_AS_ADVANCED(CMAKE_DATA_DIR CMAKE_DOC_DIR CMAKE_MAN_DIR)
403 # include special compile flags for some compilers
404 INCLUDE(CompileFlags.cmake)
406 # no clue why we are testing for this here
407 INCLUDE(CheckSymbolExists)
408 CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
409 CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
411 # build the utilities (a macro defined in this file) 
412 CMAKE_BUILD_UTILITIES()
414 # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
415 # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
416 # which isn't in the default linker search path. So without RPATH ccmake 
417 # doesn't run and the build doesn't succeed since ccmake is executed for
418 # generating the documentation.
419 IF(BUILD_CursesDialog)
420   GET_FILENAME_COMPONENT(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
421   SET(CURSES_NEED_RPATH FALSE)
422   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")
423     SET(CURSES_NEED_RPATH TRUE)
424   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")
425 ENDIF(BUILD_CursesDialog)
427 IF(BUILD_QtDialog)
428   IF(APPLE)
429     SET(CMAKE_BUNDLE_NAME
430       "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}-${CMake_VERSION_PATCH}")
431     SET(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
432     # make sure CMAKE_INSTALL_PREFIX ends in /
433     STRING(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
434     MATH(EXPR LEN "${LEN} -1" )
435     STRING(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
436     IF(NOT "${ENDCH}" STREQUAL "/")
437       SET(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
438     ENDIF(NOT "${ENDCH}" STREQUAL "/")
439     SET(CMAKE_INSTALL_PREFIX 
440       "${CMAKE_INSTALL_PREFIX}${CMAKE_BUNDLE_NAME}.app/Contents")
441   ENDIF(APPLE)
442   
443   SET(QT_NEED_RPATH FALSE)
444   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")
445     SET(QT_NEED_RPATH TRUE)
446   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")
447 ENDIF(BUILD_QtDialog)
450 # The same might be true on other systems for other libraries if 
451 # CMAKE_USE_SYSTEM_XMLRPC or other variables like this are enabled.
452 # Then only enable RPATH if we have are building at least with cmake 2.4, 
453 # since this one has much better RPATH features than cmake 2.2.
454 # The executables are then built with the RPATH for the libraries outside
455 # the build tree, which is both the build and the install RPATH.
456 IF (UNIX)
457   IF(   CMAKE_USE_SYSTEM_CURL   OR  CMAKE_USE_SYSTEM_ZLIB
458         OR  CMAKE_USE_SYSTEM_EXPAT  OR  CMAKE_USE_SYSTEM_XMLRPC  OR  CURSES_NEED_RPATH  OR  QT_NEED_RPATH)
459     SET(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
460     SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
461     SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
462   ENDIF(CMAKE_USE_SYSTEM_CURL   OR  CMAKE_USE_SYSTEM_ZLIB
463         OR  CMAKE_USE_SYSTEM_EXPAT  OR  CMAKE_USE_SYSTEM_XMLRPC  OR  CURSES_NEED_RPATH  OR  QT_NEED_RPATH)
464 ENDIF (UNIX)
467 # should we build the MFC dialog? (a macro defined in this file)
468 CMAKE_TEST_FOR_MFC()
470 # add the uninstall support
471 CONFIGURE_FILE(
472   "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
473   "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
474   @ONLY)
475 ADD_CUSTOM_TARGET(uninstall
476   "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
478 INCLUDE (CMakeCPack.cmake)
480 # setup some Testing support (a macro defined in this file)
481 CMAKE_SETUP_TESTING()
482 CONFIGURE_FILE(
483   "${CMAKE_CURRENT_SOURCE_DIR}/DartLocal.conf.in"
484   "${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
485   COPYONLY)
487 OPTION(CMAKE_STRICT   
488   "Perform strict testing to record property and variable access. Can be used to report any undefined properties or variables" OFF)
489 MARK_AS_ADVANCED(CMAKE_STRICT)
492 # build the remaining subdirectories
493 SUBDIRS(Source)
494 SUBDIRS(Modules)
495 SUBDIRS(Templates)
496 SUBDIRS(Utilities)
497 SUBDIRS(Tests)
499 # add a test
500 ADD_TEST(SystemInformationNew "${CMAKE_CMAKE_COMMAND}" 
501   --system-information  -G "${CMAKE_TEST_GENERATOR}" )
503 #-----------------------------------------------------------------------
504 # End of the main section of the CMakeLists file
505 #-----------------------------------------------------------------------