CMakeLists.txt 31 KB
Newer Older
1 2 3
# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.

4
include(CheckIncludeFile)
Brad King's avatar
Brad King committed
5
# Check if we can build support for ELF parsing.
6 7 8 9 10
if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
  CHECK_INCLUDE_FILES("stdint.h;elf_abi.h" HAVE_ELF_H)
else()
  CHECK_INCLUDE_FILE("elf.h" HAVE_ELF_H)
endif()
11 12
if(HAVE_ELF_H)
  set(CMAKE_USE_ELF_PARSER 1)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
elseif(HAIKU)
  # On Haiku, we need to include elf32.h from the private headers
  set(CMake_HAIKU_INCLUDE_DIRS
    /boot/system/develop/headers/private/system
    /boot/system/develop/headers/private/system/arch/x86
    )

  set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS})
  CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H)
  unset(CMAKE_REQUIRED_INCLUDES)

  if(HAVE_ELF32_H)
    set(CMAKE_USE_ELF_PARSER 1)
  else()
    unset(CMake_HAIKU_INCLUDE_DIRS)
    set(CMAKE_USE_ELF_PARSER)
  endif()
30
else()
31
  set(CMAKE_USE_ELF_PARSER)
32
endif()
Brad King's avatar
Brad King committed
33

34 35 36 37 38 39 40 41 42 43
if(NOT CMake_DEFAULT_RECURSION_LIMIT)
  if(DEFINED ENV{DASHBOARD_TEST_FROM_CTEST})
    set(CMake_DEFAULT_RECURSION_LIMIT 100)
  elseif(MINGW)
    set(CMake_DEFAULT_RECURSION_LIMIT 400)
  else()
    set(CMake_DEFAULT_RECURSION_LIMIT 1000)
  endif()
endif()

44 45 46 47
if(APPLE)
  set(CMAKE_USE_MACH_PARSER 1)
endif()

48
set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})
49

50
if(WIN32)
51
  # ensure Unicode friendly APIs are used on Windows
52
  add_definitions(-DUNICODE -D_UNICODE)
53 54 55

  # minimize windows.h content
  add_definitions(-DWIN32_LEAN_AND_MEAN)
56 57
endif()

58 59 60 61 62 63 64 65 66
# configure the .dox.in file
if(CMake_BUILD_DEVELOPER_REFERENCE)
  configure_file(
    "${CMake_SOURCE_DIR}/Source/dir.dox.in"
    "${CMake_BINARY_DIR}/Source/dir.dox"
    @ONLY
    )
endif()

67
# configure the .h file
68
configure_file(
69 70 71
  "${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in"
  "${CMake_BINARY_DIR}/Source/cmConfigure.h"
  )
72
configure_file(
73 74 75
  "${CMake_SOURCE_DIR}/Source/cmVersionConfig.h.in"
  "${CMake_BINARY_DIR}/Source/cmVersionConfig.h"
  )
76
configure_file(
77 78 79
  "${CMake_SOURCE_DIR}/Source/CPack/cmCPackConfigure.h.in"
  "${CMake_BINARY_DIR}/Source/CPack/cmCPackConfigure.h"
  )
80

81 82 83 84 85 86
# Tell CMake executable in the build tree where to find the source tree.
configure_file(
  "${CMake_SOURCE_DIR}/Source/CMakeSourceDir.txt.in"
  "${CMake_BINARY_DIR}/CMakeFiles/CMakeSourceDir.txt" @ONLY
  )

Andy Cedilnik's avatar
Andy Cedilnik committed
87
# add the include path to find the .h
88
include_directories(
89 90
  "${CMake_BINARY_DIR}/Source"
  "${CMake_SOURCE_DIR}/Source"
91
  "${CMake_SOURCE_DIR}/Source/LexerParser"
92 93
  ${CMAKE_ZLIB_INCLUDES}
  ${CMAKE_EXPAT_INCLUDES}
94
  ${CMAKE_TAR_INCLUDES}
95
  ${CMake_HAIKU_INCLUDE_DIRS}
96
  )
97 98

# let cmake know it is supposed to use it
99
add_definitions(-DCMAKE_BUILD_WITH_CMAKE)
100

Brad King's avatar
Brad King committed
101
# Check if we can build the ELF parser.
102 103
if(CMAKE_USE_ELF_PARSER)
  set(ELF_SRCS cmELF.h cmELF.cxx)
104
endif()
Brad King's avatar
Brad King committed
105

106 107 108 109 110
# Check if we can build the Mach-O parser.
if(CMAKE_USE_MACH_PARSER)
  set(MACH_SRCS cmMachO.h cmMachO.cxx)
endif()

