ENH: put the 64 bit paths first
[cmake.git] / Source / CMakeLists.txt
blobab5b64cad76c58b53e4e76a6e2a92d93c033343c
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/cmCTestGlobalVC.cxx
359   CTest/cmCTestGlobalVC.h
360   CTest/cmCTestCVS.cxx
361   CTest/cmCTestCVS.h
362   CTest/cmCTestSVN.cxx
363   CTest/cmCTestSVN.h
364   CTest/cmCTestBZR.cxx
365   CTest/cmCTestBZR.h
366   CTest/cmCTestGIT.cxx
367   CTest/cmCTestGIT.h
368   )
370 # Build CTestLib
371 ADD_LIBRARY(CTestLib ${CTEST_SRCS})
372 TARGET_LINK_LIBRARIES(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES} ${CMAKE_XMLRPC_LIBRARIES})
375 # Sources for CPack
377 SET(CPACK_SRCS
378   CPack/cmCPackComponentGroup.cxx
379   CPack/cmCPackGeneratorFactory.cxx
380   CPack/cmCPackGenerator.cxx
381   CPack/cmCPackLog.cxx
382   CPack/cmCPackNSISGenerator.cxx
383   CPack/cmCPackSTGZGenerator.cxx
384   CPack/cmCPackTGZGenerator.cxx
385   CPack/cmCPackTarBZip2Generator.cxx
386   CPack/cmCPackTarCompressGenerator.cxx
387   CPack/cmCPackZIPGenerator.cxx
388   )
390 IF(WIN32 AND UNIX)
391   SET(CPACK_SRCS ${CPACK_SRCS}
392     CPack/cmCPackCygwinBinaryGenerator.cxx
393     CPack/cmCPackCygwinSourceGenerator.cxx
394     )
395 ENDIF(WIN32 AND UNIX)
396   
397 IF(UNIX)
398   SET(CPACK_SRCS ${CPACK_SRCS}
399     CPack/cmCPackDebGenerator.cxx
400     CPack/cmCPackRPMGenerator.cxx
401     )
402 ENDIF(UNIX)
404 IF(APPLE)
405   SET(CPACK_SRCS ${CPACK_SRCS}
406     CPack/cmCPackBundleGenerator.cxx
407     CPack/cmCPackDragNDropGenerator.cxx
408     CPack/cmCPackOSXX11Generator.cxx
409     CPack/cmCPackPackageMakerGenerator.cxx
410     )
411 ENDIF(APPLE)
413 # Build CPackLib
414 ADD_LIBRARY(CPackLib ${CPACK_SRCS})
415 TARGET_LINK_LIBRARIES(CPackLib CMakeLib)
417 IF(APPLE)
418   ADD_EXECUTABLE(cmakexbuild cmakexbuild.cxx)
419   TARGET_LINK_LIBRARIES(cmakexbuild CMakeLib)
420   ADD_EXECUTABLE(OSXScriptLauncher
421     CPack/OSXScriptLauncher.cxx)
422   TARGET_LINK_LIBRARIES(OSXScriptLauncher cmsys)
423   TARGET_LINK_LIBRARIES(OSXScriptLauncher "-framework Carbon")
424 ENDIF(APPLE)
426 # Build CMake executable
427 ADD_EXECUTABLE(cmake cmakemain.cxx)
428 TARGET_LINK_LIBRARIES(cmake CMakeLib)
429 ADD_EXECUTABLE(DumpDocumentation cmDumpDocumentation)
430 TARGET_LINK_LIBRARIES(DumpDocumentation CMakeLib)
432 # Build special executable for running programs on Windows 98
433 IF(WIN32)
434   IF(NOT UNIX)
435     ADD_EXECUTABLE(cmw9xcom cmw9xcom.cxx)
436     TARGET_LINK_LIBRARIES(cmw9xcom CMakeLib)
437     INSTALL_TARGETS(/bin cmw9xcom)
438   ENDIF(NOT UNIX)
439 ENDIF(WIN32)
441 # Build CTest executable
442 ADD_EXECUTABLE(ctest ctest.cxx)
443 TARGET_LINK_LIBRARIES(ctest CTestLib)
445 # Build CPack executable
446 ADD_EXECUTABLE(cpack CPack/cpack.cxx)
447 TARGET_LINK_LIBRARIES(cpack CPackLib)
449 # Curses GUI
450 IF(BUILD_CursesDialog)
451   INCLUDE(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt)
452 ENDIF(BUILD_CursesDialog)
454 # MFC GUI
455 # MFC libraries are only available on Visual Studio
456 IF(BUILD_MFCDialog)
457   SUBDIRS(MFCDialog)
458 ENDIF(BUILD_MFCDialog)
460 # Qt GUI
461 OPTION(BUILD_QtDialog "Build Qt dialog for CMake" FALSE)
462 IF(BUILD_QtDialog)
463   SUBDIRS(QtDialog)
464 ENDIF(BUILD_QtDialog)
466 # WX Widgets GUI
467 OPTION(BUILD_WXDialog "Build wxWidgets dialog for CMake" FALSE)
468 MARK_AS_ADVANCED(BUILD_WXDialog)
469 IF(BUILD_WXDialog)
470   SUBDIRS(WXDialog)
471 ENDIF(BUILD_WXDialog)
473 # FLTK GUI, needs some work: generator selection, paths with spaces, ...
474 # OPTION(BUILD_FLTKDialog "Build FLTK dialog for CMake" FALSE)
475 # MARK_AS_ADVANCED(BUILD_FLTKDialog)
476 # IF(BUILD_FLTKDialog)
477 #  SUBDIRS(FLTKDialog)
478 # ENDIF(BUILD_FLTKDialog)
480 INCLUDE (${CMAKE_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
481 INCLUDE (${CMAKE_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
483 INSTALL_TARGETS(/bin cmake)
484 INSTALL_TARGETS(/bin ctest)
485 INSTALL_TARGETS(/bin cpack)
486 IF(APPLE)
487   INSTALL_TARGETS(/bin cmakexbuild)
488 ENDIF(APPLE)
490 INSTALL_FILES(${CMAKE_DATA_DIR}/include cmCPluginAPI.h)