Resync
[CMakeLuaTailorHgBridge.git] / CMakeLua / Source / CMakeLists.txt
blob1193363832348475e93b7b841476a6ea927c8740
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   cmDepends.cxx
120   cmDepends.h
121   cmDependsC.cxx
122   cmDependsC.h
123   cmDependsFortran.cxx
124   cmDependsFortran.h
125   cmDependsFortranLexer.cxx
126   cmDependsFortranParser.cxx
127   cmDependsFortranParser.h
128   cmDependsJava.cxx
129   cmDependsJava.h
130   cmDependsJavaLexer.cxx
131   cmDependsJavaParser.cxx
132   cmDependsJavaParserHelper.cxx
133   cmDependsJavaParserHelper.h
134   cmDocumentation.cxx
135   cmDocumentationFormatter.cxx
136   cmDocumentationFormatterHTML.cxx
137   cmDocumentationFormatterDocbook.cxx
138   cmDocumentationFormatterMan.cxx
139   cmDocumentationFormatterText.cxx
140   cmDocumentationFormatterUsage.cxx
141   cmDocumentationSection.cxx
142   cmDocumentVariables.cxx
143   cmDynamicLoader.cxx
144   cmDynamicLoader.h
145   ${ELF_SRCS}
146   cmExprLexer.cxx
147   cmExprParser.cxx
148   cmExprParserHelper.cxx
149   cmExportBuildFileGenerator.h
150   cmExportBuildFileGenerator.cxx
151   cmExportFileGenerator.h
152   cmExportFileGenerator.cxx
153   cmExportInstallFileGenerator.h
154   cmExportInstallFileGenerator.cxx
155   cmExtraEclipseCDT4Generator.cxx
156   cmExtraEclipseCDT4Generator.h
157   cmFileTimeComparison.cxx
158   cmFileTimeComparison.h
159   cmGeneratedFileStream.cxx
160   cmGlobalGenerator.cxx
161   cmGlobalGenerator.h
162   cmGlobalUnixMakefileGenerator3.cxx
163   cmGlobalUnixMakefileGenerator3.h
164   cmGraphAdjacencyList.h
165   cmInstallGenerator.h
166   cmInstallGenerator.cxx
167   cmInstallExportGenerator.cxx
168   cmInstallFilesGenerator.h
169   cmInstallFilesGenerator.cxx
170   cmInstallScriptGenerator.h
171   cmInstallScriptGenerator.cxx
172   cmInstallTargetGenerator.h
173   cmInstallTargetGenerator.cxx
174   cmInstallDirectoryGenerator.h
175   cmInstallDirectoryGenerator.cxx
176   cmListFileCache.cxx
177   cmListFileCache.h
178   cmListFileLexer.c
179   cmLocalGenerator.cxx
180   cmLocalGenerator.h
181   cmLocalUnixMakefileGenerator3.cxx
182   cmMakeDepend.cxx
183   cmMakeDepend.h
184   cmMakefile.cxx
185   cmMakefile.h
186   cmMakefileTargetGenerator.cxx
187   cmMakefileExecutableTargetGenerator.cxx
188   cmMakefileLibraryTargetGenerator.cxx
189   cmMakefileUtilityTargetGenerator.cxx
190   cmOrderDirectories.cxx
191   cmOrderDirectories.h
192   cmPolicies.h
193   cmPolicies.cxx
194   cmProcessTools.cxx
195   cmProcessTools.h
196   cmProperty.cxx
197   cmProperty.h
198   cmPropertyDefinition.cxx
199   cmPropertyDefinition.h
200   cmPropertyDefinitionMap.cxx
201   cmPropertyDefinitionMap.h
202   cmPropertyMap.cxx
203   cmPropertyMap.h
204   cmScriptGenerator.h
205   cmScriptGenerator.cxx
206   cmSourceFile.cxx
207   cmSourceFile.h
208   cmSourceFileLocation.cxx
209   cmSourceFileLocation.h
210   cmSourceGroup.cxx
211   cmSourceGroup.h
212   cmSystemTools.cxx
213   cmSystemTools.h
214   cmTarget.cxx
215   cmTarget.h
216   cmTest.cxx
217   cmTest.h
218   cmTestGenerator.cxx
219   cmTestGenerator.h
220   cmVariableWatch.cxx
221   cmVariableWatch.h
222   cmVersion.cxx
223   cmVersion.h
224   cmXMLParser.cxx
225   cmXMLParser.h
226   cmXMLSafe.cxx
227   cmXMLSafe.h
228   cmake.cxx
229   cmake.h
230   cmakewizard.cxx
231   cmakewizard.h
232   )
234 # Kdevelop only works on UNIX and not windows
235 IF(UNIX)
236   SET(SRCS ${SRCS} cmGlobalKdevelopGenerator.cxx)
237 ENDIF(UNIX)
239 IF(NOT CYGWIN)
240   SET(SRCS ${SRCS} cmExtraCodeBlocksGenerator.cxx)
241 ENDIF(NOT CYGWIN)
243 # XCode only works on apple
244 IF(APPLE)
245   SET(SRCS ${SRCS}
246     cmXCodeObject.cxx
247     cmXCode21Object.cxx
248     cmGlobalXCodeGenerator.cxx
249     cmGlobalXCodeGenerator.h
250     cmGlobalXCode21Generator.cxx
251     cmGlobalXCode21Generator.h
252     cmLocalXCodeGenerator.cxx
253     cmLocalXCodeGenerator.h)
254 ENDIF(APPLE)
257 IF (WIN32)
258   SET(SRCS ${SRCS}
259     cmCallVisualStudioMacro.cxx
260     cmCallVisualStudioMacro.h
261     )
263   IF(NOT UNIX)
264     SET(SRCS ${SRCS}
265       cmGlobalBorlandMakefileGenerator.cxx
266       cmGlobalBorlandMakefileGenerator.h
267       cmGlobalMSYSMakefileGenerator.cxx
268       cmGlobalMinGWMakefileGenerator.cxx
269       cmGlobalNMakeMakefileGenerator.cxx
270       cmGlobalNMakeMakefileGenerator.h
271       cmGlobalVisualStudio6Generator.cxx
272       cmGlobalVisualStudio6Generator.h
273       cmGlobalVisualStudio71Generator.cxx
274       cmGlobalVisualStudio71Generator.h
275       cmGlobalVisualStudio7Generator.cxx
276       cmGlobalVisualStudio7Generator.h
277       cmGlobalVisualStudio8Generator.cxx
278       cmGlobalVisualStudio8Generator.h
279       cmGlobalVisualStudio9Generator.cxx
280       cmGlobalVisualStudio9Generator.h
281       cmGlobalVisualStudio8Win64Generator.cxx
282       cmGlobalVisualStudio8Win64Generator.h
283       cmGlobalVisualStudio9Win64Generator.cxx
284       cmGlobalVisualStudio9Win64Generator.h
285       cmGlobalVisualStudioGenerator.cxx
286       cmGlobalVisualStudioGenerator.h
287       cmGlobalWatcomWMakeGenerator.cxx
288       cmLocalVisualStudio6Generator.cxx
289       cmLocalVisualStudio6Generator.h
290       cmLocalVisualStudio7Generator.cxx
291       cmLocalVisualStudio7Generator.h
292       cmLocalVisualStudioGenerator.cxx
293       cmLocalVisualStudioGenerator.h
294       cmWin32ProcessExecution.cxx
295       cmWin32ProcessExecution.h
296       )
297   ENDIF(NOT UNIX)
298 ENDIF (WIN32)
300 # create a library used by the command line and the GUI
301 ADD_LIBRARY(CMakeLib ${SRCS})
302 TARGET_LINK_LIBRARIES(CMakeLib cmsys
303   ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
304   ${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
305   ${CMAKE_CURL_LIBRARIES})
307 # On Apple we need Carbon
308 IF(APPLE)
309   TARGET_LINK_LIBRARIES(CMakeLib "-framework CoreFoundation")
310 ENDIF(APPLE)
312 # On some platforms we need the rpcrt4 library for the VS 7 generators.
313 IF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
314   TARGET_LINK_LIBRARIES(CMakeLib rpcrt4)
315 ENDIF(CMAKE_BUILD_ON_VISUAL_STUDIO OR MINGW)
318 # CTestLib
320 INCLUDE_DIRECTORIES(
321   "${CMAKE_SOURCE_DIR}/Source/CTest"
322   ${CMAKE_XMLRPC_INCLUDES}
323   ${CMAKE_CURL_INCLUDES}
324   )
326 # Sources for CTestLib
328 SET(CTEST_SRCS cmCTest.cxx
329   CTest/cmProcess.cxx
330   CTest/cmCTestBuildAndTestHandler.cxx
331   CTest/cmCTestBuildCommand.cxx
332   CTest/cmCTestBuildHandler.cxx
333   CTest/cmCTestConfigureCommand.cxx
334   CTest/cmCTestConfigureHandler.cxx
335   CTest/cmCTestCoverageCommand.cxx
336   CTest/cmCTestCoverageHandler.cxx
337   CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
338   CTest/cmCTestGenericHandler.cxx
339   CTest/cmCTestHandlerCommand.cxx
340   CTest/cmCTestLaunch.cxx
341   CTest/cmCTestMemCheckCommand.cxx
342   CTest/cmCTestMemCheckHandler.cxx
343   CTest/cmCTestMultiProcessHandler.cxx
344   CTest/cmCTestReadCustomFilesCommand.cxx
345   CTest/cmCTestRunScriptCommand.cxx
346   CTest/cmCTestScriptHandler.cxx
347   CTest/cmCTestSleepCommand.cxx
348   CTest/cmCTestStartCommand.cxx
349   CTest/cmCTestSubmitCommand.cxx
350   CTest/cmCTestSubmitHandler.cxx
351   CTest/cmCTestTestCommand.cxx
352   CTest/cmCTestTestHandler.cxx
353   CTest/cmCTestUpdateCommand.cxx
354   CTest/cmCTestUpdateHandler.cxx
356   CTest/cmCTestVC.cxx
357   CTest/cmCTestVC.h
358   CTest/cmCTestCVS.cxx
359   CTest/cmCTestCVS.h
360   CTest/cmCTestSVN.cxx
361   CTest/cmCTestSVN.h
362   )
364 # Build CTestLib
365 ADD_LIBRARY(CTestLib ${CTEST_SRCS})
366 TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
369 # Sources for CPack
371 SET(CPACK_SRCS
372   CPack/cmCPackComponentGroup.cxx
373   CPack/cmCPackGeneratorFactory.cxx
374   CPack/cmCPackGenerator.cxx
375   CPack/cmCPackLog.cxx
376   CPack/cmCPackNSISGenerator.cxx
377   CPack/cmCPackSTGZGenerator.cxx
378   CPack/cmCPackTGZGenerator.cxx
379   CPack/cmCPackTarBZip2Generator.cxx
380   CPack/cmCPackTarCompressGenerator.cxx
381   CPack/cmCPackZIPGenerator.cxx
382   )
384 IF(WIN32 AND UNIX)
385   SET(CPACK_SRCS ${CPACK_SRCS}
386     CPack/cmCPackCygwinBinaryGenerator.cxx
387     CPack/cmCPackCygwinSourceGenerator.cxx
388     )
389 ENDIF(WIN32 AND UNIX)
390   
391 IF(UNIX)
392   SET(CPACK_SRCS ${CPACK_SRCS}
393     CPack/cmCPackDebGenerator.cxx
394     CPack/cmCPackRPMGenerator.cxx
395     )
396 ENDIF(UNIX)
398 IF(APPLE)
399   SET(CPACK_SRCS ${CPACK_SRCS}
400     CPack/cmCPackBundleGenerator.cxx
401     CPack/cmCPackDragNDropGenerator.cxx
402     CPack/cmCPackOSXX11Generator.cxx
403     CPack/cmCPackPackageMakerGenerator.cxx
404     )
405 ENDIF(APPLE)
407 # Build CPackLib
408 ADD_LIBRARY(CPackLib ${CPACK_SRCS})
409 TARGET_LINK_LIBRARIES(CPackLib CMakeLib)
411 IF(APPLE)
412   ADD_EXECUTABLE(cmakexbuild cmakexbuild.cxx)
413   TARGET_LINK_LIBRARIES(cmakexbuild CMakeLib)
414   ADD_EXECUTABLE(OSXScriptLauncher
415     CPack/OSXScriptLauncher.cxx)
416   TARGET_LINK_LIBRARIES(OSXScriptLauncher cmsys)
417   TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework Carbon")
418 ENDIF(APPLE)
420 # Build CMake executable
421 ADD_EXECUTABLE(cmake cmakemain.cxx)
422 TARGET_LINK_LIBRARIES(cmake CMakeLib)
423 ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
424 TARGET_LINK_LIBRARIES(DumpDocumentation CMakeLib)
426 # Build special executable for running programs on Windows 98
427 IF(WIN32)
428   IF(NOT UNIX)
429     ADD_EXECUTABLE(cmw9xcom cmw9xcom.cxx)
430     TARGET_LINK_LIBRARIES(cmw9xcom CMakeLib)
431     INSTALL_TARGETS(/bin cmw9xcom)
432   ENDIF(NOT UNIX)
433 ENDIF(WIN32)
435 # Build CTest executable
436 ADD_EXECUTABLE(ctest ctest.cxx)
437 TARGET_LINK_LIBRARIES(ctest CTestLib)
439 # Build CPack executable
440 ADD_EXECUTABLE(cpack CPack/cpack.cxx)
441 TARGET_LINK_LIBRARIES(cpack CPackLib)
443 # Curses GUI
444 IF(BUILD_CursesDialog)
445   INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt)
446 ENDIF(BUILD_CursesDialog)
448 # MFC GUI
449 # MFC libraries are only available on Visual Studio
450 IF(BUILD_MFCDialog)
451   SUBDIRS(MFCDialog)
452 ENDIF(BUILD_MFCDialog)
454 # Qt GUI
455 OPTION(BUILD_QtDialog "Build Qt dialog for CMake" FALSE)
456 IF(BUILD_QtDialog)
457   SUBDIRS(QtDialog)
458 ENDIF(BUILD_QtDialog)
460 # WX Widgets GUI
461 OPTION(BUILD_WXDialog "Build wxWidgets dialog for CMake" FALSE)
462 MARK_AS_ADVANCED(BUILD_WXDialog)
463 IF(BUILD_WXDialog)
464   SUBDIRS(WXDialog)
465 ENDIF(BUILD_WXDialog)
467 # FLTK GUI, needs some work: generator selection, paths with spaces, ...
468 # OPTION(BUILD_FLTKDialog "Build FLTK dialog for CMake" FALSE)
469 # MARK_AS_ADVANCED(BUILD_FLTKDialog)
470 # IF(BUILD_FLTKDialog)
471 #  SUBDIRS(FLTKDialog)
472 # ENDIF(BUILD_FLTKDialog)
474 INCLUDE (${CMAKE_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
475 INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
477 INSTALL_TARGETS(/bin cmake)
478 INSTALL_TARGETS(/bin ctest)
479 INSTALL_TARGETS(/bin cpack)
480 IF(APPLE)
481   INSTALL_TARGETS(/bin cmakexbuild)
482 ENDIF(APPLE)
484 INSTALL_FILES(${CMAKE_DATA_DIR}/include cmCPluginAPI.h)