111 112 113
#
# Sources for CMakeLib
#
114
set(SRCS
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
  # Lexers/Parsers
  LexerParser/cmCommandArgumentLexer.cxx
  LexerParser/cmCommandArgumentLexer.h
  LexerParser/cmCommandArgumentLexer.in.l
  LexerParser/cmCommandArgumentParser.cxx
  LexerParser/cmCommandArgumentParserTokens.h
  LexerParser/cmCommandArgumentParser.y
  LexerParser/cmDependsJavaLexer.cxx
  LexerParser/cmDependsJavaLexer.h
  LexerParser/cmDependsJavaLexer.in.l
  LexerParser/cmDependsJavaParser.cxx
  LexerParser/cmDependsJavaParserTokens.h
  LexerParser/cmDependsJavaParser.y
  LexerParser/cmExprLexer.cxx
  LexerParser/cmExprLexer.h
  LexerParser/cmExprLexer.in.l
  LexerParser/cmExprParser.cxx
  LexerParser/cmExprParserTokens.h
  LexerParser/cmExprParser.y
  LexerParser/cmFortranLexer.cxx
  LexerParser/cmFortranLexer.h
  LexerParser/cmFortranLexer.in.l
  LexerParser/cmFortranParser.cxx
  LexerParser/cmFortranParserTokens.h
  LexerParser/cmFortranParser.y
  LexerParser/cmListFileLexer.c
  LexerParser/cmListFileLexer.in.l

143 144
  cmAffinity.cxx
  cmAffinity.h
145
  cmArchiveWrite.cxx
wahikihiki's avatar
wahikihiki committed
146 147
  cmArgumentParser.cxx
  cmArgumentParser.h
148
  cmBase32.cxx
Andy Cedilnik's avatar
Andy Cedilnik committed
149 150
  cmCacheManager.cxx
  cmCacheManager.h
151 152
  cmCLocaleEnvironmentScope.h
  cmCLocaleEnvironmentScope.cxx
153
  cmCommandArgumentParserHelper.cxx
154 155
  cmCommonTargetGenerator.cxx
  cmCommonTargetGenerator.h
156 157
  cmComputeComponentGraph.cxx
  cmComputeComponentGraph.h
158 159
  cmComputeLinkDepends.cxx
  cmComputeLinkDepends.h
160 161
  cmComputeLinkInformation.cxx
  cmComputeLinkInformation.h
162 163
  cmComputeTargetDepends.h
  cmComputeTargetDepends.cxx
164 165
  cmCPackPropertiesGenerator.h
  cmCPackPropertiesGenerator.cxx
166 167
  cmCryptoHash.cxx
  cmCryptoHash.h
168 169
  cmCurl.cxx
  cmCurl.h
Andy Cedilnik's avatar
Andy Cedilnik committed
170 171
  cmCustomCommand.cxx
  cmCustomCommand.h
172 173
  cmCustomCommandGenerator.cxx
  cmCustomCommandGenerator.h
174 175
  cmDefinitions.cxx
  cmDefinitions.h
176 177 178 179 180 181
  cmDepends.cxx
  cmDepends.h
  cmDependsC.cxx
  cmDependsC.h
  cmDependsFortran.cxx
  cmDependsFortran.h
182 183
  cmDependsJava.cxx
  cmDependsJava.h
184 185
  cmDependsJavaParserHelper.cxx
  cmDependsJavaParserHelper.h
Andy Cedilnik's avatar
Andy Cedilnik committed
186
  cmDocumentation.cxx
187
  cmDocumentationFormatter.cxx
188
  cmDocumentationSection.cxx
Andy Cedilnik's avatar
Andy Cedilnik committed
189 190
  cmDynamicLoader.cxx
  cmDynamicLoader.h
Brad King's avatar
Brad King committed
191
  ${ELF_SRCS}
192
  cmExprParserHelper.cxx
193 194
  cmExportBuildAndroidMKGenerator.h
  cmExportBuildAndroidMKGenerator.cxx
195 196 197 198
  cmExportBuildFileGenerator.h
  cmExportBuildFileGenerator.cxx
  cmExportFileGenerator.h
  cmExportFileGenerator.cxx
199 200
  cmExportInstallAndroidMKGenerator.h
  cmExportInstallAndroidMKGenerator.cxx
201 202
  cmExportInstallFileGenerator.h
  cmExportInstallFileGenerator.cxx
203 204
  cmExportTryCompileFileGenerator.h
  cmExportTryCompileFileGenerator.cxx
205 206
  cmExportSet.h
  cmExportSet.cxx
207 208
  cmExportSetMap.h
  cmExportSetMap.cxx
209 210
  cmExternalMakefileProjectGenerator.cxx
  cmExternalMakefileProjectGenerator.h
211 212
  cmExtraCodeBlocksGenerator.cxx
  cmExtraCodeBlocksGenerator.h
213 214
  cmExtraCodeLiteGenerator.cxx
  cmExtraCodeLiteGenerator.h
215 216
  cmExtraEclipseCDT4Generator.cxx
  cmExtraEclipseCDT4Generator.h
217 218
  cmExtraKateGenerator.cxx
  cmExtraKateGenerator.h
219 220
  cmExtraSublimeTextGenerator.cxx
  cmExtraSublimeTextGenerator.h
221 222
  cmFileAPI.cxx
  cmFileAPI.h
Brad King's avatar
Brad King committed
223 224
  cmFileAPICache.cxx
  cmFileAPICache.h
Brad King's avatar
Brad King committed
225 226
  cmFileAPICodemodel.cxx
  cmFileAPICodemodel.h
Brad King's avatar
Brad King committed
227 228
  cmFileAPICMakeFiles.cxx
  cmFileAPICMakeFiles.h
229 230 231 232
  cmFileCopier.cxx
  cmFileCopier.h
  cmFileInstaller.cxx
  cmFileInstaller.h
233 234 235 236 237 238
  cmFileLock.cxx
  cmFileLock.h
  cmFileLockPool.cxx
  cmFileLockPool.h
  cmFileLockResult.cxx
  cmFileLockResult.h
239 240
  cmFilePathChecksum.cxx
  cmFilePathChecksum.h
241 242
  cmFileTime.cxx
  cmFileTime.h
243 244
  cmFileTimeCache.cxx
  cmFileTimeCache.h
245
  cmFortranParserImpl.cxx
246 247
  cmFSPermissions.cxx
  cmFSPermissions.h
Andy Cedilnik's avatar
Andy Cedilnik committed
248
  cmGeneratedFileStream.cxx
249 250
  cmGeneratorExpressionContext.cxx
  cmGeneratorExpressionContext.h
251 252
  cmGeneratorExpressionDAGChecker.cxx
  cmGeneratorExpressionDAGChecker.h
253 254
  cmGeneratorExpressionEvaluationFile.cxx
  cmGeneratorExpressionEvaluationFile.h
255 256 257 258
  cmGeneratorExpressionEvaluator.cxx
  cmGeneratorExpressionEvaluator.h
  cmGeneratorExpressionLexer.cxx
  cmGeneratorExpressionLexer.h
259 260
  cmGeneratorExpressionNode.cxx
  cmGeneratorExpressionNode.h
261 262
  cmGeneratorExpressionParser.cxx
  cmGeneratorExpressionParser.h
263 264
  cmGeneratorExpression.cxx
  cmGeneratorExpression.h
265 266
  cmGeneratorTarget.cxx
  cmGeneratorTarget.h
267 268
  cmGlobalCommonGenerator.cxx
  cmGlobalCommonGenerator.h
Andy Cedilnik's avatar
Andy Cedilnik committed
269 270
  cmGlobalGenerator.cxx
  cmGlobalGenerator.h
271
  cmGlobalGeneratorFactory.h
Ken Martin's avatar
Ken Martin committed
272 273
  cmGlobalUnixMakefileGenerator3.cxx
  cmGlobalUnixMakefileGenerator3.h
274 275
  cmGlobVerificationManager.cxx
  cmGlobVerificationManager.h
276
  cmGraphAdjacencyList.h
277 278
  cmGraphVizWriter.cxx
  cmGraphVizWriter.h
279 280
  cmInstallGenerator.h
  cmInstallGenerator.cxx
281
  cmInstallExportGenerator.cxx
282 283
  cmInstalledFile.h
  cmInstalledFile.cxx
284 285
  cmInstallFilesGenerator.h
  cmInstallFilesGenerator.cxx
286 287
  cmInstallScriptGenerator.h
  cmInstallScriptGenerator.cxx
288 289
  cmInstallSubdirectoryGenerator.h
  cmInstallSubdirectoryGenerator.cxx
290 291
  cmInstallTargetGenerator.h
  cmInstallTargetGenerator.cxx
292 293
  cmInstallDirectoryGenerator.h
  cmInstallDirectoryGenerator.cxx
294
  cmLinkedTree.h
295
  cmLinkItem.cxx
296
  cmLinkItem.h
297 298
  cmLinkLineComputer.cxx
  cmLinkLineComputer.h
299 300
  cmLinkLineDeviceComputer.cxx
  cmLinkLineDeviceComputer.h
Andy Cedilnik's avatar
Andy Cedilnik committed
301 302
  cmListFileCache.cxx
  cmListFileCache.h
303 304
  cmLocalCommonGenerator.cxx
  cmLocalCommonGenerator.h
Andy Cedilnik's avatar
Andy Cedilnik committed
305 306
  cmLocalGenerator.cxx
  cmLocalGenerator.h
307 308
  cmRulePlaceholderExpander.cxx
  cmRulePlaceholderExpander.h
Ken Martin's avatar
Ken Martin committed
309
  cmLocalUnixMakefileGenerator3.cxx
310
  cmLocale.h
311
  ${MACH_SRCS}
Andy Cedilnik's avatar
Andy Cedilnik committed
312 313
  cmMakefile.cxx
  cmMakefile.h
314 315 316 317
  cmMakefileTargetGenerator.cxx
  cmMakefileExecutableTargetGenerator.cxx
  cmMakefileLibraryTargetGenerator.cxx
  cmMakefileUtilityTargetGenerator.cxx
318
  cmMessageType.h
319 320
  cmMessenger.cxx
  cmMessenger.h
321 322
  cmMSVC60LinkLineComputer.cxx
  cmMSVC60LinkLineComputer.h
323 324
  cmOSXBundleGenerator.cxx
  cmOSXBundleGenerator.h
325 326
  cmOutputConverter.cxx
  cmOutputConverter.h
327 328
  cmNewLineStyle.h
  cmNewLineStyle.cxx
329 330
  cmOrderDirectories.cxx
  cmOrderDirectories.h
331 332
  cmPolicies.h
  cmPolicies.cxx
333 334
  cmProcessOutput.cxx
  cmProcessOutput.h
335 336
  cmProcessTools.cxx
  cmProcessTools.h
337 338 339 340
  cmProperty.cxx
  cmProperty.h
  cmPropertyDefinition.cxx
  cmPropertyDefinition.h
341 342 343 344
  cmPropertyDefinitionMap.cxx
  cmPropertyDefinitionMap.h
  cmPropertyMap.cxx
  cmPropertyMap.h
345 346
  cmQtAutoGen.cxx
  cmQtAutoGen.h
347 348
  cmQtAutoGenerator.cxx
  cmQtAutoGenerator.h
349 350
  cmQtAutoGenGlobalInitializer.cxx
  cmQtAutoGenGlobalInitializer.h
351 352
  cmQtAutoGenInitializer.cxx
  cmQtAutoGenInitializer.h
353 354
  cmQtAutoGeneratorMocUic.cxx
  cmQtAutoGeneratorMocUic.h
355 356
  cmQtAutoGeneratorRcc.cxx
  cmQtAutoGeneratorRcc.h
357 358
  cmRST.cxx
  cmRST.h
359 360
  cmScriptGenerator.h
  cmScriptGenerator.cxx
Andy Cedilnik's avatar
Andy Cedilnik committed
361 362
  cmSourceFile.cxx
  cmSourceFile.h
363 364
  cmSourceFileLocation.cxx
  cmSourceFileLocation.h
365
  cmSourceFileLocationKind.h
Andy Cedilnik's avatar
Andy Cedilnik committed
366 367
  cmSourceGroup.cxx
  cmSourceGroup.h
Stephen Kelly's avatar
Stephen Kelly committed
368 369
  cmState.cxx
  cmState.h
370 371 372 373
  cmStateDirectory.cxx
  cmStateDirectory.h
  cmStateSnapshot.cxx
  cmStateSnapshot.h
374
  cmStateTypes.h
Andy Cedilnik's avatar
Andy Cedilnik committed
375 376 377 378
  cmSystemTools.cxx
  cmSystemTools.h
  cmTarget.cxx
  cmTarget.h
379 380
  cmTargetPropertyComputer.cxx
  cmTargetPropertyComputer.h
381
  cmTargetExport.h
382 383
  cmTest.cxx
  cmTest.h
384 385
  cmTestGenerator.cxx
  cmTestGenerator.h
386
  cmUuid.cxx
387 388
  cmUVHandlePtr.cxx
  cmUVHandlePtr.h
389
  cmUVSignalHackRAII.h
Andy Cedilnik's avatar
Andy Cedilnik committed
390 391 392 393
  cmVariableWatch.cxx
  cmVariableWatch.h
  cmVersion.cxx
  cmVersion.h
394 395
  cmWorkingDirectory.cxx
  cmWorkingDirectory.h
Andy Cedilnik's avatar
Andy Cedilnik committed
396 397
  cmXMLParser.cxx
  cmXMLParser.h
398 399
  cmXMLSafe.cxx
  cmXMLSafe.h
400 401
  cmXMLWriter.cxx
  cmXMLWriter.h
Andy Cedilnik's avatar
Andy Cedilnik committed
402 403
  cmake.cxx
  cmake.h
404 405
  cm_string_view.cxx
  cm_string_view.hxx
406
  cm_static_string_view.hxx
407

408 409
  cmCommand.cxx
  cmCommand.h
410 411
  cmCommands.cxx
  cmCommands.h
412 413
  cmAddCompileDefinitionsCommand.cxx
  cmAddCompileDefinitionsCommand.h
414 415
  cmAddCompileOptionsCommand.cxx
  cmAddCompileOptionsCommand.h
416 417
  cmAddLinkOptionsCommand.cxx
  cmAddLinkOptionsCommand.h
418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433
  cmAddCustomCommandCommand.cxx
  cmAddCustomCommandCommand.h
  cmAddCustomTargetCommand.cxx
  cmAddCustomTargetCommand.h
  cmAddDefinitionsCommand.cxx
  cmAddDefinitionsCommand.h
  cmAddDependenciesCommand.cxx
  cmAddDependenciesCommand.h
  cmAddExecutableCommand.cxx
  cmAddExecutableCommand.h
  cmAddLibraryCommand.cxx
  cmAddLibraryCommand.h
  cmAddSubDirectoryCommand.cxx
  cmAddSubDirectoryCommand.h
  cmAddTestCommand.cxx
  cmAddTestCommand.h
434 435
  cmAuxSourceDirectoryCommand.cxx
  cmAuxSourceDirectoryCommand.h
436 437 438 439
  cmBreakCommand.cxx
  cmBreakCommand.h
  cmBuildCommand.cxx
  cmBuildCommand.h
440 441 442 443
  cmBuildNameCommand.cxx
  cmBuildNameCommand.h
  cmCMakeHostSystemInformationCommand.cxx
  cmCMakeHostSystemInformationCommand.h
444 445 446 447 448 449
  cmCMakeMinimumRequired.cxx
  cmCMakeMinimumRequired.h
  cmCMakePolicyCommand.cxx
  cmCMakePolicyCommand.h
  cmCommandArgumentsHelper.cxx
  cmCommandArgumentsHelper.h
450 451
  cmConditionEvaluator.cxx
  cmConditionEvaluator.h
452 453 454 455 456 457 458 459 460 461
  cmConfigureFileCommand.cxx
  cmConfigureFileCommand.h
  cmContinueCommand.cxx
  cmContinueCommand.h
  cmCoreTryCompile.cxx
  cmCoreTryCompile.h
  cmCreateTestSourceList.cxx
  cmCreateTestSourceList.h
  cmDefinePropertyCommand.cxx
  cmDefinePropertyCommand.h
462 463
  cmDisallowedCommand.cxx
  cmDisallowedCommand.h
464 465 466 467 468 469 470 471
  cmEnableLanguageCommand.cxx
  cmEnableLanguageCommand.h
  cmEnableTestingCommand.cxx
  cmEnableTestingCommand.h
  cmExecProgramCommand.cxx
  cmExecProgramCommand.h
  cmExecuteProcessCommand.cxx
  cmExecuteProcessCommand.h
472 473
  cmExpandedCommandArgument.cxx
  cmExpandedCommandArgument.h
474 475 476 477 478 479
  cmExportCommand.cxx
  cmExportCommand.h
  cmExportLibraryDependenciesCommand.cxx
  cmExportLibraryDependenciesCommand.h
  cmFLTKWrapUICommand.cxx
  cmFLTKWrapUICommand.h
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499
  cmFileCommand.cxx
  cmFileCommand.h
  cmFindBase.cxx
  cmFindBase.h
  cmFindCommon.cxx
  cmFindCommon.h
  cmFindFileCommand.cxx
  cmFindFileCommand.h
  cmFindLibraryCommand.cxx
  cmFindLibraryCommand.h
  cmFindPackageCommand.cxx
  cmFindPackageCommand.h
  cmFindPathCommand.cxx
  cmFindPathCommand.h
  cmFindProgramCommand.cxx
  cmFindProgramCommand.h
  cmForEachCommand.cxx
  cmForEachCommand.h
  cmFunctionCommand.cxx
  cmFunctionCommand.h
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521
  cmGetCMakePropertyCommand.cxx
  cmGetCMakePropertyCommand.h
  cmGetDirectoryPropertyCommand.cxx
  cmGetDirectoryPropertyCommand.h
  cmGetFilenameComponentCommand.cxx
  cmGetFilenameComponentCommand.h
  cmGetPropertyCommand.cxx
  cmGetPropertyCommand.h
  cmGetSourceFilePropertyCommand.cxx
  cmGetSourceFilePropertyCommand.h
  cmGetTargetPropertyCommand.cxx
  cmGetTargetPropertyCommand.h
  cmGetTestPropertyCommand.cxx
  cmGetTestPropertyCommand.h
  cmHexFileConverter.cxx
  cmHexFileConverter.h
  cmIfCommand.cxx
  cmIfCommand.h
  cmIncludeCommand.cxx
  cmIncludeCommand.h
  cmIncludeDirectoryCommand.cxx
  cmIncludeDirectoryCommand.h
522 523
  cmIncludeExternalMSProjectCommand.cxx
  cmIncludeExternalMSProjectCommand.h
524 525
  cmIncludeGuardCommand.cxx
  cmIncludeGuardCommand.h
526 527 528 529 530 531 532 533
  cmIncludeRegularExpressionCommand.cxx
  cmIncludeRegularExpressionCommand.h
  cmInstallCommand.cxx
  cmInstallCommand.h
  cmInstallCommandArguments.cxx
  cmInstallCommandArguments.h
  cmInstallFilesCommand.cxx
  cmInstallFilesCommand.h
534 535
  cmInstallProgramsCommand.cxx
  cmInstallProgramsCommand.h
536 537 538 539
  cmInstallTargetsCommand.cxx
  cmInstallTargetsCommand.h
  cmLinkDirectoriesCommand.cxx
  cmLinkDirectoriesCommand.h
540 541
  cmLinkLibrariesCommand.cxx
  cmLinkLibrariesCommand.h
542 543
  cmListCommand.cxx
  cmListCommand.h
544 545 546 547
  cmLoadCacheCommand.cxx
  cmLoadCacheCommand.h
  cmLoadCommandCommand.cxx
  cmLoadCommandCommand.h
548 549 550 551 552 553 554 555 556 557 558 559
  cmMacroCommand.cxx
  cmMacroCommand.h
  cmMakeDirectoryCommand.cxx
  cmMakeDirectoryCommand.h
  cmMarkAsAdvancedCommand.cxx
  cmMarkAsAdvancedCommand.h
  cmMathCommand.cxx
  cmMathCommand.h
  cmMessageCommand.cxx
  cmMessageCommand.h
  cmOptionCommand.cxx
  cmOptionCommand.h
560 561
  cmOutputRequiredFilesCommand.cxx
  cmOutputRequiredFilesCommand.h
562 563 564 565
  cmParseArgumentsCommand.cxx
  cmParseArgumentsCommand.h
  cmPathLabel.cxx
  cmPathLabel.h
566 567
  cmProjectCommand.cxx
  cmProjectCommand.h
568 569 570 571 572 573 574 575
  cmQTWrapCPPCommand.cxx
  cmQTWrapCPPCommand.h
  cmQTWrapUICommand.cxx
  cmQTWrapUICommand.h
  cmRemoveCommand.cxx
  cmRemoveCommand.h
  cmRemoveDefinitionsCommand.cxx
  cmRemoveDefinitionsCommand.h
576 577
  cmReturnCommand.cxx
  cmReturnCommand.h
578 579
  cmSearchPath.cxx
  cmSearchPath.h
580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595
  cmSeparateArgumentsCommand.cxx
  cmSeparateArgumentsCommand.h
  cmSetCommand.cxx
  cmSetCommand.h
  cmSetDirectoryPropertiesCommand.cxx
  cmSetDirectoryPropertiesCommand.h
  cmSetPropertyCommand.cxx
  cmSetPropertyCommand.h
  cmSetSourceFilesPropertiesCommand.cxx
  cmSetSourceFilesPropertiesCommand.h
  cmSetTargetPropertiesCommand.cxx
  cmSetTargetPropertiesCommand.h
  cmSetTestsPropertiesCommand.cxx
  cmSetTestsPropertiesCommand.h
  cmSiteNameCommand.cxx
  cmSiteNameCommand.h
596 597
  cmSourceGroupCommand.cxx
  cmSourceGroupCommand.h
598 599
  cmString.cxx
  cmString.hxx
600
  cmStringReplaceHelper.cxx
601 602 603 604
  cmStringCommand.cxx
  cmStringCommand.h
  cmSubdirCommand.cxx
  cmSubdirCommand.h
605 606 607 608 609 610 611 612 613 614
  cmSubdirDependsCommand.cxx
  cmSubdirDependsCommand.h
  cmTargetCompileDefinitionsCommand.cxx
  cmTargetCompileDefinitionsCommand.h
  cmTargetCompileFeaturesCommand.cxx
  cmTargetCompileFeaturesCommand.h
  cmTargetCompileOptionsCommand.cxx
  cmTargetCompileOptionsCommand.h
  cmTargetIncludeDirectoriesCommand.cxx
  cmTargetIncludeDirectoriesCommand.h
615 616
  cmTargetLinkOptionsCommand.cxx
  cmTargetLinkOptionsCommand.h
617 618
  cmTargetLinkDirectoriesCommand.cxx
  cmTargetLinkDirectoriesCommand.h
619 620
  cmTargetLinkLibrariesCommand.cxx
  cmTargetLinkLibrariesCommand.h
621 622 623 624
  cmTargetPropCommandBase.cxx
  cmTargetPropCommandBase.h
  cmTargetSourcesCommand.cxx
  cmTargetSourcesCommand.h
625 626 627 628 629 630
  cmTimestamp.cxx
  cmTimestamp.h
  cmTryCompileCommand.cxx
  cmTryCompileCommand.h
  cmTryRunCommand.cxx
  cmTryRunCommand.h
631 632
  cmUnexpectedCommand.cxx
  cmUnexpectedCommand.h
633 634
  cmUnsetCommand.cxx
  cmUnsetCommand.h
635 636 637 638 639 640 641 642
  cmUseMangledMesaCommand.cxx
  cmUseMangledMesaCommand.h
  cmUtilitySourceCommand.cxx
  cmUtilitySourceCommand.h
  cmVariableRequiresCommand.cxx
  cmVariableRequiresCommand.h
  cmVariableWatchCommand.cxx
  cmVariableWatchCommand.h
643 644
  cmWhileCommand.cxx
  cmWhileCommand.h
645 646
  cmWriteFileCommand.cxx
  cmWriteFileCommand.h
647

648 649
  cm_get_date.h
  cm_get_date.c
650 651
  cm_utf8.h
  cm_utf8.c
652 653
  cm_codecvt.hxx
  cm_codecvt.cxx
654
  cm_thread.hxx
655 656 657

  cmDuration.h
  cmDuration.cxx
Andy Cedilnik's avatar
Andy Cedilnik committed
658
  )
