STYLE: Fix typo in GetFilenameLastExtension docs
[cmake.git] / Source / CMakeLists.txt
blob516e20809ecf1cc107deaa659ddafd6733fc7497
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/CPack/cmCPackConfigure.h.in"
17   "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h"
18   )
20 # add the include path to find the .h
21 INCLUDE_DIRECTORIES(
22   "${CMake_BINARY_DIR}/Source"
23   "${CMake_SOURCE_DIR}/Source"
24   ${CMAKE_ZLIB_INCLUDES}
25   ${CMAKE_EXPAT_INCLUDES}
26   ${CMAKE_TAR_INCLUDES}
27   ${CMAKE_COMPRESS_INCLUDES}
28   )
30 # let cmake know it is supposed to use it
31 ADD_DEFINITIONS(-DCMAKE_BUILD_WITH_CMAKE)
33 OPTION(CMAKE_REGENERATE_YACCLEX
34   "Regenerate YACC and LEXX files" OFF)
35 MARK_AS_ADVANCED(CMAKE_REGENERATE_YACCLEX)
36 IF(CMAKE_REGENERATE_YACCLEX)
37   SET(parsersLexers cmDependsFortran cmCommandArgument cmExpr)
38   FIND_PROGRAM(YACC_EXECUTABLE
39     NAMES yacc bison
40     PATHS /usr/bin
41     DOC "Yacc or Bison executable")
42   FIND_PROGRAM(FLEX_EXECUTABLE
43     NAMES flex
44     PATHS /usr/bin
45     DOC "Flex executable")
46   MARK_AS_ADVANCED(YACC_EXECUTABLE FLEX_EXECUTABLE)
47   IF(YACC_EXECUTABLE)
48     SET(BISON_FLAGS)
49     IF(YACC_EXECUTABLE MATCHES "bison")
50       SET(BISON_FLAGS "--yacc")
51     ENDIF(YACC_EXECUTABLE MATCHES "bison")
52     SET(yacc_files)
53     FOREACH(name ${parsersLexers})
54       SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}Parser.y")
55       SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}Parser.cxx")
56       SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}ParserTokens.h")
57       ADD_CUSTOM_COMMAND(
58         OUTPUT "${dst}"
59         DEPENDS "${src}"
60         COMMAND
61         ${YACC_EXECUTABLE}
62         --name-prefix=${name}_yy --defines=${hdr} -o${dst} ${src}
63         )
64       SET(yacc_files ${yacc_files} "${dst}")
65     ENDFOREACH(name)
66     ADD_CUSTOM_TARGET(RerunYacc DEPENDS ${yacc_files})
67   ENDIF(YACC_EXECUTABLE)
68   IF(FLEX_EXECUTABLE)
69     SET(lex_files)
70     FOREACH(name ${parsersLexers})
71       SET(src "${CMAKE_CURRENT_SOURCE_DIR}/${name}Lexer.in.l")
72       SET(dst "${CMAKE_CURRENT_BINARY_DIR}/${name}Lexer.cxx")
73       SET(hdr "${CMAKE_CURRENT_BINARY_DIR}/${name}Lexer.h")
74       ADD_CUSTOM_COMMAND(
75         OUTPUT "${dst}"
76         DEPENDS "${src}"
77         COMMAND
78         ${FLEX_EXECUTABLE}
79         --prefix=${name}_yy --header-file=${hdr} -o${dst} ${src}
80         )
81       SET(lex_files ${lex_files} "${dst}")
82     ENDFOREACH(name)
83     ADD_CUSTOM_TARGET(RerunLex DEPENDS ${lex_files})
84   ENDIF(FLEX_EXECUTABLE)
86 ENDIF(CMAKE_REGENERATE_YACCLEX)
88 # Check if we can build the ELF parser.
89 IF(CMAKE_USE_ELF_PARSER)
90   SET(ELF_SRCS cmELF.h cmELF.cxx)
91 ENDIF(CMAKE_USE_ELF_PARSER)
94 # Sources for CMakeLib
96 SET(SRCS
97   cmBootstrapCommands.cxx
98   cmCacheManager.cxx
99   cmCacheManager.h
100   cmCommands.cxx
101   cmCommands.h
102   cmCommandArgumentLexer.cxx
103   cmCommandArgumentParser.cxx
104   cmCommandArgumentParserHelper.cxx
105   cmComputeComponentGraph.cxx
106   cmComputeComponentGraph.h
107   cmComputeLinkDepends.cxx
108   cmComputeLinkDepends.h
109   cmComputeLinkInformation.cxx
110   cmComputeLinkInformation.h
111   cmComputeTargetDepends.h
112   cmComputeTargetDepends.cxx
113   cmCustomCommand.cxx
114   cmCustomCommand.h
115   cmDepends.cxx
116   cmDepends.h
117   cmDependsC.cxx
118   cmDependsC.h
119   cmDependsFortran.cxx
120   cmDependsFortran.h
121   cmDependsFortranLexer.cxx
122   cmDependsFortranParser.cxx
123   cmDependsFortranParser.h
124   cmDependsJava.cxx
125   cmDependsJava.h
126   cmDependsJavaLexer.cxx
127   cmDependsJavaParser.cxx
128   cmDependsJavaParserHelper.cxx
129   cmDependsJavaParserHelper.h
130   cmDocumentation.cxx
131   cmDocumentationFormatter.cxx
132   cmDocumentationFormatterHTML.cxx
133   cmDocumentationFormatterDocbook.cxx
134   cmDocumentationFormatterMan.cxx
135   cmDocumentationFormatterText.cxx
136   cmDocumentationFormatterUsage.cxx
137   cmDocumentationSection.cxx
138   cmDocumentVariables.cxx
139   cmDynamicLoader.cxx
140   cmDynamicLoader.h
141   ${ELF_SRCS}
142   cmExprLexer.cxx
143   cmExprParser.cxx
144   cmExprParserHelper.cxx
145   cmExportBuildFileGenerator.h
146   cmExportBuildFileGenerator.cxx
147   cmExportFileGenerator.h
148   cmExportFileGenerator.cxx
149   cmExportInstallFileGenerator.h
150   cmExportInstallFileGenerator.cxx
151   cmExtraEclipseCDT4Generator.cxx
152   cmExtraEclipseCDT4Generator.h
153   cmFileTimeComparison.cxx
154   cmFileTimeComparison.h
155   cmGeneratedFileStream.cxx
156   cmGlobalGenerator.cxx
157   cmGlobalGenerator.h
158   cmGlobalUnixMakefileGenerator3.cxx
159   cmGlobalUnixMakefileGenerator3.h
160   cmGraphAdjacencyList.h
161   cmInstallGenerator.h
162   cmInstallGenerator.cxx
163   cmInstallExportGenerator.cxx
164   cmInstallFilesGenerator.h
165   cmInstallFilesGenerator.cxx
166   cmInstallScriptGenerator.h
167   cmInstallScriptGenerator.cxx
168   cmInstallTargetGenerator.h
169   cmInstallTargetGenerator.cxx
170   cmInstallDirectoryGenerator.h
171   cmInstallDirectoryGenerator.cxx
172   cmListFileCache.cxx
173   cmListFileCache.h
174   cmListFileLexer.c
175   cmLocalGenerator.cxx
176   cmLocalGenerator.h
177   cmLocalUnixMakefileGenerator3.cxx
178   cmMakeDepend.cxx
179   cmMakeDepend.h
180   cmMakefile.cxx
181   cmMakefile.h
182   cmMakefileTargetGenerator.cxx
183   cmMakefileExecutableTargetGenerator.cxx
184   cmMakefileLibraryTargetGenerator.cxx
185   cmMakefileUtilityTargetGenerator.cxx
186   cmOrderDirectories.cxx
187   cmOrderDirectories.h
188   cmPolicies.h
189   cmPolicies.cxx
190   cmProperty.cxx
191   cmProperty.h
192   cmPropertyDefinition.cxx
193   cmPropertyDefinition.h
194   cmPropertyDefinitionMap.cxx
195   cmPropertyDefinitionMap.h
196   cmPropertyMap.cxx
197   cmPropertyMap.h
198   cmSourceFile.cxx
199   cmSourceFile.h
200   cmSourceFileLocation.cxx
201   cmSourceFileLocation.h
202   cmSourceGroup.cxx
203   cmSourceGroup.h
204   cmSystemTools.cxx
205   cmSystemTools.h
206   cmTarget.cxx
207   cmTarget.h
208   cmTest.cxx
209   cmTest.h
210   cmVariableWatch.cxx
211   cmVariableWatch.h
212   cmVersion.cxx
213   cmVersion.h
214   cmXMLParser.cxx
215   cmXMLParser.h
216   cmake.cxx
217   cmake.h
218   cmakewizard.cxx
219   cmakewizard.h
220   )
222 # Kdevelop only works on UNIX and not windows
223 IF(UNIX)
224   SET(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx)
225 ENDIF(UNIX)
227 IF(NOT CYGWIN)
228   SET(SRCS ${SRCS} cmExtraCodeBlocksGenerator.cxx)
229 ENDIF(NOT CYGWIN)
231 # XCode only works on apple
232 IF(APPLE)
233   SET(SRCS ${SRCS}
234     cmXCodeObject.cxx
235     cmXCode21Object.cxx
236     cmGlobalXCodeGenerator.cxx
237     cmGlobalXCodeGenerator.h
238     cmGlobalXCode21Generator.cxx
239     cmGlobalXCode21Generator.h
240     cmLocalXCodeGenerator.cxx
241     cmLocalXCodeGenerator.h)
242 ENDIF(APPLE)
245 IF (WIN32)
246   SET(SRCS ${SRCS}
247     cmCallVisualStudioMacro.cxx
248     cmCallVisualStudioMacro.h
249     )
251   IF(NOT UNIX)
252     SET(SRCS ${SRCS}
253       cmGlobalBorlandMakefileGenerator.cxx
254       cmGlobalBorlandMakefileGenerator.h
255       cmGlobalMSYSMakefileGenerator.cxx
256       cmGlobalMinGWMakefileGenerator.cxx
257       cmGlobalNMakeMakefileGenerator.cxx
258       cmGlobalNMakeMakefileGenerator.h
259       cmGlobalVisualStudio6Generator.cxx
260       cmGlobalVisualStudio6Generator.h
261       cmGlobalVisualStudio71Generator.cxx
262       cmGlobalVisualStudio71Generator.h
263       cmGlobalVisualStudio7Generator.cxx
264       cmGlobalVisualStudio7Generator.h
265       cmGlobalVisualStudio8Generator.cxx
266       cmGlobalVisualStudio8Generator.h
267       cmGlobalVisualStudio9Generator.cxx
268       cmGlobalVisualStudio9Generator.h
269       cmGlobalVisualStudio8Win64Generator.cxx
270       cmGlobalVisualStudio8Win64Generator.h
271       cmGlobalVisualStudio9Win64Generator.cxx
272       cmGlobalVisualStudio9Win64Generator.h
273       cmGlobalVisualStudioGenerator.cxx
274       cmGlobalVisualStudioGenerator.h
275       cmGlobalWatcomWMakeGenerator.cxx
276       cmLocalVisualStudio6Generator.cxx
277       cmLocalVisualStudio6Generator.h
278       cmLocalVisualStudio7Generator.cxx
279       cmLocalVisualStudio7Generator.h
280       cmLocalVisualStudioGenerator.cxx
281       cmLocalVisualStudioGenerator.h
282       cmWin32ProcessExecution.cxx
283       cmWin32ProcessExecution.h
284       )
285   ENDIF(NOT UNIX)
286 ENDIF (WIN32)
288 # create a library used by the command line and the GUI
289 ADD_LIBRARY(CMakeLib ${SRCS})
290 TARGET_LINK_LIBRARIES(CMakeLib cmsys
291   ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
292   ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
293   ${CMAKE_CURL_LIBRARIES})
295 # On Apple we need Carbon
296 IF(APPLE)
297   TARGET_LINK_LIBRARIES(CMakeLib "-framework CoreFoundation")
298 ENDIF(APPLE)
300 # On some platforms we need the rpcrt4 library for the VS 7 generators.
301 IF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
302   TARGET_LINK_LIBRARIES(CMakeLib rpcrt4)
303 ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
306 # CTestLib
308 INCLUDE_DIRECTORIES(
309   "${CMAKE_SOURCE_DIR}/Source/CTest"
310   ${CMAKE_XMLRPC_INCLUDES}
311   ${CMAKE_CURL_INCLUDES}
312   )
314 # Sources for CTestLib
316 SET(CTEST_SRCS cmCTest.cxx
317   CTest/cmProcess.cxx
318   CTest/cmCTestBuildAndTestHandler.cxx
319   CTest/cmCTestBuildCommand.cxx
320   CTest/cmCTestBuildHandler.cxx
321   CTest/cmCTestConfigureCommand.cxx
322   CTest/cmCTestConfigureHandler.cxx
323   CTest/cmCTestCoverageCommand.cxx
324   CTest/cmCTestCoverageHandler.cxx
325   CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
326   CTest/cmCTestGenericHandler.cxx
327   CTest/cmCTestHandlerCommand.cxx
328   CTest/cmCTestMemCheckCommand.cxx
329   CTest/cmCTestMemCheckHandler.cxx
330   CTest/cmCTestMultiProcessHandler.cxx
331   CTest/cmCTestReadCustomFilesCommand.cxx
332   CTest/cmCTestRunScriptCommand.cxx
333   CTest/cmCTestScriptHandler.cxx
334   CTest/cmCTestSleepCommand.cxx
335   CTest/cmCTestStartCommand.cxx
336   CTest/cmCTestSubmitCommand.cxx
337   CTest/cmCTestSubmitHandler.cxx
338   CTest/cmCTestTestCommand.cxx
339   CTest/cmCTestTestHandler.cxx
340   CTest/cmCTestUpdateCommand.cxx
341   CTest/cmCTestUpdateHandler.cxx
342   )
344 # Build CTestLib
345 ADD_LIBRARY(CTestLib ${CTEST_SRCS})
346 TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
349 # Sources for CPack
351 SET(CPACK_SRCS
352   CPack/cmCPackComponentGroup.cxx
353   CPack/cmCPackGeneratorFactory.cxx
354   CPack/cmCPackGenerator.cxx
355   CPack/cmCPackLog.cxx
356   CPack/cmCPackNSISGenerator.cxx
357   CPack/cmCPackSTGZGenerator.cxx
358   CPack/cmCPackTGZGenerator.cxx
359   CPack/cmCPackTarBZip2Generator.cxx
360   CPack/cmCPackTarCompressGenerator.cxx
361   CPack/cmCPackZIPGenerator.cxx
362   )
364 IF(WIN32 AND UNIX)
365   SET(CPACK_SRCS ${CPACK_SRCS}
366     CPack/cmCPackCygwinBinaryGenerator.cxx
367     CPack/cmCPackCygwinSourceGenerator.cxx
368     )
369 ENDIF(WIN32 AND UNIX)
370   
371 IF(UNIX)
372   SET(CPACK_SRCS ${CPACK_SRCS}
373     CPack/cmCPackDebGenerator.cxx
374     CPack/cmCPackRPMGenerator.cxx
375     )
376 ENDIF(UNIX)
378 IF(APPLE)
379   SET(CPACK_SRCS ${CPACK_SRCS}
380     CPack/cmCPackBundleGenerator.cxx
381     CPack/cmCPackOSXX11Generator.cxx
382     CPack/cmCPackPackageMakerGenerator.cxx
383     )
384 ENDIF(APPLE)
386 # Build CPackLib
387 ADD_LIBRARY(CPackLib ${CPACK_SRCS})
388 TARGET_LINK_LIBRARIES(CPackLib CMakeLib)
390 IF(APPLE)
391   ADD_EXECUTABLE(cmakexbuild cmakexbuild.cxx)
392   TARGET_LINK_LIBRARIES(cmakexbuild CMakeLib)
393   ADD_EXECUTABLE(OSXScriptLauncher
394     CPack/OSXScriptLauncher.cxx)
395   TARGET_LINK_LIBRARIES(OSXScriptLauncher cmsys)
396   TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework Carbon")
397 ENDIF(APPLE)
399 # Build CMake executable
400 ADD_EXECUTABLE(cmake cmakemain.cxx)
401 TARGET_LINK_LIBRARIES(cmake CMakeLib)
402 ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
403 TARGET_LINK_LIBRARIES(DumpDocumentation CMakeLib)
405 # Build special executable for running programs on Windows 98
406 IF(WIN32)
407   IF(NOT UNIX)
408     ADD_EXECUTABLE(cmw9xcom cmw9xcom.cxx)
409     TARGET_LINK_LIBRARIES(cmw9xcom CMakeLib)
410     INSTALL_TARGETS(/bin cmw9xcom)
411   ENDIF(NOT UNIX)
412 ENDIF(WIN32)
414 # Build CTest executable
415 ADD_EXECUTABLE(ctest ctest.cxx)
416 TARGET_LINK_LIBRARIES(ctest CTestLib)
418 # Build CPack executable
419 ADD_EXECUTABLE(cpack CPack/cpack.cxx)
420 TARGET_LINK_LIBRARIES(cpack CPackLib)
422 # Curses GUI
423 IF(BUILD_CursesDialog)
424   INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt)
425 ENDIF(BUILD_CursesDialog)
427 # MFC GUI
428 # MFC libraries are only available on Visual Studio
429 IF(BUILD_MFCDialog)
430   SUBDIRS(MFCDialog)
431 ENDIF(BUILD_MFCDialog)
433 # Qt GUI
434 OPTION(BUILD_QtDialog "Build Qt dialog for CMake" FALSE)
435 IF(BUILD_QtDialog)
436   SUBDIRS(QtDialog)
437 ENDIF(BUILD_QtDialog)
439 # WX Widgets GUI
440 OPTION(BUILD_WXDialog "Build wxWidgets dialog for CMake" FALSE)
441 MARK_AS_ADVANCED(BUILD_WXDialog)
442 IF(BUILD_WXDialog)
443   SUBDIRS(WXDialog)
444 ENDIF(BUILD_WXDialog)
446 # FLTK GUI, needs some work: generator selection, paths with spaces, ...
447 # OPTION(BUILD_FLTKDialog "Build FLTK dialog for CMake" FALSE)
448 # MARK_AS_ADVANCED(BUILD_FLTKDialog)
449 # IF(BUILD_FLTKDialog)
450 #  SUBDIRS(FLTKDialog)
451 # ENDIF(BUILD_FLTKDialog)
453 INCLUDE (${CMAKE_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
454 INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
456 INSTALL_TARGETS(/bin cmake)
457 INSTALL_TARGETS(/bin ctest)
458 INSTALL_TARGETS(/bin cpack)
459 IF(APPLE)
460   INSTALL_TARGETS(/bin cmakexbuild)
461 ENDIF(APPLE)
463 INSTALL_FILES(${CMAKE_DATA_DIR}/include cmCPluginAPI.h)