Updated formatting of documentation plus a little reorganization.
[cmake.git] / Source / CMakeLists.txt
blob3849e9fee9c536431bb9af1825a813488296d115
1 INCLUDE(CheckIncludeFile)
2 # Check if we can build support for ELF parsing.
3 CHECK_INCLUDE_FILE("elf.h" HAVE_ELF_H)
4 IF(HAVE_ELF_H)
5   SET(CMAKE_USE_ELF_PARSER 1)
6 ELSE(HAVE_ELF_H)
7   SET(CMAKE_USE_ELF_PARSER)
8 ENDIF(HAVE_ELF_H)
10 # configure the .h file
11 CONFIGURE_FILE(
12   "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in"
13   "${CMake_BINARY_DIR}/Source/cmConfigure.h"
14   )
15 CONFIGURE_FILE(
16   "${CMake_SOURCE_DIR}/Source/cmVersionConfig.h.in"
17   "${CMake_BINARY_DIR}/Source/cmVersionConfig.h"
18   )
19 CONFIGURE_FILE(
20   "${CMake_SOURCE_DIR}/Source/CPack/cmCPackConfigure.h.in"
21   "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h"
22   )
24 # add the include path to find the .h
25 INCLUDE_DIRECTORIES(
26   "${CMake_BINARY_DIR}/Source"
27   "${CMake_SOURCE_DIR}/Source"
28   ${CMAKE_ZLIB_INCLUDES}
29   ${CMAKE_EXPAT_INCLUDES}
30   ${CMAKE_TAR_INCLUDES}
31   ${CMAKE_COMPRESS_INCLUDES}
32   )
34 # let cmake know it is supposed to use it
35 ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE)
37 OPTION(CMAKE_REGENERATE_YACCLEX
38   "Regenerate YACC and LEXX files" OFF)
39 MARK_AS_ADVANCED(CMAKE_REGENERATE_YACCLEX)
40 IF(CMAKE_REGENERATE_YACCLEX)
41   SET(parsersLexers cmDependsFortran cmCommandArgument cmExpr)
42   FIND_PROGRAM(YACC_EXECUTABLE
43     NAMES yacc bison
44     PATHS /usr/bin
45     DOC "Yacc or Bison executable")
46   FIND_PROGRAM(FLEX_EXECUTABLE
47     NAMES flex
48     PATHS /usr/bin
49     DOC "Flex executable")
50   MARK_AS_ADVANCED(YACC_EXECUTABLE FLEX_EXECUTABLE)
51   IF(YACC_EXECUTABLE)
52     SET(BISON_FLAGS)
53     IF(YACC_EXECUTABLE MATCHES "bison")
54       SET(BISON_FLAGS "--yacc")
55     ENDIF(YACC_EXECUTABLE MATCHES "bison")
56     SET(yacc_files)
57     FOREACH(name ${parsersLexers})
58       SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}Parser.y")
59       SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}Parser.cxx")
60       SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}ParserTokens.h")
61       ADD_CUSTOM_COMMAND(
62         OUTPUT "${dst}"
63         DEPENDS "${src}"
64         COMMAND
65         ${YACC_EXECUTABLE}
66         --name-prefix=${name}_yy --defines=${hdr} -o${dst} ${src}
67         )
68       SET(yacc_files ${yacc_files} "${dst}")
69     ENDFOREACH(name)
70     ADD_CUSTOM_TARGET(RerunYacc DEPENDS ${yacc_files})
71   ENDIF(YACC_EXECUTABLE)
72   IF(FLEX_EXECUTABLE)
73     SET(lex_files)
74     FOREACH(name ${parsersLexers})
75       SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}Lexer.in.l")
76       SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}Lexer.cxx")
77       SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}Lexer.h")
78       ADD_CUSTOM_COMMAND(
79         OUTPUT "${dst}"
80         DEPENDS "${src}"
81         COMMAND
82         ${FLEX_EXECUTABLE}
83         --prefix=${name}_yy --header-file=${hdr} -o${dst} ${src}
84         )
85       SET(lex_files ${lex_files} "${dst}")
86     ENDFOREACH(name)
87     ADD_CUSTOM_TARGET(RerunLex DEPENDS ${lex_files})
88   ENDIF(FLEX_EXECUTABLE)
90 ENDIF(CMAKE_REGENERATE_YACCLEX)
92 # Check if we can build the ELF parser.
93 IF(CMAKE_USE_ELF_PARSER)
94   SET(ELF_SRCS cmELF.h cmELF.cxx)
95 ENDIF(CMAKE_USE_ELF_PARSER)
98 # Sources for CMakeLib
100 SET(SRCS
101   cmBootstrapCommands.cxx
102   cmCacheManager.cxx
103   cmCacheManager.h
104   cmCommands.cxx
105   cmCommands.h
106   cmCommandArgumentLexer.cxx
107   cmCommandArgumentParser.cxx
108   cmCommandArgumentParserHelper.cxx
109   cmComputeComponentGraph.cxx
110   cmComputeComponentGraph.h
111   cmComputeLinkDepends.cxx
112   cmComputeLinkDepends.h
113   cmComputeLinkInformation.cxx
114   cmComputeLinkInformation.h
115   cmComputeTargetDepends.h
116   cmComputeTargetDepends.cxx
117   cmCustomCommand.cxx
118   cmCustomCommand.h
119   cmDefinitions.cxx
120   cmDefinitions.h
121   cmDepends.cxx
122   cmDepends.h
123   cmDependsC.cxx
124   cmDependsC.h
125   cmDependsFortran.cxx
126   cmDependsFortran.h
127   cmDependsFortranLexer.cxx
128   cmDependsFortranParser.cxx
129   cmDependsFortranParser.h
130   cmDependsJava.cxx
131   cmDependsJava.h
132   cmDependsJavaLexer.cxx
133   cmDependsJavaParser.cxx
134   cmDependsJavaParserHelper.cxx
135   cmDependsJavaParserHelper.h
136   cmDocumentation.cxx
137   cmDocumentationFormatter.cxx
138   cmDocumentationFormatterHTML.cxx
139   cmDocumentationFormatterDocbook.cxx
140   cmDocumentationFormatterMan.cxx
141   cmDocumentationFormatterText.cxx
142   cmDocumentationFormatterUsage.cxx
143   cmDocumentationSection.cxx
144   cmDocumentVariables.cxx
145   cmDynamicLoader.cxx
146   cmDynamicLoader.h
147   ${ELF_SRCS}
148   cmExprLexer.cxx
149   cmExprParser.cxx
150   cmExprParserHelper.cxx
151   cmExportBuildFileGenerator.h
152   cmExportBuildFileGenerator.cxx
153   cmExportFileGenerator.h
154   cmExportFileGenerator.cxx
155   cmExportInstallFileGenerator.h
156   cmExportInstallFileGenerator.cxx
157   cmExtraEclipseCDT4Generator.cxx
158   cmExtraEclipseCDT4Generator.h
159   cmFileTimeComparison.cxx
160   cmFileTimeComparison.h
161   cmGeneratedFileStream.cxx
162   cmGeneratorExpression.cxx
163   cmGeneratorExpression.h
164   cmGlobalGenerator.cxx
165   cmGlobalGenerator.h
166   cmGlobalUnixMakefileGenerator3.cxx
167   cmGlobalUnixMakefileGenerator3.h
168   cmGraphAdjacencyList.h
169   cmInstallGenerator.h
170   cmInstallGenerator.cxx
171   cmInstallExportGenerator.cxx
172   cmInstallFilesGenerator.h
173   cmInstallFilesGenerator.cxx
174   cmInstallScriptGenerator.h
175   cmInstallScriptGenerator.cxx
176   cmInstallTargetGenerator.h
177   cmInstallTargetGenerator.cxx
178   cmInstallDirectoryGenerator.h
179   cmInstallDirectoryGenerator.cxx
180   cmListFileCache.cxx
181   cmListFileCache.h
182   cmListFileLexer.c
183   cmLocalGenerator.cxx
184   cmLocalGenerator.h
185   cmLocalUnixMakefileGenerator3.cxx
186   cmMakeDepend.cxx
187   cmMakeDepend.h
188   cmMakefile.cxx
189   cmMakefile.h
190   cmMakefileTargetGenerator.cxx
191   cmMakefileExecutableTargetGenerator.cxx
192   cmMakefileLibraryTargetGenerator.cxx
193   cmMakefileUtilityTargetGenerator.cxx
194   cmOrderDirectories.cxx
195   cmOrderDirectories.h
196   cmPolicies.h
197   cmPolicies.cxx
198   cmProcessTools.cxx
199   cmProcessTools.h
200   cmProperty.cxx
201   cmProperty.h
202   cmPropertyDefinition.cxx
203   cmPropertyDefinition.h
204   cmPropertyDefinitionMap.cxx
205   cmPropertyDefinitionMap.h
206   cmPropertyMap.cxx
207   cmPropertyMap.h
208   cmScriptGenerator.h
209   cmScriptGenerator.cxx
210   cmSourceFile.cxx
211   cmSourceFile.h
212   cmSourceFileLocation.cxx
213   cmSourceFileLocation.h
214   cmSourceGroup.cxx
215   cmSourceGroup.h
216   cmSystemTools.cxx
217   cmSystemTools.h
218   cmTarget.cxx
219   cmTarget.h
220   cmTest.cxx
221   cmTest.h
222   cmTestGenerator.cxx
223   cmTestGenerator.h
224   cmVariableWatch.cxx
225   cmVariableWatch.h
226   cmVersion.cxx
227   cmVersion.h
228   cmXMLParser.cxx
229   cmXMLParser.h
230   cmXMLSafe.cxx
231   cmXMLSafe.h
232   cmake.cxx
233   cmake.h
234   cmakewizard.cxx
235   cmakewizard.h
236   )
238 # Kdevelop only works on UNIX and not windows
239 IF(UNIX)
240   SET(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx)
241 ENDIF(UNIX)
243 IF(NOT CYGWIN)
244   SET(SRCS ${SRCS} cmExtraCodeBlocksGenerator.cxx)
245 ENDIF(NOT CYGWIN)
247 # XCode only works on apple
248 IF(APPLE)
249   SET(SRCS ${SRCS}
250     cmXCodeObject.cxx
251     cmXCode21Object.cxx
252     cmGlobalXCodeGenerator.cxx
253     cmGlobalXCodeGenerator.h
254     cmLocalXCodeGenerator.cxx
255     cmLocalXCodeGenerator.h)
256 ENDIF(APPLE)
259 IF (WIN32)
260   SET(SRCS ${SRCS}
261     cmCallVisualStudioMacro.cxx
262     cmCallVisualStudioMacro.h
263     )
265   IF(NOT UNIX)
266     SET(SRCS ${SRCS}
267       cmGlobalBorlandMakefileGenerator.cxx
268       cmGlobalBorlandMakefileGenerator.h
269       cmGlobalMSYSMakefileGenerator.cxx
270       cmGlobalMinGWMakefileGenerator.cxx
271       cmGlobalNMakeMakefileGenerator.cxx
272       cmGlobalNMakeMakefileGenerator.h
273       cmGlobalVisualStudio6Generator.cxx
274       cmGlobalVisualStudio6Generator.h
275       cmGlobalVisualStudio71Generator.cxx
276       cmGlobalVisualStudio71Generator.h
277       cmGlobalVisualStudio7Generator.cxx
278       cmGlobalVisualStudio7Generator.h
279       cmGlobalVisualStudio8Generator.cxx
280       cmGlobalVisualStudio8Generator.h
281       cmGlobalVisualStudio9Generator.cxx
282       cmGlobalVisualStudio9Generator.h
283       cmGlobalVisualStudio8Win64Generator.cxx
284       cmGlobalVisualStudio8Win64Generator.h
285       cmGlobalVisualStudio9Win64Generator.cxx
286       cmGlobalVisualStudio9Win64Generator.h
287       cmVisualStudioGeneratorOptions.h
288       cmVisualStudioGeneratorOptions.cxx
289       cmVisualStudio10TargetGenerator.h
290       cmVisualStudio10TargetGenerator.cxx
291       cmLocalVisualStudio10Generator.cxx
292       cmLocalVisualStudio10Generator.h
293       cmGlobalVisualStudio10Generator.h
294       cmGlobalVisualStudio10Generator.cxx
295       cmGlobalVisualStudioGenerator.cxx
296       cmGlobalVisualStudioGenerator.h
297       cmGlobalWatcomWMakeGenerator.cxx
298       cmIDEFlagTable.h
299       cmIDEOptions.cxx
300       cmIDEOptions.h
301       cmLocalVisualStudio6Generator.cxx
302       cmLocalVisualStudio6Generator.h
303       cmLocalVisualStudio7Generator.cxx
304       cmLocalVisualStudio7Generator.h
305       cmLocalVisualStudioGenerator.cxx
306       cmLocalVisualStudioGenerator.h
307       cmWin32ProcessExecution.cxx
308       cmWin32ProcessExecution.h
309       )
310   ENDIF(NOT UNIX)
311 ENDIF (WIN32)
313 # create a library used by the command line and the GUI
314 ADD_LIBRARY(CMakeLib ${SRCS})
315 TARGET_LINK_LIBRARIES(CMakeLib cmsys
316   ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
317   ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
318   ${CMAKE_CURL_LIBRARIES})
320 # On Apple we need Carbon
321 IF(APPLE)
322   TARGET_LINK_LIBRARIES(CMakeLib "-framework CoreFoundation")
323 ENDIF(APPLE)
325 # On some platforms we need the rpcrt4 library for the VS 7 generators.
326 IF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
327   TARGET_LINK_LIBRARIES(CMakeLib rpcrt4)
328 ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
331 # CTestLib
333 INCLUDE_DIRECTORIES(
334   "${CMAKE_SOURCE_DIR}/Source/CTest"
335   ${CMAKE_XMLRPC_INCLUDES}
336   ${CMAKE_CURL_INCLUDES}
337   )
339 # Sources for CTestLib
341 SET(CTEST_SRCS cmCTest.cxx
342   CTest/cmProcess.cxx
343   CTest/cmCTestBatchTestHandler.cxx
344   CTest/cmCTestBuildAndTestHandler.cxx
345   CTest/cmCTestBuildCommand.cxx
346   CTest/cmCTestBuildHandler.cxx
347   CTest/cmCTestConfigureCommand.cxx
348   CTest/cmCTestConfigureHandler.cxx
349   CTest/cmCTestCoverageCommand.cxx
350   CTest/cmCTestCoverageHandler.cxx
351   CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
352   CTest/cmCTestGenericHandler.cxx
353   CTest/cmCTestHandlerCommand.cxx
354   CTest/cmCTestLaunch.cxx
355   CTest/cmCTestMemCheckCommand.cxx
356   CTest/cmCTestMemCheckHandler.cxx
357   CTest/cmCTestMultiProcessHandler.cxx
358   CTest/cmCTestReadCustomFilesCommand.cxx
359   CTest/cmCTestRunScriptCommand.cxx
360   CTest/cmCTestRunTest.cxx
361   CTest/cmCTestScriptHandler.cxx
362   CTest/cmCTestSleepCommand.cxx
363   CTest/cmCTestStartCommand.cxx
364   CTest/cmCTestSubmitCommand.cxx
365   CTest/cmCTestSubmitHandler.cxx
366   CTest/cmCTestTestCommand.cxx
367   CTest/cmCTestTestHandler.cxx
368   CTest/cmCTestUpdateCommand.cxx
369   CTest/cmCTestUpdateHandler.cxx
371   CTest/cmCTestVC.cxx
372   CTest/cmCTestVC.h
373   CTest/cmCTestGlobalVC.cxx
374   CTest/cmCTestGlobalVC.h
375   CTest/cmCTestCVS.cxx
376   CTest/cmCTestCVS.h
377   CTest/cmCTestSVN.cxx
378   CTest/cmCTestSVN.h
379   CTest/cmCTestBZR.cxx
380   CTest/cmCTestBZR.h
381   CTest/cmCTestGIT.cxx
382   CTest/cmCTestGIT.h
383   CTest/cmCTestHG.cxx
384   CTest/cmCTestHG.h
385   )
387 # Build CTestLib
388 ADD_LIBRARY(CTestLib ${CTEST_SRCS})
389 TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
392 # Sources for CPack
394 SET(CPACK_SRCS
395   CPack/cmCPackComponentGroup.cxx
396   CPack/cmCPackGeneratorFactory.cxx
397   CPack/cmCPackGenerator.cxx
398   CPack/cmCPackLog.cxx
399   CPack/cmCPackNSISGenerator.cxx
400   CPack/cmCPackSTGZGenerator.cxx
401   CPack/cmCPackTGZGenerator.cxx
402   CPack/cmCPackTarBZip2Generator.cxx
403   CPack/cmCPackTarCompressGenerator.cxx
404   CPack/cmCPackZIPGenerator.cxx
405   )
407 IF(WIN32 AND UNIX)
408   SET(CPACK_SRCS ${CPACK_SRCS}
409     CPack/cmCPackCygwinBinaryGenerator.cxx
410     CPack/cmCPackCygwinSourceGenerator.cxx
411     )
412 ENDIF(WIN32 AND UNIX)
413   
414 IF(UNIX)
415   SET(CPACK_SRCS ${CPACK_SRCS}
416     CPack/cmCPackDebGenerator.cxx
417     CPack/cmCPackRPMGenerator.cxx
418     )
419 ENDIF(UNIX)
421 IF(APPLE)
422   SET(CPACK_SRCS ${CPACK_SRCS}
423     CPack/cmCPackBundleGenerator.cxx
424     CPack/cmCPackDragNDropGenerator.cxx
425     CPack/cmCPackOSXX11Generator.cxx
426     CPack/cmCPackPackageMakerGenerator.cxx
427     )
428 ENDIF(APPLE)
430 # Build CPackLib
431 ADD_LIBRARY(CPackLib ${CPACK_SRCS})
432 TARGET_LINK_LIBRARIES(CPackLib CMakeLib)
434 IF(APPLE)
435   ADD_EXECUTABLE(cmakexbuild cmakexbuild.cxx)
436   TARGET_LINK_LIBRARIES(cmakexbuild CMakeLib)
437   ADD_EXECUTABLE(OSXScriptLauncher
438     CPack/OSXScriptLauncher.cxx)
439   TARGET_LINK_LIBRARIES(OSXScriptLauncher cmsys)
440   TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework Carbon")
441 ENDIF(APPLE)
443 # Build CMake executable
444 ADD_EXECUTABLE(cmake cmakemain.cxx)
445 TARGET_LINK_LIBRARIES(cmake CMakeLib)
446 ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
447 TARGET_LINK_LIBRARIES(DumpDocumentation CMakeLib)
449 # Build special executable for running programs on Windows 98
450 IF(WIN32)
451   IF(NOT UNIX)
452     ADD_EXECUTABLE(cmw9xcom cmw9xcom.cxx)
453     TARGET_LINK_LIBRARIES(cmw9xcom CMakeLib)
454     INSTALL_TARGETS(/bin cmw9xcom)
455   ENDIF(NOT UNIX)
456 ENDIF(WIN32)
458 # Build CTest executable
459 ADD_EXECUTABLE(ctest ctest.cxx)
460 TARGET_LINK_LIBRARIES(ctest CTestLib)
462 # Build CPack executable
463 ADD_EXECUTABLE(cpack CPack/cpack.cxx)
464 TARGET_LINK_LIBRARIES(cpack CPackLib)
466 # Curses GUI
467 IF(BUILD_CursesDialog)
468   INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt)
469 ENDIF(BUILD_CursesDialog)
471 # Qt GUI
472 OPTION(BUILD_QtDialog "Build Qt dialog for CMake" FALSE)
473 IF(BUILD_QtDialog)
474   SUBDIRS(QtDialog)
475 ENDIF(BUILD_QtDialog)
477 INCLUDE (${CMAKE_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
478 INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
480 INSTALL_TARGETS(/bin cmake)
481 INSTALL_TARGETS(/bin ctest)
482 INSTALL_TARGETS(/bin cpack)
483 IF(APPLE)
484   INSTALL_TARGETS(/bin cmakexbuild)
485 ENDIF(APPLE)
487 INSTALL_FILES(${CMAKE_DATA_DIR}/include cmCPluginAPI.h)