Ken Martin's avatar
Ken Martin committed
659

660 661 662
SET_PROPERTY(SOURCE cmProcessOutput.cxx APPEND PROPERTY COMPILE_DEFINITIONS
  KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})

663
# Xcode only works on Apple
664 665
if(APPLE)
  set(SRCS ${SRCS}
666
    cmXCodeObject.cxx
667
    cmXCode21Object.cxx
668
    cmXCodeScheme.cxx
669
    cmGlobalXCodeGenerator.cxx
670
    cmGlobalXCodeGenerator.h
671 672
    cmLocalXCodeGenerator.cxx
    cmLocalXCodeGenerator.h)
673
endif()
674 675


676 677
if (WIN32)
  set(SRCS ${SRCS}
678 679
    cmCallVisualStudioMacro.cxx
    cmCallVisualStudioMacro.h
680
    bindexplib.cxx
681 682
    )

683 684
  if(NOT UNIX)
    set(SRCS ${SRCS}
685
      cmGlobalBorlandMakefileGenerator.cxx
686
      cmGlobalBorlandMakefileGenerator.h
687 688
      cmGlobalMSYSMakefileGenerator.cxx
      cmGlobalMinGWMakefileGenerator.cxx
689
      cmGlobalNMakeMakefileGenerator.cxx
690
      cmGlobalNMakeMakefileGenerator.h
691 692
      cmGlobalJOMMakefileGenerator.cxx
      cmGlobalJOMMakefileGenerator.h
693 694 695 696 697 698
      cmGlobalVisualStudio71Generator.cxx
      cmGlobalVisualStudio71Generator.h
      cmGlobalVisualStudio7Generator.cxx
      cmGlobalVisualStudio7Generator.h
      cmGlobalVisualStudio8Generator.cxx
      cmGlobalVisualStudio8Generator.h
699 700
      cmGlobalVisualStudio9Generator.cxx
      cmGlobalVisualStudio9Generator.h
701 702 703 704
      cmVisualStudioGeneratorOptions.h
      cmVisualStudioGeneratorOptions.cxx
      cmVisualStudio10TargetGenerator.h
      cmVisualStudio10TargetGenerator.cxx
705 706
      cmVisualStudio10ToolsetOptions.h
      cmVisualStudio10ToolsetOptions.cxx
707 708 709 710
      cmLocalVisualStudio10Generator.cxx
      cmLocalVisualStudio10Generator.h
      cmGlobalVisualStudio10Generator.h
      cmGlobalVisualStudio10Generator.cxx
711 712
      cmGlobalVisualStudio11Generator.h
      cmGlobalVisualStudio11Generator.cxx
713 714
      cmGlobalVisualStudio12Generator.h
      cmGlobalVisualStudio12Generator.cxx
715 716
      cmGlobalVisualStudio14Generator.h
      cmGlobalVisualStudio14Generator.cxx
717 718
      cmGlobalVisualStudioGenerator.cxx
      cmGlobalVisualStudioGenerator.h
719 720
      cmGlobalVisualStudioVersionedGenerator.h
      cmGlobalVisualStudioVersionedGenerator.cxx
721
      cmIDEFlagTable.h
722 723
      cmIDEOptions.cxx
      cmIDEOptions.h
724 725
      cmLocalVisualStudio7Generator.cxx
      cmLocalVisualStudio7Generator.h
726 727
      cmLocalVisualStudioGenerator.cxx
      cmLocalVisualStudioGenerator.h
728 729 730 731
      cmVisualStudioSlnData.h
      cmVisualStudioSlnData.cxx
      cmVisualStudioSlnParser.h
      cmVisualStudioSlnParser.cxx
732 733
      cmVisualStudioWCEPlatformParser.h
      cmVisualStudioWCEPlatformParser.cxx
734 735
      cmVSSetupHelper.cxx
      cmVSSetupHelper.h
736
      )
737 738 739 740

    # Add a manifest file to executables on Windows to allow for
    # GetVersion to work properly on Windows 8 and above.
    set(MANIFEST_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake.version.manifest)
741 742
  endif()
endif ()
Ken Martin's avatar
Ken Martin committed
743

744
# Watcom support
745
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
746 747 748 749 750 751 752
  set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE)
  list(APPEND SRCS
    cmGlobalWatcomWMakeGenerator.cxx
    cmGlobalWatcomWMakeGenerator.h
    )
endif()

753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768
# GHS support
# Works only for windows and linux
if(WIN32 OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
  set(SRCS ${SRCS}
      cmGlobalGhsMultiGenerator.cxx
      cmGlobalGhsMultiGenerator.h
      cmLocalGhsMultiGenerator.cxx
      cmLocalGhsMultiGenerator.h
      cmGhsMultiTargetGenerator.cxx
      cmGhsMultiTargetGenerator.h
      cmGhsMultiGpj.cxx
      cmGhsMultiGpj.h
    )
endif()


769
# Ninja support
770
set(SRCS ${SRCS}
771 772 773 774 775 776 777 778 779 780 781
  cmGlobalNinjaGenerator.cxx
  cmGlobalNinjaGenerator.h
  cmNinjaTypes.h
  cmLocalNinjaGenerator.cxx
  cmLocalNinjaGenerator.h
  cmNinjaTargetGenerator.cxx
  cmNinjaTargetGenerator.h
  cmNinjaNormalTargetGenerator.cxx
  cmNinjaNormalTargetGenerator.h
  cmNinjaUtilityTargetGenerator.cxx
  cmNinjaUtilityTargetGenerator.h
782 783
  cmNinjaLinkLineComputer.cxx
  cmNinjaLinkLineComputer.h
784
  )
785

786 787 788
# Temporary variable for tools targets
set(_tools)

789
if(WIN32 AND NOT CYGWIN)
790
  set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501)
791
  add_executable(cmcldeps cmcldeps.cxx ${MANIFEST_FILE})
792
  list(APPEND _tools cmcldeps)
793 794
  target_link_libraries(cmcldeps CMakeLib)
endif()
795

796 797 798 799 800 801
foreach(v CURL_CA_BUNDLE CURL_CA_PATH)
  if(${v})
    set_property(SOURCE cmCurl.cxx APPEND PROPERTY COMPILE_DEFINITIONS ${v}="${${v}}")
  endif()
endforeach()

802 803
foreach(check
    STAT_HAS_ST_MTIM
804
    STAT_HAS_ST_MTIMESPEC
805 806 807 808 809 810
    )
  if(KWSYS_CXX_${check}_COMPILED) # abuse KWSys check cache entry
    set(CMake_${check} 1)
  else()
    set(CMake_${check} 0)
  endif()
811 812
  set_property(SOURCE cmFileTime.cxx APPEND PROPERTY
    COMPILE_DEFINITIONS CMake_${check}=${CMake_${check}})
813 814
endforeach()

815
# create a library used by the command line and the GUI
816 817
add_library(CMakeLib ${SRCS})
target_link_libraries(CMakeLib cmsys
818
  ${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
819
  ${CMAKE_TAR_LIBRARIES}
820
  ${CMAKE_CURL_LIBRARIES}
821
  ${CMAKE_JSONCPP_LIBRARIES}
822
  ${CMAKE_LIBUV_LIBRARIES}
823
  ${CMAKE_LIBRHASH_LIBRARIES}
824
  ${CMake_KWIML_LIBRARIES}
825
  ${CMAKE_THREAD_LIBS_INIT}
826
  )
827

828 829 830 831 832 833 834 835 836
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc")
  # the atomic instructions are implemented using libatomic on some platforms,
  # so linking to that may be required
  check_library_exists(atomic __atomic_fetch_add_4 "" LIBATOMIC_NEEDED)
  if(LIBATOMIC_NEEDED)
    target_link_libraries(CMakeLib atomic)
  endif()
endif()

837
# On Apple we need CoreFoundation and CoreServices
838 839
if(APPLE)
  target_link_libraries(CMakeLib "-framework CoreFoundation")
840
  target_link_libraries(CMakeLib "-framework CoreServices")
841
endif()
842

843 844
if(WIN32 AND NOT UNIX)
  # We need the rpcrt4 library on Windows.
845 846
  # We need the crypt32 library on Windows for crypto/cert APIs.
  target_link_libraries(CMakeLib rpcrt4 crypt32)
847
endif()
848

849 850
target_compile_definitions(CMakeLib PUBLIC ${CLANG_TIDY_DEFINITIONS})

851 852 853
#
# CTestLib
#
854
include_directories(
855
  "${CMake_SOURCE_DIR}/Source/CTest"
856
  ${CMAKE_CURL_INCLUDES}
857
  )
858 859 860
#
# Sources for CTestLib
#
861
set(CTEST_SRCS cmCTest.cxx
862
  CTest/cmProcess.cxx
863
  CTest/cmCTestBuildAndTestHandler.cxx
864
  CTest/cmCTestBuildCommand.cxx
Ken Martin's avatar
Ken Martin committed
865
  CTest/cmCTestBuildHandler.cxx
866
  CTest/cmCTestConfigureCommand.cxx
Ken Martin's avatar
Ken Martin committed
867
  CTest/cmCTestConfigureHandler.cxx
868
  CTest/cmCTestCoverageCommand.cxx
Ken Martin's avatar
Ken Martin committed
869
  CTest/cmCTestCoverageHandler.cxx
870
  CTest/cmCTestCurl.cxx
871
  CTest/cmParseMumpsCoverage.cxx
872
  CTest/cmParseCacheCoverage.cxx
873
  CTest/cmParseGTMCoverage.cxx
874
  CTest/cmParseJacocoCoverage.cxx
875
  CTest/cmParseBlanketJSCoverage.cxx
876
  CTest/cmParsePHPCoverage.cxx
877
  CTest/cmParseCoberturaCoverage.cxx
878
  CTest/cmParseDelphiCoverage.cxx
879
  CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
880
  CTest/cmCTestGenericHandler.cxx
881
  CTest/cmCTestHandlerCommand.cxx
882
  CTest/cmCTestLaunch.cxx
883
  CTest/cmCTestMemCheckCommand.cxx
884
  CTest/cmCTestMemCheckHandler.cxx
885
  CTest/cmCTestMultiProcessHandler.cxx
886
  CTest/cmCTestReadCustomFilesCommand.cxx
887
  CTest/cmCTestRunScriptCommand.cxx
888
  CTest/cmCTestRunTest.cxx
889
  CTest/cmCTestScriptHandler.cxx
890
  CTest/cmCTestSleepCommand.cxx
891
  CTest/cmCTestStartCommand.cxx
892 893 894
  CTest/cmCTestSubmitCommand.cxx
  CTest/cmCTestSubmitHandler.cxx
  CTest/cmCTestTestCommand.cxx
895 896 897
  CTest/cmCTestTestHandler.cxx
  CTest/cmCTestUpdateCommand.cxx
  CTest/cmCTestUpdateHandler.cxx
Zach's avatar
Zach committed
898 899
  CTest/cmCTestUploadCommand.cxx
  CTest/cmCTestUploadHandler.cxx
900 901 902

  CTest/cmCTestVC.cxx
  CTest/cmCTestVC.h
903 904
  CTest/cmCTestGlobalVC.cxx
  CTest/cmCTestGlobalVC.h
905 906 907 908
  CTest/cmCTestCVS.cxx
  CTest/cmCTestCVS.h
  CTest/cmCTestSVN.cxx
  CTest/cmCTestSVN.h
909 910
  CTest/cmCTestBZR.cxx
  CTest/cmCTestBZR.h
911 912
  CTest/cmCTestGIT.cxx
  CTest/cmCTestGIT.h
913 914
  CTest/cmCTestHG.cxx
  CTest/cmCTestHG.h
915 916
  CTest/cmCTestP4.cxx
  CTest/cmCTestP4.h
Andy Cedilnik's avatar
Andy Cedilnik committed
917
  )
Ken Martin's avatar
Ken Martin committed
918

919
# Build CTestLib
920
add_library(CTestLib ${CTEST_SRCS})
921
target_link_libraries(CTestLib CMakeLib ${CMAKE_CURL_LIBRARIES})
922

923 924 925 926 927 928
#
# CPack
#
include_directories(
  "${CMake_SOURCE_DIR}/Source/CPack"
  )
929 930 931
#
# Sources for CPack
#
932
set(CPACK_SRCS
933
  CPack/cmCPackArchiveGenerator.cxx
934
  CPack/cmCPackComponentGroup.cxx
935
  CPack/cmCPackDebGenerator.cxx
936
  CPack/cmCPackExternalGenerator.cxx
Bill Hoffman's avatar
Bill Hoffman committed
937
  CPack/cmCPackGeneratorFactory.cxx
Bill Hoffman's avatar
Bill Hoffman committed
938
  CPack/cmCPackGenerator.cxx
939
  CPack/cmCPackLog.cxx
940
  CPack/cmCPackNSISGenerator.cxx
Alex Turbov's avatar
Alex Turbov committed
941
  CPack/cmCPackNuGetGenerator.cxx
942 943
  CPack/cmCPackSTGZGenerator.cxx
  CPack/cmCPackTGZGenerator.cxx
944
  CPack/cmCPackTXZGenerator.cxx
945
  CPack/cmCPackTarBZip2Generator.cxx
946
  CPack/cmCPackTarCompressGenerator.cxx
947
  CPack/cmCPackZIPGenerator.cxx
948
  CPack/cmCPack7zGenerator.cxx
949
  )
950 951 952 953 954 955 956 957 958 959 960 961 962
# CPack IFW generator
set(CPACK_SRCS ${CPACK_SRCS}
  CPack/IFW/cmCPackIFWCommon.cxx
  CPack/IFW/cmCPackIFWCommon.h
  CPack/IFW/cmCPackIFWGenerator.cxx
  CPack/IFW/cmCPackIFWGenerator.h
  CPack/IFW/cmCPackIFWInstaller.cxx
  CPack/IFW/cmCPackIFWInstaller.h
  CPack/IFW/cmCPackIFWPackage.cxx
  CPack/IFW/cmCPackIFWPackage.h
  CPack/IFW/cmCPackIFWRepository.cxx
  CPack/IFW/cmCPackIFWRepository.h
  )
963

964 965
if(CYGWIN)
  set(CPACK_SRCS ${CPACK_SRCS}
966 967 968
    CPack/cmCPackCygwinBinaryGenerator.cxx
    CPack/cmCPackCygwinSourceGenerator.cxx
    )
969
endif()
970

971 972
option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF)

973 974
if(UNIX)
  set(CPACK_SRCS ${CPACK_SRCS}
975 976
    CPack/cmCPackRPMGenerator.cxx
    )
977 978 979 980 981 982 983 984

  # Optionally, try to use pkg(8)
  if(CPACK_ENABLE_FREEBSD_PKG)
    # On UNIX, you may find FreeBSD's pkg(8) and attendant
    # library -- it can be used on FreeBSD, Dragonfly, NetBSD,
    # OpenBSD and also Linux and OSX. Look for the header and
    # the library; it's a warning on FreeBSD if they're not
    # found, and informational on other platforms.
985
    find_path(FREEBSD_PKG_INCLUDE_DIRS "pkg.h")
986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003
    if(FREEBSD_PKG_INCLUDE_DIRS)
      find_library(FREEBSD_PKG_LIBRARIES
        pkg
        DOC "FreeBSD pkg(8) library")
      if(FREEBSD_PKG_LIBRARIES)
        set(CPACK_SRCS ${CPACK_SRCS}
          CPack/cmCPackFreeBSDGenerator.cxx
          )
      endif()
    endif()

    if (NOT FREEBSD_PKG_INCLUDE_DIRS OR NOT FREEBSD_PKG_LIBRARIES)
      message(FATAL_ERROR "CPack needs libpkg(3) to produce FreeBSD packages natively.")
    endif()
  else()
    set(FREEBSD_PKG_INCLUDE_DIRS NOTFOUND)
    set(FREEBSD_PKG_LIBRARIES NOTFOUND)
  endif()
1004
endif()
1005

1006 1007 1008 1009
if(CYGWIN)
  find_package(LibUUID)
endif()
if(WIN32 OR (CYGWIN AND LibUUID_FOUND))
1010
  set(CPACK_SRCS ${CPACK_SRCS}
1011 1012
    CPack/WiX/cmCMakeToWixPath.cxx
    CPack/WiX/cmCMakeToWixPath.h
1013
    CPack/WiX/cmCPackWIXGenerator.cxx
1014
    CPack/WiX/cmCPackWIXGenerator.h
1015
    CPack/WiX/cmWIXAccessControlList.cxx
1016
    CPack/WiX/cmWIXAccessControlList.h
1017
    CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
1018
    CPack/WiX/cmWIXDirectoriesSourceWriter.h
1019
    CPack/WiX/cmWIXFeaturesSourceWriter.cxx
1020
    CPack/WiX/cmWIXFeaturesSourceWriter.h
1021
    CPack/WiX/cmWIXFilesSourceWriter.cxx
1022
    CPack/WiX/cmWIXFilesSourceWriter.h
1023
    CPack/WiX/cmWIXPatch.cxx
1024
    CPack/WiX/cmWIXPatch.h
1025
    CPack/WiX/cmWIXPatchParser.cxx
1026
    CPack/WiX/cmWIXPatchParser.h
1027
    CPack/WiX/cmWIXRichTextFormatWriter.cxx
1028
    CPack/WiX/cmWIXRichTextFormatWriter.h
1029
    CPack/WiX/cmWIXShortcut.cxx
1030
    CPack/WiX/cmWIXShortcut.h
1031
    CPack/WiX/cmWIXSourceWriter.cxx
1032
    CPack/WiX/cmWIXSourceWriter.h
1033
    )
1034 1035
endif()

1036 1037
if(APPLE)
  set(CPACK_SRCS ${CPACK_SRCS}
1038
    CPack/cmCPackBundleGenerator.cxx
1039
    CPack/cmCPackDragNDropGenerator.cxx
1040
    CPack/cmCPackOSXX11Generator.cxx
1041
    CPack/cmCPackPKGGenerator.cxx
1042
    CPack/cmCPackPackageMakerGenerator.cxx
1043
    CPack/cmCPackProductBuildGenerator.cxx
1044
    )
1045
endif()
1046

1047
# Build CPackLib
1048 1049
add_library(CPackLib ${CPACK_SRCS})
target_link_libraries(CPackLib CMakeLib)
1050
if(APPLE)
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064
  # Some compilers produce errors in the CoreServices framework headers.
  # Ideally such errors should be fixed by either the compiler vendor
  # or the framework source, but we try to workaround it and build anyway.
  # If it does not work, build with reduced functionality and warn.
  check_include_file("CoreServices/CoreServices.h" HAVE_CoreServices)
  if(HAVE_CoreServices)
    set_property(SOURCE CPack/cmCPackDragNDropGenerator.cxx PROPERTY COMPILE_DEFINITIONS HAVE_CoreServices)
    target_link_libraries(CPackLib "-framework CoreServices")
  else()
    message(WARNING "This compiler does not appear to support\n"
      "  #include <CoreServices/CoreServices.h>\n"
      "Some CPack functionality may be limited.\n"
      "See CMakeFiles/CMakeError.log for details of the failure.")
  endif()
1065
endif()
1066 1067 1068 1069 1070
if(CYGWIN AND LibUUID_FOUND)
  target_link_libraries(CPackLib ${LibUUID_LIBRARIES})
  include_directories(CPackLib ${LibUUID_INCLUDE_DIRS})
  set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID)
endif()
1071 1072 1073 1074 1075
if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES)
  target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES})
  include_directories(${FREEBSD_PKG_INCLUDE_DIRS})
  add_definitions(-DHAVE_FREEBSD_PKG)
endif()
1076

1077 1078
if(APPLE)
  add_executable(OSXScriptLauncher
1079
    CPack/OSXScriptLauncher.cxx)
1080 1081
  target_link_libraries(OSXScriptLauncher cmsys)
  target_link_libraries(OSXScriptLauncher "-framework CoreFoundation")
1082
endif()
1083

1084
# Build CMake executable
1085
add_executable(cmake cmakemain.cxx cmcmd.cxx cmcmd.h ${MANIFEST_FILE})
1086
list(APPEND _tools cmake)
1087
target_link_libraries(cmake CMakeLib)
1088

1089 1090 1091
add_library(CMakeServerLib
  cmConnection.h cmConnection.cxx
  cmFileMonitor.cxx cmFileMonitor.h
1092 1093 1094
  cmJsonObjectDictionary.h
  cmJsonObjects.h
  cmJsonObjects.cxx
1095 1096 1097 1098 1099 1100 1101
  cmPipeConnection.cxx cmPipeConnection.h
  cmServer.cxx cmServer.h
  cmServerConnection.cxx cmServerConnection.h
  cmServerProtocol.cxx cmServerProtocol.h
  )
target_link_libraries(CMakeServerLib CMakeLib)
target_link_libraries(cmake CMakeServerLib)
1102

1103
# Build CTest executable
1104
add_executable(ctest ctest.cxx ${MANIFEST_FILE})
1105
list(APPEND _tools ctest)
1106
target_link_libraries(ctest CTestLib)
1107

1108
# Build CPack executable
1109
add_executable(cpack CPack/cpack.cxx ${MANIFEST_FILE})
1110
list(APPEND _tools cpack)
1111
target_link_libraries(cpack CPackLib)
1112

1113
# Curses GUI
1114 1115
if(BUILD_CursesDialog)
  include(${CMake_SOURCE_DIR}/Source/CursesDialog/CMakeLists.txt)
1116
endif()
1117

1118
# Qt GUI
1119 1120
option(BUILD_QtDialog "Build Qt dialog for CMake" FALSE)
if(BUILD_QtDialog)
1121
  add_subdirectory(QtDialog)
1122
endif()
1123 1124 1125 1126

include (${CMake_BINARY_DIR}/Source/LocalUserOptions.cmake OPTIONAL)
include (${CMake_SOURCE_DIR}/Source/LocalUserOptions.cmake OPTIONAL)

1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139
if(WIN32)
  # Add Windows executable version information.
  configure_file("CMakeVersion.rc.in" "CMakeVersion.rc" @ONLY)

  # We use a separate object library for this to work around a limitation of
  # MinGW's windres tool with spaces in the path to the include directories.
  add_library(CMakeVersion OBJECT "${CMAKE_CURRENT_BINARY_DIR}/CMakeVersion.rc")
  set_property(TARGET CMakeVersion PROPERTY INCLUDE_DIRECTORIES "")
  foreach(_tool ${_tools})
    target_sources(${_tool} PRIVATE $<TARGET_OBJECTS:CMakeVersion>)
  endforeach()
endif()

1140 1141 1142
# Install tools

foreach(_tool ${_tools})
1143
  CMake_OPTIONAL_COMPONENT(${_tool})
1144
  install(TARGETS ${_tool} DESTINATION ${CMAKE_BIN_DIR} ${COMPONENT})
1145 1146
endforeach()

1147
install(FILES cmCPluginAPI.h DESTINATION ${CMAKE_DATA_DIR}/include)
1148 1149 1150

# Unset temporary variables
unset(_tools)