summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeLists.txt37
-rw-r--r--Source/CMakeVersion.cmake6
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx2
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx2
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx7
-rw-r--r--Source/CPack/cmCPackArchiveGenerator.cxx8
-rw-r--r--Source/CPack/cmCPackBundleGenerator.cxx146
-rw-r--r--Source/CPack/cmCPackBundleGenerator.h2
-rw-r--r--Source/CPack/cmCPackComponentGroup.cxx2
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx8
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx44
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.h4
-rw-r--r--Source/CPack/cmCPackGenerator.cxx26
-rw-r--r--Source/CPack/cmCPackGenerator.h2
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.cxx9
-rw-r--r--Source/CPack/cmCPackLog.cxx10
-rw-r--r--Source/CPack/cmCPackLog.h2
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx36
-rw-r--r--Source/CPack/cmCPackNSISGenerator.h8
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.cxx6
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx22
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.h10
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx2
-rw-r--r--Source/CPack/cpack.cxx8
-rw-r--r--Source/CTest/cmCTestBatchTestHandler.cxx2
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx44
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h2
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx6
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx30
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx2
-rw-r--r--Source/CTest/cmCTestConfigureHandler.cxx4
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx184
-rw-r--r--Source/CTest/cmCTestCoverageHandler.h6
-rw-r--r--Source/CTest/cmCTestCurl.cxx282
-rw-r--r--Source/CTest/cmCTestCurl.h54
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx2
-rw-r--r--Source/CTest/cmCTestGIT.cxx2
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx4
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx10
-rw-r--r--Source/CTest/cmCTestLaunch.cxx23
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx36
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx52
-rw-r--r--Source/CTest/cmCTestP4.cxx10
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.cxx2
-rw-r--r--Source/CTest/cmCTestRunTest.cxx18
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx36
-rw-r--r--Source/CTest/cmCTestStartCommand.cxx4
-rw-r--r--Source/CTest/cmCTestSubmitCommand.cxx122
-rw-r--r--Source/CTest/cmCTestSubmitCommand.h9
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx269
-rw-r--r--Source/CTest/cmCTestSubmitHandler.h5
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx142
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx6
-rw-r--r--Source/CTest/cmCTestUpdateHandler.h8
-rw-r--r--Source/CTest/cmCTestUploadCommand.cxx2
-rw-r--r--Source/CTest/cmCTestVC.cxx2
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.cxx164
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.h48
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx6
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.cxx48
-rw-r--r--Source/CTest/cmParseDelphiCoverage.cxx251
-rw-r--r--Source/CTest/cmParseDelphiCoverage.h46
-rw-r--r--Source/CTest/cmParseGTMCoverage.cxx4
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx2
-rw-r--r--Source/CTest/cmParsePHPCoverage.cxx2
-rw-r--r--Source/CTest/cmProcess.cxx4
-rw-r--r--Source/CursesDialog/CMakeLists.txt18
-rw-r--r--Source/CursesDialog/ccmake.cxx3
-rw-r--r--Source/CursesDialog/cmCursesBoolWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.h6
-rw-r--r--Source/CursesDialog/cmCursesDummyWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesFilePathWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesForm.h6
-rw-r--r--Source/CursesDialog/cmCursesLabelWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.h6
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx23
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h6
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesPathWidget.cxx2
-rw-r--r--Source/CursesDialog/cmCursesPathWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesStandardIncludes.h42
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.h6
-rw-r--r--Source/CursesDialog/cmCursesWidget.h6
-rw-r--r--Source/CursesDialog/form/fld_attr.c8
-rw-r--r--Source/CursesDialog/form/form.h10
-rw-r--r--Source/CursesDialog/form/form.priv.h6
-rw-r--r--Source/CursesDialog/form/frm_driver.c19
-rw-r--r--Source/CursesDialog/form/frm_post.c5
-rw-r--r--Source/CursesDialog/form/frm_req_name.c6
-rw-r--r--Source/QtDialog/CMake.desktop2
-rw-r--r--Source/QtDialog/CMakeLists.txt10
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx2
-rw-r--r--Source/QtDialog/CMakeSetupDialog.ui2
-rw-r--r--Source/QtDialog/QCMake.h6
-rw-r--r--Source/QtDialog/QMacInstallDialog.cxx6
-rw-r--r--Source/cmAddCustomCommandCommand.cxx50
-rw-r--r--Source/cmAddCustomTargetCommand.cxx57
-rw-r--r--Source/cmAddDependenciesCommand.cxx6
-rw-r--r--Source/cmAddExecutableCommand.cxx14
-rw-r--r--Source/cmAddLibraryCommand.cxx51
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx12
-rw-r--r--Source/cmAddTestCommand.cxx12
-rw-r--r--Source/cmArchiveWrite.cxx23
-rw-r--r--Source/cmArchiveWrite.h2
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx2
-rw-r--r--Source/cmBootstrapCommands1.cxx4
-rw-r--r--Source/cmBreakCommand.cxx68
-rw-r--r--Source/cmBuildCommand.cxx2
-rw-r--r--Source/cmBuildNameCommand.cxx2
-rw-r--r--Source/cmCMakeMinimumRequired.cxx22
-rw-r--r--Source/cmCMakePolicyCommand.cxx8
-rw-r--r--Source/cmCPluginAPI.cxx5
-rw-r--r--Source/cmCTest.cxx91
-rw-r--r--Source/cmCTest.h2
-rw-r--r--Source/cmCacheManager.cxx14
-rw-r--r--Source/cmCallVisualStudioMacro.cxx19
-rw-r--r--Source/cmCommand.h2
-rw-r--r--Source/cmCommandArgumentParser.cxx6
-rw-r--r--Source/cmCommandArgumentParser.y6
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx10
-rw-r--r--Source/cmCommandArgumentsHelper.cxx9
-rw-r--r--Source/cmComputeLinkDepends.cxx21
-rw-r--r--Source/cmComputeLinkInformation.cxx67
-rw-r--r--Source/cmComputeTargetDepends.cxx4
-rw-r--r--Source/cmConditionEvaluator.cxx21
-rw-r--r--Source/cmConfigure.cmake.h.in5
-rw-r--r--Source/cmConfigureFileCommand.cxx19
-rw-r--r--Source/cmContinueCommand.cxx39
-rw-r--r--Source/cmContinueCommand.h55
-rw-r--r--Source/cmCoreTryCompile.cxx76
-rw-r--r--Source/cmCreateTestSourceList.cxx8
-rw-r--r--Source/cmCurl.cxx64
-rw-r--r--Source/cmCurl.h (renamed from Source/cmStandardIncludes.cxx)13
-rw-r--r--Source/cmCustomCommand.cxx40
-rw-r--r--Source/cmCustomCommand.h11
-rw-r--r--Source/cmCustomCommandGenerator.cxx6
-rw-r--r--Source/cmCustomCommandGenerator.h1
-rw-r--r--Source/cmDefinePropertyCommand.cxx4
-rw-r--r--Source/cmDepends.cxx12
-rw-r--r--Source/cmDependsC.cxx17
-rw-r--r--Source/cmDependsFortran.cxx14
-rw-r--r--Source/cmDependsFortranParser.cxx6
-rw-r--r--Source/cmDependsFortranParser.y6
-rw-r--r--Source/cmDependsJavaParser.cxx6
-rw-r--r--Source/cmDependsJavaParser.y6
-rw-r--r--Source/cmDependsJavaParserHelper.cxx10
-rw-r--r--Source/cmDocumentation.cxx11
-rw-r--r--Source/cmDocumentationFormatter.cxx6
-rw-r--r--Source/cmDynamicLoader.h4
-rw-r--r--Source/cmELF.cxx2
-rw-r--r--Source/cmExecProgramCommand.cxx12
-rw-r--r--Source/cmExecuteProcessCommand.cxx6
-rw-r--r--Source/cmExecutionStatus.h7
-rw-r--r--Source/cmExportBuildFileGenerator.cxx6
-rw-r--r--Source/cmExportCommand.cxx26
-rw-r--r--Source/cmExportFileGenerator.cxx20
-rw-r--r--Source/cmExportInstallFileGenerator.cxx65
-rw-r--r--Source/cmExportInstallFileGenerator.h4
-rw-r--r--Source/cmExportSet.cxx5
-rw-r--r--Source/cmExportSetMap.cxx7
-rw-r--r--Source/cmExprParser.cxx6
-rw-r--r--Source/cmExprParser.y6
-rw-r--r--Source/cmExprParserHelper.cxx2
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx24
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx4
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx20
-rw-r--r--Source/cmExtraKateGenerator.cxx2
-rw-r--r--Source/cmFileCommand.cxx453
-rw-r--r--Source/cmFileCommand.h1
-rw-r--r--Source/cmFileLock.cxx78
-rw-r--r--Source/cmFileLock.h74
-rw-r--r--Source/cmFileLockPool.cxx187
-rw-r--r--Source/cmFileLockPool.h102
-rw-r--r--Source/cmFileLockResult.cxx111
-rw-r--r--Source/cmFileLockResult.h85
-rw-r--r--Source/cmFileLockUnix.cxx102
-rw-r--r--Source/cmFileLockWin32.cxx126
-rw-r--r--Source/cmFindBase.cxx282
-rw-r--r--Source/cmFindBase.h19
-rw-r--r--Source/cmFindCommon.cxx206
-rw-r--r--Source/cmFindCommon.h66
-rw-r--r--Source/cmFindLibraryCommand.cxx22
-rw-r--r--Source/cmFindPackageCommand.cxx322
-rw-r--r--Source/cmFindPackageCommand.h41
-rw-r--r--Source/cmFindPathCommand.cxx8
-rw-r--r--Source/cmFindProgramCommand.cxx4
-rw-r--r--Source/cmForEachCommand.cxx16
-rw-r--r--Source/cmFunctionCommand.cxx14
-rw-r--r--Source/cmGeneratedFileStream.cxx8
-rw-r--r--Source/cmGeneratedFileStream.h8
-rw-r--r--Source/cmGeneratorExpression.cxx32
-rw-r--r--Source/cmGeneratorExpression.h5
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx10
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx35
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h4
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx83
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h1
-rw-r--r--Source/cmGeneratorExpressionParser.cxx10
-rw-r--r--Source/cmGeneratorTarget.cxx49
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx2
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx2
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx10
-rw-r--r--Source/cmGetPropertyCommand.cxx14
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx2
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.cxx1
-rw-r--r--Source/cmGlobalGenerator.cxx251
-rw-r--r--Source/cmGlobalGenerator.h40
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx8
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx73
-rw-r--r--Source/cmGlobalNinjaGenerator.h8
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx10
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx16
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx4
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx5
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx5
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx3
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx12
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx139
-rw-r--r--Source/cmGlobalXCodeGenerator.h11
-rw-r--r--Source/cmGraphVizWriter.cxx6
-rw-r--r--Source/cmIfCommand.cxx11
-rw-r--r--Source/cmIncludeCommand.cxx10
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx8
-rw-r--r--Source/cmInstallCommand.cxx103
-rw-r--r--Source/cmInstallExportGenerator.cxx2
-rw-r--r--Source/cmInstallFilesCommand.cxx9
-rw-r--r--Source/cmInstallProgramsCommand.cxx6
-rw-r--r--Source/cmInstallTargetGenerator.cxx12
-rw-r--r--Source/cmInstalledFile.h6
-rw-r--r--Source/cmLinkDirectoriesCommand.cxx2
-rw-r--r--Source/cmListCommand.cxx56
-rw-r--r--Source/cmListFileCache.cxx19
-rw-r--r--Source/cmLoadCacheCommand.cxx9
-rw-r--r--Source/cmLoadCommandCommand.cxx2
-rw-r--r--Source/cmLocalGenerator.cxx152
-rw-r--r--Source/cmLocalNinjaGenerator.cxx17
-rw-r--r--Source/cmLocalNinjaGenerator.h2
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx133
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h11
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx22
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx4
-rw-r--r--Source/cmLocale.h31
-rw-r--r--Source/cmMachO.cxx419
-rw-r--r--Source/cmMachO.h51
-rw-r--r--Source/cmMacroCommand.cxx14
-rw-r--r--Source/cmMakeDepend.cxx21
-rw-r--r--Source/cmMakefile.cxx441
-rw-r--r--Source/cmMakefile.h51
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx4
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx27
-rw-r--r--Source/cmMakefileTargetGenerator.cxx161
-rw-r--r--Source/cmMakefileTargetGenerator.h12
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx101
-rw-r--r--Source/cmNinjaTargetGenerator.cxx87
-rw-r--r--Source/cmNinjaTargetGenerator.h3
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx26
-rw-r--r--Source/cmOSXBundleGenerator.cxx20
-rw-r--r--Source/cmOrderDirectories.cxx24
-rw-r--r--Source/cmPathLabel.cxx41
-rw-r--r--Source/cmPathLabel.h44
-rw-r--r--Source/cmPolicies.cxx34
-rw-r--r--Source/cmPolicies.h2
-rw-r--r--Source/cmProjectCommand.cxx2
-rw-r--r--Source/cmQtAutoGenerators.cxx459
-rw-r--r--Source/cmQtAutoGenerators.h14
-rw-r--r--Source/cmRST.cxx9
-rw-r--r--Source/cmRemoveCommand.cxx7
-rw-r--r--Source/cmSearchPath.cxx251
-rw-r--r--Source/cmSearchPath.h57
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx2
-rw-r--r--Source/cmSetCommand.cxx6
-rw-r--r--Source/cmSetPropertyCommand.cxx22
-rw-r--r--Source/cmSetTargetPropertiesCommand.cxx2
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx2
-rw-r--r--Source/cmSiteNameCommand.cxx4
-rw-r--r--Source/cmSourceFile.cxx4
-rw-r--r--Source/cmSourceFileLocation.cxx14
-rw-r--r--Source/cmSourceGroupCommand.cxx2
-rw-r--r--Source/cmStandardIncludes.h333
-rw-r--r--Source/cmStandardLexer.h25
-rw-r--r--Source/cmStringCommand.cxx70
-rw-r--r--Source/cmStringCommand.h2
-rw-r--r--Source/cmSubdirCommand.cxx4
-rw-r--r--Source/cmSystemTools.cxx180
-rw-r--r--Source/cmSystemTools.h20
-rw-r--r--Source/cmTarget.cxx231
-rw-r--r--Source/cmTarget.h2
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx4
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx14
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx14
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx14
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx12
-rw-r--r--Source/cmTargetSourcesCommand.cxx14
-rw-r--r--Source/cmTryRunCommand.cxx23
-rw-r--r--Source/cmUseMangledMesaCommand.cxx2
-rw-r--r--Source/cmUtilitySourceCommand.cxx2
-rw-r--r--Source/cmUuid.cxx2
-rw-r--r--Source/cmVariableWatch.cxx21
-rw-r--r--Source/cmVariableWatchCommand.cxx6
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx36
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx41
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h7
-rw-r--r--Source/cmWhileCommand.cxx12
-rw-r--r--Source/cmWriteFileCommand.cxx2
-rw-r--r--Source/cmXMLParser.cxx2
-rw-r--r--Source/cm_get_date.c16
-rw-r--r--Source/cm_get_date.h28
-rw-r--r--Source/cm_sha2.c27
-rw-r--r--Source/cmake.cxx119
-rw-r--r--Source/cmakemain.cxx16
-rw-r--r--Source/cmcmd.cxx159
-rw-r--r--Source/ctest.cxx5
-rw-r--r--Source/kwsys/Base64.c24
-rw-r--r--Source/kwsys/Base64.h.in18
-rw-r--r--Source/kwsys/CMakeLists.txt226
-rw-r--r--Source/kwsys/CONTRIBUTING.rst35
-rw-r--r--Source/kwsys/Directory.cxx23
-rw-r--r--Source/kwsys/Directory.hxx.in2
-rw-r--r--Source/kwsys/DynamicLoader.cxx66
-rw-r--r--Source/kwsys/DynamicLoader.hxx.in15
-rw-r--r--Source/kwsys/EncodingC.c4
-rw-r--r--Source/kwsys/FStream.hxx.in10
-rw-r--r--Source/kwsys/Glob.cxx2
-rw-r--r--Source/kwsys/ProcessUNIX.c4
-rw-r--r--Source/kwsys/ProcessWin32.c12
-rw-r--r--Source/kwsys/README.txt2
-rw-r--r--Source/kwsys/SharedForward.h.in16
-rw-r--r--Source/kwsys/SystemInformation.cxx25
-rw-r--r--Source/kwsys/SystemTools.cxx250
-rw-r--r--Source/kwsys/SystemTools.hxx.in51
-rw-r--r--Source/kwsys/kwsysPlatformTests.cmake88
-rw-r--r--Source/kwsys/kwsysPlatformTestsCXX.cxx4
-rw-r--r--Source/kwsys/testSystemTools.cxx4
337 files changed, 8212 insertions, 4286 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index f9405b3..8a83c3e 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -39,6 +39,10 @@ else()
set(CMAKE_USE_ELF_PARSER)
endif()
+if(APPLE)
+ set(CMAKE_USE_MACH_PARSER 1)
+endif()
+
set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})
# ensure Unicode friendly APIs are used on Windows
@@ -140,11 +144,15 @@ if(CMAKE_USE_ELF_PARSER)
set(ELF_SRCS cmELF.h cmELF.cxx)
endif()
+# Check if we can build the Mach-O parser.
+if(CMAKE_USE_MACH_PARSER)
+ set(MACH_SRCS cmMachO.h cmMachO.cxx)
+endif()
+
#
# Sources for CMakeLib
#
set(SRCS
- cmStandardIncludes.cxx
cmArchiveWrite.cxx
cmBootstrapCommands1.cxx
cmBootstrapCommands2.cxx
@@ -167,6 +175,8 @@ set(SRCS
cmCPackPropertiesGenerator.cxx
cmCryptoHash.cxx
cmCryptoHash.h
+ cmCurl.cxx
+ cmCurl.h
cmCustomCommand.cxx
cmCustomCommand.h
cmCustomCommandGenerator.cxx
@@ -219,6 +229,12 @@ set(SRCS
cmExtraKateGenerator.h
cmExtraSublimeTextGenerator.cxx
cmExtraSublimeTextGenerator.h
+ cmFileLock.cxx
+ cmFileLock.h
+ cmFileLockPool.cxx
+ cmFileLockPool.h
+ cmFileLockResult.cxx
+ cmFileLockResult.h
cmFileTimeComparison.cxx
cmFileTimeComparison.h
cmGeneratedFileStream.cxx
@@ -261,6 +277,8 @@ set(SRCS
cmLocalGenerator.cxx
cmLocalGenerator.h
cmLocalUnixMakefileGenerator3.cxx
+ cmLocale.h
+ ${MACH_SRCS}
cmMakeDepend.cxx
cmMakeDepend.h
cmMakefile.cxx
@@ -320,6 +338,8 @@ set(SRCS
cmake.cxx
cmake.h
+ cm_get_date.h
+ cm_get_date.c
cm_sha2.h
cm_sha2.c
cm_utf8.h
@@ -473,19 +493,27 @@ set(SRCS ${SRCS}
cmNinjaUtilityTargetGenerator.cxx
cmNinjaUtilityTargetGenerator.h
)
-if(WIN32 AND NOT CYGWIN AND NOT BORLAND)
+if(WIN32 AND NOT CYGWIN)
set_source_files_properties(cmcldeps.cxx PROPERTIES COMPILE_DEFINITIONS _WIN32_WINNT=0x0501)
add_executable(cmcldeps cmcldeps.cxx)
target_link_libraries(cmcldeps CMakeLib)
install(TARGETS cmcldeps DESTINATION bin)
endif()
+foreach(v CURL_CA_BUNDLE CURL_CA_PATH)
+ if(${v})
+ set_property(SOURCE cmCurl.cxx APPEND PROPERTY COMPILE_DEFINITIONS ${v}="${${v}}")
+ endif()
+endforeach()
+
# create a library used by the command line and the GUI
add_library(CMakeLib ${SRCS})
target_link_libraries(CMakeLib cmsys
${CMAKE_EXPAT_LIBRARIES} ${CMAKE_ZLIB_LIBRARIES}
${CMAKE_TAR_LIBRARIES} ${CMAKE_COMPRESS_LIBRARIES}
- ${CMAKE_CURL_LIBRARIES} )
+ ${CMAKE_CURL_LIBRARIES}
+ ${CMAKE_JSONCPP_LIBRARIES}
+ )
# On Apple we need CoreFoundation
if(APPLE)
@@ -518,12 +546,15 @@ set(CTEST_SRCS cmCTest.cxx
CTest/cmCTestConfigureHandler.cxx
CTest/cmCTestCoverageCommand.cxx
CTest/cmCTestCoverageHandler.cxx
+ CTest/cmCTestCurl.cxx
CTest/cmParseMumpsCoverage.cxx
CTest/cmParseCacheCoverage.cxx
CTest/cmParseGTMCoverage.cxx
CTest/cmParseJacocoCoverage.cxx
+ CTest/cmParseBlanketJSCoverage.cxx
CTest/cmParsePHPCoverage.cxx
CTest/cmParseCoberturaCoverage.cxx
+ CTest/cmParseDelphiCoverage.cxx
CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
CTest/cmCTestGenericHandler.cxx
CTest/cmCTestHandlerCommand.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 7b27901..8ffe8c4 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,5 +1,5 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
-set(CMake_VERSION_MINOR 1)
-set(CMake_VERSION_PATCH 2)
-#set(CMake_VERSION_RC 0)
+set(CMake_VERSION_MINOR 2)
+set(CMake_VERSION_PATCH 0)
+set(CMake_VERSION_RC 1)
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index 0644ecb..4a99e50 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -24,7 +24,7 @@
#endif
#define cmCPackLogger(logType, msg) \
do { \
- cmOStringStream cmCPackLog_msg; \
+ std::ostringstream cmCPackLog_msg; \
cmCPackLog_msg << msg; \
if(Generator) { \
Generator->Logger->Log(logType, __FILE__, __LINE__, \
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index 3c45639..38cef87 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -25,7 +25,7 @@
#endif
#define cmCPackLogger(logType, msg) \
do { \
- cmOStringStream cmCPackLog_msg; \
+ std::ostringstream cmCPackLog_msg; \
cmCPackLog_msg << msg; \
if(Generator) { \
Generator->Logger->Log(logType, __FILE__, __LINE__, \
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 7e00027..59c38e9 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -1150,12 +1150,7 @@ void cmCPackWIXGenerator::CollectExtensions(
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(variableContent, list);
-
- for(std::vector<std::string>::const_iterator i = list.begin();
- i != list.end(); ++i)
- {
- extensions.insert(*i);
- }
+ extensions.insert(list.begin(), list.end());
}
void cmCPackWIXGenerator::AddCustomFlags(
diff --git a/Source/CPack/cmCPackArchiveGenerator.cxx b/Source/CPack/cmCPackArchiveGenerator.cxx
index 6e7b8d7..e2437b5 100644
--- a/Source/CPack/cmCPackArchiveGenerator.cxx
+++ b/Source/CPack/cmCPackArchiveGenerator.cxx
@@ -56,7 +56,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
localToplevel += "/"+ component->Name;
std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
// Change to local toplevel
- cmSystemTools::ChangeDirectory(localToplevel.c_str());
+ cmSystemTools::ChangeDirectory(localToplevel);
std::string filePrefix;
if (this->IsOn("CPACK_COMPONENT_INCLUDE_TOPLEVEL_DIRECTORY"))
{
@@ -80,7 +80,7 @@ int cmCPackArchiveGenerator::addOneComponentToArchive(cmArchiveWrite& archive,
}
}
// Go back to previous dir
- cmSystemTools::ChangeDirectory(dir.c_str());
+ cmSystemTools::ChangeDirectory(dir);
return 1;
}
@@ -270,7 +270,7 @@ int cmCPackArchiveGenerator::PackageFiles()
DECLARE_AND_OPEN_ARCHIVE(packageFileNames[0],archive);
std::vector<std::string>::const_iterator fileIt;
std::string dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(toplevel.c_str());
+ cmSystemTools::ChangeDirectory(toplevel);
for ( fileIt = files.begin(); fileIt != files.end(); ++ fileIt )
{
// Get the relative path to the file
@@ -288,7 +288,7 @@ int cmCPackArchiveGenerator::PackageFiles()
return 0;
}
}
- cmSystemTools::ChangeDirectory(dir.c_str());
+ cmSystemTools::ChangeDirectory(dir);
// The destructor of cmArchiveWrite will close and finish the write
return 1;
}
diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx
index 6c994f1..e751568 100644
--- a/Source/CPack/cmCPackBundleGenerator.cxx
+++ b/Source/CPack/cmCPackBundleGenerator.cxx
@@ -39,6 +39,21 @@ int cmCPackBundleGenerator::InitializeInternal()
return 0;
}
+ if(this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP"))
+ {
+ const std::string codesign_path = cmSystemTools::FindProgram("codesign",
+ std::vector<std::string>(), false);
+
+ if(codesign_path.empty())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Cannot locate codesign command"
+ << std::endl);
+ return 0;
+ }
+ this->SetOptionIfNotSet("CPACK_COMMAND_CODESIGN", codesign_path.c_str());
+ }
+
return this->Superclass::InitializeInternal();
}
@@ -53,7 +68,7 @@ const char* cmCPackBundleGenerator::GetPackagingInstallPrefix()
}
//----------------------------------------------------------------------
-int cmCPackBundleGenerator::PackageFiles()
+int cmCPackBundleGenerator::ConstructBundle()
{
// Get required arguments ...
@@ -97,24 +112,24 @@ int cmCPackBundleGenerator::PackageFiles()
// The staging directory contains everything that will end-up inside the
// final disk image ...
- cmOStringStream staging;
+ std::ostringstream staging;
staging << toplevel;
- cmOStringStream contents;
+ std::ostringstream contents;
contents << staging.str() << "/" << cpack_bundle_name
<< ".app/" << "Contents";
- cmOStringStream application;
+ std::ostringstream application;
application << contents.str() << "/" << "MacOS";
- cmOStringStream resources;
+ std::ostringstream resources;
resources << contents.str() << "/" << "Resources";
// Install a required, user-provided bundle metadata file ...
- cmOStringStream plist_source;
+ std::ostringstream plist_source;
plist_source << cpack_bundle_plist;
- cmOStringStream plist_target;
+ std::ostringstream plist_target;
plist_target << contents.str() << "/" << "Info.plist";
if(!this->CopyFile(plist_source, plist_target))
@@ -127,10 +142,10 @@ int cmCPackBundleGenerator::PackageFiles()
}
// Install a user-provided bundle icon ...
- cmOStringStream icon_source;
+ std::ostringstream icon_source;
icon_source << cpack_bundle_icon;
- cmOStringStream icon_target;
+ std::ostringstream icon_target;
icon_target << resources.str() << "/" << cpack_bundle_name << ".icns";
if(!this->CopyFile(icon_source, icon_target))
@@ -146,10 +161,10 @@ int cmCPackBundleGenerator::PackageFiles()
// executable or a script) ...
if(!cpack_bundle_startup_command.empty())
{
- cmOStringStream command_source;
+ std::ostringstream command_source;
command_source << cpack_bundle_startup_command;
- cmOStringStream command_target;
+ std::ostringstream command_target;
command_target << application.str() << "/" << cpack_bundle_name;
if(!this->CopyFile(command_source, command_target))
@@ -165,6 +180,22 @@ int cmCPackBundleGenerator::PackageFiles()
cmSystemTools::SetPermissions(command_target.str().c_str(), 0777);
}
+ return 1;
+}
+
+//----------------------------------------------------------------------
+int cmCPackBundleGenerator::PackageFiles()
+{
+ if(!this->ConstructBundle())
+ {
+ return 0;
+ }
+
+ if(!this->SignBundle(toplevel))
+ {
+ return 0;
+ }
+
return this->CreateDMG(toplevel, packageFileNames[0]);
}
@@ -172,3 +203,96 @@ bool cmCPackBundleGenerator::SupportsComponentInstallation() const
{
return false;
}
+
+
+int cmCPackBundleGenerator::SignBundle(const std::string& src_dir)
+{
+ const std::string cpack_apple_cert_app =
+ this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP")
+ ? this->GetOption("CPACK_BUNDLE_APPLE_CERT_APP") : "";
+
+ // codesign the application.
+ if(!cpack_apple_cert_app.empty())
+ {
+ std::string bundle_path;
+ bundle_path = src_dir + "/";
+ bundle_path += this->GetOption("CPACK_BUNDLE_NAME");
+ bundle_path += ".app";
+
+ // A list of additional files to sign, ie. frameworks and plugins.
+ const std::string sign_files =
+ this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES")
+ ? this->GetOption("CPACK_BUNDLE_APPLE_CODESIGN_FILES") : "";
+
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(sign_files, relFiles);
+
+ // sign the files supplied by the user, ie. frameworks.
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ std::ostringstream temp_sign_file_cmd;
+ temp_sign_file_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
+ temp_sign_file_cmd << " --deep -f -s \"" << cpack_apple_cert_app;
+ temp_sign_file_cmd << "\" -i ";
+ temp_sign_file_cmd << this->GetOption("CPACK_APPLE_BUNDLE_ID");
+ temp_sign_file_cmd << " \"";
+ temp_sign_file_cmd << bundle_path;
+ temp_sign_file_cmd << it->c_str() << "\"";
+
+ if(!this->RunCommand(temp_sign_file_cmd))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error signing file:"
+ << bundle_path << it->c_str() << std::endl);
+
+ return 0;
+ }
+ }
+
+ // sign main binary
+ std::ostringstream temp_sign_binary_cmd;
+ temp_sign_binary_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
+ temp_sign_binary_cmd << " --deep -f -s \"" << cpack_apple_cert_app;
+ temp_sign_binary_cmd << "\" \"" << bundle_path << "\"";
+
+ if(!this->RunCommand(temp_sign_binary_cmd))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error signing the application binary."
+ << std::endl);
+
+ return 0;
+ }
+
+ // sign app bundle
+ std::ostringstream temp_codesign_cmd;
+ temp_codesign_cmd << this->GetOption("CPACK_COMMAND_CODESIGN");
+ temp_codesign_cmd << " --deep -f -s \"" << cpack_apple_cert_app << "\"";
+ if(this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS"))
+ {
+ temp_codesign_cmd << " --entitlements ";
+ temp_codesign_cmd << this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS");
+ }
+ temp_codesign_cmd << " \"" << bundle_path << "\"";
+
+ if(!this->RunCommand(temp_codesign_cmd))
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error signing the application package."
+ << std::endl);
+
+ return 0;
+ }
+
+ cmCPackLogger(cmCPackLog::LOG_OUTPUT,
+ "- Application has been codesigned"
+ << std::endl);
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE,
+ (this->GetOption("CPACK_BUNDLE_APPLE_ENTITLEMENTS")
+ ? "with entitlement sandboxing" : "without entitlement sandboxing")
+ << std::endl);
+ }
+
+ return 1;
+}
diff --git a/Source/CPack/cmCPackBundleGenerator.h b/Source/CPack/cmCPackBundleGenerator.h
index ed0187d..9cb2f0a 100644
--- a/Source/CPack/cmCPackBundleGenerator.h
+++ b/Source/CPack/cmCPackBundleGenerator.h
@@ -31,6 +31,8 @@ public:
protected:
virtual int InitializeInternal();
virtual const char* GetPackagingInstallPrefix();
+ int ConstructBundle();
+ int SignBundle(const std::string& src_dir);
int PackageFiles();
bool SupportsComponentInstallation() const;
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index 77f11cb..fd20e9b 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -30,7 +30,7 @@ unsigned long cmCPackComponent::GetInstalledSize(
std::string path = installDir;
path += '/';
path += *fileIt;
- this->TotalSize += cmSystemTools::FileLength(path.c_str());
+ this->TotalSize += cmSystemTools::FileLength(path);
}
return this->TotalSize;
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 936942b..0a64bd5 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -58,7 +58,7 @@ int cmCPackDebGenerator::PackageOnePack(std::string initialTopLevel,
// Begin the archive for this pack
std::string localToplevel(initialTopLevel);
std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel.c_str())
+ cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
@@ -186,7 +186,7 @@ int cmCPackDebGenerator::PackageComponentsAllInOne()
// The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel);
std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel.c_str())
+ cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
@@ -390,7 +390,7 @@ int cmCPackDebGenerator::createDeb()
packageFiles.begin();
fileIt != packageFiles.end(); ++ fileIt )
{
- totalSize += cmSystemTools::FileLength(fileIt->c_str());
+ totalSize += cmSystemTools::FileLength(*fileIt);
}
}
out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n";
@@ -540,7 +540,7 @@ int cmCPackDebGenerator::createDeb()
localcopy += filenamename;
// if we can copy the file, it means it does exist, let's add it:
if( cmsys::SystemTools::CopyFileIfDifferent(
- i->c_str(), localcopy.c_str()) )
+ *i, localcopy) )
{
// debian is picky and need relative to ./ path in the tar.*
cmd += " ./";
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index 9f0a77e..5da9234 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -169,8 +169,8 @@ int cmCPackDragNDropGenerator::PackageFiles()
}
//----------------------------------------------------------------------
-bool cmCPackDragNDropGenerator::CopyFile(cmOStringStream& source,
- cmOStringStream& target)
+bool cmCPackDragNDropGenerator::CopyFile(std::ostringstream& source,
+ std::ostringstream& target)
{
if(!cmSystemTools::CopyFileIfDifferent(
source.str().c_str(),
@@ -190,7 +190,7 @@ bool cmCPackDragNDropGenerator::CopyFile(cmOStringStream& source,
}
//----------------------------------------------------------------------
-bool cmCPackDragNDropGenerator::RunCommand(cmOStringStream& command,
+bool cmCPackDragNDropGenerator::RunCommand(std::ostringstream& command,
std::string* output)
{
int exit_code = 1;
@@ -255,12 +255,12 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// The staging directory contains everything that will end-up inside the
// final disk image ...
- cmOStringStream staging;
+ std::ostringstream staging;
staging << src_dir;
// Add a symlink to /Applications so users can drag-and-drop the bundle
// into it
- cmOStringStream application_link;
+ std::ostringstream application_link;
application_link << staging.str() << "/Applications";
cmSystemTools::CreateSymlink("/Applications",
application_link.str().c_str());
@@ -268,10 +268,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally add a custom volume icon ...
if(!cpack_package_icon.empty())
{
- cmOStringStream package_icon_source;
+ std::ostringstream package_icon_source;
package_icon_source << cpack_package_icon;
- cmOStringStream package_icon_destination;
+ std::ostringstream package_icon_destination;
package_icon_destination << staging.str() << "/.VolumeIcon.icns";
if(!this->CopyFile(package_icon_source, package_icon_destination))
@@ -289,10 +289,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// (e.g. for setting background/layout) ...
if(!cpack_dmg_ds_store.empty())
{
- cmOStringStream package_settings_source;
+ std::ostringstream package_settings_source;
package_settings_source << cpack_dmg_ds_store;
- cmOStringStream package_settings_destination;
+ std::ostringstream package_settings_destination;
package_settings_destination << staging.str() << "/.DS_Store";
if(!this->CopyFile(package_settings_source, package_settings_destination))
@@ -309,10 +309,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally add a custom background image ...
if(!cpack_dmg_background_image.empty())
{
- cmOStringStream package_background_source;
+ std::ostringstream package_background_source;
package_background_source << cpack_dmg_background_image;
- cmOStringStream package_background_destination;
+ std::ostringstream package_background_destination;
package_background_destination << staging.str() << "/background.png";
if(!this->CopyFile(package_background_source,
@@ -326,7 +326,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
return 0;
}
- cmOStringStream temp_background_hiding_command;
+ std::ostringstream temp_background_hiding_command;
temp_background_hiding_command << this->GetOption("CPACK_COMMAND_SETFILE");
temp_background_hiding_command << " -a V \"";
temp_background_hiding_command << package_background_destination.str();
@@ -346,7 +346,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::string temp_image = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
temp_image += "/temp.dmg";
- cmOStringStream temp_image_command;
+ std::ostringstream temp_image_command;
temp_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
temp_image_command << " create";
temp_image_command << " -ov";
@@ -368,9 +368,9 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Optionally set the custom icon flag for the image ...
if(!cpack_package_icon.empty())
{
- cmOStringStream temp_mount;
+ std::ostringstream temp_mount;
- cmOStringStream attach_command;
+ std::ostringstream attach_command;
attach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
attach_command << " attach";
attach_command << " \"" << temp_image << "\"";
@@ -389,7 +389,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
mountpoint_regex.find(attach_output.c_str());
temp_mount << mountpoint_regex.match(1);
- cmOStringStream setfile_command;
+ std::ostringstream setfile_command;
setfile_command << this->GetOption("CPACK_COMMAND_SETFILE");
setfile_command << " -a C";
setfile_command << " \"" << temp_mount.str() << "\"";
@@ -403,7 +403,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
return 0;
}
- cmOStringStream detach_command;
+ std::ostringstream detach_command;
detach_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
detach_command << " detach";
detach_command << " \"" << temp_mount.str() << "\"";
@@ -471,7 +471,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
std::string temp_udco = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
temp_udco += "/temp-udco.dmg";
- cmOStringStream udco_image_command;
+ std::ostringstream udco_image_command;
udco_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
udco_image_command << " convert \"" << temp_image << "\"";
udco_image_command << " -format UDCO";
@@ -488,7 +488,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
// unflatten dmg
- cmOStringStream unflatten_command;
+ std::ostringstream unflatten_command;
unflatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
unflatten_command << " unflatten ";
unflatten_command << "\"" << temp_udco << "\"";
@@ -503,7 +503,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
// Rez the SLA
- cmOStringStream embed_sla_command;
+ std::ostringstream embed_sla_command;
embed_sla_command << this->GetOption("CPACK_COMMAND_REZ");
const char* sysroot = this->GetOption("CPACK_OSX_SYSROOT");
if(sysroot && sysroot[0] != '\0')
@@ -524,7 +524,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
}
// flatten dmg
- cmOStringStream flatten_command;
+ std::ostringstream flatten_command;
flatten_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
flatten_command << " flatten ";
flatten_command << "\"" << temp_udco << "\"";
@@ -543,7 +543,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir,
// Create the final compressed read-only disk image ...
- cmOStringStream final_image_command;
+ std::ostringstream final_image_command;
final_image_command << this->GetOption("CPACK_COMMAND_HDIUTIL");
final_image_command << " convert \"" << temp_image << "\"";
final_image_command << " -format ";
diff --git a/Source/CPack/cmCPackDragNDropGenerator.h b/Source/CPack/cmCPackDragNDropGenerator.h
index 808c618..1c84d49 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.h
+++ b/Source/CPack/cmCPackDragNDropGenerator.h
@@ -33,8 +33,8 @@ protected:
bool SupportsComponentInstallation() const;
- bool CopyFile(cmOStringStream& source, cmOStringStream& target);
- bool RunCommand(cmOStringStream& command, std::string* output = 0);
+ bool CopyFile(std::ostringstream& source, std::ostringstream& target);
+ bool RunCommand(std::ostringstream& command, std::string* output = 0);
std::string
GetComponentInstallDirNameSuffix(const std::string& componentName);
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 8139d29..1c670d2 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -160,7 +160,7 @@ int cmCPackGenerator::PrepareNames()
"Cannot open description file name: " << descFileName << std::endl);
return 0;
}
- cmOStringStream ostr;
+ std::ostringstream ostr;
std::string line;
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
@@ -217,7 +217,7 @@ int cmCPackGenerator::InstallProject()
{
std::string destDir = "DESTDIR=";
destDir += tempInstallDirectory;
- cmSystemTools::PutEnv(destDir.c_str());
+ cmSystemTools::PutEnv(destDir);
}
else
{
@@ -277,7 +277,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
{
std::string tempInstallDirectoryEnv = "CMAKE_INSTALL_PREFIX=";
tempInstallDirectoryEnv += tempInstallDirectory;
- cmSystemTools::PutEnv(tempInstallDirectoryEnv.c_str());
+ cmSystemTools::PutEnv(tempInstallDirectoryEnv);
std::vector<std::string> installCommandsVector;
cmSystemTools::ExpandListArgument(installCommands,installCommandsVector);
std::vector<std::string>::iterator it;
@@ -399,12 +399,12 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
<< inFile << " -> " << filePath << std::endl);
/* If the file is a symlink we will have to re-create it */
- if ( cmSystemTools::FileIsSymlink(inFile.c_str()))
+ if ( cmSystemTools::FileIsSymlink(inFile))
{
std::string targetFile;
std::string inFileRelative =
cmSystemTools::RelativePath(top.c_str(),inFile.c_str());
- cmSystemTools::ReadSymlink(inFile.c_str(),targetFile);
+ cmSystemTools::ReadSymlink(inFile,targetFile);
symlinkedFiles.push_back(std::pair<std::string,
std::string>(targetFile,inFileRelative));
}
@@ -421,7 +421,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
}
/* rebuild symlinks in the installed tree */
- if (symlinkedFiles.size()>0)
+ if (!symlinkedFiles.empty())
{
std::list< std::pair<std::string,std::string> >::iterator symlinkedIt;
std::string curDir = cmSystemTools::GetCurrentWorkingDirectory();
@@ -429,7 +429,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
goToDir += "/"+subdir;
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Change dir to: " << goToDir <<std::endl);
- cmSystemTools::ChangeDirectory(goToDir.c_str());
+ cmSystemTools::ChangeDirectory(goToDir);
for (symlinkedIt=symlinkedFiles.begin();
symlinkedIt != symlinkedFiles.end();
++symlinkedIt)
@@ -449,8 +449,8 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
<< symlinkedIt->first
<< std::endl);
}
- if (!cmSystemTools::CreateSymlink((symlinkedIt->first).c_str(),
- (symlinkedIt->second).c_str()))
+ if (!cmSystemTools::CreateSymlink(symlinkedIt->first,
+ symlinkedIt->second))
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot create symlink: "
<< symlinkedIt->second << "--> "
@@ -460,7 +460,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Going back to: "
<< curDir <<std::endl);
- cmSystemTools::ChangeDirectory(curDir.c_str());
+ cmSystemTools::ChangeDirectory(curDir);
}
}
}
@@ -807,7 +807,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
* in order to put things in subdirs...
*/
cmSystemTools::PutEnv(
- (std::string("DESTDIR=")+tempInstallDirectory).c_str()
+ std::string("DESTDIR=")+tempInstallDirectory
);
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Creating directory: '" << dir << "'" << std::endl);
@@ -938,7 +938,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
}
if (NULL !=mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES")) {
- if (absoluteDestFiles.length()>0) {
+ if (!absoluteDestFiles.empty()) {
absoluteDestFiles +=";";
}
absoluteDestFiles +=
@@ -1368,7 +1368,7 @@ int cmCPackGenerator::PrepareGroupingKind()
groupingType = this->GetOption("CPACK_COMPONENTS_GROUPING");
}
- if (groupingType.length()>0)
+ if (!groupingType.empty())
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "["
<< this->Name << "]"
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index ed89b53..907bb1e 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -29,7 +29,7 @@
#define cmCPackLogger(logType, msg) \
do { \
- cmOStringStream cmCPackLog_msg; \
+ std::ostringstream cmCPackLog_msg; \
cmCPackLog_msg << msg; \
this->Logger->Log(logType, __FILE__, __LINE__,\
cmCPackLog_msg.str().c_str());\
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index c8737f4..a07c29a 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -47,9 +47,6 @@
#include "cmCPackLog.h"
-#if defined(__BORLANDC__)
-# pragma warn -8008 /* condition is always true */
-#endif
//----------------------------------------------------------------------
cmCPackGeneratorFactory::cmCPackGeneratorFactory()
@@ -161,11 +158,7 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
//----------------------------------------------------------------------
cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
{
- std::vector<cmCPackGenerator*>::iterator it;
- for ( it = this->Generators.begin(); it != this->Generators.end(); ++ it )
- {
- delete *it;
- }
+ cmDeleteAll(this->Generators);
}
//----------------------------------------------------------------------
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index 7befca0..7633ac2 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -102,7 +102,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
display = true;
if ( needTagString )
{
- if ( tagString.size() > 0 ) { tagString += ","; }
+ if (!tagString.empty()) { tagString += ","; }
tagString = "VERBOSE";
}
}
@@ -112,7 +112,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
display = true;
if ( needTagString )
{
- if ( tagString.size() > 0 ) { tagString += ","; }
+ if (!tagString.empty()) { tagString += ","; }
tagString = "WARNING";
}
}
@@ -122,7 +122,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
display = true;
if ( needTagString )
{
- if ( tagString.size() > 0 ) { tagString += ","; }
+ if (!tagString.empty()) { tagString += ","; }
tagString = "ERROR";
}
}
@@ -132,7 +132,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
display = true;
if ( needTagString )
{
- if ( tagString.size() > 0 ) { tagString += ","; }
+ if (!tagString.empty()) { tagString += ","; }
tagString = "DEBUG";
}
useFileAndLine = true;
@@ -143,7 +143,7 @@ void cmCPackLog::Log(int tag, const char* file, int line,
display = true;
if ( needTagString )
{
- if ( tagString.size() > 0 ) { tagString += ","; }
+ if (!tagString.empty()) { tagString += ","; }
tagString = "VERBOSE";
}
}
diff --git a/Source/CPack/cmCPackLog.h b/Source/CPack/cmCPackLog.h
index 812f1de..7a7ff58 100644
--- a/Source/CPack/cmCPackLog.h
+++ b/Source/CPack/cmCPackLog.h
@@ -17,7 +17,7 @@
#define cmCPack_Log(ctSelf, logType, msg) \
do { \
- cmOStringStream cmCPackLog_msg; \
+ std::ostringstream cmCPackLog_msg; \
cmCPackLog_msg << msg; \
(ctSelf)->Log(logType, __FILE__, __LINE__, cmCPackLog_msg.str().c_str());\
} while ( 0 )
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index a5eee6b..8f63ca2 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -71,7 +71,7 @@ int cmCPackNSISGenerator::PackageFiles()
tmpFile += "/NSISOutput.log";
std::string nsisInstallOptions = nsisFileName + "/NSIS.InstallOptions.ini";
nsisFileName += "/project.nsi";
- cmOStringStream str;
+ std::ostringstream str;
std::vector<std::string>::const_iterator it;
for ( it = files.begin(); it != files.end(); ++ it )
{
@@ -91,7 +91,7 @@ int cmCPackNSISGenerator::PackageFiles()
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel.c_str(), dirs);
std::vector<std::string>::const_iterator sit;
- cmOStringStream dstr;
+ std::ostringstream dstr;
for ( sit = dirs.begin(); sit != dirs.end(); ++ sit )
{
std::string componentName;
@@ -190,7 +190,7 @@ int cmCPackNSISGenerator::PackageFiles()
std::string groupDescriptions;
std::string installTypesCode;
std::string defines;
- cmOStringStream macrosOut;
+ std::ostringstream macrosOut;
bool anyDownloadedComponents = false;
// Create installation types. The order is significant, so we first fill
@@ -503,8 +503,8 @@ int cmCPackNSISGenerator::InitializeInternal()
<< "not set" << std::endl);
}
- cmOStringStream str;
- cmOStringStream deleteStr;
+ std::ostringstream str;
+ std::ostringstream deleteStr;
if ( cpackPackageExecutables )
{
@@ -565,8 +565,8 @@ int cmCPackNSISGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
-void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str,
- cmOStringStream& deleteStr)
+void cmCPackNSISGenerator::CreateMenuLinks( std::ostringstream& str,
+ std::ostringstream& deleteStr)
{
const char* cpackMenuLinks
= this->GetOption("CPACK_NSIS_MENU_LINKS");
@@ -657,8 +657,8 @@ bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
cmsys_stl::string fullPath = topdir;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
- if(cmsys::SystemTools::FileIsDirectory(fullPath.c_str()) &&
- !cmsys::SystemTools::FileIsSymlink(fullPath.c_str()))
+ if(cmsys::SystemTools::FileIsDirectory(fullPath) &&
+ !cmsys::SystemTools::FileIsSymlink(fullPath))
{
if (!this->GetListOfSubdirectories(fullPath.c_str(), dirs))
{
@@ -694,7 +694,7 @@ bool cmCPackNSISGenerator::SupportsComponentInstallation() const
std::string
cmCPackNSISGenerator::
CreateComponentDescription(cmCPackComponent *component,
- cmOStringStream& macrosOut)
+ std::ostringstream& macrosOut)
{
// Basic description of the component
std::string componentCode = "Section ";
@@ -714,7 +714,7 @@ CreateComponentDescription(cmCPackComponent *component,
}
else if (!component->InstallationTypes.empty())
{
- cmOStringStream out;
+ std::ostringstream out;
std::vector<cmCPackInstallationType *>::iterator installTypeIter;
for (installTypeIter = component->InstallationTypes.begin();
installTypeIter != component->InstallationTypes.end();
@@ -734,7 +734,7 @@ CreateComponentDescription(cmCPackComponent *component,
// Compute the name of the archive.
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packagesDir += ".dummy";
- cmOStringStream out;
+ std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
<< "-" << component->Name << ".zip";
component->ArchiveFile = out.str();
@@ -771,7 +771,7 @@ CreateComponentDescription(cmCPackComponent *component,
<< archiveFile << std::endl);
if (cmSystemTools::FileExists(archiveFile.c_str(), true))
{
- if (!cmSystemTools::RemoveFile(archiveFile.c_str()))
+ if (!cmSystemTools::RemoveFile(archiveFile))
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Unable to remove archive file " << archiveFile
@@ -825,7 +825,7 @@ CreateComponentDescription(cmCPackComponent *component,
}
out << std::endl;
- totalSize += cmSystemTools::FileLength((dirName + *fileIt).c_str());
+ totalSize += cmSystemTools::FileLength(dirName + *fileIt);
}
}
@@ -859,7 +859,7 @@ CreateComponentDescription(cmCPackComponent *component,
{
totalSizeInKbytes = 1;
}
- cmOStringStream out;
+ std::ostringstream out;
out << " AddSize " << totalSizeInKbytes << "\n"
<< " Push \"" << component->ArchiveFile << "\"\n"
<< " Call DownloadFile\n"
@@ -935,7 +935,7 @@ std::string cmCPackNSISGenerator::CreateSelectionDependenciesDescription
}
visited.insert(component);
- cmOStringStream out;
+ std::ostringstream out;
std::vector<cmCPackComponent *>::iterator dependIt;
for (dependIt = component->Dependencies.begin();
dependIt != component->Dependencies.end();
@@ -967,7 +967,7 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
}
visited.insert(component);
- cmOStringStream out;
+ std::ostringstream out;
std::vector<cmCPackComponent *>::iterator dependIt;
for (dependIt = component->ReverseDependencies.begin();
dependIt != component->ReverseDependencies.end();
@@ -992,7 +992,7 @@ std::string cmCPackNSISGenerator::CreateDeselectionDependenciesDescription
std::string
cmCPackNSISGenerator::
CreateComponentGroupDescription(cmCPackComponentGroup *group,
- cmOStringStream& macrosOut)
+ std::ostringstream& macrosOut)
{
if (group->Components.empty() && group->Subgroups.empty())
{
diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h
index e46fbda..c7b2ce1 100644
--- a/Source/CPack/cmCPackNSISGenerator.h
+++ b/Source/CPack/cmCPackNSISGenerator.h
@@ -38,8 +38,8 @@ public:
protected:
virtual int InitializeInternal();
- void CreateMenuLinks( cmOStringStream& str,
- cmOStringStream& deleteStr);
+ void CreateMenuLinks( std::ostringstream& str,
+ std::ostringstream& deleteStr);
int PackageFiles();
virtual const char* GetOutputExtension() { return ".exe"; }
virtual const char* GetOutputPostfix() { return "win32"; }
@@ -56,7 +56,7 @@ protected:
/// macrosOut.
std::string
CreateComponentDescription(cmCPackComponent *component,
- cmOStringStream& macrosOut);
+ std::ostringstream& macrosOut);
/// Produce NSIS code that selects all of the components that this component
/// depends on, recursively.
@@ -75,7 +75,7 @@ protected:
/// added macros will be emitted via macrosOut.
std::string
CreateComponentGroupDescription(cmCPackComponentGroup *group,
- cmOStringStream& macrosOut);
+ std::ostringstream& macrosOut);
/// Translations any newlines found in the string into \\r\\n, so that the
/// resulting string can be used within NSIS.
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 28c7f1d..313e08b 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -45,8 +45,8 @@ int cmCPackOSXX11Generator::PackageFiles()
{
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
<< cpackPackageExecutables << "." << std::endl);
- cmOStringStream str;
- cmOStringStream deleteStr;
+ std::ostringstream str;
+ std::ostringstream deleteStr;
std::vector<std::string> cpackPackageExecutablesVector;
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
cpackPackageExecutablesVector);
@@ -165,7 +165,7 @@ int cmCPackOSXX11Generator::PackageFiles()
std::string output;
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/hdiutilOutput.log";
- cmOStringStream dmgCmd;
+ std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \""
<< diskImageDirectory.c_str()
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index e58415c..dfe35c9 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -334,7 +334,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
if (this->Components.empty())
{
// Use PackageMaker to build the package.
- cmOStringStream pkgCmd;
+ std::ostringstream pkgCmd;
pkgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM")
<< "\" -build -p \"" << packageDirFileName << "\"";
if (this->Components.empty())
@@ -368,7 +368,7 @@ int cmCPackPackageMakerGenerator::PackageFiles()
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/hdiutilOutput.log";
- cmOStringStream dmgCmd;
+ std::ostringstream dmgCmd;
dmgCmd << "\"" << this->GetOption("CPACK_INSTALLER_PROGRAM_DISK_IMAGE")
<< "\" create -ov -format UDZO -srcfolder \"" << packageDirFileName
<< "\" \"" << packageFileNames[0] << "\"";
@@ -703,7 +703,7 @@ cmCPackPackageMakerGenerator::GetPackageName(const cmCPackComponent& component)
{
std::string packagesDir = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
packagesDir += ".dummy";
- cmOStringStream out;
+ std::ostringstream out;
out << cmSystemTools::GetFilenameWithoutLastExtension(packagesDir)
<< "-" << component.Name << ".pkg";
return out.str();
@@ -726,7 +726,7 @@ GenerateComponentPackage(const char *packageFile,
packageFile << std::endl);
// The command that will be used to run PackageMaker
- cmOStringStream pkgCmd;
+ std::ostringstream pkgCmd;
if (this->PackageCompatibilityVersion < getVersion(10, 5) ||
this->PackageMakerVersion < 3.0)
@@ -816,7 +816,7 @@ WriteDistributionFile(const char* metapackageFile)
// Create the choice outline, which provides a tree-based view of
// the components in their groups.
- cmOStringStream choiceOut;
+ std::ostringstream choiceOut;
choiceOut << "<choices-outline>" << std::endl;
// Emit the outline for the groups
@@ -878,7 +878,8 @@ WriteDistributionFile(const char* metapackageFile)
//----------------------------------------------------------------------
void
cmCPackPackageMakerGenerator::
-CreateChoiceOutline(const cmCPackComponentGroup& group, cmOStringStream& out)
+CreateChoiceOutline(const cmCPackComponentGroup& group,
+ std::ostringstream& out)
{
out << "<line choice=\"" << group.Name << "Choice\">" << std::endl;
std::vector<cmCPackComponentGroup*>::const_iterator groupIt;
@@ -901,7 +902,7 @@ CreateChoiceOutline(const cmCPackComponentGroup& group, cmOStringStream& out)
//----------------------------------------------------------------------
void
cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group,
- cmOStringStream& out)
+ std::ostringstream& out)
{
out << "<choice id=\"" << group.Name << "Choice\" "
<< "title=\"" << group.DisplayName << "\" "
@@ -919,7 +920,7 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponentGroup& group,
//----------------------------------------------------------------------
void
cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
- cmOStringStream& out)
+ std::ostringstream& out)
{
std::string packageId = "com.";
packageId += this->GetOption("CPACK_PACKAGE_VENDOR");
@@ -980,6 +981,7 @@ cmCPackPackageMakerGenerator::CreateChoice(const cmCPackComponent& component,
std::string dirName = this->GetOption("CPACK_TEMPORARY_DIRECTORY");
dirName += '/';
dirName += component.Name;
+ dirName += this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX");
unsigned long installedSize
= component.GetInstalledSizeInKbytes(dirName.c_str());
@@ -1004,7 +1006,7 @@ void
cmCPackPackageMakerGenerator::
AddDependencyAttributes(const cmCPackComponent& component,
std::set<const cmCPackComponent *>& visited,
- cmOStringStream& out)
+ std::ostringstream& out)
{
if (visited.find(&component) != visited.end())
{
@@ -1028,7 +1030,7 @@ void
cmCPackPackageMakerGenerator::
AddReverseDependencyAttributes(const cmCPackComponent& component,
std::set<const cmCPackComponent *>& visited,
- cmOStringStream& out)
+ std::ostringstream& out)
{
if (visited.find(&component) != visited.end())
{
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index 4f9e2a8..7d349c6 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -84,30 +84,30 @@ protected:
// dependency attributes for inter-component dependencies.
void AddDependencyAttributes(const cmCPackComponent& component,
std::set<const cmCPackComponent *>& visited,
- cmOStringStream& out);
+ std::ostringstream& out);
// Subroutine of WriteDistributionFile that writes out the
// reverse dependency attributes for inter-component dependencies.
void
AddReverseDependencyAttributes(const cmCPackComponent& component,
std::set<const cmCPackComponent *>& visited,
- cmOStringStream& out);
+ std::ostringstream& out);
// Generates XML that encodes the hierarchy of component groups and
// their components in a form that can be used by distribution
// metapackages.
void CreateChoiceOutline(const cmCPackComponentGroup& group,
- cmOStringStream& out);
+ std::ostringstream& out);
/// Create the "choice" XML element to describe a component group
/// for the installer GUI.
void CreateChoice(const cmCPackComponentGroup& group,
- cmOStringStream& out);
+ std::ostringstream& out);
/// Create the "choice" XML element to describe a component for the
/// installer GUI.
void CreateChoice(const cmCPackComponent& component,
- cmOStringStream& out);
+ std::ostringstream& out);
// Escape the given string to make it usable as an XML attribute
// value.
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index c6171dc..71ab3a0 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -57,7 +57,7 @@ int cmCPackRPMGenerator::PackageOnePack(std::string initialToplevel,
// Begin the archive for this pack
std::string localToplevel(initialToplevel);
std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel.c_str())
+ cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName(
GetComponentPackageFileName(this->GetOption("CPACK_PACKAGE_FILE_NAME"),
@@ -166,7 +166,7 @@ int cmCPackRPMGenerator::PackageComponentsAllInOne()
// The ALL GROUPS in ONE package case
std::string localToplevel(initialTopLevel);
std::string packageFileName(
- cmSystemTools::GetParentDirectory(toplevel.c_str())
+ cmSystemTools::GetParentDirectory(toplevel)
);
std::string outputFileName(
std::string(this->GetOption("CPACK_PACKAGE_FILE_NAME"))
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 6c1d201..e5da5cf 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -71,8 +71,6 @@ int cmCPackSTGZGenerator::PackageFiles()
retval &= cmSystemTools::SetPermissions((*it).c_str(),
#if defined( _MSC_VER ) || defined( __MINGW32__ )
S_IREAD | S_IWRITE | S_IEXEC
-#elif defined( __BORLANDC__ )
- S_IRUSR | S_IWUSR | S_IXUSR
#else
S_IRUSR | S_IWUSR | S_IXUSR |
S_IRGRP | S_IWGRP | S_IXGRP |
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index c57028d..6106472 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -26,7 +26,6 @@
#include <cmsys/CommandLineArguments.hxx>
#include <cmsys/SystemTools.hxx>
#include <cmsys/Encoding.hxx>
-#include <locale.h>
//----------------------------------------------------------------------------
static const char * cmDocumentationName[][2] =
@@ -101,7 +100,6 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
// this is CPack.
int main (int argc, char const* const* argv)
{
- setlocale(LC_CTYPE, "");
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = args.argc();
@@ -117,7 +115,7 @@ int main (int argc, char const* const* argv)
cmSystemTools::EnableMSVCDebugHook();
- if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
+ if (cmSystemTools::GetCurrentWorkingDirectory().empty())
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Current working directory cannot be established." << std::endl);
@@ -267,7 +265,7 @@ int main (int argc, char const* const* argv)
if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
{
cpackConfigFile =
- cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
+ cmSystemTools::CollapseFullPath(cpackConfigFile);
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
"Read CPack configuration file: " << cpackConfigFile
<< std::endl);
@@ -426,7 +424,7 @@ int main (int argc, char const* const* argv)
= mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
const char* projVersionPatch
= mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << projVersionMajor << "." << projVersionMinor << "."
<< projVersionPatch;
mf->AddDefinition("CPACK_PACKAGE_VERSION",
diff --git a/Source/CTest/cmCTestBatchTestHandler.cxx b/Source/CTest/cmCTestBatchTestHandler.cxx
index 7f966aa..d62c260 100644
--- a/Source/CTest/cmCTestBatchTestHandler.cxx
+++ b/Source/CTest/cmCTestBatchTestHandler.cxx
@@ -58,7 +58,7 @@ void cmCTestBatchTestHandler::WriteSrunArgs(int test, cmsys::ofstream& fout)
fout << "-J=" << properties->Name << " ";
//Write dependency information
- /*if(this->Tests[test].size() > 0)
+ /*if(!this->Tests[test].empty())
{
fout << "-P=afterany";
for(TestSet::iterator i = this->Tests[test].begin();
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 41db042..d90aeb7 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -55,14 +55,14 @@ int cmCTestBuildAndTestHandler::ProcessHandler()
//----------------------------------------------------------------------
int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
- cmOStringStream &out, std::string &cmakeOutString, std::string &cwd,
+ std::ostringstream &out, std::string &cmakeOutString, std::string &cwd,
cmake *cm)
{
unsigned int k;
std::vector<std::string> args;
args.push_back(cmSystemTools::GetCMakeCommand());
args.push_back(this->SourceDir);
- if(this->BuildGenerator.size())
+ if(!this->BuildGenerator.empty())
{
std::string generator = "-G";
generator += this->BuildGenerator;
@@ -74,7 +74,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
platform += this->BuildGeneratorPlatform;
args.push_back(platform);
}
- if(this->BuildGeneratorToolset.size())
+ if(!this->BuildGeneratorToolset.empty())
{
std::string toolset = "-T";
toolset += this->BuildGeneratorToolset;
@@ -82,7 +82,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
}
const char* config = 0;
- if ( this->CTest->GetConfigType().size() > 0 )
+ if (!this->CTest->GetConfigType().empty())
{
config = this->CTest->GetConfigType().c_str();
}
@@ -109,7 +109,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
if(outstring)
{
*outstring = out.str();
@@ -128,7 +128,7 @@ int cmCTestBuildAndTestHandler::RunCMake(std::string* outstring,
out << "Error: cmake execution failed\n";
out << cmakeOutString << "\n";
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
if(outstring)
{
*outstring = out.str();
@@ -193,7 +193,7 @@ public:
int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{
// if the generator and make program are not specified then it is an error
- if (!this->BuildGenerator.size())
+ if (this->BuildGenerator.empty())
{
if(outstring)
{
@@ -209,10 +209,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string cmakeOutString;
cmCTestBuildAndTestCaptureRAII captureRAII(cm, cmakeOutString);
static_cast<void>(captureRAII);
- cmOStringStream out;
+ std::ostringstream out;
- if ( this->CTest->GetConfigType().size() == 0 &&
- this->ConfigSample.size())
+ if ( this->CTest->GetConfigType().empty() &&
+ !this->ConfigSample.empty())
{
// use the config sample to set the ConfigType
std::string fullPath;
@@ -225,7 +225,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
resultingConfig,
extraPaths,
failed);
- if (fullPath.size() && resultingConfig.size())
+ if (!fullPath.empty() && !resultingConfig.empty())
{
this->CTest->SetConfigType(resultingConfig.c_str());
}
@@ -241,11 +241,11 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
out << "Internal cmake changing into directory: "
<< this->BinaryDir << std::endl;
- if (!cmSystemTools::FileIsDirectory(this->BinaryDir.c_str()))
+ if (!cmSystemTools::FileIsDirectory(this->BinaryDir))
{
cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
}
- cmSystemTools::ChangeDirectory(this->BinaryDir.c_str());
+ cmSystemTools::ChangeDirectory(this->BinaryDir);
if(this->BuildNoCMake)
{
@@ -269,7 +269,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
// do the build
std::vector<std::string>::iterator tarIt;
- if ( this->BuildTargets.size() == 0 )
+ if (this->BuildTargets.empty())
{
this->BuildTargets.push_back("");
}
@@ -291,7 +291,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
std::string output;
const char* config = 0;
- if ( this->CTest->GetConfigType().size() > 0 )
+ if (!this->CTest->GetConfigType().empty())
{
config = this->CTest->GetConfigType().c_str();
}
@@ -329,7 +329,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
}
// if no test was specified then we are done
- if (!this->TestCommand.size())
+ if (this->TestCommand.empty())
{
return 0;
}
@@ -340,7 +340,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string resultingConfig;
std::vector<std::string> extraPaths;
// if this->ExecutableDirectory is set try that as well
- if (this->ExecutableDirectory.size())
+ if (!this->ExecutableDirectory.empty())
{
std::string tempPath = this->ExecutableDirectory;
tempPath += "/";
@@ -374,7 +374,7 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
cmCTestLog(this->CTest, ERROR_MESSAGE, out.str());
}
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
return 1;
}
@@ -388,10 +388,10 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
std::string outs;
int retval = 0;
// run the test from the this->BuildRunDir if set
- if(this->BuildRunDir.size())
+ if(!this->BuildRunDir.empty())
{
out << "Run test in directory: " << this->BuildRunDir << "\n";
- cmSystemTools::ChangeDirectory(this->BuildRunDir.c_str());
+ cmSystemTools::ChangeDirectory(this->BuildRunDir);
}
out << "Running test command: \"" << fullPath << "\"";
for(size_t k=0; k < this->TestCommandArgs.size(); ++k)
@@ -453,9 +453,9 @@ int cmCTestBuildAndTestHandler::ProcessCommandLineArguments(
// dir must exist before CollapseFullPath is called
cmSystemTools::MakeDirectory(this->BinaryDir.c_str());
this->BinaryDir
- = cmSystemTools::CollapseFullPath(this->BinaryDir.c_str());
+ = cmSystemTools::CollapseFullPath(this->BinaryDir);
this->SourceDir
- = cmSystemTools::CollapseFullPath(this->SourceDir.c_str());
+ = cmSystemTools::CollapseFullPath(this->SourceDir);
}
else
{
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index 5a7b916..a75c631 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -50,7 +50,7 @@ public:
protected:
///! Run CMake and build a test and then run it as a single test.
int RunCMakeAndTest(std::string* output);
- int RunCMake(std::string* outstring, cmOStringStream &out,
+ int RunCMake(std::string* outstring, std::ostringstream &out,
std::string &cmakeOutString,
std::string &cwd, cmake *cm);
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index a5a593a..c4df741 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -148,7 +148,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
}
else
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "has no project to build. If this is a "
"\"built with CMake\" project, verify that CTEST_CMAKE_GENERATOR "
"and CTEST_PROJECT_NAME are set."
@@ -181,7 +181,7 @@ bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
bool ret = cmCTestHandlerCommand::InitialPass(args, status);
if ( this->Values[ctb_NUMBER_ERRORS] && *this->Values[ctb_NUMBER_ERRORS])
{
- cmOStringStream str;
+ std::ostringstream str;
str << this->Handler->GetTotalErrors();
this->Makefile->AddDefinition(
this->Values[ctb_NUMBER_ERRORS], str.str().c_str());
@@ -189,7 +189,7 @@ bool cmCTestBuildCommand::InitialPass(std::vector<std::string> const& args,
if ( this->Values[ctb_NUMBER_WARNINGS]
&& *this->Values[ctb_NUMBER_WARNINGS])
{
- cmOStringStream str;
+ std::ostringstream str;
str << this->Handler->GetTotalWarnings();
this->Makefile->AddDefinition(
this->Values[ctb_NUMBER_WARNINGS], str.str().c_str());
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 13404a8..f941408 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -36,9 +36,6 @@
#include <math.h>
#include <float.h>
-#if defined(__BORLANDC__)
-# pragma warn -8060 /* possibly incorrect assignment */
-#endif
static const char* cmCTestErrorMatches[] = {
"^[Bb]us [Ee]rror",
@@ -347,7 +344,7 @@ int cmCTestBuildHandler::ProcessHandler()
// Determine build command and build directory
std::string makeCommand = this->GetMakeCommand();
- if ( makeCommand.size() == 0 )
+ if (makeCommand.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find MakeCommand key in the DartConfiguration.tcl"
@@ -357,7 +354,7 @@ int cmCTestBuildHandler::ProcessHandler()
const std::string &buildDirectory
= this->CTest->GetCTestConfiguration("BuildDirectory");
- if ( buildDirectory.size() == 0 )
+ if (buildDirectory.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
@@ -610,7 +607,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os)
int numWarningsAllowed = this->MaxWarnings;
// Identify fragments on disk.
cmsys::Directory launchDir;
- launchDir.Load(this->CTestLaunchDir.c_str());
+ launchDir.Load(this->CTestLaunchDir);
unsigned long n = launchDir.GetNumberOfFiles();
for(unsigned long i=0; i < n; ++i)
{
@@ -649,7 +646,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory");
// make sure the source dir is in the correct case on windows
// via a call to collapse full path.
- srcdir = cmSystemTools::CollapseFullPath(srcdir.c_str());
+ srcdir = cmSystemTools::CollapseFullPath(srcdir);
srcdir += "/";
for ( it = ew.begin();
it != ew.end() && (numErrorsAllowed || numWarningsAllowed); it++ )
@@ -695,7 +692,7 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
{
// make sure it is a full path with the correct case
cm->SourceFile = cmSystemTools::CollapseFullPath(
- cm->SourceFile.c_str());
+ cm->SourceFile);
cmSystemTools::ReplaceString(
cm->SourceFile, srcdir.c_str(), "");
}
@@ -705,12 +702,12 @@ void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
}
if ( !cm->SourceFile.empty() && cm->LineNumber >= 0 )
{
- if ( cm->SourceFile.size() > 0 )
+ if (!cm->SourceFile.empty())
{
os << "\t\t<SourceFile>" << cm->SourceFile << "</SourceFile>"
<< std::endl;
}
- if ( cm->SourceFileTail.size() > 0 )
+ if (!cm->SourceFileTail.empty())
{
os << "\t\t<SourceFileTail>" << cm->SourceFileTail
<< "</SourceFileTail>" << std::endl;
@@ -822,7 +819,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler):
launchDir += "/Build";
// Clean out any existing launcher fragments.
- cmSystemTools::RemoveADirectory(launchDir.c_str());
+ cmSystemTools::RemoveADirectory(launchDir);
if(this->Handler->UseCTestLaunch)
{
@@ -831,7 +828,7 @@ cmCTestBuildHandler::LaunchHelper::LaunchHelper(cmCTestBuildHandler* handler):
this->WriteLauncherConfig();
std::string launchEnv = "CTEST_LAUNCH_LOGS=";
launchEnv += launchDir;
- cmSystemTools::PutEnv(launchEnv.c_str());
+ cmSystemTools::PutEnv(launchEnv);
}
}
@@ -1097,11 +1094,8 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
{
// Create a contiguous array for the line
this->CurrentProcessingLine.clear();
- t_BuildProcessingQueueType::iterator cit;
- for ( cit = queue->begin(); cit != it; ++cit )
- {
- this->CurrentProcessingLine.push_back(*cit);
- }
+ this->CurrentProcessingLine.insert(this->CurrentProcessingLine.end(),
+ queue->begin(), it);
this->CurrentProcessingLine.push_back(0);
const char* line = &*this->CurrentProcessingLine.begin();
@@ -1156,7 +1150,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
{
// This is not an error or warning.
// So, figure out if this is a post-context line
- if ( this->ErrorsAndWarnings.size() &&
+ if ( !this->ErrorsAndWarnings.empty() &&
this->LastErrorOrWarning != this->ErrorsAndWarnings.end() &&
this->PostContextCount < this->MaxPostContext )
{
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index ef62fd3..0f13263 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -66,7 +66,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
const std::string cmakelists_file = source_dir + "/CMakeLists.txt";
if ( !cmSystemTools::FileExists(cmakelists_file.c_str()) )
{
- cmOStringStream e;
+ std::ostringstream e;
e << "CMakeLists.txt file does not exist ["
<< cmakelists_file << "]";
this->SetError(e.str());
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index c492bf0..506433f 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -38,7 +38,7 @@ int cmCTestConfigureHandler::ProcessHandler()
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Configure project" << std::endl);
std::string cCommand
= this->CTest->GetCTestConfiguration("ConfigureCommand");
- if ( cCommand.size() == 0 )
+ if (cCommand.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find ConfigureCommand key in the DartConfiguration.tcl"
@@ -48,7 +48,7 @@ int cmCTestConfigureHandler::ProcessHandler()
std::string buildDirectory
= this->CTest->GetCTestConfiguration("BuildDirectory");
- if ( buildDirectory.size() == 0 )
+ if (buildDirectory.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 76f6584..08b7c66 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -15,6 +15,8 @@
#include "cmParseGTMCoverage.h"
#include "cmParseCacheCoverage.h"
#include "cmParseJacocoCoverage.h"
+#include "cmParseDelphiCoverage.h"
+#include "cmParseBlanketJSCoverage.h"
#include "cmCTest.h"
#include "cmake.h"
#include "cmMakefile.h"
@@ -85,7 +87,7 @@ public:
}
args.push_back(0); // null terminate
cmsysProcess_SetCommand(this->Process, &*args.begin());
- if(this->WorkingDirectory.size())
+ if(!this->WorkingDirectory.empty())
{
cmsysProcess_SetWorkingDirectory(this->Process,
this->WorkingDirectory.c_str());
@@ -164,7 +166,7 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
fi != files.end(); ++fi)
{
log << "Removing old coverage log: " << *fi << "\n";
- cmSystemTools::RemoveFile(fi->c_str());
+ cmSystemTools::RemoveFile(*fi);
}
}
@@ -237,10 +239,10 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
std::string fSrcDir = cmSystemTools::CollapseFullPath(srcDir);
std::string fBinDir = cmSystemTools::CollapseFullPath(binDir);
std::string fFile = cmSystemTools::CollapseFullPath(file);
- bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(),
- fSrcDir.c_str());
- bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(),
- fBinDir.c_str());
+ bool sourceSubDir = cmSystemTools::IsSubDirectory(fFile,
+ fSrcDir);
+ bool buildSubDir = cmSystemTools::IsSubDirectory(fFile,
+ fBinDir);
// Always check parent directory of the file.
std::string fileDir = cmSystemTools::GetFilenamePath(fFile);
std::string checkDir;
@@ -268,7 +270,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
std::string ndc
= cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage",
fFile.c_str(), checkDir.c_str());
- if ( ndc.size() )
+ if (!ndc.empty())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
<< " so skip coverage of " << file << std::endl);
@@ -279,7 +281,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
// Get the relative path to the file an apply it to the opposite directory.
// If it is the same as fileDir, then ignore, otherwise check.
std::string relPath;
- if(checkDir.size() )
+ if(!checkDir.empty())
{
relPath = cmSystemTools::RelativePath(checkDir.c_str(),
fFile.c_str());
@@ -307,7 +309,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
ndc = cmSystemTools::FileExistsInParentDirectories(".NoDartCoverage",
fFile.c_str(), checkDir.c_str());
- if ( ndc.size() )
+ if (!ndc.empty())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
<< " so skip coverage of: " << file << std::endl);
@@ -423,6 +425,19 @@ int cmCTestCoverageHandler::ProcessHandler()
return error;
}
+ file_count += this->HandleBlanketJSCoverage(&cont);
+ error = cont.Error;
+ if ( file_count < 0 )
+ {
+ return error;
+ }
+
+ file_count += this->HandleDelphiCoverage(&cont);
+ error = cont.Error;
+ if ( file_count < 0 )
+ {
+ return error;
+ }
std::set<std::string> uncovered = this->FindUncoveredFiles(&cont);
if ( file_count == 0 )
@@ -529,7 +544,7 @@ int cmCTestCoverageHandler::ProcessHandler()
cmsys::ifstream ifs(fullFileName.c_str());
if ( !ifs)
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "Cannot open source file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
error ++;
@@ -548,7 +563,7 @@ int cmCTestCoverageHandler::ProcessHandler()
if ( !cmSystemTools::GetLineFromStream(ifs, line) &&
cc != fcov.size() -1 )
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "Problem reading source file: " << fullFileName
<< " line:" << cc << " out total: " << fcov.size()-1;
errorsWhileAccumulating.push_back(ostr.str());
@@ -569,8 +584,8 @@ int cmCTestCoverageHandler::ProcessHandler()
}
if ( cmSystemTools::GetLineFromStream(ifs, line) )
{
- cmOStringStream ostr;
- ostr << "Looks like there are more lines in the file: " << line;
+ std::ostringstream ostr;
+ ostr << "Looks like there are more lines in the file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
}
float cper = 0;
@@ -618,7 +633,7 @@ int cmCTestCoverageHandler::ProcessHandler()
cmsys::ifstream ifs(fullPath.c_str());
if (!ifs)
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "Cannot open source file: " << fullPath;
errorsWhileAccumulating.push_back(ostr.str());
error ++;
@@ -650,7 +665,7 @@ int cmCTestCoverageHandler::ProcessHandler()
this->EndCoverageLogFile(covLogFile, logFileCount);
- if ( errorsWhileAccumulating.size() > 0 )
+ if (!errorsWhileAccumulating.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
@@ -758,8 +773,8 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
//----------------------------------------------------------------------
bool IsFileInDir(const std::string &infile, const std::string &indir)
{
- std::string file = cmSystemTools::CollapseFullPath(infile.c_str());
- std::string dir = cmSystemTools::CollapseFullPath(indir.c_str());
+ std::string file = cmSystemTools::CollapseFullPath(infile);
+ std::string dir = cmSystemTools::CollapseFullPath(indir);
if (
file.size() > dir.size() &&
@@ -779,7 +794,7 @@ int cmCTestCoverageHandler::HandlePHPCoverage(
{
cmParsePHPCoverage cov(*cont, this->CTest);
std::string coverageDir = this->CTest->GetBinaryDir() + "/xdebugCoverage";
- if(cmSystemTools::FileIsDirectory(coverageDir.c_str()))
+ if(cmSystemTools::FileIsDirectory(coverageDir))
{
cov.ReadPHPCoverageDirectory(coverageDir.c_str());
}
@@ -869,7 +884,7 @@ struct cmCTestCoverageHandlerLocale
{
if(!lc_all.empty())
{
- cmSystemTools::PutEnv(("LC_ALL=" + lc_all).c_str());
+ cmSystemTools::PutEnv("LC_ALL=" + lc_all);
}
else
{
@@ -895,7 +910,7 @@ int cmCTestCoverageHandler::HandleJacocoCoverage(
g.FindFiles(coverageFile);
files=g.GetFiles();
- if (files.size() > 0)
+ if (!files.empty())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Found Jacoco Files, Performing Coverage" << std::endl);
@@ -910,7 +925,68 @@ int cmCTestCoverageHandler::HandleJacocoCoverage(
return static_cast<int>(cont->TotalCoverage.size());
}
+//----------------------------------------------------------------------
+int cmCTestCoverageHandler::HandleDelphiCoverage(
+ cmCTestCoverageHandlerContainer* cont)
+{
+ cmParseDelphiCoverage cov =
+ cmParseDelphiCoverage(*cont, this->CTest);
+ cmsys::Glob g;
+ std::vector<std::string> files;
+ g.SetRecurse(true);
+
+
+ std::string BinDir
+ = this->CTest->GetBinaryDir();
+ std::string coverageFile = BinDir+ "/*.html";
+
+ g.FindFiles(coverageFile);
+ files=g.GetFiles();
+ if (!files.empty())
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found Delphi HTML Files, Performing Coverage" << std::endl);
+ cov.LoadCoverageData(files);
+ }
+ else
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " Cannot find Delphi coverage files: " << coverageFile
+ << std::endl);
+ }
+ return static_cast<int>(cont->TotalCoverage.size());
+}
+
+//----------------------------------------------------------------------
+int cmCTestCoverageHandler::HandleBlanketJSCoverage(
+ cmCTestCoverageHandlerContainer* cont)
+ {
+ cmParseBlanketJSCoverage cov =
+ cmParseBlanketJSCoverage(*cont, this->CTest);
+ std::string SourceDir
+ = this->CTest->GetCTestConfiguration("SourceDirectory");
+
+ //Look for something other than output.json, still JSON extension.
+ std::string coverageFile = SourceDir+ "/*.json";
+ cmsys::Glob g;
+ std::vector<std::string> files;
+ g.FindFiles(coverageFile);
+ files=g.GetFiles();
+ if (!files.empty())
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Found BlanketJS output JSON, Performing Coverage" << std::endl);
+ cov.LoadCoverageData(files);
+ }
+ else
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " Cannot find BlanketJS coverage files: " << coverageFile
+ << std::endl);
+ }
+ return static_cast<int>(cont->TotalCoverage.size());
+ }
//----------------------------------------------------------------------
int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestCoverageHandlerContainer* cont)
@@ -961,7 +1037,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
this->FindGCovFiles(files);
std::vector<std::string>::iterator it;
- if ( files.size() == 0 )
+ if (files.empty())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Cannot find any GCov coverage files."
@@ -974,7 +1050,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string tempDir = testingDir + "/CoverageInfo";
std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str());
- cmSystemTools::ChangeDirectory(tempDir.c_str());
+ cmSystemTools::ChangeDirectory(tempDir);
int gcovStyle = 0;
@@ -1055,7 +1131,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
cmCTestLog(this->CTest, DEBUG, "Line: [" << *line << "]"
<< std::endl);
- if ( line->size() == 0 )
+ if (line->empty())
{
// Ignore empty line; probably style 2
}
@@ -1235,7 +1311,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
//TODO: Handle gcov 3.0 non-coverage lines
// Skip empty lines
- if ( !nl.size() )
+ if (nl.empty())
{
continue;
}
@@ -1295,7 +1371,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
*cont->OFS << " produced in source dir: " << sourceFile
<< std::endl;
actualSourceFile
- = cmSystemTools::CollapseFullPath(sourceFile.c_str());
+ = cmSystemTools::CollapseFullPath(sourceFile);
}
else if ( IsFileInDir(sourceFile, cont->BinaryDir) )
{
@@ -1304,7 +1380,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
*cont->OFS << " produced in binary dir: " << sourceFile
<< std::endl;
actualSourceFile
- = cmSystemTools::CollapseFullPath(sourceFile.c_str());
+ = cmSystemTools::CollapseFullPath(sourceFile);
}
if ( actualSourceFile.empty() )
@@ -1345,7 +1421,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
}
}
- cmSystemTools::ChangeDirectory(currentDirectory.c_str());
+ cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -1380,7 +1456,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
this->FindLCovFiles(files);
std::vector<std::string>::iterator it;
- if ( files.size() == 0 )
+ if (files.empty())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Cannot find any LCov coverage files."
@@ -1409,30 +1485,30 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
for ( it = files.begin(); it != files.end(); ++ it )
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "." << std::flush);
- std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str());
- cmSystemTools::ChangeDirectory(fileDir.c_str());
+ std::string fileDir = cmSystemTools::GetFilenamePath(*it);
+ cmSystemTools::ChangeDirectory(fileDir);
std::string command = "\"" + lcovCommand + "\" " +
lcovExtraFlags + " ";
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: "
- << fileDir.c_str() << std::endl);
+ << fileDir << std::endl);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, command.c_str()
<< std::endl);
std::string output = "";
std::string errors = "";
int retVal = 0;
- *cont->OFS << "* Run coverage for: " << fileDir.c_str() << std::endl;
- *cont->OFS << " Command: " << command.c_str() << std::endl;
+ *cont->OFS << "* Run coverage for: " << fileDir << std::endl;
+ *cont->OFS << " Command: " << command << std::endl;
int res = this->CTest->RunCommand(command.c_str(), &output, &errors,
&retVal, fileDir.c_str(), 0 /*this->TimeOut*/);
- *cont->OFS << " Output: " << output.c_str() << std::endl;
- *cont->OFS << " Errors: " << errors.c_str() << std::endl;
+ *cont->OFS << " Output: " << output << std::endl;
+ *cont->OFS << " Errors: " << errors << std::endl;
if ( ! res )
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Problem running coverage on file: " << it->c_str() << std::endl);
+ "Problem running coverage on file: " << *it << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << errors << std::endl);
cont->Error ++;
@@ -1441,7 +1517,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
if ( retVal != 0 )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
- << retVal << " while processing: " << it->c_str() << std::endl);
+ << retVal << " while processing: " << *it << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Command produced error: " << cont->Error << std::endl);
}
@@ -1462,7 +1538,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
std::string sourceFile;
std::string lcovFile;
- if ( line->size() == 0 )
+ if (line->empty())
{
// Ignore empty line
}
@@ -1551,7 +1627,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
cnt ++;
// Skip empty lines
- if ( !nl.size() )
+ if (nl.empty())
{
continue;
}
@@ -1609,7 +1685,7 @@ int cmCTestCoverageHandler::HandleLCovCoverage(
}
}
- cmSystemTools::ChangeDirectory(currentDirectory.c_str());
+ cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -1653,7 +1729,7 @@ void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
gl.RecurseThroughSymlinksOff();
std::string prevBinaryDir;
cmSystemTools::ChangeDirectory(
- this->CTest->GetCTestConfiguration("BuildDirectory").c_str());
+ this->CTest->GetCTestConfiguration("BuildDirectory"));
// Run profmerge to merge all *.dyn files into dpi files
cmSystemTools::RunSingleCommand("profmerge");
@@ -1683,7 +1759,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
gl.FindFiles(daGlob);
std::vector<std::string> files = gl.GetFiles();
- if ( files.size() == 0 )
+ if (files.empty())
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Cannot find any Python Trace.py coverage files."
@@ -1696,9 +1772,9 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
std::string tempDir = testingDir + "/CoverageInfo";
std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::MakeDirectory(tempDir.c_str());
- cmSystemTools::ChangeDirectory(tempDir.c_str());
+ cmSystemTools::ChangeDirectory(tempDir);
- cmSystemTools::ChangeDirectory(currentDirectory.c_str());
+ cmSystemTools::ChangeDirectory(currentDirectory);
std::vector<std::string>::iterator fileIt;
int file_count = 0;
@@ -1714,7 +1790,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
}
std::string actualSourceFile
- = cmSystemTools::CollapseFullPath(fileName.c_str());
+ = cmSystemTools::CollapseFullPath(fileName);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" Check coverage for file: " << actualSourceFile
<< std::endl);
@@ -1737,7 +1813,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
cnt ++;
// Skip empty lines
- if ( !nl.size() )
+ if (nl.empty())
{
continue;
}
@@ -1802,7 +1878,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
}
++ file_count;
}
- cmSystemTools::ChangeDirectory(currentDirectory.c_str());
+ cmSystemTools::ChangeDirectory(currentDirectory);
return file_count;
}
@@ -2000,7 +2076,7 @@ int cmCTestCoverageHandler::RunBullseyeCommand(
std::string& outputFile)
{
std::string program = cmSystemTools::FindProgram(cmd);
- if(program.size() == 0)
+ if(program.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find :" << cmd << "\n");
return 0;
@@ -2107,7 +2183,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
while(cmSystemTools::GetLineFromStream(fin, stdline))
{
// if we have a line of output from stdout
- if(stdline.size())
+ if(!stdline.empty())
{
// parse the comma separated output
this->ParseBullsEyeCovsrcLine(stdline,
@@ -2132,7 +2208,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
file += "/";
file += sourceFile;
}
- file = cmSystemTools::CollapseFullPath(file.c_str());
+ file = cmSystemTools::CollapseFullPath(file);
bool shouldIDoCoverage
= this->ShouldIDoCoverage(file.c_str(),
cont->SourceDir.c_str(),
@@ -2422,11 +2498,7 @@ void cmCTestCoverageHandler::LoadLabels(const char* dir)
// Label the source with the target labels.
LabelSet& labelSet = this->SourceLabels[source];
- for(std::vector<int>::const_iterator li = targetLabels.begin();
- li != targetLabels.end(); ++li)
- {
- labelSet.insert(*li);
- }
+ labelSet.insert(targetLabels.begin(), targetLabels.end());
}
}
}
@@ -2524,7 +2596,7 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
}
}
- if(extraMatches.size())
+ if(!extraMatches.empty())
{
for(cmCTestCoverageHandlerContainer::TotalCoverageMap::iterator i =
cont->TotalCoverage.begin(); i != cont->TotalCoverage.end(); ++i)
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index d0f274c..4aec795 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -84,6 +84,12 @@ private:
//! Handle coverage for Jacoco
int HandleJacocoCoverage(cmCTestCoverageHandlerContainer* cont);
+ //! Handle coverage for Delphi (Pascal)
+ int HandleDelphiCoverage(cmCTestCoverageHandlerContainer* cont);
+
+ //! Handle coverage for Jacoco
+ int HandleBlanketJSCoverage(cmCTestCoverageHandlerContainer* cont);
+
//! Handle coverage using Bullseye
int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont);
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
new file mode 100644
index 0000000..b4c0137
--- /dev/null
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -0,0 +1,282 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmCTestCurl.h"
+
+#include "cmSystemTools.h"
+#include "cmCTest.h"
+
+cmCTestCurl::cmCTestCurl(cmCTest* ctest)
+{
+ this->CTest = ctest;
+ this->SetProxyType();
+ this->UseHttp10 = false;
+ // In windows, this will init the winsock stuff
+ ::curl_global_init(CURL_GLOBAL_ALL);
+ // default is to verify https
+ this->VerifyPeerOff = false;
+ this->VerifyHostOff = false;
+ this->TimeOutSeconds = 0;
+ this->Curl = curl_easy_init();
+}
+
+cmCTestCurl::~cmCTestCurl()
+{
+ ::curl_easy_cleanup(this->Curl);
+ ::curl_global_cleanup();
+}
+
+std::string cmCTestCurl::Escape(std::string const& source)
+{
+ char* data1 = curl_easy_escape(this->Curl, source.c_str(), 0);
+ std::string ret = data1;
+ curl_free(data1);
+ return ret;
+}
+
+namespace
+{
+static size_t
+curlWriteMemoryCallback(void *ptr, size_t size, size_t nmemb,
+ void *data)
+{
+ int realsize = (int)(size * nmemb);
+
+ std::vector<char> *vec
+ = static_cast<std::vector<char>* >(data);
+ const char* chPtr = static_cast<char*>(ptr);
+ vec->insert(vec->end(), chPtr, chPtr + realsize);
+ return realsize;
+}
+
+static size_t
+curlDebugCallback(CURL *, curl_infotype, char *chPtr,
+ size_t size, void *data)
+{
+ std::vector<char> *vec
+ = static_cast<std::vector<char>* >(data);
+ vec->insert(vec->end(), chPtr, chPtr + size);
+
+ return size;
+}
+
+}
+
+void cmCTestCurl::SetCurlOptions(std::vector<std::string> const& args)
+{
+ for( std::vector<std::string>::const_iterator i = args.begin();
+ i != args.end(); ++i)
+ {
+ if(*i == "CURLOPT_SSL_VERIFYPEER_OFF")
+ {
+ this->VerifyPeerOff = true;
+ }
+ if(*i == "CURLOPT_SSL_VERIFYHOST_OFF")
+ {
+ this->VerifyHostOff = true;
+ }
+ }
+}
+
+bool cmCTestCurl::InitCurl()
+{
+ if(!this->Curl)
+ {
+ return false;
+ }
+ if(this->VerifyPeerOff)
+ {
+ curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYPEER, 0);
+ }
+ if(this->VerifyHostOff)
+ {
+ curl_easy_setopt(this->Curl, CURLOPT_SSL_VERIFYHOST, 0);
+ }
+ if(this->HTTPProxy.size())
+ {
+ curl_easy_setopt(this->Curl, CURLOPT_PROXY, this->HTTPProxy.c_str());
+ curl_easy_setopt(this->Curl, CURLOPT_PROXYTYPE, this->HTTPProxyType);
+ if (this->HTTPProxyAuth.size() > 0)
+ {
+ curl_easy_setopt(this->Curl, CURLOPT_PROXYUSERPWD,
+ this->HTTPProxyAuth.c_str());
+ }
+ }
+ if(this->UseHttp10)
+ {
+ curl_easy_setopt(this->Curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
+ }
+ // enable HTTP ERROR parsing
+ curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
+ return true;
+}
+
+
+bool cmCTestCurl::UploadFile(std::string const& local_file,
+ std::string const& url,
+ std::string const& fields,
+ std::string& response)
+{
+ response = "";
+ if(!this->InitCurl())
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
+ return false;
+ }
+ /* enable uploading */
+ curl_easy_setopt(this->Curl, CURLOPT_UPLOAD, 1);
+ // if there is little to no activity for too long stop submitting
+ if(this->TimeOutSeconds)
+ {
+ ::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_LIMIT, 1);
+ ::curl_easy_setopt(this->Curl, CURLOPT_LOW_SPEED_TIME,
+ this->TimeOutSeconds);
+ }
+ /* HTTP PUT please */
+ ::curl_easy_setopt(this->Curl, CURLOPT_PUT, 1);
+ ::curl_easy_setopt(this->Curl, CURLOPT_VERBOSE, 1);
+
+ FILE* ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
+ if(!ftpfile)
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Could not open file for upload: " << local_file << "\n");
+ return false;
+ }
+ // set the url
+ std::string upload_url = url;
+ upload_url += "?";
+ upload_url += fields;
+ ::curl_easy_setopt(this->Curl, CURLOPT_URL, upload_url.c_str());
+ // now specify which file to upload
+ ::curl_easy_setopt(this->Curl, CURLOPT_INFILE, ftpfile);
+ unsigned long filelen = cmSystemTools::FileLength(local_file);
+ // and give the size of the upload (optional)
+ ::curl_easy_setopt(this->Curl, CURLOPT_INFILESIZE,
+ static_cast<long>(filelen));
+ ::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
+ curlWriteMemoryCallback);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
+ curlDebugCallback);
+ std::vector<char> responseData;
+ std::vector<char> debugData;
+ ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void *)&debugData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
+ // Now run off and do what you've been told!
+ ::curl_easy_perform(this->Curl);
+ ::fclose(ftpfile);
+
+ if ( responseData.size() > 0 )
+ {
+ response = std::string(responseData.begin(), responseData.end());
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Curl response: [" << response << "]\n");
+ }
+ std::string curlDebug;
+ if ( debugData.size() > 0 )
+ {
+ curlDebug = std::string(debugData.begin(), debugData.end());
+ cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
+ }
+ if(response.size() == 0)
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "No response from server.\n" <<
+ curlDebug);
+ return false;
+ }
+ return true;
+}
+
+bool cmCTestCurl::HttpRequest(std::string const& url,
+ std::string const& fields,
+ std::string& response)
+{
+ response = "";
+ cmCTestLog(this->CTest, DEBUG, "HttpRequest\n"
+ << "url: " << url << "\n"
+ << "fields " << fields << "\n");
+ if(!this->InitCurl())
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Initialization of curl failed");
+ return false;
+ }
+ curl_easy_setopt(this->Curl, CURLOPT_POST, 1);
+ curl_easy_setopt(this->Curl, CURLOPT_POSTFIELDS, fields.c_str());
+ ::curl_easy_setopt(this->Curl, CURLOPT_URL, url.c_str());
+ ::curl_easy_setopt(this->Curl, CURLOPT_FOLLOWLOCATION, 1);
+ //set response options
+ ::curl_easy_setopt(this->Curl, CURLOPT_WRITEFUNCTION,
+ curlWriteMemoryCallback);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGFUNCTION,
+ curlDebugCallback);
+ std::vector<char> responseData;
+ std::vector<char> debugData;
+ ::curl_easy_setopt(this->Curl, CURLOPT_FILE, (void *)&responseData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_DEBUGDATA, (void *)&debugData);
+ ::curl_easy_setopt(this->Curl, CURLOPT_FAILONERROR, 1);
+
+ CURLcode res = ::curl_easy_perform(this->Curl);
+
+ if ( responseData.size() > 0 )
+ {
+ response = std::string(responseData.begin(), responseData.end());
+ cmCTestLog(this->CTest, DEBUG, "Curl response: [" << response << "]\n");
+ }
+ if ( debugData.size() > 0 )
+ {
+ std::string curlDebug = std::string(debugData.begin(), debugData.end());
+ cmCTestLog(this->CTest, DEBUG, "Curl debug: [" << curlDebug << "]\n");
+ }
+ cmCTestLog(this->CTest, DEBUG, "Curl res: " << res << "\n");
+ return (res == 0);
+}
+
+void cmCTestCurl::SetProxyType()
+{
+ if ( cmSystemTools::GetEnv("HTTP_PROXY") )
+ {
+ this->HTTPProxy = cmSystemTools::GetEnv("HTTP_PROXY");
+ if ( cmSystemTools::GetEnv("HTTP_PROXY_PORT") )
+ {
+ this->HTTPProxy += ":";
+ this->HTTPProxy += cmSystemTools::GetEnv("HTTP_PROXY_PORT");
+ }
+ if ( cmSystemTools::GetEnv("HTTP_PROXY_TYPE") )
+ {
+ // this is the default
+ this->HTTPProxyType = CURLPROXY_HTTP;
+ std::string type = cmSystemTools::GetEnv("HTTP_PROXY_TYPE");
+ // HTTP/SOCKS4/SOCKS5
+ if ( type == "HTTP" )
+ {
+ this->HTTPProxyType = CURLPROXY_HTTP;
+ }
+ else if ( type == "SOCKS4" )
+ {
+ this->HTTPProxyType = CURLPROXY_SOCKS4;
+ }
+ else if ( type == "SOCKS5" )
+ {
+ this->HTTPProxyType = CURLPROXY_SOCKS5;
+ }
+ }
+ if ( cmSystemTools::GetEnv("HTTP_PROXY_USER") )
+ {
+ this->HTTPProxyAuth = cmSystemTools::GetEnv("HTTP_PROXY_USER");
+ }
+ if ( cmSystemTools::GetEnv("HTTP_PROXY_PASSWD") )
+ {
+ this->HTTPProxyAuth += ":";
+ this->HTTPProxyAuth += cmSystemTools::GetEnv("HTTP_PROXY_PASSWD");
+ }
+ }
+}
diff --git a/Source/CTest/cmCTestCurl.h b/Source/CTest/cmCTestCurl.h
new file mode 100644
index 0000000..0737bb6
--- /dev/null
+++ b/Source/CTest/cmCTestCurl.h
@@ -0,0 +1,54 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmCTestCurl_h
+#define cmCTestCurl_h
+
+#include "cmStandardIncludes.h"
+
+#include "cm_curl.h"
+
+class cmCTest;
+
+class cmCTestCurl
+{
+public:
+ cmCTestCurl(cmCTest*);
+ ~cmCTestCurl();
+ bool UploadFile(std::string const& url,
+ std::string const& file,
+ std::string const& fields,
+ std::string& response);
+ bool HttpRequest(std::string const& url,
+ std::string const& fields,
+ std::string& response);
+ // currently only supports CURLOPT_SSL_VERIFYPEER_OFF
+ // and CURLOPT_SSL_VERIFYHOST_OFF
+ void SetCurlOptions(std::vector<std::string> const& args);
+ void SetUseHttp10On() { this->UseHttp10 = true;}
+ void SetTimeOutSeconds(int s) { this->TimeOutSeconds = s;}
+ std::string Escape(std::string const& source);
+protected:
+ void SetProxyType();
+ bool InitCurl();
+private:
+ cmCTest* CTest;
+ CURL* Curl;
+ std::string HTTPProxyAuth;
+ std::string HTTPProxy;
+ curl_proxytype HTTPProxyType;
+ bool VerifyHostOff;
+ bool VerifyPeerOff;
+ bool UseHttp10;
+ int TimeOutSeconds;
+};
+
+#endif
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
index 5ddef01..e175592 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -24,7 +24,7 @@ bool cmCTestEmptyBinaryDirectoryCommand
if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) )
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "problem removing the binary directory: " << args[0];
this->SetError(ostr.str());
return false;
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index aaa01b2..98bc9d7 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -158,7 +158,7 @@ std::string cmCTestGIT::FindTopDir()
{
top_dir += "/";
top_dir += cdup;
- top_dir = cmSystemTools::CollapseFullPath(top_dir.c_str());
+ top_dir = cmSystemTools::CollapseFullPath(top_dir);
}
return top_dir;
}
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index 2df2229..13c8ca5 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -103,7 +103,7 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
<< std::endl;);
return false;
}
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << name;
if ( this->SubmitIndex > 0 )
{
@@ -142,7 +142,7 @@ bool cmCTestGenericHandler::StartLogFile(const char* name,
"Cannot create log file without providing the name" << std::endl;);
return false;
}
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "Last" << name;
if ( this->SubmitIndex > 0 )
{
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 0e29160..b886777 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -46,7 +46,7 @@ bool cmCTestHandlerCommand
if(!this->CheckArgumentKeyword(args[i]) &&
!this->CheckArgumentValue(args[i]))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
@@ -137,16 +137,16 @@ bool cmCTestHandlerCommand
}
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(
- this->CTest->GetCTestConfiguration("BuildDirectory").c_str());
+ this->CTest->GetCTestConfiguration("BuildDirectory"));
int res = handler->ProcessHandler();
if ( this->Values[ct_RETURN_VALUE] && *this->Values[ct_RETURN_VALUE])
{
- cmOStringStream str;
+ std::ostringstream str;
str << res;
this->Makefile->AddDefinition(
this->Values[ct_RETURN_VALUE], str.str().c_str());
}
- cmSystemTools::ChangeDirectory(current_dir.c_str());
+ cmSystemTools::ChangeDirectory(current_dir);
return true;
}
@@ -183,7 +183,7 @@ bool cmCTestHandlerCommand::CheckArgumentValue(std::string const& arg)
unsigned int k = this->ArgumentIndex;
if(this->Values[k])
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Called with more than one value for " << this->Arguments[k];
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index 10a5199..62fa2be 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -21,6 +21,12 @@
#include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
+#ifdef _WIN32
+#include <io.h> // for _setmode
+#include <fcntl.h> // for _O_BINARY
+#include <stdio.h> // for std{out,err} and fileno
+#endif
+
//----------------------------------------------------------------------------
cmCTestLaunch::cmCTestLaunch(int argc, const char* const* argv)
{
@@ -48,8 +54,8 @@ cmCTestLaunch::~cmCTestLaunch()
cmsysProcess_Delete(this->Process);
if(!this->Passthru)
{
- cmSystemTools::RemoveFile(this->LogOut.c_str());
- cmSystemTools::RemoveFile(this->LogErr.c_str());
+ cmSystemTools::RemoveFile(this->LogOut);
+ cmSystemTools::RemoveFile(this->LogErr);
}
}
@@ -259,6 +265,13 @@ void cmCTestLaunch::RunChild()
std::ios::out | std::ios::binary);
}
+#ifdef _WIN32
+ // Do this so that newline transformation is not done when writing to cout
+ // and cerr below.
+ _setmode(fileno(stdout), _O_BINARY);
+ _setmode(fileno(stderr), _O_BINARY);
+#endif
+
// Run the real command.
cmsysProcess_Execute(cp);
@@ -434,8 +447,8 @@ void cmCTestLaunch::WriteXMLAction(std::ostream& fxml)
// If file is in source tree use its relative location.
if(cmSystemTools::FileIsFullPath(this->SourceDir.c_str()) &&
cmSystemTools::FileIsFullPath(source.c_str()) &&
- cmSystemTools::IsSubDirectory(source.c_str(),
- this->SourceDir.c_str()))
+ cmSystemTools::IsSubDirectory(source,
+ this->SourceDir))
{
source = cmSystemTools::RelativePath(this->SourceDir.c_str(),
source.c_str());
@@ -707,7 +720,7 @@ bool cmCTestLaunch::Match(std::string const& line,
//----------------------------------------------------------------------------
bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const
{
- if(this->OptionFilterPrefix.size() && cmSystemTools::StringStartsWith(
+ if(!this->OptionFilterPrefix.empty() && cmSystemTools::StringStartsWith(
line.c_str(), this->OptionFilterPrefix.c_str()))
{
return true;
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 4835010..d4ff24f 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -75,7 +75,7 @@ public:
this->ParseError(atts);
}
// Create the log
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << name << ":\n";
int i = 0;
for(; atts[i] != 0; i+=2)
@@ -198,7 +198,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
{
std::vector<std::string>::size_type pp;
std::string index;
- cmOStringStream stream;
+ std::ostringstream stream;
std::string memcheckcommand
= cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
stream << test;
@@ -223,7 +223,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
this->MemoryTesterEnvironmentVariable;
for ( pp = 0; pp < this->MemoryTesterOptions.size(); pp ++ )
{
- if(memTesterEnvironmentVariable.size())
+ if(!memTesterEnvironmentVariable.empty())
{
// If we are using env to pass options, append all the options to
// this string with space separation.
@@ -241,7 +241,7 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
}
// if this is an env option type, then add the env string as a single
// argument.
- if(memTesterEnvironmentVariable.size())
+ if(!memTesterEnvironmentVariable.empty())
{
std::string::size_type pos = memTesterEnvironmentVariable.find("??");
if (pos != std::string::npos)
@@ -592,7 +592,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
this->MemoryTesterStyle = cmCTestMemCheckHandler::VALGRIND;
}
}
- if(this->MemoryTester.size() == 0 )
+ if(this->MemoryTester.empty())
{
cmCTestLog(this->CTest, WARNING,
"Memory checker (MemoryCheckCommand) "
@@ -834,7 +834,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
int defects = 0;
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
- cmOStringStream ostr;
+ std::ostringstream ostr;
log = "";
for( std::vector<std::string>::iterator i = lines.begin();
i != lines.end(); ++i)
@@ -848,10 +848,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckSanitizerOutput(
{
resultFound = sanitizerWarning.match(1);
}
- if(resultFound.size())
+ if(!resultFound.empty())
{
std::vector<int>::size_type idx = this->FindOrAddWarning(resultFound);
- if(result.size() == 0 || idx > result.size()-1)
+ if(result.empty() || idx > result.size()-1)
{
result.push_back(1);
}
@@ -878,7 +878,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
{
std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
- cmOStringStream ostr;
+ std::ostringstream ostr;
log = "";
cmsys::RegularExpression pfW("^\\[[WEI]\\] ([A-Z][A-Z][A-Z][A-Z]*): ");
@@ -941,7 +941,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
std::string::size_type cc;
- cmOStringStream ostr;
+ std::ostringstream ostr;
log = "";
int defects = 0;
@@ -1197,11 +1197,15 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
<< res.Name << std::endl);
std::vector<std::string> files;
this->TestOutputFileNames(test, files);
- if ( files.size() == 0 )
+ if (files.empty())
{
return;
}
std::string ofile = files[0];
+ if ( ofile.empty() )
+ {
+ return;
+ }
// put a scope around this to close ifs so the file can be removed
{
cmsys::ifstream ifs(ofile.c_str());
@@ -1221,10 +1225,10 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
}
}
cmSystemTools::Delay(1000);
- cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str());
+ cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
<< this->BoundsCheckerDPBDFile << std::endl);
- cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str());
+ cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
<< this->BoundsCheckerXMLFile << std::endl);
}
@@ -1255,7 +1259,7 @@ cmCTestMemCheckHandler::AppendMemTesterOutput(cmCTestTestResult& res,
}
if(this->LogWithPID)
{
- cmSystemTools::RemoveFile(ofile.c_str());
+ cmSystemTools::RemoveFile(ofile);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "<< ofile <<"\n");
}
}
@@ -1265,7 +1269,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames(int test,
files)
{
std::string index;
- cmOStringStream stream;
+ std::ostringstream stream;
stream << test;
index = stream.str();
std::string ofile = this->MemoryTesterOutputFile;
@@ -1276,7 +1280,7 @@ void cmCTestMemCheckHandler::TestOutputFileNames(int test,
ofile += ".*";
cmsys::Glob g;
g.FindFiles(ofile);
- if(g.GetFiles().size() == 0)
+ if(g.GetFiles().empty())
{
std::string log = "Cannot find memory tester output file: "
+ ofile;
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 7ba434c..f9e8a3c 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -92,7 +92,7 @@ void cmCTestMultiProcessHandler::RunTests()
}
this->TestHandler->SetMaxIndex(this->FindMaxIndex());
this->StartNextTests();
- while(this->Tests.size() != 0)
+ while(!this->Tests.empty())
{
if(this->StopTimePassed)
{
@@ -123,7 +123,7 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
testRun->SetTestProperties(this->Properties[test]);
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->Properties[test]->Directory.c_str());
+ cmSystemTools::ChangeDirectory(this->Properties[test]->Directory);
// Lock the resources we'll be using
this->LockResources(test);
@@ -156,18 +156,15 @@ void cmCTestMultiProcessHandler::StartTestProcess(int test)
this->Failed->push_back(this->Properties[test]->Name);
delete testRun;
}
- cmSystemTools::ChangeDirectory(current_dir.c_str());
+ cmSystemTools::ChangeDirectory(current_dir);
}
//---------------------------------------------------------
void cmCTestMultiProcessHandler::LockResources(int index)
{
- for(std::set<std::string>::iterator i =
- this->Properties[index]->LockedResources.begin();
- i != this->Properties[index]->LockedResources.end(); ++i)
- {
- this->LockedResources.insert(*i);
- }
+ this->LockedResources.insert(
+ this->Properties[index]->LockedResources.begin(),
+ this->Properties[index]->LockedResources.end());
}
//---------------------------------------------------------
@@ -268,7 +265,7 @@ void cmCTestMultiProcessHandler::StartNextTests()
bool cmCTestMultiProcessHandler::CheckOutput()
{
// no more output we are done
- if(this->RunningTests.size() == 0)
+ if(this->RunningTests.empty())
{
return false;
}
@@ -334,7 +331,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
{
if(line == "---") break;
std::vector<cmsys::String> parts =
- cmSystemTools::SplitString(line.c_str(), ' ');
+ cmSystemTools::SplitString(line, ' ');
//Format: <name> <previous_runs> <avg_cost>
if(parts.size() < 3) break;
@@ -357,7 +354,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
}
}
fin.close();
- cmSystemTools::RemoveFile(fname.c_str());
+ cmSystemTools::RemoveFile(fname);
}
// Add all tests not previously listed in the file
@@ -393,7 +390,7 @@ void cmCTestMultiProcessHandler::ReadCostData()
if(line == "---") break;
std::vector<cmsys::String> parts =
- cmSystemTools::SplitString(line.c_str(), ' ');
+ cmSystemTools::SplitString(line, ' ');
// Probably an older version of the file, will be fixed next run
if(parts.size() < 3)
@@ -499,11 +496,7 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
i != previousSet.end(); ++i)
{
TestSet const& dependencies = this->Tests[*i];
- for(TestSet::const_iterator j = dependencies.begin();
- j != dependencies.end(); ++j)
- {
- currentSet.insert(*j);
- }
+ currentSet.insert(dependencies.begin(), dependencies.end());
}
for(TestSet::const_iterator i = currentSet.begin();
@@ -526,11 +519,8 @@ void cmCTestMultiProcessHandler::CreateParallelTestCostList()
TestList sortedCopy;
- for(TestSet::const_iterator j = currentSet.begin();
- j != currentSet.end(); ++j)
- {
- sortedCopy.push_back(*j);
- }
+ sortedCopy.insert(sortedCopy.end(),
+ currentSet.begin(), currentSet.end());
std::stable_sort(sortedCopy.begin(), sortedCopy.end(), comp);
@@ -621,7 +611,7 @@ void cmCTestMultiProcessHandler::MarkFinished()
{
std::string fname = this->CTest->GetBinaryDir()
+ "/Testing/Temporary/CTestCheckpoint.txt";
- cmSystemTools::RemoveFile(fname.c_str());
+ cmSystemTools::RemoveFile(fname);
}
//---------------------------------------------------------
@@ -639,14 +629,14 @@ void cmCTestMultiProcessHandler::PrintTestList()
//push working dir
std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(p.Directory.c_str());
+ cmSystemTools::ChangeDirectory(p.Directory);
cmCTestRunTest testRun(this->TestHandler);
testRun.SetIndex(p.Index);
testRun.SetTestProperties(&p);
testRun.ComputeArguments(); //logs the command in verbose mode
- if(p.Labels.size()) //print the labels
+ if(!p.Labels.empty()) //print the labels
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Labels:");
}
@@ -655,7 +645,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " " << *label);
}
- if(p.Labels.size()) //print the labels
+ if(!p.Labels.empty()) //print the labels
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl);
}
@@ -668,7 +658,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Test");
}
- cmOStringStream indexStr;
+ std::ostringstream indexStr;
indexStr << " #" << p.Index << ":";
cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
@@ -676,7 +666,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl);
//pop working dir
- cmSystemTools::ChangeDirectory(current_dir.c_str());
+ cmSystemTools::ChangeDirectory(current_dir);
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl << "Total Tests: "
@@ -693,7 +683,7 @@ void cmCTestMultiProcessHandler::PrintLabels()
allLabels.insert(p.Labels.begin(), p.Labels.end());
}
- if(allLabels.size())
+ if(!allLabels.empty())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "All Labels:" << std::endl);
}
@@ -735,7 +725,7 @@ void cmCTestMultiProcessHandler::CheckResume()
}
else if(cmSystemTools::FileExists(fname.c_str(), true))
{
- cmSystemTools::RemoveFile(fname.c_str());
+ cmSystemTools::RemoveFile(fname);
}
}
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 0bb1a99..31002a6 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -324,7 +324,7 @@ private:
//----------------------------------------------------------------------------
void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions)
{
- if(P4Options.size() == 0)
+ if(P4Options.empty())
{
const char* p4 = this->CommandLineTool.c_str();
P4Options.push_back(p4);
@@ -349,11 +349,7 @@ void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions)
std::vector<std::string> args =
cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<std::string>::const_iterator ai = args.begin();
- ai != args.end(); ++ai)
- {
- P4Options.push_back(*ai);
- }
+ P4Options.insert(P4Options.end(), args.begin(), args.end());
}
CommandOptions.clear();
@@ -451,7 +447,7 @@ void cmCTestP4::LoadRevisions()
ChangeLists.clear();
this->RunChild(&p4_changes[0], &out, &err);
- if(ChangeLists.size() == 0)
+ if(ChangeLists.empty())
return;
//p4 describe -s ...@1111111,2222222
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index bdf9b9c..7afbe04 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -54,7 +54,7 @@ bool cmCTestRunScriptCommand
int ret;
cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np,
&ret);
- cmOStringStream str;
+ std::ostringstream str;
str << ret;
this->Makefile->AddDefinition(returnVariable, str.str().c_str());
}
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index bdd8c02..314c8ad 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -116,10 +116,10 @@ void cmCTestRunTest::CompressOutput()
unsigned char *encoded_buffer
= new unsigned char[static_cast<int>(outSize * 1.5)];
- unsigned long rlen
+ size_t rlen
= cmsysBase64_Encode(out, strm.total_out, encoded_buffer, 1);
- for(unsigned long i = 0; i < rlen; i++)
+ for(size_t i = 0; i < rlen; i++)
{
this->CompressedOutput += encoded_buffer[i];
}
@@ -155,7 +155,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
std::string> >::iterator passIt;
bool forceFail = false;
bool outputTestErrorsToConsole = false;
- if ( this->TestProperties->RequiredRegularExpressions.size() > 0 )
+ if (!this->TestProperties->RequiredRegularExpressions.empty())
{
bool found = false;
for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
@@ -184,7 +184,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
}
reason += "]";
}
- if ( this->TestProperties->ErrorRegularExpressions.size() > 0 )
+ if (!this->TestProperties->ErrorRegularExpressions.empty())
{
for ( passIt = this->TestProperties->ErrorRegularExpressions.begin();
passIt != this->TestProperties->ErrorRegularExpressions.end();
@@ -280,12 +280,12 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
// Set the working directory to the tests directory
std::string oldpath = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(this->TestProperties->Directory.c_str());
+ cmSystemTools::ChangeDirectory(this->TestProperties->Directory);
this->DartProcessing();
// restore working directory
- cmSystemTools::ChangeDirectory(oldpath.c_str());
+ cmSystemTools::ChangeDirectory(oldpath);
// if this is doing MemCheck then all the output needs to be put into
@@ -318,7 +318,7 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
*this->TestHandler->LogFile
<< "----------------------------------------------------------"
<< std::endl;
- if(this->TestResult.Reason.size())
+ if(!this->TestResult.Reason.empty())
{
*this->TestHandler->LogFile << reasonType << ":\n"
<< this->TestResult.Reason << "\n";
@@ -670,7 +670,7 @@ bool cmCTestRunTest::ForkProcess(double testTimeOut, bool explicitTimeout,
cmSystemTools::SaveRestoreEnvironment sre;
#endif
- if (environment && environment->size()>0)
+ if (environment && !environment->empty())
{
cmSystemTools::AppendEnv(*environment);
}
@@ -694,7 +694,7 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
cmCTestLog(this->CTest, HANDLER_OUTPUT, "Test");
}
- cmOStringStream indexStr;
+ std::ostringstream indexStr;
indexStr << " #" << this->Index << ":";
cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index f050148..8184bb4 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -183,8 +183,8 @@ int cmCTestScriptHandler::ProcessHandler()
for (size_t i=0; i < this->ConfigurationScripts.size(); ++i)
{
// for each script run it
- res += this->RunConfigurationScript
- (cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i].c_str()),
+ res |= this->RunConfigurationScript
+ (cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
this->ScriptProcessScope[i]);
}
if ( res )
@@ -299,7 +299,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
cmsysProcess_Delete(cp);
if(failed)
{
- cmOStringStream message;
+ std::ostringstream message;
message << "Error running command: [";
message << result << "] ";
for(std::vector<const char*>::iterator i = argv.begin();
@@ -415,7 +415,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
this->UpdateElapsedTime();
// add the script arg if defined
- if (script_arg.size())
+ if (!script_arg.empty())
{
this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str());
}
@@ -482,8 +482,8 @@ int cmCTestScriptHandler::ExtractVariables()
= this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
// add in translations for src and bin
- cmSystemTools::AddKeepPath(this->SourceDir.c_str());
- cmSystemTools::AddKeepPath(this->BinaryDir.c_str());
+ cmSystemTools::AddKeepPath(this->SourceDir);
+ cmSystemTools::AddKeepPath(this->BinaryDir);
this->CTestCmd
= this->Makefile->GetSafeDefinition("CTEST_COMMAND");
@@ -743,11 +743,11 @@ int cmCTestScriptHandler::BackupDirectories()
// if for some reason those directories exist then first delete them
if (cmSystemTools::FileExists(this->BackupSourceDir.c_str()))
{
- cmSystemTools::RemoveADirectory(this->BackupSourceDir.c_str());
+ cmSystemTools::RemoveADirectory(this->BackupSourceDir);
}
if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str()))
{
- cmSystemTools::RemoveADirectory(this->BackupBinaryDir.c_str());
+ cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
}
// first rename the src and binary directories
@@ -991,8 +991,8 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
// if all was succesful, delete the backup dirs to free up disk space
if (this->Backup)
{
- cmSystemTools::RemoveADirectory(this->BackupSourceDir.c_str());
- cmSystemTools::RemoveADirectory(this->BackupBinaryDir.c_str());
+ cmSystemTools::RemoveADirectory(this->BackupSourceDir);
+ cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
}
return 0;
@@ -1033,11 +1033,11 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
// if for some reason those directories exist then first delete them
if (cmSystemTools::FileExists(this->SourceDir.c_str()))
{
- cmSystemTools::RemoveADirectory(this->SourceDir.c_str());
+ cmSystemTools::RemoveADirectory(this->SourceDir);
}
if (cmSystemTools::FileExists(this->BinaryDir.c_str()))
{
- cmSystemTools::RemoveADirectory(this->BinaryDir.c_str());
+ cmSystemTools::RemoveADirectory(this->BinaryDir);
}
// rename the src and binary directories
rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str());
@@ -1100,7 +1100,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
const std::string& directoryPath)
{
cmsys::Directory directory;
- directory.Load(directoryPath.c_str());
+ directory.Load(directoryPath);
for(unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i)
{
@@ -1113,26 +1113,26 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
std::string fullPath = directoryPath + std::string("/") + path;
- bool isDirectory = cmSystemTools::FileIsDirectory(fullPath.c_str()) &&
- !cmSystemTools::FileIsSymlink(fullPath.c_str());
+ bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) &&
+ !cmSystemTools::FileIsSymlink(fullPath);
if(isDirectory)
{
- if(!cmSystemTools::RemoveADirectory(fullPath.c_str()))
+ if(!cmSystemTools::RemoveADirectory(fullPath))
{
return false;
}
}
else
{
- if(!cmSystemTools::RemoveFile(fullPath.c_str()))
+ if(!cmSystemTools::RemoveFile(fullPath))
{
return false;
}
}
}
- return cmSystemTools::RemoveADirectory(directoryPath.c_str());
+ return cmSystemTools::RemoveADirectory(directoryPath);
}
//-------------------------------------------------------------------------
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index da46f4a..8ea6cef 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -124,9 +124,9 @@ bool cmCTestStartCommand
{
return false;
}
- if(!cmSystemTools::FileIsDirectory(sourceDir.c_str()))
+ if(!cmSystemTools::FileIsDirectory(sourceDir))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given source path\n"
<< " " << sourceDir << "\n"
<< "which is not an existing directory. "
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 07a994d..cc3514f 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -27,7 +27,8 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
= this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
bool ctestDropSiteCDash
= this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
-
+ const char* ctestProjectName
+ = this->Makefile->GetDefinition("CTEST_PROJECT_NAME");
if ( !ctestDropMethod )
{
ctestDropMethod = "http";
@@ -43,7 +44,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
// error: CDash requires CTEST_DROP_LOCATION definition
// in CTestConfig.cmake
}
-
+ this->CTest->SetCTestConfiguration("ProjectName", ctestProjectName);
this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
this->CTest->SetCTestConfiguration("DropSite", ctestDropSite);
this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation);
@@ -74,13 +75,8 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
std::vector<std::string> notesFiles;
cmCTest::VectorOfStrings newNotesFiles;
cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
- std::vector<std::string>::iterator it;
- for ( it = notesFiles.begin();
- it != notesFiles.end();
- ++ it )
- {
- newNotesFiles.push_back(*it);
- }
+ newNotesFiles.insert(newNotesFiles.end(),
+ notesFiles.begin(), notesFiles.end());
this->CTest->GenerateNotesFile(newNotesFiles);
}
@@ -91,13 +87,8 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
std::vector<std::string> extraFiles;
cmCTest::VectorOfStrings newExtraFiles;
cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
- std::vector<std::string>::iterator it;
- for ( it = extraFiles.begin();
- it != extraFiles.end();
- ++ it )
- {
- newExtraFiles.push_back(*it);
- }
+ newExtraFiles.insert(newExtraFiles.end(),
+ extraFiles.begin(), extraFiles.end());
if ( !this->CTest->SubmitExtraFiles(newExtraFiles))
{
this->SetError("problem submitting extra files.");
@@ -154,44 +145,75 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
this->InternalTest ? "ON" : "OFF");
+ if (this->CDashUpload)
+ {
+ static_cast<cmCTestSubmitHandler*>(handler)->
+ SetOption("CDashUploadFile", this->CDashUploadFile.c_str());
+ static_cast<cmCTestSubmitHandler*>(handler)->
+ SetOption("CDashUploadType", this->CDashUploadType.c_str());
+ }
return handler;
}
+//----------------------------------------------------------------------------
+bool cmCTestSubmitCommand::InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ this->CDashUpload = !args.empty() && args[0] == "CDASH_UPLOAD";
+ return this->cmCTestHandlerCommand::InitialPass(args, status);
+}
//----------------------------------------------------------------------------
bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
{
- // Look for arguments specific to this command.
- if(arg == "PARTS")
+ if (this->CDashUpload)
{
- this->ArgumentDoing = ArgumentDoingParts;
- this->PartsMentioned = true;
- return true;
- }
+ if(arg == "CDASH_UPLOAD")
+ {
+ this->ArgumentDoing = ArgumentDoingCDashUpload;
+ return true;
+ }
- if(arg == "FILES")
- {
- this->ArgumentDoing = ArgumentDoingFiles;
- this->FilesMentioned = true;
- return true;
+ if(arg == "CDASH_UPLOAD_TYPE")
+ {
+ this->ArgumentDoing = ArgumentDoingCDashUploadType;
+ return true;
+ }
}
-
- if(arg == "RETRY_COUNT")
+ else
{
- this->ArgumentDoing = ArgumentDoingRetryCount;
- return true;
- }
+ // Look for arguments specific to this command.
+ if(arg == "PARTS")
+ {
+ this->ArgumentDoing = ArgumentDoingParts;
+ this->PartsMentioned = true;
+ return true;
+ }
- if(arg == "RETRY_DELAY")
- {
- this->ArgumentDoing = ArgumentDoingRetryDelay;
- return true;
- }
+ if(arg == "FILES")
+ {
+ this->ArgumentDoing = ArgumentDoingFiles;
+ this->FilesMentioned = true;
+ return true;
+ }
- if(arg == "INTERNAL_TEST_CHECKSUM")
- {
- this->InternalTest = true;
- return true;
+ if(arg == "RETRY_COUNT")
+ {
+ this->ArgumentDoing = ArgumentDoingRetryCount;
+ return true;
+ }
+
+ if(arg == "RETRY_DELAY")
+ {
+ this->ArgumentDoing = ArgumentDoingRetryDelay;
+ return true;
+ }
+
+ if(arg == "INTERNAL_TEST_CHECKSUM")
+ {
+ this->InternalTest = true;
+ return true;
+ }
}
// Look for other arguments.
@@ -212,7 +234,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Part name \"" << arg << "\" is invalid.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
this->ArgumentDoing = ArgumentDoingError;
@@ -229,7 +251,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "File \"" << filename << "\" does not exist. Cannot submit "
<< "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -250,6 +272,20 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
return true;
}
+ if(this->ArgumentDoing == ArgumentDoingCDashUpload)
+ {
+ this->ArgumentDoing = ArgumentDoingNone;
+ this->CDashUploadFile = arg;
+ return true;
+ }
+
+ if(this->ArgumentDoing == ArgumentDoingCDashUploadType)
+ {
+ this->ArgumentDoing = ArgumentDoingNone;
+ this->CDashUploadType = arg;
+ return true;
+ }
+
// Look for other arguments.
return this->Superclass::CheckArgumentValue(arg);
}
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index 3673fbd..19e8eaf 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -32,6 +32,7 @@ public:
this->InternalTest = false;
this->RetryCount = "";
this->RetryDelay = "";
+ this->CDashUpload = false;
}
/**
@@ -45,6 +46,9 @@ public:
return ni;
}
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status);
+
/**
* The name of the command as specified in CMakeList.txt.
*/
@@ -64,6 +68,8 @@ protected:
ArgumentDoingFiles,
ArgumentDoingRetryDelay,
ArgumentDoingRetryCount,
+ ArgumentDoingCDashUpload,
+ ArgumentDoingCDashUploadType,
ArgumentDoingLast2
};
@@ -74,6 +80,9 @@ protected:
cmCTest::SetOfStrings Files;
std::string RetryCount;
std::string RetryDelay;
+ bool CDashUpload;
+ std::string CDashUploadFile;
+ std::string CDashUploadType;
};
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 06fcb75..5b52df7 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -10,7 +10,8 @@
See the License for more information.
============================================================================*/
#include "cmCTestSubmitHandler.h"
-
+#include "cmCTestScriptHandler.h"
+#include "cmake.h"
#include "cmSystemTools.h"
#include "cmVersion.h"
#include "cmGeneratedFileStream.h"
@@ -23,8 +24,10 @@
// For XML-RPC submission
#include "cm_xmlrpc.h"
+#include <cm_jsoncpp_reader.h>
// For curl submission
-#include "cm_curl.h"
+#include "cmCurl.h"
+#include "cmCTestCurl.h"
#include <sys/stat.h>
@@ -61,7 +64,7 @@ private:
std::string GetCurrentValue()
{
std::string val;
- if(this->CurrentValue.size())
+ if(!this->CurrentValue.empty())
{
val.assign(&this->CurrentValue[0], this->CurrentValue.size());
}
@@ -234,9 +237,9 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
::curl_global_cleanup();
return false;
}
- unsigned long filelen = cmSystemTools::FileLength(local_file.c_str());
+ unsigned long filelen = cmSystemTools::FileLength(local_file);
- ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
+ ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
*this->LogFile << "\tUpload file: " << local_file << " to "
<< upload_as << std::endl;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
@@ -273,13 +276,13 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
// Now run off and do what you've been told!
res = ::curl_easy_perform(curl);
- if ( chunk.size() > 0 )
+ if (!chunk.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
}
- if ( chunkDebug.size() > 0 )
+ if (!chunkDebug.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
@@ -301,7 +304,7 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
<< error_buffer << std::endl
<< " Curl output was: ";
// avoid dereference of empty vector
- if(chunk.size())
+ if(!chunk.empty())
{
*this->LogFile << cmCTestLogWrite(&*chunk.begin(), chunk.size());
cmCTestLog(this->CTest, ERROR_MESSAGE, "CURL output: ["
@@ -363,6 +366,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
curl = curl_easy_init();
if(curl)
{
+ cmCurlSetCAInfo(curl);
if(verifyPeerOff)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
@@ -390,7 +394,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
break;
default:
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- if (this->HTTPProxyAuth.size() > 0)
+ if (!this->HTTPProxyAuth.empty())
{
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
this->HTTPProxyAuth.c_str());
@@ -475,9 +479,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
::curl_global_cleanup();
return false;
}
- unsigned long filelen = cmSystemTools::FileLength(local_file.c_str());
+ unsigned long filelen = cmSystemTools::FileLength(local_file);
- ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
+ ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
<< local_file << " to "
<< upload_as << " Size: " << filelen << std::endl);
@@ -523,14 +527,14 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
chunk.assign(mock_output.begin(), mock_output.end());
}
- if ( chunk.size() > 0 )
+ if (!chunk.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
this->ParseResponse(chunk);
}
- if ( chunkDebug.size() > 0 )
+ if (!chunkDebug.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size()) << "]"
@@ -567,7 +571,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
<< count << std::endl);
::fclose(ftpfile);
- ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
+ ftpfile = cmsys::SystemTools::Fopen(local_file, "rb");
::curl_easy_setopt(curl, CURLOPT_INFILE, ftpfile);
chunk.clear();
@@ -576,7 +580,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
res = ::curl_easy_perform(curl);
- if ( chunk.size() > 0 )
+ if (!chunk.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
@@ -605,7 +609,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
<< " Error message was: " << error_buffer
<< std::endl;
// avoid deref of begin for zero size array
- if(chunk.size())
+ if(!chunk.empty())
{
*this->LogFile << " Curl output was: "
<< cmCTestLogWrite(&*chunk.begin(), chunk.size())
@@ -697,7 +701,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
break;
default:
curl_easy_setopt(curl, CURLOPT_PROXYTYPE, CURLPROXY_HTTP);
- if (this->HTTPProxyAuth.size() > 0)
+ if (!this->HTTPProxyAuth.empty())
{
curl_easy_setopt(curl, CURLOPT_PROXYUSERPWD,
this->HTTPProxyAuth.c_str());
@@ -766,7 +770,7 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
<< std::endl
<< " Error message was: " << error_buffer
<< std::endl;
- if(chunk.size())
+ if(!chunk.empty())
{
*this->LogFile
<< " Curl output was: "
@@ -780,13 +784,13 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
return false;
}
- if ( chunk.size() > 0 )
+ if (!chunk.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL output: ["
<< cmCTestLogWrite(&*chunk.begin(), chunk.size()) << "]"
<< std::endl);
}
- if ( chunkDebug.size() > 0 )
+ if (!chunkDebug.empty())
{
cmCTestLog(this->CTest, DEBUG, "CURL debug output: ["
<< cmCTestLogWrite(&*chunkDebug.begin(), chunkDebug.size())
@@ -812,8 +816,8 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
const std::string& remoteprefix,
const std::string& url)
{
- if ( !scp_command.size() || !localprefix.size() ||
- !files.size() || !remoteprefix.size() || !url.size() )
+ if ( scp_command.empty() || localprefix.empty() ||
+ files.empty() || remoteprefix.empty() || url.empty() )
{
return 0;
}
@@ -912,8 +916,8 @@ bool cmCTestSubmitHandler::SubmitUsingCP(
const std::string& remoteprefix,
const std::string& destination)
{
- if ( !localprefix.size() ||
- !files.size() || !remoteprefix.size() || !destination.size() )
+ if ( localprefix.empty() ||
+ files.empty() || remoteprefix.empty() || destination.empty() )
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Missing arguments for submit via cp:\n"
@@ -931,13 +935,13 @@ bool cmCTestSubmitHandler::SubmitUsingCP(
cmSystemTools::ConvertToUnixSlashes(lfname);
lfname += "/" + *file;
std::string rfname = destination + "/" + remoteprefix + *file;
- cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str());
+ cmSystemTools::CopyFileAlways(lfname, rfname);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
<< lfname << " to "
<< rfname << std::endl);
}
std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
- cmSystemTools::Touch(tagDoneFile.c_str(), true);
+ cmSystemTools::Touch(tagDoneFile, true);
if ( problems )
{
return false;
@@ -1055,19 +1059,184 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&,
}
#endif
+void cmCTestSubmitHandler::ConstructCDashURL(std::string& dropMethod,
+ std::string& url)
+{
+ dropMethod = this->CTest->GetCTestConfiguration("DropMethod");
+ url = dropMethod;
+ url += "://";
+ if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
+ {
+ url += this->CTest->GetCTestConfiguration("DropSiteUser");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ this->CTest->GetCTestConfiguration("DropSiteUser").c_str());
+ if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
+ {
+ url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******");
+ }
+ url += "@";
+ }
+ url += this->CTest->GetCTestConfiguration("DropSite") +
+ this->CTest->GetCTestConfiguration("DropLocation");
+}
+
+
+int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file,
+ std::string const& typeString)
+{
+ if (file.empty())
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Upload file not specified\n");
+ return -1;
+ }
+ if (!cmSystemTools::FileExists(file))
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Upload file not found: '" << file << "'\n");
+ return -1;
+ }
+ cmCTestCurl curl(this->CTest);
+ std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
+ std::vector<std::string> args;
+ cmSystemTools::ExpandListArgument(curlopt, args);
+ curl.SetCurlOptions(args);
+ curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT);
+ std::string dropMethod;
+ std::string url;
+ this->ConstructCDashURL(dropMethod, url);
+ std::string::size_type pos = url.find("submit.php?");
+ url = url.substr(0, pos+10);
+ if ( ! (dropMethod == "http" || dropMethod == "https" ) )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Only http and https are supported for CDASH_UPLOAD\n");
+ return -1;
+ }
+ char md5sum[33];
+ md5sum[32] = 0;
+ cmSystemTools::ComputeFileMD5(file, md5sum);
+ // 1. request the buildid and check to see if the file
+ // has already been uploaded
+ // TODO I added support for subproject. You would need to add
+ // a "&subproject=subprojectname" to the first POST.
+ cmCTestScriptHandler* ch =
+ static_cast<cmCTestScriptHandler*>(this->CTest->GetHandler("script"));
+ cmake* cm = ch->GetCMake();
+ const char* subproject = cm->GetProperty("SubProject", cmProperty::GLOBAL);
+ // TODO: Encode values for a URL instead of trusting caller.
+ std::ostringstream str;
+ str << "project="
+ << curl.Escape(this->CTest->GetCTestConfiguration("ProjectName")) << "&";
+ if(subproject)
+ {
+ str << "subproject=" << curl.Escape(subproject) << "&";
+ }
+ str << "stamp=" << curl.Escape(this->CTest->GetCurrentTag()) << "-"
+ << curl.Escape(this->CTest->GetTestModelString()) << "&"
+ << "model=" << curl.Escape(this->CTest->GetTestModelString()) << "&"
+ << "build="
+ << curl.Escape(this->CTest->GetCTestConfiguration("BuildName")) << "&"
+ << "site="
+ << curl.Escape(this->CTest->GetCTestConfiguration("Site")) << "&"
+ << "track="
+ << curl.Escape(this->CTest->GetTestModelString()) << "&"
+ << "starttime=" << (int)cmSystemTools::GetTime() << "&"
+ << "endtime=" << (int)cmSystemTools::GetTime() << "&"
+ << "datafilesmd5[0]=" << md5sum << "&"
+ << "type=" << curl.Escape(typeString);
+ std::string fields = str.str();
+ cmCTestLog(this->CTest, DEBUG, "fields: " << fields << "\nurl:"
+ << url << "\nfile: " << file << "\n");
+ std::string response;
+ if(!curl.HttpRequest(url, fields, response))
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error in HttpRequest\n" << response);
+ return -1;
+ }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Request upload response: [" << response << "]\n");
+ Json::Value json;
+ Json::Reader reader;
+ if(!reader.parse(response, json))
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error parsing json string [" << response << "]\n"
+ << reader.getFormattedErrorMessages() << "\n");
+ return -1;
+ }
+ if(json["status"].asInt() != 0)
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Bad status returned from CDash: "
+ << json["status"].asInt());
+ return -1;
+ }
+ if(json["datafilesmd5"].isArray())
+ {
+ int datares = json["datafilesmd5"][0].asInt();
+ if(datares == 1)
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "File already exists on CDash, skip upload "
+ << file << "\n");
+ return 0;
+ }
+ }
+ else
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "bad datafilesmd5 value in response "
+ << response << "\n");
+ return -1;
+ }
+
+ std::string upload_as = cmSystemTools::GetFilenameName(file);
+ std::ostringstream fstr;
+ fstr << "type=" << curl.Escape(typeString) << "&"
+ << "md5=" << md5sum << "&"
+ << "filename=" << curl.Escape(upload_as) << "&"
+ << "buildid=" << json["buildid"].asString();
+ if(!curl.UploadFile(file, url, fstr.str(), response))
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error uploading to CDash. "
+ << file << " " << url << " " << fstr.str());
+ return -1;
+ }
+ if(!reader.parse(response, json))
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "error parsing json string [" << response << "]\n"
+ << reader.getFormattedErrorMessages() << "\n");
+ return -1;
+ }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Upload file response: [" << response << "]\n");
+ return 0;
+}
+
//----------------------------------------------------------------------------
int cmCTestSubmitHandler::ProcessHandler()
{
+ const char* cdashUploadFile = this->GetOption("CDashUploadFile");
+ const char* cdashUploadType = this->GetOption("CDashUploadType");
+ if(cdashUploadFile && cdashUploadType)
+ {
+ return this->HandleCDashUploadFile(cdashUploadFile, cdashUploadType);
+ }
std::string iscdash = this->CTest->GetCTestConfiguration("IsCDash");
// cdash does not need to trigger so just return true
- if(iscdash.size())
+ if(!iscdash.empty())
{
this->CDash = true;
}
const std::string &buildDirectory
= this->CTest->GetCTestConfiguration("BuildDirectory");
- if ( buildDirectory.size() == 0 )
+ if (buildDirectory.empty())
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find BuildDirectory key in the DartConfiguration.tcl"
@@ -1140,12 +1309,12 @@ int cmCTestSubmitHandler::ProcessHandler()
}
}
- if ( this->HTTPProxy.size() > 0 )
+ if (!this->HTTPProxy.empty())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use HTTP Proxy: "
<< this->HTTPProxy << std::endl);
}
- if ( this->FTPProxy.size() > 0 )
+ if (!this->FTPProxy.empty())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Use FTP Proxy: "
<< this->FTPProxy << std::endl);
@@ -1160,11 +1329,7 @@ int cmCTestSubmitHandler::ProcessHandler()
{
// Submit the explicitly selected files:
//
- cmCTest::SetOfStrings::const_iterator it;
- for (it = this->Files.begin(); it != this->Files.end(); ++it)
- {
- files.insert(*it);
- }
+ files.insert(this->Files.begin(), this->Files.end());
}
// Add to the list of files to submit from any selected, existing parts:
@@ -1219,11 +1384,7 @@ int cmCTestSubmitHandler::ProcessHandler()
// Submit files from this part.
std::vector<std::string> const& pfiles = this->CTest->GetSubmitFiles(p);
- for(std::vector<std::string>::const_iterator pi = pfiles.begin();
- pi != pfiles.end(); ++pi)
- {
- files.insert(*pi);
- }
+ files.insert(pfiles.begin(), pfiles.end());
}
if ( ofs )
@@ -1264,12 +1425,12 @@ int cmCTestSubmitHandler::ProcessHandler()
this->CTest->GetCTestConfiguration("DropSite") +
cmCTest::MakeURLSafe(
this->CTest->GetCTestConfiguration("DropLocation"));
- if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
+ if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT,
this->CTest->GetCTestConfiguration(
"DropSiteUser").c_str());
- if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
+ if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******");
}
@@ -1318,12 +1479,12 @@ int cmCTestSubmitHandler::ProcessHandler()
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Using HTTP submit method"
<< std::endl
<< " Drop site:" << url);
- if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
+ if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
{
url += this->CTest->GetCTestConfiguration("DropSiteUser");
cmCTestLog(this->CTest, HANDLER_OUTPUT,
this->CTest->GetCTestConfiguration("DropSiteUser").c_str());
- if ( this->CTest->GetCTestConfiguration("DropSitePassword").size() > 0 )
+ if (!this->CTest->GetCTestConfiguration("DropSitePassword").empty())
{
url += ":" + this->CTest->GetCTestConfiguration("DropSitePassword");
cmCTestLog(this->CTest, HANDLER_OUTPUT, ":******");
@@ -1408,7 +1569,7 @@ int cmCTestSubmitHandler::ProcessHandler()
{
std::string url;
std::string oldWorkingDirectory;
- if ( this->CTest->GetCTestConfiguration("DropSiteUser").size() > 0 )
+ if (!this->CTest->GetCTestConfiguration("DropSiteUser").empty())
{
url += this->CTest->GetCTestConfiguration("DropSiteUser") + "@";
}
@@ -1418,20 +1579,20 @@ int cmCTestSubmitHandler::ProcessHandler()
// change to the build directory so that we can uses a relative path
// on windows since scp dosn't support "c:" a drive in the path
oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(buildDirectory.c_str());
+ cmSystemTools::ChangeDirectory(buildDirectory);
if ( !this->SubmitUsingSCP(
this->CTest->GetCTestConfiguration("ScpCommand"),
"Testing/"+this->CTest->GetCurrentTag(), files, prefix, url) )
{
- cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
+ cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when submitting via SCP"
<< std::endl);
ofs << " Problems when submitting via SCP" << std::endl;
return -1;
}
- cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
+ cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
<< std::endl);
ofs << " Submission successful" << std::endl;
@@ -1447,7 +1608,7 @@ int cmCTestSubmitHandler::ProcessHandler()
// on windows since scp dosn't support "c:" a drive in the path
std::string
oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(buildDirectory.c_str());
+ cmSystemTools::ChangeDirectory(buildDirectory);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: "
<< buildDirectory << std::endl);
@@ -1457,14 +1618,14 @@ int cmCTestSubmitHandler::ProcessHandler()
prefix,
location) )
{
- cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
+ cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Problems when submitting via CP"
<< std::endl);
ofs << " Problems when submitting via cp" << std::endl;
return -1;
}
- cmSystemTools::ChangeDirectory(oldWorkingDirectory.c_str());
+ cmSystemTools::ChangeDirectory(oldWorkingDirectory);
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Submission successful"
<< std::endl);
ofs << " Submission successful" << std::endl;
@@ -1503,9 +1664,5 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts)
//----------------------------------------------------------------------------
void cmCTestSubmitHandler::SelectFiles(cmCTest::SetOfStrings const& files)
{
- cmCTest::SetOfStrings::const_iterator it;
- for (it = files.begin(); it != files.end(); ++it)
- {
- this->Files.insert(*it);
- }
+ this->Files.insert(files.begin(), files.end());
}
diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h
index accabd1..f9cd894 100644
--- a/Source/CTest/cmCTestSubmitHandler.h
+++ b/Source/CTest/cmCTestSubmitHandler.h
@@ -41,6 +41,11 @@ public:
/** Specify a set of files to submit. */
void SelectFiles(cmCTest::SetOfStrings const& files);
+ // handle the cdash file upload protocol
+ int HandleCDashUploadFile(std::string const& file, std::string const& type);
+
+ void ConstructCDashURL(std::string& dropMethod, std::string& url);
+
private:
void SetLogFile(std::ostream* ost) { this->LogFile = ost; }
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index 231f035..d209094 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -53,7 +53,7 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
if ( this->Values[ctt_START] || this->Values[ctt_END] ||
this->Values[ctt_STRIDE] )
{
- cmOStringStream testsToRunString;
+ std::ostringstream testsToRunString;
if ( this->Values[ctt_START] )
{
testsToRunString << this->Values[ctt_START];
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f21d166..925e3c9 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -93,12 +93,12 @@ bool cmCTestSubdirCommand
fname += *it;
}
- if ( !cmSystemTools::FileIsDirectory(fname.c_str()) )
+ if ( !cmSystemTools::FileIsDirectory(fname) )
{
// No subdirectory? So what...
continue;
}
- cmSystemTools::ChangeDirectory(fname.c_str());
+ cmSystemTools::ChangeDirectory(fname);
const char* testFilename;
if( cmSystemTools::FileExists("CTestTestfile.cmake") )
{
@@ -120,7 +120,7 @@ bool cmCTestSubdirCommand
bool readit =
this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),
fname.c_str());
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
if(!readit)
{
std::string m = "Could not find include file: ";
@@ -129,7 +129,7 @@ bool cmCTestSubdirCommand
return false;
}
}
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
return true;
}
@@ -175,7 +175,7 @@ bool cmCTestAddSubdirectoryCommand
}
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
std::string fname = cwd;
fname += "/";
fname += args[1];
@@ -185,7 +185,7 @@ bool cmCTestAddSubdirectoryCommand
// No subdirectory? So what...
return true;
}
- cmSystemTools::ChangeDirectory(fname.c_str());
+ cmSystemTools::ChangeDirectory(fname);
const char* testFilename;
if( cmSystemTools::FileExists("CTestTestfile.cmake") )
{
@@ -200,7 +200,7 @@ bool cmCTestAddSubdirectoryCommand
else
{
// No CTestTestfile? Who cares...
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
return true;
}
fname += "/";
@@ -208,7 +208,7 @@ bool cmCTestAddSubdirectoryCommand
bool readit =
this->Makefile->ReadListFile(this->Makefile->GetCurrentListFile(),
fname.c_str());
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
if(!readit)
{
std::string m = "Could not find include file: ";
@@ -564,7 +564,7 @@ int cmCTestTestHandler::ProcessHandler()
}
else
{
- if (this->HandlerVerbose && passed.size() &&
+ if (this->HandlerVerbose && !passed.empty() &&
(this->UseIncludeRegExpFlag || this->UseExcludeRegExpFlag))
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
@@ -578,7 +578,7 @@ int cmCTestTestHandler::ProcessHandler()
}
float percent = float(passed.size()) * 100.0f / float(total);
- if ( failed.size() > 0 && percent > 99)
+ if (!failed.empty() && percent > 99)
{
percent = 99;
}
@@ -596,7 +596,7 @@ int cmCTestTestHandler::ProcessHandler()
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = "
<< realBuf << "\n" );
- if (failed.size())
+ if (!failed.empty())
{
cmGeneratedFileStream ofs;
cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
@@ -668,7 +668,7 @@ void cmCTestTestHandler::PrintLabelSummary()
for(; it != this->TestList.end(); ++it)
{
cmCTestTestProperties& p = *it;
- if(p.Labels.size() != 0)
+ if(!p.Labels.empty())
{
for(std::vector<std::string>::iterator l = p.Labels.begin();
l != p.Labels.end(); ++l)
@@ -688,7 +688,7 @@ void cmCTestTestHandler::PrintLabelSummary()
{
cmCTestTestResult &result = *ri;
cmCTestTestProperties& p = *result.Properties;
- if(p.Labels.size() != 0)
+ if(!p.Labels.empty())
{
for(std::vector<std::string>::iterator l = p.Labels.begin();
l != p.Labels.end(); ++l)
@@ -698,7 +698,7 @@ void cmCTestTestHandler::PrintLabelSummary()
}
}
// now print times
- if(labels.size())
+ if(!labels.empty())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:");
}
@@ -717,7 +717,7 @@ void cmCTestTestHandler::PrintLabelSummary()
<< buf << "\n";
}
}
- if(labels.size())
+ if(!labels.empty())
{
if(this->LogFile)
{
@@ -738,7 +738,7 @@ void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it)
}
// if there are no labels and we are filtering by labels
// then exclude the test as it does not have the label
- if(it.Labels.size() == 0 )
+ if(it.Labels.empty())
{
it.IsInBasedOnREOptions = false;
return;
@@ -772,7 +772,7 @@ void cmCTestTestHandler::CheckLabelFilterExclude(cmCTestTestProperties& it)
}
// if there are no labels and we are excluding by labels
// then do nothing as a no label can not be a match
- if(it.Labels.size() == 0 )
+ if(it.Labels.empty())
{
return;
}
@@ -850,7 +850,7 @@ void cmCTestTestHandler::ComputeTestList()
if (this->UseUnion)
{
// if it is not in the list and not in the regexp then skip
- if ((this->TestsToRun.size() &&
+ if ((!this->TestsToRun.empty() &&
std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt)
== this->TestsToRun.end()) && !it->IsInBasedOnREOptions)
{
@@ -860,7 +860,7 @@ void cmCTestTestHandler::ComputeTestList()
else
{
// is this test in the list of tests to run? If not then skip it
- if ((this->TestsToRun.size() &&
+ if ((!this->TestsToRun.empty() &&
std::find(this->TestsToRun.begin(),
this->TestsToRun.end(), inREcnt)
== this->TestsToRun.end()) || !it->IsInBasedOnREOptions)
@@ -891,7 +891,7 @@ void cmCTestTestHandler::ComputeTestListForRerunFailed()
cnt ++;
// if this test is not in our list of tests to run, then skip it.
- if ((this->TestsToRun.size() &&
+ if ((!this->TestsToRun.empty() &&
std::find(this->TestsToRun.begin(), this->TestsToRun.end(), cnt)
== this->TestsToRun.end()))
{
@@ -1094,7 +1094,7 @@ void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
p.Timeout = this->CTest->GetGlobalTimeout();
}
- if(p.Depends.size())
+ if(!p.Depends.empty())
{
for(std::vector<std::string>::iterator i = p.Depends.begin();
i != p.Depends.end(); ++i)
@@ -1192,7 +1192,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
<< "name=\"Execution Time\"><Value>"
<< result->ExecutionTime
<< "</Value></NamedMeasurement>\n";
- if(result->Reason.size())
+ if(!result->Reason.empty())
{
const char* reasonType = "Pass Reason";
if(result->Status != cmCTestTestHandler::COMPLETED &&
@@ -1317,7 +1317,7 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os,
result->Properties->AttachedFiles.begin();
file != result->Properties->AttachedFiles.end(); ++file)
{
- std::string base64 = this->CTest->Base64GzipEncodeFile(*file);
+ const std::string &base64 = this->CTest->Base64GzipEncodeFile(*file);
std::string fname = cmSystemTools::GetFilenameName(*file);
os << "\t\t<NamedMeasurement name=\"Attached File\" encoding=\"base64\" "
"compression=\"tar/gzip\" filename=\"" << fname << "\" type=\"file\">"
@@ -1376,7 +1376,7 @@ void cmCTestTestHandler
{
std::string tempPath;
- if (filepath.size() &&
+ if (!filepath.empty() &&
filepath[filepath.size()-1] != '/')
{
filepath += "/";
@@ -1385,7 +1385,7 @@ void cmCTestTestHandler
attempted.push_back(tempPath);
attemptedConfigs.push_back("");
- if(ctest->GetConfigType().size())
+ if(!ctest->GetConfigType().empty())
{
tempPath = filepath;
tempPath += ctest->GetConfigType();
@@ -1463,7 +1463,7 @@ std::string cmCTestTestHandler
// even if a fullpath was specified also try it relative to the current
// directory
- if (filepath.size() && filepath[0] == '/')
+ if (!filepath.empty() && filepath[0] == '/')
{
std::string localfilepath = filepath.substr(1,filepath.size()-1);
cmCTestTestHandler::AddConfigurations(ctest, attempted,
@@ -1474,7 +1474,7 @@ std::string cmCTestTestHandler
// if extraPaths are provided and we were not passed a full path, try them,
// try any extra paths
- if (filepath.size() == 0)
+ if (filepath.empty())
{
for (unsigned int i = 0; i < extraPaths.size(); ++i)
{
@@ -1494,13 +1494,13 @@ std::string cmCTestTestHandler
// now look in the paths we specified above
for(unsigned int ai=0;
- ai < attempted.size() && fullPath.size() == 0; ++ai)
+ ai < attempted.size() && fullPath.empty(); ++ai)
{
// first check without exe extension
if(cmSystemTools::FileExists(attempted[ai].c_str())
- && !cmSystemTools::FileIsDirectory(attempted[ai].c_str()))
+ && !cmSystemTools::FileIsDirectory(attempted[ai]))
{
- fullPath = cmSystemTools::CollapseFullPath(attempted[ai].c_str());
+ fullPath = cmSystemTools::CollapseFullPath(attempted[ai]);
resultingConfig = attemptedConfigs[ai];
}
// then try with the exe extension
@@ -1510,9 +1510,9 @@ std::string cmCTestTestHandler
tempPath = attempted[ai];
tempPath += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(tempPath.c_str())
- && !cmSystemTools::FileIsDirectory(tempPath.c_str()))
+ && !cmSystemTools::FileIsDirectory(tempPath))
{
- fullPath = cmSystemTools::CollapseFullPath(tempPath.c_str());
+ fullPath = cmSystemTools::CollapseFullPath(tempPath);
resultingConfig = attemptedConfigs[ai];
}
else
@@ -1524,7 +1524,7 @@ std::string cmCTestTestHandler
// if everything else failed, check the users path, but only if a full path
// wasn't specified
- if (fullPath.size() == 0 && filepath.size() == 0)
+ if (fullPath.empty() && filepath.empty())
{
std::string path = cmSystemTools::FindProgram(filename.c_str());
if (path != "")
@@ -1533,7 +1533,7 @@ std::string cmCTestTestHandler
return path;
}
}
- if(fullPath.size() == 0)
+ if(fullPath.empty())
{
cmCTestLog(ctest, HANDLER_OUTPUT,
"Could not find executable " << testCommand << "\n"
@@ -1746,7 +1746,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
std::string dirName = this->CTest->GetBinaryDir() + "/Testing/Temporary";
cmsys::Directory directory;
- if (directory.Load(dirName.c_str()) == 0)
+ if (directory.Load(dirName) == 0)
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to read the contents of "
<< dirName << std::endl);
@@ -1754,7 +1754,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
}
int numFiles = static_cast<int>
- (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str()));
+ (cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
std::string pattern = "LastTestsFailed";
std::string logName = "";
@@ -1777,7 +1777,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
// if multiple matching logs were found we use the most recently
// modified one.
int res;
- cmSystemTools::FileTimeCompare(logName.c_str(), fileName.c_str(), &res);
+ cmSystemTools::FileTimeCompare(logName, fileName, &res);
if (res == -1)
{
logName = fileName;
@@ -1865,7 +1865,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
SPACE_REGEX "*(name|type|encoding|compression)=\"([^\"]*)\""
SPACE_REGEX "*>([^<]*)</DartMeasurementFile>");
- cmOStringStream ostr;
+ std::ostringstream ostr;
bool done = false;
std::string cxml = xml;
while ( ! done )
@@ -1939,7 +1939,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
cmCTest::CleanString(measurementfile.match(5));
if ( cmSystemTools::FileExists(filename.c_str()) )
{
- long len = cmSystemTools::FileLength(filename.c_str());
+ long len = cmSystemTools::FileLength(filename);
if ( len == 0 )
{
std::string k1 = measurementfile.match(1);
@@ -1976,9 +1976,8 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
= new unsigned char [ static_cast<int>(
static_cast<double>(len) * 1.5 + 5.0) ];
- unsigned long rlen
+ size_t rlen
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
- unsigned long cc;
ostr
<< "\t\t\t<NamedMeasurement"
@@ -1988,7 +1987,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
<< measurementfile.match(4) << "\""
<< " encoding=\"base64\""
<< ">" << std::endl << "\t\t\t\t<Value>";
- for ( cc = 0; cc < rlen; cc ++ )
+ for (size_t cc = 0; cc < rlen; cc ++ )
{
ostr << encoded_buffer[cc];
if ( cc % 60 == 0 && cc )
@@ -2099,7 +2098,7 @@ bool cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
output = output.substr(0, current - begin);
// Append truncation message.
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "...\n"
"The rest of the test output was removed since it exceeds the threshold "
"of " << length << " bytes.\n";
@@ -2153,36 +2152,18 @@ bool cmCTestTestHandler::SetTestsProperties(
}
if ( key == "ATTACHED_FILES" )
{
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
-
- for(std::vector<std::string>::iterator f = lval.begin();
- f != lval.end(); ++f)
- {
- rtit->AttachedFiles.push_back(*f);
- }
+ cmSystemTools::ExpandListArgument(val, rtit->AttachedFiles);
}
if ( key == "ATTACHED_FILES_ON_FAIL" )
{
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
-
- for(std::vector<std::string>::iterator f = lval.begin();
- f != lval.end(); ++f)
- {
- rtit->AttachOnFail.push_back(*f);
- }
+ cmSystemTools::ExpandListArgument(val, rtit->AttachOnFail);
}
if ( key == "RESOURCE_LOCK" )
{
std::vector<std::string> lval;
cmSystemTools::ExpandListArgument(val, lval);
- for(std::vector<std::string>::iterator f = lval.begin();
- f != lval.end(); ++f)
- {
- rtit->LockedResources.insert(*f);
- }
+ rtit->LockedResources.insert(lval.begin(), lval.end());
}
if ( key == "TIMEOUT" )
{
@@ -2195,14 +2176,7 @@ bool cmCTestTestHandler::SetTestsProperties(
}
if ( key == "REQUIRED_FILES" )
{
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
-
- for(std::vector<std::string>::iterator f = lval.begin();
- f != lval.end(); ++f)
- {
- rtit->RequiredFiles.push_back(*f);
- }
+ cmSystemTools::ExpandListArgument(val, rtit->RequiredFiles);
}
if ( key == "RUN_SERIAL" )
{
@@ -2239,33 +2213,15 @@ bool cmCTestTestHandler::SetTestsProperties(
}
if ( key == "DEPENDS" )
{
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for ( crit = lval.begin(); crit != lval.end(); ++ crit )
- {
- rtit->Depends.push_back(*crit);
- }
+ cmSystemTools::ExpandListArgument(val, rtit->Depends);
}
if ( key == "ENVIRONMENT" )
{
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for ( crit = lval.begin(); crit != lval.end(); ++ crit )
- {
- rtit->Environment.push_back(*crit);
- }
+ cmSystemTools::ExpandListArgument(val, rtit->Environment);
}
if ( key == "LABELS" )
{
- std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val, lval);
- std::vector<std::string>::iterator crit;
- for ( crit = lval.begin(); crit != lval.end(); ++ crit )
- {
- rtit->Labels.push_back(*crit);
- }
+ cmSystemTools::ExpandListArgument(val, rtit->Labels);
}
if ( key == "MEASUREMENT" )
{
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 68f5fe1..4c37c8b 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -94,11 +94,11 @@ cmCTestUpdateHandlerLocale::~cmCTestUpdateHandlerLocale()
{
// restore the value of LC_MESSAGES after running the version control
// commands
- if(saveLCMessages.size())
+ if(!saveLCMessages.empty())
{
std::string put = "LC_MESSAGES=";
put += saveLCMessages;
- cmSystemTools::PutEnv(put.c_str());
+ cmSystemTools::PutEnv(put);
}
else
{
@@ -413,7 +413,7 @@ bool cmCTestUpdateHandler::SelectVCS()
}
if (this->UpdateCommand.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot find UpdateCommand ";
if (key)
{
diff --git a/Source/CTest/cmCTestUpdateHandler.h b/Source/CTest/cmCTestUpdateHandler.h
index 954c024..d2423c0 100644
--- a/Source/CTest/cmCTestUpdateHandler.h
+++ b/Source/CTest/cmCTestUpdateHandler.h
@@ -17,10 +17,6 @@
#include "cmCTestGenericHandler.h"
#include "cmListFileCache.h"
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 1375 /* base class destructor not virtual */
-#endif
-
/** \class cmCTestUpdateHandler
* \brief A class that handles ctest -S invocations
*
@@ -70,8 +66,4 @@ private:
bool SelectVCS();
};
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma reset woff 1375 /* base class destructor not virtual */
-#endif
-
#endif
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index f7de294..5613751 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -55,7 +55,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "File \"" << filename << "\" does not exist. Cannot submit "
<< "a non-existent file.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 15f796f..6e93e95 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -105,7 +105,7 @@ bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
//----------------------------------------------------------------------------
std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
{
- cmOStringStream line;
+ std::ostringstream line;
const char* sep = "";
for(const char* const* arg = cmd; *arg; ++arg)
{
diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx
new file mode 100644
index 0000000..85d066b
--- /dev/null
+++ b/Source/CTest/cmParseBlanketJSCoverage.cxx
@@ -0,0 +1,164 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmStandardIncludes.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "cmSystemTools.h"
+#include "cmParseBlanketJSCoverage.h"
+#include <cmsys/Directory.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/FStream.hxx>
+
+
+class cmParseBlanketJSCoverage::JSONParser
+ {
+public:
+ typedef cmCTestCoverageHandlerContainer::
+ SingleFileCoverageVector FileLinesType;
+ JSONParser(cmCTestCoverageHandlerContainer& cont)
+ : Coverage(cont)
+ {
+ }
+
+ virtual ~JSONParser()
+ {
+ }
+
+ std::string getValue(std::string line, int type)
+ {
+ size_t begIndex;
+ size_t endIndex;
+ endIndex = line.rfind(',');
+ begIndex = line.find_first_of(':');
+ if(type == 0)
+ {
+ // A unique substring to remove the extra characters
+ // around the files name in the JSON (extra " and ,)
+ std::string foundFileName =
+ line.substr(begIndex+3,endIndex-(begIndex+4));
+ return foundFileName;
+ }
+ else
+ {
+ return line.substr(begIndex,line.npos);
+ }
+ }
+ bool ParseFile(std::string file)
+ {
+ FileLinesType localCoverageVector;
+ std::string filename;
+ bool foundFile = false;
+ bool inSource = false;
+ std::string covResult;
+ std::string line;
+
+ cmsys::ifstream in(file.c_str());
+ if(!in)
+ {
+ return false;
+ }
+ while( cmSystemTools::GetLineFromStream(in, line))
+ {
+ if(line.find("filename") != line.npos)
+ {
+ if(foundFile)
+ {
+ /*
+ * Upon finding a second file name, generate a
+ * vector within the total coverage to capture the
+ * information in the local vector
+ */
+ FileLinesType& CoverageVector =
+ this->Coverage.TotalCoverage[filename];
+ CoverageVector = localCoverageVector;
+ localCoverageVector.clear();
+ }
+ foundFile= true;
+ inSource = false;
+ filename = getValue(line,0).c_str();
+ }
+ else if((line.find("coverage") != line.npos) && foundFile && inSource )
+ {
+ /*
+ * two types of "coverage" in the JSON structure
+ *
+ * The coverage result over the file or set of files
+ * and the coverage for each individual line
+ *
+ * FoundFile and foundSource ensure that
+ * only the value of the line coverage is captured
+ */
+ std::string result = getValue(line,1);
+ result = result.substr(2,result.npos);
+ if(result == "\"\"")
+ {
+ // Empty quotation marks indicate that the
+ // line is not executable
+ localCoverageVector.push_back(-1);
+ }
+ else
+ {
+ // Else, it contains the number of time executed
+ localCoverageVector.push_back(atoi(result.c_str()));
+ }
+ }
+ else if(line.find("source") != line.npos)
+ {
+ inSource=true;
+ }
+ }
+
+ // On exit, capture end of last file covered.
+ FileLinesType& CoverageVector =
+ this->Coverage.TotalCoverage[filename];
+ CoverageVector = localCoverageVector;
+ localCoverageVector.clear();
+ return true;
+ }
+private:
+ cmCTestCoverageHandlerContainer& Coverage;
+};
+
+cmParseBlanketJSCoverage::cmParseBlanketJSCoverage(
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ :Coverage(cont), CTest(ctest)
+ {
+ }
+
+bool cmParseBlanketJSCoverage::LoadCoverageData(std::vector<std::string> files)
+ {
+ size_t i=0;
+ std::string path;
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Found " << files.size() <<" Files" << std::endl);
+ for(i=0;i<files.size();i++)
+ {
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Reading JSON File " << files[i] << std::endl);
+
+ if(!this->ReadJSONFile(files[i]))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+bool cmParseBlanketJSCoverage::ReadJSONFile(std::string file)
+ {
+ cmParseBlanketJSCoverage::JSONParser parser
+ (this->Coverage);
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Parsing " << file << std::endl);
+ parser.ParseFile(file);
+ return true;
+ }
diff --git a/Source/CTest/cmParseBlanketJSCoverage.h b/Source/CTest/cmParseBlanketJSCoverage.h
new file mode 100644
index 0000000..fc1d477
--- /dev/null
+++ b/Source/CTest/cmParseBlanketJSCoverage.h
@@ -0,0 +1,48 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmParseBlanketJSCoverage_h
+#define cmParseBlanketJSCoverage_h
+
+#include "cmStandardIncludes.h"
+#include "cmCTestCoverageHandler.h"
+
+
+/** \class cmParseBlanketJSCoverage
+ * \brief Parse BlanketJS coverage information
+ *
+ * This class is used to parse BlanketJS(Pascal) coverage information
+ * generated by the Blanket.js library when used in conjunction with the
+ * test runner mocha.js, which is used to write out the JSON format.
+ *
+ * Blanket.js:
+ * http://blanketjs.org/
+ *
+ * Mocha.js
+ * http://visionmedia.github.io/mocha/
+ */
+class cmParseBlanketJSCoverage
+{
+public:
+ cmParseBlanketJSCoverage(cmCTestCoverageHandlerContainer& cont,
+ cmCTest* ctest);
+ bool LoadCoverageData(std::vector<std::string> files);
+ // Read the JSON output
+ bool ReadJSONFile(std::string file);
+
+protected:
+
+ class JSONParser;
+ cmCTestCoverageHandlerContainer& Coverage;
+ cmCTest* CTest;
+};
+#endif
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index d17f169..3642308 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -31,7 +31,7 @@ bool cmParseCacheCoverage::LoadCoverageData(const char* d)
{
std::string file = dir.GetFile(i);
if(file != "." && file != ".."
- && !cmSystemTools::FileIsDirectory(file.c_str()))
+ && !cmSystemTools::FileIsDirectory(file))
{
std::string path = d;
path += "/";
@@ -163,7 +163,7 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
}
// if we do not have a routine yet, then it should be
// the first argument in the vector
- if(routine.size() == 0)
+ if(routine.empty())
{
routine = separateLine[0];
// Find the full path to the file
@@ -191,7 +191,7 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
// move to next line. We should have already warned
// after the call to FindMumpsFile that we did not find
// it, so don't report again to cut down on output
- if(filepath.size() == 0)
+ if(filepath.empty())
{
continue;
}
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index 0742be1..e19b199 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -12,9 +12,11 @@ public:
XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
: CTest(ctest), Coverage(cont)
{
- this->InSources = false;
- this->InSource = false;
+ this->InSources = false;
+ this->InSource = false;
+ this->SkipThisClass = false;
this->FilePaths.push_back(this->Coverage.SourceDir);
+ this->FilePaths.push_back(this->Coverage.BinaryDir);
this->CurFileName = "";
}
@@ -35,6 +37,10 @@ protected:
{
this->InSources=false;
}
+ else if(name == "class")
+ {
+ this->SkipThisClass = false;
+ }
}
virtual void CharacterDataHandler(const char* data, int length)
@@ -72,15 +78,33 @@ protected:
<< atts[tagCount+1]<< std::endl);
std::string filename = atts[tagCount+1];
this->CurFileName = "";
+
+ // Check if this is an absolute path that falls within our
+ // source or binary directories.
for(size_t i=0;i < FilePaths.size();i++)
{
- finalpath = FilePaths[i] + "/" + filename;
- if(cmSystemTools::FileExists(finalpath.c_str()))
+ if (filename.find(FilePaths[i]) == 0)
{
- this->CurFileName = finalpath;
+ this->CurFileName = filename;
break;
}
}
+
+ if (this->CurFileName == "")
+ {
+ // Check if this is a path that is relative to our source or
+ // binary directories.
+ for(size_t i=0;i < FilePaths.size();i++)
+ {
+ finalpath = FilePaths[i] + "/" + filename;
+ if(cmSystemTools::FileExists(finalpath.c_str()))
+ {
+ this->CurFileName = finalpath;
+ break;
+ }
+ }
+ }
+
cmsys::ifstream fin(this->CurFileName.c_str());
if(this->CurFileName == "" || !fin )
{
@@ -89,10 +113,11 @@ protected:
fin.open(this->CurFileName.c_str());
if (!fin)
{
- cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Python Coverage: Error opening " << this->CurFileName
- << std::endl);
- this->Coverage.Error++;
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Skipping system file " << filename <<
+ std::endl);
+
+ this->SkipThisClass = true;
break;
}
}
@@ -117,6 +142,10 @@ protected:
int curHits = -1;
while(true)
{
+ if(this->SkipThisClass)
+ {
+ break;
+ }
if(strcmp(atts[tagCount], "hits") == 0)
{
curHits = atoi(atts[tagCount+1]);
@@ -144,6 +173,7 @@ private:
bool InSources;
bool InSource;
+ bool SkipThisClass;
std::vector<std::string> FilePaths;
typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
FileLinesType;
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
new file mode 100644
index 0000000..4dfdfac
--- /dev/null
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -0,0 +1,251 @@
+#include "cmStandardIncludes.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include "cmSystemTools.h"
+#include "cmXMLParser.h"
+#include "cmParseDelphiCoverage.h"
+#include <cmsys/Directory.hxx>
+#include <cmsys/Glob.hxx>
+#include <cmsys/FStream.hxx>
+
+
+class cmParseDelphiCoverage::HTMLParser
+{
+public:
+ typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector
+ FileLinesType;
+ HTMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont)
+ : CTest(ctest), Coverage(cont)
+ {
+ }
+
+ virtual ~HTMLParser()
+ {
+ }
+
+ bool initializeDelphiFile(const std::string filename,
+ cmParseDelphiCoverage::HTMLParser::FileLinesType &coverageVector)
+ {
+ std::string line;
+ size_t comPos;
+ size_t semiPos;
+ bool blockComFlag= false;
+ bool lineComFlag= false;
+ std::vector<std::string> beginSet;
+ cmsys::ifstream in(filename.c_str());
+ if(!in)
+ {
+ return false;
+ }
+ while(cmSystemTools::GetLineFromStream(in, line))
+ {
+ lineComFlag=false;
+ // Unique cases found in lines.
+ size_t beginPos = line.find("begin");
+
+ //Check that the begin is the first non-space string on the line
+ if( (beginPos == line.find_first_not_of(' ')) && beginPos != line.npos )
+ {
+ beginSet.push_back("begin");
+ coverageVector.push_back(-1);
+ continue;
+ }
+ else if(line.find('{') != line.npos)
+ {
+ blockComFlag=true;
+ }
+ else if(line.find('}') != line.npos)
+ {
+ blockComFlag=false;
+ coverageVector.push_back(-1);
+ continue;
+ }
+ else if((line.find("end;") != line.npos)
+ && !beginSet.empty())
+ {
+ beginSet.pop_back();
+ coverageVector.push_back(-1);
+ continue;
+ }
+
+ // This checks for comments after lines of code, finding the
+ // comment symbol after the ending semicolon.
+ comPos = line.find("//");
+ if(comPos != line.npos)
+ {
+ semiPos= line.find(';');
+ if(comPos < semiPos)
+ {
+ lineComFlag=true;
+ }
+ }
+ //Based up what was found, add a line to the coverageVector
+ if(!beginSet.empty() && line != "" && !blockComFlag
+ && !lineComFlag)
+ {
+ coverageVector.push_back(0);
+ }
+ else
+ {
+ coverageVector.push_back(-1);
+ }
+ }
+ return true;
+ }
+ bool ParseFile(const char* file)
+ {
+ std::string line=file;
+ std::string lineresult;
+ std::string lastroutine;
+ std::string filename;
+ std::string filelineoffset;
+ size_t afterLineNum = 0;
+ size_t lastoffset = 0;
+ size_t endcovpos = 0;
+ size_t endnamepos = 0;
+ size_t pos = 0;
+
+ /*
+ * This first 'while' section goes through the found HTML
+ * file name and attempts to capture the source file name
+ * which is set as part of the HTML file name: the name of
+ * the file is found in parenthesis '()'
+ *
+ * See test HTML file name: UTCovTest(UTCovTest.pas).html.
+ *
+ * Find the text inside each pair of parenthesis and check
+ * to see if it ends in '.pas'. If it can't be found,
+ * exit the function.
+ */
+ while(true)
+ {
+ lastoffset = line.find('(',pos);
+ if(lastoffset==line.npos)
+ {
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ endnamepos << "File not found " << lastoffset << std::endl);
+ return false;
+ }
+ endnamepos = line.find(')',lastoffset);
+ filename = line.substr(lastoffset+1,
+ (endnamepos-1)-lastoffset);
+ if(filename.find(".pas") != filename.npos)
+ {
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Coverage found for file: " << filename << std::endl);
+ break;
+ }
+ pos = lastoffset+1;
+ }
+ /*
+ * Glob through the source directory for the
+ * file found above
+ */
+ cmsys::Glob gl;
+ gl.RecurseOn();
+ gl.RecurseThroughSymlinksOff();
+ std::string glob = Coverage.SourceDir + "*/" + filename;
+ gl.FindFiles(glob);
+ std::vector<std::string> const& files = gl.GetFiles();
+ if(files.empty())
+ {
+ /*
+ * If that doesn't find any matching files
+ * return a failure.
+ */
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Unable to find file matching" << glob << std::endl);
+ return false;
+ }
+ FileLinesType& coverageVector =
+ this->Coverage.TotalCoverage[files[0]];
+
+ /*
+ * Initialize the file to have all code between 'begin' and
+ * 'end' tags marked as executable
+ */
+
+ this->initializeDelphiFile(files[0],coverageVector);
+
+ cmsys::ifstream in(file);
+ if(!in)
+ {
+ return false;
+ }
+
+ /*
+ * Now read the HTML file, looking for the lines that have an
+ * "inline" in it. Then parse out the "class" value of that
+ * line to determine if the line is executed or not.
+ *
+ * Sample HTML line:
+ *
+ * <tr class="covered"><td>47</td><td><pre style="display:inline;">
+ * &nbsp;CheckEquals(1,2-1);</pre></td></tr>
+ *
+ */
+
+ while( cmSystemTools::GetLineFromStream(in, line))
+ {
+ if(line.find("inline") == line.npos)
+ {
+ continue;
+ }
+
+ lastoffset = line.find("class=");
+ endcovpos = line.find(">",lastoffset);
+ lineresult = line.substr(lastoffset+7,(endcovpos-8)-lastoffset);
+
+ if(lineresult == "covered")
+ {
+ afterLineNum = line.find('<',endcovpos+5);
+ filelineoffset= line.substr(endcovpos+5,
+ afterLineNum-(endcovpos+5));
+ coverageVector[atoi(filelineoffset.c_str())-1] = 1;
+ }
+ }
+ return true;
+ }
+
+
+ private:
+ cmCTest* CTest;
+ cmCTestCoverageHandlerContainer& Coverage;
+};
+
+cmParseDelphiCoverage::cmParseDelphiCoverage(
+ cmCTestCoverageHandlerContainer& cont, cmCTest* ctest)
+ :Coverage(cont), CTest(ctest)
+ {
+ }
+
+bool cmParseDelphiCoverage::LoadCoverageData(
+ const std::vector<std::string> files)
+ {
+ size_t i;
+ std::string path;
+ size_t numf = files.size();
+ for (i = 0; i < numf; i++)
+ {
+ path = files[i];
+
+ cmCTestLog(this->CTest,HANDLER_VERBOSE_OUTPUT,
+ "Reading HTML File " << path << std::endl);
+ if(cmSystemTools::GetFilenameLastExtension(path) == ".html")
+ {
+ if(!this->ReadDelphiHTML(path.c_str()))
+ {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+bool cmParseDelphiCoverage::ReadDelphiHTML(const char* file)
+ {
+ cmParseDelphiCoverage::HTMLParser
+ parser(this->CTest, this->Coverage);
+ parser.ParseFile(file);
+ return true;
+ }
diff --git a/Source/CTest/cmParseDelphiCoverage.h b/Source/CTest/cmParseDelphiCoverage.h
new file mode 100644
index 0000000..018340b
--- /dev/null
+++ b/Source/CTest/cmParseDelphiCoverage.h
@@ -0,0 +1,46 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmParseDelphiCoverage_h
+#define cmParseDelphiCoverage_h
+
+#include "cmStandardIncludes.h"
+#include "cmCTestCoverageHandler.h"
+
+
+/** \class cmParseDelphiCoverage
+ * \brief Parse Delphi coverage information
+ *
+ * This class is used to parse Delphi(Pascal) coverage information
+ * generated by the Delphi-Code-Coverage tool
+ *
+ * https://code.google.com/p/delphi-code-coverage/
+ */
+
+class cmParseDelphiCoverage
+ {
+ public:
+ cmParseDelphiCoverage(cmCTestCoverageHandlerContainer& cont,
+ cmCTest* ctest);
+ bool LoadCoverageData(const std::vector<std::string> files);
+ bool ReadDelphiHTML(const char* file);
+ // Read a single HTML file from output
+ bool ReadHTMLFile(const char* f);
+
+
+ protected:
+
+ class HTMLParser;
+ cmCTestCoverageHandlerContainer& Coverage;
+ cmCTest* CTest;
+ };
+#endif
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index be10c2e..f3f8008 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -30,7 +30,7 @@ bool cmParseGTMCoverage::LoadCoverageData(const char* d)
{
std::string file = dir.GetFile(i);
if(file != "." && file != ".."
- && !cmSystemTools::FileIsDirectory(file.c_str()))
+ && !cmSystemTools::FileIsDirectory(file))
{
std::string path = d;
path += "/";
@@ -80,7 +80,7 @@ bool cmParseGTMCoverage::ReadMCovFile(const char* file)
// no need to search the file if we just did it
if(function == lastfunction && lastroutine == routine)
{
- if(lastpath.size())
+ if(!lastpath.empty())
{
this->Coverage.TotalCoverage[lastpath][lastoffset + linenumber]
+= count;
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index f270adb..780debc 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -106,7 +106,7 @@ class cmParseJacocoCoverage::XMLParser: public cmXMLParser
{
FileLinesType& curFileLines=
this->Coverage.TotalCoverage[this->CurFileName];
- if(curFileLines.size() > 0)
+ if(!curFileLines.empty())
{
curFileLines[nr-1] = ci;
}
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index 3b7f968..c7f5a68 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -239,7 +239,7 @@ bool cmParsePHPCoverage::ReadPHPCoverageDirectory(const char* d)
{
std::string file = dir.GetFile(i);
if(file != "." && file != ".."
- && !cmSystemTools::FileIsDirectory(file.c_str()))
+ && !cmSystemTools::FileIsDirectory(file))
{
std::string path = d;
path += "/";
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 167b992..e1bd02b 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -39,7 +39,7 @@ void cmProcess::SetCommandArguments(std::vector<std::string> const& args)
bool cmProcess::StartProcess()
{
- if(this->Command.size() == 0)
+ if(this->Command.empty())
{
return false;
}
@@ -56,7 +56,7 @@ bool cmProcess::StartProcess()
this->ProcessArgs.push_back(0); // null terminate the list
this->Process = cmsysProcess_New();
cmsysProcess_SetCommand(this->Process, &*this->ProcessArgs.begin());
- if(this->WorkingDirectory.size())
+ if(!this->WorkingDirectory.empty())
{
cmsysProcess_SetWorkingDirectory(this->Process,
this->WorkingDirectory.c_str());
diff --git a/Source/CursesDialog/CMakeLists.txt b/Source/CursesDialog/CMakeLists.txt
index 548f5a5..7d4e88c 100644
--- a/Source/CursesDialog/CMakeLists.txt
+++ b/Source/CursesDialog/CMakeLists.txt
@@ -26,13 +26,25 @@ set( CURSES_SRCS
CursesDialog/ccmake
)
-include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form
- ${CMake_BINARY_DIR}/Source/CursesDialog/form)
+if( NOT CMAKE_USE_SYSTEM_FORM )
+ include_directories(${CMake_SOURCE_DIR}/Source/CursesDialog/form
+ ${CMake_BINARY_DIR}/Source/CursesDialog/form)
+endif()
include_directories(${CURSES_INCLUDE_PATH})
add_executable(ccmake ${CURSES_SRCS} )
target_link_libraries(ccmake CMakeLib)
-target_link_libraries(ccmake cmForm)
+if(CMAKE_USE_SYSTEM_FORM)
+ target_link_libraries(ccmake
+ ${CURSES_FORM_LIBRARY}
+ ${CURSES_LIBRARY}
+ )
+ if(CURSES_EXTRA_LIBRARY)
+ target_link_libraries(ccmake ${CURSES_EXTRA_LIBRARY})
+ endif()
+else()
+ target_link_libraries(ccmake cmForm)
+endif()
install(TARGETS ccmake DESTINATION bin)
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index 28f3d9b..3d92a2d 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -16,7 +16,6 @@
#include <signal.h>
#include <sys/ioctl.h>
-#include <locale.h>
#include "cmCursesMainForm.h"
#include "cmCursesStandardIncludes.h"
@@ -95,8 +94,6 @@ void CMakeMessageHandler(const char* message, const char* title, bool&,
int main(int argc, char const* const* argv)
{
- setlocale(LC_CTYPE, "");
-
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
diff --git a/Source/CursesDialog/cmCursesBoolWidget.h b/Source/CursesDialog/cmCursesBoolWidget.h
index d2a25ca..8a57c73 100644
--- a/Source/CursesDialog/cmCursesBoolWidget.h
+++ b/Source/CursesDialog/cmCursesBoolWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesBoolWidget_h
-#define __cmCursesBoolWidget_h
+#ifndef cmCursesBoolWidget_h
+#define cmCursesBoolWidget_h
#include "cmCursesWidget.h"
class cmCursesMainForm;
@@ -37,4 +37,4 @@ protected:
};
-#endif // __cmCursesBoolWidget_h
+#endif // cmCursesBoolWidget_h
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h
index 98107cc..7cdf13b 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.h
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesCacheEntryComposite_h
-#define __cmCursesCacheEntryComposite_h
+#ifndef cmCursesCacheEntryComposite_h
+#define cmCursesCacheEntryComposite_h
#include "../cmCacheManager.h"
#include "cmCursesLabelWidget.h"
@@ -40,4 +40,4 @@ protected:
int EntryWidth;
};
-#endif // __cmCursesCacheEntryComposite_h
+#endif // cmCursesCacheEntryComposite_h
diff --git a/Source/CursesDialog/cmCursesDummyWidget.h b/Source/CursesDialog/cmCursesDummyWidget.h
index 9ac1365..2b3b9b5 100644
--- a/Source/CursesDialog/cmCursesDummyWidget.h
+++ b/Source/CursesDialog/cmCursesDummyWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesDummyWidget_h
-#define __cmCursesDummyWidget_h
+#ifndef cmCursesDummyWidget_h
+#define cmCursesDummyWidget_h
#include "cmCursesWidget.h"
@@ -33,4 +33,4 @@ protected:
};
-#endif // __cmCursesDummyWidget_h
+#endif // cmCursesDummyWidget_h
diff --git a/Source/CursesDialog/cmCursesFilePathWidget.h b/Source/CursesDialog/cmCursesFilePathWidget.h
index 9d2972e..6c50dd4 100644
--- a/Source/CursesDialog/cmCursesFilePathWidget.h
+++ b/Source/CursesDialog/cmCursesFilePathWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesFilePathWidget_h
-#define __cmCursesFilePathWidget_h
+#ifndef cmCursesFilePathWidget_h
+#define cmCursesFilePathWidget_h
#include "cmCursesPathWidget.h"
@@ -25,4 +25,4 @@ protected:
};
-#endif // __cmCursesFilePathWidget_h
+#endif // cmCursesFilePathWidget_h
diff --git a/Source/CursesDialog/cmCursesForm.h b/Source/CursesDialog/cmCursesForm.h
index f9317b9..9837f5a 100644
--- a/Source/CursesDialog/cmCursesForm.h
+++ b/Source/CursesDialog/cmCursesForm.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesForm_h
-#define __cmCursesForm_h
+#ifndef cmCursesForm_h
+#define cmCursesForm_h
#include "../cmStandardIncludes.h"
#include "cmCursesStandardIncludes.h"
@@ -73,4 +73,4 @@ protected:
FORM* Form;
};
-#endif // __cmCursesForm_h
+#endif // cmCursesForm_h
diff --git a/Source/CursesDialog/cmCursesLabelWidget.h b/Source/CursesDialog/cmCursesLabelWidget.h
index cc32d11..98170f5 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.h
+++ b/Source/CursesDialog/cmCursesLabelWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesLabelWidget_h
-#define __cmCursesLabelWidget_h
+#ifndef cmCursesLabelWidget_h
+#define cmCursesLabelWidget_h
#include "cmCursesWidget.h"
#include "cmCursesStandardIncludes.h"
@@ -35,4 +35,4 @@ protected:
void operator=(const cmCursesLabelWidget&);
};
-#endif // __cmCursesLabelWidget_h
+#endif // cmCursesLabelWidget_h
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.h b/Source/CursesDialog/cmCursesLongMessageForm.h
index 1e86974..6e37eea 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.h
+++ b/Source/CursesDialog/cmCursesLongMessageForm.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesLongMessageForm_h
-#define __cmCursesLongMessageForm_h
+#ifndef cmCursesLongMessageForm_h
+#define cmCursesLongMessageForm_h
#include "../cmStandardIncludes.h"
#include "cmCursesForm.h"
@@ -55,4 +55,4 @@ protected:
};
-#endif // __cmCursesLongMessageForm_h
+#endif // cmCursesLongMessageForm_h
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 0734927..dcd0b6c 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -47,7 +47,7 @@ cmCursesMainForm::cmCursesMainForm(std::vector<std::string> const& args,
cmSystemTools::GetCMakeCursesCommand());
// create the arguments for the cmake object
- std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0].c_str());
+ std::string whereCMake = cmSystemTools::GetProgramPath(this->Args[0]);
whereCMake += "/cmake";
this->Args[0] = whereCMake;
this->CMakeInstance->SetArgs(this->Args);
@@ -69,11 +69,7 @@ cmCursesMainForm::~cmCursesMainForm()
// Clean-up composites
if (this->Entries)
{
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
- delete *it;
- }
+ cmDeleteAll(*this->Entries);
}
delete this->Entries;
if (this->CMakeInstance)
@@ -188,12 +184,7 @@ void cmCursesMainForm::InitializeUI()
// Clean old entries
if (this->Entries)
{
- // Have to call delete on each pointer
- std::vector<cmCursesCacheEntryComposite*>::iterator it;
- for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
- {
- delete *it;
- }
+ cmDeleteAll(*this->Entries);
}
delete this->Entries;
this->Entries = newEntries;
@@ -902,7 +893,7 @@ void cmCursesMainForm::HandleInput()
if ( key == 10 || key == KEY_ENTER )
{
this->SearchMode = false;
- if ( this->SearchString.size() > 0 )
+ if (!this->SearchString.empty())
{
this->JumpToCacheEntry(this->SearchString.c_str());
this->OldSearchString = this->SearchString;
@@ -927,7 +918,7 @@ void cmCursesMainForm::HandleInput()
}
else if ( key == ctrl('h') || key == KEY_BACKSPACE || key == KEY_DC )
{
- if ( this->SearchString.size() > 0 )
+ if (!this->SearchString.empty())
{
this->SearchString.resize(this->SearchString.size()-1);
}
@@ -1076,7 +1067,7 @@ void cmCursesMainForm::HandleInput()
}
else if ( key == 'n' )
{
- if ( this->OldSearchString.size() > 0 )
+ if (!this->OldSearchString.empty())
{
this->JumpToCacheEntry(this->OldSearchString.c_str());
}
@@ -1210,7 +1201,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr)
int findex = start_index;
for(;;)
{
- if ( str.size() > 0 )
+ if (!str.empty())
{
cmCursesWidget* lbl = 0;
if ( findex >= 0 )
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index fba9bc5..6455252 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesMainForm_h
-#define __cmCursesMainForm_h
+#ifndef cmCursesMainForm_h
+#define cmCursesMainForm_h
#include "../cmStandardIncludes.h"
#include "cmCursesForm.h"
@@ -161,4 +161,4 @@ protected:
bool SearchMode;
};
-#endif // __cmCursesMainForm_h
+#endif // cmCursesMainForm_h
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h
index 5cee489..324014e 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.h
+++ b/Source/CursesDialog/cmCursesOptionsWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesOptionsWidget_h
-#define __cmCursesOptionsWidget_h
+#ifndef cmCursesOptionsWidget_h
+#define cmCursesOptionsWidget_h
#include "cmCursesWidget.h"
class cmCursesMainForm;
@@ -36,4 +36,4 @@ protected:
std::vector<std::string>::size_type CurrentOption;
};
-#endif // __cmCursesOptionsWidget_h
+#endif // cmCursesOptionsWidget_h
diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx
index cd93bc3..89e2238 100644
--- a/Source/CursesDialog/cmCursesPathWidget.cxx
+++ b/Source/CursesDialog/cmCursesPathWidget.cxx
@@ -69,7 +69,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
cstr = cstr.substr(0, cstr.size()-1);
}
- if ( cmSystemTools::FileIsDirectory(cstr.c_str()) )
+ if ( cmSystemTools::FileIsDirectory(cstr) )
{
cstr += "/";
}
diff --git a/Source/CursesDialog/cmCursesPathWidget.h b/Source/CursesDialog/cmCursesPathWidget.h
index 45c22a3..18d298a 100644
--- a/Source/CursesDialog/cmCursesPathWidget.h
+++ b/Source/CursesDialog/cmCursesPathWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesPathWidget_h
-#define __cmCursesPathWidget_h
+#ifndef cmCursesPathWidget_h
+#define cmCursesPathWidget_h
#include "cmCursesStringWidget.h"
@@ -37,4 +37,4 @@ protected:
std::string::size_type CurrentIndex;
};
-#endif // __cmCursesPathWidget_h
+#endif // cmCursesPathWidget_h
diff --git a/Source/CursesDialog/cmCursesStandardIncludes.h b/Source/CursesDialog/cmCursesStandardIncludes.h
index b157a28..6047ec5 100644
--- a/Source/CursesDialog/cmCursesStandardIncludes.h
+++ b/Source/CursesDialog/cmCursesStandardIncludes.h
@@ -15,52 +15,12 @@
#define _MSE_INT_H
#endif
-#include <cmFormConfigure.h>
-
#if defined(__hpux)
# define _BOOL_DEFINED
# include <sys/time.h>
-# define _XOPEN_SOURCE_EXTENDED
-# include <curses.h>
-# include <form.h>
-# undef _XOPEN_SOURCE_EXTENDED
-#else
-/* figure out which curses.h to include */
-# if defined(CURSES_HAVE_NCURSES_H)
-# include <ncurses.h>
-# elif defined(CURSES_HAVE_NCURSES_NCURSES_H)
-# include <ncurses/ncurses.h>
-# elif defined(CURSES_HAVE_NCURSES_CURSES_H)
-# include <ncurses/curses.h>
-# else
-# include <curses.h>
-# endif
-
-# include <form.h>
-#endif
-
-// This is a hack to prevent warnings about these functions being
-// declared but not referenced.
-#if defined(__sgi) && !defined(__GNUC__)
-class cmCursesStandardIncludesHack
-{
-public:
- enum
- {
- Ref1 = sizeof(cfgetospeed(0)),
- Ref2 = sizeof(cfgetispeed(0)),
- Ref3 = sizeof(tcgetattr(0, 0)),
- Ref4 = sizeof(tcsetattr(0, 0, 0)),
- Ref5 = sizeof(cfsetospeed(0,0)),
- Ref6 = sizeof(cfsetispeed(0,0))
- };
-};
-#endif
-
-#ifndef getmaxyx
- #define getmaxyx(w,y,x) ((y) = getmaxy(w), (x) = getmaxx(w))
#endif
+#include <form.h>
// on some machines move erase and clear conflict with stl
// so remove them from the namespace
diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h
index dd8c02a..fc1b2ba 100644
--- a/Source/CursesDialog/cmCursesStringWidget.h
+++ b/Source/CursesDialog/cmCursesStringWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesStringWidget_h
-#define __cmCursesStringWidget_h
+#ifndef cmCursesStringWidget_h
+#define cmCursesStringWidget_h
#include "cmCursesWidget.h"
@@ -73,4 +73,4 @@ protected:
bool Done;
};
-#endif // __cmCursesStringWidget_h
+#endif // cmCursesStringWidget_h
diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h
index d91a0cb..7d82864 100644
--- a/Source/CursesDialog/cmCursesWidget.h
+++ b/Source/CursesDialog/cmCursesWidget.h
@@ -9,8 +9,8 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#ifndef __cmCursesWidget_h
-#define __cmCursesWidget_h
+#ifndef cmCursesWidget_h
+#define cmCursesWidget_h
#include "../cmCacheManager.h"
#include "cmCursesStandardIncludes.h"
@@ -84,4 +84,4 @@ protected:
int Page;
};
-#endif // __cmCursesWidget_h
+#endif // cmCursesWidget_h
diff --git a/Source/CursesDialog/form/fld_attr.c b/Source/CursesDialog/form/fld_attr.c
index 8619588..35ea903 100644
--- a/Source/CursesDialog/form/fld_attr.c
+++ b/Source/CursesDialog/form/fld_attr.c
@@ -29,13 +29,7 @@
/****************************************************************************
* Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
-#if defined(__hpux)
- #define _XOPEN_SOURCE_EXTENDED
-#endif
- #include "form.priv.h"
-#if defined(__hpux)
- #undef _XOPEN_SOURCE_EXTENDED
-#endif
+#include "form.priv.h"
MODULE_ID("$Id$")
/*----------------------------------------------------------------------------
diff --git a/Source/CursesDialog/form/form.h b/Source/CursesDialog/form/form.h
index 94f05af..1219cb5 100644
--- a/Source/CursesDialog/form/form.h
+++ b/Source/CursesDialog/form/form.h
@@ -47,7 +47,17 @@
# elif defined(CURSES_HAVE_NCURSES_CURSES_H)
# include <ncurses/curses.h>
# else
+# if defined(__hpux)
+# if defined(_XOPEN_SOURCE_EXTENDED)
+# define HAVE__XOPEN_SOURCE_EXTENDED
+# else
+# define _XOPEN_SOURCE_EXTENDED
+# endif
+# endif
# include <curses.h>
+# if defined(__hpux) && !defined(HAVE__XOPEN_SOURCE_EXTENDED)
+# undef _XOPEN_SOURCE_EXTENDED
+# endif
# endif
#include <eti.h>
diff --git a/Source/CursesDialog/form/form.priv.h b/Source/CursesDialog/form/form.priv.h
index 3691f2f..8516a6f 100644
--- a/Source/CursesDialog/form/form.priv.h
+++ b/Source/CursesDialog/form/form.priv.h
@@ -33,12 +33,6 @@
#include "mf_common.h"
#include "form.h"
-/* get around odd bug on aCC and itanium */
-#if defined(__hpux) && defined(__ia64)
-#define getmaxx __getmaxx
-#define getmaxy __getmaxy
-#endif
-
/* form status values */
#define _OVLMODE (0x04) /* Form is in overlay mode */
#define _WINDOW_MODIFIED (0x10) /* Current field window has been modified */
diff --git a/Source/CursesDialog/form/frm_driver.c b/Source/CursesDialog/form/frm_driver.c
index b9611bf..26f580e 100644
--- a/Source/CursesDialog/form/frm_driver.c
+++ b/Source/CursesDialog/form/frm_driver.c
@@ -29,13 +29,7 @@
/****************************************************************************
* Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
****************************************************************************/
-#if defined(__hpux)
- #define _XOPEN_SOURCE_EXTENDED
-#endif
#include "form.priv.h"
-#if defined(__hpux)
- #undef _XOPEN_SOURCE_EXTENDED
-#endif
/* AIX seems to define this */
#undef lines
@@ -357,12 +351,7 @@ static void Buffer_To_Window(const FIELD * field, WINDOW * win)
assert(win && field);
-#if defined(__LSB_VERSION__)
getmaxyx(win, height, width);
-#else
- width = getmaxx(win);
- height = getmaxy(win);
-#endif
for(row=0, pBuffer=field->buf;
row < height;
@@ -394,17 +383,13 @@ static void Window_To_Buffer(WINDOW * win, FIELD * field)
int pad;
int len = 0;
char *p;
- int row, height;
+ int row, height, width;
assert(win && field && field->buf );
pad = field->pad;
p = field->buf;
-#if defined(__LSB_VERSION__)
- { int width; getmaxyx(win, height, width); }
-#else
- height = getmaxy(win);
-#endif
+ getmaxyx(win, height, width);
for(row=0; (row < height) && (row < field->drows); row++ )
{
diff --git a/Source/CursesDialog/form/frm_post.c b/Source/CursesDialog/form/frm_post.c
index 3c63de7..924fe6a 100644
--- a/Source/CursesDialog/form/frm_post.c
+++ b/Source/CursesDialog/form/frm_post.c
@@ -63,12 +63,7 @@ int post_form(FORM * form)
RETURN(E_NOT_CONNECTED);
formwin = Get_Form_Window(form);
-#if defined(__LSB_VERSION__)
getmaxyx(formwin, height, width);
-#else
- width = getmaxx(formwin);
- height = getmaxy(formwin);
-#endif
if ((form->cols > width) || (form->rows > height))
RETURN(E_NO_ROOM);
diff --git a/Source/CursesDialog/form/frm_req_name.c b/Source/CursesDialog/form/frm_req_name.c
index b108dab..6fb9183 100644
--- a/Source/CursesDialog/form/frm_req_name.c
+++ b/Source/CursesDialog/form/frm_req_name.c
@@ -35,13 +35,7 @@
* Routines to handle external names of menu requests *
***************************************************************************/
-#if defined(__hpux)
- #define _XOPEN_SOURCE_EXTENDED
-#endif
#include "form.priv.h"
-#if defined(__hpux)
- #undef _XOPEN_SOURCE_EXTENDED
-#endif
MODULE_ID("$Id$")
diff --git a/Source/QtDialog/CMake.desktop b/Source/QtDialog/CMake.desktop
index 7be495f..842091f 100644
--- a/Source/QtDialog/CMake.desktop
+++ b/Source/QtDialog/CMake.desktop
@@ -3,7 +3,7 @@ Version=1.0
Name=CMake
Comment=Cross-platform buildsystem
Exec=cmake-gui %f
-Icon=CMakeSetup32
+Icon=CMakeSetup
Terminal=false
X-MultipleArgs=false
Type=Application
diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt
index 03c2fb4..b59af94 100644
--- a/Source/QtDialog/CMakeLists.txt
+++ b/Source/QtDialog/CMakeLists.txt
@@ -171,11 +171,17 @@ set(CMAKE_INSTALL_DESTINATION_ARGS
install(TARGETS cmake-gui RUNTIME DESTINATION bin ${CMAKE_INSTALL_DESTINATION_ARGS})
-if(UNIX)
+if(UNIX AND NOT APPLE)
+ foreach (size IN ITEMS 32 128)
+ install(
+ FILES "${CMAKE_CURRENT_SOURCE_DIR}/CMakeSetup${size}.png"
+ DESTINATION "share/icons/hicolor/${size}x${size}/apps"
+ RENAME "CMakeSetup.png")
+ endforeach ()
+
# install a desktop file so CMake appears in the application start menu
# with an icon
install(FILES CMake.desktop DESTINATION share/applications )
- install(FILES CMakeSetup32.png DESTINATION share/pixmaps )
install(FILES cmakecache.xml DESTINATION share/mime/packages )
endif()
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 0574681..b8077f2 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -119,7 +119,7 @@ CMakeSetupDialog::CMakeSetupDialog()
QAction* showChangesAction = ToolsMenu->addAction(tr("&Show My Changes"));
QObject::connect(showChangesAction, SIGNAL(triggered(bool)),
this, SLOT(showUserChanges()));
-#if defined(Q_WS_MAC)
+#if defined(Q_WS_MAC) || defined(Q_OS_MAC)
this->InstallForCommandLineAction
= ToolsMenu->addAction(tr("&Install For Command Line Use"));
QObject::connect(this->InstallForCommandLineAction, SIGNAL(triggered(bool)),
diff --git a/Source/QtDialog/CMakeSetupDialog.ui b/Source/QtDialog/CMakeSetupDialog.ui
index 98da249..b04bd93 100644
--- a/Source/QtDialog/CMakeSetupDialog.ui
+++ b/Source/QtDialog/CMakeSetupDialog.ui
@@ -134,7 +134,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
- <width>40</width>
+ <width>12</width>
<height>23</height>
</size>
</property>
diff --git a/Source/QtDialog/QCMake.h b/Source/QtDialog/QCMake.h
index bd82f0d..d910eb7 100644
--- a/Source/QtDialog/QCMake.h
+++ b/Source/QtDialog/QCMake.h
@@ -10,8 +10,8 @@
See the License for more information.
============================================================================*/
-#ifndef __QCMake_h
-#define __QCMake_h
+#ifndef QCMake_h
+#define QCMake_h
#ifdef _MSC_VER
#pragma warning ( disable : 4127 )
#pragma warning ( disable : 4512 )
@@ -152,5 +152,5 @@ protected:
QAtomicInt InterruptFlag;
};
-#endif // __QCMake_h
+#endif // QCMake_h
diff --git a/Source/QtDialog/QMacInstallDialog.cxx b/Source/QtDialog/QMacInstallDialog.cxx
index 8b8c531..fa7df43 100644
--- a/Source/QtDialog/QMacInstallDialog.cxx
+++ b/Source/QtDialog/QMacInstallDialog.cxx
@@ -15,11 +15,11 @@ QMacInstallDialog::QMacInstallDialog(QWidget*w)
{
this->Internals = new QMacInstallDialogInternals;
this->Internals->setupUi(this);
- QObject::connect(this->Internals->choosePathButton, SIGNAL(pressed()),
+ QObject::connect(this->Internals->choosePathButton, SIGNAL(clicked(bool)),
this, SLOT(ShowBrowser()));
- QObject::connect(this->Internals->skipInstallButton, SIGNAL(pressed()),
+ QObject::connect(this->Internals->skipInstallButton, SIGNAL(clicked(bool)),
this, SLOT(SkipInstall()));
- QObject::connect(this->Internals->doInstallButton, SIGNAL(pressed()),
+ QObject::connect(this->Internals->doInstallButton, SIGNAL(clicked(bool)),
this, SLOT(DoInstall()));
this->Internals->InstallPrefix->setText("/usr/bin/");
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 6a95550..8fb49ca 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -32,9 +32,10 @@ bool cmAddCustomCommandCommand
std::string source, target, main_dependency, working;
std::string comment_buffer;
const char* comment = 0;
- std::vector<std::string> depends, outputs, output;
+ std::vector<std::string> depends, outputs, output, byproducts;
bool verbatim = false;
bool append = false;
+ bool uses_terminal = false;
std::string implicit_depends_lang;
cmCustomCommand::ImplicitDependsList implicit_depends;
@@ -56,6 +57,7 @@ bool cmAddCustomCommandCommand
doing_main_dependency,
doing_output,
doing_outputs,
+ doing_byproducts,
doing_comment,
doing_working_directory,
doing_nothing
@@ -102,6 +104,10 @@ bool cmAddCustomCommandCommand
{
append = true;
}
+ else if(copy == "USES_TERMINAL")
+ {
+ uses_terminal = true;
+ }
else if(copy == "TARGET")
{
doing = doing_target;
@@ -122,6 +128,10 @@ bool cmAddCustomCommandCommand
{
doing = doing_output;
}
+ else if (copy == "BYPRODUCTS")
+ {
+ doing = doing_byproducts;
+ }
else if (copy == "WORKING_DIRECTORY")
{
doing = doing_working_directory;
@@ -145,6 +155,7 @@ bool cmAddCustomCommandCommand
{
case doing_output:
case doing_outputs:
+ case doing_byproducts:
if (!cmSystemTools::FileIsFullPath(copy.c_str()))
{
// This is an output to be generated, so it should be
@@ -228,6 +239,9 @@ bool cmAddCustomCommandCommand
case doing_outputs:
outputs.push_back(filename);
break;
+ case doing_byproducts:
+ byproducts.push_back(filename);
+ break;
case doing_comment:
comment_buffer = copy;
comment = comment_buffer.c_str();
@@ -267,7 +281,9 @@ bool cmAddCustomCommandCommand
}
// Make sure the output names and locations are safe.
- if(!this->CheckOutputs(output) || !this->CheckOutputs(outputs))
+ if(!this->CheckOutputs(output) ||
+ !this->CheckOutputs(outputs) ||
+ !this->CheckOutputs(byproducts))
{
return false;
}
@@ -289,7 +305,7 @@ bool cmAddCustomCommandCommand
}
// No command for this output exists.
- cmOStringStream e;
+ std::ostringstream e;
e << "given APPEND option with output \"" << output[0]
<< "\" which is not already a custom command output.";
this->SetError(e.str());
@@ -300,7 +316,7 @@ bool cmAddCustomCommandCommand
if(!working.empty())
{
const char* build_dir = this->Makefile->GetCurrentOutputDirectory();
- working = cmSystemTools::CollapseFullPath(working.c_str(), build_dir);
+ working = cmSystemTools::CollapseFullPath(working, build_dir);
}
// Choose which mode of the command to use.
@@ -309,19 +325,19 @@ bool cmAddCustomCommandCommand
{
// Source is empty, use the target.
std::vector<std::string> no_depends;
- this->Makefile->AddCustomCommandToTarget(target, no_depends,
+ this->Makefile->AddCustomCommandToTarget(target, byproducts, no_depends,
commandLines, cctype,
comment, working.c_str(),
- escapeOldStyle);
+ escapeOldStyle, uses_terminal);
}
else if(target.empty())
{
// Target is empty, use the output.
- this->Makefile->AddCustomCommandToOutput(output, depends,
- main_dependency,
+ this->Makefile->AddCustomCommandToOutput(output, byproducts,
+ depends, main_dependency,
commandLines, comment,
working.c_str(), false,
- escapeOldStyle);
+ escapeOldStyle, uses_terminal);
// Add implicit dependency scanning requests if any were given.
if(!implicit_depends.empty())
@@ -338,7 +354,7 @@ bool cmAddCustomCommandCommand
}
if(!okay)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not locate source file with a custom command producing \""
<< output[0] << "\" even though this command tried to create it!";
this->SetError(e.str());
@@ -346,10 +362,20 @@ bool cmAddCustomCommandCommand
}
}
}
+ else if (!byproducts.empty())
+ {
+ this->SetError("BYPRODUCTS may not be specified with SOURCE signatures");
+ return false;
+ }
+ else if (uses_terminal)
+ {
+ this->SetError("USES_TERMINAL may not be used with SOURCE signatures");
+ return false;
+ }
else
{
bool issueMessage = true;
- cmOStringStream e;
+ std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0050))
{
@@ -410,7 +436,7 @@ cmAddCustomCommandCommand
std::string::size_type pos = o->find_first_of("#<>");
if(pos != o->npos)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "called with OUTPUT containing a \"" << (*o)[pos]
<< "\". This character is not allowed.";
this->SetError(msg.str());
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index 2fb0eb3..a0e20c8 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -30,7 +30,7 @@ bool cmAddCustomTargetCommand
// Check the target name.
if(targetName.find_first_of("/\\") != targetName.npos)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "called with invalid target name \"" << targetName
<< "\". Target names may not contain a slash. "
<< "Use ADD_CUSTOM_COMMAND to generate files.";
@@ -45,9 +45,10 @@ bool cmAddCustomTargetCommand
cmCustomCommandLines commandLines;
// Accumulate dependencies.
- std::vector<std::string> depends;
+ std::vector<std::string> depends, byproducts;
std::string working_directory;
bool verbatim = false;
+ bool uses_terminal = false;
std::string comment_buffer;
const char* comment = 0;
std::vector<std::string> sources;
@@ -56,10 +57,11 @@ bool cmAddCustomTargetCommand
enum tdoing {
doing_command,
doing_depends,
+ doing_byproducts,
doing_working_directory,
doing_comment,
doing_source,
- doing_verbatim
+ doing_nothing
};
tdoing doing = doing_command;
@@ -84,15 +86,24 @@ bool cmAddCustomTargetCommand
{
doing = doing_depends;
}
+ else if(copy == "BYPRODUCTS")
+ {
+ doing = doing_byproducts;
+ }
else if(copy == "WORKING_DIRECTORY")
{
doing = doing_working_directory;
}
else if(copy == "VERBATIM")
{
- doing = doing_verbatim;
+ doing = doing_nothing;
verbatim = true;
}
+ else if(copy == "USES_TERMINAL")
+ {
+ doing = doing_nothing;
+ uses_terminal = true;
+ }
else if (copy == "COMMENT")
{
doing = doing_comment;
@@ -122,6 +133,19 @@ bool cmAddCustomTargetCommand
case doing_command:
currentLine.push_back(copy);
break;
+ case doing_byproducts:
+ {
+ std::string filename;
+ if (!cmSystemTools::FileIsFullPath(copy.c_str()))
+ {
+ filename = this->Makefile->GetCurrentOutputDirectory();
+ filename += "/";
+ }
+ filename += copy;
+ cmSystemTools::ConvertToUnixSlashes(filename);
+ byproducts.push_back(filename);
+ }
+ break;
case doing_depends:
{
std::string dep = copy;
@@ -146,7 +170,7 @@ bool cmAddCustomTargetCommand
std::string::size_type pos = targetName.find_first_of("#<>");
if(pos != targetName.npos)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "called with target name containing a \"" << targetName[pos]
<< "\". This character is not allowed.";
this->SetError(msg.str());
@@ -165,7 +189,7 @@ bool cmAddCustomTargetCommand
if (!nameOk)
{
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- cmOStringStream e;
+ std::ostringstream e;
bool issueMessage = false;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
{
@@ -218,15 +242,30 @@ bool cmAddCustomTargetCommand
{
const char* build_dir = this->Makefile->GetCurrentOutputDirectory();
working_directory =
- cmSystemTools::CollapseFullPath(working_directory.c_str(), build_dir);
+ cmSystemTools::CollapseFullPath(working_directory, build_dir);
+ }
+
+ if (commandLines.empty() && !byproducts.empty())
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "BYPRODUCTS may not be specified without any COMMAND");
+ return true;
+ }
+ if (commandLines.empty() && uses_terminal)
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "USES_TERMINAL may not be specified without any COMMAND");
+ return true;
}
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
cmTarget* target =
this->Makefile->AddUtilityCommand(targetName, excludeFromAll,
- working_directory.c_str(), depends,
- commandLines, escapeOldStyle, comment);
+ working_directory.c_str(),
+ byproducts, depends,
+ commandLines, escapeOldStyle, comment,
+ uses_terminal);
// Add additional user-specified source files to the target.
target->AddSources(sources);
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index e897d81..b560452 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -26,7 +26,7 @@ bool cmAddDependenciesCommand
std::string target_name = args[0];
if(this->Makefile->IsAlias(target_name))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot add target-level dependencies to alias target \""
<< target_name << "\".\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -35,7 +35,7 @@ bool cmAddDependenciesCommand
{
if (target->GetType() == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot add target-level dependencies to INTERFACE library "
"target \"" << target_name << "\".\n";
this->SetError(e.str());
@@ -51,7 +51,7 @@ bool cmAddDependenciesCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot add target-level dependencies to non-existent target \""
<< target_name << "\".\n"
<< "The add_dependencies works for top-level logical targets created "
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index c30e764..74dc8eb 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -79,7 +79,7 @@ bool cmAddExecutableCommand
if (!nameOk)
{
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- cmOStringStream e;
+ std::ostringstream e;
bool issueMessage = false;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
{
@@ -149,7 +149,7 @@ bool cmAddExecutableCommand
}
if(args.size() != 3)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "ALIAS requires exactly one target argument.";
this->SetError(e.str());
return false;
@@ -158,7 +158,7 @@ bool cmAddExecutableCommand
const char *aliasedName = s->c_str();
if(this->Makefile->IsAlias(aliasedName))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
this->SetError(e.str());
@@ -168,7 +168,7 @@ bool cmAddExecutableCommand
this->Makefile->FindTargetToUse(aliasedName, true);
if(!aliasedTarget)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" does not already "
"exist.";
@@ -178,7 +178,7 @@ bool cmAddExecutableCommand
cmTarget::TargetType type = aliasedTarget->GetType();
if(type != cmTarget::EXECUTABLE)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" is not an "
"executable.";
@@ -187,7 +187,7 @@ bool cmAddExecutableCommand
}
if(aliasedTarget->IsImported())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" is IMPORTED.";
this->SetError(e.str());
@@ -203,7 +203,7 @@ bool cmAddExecutableCommand
// Make sure the target does not already exist.
if(this->Makefile->FindTargetToUse(exename))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create imported target \"" << exename
<< "\" because another target with the same name already exists.";
this->SetError(e.str());
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index cdc9f2a..db2f6fb 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -51,7 +51,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting STATIC type.";
this->SetError(e.str());
return false;
@@ -64,7 +64,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting SHARED type.";
this->SetError(e.str());
return false;
@@ -77,7 +77,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting MODULE type.";
this->SetError(e.str());
return false;
@@ -90,7 +90,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting OBJECT type.";
this->SetError(e.str());
return false;
@@ -103,7 +103,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting UNKNOWN type.";
this->SetError(e.str());
return false;
@@ -116,7 +116,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
this->SetError(e.str());
return false;
@@ -128,21 +128,21 @@ bool cmAddLibraryCommand
{
if (haveSpecifiedType)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting/multiple types.";
this->SetError(e.str());
return false;
}
if (isAlias)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
this->SetError(e.str());
return false;
}
if (excludeFromAll)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
this->SetError(e.str());
return false;
@@ -155,7 +155,7 @@ bool cmAddLibraryCommand
{
if (type == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
this->SetError(e.str());
return false;
@@ -175,7 +175,7 @@ bool cmAddLibraryCommand
}
else if(type == cmTarget::INTERFACE_LIBRARY && *s == "GLOBAL")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "GLOBAL option may only be used with IMPORTED libraries.";
this->SetError(e.str());
return false;
@@ -190,14 +190,14 @@ bool cmAddLibraryCommand
{
if (s != args.end())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library requires no source arguments.";
this->SetError(e.str());
return false;
}
if (importGlobal && !importTarget)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
this->SetError(e.str());
return false;
@@ -214,7 +214,7 @@ bool cmAddLibraryCommand
if (!nameOk)
{
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
- cmOStringStream e;
+ std::ostringstream e;
bool issueMessage = false;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0037))
{
@@ -267,7 +267,7 @@ bool cmAddLibraryCommand
}
if(args.size() != 3)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "ALIAS requires exactly one target argument.";
this->SetError(e.str());
return false;
@@ -276,7 +276,7 @@ bool cmAddLibraryCommand
const char *aliasedName = s->c_str();
if(this->Makefile->IsAlias(aliasedName))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
this->SetError(e.str());
@@ -286,7 +286,7 @@ bool cmAddLibraryCommand
this->Makefile->FindTargetToUse(aliasedName, true);
if(!aliasedTarget)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" does not already "
"exist.";
@@ -300,7 +300,7 @@ bool cmAddLibraryCommand
&& aliasedType != cmTarget::OBJECT_LIBRARY
&& aliasedType != cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is not a library.";
this->SetError(e.str());
@@ -308,7 +308,7 @@ bool cmAddLibraryCommand
}
if(aliasedTarget->IsImported())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is IMPORTED.";
this->SetError(e.str());
@@ -328,13 +328,12 @@ bool cmAddLibraryCommand
CMAKE_${LANG}_CREATE_SHARED_LIBRARY is defined and if not default to
STATIC. But at this point we know only the name of the target, but not
yet its linker language. */
- if ((type != cmTarget::STATIC_LIBRARY) &&
- (type != cmTarget::OBJECT_LIBRARY) &&
- (type != cmTarget::INTERFACE_LIBRARY) &&
+ if ((type == cmTarget::SHARED_LIBRARY ||
+ type == cmTarget::MODULE_LIBRARY) &&
(this->Makefile->GetCMakeInstance()->GetPropertyAsBool(
"TARGET_SUPPORTS_SHARED_LIBS") == false))
{
- cmOStringStream w;
+ std::ostringstream w;
w <<
"ADD_LIBRARY called with " <<
(type==cmTarget::SHARED_LIBRARY ? "SHARED" : "MODULE") <<
@@ -365,7 +364,7 @@ bool cmAddLibraryCommand
{
if (!cmGeneratorExpression::IsValidTargetName(libName))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
this->SetError(e.str());
return false;
@@ -375,7 +374,7 @@ bool cmAddLibraryCommand
// Make sure the target does not already exist.
if(this->Makefile->FindTargetToUse(libName))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create imported target \"" << libName
<< "\" because another target with the same name already exists.";
this->SetError(e.str());
@@ -414,7 +413,7 @@ bool cmAddLibraryCommand
if (!cmGeneratorExpression::IsValidTargetName(libName)
|| libName.find("::") != std::string::npos)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Invalid name for INTERFACE library target: " << libName;
this->SetError(e.str());
return false;
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 4ea2524..01598bc 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -37,7 +37,7 @@ bool cmAddSubDirectoryCommand::InitialPass
excludeFromAll = true;
continue;
}
- else if (!binArg.size())
+ else if (binArg.empty())
{
binArg = *i;
}
@@ -61,7 +61,7 @@ bool cmAddSubDirectoryCommand::InitialPass
srcPath += "/";
srcPath += srcArg;
}
- if(!cmSystemTools::FileIsDirectory(srcPath.c_str()))
+ if(!cmSystemTools::FileIsDirectory(srcPath))
{
std::string error = "given source \"";
error += srcArg;
@@ -69,7 +69,7 @@ bool cmAddSubDirectoryCommand::InitialPass
this->SetError(error);
return false;
}
- srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str());
+ srcPath = cmSystemTools::CollapseFullPath(srcPath);
// Compute the full path to the binary directory.
std::string binPath;
@@ -78,10 +78,10 @@ bool cmAddSubDirectoryCommand::InitialPass
// No binary directory was specified. If the source directory is
// not a subdirectory of the current directory then it is an
// error.
- if(!cmSystemTools::IsSubDirectory(srcPath.c_str(),
+ if(!cmSystemTools::IsSubDirectory(srcPath,
this->Makefile->GetCurrentDirectory()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "not given a binary directory but the given source directory "
<< "\"" << srcPath << "\" is not a subdirectory of \""
<< this->Makefile->GetCurrentDirectory() << "\". "
@@ -118,7 +118,7 @@ bool cmAddSubDirectoryCommand::InitialPass
binPath += binArg;
}
}
- binPath = cmSystemTools::CollapseFullPath(binPath.c_str());
+ binPath = cmSystemTools::CollapseFullPath(binPath);
// Add the subdirectory using the computed full paths.
this->Makefile->AddSubDirectory(srcPath, binPath,
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index 2531a1a..3472b98 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -36,11 +36,7 @@ bool cmAddTestCommand
// Collect the command with arguments.
std::vector<std::string> command;
- for(std::vector<std::string>::const_iterator it = args.begin() + 1;
- it != args.end(); ++it)
- {
- command.push_back(*it);
- }
+ command.insert(command.end(), args.begin() + 1, args.end());
// Create the test but add a generator only the first time it is
// seen. This preserves behavior from before test generators.
@@ -51,7 +47,7 @@ bool cmAddTestCommand
// allow it to be duplicated.
if(!test->GetOldStyle())
{
- cmOStringStream e;
+ std::ostringstream e;
e << " given test name \"" << args[0]
<< "\" which already exists in this directory.";
this->SetError(e.str());
@@ -135,7 +131,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << " given unknown argument:\n " << args[i] << "\n";
this->SetError(e.str());
return false;
@@ -159,7 +155,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
// Require a unique test name within the directory.
if(this->Makefile->GetTest(name))
{
- cmOStringStream e;
+ std::ostringstream e;
e << " given test NAME \"" << name
<< "\" which already exists in this directory.";
this->SetError(e.str());
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index a2aecac..cf2fe82 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -12,10 +12,12 @@
#include "cmArchiveWrite.h"
#include "cmSystemTools.h"
+#include "cmLocale.h"
#include <cmsys/ios/iostream>
#include <cmsys/Directory.hxx>
#include <cmsys/FStream.hxx>
#include <cm_libarchive.h>
+#include "cm_get_date.h"
//----------------------------------------------------------------------------
static std::string cm_archive_error_string(struct archive* a)
@@ -259,6 +261,9 @@ bool cmArchiveWrite::AddFile(const char* file,
}
const char* out = file + skip;
+ cmLocaleRAII localeRAII;
+ static_cast<void>(localeRAII);
+
// Meta-data.
std::string dest = prefix? prefix : "";
dest += out;
@@ -271,10 +276,26 @@ bool cmArchiveWrite::AddFile(const char* file,
cm_archive_entry_copy_pathname(e, dest);
if(archive_read_disk_entry_from_file(this->Disk, e, -1, 0) != ARCHIVE_OK)
{
- this->Error = "archive_read_disk_entry_from_file: ";
+ this->Error = "archive_read_disk_entry_from_file '";
+ this->Error += file;
+ this->Error += "': ";
this->Error += cm_archive_error_string(this->Disk);
return false;
}
+ if (!this->MTime.empty())
+ {
+ time_t now;
+ time(&now);
+ time_t t = cm_get_date(now, this->MTime.c_str());
+ if (t == -1)
+ {
+ this->Error = "unable to parse mtime '";
+ this->Error += this->MTime;
+ this->Error += "'";
+ return false;
+ }
+ archive_entry_set_mtime(e, t, 0);
+ }
// Clear acl and xattr fields not useful for distribution.
archive_entry_acl_clear(e);
archive_entry_xattr_clear(e);
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index a6dcc0e..17357b4 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -74,6 +74,7 @@ public:
// std::cout.
void SetVerbose(bool v) { this->Verbose = v; }
+ void SetMTime(std::string const& t) { this->MTime = t; }
private:
bool Okay() const { return this->Error.empty(); }
bool AddPath(const char* path, size_t skip, const char* prefix);
@@ -90,6 +91,7 @@ private:
struct archive* Disk;
bool Verbose;
std::string Error;
+ std::string MTime;
};
#endif
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index d8c3c43..a30d992 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -61,7 +61,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass
std::string ext = file.substr(dotpos+1);
std::string base = file.substr(0, dotpos);
// Process only source files
- if( base.size() != 0
+ if(!base.empty()
&& std::find( this->Makefile->GetSourceExtensions().begin(),
this->Makefile->GetSourceExtensions().end(), ext )
!= this->Makefile->GetSourceExtensions().end() )
diff --git a/Source/cmBootstrapCommands1.cxx b/Source/cmBootstrapCommands1.cxx
index 9093579..4274d85 100644
--- a/Source/cmBootstrapCommands1.cxx
+++ b/Source/cmBootstrapCommands1.cxx
@@ -28,6 +28,7 @@
#include "cmCMakePolicyCommand.cxx"
#include "cmCommandArgumentsHelper.cxx"
#include "cmConfigureFileCommand.cxx"
+#include "cmContinueCommand.cxx"
#include "cmCoreTryCompile.cxx"
#include "cmCreateTestSourceList.cxx"
#include "cmDefinePropertyCommand.cxx"
@@ -52,6 +53,8 @@
#include "cmFindProgramCommand.cxx"
#include "cmForEachCommand.cxx"
#include "cmFunctionCommand.cxx"
+#include "cmPathLabel.cxx"
+#include "cmSearchPath.cxx"
void GetBootstrapCommands1(std::list<cmCommand*>& commands)
{
@@ -68,6 +71,7 @@ void GetBootstrapCommands1(std::list<cmCommand*>& commands)
commands.push_back(new cmCMakeMinimumRequired);
commands.push_back(new cmCMakePolicyCommand);
commands.push_back(new cmConfigureFileCommand);
+ commands.push_back(new cmContinueCommand);
commands.push_back(new cmCreateTestSourceList);
commands.push_back(new cmDefinePropertyCommand);
commands.push_back(new cmElseCommand);
diff --git a/Source/cmBreakCommand.cxx b/Source/cmBreakCommand.cxx
index b70e400..34245b3 100644
--- a/Source/cmBreakCommand.cxx
+++ b/Source/cmBreakCommand.cxx
@@ -12,10 +12,76 @@
#include "cmBreakCommand.h"
// cmBreakCommand
-bool cmBreakCommand::InitialPass(std::vector<std::string> const&,
+bool cmBreakCommand::InitialPass(std::vector<std::string> const &args,
cmExecutionStatus &status)
{
+ if(!this->Makefile->IsLoopBlock())
+ {
+ bool issueMessage = true;
+ std::ostringstream e;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
+ {
+ case cmPolicies::WARN:
+ e << (this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n";
+ break;
+ case cmPolicies::OLD:
+ issueMessage = false;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ messageType = cmake::FATAL_ERROR;
+ break;
+ }
+
+ if(issueMessage)
+ {
+ e << "A BREAK command was found outside of a proper "
+ "FOREACH or WHILE loop scope.";
+ this->Makefile->IssueMessage(messageType, e.str());
+ if(messageType == cmake::FATAL_ERROR)
+ {
+ return false;
+ }
+ }
+ }
+
status.SetBreakInvoked(true);
+
+ if(!args.empty())
+ {
+ bool issueMessage = true;
+ std::ostringstream e;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0055))
+ {
+ case cmPolicies::WARN:
+ e << (this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0055)) << "\n";
+ break;
+ case cmPolicies::OLD:
+ issueMessage = false;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ messageType = cmake::FATAL_ERROR;
+ break;
+ }
+
+ if(issueMessage)
+ {
+ e << "The BREAK command does not accept any arguments.";
+ this->Makefile->IssueMessage(messageType, e.str());
+ if(messageType == cmake::FATAL_ERROR)
+ {
+ return false;
+ }
+ }
+ }
+
return true;
}
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index 93f7801..5d32437 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -78,7 +78,7 @@ bool cmBuildCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "unknown argument \"" << args[i] << "\"";
this->SetError(e.str());
return false;
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index c64209f..171ed0f 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -50,7 +50,7 @@ bool cmBuildNameCommand
{
buildname = "";
cmSystemTools::RunSingleCommand("uname -a", &buildname);
- if(buildname.length())
+ if(!buildname.empty())
{
std::string RegExp = "([^ ]*) [^ ]* ([^ ]*) ";
cmsys::RegularExpression reg( RegExp.c_str() );
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 58b61de..8591ed6 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -63,22 +63,22 @@ bool cmCMakeMinimumRequired
// Get the current version number.
- int current_major = cmVersion::GetMajorVersion();
- int current_minor = cmVersion::GetMinorVersion();
- int current_patch = cmVersion::GetPatchVersion();
- int current_tweak = cmVersion::GetTweakVersion();
+ unsigned int current_major = cmVersion::GetMajorVersion();
+ unsigned int current_minor = cmVersion::GetMinorVersion();
+ unsigned int current_patch = cmVersion::GetPatchVersion();
+ unsigned int current_tweak = cmVersion::GetTweakVersion();
// Parse at least two components of the version number.
// Use zero for those not specified.
- int required_major = 0;
- int required_minor = 0;
- int required_patch = 0;
- int required_tweak = 0;
+ unsigned int required_major = 0;
+ unsigned int required_minor = 0;
+ unsigned int required_patch = 0;
+ unsigned int required_tweak = 0;
if(sscanf(version_string.c_str(), "%u.%u.%u.%u",
&required_major, &required_minor,
&required_patch, &required_tweak) < 2)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not parse VERSION \"" << version_string << "\".";
this->SetError(e.str());
return false;
@@ -97,7 +97,7 @@ bool cmCMakeMinimumRequired
current_tweak < required_tweak))
{
// The current version is too low.
- cmOStringStream e;
+ std::ostringstream e;
e << "CMake " << version_string
<< " or higher is required. You are running version "
<< cmVersion::GetCMakeVersion();
@@ -132,7 +132,7 @@ bool cmCMakeMinimumRequired::EnforceUnknownArguments()
{
if(!this->UnknownArguments.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "called with unknown argument \""
<< this->UnknownArguments[0] << "\".";
this->SetError(e.str());
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index ddd5d6a..9662fbf 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -56,7 +56,7 @@ bool cmCMakePolicyCommand
return this->HandleVersionMode(args);
}
- cmOStringStream e;
+ std::ostringstream e;
e << "given unknown first argument \"" << args[0] << "\"";
this->SetError(e.str());
return false;
@@ -82,7 +82,7 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "SET given unrecognized policy status \"" << args[2] << "\"";
this->SetError(e.str());
return false;
@@ -113,7 +113,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
cmPolicies::PolicyID pid;
if(!this->Makefile->GetPolicies()->GetPolicyID(id.c_str(), pid))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "GET given policy \"" << id << "\" which is not known to this "
<< "version of CMake.";
this->SetError(e.str());
@@ -140,7 +140,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
case cmPolicies::REQUIRED_ALWAYS:
// The policy is required to be set before anything needs it.
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Makefile->GetPolicies()->GetRequiredPolicyError(pid)
<< "\n"
<< "The call to cmake_policy(GET " << id << " ...) at which this "
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index dd2a1b8..d0dc30a 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -353,10 +353,11 @@ void CCONV cmAddCustomCommandToTarget(void *arg, const char* target,
}
// Pass the call to the makefile instance.
+ std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
const char* no_comment = 0;
const char* no_working_dir = 0;
- mf->AddCustomCommandToTarget(target, no_depends, commandLines,
+ mf->AddCustomCommandToTarget(target, no_byproducts, no_depends, commandLines,
cctype, no_comment, no_working_dir);
}
@@ -768,7 +769,7 @@ void CCONV cmSourceFileSetName(void *arg, const char* name, const char* dir,
}
}
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot find source file \"" << pathname << "\"";
e << "\n\nTried extensions";
for( std::vector<std::string>::const_iterator ext = sourceExts.begin();
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index a7905a4..f08b87c 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -9,7 +9,7 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#include "cm_curl.h"
+#include "cmCurl.h" // include before anything that includes windows.h
#include "cmCTest.h"
#include "cmake.h"
@@ -192,6 +192,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
FILE* file;
::curl_global_init(CURL_GLOBAL_ALL);
curl = ::curl_easy_init();
+ cmCurlSetCAInfo(curl);
//set request options based on method
switch(method)
@@ -208,11 +209,11 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
return -1;
}
::curl_easy_setopt(curl, CURLOPT_PUT, 1);
- file = cmsys::SystemTools::Fopen(putFile.c_str(), "rb");
+ file = cmsys::SystemTools::Fopen(putFile, "rb");
::curl_easy_setopt(curl, CURLOPT_INFILE, file);
//fall through to append GET fields
case cmCTest::HTTP_GET:
- if(fields.size())
+ if(!fields.empty())
{
url += "?" + fields;
}
@@ -240,7 +241,7 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
//----------------------------------------------------------------------
std::string cmCTest::MakeURLSafe(const std::string& str)
{
- cmOStringStream ost;
+ std::ostringstream ost;
char buffer[10];
for ( std::string::size_type pos = 0; pos < str.size(); pos ++ )
{
@@ -378,13 +379,7 @@ cmCTest::cmCTest()
//----------------------------------------------------------------------
cmCTest::~cmCTest()
{
- cmCTest::t_TestingHandlers::iterator it;
- for ( it = this->TestingHandlers.begin();
- it != this->TestingHandlers.end(); ++ it )
- {
- delete it->second;
- it->second = 0;
- }
+ cmDeleteAll(this->TestingHandlers);
this->SetOutputLogFileName(0);
}
@@ -524,7 +519,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
std::string testingDir = this->BinaryDir + "/Testing";
if ( cmSystemTools::FileExists(testingDir.c_str()) )
{
- if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) )
+ if ( !cmSystemTools::FileIsDirectory(testingDir) )
{
cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir
<< " is in the place of the testing directory" << std::endl);
@@ -586,7 +581,7 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
}
tfin.close();
}
- if (tag.size() == 0 || (0 != command) || this->Parts[PartStart])
+ if (tag.empty() || (0 != command) || this->Parts[PartStart])
{
cmCTestLog(this, DEBUG, "TestModel: " << this->GetTestModelString()
<< std::endl);
@@ -778,7 +773,7 @@ bool cmCTest::UpdateCTestConfiguration()
fin.getline(buffer, 1023);
buffer[1023] = 0;
std::string line = cmCTest::CleanString(buffer);
- if(line.size() == 0)
+ if(line.empty())
{
continue;
}
@@ -809,7 +804,7 @@ bool cmCTest::UpdateCTestConfiguration()
if ( !this->GetCTestConfiguration("BuildDirectory").empty() )
{
this->BinaryDir = this->GetCTestConfiguration("BuildDirectory");
- cmSystemTools::ChangeDirectory(this->BinaryDir.c_str());
+ cmSystemTools::ChangeDirectory(this->BinaryDir);
}
this->TimeOut = atoi(this->GetCTestConfiguration("TimeOut").c_str());
if ( this->ProduceXML )
@@ -878,13 +873,13 @@ bool cmCTest::OpenOutputFile(const std::string& path,
bool compress)
{
std::string testingDir = this->BinaryDir + "/Testing";
- if ( path.size() > 0 )
+ if (!path.empty())
{
testingDir += "/" + path;
}
if ( cmSystemTools::FileExists(testingDir.c_str()) )
{
- if ( !cmSystemTools::FileIsDirectory(testingDir.c_str()) )
+ if ( !cmSystemTools::FileIsDirectory(testingDir) )
{
cmCTestLog(this, ERROR_MESSAGE, "File " << testingDir
<< " is in the place of the testing directory"
@@ -1061,19 +1056,19 @@ int cmCTest::ProcessTests()
if ( !notest )
{
std::string notes_dir = this->BinaryDir + "/Testing/Notes";
- if ( cmSystemTools::FileIsDirectory(notes_dir.c_str()) )
+ if ( cmSystemTools::FileIsDirectory(notes_dir) )
{
cmsys::Directory d;
- d.Load(notes_dir.c_str());
+ d.Load(notes_dir);
unsigned long kk;
for ( kk = 0; kk < d.GetNumberOfFiles(); kk ++ )
{
const char* file = d.GetFile(kk);
std::string fullname = notes_dir + "/" + file;
if ( cmSystemTools::FileExists(fullname.c_str()) &&
- !cmSystemTools::FileIsDirectory(fullname.c_str()) )
+ !cmSystemTools::FileIsDirectory(fullname) )
{
- if ( this->NotesFiles.size() > 0 )
+ if (!this->NotesFiles.empty())
{
this->NotesFiles += ";";
}
@@ -1086,7 +1081,7 @@ int cmCTest::ProcessTests()
if (this->Parts[PartNotes])
{
this->UpdateCTestConfiguration();
- if ( this->NotesFiles.size() )
+ if (!this->NotesFiles.empty())
{
this->GenerateNotesFile(this->NotesFiles.c_str());
}
@@ -1272,7 +1267,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
std::ostream* log, double testTimeOut,
std::vector<std::string>* environment)
{
- bool modifyEnv = (environment && environment->size()>0);
+ bool modifyEnv = (environment && !environment->empty());
// determine how much time we have
double timeout = this->GetRemainingTimeAllowed() - 120;
@@ -1294,7 +1289,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
"Test timeout computed to be: " << timeout << "\n");
if(cmSystemTools::SameFile(
- argv[0], cmSystemTools::GetCTestCommand().c_str()) &&
+ argv[0], cmSystemTools::GetCTestCommand()) &&
!this->ForceNewCTestProcess)
{
cmCTest inst;
@@ -1302,7 +1297,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
inst.TimeOut = timeout;
// Capture output of the child ctest.
- cmOStringStream oss;
+ std::ostringstream oss;
inst.SetStreams(&oss, &oss);
std::vector<std::string> args;
@@ -1316,7 +1311,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
if (strcmp(argv[i],"--build-generator") == 0 && timeout > 0)
{
args.push_back("--test-timeout");
- cmOStringStream msg;
+ std::ostringstream msg;
msg << timeout;
args.push_back(msg.str());
}
@@ -1342,7 +1337,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
{
*log << *output;
}
- cmSystemTools::ChangeDirectory(oldpath.c_str());
+ cmSystemTools::ChangeDirectory(oldpath);
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT,
"Internal cmCTest object used to run test." << std::endl
@@ -1659,7 +1654,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles)
cmCTestLog(this, OUTPUT, "Create notes file" << std::endl);
files = cmSystemTools::SplitString(cfiles, ';');
- if ( files.size() == 0 )
+ if (files.empty())
{
return 1;
}
@@ -1674,21 +1669,22 @@ std::string cmCTest::Base64GzipEncodeFile(std::string file)
std::vector<std::string> files;
files.push_back(file);
- if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
+ if(!cmSystemTools::CreateTar(tarFile.c_str(), files,
+ cmSystemTools::TarCompressGZip, false))
{
cmCTestLog(this, ERROR_MESSAGE, "Error creating tar while "
"encoding file: " << file << std::endl);
return "";
}
std::string base64 = this->Base64EncodeFile(tarFile);
- cmSystemTools::RemoveFile(tarFile.c_str());
+ cmSystemTools::RemoveFile(tarFile);
return base64;
}
//----------------------------------------------------------------------
std::string cmCTest::Base64EncodeFile(std::string file)
{
- long len = cmSystemTools::FileLength(file.c_str());
+ size_t const len = cmSystemTools::FileLength(file);
cmsys::ifstream ifs(file.c_str(), std::ios::in
#ifdef _WIN32
| std::ios::binary
@@ -1699,14 +1695,13 @@ std::string cmCTest::Base64EncodeFile(std::string file)
ifs.close();
unsigned char *encoded_buffer
- = new unsigned char [ static_cast<int>(
- static_cast<double>(len) * 1.5 + 5.0) ];
+ = new unsigned char [ (len * 3) / 2 + 5 ];
- unsigned long rlen
+ size_t const rlen
= cmsysBase64_Encode(file_buffer, len, encoded_buffer, 1);
std::string base64 = "";
- for(unsigned long i = 0; i < rlen; i++)
+ for(size_t i = 0; i < rlen; i++)
{
base64 += encoded_buffer[i];
}
@@ -1750,7 +1745,7 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles)
cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl);
files = cmSystemTools::SplitString(cfiles, ';');
- if ( files.size() == 0 )
+ if (files.empty())
{
return 1;
}
@@ -2598,16 +2593,14 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
return;
}
cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl);
- std::vector<std::string> slist;
- cmSystemTools::ExpandListArgument(dval, slist);
- std::vector<std::string>::iterator it;
vec.clear();
+ cmSystemTools::ExpandListArgument(dval, vec);
- for ( it = slist.begin(); it != slist.end(); ++it )
+ for (std::vector<std::string>::const_iterator it = vec.begin();
+ it != vec.end(); ++it )
{
cmCTestLog(this, DEBUG, " -- " << *it << std::endl);
- vec.push_back(*it);
}
}
@@ -2628,10 +2621,10 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
{
const std::string& sourceDir
= cmSystemTools::CollapseFullPath(
- this->GetCTestConfiguration("SourceDirectory").c_str());
+ this->GetCTestConfiguration("SourceDirectory"));
const std::string& buildDir
= cmSystemTools::CollapseFullPath(
- this->GetCTestConfiguration("BuildDirectory").c_str());
+ this->GetCTestConfiguration("BuildDirectory"));
std::string fname = cmSystemTools::CollapseFullPath(cfname);
// Find relative paths to both directories
@@ -2860,7 +2853,7 @@ void cmCTest::SetConfigType(const char* ct)
cmSystemTools::ReplaceString(this->ConfigType, ".\\", "");
std::string confTypeEnv
= "CMAKE_CONFIG_TYPE=" + this->ConfigType;
- cmSystemTools::PutEnv(confTypeEnv.c_str());
+ cmSystemTools::PutEnv(confTypeEnv);
}
//----------------------------------------------------------------------
@@ -2944,11 +2937,11 @@ bool cmCTest::RunCommand(
}
cmsysProcess_WaitForExit(cp, 0);
- if ( tempOutput.size() > 0 )
+ if (!tempOutput.empty())
{
stdOut->append(&*tempOutput.begin(), tempOutput.size());
}
- if ( tempError.size() > 0 )
+ if (!tempError.empty())
{
stdErr->append(&*tempError.begin(), tempError.size());
}
@@ -3144,7 +3137,7 @@ double cmCTest::GetRemainingTimeAllowed()
void cmCTest::OutputTestErrors(std::vector<char> const &process_output)
{
std::string test_outputs("\n*** Test Failed:\n");
- if(process_output.size())
+ if(!process_output.empty())
{
test_outputs.append(&*process_output.begin(), process_output.size());
}
@@ -3192,9 +3185,9 @@ bool cmCTest::CompressString(std::string& str)
// Now base64 encode the resulting binary string
unsigned char* base64EncodedBuffer
- = new unsigned char[static_cast<int>(outSize * 1.5)];
+ = new unsigned char[(outSize * 3) / 2];
- unsigned long rlen
+ size_t rlen
= cmsysBase64_Encode(out, strm.total_out, base64EncodedBuffer, 1);
str = "";
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index e19d32c..deb8896 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -27,7 +27,7 @@ class cmCTestStartCommand;
#define cmCTestLog(ctSelf, logType, msg) \
do { \
- cmOStringStream cmCTestLog_msg; \
+ std::ostringstream cmCTestLog_msg; \
cmCTestLog_msg << msg; \
(ctSelf)->Log(cmCTest::logType, __FILE__, __LINE__,\
cmCTestLog_msg.str().c_str());\
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index d6b84a0..45e92ce 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -139,7 +139,7 @@ bool cmCacheManager::ParseEntry(const std::string& entry,
{
// input line is: key:type=value
static cmsys::RegularExpression reg(
- "^([^:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
+ "^([^=:]*):([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
// input line is: "key":type=value
static cmsys::RegularExpression regQuoted(
"^\"([^\"]*)\":([^=]*)=(.*[^\r\t ]|[\r\t ]*)[\r\t ]*$");
@@ -189,7 +189,7 @@ void cmCacheManager::CleanCMakeFiles(const std::string& path)
for(std::vector<std::string>::iterator i = files.begin();
i != files.end(); ++i)
{
- cmSystemTools::RemoveFile(i->c_str());
+ cmSystemTools::RemoveFile(*i);
}
}
@@ -336,7 +336,7 @@ bool cmCacheManager::LoadCache(const std::string& path,
cmSystemTools::ConvertToUnixSlashes(currentcwd);
currentcwd += "/CMakeCache.txt";
oldcwd += "/CMakeCache.txt";
- if(!cmSystemTools::SameFile(oldcwd.c_str(), currentcwd.c_str()))
+ if(!cmSystemTools::SameFile(oldcwd, currentcwd))
{
std::string message =
std::string("The current CMakeCache.txt directory ") +
@@ -586,13 +586,13 @@ bool cmCacheManager::DeleteCache(const std::string& path)
cacheFile += "/CMakeCache.txt";
if(cmSystemTools::FileExists(cacheFile.c_str()))
{
- cmSystemTools::RemoveFile(cacheFile.c_str());
+ cmSystemTools::RemoveFile(cacheFile);
// now remove the files in the CMakeFiles directory
// this cleans up language cache files
cmakeFiles += cmake::GetCMakeFilesDirectory();
- if(cmSystemTools::FileIsDirectory(cmakeFiles.c_str()))
+ if(cmSystemTools::FileIsDirectory(cmakeFiles))
{
- cmSystemTools::RemoveADirectory(cmakeFiles.c_str());
+ cmSystemTools::RemoveADirectory(cmakeFiles);
}
}
return true;
@@ -609,7 +609,7 @@ void cmCacheManager::OutputKey(std::ostream& fout, std::string const& key)
void cmCacheManager::OutputValue(std::ostream& fout, std::string const& value)
{
// if value has trailing space or tab, enclose it in single quotes
- if (value.size() &&
+ if (!value.empty() &&
(value[value.size() - 1] == ' ' ||
value[value.size() - 1] == '\t'))
{
diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx
index 0c15477..c211111 100644
--- a/Source/cmCallVisualStudioMacro.cxx
+++ b/Source/cmCallVisualStudioMacro.cxx
@@ -34,8 +34,6 @@ static bool LogErrorsAsMessages;
// Copied from a correct comdef.h to avoid problems with deficient versions
// of comdef.h that exist in the wild... Fixes issue #7533.
//
-#if ( _MSC_VER >= 1300 )
-// VS7 and later:
#ifdef _NATIVE_WCHAR_T_DEFINED
# ifdef _DEBUG
# pragma comment(lib, "comsuppwd.lib")
@@ -49,10 +47,6 @@ static bool LogErrorsAsMessages;
# pragma comment(lib, "comsupp.lib")
# endif
#endif
-#else
-// VS6 only had comsupp.lib:
-# pragma comment(lib, "comsupp.lib")
-#endif
//----------------------------------------------------------------------------
@@ -63,12 +57,13 @@ static bool LogErrorsAsMessages;
{ \
if (LogErrorsAsMessages) \
{ \
- std::ostringstream oss; \
- oss.flags(std::ios::hex); \
- oss << context << " failed HRESULT, hr = 0x" << hr << std::endl; \
- oss.flags(std::ios::dec); \
- oss << __FILE__ << "(" << __LINE__ << ")"; \
- cmSystemTools::Message(oss.str().c_str()); \
+ std::ostringstream _hresult_oss; \
+ _hresult_oss.flags(std::ios::hex); \
+ _hresult_oss << context << " failed HRESULT, hr = 0x" \
+ << hr << std::endl; \
+ _hresult_oss.flags(std::ios::dec); \
+ _hresult_oss << __FILE__ << "(" << __LINE__ << ")"; \
+ cmSystemTools::Message(_hresult_oss.str().c_str()); \
} \
}
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index a34ea71..6689243 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -155,7 +155,7 @@ public:
*/
const char* GetError()
{
- if(this->Error.length() == 0)
+ if(this->Error.empty())
{
this->Error = this->GetName();
this->Error += " unknown error.";
diff --git a/Source/cmCommandArgumentParser.cxx b/Source/cmCommandArgumentParser.cxx
index c5146c5..9f8a4de 100644
--- a/Source/cmCommandArgumentParser.cxx
+++ b/Source/cmCommandArgumentParser.cxx
@@ -183,12 +183,6 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
#define YYINITDEPTH 10000
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no
diff --git a/Source/cmCommandArgumentParser.y b/Source/cmCommandArgumentParser.y
index 48f5c8e..b1d53f6 100644
--- a/Source/cmCommandArgumentParser.y
+++ b/Source/cmCommandArgumentParser.y
@@ -64,12 +64,6 @@ static void cmCommandArgumentError(yyscan_t yyscanner, const char* message);
#define YYINITDEPTH 10000
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index 64b67c9..747b7e4 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -103,7 +103,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
}
return this->EmptyVariable;
}
- cmOStringStream e;
+ std::ostringstream e;
e << "Syntax $" << key << "{} is not supported. "
<< "Only ${}, $ENV{}, and $CACHE{} are allowed.";
this->SetError(e.str());
@@ -118,7 +118,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
}
if(this->FileLine >= 0 && strcmp(var, "CMAKE_CURRENT_LIST_LINE") == 0)
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << this->FileLine;
return this->AddString(ostr.str());
}
@@ -136,7 +136,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
cmSystemTools::IsSubDirectory(this->FileName,
this->Makefile->GetHomeOutputDirectory()))
{
- cmOStringStream msg;
+ std::ostringstream msg;
cmListFileBacktrace bt(this->Makefile->GetLocalGenerator());
cmListFileContext lfc;
lfc.FilePath = this->FileName;
@@ -253,7 +253,7 @@ bool cmCommandArgumentParserHelper::HandleEscapeSymbol
break;
default:
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Invalid escape sequence \\" << symbol;
this->SetError(e.str());
}
@@ -335,7 +335,7 @@ int cmCommandArgumentParserHelper::LexInput(char* buf, int maxlen)
void cmCommandArgumentParserHelper::Error(const char* str)
{
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << str << " (" << pos << ")";
this->SetError(ostr.str());
}
diff --git a/Source/cmCommandArgumentsHelper.cxx b/Source/cmCommandArgumentsHelper.cxx
index 1d5fc07..1a2efc6 100644
--- a/Source/cmCommandArgumentsHelper.cxx
+++ b/Source/cmCommandArgumentsHelper.cxx
@@ -50,13 +50,8 @@ void cmCommandArgument::FollowsGroup(const cmCommandArgumentGroup* group)
if (group!=0)
{
this->ArgumentsBeforeEmpty = false;
- for(std::vector<cmCommandArgument*>::const_iterator
- argIt= group->ContainedArguments.begin();
- argIt != group->ContainedArguments.end();
- ++argIt)
- {
- this->ArgumentsBefore.insert(*argIt);
- }
+ this->ArgumentsBefore.insert(group->ContainedArguments.begin(),
+ group->ContainedArguments.end());
}
}
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index a636d23..32d5cd3 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -200,12 +200,7 @@ cmComputeLinkDepends
//----------------------------------------------------------------------------
cmComputeLinkDepends::~cmComputeLinkDepends()
{
- for(std::vector<DependSetList*>::iterator
- i = this->InferredDependSets.begin();
- i != this->InferredDependSets.end(); ++i)
- {
- delete *i;
- }
+ cmDeleteAll(this->InferredDependSets);
delete this->CCG;
}
@@ -266,10 +261,9 @@ cmComputeLinkDepends::Compute()
// Iterate in reverse order so we can keep only the last occurrence
// of a shared library.
std::set<int> emmitted;
- const std::vector<int>& cFLO = this->FinalLinkOrder;
for(std::vector<int>::const_reverse_iterator
- li = cFLO.rbegin(),
- le = cFLO.rend();
+ li = this->FinalLinkOrder.rbegin(),
+ le = this->FinalLinkOrder.rend();
li != le; ++li)
{
int i = *li;
@@ -682,11 +676,8 @@ void cmComputeLinkDepends::InferDependencies()
}
// Add the inferred dependencies to the graph.
- for(DependSet::const_iterator j = common.begin(); j != common.end(); ++j)
- {
- int dependee_index = *j;
- this->EntryConstraintGraph[depender_index].push_back(dependee_index);
- }
+ cmGraphEdgeList& edges = this->EntryConstraintGraph[depender_index];
+ edges.insert(edges.end(), common.begin(), common.end());
}
}
@@ -710,7 +701,7 @@ void cmComputeLinkDepends::CleanConstraintGraph()
void cmComputeLinkDepends::DisplayConstraintGraph()
{
// Display the graph nodes and their edges.
- cmOStringStream e;
+ std::ostringstream e;
for(unsigned int i=0; i < this->EntryConstraintGraph.size(); ++i)
{
EdgeList const& nl = this->EntryConstraintGraph[i];
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index e1852a3..479da75 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -408,11 +408,7 @@ cmComputeLinkInformation
// Construct a mask to not bother with this behavior for link
// directories already specified by the user.
std::vector<std::string> const& dirs = this->Target->GetLinkDirectories();
- for(std::vector<std::string>::const_iterator di = dirs.begin();
- di != dirs.end(); ++di)
- {
- this->OldLinkDirMask.insert(*di);
- }
+ this->OldLinkDirMask.insert(dirs.begin(), dirs.end());
}
}
@@ -448,18 +444,7 @@ std::string cmComputeLinkInformation::GetRPathLinkString()
}
// Construct the linker runtime search path.
- std::string rpath_link;
- const char* sep = "";
- std::vector<std::string> const& dirs =
- this->OrderDependentRPath->GetOrderedDirectories();
- for(std::vector<std::string>::const_iterator di = dirs.begin();
- di != dirs.end(); ++di)
- {
- rpath_link += sep;
- sep = ":";
- rpath_link += *di;
- }
- return rpath_link;
+ return cmJoin(this->OrderDependentRPath->GetOrderedDirectories(), ":");
}
//----------------------------------------------------------------------------
@@ -675,7 +660,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
// This is not a CMake target. Use the name given.
if(cmSystemTools::FileIsFullPath(item.c_str()))
{
- if(cmSystemTools::FileIsDirectory(item.c_str()))
+ if(cmSystemTools::FileIsDirectory(item))
{
// This is a directory.
this->AddDirectoryItem(item);
@@ -1342,7 +1327,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
// Try to separate the framework name and path.
if(!this->SplitFramework.find(item.c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
cmSystemTools::Error(e.str().c_str());
@@ -1389,7 +1374,7 @@ void cmComputeLinkInformation::DropDirectoryItem(std::string const& item)
{
// A full path to a directory was found as a link item. Warn the
// user.
- cmOStringStream e;
+ std::ostringstream e;
e << "WARNING: Target \"" << this->Target->GetName()
<< "\" requests linking to directory \"" << item << "\". "
<< "Targets may link only to libraries. "
@@ -1420,11 +1405,8 @@ void cmComputeLinkInformation::ComputeFrameworkInfo()
cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
}
- for(std::vector<std::string>::const_iterator i = implicitDirVec.begin();
- i != implicitDirVec.end(); ++i)
- {
- this->FrameworkPathsEmmitted.insert(*i);
- }
+ this->FrameworkPathsEmmitted.insert(implicitDirVec.begin(),
+ implicitDirVec.end());
// Regular expression to extract a framework path and name.
this->SplitFramework.compile("(.*)/(.*)\\.framework$");
@@ -1505,7 +1487,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
if(!this->CMakeInstance->GetPropertyAsBool(wid))
{
this->CMakeInstance->SetProperty(wid, "1");
- cmOStringStream w;
+ std::ostringstream w;
w << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0008)) << "\n"
<< "Target \"" << this->Target->GetName() << "\" links to item\n"
@@ -1524,7 +1506,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
{
- cmOStringStream e;
+ std::ostringstream e;
e << (this->Makefile->GetPolicies()->
GetRequiredPolicyError(cmPolicies::CMP0008)) << "\n"
<< "Target \"" << this->Target->GetName() << "\" links to item\n"
@@ -1554,7 +1536,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
if(!this->CMakeInstance->GetPropertyAsBool("CMP0003-WARNING-GIVEN"))
{
this->CMakeInstance->SetProperty("CMP0003-WARNING-GIVEN", "1");
- cmOStringStream w;
+ std::ostringstream w;
this->PrintLinkPolicyDiagnosis(w);
this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(),
this->Target->GetBacktrace());
@@ -1569,7 +1551,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories()
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
{
- cmOStringStream e;
+ std::ostringstream e;
e << (this->Makefile->GetPolicies()->
GetRequiredPolicyError(cmPolicies::CMP0003)) << "\n";
this->PrintLinkPolicyDiagnosis(e);
@@ -1694,11 +1676,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
}
// Store implicit link directories.
- for(std::vector<std::string>::const_iterator i = implicitDirVec.begin();
- i != implicitDirVec.end(); ++i)
- {
- this->ImplicitLinkDirs.insert(*i);
- }
+ this->ImplicitLinkDirs.insert(implicitDirVec.begin(), implicitDirVec.end());
// Get language-specific implicit libraries.
std::vector<std::string> implicitLibVec;
@@ -1937,10 +1915,10 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
// Do not add any path inside the source or build tree.
const char* topSourceDir = this->Makefile->GetHomeDirectory();
const char* topBinaryDir = this->Makefile->GetHomeOutputDirectory();
- if(!cmSystemTools::ComparePath(ri->c_str(), topSourceDir) &&
- !cmSystemTools::ComparePath(ri->c_str(), topBinaryDir) &&
- !cmSystemTools::IsSubDirectory(ri->c_str(), topSourceDir) &&
- !cmSystemTools::IsSubDirectory(ri->c_str(), topBinaryDir))
+ if(!cmSystemTools::ComparePath(*ri, topSourceDir) &&
+ !cmSystemTools::ComparePath(*ri, topBinaryDir) &&
+ !cmSystemTools::IsSubDirectory(*ri, topSourceDir) &&
+ !cmSystemTools::IsSubDirectory(*ri, topBinaryDir))
{
std::string d = *ri;
if (!rootPath.empty() && d.find(rootPath) == 0)
@@ -1999,18 +1977,7 @@ std::string cmComputeLinkInformation::GetRPathString(bool for_install)
this->GetRPath(runtimeDirs, for_install);
// Concatenate the paths.
- std::string rpath;
- const char* sep = "";
- for(std::vector<std::string>::const_iterator ri = runtimeDirs.begin();
- ri != runtimeDirs.end(); ++ri)
- {
- // Separate from previous path.
- rpath += sep;
- sep = this->GetRuntimeSep().c_str();
-
- // Add this path.
- rpath += *ri;
- }
+ std::string rpath = cmJoin(runtimeDirs, this->GetRuntimeSep());
// If the rpath will be replaced at install time, prepare space.
if(!for_install && this->RuntimeUseChrpath)
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 75d3967..cf2b88e 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -361,7 +361,7 @@ void cmComputeTargetDepends::AddTargetDepend(
cmMakefile *makefile = depender->GetMakefile();
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
bool issueMessage = false;
- cmOStringStream e;
+ std::ostringstream e;
switch(depender->GetPolicyStatusCMP0046())
{
case cmPolicies::WARN:
@@ -539,7 +539,7 @@ cmComputeTargetDepends
bool strong)
{
// Construct the error message.
- cmOStringStream e;
+ std::ostringstream e;
e << "The inter-target dependency graph contains the following "
<< "strongly connected component (cycle):\n";
std::vector<NodeList> const& components = ccg.GetComponents();
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 6065b8a..eb4f3a1 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -11,7 +11,6 @@
============================================================================*/
#include "cmConditionEvaluator.h"
-#include "cmStringCommand.h"
cmConditionEvaluator::cmConditionEvaluator(cmMakefile& makefile):
Makefile(makefile),
@@ -54,10 +53,7 @@ bool cmConditionEvaluator::IsTrue(
cmArgumentList newArgs;
// copy to the list structure
- for(unsigned int i = 0; i < args.size(); ++i)
- {
- newArgs.push_back(args[i]);
- }
+ newArgs.insert(newArgs.end(), args.begin(), args.end());
// now loop through the arguments and see if we can reduce any of them
// we do this multiple times. Once for each level of precedence
@@ -120,7 +116,7 @@ const char* cmConditionEvaluator::GetDefinitionIfUnquoted(
if(!hasBeenReported)
{
- cmOStringStream e;
+ std::ostringstream e;
e << (this->Makefile.GetPolicies()->GetPolicyWarning(
cmPolicies::CMP0054)) << "\n";
e << "Quoted variables like \"" << argument.GetValue() <<
@@ -170,7 +166,7 @@ bool cmConditionEvaluator::IsKeyword(std::string const& keyword,
if(!hasBeenReported)
{
- cmOStringStream e;
+ std::ostringstream e;
e << (this->Makefile.GetPolicies()->GetPolicyWarning(
cmPolicies::CMP0054)) << "\n";
e << "Quoted keywords like \"" << argument.GetValue() <<
@@ -412,10 +408,7 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList &newArgs,
// copy to the list structure
cmArgumentList::iterator argP1 = arg;
argP1++;
- for(; argP1 != argClose; argP1++)
- {
- newArgs2.push_back(*argP1);
- }
+ newArgs2.insert(newArgs2.end(), argP1, argClose);
newArgs2.pop_back();
// now recursively invoke IsTrue to handle the values inside the
// parenthetical expression
@@ -556,11 +549,11 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
{
def = this->GetVariableOrString(*arg);
const char* rex = argP2->c_str();
- cmStringCommand::ClearMatches(&this->Makefile);
+ this->Makefile.ClearMatches();
cmsys::RegularExpression regEntry;
if ( !regEntry.compile(rex) )
{
- cmOStringStream error;
+ std::ostringstream error;
error << "Regular expression \"" << rex << "\" cannot compile";
errorString = error.str();
status = cmake::FATAL_ERROR;
@@ -568,7 +561,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList &newArgs,
}
if (regEntry.find(def))
{
- cmStringCommand::StoreMatches(&this->Makefile, regEntry);
+ this->Makefile.StoreMatches(regEntry);
*arg = cmExpandedCommandArgument("1", true);
}
else
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index 2b0280d..c0a1aa9 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -9,12 +9,9 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#cmakedefine CMAKE_NO_STD_NAMESPACE
-#cmakedefine CMAKE_NO_ANSI_STREAM_HEADERS
-#cmakedefine CMAKE_NO_ANSI_STRING_STREAM
-#cmakedefine CMAKE_NO_ANSI_FOR_SCOPE
#cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE
#cmakedefine HAVE_UNSETENV
#cmakedefine CMAKE_USE_ELF_PARSER
+#cmakedefine CMAKE_USE_MACH_PARSER
#cmakedefine CMAKE_ENCODING_UTF8
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 395e6c8..fa7f486 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -32,9 +32,9 @@ bool cmConfigureFileCommand
this->InputFile += inFile;
// If the input location is a directory, error out.
- if(cmSystemTools::FileIsDirectory(this->InputFile.c_str()))
+ if(cmSystemTools::FileIsDirectory(this->InputFile))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "input location\n"
<< " " << this->InputFile << "\n"
<< "is a directory but a file was expected.";
@@ -51,7 +51,7 @@ bool cmConfigureFileCommand
this->OutputFile += outFile;
// If the output location is already a directory put the file in it.
- if(cmSystemTools::FileIsDirectory(this->OutputFile.c_str()))
+ if(cmSystemTools::FileIsDirectory(this->OutputFile))
{
this->OutputFile += "/";
this->OutputFile += cmSystemTools::GetFilenameName(inFile);
@@ -74,6 +74,7 @@ bool cmConfigureFileCommand
this->CopyOnly = false;
this->EscapeQuotes = false;
+ std::string unknown_args;
this->AtOnly = false;
for(unsigned int i=2;i < args.size();++i)
{
@@ -99,6 +100,18 @@ bool cmConfigureFileCommand
{
/* Ignore legacy option. */
}
+ else
+ {
+ unknown_args += " ";
+ unknown_args += args[i];
+ unknown_args += "\n";
+ }
+ }
+ if (!unknown_args.empty())
+ {
+ std::string msg = "configure_file called with unknown argument(s):\n";
+ msg += unknown_args;
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, msg);
}
if ( !this->ConfigureFile() )
diff --git a/Source/cmContinueCommand.cxx b/Source/cmContinueCommand.cxx
new file mode 100644
index 0000000..4a03caa
--- /dev/null
+++ b/Source/cmContinueCommand.cxx
@@ -0,0 +1,39 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2014 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmContinueCommand.h"
+
+// cmContinueCommand
+bool cmContinueCommand::InitialPass(std::vector<std::string> const &args,
+ cmExecutionStatus &status)
+{
+ if(!this->Makefile->IsLoopBlock())
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "A CONTINUE command was found outside of a "
+ "proper FOREACH or WHILE loop scope.");
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+
+ status.SetContinueInvoked(true);
+
+ if(!args.empty())
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR,
+ "The CONTINUE command does not accept any "
+ "arguments.");
+ cmSystemTools::SetFatalErrorOccured();
+ return true;
+ }
+
+ return true;
+}
diff --git a/Source/cmContinueCommand.h b/Source/cmContinueCommand.h
new file mode 100644
index 0000000..093b14f
--- /dev/null
+++ b/Source/cmContinueCommand.h
@@ -0,0 +1,55 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2014 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmContinueCommand_h
+#define cmContinueCommand_h
+
+#include "cmCommand.h"
+
+/** \class cmContinueCommand
+ * \brief Continue from an enclosing foreach or while loop
+ *
+ * cmContinueCommand returns from an enclosing foreach or while loop
+ */
+class cmContinueCommand : public cmCommand
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmContinueCommand;
+ }
+
+ /**
+ * This is called when the command is first encountered in
+ * the CMakeLists.txt file.
+ */
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status);
+
+ /**
+ * This determines if the command is invoked when in script mode.
+ */
+ virtual bool IsScriptable() const { return true; }
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual std::string GetName() const { return "continue"; }
+
+ cmTypeMacro(cmContinueCommand, cmCommand);
+};
+
+
+
+#endif
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index bc5708d..5b5d6b6 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -109,7 +109,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
}
default:
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
- "Only libraries may be used as try_compile IMPORTED "
+ "Only libraries may be used as try_compile or try_run IMPORTED "
"LINK_LIBRARIES. Got " + std::string(tgt->GetName()) + " of "
"type " + tgt->GetTargetTypeName(tgt->GetType()) + ".");
return -1;
@@ -150,7 +150,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
}
else
{
- cmOStringStream m;
+ std::ostringstream m;
m << "try_compile given unknown argument \"" << argv[i] << "\".";
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
}
@@ -201,13 +201,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
else
{
// only valid for srcfile signatures
- if (compileDefs.size())
+ if (!compileDefs.empty())
{
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
"COMPILE_DEFINITIONS specified on a srcdir type TRY_COMPILE");
return -1;
}
- if (copyFile.size())
+ if (!copyFile.empty())
{
this->Makefile->IssueMessage(cmake::FATAL_ERROR,
"COPY_FILE specified on a srcdir type TRY_COMPILE");
@@ -220,7 +220,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
// do not allow recursive try Compiles
if (this->BinaryDirectory == this->Makefile->GetHomeOutputDirectory())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Attempt at a recursive or nested TRY_COMPILE in directory\n"
<< " " << this->BinaryDirectory << "\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -233,7 +233,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
{
// remove any CMakeCache.txt files so we will have a clean test
std::string ccFile = this->BinaryDirectory + "/CMakeCache.txt";
- cmSystemTools::RemoveFile(ccFile.c_str());
+ cmSystemTools::RemoveFile(ccFile);
// Choose sources.
if(!useSources)
@@ -256,7 +256,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
}
else
{
- cmOStringStream err;
+ std::ostringstream err;
err << "Unknown extension \"" << ext << "\" for file\n"
<< " " << *si << "\n"
<< "try_compile() works only for enabled languages. "
@@ -279,10 +279,10 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
sourceDirectory = this->BinaryDirectory.c_str();
// now create a CMakeLists.txt file in that directory
- FILE *fout = cmsys::SystemTools::Fopen(outFileName.c_str(),"w");
+ FILE *fout = cmsys::SystemTools::Fopen(outFileName,"w");
if (!fout)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Failed to open\n"
<< " " << outFileName << "\n"
<< cmSystemTools::GetLastSystemError();
@@ -331,11 +331,47 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
" ${COMPILE_DEFINITIONS}\")\n", li->c_str(), li->c_str());
}
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0056))
+ {
+ case cmPolicies::WARN:
+ if(this->Makefile->PolicyOptionalWarningEnabled(
+ "CMAKE_POLICY_WARNING_CMP0056"))
+ {
+ std::ostringstream w;
+ w << (this->Makefile->GetCMakeInstance()->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0056)) << "\n"
+ "For compatibility with older versions of CMake, try_compile "
+ "is not honoring caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) "
+ "in the test project."
+ ;
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, w.str());
+ }
+ case cmPolicies::OLD:
+ // OLD behavior is to do nothing.
+ break;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ this->Makefile->GetCMakeInstance()->GetPolicies()
+ ->GetRequiredPolicyError(cmPolicies::CMP0056)
+ );
+ case cmPolicies::NEW:
+ // NEW behavior is to pass linker flags.
+ {
+ const char* exeLinkFlags =
+ this->Makefile->GetDefinition("CMAKE_EXE_LINKER_FLAGS");
+ fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS %s)\n",
+ lg->EscapeForCMake(exeLinkFlags?exeLinkFlags:"").c_str());
+ } break;
+ }
+ fprintf(fout, "set(CMAKE_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}"
+ " ${EXE_LINKER_FLAGS}\")\n");
fprintf(fout, "include_directories(${INCLUDE_DIRECTORIES})\n");
fprintf(fout, "set(CMAKE_SUPPRESS_REGENERATION 1)\n");
fprintf(fout, "link_directories(${LINK_DIRECTORIES})\n");
// handle any compile flags we need to pass on
- if (compileDefs.size())
+ if (!compileDefs.empty())
{
fprintf(fout, "add_definitions( ");
for (size_t i = 0; i < compileDefs.size(); ++i)
@@ -501,7 +537,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
"Result of TRY_COMPILE",
cmCacheManager::INTERNAL);
- if ( outputVariable.size() > 0 )
+ if (!outputVariable.empty())
{
this->Makefile->AddDefinition(outputVariable, output.c_str());
}
@@ -511,13 +547,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
std::string copyFileErrorMessage;
this->FindOutputFile(targetName);
- if ((res==0) && (copyFile.size()))
+ if ((res==0) && !copyFile.empty())
{
if(this->OutputFile.empty() ||
- !cmSystemTools::CopyFileAlways(this->OutputFile.c_str(),
- copyFile.c_str()))
+ !cmSystemTools::CopyFileAlways(this->OutputFile,
+ copyFile))
{
- cmOStringStream emsg;
+ std::ostringstream emsg;
emsg << "Cannot copy output executable\n"
<< " '" << this->OutputFile << "'\n"
<< "to destination specified by COPY_FILE:\n"
@@ -580,10 +616,10 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
std::string fullPath = binDir;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
- if(cmSystemTools::FileIsDirectory(fullPath.c_str()))
+ if(cmSystemTools::FileIsDirectory(fullPath))
{
this->CleanupFiles(fullPath.c_str());
- cmSystemTools::RemoveADirectory(fullPath.c_str());
+ cmSystemTools::RemoveADirectory(fullPath);
}
else
{
@@ -599,7 +635,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
}
if(retry.Count == 0)
#else
- if(!cmSystemTools::RemoveFile(fullPath.c_str()))
+ if(!cmSystemTools::RemoveFile(fullPath))
#endif
{
std::string m = "Remove failed on file: " + fullPath;
@@ -649,13 +685,13 @@ void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
command += tmpOutputFile;
if(cmSystemTools::FileExists(command.c_str()))
{
- tmpOutputFile = cmSystemTools::CollapseFullPath(command.c_str());
+ tmpOutputFile = cmSystemTools::CollapseFullPath(command);
this->OutputFile = tmpOutputFile;
return;
}
}
- cmOStringStream emsg;
+ std::ostringstream emsg;
emsg << "Unable to find the executable at any of:\n";
for (unsigned int i = 0; i < searchDirs.size(); ++i)
{
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index 02fb8cb..f93d3df 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -101,7 +101,7 @@ bool cmCreateTestSourceList
break;
}
std::string func_name;
- if (cmSystemTools::GetFilenamePath(*i).size() > 0)
+ if (!cmSystemTools::GetFilenamePath(*i).empty())
{
func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(*i);
@@ -126,7 +126,7 @@ bool cmCreateTestSourceList
for(i = testsBegin, j = tests_func_name.begin(); i != tests.end(); ++i, ++j)
{
std::string func_name;
- if (cmSystemTools::GetFilenamePath(*i).size() > 0)
+ if (!cmSystemTools::GetFilenamePath(*i).empty())
{
func_name = cmSystemTools::GetFilenamePath(*i) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(*i);
@@ -145,12 +145,12 @@ bool cmCreateTestSourceList
" },\n";
numTests++;
}
- if(extraInclude.size())
+ if(!extraInclude.empty())
{
this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
extraInclude.c_str());
}
- if(function.size())
+ if(!function.empty())
{
this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION",
function.c_str());
diff --git a/Source/cmCurl.cxx b/Source/cmCurl.cxx
new file mode 100644
index 0000000..96d3547
--- /dev/null
+++ b/Source/cmCurl.cxx
@@ -0,0 +1,64 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmCurl.h"
+#include "cmSystemTools.h"
+
+#define check_curl_result(result, errstr) \
+ if (result != CURLE_OK) \
+ { \
+ e += e.empty()? "" : "\n"; \
+ e += errstr; \
+ e += ::curl_easy_strerror(result); \
+ }
+
+//----------------------------------------------------------------------------
+std::string cmCurlSetCAInfo(::CURL *curl, const char* cafile)
+{
+ std::string e;
+ if(cafile && *cafile)
+ {
+ ::CURLcode res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cafile);
+ check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
+ }
+#if !defined(CMAKE_USE_SYSTEM_CURL) && \
+ !defined(_WIN32) && !defined(__APPLE__) && \
+ !defined(CURL_CA_BUNDLE) && !defined(CURL_CA_PATH)
+# define CMAKE_CAFILE_FEDORA "/etc/pki/tls/certs/ca-bundle.crt"
+ else if(cmSystemTools::FileExists(CMAKE_CAFILE_FEDORA, true))
+ {
+ ::CURLcode res =
+ ::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_FEDORA);
+ check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
+ }
+# undef CMAKE_CAFILE_FEDORA
+ else
+ {
+# define CMAKE_CAFILE_COMMON "/etc/ssl/certs/ca-certificates.crt"
+ if(cmSystemTools::FileExists(CMAKE_CAFILE_COMMON, true))
+ {
+ ::CURLcode res =
+ ::curl_easy_setopt(curl, CURLOPT_CAINFO, CMAKE_CAFILE_COMMON);
+ check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
+ }
+# undef CMAKE_CAFILE_COMMON
+# define CMAKE_CAPATH_COMMON "/etc/ssl/certs"
+ if(cmSystemTools::FileIsDirectory(CMAKE_CAPATH_COMMON))
+ {
+ ::CURLcode res =
+ ::curl_easy_setopt(curl, CURLOPT_CAPATH, CMAKE_CAPATH_COMMON);
+ check_curl_result(res, "Unable to set TLS/SSL Verify CAPATH: ");
+ }
+# undef CMAKE_CAPATH_COMMON
+ }
+#endif
+ return e;
+}
diff --git a/Source/cmStandardIncludes.cxx b/Source/cmCurl.h
index a4bdb2e..0c5609c 100644
--- a/Source/cmStandardIncludes.cxx
+++ b/Source/cmCurl.h
@@ -1,6 +1,6 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
- Copyright 2000-2010 Kitware, Inc., Insight Software Consortium
+ Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
@@ -9,8 +9,13 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
+#ifndef cmCurl_h
+#define cmCurl_h
+
+#include <cmsys/Configure.h>
+#include "cm_curl.h"
#include "cmStandardIncludes.h"
-#if !defined(CMAKE_NO_ANSI_STRING_STREAM)
-cmOStringStream::cmOStringStream() {}
-cmOStringStream::~cmOStringStream() {}
+
+std::string cmCurlSetCAInfo(::CURL *curl, const char* cafile = 0);
+
#endif
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index c161eb6..015825d 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -22,11 +22,13 @@ cmCustomCommand::cmCustomCommand()
this->HaveComment = false;
this->EscapeOldStyle = true;
this->EscapeAllowMakeVars = false;
+ this->UsesTerminal = false;
}
//----------------------------------------------------------------------------
cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
Outputs(r.Outputs),
+ Byproducts(r.Byproducts),
Depends(r.Depends),
CommandLines(r.CommandLines),
HaveComment(r.HaveComment),
@@ -34,7 +36,8 @@ cmCustomCommand::cmCustomCommand(const cmCustomCommand& r):
WorkingDirectory(r.WorkingDirectory),
EscapeAllowMakeVars(r.EscapeAllowMakeVars),
EscapeOldStyle(r.EscapeOldStyle),
- Backtrace(r.Backtrace)
+ Backtrace(r.Backtrace),
+ UsesTerminal(r.UsesTerminal)
{
}
@@ -47,6 +50,7 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
}
this->Outputs = r.Outputs;
+ this->Byproducts= r.Byproducts;
this->Depends = r.Depends;
this->CommandLines = r.CommandLines;
this->HaveComment = r.HaveComment;
@@ -56,6 +60,7 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
this->EscapeOldStyle = r.EscapeOldStyle;
this->ImplicitDepends = r.ImplicitDepends;
this->Backtrace = r.Backtrace;
+ this->UsesTerminal = r.UsesTerminal;
return *this;
}
@@ -63,11 +68,13 @@ cmCustomCommand& cmCustomCommand::operator=(cmCustomCommand const& r)
//----------------------------------------------------------------------------
cmCustomCommand::cmCustomCommand(cmMakefile const* mf,
const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
const char* comment,
const char* workingDirectory):
Outputs(outputs),
+ Byproducts(byproducts),
Depends(depends),
CommandLines(commandLines),
HaveComment(comment?true:false),
@@ -97,6 +104,12 @@ const std::vector<std::string>& cmCustomCommand::GetOutputs() const
}
//----------------------------------------------------------------------------
+const std::vector<std::string>& cmCustomCommand::GetByproducts() const
+{
+ return this->Byproducts;
+}
+
+//----------------------------------------------------------------------------
const std::vector<std::string>& cmCustomCommand::GetDepends() const
{
return this->Depends;
@@ -118,21 +131,14 @@ const char* cmCustomCommand::GetComment() const
//----------------------------------------------------------------------------
void cmCustomCommand::AppendCommands(const cmCustomCommandLines& commandLines)
{
- for(cmCustomCommandLines::const_iterator i=commandLines.begin();
- i != commandLines.end(); ++i)
- {
- this->CommandLines.push_back(*i);
- }
+ this->CommandLines.insert(this->CommandLines.end(),
+ commandLines.begin(), commandLines.end());
}
//----------------------------------------------------------------------------
void cmCustomCommand::AppendDepends(const std::vector<std::string>& depends)
{
- for(std::vector<std::string>::const_iterator i=depends.begin();
- i != depends.end(); ++i)
- {
- this->Depends.push_back(*i);
- }
+ this->Depends.insert(this->Depends.end(), depends.begin(), depends.end());
}
//----------------------------------------------------------------------------
@@ -184,3 +190,15 @@ void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
this->ImplicitDepends.insert(this->ImplicitDepends.end(),
l.begin(), l.end());
}
+
+//----------------------------------------------------------------------------
+bool cmCustomCommand::GetUsesTerminal() const
+{
+ return this->UsesTerminal;
+}
+
+//----------------------------------------------------------------------------
+void cmCustomCommand::SetUsesTerminal(bool b)
+{
+ this->UsesTerminal = b;
+}
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 21dbefb..0bfaef2 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -32,6 +32,7 @@ public:
/** Main constructor specifies all information for the command. */
cmCustomCommand(cmMakefile const* mf,
const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
const char* comment,
@@ -42,6 +43,9 @@ public:
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
+ /** Get the extra files produced by the command. */
+ const std::vector<std::string>& GetByproducts() const;
+
/** Get the vector that holds the list of dependencies. */
const std::vector<std::string>& GetDepends() const;
@@ -79,8 +83,14 @@ public:
void AppendImplicitDepends(ImplicitDependsList const&);
ImplicitDependsList const& GetImplicitDepends() const;
+ /** Set/Get whether this custom command should be given access to the
+ real console (if possible). */
+ bool GetUsesTerminal() const;
+ void SetUsesTerminal(bool b);
+
private:
std::vector<std::string> Outputs;
+ std::vector<std::string> Byproducts;
std::vector<std::string> Depends;
cmCustomCommandLines CommandLines;
bool HaveComment;
@@ -90,6 +100,7 @@ private:
bool EscapeOldStyle;
cmListFileBacktrace Backtrace;
ImplicitDependsList ImplicitDepends;
+ bool UsesTerminal;
};
#endif
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 1bca6e6..162d7a1 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -91,6 +91,12 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
}
//----------------------------------------------------------------------------
+std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const
+{
+ return this->CC.GetByproducts();
+}
+
+//----------------------------------------------------------------------------
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
{
if (!this->DependsDone)
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 0d8a0a4..b4ae014 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -42,6 +42,7 @@ public:
const char* GetComment() const;
std::string GetWorkingDirectory() const;
std::vector<std::string> const& GetOutputs() const;
+ std::vector<std::string> const& GetByproducts() const;
std::vector<std::string> const& GetDepends() const;
};
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 6b729de..5ff0186 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -53,7 +53,7 @@ bool cmDefinePropertyCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid scope " << args[0] << ". "
<< "Valid scopes are "
<< "GLOBAL, DIRECTORY, TARGET, SOURCE, "
@@ -100,7 +100,7 @@ bool cmDefinePropertyCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 134f45b..d419011 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -94,7 +94,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile,
// Get the CWD but do not call CollapseFullPath because
// we only need it to cd back, and the form does not matter
oldcwd = cmSystemTools::GetCurrentWorkingDirectory(false);
- cmSystemTools::ChangeDirectory(this->CompileDirectory.c_str());
+ cmSystemTools::ChangeDirectory(this->CompileDirectory);
}
// Check whether dependencies must be regenerated.
@@ -111,7 +111,7 @@ bool cmDepends::Check(const char *makeFile, const char *internalFile,
// Restore working directory.
if(oldcwd != ".")
{
- cmSystemTools::ChangeDirectory(oldcwd.c_str());
+ cmSystemTools::ChangeDirectory(oldcwd);
}
return okay;
@@ -123,7 +123,7 @@ void cmDepends::Clear(const char *file)
// Print verbose output.
if(this->Verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Clearing dependencies in \"" << file << "\"." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
}
@@ -213,7 +213,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
// Print verbose output.
if(this->Verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Dependee \"" << dependee
<< "\" does not exist for depender \""
<< depender << "\"." << std::endl;
@@ -235,7 +235,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
// Print verbose output.
if(this->Verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Dependee \"" << dependee
<< "\" is newer than depender \""
<< depender << "\"." << std::endl;
@@ -257,7 +257,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
// Print verbose output.
if(this->Verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Dependee \"" << dependee
<< "\" is newer than depends file \""
<< internalDependsFileName << "\"." << std::endl;
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index a1fc268..6dde349 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -90,12 +90,7 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
cmDependsC::~cmDependsC()
{
this->WriteCacheFile();
-
- for (std::map<std::string, cmIncludeLines*>::iterator it=
- this->FileCache.begin(); it!=this->FileCache.end(); ++it)
- {
- delete it->second;
- }
+ cmDeleteAll(this->FileCache);
}
//----------------------------------------------------------------------------
@@ -125,11 +120,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
this->ValidDeps->find(obj);
if (tmpIt!= this->ValidDeps->end())
{
- for(DependencyVector::const_iterator i=tmpIt->second.begin();
- i != tmpIt->second.end(); ++i)
- {
- dependencies.insert(*i);
- }
+ dependencies.insert(tmpIt->second.begin(), tmpIt->second.end());
haveDeps = true;
}
}
@@ -294,7 +285,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
//----------------------------------------------------------------------------
void cmDependsC::ReadCacheFile()
{
- if(this->CacheFileName.size() == 0)
+ if(this->CacheFileName.empty())
{
return;
}
@@ -383,7 +374,7 @@ void cmDependsC::ReadCacheFile()
//----------------------------------------------------------------------------
void cmDependsC::WriteCacheFile() const
{
- if(this->CacheFileName.size() == 0)
+ if(this->CacheFileName.empty())
{
return;
}
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 8fc8347..d9818ce 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -319,17 +319,13 @@ void cmDependsFortran::LocateModules()
infoI != objInfo.end(); ++infoI)
{
cmDependsFortranSourceInfo const& info = infoI->second;
- for(std::set<std::string>::const_iterator i = info.Provides.begin();
- i != info.Provides.end(); ++i)
- {
- // Include this module in the set provided by this target.
- this->Internal->TargetProvides.insert(*i);
- }
+ // Include this module in the set provided by this target.
+ this->Internal->TargetProvides.insert(info.Provides.begin(),
+ info.Provides.end());
for(std::set<std::string>::const_iterator i = info.Requires.begin();
i != info.Requires.end(); ++i)
{
- // Include this module in the set required by this target.
this->Internal->TargetRequires[*i] = "";
}
}
@@ -668,7 +664,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
if(cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
compilerId.c_str()))
{
- if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str()))
+ if(!cmSystemTools::CopyFileAlways(mod_upper, stamp))
{
std::cerr << "Error copying Fortran module from \""
<< mod_upper << "\" to \"" << stamp
@@ -683,7 +679,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
if(cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
compilerId.c_str()))
{
- if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str()))
+ if(!cmSystemTools::CopyFileAlways(mod_lower, stamp))
{
std::cerr << "Error copying Fortran module from \""
<< mod_lower << "\" to \"" << stamp
diff --git a/Source/cmDependsFortranParser.cxx b/Source/cmDependsFortranParser.cxx
index 7b49a9c..9d51025 100644
--- a/Source/cmDependsFortranParser.cxx
+++ b/Source/cmDependsFortranParser.cxx
@@ -144,12 +144,6 @@ static bool cmDependsFortranParserIsKeyword(const char* word,
}
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch contains default but no case. */
diff --git a/Source/cmDependsFortranParser.y b/Source/cmDependsFortranParser.y
index d814f30..a987c13 100644
--- a/Source/cmDependsFortranParser.y
+++ b/Source/cmDependsFortranParser.y
@@ -68,12 +68,6 @@ static bool cmDependsFortranParserIsKeyword(const char* word,
}
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch contains default but no case. */
diff --git a/Source/cmDependsJavaParser.cxx b/Source/cmDependsJavaParser.cxx
index 586c0de..899f4d2 100644
--- a/Source/cmDependsJavaParser.cxx
+++ b/Source/cmDependsJavaParser.cxx
@@ -336,12 +336,6 @@ static void cmDependsJavaError(yyscan_t yyscanner, const char* message);
#define jpStoreClass(str) \
yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str))
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but
diff --git a/Source/cmDependsJavaParser.y b/Source/cmDependsJavaParser.y
index 944d4b5..b66dc6d 100644
--- a/Source/cmDependsJavaParser.y
+++ b/Source/cmDependsJavaParser.y
@@ -52,12 +52,6 @@ static void cmDependsJavaError(yyscan_t yyscanner, const char* message);
#define jpElementStart(cnt) yyGetParser->PrepareElement(&yyval)
#define jpStoreClass(str) yyGetParser->AddClassFound(str); yyGetParser->DeallocateParserType(&(str))
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 02f2d21..3c02325 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -226,7 +226,7 @@ void cmDependsJavaParserHelper::EndClass()
{
CurrentClass* parent = 0;
CurrentClass* current = 0;
- if ( this->ClassStack.size() > 0 )
+ if (!this->ClassStack.empty())
{
current = &(*(this->ClassStack.end() - 1));
if ( this->ClassStack.size() > 1 )
@@ -251,7 +251,7 @@ void cmDependsJavaParserHelper::EndClass()
void cmDependsJavaParserHelper::PrintClasses()
{
- if ( this->ClassStack.size() == 0 )
+ if (this->ClassStack.empty())
{
std::cerr << "Error when parsing. No classes on class stack" << std::endl;
abort();
@@ -305,13 +305,13 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
if ( verb )
{
- if ( this->CurrentPackage.size() > 0 )
+ if (!this->CurrentPackage.empty())
{
std::cout << "Current package is: " <<
this->CurrentPackage << std::endl;
}
std::cout << "Imports packages:";
- if ( this->PackagesImport.size() > 0 )
+ if (!this->PackagesImport.empty())
{
std::vector<std::string>::iterator it;
for ( it = this->PackagesImport.begin();
@@ -323,7 +323,7 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
}
std::cout << std::endl;
std::cout << "Depends on:";
- if ( this->ClassesFound.size() > 0 )
+ if (!this->ClassesFound.empty())
{
std::vector<std::string>::iterator it;
for ( it = this->ClassesFound.begin();
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 3ff1017..f4e3a75 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -87,12 +87,7 @@ cmDocumentation::cmDocumentation()
//----------------------------------------------------------------------------
cmDocumentation::~cmDocumentation()
{
- for(std::map<std::string,cmDocumentationSection *>::iterator i =
- this->AllSections.begin();
- i != this->AllSections.end(); ++i)
- {
- delete i->second;
- }
+ cmDeleteAll(this->AllSections);
}
//----------------------------------------------------------------------------
@@ -167,7 +162,7 @@ bool cmDocumentation::PrintRequestedDocumentation(std::ostream& os)
// given stream.
cmsys::ofstream* fout = 0;
std::ostream* s = &os;
- if(i->Filename.length() > 0)
+ if(!i->Filename.empty())
{
fout = new cmsys::ofstream(i->Filename.c_str(), std::ios::out);
if(fout)
@@ -882,7 +877,7 @@ bool cmDocumentation::PrintHelp(std::ostream& os)
//----------------------------------------------------------------------------
const char* cmDocumentation::GetNameString() const
{
- if(this->NameString.length() > 0)
+ if(!this->NameString.empty())
{
return this->NameString.c_str();
}
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 29c806d..4de59c0 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -46,7 +46,7 @@ void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
preformatted.append(1, '\n');
}
}
- if(preformatted.length())
+ if(!preformatted.empty())
{
this->PrintPreformatted(os, preformatted.c_str());
}
@@ -62,7 +62,7 @@ void cmDocumentationFormatter::PrintFormatted(std::ostream& os,
++ptr;
paragraph.append(1, '\n');
}
- if(paragraph.length())
+ if(!paragraph.empty())
{
this->PrintParagraph(os, paragraph.c_str());
}
@@ -201,7 +201,7 @@ void cmDocumentationFormatter
for(std::vector<cmDocumentationEntry>::const_iterator op = entries.begin();
op != entries.end(); ++op)
{
- if(op->Name.size())
+ if(!op->Name.empty())
{
os << " " << op->Name;
this->TextIndent = " ";
diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h
index d038b5c..84bc9bc 100644
--- a/Source/cmDynamicLoader.h
+++ b/Source/cmDynamicLoader.h
@@ -15,8 +15,8 @@
// libraries into a process.
-#ifndef __cmDynamicLoader_h
-#define __cmDynamicLoader_h
+#ifndef cmDynamicLoader_h
+#define cmDynamicLoader_h
#include "cmStandardIncludes.h"
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index cab23b7..d062987 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -532,7 +532,7 @@ cmELFInternalImpl<Types>
break;
}
#endif
- cmOStringStream e;
+ std::ostringstream e;
e << "Unknown ELF file type " << eti;
this->SetErrorMessage(e.str().c_str());
return;
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 9b59088..e021d0b 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -41,7 +41,7 @@ bool cmExecProgramCommand
}
else if ( haveoutput_variable )
{
- if ( output_variable.size() > 0 )
+ if (!output_variable.empty())
{
this->SetError("called with incorrect number of arguments");
return false;
@@ -59,7 +59,7 @@ bool cmExecProgramCommand
}
else if ( havereturn_variable )
{
- if ( return_variable.size() > 0 )
+ if (!return_variable.empty())
{
this->SetError("called with incorrect number of arguments");
return false;
@@ -84,7 +84,7 @@ bool cmExecProgramCommand
}
std::string command;
- if(arguments.size())
+ if(!arguments.empty())
{
command = cmSystemTools::ConvertToRunCommandPath(args[0].c_str());
command += " ";
@@ -95,7 +95,7 @@ bool cmExecProgramCommand
command = args[0];
}
bool verbose = true;
- if(output_variable.size() > 0)
+ if(!output_variable.empty())
{
verbose = false;
}
@@ -118,7 +118,7 @@ bool cmExecProgramCommand
retVal = -1;
}
- if ( output_variable.size() > 0 )
+ if (!output_variable.empty())
{
std::string::size_type first = output.find_first_not_of(" \n\t\r");
std::string::size_type last = output.find_last_not_of(" \n\t\r");
@@ -135,7 +135,7 @@ bool cmExecProgramCommand
this->Makefile->AddDefinition(output_variable, coutput.c_str());
}
- if ( return_variable.size() > 0 )
+ if (!return_variable.empty())
{
char buffer[100];
sprintf(buffer, "%d", retVal);
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 11f8ae5..1225992 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -189,7 +189,7 @@ bool cmExecuteProcessCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << " given unknown argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
@@ -324,12 +324,12 @@ bool cmExecuteProcessCommand
error_strip_trailing_whitespace);
// Store the output obtained.
- if(!output_variable.empty() && tempOutput.size())
+ if(!output_variable.empty() && !tempOutput.empty())
{
this->Makefile->AddDefinition(output_variable,
&*tempOutput.begin());
}
- if(!merge_output && !error_variable.empty() && tempError.size())
+ if(!merge_output && !error_variable.empty() && !tempError.empty())
{
this->Makefile->AddDefinition(error_variable,
&*tempError.begin());
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 5c94a97..d4da5a4 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -36,10 +36,16 @@ public:
virtual bool GetBreakInvoked()
{ return this->BreakInvoked; }
+ virtual void SetContinueInvoked(bool val)
+ { this->ContinueInvoked = val; }
+ virtual bool GetContinueInvoked()
+ { return this->ContinueInvoked; }
+
virtual void Clear()
{
this->ReturnInvoked = false;
this->BreakInvoked = false;
+ this->ContinueInvoked = false;
this->NestedError = false;
}
virtual void SetNestedError(bool val) { this->NestedError = val; }
@@ -49,6 +55,7 @@ public:
protected:
bool ReturnInvoked;
bool BreakInvoked;
+ bool ContinueInvoked;
bool NestedError;
};
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 134ee98..a28ec48 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -45,7 +45,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given target \"" << te->GetName() << "\" more than once.";
this->Makefile->GetCMakeInstance()
->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
@@ -70,7 +70,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
cmTarget* te = *tei;
if (te->GetProperty("INTERFACE_SOURCES"))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \""
<< te->GetName()
<< "\" has a populated INTERFACE_SOURCES property. This is not "
@@ -313,7 +313,7 @@ cmExportBuildFileGenerator
return;
}
- cmOStringStream e;
+ std::ostringstream e;
e << "export called with target \"" << depender->GetName()
<< "\" which requires target \"" << dependee->GetName() << "\" ";
if (occurrences == 0)
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index db21c49..76283d4 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -89,7 +89,7 @@ bool cmExportCommand
if(cmSystemTools::GetFilenameLastExtension(this->Filename.GetCString())
!= ".cmake")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "FILE option given filename \"" << this->Filename.GetString()
<< "\" which does not have an extension of \".cmake\".\n";
this->SetError(e.str());
@@ -103,7 +103,7 @@ bool cmExportCommand
{
if(!this->Makefile->CanIWriteThisFile(fname.c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "FILE option given filename \"" << fname
<< "\" which is in the source tree.\n";
this->SetError(e.str());
@@ -126,7 +126,7 @@ bool cmExportCommand
{
if (this->Append.IsEnabled())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "EXPORT signature does not recognise the APPEND option.";
this->SetError(e.str());
return false;
@@ -134,7 +134,7 @@ bool cmExportCommand
if (this->ExportOld.IsEnabled())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "EXPORT signature does not recognise the "
"EXPORT_LINK_INTERFACE_LIBRARIES option.";
this->SetError(e.str());
@@ -145,7 +145,7 @@ bool cmExportCommand
std::string setName = this->ExportSetName.GetString();
if (setMap.find(setName) == setMap.end())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Export set \"" << setName << "\" not found.";
this->SetError(e.str());
return false;
@@ -161,7 +161,7 @@ bool cmExportCommand
{
if (this->Makefile->IsAlias(*currentTarget))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given ALIAS target \"" << *currentTarget
<< "\" which may not be exported.";
this->SetError(e.str());
@@ -172,7 +172,7 @@ bool cmExportCommand
{
if(target->GetType() == cmTarget::OBJECT_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given OBJECT library \"" << *currentTarget
<< "\" which may not be exported.";
this->SetError(e.str());
@@ -181,7 +181,7 @@ bool cmExportCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given target \"" << *currentTarget
<< "\" which is not built by this project.";
this->SetError(e.str());
@@ -261,7 +261,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "PACKAGE given unknown argument: " << args[i];
this->SetError(e.str());
return false;
@@ -278,7 +278,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
cmsys::RegularExpression packageRegex(packageExpr);
if(!packageRegex.find(package.c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "PACKAGE given invalid package name \"" << package << "\". "
<< "Package names must match \"" << packageExpr << "\".";
this->SetError(e.str());
@@ -314,7 +314,7 @@ void cmExportCommand::ReportRegistryError(std::string const& msg,
std::string const& key,
long err)
{
- cmOStringStream e;
+ std::ostringstream e;
e << msg << "\n"
<< " HKEY_CURRENT_USER\\" << key << "\n";
wchar_t winmsg[1024];
@@ -355,7 +355,7 @@ void cmExportCommand::StorePackageRegistryWin(std::string const& package,
RegCloseKey(hKey);
if(err != ERROR_SUCCESS)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Cannot set registry value \"" << hash << "\" under key";
this->ReportRegistryError(msg.str(), key, err);
return;
@@ -400,7 +400,7 @@ void cmExportCommand::StorePackageRegistryDir(std::string const& package,
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot create package registry file:\n"
<< " " << fname << "\n"
<< cmSystemTools::GetLastSystemError() << "\n";
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 1f39d7a..af4ce8b 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -81,7 +81,7 @@ bool cmExportFileGenerator::GenerateImportFile()
if(!foutPtr.get() || !*foutPtr)
{
std::string se = cmSystemTools::GetLastSystemError();
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot write to file \"" << this->MainImportFile
<< "\": " << se;
cmSystemTools::Error(e.str().c_str());
@@ -247,7 +247,7 @@ static bool checkInterfaceDirs(const std::string &prepro,
continue;
}
cmake::MessageType messageType = cmake::FATAL_ERROR;
- cmOStringStream e;
+ std::ostringstream e;
if (genexPos != std::string::npos)
{
switch (target->GetPolicyStatusCMP0041())
@@ -295,7 +295,7 @@ static bool checkInterfaceDirs(const std::string &prepro,
{
case cmPolicies::WARN:
{
- cmOStringStream s;
+ std::ostringstream s;
s << target->GetMakefile()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
s << "Directory:\n \"" << *li << "\"\nin "
@@ -391,7 +391,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
if (cge->GetHadContextSensitiveCondition())
{
cmMakefile* mf = target->GetMakefile();
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << target->GetName() << "\" is installed with "
"INCLUDES DESTINATION set to a context sensitive path. Paths which "
"depend on the configuration, policy values or the link interface are "
@@ -456,11 +456,7 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop,
}
std::vector<std::string> content;
cmSystemTools::ExpandListArgument(p, content);
- for (std::vector<std::string>::const_iterator ci = content.begin();
- ci != content.end(); ++ci)
- {
- ifaceProperties.insert(*ci);
- }
+ ifaceProperties.insert(content.begin(), content.end());
}
//----------------------------------------------------------------------------
@@ -473,7 +469,7 @@ void getCompatibleInterfaceProperties(cmTarget *target,
if (!info)
{
cmMakefile* mf = target->GetMakefile();
- cmOStringStream e;
+ std::ostringstream e;
e << "Exporting the target \"" << target->GetName() << "\" is not "
"allowed since its linker language cannot be determined";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -773,7 +769,7 @@ cmExportFileGenerator
if(newCMP0022Behavior && !this->ExportOld)
{
cmMakefile *mf = target->GetMakefile();
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << target->GetName() << "\" has policy CMP0022 enabled, "
"but also has old-style LINK_INTERFACE_LIBRARIES properties "
"populated, but it was exported without the "
@@ -857,7 +853,7 @@ cmExportFileGenerator
{
std::string prop = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
prop += suffix;
- cmOStringStream m;
+ std::ostringstream m;
m << iface->Multiplicity;
properties[prop] = m.str();
}
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 23180f1..98ed818 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -56,7 +56,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\" ...) " << "includes target \"" << te->Target->GetName()
@@ -69,13 +69,24 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->GenerateExpectedTargetsCode(os, expectedTargets);
}
- // Add code to compute the installation prefix relative to the
- // import file location.
+ // Set an _IMPORT_PREFIX variable for import location properties
+ // to reference if they are relative to the install prefix.
+ std::string installPrefix =
+ this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
const char* installDest = this->IEGen->GetDestination();
- if(!cmSystemTools::FileIsFullPath(installDest))
+ if(cmSystemTools::FileIsFullPath(installDest))
{
- std::string installPrefix =
- this->IEGen->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_PREFIX");
+ // The export file is being installed to an absolute path so the
+ // package is not relocatable. Use the configured install prefix.
+ os <<
+ "# The installation prefix configured by this project.\n"
+ "set(_IMPORT_PREFIX \"" << installPrefix << "\")\n"
+ "\n";
+ }
+ else
+ {
+ // Add code to compute the installation prefix relative to the
+ // import file location.
std::string absDest = installPrefix + "/" + installDest;
std::string absDestS = absDest + "/";
os << "# Compute the installation prefix relative to this file.\n"
@@ -106,9 +117,6 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
dest = cmSystemTools::GetFilenamePath(dest);
}
os << "\n";
-
- // Import location properties may reference this variable.
- this->ImportPrefix = "${_IMPORT_PREFIX}/";
}
std::vector<std::string> missingTargets;
@@ -125,7 +133,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
if (te->GetProperty("INTERFACE_SOURCES"))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \""
<< te->GetName()
<< "\" has a populated INTERFACE_SOURCES property. This is not "
@@ -209,12 +217,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
<< "\n";
// Cleanup the import prefix variable.
- if(!this->ImportPrefix.empty())
- {
- os << "# Cleanup temporary variables.\n"
- << "set(_IMPORT_PREFIX)\n"
- << "\n";
- }
+ os << "# Cleanup temporary variables.\n"
+ << "set(_IMPORT_PREFIX)\n"
+ << "\n";
this->GenerateImportedFileCheckLoop(os);
bool result = true;
@@ -285,7 +290,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(
if(!exportFileStream)
{
std::string se = cmSystemTools::GetLastSystemError();
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot write to file \"" << fileName
<< "\": " << se;
cmSystemTools::Error(e.str().c_str());
@@ -394,11 +399,7 @@ cmExportInstallFileGenerator
if(!cmSystemTools::FileIsFullPath(dest.c_str()))
{
// The target is installed relative to the installation prefix.
- if(this->ImportPrefix.empty())
- {
- this->ComplainAboutImportPrefix(itgen);
- }
- value = this->ImportPrefix;
+ value = "${_IMPORT_PREFIX}/";
}
value += dest;
value += "/";
@@ -508,24 +509,6 @@ cmExportInstallFileGenerator
return namespaces;
}
-
-//----------------------------------------------------------------------------
-void
-cmExportInstallFileGenerator
-::ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen)
-{
- const char* installDest = this->IEGen->GetDestination();
- cmOStringStream e;
- e << "install(EXPORT \""
- << this->IEGen->GetExportSet()->GetName()
- << "\") given absolute "
- << "DESTINATION \"" << installDest << "\" but the export "
- << "references an installation of target \""
- << itgen->GetTarget()->GetName() << "\" which has relative "
- << "DESTINATION \"" << itgen->GetDestination() << "\".";
- cmSystemTools::Error(e.str().c_str());
-}
-
//----------------------------------------------------------------------------
void
cmExportInstallFileGenerator
@@ -533,7 +516,7 @@ cmExportInstallFileGenerator
cmTarget* dependee,
int occurrences)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "install(EXPORT \""
<< this->IEGen->GetExportSet()->GetName()
<< "\" ...) "
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index b851ad5..6f86ac9 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -83,14 +83,10 @@ protected:
std::set<std::string>& importedLocations
);
- void ComplainAboutImportPrefix(cmInstallTargetGenerator* itgen);
-
std::string InstallNameDir(cmTarget* target, const std::string& config);
cmInstallExportGenerator* IEGen;
- std::string ImportPrefix;
-
// The import file generated for each configuration.
std::map<std::string, std::string> ConfigImportFiles;
};
diff --git a/Source/cmExportSet.cxx b/Source/cmExportSet.cxx
index 33b0630..14812e4 100644
--- a/Source/cmExportSet.cxx
+++ b/Source/cmExportSet.cxx
@@ -15,10 +15,7 @@
cmExportSet::~cmExportSet()
{
- for(unsigned int i = 0; i < this->TargetExports.size(); ++ i)
- {
- delete this->TargetExports[i];
- }
+ cmDeleteAll(this->TargetExports);
}
void cmExportSet::AddTargetExport(cmTargetExport* te)
diff --git a/Source/cmExportSetMap.cxx b/Source/cmExportSetMap.cxx
index 5174118..14c4458 100644
--- a/Source/cmExportSetMap.cxx
+++ b/Source/cmExportSetMap.cxx
@@ -25,12 +25,7 @@ cmExportSet* cmExportSetMap::operator[](const std::string &name)
void cmExportSetMap::clear()
{
- for(std::map<std::string, cmExportSet*>::iterator it = this->begin();
- it != this->end();
- ++ it)
- {
- delete it->second;
- }
+ cmDeleteAll(*this);
this->derived::clear();
}
diff --git a/Source/cmExprParser.cxx b/Source/cmExprParser.cxx
index 77880c0..c12b42e 100644
--- a/Source/cmExprParser.cxx
+++ b/Source/cmExprParser.cxx
@@ -157,12 +157,6 @@ static void cmExprError(yyscan_t yyscanner, const char* message);
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but
diff --git a/Source/cmExprParser.y b/Source/cmExprParser.y
index 12c2e48..f2c85d0 100644
--- a/Source/cmExprParser.y
+++ b/Source/cmExprParser.y
@@ -52,12 +52,6 @@ static void cmExprError(yyscan_t yyscanner, const char* message);
/* Disable some warnings in the generated code. */
-#ifdef __BORLANDC__
-# pragma warn -8004 /* Variable assigned a value that is not used. */
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8060 /* possibly incorrect assignment */
-# pragma warn -8066 /* unreachable code */
-#endif
#ifdef _MSC_VER
# pragma warning (disable: 4102) /* Unused goto label. */
# pragma warning (disable: 4065) /* Switch statement contains default but no case. */
diff --git a/Source/cmExprParserHelper.cxx b/Source/cmExprParserHelper.cxx
index cc35f84..6016c4c 100644
--- a/Source/cmExprParserHelper.cxx
+++ b/Source/cmExprParserHelper.cxx
@@ -99,7 +99,7 @@ int cmExprParserHelper::LexInput(char* buf, int maxlen)
void cmExprParserHelper::Error(const char* str)
{
unsigned long pos = static_cast<unsigned long>(this->InputBufferPos);
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << str << " (" << pos << ")";
this->ErrorString = ostr.str();
}
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 56a6edb..69857ef 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -276,7 +276,7 @@ void cmExtraCodeBlocksGenerator
it->second[0]->GetMakefile()->GetHomeDirectory(),
jt->c_str());
std::vector<std::string> splitted;
- cmSystemTools::SplitPath(relative.c_str(), splitted, false);
+ cmSystemTools::SplitPath(relative, splitted, false);
// Split filename from path
std::string fileName = *(splitted.end()-1);
splitted.erase(splitted.end() - 1, splitted.end());
@@ -615,12 +615,8 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
std::vector<std::string> includes;
target->GetMakefile()->GetLocalGenerator()->
GetIncludeDirectories(includes, gtgt, "C", buildType);
- for(std::vector<std::string>::const_iterator dirIt=includes.begin();
- dirIt != includes.end();
- ++dirIt)
- {
- uniqIncludeDirs.insert(*dirIt);
- }
+
+ uniqIncludeDirs.insert(includes.begin(), includes.end());
std::string systemIncludeDirs = makefile->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
@@ -628,12 +624,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
{
std::vector<std::string> dirs;
cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
- for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
- dirIt != dirs.end();
- ++dirIt)
- {
- uniqIncludeDirs.insert(*dirIt);
- }
+ uniqIncludeDirs.insert(dirs.begin(), dirs.end());
}
systemIncludeDirs = makefile->GetSafeDefinition(
@@ -642,12 +633,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
{
std::vector<std::string> dirs;
cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
- for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
- dirIt != dirs.end();
- ++dirIt)
- {
- uniqIncludeDirs.insert(*dirIt);
- }
+ uniqIncludeDirs.insert(dirs.begin(), dirs.end());
}
for(std::set<std::string>::const_iterator dirIt=uniqIncludeDirs.begin();
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index cc42bca..eb50a7d 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -454,7 +454,7 @@ cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const
else if ( generator == "MinGW Makefiles" ||
generator == "Unix Makefiles" )
{
- cmOStringStream ss;
+ std::ostringstream ss;
ss << make << " -j " << this->CpuCount;
buildCommand = ss.str();
}
@@ -482,7 +482,7 @@ cmExtraCodeLiteGenerator::GetSingleFileBuildCommand
std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" )
{
- cmOStringStream ss;
+ std::ostringstream ss;
ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o";
buildCommand = ss.str();
}
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 7867ad6..d64b0d7 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -125,8 +125,8 @@ void cmExtraEclipseCDT4Generator::Generate()
"Enable CMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT instead.");
}
- if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
- this->HomeDirectory.c_str()))
+ if (cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
+ this->HomeDirectory))
{
mf->IssueMessage(cmake::WARNING, "The build directory is a subdirectory "
"of the source directory.\n"
@@ -496,8 +496,8 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile()
std::string linkSourceDirectory = this->GetEclipsePath(
mf->GetStartDirectory());
// .project dir can't be subdir of a linked resource dir
- if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory.c_str(),
- linkSourceDirectory.c_str()))
+ if (!cmSystemTools::IsSubDirectory(this->HomeOutputDirectory,
+ linkSourceDirectory))
{
this->AppendLinkedResource(fout, sourceLinkedResourceName,
this->GetEclipsePath(linkSourceDirectory),
@@ -591,7 +591,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
++fileIt)
{
std::string fullPath = (*fileIt)->GetFullPath();
- if (!cmSystemTools::FileIsDirectory(fullPath.c_str()))
+ if (!cmSystemTools::FileIsDirectory(fullPath))
{
std::string linkName4 = linkName3;
linkName4 += "/";
@@ -636,8 +636,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
// a linked resource must not point to a parent directory of .project or
// .project itself
if ((baseDir != linkSourceDirectory) &&
- !cmSystemTools::IsSubDirectory(baseDir.c_str(),
- linkSourceDirectory.c_str()))
+ !cmSystemTools::IsSubDirectory(baseDir,
+ linkSourceDirectory))
{
std::string linkName = "[Subprojects]/";
linkName += it->first;
@@ -664,7 +664,7 @@ void cmExtraEclipseCDT4Generator::AppendIncludeDirectories(
{
if (!inc->empty())
{
- std::string dir = cmSystemTools::CollapseFullPath(inc->c_str());
+ std::string dir = cmSystemTools::CollapseFullPath(*inc);
// handle framework include dirs on OSX, the remainder after the
// Frameworks/ part has to be stripped
@@ -820,7 +820,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
// exlude source directory from output search path
// - only if not named the same as an output directory
if (!cmSystemTools::FileIsDirectory(
- std::string(this->HomeOutputDirectory + "/" + *it).c_str()))
+ std::string(this->HomeOutputDirectory + "/" + *it)))
{
excludeFromOut += this->EscapeForXML(*it) + "/|";
}
@@ -1180,7 +1180,7 @@ std::string
cmExtraEclipseCDT4Generator::GetPathBasename(const std::string& path)
{
std::string outputBasename = path;
- while (outputBasename.size() > 0 &&
+ while (!outputBasename.empty() &&
(outputBasename[outputBasename.size() - 1] == '/' ||
outputBasename[outputBasename.size() - 1] == '\\'))
{
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index 567542e..9645d0e 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -334,7 +334,7 @@ std::string cmExtraKateGenerator::GenerateProjectName(const std::string& name,
std::string cmExtraKateGenerator::GetPathBasename(const std::string& path)const
{
std::string outputBasename = path;
- while (outputBasename.size() > 0 &&
+ while (!outputBasename.empty() &&
(outputBasename[outputBasename.size() - 1] == '/' ||
outputBasename[outputBasename.size() - 1] == '\\'))
{
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 1325cec..579e715 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -20,7 +20,8 @@
#include "cmTimestamp.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
-#include "cm_curl.h"
+#include "cmCurl.h"
+#include "cmFileLockResult.h"
#endif
#undef GetCurrentDirectory
@@ -33,6 +34,7 @@
#include <cmsys/Glob.hxx>
#include <cmsys/RegularExpression.hxx>
#include <cmsys/FStream.hxx>
+#include <cmsys/Encoding.hxx>
// Table of permissions flags.
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -61,6 +63,35 @@ static mode_t mode_setuid = S_ISUID;
static mode_t mode_setgid = S_ISGID;
#endif
+#if defined(WIN32) && defined(CMAKE_ENCODING_UTF8)
+// libcurl doesn't support file:// urls for unicode filenames on Windows.
+// Convert string from UTF-8 to ACP if this is a file:// URL.
+static std::string fix_file_url_windows(const std::string& url)
+{
+ std::string ret = url;
+ if(strncmp(url.c_str(), "file://", 7) == 0)
+ {
+ cmsys_stl::wstring wurl = cmsys::Encoding::ToWide(url);
+ if(!wurl.empty())
+ {
+ int mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1,
+ NULL, 0, NULL, NULL);
+ if(mblen > 0)
+ {
+ std::vector<char> chars(mblen);
+ mblen = WideCharToMultiByte(CP_ACP, 0, wurl.c_str(), -1,
+ &chars[0], mblen, NULL, NULL);
+ if(mblen > 0)
+ {
+ ret = &chars[0];
+ }
+ }
+ }
+ }
+ return ret;
+}
+#endif
+
// cmLibraryCommand
bool cmFileCommand
::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
@@ -172,6 +203,10 @@ bool cmFileCommand
{
return this->HandleGenerateCommand(args);
}
+ else if ( subCommand == "LOCK" )
+ {
+ return this->HandleLockCommand(args);
+ }
std::string e = "does not recognize sub-command "+subCommand;
this->SetError(e);
@@ -220,8 +255,6 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
cmSystemTools::SetPermissions(fileName.c_str(),
#if defined( _MSC_VER ) || defined( __MINGW32__ )
mode | S_IWRITE
-#elif defined( __BORLANDC__ )
- mode | S_IWUSR
#else
mode | S_IWUSR | S_IWGRP
#endif
@@ -303,14 +336,14 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
// is there a limit?
long sizeLimit = -1;
- if (limitArg.GetString().size() > 0)
+ if (!limitArg.GetString().empty())
{
sizeLimit = atoi(limitArg.GetCString());
}
// is there an offset?
long offset = 0;
- if (offsetArg.GetString().size() > 0)
+ if (!offsetArg.GetString().empty())
{
offset = atoi(offsetArg.GetCString());
}
@@ -371,7 +404,7 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
#if defined(CMAKE_BUILD_WITH_CMAKE)
if(args.size() != 3)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " requires a file name and output variable";
this->SetError(e.str());
return false;
@@ -386,14 +419,14 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
this->Makefile->AddDefinition(args[2], out.c_str());
return true;
}
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " failed to read file \"" << args[1] << "\": "
<< cmSystemTools::GetLastSystemError();
this->SetError(e.str());
}
return false;
#else
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " not available during bootstrap";
this->SetError(e.str().c_str());
return false;
@@ -439,7 +472,13 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
bool have_regex = false;
bool newline_consume = false;
bool hex_conversion_enabled = true;
- bool utf8_encoding = false;
+ enum { encoding_none = cmsys::FStream::BOM_None,
+ encoding_utf8 = cmsys::FStream::BOM_UTF8,
+ encoding_utf16le = cmsys::FStream::BOM_UTF16LE,
+ encoding_utf16be = cmsys::FStream::BOM_UTF16BE,
+ encoding_utf32le = cmsys::FStream::BOM_UTF32LE,
+ encoding_utf32be = cmsys::FStream::BOM_UTF32BE};
+ int encoding = encoding_none;
int arg_mode = arg_none;
for(unsigned int i=3; i < args.size(); ++i)
{
@@ -486,7 +525,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
if(sscanf(args[i].c_str(), "%d", &limit_input) != 1 ||
limit_input < 0)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option LIMIT_INPUT value \""
<< args[i] << "\" is not an unsigned integer.";
this->SetError(e.str());
@@ -499,7 +538,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
if(sscanf(args[i].c_str(), "%d", &limit_output) != 1 ||
limit_output < 0)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option LIMIT_OUTPUT value \""
<< args[i] << "\" is not an unsigned integer.";
this->SetError(e.str());
@@ -512,7 +551,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
int count;
if(sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option LIMIT_COUNT value \""
<< args[i] << "\" is not an unsigned integer.";
this->SetError(e.str());
@@ -526,7 +565,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
int len;
if(sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option LENGTH_MINIMUM value \""
<< args[i] << "\" is not an unsigned integer.";
this->SetError(e.str());
@@ -540,7 +579,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
int len;
if(sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option LENGTH_MAXIMUM value \""
<< args[i] << "\" is not an unsigned integer.";
this->SetError(e.str());
@@ -553,7 +592,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
{
if(!regex.compile(args[i].c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option REGEX value \""
<< args[i] << "\" could not be compiled.";
this->SetError(e.str());
@@ -566,11 +605,27 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
{
if(args[i] == "UTF-8")
{
- utf8_encoding = true;
+ encoding = encoding_utf8;
+ }
+ else if(args[i] == "UTF-16LE")
+ {
+ encoding = encoding_utf16le;
+ }
+ else if(args[i] == "UTF-16BE")
+ {
+ encoding = encoding_utf16be;
+ }
+ else if(args[i] == "UTF-32LE")
+ {
+ encoding = encoding_utf32le;
+ }
+ else if(args[i] == "UTF-32BE")
+ {
+ encoding = encoding_utf32be;
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS option ENCODING \""
<< args[i] << "\" not recognized.";
this->SetError(e.str());
@@ -580,7 +635,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS given unknown argument \""
<< args[i] << "\"";
this->SetError(e.str());
@@ -608,12 +663,29 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
#endif
if(!fin)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "STRINGS file \"" << fileName << "\" cannot be read.";
this->SetError(e.str());
return false;
}
+ //If BOM is found and encoding was not specified, use the BOM
+ int bom_found = cmsys::FStream::ReadBOM(fin);
+ if(encoding == encoding_none && bom_found != cmsys::FStream::BOM_None)
+ {
+ encoding = bom_found;
+ }
+
+ unsigned int bytes_rem = 0;
+ if(encoding == encoding_utf16le || encoding == encoding_utf16be)
+ {
+ bytes_rem = 1;
+ }
+ if(encoding == encoding_utf32le || encoding == encoding_utf32be)
+ {
+ bytes_rem = 3;
+ }
+
// Parse strings out of the file.
int output_size = 0;
std::vector<std::string> strings;
@@ -625,6 +697,25 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
std::string current_str;
int c = fin.get();
+ for(unsigned int i=0; i<bytes_rem; ++i)
+ {
+ int c1 = fin.get();
+ if(!fin)
+ {
+ fin.putback(static_cast<char>(c1));
+ break;
+ }
+ c = (c << 8) | c1;
+ }
+ if(encoding == encoding_utf16le)
+ {
+ c = ((c & 0xFF) << 8) | ((c & 0xFF00) >> 8);
+ }
+ else if(encoding == encoding_utf32le)
+ {
+ c = (((c & 0xFF) << 24) | ((c & 0xFF00) << 8) |
+ ((c & 0xFF0000) >> 8) | ((c & 0xFF000000) >> 24));
+ }
if(c == '\r')
{
@@ -640,7 +731,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// c is guaranteed to fit in char by the above if...
current_str += static_cast<char>(c);
}
- else if(utf8_encoding)
+ else if(encoding == encoding_utf8)
{
// Check for UTF-8 encoded string (up to 4 octets)
static const unsigned char utf8_check_table[3][2] =
@@ -712,7 +803,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
// A non-string character has been found. Check if the current
// string matches the requirements. We require that the length
// be at least one no matter what the user specified.
- if(s.length() >= minlen && s.length() >= 1 &&
+ if(s.length() >= minlen && !s.empty() &&
(!have_regex || regex.find(s.c_str())))
{
output_size += static_cast<int>(s.size()) + 1;
@@ -866,7 +957,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
{
std::string expr = this->Makefile->GetCurrentDirectory();
// Handle script mode
- if ( expr.size() > 0 )
+ if (!expr.empty())
{
expr += "/" + *i;
g.FindFiles(expr);
@@ -1004,7 +1095,7 @@ cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "DIFFERENT given unknown argument " << args[i];
this->SetError(e.str());
return false;
@@ -1119,7 +1210,7 @@ protected:
{
if(permissions && !cmSystemTools::SetPermissions(toFile, permissions))
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot set permissions on \"" << toFile << "\"";
this->FileCommand->SetError(e.str());
return false;
@@ -1143,7 +1234,7 @@ protected:
else if(arg == "SETGID") { permissions |= mode_setgid; }
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " given invalid permission \"" << arg << "\".";
this->FileCommand->SetError(e.str());
return false;
@@ -1170,7 +1261,7 @@ protected:
virtual bool ReportMissing(const char* fromFile)
{
// The input file does not exist and installation is not optional.
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot find \"" << fromFile << "\".";
this->FileCommand->SetError(e.str());
return false;
@@ -1203,14 +1294,14 @@ protected:
void NotBeforeMatch(std::string const& arg)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "option " << arg << " may not appear before PATTERN or REGEX.";
this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
void NotAfterMatch(std::string const& arg)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "option " << arg << " may not appear after PATTERN or REGEX.";
this->FileCommand->SetError(e.str());
this->Doing = DoingError;
@@ -1248,7 +1339,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
if(!this->CheckKeyword(args[i]) &&
!this->CheckValue(args[i]))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "called with unknown argument \"" << args[i] << "\".";
this->FileCommand->SetError(e.str());
return false;
@@ -1264,7 +1355,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
// Require a destination.
if(this->Destination.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " given no DESTINATION";
this->FileCommand->SetError(e.str());
return false;
@@ -1444,7 +1535,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not compile PATTERN \"" << arg << "\".";
this->FileCommand->SetError(e.str());
this->Doing = DoingError;
@@ -1460,7 +1551,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not compile REGEX \"" << arg << "\".";
this->FileCommand->SetError(e.str());
this->Doing = DoingError;
@@ -1504,7 +1595,7 @@ bool cmFileCopier::Run(std::vector<std::string> const& args)
{
// Split the input file into its directory and name components.
std::vector<std::string> fromPathComponents;
- cmSystemTools::SplitPath(files[i].c_str(), fromPathComponents);
+ cmSystemTools::SplitPath(files[i], fromPathComponents);
std::string fromName = *(fromPathComponents.end()-1);
std::string fromDir = cmSystemTools::JoinPath(fromPathComponents.begin(),
fromPathComponents.end()-1);
@@ -1540,7 +1631,7 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile)
{
if(!*fromFile)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL encountered an empty string input file name.";
this->FileCommand->SetError(e.str());
return false;
@@ -1581,7 +1672,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
std::string symlinkTarget;
if(!cmSystemTools::ReadSymlink(fromFile, symlinkTarget))
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\".";
this->FileCommand->SetError(e.str());
@@ -1612,9 +1703,9 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
cmSystemTools::RemoveFile(toFile);
// Create the symlink.
- if(!cmSystemTools::CreateSymlink(symlinkTarget.c_str(), toFile))
+ if(!cmSystemTools::CreateSymlink(symlinkTarget, toFile))
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\".";
this->FileCommand->SetError(e.str());
@@ -1646,7 +1737,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
// Copy the file.
if(copy && !cmSystemTools::CopyAFile(fromFile, toFile, true))
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot copy file \"" << fromFile
<< "\" to \"" << toFile << "\".";
this->FileCommand->SetError(e.str());
@@ -1665,7 +1756,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
}
if (!cmSystemTools::CopyFileTime(fromFile, toFile))
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot set modification time on \""
<< toFile << "\"";
this->FileCommand->SetError(e.str());
@@ -1697,7 +1788,7 @@ bool cmFileCopier::InstallDirectory(const char* source,
// Make sure the destination directory exists.
if(!cmSystemTools::MakeDirectory(destination))
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Name << " cannot make directory \"" << destination << "\": "
<< cmSystemTools::GetLastSystemError();
this->FileCommand->SetError(e.str());
@@ -2042,7 +2133,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg)
else if(arg == "COMPONENTS" || arg == "CONFIGURATIONS" ||
arg == "PROPERTIES")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL called with old-style " << arg << " argument. "
<< "This script was generated with an older version of CMake. "
<< "Re-run this cmake version on your build tree.";
@@ -2110,7 +2201,7 @@ bool cmFileInstaller
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Option TYPE given unknown value \"" << stype << "\".";
this->FileCommand->SetError(e.str());
return false;
@@ -2203,7 +2294,7 @@ bool cmFileInstaller::HandleInstallDestination()
return false;
}
}
- if ( !cmSystemTools::FileIsDirectory(destination.c_str()) )
+ if ( !cmSystemTools::FileIsDirectory(destination) )
{
std::string errstring = "INSTALL destination: " + destination +
" is not a directory.";
@@ -2255,7 +2346,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_CHANGE given unknown argument " << args[i];
this->SetError(e.str());
return false;
@@ -2278,7 +2369,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
}
if(!cmSystemTools::FileExists(file, true))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
this->SetError(e.str());
return false;
@@ -2290,7 +2381,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
bool changed;
if(!cmSystemTools::ChangeRPath(file, oldRPath, newRPath, &emsg, &changed))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_CHANGE could not write new RPATH:\n"
<< " " << newRPath << "\n"
<< "to the file:\n"
@@ -2340,7 +2431,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_REMOVE given unknown argument " << args[i];
this->SetError(e.str());
return false;
@@ -2353,7 +2444,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
}
if(!cmSystemTools::FileExists(file, true))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
this->SetError(e.str());
return false;
@@ -2365,7 +2456,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
bool removed;
if(!cmSystemTools::RemoveRPath(file, &emsg, &removed))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_REMOVE could not remove RPATH from file:\n"
<< " " << file << "\n"
<< emsg;
@@ -2421,7 +2512,7 @@ cmFileCommand::HandleRPathCheckCommand(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "RPATH_CHECK given unknown argument " << args[i];
this->SetError(e.str());
return false;
@@ -2522,7 +2613,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
if(!cmSystemTools::RenameFile(oldname.c_str(), newname.c_str()))
{
std::string err = cmSystemTools::GetLastSystemError();
- cmOStringStream e;
+ std::ostringstream e;
e << "RENAME failed to rename\n"
<< " " << oldname << "\n"
<< "to\n"
@@ -2553,14 +2644,14 @@ bool cmFileCommand::HandleRemove(std::vector<std::string> const& args,
fileName += "/" + *i;
}
- if(cmSystemTools::FileIsDirectory(fileName.c_str()) &&
- !cmSystemTools::FileIsSymlink(fileName.c_str()) && recurse)
+ if(cmSystemTools::FileIsDirectory(fileName) &&
+ !cmSystemTools::FileIsSymlink(fileName) && recurse)
{
- cmSystemTools::RemoveADirectory(fileName.c_str());
+ cmSystemTools::RemoveADirectory(fileName);
}
else
{
- cmSystemTools::RemoveFile(fileName.c_str());
+ cmSystemTools::RemoveFile(fileName);
}
}
return true;
@@ -2584,7 +2675,7 @@ bool cmFileCommand::HandleCMakePathCommand(std::vector<std::string>
#else
char pathSep = ':';
#endif
- std::vector<cmsys::String> path = cmSystemTools::SplitString(i->c_str(),
+ std::vector<cmsys::String> path = cmSystemTools::SplitString(*i,
pathSep);
i++;
const char* var = i->c_str();
@@ -2689,7 +2780,7 @@ namespace {
if (updated)
{
- cmOStringStream oss;
+ std::ostringstream oss;
oss << "[" << this->Text << " " << this->CurrentPercentage
<< "% complete]";
status = oss.str();
@@ -2959,9 +3050,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
msg = "returning early; file already exists with expected ";
msg += hashMatchMSG;
msg += "\"";
- if(statusVar.size())
+ if(!statusVar.empty())
{
- cmOStringStream result;
+ std::ostringstream result;
result << (int)0 << ";\"" << msg;
this->Makefile->AddDefinition(statusVar,
result.str().c_str());
@@ -2990,6 +3081,10 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
return false;
}
+#if defined(WIN32) && defined(CMAKE_ENCODING_UTF8)
+ url = fix_file_url_windows(url);
+#endif
+
::CURL *curl;
::curl_global_init(CURL_GLOBAL_DEFAULT);
curl = ::curl_easy_init();
@@ -3031,10 +3126,11 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
}
// check to see if a CAINFO file has been specified
// command arg comes first
- if(cainfo && *cainfo)
+ std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
+ if (!cainfo_err.empty())
{
- res = ::curl_easy_setopt(curl, CURLOPT_CAINFO, cainfo);
- check_curl_result(res, "Unable to set TLS/SSL Verify CAINFO: ");
+ this->SetError(cainfo_err);
+ return false;
}
cmFileCommandVectorOfChar chunkDebug;
@@ -3048,7 +3144,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
check_curl_result(res, "DOWNLOAD cannot set follow-redirect option: ");
- if(verboseLog.size())
+ if(!verboseLog.empty())
{
res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
check_curl_result(res, "DOWNLOAD cannot set verbose: ");
@@ -3094,9 +3190,9 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
g_curl.release();
::curl_easy_cleanup(curl);
- if(statusVar.size())
+ if(!statusVar.empty())
{
- cmOStringStream result;
+ std::ostringstream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
this->Makefile->AddDefinition(statusVar,
result.str().c_str());
@@ -3114,7 +3210,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (hash.get())
{
std::string actualHash = hash->HashFile(file);
- if (actualHash.size() == 0)
+ if (actualHash.empty())
{
this->SetError("DOWNLOAD cannot compute hash on downloaded file");
return false;
@@ -3122,7 +3218,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if (expectedHash != actualHash)
{
- cmOStringStream oss;
+ std::ostringstream oss;
oss << "DOWNLOAD HASH mismatch" << std::endl
<< " for file: [" << file << "]" << std::endl
<< " expected hash: [" << expectedHash << "]" << std::endl
@@ -3135,14 +3231,14 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
}
}
- if(chunkDebug.size())
+ if(!chunkDebug.empty())
{
chunkDebug.push_back(0);
if(CURLE_OPERATION_TIMEOUTED == res)
{
std::string output = &*chunkDebug.begin();
- if(verboseLog.size())
+ if(!verboseLog.empty())
{
this->Makefile->AddDefinition(verboseLog,
&*chunkDebug.begin());
@@ -3241,7 +3337,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
// Open file for reading:
//
- FILE *fin = cmsys::SystemTools::Fopen(filename.c_str(), "rb");
+ FILE *fin = cmsys::SystemTools::Fopen(filename, "rb");
if(!fin)
{
std::string errStr = "UPLOAD cannot open file '";
@@ -3250,7 +3346,11 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
return false;
}
- unsigned long file_size = cmsys::SystemTools::FileLength(filename.c_str());
+ unsigned long file_size = cmsys::SystemTools::FileLength(filename);
+
+#if defined(WIN32) && defined(CMAKE_ENCODING_UTF8)
+ url = fix_file_url_windows(url);
+#endif
::CURL *curl;
::curl_global_init(CURL_GLOBAL_DEFAULT);
@@ -3294,7 +3394,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
res = ::curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
check_curl_result(res, "UPLOAD cannot set follow-redirect option: ");
- if(logVar.size())
+ if(!logVar.empty())
{
res = ::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
check_curl_result(res, "UPLOAD cannot set verbose: ");
@@ -3349,9 +3449,9 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
g_curl.release();
::curl_easy_cleanup(curl);
- if(statusVar.size())
+ if(!statusVar.empty())
{
- cmOStringStream result;
+ std::ostringstream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
this->Makefile->AddDefinition(statusVar,
result.str().c_str());
@@ -3362,11 +3462,11 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
fclose(fin);
fin = NULL;
- if(logVar.size())
+ if(!logVar.empty())
{
std::string log;
- if(chunkResponse.size())
+ if(!chunkResponse.empty())
{
chunkResponse.push_back(0);
log += "Response:\n";
@@ -3374,7 +3474,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
log += "\n";
}
- if(chunkDebug.size())
+ if(!chunkDebug.empty())
{
chunkDebug.push_back(0);
log += "Debug:\n";
@@ -3466,6 +3566,205 @@ bool cmFileCommand::HandleGenerateCommand(
}
//----------------------------------------------------------------------------
+bool cmFileCommand::HandleLockCommand(
+ std::vector<std::string> const& args)
+{
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ // Default values
+ bool directory = false;
+ bool release = false;
+ enum Guard {
+ GUARD_FUNCTION,
+ GUARD_FILE,
+ GUARD_PROCESS
+ };
+ Guard guard = GUARD_PROCESS;
+ std::string resultVariable;
+ unsigned long timeout = static_cast<unsigned long>(-1);
+
+ // Parse arguments
+ if(args.size() < 2)
+ {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "sub-command LOCK requires at least two arguments.");
+ return false;
+ }
+
+ std::string path = args[1];
+ for (unsigned i = 2; i < args.size(); ++i)
+ {
+ if (args[i] == "DIRECTORY")
+ {
+ directory = true;
+ }
+ else if (args[i] == "RELEASE")
+ {
+ release = true;
+ }
+ else if (args[i] == "GUARD")
+ {
+ ++i;
+ const char* merr = "expected FUNCTION, FILE or PROCESS after GUARD";
+ if (i >= args.size())
+ {
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, merr);
+ return false;
+ }
+ else
+ {
+ if (args[i] == "FUNCTION")
+ {
+ guard = GUARD_FUNCTION;
+ }
+ else if (args[i] == "FILE")
+ {
+ guard = GUARD_FILE;
+ }
+ else if (args[i] == "PROCESS")
+ {
+ guard = GUARD_PROCESS;
+ }
+ else
+ {
+ std::ostringstream e;
+ e << merr << ", but got:\n \"" << args[i] << "\".";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ }
+ }
+ else if (args[i] == "RESULT_VARIABLE")
+ {
+ ++i;
+ if (i >= args.size())
+ {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "expected variable name after RESULT_VARIABLE");
+ return false;
+ }
+ resultVariable = args[i];
+ }
+ else if (args[i] == "TIMEOUT")
+ {
+ ++i;
+ if (i >= args.size())
+ {
+ this->Makefile->IssueMessage(
+ cmake::FATAL_ERROR,
+ "expected timeout value after TIMEOUT");
+ return false;
+ }
+ long scanned;
+ if(!cmSystemTools::StringToLong(args[i].c_str(), &scanned)
+ || scanned < 0)
+ {
+ std::ostringstream e;
+ e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ timeout = static_cast<unsigned long>(scanned);
+ }
+ else
+ {
+ std::ostringstream e;
+ e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n";
+ e << "but got: \"" << args[i] << "\".";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ }
+
+ if (directory)
+ {
+ path += "/cmake.lock";
+ }
+
+ if (!cmsys::SystemTools::FileIsFullPath(path))
+ {
+ path = this->Makefile->GetCurrentDirectory() + ("/" + path);
+ }
+
+ // Unify path (remove '//', '/../', ...)
+ path = cmSystemTools::CollapseFullPath(path);
+
+ // Create file and directories if needed
+ std::string parentDir = cmSystemTools::GetParentDirectory(path);
+ if (!cmSystemTools::MakeDirectory(parentDir))
+ {
+ std::ostringstream e;
+ e << "directory\n \"" << parentDir << "\"\ncreation failed ";
+ e << "(check permissions).";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ FILE *file = cmsys::SystemTools::Fopen(path, "w");
+ if (!file)
+ {
+ std::ostringstream e;
+ e << "file\n \"" << path << "\"\ncreation failed (check permissions).";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ fclose(file);
+
+ // Actual lock/unlock
+ cmFileLockPool& lockPool = this->Makefile->GetLocalGenerator()->
+ GetGlobalGenerator()->GetFileLockPool();
+
+ cmFileLockResult fileLockResult(cmFileLockResult::MakeOk());
+ if (release)
+ {
+ fileLockResult = lockPool.Release(path);
+ }
+ else
+ {
+ switch (guard)
+ {
+ case GUARD_FUNCTION:
+ fileLockResult = lockPool.LockFunctionScope(path, timeout);
+ break;
+ case GUARD_FILE:
+ fileLockResult = lockPool.LockFileScope(path, timeout);
+ break;
+ case GUARD_PROCESS:
+ fileLockResult = lockPool.LockProcessScope(path, timeout);
+ break;
+ default:
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ }
+
+ const std::string result = fileLockResult.GetOutputMessage();
+
+ if (resultVariable.empty() && !fileLockResult.IsOk())
+ {
+ std::ostringstream e;
+ e << "error locking file\n \"" << path << "\"\n" << result << ".";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+
+ if (!resultVariable.empty())
+ {
+ this->Makefile->AddDefinition(resultVariable, result.c_str());
+ }
+
+ return true;
+#else
+ static_cast<void>(args);
+ this->SetError("sub-command LOCK not implemented in bootstrap cmake");
+ return false;
+#endif
+}
+
+//----------------------------------------------------------------------------
bool cmFileCommand::HandleTimestampCommand(
std::vector<std::string> const& args)
{
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index 8d66fdf..a4d341f 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -75,6 +75,7 @@ protected:
bool HandleTimestampCommand(std::vector<std::string> const& args);
bool HandleGenerateCommand(std::vector<std::string> const& args);
+ bool HandleLockCommand(std::vector<std::string> const& args);
private:
void AddEvaluationFile(const std::string &inputName,
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
new file mode 100644
index 0000000..e6aa5f4
--- /dev/null
+++ b/Source/cmFileLock.cxx
@@ -0,0 +1,78 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmFileLock.h"
+
+#include <assert.h>
+#include "cmFileLockResult.h"
+
+// Common implementation
+
+cmFileLock::~cmFileLock()
+{
+ if (!this->Filename.empty())
+ {
+ const cmFileLockResult result = this->Release();
+ static_cast<void>(result);
+ assert(result.IsOk());
+ }
+}
+
+cmFileLockResult cmFileLock::Lock(
+ const std::string& filename, unsigned long timeout)
+{
+ if (filename.empty())
+ {
+ // Error is internal since all the directories and file must be created
+ // before actual lock called.
+ return cmFileLockResult::MakeInternal();
+ }
+
+ if (!this->Filename.empty())
+ {
+ // Error is internal since double-lock must be checked in class
+ // cmFileLockPool by the cmFileLock::IsLocked method.
+ return cmFileLockResult::MakeInternal();
+ }
+
+ this->Filename = filename;
+ cmFileLockResult result = this->OpenFile();
+ if (result.IsOk())
+ {
+ if (timeout == static_cast<unsigned long>(-1))
+ {
+ result = this->LockWithoutTimeout();
+ }
+ else
+ {
+ result = this->LockWithTimeout(timeout);
+ }
+ }
+
+ if (!result.IsOk())
+ {
+ this->Filename = "";
+ }
+
+ return result;
+}
+
+bool cmFileLock::IsLocked(const std::string& filename) const
+{
+ return filename == this->Filename;
+}
+
+#if defined(_WIN32)
+# include "cmFileLockWin32.cxx"
+#else
+# include "cmFileLockUnix.cxx"
+#endif
diff --git a/Source/cmFileLock.h b/Source/cmFileLock.h
new file mode 100644
index 0000000..dd959a7
--- /dev/null
+++ b/Source/cmFileLock.h
@@ -0,0 +1,74 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmFileLock_h
+#define cmFileLock_h
+
+#include "cmStandardIncludes.h"
+
+#if defined(_WIN32)
+# include <windows.h> // HANDLE
+#endif
+
+class cmFileLockResult;
+
+/**
+ * @brief Cross-platform file locking.
+ * @details Under the hood this class use 'fcntl' for Unix-like platforms and
+ * 'LockFileEx'/'UnlockFileEx' for Win32 platform. Locks are exclusive and
+ * advisory.
+ */
+class cmFileLock
+{
+ public:
+ cmFileLock();
+ ~cmFileLock();
+
+ /**
+ * @brief Lock the file.
+ * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
+ */
+ cmFileLockResult Lock(const std::string& filename, unsigned long timeoutSec);
+
+ /**
+ * @brief Unlock the file.
+ */
+ cmFileLockResult Release();
+
+ /**
+ * @brief Check file is locked by this class.
+ * @details This function helps to find double locks (deadlocks) and to do
+ * explicit unlocks.
+ */
+ bool IsLocked(const std::string& filename) const;
+
+ private:
+ cmFileLock(const cmFileLock&);
+ cmFileLock& operator=(const cmFileLock&);
+
+ cmFileLockResult OpenFile();
+ cmFileLockResult LockWithoutTimeout();
+ cmFileLockResult LockWithTimeout(unsigned long timeoutSec);
+
+#if defined(_WIN32)
+ typedef HANDLE FileId;
+ BOOL LockFile(DWORD flags);
+#else
+ typedef int FileId;
+ int LockFile(int cmd, int type);
+#endif
+
+ FileId File;
+ std::string Filename;
+};
+
+#endif // cmFileLock_h
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
new file mode 100644
index 0000000..cf8e9a9
--- /dev/null
+++ b/Source/cmFileLockPool.cxx
@@ -0,0 +1,187 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmFileLockPool.h"
+
+#include <assert.h>
+
+#include "cmFileLock.h"
+#include "cmFileLockResult.h"
+
+cmFileLockPool::cmFileLockPool()
+{
+}
+
+cmFileLockPool::~cmFileLockPool()
+{
+ cmDeleteAll(this->FunctionScopes);
+ cmDeleteAll(this->FileScopes);
+}
+
+void cmFileLockPool::PushFunctionScope()
+{
+ this->FunctionScopes.push_back(new ScopePool());
+}
+
+void cmFileLockPool::PopFunctionScope()
+{
+ assert(!this->FunctionScopes.empty());
+ delete this->FunctionScopes.back();
+ this->FunctionScopes.pop_back();
+}
+
+void cmFileLockPool::PushFileScope()
+{
+ this->FileScopes.push_back(new ScopePool());
+}
+
+void cmFileLockPool::PopFileScope()
+{
+ assert(!this->FileScopes.empty());
+ delete this->FileScopes.back();
+ this->FileScopes.pop_back();
+}
+
+cmFileLockResult cmFileLockPool::LockFunctionScope(
+ const std::string& filename, unsigned long timeoutSec)
+{
+ if (this->IsAlreadyLocked(filename))
+ {
+ return cmFileLockResult::MakeAlreadyLocked();
+ }
+ if (this->FunctionScopes.empty())
+ {
+ return cmFileLockResult::MakeNoFunction();
+ }
+ return this->FunctionScopes.back()->Lock(filename, timeoutSec);
+}
+
+cmFileLockResult cmFileLockPool::LockFileScope(
+ const std::string& filename, unsigned long timeoutSec)
+{
+ if (this->IsAlreadyLocked(filename))
+ {
+ return cmFileLockResult::MakeAlreadyLocked();
+ }
+ assert(!this->FileScopes.empty());
+ return this->FileScopes.back()->Lock(filename, timeoutSec);
+}
+
+cmFileLockResult cmFileLockPool::LockProcessScope(
+ const std::string& filename, unsigned long timeoutSec)
+{
+ if (this->IsAlreadyLocked(filename))
+ {
+ return cmFileLockResult::MakeAlreadyLocked();
+ }
+ return this->ProcessScope.Lock(filename, timeoutSec);
+}
+
+cmFileLockResult cmFileLockPool::Release(const std::string& filename)
+{
+ for (It i = this->FunctionScopes.begin();
+ i != this->FunctionScopes.end(); ++i)
+ {
+ const cmFileLockResult result = (*i)->Release(filename);
+ if (!result.IsOk())
+ {
+ return result;
+ }
+ }
+
+ for (It i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i)
+ {
+ const cmFileLockResult result = (*i)->Release(filename);
+ if (!result.IsOk())
+ {
+ return result;
+ }
+ }
+
+ return this->ProcessScope.Release(filename);
+}
+
+bool cmFileLockPool::IsAlreadyLocked(const std::string& filename) const
+{
+ for (CIt i = this->FunctionScopes.begin();
+ i != this->FunctionScopes.end(); ++i)
+ {
+ const bool result = (*i)->IsAlreadyLocked(filename);
+ if (result)
+ {
+ return true;
+ }
+ }
+
+ for (CIt i = this->FileScopes.begin(); i != this->FileScopes.end(); ++i)
+ {
+ const bool result = (*i)->IsAlreadyLocked(filename);
+ if (result)
+ {
+ return true;
+ }
+ }
+
+ return this->ProcessScope.IsAlreadyLocked(filename);
+}
+
+cmFileLockPool::ScopePool::ScopePool()
+{
+}
+
+cmFileLockPool::ScopePool::~ScopePool()
+{
+ cmDeleteAll(this->Locks);
+}
+
+cmFileLockResult cmFileLockPool::ScopePool::Lock(
+ const std::string& filename, unsigned long timeoutSec)
+{
+ cmFileLock *lock = new cmFileLock();
+ const cmFileLockResult result = lock->Lock(filename, timeoutSec);
+ if (result.IsOk())
+ {
+ this->Locks.push_back(lock);
+ return cmFileLockResult::MakeOk();
+ }
+ else
+ {
+ delete lock;
+ return result;
+ }
+}
+
+cmFileLockResult cmFileLockPool::ScopePool::Release(
+ const std::string& filename)
+{
+ for (It i = this->Locks.begin(); i != this->Locks.end(); ++i)
+ {
+ if ((*i)->IsLocked(filename))
+ {
+ return (*i)->Release();
+ }
+ }
+ return cmFileLockResult::MakeOk();
+}
+
+bool cmFileLockPool::ScopePool::IsAlreadyLocked(
+ const std::string& filename) const
+{
+ for (CIt i = this->Locks.begin(); i != this->Locks.end(); ++i)
+ {
+ if ((*i)->IsLocked(filename))
+ {
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/Source/cmFileLockPool.h b/Source/cmFileLockPool.h
new file mode 100644
index 0000000..baef310
--- /dev/null
+++ b/Source/cmFileLockPool.h
@@ -0,0 +1,102 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmFileLockPool_h
+#define cmFileLockPool_h
+
+#include "cmStandardIncludes.h"
+
+class cmFileLockResult;
+class cmFileLock;
+
+class cmFileLockPool
+{
+ public:
+ cmFileLockPool();
+ ~cmFileLockPool();
+
+ //@{
+ /**
+ * @brief Function scope control.
+ */
+ void PushFunctionScope();
+ void PopFunctionScope();
+ //@}
+
+ //@{
+ /**
+ * @brief File scope control.
+ */
+ void PushFileScope();
+ void PopFileScope();
+ //@}
+
+ //@{
+ /**
+ * @brief Lock the file in given scope.
+ * @param timeoutSec Lock timeout. If -1 try until success or fatal error.
+ */
+ cmFileLockResult LockFunctionScope(
+ const std::string& filename, unsigned long timeoutSec
+ );
+ cmFileLockResult LockFileScope(
+ const std::string& filename, unsigned long timeoutSec
+ );
+ cmFileLockResult LockProcessScope(
+ const std::string& filename, unsigned long timeoutSec
+ );
+ //@}
+
+ /**
+ * @brief Unlock the file explicitly.
+ */
+ cmFileLockResult Release(const std::string& filename);
+
+ private:
+ cmFileLockPool(const cmFileLockPool&);
+ cmFileLockPool& operator=(const cmFileLockPool&);
+
+ bool IsAlreadyLocked(const std::string& filename) const;
+
+ class ScopePool
+ {
+ public:
+ ScopePool();
+ ~ScopePool();
+
+ cmFileLockResult Lock(
+ const std::string& filename, unsigned long timeoutSec
+ );
+ cmFileLockResult Release(const std::string& filename);
+ bool IsAlreadyLocked(const std::string& filename) const;
+
+ private:
+ ScopePool(const ScopePool&);
+ ScopePool& operator=(const ScopePool&);
+
+ typedef std::list<cmFileLock*> List;
+ typedef List::iterator It;
+ typedef List::const_iterator CIt;
+
+ List Locks;
+ };
+
+ typedef std::list<ScopePool*> List;
+
+ typedef List::iterator It;
+ typedef List::const_iterator CIt;
+
+ List FunctionScopes;
+ List FileScopes;
+ ScopePool ProcessScope;
+};
+
+#endif // cmFileLockPool_h
diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx
new file mode 100644
index 0000000..045e7ee
--- /dev/null
+++ b/Source/cmFileLockResult.cxx
@@ -0,0 +1,111 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmFileLockResult.h"
+
+#include <errno.h>
+
+cmFileLockResult cmFileLockResult::MakeOk()
+{
+ return cmFileLockResult(OK, 0);
+}
+
+cmFileLockResult cmFileLockResult::MakeSystem()
+{
+#if defined(_WIN32)
+ const Error lastError = GetLastError();
+#else
+ const Error lastError = errno;
+#endif
+ return cmFileLockResult(SYSTEM, lastError);
+}
+
+cmFileLockResult cmFileLockResult::MakeTimeout()
+{
+ return cmFileLockResult(TIMEOUT, 0);
+}
+
+cmFileLockResult cmFileLockResult::MakeAlreadyLocked()
+{
+ return cmFileLockResult(ALREADY_LOCKED, 0);
+}
+
+cmFileLockResult cmFileLockResult::MakeInternal()
+{
+ return cmFileLockResult(INTERNAL, 0);
+}
+
+cmFileLockResult cmFileLockResult::MakeNoFunction()
+{
+ return cmFileLockResult(NO_FUNCTION, 0);
+}
+
+bool cmFileLockResult::IsOk() const
+{
+ return this->Type == OK;
+}
+
+std::string cmFileLockResult::GetOutputMessage() const
+{
+ switch (this->Type)
+ {
+ case OK:
+ return "0";
+ case SYSTEM:
+#if defined(_WIN32)
+ {
+ char* errorText = NULL;
+
+ // http://stackoverflow.com/a/455533/2288008
+ DWORD flags = FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_IGNORE_INSERTS;
+ ::FormatMessageA(
+ flags,
+ NULL,
+ this->ErrorValue,
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)&errorText,
+ 0,
+ NULL
+ );
+
+ if (errorText != NULL)
+ {
+ const std::string message = errorText;
+ ::LocalFree(errorText);
+ return message;
+ }
+ else
+ {
+ return "Internal error (FormatMessageA failed)";
+ }
+ }
+#else
+ return strerror(this->ErrorValue);
+#endif
+ case TIMEOUT:
+ return "Timeout reached";
+ case ALREADY_LOCKED:
+ return "File already locked";
+ case NO_FUNCTION:
+ return "'GUARD FUNCTION' not used in function definition";
+ case INTERNAL:
+ default:
+ return "Internal error";
+ }
+}
+
+cmFileLockResult::cmFileLockResult(ErrorType typeValue, Error errorValue):
+ Type(typeValue), ErrorValue(errorValue)
+{
+}
diff --git a/Source/cmFileLockResult.h b/Source/cmFileLockResult.h
new file mode 100644
index 0000000..531fb49
--- /dev/null
+++ b/Source/cmFileLockResult.h
@@ -0,0 +1,85 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#ifndef cmFileLockResult_h
+#define cmFileLockResult_h
+
+#include "cmStandardIncludes.h"
+
+#if defined(_WIN32)
+# include <windows.h> // DWORD
+#endif
+
+/**
+ * @brief Result of the locking/unlocking file.
+ * @note See @c cmFileLock
+ */
+class cmFileLockResult
+{
+ public:
+#if defined(_WIN32)
+ typedef DWORD Error;
+#else
+ typedef int Error;
+#endif
+
+ /**
+ * @brief Successful lock/unlock.
+ */
+ static cmFileLockResult MakeOk();
+
+ /**
+ * @brief Lock/Unlock failed. Read error/GetLastError.
+ */
+ static cmFileLockResult MakeSystem();
+
+ /**
+ * @brief Lock/Unlock failed. Timeout reached.
+ */
+ static cmFileLockResult MakeTimeout();
+
+ /**
+ * @brief File already locked.
+ */
+ static cmFileLockResult MakeAlreadyLocked();
+
+ /**
+ * @brief Internal error.
+ */
+ static cmFileLockResult MakeInternal();
+
+ /**
+ * @brief Try to lock with function guard outside of the function
+ */
+ static cmFileLockResult MakeNoFunction();
+
+ bool IsOk() const;
+ std::string GetOutputMessage() const;
+
+ private:
+ enum ErrorType
+ {
+ OK,
+ SYSTEM,
+ TIMEOUT,
+ ALREADY_LOCKED,
+ INTERNAL,
+ NO_FUNCTION
+ };
+
+ cmFileLockResult(ErrorType type, Error errorValue);
+
+ ErrorType Type;
+ Error ErrorValue;
+};
+
+#endif // cmFileLockResult_h
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
new file mode 100644
index 0000000..fc18a64
--- /dev/null
+++ b/Source/cmFileLockUnix.cxx
@@ -0,0 +1,102 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmFileLock.h"
+
+#include <errno.h> // errno
+#include <stdio.h> // SEEK_SET
+#include <fcntl.h>
+#include "cmSystemTools.h"
+
+cmFileLock::cmFileLock(): File(-1)
+{
+}
+
+cmFileLockResult cmFileLock::Release()
+{
+ if (this->Filename.empty())
+ {
+ return cmFileLockResult::MakeOk();
+ }
+ const int lockResult = this->LockFile(F_SETLK, F_UNLCK);
+
+ this->Filename = "";
+
+ if (lockResult == 0)
+ {
+ return cmFileLockResult::MakeOk();
+ }
+ else
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+}
+
+cmFileLockResult cmFileLock::OpenFile()
+{
+ this->File = ::open(this->Filename.c_str(), O_RDWR);
+ if (this->File == -1)
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+ else
+ {
+ return cmFileLockResult::MakeOk();
+ }
+}
+
+cmFileLockResult cmFileLock::LockWithoutTimeout()
+{
+ if (this->LockFile(F_SETLKW, F_WRLCK) == -1)
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+ else
+ {
+ return cmFileLockResult::MakeOk();
+ }
+}
+
+cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
+{
+ while (true)
+ {
+ if (this->LockFile(F_SETLK, F_WRLCK) == -1)
+ {
+ if (errno != EACCES && errno != EAGAIN)
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+ }
+ else
+ {
+ return cmFileLockResult::MakeOk();
+ }
+ if (seconds == 0)
+ {
+ return cmFileLockResult::MakeTimeout();
+ }
+ --seconds;
+ cmSystemTools::Delay(1000);
+ }
+}
+
+int cmFileLock::LockFile(int cmd, int type)
+{
+ struct ::flock lock;
+ lock.l_start = 0;
+ lock.l_len = 0; // lock all bytes
+ lock.l_pid = 0; // unused (for F_GETLK only)
+ lock.l_type = static_cast<short>(type); // exclusive lock
+ lock.l_whence = SEEK_SET;
+ return ::fcntl(this->File, cmd, &lock);
+}
diff --git a/Source/cmFileLockWin32.cxx b/Source/cmFileLockWin32.cxx
new file mode 100644
index 0000000..4691689
--- /dev/null
+++ b/Source/cmFileLockWin32.cxx
@@ -0,0 +1,126 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Ruslan Baratov
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmFileLock.h"
+
+#include <windows.h> // CreateFileW
+#include "cmSystemTools.h"
+
+cmFileLock::cmFileLock(): File(INVALID_HANDLE_VALUE)
+{
+}
+
+cmFileLockResult cmFileLock::Release()
+{
+ if (this->Filename.empty())
+ {
+ return cmFileLockResult::MakeOk();
+ }
+ const unsigned long len = static_cast<unsigned long>(-1);
+ static OVERLAPPED overlapped;
+ const DWORD reserved = 0;
+ const BOOL unlockResult = UnlockFileEx(
+ File,
+ reserved,
+ len,
+ len,
+ &overlapped
+ );
+
+ this->Filename = "";
+
+ if (unlockResult)
+ {
+ return cmFileLockResult::MakeOk();
+ }
+ else
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+}
+
+cmFileLockResult cmFileLock::OpenFile()
+{
+ const DWORD access = GENERIC_READ | GENERIC_WRITE;
+ const DWORD shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
+ const PSECURITY_ATTRIBUTES security = NULL;
+ const DWORD attr = 0;
+ const HANDLE templ = NULL;
+ this->File = CreateFileW(
+ cmSystemTools::ConvertToWindowsExtendedPath(this->Filename).c_str(),
+ access,
+ shareMode,
+ security,
+ OPEN_EXISTING,
+ attr,
+ templ
+ );
+ if (this->File == INVALID_HANDLE_VALUE)
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+ else
+ {
+ return cmFileLockResult::MakeOk();
+ }
+}
+
+cmFileLockResult cmFileLock::LockWithoutTimeout()
+{
+ if (!this->LockFile(LOCKFILE_EXCLUSIVE_LOCK))
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+ else
+ {
+ return cmFileLockResult::MakeOk();
+ }
+}
+
+cmFileLockResult cmFileLock::LockWithTimeout(unsigned long seconds)
+{
+ const DWORD flags = LOCKFILE_EXCLUSIVE_LOCK | LOCKFILE_FAIL_IMMEDIATELY;
+ while (true)
+ {
+ const BOOL result = this->LockFile(flags);
+ if (result)
+ {
+ return cmFileLockResult::MakeOk();
+ }
+ const DWORD error = GetLastError();
+ if (error != ERROR_LOCK_VIOLATION)
+ {
+ return cmFileLockResult::MakeSystem();
+ }
+ if (seconds == 0)
+ {
+ return cmFileLockResult::MakeTimeout();
+ }
+ --seconds;
+ cmSystemTools::Delay(1000);
+ }
+}
+
+BOOL cmFileLock::LockFile(DWORD flags)
+{
+ const DWORD reserved = 0;
+ const unsigned long len = static_cast<unsigned long>(-1);
+ static OVERLAPPED overlapped;
+ return LockFileEx(
+ this->File,
+ flags,
+ reserved,
+ len,
+ len,
+ &overlapped
+ );
+}
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index e4e819a..69991d5 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -140,11 +140,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
}
else if(doing == DoingPaths)
{
- this->AddUserPath(args[j], this->UserPaths);
+ this->UserGuessArgs.push_back(args[j]);
}
else if(doing == DoingHints)
{
- this->AddUserPath(args[j], this->UserHints);
+ this->UserHintsArgs.push_back(args[j]);
}
else if(doing == DoingPathSuffixes)
{
@@ -152,10 +152,10 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
}
}
- if(this->VariableDocumentation.size() == 0)
+ if(this->VariableDocumentation.empty())
{
this->VariableDocumentation = "Where can ";
- if(this->Names.size() == 0)
+ if(this->Names.empty())
{
this->VariableDocumentation += "the (unknown) library be found";
}
@@ -184,18 +184,11 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
std::vector<std::string> shortArgs = this->Names;
this->Names.clear(); // clear out any values in Names
this->Names.push_back(shortArgs[0]);
- for(unsigned int j = 1; j < shortArgs.size(); ++j)
- {
- this->AddUserPath(shortArgs[j], this->UserPaths);
- }
+ this->UserGuessArgs.insert(this->UserGuessArgs.end(),
+ shortArgs.begin() + 1, shortArgs.end());
}
this->ExpandPaths();
- // Filter out ignored paths from the prefix list
- std::set<std::string> ignored;
- this->GetIgnoredPaths(ignored);
- this->FilterPaths(this->SearchPaths, ignored);
-
this->ComputeFinalPaths();
return true;
@@ -203,226 +196,142 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
void cmFindBase::ExpandPaths()
{
- this->AddCMakeVariablePath();
- this->AddCMakeEnvironmentPath();
- this->AddUserHintsPath();
- this->AddSystemEnvironmentPath();
- this->AddCMakeSystemVariablePath();
- this->AddUserGuessPath();
-
- // Add suffixes and clean up paths.
- this->AddPathSuffixes();
-}
-
-//----------------------------------------------------------------------------
-void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
- PathType pathType)
-{
- // default for programs
- std::string subdir = "bin";
-
- if (this->CMakePathName == "INCLUDE")
+ if(!this->NoDefaultPath)
{
- subdir = "include";
- }
- else if (this->CMakePathName == "LIBRARY")
- {
- subdir = "lib";
- }
- else if (this->CMakePathName == "FRAMEWORK")
- {
- subdir = ""; // ? what to do for frameworks ?
- }
-
- for(std::vector<std::string>::const_iterator it = in_paths.begin();
- it != in_paths.end(); ++it)
- {
- std::string dir = *it;
- if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/')
+ if(!this->NoCMakePath)
{
- dir += "/";
+ this->FillCMakeVariablePath();
}
- if(subdir == "include" || subdir == "lib")
+ if(!this->NoCMakeEnvironmentPath)
{
- const char* arch =
- this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE");
- if(arch && *arch)
- {
- this->AddPathInternal(dir+subdir+"/"+arch, pathType);
- }
+ this->FillCMakeEnvironmentPath();
}
- std::string add = dir + subdir;
- if(add != "/")
+ if(!this->NoSystemEnvironmentPath)
{
- this->AddPathInternal(add, pathType);
+ this->FillSystemEnvironmentPath();
}
- if (subdir == "bin")
+ if(!this->NoCMakeSystemPath)
{
- this->AddPathInternal(dir+"sbin", pathType);
- }
- if(!subdir.empty() && *it != "/")
- {
- this->AddPathInternal(*it, pathType);
+ this->FillCMakeSystemVariablePath();
}
}
-}
-//----------------------------------------------------------------------------
-void cmFindBase::AddCMakePrefixPath(const std::string& variable)
-{
- // Get a path from a CMake variable.
- if(const char* varPath = this->Makefile->GetDefinition(variable))
- {
- std::vector<std::string> tmp;
- cmSystemTools::ExpandListArgument(varPath, tmp);
- this->AddPrefixPaths(tmp, CMakePath);
- }
+ this->FillUserHintsPath();
+ this->FillUserGuessPath();
}
//----------------------------------------------------------------------------
-void cmFindBase::AddEnvPrefixPath(const std::string& variable)
+void cmFindBase::FillCMakeEnvironmentPath()
{
- // Get a path from the environment.
- std::vector<std::string> tmp;
- cmSystemTools::GetPath(tmp, variable.c_str());
- this->AddPrefixPaths(tmp, EnvPath);
-}
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
-//----------------------------------------------------------------------------
-void cmFindBase::AddCMakeEnvironmentPath()
-{
- if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
- {
- // Add CMAKE_*_PATH environment variables
- std::string var = "CMAKE_";
- var += this->CMakePathName;
- var += "_PATH";
- this->AddEnvPrefixPath("CMAKE_PREFIX_PATH");
- this->AddEnvPath(var.c_str());
+ // Add CMAKE_*_PATH environment variables
+ std::string var = "CMAKE_";
+ var += this->CMakePathName;
+ var += "_PATH";
+ paths.AddEnvPrefixPath("CMAKE_PREFIX_PATH");
+ paths.AddEnvPath(var);
- if(this->CMakePathName == "PROGRAM")
- {
- this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
- }
- else
- {
- this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
- }
+ if(this->CMakePathName == "PROGRAM")
+ {
+ paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
}
+ else
+ {
+ paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
+ }
+ paths.AddSuffixes(this->SearchPathSuffixes);
}
//----------------------------------------------------------------------------
-void cmFindBase::AddCMakeVariablePath()
+void cmFindBase::FillCMakeVariablePath()
{
- if(!this->NoCMakePath && !this->NoDefaultPath)
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake];
+
+ // Add CMake varibles of the same name as the previous environment
+ // varibles CMAKE_*_PATH to be used most of the time with -D
+ // command line options
+ std::string var = "CMAKE_";
+ var += this->CMakePathName;
+ var += "_PATH";
+ paths.AddCMakePrefixPath("CMAKE_PREFIX_PATH");
+ paths.AddCMakePath(var);
+
+ if(this->CMakePathName == "PROGRAM")
{
- // Add CMake varibles of the same name as the previous environment
- // varibles CMAKE_*_PATH to be used most of the time with -D
- // command line options
- std::string var = "CMAKE_";
- var += this->CMakePathName;
- var += "_PATH";
- this->AddCMakePrefixPath("CMAKE_PREFIX_PATH");
- this->AddCMakePath(var);
-
- if(this->CMakePathName == "PROGRAM")
- {
- this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
- }
- else
- {
- this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
- }
+ paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
}
+ else
+ {
+ paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
+ }
+ paths.AddSuffixes(this->SearchPathSuffixes);
}
//----------------------------------------------------------------------------
-void cmFindBase::AddSystemEnvironmentPath()
+void cmFindBase::FillSystemEnvironmentPath()
{
- if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment];
+
+ // Add LIB or INCLUDE
+ if(!this->EnvironmentPath.empty())
{
- // Add LIB or INCLUDE
- if(!this->EnvironmentPath.empty())
- {
- this->AddEnvPath(this->EnvironmentPath.c_str());
- }
- // Add PATH
- this->AddEnvPath(0);
+ paths.AddEnvPath(this->EnvironmentPath);
}
+ // Add PATH
+ paths.AddEnvPath("PATH");
+ paths.AddSuffixes(this->SearchPathSuffixes);
}
//----------------------------------------------------------------------------
-void cmFindBase::AddCMakeSystemVariablePath()
+void cmFindBase::FillCMakeSystemVariablePath()
{
- if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
- {
- std::string var = "CMAKE_SYSTEM_";
- var += this->CMakePathName;
- var += "_PATH";
- this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
- this->AddCMakePath(var);
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem];
- if(this->CMakePathName == "PROGRAM")
- {
- this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
- }
- else
- {
- this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
- }
+ std::string var = "CMAKE_SYSTEM_";
+ var += this->CMakePathName;
+ var += "_PATH";
+ paths.AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
+ paths.AddCMakePath(var);
+
+ if(this->CMakePathName == "PROGRAM")
+ {
+ paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
}
+ else
+ {
+ paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
+ }
+ paths.AddSuffixes(this->SearchPathSuffixes);
}
//----------------------------------------------------------------------------
-void cmFindBase::AddUserHintsPath()
+void cmFindBase::FillUserHintsPath()
{
- this->AddPathsInternal(this->UserHints, CMakePath);
-}
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints];
-//----------------------------------------------------------------------------
-void cmFindBase::AddUserGuessPath()
-{
- this->AddPathsInternal(this->UserPaths, CMakePath);
+ for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin();
+ p != this->UserHintsArgs.end(); ++p)
+ {
+ paths.AddUserPath(*p);
+ }
+ paths.AddSuffixes(this->SearchPathSuffixes);
}
//----------------------------------------------------------------------------
-void cmFindBase::AddPathSuffixes()
+void cmFindBase::FillUserGuessPath()
{
- std::vector<std::string>& paths = this->SearchPaths;
- std::vector<std::string> finalPath = paths;
- std::vector<std::string>::iterator i;
- // clear the path
- paths.clear();
- // convert all paths to unix slashes and add search path suffixes
- // if there are any
- for(i = finalPath.begin();
- i != finalPath.end(); ++i)
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess];
+
+ for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin();
+ p != this->UserGuessArgs.end(); ++p)
{
- cmSystemTools::ConvertToUnixSlashes(*i);
- // copy each finalPath combined with SearchPathSuffixes
- // to the SearchPaths ivar
- for(std::vector<std::string>::iterator j =
- this->SearchPathSuffixes.begin();
- j != this->SearchPathSuffixes.end(); ++j)
- {
- // if *i is only / then do not add a //
- // this will get incorrectly considered a network
- // path on windows and cause huge delays.
- std::string p = *i;
- if(p.size() && p[p.size()-1] != '/')
- {
- p += std::string("/");
- }
- p += *j;
- // add to all paths because the search path may be modified
- // later with lib being replaced for lib64 which may exist
- paths.push_back(p);
- }
- // now put the path without the path suffixes in the SearchPaths
- paths.push_back(*i);
+ paths.AddUserPath(*p);
}
+ paths.AddSuffixes(this->SearchPathSuffixes);
}
+//----------------------------------------------------------------------------
void cmFindBase::PrintFindStuff()
{
std::cerr << "SearchFrameworkLast: " << this->SearchFrameworkLast << "\n";
@@ -457,9 +366,10 @@ void cmFindBase::PrintFindStuff()
}
std::cerr << "\n";
std::cerr << "SearchPaths\n";
- for(unsigned int i =0; i < this->SearchPaths.size(); ++i)
+ for(std::vector<std::string>::const_iterator i = this->SearchPaths.begin();
+ i != this->SearchPaths.end(); ++i)
{
- std::cerr << "[" << this->SearchPaths[i] << "]\n";
+ std::cerr << "[" << *i << "]\n";
}
}
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 42d9bc1..8ca311d 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -34,7 +34,6 @@ public:
protected:
void PrintFindStuff();
void ExpandPaths();
- void AddPathSuffixes();
// see if the VariableName is already set in the cache,
// also copy the documentation from the cache to VariableDocumentation
@@ -55,18 +54,12 @@ protected:
bool AlreadyInCacheWithoutMetaInfo;
private:
// Add pieces of the search.
- void AddCMakeEnvironmentPath();
- void AddCMakeVariablePath();
- void AddSystemEnvironmentPath();
- void AddCMakeSystemVariablePath();
- void AddUserHintsPath();
- void AddUserGuessPath();
-
- // Helpers.
- void AddCMakePrefixPath(const std::string& variable);
- void AddEnvPrefixPath(const std::string& variable);
- void AddPrefixPaths(std::vector<std::string> const& in_paths,
- PathType pathType);
+ void FillCMakeVariablePath();
+ void FillCMakeEnvironmentPath();
+ void FillUserHintsPath();
+ void FillSystemEnvironmentPath();
+ void FillCMakeSystemVariablePath();
+ void FillUserGuessPath();
};
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 10241f2..913985f 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -10,6 +10,19 @@
See the License for more information.
============================================================================*/
#include "cmFindCommon.h"
+#include <functional>
+#include <algorithm>
+
+//----------------------------------------------------------------------------
+cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE");
+cmFindCommon::PathLabel
+ cmFindCommon::PathLabel::CMakeEnvironment("CMAKE_ENVIRONMENT");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::Hints("HINTS");
+cmFindCommon::PathLabel
+ cmFindCommon::PathLabel::SystemEnvironment("SYSTM_ENVIRONMENT");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeSystem("CMAKE_SYSTEM");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::Guess("GUESS");
//----------------------------------------------------------------------------
cmFindCommon::cmFindCommon()
@@ -34,6 +47,8 @@ cmFindCommon::cmFindCommon()
this->SearchFrameworkLast = false;
this->SearchAppBundleOnly = false;
this->SearchAppBundleLast = false;
+
+ this->InitializeSearchPathGroups();
}
//----------------------------------------------------------------------------
@@ -42,11 +57,42 @@ cmFindCommon::~cmFindCommon()
}
//----------------------------------------------------------------------------
-void cmFindCommon::SelectDefaultRootPathMode()
+void cmFindCommon::InitializeSearchPathGroups()
{
- // Use both by default.
- this->FindRootPathMode = RootPathModeBoth;
+ std::vector<PathLabel>* labels;
+
+ // Define the varoius different groups of path types
+
+ // All search paths
+ labels = &this->PathGroupLabelMap[PathGroup::All];
+ labels->push_back(PathLabel::CMake);
+ labels->push_back(PathLabel::CMakeEnvironment);
+ labels->push_back(PathLabel::Hints);
+ labels->push_back(PathLabel::SystemEnvironment);
+ labels->push_back(PathLabel::CMakeSystem);
+ labels->push_back(PathLabel::Guess);
+
+ // Define the search group order
+ this->PathGroupOrder.push_back(PathGroup::All);
+
+ // Create the idividual labeld search paths
+ this->LabeledPaths.insert(std::make_pair(PathLabel::CMake,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeEnvironment,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::Hints,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::SystemEnvironment,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::CMakeSystem,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::Guess,
+ cmSearchPath(this)));
+}
+//----------------------------------------------------------------------------
+void cmFindCommon::SelectDefaultRootPathMode()
+{
// Check the policy variable for this find command type.
std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
findRootPathVar += this->CMakePathName;
@@ -54,11 +100,11 @@ void cmFindCommon::SelectDefaultRootPathMode()
this->Makefile->GetSafeDefinition(findRootPathVar);
if (rootPathMode=="NEVER")
{
- this->FindRootPathMode = RootPathModeNoRootPath;
+ this->FindRootPathMode = RootPathModeNever;
}
else if (rootPathMode=="ONLY")
{
- this->FindRootPathMode = RootPathModeOnlyRootPath;
+ this->FindRootPathMode = RootPathModeOnly;
}
else if (rootPathMode=="BOTH")
{
@@ -132,12 +178,12 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
fprintf(stderr, "[%s]\n", i->c_str());
}
#endif
-
// Short-circuit if there is nothing to do.
- if(this->FindRootPathMode == RootPathModeNoRootPath)
+ if(this->FindRootPathMode == RootPathModeNever)
{
return;
}
+
const char* sysroot =
this->Makefile->GetDefinition("CMAKE_SYSROOT");
const char* rootPath =
@@ -182,9 +228,9 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
// already inside. Skip the unrooted path if it is relative to
// a user home directory or is empty.
std::string rootedDir;
- if(cmSystemTools::IsSubDirectory(ui->c_str(), ri->c_str())
+ if(cmSystemTools::IsSubDirectory(*ui, *ri)
|| (stagePrefix
- && cmSystemTools::IsSubDirectory(ui->c_str(), stagePrefix)))
+ && cmSystemTools::IsSubDirectory(*ui, stagePrefix)))
{
rootedDir = *ui;
}
@@ -195,7 +241,7 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
rootedDir += "/";
// Append the original path with its old root removed.
- rootedDir += cmSystemTools::SplitPathRootComponent(ui->c_str());
+ rootedDir += cmSystemTools::SplitPathRootComponent(*ui);
}
// Store the new path.
@@ -212,24 +258,20 @@ void cmFindCommon::RerootPaths(std::vector<std::string>& paths)
}
//----------------------------------------------------------------------------
-void cmFindCommon::FilterPaths(std::vector<std::string>& paths,
- const std::set<std::string>& ignore)
+void cmFindCommon::FilterPaths(const std::vector<std::string>& inPaths,
+ const std::set<std::string>& ignore,
+ std::vector<std::string>& outPaths)
{
- // Now filter out anything that's in the ignore set.
- std::vector<std::string> unfiltered;
- unfiltered.swap(paths);
-
- for(std::vector<std::string>::iterator pi = unfiltered.begin();
- pi != unfiltered.end(); ++pi)
+ for(std::vector<std::string>::const_iterator i = inPaths.begin();
+ i != inPaths.end(); ++i)
{
- if (ignore.count(*pi) == 0)
+ if(ignore.count(*i) == 0)
{
- paths.push_back(*pi);
+ outPaths.push_back(*i);
}
}
}
-
//----------------------------------------------------------------------------
void cmFindCommon::GetIgnoredPaths(std::vector<std::string>& ignore)
{
@@ -266,8 +308,6 @@ void cmFindCommon::GetIgnoredPaths(std::set<std::string>& ignore)
ignore.insert(ignoreVec.begin(), ignoreVec.end());
}
-
-
//----------------------------------------------------------------------------
bool cmFindCommon::CheckCommonArgument(std::string const& arg)
{
@@ -291,13 +331,13 @@ bool cmFindCommon::CheckCommonArgument(std::string const& arg)
{
this->NoCMakeSystemPath = true;
}
- else if(arg == "NO_CMAKE_FIND_ROOT_PATH")
+ else if(arg == "NO_CMAKE_FIND_ROOT_PATH")
{
- this->FindRootPathMode = RootPathModeNoRootPath;
+ this->FindRootPathMode = RootPathModeNever;
}
else if(arg == "ONLY_CMAKE_FIND_ROOT_PATH")
{
- this->FindRootPathMode = RootPathModeOnlyRootPath;
+ this->FindRootPathMode = RootPathModeOnly;
}
else if(arg == "CMAKE_FIND_ROOT_PATH_BOTH")
{
@@ -345,116 +385,34 @@ void cmFindCommon::AddPathSuffix(std::string const& arg)
}
//----------------------------------------------------------------------------
-void cmFindCommon::AddUserPath(std::string const& p,
- std::vector<std::string>& paths)
-{
- // We should view the registry as the target application would view
- // it.
- cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
- cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
- if(this->Makefile->PlatformIs64Bit())
- {
- view = cmSystemTools::KeyWOW64_64;
- other_view = cmSystemTools::KeyWOW64_32;
- }
-
- // Expand using the view of the target application.
- std::string expanded = p;
- cmSystemTools::ExpandRegistryValues(expanded, view);
- cmSystemTools::GlobDirs(expanded, paths);
-
- // Executables can be either 32-bit or 64-bit, so expand using the
- // alternative view.
- if(expanded != p && this->CMakePathName == "PROGRAM")
- {
- expanded = p;
- cmSystemTools::ExpandRegistryValues(expanded, other_view);
- cmSystemTools::GlobDirs(expanded, paths);
- }
-}
-
-//----------------------------------------------------------------------------
-void cmFindCommon::AddCMakePath(const std::string& variable)
-{
- // Get a path from a CMake variable.
- if(const char* varPath = this->Makefile->GetDefinition(variable))
- {
- std::vector<std::string> tmp;
- cmSystemTools::ExpandListArgument(varPath, tmp);
-
- // Relative paths are interpreted with respect to the current
- // source directory.
- this->AddPathsInternal(tmp, CMakePath);
- }
-}
-
-//----------------------------------------------------------------------------
-void cmFindCommon::AddEnvPath(const char* variable)
-{
- // Get a path from the environment.
- std::vector<std::string> tmp;
- cmSystemTools::GetPath(tmp, variable);
- // Relative paths are interpreted with respect to the current
- // working directory.
- this->AddPathsInternal(tmp, EnvPath);
-}
-
-//----------------------------------------------------------------------------
-void cmFindCommon::AddPathsInternal(std::vector<std::string> const& in_paths,
- PathType pathType)
+void AddTrailingSlash(std::string& s)
{
- for(std::vector<std::string>::const_iterator i = in_paths.begin();
- i != in_paths.end(); ++i)
+ if(!s.empty() && *s.rbegin() != '/')
{
- this->AddPathInternal(*i, pathType);
+ s += '/';
}
}
-
-//----------------------------------------------------------------------------
-void cmFindCommon::AddPathInternal(std::string const& in_path,
- PathType pathType)
+void cmFindCommon::ComputeFinalPaths()
{
- if(in_path.empty())
- {
- return;
- }
+ // Filter out ignored paths from the prefix list
+ std::set<std::string> ignored;
+ this->GetIgnoredPaths(ignored);
- // Select the base path with which to interpret relative paths.
- const char* relbase = 0;
- if(pathType == CMakePath)
+ // Combine the seperate path types, filtering out ignores
+ this->SearchPaths.clear();
+ std::vector<PathLabel>& allLabels = this->PathGroupLabelMap[PathGroup::All];
+ for(std::vector<PathLabel>::const_iterator l = allLabels.begin();
+ l != allLabels.end(); ++l)
{
- relbase = this->Makefile->GetCurrentDirectory();
+ this->LabeledPaths[*l].ExtractWithout(ignored, this->SearchPaths);
}
- // Convert to clean full path.
- std::string fullPath =
- cmSystemTools::CollapseFullPath(in_path.c_str(), relbase);
-
- // Insert the path if has not already been emitted.
- if(this->SearchPathsEmitted.insert(fullPath).second)
- {
- this->SearchPaths.push_back(fullPath);
- }
-}
-
-//----------------------------------------------------------------------------
-void cmFindCommon::ComputeFinalPaths()
-{
- std::vector<std::string>& paths = this->SearchPaths;
-
// Expand list of paths inside all search roots.
- this->RerootPaths(paths);
+ this->RerootPaths(this->SearchPaths);
// Add a trailing slash to all paths to aid the search process.
- for(std::vector<std::string>::iterator i = paths.begin();
- i != paths.end(); ++i)
- {
- std::string& p = *i;
- if(!p.empty() && p[p.size()-1] != '/')
- {
- p += "/";
- }
- }
+ std::for_each(this->SearchPaths.begin(), this->SearchPaths.end(),
+ &AddTrailingSlash);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 5a905cd..3fefc8d 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -13,6 +13,8 @@
#define cmFindCommon_h
#include "cmCommand.h"
+#include "cmSearchPath.h"
+#include "cmPathLabel.h"
/** \class cmFindCommon
* \brief Base class for FIND_XXX implementations.
@@ -29,12 +31,39 @@ public:
cmTypeMacro(cmFindCommon, cmCommand);
protected:
-
- enum RootPathMode { RootPathModeBoth,
- RootPathModeOnlyRootPath,
- RootPathModeNoRootPath };
-
- enum PathType { FullPath, CMakePath, EnvPath };
+ friend class cmSearchPath;
+
+ /** Used to define groups of path labels */
+ class PathGroup : public cmPathLabel
+ {
+ protected:
+ PathGroup();
+ public:
+ PathGroup(const std::string& label) : cmPathLabel(label) { }
+ static PathGroup All;
+ };
+
+ /* Individual path types */
+ class PathLabel : public cmPathLabel
+ {
+ protected:
+ PathLabel();
+ public:
+ PathLabel(const std::string& label) : cmPathLabel(label) { }
+ static PathLabel CMake;
+ static PathLabel CMakeEnvironment;
+ static PathLabel Hints;
+ static PathLabel SystemEnvironment;
+ static PathLabel CMakeSystem;
+ static PathLabel Guess;
+ };
+
+ enum RootPathMode { RootPathModeNever,
+ RootPathModeOnly,
+ RootPathModeBoth };
+
+ /** Construct the various path groups and labels */
+ void InitializeSearchPathGroups();
/** Place a set of search paths under the search roots. */
void RerootPaths(std::vector<std::string>& paths);
@@ -44,8 +73,9 @@ protected:
void GetIgnoredPaths(std::set<std::string>& ignore);
/** Remove paths in the ignore set from the supplied vector. */
- void FilterPaths(std::vector<std::string>& paths,
- const std::set<std::string>& ignore);
+ void FilterPaths(const std::vector<std::string>& inPaths,
+ const std::set<std::string>& ignore,
+ std::vector<std::string>& outPaths);
/** Compute final search path list (reroot + trailing slash). */
void ComputeFinalPaths();
@@ -56,19 +86,15 @@ protected:
/** Compute the current default bundle/framework search policy. */
void SelectDefaultMacMode();
+ // Path arguments prior to path manipulation routines
+ std::vector<std::string> UserHintsArgs;
+ std::vector<std::string> UserGuessArgs;
+
std::string CMakePathName;
RootPathMode FindRootPathMode;
bool CheckCommonArgument(std::string const& arg);
void AddPathSuffix(std::string const& arg);
- void AddUserPath(std::string const& p,
- std::vector<std::string>& paths);
- void AddCMakePath(const std::string& variable);
- void AddEnvPath(const char* variable);
- void AddPathsInternal(std::vector<std::string> const& in_paths,
- PathType pathType);
- void AddPathInternal(std::string const& in_path, PathType pathType);
-
void SetMakefile(cmMakefile* makefile);
bool NoDefaultPath;
@@ -78,8 +104,12 @@ protected:
bool NoCMakeSystemPath;
std::vector<std::string> SearchPathSuffixes;
- std::vector<std::string> UserPaths;
- std::vector<std::string> UserHints;
+
+ std::map<PathGroup, std::vector<PathLabel> > PathGroupLabelMap;
+ std::vector<PathGroup> PathGroupOrder;
+ std::map<std::string, PathLabel> PathLabelStringMap;
+ std::map<PathLabel, cmSearchPath> LabeledPaths;
+
std::vector<std::string> SearchPaths;
std::set<std::string> SearchPathsEmitted;
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index fe5e45f..78f0e9e 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -88,7 +88,7 @@ void cmFindLibraryCommand::AddArchitecturePaths(const char* suffix)
{
std::vector<std::string> original;
original.swap(this->SearchPaths);
- for(std::vector<std::string>::iterator i = original.begin();
+ for(std::vector<std::string>::const_iterator i = original.begin();
i != original.end(); ++i)
{
this->AddArchitecturePath(*i, 0, suffix);
@@ -107,7 +107,7 @@ void cmFindLibraryCommand::AddArchitecturePath(
// Follow "lib<suffix>".
std::string next_dir = cur_dir + suffix;
- if(cmSystemTools::FileIsDirectory(next_dir.c_str()))
+ if(cmSystemTools::FileIsDirectory(next_dir))
{
next_dir += dir.substr(pos+3);
std::string::size_type next_pos = pos+3+strlen(suffix)+1;
@@ -115,7 +115,7 @@ void cmFindLibraryCommand::AddArchitecturePath(
}
// Follow "lib".
- if(cmSystemTools::FileIsDirectory(cur_dir.c_str()))
+ if(cmSystemTools::FileIsDirectory(cur_dir))
{
this->AddArchitecturePath(dir, pos+3+1, suffix, false);
}
@@ -124,13 +124,13 @@ void cmFindLibraryCommand::AddArchitecturePath(
{
// Check for <dir><suffix>/.
std::string cur_dir = dir + suffix + "/";
- if(cmSystemTools::FileIsDirectory(cur_dir.c_str()))
+ if(cmSystemTools::FileIsDirectory(cur_dir))
{
this->SearchPaths.push_back(cur_dir);
}
// Now add the original unchanged path
- if(cmSystemTools::FileIsDirectory(dir.c_str()))
+ if(cmSystemTools::FileIsDirectory(dir))
{
this->SearchPaths.push_back(dir);
}
@@ -353,7 +353,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
if(cmSystemTools::FileExists(this->TestPath.c_str(), true))
{
this->BestPath =
- cmSystemTools::CollapseFullPath(this->TestPath.c_str());
+ cmSystemTools::CollapseFullPath(this->TestPath);
cmSystemTools::ConvertToUnixSlashes(this->BestPath);
return true;
}
@@ -382,7 +382,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
{
this->TestPath = path;
this->TestPath += origName;
- if(!cmSystemTools::FileIsDirectory(this->TestPath.c_str()))
+ if(!cmSystemTools::FileIsDirectory(this->TestPath))
{
// This is a matching file. Check if it is better than the
// best name found so far. Earlier prefixes are preferred,
@@ -506,9 +506,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryNamesPerDir()
fwPath = *di;
fwPath += *ni;
fwPath += ".framework";
- if(cmSystemTools::FileIsDirectory(fwPath.c_str()))
+ if(cmSystemTools::FileIsDirectory(fwPath))
{
- return cmSystemTools::CollapseFullPath(fwPath.c_str());
+ return cmSystemTools::CollapseFullPath(fwPath);
}
}
}
@@ -532,9 +532,9 @@ std::string cmFindLibraryCommand::FindFrameworkLibraryDirsPerName()
fwPath = *di;
fwPath += *ni;
fwPath += ".framework";
- if(cmSystemTools::FileIsDirectory(fwPath.c_str()))
+ if(cmSystemTools::FileIsDirectory(fwPath))
{
- return cmSystemTools::CollapseFullPath(fwPath.c_str());
+ return cmSystemTools::CollapseFullPath(fwPath);
}
}
}
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 55a61f5..7746980 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -26,6 +26,14 @@
#endif
//----------------------------------------------------------------------------
+cmFindPackageCommand::PathLabel
+ cmFindPackageCommand::PathLabel::UserRegistry("PACKAGE_REGISTRY");
+cmFindPackageCommand::PathLabel
+ cmFindPackageCommand::PathLabel::Builds("BUILDS");
+cmFindPackageCommand::PathLabel
+ cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY");
+
+//----------------------------------------------------------------------------
cmFindPackageCommand::cmFindPackageCommand()
{
this->CMakePathName = "PACKAGE";
@@ -51,6 +59,33 @@ cmFindPackageCommand::cmFindPackageCommand()
this->VersionFoundTweak = 0;
this->VersionFoundCount = 0;
this->RequiredCMakeVersion = 0;
+
+ this->AppendSearchPathGroups();
+}
+
+//----------------------------------------------------------------------------
+void cmFindPackageCommand::AppendSearchPathGroups()
+{
+ std::vector<cmFindCommon::PathLabel>* labels;
+
+ // Update the All group with new paths
+ labels = &this->PathGroupLabelMap[PathGroup::All];
+ labels->insert(std::find(labels->begin(), labels->end(),
+ PathLabel::CMakeSystem),
+ PathLabel::UserRegistry);
+ labels->insert(std::find(labels->begin(), labels->end(),
+ PathLabel::CMakeSystem),
+ PathLabel::Builds);
+ labels->insert(std::find(labels->begin(), labels->end(), PathLabel::Guess),
+ PathLabel::SystemRegistry);
+
+ // Create the new path objects
+ this->LabeledPaths.insert(std::make_pair(PathLabel::UserRegistry,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::Builds,
+ cmSearchPath(this)));
+ this->LabeledPaths.insert(std::make_pair(PathLabel::SystemRegistry,
+ cmSearchPath(this)));
}
//----------------------------------------------------------------------------
@@ -248,11 +283,11 @@ bool cmFindPackageCommand
}
else if(doing == DoingPaths)
{
- this->AddUserPath(args[i], this->UserPaths);
+ this->UserGuessArgs.push_back(args[i]);
}
else if(doing == DoingHints)
{
- this->AddUserPath(args[i], this->UserHints);
+ this->UserHintsArgs.push_back(args[i]);
}
else if(doing == DoingPathSuffixes)
{
@@ -263,7 +298,7 @@ bool cmFindPackageCommand
if(args[i].find_first_of(":/\\") != args[i].npos ||
cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given CONFIGS option followed by invalid file name \""
<< args[i] << "\". The names given must be file names without "
<< "a path and with a \".cmake\" extension.";
@@ -279,7 +314,7 @@ bool cmFindPackageCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "called with invalid argument \"" << args[i] << "\"";
this->SetError(e.str());
return false;
@@ -292,7 +327,7 @@ bool cmFindPackageCommand
std::back_inserter(doubledComponents));
if(!doubledComponents.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "called with components that are both required and optional:\n";
for(unsigned int i=0; i<doubledComponents.size(); ++i)
{
@@ -307,7 +342,7 @@ bool cmFindPackageCommand
this->UseConfigFiles = moduleArgs.empty();
if(!this->UseFindModules && !this->UseConfigFiles)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given options exclusive to Module mode:\n";
for(std::set<unsigned int>::const_iterator si = moduleArgs.begin();
si != moduleArgs.end(); ++si)
@@ -389,7 +424,7 @@ bool cmFindPackageCommand
{
if (this->Required)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "for module " << this->Name << " called with REQUIRED, but "
<< disableFindPackageVar
<< " is enabled. A REQUIRED package cannot be disabled.";
@@ -422,7 +457,7 @@ bool cmFindPackageCommand
if(this->UseFindModules && this->UseConfigFiles &&
this->Makefile->IsOn("CMAKE_FIND_PACKAGE_WARN_NO_MODULE"))
{
- cmOStringStream aw;
+ std::ostringstream aw;
if(this->RequiredCMakeVersion >= CMake_VERSION_ENCODE(2,8,8))
{
aw << "find_package called without either MODULE or CONFIG option and "
@@ -587,7 +622,7 @@ bool cmFindPackageCommand::FindModule(bool& found)
module += this->Name;
module += ".cmake";
std::string mfile = this->Makefile->GetModulesFile(module.c_str());
- if ( mfile.size() )
+ if (!mfile.empty())
{
// Load the module we found, and set "<name>_FIND_MODULE" to true
// while inside it.
@@ -713,8 +748,8 @@ bool cmFindPackageCommand::HandlePackageMode()
if (result && !found && (!this->Quiet || this->Required))
{
// The variable is not set.
- cmOStringStream e;
- cmOStringStream aw;
+ std::ostringstream e;
+ std::ostringstream aw;
if (configFileSetFOUNDFalse)
{
e << "Found package configuration file:\n"
@@ -728,7 +763,7 @@ bool cmFindPackageCommand::HandlePackageMode()
}
// If there are files in ConsideredConfigs, it means that FooConfig.cmake
// have been found, but they didn't have appropriate versions.
- else if (this->ConsideredConfigs.size() > 0)
+ else if (!this->ConsideredConfigs.empty())
{
e << "Could not find a configuration file for package \""
<< this->Name << "\" that "
@@ -1111,86 +1146,97 @@ void cmFindPackageCommand::AppendSuccessInformation()
//----------------------------------------------------------------------------
void cmFindPackageCommand::ComputePrefixes()
{
- this->AddPrefixesCMakeVariable();
- this->AddPrefixesCMakeEnvironment();
- this->AddPrefixesUserHints();
- this->AddPrefixesSystemEnvironment();
- this->AddPrefixesUserRegistry();
- this->AddPrefixesBuilds();
- this->AddPrefixesCMakeSystemVariable();
- this->AddPrefixesSystemRegistry();
- this->AddPrefixesUserGuess();
+ if(!this->NoDefaultPath)
+ {
+ if(!this->NoCMakePath)
+ {
+ this->FillPrefixesCMakeVariable();
+ }
+ if(!this->NoCMakeEnvironmentPath)
+ {
+ this->FillPrefixesCMakeEnvironment();
+ }
+ if(!this->NoSystemEnvironmentPath)
+ {
+ this->FillPrefixesSystemEnvironment();
+ }
+ if(!this->NoUserRegistry)
+ {
+ this->FillPrefixesUserRegistry();
+ }
+ if(!this->NoBuilds)
+ {
+ this->FillPrefixesBuilds();
+ }
+ if(!this->NoCMakeSystemPath)
+ {
+ this->FillPrefixesCMakeSystemVariable();
+ }
+ if(!this->NoSystemRegistry)
+ {
+ this->FillPrefixesSystemRegistry();
+ }
+ }
+ this->FillPrefixesUserHints();
+ this->FillPrefixesUserGuess();
+
this->ComputeFinalPaths();
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesCMakeEnvironment()
+void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
{
- if(!this->NoCMakeEnvironmentPath && !this->NoDefaultPath)
- {
- // Check the environment variable with the same name as the cache
- // entry.
- std::string env;
- if(cmSystemTools::GetEnv(this->Variable.c_str(), env) && env.length() > 0)
- {
- cmSystemTools::ConvertToUnixSlashes(env);
- this->AddPathInternal(env, EnvPath);
- }
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeEnvironment];
- this->AddEnvPath("CMAKE_PREFIX_PATH");
- this->AddEnvPath("CMAKE_FRAMEWORK_PATH");
- this->AddEnvPath("CMAKE_APPBUNDLE_PATH");
- }
+ // Check the environment variable with the same name as the cache
+ // entry.
+ paths.AddEnvPath(this->Variable);
+
+ // And now the general CMake environment variables
+ paths.AddEnvPath("CMAKE_PREFIX_PATH");
+ paths.AddEnvPath("CMAKE_FRAMEWORK_PATH");
+ paths.AddEnvPath("CMAKE_APPBUNDLE_PATH");
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesCMakeVariable()
+void cmFindPackageCommand::FillPrefixesCMakeVariable()
{
- if(!this->NoCMakePath && !this->NoDefaultPath)
- {
- this->AddCMakePath("CMAKE_PREFIX_PATH");
- this->AddCMakePath("CMAKE_FRAMEWORK_PATH");
- this->AddCMakePath("CMAKE_APPBUNDLE_PATH");
- }
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::CMake];
+
+ paths.AddCMakePath("CMAKE_PREFIX_PATH");
+ paths.AddCMakePath("CMAKE_FRAMEWORK_PATH");
+ paths.AddCMakePath("CMAKE_APPBUNDLE_PATH");
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesSystemEnvironment()
+void cmFindPackageCommand::FillPrefixesSystemEnvironment()
{
- if(!this->NoSystemEnvironmentPath && !this->NoDefaultPath)
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemEnvironment];
+
+ // Use the system search path to generate prefixes.
+ // Relative paths are interpreted with respect to the current
+ // working directory.
+ std::vector<std::string> tmp;
+ cmSystemTools::GetPath(tmp);
+ for(std::vector<std::string>::iterator i = tmp.begin();
+ i != tmp.end(); ++i)
{
- // Use the system search path to generate prefixes.
- // Relative paths are interpreted with respect to the current
- // working directory.
- std::vector<std::string> tmp;
- cmSystemTools::GetPath(tmp);
- for(std::vector<std::string>::iterator i = tmp.begin();
- i != tmp.end(); ++i)
+ // If the path is a PREFIX/bin case then add its parent instead.
+ if((cmHasLiteralSuffix(*i, "/bin")) ||
+ (cmHasLiteralSuffix(*i, "/sbin")))
{
- std::string const& d = *i;
-
- // If the path is a PREFIX/bin case then add its parent instead.
- if((cmHasLiteralSuffix(d, "/bin")) ||
- (cmHasLiteralSuffix(d, "/sbin")))
- {
- this->AddPathInternal(cmSystemTools::GetFilenamePath(d), EnvPath);
- }
- else
- {
- this->AddPathInternal(d, EnvPath);
- }
+ paths.AddPath(cmSystemTools::GetFilenamePath(*i));
+ }
+ else
+ {
+ paths.AddPath(*i);
}
}
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesUserRegistry()
+void cmFindPackageCommand::FillPrefixesUserRegistry()
{
- if(this->NoUserRegistry || this->NoDefaultPath)
- {
- return;
- }
-
#if defined(_WIN32) && !defined(__CYGWIN__)
this->LoadPackageRegistryWinUser();
#elif defined(__HAIKU__)
@@ -1201,7 +1247,8 @@ void cmFindPackageCommand::AddPrefixesUserRegistry()
std::string fname = dir;
fname += "/cmake/packages/";
fname += Name;
- this->LoadPackageRegistryDir(fname);
+ this->LoadPackageRegistryDir(fname,
+ this->LabeledPaths[PathLabel::UserRegistry]);
}
#else
if(const char* home = cmSystemTools::GetEnv("HOME"))
@@ -1209,13 +1256,14 @@ void cmFindPackageCommand::AddPrefixesUserRegistry()
std::string dir = home;
dir += "/.cmake/packages/";
dir += this->Name;
- this->LoadPackageRegistryDir(dir);
+ this->LoadPackageRegistryDir(dir,
+ this->LabeledPaths[PathLabel::UserRegistry]);
}
#endif
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesSystemRegistry()
+void cmFindPackageCommand::FillPrefixesSystemRegistry()
{
if(this->NoSystemRegistry || this->NoDefaultPath)
{
@@ -1241,29 +1289,32 @@ void cmFindPackageCommand::AddPrefixesSystemRegistry()
void cmFindPackageCommand::LoadPackageRegistryWinUser()
{
// HKEY_CURRENT_USER\\Software shares 32-bit and 64-bit views.
- this->LoadPackageRegistryWin(true, 0);
+ this->LoadPackageRegistryWin(true, 0,
+ this->LabeledPaths[PathLabel::UserRegistry]);
}
//----------------------------------------------------------------------------
void cmFindPackageCommand::LoadPackageRegistryWinSystem()
{
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::SystemRegistry];
+
// HKEY_LOCAL_MACHINE\\SOFTWARE has separate 32-bit and 64-bit views.
// Prefer the target platform view first.
if(this->Makefile->PlatformIs64Bit())
{
- this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY);
- this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY);
+ this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
+ this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
}
else
{
- this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY);
- this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY);
+ this->LoadPackageRegistryWin(false, KEY_WOW64_32KEY, paths);
+ this->LoadPackageRegistryWin(false, KEY_WOW64_64KEY, paths);
}
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
- unsigned int view)
+void cmFindPackageCommand::LoadPackageRegistryWin(bool user, unsigned int view,
+ cmSearchPath& outPaths)
{
std::wstring key = L"Software\\Kitware\\CMake\\Packages\\";
key += cmsys::Encoding::ToWide(this->Name);
@@ -1289,8 +1340,8 @@ void cmFindPackageCommand::LoadPackageRegistryWin(bool user,
if(valueType == REG_SZ)
{
data[dataSize] = 0;
- cmsys_ios::stringstream ss(cmsys::Encoding::ToNarrow(&data[0]));
- if(!this->CheckPackageRegistryEntry(ss))
+ if(!this->CheckPackageRegistryEntry(
+ cmsys::Encoding::ToNarrow(&data[0]), outPaths))
{
// The entry is invalid.
bad.insert(name);
@@ -1332,10 +1383,11 @@ public:
};
//----------------------------------------------------------------------------
-void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir)
+void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir,
+ cmSearchPath& outPaths)
{
cmsys::Directory files;
- if(!files.Load(dir.c_str()))
+ if(!files.Load(dir))
{
return;
}
@@ -1347,14 +1399,16 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir)
fname += "/";
fname += files.GetFile(i);
- if(!cmSystemTools::FileIsDirectory(fname.c_str()))
+ if(!cmSystemTools::FileIsDirectory(fname))
{
// Hold this file hostage until it behaves.
cmFindPackageCommandHoldFile holdFile(fname.c_str());
// Load the file.
cmsys::ifstream fin(fname.c_str(), std::ios::in | cmsys_ios_binary);
- if(fin && this->CheckPackageRegistryEntry(fin))
+ std::string fentry;
+ if(fin && cmSystemTools::GetLineFromStream(fin, fentry) &&
+ this->CheckPackageRegistryEntry(fentry, outPaths))
{
// The file references an existing package, so release it.
holdFile.Release();
@@ -1367,23 +1421,25 @@ void cmFindPackageCommand::LoadPackageRegistryDir(std::string const& dir)
#endif
//----------------------------------------------------------------------------
-bool cmFindPackageCommand::CheckPackageRegistryEntry(std::istream& is)
+bool cmFindPackageCommand::CheckPackageRegistryEntry(const std::string& fname,
+ cmSearchPath& outPaths)
{
// Parse the content of one package registry entry.
- std::string fname;
- if(cmSystemTools::GetLineFromStream(is, fname) &&
- cmSystemTools::FileIsFullPath(fname.c_str()))
+ if(cmSystemTools::FileIsFullPath(fname.c_str()))
{
// The first line in the stream is the full path to a file or
// directory containing the package.
if(cmSystemTools::FileExists(fname.c_str()))
{
// The path exists. Look for the package here.
- if(!cmSystemTools::FileIsDirectory(fname.c_str()))
+ if(!cmSystemTools::FileIsDirectory(fname))
+ {
+ outPaths.AddPath(cmSystemTools::GetFilenamePath(fname));
+ }
+ else
{
- fname = cmSystemTools::GetFilenamePath(fname);
+ outPaths.AddPath(fname);
}
- this->AddPathInternal(fname, FullPath);
return true;
}
else
@@ -1404,52 +1460,60 @@ bool cmFindPackageCommand::CheckPackageRegistryEntry(std::istream& is)
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesBuilds()
+void cmFindPackageCommand::FillPrefixesBuilds()
{
- if(!this->NoBuilds && !this->NoDefaultPath)
- {
- // It is likely that CMake will have recently built the project.
- for(int i=0; i <= 10; ++i)
- {
- cmOStringStream r;
- r <<
- "[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\"
- "Settings\\StartPath;WhereBuild" << i << "]";
- std::string f = r.str();
- cmSystemTools::ExpandRegistryValues(f);
- cmSystemTools::ConvertToUnixSlashes(f);
- if(cmSystemTools::FileIsFullPath(f.c_str()) &&
- cmSystemTools::FileIsDirectory(f.c_str()))
- {
- this->AddPathInternal(f, FullPath);
- }
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::Builds];
+
+ // It is likely that CMake will have recently built the project.
+ for(int i=0; i <= 10; ++i)
+ {
+ std::ostringstream r;
+ r <<
+ "[HKEY_CURRENT_USER\\Software\\Kitware\\CMakeSetup\\"
+ "Settings\\StartPath;WhereBuild" << i << "]";
+ std::string f = r.str();
+ cmSystemTools::ExpandRegistryValues(f);
+ cmSystemTools::ConvertToUnixSlashes(f);
+ if(cmSystemTools::FileIsFullPath(f.c_str()) &&
+ cmSystemTools::FileIsDirectory(f))
+ {
+ paths.AddPath(f);
}
}
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesCMakeSystemVariable()
+void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
{
- if(!this->NoCMakeSystemPath && !this->NoDefaultPath)
- {
- this->AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
- this->AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
- this->AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
- }
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::CMakeSystem];
+
+ paths.AddCMakePath("CMAKE_SYSTEM_PREFIX_PATH");
+ paths.AddCMakePath("CMAKE_SYSTEM_FRAMEWORK_PATH");
+ paths.AddCMakePath("CMAKE_SYSTEM_APPBUNDLE_PATH");
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesUserGuess()
+void cmFindPackageCommand::FillPrefixesUserGuess()
{
- // Add guesses specified by the caller.
- this->AddPathsInternal(this->UserPaths, CMakePath);
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::Guess];
+
+ for(std::vector<std::string>::const_iterator p = this->UserGuessArgs.begin();
+ p != this->UserGuessArgs.end(); ++p)
+ {
+ paths.AddUserPath(*p);
+ }
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddPrefixesUserHints()
+void cmFindPackageCommand::FillPrefixesUserHints()
{
- // Add hints specified by the caller.
- this->AddPathsInternal(this->UserHints, CMakePath);
+ cmSearchPath &paths = this->LabeledPaths[PathLabel::Hints];
+
+ for(std::vector<std::string>::const_iterator p = this->UserHintsArgs.begin();
+ p != this->UserHintsArgs.end(); ++p)
+ {
+ paths.AddUserPath(*p);
+ }
}
//----------------------------------------------------------------------------
@@ -1847,7 +1911,7 @@ private:
// Construct a list of matches.
std::vector<std::string> matches;
cmsys::Directory d;
- d.Load(parent.c_str());
+ d.Load(parent);
for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i)
{
const char* fname = d.GetFile(i);
@@ -1901,7 +1965,7 @@ private:
// Construct a list of matches.
std::vector<std::string> matches;
cmsys::Directory d;
- d.Load(parent.c_str());
+ d.Load(parent);
for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i)
{
const char* fname = d.GetFile(i);
@@ -1955,7 +2019,7 @@ private:
// Look for matching files.
std::vector<std::string> matches;
cmsys::Directory d;
- d.Load(parent.c_str());
+ d.Load(parent);
for(unsigned long i=0; i < d.GetNumberOfFiles(); ++i)
{
const char* fname = d.GetFile(i);
@@ -2007,7 +2071,7 @@ private:
for(std::vector<std::string>::const_iterator fi = files.begin();
fi != files.end(); ++fi)
{
- if(cmSystemTools::FileIsDirectory(fi->c_str()))
+ if(cmSystemTools::FileIsDirectory(*fi))
{
if(this->Consider(*fi, lister))
{
@@ -2035,7 +2099,7 @@ bool cmFindPackageCommand::SearchPrefix(std::string const& prefix_in)
}
// Skip this if the prefix does not exist.
- if(!cmSystemTools::FileIsDirectory(prefix_in.c_str()))
+ if(!cmSystemTools::FileIsDirectory(prefix_in))
{
return false;
}
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 2249459..949dcb1 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -53,6 +53,21 @@ public:
cmTypeMacro(cmFindPackageCommand, cmFindCommon);
private:
+ class PathLabel : public cmFindCommon::PathLabel
+ {
+ protected:
+ PathLabel();
+ public:
+ PathLabel(const std::string& label) : cmFindCommon::PathLabel(label) { }
+ static PathLabel UserRegistry;
+ static PathLabel Builds;
+ static PathLabel SystemRegistry;
+ };
+
+ // Add additional search path labels and groups not present in the
+ // parent class
+ void AppendSearchPathGroups();
+
void AppendSuccessInformation();
void AppendToFoundProperty(bool found);
void SetModuleVariables(const std::string& components);
@@ -69,20 +84,22 @@ private:
void StoreVersionFound();
void ComputePrefixes();
- void AddPrefixesCMakeEnvironment();
- void AddPrefixesCMakeVariable();
- void AddPrefixesSystemEnvironment();
- void AddPrefixesUserRegistry();
- void AddPrefixesSystemRegistry();
- void AddPrefixesBuilds();
- void AddPrefixesCMakeSystemVariable();
- void AddPrefixesUserGuess();
- void AddPrefixesUserHints();
- void LoadPackageRegistryDir(std::string const& dir);
+ void FillPrefixesCMakeEnvironment();
+ void FillPrefixesCMakeVariable();
+ void FillPrefixesSystemEnvironment();
+ void FillPrefixesUserRegistry();
+ void FillPrefixesSystemRegistry();
+ void FillPrefixesBuilds();
+ void FillPrefixesCMakeSystemVariable();
+ void FillPrefixesUserGuess();
+ void FillPrefixesUserHints();
+ void LoadPackageRegistryDir(std::string const& dir, cmSearchPath& outPaths);
void LoadPackageRegistryWinUser();
void LoadPackageRegistryWinSystem();
- void LoadPackageRegistryWin(bool user, unsigned int view);
- bool CheckPackageRegistryEntry(std::istream& is);
+ void LoadPackageRegistryWin(bool user, unsigned int view,
+ cmSearchPath& outPaths);
+ bool CheckPackageRegistryEntry(const std::string& fname,
+ cmSearchPath& outPaths);
bool SearchDirectory(std::string const& dir);
bool CheckDirectory(std::string const& dir);
bool FindConfigFile(std::string const& dir, std::string& file);
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 5531cdf..49fbf45 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -48,7 +48,7 @@ bool cmFindPathCommand
}
std::string result = this->FindHeader();
- if(result.size() != 0)
+ if(!result.empty())
{
this->Makefile->AddCacheDefinition
(this->VariableName, result.c_str(),
@@ -108,7 +108,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file,
fileName = file;
frameWorkName = "";
}
- if(frameWorkName.size())
+ if(!frameWorkName.empty())
{
std::string fpath = dir;
fpath += frameWorkName;
@@ -134,9 +134,9 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file,
cmsys::Glob globIt;
globIt.FindFiles(glob);
std::vector<std::string> files = globIt.GetFiles();
- if(files.size())
+ if(!files.empty())
{
- std::string fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
+ std::string fheader = cmSystemTools::CollapseFullPath(files[0]);
if(this->IncludeFileInPath)
{
return fheader;
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index f6e37f6..4ee419c 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -88,7 +88,7 @@ std::string cmFindProgramCommand
{
std::string appName = *name + std::string(".app");
- std::string appPath = cmSystemTools::FindDirectory(appName.c_str(),
+ std::string appPath = cmSystemTools::FindDirectory(appName,
this->SearchPaths,
true);
@@ -97,7 +97,7 @@ std::string cmFindProgramCommand
std::string executable = GetBundleExecutable(appPath);
if (!executable.empty())
{
- return cmSystemTools::CollapseFullPath(executable.c_str());
+ return cmSystemTools::CollapseFullPath(executable);
}
}
}
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index e3f66c1..8e3510d 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endofreach for this statement
if (!this->Depth)
{
+ cmMakefile::LoopBlockPop loopBlockPop(&mf);
+
// Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff));
@@ -67,12 +69,17 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
mf.AddDefinition(this->Args[0],oldDef.c_str());
return true;
}
+ if (status.GetContinueInvoked())
+ {
+ break;
+ }
if(cmSystemTools::GetFatalErrorOccured() )
{
return true;
}
}
}
+
// restore the variable to its prior value
mf.AddDefinition(this->Args[0],oldDef.c_str());
return true;
@@ -163,7 +170,7 @@ bool cmForEachCommand
step == 0
)
{
- cmOStringStream str;
+ std::ostringstream str;
str << "called with incorrect range specification: start ";
str << start << ", stop " << stop << ", step " << step;
this->SetError(str.str());
@@ -199,6 +206,8 @@ bool cmForEachCommand
}
this->Makefile->AddFunctionBlocker(f);
+ this->Makefile->PushLoopBlock();
+
return true;
}
@@ -234,7 +243,7 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Unknown argument:\n" << " " << args[i] << "\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return true;
@@ -242,5 +251,8 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
}
this->Makefile->AddFunctionBlocker(f.release()); // TODO: pass auto_ptr
+
+ this->Makefile->PushLoopBlock();
+
return true;
}
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 3580374..c33048c 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -103,7 +103,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass
cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
// set the value of argc
- cmOStringStream strStream;
+ std::ostringstream strStream;
strStream << expandedArgs.size();
this->Makefile->AddDefinition("ARGC",strStream.str().c_str());
this->Makefile->MarkVariableAsUsed("ARGC");
@@ -111,7 +111,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass
// set the values for ARGV0 ARGV1 ...
for (unsigned int t = 0; t < expandedArgs.size(); ++t)
{
- cmOStringStream tmpStream;
+ std::ostringstream tmpStream;
tmpStream << "ARGV" << t;
this->Makefile->AddDefinition(tmpStream.str(),
expandedArgs[t].c_str());
@@ -132,14 +132,14 @@ bool cmFunctionHelperCommand::InvokeInitialPass
unsigned int cnt = 0;
for ( eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit )
{
- if ( argvDef.size() > 0 )
+ if (!argvDef.empty())
{
argvDef += ";";
}
argvDef += *eit;
if ( cnt >= this->Args.size()-1 )
{
- if ( argnDef.size() > 0 )
+ if (!argnDef.empty())
{
argnDef += ";";
}
@@ -271,11 +271,7 @@ bool cmFunctionCommand
// create a function blocker
cmFunctionFunctionBlocker *f = new cmFunctionFunctionBlocker();
- for(std::vector<std::string>::const_iterator j = args.begin();
- j != args.end(); ++j)
- {
- f->Args.push_back(*j);
- }
+ f->Args.insert(f->Args.end(), args.begin(), args.end());
this->Makefile->AddFunctionBlocker(f);
return true;
}
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 78ad4b2..600b793 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -152,7 +152,7 @@ void cmGeneratedFileStreamBase::Open(const char* name)
#endif
// Make sure the temporary file that will be used is not present.
- cmSystemTools::RemoveFile(this->TempName.c_str());
+ cmSystemTools::RemoveFile(this->TempName);
std::string dir = cmSystemTools::GetFilenamePath(this->TempName);
cmSystemTools::MakeDirectory(dir.c_str());
@@ -174,7 +174,7 @@ bool cmGeneratedFileStreamBase::Close()
if(!this->Name.empty() &&
this->Okay &&
(!this->CopyIfDifferent ||
- cmSystemTools::FilesDiffer(this->TempName.c_str(), resname.c_str())))
+ cmSystemTools::FilesDiffer(this->TempName, resname)))
{
// The destination is to be replaced. Rename the temporary to the
// destination atomically.
@@ -185,7 +185,7 @@ bool cmGeneratedFileStreamBase::Close()
{
this->RenameFile(gzname.c_str(), resname.c_str());
}
- cmSystemTools::RemoveFile(gzname.c_str());
+ cmSystemTools::RemoveFile(gzname);
}
else
{
@@ -198,7 +198,7 @@ bool cmGeneratedFileStreamBase::Close()
// Else, the destination was not replaced.
//
// Always delete the temporary file. We never want it to stay around.
- cmSystemTools::RemoveFile(this->TempName.c_str());
+ cmSystemTools::RemoveFile(this->TempName);
return replaced;
}
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index 7adee7b..2aa6beb 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -15,10 +15,6 @@
#include "cmStandardIncludes.h"
#include <cmsys/FStream.hxx>
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 1375 /* base class destructor not virtual */
-#endif
-
// This is the first base class of cmGeneratedFileStream. It will be
// created before and destroyed after the ofstream portion and can
// therefore be used to manage the temporary file.
@@ -146,8 +142,4 @@ private:
cmGeneratedFileStream(cmGeneratedFileStream const&); // not implemented
};
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma reset woff 1375 /* base class destructor not virtual */
-#endif
-
#endif
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 7fc1464..bf96951 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -15,8 +15,6 @@
#include "cmTarget.h"
#include "assert.h"
-#include <cmsys/String.h>
-
#include "cmGeneratorExpressionEvaluator.h"
#include "cmGeneratorExpressionLexer.h"
#include "cmGeneratorExpressionParser.h"
@@ -33,18 +31,10 @@ cmGeneratorExpression::cmGeneratorExpression(
cmsys::auto_ptr<cmCompiledGeneratorExpression>
cmGeneratorExpression::Parse(std::string const& input)
{
-#if !defined(__BORLANDC__)
return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
new cmCompiledGeneratorExpression(
this->Backtrace ? *this->Backtrace : cmListFileBacktrace(NULL),
input));
-#else
- cmListFileBacktrace emptyBacktrace(NULL);
- return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
- new cmCompiledGeneratorExpression(
- this->Backtrace ? *this->Backtrace : emptyBacktrace,
- input));
-#endif
}
//----------------------------------------------------------------------------
@@ -98,6 +88,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
context.HadError = false;
context.HadContextSensitiveCondition = false;
context.HadHeadSensitiveCondition = false;
+ context.SourceSensitiveTargets.clear();
context.HeadTarget = headTarget;
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
@@ -107,12 +98,8 @@ const char *cmCompiledGeneratorExpression::Evaluate(
{
this->Output += (*it)->Evaluate(&context, dagChecker);
- for(std::set<std::string>::const_iterator
- p = context.SeenTargetProperties.begin();
- p != context.SeenTargetProperties.end(); ++p)
- {
- this->SeenTargetProperties.insert(*p);
- }
+ this->SeenTargetProperties.insert(context.SeenTargetProperties.begin(),
+ context.SeenTargetProperties.end());
if (context.HadError)
{
this->Output = "";
@@ -126,6 +113,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
{
this->HadContextSensitiveCondition = context.HadContextSensitiveCondition;
this->HadHeadSensitiveCondition = context.HadHeadSensitiveCondition;
+ this->SourceSensitiveTargets = context.SourceSensitiveTargets;
}
this->DependTargets = context.DependTargets;
@@ -158,15 +146,7 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
//----------------------------------------------------------------------------
cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
{
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
- = this->Evaluators.begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
- = this->Evaluators.end();
-
- for ( ; it != end; ++it)
- {
- delete *it;
- }
+ cmDeleteAll(this->Evaluators);
}
//----------------------------------------------------------------------------
@@ -453,7 +433,7 @@ std::string cmGeneratorExpression::Preprocess(const std::string &input,
return stripExportInterface(input, context, resolveRelative);
}
- assert(!"cmGeneratorExpression::Preprocess called with invalid args");
+ assert(0 && "cmGeneratorExpression::Preprocess called with invalid args");
return std::string();
}
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index b952520..57f78c5 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -115,6 +115,10 @@ public:
{
return this->HadHeadSensitiveCondition;
}
+ std::set<cmTarget const*> GetSourceSensitiveTargets() const
+ {
+ return this->SourceSensitiveTargets;
+ }
void SetEvaluateForBuildsystem(bool eval)
{
@@ -146,6 +150,7 @@ private:
mutable std::string Output;
mutable bool HadContextSensitiveCondition;
mutable bool HadHeadSensitiveCondition;
+ mutable std::set<cmTarget const*> SourceSensitiveTargets;
bool EvaluateForBuildsystem;
};
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index 75a84cb..c8b9949 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -66,9 +66,7 @@ cmGeneratorExpressionDAGChecker::Initialize()
if (it != top->Seen.end())
{
const std::set<std::string> &propSet = it->second;
- const std::set<std::string>::const_iterator i
- = propSet.find(this->Property);
- if (i != propSet.end())
+ if (propSet.find(this->Property) != propSet.end())
{
this->CheckResult = ALREADY_SEEN;
return;
@@ -106,7 +104,7 @@ void cmGeneratorExpressionDAGChecker::ReportError(
if (parent && !parent->Parent)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< "Self reference on target \""
@@ -118,7 +116,7 @@ void cmGeneratorExpressionDAGChecker::ReportError(
}
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< "Dependency loop found.";
@@ -130,7 +128,7 @@ void cmGeneratorExpressionDAGChecker::ReportError(
int loopStep = 1;
while (parent)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Loop step " << loopStep << "\n"
<< " "
<< (parent->Content ? parent->Content->GetOriginalExpression() : expr)
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index f9067cf..4e2a868 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -13,6 +13,9 @@
#include "cmGeneratorExpressionEvaluationFile.h"
#include "cmMakefile.h"
+#include "cmLocalGenerator.h"
+#include "cmGlobalGenerator.h"
+#include "cmSourceFile.h"
#include "cmGeneratedFileStream.h"
#include <cmsys/FStream.hxx>
@@ -36,7 +39,7 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
//----------------------------------------------------------------------------
void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
cmCompiledGeneratorExpression* inputExpression,
- std::map<std::string, std::string> &outputFiles)
+ std::map<std::string, std::string> &outputFiles, mode_t perm)
{
std::string rawCondition = this->Condition->GetInput();
if (!rawCondition.empty())
@@ -48,7 +51,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
}
if (condResult != "1")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Evaluation file condition \"" << rawCondition << "\" did "
"not evaluate to valid content. Got \"" << condResult << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -70,24 +73,44 @@ void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
{
return;
}
- cmOStringStream e;
+ std::ostringstream e;
e << "Evaluation file to be written multiple times for different "
"configurations with different content:\n " << outputFileName;
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
+ this->Makefile->AddCMakeOutputFile(outputFileName.c_str());
this->Files.push_back(outputFileName);
outputFiles[outputFileName] = outputContent;
cmGeneratedFileStream fout(outputFileName.c_str());
fout.SetCopyIfDifferent(true);
fout << outputContent;
+ if (fout.Close() && perm)
+ {
+ cmSystemTools::SetPermissions(outputFileName.c_str(), perm);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorExpressionEvaluationFile::CreateOutputFile(
+ std::string const& config)
+{
+ std::string name = this->OutputFileExpr->Evaluate(this->Makefile, config);
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(name);
+ sf->SetProperty("GENERATED", "1");
+
+ cmGlobalGenerator *gg
+ = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
+ gg->SetFilenameTargetDepends(sf,
+ this->OutputFileExpr->GetSourceSensitiveTargets());
}
//----------------------------------------------------------------------------
void cmGeneratorExpressionEvaluationFile::Generate()
{
+ mode_t perm = 0;
std::string inputContent;
if (this->InputIsContent)
{
@@ -95,10 +118,12 @@ void cmGeneratorExpressionEvaluationFile::Generate()
}
else
{
+ this->Makefile->AddCMakeDependFile(this->Input.c_str());
+ cmSystemTools::GetPermissions(this->Input.c_str(), perm);
cmsys::ifstream fin(this->Input.c_str());
if(!fin)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Evaluation file \"" << this->Input << "\" cannot be read.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
@@ -131,7 +156,7 @@ void cmGeneratorExpressionEvaluationFile::Generate()
for(std::vector<std::string>::const_iterator li = allConfigs.begin();
li != allConfigs.end(); ++li)
{
- this->Generate(*li, inputExpression.get(), outputFiles);
+ this->Generate(*li, inputExpression.get(), outputFiles, perm);
if(cmSystemTools::GetFatalErrorOccured())
{
return;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index f939916..3394ade 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -31,10 +31,12 @@ public:
std::vector<std::string> GetFiles() const { return this->Files; }
+ void CreateOutputFile(std::string const& config);
+
private:
void Generate(const std::string& config,
cmCompiledGeneratorExpression* inputExpression,
- std::map<std::string, std::string> &outputFiles);
+ std::map<std::string, std::string> &outputFiles, mode_t perm);
private:
const std::string Input;
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index d5d78d5..6692a92 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -36,7 +36,7 @@ void reportError(cmGeneratorExpressionContext *context,
return;
}
- cmOStringStream e;
+ std::ostringstream e;
e << "Error evaluating generator expression:\n"
<< " " << expr << "\n"
<< result;
@@ -362,7 +362,7 @@ static const struct MakeCIdentifierNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const
{
- return cmSystemTools::MakeCidentifier(parameters.front().c_str());
+ return cmSystemTools::MakeCidentifier(parameters.front());
}
} makeCIdentifierNode;
@@ -429,7 +429,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
{
const char *compilerId =
context->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID");
- if (parameters.size() == 0)
+ if (parameters.empty())
{
return compilerId ? compilerId : "";
}
@@ -456,7 +456,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
{
case cmPolicies::WARN:
{
- cmOStringStream e;
+ std::ostringstream e;
e << context->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0044);
context->Makefile->GetCMakeInstance()
@@ -534,7 +534,7 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
{
const char *compilerVersion = context->Makefile->GetSafeDefinition(
"CMAKE_" + lang + "_COMPILER_VERSION");
- if (parameters.size() == 0)
+ if (parameters.empty())
{
return compilerVersion ? compilerVersion : "";
}
@@ -616,7 +616,7 @@ struct PlatformIdNode : public cmGeneratorExpressionNode
{
const char *platformId =
context->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME");
- if (parameters.size() == 0)
+ if (parameters.empty())
{
return platformId ? platformId : "";
}
@@ -803,18 +803,9 @@ static const struct JoinNode : public cmGeneratorExpressionNode
const GeneratorExpressionContent *,
cmGeneratorExpressionDAGChecker *) const
{
- std::string result;
-
std::vector<std::string> list;
cmSystemTools::ExpandListArgument(parameters.front(), list);
- std::string sep;
- for(std::vector<std::string>::const_iterator li = list.begin();
- li != list.end(); ++li)
- {
- result += sep + *li;
- sep = parameters[1];
- }
- return result;
+ return cmJoin(list, parameters[1]);
}
} joinNode;
@@ -953,14 +944,14 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (!target)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \""
<< targetName
<< "\" not found.";
reportError(context, content->GetOriginalExpression(), e.str());
return std::string();
}
- context->AllTargets.insert(target);
+ context->AllTargets.insert(target);
}
if (target == context->HeadTarget)
@@ -971,6 +962,10 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
// value for all evaluations.
context->SeenTargetProperties.insert(propertyName);
}
+ if (propertyName == "SOURCES")
+ {
+ context->SourceSensitiveTargets.insert(target);
+ }
if (propertyName.empty())
{
@@ -1249,7 +1244,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
{
if (!context->EvaluateForBuildsystem)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The evaluation of the TARGET_OBJECTS generator expression "
"is only suitable for consumption by CMake. It is not suitable "
"for writing out elsewhere.";
@@ -1259,10 +1254,10 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
std::string tgtName = parameters.front();
cmGeneratorTarget* gt =
- context->Makefile->FindGeneratorTargetToUse(tgtName.c_str());
+ context->Makefile->FindGeneratorTargetToUse(tgtName);
if (!gt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Objects of target \"" << tgtName
<< "\" referenced but no such target exists.";
reportError(context, content->GetOriginalExpression(), e.str());
@@ -1270,7 +1265,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode
}
if (gt->GetType() != cmTarget::OBJECT_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Objects of target \"" << tgtName
<< "\" referenced but is not an OBJECT library.";
reportError(context, content->GetOriginalExpression(), e.str());
@@ -1375,6 +1370,8 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{
std::vector<std::string> const& langAvailable
= availableFeatures[lit->first];
+ const char* standardDefault = context->Makefile
+ ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
for (std::vector<std::string>::const_iterator it = lit->second.begin();
it != lit->second.end(); ++it)
{
@@ -1383,6 +1380,12 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
{
return "0";
}
+ if (standardDefault && !*standardDefault)
+ {
+ // This compiler has no notion of language standard levels.
+ // All features known for the language are always available.
+ continue;
+ }
if (!context->Makefile->HaveStandardAvailable(target,
lit->first, *it))
{
@@ -1391,8 +1394,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
const char* l = target->GetProperty(lit->first + "_STANDARD");
if (!l)
{
- l = context->Makefile
- ->GetDefinition("CMAKE_" + lit->first + "_STANDARD_DEFAULT");
+ l = standardDefault;
}
assert(l);
context->MaxLanguageStandard[target][lit->first] = l;
@@ -1432,7 +1434,7 @@ cmPolicies::PolicyStatus statusForTarget(cmTarget const* tgt,
#undef RETURN_POLICY
- assert("!Unreachable code. Not a valid policy");
+ assert(0 && "Unreachable code. Not a valid policy");
return cmPolicies::WARN;
}
@@ -1448,7 +1450,7 @@ cmPolicies::PolicyID policyForString(const char *policy_id)
#undef RETURN_POLICY_ID
- assert("!Unreachable code. Not a valid policy");
+ assert(0 && "Unreachable code. Not a valid policy");
return cmPolicies::CMP0002;
}
@@ -2031,7 +2033,7 @@ std::string GeneratorExpressionContent::EvaluateParameters(
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "$<" + identifier + "> expression requires "
<< numExpected
<< " comma separated parameters, but got "
@@ -2057,30 +2059,9 @@ std::string GeneratorExpressionContent::EvaluateParameters(
}
//----------------------------------------------------------------------------
-static void deleteAll(const std::vector<cmGeneratorExpressionEvaluator*> &c)
-{
- std::vector<cmGeneratorExpressionEvaluator*>::const_iterator it
- = c.begin();
- const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
- = c.end();
- for ( ; it != end; ++it)
- {
- delete *it;
- }
-}
-
-//----------------------------------------------------------------------------
GeneratorExpressionContent::~GeneratorExpressionContent()
{
- deleteAll(this->IdentifierChildren);
-
- typedef std::vector<cmGeneratorExpressionEvaluator*> EvaluatorVector;
- std::vector<EvaluatorVector>::const_iterator pit =
- this->ParamChildren.begin();
- const std::vector<EvaluatorVector>::const_iterator pend =
- this->ParamChildren.end();
- for ( ; pit != pend; ++pit)
- {
- deleteAll(*pit);
- }
+ cmDeleteAll(this->IdentifierChildren);
+ std::for_each(this->ParamChildren.begin(), this->ParamChildren.end(),
+ cmDeleteAll<std::vector<cmGeneratorExpressionEvaluator*> >);
}
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 8a529e8..0bf1797 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -31,6 +31,7 @@ struct cmGeneratorExpressionContext
std::set<cmTarget*> DependTargets;
std::set<cmTarget const*> AllTargets;
std::set<std::string> SeenTargetProperties;
+ std::set<cmTarget const*> SourceSensitiveTargets;
std::map<cmTarget const*, std::map<std::string, std::string> >
MaxLanguageStandard;
cmMakefile *Makefile;
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index a41a6e5..a17da8c 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -39,7 +39,7 @@ void cmGeneratorExpressionParser::Parse(
static void extendText(std::vector<cmGeneratorExpressionEvaluator*> &result,
std::vector<cmGeneratorExpressionToken>::const_iterator it)
{
- if (result.size() > 0
+ if (!result.empty()
&& (*(result.end() - 1))->GetType()
== cmGeneratorExpressionEvaluator::Text)
{
@@ -57,7 +57,7 @@ static void extendText(std::vector<cmGeneratorExpressionEvaluator*> &result,
static void extendResult(std::vector<cmGeneratorExpressionEvaluator*> &result,
const std::vector<cmGeneratorExpressionEvaluator*> &contents)
{
- if (result.size() > 0
+ if (!result.empty()
&& (*(result.end() - 1))->GetType()
== cmGeneratorExpressionEvaluator::Text
&& (*contents.begin())->GetType()
@@ -256,7 +256,7 @@ void cmGeneratorExpressionParser::ParseContent(
{
if (this->NestingLevel == 0)
{
- if (result.size() > 0
+ if (!result.empty()
&& (*(result.end() - 1))->GetType()
== cmGeneratorExpressionEvaluator::Text)
{
@@ -292,11 +292,11 @@ void cmGeneratorExpressionParser::ParseContent(
}
else
{
- assert(!"Got unexpected syntax token.");
+ assert(0 && "Got unexpected syntax token.");
}
assert(this->it != this->Tokens.end());
++this->it;
return;
}
- assert(!"Unhandled token in generator expression.");
+ assert(0 && "Unhandled token in generator expression.");
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 0c60237..a4f099b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -31,7 +31,7 @@ void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
{
if(!badObjLib.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "OBJECT library \"" << target->GetName() << "\" contains:\n";
for(std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
i != badObjLib.end(); ++i)
@@ -56,7 +56,6 @@ struct ModuleDefinitionFileTag {};
struct AppManifestTag{};
struct CertificatesTag{};
-#if !defined(_MSC_VER) || _MSC_VER >= 1310
template<typename Tag, typename OtherTag>
struct IsSameTag
{
@@ -72,25 +71,6 @@ struct IsSameTag<Tag, Tag>
Result = true
};
};
-#else
-struct IsSameTagBase
-{
- typedef char (&no_type)[1];
- typedef char (&yes_type)[2];
- template<typename T> struct Check;
- template<typename T> static yes_type check(Check<T>*, Check<T>*);
- static no_type check(...);
-};
-template<typename Tag1, typename Tag2>
-struct IsSameTag: public IsSameTagBase
-{
- enum {
- Result = (sizeof(check(static_cast< Check<Tag1>* >(0),
- static_cast< Check<Tag2>* >(0))) ==
- sizeof(yes_type))
- };
-};
-#endif
template<bool>
struct DoAccept
@@ -509,11 +489,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
unique.insert(*li);
}
result.clear();
- for(std::set<std::string>::iterator li = unique.begin();
- li != unique.end(); ++li)
- {
- result.push_back(*li);
- }
+ result.insert(result.end(), unique.begin(), unique.end());
IncludeCacheType::value_type entry(config_upper, result);
iter = this->SystemIncludesCache.insert(entry).first;
@@ -646,6 +622,17 @@ cmTargetTraceDependencies
si != sources.end(); ++si)
{
cmSourceFile* sf = *si;
+ const std::set<cmTarget const*> tgts =
+ this->GlobalGenerator->GetFilenameTargetDepends(sf);
+ if (tgts.find(this->Target) != tgts.end())
+ {
+ std::ostringstream e;
+ e << "Evaluation output file\n \"" << sf->GetFullPath()
+ << "\"\ndepends on the sources of a target it is used in. This "
+ "is a dependency loop and is not allowed.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second)
{
this->SourceQueue.push(sf);
@@ -780,8 +767,8 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
std::string tLocation = t->GetLocationForBuild();
tLocation = cmSystemTools::GetFilenamePath(tLocation);
std::string depLocation = cmSystemTools::GetFilenamePath(dep);
- depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
- tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
+ depLocation = cmSystemTools::CollapseFullPath(depLocation);
+ tLocation = cmSystemTools::CollapseFullPath(tLocation);
if(depLocation == tLocation)
{
this->Target->AddUtility(util);
@@ -839,11 +826,7 @@ cmTargetTraceDependencies
= ge.Parse(*cli);
cge->Evaluate(this->Makefile, "", true);
std::set<cmTarget*> geTargets = cge->GetTargets();
- for(std::set<cmTarget*>::const_iterator it = geTargets.begin();
- it != geTargets.end(); ++it)
- {
- targets.insert(*it);
- }
+ targets.insert(geTargets.begin(), geTargets.end());
}
}
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index e88f498..e193cf5 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -33,7 +33,7 @@ bool cmGetCMakePropertyCommand
{
int cacheonly = 0;
std::vector<std::string> vars = this->Makefile->GetDefinitions(cacheonly);
- if (vars.size()>0)
+ if (!vars.empty())
{
output = vars[0];
}
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index fcc3da1..8fb2fa1 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -49,7 +49,7 @@ bool cmGetDirectoryPropertyCommand
}
// The local generators are associated with collapsed paths.
- sd = cmSystemTools::CollapseFullPath(sd.c_str());
+ sd = cmSystemTools::CollapseFullPath(sd);
// lookup the makefile from the directory name
cmLocalGenerator *lg =
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 10406d2..9aceb39 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -79,7 +79,7 @@ bool cmGetFilenameComponentCommand
}
}
}
- cmSystemTools::SplitProgramFromArgs(filename.c_str(),
+ cmSystemTools::SplitProgramFromArgs(filename,
result, programArgs);
}
else if (args[2] == "EXT")
@@ -97,11 +97,11 @@ bool cmGetFilenameComponentCommand
// If the path given is relative evaluate it relative to the
// current source directory.
result = cmSystemTools::CollapseFullPath(
- filename.c_str(), this->Makefile->GetCurrentDirectory());
+ filename, this->Makefile->GetCurrentDirectory());
if(args[2] == "REALPATH")
{
// Resolve symlinks if possible
- result = cmSystemTools::GetRealPath(result.c_str());
+ result = cmSystemTools::GetRealPath(result);
}
}
else
@@ -113,7 +113,7 @@ bool cmGetFilenameComponentCommand
if(args.size() == 4 && args[3] == "CACHE")
{
- if(programArgs.size() && storeArgs.size())
+ if(!programArgs.empty() && !storeArgs.empty())
{
this->Makefile->AddCacheDefinition
(storeArgs, programArgs.c_str(),
@@ -127,7 +127,7 @@ bool cmGetFilenameComponentCommand
}
else
{
- if(programArgs.size() && storeArgs.size())
+ if(!programArgs.empty() && !storeArgs.empty())
{
this->Makefile->AddDefinition(storeArgs, programArgs.c_str());
}
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 9a88191..f0b2686 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -73,7 +73,7 @@ bool cmGetPropertyCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid scope " << args[1] << ". "
<< "Valid scopes are "
<< "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.";
@@ -122,7 +122,7 @@ bool cmGetPropertyCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
@@ -259,7 +259,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
}
// The local generators are associated with collapsed paths.
- dir = cmSystemTools::CollapseFullPath(dir.c_str());
+ dir = cmSystemTools::CollapseFullPath(dir);
// Lookup the generator.
if(cmLocalGenerator* lg =
@@ -312,7 +312,7 @@ bool cmGetPropertyCommand::HandleTargetMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not find TARGET " << this->Name
<< ". Perhaps it has not yet been created.";
this->SetError(e.str());
@@ -338,7 +338,7 @@ bool cmGetPropertyCommand::HandleSourceMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given SOURCE name that could not be found or created: "
<< this->Name;
this->SetError(e.str());
@@ -362,7 +362,7 @@ bool cmGetPropertyCommand::HandleTestMode()
}
// If not found it is an error.
- cmOStringStream e;
+ std::ostringstream e;
e << "given TEST name that does not exist: " << this->Name;
this->SetError(e.str());
return false;
@@ -423,7 +423,7 @@ bool cmGetPropertyCommand::HandleInstallMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given INSTALL name that could not be found or created: "
<< this->Name;
this->SetError(e.str());
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index fb59df8..eed19f4 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -50,7 +50,7 @@ bool cmGetTargetPropertyCommand
else
{
bool issueMessage = false;
- cmOStringStream e;
+ std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0045))
{
diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx
index 6c20952..950d440 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.cxx
+++ b/Source/cmGlobalBorlandMakefileGenerator.cxx
@@ -49,6 +49,7 @@ cmLocalGenerator *cmGlobalBorlandMakefileGenerator::CreateLocalGenerator()
lg->SetUnixCD(false);
lg->SetMakeCommandEscapeTargetTwice(true);
lg->SetBorlandMakeCurlyHack(true);
+ lg->SetNoMultiOutputMultiDepRules(true);
return lg;
}
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 2f4d9bb..6d0fedc 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -11,6 +11,9 @@
============================================================================*/
#if defined(_WIN32) && !defined(__CYGWIN__)
#include "windows.h" // this must be first to define GetCurrentDirectory
+#if defined(_MSC_VER) && _MSC_VER >= 1800
+# define KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+#endif
#endif
#include "cmGlobalGenerator.h"
@@ -35,6 +38,8 @@
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include <cmsys/MD5.h>
+# include "cm_jsoncpp_value.h"
+# include "cm_jsoncpp_writer.h"
#endif
#include <stdlib.h> // required for atof
@@ -85,7 +90,7 @@ bool cmGlobalGenerator::SetGeneratorPlatform(std::string const& p,
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e <<
"Generator\n"
" " << this->GetName() << "\n"
@@ -106,7 +111,7 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts,
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e <<
"Generator\n"
" " << this->GetName() << "\n"
@@ -171,7 +176,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
{
path = name;
}
- if((path.size() == 0 || !cmSystemTools::FileExists(path.c_str()))
+ if((path.empty() || !cmSystemTools::FileExists(path.c_str()))
&& (optional==false))
{
return;
@@ -262,7 +267,7 @@ cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const
// Find the make program for the generator, required for try compiles
void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
{
- if(this->FindMakeProgramFile.size() == 0)
+ if(this->FindMakeProgramFile.empty())
{
cmSystemTools::Error(
"Generator implementation error, "
@@ -273,7 +278,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
{
std::string setMakeProgram =
mf->GetModulesFile(this->FindMakeProgramFile.c_str());
- if(setMakeProgram.size())
+ if(!setMakeProgram.empty())
{
mf->ReadListFile(0, setMakeProgram.c_str());
}
@@ -281,7 +286,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
if(!mf->GetDefinition("CMAKE_MAKE_PROGRAM")
|| cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
{
- cmOStringStream err;
+ std::ostringstream err;
err << "CMake was unable to find a build program corresponding to \""
<< this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You "
<< "probably need to select a different build tool.";
@@ -297,11 +302,11 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
{
std::string dir;
std::string file;
- cmSystemTools::SplitProgramPath(makeProgram.c_str(),
+ cmSystemTools::SplitProgramPath(makeProgram,
dir, file);
std::string saveFile = file;
- cmSystemTools::GetShortPath(makeProgram.c_str(), makeProgram);
- cmSystemTools::SplitProgramPath(makeProgram.c_str(),
+ cmSystemTools::GetShortPath(makeProgram, makeProgram);
+ cmSystemTools::SplitProgramPath(makeProgram,
dir, file);
makeProgram = dir;
makeProgram += "/";
@@ -310,25 +315,6 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
"make program",
cmCacheManager::FILEPATH);
}
-
- if(makeProgram.find("xcodebuild") != makeProgram.npos)
- {
- // due to the text file busy /bin/sh problem with xcodebuild
- // use the cmakexbuild wrapper instead. This program
- // will run xcodebuild and if it sees the error text file busy
- // it will stop forwarding output, and let the build finish.
- // Then it will retry the build. It will continue this
- // until no text file busy errors occur.
- std::string cmakexbuild =
- this->CMakeInstance->GetCacheManager()->GetCacheValue("CMAKE_COMMAND");
- cmakexbuild = cmakexbuild.substr(0, cmakexbuild.length()-5);
- cmakexbuild += "cmakexbuild";
-
- mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM",
- cmakexbuild.c_str(),
- "make program",
- cmCacheManager::FILEPATH);
- }
}
// enable the given language
@@ -380,7 +366,7 @@ void
cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
cmMakefile *mf, bool optional)
{
- if(languages.size() == 0)
+ if(languages.empty())
{
cmSystemTools::Error("EnableLanguage must have a lang specified!");
cmSystemTools::SetFatalErrorOccured();
@@ -402,7 +388,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
const char* lang = li->c_str();
if(this->LanguagesReady.find(lang) == this->LanguagesReady.end())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The test project needs language "
<< lang << " which is not enabled.";
this->TryCompileOuterMakefile
@@ -423,7 +409,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// If the configuration files path has been set,
// then we are in a try compile and need to copy the enable language
// files from the parent cmake bin dir, into the try compile bin dir
- if(this->ConfiguredFilesPath.size())
+ if(!this->ConfiguredFilesPath.empty())
{
rootBin = this->ConfiguredFilesPath;
}
@@ -456,8 +442,15 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
OSVERSIONINFO osvi;
ZeroMemory(&osvi, sizeof(osvi));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# pragma warning (push)
+# pragma warning (disable:4996)
+#endif
GetVersionEx (&osvi);
- cmOStringStream windowsVersionString;
+#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
+# pragma warning (pop)
+#endif
+ std::ostringstream windowsVersionString;
windowsVersionString << osvi.dwMajorVersion << "." << osvi.dwMinorVersion;
windowsVersionString.str();
mf->AddDefinition("CMAKE_HOST_SYSTEM_VERSION",
@@ -597,7 +590,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
std::string env = envVar;
env += "=";
env += envVarValue;
- cmSystemTools::PutEnv(env.c_str());
+ cmSystemTools::PutEnv(env);
}
// if determineLanguage was called then load the file it
@@ -650,7 +643,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
std::string compilerEnv = "CMAKE_";
compilerEnv += lang;
compilerEnv += "_COMPILER_ENV_VAR";
- cmOStringStream noCompiler;
+ std::ostringstream noCompiler;
const char* compilerFile = mf->GetDefinition(compilerName);
if(!compilerFile || !*compilerFile ||
cmSystemTools::IsNOTFOUND(compilerFile))
@@ -691,7 +684,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
compilerLangFile += "/CMake";
compilerLangFile += lang;
compilerLangFile += "Compiler.cmake";
- cmSystemTools::RemoveFile(compilerLangFile.c_str());
+ cmSystemTools::RemoveFile(compilerLangFile);
if(!this->CMakeInstance->GetIsInTryCompile())
{
this->PrintCompilerAdvice(noCompiler, lang,
@@ -758,7 +751,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
compilerLangFile += "/CMake";
compilerLangFile += lang;
compilerLangFile += "Compiler.cmake";
- cmSystemTools::RemoveFile(compilerLangFile.c_str());
+ cmSystemTools::RemoveFile(compilerLangFile);
}
} // end if in try compile
} // end need test language
@@ -842,7 +835,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
if(!this->CMakeInstance->GetIsInTryCompile() &&
mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0025"))
{
- cmOStringStream w;
+ std::ostringstream w;
w << policies->GetPolicyWarning(cmPolicies::CMP0025) << "\n"
"Converting " << lang <<
" compiler id \"AppleClang\" to \"Clang\" for compatibility."
@@ -874,7 +867,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
if(!this->CMakeInstance->GetIsInTryCompile() &&
mf->PolicyOptionalWarningEnabled("CMAKE_POLICY_WARNING_CMP0047"))
{
- cmOStringStream w;
+ std::ostringstream w;
w << policies->GetPolicyWarning(cmPolicies::CMP0047) << "\n"
"Converting " << lang <<
" compiler id \"QCC\" to \"GNU\" for compatibility."
@@ -1137,7 +1130,7 @@ void cmGlobalGenerator::Configure()
if ( this->CMakeInstance->GetWorkingMode() == cmake::NORMAL_MODE)
{
- cmOStringStream msg;
+ std::ostringstream msg;
if(cmSystemTools::GetErrorOccuredFlag())
{
msg << "Configuring incomplete, errors occurred!";
@@ -1186,7 +1179,7 @@ bool cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const
}
// This generator does not support duplicate custom targets.
- cmOStringStream e;
+ std::ostringstream e;
e << "This project has enabled the ALLOW_DUPLICATE_CUSTOM_TARGETS "
<< "global property. "
<< "The \"" << this->GetName() << "\" generator does not support "
@@ -1253,8 +1246,6 @@ void cmGlobalGenerator::Generate()
// Create per-target generator information.
this->CreateGeneratorTargets();
- this->ForceLinkerLanguages();
-
#ifdef CMAKE_BUILD_WITH_CMAKE
for (AutogensType::iterator it = autogens.begin(); it != autogens.end();
++it)
@@ -1270,6 +1261,8 @@ void cmGlobalGenerator::Generate()
this->LocalGenerators[i]->TraceDependencies();
}
+ this->ForceLinkerLanguages();
+
// Compute the manifest of main targets generated.
for (i = 0; i < this->LocalGenerators.size(); ++i)
{
@@ -1336,7 +1329,7 @@ void cmGlobalGenerator::Generate()
if(!this->CMP0042WarnTargets.empty())
{
- cmOStringStream w;
+ std::ostringstream w;
w <<
(this->GetCMakeInstance()->GetPolicies()->
GetPolicyWarning(cmPolicies::CMP0042)) << "\n";
@@ -1500,34 +1493,16 @@ void cmGlobalGenerator::CreateGeneratorTargets()
//----------------------------------------------------------------------------
void cmGlobalGenerator::ClearGeneratorMembers()
{
- for(cmGeneratorTargetsType::iterator i = this->GeneratorTargets.begin();
- i != this->GeneratorTargets.end(); ++i)
- {
- delete i->second;
- }
+ cmDeleteAll(this->GeneratorTargets);
this->GeneratorTargets.clear();
- for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
- li = this->EvaluationFiles.begin();
- li != this->EvaluationFiles.end();
- ++li)
- {
- delete *li;
- }
+ cmDeleteAll(this->EvaluationFiles);
this->EvaluationFiles.clear();
- for(std::map<std::string, cmExportBuildFileGenerator*>::iterator
- i = this->BuildExportSets.begin();
- i != this->BuildExportSets.end(); ++i)
- {
- delete i->second;
- }
+ cmDeleteAll(this->BuildExportSets);
this->BuildExportSets.clear();
- for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
- {
- delete this->LocalGenerators[i];
- }
+ cmDeleteAll(this->LocalGenerators);
this->LocalGenerators.clear();
this->ExportSets.clear();
@@ -1640,7 +1615,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
static_cast<float>(this->LocalGenerators.size()));
}
- if(notFoundMap.size())
+ if(!notFoundMap.empty())
{
std::string notFoundVars;
for(std::map<std::string, std::string>::const_iterator
@@ -1735,7 +1710,7 @@ int cmGlobalGenerator::Build(
* Run an executable command and put the stdout in output.
*/
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir.c_str());
+ cmSystemTools::ChangeDirectory(bindir);
output += "Change Dir: ";
output += bindir;
output += "\n";
@@ -1765,7 +1740,7 @@ int cmGlobalGenerator::Build(
output += "\nGenerator: execution of make clean failed.\n";
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
return 1;
}
output += *outputPtr;
@@ -1792,7 +1767,7 @@ int cmGlobalGenerator::Build(
+ makeCommandStr + "\n";
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
return 1;
}
output += *outputPtr;
@@ -1806,7 +1781,7 @@ int cmGlobalGenerator::Build(
retVal = 1;
}
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
return retVal;
}
@@ -2197,7 +2172,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
= this->CreateGlobalTarget(this->GetPackageTargetName(),
"Run CPack packaging tool...",
&cpackCommandLines, depends,
- workingDir.c_str());
+ workingDir.c_str(), /*uses_terminal*/true);
}
// CPack source
const char* packageSourceTargetName = this->GetPackageSourceTargetName();
@@ -2221,8 +2196,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
= this->CreateGlobalTarget(packageSourceTargetName,
"Run CPack packaging tool for source...",
&cpackCommandLines, depends,
- workingDir.c_str()
- );
+ workingDir.c_str(), /*uses_terminal*/true);
}
}
@@ -2247,7 +2221,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
cpackCommandLines.push_back(singleLine);
(*targets)[this->GetTestTargetName()]
= this->CreateGlobalTarget(this->GetTestTargetName(),
- "Running tests...", &cpackCommandLines, depends, 0);
+ "Running tests...", &cpackCommandLines, depends, 0,
+ /*uses_terminal*/true);
}
//Edit Cache
@@ -2270,7 +2245,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[editCacheTargetName] =
this->CreateGlobalTarget(
editCacheTargetName, "Running CMake cache editor...",
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/true);
}
else
{
@@ -2283,7 +2258,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
this->CreateGlobalTarget(
editCacheTargetName,
"No interactive CMake dialog available...",
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/false);
}
}
@@ -2302,7 +2277,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[rebuildCacheTargetName] =
this->CreateGlobalTarget(
rebuildCacheTargetName, "Running CMake to regenerate build system...",
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/true);
}
//Install
@@ -2321,8 +2296,8 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
cpackCommandLines.erase(cpackCommandLines.begin(),
cpackCommandLines.end());
depends.erase(depends.begin(), depends.end());
- cmOStringStream ostr;
- if ( componentsSet->size() > 0 )
+ std::ostringstream ostr;
+ if (!componentsSet->empty())
{
ostr << "Available install components are:";
std::set<std::string>::iterator it;
@@ -2342,7 +2317,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)["list_install_components"]
= this->CreateGlobalTarget("list_install_components",
ostr.str().c_str(),
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/false);
}
std::string cmd = cmakeCommand;
cpackCommandLines.erase(cpackCommandLines.begin(),
@@ -2383,7 +2358,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[this->GetInstallTargetName()] =
this->CreateGlobalTarget(
this->GetInstallTargetName(), "Install the project...",
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/true);
// install_local
if(const char* install_local = this->GetInstallLocalTargetName())
@@ -2399,7 +2374,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[install_local] =
this->CreateGlobalTarget(
install_local, "Installing only the local directory...",
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/true);
}
// install_strip
@@ -2416,7 +2391,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
(*targets)[install_strip] =
this->CreateGlobalTarget(
install_strip, "Installing the project stripped...",
- &cpackCommandLines, depends, 0);
+ &cpackCommandLines, depends, 0, /*uses_terminal*/true);
}
}
}
@@ -2459,24 +2434,24 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf)
this->FindMakeProgram(mf);
std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::vector<std::string> locations;
- locations.push_back(cmSystemTools::GetProgramPath(makeProgram.c_str()));
+ locations.push_back(cmSystemTools::GetProgramPath(makeProgram));
locations.push_back("/mingw/bin");
locations.push_back("c:/mingw/bin");
std::string tgcc = cmSystemTools::FindProgram("gcc", locations);
std::string gcc = "gcc.exe";
- if(tgcc.size())
+ if(!tgcc.empty())
{
gcc = tgcc;
}
std::string tgxx = cmSystemTools::FindProgram("g++", locations);
std::string gxx = "g++.exe";
- if(tgxx.size())
+ if(!tgxx.empty())
{
gxx = tgxx;
}
std::string trc = cmSystemTools::FindProgram("windres", locations);
std::string rc = "windres.exe";
- if(trc.size())
+ if(!trc.empty())
{
rc = trc;
}
@@ -2490,7 +2465,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends,
- const char* workingDirectory)
+ const char* workingDirectory,
+ bool uses_terminal)
{
// Package
cmTarget target;
@@ -2499,10 +2475,12 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
target.SetProperty("EXCLUDE_FROM_ALL","TRUE");
std::vector<std::string> no_outputs;
+ std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
// Store the custom command in the target.
- cmCustomCommand cc(0, no_outputs, no_depends, *commandLines, 0,
- workingDirectory);
+ cmCustomCommand cc(0, no_outputs, no_byproducts, no_depends,
+ *commandLines, 0, workingDirectory);
+ cc.SetUsesTerminal(uses_terminal);
target.AddPostBuildCommand(cc);
target.SetProperty("EchoString", message);
std::vector<std::string>::iterator dit;
@@ -2712,7 +2690,9 @@ void cmGlobalGenerator::AddToManifest(const std::string& config,
// Add to the content listing for the file's directory.
std::string dir = cmSystemTools::GetFilenamePath(f);
std::string file = cmSystemTools::GetFilenameName(f);
- this->DirectoryContentMap[dir].insert(file);
+ DirectoryContent& dc = this->DirectoryContentMap[dir];
+ dc.Generated.insert(file);
+ dc.All.insert(file);
}
//----------------------------------------------------------------------------
@@ -2720,25 +2700,32 @@ std::set<std::string> const&
cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk)
{
DirectoryContent& dc = this->DirectoryContentMap[dir];
- if(needDisk && !dc.LoadedFromDisk)
+ if(needDisk)
{
- // Load the directory content from disk.
- cmsys::Directory d;
- if(d.Load(dir.c_str()))
+ long mt = cmSystemTools::ModifiedTime(dir);
+ if (mt != dc.LastDiskTime)
{
- unsigned long n = d.GetNumberOfFiles();
- for(unsigned long i = 0; i < n; ++i)
+ // Reset to non-loaded directory content.
+ dc.All = dc.Generated;
+
+ // Load the directory content from disk.
+ cmsys::Directory d;
+ if(d.Load(dir))
{
- const char* f = d.GetFile(i);
- if(strcmp(f, ".") != 0 && strcmp(f, "..") != 0)
+ unsigned long n = d.GetNumberOfFiles();
+ for(unsigned long i = 0; i < n; ++i)
{
- dc.insert(f);
+ const char* f = d.GetFile(i);
+ if(strcmp(f, ".") != 0 && strcmp(f, "..") != 0)
+ {
+ dc.All.insert(f);
+ }
}
}
+ dc.LastDiskTime = mt;
}
- dc.LoadedFromDisk = true;
}
- return dc;
+ return dc.All;
}
//----------------------------------------------------------------------------
@@ -2831,8 +2818,8 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
{
// The rule has changed. Delete the output so it will be
// built again.
- fname = cmSystemTools::CollapseFullPath(fname.c_str(), home.c_str());
- cmSystemTools::RemoveFile(fname.c_str());
+ fname = cmSystemTools::CollapseFullPath(fname, home.c_str());
+ cmSystemTools::RemoveFile(fname);
}
}
else
@@ -2844,7 +2831,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
// that if the feature is turned back on and the rule has
// changed the file is still rebuilt.
std::string fpath =
- cmSystemTools::CollapseFullPath(fname.c_str(), home.c_str());
+ cmSystemTools::CollapseFullPath(fname, home.c_str());
if(cmSystemTools::FileExists(fpath.c_str()))
{
RuleHash hash;
@@ -2861,7 +2848,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
// Now generate a new persistence file with the current hashes.
if(this->RuleHashes.empty())
{
- cmSystemTools::RemoveFile(pfile.c_str());
+ cmSystemTools::RemoveFile(pfile);
}
else
{
@@ -2907,10 +2894,21 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
std::string dir = target->GetSupportDirectory();
std::string file = dir;
file += "/Labels.txt";
+ std::string json_file = dir + "/Labels.json";
+#ifdef CMAKE_BUILD_WITH_CMAKE
// Check whether labels are enabled for this target.
if(const char* value = target->GetProperty("LABELS"))
{
+ Json::Value lj_root(Json::objectValue);
+ Json::Value& lj_target =
+ lj_root["target"] = Json::objectValue;
+ lj_target["name"] = target->GetName();
+ Json::Value& lj_target_labels =
+ lj_target["labels"] = Json::arrayValue;
+ Json::Value& lj_sources =
+ lj_root["sources"] = Json::arrayValue;
+
cmSystemTools::MakeDirectory(dir.c_str());
cmGeneratedFileStream fout(file.c_str());
@@ -2925,6 +2923,7 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
li != labels.end(); ++li)
{
fout << " " << *li << "\n";
+ lj_target_labels.append(*li);
}
}
@@ -2950,23 +2949,33 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
{
continue;
}
+ Json::Value& lj_source = lj_sources.append(Json::objectValue);
cmSourceFile* sf = *si;
- fout << sf->GetFullPath() << "\n";
+ std::string const& sfp = sf->GetFullPath();
+ fout << sfp << "\n";
+ lj_source["file"] = sfp;
if(const char* svalue = sf->GetProperty("LABELS"))
{
labels.clear();
+ Json::Value& lj_source_labels =
+ lj_source["labels"] = Json::arrayValue;
cmSystemTools::ExpandListArgument(svalue, labels);
for(std::vector<std::string>::const_iterator li = labels.begin();
li != labels.end(); ++li)
{
fout << " " << *li << "\n";
+ lj_source_labels.append(*li);
}
}
}
+ cmGeneratedFileStream json_fout(json_file.c_str());
+ json_fout << lj_root;
}
else
+#endif
{
- cmSystemTools::RemoveFile(file.c_str());
+ cmSystemTools::RemoveFile(file);
+ cmSystemTools::RemoveFile(json_file);
}
}
@@ -2984,6 +2993,32 @@ std::string cmGlobalGenerator::EscapeJSON(const std::string& s) {
}
//----------------------------------------------------------------------------
+void cmGlobalGenerator::SetFilenameTargetDepends(cmSourceFile* sf,
+ std::set<cmTarget const*> tgts)
+{
+ this->FilenameTargetDepends[sf] = tgts;
+}
+
+//----------------------------------------------------------------------------
+std::set<cmTarget const*> const&
+cmGlobalGenerator::GetFilenameTargetDepends(cmSourceFile* sf) const {
+ return this->FilenameTargetDepends[sf];
+}
+
+//----------------------------------------------------------------------------
+void cmGlobalGenerator::CreateEvaluationSourceFiles(
+ std::string const& config) const
+{
+ for(std::vector<cmGeneratorExpressionEvaluationFile*>::const_iterator
+ li = this->EvaluationFiles.begin();
+ li != this->EvaluationFiles.end();
+ ++li)
+ {
+ (*li)->CreateOutputFile(config);
+ }
+}
+
+//----------------------------------------------------------------------------
void cmGlobalGenerator::AddEvaluationFile(const std::string &inputFile,
cmsys::auto_ptr<cmCompiledGeneratorExpression> outputExpr,
cmMakefile *makefile,
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index ddd7e91..08f061a 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -23,6 +23,7 @@
#include "cmGeneratorExpression.h"
#if defined(CMAKE_BUILD_WITH_CMAKE)
+# include "cmFileLockPool.h"
# include <cmsys/hash_map.hxx>
#endif
@@ -254,9 +255,9 @@ public:
cmTargetManifest const& GetTargetManifest() const
{ return this->TargetManifest; }
- /** Get the content of a directory. Directory listings are loaded
- from disk at most once and cached. During the generation step
- the content will include the target files to be built even if
+ /** Get the content of a directory. Directory listings are cached
+ and re-loaded from disk only when modified. During the generation
+ step the content will include the target files to be built even if
they do not yet exist. */
std::set<std::string> const& GetDirectoryContent(std::string const& dir,
bool needDisk = true);
@@ -341,6 +342,17 @@ public:
bool GenerateCPackPropertiesFile();
+ void CreateEvaluationSourceFiles(std::string const& config) const;
+
+ void SetFilenameTargetDepends(cmSourceFile* sf,
+ std::set<cmTarget const*> tgts);
+ std::set<cmTarget const*> const&
+ GetFilenameTargetDepends(cmSourceFile* sf) const;
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ cmFileLockPool& GetFileLockPool() { return FileLockPool; }
+#endif
+
protected:
virtual void Generate();
@@ -378,7 +390,8 @@ protected:
void CreateDefaultGlobalTargets(cmTargets* targets);
cmTarget CreateGlobalTarget(const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
- std::vector<std::string> depends, const char* workingDir);
+ std::vector<std::string> depends, const char* workingDir,
+ bool uses_terminal);
bool NeedSymbolicMark;
bool UseLinkScript;
@@ -473,13 +486,14 @@ private:
virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; }
// Cache directory content and target files to be built.
- struct DirectoryContent: public std::set<std::string>
+ struct DirectoryContent
{
- typedef std::set<std::string> derived;
- bool LoadedFromDisk;
- DirectoryContent(): LoadedFromDisk(false) {}
+ long LastDiskTime;
+ std::set<std::string> All;
+ std::set<std::string> Generated;
+ DirectoryContent(): LastDiskTime(-1) {}
DirectoryContent(DirectoryContent const& dc):
- derived(dc), LoadedFromDisk(dc.LoadedFromDisk) {}
+ LastDiskTime(dc.LastDiskTime), All(dc.All), Generated(dc.Generated) {}
};
std::map<std::string, DirectoryContent> DirectoryContentMap;
@@ -488,6 +502,14 @@ private:
// track targets to issue CMP0042 warning for.
std::set<std::string> CMP0042WarnTargets;
+
+ mutable std::map<cmSourceFile*, std::set<cmTarget const*> >
+ FilenameTargetDepends;
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ // Pool of file locks
+ cmFileLockPool FileLockPool;
+#endif
};
#endif
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index 89d25c4..b9c01fa 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -222,7 +222,7 @@ bool cmGlobalKdevelopGenerator
it!=files.end(); it++)
{
// get the full path to the file
- tmp=cmSystemTools::CollapseFullPath(it->c_str(), projectDir.c_str());
+ tmp=cmSystemTools::CollapseFullPath(*it, projectDir.c_str());
// just select the first source file
if (fileToOpen.empty())
{
@@ -236,7 +236,7 @@ bool cmGlobalKdevelopGenerator
// make it relative to the project dir
cmSystemTools::ReplaceString(tmp, projectDir.c_str(), "");
// only put relative paths
- if (tmp.size() && tmp[0] != '/')
+ if (!tmp.empty() && tmp[0] != '/')
{
fout << tmp.c_str() <<"\n";
}
@@ -274,7 +274,7 @@ void cmGlobalKdevelopGenerator
// kdevelop blacklist so they are not monitored for added or removed files
// since this is handled by adding files to the cmake files
cmsys::Directory d;
- if (d.Load(projectDir.c_str()))
+ if (d.Load(projectDir))
{
size_t numf = d.GetNumberOfFiles();
for (unsigned int i = 0; i < numf; i++)
@@ -285,7 +285,7 @@ void cmGlobalKdevelopGenerator
std::string tmp = projectDir;
tmp += "/";
tmp += nextFile;
- if (cmSystemTools::FileIsDirectory(tmp.c_str()))
+ if (cmSystemTools::FileIsDirectory(tmp))
{
tmp += "/CMakeCache.txt";
if ((nextFile == "CMakeFiles")
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 6e7b06b..3c07be1 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -71,7 +71,7 @@ std::string cmGlobalNinjaGenerator::EncodeIdent(const std::string &ident,
if (std::find_if(ident.begin(), ident.end(),
std::not1(std::ptr_fun(IsIdentChar))) != ident.end()) {
static unsigned VarNum = 0;
- cmOStringStream names;
+ std::ostringstream names;
names << "ident" << VarNum++;
vars << names.str() << " = " << ident << "\n";
return "$" + names.str();
@@ -191,7 +191,7 @@ void cmGlobalNinjaGenerator::WriteBuild(std::ostream& os,
build += " " + rule;
// Write the variables bound to this build statement.
- cmOStringStream variable_assignments;
+ std::ostringstream variable_assignments;
for(cmNinjaVars::const_iterator i = variables.begin();
i != variables.end(); ++i)
cmGlobalNinjaGenerator::WriteVariable(variable_assignments,
@@ -242,7 +242,7 @@ void cmGlobalNinjaGenerator::AddCustomCommandRule()
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
- /*restat*/ true,
+ /*restat*/ "1",
/*generator*/ false);
}
@@ -250,6 +250,7 @@ void
cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
const std::string& description,
const std::string& comment,
+ bool uses_terminal,
const cmNinjaDeps& outputs,
const cmNinjaDeps& deps,
const cmNinjaDeps& orderOnly)
@@ -266,6 +267,10 @@ cmGlobalNinjaGenerator::WriteCustomCommandBuild(const std::string& command,
cmNinjaVars vars;
vars["COMMAND"] = cmd;
vars["DESC"] = EncodeLiteral(description);
+ if (uses_terminal && SupportsConsolePool())
+ {
+ vars["pool"] = "console";
+ }
this->WriteBuild(*this->BuildFileStream,
comment,
@@ -290,7 +295,7 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule()
cmLocalGenerator *lg = this->LocalGenerators[0];
cmMakefile* mfRoot = lg->GetMakefile();
- cmOStringStream cmd;
+ std::ostringstream cmd;
cmd << lg->ConvertToOutputFormat(
mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL)
@@ -304,7 +309,7 @@ cmGlobalNinjaGenerator::AddMacOSXContentRule()
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
- /*restat*/ false,
+ /*restat*/ "",
/*generator*/ false);
}
@@ -339,7 +344,7 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
const std::string& deptype,
const std::string& rspfile,
const std::string& rspcontent,
- bool restat,
+ const std::string& restat,
bool generator)
{
// Make sure the rule has a name.
@@ -403,10 +408,10 @@ void cmGlobalNinjaGenerator::WriteRule(std::ostream& os,
os << "rspfile_content = " << rspcontent << "\n";
}
- if(restat)
+ if(!restat.empty())
{
cmGlobalNinjaGenerator::Indent(os, 1);
- os << "restat = 1\n";
+ os << "restat = " << restat << "\n";
}
if(generator)
@@ -602,7 +607,7 @@ void cmGlobalNinjaGenerator::AddRule(const std::string& name,
const std::string& deptype,
const std::string& rspfile,
const std::string& rspcontent,
- bool restat,
+ const std::string& restat,
bool generator)
{
// Do not add the same rule twice.
@@ -771,7 +776,7 @@ void cmGlobalNinjaGenerator::AddCXXCompileCommand(
if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
{
sourceFileName = cmSystemTools::CollapseFullPath(
- sourceFileName.c_str(),
+ sourceFileName,
this->GetCMakeInstance()->GetHomeOutputDirectory());
}
@@ -826,6 +831,7 @@ void cmGlobalNinjaGenerator::WriteAssumedSourceDependencies()
std::copy(i->second.begin(), i->second.end(), std::back_inserter(deps));
WriteCustomCommandBuild(/*command=*/"", /*description=*/"",
"Assume dependencies for generated source file.",
+ /*uses_terminal*/false,
cmNinjaDeps(1, i->first), deps);
}
}
@@ -851,7 +857,7 @@ cmGlobalNinjaGenerator
case cmTarget::STATIC_LIBRARY:
case cmTarget::MODULE_LIBRARY:
outputs.push_back(ng->ConvertToNinjaPath(
- target->GetFullPath(configName, false, realname).c_str()));
+ target->GetFullPath(configName, false, realname)));
break;
case cmTarget::OBJECT_LIBRARY:
@@ -970,7 +976,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
typedef std::vector<std::string>::const_iterator vect_it;
for(vect_it j = files.begin(); j != files.end(); ++j)
{
- knownDependencies.insert( ng->ConvertToNinjaPath( j->c_str() ) );
+ knownDependencies.insert( ng->ConvertToNinjaPath( *j ) );
}
//get list files which are implicit dependencies as well and will be phony
//for rebuild manifest
@@ -978,7 +984,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
typedef std::vector<std::string>::const_iterator vect_it;
for(vect_it j = lf.begin(); j != lf.end(); ++j)
{
- knownDependencies.insert( ng->ConvertToNinjaPath( j->c_str() ) );
+ knownDependencies.insert( ng->ConvertToNinjaPath( *j ) );
}
}
knownDependencies.insert( "CMakeCache.txt" );
@@ -994,7 +1000,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
typedef std::vector<std::string>::const_iterator vect_it;
for(vect_it j = files.begin(); j != files.end(); ++j)
{
- knownDependencies.insert( ng->ConvertToNinjaPath( j->c_str() ) );
+ knownDependencies.insert( ng->ConvertToNinjaPath( *j ) );
}
}
@@ -1002,7 +1008,7 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
i != this->TargetAliases.end();
++i)
{
- knownDependencies.insert( ng->ConvertToNinjaPath(i->first.c_str()) );
+ knownDependencies.insert( ng->ConvertToNinjaPath(i->first) );
}
//remove all source files we know will exist.
@@ -1011,16 +1017,13 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
i != this->AssumedSourceDependencies.end();
++i)
{
- knownDependencies.insert( ng->ConvertToNinjaPath(i->first.c_str()) );
+ knownDependencies.insert( ng->ConvertToNinjaPath(i->first) );
}
//insert outputs from all WirteBuild commands
- for(std::set<std::string>::iterator i = this->CombinedBuildOutputs.begin();
- i != this->CombinedBuildOutputs.end(); ++i)
- {
- //these paths have already be encoded when added to CombinedBuildOutputs
- knownDependencies.insert(*i);
- }
+ //these paths have already be encoded when added to CombinedBuildOutputs
+ knownDependencies.insert(this->CombinedBuildOutputs.begin(),
+ this->CombinedBuildOutputs.end());
//after we have combined the data into knownDependencies we have no need
//to keep this data around
@@ -1051,9 +1054,9 @@ void cmGlobalNinjaGenerator::WriteUnknownExplicitDependencies(std::ostream& os)
{
//verify the file is in the build directory
std::string const absDepPath = cmSystemTools::CollapseFullPath(
- i->c_str(), rootBuildDirectory.c_str());
- bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath.c_str(),
- rootBuildDirectory.c_str());
+ *i, rootBuildDirectory.c_str());
+ bool const inBuildDir = cmSystemTools::IsSubDirectory(absDepPath,
+ rootBuildDirectory);
if(inBuildDir)
{
cmNinjaDeps deps(1,*i);
@@ -1097,7 +1100,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
cmLocalGenerator *lg = this->LocalGenerators[0];
cmMakefile* mfRoot = lg->GetMakefile();
- cmOStringStream cmd;
+ std::ostringstream cmd;
cmd << lg->ConvertToOutputFormat(
mfRoot->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL)
@@ -1116,7 +1119,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
/*deptype=*/ "",
/*rspfile=*/ "",
/*rspcontent*/ "",
- /*restat=*/ false,
+ /*restat=*/ "",
/*generator=*/ true);
cmLocalNinjaGenerator *ng = static_cast<cmLocalNinjaGenerator *>(lg);
@@ -1129,7 +1132,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
for(std::vector<std::string>::const_iterator fi = lf.begin();
fi != lf.end(); ++fi)
{
- implicitDeps.push_back(ng->ConvertToNinjaPath(fi->c_str()));
+ implicitDeps.push_back(ng->ConvertToNinjaPath(*fi));
}
}
implicitDeps.push_back("CMakeCache.txt");
@@ -1141,9 +1144,7 @@ void cmGlobalNinjaGenerator::WriteTargetRebuildManifest(std::ostream& os)
cmNinjaVars variables;
// Use 'console' pool to get non buffered output of the CMake re-run call
// Available since Ninja 1.5
- if(cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
- ninjaVersion().c_str(),
- "1.5") == false)
+ if(SupportsConsolePool())
{
variables["pool"] = "console";
}
@@ -1185,6 +1186,12 @@ std::string cmGlobalNinjaGenerator::ninjaVersion() const
return version;
}
+bool cmGlobalNinjaGenerator::SupportsConsolePool() const
+{
+ return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
+ ninjaVersion().c_str(), "1.5") == false;
+}
+
void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
{
WriteRule(*this->RulesFileStream,
@@ -1196,7 +1203,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
/*deptype=*/ "",
/*rspfile=*/ "",
/*rspcontent*/ "",
- /*restat=*/ false,
+ /*restat=*/ "",
/*generator=*/ false);
WriteBuild(os,
"Clean all the built files.",
@@ -1219,7 +1226,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
/*deptype=*/ "",
/*rspfile=*/ "",
/*rspcontent*/ "",
- /*restat=*/ false,
+ /*restat=*/ "",
/*generator=*/ false);
WriteBuild(os,
"Print all primary targets available.",
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index f666ee3..3d443d8 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -103,6 +103,7 @@ public:
void WriteCustomCommandBuild(const std::string& command,
const std::string& description,
const std::string& comment,
+ bool uses_terminal,
const cmNinjaDeps& outputs,
const cmNinjaDeps& deps = cmNinjaDeps(),
const cmNinjaDeps& orderOnly = cmNinjaDeps());
@@ -124,7 +125,7 @@ public:
const std::string& deptype,
const std::string& rspfile,
const std::string& rspcontent,
- bool restat,
+ const std::string& restat,
bool generator);
/**
@@ -244,7 +245,7 @@ public:
const std::string& deptype,
const std::string& rspfile,
const std::string& rspcontent,
- bool restat,
+ const std::string& restat,
bool generator);
bool HasRule(const std::string& name);
@@ -299,6 +300,9 @@ public:
virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
std::string ninjaVersion() const;
+
+ bool SupportsConsolePool() const;
+
protected:
/// Overloaded methods. @see cmGlobalGenerator::Generate()
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 3478534..5f1bb83 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -572,7 +572,7 @@ void cmGlobalUnixMakefileGenerator3
if (!targetName.empty())
{
cmLocalUnixMakefileGenerator3 *lg;
- if (this->LocalGenerators.size())
+ if (!this->LocalGenerators.empty())
{
lg = static_cast<cmLocalUnixMakefileGenerator3 *>
(this->LocalGenerators[0]);
@@ -597,7 +597,7 @@ void cmGlobalUnixMakefileGenerator3
tname = lg->Convert(tname,cmLocalGenerator::HOME_OUTPUT);
cmSystemTools::ConvertToOutputSlashes(tname);
makeCommand.push_back(tname);
- if (!this->LocalGenerators.size())
+ if (this->LocalGenerators.empty())
{
delete lg;
}
@@ -783,7 +783,7 @@ cmGlobalUnixMakefileGenerator3
lg->GetMakefile()->GetHomeOutputDirectory();
progressDir += cmake::GetCMakeFilesDirectory();
{
- cmOStringStream progCmd;
+ std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
// all target counts
progCmd << lg->Convert(progressDir,
@@ -824,7 +824,7 @@ cmGlobalUnixMakefileGenerator3
{
// TODO: Convert the total progress count to a make variable.
- cmOStringStream progCmd;
+ std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
// # in target
progCmd << lg->Convert(progressDir,
@@ -841,7 +841,7 @@ cmGlobalUnixMakefileGenerator3
commands.push_back(lg->GetRecursiveMakeCall
(tmp.c_str(),localName));
{
- cmOStringStream progCmd;
+ std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
progCmd << lg->Convert(progressDir,
cmLocalGenerator::FULL,
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 499ac56..531a714 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -156,7 +156,7 @@ cmGlobalVisualStudio10Generator::SetGeneratorToolset(std::string const& ts,
if (this->SystemIsWindowsCE && ts.empty() &&
this->DefaultPlatformToolset.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->GetName() << " Windows CE version '" << this->SystemVersion
<< "' requires CMAKE_GENERATOR_TOOLSET to be set.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -202,7 +202,7 @@ bool cmGlobalVisualStudio10Generator::InitializeSystem(cmMakefile* mf)
{
if(this->DefaultPlatformName != "Win32")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "CMAKE_SYSTEM_NAME is 'Android' but CMAKE_GENERATOR "
<< "specifies a platform too: '" << this->GetName() << "'";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -231,7 +231,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
{
if (this->DefaultPlatformName != "Win32")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "CMAKE_SYSTEM_NAME is 'WindowsCE' but CMAKE_GENERATOR "
<< "specifies a platform too: '" << this->GetName() << "'";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -246,7 +246,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsCE(cmMakefile* mf)
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->GetName() << " does not support Windows Phone.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
@@ -255,7 +255,7 @@ bool cmGlobalVisualStudio10Generator::InitializeWindowsPhone(cmMakefile* mf)
//----------------------------------------------------------------------------
bool cmGlobalVisualStudio10Generator::InitializeWindowsStore(cmMakefile* mf)
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->GetName() << " does not support Windows Store.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
@@ -320,7 +320,7 @@ void cmGlobalVisualStudio10Generator::Generate()
if(this->LongestSource.Length > 0)
{
cmMakefile* mf = this->LongestSource.Target->GetMakefile();
- cmOStringStream e;
+ std::ostringstream e;
e <<
"The binary and/or source directory paths may be too long to generate "
"Visual Studio 10 files for this project. "
@@ -574,7 +574,7 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\"
"Windows\\v7.1;InstallationFolder", winSDK_7_1))
{
- cmOStringStream m;
+ std::ostringstream m;
m << "Found Windows SDK v7.1: " << winSDK_7_1;
mf->DisplayStatus(m.str().c_str(), -1);
this->DefaultPlatformToolset = "Windows7.1SDK";
@@ -582,7 +582,7 @@ bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot enable 64-bit tools with Visual Studio 2010 Express.\n"
<< "Install the Microsoft Windows SDK v7.1 to get 64-bit tools:\n"
<< " http://msdn.microsoft.com/en-us/windows/bb980924.aspx";
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 2b69222..3013200 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -133,7 +133,7 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsPhone(cmMakefile* mf)
{
if(!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset))
{
- cmOStringStream e;
+ std::ostringstream e;
if(this->DefaultPlatformToolset.empty())
{
e << this->GetName() << " supports Windows Phone '8.0', but not '"
@@ -156,7 +156,7 @@ bool cmGlobalVisualStudio11Generator::InitializeWindowsStore(cmMakefile* mf)
{
if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset))
{
- cmOStringStream e;
+ std::ostringstream e;
if(this->DefaultPlatformToolset.empty())
{
e << this->GetName() << " supports Windows Store '8.0', but not '"
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 047f2ad..2bc9379 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -113,7 +113,7 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsPhone(cmMakefile* mf)
{
if(!this->SelectWindowsPhoneToolset(this->DefaultPlatformToolset))
{
- cmOStringStream e;
+ std::ostringstream e;
if(this->DefaultPlatformToolset.empty())
{
e << this->GetName() << " supports Windows Phone '8.0' and '8.1', but "
@@ -136,7 +136,7 @@ bool cmGlobalVisualStudio12Generator::InitializeWindowsStore(cmMakefile* mf)
{
if(!this->SelectWindowsStoreToolset(this->DefaultPlatformToolset))
{
- cmOStringStream e;
+ std::ostringstream e;
if(this->DefaultPlatformToolset.empty())
{
e << this->GetName() << " supports Windows Store '8.0' and '8.1', but "
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index a67a649..64f9cee 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -93,6 +93,11 @@ void cmGlobalVisualStudio71Generator
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
+#ifdef CMAKE_ENCODING_UTF8
+ // Add UTF-8 BOM for .sln file to indicate encoding
+ const unsigned char utf8_bom[3] = {0xEF,0xBB,0xBF};
+ fout.write(reinterpret_cast<const char*>(utf8_bom), 3);
+#endif
// Write out the header for a SLN file
this->WriteSLNHeader(fout);
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 401e475..0eb7d2c 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -558,6 +558,11 @@ void cmGlobalVisualStudio7Generator
cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
+#ifdef CMAKE_ENCODING_UTF8
+ // Add UTF-8 BOM for .sln file to indicate encoding
+ const unsigned char utf8_bom[3] = {0xEF,0xBB,0xBF};
+ fout.write(reinterpret_cast<const char*>(utf8_bom), 3);
+#endif
// Write out the header for a SLN file
this->WriteSLNHeader(fout);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 745515b..e6ce45d 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -341,9 +341,10 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// overwritten by the CreateVCProjBuildRule.
// (this could be avoided with per-target source files)
std::string no_main_dependency = "";
+ std::vector<std::string> no_byproducts;
if(cmSourceFile* file =
mf->AddCustomCommandToOutput(
- stamps, listFiles,
+ stamps, no_byproducts, listFiles,
no_main_dependency, commandLines, "Checking Build System",
no_working_directory, true))
{
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 2dab23c..320a1f4 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -845,22 +845,14 @@ cmGlobalVisualStudioGenerator::TargetCompare
cmGlobalVisualStudioGenerator::OrderedTargetDependSet
::OrderedTargetDependSet(TargetDependSet const& targets)
{
- for(TargetDependSet::const_iterator ti =
- targets.begin(); ti != targets.end(); ++ti)
- {
- this->insert(*ti);
- }
+ this->insert(targets.begin(), targets.end());
}
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::OrderedTargetDependSet
::OrderedTargetDependSet(TargetSet const& targets)
{
- for(TargetSet::const_iterator ti = targets.begin();
- ti != targets.end(); ++ti)
- {
- this->insert(*ti);
- }
+ this->insert(targets.begin(), targets.end());
}
std::string cmGlobalVisualStudioGenerator::ExpandCFGIntDir(
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 637e60d..cd0dcc6 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -136,13 +136,13 @@ cmGlobalXCodeGenerator::cmGlobalXCodeGenerator(std::string const& version)
sscanf(this->VersionString.c_str(), "%u.%u", &v[0], &v[1]);
this->XcodeVersion = 10*v[0] + v[1];
- this->FindMakeProgramFile = "CMakeFindXCode.cmake";
this->RootObject = 0;
this->MainGroupChildren = 0;
this->SourcesGroupChildren = 0;
this->ResourcesGroupChildren = 0;
this->CurrentMakefile = 0;
this->CurrentLocalGenerator = 0;
+ this->XcodeBuildCommandInitialized = false;
}
//----------------------------------------------------------------------------
@@ -202,6 +202,49 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
}
//----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
+{
+ // The Xcode generator knows how to lookup its build tool
+ // directly instead of needing a helper module to do it, so we
+ // do not actually need to put CMAKE_MAKE_PROGRAM into the cache.
+ if(cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM")))
+ {
+ mf->AddDefinition("CMAKE_MAKE_PROGRAM",
+ this->GetXcodeBuildCommand().c_str());
+ }
+}
+
+//----------------------------------------------------------------------------
+std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
+{
+ if(!this->XcodeBuildCommandInitialized)
+ {
+ this->XcodeBuildCommandInitialized = true;
+ this->XcodeBuildCommand = this->FindXcodeBuildCommand();
+ }
+ return this->XcodeBuildCommand;
+}
+
+//----------------------------------------------------------------------------
+std::string cmGlobalXCodeGenerator::FindXcodeBuildCommand()
+{
+ if (this->XcodeVersion >= 40)
+ {
+ std::string makeProgram = cmSystemTools::FindProgram("xcodebuild");
+ if (makeProgram.empty())
+ {
+ makeProgram = "xcodebuild";
+ }
+ return makeProgram;
+ }
+ else
+ {
+ // Use cmakexbuild wrapper to suppress environment dump from output.
+ return cmSystemTools::GetCMakeCommand() + "xbuild";
+ }
+}
+
+//----------------------------------------------------------------------------
bool cmGlobalXCodeGenerator::SetGeneratorToolset(std::string const& ts,
cmMakefile* mf)
{
@@ -272,7 +315,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
{
// now build the test
makeCommand.push_back(
- this->SelectMakeProgram(makeProgram, "xcodebuild")
+ this->SelectMakeProgram(makeProgram, this->GetXcodeBuildCommand())
);
makeCommand.push_back("-project");
@@ -477,7 +520,9 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
this->PostBuildMakeTarget(target.GetName(), "$(CONFIGURATION)");
cmCustomCommandLines commandLines;
commandLines.push_back(makeHelper);
+ std::vector<std::string> no_byproducts;
lg->GetMakefile()->AddCustomCommandToTarget(target.GetName(),
+ no_byproducts,
no_depends,
commandLines,
cmTarget::POST_BUILD,
@@ -555,6 +600,7 @@ void cmGlobalXCodeGenerator::ClearXCodeObjects()
}
this->XCodeObjects.clear();
this->XCodeObjectIDs.clear();
+ this->XCodeObjectMap.clear();
this->GroupMap.clear();
this->GroupNameMap.clear();
this->TargetGroup.clear();
@@ -1196,7 +1242,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
this->CreateString("2147483647"));
copyFilesBuildPhase->AddAttribute("dstSubfolderSpec",
this->CreateString("6"));
- cmOStringStream ostr;
+ std::ostringstream ostr;
if (cmtarget.IsFrameworkOnApple())
{
// dstPath in frameworks is relative to Versions/<version>
@@ -1398,6 +1444,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
cmCustomCommand command(this->CurrentMakefile,
std::vector<std::string>(),
std::vector<std::string>(),
+ std::vector<std::string>(),
cmd,
"Creating symlinks",
"");
@@ -1524,7 +1571,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
const & commands,
const char* name)
{
- bool haveMultipleOutputPairs = false;
std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory();
dir += "/CMakeScripts";
cmSystemTools::MakeDirectory(dir.c_str());
@@ -1543,8 +1589,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
this->CreateCustomRulesMakefile(makefile.c_str(),
target,
commands,
- currentConfig->c_str(),
- haveMultipleOutputPairs);
+ currentConfig->c_str());
}
std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory();
@@ -1554,10 +1599,6 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
makecmd += " -f ";
makecmd += this->ConvertToRelativeForMake(
(makefile+"$CONFIGURATION").c_str());
- if(haveMultipleOutputPairs)
- {
- makecmd += " cmake_check_multiple_outputs";
- }
makecmd += " all";
cmSystemTools::ReplaceString(makecmd, "\\ ", "\\\\ ");
buildphase->AddAttribute("shellScript",
@@ -1572,8 +1613,7 @@ void cmGlobalXCodeGenerator
cmTarget& target,
std::vector<cmCustomCommand>
const & commands,
- const std::string& configName,
- bool& haveMultipleOutputPairs)
+ const std::string& configName)
{
std::string makefileName=makefileBasename;
if(this->XcodeVersion > 20)
@@ -1596,7 +1636,6 @@ void cmGlobalXCodeGenerator
makefileStream << "all: ";
std::map<const cmCustomCommand*, std::string> tname;
int count = 0;
- std::map<std::string, std::string> multipleOutputPairs;
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
@@ -1612,20 +1651,10 @@ void cmGlobalXCodeGenerator
makefileStream
<< "\\\n\t" << this->ConvertToRelativeForMake(o->c_str());
}
-
- // If there is more than one output treat the first as the
- // primary output and make the rest depend on it.
- std::vector<std::string>::const_iterator o = outputs.begin();
- std::string primaryOutput = this->ConvertToRelativeForMake(o->c_str());
- for(++o; o != outputs.end(); ++o)
- {
- std::string currentOutput=this->ConvertToRelativeForMake(o->c_str());
- multipleOutputPairs[currentOutput] = primaryOutput;
- }
}
else
{
- cmOStringStream str;
+ std::ostringstream str;
str << "_buildpart_" << count++ ;
tname[&ccg.GetCC()] = std::string(target.GetName()) + str.str();
makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
@@ -1644,9 +1673,15 @@ void cmGlobalXCodeGenerator
if(!outputs.empty())
{
// There is at least one output, start the rule for it
- std::string primary_output =
- this->ConvertToRelativeForMake(outputs.begin()->c_str());
- makefileStream << primary_output << ": ";
+ const char* sep = "";
+ for(std::vector<std::string>::const_iterator oi = outputs.begin();
+ oi != outputs.end(); ++oi)
+ {
+ makefileStream << sep <<
+ this->ConvertToRelativeForMake(oi->c_str());
+ sep = " ";
+ }
+ makefileStream << ": ";
}
else
{
@@ -1696,33 +1731,6 @@ void cmGlobalXCodeGenerator
}
}
}
-
- // Add rules to deal with multiple outputs of custom commands.
- if(!multipleOutputPairs.empty())
- {
- makefileStream <<
- "\n# Dependencies of multiple outputs to their primary outputs \n";
-
- for(std::map<std::string, std::string>::const_iterator o =
- multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o)
- {
- makefileStream << o->first << ": " << o->second << "\n";
- }
-
- makefileStream <<
- "\n"
- "cmake_check_multiple_outputs:\n";
- for(std::map<std::string, std::string>::const_iterator o =
- multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o)
- {
- makefileStream << "\t@if [ ! -f "
- << o->first << " ]; then rm -f "
- << o->second << "; fi\n";
- }
- }
-
- haveMultipleOutputPairs =
- haveMultipleOutputPairs || !multipleOutputPairs.empty();
}
//----------------------------------------------------------------------------
@@ -1990,7 +1998,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
buildSettings->AddAttribute("LIBRARY_STYLE",
this->CreateString("BUNDLE"));
- if (target.GetPropertyAsBool("BUNDLE"))
+ if (target.IsCFBundleOnApple())
{
// It turns out that a BUNDLE is basically the same
// in many ways as an application bundle, as far as
@@ -2344,6 +2352,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
group->AddObject(this->CreateString("-Wmost"));
group->AddObject(this->CreateString("-Wno-four-char-constants"));
group->AddObject(this->CreateString("-Wno-unknown-pragmas"));
+ group->AddObject(this->CreateString("$(inherited)"));
buildSettings->AddAttribute("WARNING_CFLAGS", group);
}
else
@@ -2363,7 +2372,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
// VERSION -> current_version
target.GetTargetVersion(false, major, minor, patch);
- cmOStringStream v;
+ std::ostringstream v;
// Xcode always wants at least 1.0.0 or nothing
if(!(major == 0 && minor == 0 && patch == 0))
@@ -2375,7 +2384,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
// SOVERSION -> compatibility_version
target.GetTargetVersion(true, major, minor, patch);
- cmOStringStream vso;
+ std::ostringstream vso;
// Xcode always wants at least 1.0.0 or nothing
if(!(major == 0 && minor == 0 && patch == 0))
@@ -2484,6 +2493,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
target->AddAttribute("name", this->CreateString(cmtarget.GetName()));
target->AddAttribute("productName",this->CreateString(cmtarget.GetName()));
target->SetTarget(&cmtarget);
+ this->XCodeObjectMap[&cmtarget] = target;
// Add source files without build rules for editing convenience.
if(cmtarget.GetType() == cmTarget::UTILITY)
@@ -2687,6 +2697,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
target->AddAttribute("productType", this->CreateString(productType));
}
target->SetTarget(&cmtarget);
+ this->XCodeObjectMap[&cmtarget] = target;
target->SetId(this->GetOrCreateId(
cmtarget.GetName(), target->GetId()).c_str());
return target;
@@ -2699,16 +2710,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
{
return 0;
}
- for(std::vector<cmXCodeObject*>::iterator i = this->XCodeObjects.begin();
- i != this->XCodeObjects.end(); ++i)
+
+ std::map<cmTarget const*, cmXCodeObject*>::const_iterator const i =
+ this->XCodeObjectMap.find(t);
+ if (i == this->XCodeObjectMap.end())
{
- cmXCodeObject* o = *i;
- if(o->GetTarget() == t)
- {
- return o;
- }
+ return 0;
}
- return 0;
+ return i->second;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 8d7cfaf..f513e28 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -70,6 +70,8 @@ public:
const std::string& suffix,
std::string& dir);
+ virtual void FindMakeProgram(cmMakefile*);
+
///! What is the configurations directory variable called?
virtual const char* GetCMakeCFGIntDir() const;
///! expand CFGIntDir
@@ -118,8 +120,7 @@ private:
void CreateCustomRulesMakefile(const char* makefileBasename,
cmTarget& target,
std::vector<cmCustomCommand> const & commands,
- const std::string& configName,
- bool& haveMultipleOutputPairs);
+ const std::string& configName);
cmXCodeObject* FindXCodeTarget(cmTarget const*);
std::string GetOrCreateId(const std::string& name, const std::string& id);
@@ -213,6 +214,11 @@ protected:
std::vector<cmXCodeObject*> XCodeObjects;
cmXCodeObject* RootObject;
private:
+ std::string const& GetXcodeBuildCommand();
+ std::string FindXcodeBuildCommand();
+ std::string XcodeBuildCommand;
+ bool XcodeBuildCommandInitialized;
+
void PrintCompilerAdvice(std::ostream&, std::string const&,
const char*) const {}
@@ -241,6 +247,7 @@ private:
std::map<std::string, cmXCodeObject* > GroupNameMap;
std::map<std::string, cmXCodeObject* > TargetGroup;
std::map<std::string, cmXCodeObject* > FileRefs;
+ std::map<cmTarget const*, cmXCodeObject* > XCodeObjectMap;
std::vector<std::string> Architectures;
std::string GeneratorToolset;
};
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index 601993f..af88d1c 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -125,7 +125,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
__set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
this->TargetsToIgnoreRegex.clear();
- if (ignoreTargetsRegexes.size() > 0)
+ if (!ignoreTargetsRegexes.empty())
{
std::vector<std::string> ignoreTargetsRegExVector;
cmSystemTools::ExpandListArgument(ignoreTargetsRegexes,
@@ -497,7 +497,7 @@ int cmGraphVizWriter::CollectAllTargets()
continue;
}
//std::cout << "Found target: " << tit->first.c_str() << std::endl;
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << this->GraphNodePrefix << cnt++;
this->TargetNamesNodes[realTargetName] = ostr.str();
this->TargetPtrs[realTargetName] = &tit->second;
@@ -544,7 +544,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
this->TargetPtrs.find(libName);
if ( tarIt == this->TargetPtrs.end() )
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << this->GraphNodePrefix << cnt++;
this->TargetNamesNodes[libName] = ostr.str();
this->TargetPtrs[libName] = NULL;
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index f728c15..3362abb 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -116,7 +116,7 @@ IsFunctionBlocked(const cmListFileFunction& lff,
bool isTrue = conditionEvaluator.IsTrue(
expandedArguments, errorString, messType);
- if (errorString.size())
+ if (!errorString.empty())
{
std::string err = cmIfCommandError(&mf, expandedArguments);
err += errorString;
@@ -151,6 +151,11 @@ IsFunctionBlocked(const cmListFileFunction& lff,
inStatus.SetBreakInvoked(true);
return true;
}
+ if (status.GetContinueInvoked())
+ {
+ inStatus.SetContinueInvoked(true);
+ return true;
+ }
}
}
return true;
@@ -172,7 +177,7 @@ bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
{
// if the endif has arguments, then make sure
// they match the arguments of the matching if
- if (lff.Arguments.size() == 0 ||
+ if (lff.Arguments.empty() ||
lff.Arguments == this->Args)
{
return true;
@@ -199,7 +204,7 @@ bool cmIfCommand
bool isTrue = conditionEvaluator.IsTrue(
expandedArguments, errorString, status);
- if (errorString.size())
+ if (!errorString.empty())
{
std::string err = cmIfCommandError(this->Makefile, expandedArguments);
err += errorString;
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index 0a4f5c9..c15d46e 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -40,7 +40,7 @@ bool cmIncludeCommand
}
else if(args[i] == "RESULT_VARIABLE")
{
- if (resultVarName.size() > 0)
+ if (!resultVarName.empty())
{
this->SetError("called with invalid arguments: "
"only one result variable allowed");
@@ -83,14 +83,14 @@ bool cmIncludeCommand
std::string module = fname;
module += ".cmake";
std::string mfile = this->Makefile->GetModulesFile(module.c_str());
- if ( mfile.size() )
+ if (!mfile.empty())
{
fname = mfile.c_str();
}
}
std::string fname_abs =
- cmSystemTools::CollapseFullPath(fname.c_str(),
+ cmSystemTools::CollapseFullPath(fname,
this->Makefile->GetStartDirectory());
cmGlobalGenerator *gg = this->Makefile->GetLocalGenerator()
@@ -98,7 +98,7 @@ bool cmIncludeCommand
if (gg->IsExportedTargetsFile(fname_abs))
{
const char *modal = 0;
- cmOStringStream e;
+ std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0024))
@@ -137,7 +137,7 @@ bool cmIncludeCommand
noPolicyScope);
// add the location of the included file if a result variable was given
- if (resultVarName.size())
+ if (!resultVarName.empty())
{
this->Makefile->AddDefinition(resultVarName,
readit?fullFilePath.c_str():"NOTFOUND");
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index df5508e..464b4c2 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -47,7 +47,7 @@ bool cmIncludeDirectoryCommand
system = true;
continue;
}
- if(i->size() == 0)
+ if(i->empty())
{
this->SetError("given empty-string as include directory.");
return false;
@@ -71,11 +71,7 @@ bool cmIncludeDirectoryCommand
}
if (system)
{
- for (std::vector<std::string>::const_iterator li = includes.begin();
- li != includes.end(); ++li)
- {
- systemIncludes.insert(*li);
- }
+ systemIncludes.insert(includes.begin(), includes.end());
}
}
std::reverse(beforeIncludes.begin(), beforeIncludes.end());
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index ec500d9..2d7d7cc 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -167,7 +167,7 @@ bool cmInstallCommand::HandleScriptMode(std::vector<std::string> const& args)
script += "/";
script += args[i];
}
- if(cmSystemTools::FileIsDirectory(script.c_str()))
+ if(cmSystemTools::FileIsDirectory(script))
{
this->SetError("given a directory as value of SCRIPT argument.");
return false;
@@ -273,7 +273,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if(!unknownArgs.empty())
{
// Unknown argument.
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
this->SetError(e.str());
return false;
@@ -373,7 +373,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (this->Makefile->IsAlias(*targetIt))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given target \"" << (*targetIt)
<< "\" which is an alias.";
this->SetError(e.str());
@@ -390,7 +390,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
target->GetType() != cmTarget::OBJECT_LIBRARY &&
target->GetType() != cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given target \"" << (*targetIt)
<< "\" which is not an executable, library, or module.";
this->SetError(e.str());
@@ -398,7 +398,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else if(target->GetType() == cmTarget::OBJECT_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given OBJECT library \"" << (*targetIt)
<< "\" which may not be installed.";
this->SetError(e.str());
@@ -410,7 +410,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
else
{
// Did not find the target.
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given target \"" << (*targetIt)
<< "\" which does not exist in this directory.";
this->SetError(e.str());
@@ -502,7 +502,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
"FRAMEWORK target \"" << target.GetName() << "\".";
this->SetError(e.str());
@@ -522,7 +522,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given no LIBRARY DESTINATION for shared library "
"target \"" << target.GetName() << "\".";
this->SetError(e.str());
@@ -542,7 +542,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given no ARCHIVE DESTINATION for static library "
"target \"" << target.GetName() << "\".";
this->SetError(e.str());
@@ -563,7 +563,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given no LIBRARY DESTINATION for module target \""
<< target.GetName() << "\".";
this->SetError(e.str());
@@ -598,7 +598,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
if(!bundleGenerator)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
"executable target \"" << target.GetName() << "\".";
this->SetError(e.str());
@@ -615,7 +615,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "TARGETS given no RUNTIME DESTINATION for executable "
"target \"" << target.GetName() << "\".";
this->SetError(e.str());
@@ -681,7 +681,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL TARGETS - target " << target.GetName() << " has "
<< "PRIVATE_HEADER files but no PRIVATE_HEADER DESTINATION.";
cmSystemTools::Message(e.str().c_str(), "Warning");
@@ -708,7 +708,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL TARGETS - target " << target.GetName() << " has "
<< "PUBLIC_HEADER files but no PUBLIC_HEADER DESTINATION.";
cmSystemTools::Message(e.str().c_str(), "Warning");
@@ -734,7 +734,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL TARGETS - target " << target.GetName() << " has "
<< "RESOURCE files but no RESOURCE DESTINATION.";
cmSystemTools::Message(e.str().c_str(), "Warning");
@@ -777,19 +777,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->GetExportSets()[exports.GetString()]->AddTargetExport(te);
- std::vector<std::string> dirs = includesArgs.GetIncludeDirs();
- if(!dirs.empty())
- {
- std::string dirString;
- const char *sep = "";
- for (std::vector<std::string>::const_iterator it = dirs.begin();
- it != dirs.end(); ++it)
- {
- te->InterfaceIncludeDirectories += sep;
- te->InterfaceIncludeDirectories += *it;
- sep = ";";
- }
- }
+ te->InterfaceIncludeDirectories =
+ cmJoin(includesArgs.GetIncludeDirs(), ";");
}
}
@@ -855,7 +844,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if(!unknownArgs.empty())
{
// Unknown argument.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
this->SetError(e.str());
return false;
@@ -870,7 +859,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if(!ica.GetRename().empty() && files.GetVector().size() > 1)
{
// The rename option works only with one file.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given RENAME option with more than one file.";
this->SetError(e.str());
return false;
@@ -890,7 +879,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if(ica.GetDestination().empty())
{
// A destination is required.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given no DESTINATION!";
this->SetError(e.str());
return false;
@@ -931,7 +920,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -945,7 +934,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -960,7 +949,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -988,7 +977,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Add this property to the current match rule.
if(!in_match_mode || doing == DoingPattern || doing == DoingRegex)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" before a PATTERN or REGEX is given.";
this->SetError(e.str());
@@ -1001,7 +990,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(!in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" before a PATTERN or REGEX is given.";
this->SetError(e.str());
@@ -1016,7 +1005,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -1030,7 +1019,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -1044,7 +1033,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -1059,7 +1048,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -1074,7 +1063,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -1088,7 +1077,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
{
if(in_match_mode)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
this->SetError(e.str());
@@ -1111,9 +1100,9 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Make sure the name is a directory.
if(cmSystemTools::FileExists(dir.c_str()) &&
- !cmSystemTools::FileIsDirectory(dir.c_str()))
+ !cmSystemTools::FileIsDirectory(dir))
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given non-directory \""
<< args[i] << "\" to install.";
this->SetError(e.str());
@@ -1169,7 +1158,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Check the requested permission.
if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_file))
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given invalid file permission \""
<< args[i] << "\".";
this->SetError(e.str());
@@ -1181,7 +1170,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Check the requested permission.
if(!cmInstallCommandArguments::CheckPermissions(args[i],permissions_dir))
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given invalid directory permission \""
<< args[i] << "\".";
this->SetError(e.str());
@@ -1193,7 +1182,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Check the requested permission.
if(!cmInstallCommandArguments::CheckPermissions(args[i], literal_args))
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given invalid permission \""
<< args[i] << "\".";
this->SetError(e.str());
@@ -1203,7 +1192,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
else
{
// Unknown argument.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given unknown argument \"" << args[i] << "\".";
this->SetError(e.str());
return false;
@@ -1224,7 +1213,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
if(!destination)
{
// A destination is required.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given no DESTINATION!";
this->SetError(e.str());
return false;
@@ -1271,7 +1260,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if (!unknownArgs.empty())
{
// Unknown argument.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
this->SetError(e.str());
return false;
@@ -1286,7 +1275,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if(ica.GetDestination().empty())
{
// A destination is required.
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given no DESTINATION!";
this->SetError(e.str());
return false;
@@ -1296,7 +1285,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
std::string fname = filename.GetString();
if(fname.find_first_of(":/\\") != fname.npos)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given invalid export file name \"" << fname << "\". "
<< "The FILE argument may not contain a path. "
<< "Specify the path in the DESTINATION argument.";
@@ -1308,7 +1297,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if(!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".cmake")
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given invalid export file name \"" << fname << "\". "
<< "The FILE argument must specify a name ending in \".cmake\".";
this->SetError(e.str());
@@ -1323,7 +1312,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if(fname.find_first_of(":/\\") != fname.npos)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " given export name \"" << exp.GetString() << "\". "
<< "This name cannot be safely converted to a file name. "
<< "Specify a different export name or use the FILE option to set "
@@ -1348,7 +1337,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if(!newCMP0022Behavior)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL(EXPORT) given keyword \""
<< "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \""
<< te->Target->GetName()
@@ -1393,9 +1382,9 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
}
// Make sure the file is not a directory.
- if(gpos == file.npos && cmSystemTools::FileIsDirectory(file.c_str()))
+ if(gpos == file.npos && cmSystemTools::FileIsDirectory(file))
{
- cmOStringStream e;
+ std::ostringstream e;
e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
this->SetError(e.str());
return false;
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index ddfd6c5..4480cc6 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -121,7 +121,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
// Skip empty sets.
if(ExportSet->GetTargetExports()->empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INSTALL(EXPORT) given unknown export \""
<< ExportSet->GetName() << "\"";
cmSystemTools::Error(e.str().c_str());
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index f106e1a..06a78e5 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -47,11 +47,8 @@ bool cmInstallFilesCommand
else
{
this->IsFilesForm = false;
- std::vector<std::string>::const_iterator s = args.begin();
- for (++s;s != args.end(); ++s)
- {
- this->FinalArgs.push_back(*s);
- }
+ this->FinalArgs.insert(this->FinalArgs.end(),
+ args.begin() + 1, args.end());
}
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
@@ -83,7 +80,7 @@ void cmInstallFilesCommand::FinalPass()
{
// replace any variables
std::string temps = *s;
- if (cmSystemTools::GetFilenamePath(temps).size() > 0)
+ if (!cmSystemTools::GetFilenamePath(temps).empty())
{
testf = cmSystemTools::GetFilenamePath(temps) + "/" +
cmSystemTools::GetFilenameWithoutLastExtension(temps) + ext;
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 0405769..cc223ab 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -27,11 +27,7 @@ bool cmInstallProgramsCommand
this->Destination = args[0];
- std::vector<std::string>::const_iterator s = args.begin();
- for (++s;s != args.end(); ++s)
- {
- this->FinalArgs.push_back(*s);
- }
+ this->FinalArgs.insert(this->FinalArgs.end(), args.begin() + 1, args.end());
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->AddInstallComponent(this->Makefile->GetSafeDefinition(
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index d689c89..6d69f54 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -47,7 +47,7 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
// Warn if installing an exclude-from-all target.
if(this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL"))
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "WARNING: Target \"" << this->Target->GetName()
<< "\" has EXCLUDE_FROM_ALL set and will not be built by default "
<< "but an install rule has been provided for it. CMake does "
@@ -95,7 +95,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
case cmTarget::INTERFACE_LIBRARY:
// Not reachable. We never create a cmInstallTargetGenerator for
// an INTERFACE_LIBRARY.
- assert(!"INTERFACE_LIBRARY targets have no installable outputs.");
+ assert(0 && "INTERFACE_LIBRARY targets have no installable outputs.");
break;
case cmTarget::OBJECT_LIBRARY:
case cmTarget::UTILITY:
@@ -424,7 +424,7 @@ cmInstallTargetGenerator
::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
std::string const& file, TweakMethod tweak)
{
- cmOStringStream tw;
+ std::ostringstream tw;
(this->*tweak)(tw, indent.Next(), config, file);
std::string tws = tw.str();
if(!tws.empty())
@@ -450,7 +450,7 @@ cmInstallTargetGenerator
else
{
// Generate a foreach loop to tweak multiple files.
- cmOStringStream tw;
+ std::ostringstream tw;
this->AddTweak(tw, indent.Next(), config, "${file}", tweak);
std::string tws = tw.str();
if(!tws.empty())
@@ -523,7 +523,7 @@ cmInstallTargetGenerator
std::string installNameTool =
this->Target->GetMakefile()->GetSafeDefinition("CMAKE_INSTALL_NAME_TOOL");
- if(!installNameTool.size())
+ if(installNameTool.empty())
{
return;
}
@@ -699,7 +699,7 @@ cmInstallTargetGenerator
(!oldRuntimeDirs.empty() || !newRuntimeDirs.empty())
)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "WARNING: Target \"" << this->Target->GetName()
<< "\" has runtime paths which cannot be changed during install. "
<< "To change runtime paths, OS X version 10.6 or newer is required. "
diff --git a/Source/cmInstalledFile.h b/Source/cmInstalledFile.h
index 7134a4e..503f92c 100644
--- a/Source/cmInstalledFile.h
+++ b/Source/cmInstalledFile.h
@@ -38,11 +38,7 @@ public:
~Property()
{
- for(ExpressionVectorType::iterator i = ValueExpressions.begin();
- i != ValueExpressions.end(); ++i)
- {
- delete *i;
- }
+ cmDeleteAll(this->ValueExpressions);
}
ExpressionVectorType ValueExpressions;
diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx
index 3644d93..ade1feb 100644
--- a/Source/cmLinkDirectoriesCommand.cxx
+++ b/Source/cmLinkDirectoriesCommand.cxx
@@ -36,7 +36,7 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
if(!cmSystemTools::FileIsFullPath(unixPath.c_str()))
{
bool convertToAbsolute = false;
- cmOStringStream e;
+ std::ostringstream e;
e << "This command specifies the relative path\n"
<< " " << unixPath << "\n"
<< "as a link directory.\n";
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index f1ea088..107dca9 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -98,7 +98,7 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
return false;
}
// if the size of the list
- if(listString.size() == 0)
+ if(listString.empty())
{
return true;
}
@@ -109,7 +109,7 @@ bool cmListCommand::GetList(std::vector<std::string>& list,
for(std::vector<std::string>::iterator i = list.begin();
i != list.end(); ++i)
{
- if(i->size() == 0)
+ if(i->empty())
{
hasEmpty = true;
break;
@@ -225,7 +225,7 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
}
if ( item < 0 || nitem <= (size_t)item )
{
- cmOStringStream str;
+ std::ostringstream str;
str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
@@ -257,7 +257,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
size_t cc;
for ( cc = 2; cc < args.size(); ++ cc )
{
- if(listString.size())
+ if(!listString.empty())
{
listString += ";";
}
@@ -322,13 +322,13 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
if((!this->GetList(varArgsExpanded, listName)
|| varArgsExpanded.empty()) && item != 0)
{
- cmOStringStream str;
+ std::ostringstream str;
str << "index: " << item << " out of range (0, 0)";
this->SetError(str.str());
return false;
}
- if ( varArgsExpanded.size() != 0 )
+ if (!varArgsExpanded.empty())
{
size_t nitem = varArgsExpanded.size();
if ( item < 0 )
@@ -337,31 +337,19 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
}
if ( item < 0 || nitem <= (size_t)item )
{
- cmOStringStream str;
+ std::ostringstream str;
str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
- << (varArgsExpanded.size() == 0?0:(varArgsExpanded.size()-1)) << ")";
+ << (varArgsExpanded.empty() ? 0 : (varArgsExpanded.size() - 1)) << ")";
this->SetError(str.str());
return false;
}
}
- size_t cc;
- size_t cnt = 0;
- for ( cc = 3; cc < args.size(); ++ cc )
- {
- varArgsExpanded.insert(varArgsExpanded.begin()+item+cnt, args[cc]);
- cnt ++;
- }
- std::string value;
- const char* sep = "";
- for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
- {
- value += sep;
- value += varArgsExpanded[cc];
- sep = ";";
- }
+ varArgsExpanded.insert(varArgsExpanded.begin()+item,
+ args.begin() + 3, args.end());
+ std::string value = cmJoin(varArgsExpanded, ";");
this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -402,15 +390,8 @@ bool cmListCommand
}
}
- std::string value;
- const char* sep = "";
- for ( cc = 0; cc < varArgsExpanded.size(); cc ++ )
- {
- value += sep;
- value += varArgsExpanded[cc];
- sep = ";";
- }
+ std::string value = cmJoin(varArgsExpanded, ";");
this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -518,16 +499,7 @@ bool cmListCommand
std::sort(varArgsExpanded.begin(), varArgsExpanded.end());
- std::string value;
- std::vector<std::string>::iterator it;
- const char* sep = "";
- for ( it = varArgsExpanded.begin(); it != varArgsExpanded.end(); ++ it )
- {
- value += sep;
- value += it->c_str();
- sep = ";";
- }
-
+ std::string value = cmJoin(varArgsExpanded, ";");
this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -570,7 +542,7 @@ bool cmListCommand::HandleRemoveAtCommand(
}
if ( item < 0 || nitem <= (size_t)item )
{
- cmOStringStream str;
+ std::ostringstream str;
str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 3fc5b69..3e26349 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -19,9 +19,6 @@
#include <cmsys/RegularExpression.hxx>
-#ifdef __BORLANDC__
-# pragma warn -8060 /* possibly incorrect assignment */
-#endif
//----------------------------------------------------------------------------
struct cmListFileParser
@@ -71,7 +68,7 @@ bool cmListFileParser::ParseFile()
bom != cmListFileLexer_BOM_UTF8)
{
cmListFileLexer_SetFileName(this->Lexer, 0, 0);
- cmOStringStream m;
+ std::ostringstream m;
m << "File\n " << this->FileName << "\n"
<< "starts with a Byte-Order-Mark that is not UTF-8.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
@@ -111,7 +108,7 @@ bool cmListFileParser::ParseFile()
}
else
{
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n"
<< this->FileName << ":" << token->line << ":\n"
<< "Parse error. Expected a newline, got "
@@ -123,7 +120,7 @@ bool cmListFileParser::ParseFile()
}
else
{
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n"
<< this->FileName << ":" << token->line << ":\n"
<< "Parse error. Expected a command name, got "
@@ -271,7 +268,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
token->type == cmListFileLexer_Token_Space) {}
if(!token)
{
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n" << this->FileName << ":"
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Function missing opening \"(\".";
@@ -280,7 +277,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
}
if(token->type != cmListFileLexer_Token_ParenLeft)
{
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n" << this->FileName << ":"
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Expected \"(\", got "
@@ -358,7 +355,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
else
{
// Error.
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n" << this->FileName << ":"
<< cmListFileLexer_GetCurrentLine(this->Lexer) << ":\n"
<< "Parse error. Function missing ending \")\". "
@@ -370,7 +367,7 @@ bool cmListFileParser::ParseFunction(const char* name, long line)
}
}
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n"
<< this->FileName << ":" << lastLine << ":\n"
<< "Parse error. Function missing ending \")\". "
@@ -392,7 +389,7 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
}
bool isError = (this->Separation == SeparationError ||
delim == cmListFileArgument::Bracket);
- cmOStringStream m;
+ std::ostringstream m;
m << "Syntax " << (isError? "Error":"Warning") << " in cmake code at\n"
<< " " << this->FileName << ":" << token->line << ":"
<< token->column << "\n"
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index 427e29d..93aec32 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -110,10 +110,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
// Prepare the table of variables to read.
this->Prefix = args[2];
- for(unsigned int i=3; i < args.size(); ++i)
- {
- this->VariablesToRead.insert(args[i]);
- }
+ this->VariablesToRead.insert(args.begin() + 3, args.end());
// Read the cache file.
cmsys::ifstream fin(cacheFile.c_str());
@@ -160,7 +157,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
}
}
}
- if(line.length())
+ if(!line.empty())
{
// Partial last line.
this->CheckLine(line.c_str());
@@ -184,7 +181,7 @@ void cmLoadCacheCommand::CheckLine(const char* line)
// This was requested. Set this variable locally with the given
// prefix.
var = this->Prefix + var;
- if(value.length())
+ if(!value.empty())
{
this->Makefile->AddDefinition(var, value.c_str());
}
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index a4063a6..cdfd00c 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -226,7 +226,7 @@ bool cmLoadCommandCommand
std::string fullPath = cmSystemTools::FindFile(moduleName.c_str(), path);
if (fullPath == "")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Attempt to load command failed from file \""
<< moduleName << "\"";
this->SetError(e.str());
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e726ab9..7ca7684 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -79,9 +79,15 @@ public:
this->GG = lg->GetGlobalGenerator();
this->LG = this->GG->GetCurrentLocalGenerator();
this->GG->SetCurrentLocalGenerator(lg);
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GG->GetFileLockPool().PushFileScope();
+#endif
}
~cmLocalGeneratorCurrent()
{
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GG->GetFileLockPool().PopFileScope();
+#endif
this->GG->SetCurrentLocalGenerator(this->LG);
}
};
@@ -147,7 +153,7 @@ void cmLocalGenerator::ComputeObjectMaxPath()
}
else
{
- cmOStringStream w;
+ std::ostringstream w;
w << "CMAKE_OBJECT_PATH_MAX is set to " << pmax
<< ", which is less than the minimum of 128. "
<< "The value will be ignored.";
@@ -156,7 +162,7 @@ void cmLocalGenerator::ComputeObjectMaxPath()
}
else
{
- cmOStringStream w;
+ std::ostringstream w;
w << "CMAKE_OBJECT_PATH_MAX is set to \"" << plen
<< "\", which fails to parse as a positive integer. "
<< "The value will be ignored.";
@@ -185,7 +191,7 @@ void cmLocalGenerator::ReadInputFile()
// The file is missing. Check policy CMP0014.
cmMakefile* mf = this->Parent->GetMakefile();
- cmOStringStream e;
+ std::ostringstream e;
e << "The source directory\n"
<< " " << this->Makefile->GetStartDirectory() << "\n"
<< "does not contain a CMakeLists.txt file.";
@@ -221,19 +227,19 @@ void cmLocalGenerator::SetupPathConversions()
std::string outdir;
outdir =
cmSystemTools::CollapseFullPath(this->Makefile->GetHomeDirectory());
- cmSystemTools::SplitPath(outdir.c_str(), this->HomeDirectoryComponents);
+ cmSystemTools::SplitPath(outdir, this->HomeDirectoryComponents);
outdir =
cmSystemTools::CollapseFullPath(this->Makefile->GetStartDirectory());
- cmSystemTools::SplitPath(outdir.c_str(), this->StartDirectoryComponents);
+ cmSystemTools::SplitPath(outdir, this->StartDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath
(this->Makefile->GetHomeOutputDirectory());
- cmSystemTools::SplitPath(outdir.c_str(),
+ cmSystemTools::SplitPath(outdir,
this->HomeOutputDirectoryComponents);
outdir = cmSystemTools::CollapseFullPath
(this->Makefile->GetStartOutputDirectory());
- cmSystemTools::SplitPath(outdir.c_str(),
+ cmSystemTools::SplitPath(outdir,
this->StartOutputDirectoryComponents);
}
@@ -259,6 +265,17 @@ void cmLocalGenerator::ConfigureFinalPass()
void cmLocalGenerator::TraceDependencies()
{
+ std::vector<std::string> configs;
+ this->Makefile->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
+ for(std::vector<std::string>::const_iterator ci = configs.begin();
+ ci != configs.end(); ++ci)
+ {
+ this->GlobalGenerator->CreateEvaluationSourceFiles(*ci);
+ }
// Generate the rule files for each target.
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
@@ -318,7 +335,7 @@ void cmLocalGenerator::GenerateTestFiles()
{
(*gi)->Generate(fout, config, configurationTypes);
}
- if ( this->Children.size())
+ if (!this->Children.empty())
{
size_t i;
for(i = 0; i < this->Children.size(); ++i)
@@ -613,11 +630,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
// Parse the string to get the custom command line.
cmCustomCommandLine commandLine;
std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
- for(std::vector<std::string>::iterator a = cmd.begin();
- a != cmd.end(); ++a)
- {
- commandLine.push_back(*a);
- }
+ commandLine.insert(commandLine.end(), cmd.begin(), cmd.end());
// Store this command line.
commandLines.push_back(commandLine);
@@ -724,11 +737,7 @@ void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
// Parse the string to get the custom command line.
cmCustomCommandLine commandLine;
std::vector<std::string> cmd = cmSystemTools::ParseArguments(i->c_str());
- for(std::vector<std::string>::iterator a = cmd.begin();
- a != cmd.end(); ++a)
- {
- commandLine.push_back(*a);
- }
+ commandLine.insert(commandLine.end(), cmd.begin(), cmd.end());
// Store this command line.
commandLines.push_back(commandLine);
@@ -923,7 +932,7 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
if(variable == "TARGET_QUOTED")
{
std::string targetQuoted = replaceValues.Target;
- if(targetQuoted.size() && targetQuoted[0] != '\"')
+ if(!targetQuoted.empty() && targetQuoted[0] != '\"')
{
targetQuoted = '\"';
targetQuoted += replaceValues.Target;
@@ -1224,7 +1233,7 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
{
if(const char* val = this->GetRuleLauncher(target, prop))
{
- cmOStringStream wrapped;
+ std::ostringstream wrapped;
wrapped << val << " " << s;
s = wrapped.str();
}
@@ -1243,7 +1252,7 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote,
cmSystemTools::FileExists(remote.c_str()))
{
std::string tmp;
- if(cmSystemTools::GetShortPath(remote.c_str(), tmp))
+ if(cmSystemTools::GetShortPath(remote, tmp))
{
return this->Convert(tmp, NONE, format, true);
}
@@ -1305,7 +1314,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
- cmOStringStream includeFlags;
+ std::ostringstream includeFlags;
std::string flagVar = "CMAKE_INCLUDE_FLAG_";
flagVar += lang;
@@ -1367,7 +1376,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
{
std::string frameworkDir = *i;
frameworkDir += "/../";
- frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+ frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
if(emitted.insert(frameworkDir).second)
{
if (sysFwSearchFlag && target &&
@@ -1401,12 +1410,12 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
std::string includePath =
this->ConvertToIncludeReference(*i, shellFormat, forceFullPaths);
- if(quotePaths && includePath.size() && includePath[0] != '\"')
+ if(quotePaths && !includePath.empty() && includePath[0] != '\"')
{
includeFlags << "\"";
}
includeFlags << includePath;
- if(quotePaths && includePath.size() && includePath[0] != '\"')
+ if(quotePaths && !includePath.empty() && includePath[0] != '\"')
{
includeFlags << "\"";
}
@@ -1414,7 +1423,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
std::string flags = includeFlags.str();
// remove trailing separators
- if((sep[0] != ' ') && flags.size()>0 && flags[flags.size()-1] == sep[0])
+ if((sep[0] != ' ') && !flags.empty() && flags[flags.size()-1] == sep[0])
{
flags[flags.size()-1] = ' ';
}
@@ -1500,7 +1509,7 @@ void cmLocalGenerator::AddCompileOptions(
}
if (this->Makefile->IsLaterStandard(it->first, standard, it->second))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The COMPILE_FEATURES property of target \""
<< target->GetName() << "\" was evaluated when computing the link "
"implementation, and the \"" << it->first << "_STANDARD\" was \""
@@ -1609,10 +1618,10 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
{
// Emit this directory only if it is a subdirectory of the
// top-level source or binary tree.
- if(cmSystemTools::ComparePath(i->c_str(), topSourceDir) ||
- cmSystemTools::ComparePath(i->c_str(), topBinaryDir) ||
- cmSystemTools::IsSubDirectory(i->c_str(), topSourceDir) ||
- cmSystemTools::IsSubDirectory(i->c_str(), topBinaryDir))
+ if(cmSystemTools::ComparePath(*i, topSourceDir) ||
+ cmSystemTools::ComparePath(*i, topBinaryDir) ||
+ cmSystemTools::IsSubDirectory(*i, topSourceDir) ||
+ cmSystemTools::IsSubDirectory(*i, topBinaryDir))
{
if(emitted.insert(*i).second)
{
@@ -1859,7 +1868,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
((useWatcomQuote) ? WATCOMQUOTE : SHELL);
bool escapeAllowMakeVars = !forResponseFile;
- cmOStringStream fout;
+ std::ostringstream fout;
std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
if(!pcli)
@@ -2105,11 +2114,11 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
{
tLocation = target->GetLocation(config);
tLocation = cmSystemTools::GetFilenamePath(tLocation);
- tLocation = cmSystemTools::CollapseFullPath(tLocation.c_str());
+ tLocation = cmSystemTools::CollapseFullPath(tLocation);
}
std::string depLocation = cmSystemTools::GetFilenamePath(
std::string(inName));
- depLocation = cmSystemTools::CollapseFullPath(depLocation.c_str());
+ depLocation = cmSystemTools::CollapseFullPath(depLocation);
if(depLocation != tLocation)
{
// it is a full path to a depend that has the same name
@@ -2194,6 +2203,13 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
{
return;
}
+ const char* defaultStd
+ = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
+ if (!defaultStd || !*defaultStd)
+ {
+ // This compiler has no notion of language standard levels.
+ return;
+ }
std::string stdProp = lang + "_STANDARD";
const char *standardProp = target->GetProperty(stdProp);
if (!standardProp)
@@ -2221,7 +2237,7 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
const char *opt = target->GetMakefile()->GetDefinition(option_flag);
if (!opt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << target->GetName() << "\" requires the language "
"dialect \"" << lang << standardProp << "\" "
<< (ext ? "(with compiler extensions)" : "") << ", but CMake "
@@ -2256,20 +2272,32 @@ AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
std::find(stds.begin(), stds.end(), standard);
assert(stdIt != stds.end());
- const char* defaultStd
- = this->Makefile->GetDefinition("CMAKE_" + lang + "_STANDARD_DEFAULT");
- std::vector<std::string>::const_iterator defaultStdIt;
- if (defaultStd)
+ std::vector<std::string>::const_iterator defaultStdIt =
+ std::find(stds.begin(), stds.end(), defaultStd);
+ if (defaultStdIt == stds.end())
{
- defaultStdIt = std::find(stds.begin(), stds.end(), defaultStd);
- assert(defaultStdIt != stds.end());
+ std::string e =
+ "CMAKE_" + lang + "_STANDARD_DEFAULT is set to invalid value '" +
+ std::string(defaultStd) + "'";
+ this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, e);
+ return;
}
- else
+
+ // Greater or equal because the standards are stored in
+ // backward chronological order.
+ if (stdIt >= defaultStdIt)
{
- defaultStdIt = stds.end() - 1;
+ std::string option_flag =
+ "CMAKE_" + lang + *stdIt
+ + "_" + type + "_COMPILE_OPTION";
+
+ const char *opt =
+ target->GetMakefile()->GetRequiredDefinition(option_flag);
+ this->AppendFlagEscape(flags, opt);
+ return;
}
- for ( ; stdIt <= defaultStdIt; ++stdIt)
+ for ( ; stdIt < defaultStdIt; ++stdIt)
{
std::string option_flag =
"CMAKE_" + lang + *stdIt
@@ -2306,7 +2334,7 @@ static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
&& strcmp(prop, "protected") != 0
&& strcmp(prop, "internal") != 0 )
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target " << target->GetName() << " uses unsupported value \""
<< prop << "\" for " << flagDefine << ".";
cmSystemTools::Error(e.str().c_str());
@@ -2421,7 +2449,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
{
case cmPolicies::WARN:
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Variable " << flagsVar << " has been modified. CMake "
"will ignore the POSITION_INDEPENDENT_CODE target property for "
"shared libraries and will use the " << flagsVar << " variable "
@@ -2501,7 +2529,7 @@ void cmLocalGenerator::AppendFlags(std::string& flags,
{
if(!newFlags.empty())
{
- if(flags.size())
+ if(!flags.empty())
{
flags += " ";
}
@@ -2739,7 +2767,7 @@ std::string cmLocalGenerator::Convert(const std::string& source,
result);
break;
case FULL:
- result = cmSystemTools::CollapseFullPath(result.c_str());
+ result = cmSystemTools::CollapseFullPath(result);
break;
case NONE:
break;
@@ -2803,7 +2831,7 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
if(!local.empty() && (!optional || this->UseRelativePaths))
{
std::vector<std::string> components;
- cmSystemTools::SplitPath(local.c_str(), components);
+ cmSystemTools::SplitPath(local, components);
std::string result = this->ConvertToRelativePath(components, remotePath);
return this->ConvertToOutputFormat(result, output);
}
@@ -2823,7 +2851,7 @@ std::string cmLocalGenerator::FindRelativePathTopSource()
{
std::string parentTop = parent->FindRelativePathTopSource();
if(cmSystemTools::IsSubDirectory(
- this->Makefile->GetStartDirectory(), parentTop.c_str()))
+ this->Makefile->GetStartDirectory(), parentTop))
{
return parentTop;
}
@@ -2843,7 +2871,7 @@ std::string cmLocalGenerator::FindRelativePathTopBinary()
{
std::string parentTop = parent->FindRelativePathTopBinary();
if(cmSystemTools::IsSubDirectory(
- this->Makefile->GetStartOutputDirectory(), parentTop.c_str()))
+ this->Makefile->GetStartOutputDirectory(), parentTop))
{
return parentTop;
}
@@ -2893,7 +2921,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
assert(in_remote[0] != '\"');
// The local path should never have a trailing slash.
- assert(local.size() > 0 && !(local[local.size()-1] == ""));
+ assert(!local.empty() && !(local[local.size()-1] == ""));
// If the path is already relative then just return the path.
if(!cmSystemTools::FileIsFullPath(in_remote.c_str()))
@@ -2929,12 +2957,12 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
// Identify the longest shared path component between the remote
// path and the local path.
std::vector<std::string> remote;
- cmSystemTools::SplitPath(in_remote.c_str(), remote);
+ cmSystemTools::SplitPath(in_remote, remote);
unsigned int common=0;
while(common < remote.size() &&
common < local.size() &&
- cmSystemTools::ComparePath(remote[common].c_str(),
- local[common].c_str()))
+ cmSystemTools::ComparePath(remote[common],
+ local[common]))
{
++common;
}
@@ -2955,7 +2983,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
// If the entire path is in common except for a trailing slash then
// just return a "./".
if(common+1 == remote.size() &&
- remote[common].size() == 0 &&
+ remote[common].empty() &&
common == local.size())
{
return "./";
@@ -2985,7 +3013,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
// the trailing slash in the output.
for(unsigned int i=common; i < remote.size(); ++i)
{
- if(relative.size() > 0)
+ if(!relative.empty())
{
relative += "/";
}
@@ -3230,7 +3258,7 @@ cmLocalGenerator
// Warn if this is the first time the path has been seen.
if(this->ObjectMaxPathViolations.insert(dir_max).second)
{
- cmOStringStream m;
+ std::ostringstream m;
m << "The object file directory\n"
<< " " << dir_max << "\n"
<< "has " << dir_max.size() << " characters. "
@@ -3628,7 +3656,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
}
if(function_style)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "WARNING: Function-style preprocessor definitions may not be "
<< "passed on the compiler command line because many compilers "
<< "do not support it.\n"
@@ -3641,7 +3669,7 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
// Many compilers do not support # in the value so we disable it.
if(define.find_first_of("#") != define.npos)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "WARNING: Preprocessor definitions containing '#' may not be "
<< "passed on the compiler command line because many compilers "
<< "do not support it.\n"
@@ -3683,7 +3711,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
}
if(!cmSystemTools::FileExists(inFile.c_str(), true))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \""
<< inFile << "\" could not be found.";
cmSystemTools::Error(e.str().c_str());
@@ -3727,7 +3755,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
}
if(!cmSystemTools::FileExists(inFile.c_str(), true))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target " << target->GetName() << " Info.plist template \""
<< inFile << "\" could not be found.";
cmSystemTools::Error(e.str().c_str());
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 398b55a..413dc0f 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -352,7 +352,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandDeps(
i != deps.end(); ++i) {
std::string dep;
if (this->GetRealDependency(*i, this->GetConfigName(), dep))
- ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str()));
+ ninjaDeps.push_back(ConvertToNinjaPath(dep));
}
}
@@ -369,7 +369,7 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
return ":";
#endif
- cmOStringStream cmd;
+ std::ostringstream cmd;
for (std::vector<std::string>::const_iterator li = cmdLines.begin();
li != cmdLines.end(); ++li)
#ifdef _WIN32
@@ -409,7 +409,7 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(
if (wd.empty())
wd = this->GetMakefile()->GetStartOutputDirectory();
- cmOStringStream cdCmd;
+ std::ostringstream cdCmd;
#ifdef _WIN32
std::string cdStr = "cd /D ";
#else
@@ -440,10 +440,18 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
const std::vector<std::string> &outputs = ccg.GetOutputs();
- cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps;
+ const std::vector<std::string> &byproducts = ccg.GetByproducts();
+ cmNinjaDeps ninjaOutputs(outputs.size()+byproducts.size()), ninjaDeps;
+#if 0
+#error TODO: Once CC in an ExternalProject target must provide the \
+ file of each imported target that has an add_dependencies pointing \
+ at us. How to know which ExternalProject step actually provides it?
+#endif
std::transform(outputs.begin(), outputs.end(),
ninjaOutputs.begin(), MapToNinjaPath());
+ std::transform(byproducts.begin(), byproducts.end(),
+ ninjaOutputs.begin() + outputs.size(), MapToNinjaPath());
this->AppendCustomCommandDeps(ccg, ninjaDeps);
for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
@@ -468,6 +476,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
this->BuildCommandLine(cmdLines),
this->ConstructComment(ccg),
"Custom command for " + ninjaOutputs[0],
+ cc->GetUsesTerminal(),
ninjaOutputs,
ninjaDeps,
orderOnlyDeps);
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index 1d27224..01e16df 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -74,7 +74,7 @@ public:
map_to_ninja_path(cmLocalNinjaGenerator *LocalGen)
: LocalGenerator(LocalGen) {}
std::string operator()(const std::string &path) {
- return LocalGenerator->ConvertToNinjaPath(path.c_str());
+ return LocalGenerator->ConvertToNinjaPath(path);
}
};
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 280d4ab..dfa6cc9 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -92,6 +92,7 @@ cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
this->SkipAssemblySourceRules = false;
this->MakeCommandEscapeTargetTwice = false;
this->BorlandMakeCurlyHack = false;
+ this->NoMultiOutputMultiDepRules = false;
}
//----------------------------------------------------------------------------
@@ -315,36 +316,43 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// Check whether preprocessing and assembly rules make sense.
// They make sense only for C and C++ sources.
- bool lang_is_c_or_cxx = false;
+ bool lang_has_preprocessor = false;
+ bool lang_has_assembly = false;
+
for(std::vector<LocalObjectEntry>::const_iterator ei =
lo->second.begin(); ei != lo->second.end(); ++ei)
{
- if(ei->Language == "C" || ei->Language == "CXX")
+ if(ei->Language == "C" ||
+ ei->Language == "CXX" ||
+ ei->Language == "Fortran")
{
- lang_is_c_or_cxx = true;
+ // Right now, C, C++ and Fortran have both a preprocessor and the
+ // ability to generate assembly code
+ lang_has_preprocessor = true;
+ lang_has_assembly = true;
break;
}
}
// Add convenience rules for preprocessed and assembly files.
- if(lang_is_c_or_cxx && (do_preprocess_rules || do_assembly_rules))
+ if(lang_has_preprocessor && do_preprocess_rules)
{
std::string::size_type dot_pos = lo->first.rfind(".");
std::string base = lo->first.substr(0, dot_pos);
- if(do_preprocess_rules)
- {
- this->WriteObjectConvenienceRule(
- ruleFileStream, "target to preprocess a source file",
- (base + ".i").c_str(), lo->second);
- lo->second.HasPreprocessRule = true;
- }
- if(do_assembly_rules)
- {
- this->WriteObjectConvenienceRule(
- ruleFileStream, "target to generate assembly for a file",
- (base + ".s").c_str(), lo->second);
- lo->second.HasAssembleRule = true;
- }
+ this->WriteObjectConvenienceRule(
+ ruleFileStream, "target to preprocess a source file",
+ (base + ".i").c_str(), lo->second);
+ lo->second.HasPreprocessRule = true;
+ }
+
+ if(lang_has_assembly && do_assembly_rules)
+ {
+ std::string::size_type dot_pos = lo->first.rfind(".");
+ std::string base = lo->first.substr(0, dot_pos);
+ this->WriteObjectConvenienceRule(
+ ruleFileStream, "target to generate assembly for a file",
+ (base + ".s").c_str(), lo->second);
+ lo->second.HasAssembleRule = true;
}
}
@@ -611,6 +619,30 @@ cmLocalUnixMakefileGenerator3
comment);
return;
}
+ std::vector<std::string> outputs(1, target);
+ this->WriteMakeRule(os, comment,
+ outputs, depends, commands,
+ symbolic, in_help);
+}
+
+//----------------------------------------------------------------------------
+void
+cmLocalUnixMakefileGenerator3
+::WriteMakeRule(std::ostream& os,
+ const char* comment,
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& depends,
+ const std::vector<std::string>& commands,
+ bool symbolic,
+ bool in_help)
+{
+ // Make sure there is an output.
+ if(outputs.empty())
+ {
+ cmSystemTools::Error("No outputs for WriteMakeRule! called with comment: ",
+ comment);
+ return;
+ }
std::string replace;
@@ -629,8 +661,18 @@ cmLocalUnixMakefileGenerator3
}
// Construct the left hand side of the rule.
- replace = target;
- std::string tgt = this->Convert(replace,HOME_OUTPUT,MAKERULE);
+ std::string tgt;
+ {
+ const char* sep = "";
+ for (std::vector<std::string>::const_iterator i = outputs.begin();
+ i != outputs.end(); ++i)
+ {
+ tgt += sep;
+ tgt += this->Convert(*i,HOME_OUTPUT,MAKERULE);
+ sep = " ";
+ }
+ }
+
const char* space = "";
if(tgt.size() == 1)
{
@@ -655,6 +697,19 @@ cmLocalUnixMakefileGenerator3
// No dependencies. The commands will always run.
os << cmMakeSafe(tgt) << space << ":\n";
}
+ else if(this->NoMultiOutputMultiDepRules && outputs.size() >= 2)
+ {
+ // Borland make does not understand multiple dependency rules when
+ // there are multiple outputs, so write them all on one line.
+ os << cmMakeSafe(tgt) << space << ":";
+ for(std::vector<std::string>::const_iterator dep = depends.begin();
+ dep != depends.end(); ++dep)
+ {
+ replace = this->Convert(*dep, HOME_OUTPUT, MAKERULE);
+ os << " " << cmMakeSafe(replace);
+ }
+ os << "\n";
+ }
else
{
// Split dependencies into multiple rule lines. This allows for
@@ -683,7 +738,8 @@ cmLocalUnixMakefileGenerator3
// Add the output to the local help if requested.
if(in_help)
{
- this->LocalHelp.push_back(target);
+ this->LocalHelp.insert(this->LocalHelp.end(),
+ outputs.begin(), outputs.end());
}
}
@@ -700,7 +756,7 @@ cmLocalUnixMakefileGenerator3
// name. This is needed to avoid funny quoting problems on
// lines with shell redirection operators.
std::string scmd;
- if(cmSystemTools::GetShortPath(cmd.c_str(), scmd))
+ if(cmSystemTools::GetShortPath(cmd, scmd))
{
return this->Convert(scmd, NONE, SHELL);
}
@@ -1101,7 +1157,7 @@ cmLocalUnixMakefileGenerator3
{
// Build the command line in a single string.
std::string cmd = ccg.GetCommand(c);
- if (cmd.size())
+ if (!cmd.empty())
{
// Use "call " before any invocations of .bat or .cmd files
// invoked as custom commands in the WindowsShell.
@@ -1495,7 +1551,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Dependee \"" << tgtInfo
<< "\" is newer than depender \""
<< internalDependFile << "\"." << std::endl;
@@ -1518,7 +1574,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Dependee \"" << dirInfoFile
<< "\" is newer than depender \""
<< internalDependFile << "\"." << std::endl;
@@ -1702,6 +1758,8 @@ cmLocalUnixMakefileGenerator3
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
{
+ // Nothing populates multiple output pairs anymore, but we need to
+ // honor it when working in a build tree generated by an older CMake.
cmMakefile* mf = this->Makefile;
// Get the string listing the multiple output pairs.
@@ -1727,13 +1785,13 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose)
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Deleting primary custom command output \"" << dependee
<< "\" because another output \""
<< depender << "\" does not exist." << std::endl;
cmSystemTools::Stdout(msg.str().c_str());
}
- cmSystemTools::RemoveFile(dependee.c_str());
+ cmSystemTools::RemoveFile(dependee);
}
}
}
@@ -1768,7 +1826,7 @@ void cmLocalUnixMakefileGenerator3
std::vector<std::string> no_depends;
this->WriteMakeRule(ruleFileStream,
"Allow only one \"make -f Makefile2\" at a time, but pass parallelism.",
- ".NOTPARALLEL", no_depends, no_commands, true);
+ ".NOTPARALLEL", no_depends, no_commands, false);
}
}
@@ -1795,13 +1853,8 @@ void cmLocalUnixMakefileGenerator3
{
text = "Running external command ...";
}
- std::set<std::string>::const_iterator dit;
- for ( dit = glIt->second.GetUtilities().begin();
- dit != glIt->second.GetUtilities().end();
- ++ dit )
- {
- depends.push_back(*dit);
- }
+ depends.insert(depends.end(), glIt->second.GetUtilities().begin(),
+ glIt->second.GetUtilities().end());
this->AppendEcho(commands, text,
cmLocalUnixMakefileGenerator3::EchoGlobal);
@@ -1857,7 +1910,7 @@ void cmLocalUnixMakefileGenerator3
std::string progressDir = this->Makefile->GetHomeOutputDirectory();
progressDir += cmake::GetCMakeFilesDirectory();
{
- cmOStringStream progCmd;
+ std::ostringstream progCmd;
progCmd <<
"$(CMAKE_COMMAND) -E cmake_progress_start ";
progCmd << this->Convert(progressDir,
@@ -1881,7 +1934,7 @@ void cmLocalUnixMakefileGenerator3
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
{
- cmOStringStream progCmd;
+ std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
progCmd << this->Convert(progressDir,
cmLocalGenerator::FULL,
@@ -1988,7 +2041,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
// Remove the internal dependency check file to force
// regeneration.
std::string internalDependFile = dir + "/depend.internal";
- cmSystemTools::RemoveFile(internalDependFile.c_str());
+ cmSystemTools::RemoveFile(internalDependFile);
}
}
@@ -2117,7 +2170,7 @@ cmLocalUnixMakefileGenerator3
cmd += " ";
// Pass down verbosity level.
- if(this->GetMakeSilentFlag().size())
+ if(!this->GetMakeSilentFlag().empty())
{
cmd += this->GetMakeSilentFlag();
cmd += " ";
@@ -2241,7 +2294,7 @@ cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
for(unsigned int i=1; i < components.size(); ++i)
{
// Only the last component can be empty to avoid double slashes.
- if(components[i].length() > 0 || (i == (components.size()-1)))
+ if(!components[i].empty() || (i == (components.size()-1)))
{
if(!first)
{
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 4f2e4a0..7c8e27f 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -61,6 +61,13 @@ public:
const std::vector<std::string>& commands,
bool symbolic,
bool in_help = false);
+ void WriteMakeRule(std::ostream& os,
+ const char* comment,
+ const std::vector<std::string>& outputs,
+ const std::vector<std::string>& depends,
+ const std::vector<std::string>& commands,
+ bool symbolic,
+ bool in_help = false);
// write the main variables used by the makefiles
void WriteMakeVariables(std::ostream& makefileStream);
@@ -154,6 +161,9 @@ public:
void SetBorlandMakeCurlyHack(bool b)
{ this->BorlandMakeCurlyHack = b; }
+ void SetNoMultiOutputMultiDepRules(bool b)
+ { this->NoMultiOutputMultiDepRules = b; }
+
// used in writing out Cmake files such as WriteDirectoryInformation
static void WriteCMakeArgument(std::ostream& os, const char* s);
@@ -338,6 +348,7 @@ private:
bool PassMakeflags;
bool MakeCommandEscapeTargetTwice;
bool BorlandMakeCurlyHack;
+ bool NoMultiOutputMultiDepRules;
//==========================================================================
std::string HomeRelativeOutputPath;
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index c14fb2b..1d62093 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -821,10 +821,12 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
command.push_back("make_directory");
command.push_back(outDir);
std::vector<std::string> no_output;
+ std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
cmCustomCommandLines commands;
commands.push_back(command);
- pcc.reset(new cmCustomCommand(0, no_output, no_depends, commands, 0, 0));
+ pcc.reset(new cmCustomCommand(0, no_output, no_byproducts,
+ no_depends, commands, 0, 0));
pcc->SetEscapeOldStyle(false);
pcc->SetEscapeAllowMakeVars(true);
return pcc;
@@ -1319,7 +1321,7 @@ void cmLocalVisualStudio6Generator
int major;
int minor;
target.GetTargetVersion(major, minor);
- cmOStringStream targetVersionStream;
+ std::ostringstream targetVersionStream;
targetVersionStream << "/version:" << major << "." << minor;
targetVersionFlag = targetVersionStream.str();
}
@@ -1996,7 +1998,7 @@ cmLocalVisualStudio6Generator
if(define.find_first_of(" ") != define.npos &&
define.find_first_of("\"$;") != define.npos)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "WARNING: The VS6 IDE does not support preprocessor definition "
<< "values with spaces and '\"', '$', or ';'.\n"
<< "CMake is dropping a preprocessor definition: " << define << "\n"
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index eb45423..914df5f 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -592,6 +592,15 @@ cmVS7FlagTable cmLocalVisualStudio7GeneratorLinkFlagTable[] =
{0,0,0,0,0}
};
+cmVS7FlagTable cmLocalVisualStudio7GeneratorFortranLinkFlagTable[] =
+{
+ {"LinkIncremental", "INCREMENTAL:NO", "link incremental",
+ "linkIncrementalNo", 0},
+ {"LinkIncremental", "INCREMENTAL:YES", "link incremental",
+ "linkIncrementalYes", 0},
+ {0,0,0,0,0}
+};
+
//----------------------------------------------------------------------------
// Helper class to write build event <Tool .../> elements.
class cmLocalVisualStudio7Generator::EventWriter
@@ -1056,8 +1065,13 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
extraLinkOptions += " ";
extraLinkOptions += targetLinkFlags;
}
- Options linkOptions(this, Options::Linker,
- cmLocalVisualStudio7GeneratorLinkFlagTable);
+ Options linkOptions(this, Options::Linker);
+ if(this->FortranProject)
+ {
+ linkOptions.AddTable(cmLocalVisualStudio7GeneratorFortranLinkFlagTable);
+ }
+ linkOptions.AddTable(cmLocalVisualStudio7GeneratorLinkFlagTable);
+
linkOptions.Parse(extraLinkOptions.c_str());
if(!this->ModuleDefinitionFile.empty())
{
@@ -1101,7 +1115,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
if(this->GetVersion() < VS8 || this->FortranProject)
{
- cmOStringStream libdeps;
+ std::ostringstream libdeps;
this->Internal->OutputObjects(libdeps, &target);
if(!libdeps.str().empty())
{
@@ -1699,7 +1713,7 @@ bool cmLocalVisualStudio7Generator
// Write the children to temporary output.
bool hasChildrenWithSources = false;
- cmOStringStream tmpOut;
+ std::ostringstream tmpOut;
for(unsigned int i=0;i<children.size();++i)
{
if(this->WriteGroup(&children[i], target, tmpOut, libName, configs))
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 9680d43..f01aa6b 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -95,10 +95,12 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
command.push_back("make_directory");
command.push_back(impDir);
std::vector<std::string> no_output;
+ std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
cmCustomCommandLines commands;
commands.push_back(command);
- pcc.reset(new cmCustomCommand(0, no_output, no_depends, commands, 0, 0));
+ pcc.reset(new cmCustomCommand(0, no_output, no_byproducts,
+ no_depends, commands, 0, 0));
pcc->SetEscapeOldStyle(false);
pcc->SetEscapeAllowMakeVars(true);
return pcc;
diff --git a/Source/cmLocale.h b/Source/cmLocale.h
new file mode 100644
index 0000000..727f0f5
--- /dev/null
+++ b/Source/cmLocale.h
@@ -0,0 +1,31 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmLocale_h
+#define cmLocale_h
+
+#include <locale.h>
+
+class cmLocaleRAII
+{
+ const char* OldLocale;
+public:
+ cmLocaleRAII(): OldLocale(setlocale(LC_CTYPE, 0))
+ {
+ setlocale(LC_CTYPE, "");
+ }
+ ~cmLocaleRAII()
+ {
+ setlocale(LC_CTYPE, this->OldLocale);
+ }
+};
+
+#endif
diff --git a/Source/cmMachO.cxx b/Source/cmMachO.cxx
new file mode 100644
index 0000000..1607845
--- /dev/null
+++ b/Source/cmMachO.cxx
@@ -0,0 +1,419 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmStandardIncludes.h" // to get CMAKE_USE_MACH_PARSER first
+#include "cmMachO.h"
+
+#include <cmsys/FStream.hxx>
+
+// Include the Mach-O format information system header.
+#include <mach-o/loader.h>
+#include <mach-o/fat.h>
+
+/**
+
+ https://developer.apple.com/library/mac/documentation/
+ DeveloperTools/Conceptual/MachORuntime/index.html
+
+ A Mach-O file has 3 major regions: header, load commands and segments.
+ Data Structures are provided from <mach-o/loader.h> which
+ correspond to the file structure.
+
+ The header can be either a struct mach_header or struct mach_header_64.
+ One can peek at the first 4 bytes to identify the type of header.
+
+ Following is the load command region which starts with
+ struct load_command, and is followed by n number of load commands.
+
+ In the case of a universal binary (an archive of multiple Mach-O files),
+ the file begins with a struct fat_header and is followed by multiple
+ struct fat_arch instances. The struct fat_arch indicates the offset
+ for each Mach-O file.
+
+ */
+
+namespace {
+
+ // peek in the file
+ template <typename T>
+ bool peek(cmsys::ifstream& fin, T &v)
+ {
+ std::streampos p = fin.tellg();
+ if(!fin.read(reinterpret_cast<char*>(&v), sizeof(T)))
+ {
+ return false;
+ }
+ fin.seekg(p);
+ return fin.good();
+ }
+
+ // read from the file and fill a data structure
+ template <typename T>
+ bool read(cmsys::ifstream& fin, T& v)
+ {
+ if(!fin.read(reinterpret_cast<char*>(&v), sizeof(T)))
+ {
+ return false;
+ }
+ return true;
+ }
+
+ // read from the file and fill multiple data structures where
+ // the vector has been resized
+ template <typename T>
+ bool read(cmsys::ifstream& fin, std::vector<T>& v)
+ {
+ // nothing to read
+ if(v.empty())
+ {
+ return true;
+ }
+ if(!fin.read(reinterpret_cast<char*>(&v[0]), sizeof(T) * v.size()))
+ {
+ return false;
+ }
+ return true;
+ }
+}
+
+
+// Contains header and load commands for a single Mach-O file
+class cmMachOHeaderAndLoadCommands
+{
+public:
+ // A load_command and its associated data
+ struct RawLoadCommand
+ {
+ uint32_t type(const cmMachOHeaderAndLoadCommands* m) const
+ {
+ if(this->LoadCommand.size() < sizeof(load_command))
+ {
+ return 0;
+ }
+ const load_command* cmd =
+ reinterpret_cast<const load_command*>(&this->LoadCommand[0]);
+ return m->swap(cmd->cmd);
+ }
+ std::vector<char> LoadCommand;
+ };
+
+ cmMachOHeaderAndLoadCommands(bool _swap)
+ : Swap(_swap)
+ {
+ }
+ virtual ~cmMachOHeaderAndLoadCommands()
+ {
+ }
+
+ virtual bool read_mach_o(cmsys::ifstream& fin) = 0;
+
+ const std::vector<RawLoadCommand>& load_commands() const
+ {
+ return this->LoadCommands;
+ }
+
+ uint32_t swap(uint32_t v) const
+ {
+ if(this->Swap)
+ {
+ char* c = reinterpret_cast<char*>(&v);
+ std::swap(c[0], c[3]);
+ std::swap(c[1], c[2]);
+ }
+ return v;
+ }
+
+protected:
+ bool read_load_commands(uint32_t ncmds, uint32_t sizeofcmds,
+ cmsys::ifstream& fin);
+
+ bool Swap;
+ std::vector<RawLoadCommand> LoadCommands;
+};
+
+// Implementation for reading Mach-O header and load commands.
+// This is 32 or 64 bit arch specific.
+template <class T>
+class cmMachOHeaderAndLoadCommandsImpl : public cmMachOHeaderAndLoadCommands
+{
+public:
+ cmMachOHeaderAndLoadCommandsImpl(bool _swap)
+ : cmMachOHeaderAndLoadCommands(_swap)
+ {
+ }
+ bool read_mach_o(cmsys::ifstream& fin)
+ {
+ if(!read(fin, this->Header))
+ {
+ return false;
+ }
+ this->Header.cputype = swap(this->Header.cputype);
+ this->Header.cpusubtype = swap(this->Header.cpusubtype);
+ this->Header.filetype = swap(this->Header.filetype);
+ this->Header.ncmds = swap(this->Header.ncmds);
+ this->Header.sizeofcmds = swap(this->Header.sizeofcmds);
+ this->Header.flags = swap(this->Header.flags);
+
+ return read_load_commands(this->Header.ncmds,
+ this->Header.sizeofcmds,
+ fin);
+ }
+protected:
+ T Header;
+};
+
+
+bool cmMachOHeaderAndLoadCommands::read_load_commands(uint32_t ncmds,
+ uint32_t sizeofcmds,
+ cmsys::ifstream& fin)
+{
+ uint32_t size_read = 0;
+ this->LoadCommands.resize(ncmds);
+ for(uint32_t i = 0; i<ncmds; i++)
+ {
+ load_command lc;
+ if(!peek(fin, lc))
+ {
+ return false;
+ }
+ lc.cmd = swap(lc.cmd);
+ lc.cmdsize = swap(lc.cmdsize);
+ size_read += lc.cmdsize;
+
+ RawLoadCommand& c = this->LoadCommands[i];
+ c.LoadCommand.resize(lc.cmdsize);
+ if(!read(fin, c.LoadCommand))
+ {
+ return false;
+ }
+ }
+
+ if(size_read != sizeofcmds)
+ {
+ this->LoadCommands.clear();
+ return false;
+ }
+
+ return true;
+}
+
+//----------------------------------------------------------------------------
+class cmMachOInternal
+{
+public:
+ cmMachOInternal(const char* fname);
+ ~cmMachOInternal();
+
+ // read a Mach-O file
+ bool read_mach_o(uint32_t file_offset);
+
+ // the file we are reading
+ cmsys::ifstream Fin;
+
+ // The archs in the universal binary
+ // If the binary is not a universal binary, this will be empty.
+ std::vector<fat_arch> FatArchs;
+
+ // the error message while parsing
+ std::string ErrorMessage;
+
+ // the list of Mach-O's
+ std::vector<cmMachOHeaderAndLoadCommands*> MachOList;
+};
+
+cmMachOInternal::cmMachOInternal(const char* fname)
+ : Fin(fname)
+{
+ // Quit now if the file could not be opened.
+ if(!this->Fin || !this->Fin.get() )
+ {
+ this->ErrorMessage = "Error opening input file.";
+ return;
+ }
+
+ if(!this->Fin.seekg(0))
+ {
+ this->ErrorMessage = "Error seeking to beginning of file.";
+ return;
+ }
+
+ // Read the binary identification block.
+ uint32_t magic = 0;
+ if(!peek(this->Fin, magic))
+ {
+ this->ErrorMessage = "Error reading Mach-O identification.";
+ return;
+ }
+
+ // Verify the binary identification.
+ if(!(magic == MH_CIGAM ||
+ magic == MH_MAGIC ||
+ magic == MH_CIGAM_64 ||
+ magic == MH_MAGIC_64 ||
+ magic == FAT_CIGAM ||
+ magic == FAT_MAGIC))
+ {
+ this->ErrorMessage = "File does not have a valid Mach-O identification.";
+ return;
+ }
+
+ if(magic == FAT_MAGIC || magic == FAT_CIGAM)
+ {
+ // this is a universal binary
+ fat_header header;
+ if(!read(this->Fin, header))
+ {
+ this->ErrorMessage = "Error reading fat header.";
+ return;
+ }
+
+ // read fat_archs
+ this->FatArchs.resize(OSSwapBigToHostInt32(header.nfat_arch));
+ if(!read(this->Fin, this->FatArchs))
+ {
+ this->ErrorMessage = "Error reading fat header archs.";
+ return;
+ }
+
+ // parse each Mach-O file
+ for(size_t i=0; i<this->FatArchs.size(); i++)
+ {
+ const fat_arch& arch = this->FatArchs[i];
+ if(!this->read_mach_o(OSSwapBigToHostInt32(arch.offset)))
+ {
+ return;
+ }
+ }
+ }
+ else
+ {
+ // parse Mach-O file at the beginning of the file
+ this->read_mach_o(0);
+ }
+}
+
+cmMachOInternal::~cmMachOInternal()
+{
+ for(size_t i=0; i<this->MachOList.size(); i++)
+ {
+ delete this->MachOList[i];
+ }
+}
+
+bool cmMachOInternal::read_mach_o(uint32_t file_offset)
+{
+ if(!this->Fin.seekg(file_offset))
+ {
+ this->ErrorMessage = "Failed to locate Mach-O content.";
+ return false;
+ }
+
+ uint32_t magic;
+ if(!peek(this->Fin, magic))
+ {
+ this->ErrorMessage = "Error reading Mach-O identification.";
+ return false;
+ }
+
+ cmMachOHeaderAndLoadCommands* f = NULL;
+ if(magic == MH_CIGAM || magic == MH_MAGIC)
+ {
+ bool swap = false;
+ if(magic == MH_CIGAM)
+ {
+ swap = true;
+ }
+ f = new cmMachOHeaderAndLoadCommandsImpl<mach_header>(swap);
+ }
+ else if(magic == MH_CIGAM_64 || magic == MH_MAGIC_64)
+ {
+ bool swap = false;
+ if(magic == MH_CIGAM_64)
+ {
+ swap = true;
+ }
+ f = new cmMachOHeaderAndLoadCommandsImpl<mach_header_64>(swap);
+ }
+
+ if(f && f->read_mach_o(this->Fin))
+ {
+ this->MachOList.push_back(f);
+ }
+ else
+ {
+ delete f;
+ this->ErrorMessage = "Failed to read Mach-O header.";
+ return false;
+ }
+
+ return true;
+}
+
+//============================================================================
+// External class implementation.
+
+//----------------------------------------------------------------------------
+cmMachO::cmMachO(const char* fname): Internal(0)
+{
+ this->Internal = new cmMachOInternal(fname);
+
+}
+
+//----------------------------------------------------------------------------
+cmMachO::~cmMachO()
+{
+ delete this->Internal;
+}
+
+std::string const& cmMachO::GetErrorMessage() const
+{
+ return this->Internal->ErrorMessage;
+}
+
+//----------------------------------------------------------------------------
+bool cmMachO::Valid() const
+{
+ return !this->Internal->MachOList.empty();
+}
+
+bool cmMachO::GetInstallName(std::string& install_name)
+{
+ if(this->Internal->MachOList.empty())
+ {
+ return false;
+ }
+
+ // grab the first Mach-O and get the install name from that one
+ cmMachOHeaderAndLoadCommands* macho = this->Internal->MachOList[0];
+ for(size_t i=0; i<macho->load_commands().size(); i++)
+ {
+ const cmMachOHeaderAndLoadCommands::RawLoadCommand &cmd =
+ macho->load_commands()[i];
+ uint32_t lc_cmd = cmd.type(macho);
+ if(lc_cmd == LC_ID_DYLIB ||
+ lc_cmd == LC_LOAD_WEAK_DYLIB ||
+ lc_cmd == LC_LOAD_DYLIB)
+ {
+ if(sizeof(dylib_command) < cmd.LoadCommand.size())
+ {
+ uint32_t namelen = cmd.LoadCommand.size() - sizeof(dylib_command);
+ install_name.assign(&cmd.LoadCommand[sizeof(dylib_command)], namelen);
+ return true;
+ }
+ }
+ }
+
+ return false;
+}
+
+void cmMachO::PrintInfo(std::ostream& /*os*/) const
+{
+}
diff --git a/Source/cmMachO.h b/Source/cmMachO.h
new file mode 100644
index 0000000..f06f8de
--- /dev/null
+++ b/Source/cmMachO.h
@@ -0,0 +1,51 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmMachO_h
+#define cmMachO_h
+
+#if !defined(CMAKE_USE_MACH_PARSER)
+# error "This file may be included only if CMAKE_USE_MACH_PARSER is enabled."
+#endif
+
+class cmMachOInternal;
+
+/** \class cmMachO
+ * \brief Executable and Link Format (Mach-O) parser.
+ */
+class cmMachO
+{
+public:
+ /** Construct with the name of the Mach-O input file to parse. */
+ cmMachO(const char* fname);
+
+ /** Destruct. */
+ ~cmMachO();
+
+ /** Get the error message if any. */
+ std::string const& GetErrorMessage() const;
+
+ /** Boolean conversion. True if the Mach-O file is valid. */
+ operator bool() const { return this->Valid(); }
+
+ /** Get Install name from binary **/
+ bool GetInstallName(std::string& install_name);
+
+ /** Print human-readable information about the Mach-O file. */
+ void PrintInfo(std::ostream& os) const;
+
+private:
+ friend class cmMachOInternal;
+ bool Valid() const;
+ cmMachOInternal* Internal;
+};
+
+#endif
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index ae81c58..69fcca7 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -107,7 +107,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
cmMakefile::PolicyPushPop polScope(this->Makefile, true, this->Policies);
// set the value of argc
- cmOStringStream argcDefStream;
+ std::ostringstream argcDefStream;
argcDefStream << expandedArgs.size();
std::string argcDef = argcDefStream.str();
@@ -116,7 +116,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
std::string argnDef;
bool argnDefInitialized = false;
bool argvDefInitialized = false;
- if( this->Functions.size())
+ if(!this->Functions.empty())
{
this->FilePath = this->Functions[0].FilePath;
}
@@ -170,7 +170,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
{
if ( cnt >= this->Args.size()-1 )
{
- if ( argnDef.size() > 0 )
+ if (!argnDef.empty())
{
argnDef += ";";
}
@@ -195,7 +195,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
std::vector<std::string>::const_iterator eit;
for(eit = expandedArgs.begin(); eit != expandedArgs.end(); ++eit)
{
- if ( argvDef.size() > 0 )
+ if (!argvDef.empty())
{
argvDef += ";";
}
@@ -328,11 +328,7 @@ bool cmMacroCommand::InitialPass(std::vector<std::string> const& args,
// create a function blocker
cmMacroFunctionBlocker *f = new cmMacroFunctionBlocker();
- for(std::vector<std::string>::const_iterator j = args.begin();
- j != args.end(); ++j)
- {
- f->Args.push_back(*j);
- }
+ f->Args.insert(f->Args.end(), args.begin(), args.end());
this->Makefile->AddFunctionBlocker(f);
return true;
}
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 52832db..31bbb73 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -34,12 +34,7 @@ cmMakeDepend::cmMakeDepend()
cmMakeDepend::~cmMakeDepend()
{
- for(DependInformationMapType::iterator i =
- this->DependInformationMap.begin();
- i != this->DependInformationMap.end(); ++i)
- {
- delete i->second;
- }
+ cmDeleteAll(this->DependInformationMap);
}
@@ -180,7 +175,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
t != this->IncludeDirectories.end(); ++t)
{
std::string incpath = *t;
- if (incpath.size() && incpath[incpath.size() - 1] != '/')
+ if (!incpath.empty() && incpath[incpath.size() - 1] != '/')
{
incpath = incpath + "/";
}
@@ -323,15 +318,15 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
i != this->IncludeDirectories.end(); ++i)
{
std::string path = *i;
- if (path.size() && path[path.size() - 1] != '/')
+ if (!path.empty() && path[path.size() - 1] != '/')
{
path = path + "/";
}
path = path + fname;
if(cmSystemTools::FileExists(path.c_str(), true)
- && !cmSystemTools::FileIsDirectory(path.c_str()))
+ && !cmSystemTools::FileIsDirectory(path))
{
- std::string fp = cmSystemTools::CollapseFullPath(path.c_str());
+ std::string fp = cmSystemTools::CollapseFullPath(path);
this->DirectoryToFileToPathMap[extraPath? extraPath: ""][fname] = fp;
return fp;
}
@@ -340,15 +335,15 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
if (extraPath)
{
std::string path = extraPath;
- if (path.size() && path[path.size() - 1] != '/')
+ if (!path.empty() && path[path.size() - 1] != '/')
{
path = path + "/";
}
path = path + fname;
if(cmSystemTools::FileExists(path.c_str(), true)
- && !cmSystemTools::FileIsDirectory(path.c_str()))
+ && !cmSystemTools::FileIsDirectory(path))
{
- std::string fp = cmSystemTools::CollapseFullPath(path.c_str());
+ std::string fp = cmSystemTools::CollapseFullPath(path);
this->DirectoryToFileToPathMap[extraPath][fname] = fp;
return fp;
}
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index ab77e4a..ba914e1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -169,6 +169,9 @@ void cmMakefile::Initialize()
// Protect the directory-level policies.
this->PushPolicyBarrier();
+ // push empty loop block
+ this->PushLoopBlockBarrier();
+
// By default the check is not done. It is enabled by
// cmListFileCache in the top level if necessary.
this->CheckCMP0000 = false;
@@ -191,45 +194,13 @@ bool cmMakefile::NeedCacheCompatibility(int major, int minor) const
cmMakefile::~cmMakefile()
{
- for(std::vector<cmInstallGenerator*>::iterator
- i = this->InstallGenerators.begin();
- i != this->InstallGenerators.end(); ++i)
- {
- delete *i;
- }
- for(std::vector<cmTestGenerator*>::iterator
- i = this->TestGenerators.begin();
- i != this->TestGenerators.end(); ++i)
- {
- delete *i;
- }
- for(std::vector<cmSourceFile*>::iterator i = this->SourceFiles.begin();
- i != this->SourceFiles.end(); ++i)
- {
- delete *i;
- }
- for(std::map<std::string, cmTest*>::iterator i = this->Tests.begin();
- i != this->Tests.end(); ++i)
- {
- delete i->second;
- }
- for(std::vector<cmTarget*>::iterator
- i = this->ImportedTargetsOwned.begin();
- i != this->ImportedTargetsOwned.end(); ++i)
- {
- delete *i;
- }
- for(unsigned int i=0; i < this->FinalPassCommands.size(); i++)
- {
- delete this->FinalPassCommands[i];
- }
- std::vector<cmFunctionBlocker*>::iterator pos;
- for (pos = this->FunctionBlockers.begin();
- pos != this->FunctionBlockers.end(); ++pos)
- {
- cmFunctionBlocker* b = *pos;
- delete b;
- }
+ cmDeleteAll(this->InstallGenerators);
+ cmDeleteAll(this->TestGenerators);
+ cmDeleteAll(this->SourceFiles);
+ cmDeleteAll(this->Tests);
+ cmDeleteAll(this->ImportedTargetsOwned);
+ cmDeleteAll(this->FinalPassCommands);
+ cmDeleteAll(this->FunctionBlockers);
this->FunctionBlockers.clear();
if (this->PolicyStack.size() != 1)
{
@@ -360,7 +331,7 @@ cmListFileBacktrace cmMakefile::GetBacktrace() const
//----------------------------------------------------------------------------
void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << lff.FilePath << "(" << lff.Line << "): ";
msg << lff.Name << "(";
for(std::vector<cmListFileArgument>::const_iterator i =
@@ -553,7 +524,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
case cmPolicies::WARN:
// Warn because the user did not set this policy.
{
- cmOStringStream w;
+ std::ostringstream w;
w << policies->GetPolicyWarning(cmPolicies::CMP0011) << "\n"
<< "The included script\n " << this->File << "\n"
<< "affects policy settings. "
@@ -565,7 +536,7 @@ void cmMakefile::IncludeScope::EnforceCMP0011()
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
{
- cmOStringStream e;
+ std::ostringstream e;
e << policies->GetRequiredPolicyError(cmPolicies::CMP0011) << "\n"
<< "The included script\n " << this->File << "\n"
<< "affects policy settings, so it requires this policy to be set.";
@@ -738,7 +709,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const
// Diagnose a violation of CMP0000 if necessary.
if(this->CheckCMP0000)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "No cmake_minimum_required command is present. "
<< "A line of code such as\n"
<< " cmake_minimum_required(VERSION "
@@ -878,12 +849,14 @@ void cmMakefile::ConfigureFinalPass()
//----------------------------------------------------------------------------
void
cmMakefile::AddCustomCommandToTarget(const std::string& target,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type,
const char* comment,
const char* workingDir,
- bool escapeOldStyle) const
+ bool escapeOldStyle,
+ bool uses_terminal)
{
// Find the target to which to add the custom command.
cmTargets::iterator ti = this->Targets.find(target);
@@ -892,7 +865,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
{
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
bool issueMessage = false;
- cmOStringStream e;
+ std::ostringstream e;
switch(this->GetPolicyStatus(cmPolicies::CMP0040))
{
case cmPolicies::WARN:
@@ -919,7 +892,7 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
if(ti->second.GetType() == cmTarget::OBJECT_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << target << "\" is an OBJECT library "
"that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -927,18 +900,30 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
}
if(ti->second.GetType() == cmTarget::INTERFACE_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << target << "\" is an INTERFACE library "
"that may not have PRE_BUILD, PRE_LINK, or POST_BUILD commands.";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
+
+ // Always create the byproduct sources and mark them generated.
+ for(std::vector<std::string>::const_iterator o = byproducts.begin();
+ o != byproducts.end(); ++o)
+ {
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
+ {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
+
// Add the command to the appropriate build step for the target.
std::vector<std::string> no_output;
- cmCustomCommand cc(this, no_output, depends,
+ cmCustomCommand cc(this, no_output, byproducts, depends,
commandLines, comment, workingDir);
cc.SetEscapeOldStyle(escapeOldStyle);
cc.SetEscapeAllowMakeVars(true);
+ cc.SetUsesTerminal(uses_terminal);
switch(type)
{
case cmTarget::PRE_BUILD:
@@ -956,13 +941,15 @@ cmMakefile::AddCustomCommandToTarget(const std::string& target,
//----------------------------------------------------------------------------
cmSourceFile*
cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment,
const char* workingDir,
bool replace,
- bool escapeOldStyle)
+ bool escapeOldStyle,
+ bool uses_terminal)
{
// Make sure there is at least one output.
if(outputs.empty())
@@ -978,7 +965,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
cmCustomCommandLine const& cl = *i;
if(!cl.empty() && !cl[0].empty() && cl[0][0] == '"')
{
- cmOStringStream e;
+ std::ostringstream e;
e << "COMMAND may not contain literal quotes:\n " << cl[0] << "\n";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
return 0;
@@ -1053,6 +1040,14 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
out->SetProperty("GENERATED", "1");
}
}
+ for(std::vector<std::string>::const_iterator o = byproducts.begin();
+ o != byproducts.end(); ++o)
+ {
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
+ {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
// Attach the custom command to the file.
if(file)
@@ -1065,10 +1060,11 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
}
cmCustomCommand* cc =
- new cmCustomCommand(this, outputs, depends2, commandLines,
- comment, workingDir);
+ new cmCustomCommand(this, outputs, byproducts, depends2,
+ commandLines, comment, workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true);
+ cc->SetUsesTerminal(uses_terminal);
file->SetCustomCommand(cc);
this->UpdateOutputToSourceMap(outputs, file);
}
@@ -1117,13 +1113,17 @@ cmMakefile::AddCustomCommandToOutput(const std::string& output,
const char* comment,
const char* workingDir,
bool replace,
- bool escapeOldStyle)
+ bool escapeOldStyle,
+ bool uses_terminal)
{
std::vector<std::string> outputs;
outputs.push_back(output);
- return this->AddCustomCommandToOutput(outputs, depends, main_dependency,
+ std::vector<std::string> no_byproducts;
+ return this->AddCustomCommandToOutput(outputs, no_byproducts,
+ depends, main_dependency,
commandLines, comment, workingDir,
- replace, escapeOldStyle);
+ replace, escapeOldStyle,
+ uses_terminal);
}
//----------------------------------------------------------------------------
@@ -1142,7 +1142,9 @@ cmMakefile::AddCustomCommandOldStyle(const std::string& target,
// In the old-style signature if the source and target were the
// same then it added a post-build rule to the target. Preserve
// this behavior.
- this->AddCustomCommandToTarget(target, depends, commandLines,
+ std::vector<std::string> no_byproducts;
+ this->AddCustomCommandToTarget(target, no_byproducts,
+ depends, commandLines,
cmTarget::POST_BUILD, comment, 0);
return;
}
@@ -1240,7 +1242,25 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
const char* workingDirectory,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
- bool escapeOldStyle, const char* comment)
+ bool escapeOldStyle, const char* comment,
+ bool uses_terminal)
+{
+ std::vector<std::string> no_byproducts;
+ return this->AddUtilityCommand(utilityName, excludeFromAll, workingDirectory,
+ no_byproducts, depends, commandLines,
+ escapeOldStyle, comment, uses_terminal);
+}
+
+//----------------------------------------------------------------------------
+cmTarget*
+cmMakefile::AddUtilityCommand(const std::string& utilityName,
+ bool excludeFromAll,
+ const char* workingDirectory,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines,
+ bool escapeOldStyle, const char* comment,
+ bool uses_terminal)
{
// Create a target instance for this utility.
cmTarget* target = this->AddNewTarget(cmTarget::UTILITY, utilityName);
@@ -1261,13 +1281,15 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
force += cmake::GetCMakeFilesDirectory();
force += "/";
force += utilityName;
+ std::vector<std::string> forced;
+ forced.push_back(force);
std::string no_main_dependency = "";
bool no_replace = false;
- this->AddCustomCommandToOutput(force, depends,
- no_main_dependency,
+ this->AddCustomCommandToOutput(forced, byproducts,
+ depends, no_main_dependency,
commandLines, comment,
workingDirectory, no_replace,
- escapeOldStyle);
+ escapeOldStyle, uses_terminal);
cmSourceFile* sf = target->AddSourceCMP0049(force);
// The output is not actually created so mark it symbolic.
@@ -1280,6 +1302,16 @@ cmMakefile::AddUtilityCommand(const std::string& utilityName,
cmSystemTools::Error("Could not get source file entry for ",
force.c_str());
}
+
+ // Always create the byproduct sources and mark them generated.
+ for(std::vector<std::string>::const_iterator o = byproducts.begin();
+ o != byproducts.end(); ++o)
+ {
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
+ {
+ out->SetProperty("GENERATED", "1");
+ }
+ }
}
return target;
}
@@ -1491,7 +1523,7 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
(tgt->GetType() == cmTarget::INTERFACE_LIBRARY) ||
tgt->IsExecutableWithExports()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << lib << "\" of type "
<< cmTarget::GetTargetTypeName(tgt->GetType())
<< " may not be linked into another target. "
@@ -1504,7 +1536,7 @@ void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Attempt to add link library \""
<< lib << "\" to target \""
<< target << "\" which is not built in this directory.";
@@ -1520,7 +1552,7 @@ void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
{
if(this->IsAlias(target))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "ALIAS target \"" << target << "\" "
<< "may not be linked into another target.";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1727,22 +1759,12 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
return;
}
- std::string incString;
- std::string sep;
-
- for(std::vector<std::string>::const_iterator li = incs.begin();
- li != incs.end(); ++li)
- {
- incString += sep + *li;
- sep = ";";
- }
-
std::vector<cmValueWithOrigin>::iterator position =
before ? this->IncludeDirectoriesEntries.begin()
: this->IncludeDirectoriesEntries.end();
cmListFileBacktrace lfbt = this->GetBacktrace();
- cmValueWithOrigin entry(incString, lfbt);
+ cmValueWithOrigin entry(cmJoin(incs, ";"), lfbt);
this->IncludeDirectoriesEntries.insert(position, entry);
// Property on each target:
@@ -1758,11 +1780,7 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
void
cmMakefile::AddSystemIncludeDirectories(const std::set<std::string> &incs)
{
- for(std::set<std::string>::const_iterator li = incs.begin();
- li != incs.end(); ++li)
- {
- this->SystemIncludeDirectories.insert(*li);
- }
+ this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
for (cmTargets::iterator l = this->Targets.begin();
l != this->Targets.end(); ++l)
@@ -1780,7 +1798,7 @@ void cmMakefile::AddDefinition(const std::string& name, const char* value)
}
this->Internal->VarStack.top().Set(name, value);
- if (this->Internal->VarUsageStack.size() &&
+ if (!this->Internal->VarUsageStack.empty() &&
this->VariableInitialized(name))
{
this->CheckForUnused("changing definition", name);
@@ -1830,7 +1848,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
{
if(!cmSystemTools::IsOff(files[cc].c_str()))
{
- files[cc] = cmSystemTools::CollapseFullPath(files[cc].c_str());
+ files[cc] = cmSystemTools::CollapseFullPath(files[cc]);
}
if ( cc > 0 )
{
@@ -1855,7 +1873,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
void cmMakefile::AddDefinition(const std::string& name, bool value)
{
this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
- if (this->Internal->VarUsageStack.size() &&
+ if (!this->Internal->VarUsageStack.empty() &&
this->VariableInitialized(name))
{
this->CheckForUnused("changing definition", name);
@@ -1919,7 +1937,7 @@ void cmMakefile::CheckForUnused(const char* reason,
{
std::string path;
cmListFileBacktrace bt(this->GetLocalGenerator());
- if (this->CallStack.size())
+ if (!this->CallStack.empty())
{
const cmListFileContext* file = this->CallStack.back().Context;
bt.push_back(*file);
@@ -1935,14 +1953,14 @@ void cmMakefile::CheckForUnused(const char* reason,
bt.push_back(lfc);
}
if (this->CheckSystemVars ||
- cmSystemTools::IsSubDirectory(path.c_str(),
+ cmSystemTools::IsSubDirectory(path,
this->GetHomeDirectory()) ||
- (cmSystemTools::IsSubDirectory(path.c_str(),
+ (cmSystemTools::IsSubDirectory(path,
this->GetHomeOutputDirectory()) &&
- !cmSystemTools::IsSubDirectory(path.c_str(),
+ !cmSystemTools::IsSubDirectory(path,
cmake::GetCMakeFilesDirectory())))
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "unused variable (" << reason << ") \'" << name << "\'";
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
msg.str(),
@@ -1954,7 +1972,7 @@ void cmMakefile::CheckForUnused(const char* reason,
void cmMakefile::RemoveDefinition(const std::string& name)
{
this->Internal->VarStack.top().Set(name, 0);
- if (this->Internal->VarUsageStack.size() &&
+ if (!this->Internal->VarUsageStack.empty() &&
this->VariableInitialized(name))
{
this->CheckForUnused("unsetting", name);
@@ -2247,7 +2265,7 @@ void cmMakefile::ExpandVariablesCMP0019()
{
return;
}
- cmOStringStream w;
+ std::ostringstream w;
const char *includeDirs = this->GetProperty("INCLUDE_DIRECTORIES");
if(mightExpandVariablesCMP0019(includeDirs))
@@ -2325,7 +2343,7 @@ void cmMakefile::ExpandVariablesCMP0019()
if(!w.str().empty())
{
- cmOStringStream m;
+ std::ostringstream m;
m << this->GetPolicies()->GetPolicyWarning(cmPolicies::CMP0019)
<< "\n"
<< "The following variable evaluations were encountered:\n"
@@ -2503,12 +2521,7 @@ std::vector<std::string> cmMakefile
}
std::vector<std::string> res;
-
- std::set<std::string>::iterator fit;
- for ( fit = definitions.begin(); fit != definitions.end(); fit ++ )
- {
- res.push_back(*fit);
- }
+ res.insert(res.end(), definitions.begin(), definitions.end());
return res;
}
@@ -2718,7 +2731,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringOld(
else
{
// Construct the main error message.
- cmOStringStream error;
+ std::ostringstream error;
error << "Syntax error in cmake code ";
if(filename && line > 0)
{
@@ -2826,7 +2839,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
case NORMAL:
if(filename && lookup == lineVar)
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << line;
varresult = ostr.str();
}
@@ -2868,7 +2881,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
cmSystemTools::IsSubDirectory(filename,
this->GetHomeOutputDirectory()))
{
- cmOStringStream msg;
+ std::ostringstream msg;
cmListFileBacktrace bt(this->GetLocalGenerator());
cmListFileContext lfc;
lfc.FilePath = filename;
@@ -2876,7 +2889,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
bt.push_back(lfc);
msg << "uninitialized variable \'" << lookup << "\'";
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str().c_str(), bt);
+ msg.str(), bt);
}
}
}
@@ -3062,7 +3075,7 @@ cmake::MessageType cmMakefile::ExpandVariablesInStringNew(
if(error)
{
- cmOStringStream emsg;
+ std::ostringstream emsg;
emsg << "Syntax error in cmake code ";
if(filename)
{
@@ -3277,7 +3290,7 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
{
// Report the context in which the unclosed block was opened.
cmListFileContext const& lfc = fb->GetStartingContext();
- cmOStringStream e;
+ std::ostringstream e;
e << "A logical block opening on the line\n"
<< " " << lfc << "\n"
<< "is not closed.";
@@ -3291,6 +3304,38 @@ void cmMakefile::PopFunctionBlockerBarrier(bool reportError)
}
//----------------------------------------------------------------------------
+void cmMakefile::PushLoopBlock()
+{
+ assert(!this->LoopBlockCounter.empty());
+ this->LoopBlockCounter.top()++;
+}
+
+void cmMakefile::PopLoopBlock()
+{
+ assert(!this->LoopBlockCounter.empty());
+ assert(this->LoopBlockCounter.top() > 0);
+ this->LoopBlockCounter.top()--;
+}
+
+void cmMakefile::PushLoopBlockBarrier()
+{
+ this->LoopBlockCounter.push(0);
+}
+
+void cmMakefile::PopLoopBlockBarrier()
+{
+ assert(!this->LoopBlockCounter.empty());
+ assert(this->LoopBlockCounter.top() == 0);
+ this->LoopBlockCounter.pop();
+}
+
+bool cmMakefile::IsLoopBlock() const
+{
+ assert(!this->LoopBlockCounter.empty());
+ return !this->LoopBlockCounter.empty() && this->LoopBlockCounter.top() > 0;
+}
+
+//----------------------------------------------------------------------------
bool cmMakefile::ExpandArguments(
std::vector<cmListFileArgument> const& inArgs,
std::vector<std::string>& outArgs) const
@@ -3403,7 +3448,7 @@ cmMakefile::RemoveFunctionBlocker(cmFunctionBlocker* fb,
if(!(*pos)->ShouldRemove(lff, *this))
{
cmListFileContext const& lfc = fb->GetStartingContext();
- cmOStringStream e;
+ std::ostringstream e;
e << "A logical block opening on the line\n"
<< " " << lfc << "\n"
<< "closes on the line\n"
@@ -3463,14 +3508,14 @@ void cmMakefile::SetScriptModeFile(const char* scriptfile)
void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
{
- cmOStringStream strStream;
+ std::ostringstream strStream;
strStream << args.size();
this->AddDefinition("CMAKE_ARGC", strStream.str().c_str());
//this->MarkVariableAsUsed("CMAKE_ARGC");
for (unsigned int t = 0; t < args.size(); ++t)
{
- cmOStringStream tmpStream;
+ std::ostringstream tmpStream;
tmpStream << "CMAKE_ARGV" << t;
this->AddDefinition(tmpStream.str(), args[t].c_str());
//this->MarkVariableAsUsed(tmpStream.str().c_str());
@@ -3554,7 +3599,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
{
this->Internal->IsSourceFileTryCompile = fast;
// does the binary directory exist ? If not create it...
- if (!cmSystemTools::FileIsDirectory(bindir.c_str()))
+ if (!cmSystemTools::FileIsDirectory(bindir))
{
cmSystemTools::MakeDirectory(bindir.c_str());
}
@@ -3562,7 +3607,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
// change to the tests directory and run cmake
// use the cmake object instead of calling cmake
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir.c_str());
+ cmSystemTools::ChangeDirectory(bindir);
// make sure the same generator is used
// use this program as the cmake to be run, it should not
@@ -3577,7 +3622,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmSystemTools::Error(
"Internal CMake error, TryCompile bad GlobalGenerator");
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return 1;
}
@@ -3651,7 +3696,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmSystemTools::Error(
"Internal CMake error, TryCompile configure of cmake failed");
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return 1;
}
@@ -3661,7 +3706,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
cmSystemTools::Error(
"Internal CMake error, TryCompile generation of cmake failed");
// return to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return 1;
}
@@ -3675,7 +3720,7 @@ int cmMakefile::TryCompile(const std::string& srcdir,
output,
this);
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
this->Internal->IsSourceFileTryCompile = false;
return ret;
}
@@ -3807,12 +3852,12 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
// from which we are being called is located itself in CMAKE_ROOT, then
// prefer results from CMAKE_ROOT depending on the policy setting.
result = moduleInCMakeModulePath;
- if (result.size() == 0)
+ if (result.empty())
{
result = moduleInCMakeRoot;
}
- if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0))
+ if (!moduleInCMakeModulePath.empty() && !moduleInCMakeRoot.empty())
{
const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
std::string mods = cmakeRoot + std::string("/Modules/");
@@ -3822,7 +3867,7 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
{
case cmPolicies::WARN:
{
- cmOStringStream e;
+ std::ostringstream e;
e << "File " << currentFile << " includes "
<< moduleInCMakeModulePath
<< " (found via CMAKE_MODULE_PATH) which shadows "
@@ -4002,7 +4047,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
if(bom != cmsys::FStream::BOM_None &&
bom != cmsys::FStream::BOM_UTF8)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "File starts with a Byte-Order-Mark that is not UTF-8:\n "
<< sinfile;
this->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -4034,7 +4079,7 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
{
cmSystemTools::SetPermissions(soutfile.c_str(), perm);
}
- cmSystemTools::RemoveFile(tempOutputFile.c_str());
+ cmSystemTools::RemoveFile(tempOutputFile);
}
return res;
}
@@ -4214,7 +4259,7 @@ const char *cmMakefile::GetProperty(const std::string& prop,
}
else if (prop == "LINK_DIRECTORIES")
{
- cmOStringStream str;
+ std::ostringstream str;
for (std::vector<std::string>::const_iterator
it = this->GetLinkDirectories().begin();
it != this->GetLinkDirectories().end();
@@ -4392,7 +4437,7 @@ void cmMakefile::AddCMakeDependFilesFromUser()
std::string cmMakefile::GetListFileStack() const
{
- cmOStringStream tmp;
+ std::ostringstream tmp;
size_t depth = this->ListFileStack.size();
if (depth > 0)
{
@@ -4424,10 +4469,24 @@ void cmMakefile::PushScope()
this->Internal->VarStack.push(cmDefinitions(parent));
this->Internal->VarInitStack.push(init);
this->Internal->VarUsageStack.push(usage);
+
+ this->PushLoopBlockBarrier();
+
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GetLocalGenerator()->GetGlobalGenerator()->
+ GetFileLockPool().PushFunctionScope();
+#endif
}
void cmMakefile::PopScope()
{
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ this->GetLocalGenerator()->GetGlobalGenerator()->
+ GetFileLockPool().PopFunctionScope();
+#endif
+
+ this->PopLoopBlockBarrier();
+
cmDefinitions* current = &this->Internal->VarStack.top();
std::set<std::string> init = this->Internal->VarInitStack.top();
std::set<std::string> usage = this->Internal->VarUsageStack.top();
@@ -4451,16 +4510,8 @@ void cmMakefile::PopScope()
this->Internal->VarInitStack.pop();
this->Internal->VarUsageStack.pop();
// Push initialization and usage up to the parent scope.
- it = init.begin();
- for (; it != init.end(); ++it)
- {
- this->Internal->VarInitStack.top().insert(*it);
- }
- it = usage.begin();
- for (; it != usage.end(); ++it)
- {
- this->Internal->VarUsageStack.top().insert(*it);
- }
+ this->Internal->VarInitStack.top().insert(init.begin(), init.end());
+ this->Internal->VarUsageStack.top().insert(usage.begin(), usage.end());
}
void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
@@ -4496,7 +4547,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
}
else
{
- cmOStringStream m;
+ std::ostringstream m;
m << "Cannot set \"" << var << "\": current scope has no parent.";
this->IssueMessage(cmake::AUTHOR_WARNING, m.str());
}
@@ -4591,7 +4642,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
{
if(this->IsAlias(name))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create target \"" << name
<< "\" because an alias with the same name already exists.";
msg = e.str();
@@ -4605,7 +4656,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
{
// Imported targets were not supported in previous versions.
// This is new code, so we can make it an error.
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create target \"" << name
<< "\" because an imported target with the same name already exists.";
msg = e.str();
@@ -4644,7 +4695,7 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
// Produce an error that tells the user how to work around the
// problem.
- cmOStringStream e;
+ std::ostringstream e;
e << "cannot create target \"" << name
<< "\" because another target with the same name already exists. "
<< "The existing target is ";
@@ -4690,7 +4741,7 @@ bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
{
return true;
}
- cmOStringStream e;
+ std::ostringstream e;
switch (this->GetPolicyStatus(cmPolicies::CMP0013))
{
case cmPolicies::WARN:
@@ -4741,6 +4792,64 @@ std::vector<cmSourceFile*> cmMakefile::GetQtUiFilesWithOptions() const
return this->QtUiFilesWithOptions;
}
+static std::string const matchVariables[] = {
+ "CMAKE_MATCH_0",
+ "CMAKE_MATCH_1",
+ "CMAKE_MATCH_2",
+ "CMAKE_MATCH_3",
+ "CMAKE_MATCH_4",
+ "CMAKE_MATCH_5",
+ "CMAKE_MATCH_6",
+ "CMAKE_MATCH_7",
+ "CMAKE_MATCH_8",
+ "CMAKE_MATCH_9"
+};
+
+static std::string const nMatchesVariable = "CMAKE_MATCH_COUNT";
+
+//----------------------------------------------------------------------------
+void cmMakefile::ClearMatches()
+{
+ const char* nMatchesStr = this->GetDefinition(nMatchesVariable);
+ if (!nMatchesStr)
+ {
+ return;
+ }
+ int nMatches = atoi(nMatchesStr);
+ for (int i=0; i<=nMatches; i++)
+ {
+ std::string const& var = matchVariables[i];
+ std::string const& s = this->GetSafeDefinition(var);
+ if(!s.empty())
+ {
+ this->AddDefinition(var, "");
+ this->MarkVariableAsUsed(var);
+ }
+ }
+ this->AddDefinition(nMatchesVariable, "0");
+ this->MarkVariableAsUsed(nMatchesVariable);
+}
+
+//----------------------------------------------------------------------------
+void cmMakefile::StoreMatches(cmsys::RegularExpression& re)
+{
+ char highest = 0;
+ for (int i=0; i<10; i++)
+ {
+ std::string const& m = re.match(i);
+ if(!m.empty())
+ {
+ std::string const& var = matchVariables[i];
+ this->AddDefinition(var, m.c_str());
+ this->MarkVariableAsUsed(var);
+ highest = static_cast<char>('0' + i);
+ }
+ }
+ char nMatches[] = {highest, '\0'};
+ this->AddDefinition(nMatchesVariable, nMatches);
+ this->MarkVariableAsUsed(nMatchesVariable);
+}
+
//----------------------------------------------------------------------------
cmPolicies::PolicyStatus
cmMakefile::GetPolicyStatus(cmPolicies::PolicyID id) const
@@ -4817,7 +4926,7 @@ bool cmMakefile::SetPolicy(const char *id,
cmPolicies::PolicyID pid;
if (!this->GetPolicies()->GetPolicyID(id, /* out */ pid))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Policy \"" << id << "\" is not known to this version of CMake.";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
@@ -5032,7 +5141,7 @@ AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
availableFeatures.end(),
feature) == availableFeatures.end())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The compiler feature \"" << feature
<< "\" is not known to " << lang << " compiler\n\""
<< this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
@@ -5072,7 +5181,7 @@ CompileFeatureKnown(cmTarget const* target, const std::string& feature,
lang = "CXX";
return true;
}
- cmOStringStream e;
+ std::ostringstream e;
if (error)
{
e << "specified";
@@ -5103,7 +5212,7 @@ CompileFeaturesAvailable(const std::string& lang, std::string *error) const
if (!featuresKnown || !*featuresKnown)
{
- cmOStringStream e;
+ std::ostringstream e;
if (error)
{
e << "no";
@@ -5144,6 +5253,27 @@ bool cmMakefile::
HaveCStandardAvailable(cmTarget const* target,
const std::string& feature) const
{
+ const char* defaultCStandard =
+ this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+ if (!defaultCStandard)
+ {
+ std::ostringstream e;
+ e << "CMAKE_C_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
+ "not fully configured for this compiler.";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ // Return true so the caller does not try to lookup the default standard.
+ return true;
+ }
+ if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
+ cmStrCmp(defaultCStandard)) == cmArrayEnd(C_STANDARDS))
+ {
+ std::ostringstream e;
+ e << "The CMAKE_C_STANDARD_DEFAULT variable contains an "
+ "invalid value: \"" << defaultCStandard << "\".";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ return false;
+ }
+
bool needC90 = false;
bool needC99 = false;
bool needC11 = false;
@@ -5153,16 +5283,16 @@ HaveCStandardAvailable(cmTarget const* target,
const char *existingCStandard = target->GetProperty("C_STANDARD");
if (!existingCStandard)
{
- existingCStandard = this->GetDefinition("CMAKE_C_STANDARD_DEFAULT");
+ existingCStandard = defaultCStandard;
}
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The C_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
@@ -5222,6 +5352,27 @@ bool cmMakefile::IsLaterStandard(std::string const& lang,
bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
const std::string& feature) const
{
+ const char* defaultCxxStandard =
+ this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+ if (!defaultCxxStandard)
+ {
+ std::ostringstream e;
+ e << "CMAKE_CXX_STANDARD_DEFAULT is not set. COMPILE_FEATURES support "
+ "not fully configured for this compiler.";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ // Return true so the caller does not try to lookup the default standard.
+ return true;
+ }
+ if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp(defaultCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
+ {
+ std::ostringstream e;
+ e << "The CMAKE_CXX_STANDARD_DEFAULT variable contains an "
+ "invalid value: \"" << defaultCxxStandard << "\".";
+ this->IssueMessage(cmake::INTERNAL_ERROR, e.str());
+ return false;
+ }
+
bool needCxx98 = false;
bool needCxx11 = false;
bool needCxx14 = false;
@@ -5230,13 +5381,13 @@ bool cmMakefile::HaveCxxStandardAvailable(cmTarget const* target,
const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
if (!existingCxxStandard)
{
- existingCxxStandard = this->GetDefinition("CMAKE_CXX_STANDARD_DEFAULT");
+ existingCxxStandard = defaultCxxStandard;
}
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The CXX_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCxxStandard << "\".";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -5311,7 +5462,7 @@ AddRequiredTargetCxxFeature(cmTarget *target,
if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The CXX_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCxxStandard << "\".";
this->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -5410,10 +5561,10 @@ AddRequiredTargetCFeature(cmTarget *target, const std::string& feature) const
if (std::find_if(cmArrayBegin(C_STANDARDS), cmArrayEnd(C_STANDARDS),
cmStrCmp(existingCStandard)) == cmArrayEnd(C_STANDARDS))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The C_STANDARD property on target \"" << target->GetName()
<< "\" contained an invalid value: \"" << existingCStandard << "\".";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 24a4f00..bff8c12 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -34,6 +34,8 @@
# include <cmsys/hash_map.hxx>
#endif
+#include <stack>
+
class cmFunctionBlocker;
class cmCommand;
class cmInstallGenerator;
@@ -123,6 +125,15 @@ public:
};
friend class LexicalPushPop;
+ class LoopBlockPop
+ {
+ public:
+ LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; }
+ ~LoopBlockPop() { this->Makefile->PopLoopBlock(); }
+ private:
+ cmMakefile* Makefile;
+ };
+
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
@@ -170,19 +181,23 @@ public:
/** Add a custom command to the build. */
void AddCustomCommandToTarget(const std::string& target,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type,
const char* comment, const char* workingDir,
- bool escapeOldStyle = true) const;
+ bool escapeOldStyle = true,
+ bool uses_terminal = false);
cmSourceFile* AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
+ const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment, const char* workingDir,
bool replace = false,
- bool escapeOldStyle = true);
+ bool escapeOldStyle = true,
+ bool uses_terminal = false);
cmSourceFile* AddCustomCommandToOutput(
const std::string& output,
const std::vector<std::string>& depends,
@@ -190,7 +205,8 @@ public:
const cmCustomCommandLines& commandLines,
const char* comment, const char* workingDir,
bool replace = false,
- bool escapeOldStyle = true);
+ bool escapeOldStyle = true,
+ bool uses_terminal = false);
void AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
@@ -237,7 +253,17 @@ public:
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle = true,
- const char* comment = 0);
+ const char* comment = 0,
+ bool uses_terminal = false);
+ cmTarget* AddUtilityCommand(const std::string& utilityName,
+ bool excludeFromAll,
+ const char* workingDirectory,
+ const std::vector<std::string>& byproducts,
+ const std::vector<std::string>& depends,
+ const cmCustomCommandLines& commandLines,
+ bool escapeOldStyle = true,
+ const char* comment = 0,
+ bool uses_terminal = false);
/**
* Add a link library to the build.
@@ -466,7 +492,7 @@ public:
this->cmStartDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
this->cmStartDirectory =
- cmSystemTools::CollapseFullPath(this->cmStartDirectory.c_str());
+ cmSystemTools::CollapseFullPath(this->cmStartDirectory);
this->AddDefinition("CMAKE_CURRENT_SOURCE_DIR",
this->cmStartDirectory.c_str());
}
@@ -479,7 +505,7 @@ public:
this->StartOutputDirectory = lib;
cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
this->StartOutputDirectory =
- cmSystemTools::CollapseFullPath(this->StartOutputDirectory.c_str());
+ cmSystemTools::CollapseFullPath(this->StartOutputDirectory);
cmSystemTools::MakeDirectory(this->StartOutputDirectory.c_str());
this->AddDefinition("CMAKE_CURRENT_BINARY_DIR",
this->StartOutputDirectory.c_str());
@@ -885,6 +911,10 @@ public:
void PopScope();
void RaiseScope(const std::string& var, const char *value);
+ // push and pop loop scopes
+ void PushLoopBlockBarrier();
+ void PopLoopBlockBarrier();
+
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
{
@@ -942,6 +972,13 @@ public:
std::string const& lhs,
std::string const& rhs);
+ void PushLoopBlock();
+ void PopLoopBlock();
+ bool IsLoopBlock() const;
+
+ void ClearMatches();
+ void StoreMatches(cmsys::RegularExpression& re);
+
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
@@ -1036,6 +1073,8 @@ private:
void PushFunctionBlockerBarrier();
void PopFunctionBlockerBarrier(bool reportError = true);
+ std::stack<int> LoopBlockCounter;
+
typedef std::map<std::string, std::string> StringStringMap;
StringStringMap MacrosMap;
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index fc52ccc..d4036d2 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -371,8 +371,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string targetVersionMajor;
std::string targetVersionMinor;
{
- cmOStringStream majorStream;
- cmOStringStream minorStream;
+ std::ostringstream majorStream;
+ std::ostringstream minorStream;
int major;
int minor;
this->Target->GetTargetVersion(major, minor);
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 80473f6..cdda36c 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -566,8 +566,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string targetVersionMajor;
std::string targetVersionMinor;
{
- cmOStringStream majorStream;
- cmOStringStream minorStream;
+ std::ostringstream majorStream;
+ std::ostringstream minorStream;
int major;
int minor;
this->Target->GetTargetVersion(major, minor);
@@ -752,26 +752,23 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->Target);
}
- // Write the build rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- targetFullPathReal,
- depends, commands, false);
-
- // Some targets have more than one output file. Create rules to
- // drive the build if any extra outputs are missing.
- std::vector<std::string> extraOutputs;
+ // Compute the list of outputs.
+ std::vector<std::string> outputs(1, targetFullPathReal);
if(targetNameSO != targetNameReal)
{
- this->GenerateExtraOutput(targetFullPathSO.c_str(),
- targetFullPathReal.c_str());
+ outputs.push_back(targetFullPathSO);
}
if(targetName != targetNameSO &&
targetName != targetNameReal)
{
- this->GenerateExtraOutput(targetFullPath.c_str(),
- targetFullPathReal.c_str());
+ outputs.push_back(targetFullPath);
}
+ // Write the build rule.
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
+ outputs, depends, commands, false);
+
+
// Write the main driver rule to build everything in this target.
this->WriteTargetDriverRule(targetFullPath, relink);
@@ -808,7 +805,7 @@ cmMakefileLibraryTargetGenerator
if(major > 0 || minor > 0 || patch > 0)
{
// Append the flag since a non-zero version is specified.
- cmOStringStream vflag;
+ std::ostringstream vflag;
vflag << flag << major << "." << minor << "." << patch;
this->LocalGenerator->AppendFlags(flags, vflag.str());
}
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 85e371d..7ed0c10 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -451,7 +451,7 @@ void cmMakefileTargetGenerator
}
else
{
- cmOStringStream err;
+ std::ostringstream err;
err << "Warning: Source file \""
<< source.GetFullPath()
<< "\" is listed multiple times for target \""
@@ -702,7 +702,14 @@ cmMakefileTargetGenerator
vars.Defines = definesString.c_str();
- bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX"));
+ // At the moment, it is assumed that C, C++, and Fortran have both
+ // assembly and preprocessor capabilities. The same is true for the
+ // ability to export compile commands
+ bool lang_has_preprocessor = ((lang == "C") ||
+ (lang == "CXX") ||
+ (lang == "Fortran"));
+ bool const lang_has_assembly = lang_has_preprocessor;
+ bool const lang_can_export_cmds = lang_has_preprocessor;
// Construct the compile rules.
{
@@ -715,7 +722,7 @@ cmMakefileTargetGenerator
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") &&
- lang_is_c_or_cxx && compileCommands.size() == 1)
+ lang_can_export_cmds && compileCommands.size() == 1)
{
std::string compileCommand = compileCommands[0];
this->LocalGenerator->ExpandRuleVariables(compileCommand, vars);
@@ -747,33 +754,24 @@ cmMakefileTargetGenerator
compileCommands.begin(), compileCommands.end());
}
- // Write the rule.
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObj,
- depends, commands, false);
-
// Check for extra outputs created by the compilation.
+ std::vector<std::string> outputs(1, relativeObj);
if(const char* extra_outputs_str =
source.GetProperty("OBJECT_OUTPUTS"))
{
- std::vector<std::string> extra_outputs;
- cmSystemTools::ExpandListArgument(extra_outputs_str, extra_outputs);
- for(std::vector<std::string>::const_iterator eoi = extra_outputs.begin();
- eoi != extra_outputs.end(); ++eoi)
- {
- // Register this as an extra output for the object file rule.
- // This will cause the object file to be rebuilt if the extra
- // output is missing.
- this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false);
-
- // Register this as an extra file to clean.
- this->CleanFiles.push_back(*eoi);
- }
+ // Register these as extra files to clean.
+ cmSystemTools::ExpandListArgument(extra_outputs_str, outputs);
+ this->CleanFiles.insert(this->CleanFiles.end(),
+ outputs.begin() + 1, outputs.end());
}
- bool do_preprocess_rules = lang_is_c_or_cxx &&
+ // Write the rule.
+ this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
+ outputs, depends, commands, false);
+
+ bool do_preprocess_rules = lang_has_preprocessor &&
this->LocalGenerator->GetCreatePreprocessedSourceRules();
- bool do_assembly_rules = lang_is_c_or_cxx &&
+ bool do_assembly_rules = lang_has_assembly &&
this->LocalGenerator->GetCreateAssemblySourceRules();
if(do_preprocess_rules || do_assembly_rules)
{
@@ -1010,25 +1008,6 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
this->LocalGenerator->
WriteDependLanguageInfo(*this->InfoFileStream,*this->Target);
- // Store multiple output pairs in the depend info file.
- if(!this->MultipleOutputPairs.empty())
- {
- *this->InfoFileStream
- << "\n"
- << "# Pairs of files generated by the same build rule.\n"
- << "set(CMAKE_MULTIPLE_OUTPUT_PAIRS\n";
- for(MultipleOutputPairsType::const_iterator pi =
- this->MultipleOutputPairs.begin();
- pi != this->MultipleOutputPairs.end(); ++pi)
- {
- *this->InfoFileStream
- << " " << this->LocalGenerator->EscapeForCMake(pi->first)
- << " " << this->LocalGenerator->EscapeForCMake(pi->second)
- << "\n";
- }
- *this->InfoFileStream << " )\n\n";
- }
-
// Store list of targets linked directly or transitively.
{
*this->InfoFileStream
@@ -1119,7 +1098,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// Add a command to call CMake to scan dependencies. CMake will
// touch the corresponding depends file after scanning dependencies.
- cmOStringStream depCmd;
+ std::ostringstream depCmd;
// TODO: Account for source file properties and directory-level
// definitions when scanning for dependencies.
#if !defined(_WIN32) || defined(__CYGWIN__)
@@ -1192,11 +1171,7 @@ cmMakefileTargetGenerator
{
cmCustomCommandGenerator ccg(*cc, this->ConfigName, this->Makefile);
const std::vector<std::string>& outputs = ccg.GetOutputs();
- for(std::vector<std::string>::const_iterator o = outputs.begin();
- o != outputs.end(); ++o)
- {
- depends.push_back(*o);
- }
+ depends.insert(depends.end(), outputs.begin(), outputs.end());
}
}
}
@@ -1211,13 +1186,7 @@ void cmMakefileTargetGenerator
depends.push_back(source.GetFullPath());
if(const char* objectDeps = source.GetProperty("OBJECT_DEPENDS"))
{
- std::vector<std::string> deps;
- cmSystemTools::ExpandListArgument(objectDeps, deps);
- for(std::vector<std::string>::iterator i = deps.begin();
- i != deps.end(); ++i)
- {
- depends.push_back(*i);
- }
+ cmSystemTools::ExpandListArgument(objectDeps, depends);
}
}
@@ -1241,7 +1210,7 @@ void cmMakefileTargetGenerator
}
// Now append the actual user-specified commands.
- cmOStringStream content;
+ std::ostringstream content;
this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false,
cmLocalGenerator::HOME_OUTPUT,
&content);
@@ -1266,7 +1235,7 @@ void cmMakefileTargetGenerator
}
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- *o, depends, commands,
+ outputs, depends, commands,
symbolic);
// If the rule has changed make sure the output is rebuilt.
@@ -1276,21 +1245,6 @@ void cmMakefileTargetGenerator
}
}
- // Write rules to drive building any outputs beyond the first.
- const char* in = o->c_str();
- for(++o; o != outputs.end(); ++o)
- {
- bool symbolic = false;
- if(need_symbolic)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(*o))
- {
- symbolic = sf->GetPropertyAsBool("SYMBOLIC");
- }
- }
- this->GenerateExtraOutput(o->c_str(), in, symbolic);
- }
-
// Setup implicit dependency scanning.
for(cmCustomCommand::ImplicitDependsList::const_iterator
idi = ccg.GetCC().GetImplicitDepends().begin();
@@ -1309,32 +1263,6 @@ void cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void
-cmMakefileTargetGenerator
-::GenerateExtraOutput(const char* out, const char* in, bool symbolic)
-{
- // Add a rule to build the primary output if the extra output needs
- // to be created.
- std::vector<std::string> commands;
- std::vector<std::string> depends;
- std::string emptyCommand = this->GlobalGenerator->GetEmptyRuleHackCommand();
- if(!emptyCommand.empty())
- {
- commands.push_back(emptyCommand);
- }
- depends.push_back(in);
- this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- out, depends, commands,
- symbolic);
-
- // Register the extra output as paired with the first output so that
- // the check-build-system step will remove the primary output if any
- // extra outputs are missing. This forces the rule to regenerate
- // all outputs.
- this->AddMultipleOutputPair(out, in);
-}
-
-//----------------------------------------------------------------------------
-void
cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
{
this->NumberOfProgressActions++;
@@ -1344,7 +1272,7 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
}
std::string progressDir = this->Makefile->GetHomeOutputDirectory();
progressDir += cmake::GetCMakeFilesDirectory();
- cmOStringStream progCmd;
+ std::ostringstream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
progCmd << this->LocalGenerator->Convert(progressDir,
cmLocalGenerator::FULL,
@@ -1527,11 +1455,8 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(
}
// Make sure the extra files are built.
- for(std::set<std::string>::const_iterator i = this->ExtraFiles.begin();
- i != this->ExtraFiles.end(); ++i)
- {
- depends.push_back(*i);
- }
+ depends.insert(depends.end(),
+ this->ExtraFiles.begin(), this->ExtraFiles.end());
}
// Write the driver rule.
@@ -1577,7 +1502,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
{
std::string frameworkDir = *i;
frameworkDir += "/../";
- frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
+ frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir);
emitted.insert(frameworkDir);
}
}
@@ -1618,11 +1543,7 @@ void cmMakefileTargetGenerator
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg))
{
std::vector<std::string> const& libDeps = cli->GetDepends();
- for(std::vector<std::string>::const_iterator j = libDeps.begin();
- j != libDeps.end(); ++j)
- {
- depends.push_back(*j);
- }
+ depends.insert(depends.end(), libDeps.begin(), libDeps.end());
}
}
@@ -1642,12 +1563,8 @@ void cmMakefileTargetGenerator
}
// Add dependencies on the external object files.
- for(std::vector<std::string>::const_iterator obj
- = this->ExternalObjects.begin();
- obj != this->ExternalObjects.end(); ++obj)
- {
- depends.push_back(*obj);
- }
+ depends.insert(depends.end(),
+ this->ExternalObjects.begin(), this->ExternalObjects.end());
// Add a dependency on the rule file itself.
this->LocalGenerator->AppendRuleDepend(depends,
@@ -1763,15 +1680,6 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
-::AddMultipleOutputPair(const char* depender, const char* dependee)
-{
- MultipleOutputPairsType::value_type p(depender, dependee);
- this->MultipleOutputPairs.insert(p);
-}
-
-//----------------------------------------------------------------------------
-void
-cmMakefileTargetGenerator
::CreateLinkScript(const char* name,
std::vector<std::string> const& link_commands,
std::vector<std::string>& makefile_commands,
@@ -1962,7 +1870,8 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
- lang, false, useResponseFile);
+ lang, false, useResponseFile,
+ config);
if(includeFlags.empty())
{
return;
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 9fac574..e31e086 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -142,15 +142,6 @@ protected:
// Lookup the link rule for this target.
std::string GetLinkRule(const std::string& linkRuleVar);
- /** In order to support parallel builds for custom commands with
- multiple outputs the outputs are given a serial order, and only
- the first output actually has the build rule. Other outputs
- just depend on the first one. The check-build-system step must
- remove a dependee if the depender is missing to make sure both
- are regenerated properly. This method is used by the local
- makefile generators to register such pairs. */
- void AddMultipleOutputPair(const char* depender, const char* dependee);
-
/** Create a script to hold link rules and a command to invoke the
script at build time. */
void CreateLinkScript(const char* name,
@@ -231,9 +222,6 @@ protected:
// Set of extra output files to be driven by the build.
std::set<std::string> ExtraFiles;
- typedef std::map<std::string, std::string> MultipleOutputPairsType;
- MultipleOutputPairsType MultipleOutputPairs;
-
// Target name info.
std::string TargetNameOut;
std::string TargetNameSO;
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index a05719d..c352c1a 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -22,6 +22,7 @@
#include <assert.h>
#include <algorithm>
+#include <limits>
#ifndef _WIN32
#include <unistd.h>
@@ -207,12 +208,7 @@ cmNinjaNormalTargetGenerator
vars.ObjectDir = "$OBJECT_DIR";
- // TODO:
- // Makefile generator expands <TARGET> to the plain target name
- // with suffix. $out expands to a relative path. This difference
- // could make trouble when switching to Ninja generator. Maybe
- // using TARGET_NAME and RuleVariables::TargetName is a fix.
- vars.Target = "$out";
+ vars.Target = "$TARGET_FILE";
vars.SONameFlag = "$SONAME_FLAG";
vars.TargetSOName = "$SONAME";
@@ -223,8 +219,8 @@ cmNinjaNormalTargetGenerator
std::string targetVersionMajor;
std::string targetVersionMinor;
{
- cmOStringStream majorStream;
- cmOStringStream minorStream;
+ std::ostringstream majorStream;
+ std::ostringstream minorStream;
int major;
int minor;
this->GetTarget()->GetTargetVersion(major, minor);
@@ -260,12 +256,12 @@ cmNinjaNormalTargetGenerator
this->GetLocalGenerator()->BuildCommandLine(linkCmds);
// Write the linker rule with response file if needed.
- cmOStringStream comment;
+ std::ostringstream comment;
comment << "Rule for linking " << this->TargetLinkLanguage << " "
<< this->GetVisibleTypeName() << ".";
- cmOStringStream description;
+ std::ostringstream description;
description << "Linking " << this->TargetLinkLanguage << " "
- << this->GetVisibleTypeName() << " $out";
+ << this->GetVisibleTypeName() << " $TARGET_FILE";
this->GetGlobalGenerator()->AddRule(ruleName,
linkCmd,
description.str(),
@@ -274,7 +270,7 @@ cmNinjaNormalTargetGenerator
/*deptype*/ "",
rspfile,
rspcontent,
- /*restat*/ false,
+ /*restat*/ "$RESTAT",
/*generator*/ false);
}
@@ -296,7 +292,7 @@ cmNinjaNormalTargetGenerator
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
- /*restat*/ false,
+ /*restat*/ "",
/*generator*/ false);
else
this->GetGlobalGenerator()->AddRule("CMAKE_SYMLINK_LIBRARY",
@@ -310,7 +306,7 @@ cmNinjaNormalTargetGenerator
/*deptype*/ "",
/*rspfile*/ "",
/*rspcontent*/ "",
- /*restat*/ false,
+ /*restat*/ "",
/*generator*/ false);
}
}
@@ -339,7 +335,7 @@ cmNinjaNormalTargetGenerator
this->GetLocalGenerator()->ConvertToOutputFormat(
mf->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL);
- linkCmds.push_back(cmakeCommand + " -E remove $out");
+ linkCmds.push_back(cmakeCommand + " -E remove $TARGET_FILE");
}
// TODO: Use ARCHIVE_APPEND for archives over a certain size.
{
@@ -371,15 +367,29 @@ cmNinjaNormalTargetGenerator
static int calculateCommandLineLengthLimit(int linkRuleLength)
{
+ static int const limits[] = {
#ifdef _WIN32
- return 8000 - linkRuleLength;
-#elif defined(__linux) || defined(__APPLE__) || defined(__HAIKU__)
- // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
- return ((int)sysconf(_SC_ARG_MAX)) - linkRuleLength - 1000;
-#else
- (void)linkRuleLength;
- return -1;
+ 8000,
#endif
+#if defined(__APPLE__) || defined(__HAIKU__) || defined(__linux)
+ // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
+ ((int)sysconf(_SC_ARG_MAX)) - 1000,
+#endif
+#if defined(__linux)
+ // #define MAX_ARG_STRLEN (PAGE_SIZE * 32) in Linux's binfmts.h
+ ((int)sysconf(_SC_PAGESIZE) * 32) - 1000,
+#endif
+ std::numeric_limits<int>::max()
+ };
+
+ size_t const arrSz = cmArraySize(limits);
+ int const sz = *std::min_element(limits, limits + arrSz);
+ if (sz == std::numeric_limits<int>::max())
+ {
+ return -1;
+ }
+
+ return sz - linkRuleLength;
}
@@ -388,14 +398,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmTarget& target = *this->GetTarget();
const std::string cfgName = this->GetConfigName();
std::string targetOutput = ConvertToNinjaPath(
- target.GetFullPath(cfgName).c_str());
+ target.GetFullPath(cfgName));
std::string targetOutputReal = ConvertToNinjaPath(
target.GetFullPath(cfgName,
/*implib=*/false,
- /*realpath=*/true).c_str());
+ /*realpath=*/true));
std::string targetOutputImplib = ConvertToNinjaPath(
target.GetFullPath(cfgName,
- /*implib=*/true).c_str());
+ /*implib=*/true));
if (target.IsAppBundleOnApple())
{
@@ -407,11 +417,11 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
targetOutput = outpath;
targetOutput += "/";
targetOutput += this->TargetNameOut;
- targetOutput = this->ConvertToNinjaPath(targetOutput.c_str());
+ targetOutput = this->ConvertToNinjaPath(targetOutput);
targetOutputReal = outpath;
targetOutputReal += "/";
targetOutputReal += this->TargetNameReal;
- targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
+ targetOutputReal = this->ConvertToNinjaPath(targetOutputReal);
}
else if (target.IsFrameworkOnApple())
{
@@ -440,7 +450,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmNinjaVars vars;
// Compute the comment.
- cmOStringStream comment;
+ std::ostringstream comment;
comment <<
"Link the " << this->GetVisibleTypeName() << " " << targetOutputReal;
@@ -463,6 +473,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
this->GetConfigName());
bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
+
+ vars["TARGET_FILE"] =
+ localGen.ConvertToOutputFormat(targetOutputReal, cmLocalGenerator::SHELL);
+
localGen.GetTargetFlags(vars["LINK_LIBRARIES"],
vars["FLAGS"],
vars["LINK_FLAGS"],
@@ -522,6 +536,10 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmLocalGenerator::SHELL);
vars["TARGET_IMPLIB"] = impLibPath;
EnsureParentDirectoryExists(impLibPath);
+ if(target.HasImportLibrary())
+ {
+ outputs.push_back(targetOutputImplib);
+ }
}
if (!this->SetMsvcTargetPdbVariable(vars))
@@ -544,7 +562,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
if (mf->IsOn("CMAKE_COMPILER_IS_MINGW"))
{
const std::string objPath = GetTarget()->GetSupportDirectory();
- vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath.c_str());
+ vars["OBJECT_DIR"] = ConvertToNinjaPath(objPath);
EnsureDirectoryExists(objPath);
// ar.exe can't handle backslashes in rsp files (implicitly used by gcc)
std::string& linkLibraries = vars["LINK_LIBRARIES"];
@@ -566,6 +584,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
&postBuildCmdLines
};
+ cmNinjaDeps byproducts;
for (unsigned i = 0; i != 3; ++i)
{
for (std::vector<cmCustomCommand>::const_iterator
@@ -574,6 +593,9 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
{
cmCustomCommandGenerator ccg(*ci, cfgName, mf);
localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
+ std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
+ std::transform(ccByproducts.begin(), ccByproducts.end(),
+ std::back_inserter(byproducts), MapToNinjaPath());
}
}
@@ -621,6 +643,17 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
this->GetLocalGenerator()->AppendTargetDepends(this->GetTarget(),
orderOnlyDeps);
+ // Ninja should restat after linking if and only if there are byproducts.
+ vars["RESTAT"] = byproducts.empty()? "" : "1";
+
+ for (cmNinjaDeps::const_iterator oi = byproducts.begin(),
+ oe = byproducts.end();
+ oi != oe; ++oi)
+ {
+ this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
+ outputs.push_back(*oi);
+ }
+
// Write the build statement for this target.
globalGen.WriteBuild(this->GetBuildFileStream(),
comment.str(),
@@ -672,16 +705,6 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
}
}
- if (!this->TargetNameImport.empty())
- {
- // Since using multiple outputs would mess up the $out variable, use an
- // alias for the import library.
- globalGen.WritePhonyBuild(this->GetBuildFileStream(),
- "Alias for import library.",
- cmNinjaDeps(1, targetOutputImplib),
- cmNinjaDeps(1, targetOutputReal));
- }
-
// Add aliases for the file name and the target name.
globalGen.AddTargetAlias(this->TargetNameOut, &target);
globalGen.AddTargetAlias(this->GetTargetName(), &target);
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 33000d6..cfd8937 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -170,8 +170,10 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
language,
- language == "RC" ? true : false); // full include paths for RC
+ language == "RC" ? true : false, // full include paths for RC
// needed by cmcldeps
+ false,
+ this->GetConfigName());
if(cmGlobalNinjaGenerator::IsMinGW())
cmSystemTools::ReplaceString(includeFlags, "\\", "/");
@@ -198,21 +200,21 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
return flags;
}
-
-bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang)
+bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
{
- cmMakefile* mf = this->GetMakefile();
-
- const bool usingMSVC = std::string("MSVC") ==
- (mf->GetDefinition("CMAKE_C_COMPILER_ID") ?
- mf->GetSafeDefinition("CMAKE_C_COMPILER_ID") :
- mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"));
-
- return !usingMSVC || lang == "RC";
+ if (lang == "C" || lang == "CXX")
+ {
+ cmMakefile* mf = this->GetMakefile();
+ return (
+ strcmp(mf->GetSafeDefinition("CMAKE_C_COMPILER_ID"), "MSVC") == 0 ||
+ strcmp(mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID"), "MSVC") == 0 ||
+ strcmp(mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID"), "MSVC") == 0 ||
+ strcmp(mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID"), "MSVC") == 0
+ );
+ }
+ return false;
}
-
-
// TODO: Refactor with
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
std::string
@@ -277,7 +279,7 @@ std::string
cmNinjaTargetGenerator
::GetSourceFilePath(cmSourceFile const* source) const
{
- return ConvertToNinjaPath(source->GetFullPath().c_str());
+ return ConvertToNinjaPath(source->GetFullPath());
}
std::string
@@ -298,7 +300,7 @@ cmNinjaTargetGenerator
std::string cmNinjaTargetGenerator::GetTargetOutputDir() const
{
std::string dir = this->Target->GetDirectory(this->GetConfigName());
- return ConvertToNinjaPath(dir.c_str());
+ return ConvertToNinjaPath(dir);
}
std::string
@@ -346,11 +348,11 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
}
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(pdbPath.c_str()),
+ ConvertToNinjaPath(pdbPath),
cmLocalGenerator::SHELL);
vars["TARGET_COMPILE_PDB"] =
this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(compilePdbPath.c_str()),
+ ConvertToNinjaPath(compilePdbPath),
cmLocalGenerator::SHELL);
EnsureParentDirectoryExists(pdbPath);
@@ -389,22 +391,22 @@ cmNinjaTargetGenerator
cmMakefile* mf = this->GetMakefile();
- const std::string cId = mf->GetDefinition("CMAKE_C_COMPILER_ID")
- ? mf->GetSafeDefinition("CMAKE_C_COMPILER_ID")
- : mf->GetSafeDefinition("CMAKE_CXX_COMPILER_ID");
- const std::string sId = mf->GetDefinition("CMAKE_C_SIMULATE_ID")
- ? mf->GetSafeDefinition("CMAKE_C_SIMULATE_ID")
- : mf->GetSafeDefinition("CMAKE_CXX_SIMULATE_ID");
- const bool usingMSVC = (cId == "MSVC" || sId == "MSVC");
-
// Tell ninja dependency format so all deps can be loaded into a database
std::string deptype;
std::string depfile;
std::string cldeps;
std::string flags = "$FLAGS";
- if (usingMSVC)
+ if (this->NeedDepTypeMSVC(lang))
+ {
+ deptype = "msvc";
+ depfile = "";
+ flags += " /showIncludes";
+ }
+ else if (lang == "RC" && this->NeedDepTypeMSVC("C"))
{
- if (!mf->GetIsSourceFileTryCompile() && lang == "RC")
+ // For the MS resource compiler we need cmcldeps, but skip dependencies
+ // for source-file try_compile cases because they are always fresh.
+ if (!mf->GetIsSourceFileTryCompile())
{
deptype = "gcc";
depfile = "$DEP_FILE";
@@ -417,12 +419,6 @@ cmNinjaTargetGenerator
cldeps += mf->GetSafeDefinition("CMAKE_CL_SHOWINCLUDES_PREFIX");
cldeps += "\" \"" + cl + "\" ";
}
- else
- {
- deptype = "msvc";
- depfile = "";
- flags += " /showIncludes";
- }
}
else
{
@@ -468,9 +464,9 @@ cmNinjaTargetGenerator
// Write the rule for compiling file of the given language.
- cmOStringStream comment;
+ std::ostringstream comment;
comment << "Rule for compiling " << lang << " files.";
- cmOStringStream description;
+ std::ostringstream description;
description << "Building " << lang << " object $out";
this->GetGlobalGenerator()->AddRule(this->LanguageCompilerRule(lang),
cmdLine,
@@ -480,7 +476,7 @@ cmNinjaTargetGenerator
deptype,
/*rspfile*/ "",
/*rspcontent*/ "",
- /*restat*/ false,
+ /*restat*/ "",
/*generator*/ false);
}
@@ -541,8 +537,11 @@ cmNinjaTargetGenerator
cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
this->GetMakefile());
const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
+ const std::vector<std::string>& ccbyproducts= ccg.GetByproducts();
std::transform(ccoutputs.begin(), ccoutputs.end(),
std::back_inserter(orderOnlyDeps), MapToNinjaPath());
+ std::transform(ccbyproducts.begin(), ccbyproducts.end(),
+ std::back_inserter(orderOnlyDeps), MapToNinjaPath());
}
if (!orderOnlyDeps.empty())
@@ -567,7 +566,7 @@ cmNinjaTargetGenerator
std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
if(!def.empty())
{
- this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
+ this->ModuleDefinitionFile = this->ConvertToNinjaPath(def);
}
this->GetBuildFileStream() << "\n";
@@ -631,7 +630,7 @@ cmNinjaTargetGenerator
cmNinjaVars vars;
vars["FLAGS"] = this->ComputeFlagsForObject(source, language);
vars["DEFINES"] = this->ComputeDefines(source, language);
- if (needsDepFile(language)) {
+ if (!this->NeedDepTypeMSVC(language)) {
vars["DEP_FILE"] =
cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");
}
@@ -639,11 +638,11 @@ cmNinjaTargetGenerator
std::string objectDir = this->Target->GetSupportDirectory();
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(objectDir.c_str()),
+ ConvertToNinjaPath(objectDir),
cmLocalGenerator::SHELL);
std::string objectFileDir = cmSystemTools::GetFilenamePath(objectFileName);
vars["OBJECT_FILE_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(objectFileDir.c_str()),
+ ConvertToNinjaPath(objectFileDir),
cmLocalGenerator::SHELL);
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars);
@@ -661,7 +660,7 @@ cmNinjaTargetGenerator
if (!cmSystemTools::FileIsFullPath(sourceFileName.c_str()))
{
escapedSourceFileName = cmSystemTools::CollapseFullPath(
- escapedSourceFileName.c_str(),
+ escapedSourceFileName,
this->GetGlobalGenerator()->GetCMakeInstance()->
GetHomeOutputDirectory());
}
@@ -765,7 +764,7 @@ void
cmNinjaTargetGenerator
::EnsureParentDirectoryExists(const std::string& path) const
{
- EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path.c_str()));
+ EnsureDirectoryExists(cmSystemTools::GetParentDirectory(path));
}
@@ -786,14 +785,14 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
// Get the input file location.
std::string input = source.GetFullPath();
input =
- this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input.c_str());
+ this->Generator->GetLocalGenerator()->ConvertToNinjaPath(input);
// Get the output file location.
std::string output = macdir;
output += "/";
output += cmSystemTools::GetFilenameName(input);
output =
- this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output.c_str());
+ this->Generator->GetLocalGenerator()->ConvertToNinjaPath(output);
// Write a build statement to copy the content into the bundle.
this->Generator->GetGlobalGenerator()->WriteMacOSXContentBuild(input,
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 40a15a3..5733fde 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -42,7 +42,7 @@ public:
std::string GetTargetName() const;
- bool needsDepFile(const std::string& lang);
+ bool NeedDepTypeMSVC(const std::string& lang) const;
protected:
@@ -116,7 +116,6 @@ protected:
void WriteObjectBuildStatements();
void WriteObjectBuildStatement(cmSourceFile const* source,
bool writeOrderDependsTargetForTarget);
- void WriteCustomCommandBuildStatement(cmCustomCommand *cc);
cmNinjaDeps GetObjects() const
{ return this->Objects; }
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index f5d18dc..42d6b46 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -27,14 +27,19 @@ cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {}
void cmNinjaUtilityTargetGenerator::Generate()
{
+ std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash();
+ utilCommandName += this->GetTargetName() + ".util";
+
std::vector<std::string> commands;
- cmNinjaDeps deps, outputs;
+ cmNinjaDeps deps, outputs, util_outputs(1, utilCommandName);
const std::vector<cmCustomCommand> *cmdLists[2] = {
&this->GetTarget()->GetPreBuildCommands(),
&this->GetTarget()->GetPostBuildCommands()
};
+ bool uses_terminal = false;
+
for (unsigned i = 0; i != 2; ++i) {
for (std::vector<cmCustomCommand>::const_iterator
ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
@@ -42,6 +47,11 @@ void cmNinjaUtilityTargetGenerator::Generate()
this->GetMakefile());
this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
+ std::vector<std::string> const& ccByproducts = ccg.GetByproducts();
+ std::transform(ccByproducts.begin(), ccByproducts.end(),
+ std::back_inserter(util_outputs), MapToNinjaPath());
+ if (ci->GetUsesTerminal())
+ uses_terminal = true;
}
}
@@ -60,8 +70,11 @@ void cmNinjaUtilityTargetGenerator::Generate()
// Depend on all custom command outputs.
const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
+ const std::vector<std::string>& ccByproducts = ccg.GetByproducts();
std::transform(ccOutputs.begin(), ccOutputs.end(),
std::back_inserter(deps), MapToNinjaPath());
+ std::transform(ccByproducts.begin(), ccByproducts.end(),
+ std::back_inserter(deps), MapToNinjaPath());
}
}
@@ -103,14 +116,19 @@ void cmNinjaUtilityTargetGenerator::Generate()
if (command.find('$') != std::string::npos)
return;
- std::string utilCommandName = cmake::GetCMakeFilesDirectoryPostSlash();
- utilCommandName += this->GetTargetName() + ".util";
+ for (cmNinjaDeps::const_iterator
+ oi = util_outputs.begin(), oe = util_outputs.end();
+ oi != oe; ++oi)
+ {
+ this->GetGlobalGenerator()->SeenCustomCommandOutput(*oi);
+ }
this->GetGlobalGenerator()->WriteCustomCommandBuild(
command,
desc,
"Utility command for " + this->GetTargetName(),
- cmNinjaDeps(1, utilCommandName),
+ uses_terminal,
+ util_outputs,
deps);
this->GetGlobalGenerator()->WritePhonyBuild(this->GetBuildFileStream(),
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 786e6e2..55e20ab 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -112,8 +112,8 @@ void cmOSXBundleGenerator::CreateFramework(
oldName = frameworkVersion;
newName = versions;
newName += "/Current";
- cmSystemTools::RemoveFile(newName.c_str());
- cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ cmSystemTools::RemoveFile(newName);
+ cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
// foo -> Versions/Current/foo
@@ -121,8 +121,8 @@ void cmOSXBundleGenerator::CreateFramework(
oldName += name;
newName = contentdir;
newName += name;
- cmSystemTools::RemoveFile(newName.c_str());
- cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ cmSystemTools::RemoveFile(newName);
+ cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
// Resources -> Versions/Current/Resources
@@ -132,8 +132,8 @@ void cmOSXBundleGenerator::CreateFramework(
oldName = "Versions/Current/Resources";
newName = contentdir;
newName += "Resources";
- cmSystemTools::RemoveFile(newName.c_str());
- cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ cmSystemTools::RemoveFile(newName);
+ cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
}
@@ -144,8 +144,8 @@ void cmOSXBundleGenerator::CreateFramework(
oldName = "Versions/Current/Headers";
newName = contentdir;
newName += "Headers";
- cmSystemTools::RemoveFile(newName.c_str());
- cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ cmSystemTools::RemoveFile(newName);
+ cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
}
@@ -156,8 +156,8 @@ void cmOSXBundleGenerator::CreateFramework(
oldName = "Versions/Current/PrivateHeaders";
newName = contentdir;
newName += "PrivateHeaders";
- cmSystemTools::RemoveFile(newName.c_str());
- cmSystemTools::CreateSymlink(oldName.c_str(), newName.c_str());
+ cmSystemTools::RemoveFile(newName);
+ cmSystemTools::CreateSymlink(oldName, newName);
this->Makefile->AddCMakeOutputFile(newName);
}
}
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 007364c..23f8526 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -86,7 +86,7 @@ public:
}
}
- void FindImplicitConflicts(cmOStringStream& w)
+ void FindImplicitConflicts(std::ostringstream& w)
{
bool first = true;
for(unsigned int i=0; i < this->OD->OriginalDirectories.size(); ++i)
@@ -140,7 +140,7 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
{
// The file conflicts only if it is not the same as the original
// file due to a symlink or hardlink.
- return !cmSystemTools::SameFile(this->FullPath.c_str(), file.c_str());
+ return !cmSystemTools::SameFile(this->FullPath, file);
}
// Check if the file will be built by cmake.
@@ -291,18 +291,8 @@ cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg,
//----------------------------------------------------------------------------
cmOrderDirectories::~cmOrderDirectories()
{
- for(std::vector<cmOrderDirectoriesConstraint*>::iterator
- i = this->ConstraintEntries.begin();
- i != this->ConstraintEntries.end(); ++i)
- {
- delete *i;
- }
- for(std::vector<cmOrderDirectoriesConstraint*>::iterator
- i = this->ImplicitDirEntries.begin();
- i != this->ImplicitDirEntries.end(); ++i)
- {
- delete *i;
- }
+ cmDeleteAll(this->ConstraintEntries);
+ cmDeleteAll(this->ImplicitDirEntries);
}
//----------------------------------------------------------------------------
@@ -541,7 +531,7 @@ void cmOrderDirectories::FindImplicitConflicts()
{
// Check for items in implicit link directories that have conflicts
// in the explicit directories.
- cmOStringStream conflicts;
+ std::ostringstream conflicts;
for(unsigned int i=0; i < this->ImplicitDirEntries.size(); ++i)
{
this->ImplicitDirEntries[i]->FindImplicitConflicts(conflicts);
@@ -555,7 +545,7 @@ void cmOrderDirectories::FindImplicitConflicts()
}
// Warn about the conflicts.
- cmOStringStream w;
+ std::ostringstream w;
w << "Cannot generate a safe " << this->Purpose
<< " for target " << this->Target->GetName()
<< " because files in some directories may conflict with "
@@ -624,7 +614,7 @@ void cmOrderDirectories::DiagnoseCycle()
this->CycleDiagnosed = true;
// Construct the message.
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot generate a safe " << this->Purpose
<< " for target " << this->Target->GetName()
<< " because there is a cycle in the constraint graph:\n";
diff --git a/Source/cmPathLabel.cxx b/Source/cmPathLabel.cxx
new file mode 100644
index 0000000..67d56e1
--- /dev/null
+++ b/Source/cmPathLabel.cxx
@@ -0,0 +1,41 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmPathLabel.h"
+
+//----------------------------------------------------------------------------
+cmPathLabel::cmPathLabel(const std::string& label)
+: Label(label), Hash(0)
+{
+ // Use a Jenkins one-at-a-time hash with under/over-flow protection
+ for(size_t i = 0; i < this->Label.size(); ++i)
+ {
+ this->Hash += this->Label[i];
+ this->Hash += ((this->Hash & 0x003FFFFF) << 10);
+ this->Hash ^= ((this->Hash & 0xFFFFFFC0) >> 6);
+ }
+ this->Hash += ((this->Hash & 0x1FFFFFFF) << 3);
+ this->Hash ^= ((this->Hash & 0xFFFFF800) >> 11);
+ this->Hash += ((this->Hash & 0x0001FFFF) << 15);
+}
+
+//----------------------------------------------------------------------------
+bool cmPathLabel::operator < (const cmPathLabel& l) const
+{
+ return this->Hash < l.Hash;
+}
+
+//----------------------------------------------------------------------------
+bool cmPathLabel::operator == (const cmPathLabel& l) const
+{
+ return this->Hash == l.Hash;
+}
diff --git a/Source/cmPathLabel.h b/Source/cmPathLabel.h
new file mode 100644
index 0000000..02d5261
--- /dev/null
+++ b/Source/cmPathLabel.h
@@ -0,0 +1,44 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmPathLabel_h
+#define cmPathLabel_h
+
+#include "cmStandardIncludes.h"
+
+/** \class cmPathLabel
+ * \brief Helper class for text based labels
+ *
+ * cmPathLabel is extended in different classes to act as an inheritable
+ * enum. Comparisons are done on a precomputed Jenkins hash of the string
+ * label for indexing and searchig.
+ */
+class cmPathLabel
+{
+public:
+ cmPathLabel(const std::string& label);
+
+ // The comparison operators are only for quick sorting and searching and
+ // in no way imply any lexicographical order of the label
+ bool operator < (const cmPathLabel& l) const;
+ bool operator == (const cmPathLabel& l) const;
+
+ const std::string& GetLabel() const { return this->Label; }
+ const unsigned int& GetHash() const { return this->Hash; }
+
+protected:
+ cmPathLabel();
+
+ std::string Label;
+ unsigned int Hash;
+};
+
+#endif
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index a420f59..3a48101 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -41,7 +41,7 @@ public:
std::string GetVersionString()
{
- cmOStringStream v;
+ std::ostringstream v;
v << this->MajorVersionIntroduced << "." << this->MinorVersionIntroduced;
if(this->PatchVersionIntroduced > 0)
{
@@ -364,17 +364,21 @@ cmPolicies::cmPolicies()
CMP0054, "CMP0054",
"Only interpret if() arguments as variables or keywords when unquoted.",
3,1,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0055, "CMP0055",
+ "Strict checking for break() command.",
+ 3,2,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0056, "CMP0056",
+ "Honor link flags in try_compile() source-file signature.",
+ 3,2,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
{
- // free the policies
- std::map<cmPolicies::PolicyID,cmPolicy *>::iterator i
- = this->Policies.begin();
- for (;i != this->Policies.end(); ++i)
- {
- delete i->second;
- }
+ cmDeleteAll(this->Policies);
}
void cmPolicies::DefinePolicy(cmPolicies::PolicyID iD,
@@ -422,7 +426,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
if(sscanf(ver.c_str(), "%u.%u.%u.%u",
&majorVer, &minorVer, &patchVer, &tweakVer) < 2)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Invalid policy version value \"" << ver << "\". "
<< "A numeric major.minor[.patch[.tweak]] must be given.";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -452,7 +456,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile *mf,
patchVer == cmVersion::GetPatchVersion() &&
tweakVer > cmVersion::GetTweakVersion()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "An attempt was made to set the policy version of CMake to \""
<< version << "\" which is greater than this version of CMake. "
<< "This is not allowed because the greater version may have new "
@@ -524,7 +528,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << defaultVar << " has value \"" << defaultValue
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
mf->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -574,7 +578,7 @@ std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id)
return "Request for warning text for undefined policy!";
}
- cmOStringStream msg;
+ std::ostringstream msg;
msg <<
"Policy " << pos->second->IDString << " is not set: "
"" << pos->second->ShortDescription << " "
@@ -598,7 +602,7 @@ std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id)
return "Request for error text for undefined policy!";
}
- cmOStringStream error;
+ std::ostringstream error;
error <<
"Policy " << pos->second->IDString << " is not set to NEW: "
"" << pos->second->ShortDescription << " "
@@ -635,7 +639,7 @@ std::string
cmPolicies::GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id)
{
std::string pid = this->GetPolicyIDString(id);
- cmOStringStream e;
+ std::ostringstream e;
e << "Policy " << pid << " may not be set to OLD behavior because this "
<< "version of CMake no longer supports it. "
<< "The policy was introduced in "
@@ -657,7 +661,7 @@ cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
unsigned int patchVer,
cmMakefile* mf)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The project requests behavior compatible with CMake version \""
<< majorVer << "." << minorVer << "." << patchVer
<< "\", which requires the OLD behavior for some policies:\n";
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 7c73da8..c393c2f 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -111,6 +111,8 @@ public:
CMP0053, ///< Simplify variable reference and escape sequence evaluation
CMP0054, ///< Only interpret if() arguments as variables
/// or keywords when unquoted.
+ CMP0055, ///< Strict checking for break() command.
+ CMP0056, ///< Honor link flags in try_compile() source-file signature.
/** \brief Always the last entry.
*
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index 12318c8..61c0133 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -215,7 +215,7 @@ bool cmProjectCommand
}
if(!vw.empty())
{
- cmOStringStream w;
+ std::ostringstream w;
w << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0048))
<< "\nThe following variable(s) would be set to empty:" << vw;
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 93ebde6..e18e757 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -166,6 +166,103 @@ static std::string getAutogenTargetDir(cmTarget const* target)
return targetDir;
}
+std::string cmQtAutoGenerators::ListQt5RccInputs(cmSourceFile* sf,
+ cmTarget const* target,
+ std::vector<std::string>& depends)
+{
+ std::string rccCommand = this->GetRccExecutable(target);
+ std::vector<std::string> qrcEntries;
+
+ std::vector<std::string> command;
+ command.push_back(rccCommand);
+ command.push_back("--list");
+
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+
+ command.push_back(absFile);
+
+ std::string output;
+ int retVal = 0;
+ bool result = cmSystemTools::RunSingleCommand(command, &output,
+ &retVal, 0,
+ cmSystemTools::OUTPUT_NONE);
+ if (!result || retVal)
+ {
+ std::cerr << "AUTOGEN: error: Rcc list process for " << sf->GetFullPath()
+ << " failed:\n" << output << std::endl;
+ return std::string();
+ }
+
+ std::istringstream ostr(output);
+ std::string oline;
+ while(std::getline(ostr, oline))
+ {
+ if (oline.empty())
+ {
+ // The output of rcc --list contains many empty lines.
+ continue;
+ }
+ if (cmHasLiteralPrefix(oline, "RCC: Error in"))
+ {
+ static std::string searchString = "Cannot find file '";
+
+ std::string::size_type pos = oline.find(searchString);
+ if (pos == std::string::npos)
+ {
+ std::cerr << "AUTOGEN: error: Rcc lists unparsable output "
+ << oline << std::endl;
+ return std::string();
+ }
+ pos += searchString.length();
+ std::string::size_type sz = oline.size() - pos - 1;
+ qrcEntries.push_back(oline.substr(pos, sz));
+ }
+ else
+ {
+ qrcEntries.push_back(oline);
+ }
+ }
+ depends.insert(depends.end(), qrcEntries.begin(), qrcEntries.end());
+ return cmJoin(qrcEntries, "@list_sep@");
+}
+
+std::string cmQtAutoGenerators::ListQt4RccInputs(cmSourceFile* sf,
+ std::vector<std::string>& depends)
+{
+ const std::string qrcContents = ReadAll(sf->GetFullPath());
+
+ cmsys::RegularExpression fileMatchRegex("(<file[^<]+)");
+
+ std::string entriesList;
+ const char* sep = "";
+
+ size_t offset = 0;
+ while (fileMatchRegex.find(qrcContents.c_str() + offset))
+ {
+ std::string qrcEntry = fileMatchRegex.match(1);
+
+ offset += qrcEntry.size();
+
+ cmsys::RegularExpression fileReplaceRegex("(^<file[^>]*>)");
+ fileReplaceRegex.find(qrcEntry);
+ std::string tag = fileReplaceRegex.match(1);
+
+ qrcEntry = qrcEntry.substr(tag.size());
+
+ if (!cmSystemTools::FileIsFullPath(qrcEntry.c_str()))
+ {
+ qrcEntry = sf->GetLocation().GetDirectory() + "/" + qrcEntry;
+ }
+
+ entriesList += sep;
+ entriesList += qrcEntry;
+ sep = "@list_sep@";
+ depends.push_back(qrcEntry);
+ }
+ return entriesList;
+}
+
bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
{
cmMakefile* makefile = target->GetMakefile();
@@ -271,13 +368,69 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
}
}
}
+#endif
+
+ std::vector<std::string> rcc_output;
+ if(makefile->GetLocalGenerator()->GetGlobalGenerator()->GetName() == "Ninja"
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ || usePRE_BUILD
+#endif
+ )
+ {
+ std::vector<cmSourceFile*> srcFiles;
+ target->GetConfigCommonSourceFiles(srcFiles);
+ for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
+ fileIt != srcFiles.end();
+ ++fileIt)
+ {
+ cmSourceFile* sf = *fileIt;
+ std::string absFile = cmsys::SystemTools::GetRealPath(
+ sf->GetFullPath());
+
+ std::string ext = sf->GetExtension();
+
+ if (target->GetPropertyAsBool("AUTORCC"))
+ {
+ if (ext == "qrc"
+ && !cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC")))
+ {
+ std::string basename = cmsys::SystemTools::
+ GetFilenameWithoutLastExtension(absFile);
+
+ std::string rcc_output_dir = target->GetSupportDirectory();
+ cmSystemTools::MakeDirectory(rcc_output_dir.c_str());
+ std::string rcc_output_file = rcc_output_dir;
+ rcc_output_file += "/qrc_" + basename + ".cpp";
+ rcc_output.push_back(rcc_output_file);
+
+ if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
+ {
+ if (qtMajorVersion == "5")
+ {
+ this->ListQt5RccInputs(sf, target, depends);
+ }
+ else
+ {
+ this->ListQt4RccInputs(sf, depends);
+ }
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ usePRE_BUILD = false;
+#endif
+ }
+ }
+ }
+ }
+ }
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
if(usePRE_BUILD)
{
// Add the pre-build command directly to bypass the OBJECT_LIBRARY
// rejection in cmMakefile::AddCustomCommandToTarget because we know
// PRE_BUILD will work for an OBJECT_LIBRARY in this specific case.
std::vector<std::string> no_output;
- cmCustomCommand cc(makefile, no_output, depends,
+ std::vector<std::string> no_byproducts;
+ cmCustomCommand cc(makefile, no_output, no_byproducts, depends,
commandLines, autogenComment.c_str(),
workingDirectory.c_str());
cc.SetEscapeOldStyle(false);
@@ -287,10 +440,31 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
else
#endif
{
- cmTarget* autogenTarget = makefile->AddUtilityCommand(
+ cmTarget* autogenTarget = 0;
+ if (!rcc_output.empty())
+ {
+ std::vector<std::string> no_byproducts;
+ makefile->AddCustomCommandToOutput(rcc_output, no_byproducts,
+ depends, "",
+ commandLines, 0,
+ workingDirectory.c_str(),
+ false, false);
+
+ cmCustomCommandLines no_commands;
+ autogenTarget = makefile->AddUtilityCommand(
+ autogenTargetName, true,
+ workingDirectory.c_str(), rcc_output,
+ no_commands, false, autogenComment.c_str());
+
+ }
+ else
+ {
+ autogenTarget = makefile->AddUtilityCommand(
autogenTargetName, true,
workingDirectory.c_str(), depends,
commandLines, false, autogenComment.c_str());
+ }
+
// Set target folder
const char* autogenFolder = makefile->GetCMakeInstance()->GetProperty(
"AUTOMOC_TARGETS_FOLDER");
@@ -329,29 +503,13 @@ static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
// Get the include dirs for this target, without stripping the implicit
// include dirs off, see http://public.kitware.com/Bug/view.php?id=13667
localGen->GetIncludeDirectories(includeDirs, gtgt, "CXX", config, false);
- const char* sep = "";
- incs = "";
- for(std::vector<std::string>::const_iterator incDirIt = includeDirs.begin();
- incDirIt != includeDirs.end();
- ++incDirIt)
- {
- incs += sep;
- sep = ";";
- incs += *incDirIt;
- }
+
+ incs = cmJoin(includeDirs, ";");
std::set<std::string> defines;
localGen->AddCompileDefinitions(defines, target, config);
- sep = "";
- for(std::set<std::string>::const_iterator defIt = defines.begin();
- defIt != defines.end();
- ++defIt)
- {
- defs += sep;
- sep = ";";
- defs += *defIt;
- }
+ defs += cmJoin(defines, ";");
}
void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
@@ -418,6 +576,8 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
inputFile += "/Modules/AutogenInfo.cmake.in";
std::string outputFile = targetDir;
outputFile += "/AutogenInfo.cmake";
+ makefile->AddDefinition("_qt_rcc_inputs",
+ makefile->GetDefinition("_qt_rcc_inputs_" + target->GetName()));
makefile->ConfigureFile(inputFile.c_str(), outputFile.c_str(),
false, true, false);
@@ -488,7 +648,7 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
{
cmSourceFile* sf = *fileIt;
std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath().c_str());
+ sf->GetFullPath());
bool skipMoc = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTOMOC"));
bool generated = cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED"));
@@ -694,16 +854,7 @@ static void GetUicOpts(cmTarget const* target, const std::string& config,
{
std::vector<std::string> opts;
target->GetAutoUicOptions(opts, config);
-
- const char* sep = "";
- for(std::vector<std::string>::const_iterator optIt = opts.begin();
- optIt != opts.end();
- ++optIt)
- {
- optString += sep;
- sep = ";";
- optString += *optIt;
- }
+ optString = cmJoin(opts, ";");
}
void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
@@ -714,12 +865,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
std::set<std::string> skipped;
std::vector<std::string> skipVec;
cmSystemTools::ExpandListArgument(this->SkipUic, skipVec);
-
- for (std::vector<std::string>::const_iterator li = skipVec.begin();
- li != skipVec.end(); ++li)
- {
- skipped.insert(*li);
- }
+ skipped.insert(skipVec.begin(), skipVec.end());
makefile->AddDefinition("_skip_uic",
cmLocalGenerator::EscapeForCMake(this->SkipUic).c_str());
@@ -766,7 +912,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
{
cmSourceFile* sf = *fileIt;
std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath().c_str());
+ sf->GetFullPath());
if (!skipped.insert(absFile).second)
{
@@ -869,9 +1015,12 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
std::vector<cmSourceFile*> srcFiles;
target->GetConfigCommonSourceFiles(srcFiles);
+ std::string qrcInputs;
+ const char* qrcInputsSep = "";
+
std::string rccFileFiles;
std::string rccFileOptions;
- const char *sep = "";
+ const char *optionSep = "";
const char *qtVersion = makefile->GetDefinition("_target_qt_version");
@@ -880,6 +1029,11 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
cmSystemTools::ExpandListArgument(opts, rccOptions);
}
+ std::string qtMajorVersion = makefile->GetSafeDefinition("QT_VERSION_MAJOR");
+ if (qtMajorVersion == "")
+ {
+ qtMajorVersion = makefile->GetSafeDefinition("Qt5Core_VERSION_MAJOR");
+ }
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end();
@@ -890,7 +1044,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
if (ext == "qrc")
{
std::string absFile = cmsys::SystemTools::GetRealPath(
- sf->GetFullPath().c_str());
+ sf->GetFullPath());
bool skip = cmSystemTools::IsOn(sf->GetPropertyForUser("SKIP_AUTORCC"));
if (!skip)
@@ -909,9 +1063,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
if (!rccOptions.empty())
{
- rccFileFiles += sep;
+ rccFileFiles += optionSep;
rccFileFiles += absFile;
- rccFileOptions += sep;
+ rccFileOptions += optionSep;
}
const char *listSep = "";
for(std::vector<std::string>::const_iterator it = rccOptions.begin();
@@ -922,10 +1076,34 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
rccFileOptions += *it;
listSep = "@list_sep@";
}
- sep = ";";
+ optionSep = ";";
+
+ std::vector<std::string> depends;
+
+ std::string entriesList;
+ if (!cmSystemTools::IsOn(sf->GetPropertyForUser("GENERATED")))
+ {
+ if (qtMajorVersion == "5")
+ {
+ entriesList = this->ListQt5RccInputs(sf, target, depends);
+ }
+ else
+ {
+ entriesList = this->ListQt4RccInputs(sf, depends);
+ }
+ if (entriesList.empty())
+ {
+ return;
+ }
+ }
+ qrcInputs += qrcInputsSep;
+ qrcInputs += entriesList;
+ qrcInputsSep = ";";
}
}
}
+ makefile->AddDefinition("_qt_rcc_inputs_" + target->GetName(),
+ cmLocalGenerator::EscapeForCMake(qrcInputs).c_str());
makefile->AddDefinition("_rcc_files",
cmLocalGenerator::EscapeForCMake(_rcc_files).c_str());
@@ -935,6 +1113,29 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
makefile->AddDefinition("_qt_rcc_options_options",
cmLocalGenerator::EscapeForCMake(rccFileOptions).c_str());
+ makefile->AddDefinition("_qt_rcc_executable",
+ this->GetRccExecutable(target).c_str());
+}
+
+std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target)
+{
+ cmMakefile *makefile = target->GetMakefile();
+ const char *qtVersion = makefile->GetDefinition("_target_qt_version");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("Qt5Core_VERSION_MAJOR");
+ if (!qtVersion)
+ {
+ qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
+ }
+ if (const char *targetQtVersion =
+ target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION",
+ ""))
+ {
+ qtVersion = targetQtVersion;
+ }
+ }
+
std::string targetName = target->GetName();
if (strcmp(qtVersion, "5") == 0)
{
@@ -943,9 +1144,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
cmSystemTools::Error("Qt5::rcc target not found ",
targetName.c_str());
- return;
+ return std::string();
}
- makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(""));
+ return qt5Rcc->GetLocation("");
}
else if (strcmp(qtVersion, "4") == 0)
{
@@ -954,15 +1155,14 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
{
cmSystemTools::Error("Qt4::rcc target not found ",
targetName.c_str());
- return;
+ return std::string();
}
- makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(""));
- }
- else
- {
- cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
- "Qt 5 ", targetName.c_str());
+ return qt4Rcc->GetLocation("");
}
+
+ cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
+ "Qt 5 ", targetName.c_str());
+ return std::string();
}
static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
@@ -1013,7 +1213,7 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
const std::string& config)
{
std::string filename(
- cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
+ cmSystemTools::CollapseFullPath(targetDirectory));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutogenInfo.cmake";
@@ -1030,7 +1230,10 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
"AM_Qt5Core_VERSION_MAJOR");
}
this->Sources = makefile->GetSafeDefinition("AM_SOURCES");
- this->RccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES");
+ {
+ std::string rccSources = makefile->GetSafeDefinition("AM_RCC_SOURCES");
+ cmSystemTools::ExpandListArgument(rccSources, this->RccSources);
+ }
this->SkipMoc = makefile->GetSafeDefinition("AM_SKIP_MOC");
this->SkipUic = makefile->GetSafeDefinition("AM_SKIP_UIC");
this->Headers = makefile->GetSafeDefinition("AM_HEADERS");
@@ -1128,6 +1331,28 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
cmSystemTools::ReplaceString(*optionIt, "@list_sep@", ";");
this->RccOptions[*fileIt] = *optionIt;
}
+
+ const char *rccInputs = makefile->GetSafeDefinition("AM_RCC_INPUTS");
+ std::vector<std::string> rccInputLists;
+ cmSystemTools::ExpandListArgument(rccInputs, rccInputLists);
+
+ if (this->RccSources.size() != rccInputLists.size())
+ {
+ cmSystemTools::Error("Error processing file: ", filename.c_str());
+ return false;
+ }
+
+ for (std::vector<std::string>::iterator fileIt = this->RccSources.begin(),
+ inputIt = rccInputLists.begin();
+ fileIt != this->RccSources.end();
+ ++fileIt, ++inputIt)
+ {
+ cmSystemTools::ReplaceString(*inputIt, "@list_sep@", ";");
+ std::vector<std::string> rccInputFiles;
+ cmSystemTools::ExpandListArgument(*inputIt, rccInputFiles);
+
+ this->RccInputs[*fileIt] = rccInputFiles;
+ }
}
this->CurrentCompileSettingsStr = this->MakeCompileSettingsString(makefile);
@@ -1158,7 +1383,7 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile,
const std::string& targetDirectory)
{
std::string filename(
- cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
+ cmSystemTools::CollapseFullPath(targetDirectory));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutomocOldMocDefinitions.cmake";
@@ -1176,7 +1401,7 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile(
const std::string& targetDirectory)
{
std::string filename(
- cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
+ cmSystemTools::CollapseFullPath(targetDirectory));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutomocOldMocDefinitions.cmake";
@@ -1218,11 +1443,11 @@ void cmQtAutoGenerators::Init()
{
const std::string &path = *it;
this->MocIncludes.push_back("-I" + path);
- if (this->EndsWith(path, ".framework/Headers"))
+ if (cmHasLiteralSuffix(path, ".framework/Headers"))
{
// Go up twice to get to the framework root
std::vector<std::string> pathComponents;
- cmsys::SystemTools::SplitPath(path.c_str(), pathComponents);
+ cmsys::SystemTools::SplitPath(path, pathComponents);
std::string frameworkPath =cmsys::SystemTools::JoinPath(
pathComponents.begin(), pathComponents.end() - 2);
frameworkPaths.insert(frameworkPath);
@@ -1239,7 +1464,7 @@ void cmQtAutoGenerators::Init()
if (this->IncludeProjectDirsBefore)
{
- const std::string &binDir = "-I" + this->ProjectBinaryDir;
+ const std::string binDir = "-I" + this->ProjectBinaryDir;
const std::string srcDir = "-I" + this->ProjectSourceDir;
@@ -1358,12 +1583,7 @@ bool cmQtAutoGenerators::RunAutogen(cmMakefile* makefile)
std::vector<std::string> headerFilesVec;
cmSystemTools::ExpandListArgument(this->Headers, headerFilesVec);
- for (std::vector<std::string>::const_iterator it = headerFilesVec.begin();
- it != headerFilesVec.end();
- ++it)
- {
- headerFiles.insert(*it);
- }
+ headerFiles.insert(headerFilesVec.begin(), headerFilesVec.end());
// key = moc source filepath, value = moc output filename
std::map<std::string, std::string> notIncludedMocs;
@@ -1484,7 +1704,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
}
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
- cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+ cmsys::SystemTools::GetRealPath(absFilename)) + '/';
const std::string scannedFileBasename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(absFilename);
std::string macroName;
@@ -1510,7 +1730,7 @@ void cmQtAutoGenerators::ParseCppFile(const std::string& absFilename,
std::string basename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(currentMoc);
- const bool moc_style = this->StartsWith(basename, "moc_");
+ const bool moc_style = cmHasLiteralPrefix(basename, "moc_");
// If the moc include is of the moc_foo.cpp style we expect
// the Q_OBJECT class declaration in a header file.
@@ -1672,7 +1892,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
}
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
- cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+ cmsys::SystemTools::GetRealPath(absFilename)) + '/';
const std::string scannedFileBasename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(absFilename);
@@ -1692,7 +1912,7 @@ void cmQtAutoGenerators::StrictParseCppFile(const std::string& absFilename,
std::string basename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(currentMoc);
- const bool mocUnderscoreStyle = this->StartsWith(basename, "moc_");
+ const bool mocUnderscoreStyle = cmHasLiteralPrefix(basename, "moc_");
// If the moc include is of the moc_foo.cpp style we expect
// the Q_OBJECT class declaration in a header file.
@@ -1802,7 +2022,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename,
std::string::size_type matchOffset = 0;
const std::string realName =
- cmsys::SystemTools::GetRealPath(absFilename.c_str());
+ cmsys::SystemTools::GetRealPath(absFilename);
matchOffset = 0;
if ((strstr(contentsString.c_str(), "ui_") != NULL)
@@ -1836,7 +2056,7 @@ cmQtAutoGenerators::SearchHeadersForCppFile(const std::string& absFilename,
const std::string basename =
cmsys::SystemTools::GetFilenameWithoutLastExtension(absFilename);
const std::string absPath = cmsys::SystemTools::GetFilenamePath(
- cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+ cmsys::SystemTools::GetRealPath(absFilename)) + '/';
for(std::vector<std::string>::const_iterator ext = headerExtensions.begin();
ext != headerExtensions.end();
@@ -1904,8 +2124,8 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
{
const std::string mocFilePath = this->Builddir + mocFileName;
int sourceNewerThanMoc = 0;
- bool success = cmsys::SystemTools::FileTimeCompare(sourceFile.c_str(),
- mocFilePath.c_str(),
+ bool success = cmsys::SystemTools::FileTimeCompare(sourceFile,
+ mocFilePath,
&sourceNewerThanMoc);
if (this->GenerateAll || !success || sourceNewerThanMoc >= 0)
{
@@ -1924,24 +2144,12 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
std::vector<std::string> command;
command.push_back(this->MocExecutable);
- for (std::list<std::string>::const_iterator it = this->MocIncludes.begin();
- it != this->MocIncludes.end();
- ++it)
- {
- command.push_back(*it);
- }
- for(std::list<std::string>::const_iterator it=this->MocDefinitions.begin();
- it != this->MocDefinitions.end();
- ++it)
- {
- command.push_back(*it);
- }
- for(std::vector<std::string>::const_iterator it=this->MocOptions.begin();
- it != this->MocOptions.end();
- ++it)
- {
- command.push_back(*it);
- }
+ command.insert(command.end(),
+ this->MocIncludes.begin(), this->MocIncludes.end());
+ command.insert(command.end(),
+ this->MocDefinitions.begin(), this->MocDefinitions.end());
+ command.insert(command.end(),
+ this->MocOptions.begin(), this->MocOptions.end());
#ifdef _WIN32
command.push_back("-DWIN32");
#endif
@@ -1968,7 +2176,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
std::cerr << "AUTOGEN: error: process for " << mocFilePath <<" failed:\n"
<< output << std::endl;
this->RunMocFailed = true;
- cmSystemTools::RemoveFile(mocFilePath.c_str());
+ cmSystemTools::RemoveFile(mocFilePath);
}
return true;
}
@@ -1984,14 +2192,14 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
}
const std::string path = cmsys::SystemTools::GetFilenamePath(
- realName.c_str()) + '/';
+ realName) + '/';
std::string ui_output_file = "ui_" + uiFileName + ".h";
std::string ui_input_file = path + uiFileName + ".ui";
int sourceNewerThanUi = 0;
- bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file.c_str(),
- (this->Builddir + ui_output_file).c_str(),
+ bool success = cmsys::SystemTools::FileTimeCompare(ui_input_file,
+ this->Builddir + ui_output_file,
&sourceNewerThanUi);
if (this->GenerateAll || !success || sourceNewerThanUi >= 0)
{
@@ -2013,12 +2221,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
cmSystemTools::ExpandListArgument(optionIt->second, fileOpts);
this->MergeUicOptions(opts, fileOpts, this->QtMajorVersion == "5");
}
- for(std::vector<std::string>::const_iterator optIt = opts.begin();
- optIt != opts.end();
- ++optIt)
- {
- command.push_back(*optIt);
- }
+ command.insert(command.end(), opts.begin(), opts.end());
command.push_back("-o");
command.push_back(this->Builddir + ui_output_file);
@@ -2040,9 +2243,10 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
if (!result || retVal)
{
std::cerr << "AUTOUIC: error: process for " << ui_output_file <<
- " failed:\n" << output << std::endl;
+ " needed by\n \"" << realName << "\"\nfailed:\n" << output
+ << std::endl;
this->RunUicFailed = true;
- cmSystemTools::RemoveFile(ui_output_file.c_str());
+ cmSystemTools::RemoveFile(ui_output_file);
return false;
}
return true;
@@ -2050,13 +2254,29 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
return false;
}
-bool cmQtAutoGenerators::GenerateQrc()
+bool cmQtAutoGenerators::InputFilesNewerThanQrc(const std::string& qrcFile,
+ const std::string& rccOutput)
{
- std::vector<std::string> sourceFiles;
- cmSystemTools::ExpandListArgument(this->RccSources, sourceFiles);
+ std::vector<std::string> const& files = this->RccInputs[qrcFile];
+ for (std::vector<std::string>::const_iterator it = files.begin();
+ it != files.end(); ++it)
+ {
+ int inputNewerThanQrc = 0;
+ bool success = cmsys::SystemTools::FileTimeCompare(*it,
+ rccOutput,
+ &inputNewerThanQrc);
+ if (!success || inputNewerThanQrc >= 0)
+ {
+ return true;
+ }
+ }
+ return false;
+}
- for(std::vector<std::string>::const_iterator si = sourceFiles.begin();
- si != sourceFiles.end(); ++si)
+bool cmQtAutoGenerators::GenerateQrc()
+{
+ for(std::vector<std::string>::const_iterator si = this->RccSources.begin();
+ si != this->RccSources.end(); ++si)
{
std::string ext = cmsys::SystemTools::GetFilenameLastExtension(*si);
@@ -2075,23 +2295,20 @@ bool cmQtAutoGenerators::GenerateQrc()
+ ".dir/qrc_" + basename + ".cpp";
int sourceNewerThanQrc = 0;
- bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(),
- rcc_output_file.c_str(),
+ bool generateQrc = !cmsys::SystemTools::FileTimeCompare(*si,
+ rcc_output_file,
&sourceNewerThanQrc);
- if (this->GenerateAll || !success || sourceNewerThanQrc >= 0)
+ generateQrc = generateQrc || (sourceNewerThanQrc >= 0);
+ generateQrc = generateQrc || this->InputFilesNewerThanQrc(*si,
+ rcc_output_file);
+
+ if (this->GenerateAll || generateQrc)
{
std::map<std::string, std::string>::const_iterator optionIt
= this->RccOptions.find(*si);
if (optionIt != this->RccOptions.end())
{
- std::vector<std::string> opts;
- cmSystemTools::ExpandListArgument(optionIt->second, opts);
- for(std::vector<std::string>::const_iterator optIt = opts.begin();
- optIt != opts.end();
- ++optIt)
- {
- command.push_back(*optIt);
- }
+ cmSystemTools::ExpandListArgument(optionIt->second, command);
}
command.push_back("-name");
@@ -2118,7 +2335,7 @@ bool cmQtAutoGenerators::GenerateQrc()
std::cerr << "AUTORCC: error: process for " << rcc_output_file <<
" failed:\n" << output << std::endl;
this->RunRccFailed = true;
- cmSystemTools::RemoveFile(rcc_output_file.c_str());
+ cmSystemTools::RemoveFile(rcc_output_file);
return false;
}
}
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index c298f5d..79fa5df 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -86,9 +86,20 @@ private:
void MergeRccOptions(std::vector<std::string> &opts,
const std::vector<std::string> &fileOpts, bool isQt5);
+ std::string GetRccExecutable(cmTarget const* target);
+
+ std::string ListQt5RccInputs(cmSourceFile* sf, cmTarget const* target,
+ std::vector<std::string>& depends);
+
+ std::string ListQt4RccInputs(cmSourceFile* sf,
+ std::vector<std::string>& depends);
+
+ bool InputFilesNewerThanQrc(const std::string& qrcFile,
+ const std::string& rccOutput);
+
std::string QtMajorVersion;
std::string Sources;
- std::string RccSources;
+ std::vector<std::string> RccSources;
std::string SkipMoc;
std::string SkipUic;
std::string Headers;
@@ -116,6 +127,7 @@ private:
std::vector<std::string> UicTargetOptions;
std::map<std::string, std::string> UicOptions;
std::map<std::string, std::string> RccOptions;
+ std::map<std::string, std::vector<std::string> > RccInputs;
bool Verbose;
bool ColorOutput;
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index cca995b..f4607c6 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -417,14 +417,7 @@ void cmRST::ProcessDirectiveReplace()
{
// Record markup lines as replacement text.
std::string& replacement = this->Replace[this->ReplaceName];
- const char* sep = "";
- for(std::vector<std::string>::iterator i = this->MarkupLines.begin();
- i != this->MarkupLines.end(); ++i)
- {
- replacement += sep;
- replacement += *i;
- sep = " ";
- }
+ replacement += cmJoin(this->MarkupLines, " ");
this->ReplaceName = "";
}
diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx
index bcb8564..bad38be 100644
--- a/Source/cmRemoveCommand.cxx
+++ b/Source/cmRemoveCommand.cxx
@@ -39,10 +39,7 @@ bool cmRemoveCommand
// check for REMOVE(VAR v1 v2 ... vn)
std::vector<std::string> argsExpanded;
std::vector<std::string> temp;
- for(unsigned int j = 1; j < args.size(); ++j)
- {
- temp.push_back(args[j]);
- }
+ temp.insert(temp.end(), args.begin() + 1, args.end());
cmSystemTools::ExpandList(temp, argsExpanded);
// now create the new value
@@ -60,7 +57,7 @@ bool cmRemoveCommand
}
if (!found)
{
- if (value.size())
+ if (!value.empty())
{
value += ";";
}
diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx
new file mode 100644
index 0000000..861dbf1
--- /dev/null
+++ b/Source/cmSearchPath.cxx
@@ -0,0 +1,251 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+
+#include "cmSearchPath.h"
+#include "cmFindCommon.h"
+
+//----------------------------------------------------------------------------
+cmSearchPath::cmSearchPath(cmFindCommon* findCmd)
+: FC(findCmd)
+{
+}
+
+//----------------------------------------------------------------------------
+cmSearchPath::~cmSearchPath()
+{
+}
+
+//----------------------------------------------------------------------------
+
+void cmSearchPath::ExtractWithout(const std::set<std::string>& ignore,
+ std::vector<std::string>& outPaths,
+ bool clear) const
+{
+ if(clear)
+ {
+ outPaths.clear();
+ }
+ for(std::vector<std::string>::const_iterator p = this->Paths.begin();
+ p != this->Paths.end(); ++p)
+ {
+ if(ignore.count(*p) == 0)
+ {
+ outPaths.push_back(*p);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddPath(const std::string& path)
+{
+ this->AddPathInternal(path);
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddUserPath(const std::string& path)
+{
+ assert(this->FC != NULL);
+
+ std::vector<std::string> outPaths;
+
+ // We should view the registry as the target application would view
+ // it.
+ cmSystemTools::KeyWOW64 view = cmSystemTools::KeyWOW64_32;
+ cmSystemTools::KeyWOW64 other_view = cmSystemTools::KeyWOW64_64;
+ if(this->FC->Makefile->PlatformIs64Bit())
+ {
+ view = cmSystemTools::KeyWOW64_64;
+ other_view = cmSystemTools::KeyWOW64_32;
+ }
+
+ // Expand using the view of the target application.
+ std::string expanded = path;
+ cmSystemTools::ExpandRegistryValues(expanded, view);
+ cmSystemTools::GlobDirs(expanded, outPaths);
+
+ // Executables can be either 32-bit or 64-bit, so expand using the
+ // alternative view.
+ if(expanded != path && this->FC->CMakePathName == "PROGRAM")
+ {
+ expanded = path;
+ cmSystemTools::ExpandRegistryValues(expanded, other_view);
+ cmSystemTools::GlobDirs(expanded, outPaths);
+ }
+
+ // Process them all from the current directory
+ for(std::vector<std::string>::const_iterator p = outPaths.begin();
+ p != outPaths.end(); ++p)
+ {
+ this->AddPathInternal(*p, this->FC->Makefile->GetCurrentDirectory());
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddCMakePath(const std::string& variable)
+{
+ assert(this->FC != NULL);
+
+ // Get a path from a CMake variable.
+ if(const char* value = this->FC->Makefile->GetDefinition(variable))
+ {
+ std::vector<std::string> expanded;
+ cmSystemTools::ExpandListArgument(value, expanded);
+
+ for(std::vector<std::string>::const_iterator p = expanded.begin();
+ p!= expanded.end(); ++p)
+ {
+ this->AddPathInternal(*p, this->FC->Makefile->GetCurrentDirectory());
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddEnvPath(const std::string& variable)
+{
+ std::vector<std::string> expanded;
+ cmSystemTools::GetPath(expanded, variable.c_str());
+ for(std::vector<std::string>::const_iterator p = expanded.begin();
+ p!= expanded.end(); ++p)
+ {
+ this->AddPathInternal(*p);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddCMakePrefixPath(const std::string& variable)
+{
+ assert(this->FC != NULL);
+
+ // Get a path from a CMake variable.
+ if(const char* value = this->FC->Makefile->GetDefinition(variable))
+ {
+ std::vector<std::string> expanded;
+ cmSystemTools::ExpandListArgument(value, expanded);
+
+ this->AddPrefixPaths(expanded, this->FC->Makefile->GetCurrentDirectory());
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddEnvPrefixPath(const std::string& variable)
+{
+ std::vector<std::string> expanded;
+ cmSystemTools::GetPath(expanded, variable.c_str());
+ this->AddPrefixPaths(expanded);
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddSuffixes(const std::vector<std::string>& suffixes)
+{
+ std::vector<std::string> inPaths;
+ inPaths.swap(this->Paths);
+ this->Paths.reserve(inPaths.size()*(suffixes.size()+1));
+
+ for(std::vector<std::string>::iterator ip = inPaths.begin();
+ ip != inPaths.end(); ++ip)
+ {
+ cmSystemTools::ConvertToUnixSlashes(*ip);
+
+ // if *i is only / then do not add a //
+ // this will get incorrectly considered a network
+ // path on windows and cause huge delays.
+ std::string p = *ip;
+ if(!p.empty() && *p.rbegin() != '/')
+ {
+ p += "/";
+ }
+
+ // Combine with all the suffixes
+ for(std::vector<std::string>::const_iterator s = suffixes.begin();
+ s != suffixes.end(); ++s)
+ {
+ this->Paths.push_back(p+*s);
+ }
+
+ // And now the original w/o any suffix
+ this->Paths.push_back(*ip);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths,
+ const char *base)
+{
+ assert(this->FC != NULL);
+
+ // default for programs
+ std::string subdir = "bin";
+
+ if (this->FC->CMakePathName == "INCLUDE")
+ {
+ subdir = "include";
+ }
+ else if (this->FC->CMakePathName == "LIBRARY")
+ {
+ subdir = "lib";
+ }
+ else if (this->FC->CMakePathName == "FRAMEWORK")
+ {
+ subdir = ""; // ? what to do for frameworks ?
+ }
+
+ for(std::vector<std::string>::const_iterator p = paths.begin();
+ p != paths.end(); ++p)
+ {
+ std::string dir = *p;
+ if(!subdir.empty() && !dir.empty() && *dir.rbegin() != '/')
+ {
+ dir += "/";
+ }
+ if(subdir == "include" || subdir == "lib")
+ {
+ const char* arch =
+ this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE");
+ if(arch && *arch)
+ {
+ this->AddPathInternal(dir+subdir+"/"+arch, base);
+ }
+ }
+ std::string add = dir + subdir;
+ if(add != "/")
+ {
+ this->AddPathInternal(add, base);
+ }
+ if (subdir == "bin")
+ {
+ this->AddPathInternal(dir+"sbin", base);
+ }
+ if(!subdir.empty() && *p != "/")
+ {
+ this->AddPathInternal(*p, base);
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmSearchPath::AddPathInternal(const std::string& path, const char *base)
+{
+ assert(this->FC != NULL);
+
+ std::string collapsed = cmSystemTools::CollapseFullPath(path, base);
+
+ if(collapsed.empty())
+ {
+ return;
+ }
+
+ // Insert the path if has not already been emitted.
+ if(this->FC->SearchPathsEmitted.insert(collapsed).second)
+ {
+ this->Paths.push_back(collapsed);
+ }
+}
diff --git a/Source/cmSearchPath.h b/Source/cmSearchPath.h
new file mode 100644
index 0000000..51a6149
--- /dev/null
+++ b/Source/cmSearchPath.h
@@ -0,0 +1,57 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cmSearchPath_h
+#define cmSearchPath_h
+
+#include "cmStandardIncludes.h"
+
+class cmFindCommon;
+
+/** \class cmSearchPath
+ * \brief Container for encapsulating a set of search paths
+ *
+ * cmSearchPath is a container that encapsulates search path construction and
+ * management
+ */
+class cmSearchPath
+{
+public:
+ // cmSearchPath must be initialized from a valid pointer. The only reason
+ // for teh default is to allow it to be easily used in stl containers.
+ // Attempting to initialize with a NULL value will fail an assertion
+ cmSearchPath(cmFindCommon* findCmd = 0);
+ ~cmSearchPath();
+
+ const std::vector<std::string>& GetPaths() const { return this->Paths; }
+
+ void ExtractWithout(const std::set<std::string>& ignore,
+ std::vector<std::string>& outPaths,
+ bool clear = false) const;
+
+ void AddPath(const std::string& path);
+ void AddUserPath(const std::string& path);
+ void AddCMakePath(const std::string& variable);
+ void AddEnvPath(const std::string& variable);
+ void AddCMakePrefixPath(const std::string& variable);
+ void AddEnvPrefixPath(const std::string& variable);
+ void AddSuffixes(const std::vector<std::string>& suffixes);
+
+protected:
+ void AddPrefixPaths(const std::vector<std::string>& paths,
+ const char *base = 0);
+ void AddPathInternal(const std::string& path, const char *base = 0);
+
+ cmFindCommon *FC;
+ std::vector<std::string> Paths;
+};
+
+#endif
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 1ee3f29..8e6c311 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -51,7 +51,7 @@ bool cmSeparateArgumentsCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given unknown argument " << args[i];
this->SetError(e.str());
return false;
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 0ca36eb..90d7b03 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -37,13 +37,13 @@ bool cmSetCommand
delete [] varName;
// will it be set to something, then set it
- if (args.size() > 1 && args[1].size())
+ if (args.size() > 1 && !args[1].empty())
{
// but only if it is different from current value
if (!currValue || strcmp(currValue,args[1].c_str()))
{
putEnvArg += args[1];
- cmSystemTools::PutEnv(putEnvArg.c_str());
+ cmSystemTools::PutEnv(putEnvArg);
}
return true;
}
@@ -51,7 +51,7 @@ bool cmSetCommand
// if it will be cleared, then clear it if it isn;t already clear
if (currValue)
{
- cmSystemTools::PutEnv(putEnvArg.c_str());
+ cmSystemTools::PutEnv(putEnvArg);
}
return true;
}
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index c624d17..1150bc7 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -67,7 +67,7 @@ bool cmSetPropertyCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid scope " << *arg << ". "
<< "Valid scopes are GLOBAL, DIRECTORY, "
"TARGET, SOURCE, TEST, CACHE, INSTALL.";
@@ -117,7 +117,7 @@ bool cmSetPropertyCommand
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid argument \"" << *arg << "\".";
this->SetError(e.str());
return false;
@@ -204,7 +204,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
}
// The local generators are associated with collapsed paths.
- dir = cmSystemTools::CollapseFullPath(dir.c_str());
+ dir = cmSystemTools::CollapseFullPath(dir);
// Lookup the generator.
if(cmLocalGenerator* lg =
@@ -265,7 +265,7 @@ bool cmSetPropertyCommand::HandleTargetMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not find TARGET " << *ni
<< ". Perhaps it has not yet been created.";
this->SetError(e.str());
@@ -316,7 +316,7 @@ bool cmSetPropertyCommand::HandleSourceMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given SOURCE name that could not be found or created: " << *ni;
this->SetError(e.str());
return false;
@@ -373,7 +373,7 @@ bool cmSetPropertyCommand::HandleTestMode()
// Names that are still left were not found.
if(!this->Names.empty())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given TEST names that do not exist:\n";
for(std::set<std::string>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
@@ -417,7 +417,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
!cmSystemTools::IsOn(this->PropertyValue.c_str()) &&
!cmSystemTools::IsOff(this->PropertyValue.c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given non-boolean value \"" << this->PropertyValue
<< "\" for CACHE property \"ADVANCED\". ";
this->SetError(e.str());
@@ -428,7 +428,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
{
if(!cmCacheManager::IsType(this->PropertyValue.c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
this->SetError(e.str());
return false;
@@ -438,7 +438,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
this->PropertyName != "STRINGS" &&
this->PropertyName != "VALUE")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given invalid CACHE property " << this->PropertyName << ". "
<< "Settable CACHE properties are: "
<< "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
@@ -463,7 +463,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "could not find CACHE variable " << *ni
<< ". Perhaps it has not yet been created.";
this->SetError(e.str());
@@ -513,7 +513,7 @@ bool cmSetPropertyCommand::HandleInstallMode()
}
else
{
- cmOStringStream e;
+ std::ostringstream e;
e << "given INSTALL name that could not be found or created: " << *i;
this->SetError(e.str());
return false;
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index bf3519c..aeb8077 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -61,7 +61,7 @@ bool cmSetTargetPropertiesCommand
return false;
}
}
- if(propertyPairs.size() == 0)
+ if(propertyPairs.empty())
{
this->SetError("called with illegal arguments, maybe missing "
"a PROPERTIES specifier?");
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index b026ff3..e66d13d 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -62,7 +62,7 @@ bool cmSetTestsPropertiesCommand
return false;
}
}
- if(propertyPairs.size() == 0)
+ if(propertyPairs.empty())
{
this->SetError("called with illegal arguments, maybe "
"missing a PROPERTIES specifier?");
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index e61caab..927888b 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -66,7 +66,7 @@ bool cmSiteNameCommand
&host, 0, 0, cmSystemTools::OUTPUT_NONE);
// got the hostname
- if (host.length())
+ if (!host.empty())
{
// remove any white space from the host name
std::string hostRegExp = "[ \t\n\r]*([^\t\n\r ]*)[ \t\n\r]*";
@@ -77,7 +77,7 @@ bool cmSiteNameCommand
host = hostReg.match(1);
}
- if(host.length())
+ if(!host.empty())
{
siteName = host;
}
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 12eb411..6847475 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -179,7 +179,7 @@ bool cmSourceFile::FindFullPath(std::string* error)
tryPath += "/";
}
tryPath += this->Location.GetName();
- tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di);
+ tryPath = cmSystemTools::CollapseFullPath(tryPath, *di);
if(this->TryFullPath(tryPath, ""))
{
return true;
@@ -202,7 +202,7 @@ bool cmSourceFile::FindFullPath(std::string* error)
}
}
- cmOStringStream e;
+ std::ostringstream e;
std::string missing = this->Location.GetDirectory();
if(!missing.empty())
{
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 004fd1f..b81951d 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -63,7 +63,7 @@ cmSourceFileLocation
if (cmSystemTools::FileIsFullPath(this->Directory.c_str()))
{
this->Directory
- = cmSystemTools::CollapseFullPath(this->Directory.c_str());
+ = cmSystemTools::CollapseFullPath(this->Directory);
}
this->Name = cmSystemTools::GetFilenameName(name);
this->UpdateExtension(name);
@@ -92,7 +92,7 @@ void cmSourceFileLocation::DirectoryUseSource()
{
this->Directory =
cmSystemTools::CollapseFullPath(
- this->Directory.c_str(), this->Makefile->GetCurrentDirectory());
+ this->Directory, this->Makefile->GetCurrentDirectory());
this->AmbiguousDirectory = false;
}
}
@@ -105,7 +105,7 @@ void cmSourceFileLocation::DirectoryUseBinary()
{
this->Directory =
cmSystemTools::CollapseFullPath(
- this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory());
+ this->Directory, this->Makefile->GetCurrentOutputDirectory());
this->AmbiguousDirectory = false;
}
}
@@ -281,10 +281,10 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
// Compare possible directory combinations.
std::string const& srcDir =
cmSystemTools::CollapseFullPath(
- this->Directory.c_str(), this->Makefile->GetCurrentDirectory());
+ this->Directory, this->Makefile->GetCurrentDirectory());
std::string const& binDir =
cmSystemTools::CollapseFullPath(
- this->Directory.c_str(), this->Makefile->GetCurrentOutputDirectory());
+ this->Directory, this->Makefile->GetCurrentOutputDirectory());
if(srcDir != loc.Directory &&
binDir != loc.Directory)
{
@@ -296,10 +296,10 @@ bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
// Compare possible directory combinations.
std::string const& srcDir =
cmSystemTools::CollapseFullPath(
- loc.Directory.c_str(), loc.Makefile->GetCurrentDirectory());
+ loc.Directory, loc.Makefile->GetCurrentDirectory());
std::string const& binDir =
cmSystemTools::CollapseFullPath(
- loc.Directory.c_str(), loc.Makefile->GetCurrentOutputDirectory());
+ loc.Directory, loc.Makefile->GetCurrentOutputDirectory());
if(srcDir != this->Directory &&
binDir != this->Directory)
{
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index edba5ba..1741e05 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -90,7 +90,7 @@ bool cmSourceGroupCommand
}
else
{
- cmOStringStream err;
+ std::ostringstream err;
err << "Unknown argument \"" << args[i] << "\". "
<< "Perhaps the FILES keyword is missing.\n";
this->SetError(err.str());
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index 8baf7b3..646300d 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -16,8 +16,6 @@
#ifndef cmStandardIncludes_h
#define cmStandardIncludes_h
-// include configure generated header to define CMAKE_NO_ANSI_STREAM_HEADERS,
-// CMAKE_NO_STD_NAMESPACE, and other macros.
#include <cmConfigure.h>
#include <cmsys/Configure.hxx>
@@ -25,15 +23,8 @@
#pragma warning ( disable : 4786 )
#pragma warning ( disable : 4503 )
#pragma warning ( disable : 4512 ) /* operator=() could not be generated */
-#define CMAKE_NO_ANSI_FOR_SCOPE
#endif
-#ifdef __BORLANDC__
-# pragma warn -8030 /* Temporary used for parameter */
-# pragma warn -8027 /* 'for' not inlined. */
-# pragma warn -8026 /* 'exception' not inlined. */
-# pragma warn -8004 /* value never used */
-#endif
#ifdef __ICL
#pragma warning ( disable : 985 )
@@ -43,63 +34,23 @@
// Provide fixed-size integer types.
#include <cmIML/INT.h>
-#include <stdarg.h> // Work-around for SGI MIPSpro 7.4.2m header bug
-
-// This is a hack to prevent warnings about these functions being
-// declared but not referenced.
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 3970 /* conversion from pointer to same-sized */
-# include <sys/termios.h>
-class cmStandardIncludesHack
-{
-public:
- enum
- {
- Ref1 = sizeof(cfgetospeed(0)),
- Ref2 = sizeof(cfgetispeed(0)),
- Ref3 = sizeof(tcgetattr(0, 0)),
- Ref4 = sizeof(tcsetattr(0, 0, 0)),
- Ref5 = sizeof(cfsetospeed(0,0)),
- Ref6 = sizeof(cfsetispeed(0,0))
- };
-};
-#endif
-
// Include stream compatibility layer from KWSys.
// This is needed to work with large file support
// on some platforms whose stream operators do not
// support the large integer types.
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include <cmsys/IOStream.hxx>
-# undef GetCurrentDirectory // Borland <iosfwd> includes windows.h
#endif
// Avoid warnings in system headers.
#if defined(_MSC_VER)
# pragma warning (push,1)
#endif
-#if defined(__BORLANDC__)
-# pragma warn -8008 /* condition is always false (RESET BELOW!) */
-# pragma warn -8066 /* unreachable code (RESET BELOW!) */
-#endif
-
-#ifndef CMAKE_NO_ANSI_STREAM_HEADERS
-# include <fstream>
-# include <iostream>
-# include <iomanip>
-#else
-# include <fstream.h>
-# include <iostream.h>
-# include <iomanip.h>
-#endif
-#if !defined(CMAKE_NO_ANSI_STRING_STREAM)
-# include <sstream>
-#elif !defined(CMAKE_NO_ANSI_STREAM_HEADERS)
-# include <strstream>
-#else
-# include <strstream.h>
-#endif
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
// we must have stl with the standard include style
#include <vector>
@@ -112,10 +63,6 @@ public:
#include <set>
#include <deque>
-#if defined(__BORLANDC__)
-# pragma warn .8008 /* condition is always false (disabled above) */
-# pragma warn .8066 /* unreachable code (disabled above) */
-#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
@@ -125,199 +72,18 @@ public:
#include <stdio.h>
#include <stdlib.h>
-// Borland C++ defines several of the stdlib.h and string.h symbols in
-// sub-headers search.h and mem.h. These sub-headers have using
-// declarations to pull functions from the std namespace to the global
-// namespace, but they are defined only if the header was not included
-// through the C++-style cstdlib or cstring header. These outer
-// headers are included by the streams library in C++-style and
-// include blockers are put in place that prevent including the
-// C-style versions from ever including the sub-headers. Therefore we
-// have to include the sub-headers here to get the using declarations.
-#if defined(__BORLANDC__)
-# include <mem.h> /* mem... functions from string.h */
-# include <search.h> /* search functions from stdlib.h */
-#endif
-
-
-#if !defined(_WIN32) && defined(__COMO__)
-// Hack for como strict mode to avoid defining _SVID_SOURCE or _BSD_SOURCE.
-extern "C"
-{
-extern FILE *popen (__const char *__command, __const char *__modes) __THROW;
-extern int pclose (FILE *__stream) __THROW;
-extern char *realpath (__const char *__restrict __name,
- char *__restrict __resolved) __THROW;
-extern char *strdup (__const char *__s) __THROW;
-extern int putenv (char *__string) __THROW;
-}
-#endif
-
-// if std:: is not supported, then just #define it away
-#ifdef CMAKE_NO_STD_NAMESPACE
-#define std
-#endif
-
-// if the compiler does not support ansi for scoping of vars use a
-// #define hack
-#ifdef CMAKE_NO_ANSI_FOR_SCOPE
-#define for if(false) {} else for
-#endif
-
-// Provide std::ios_base on ancient GCC 2.9x
-#if defined(__GNUC__) && __GNUC__ < 3
-namespace std { typedef ios ios_base; }
-#endif
-
-// check for the 720 compiler on the SGI
-// which has some strange properties that I don't think are worth
-// checking for in a general way in configure
-#if defined(__sgi) && !defined(__GNUC__)
-# if (_COMPILER_VERSION >= 730)
-# define CM_SGI_CC_730
-# elif (_COMPILER_VERSION >= 720)
-# define CM_HAS_STD_BUT_NOT_FOR_IOSTREAM
-# endif
-#endif
-
-#ifdef __DECCXX_VER
-# if __DECCXX_VER <= 60390008
-# define CM_HAS_STD_BUT_NOT_FOR_IOSTREAM
-# endif
-#endif
-
#if defined( _MSC_VER )
typedef unsigned short mode_t;
#endif
-
-#ifdef CM_HAS_STD_BUT_NOT_FOR_IOSTREAM
-// some compilers have std:: but not for the stream library,
-// so we have to bring it into the std namespace by hand.
-namespace std {
-using ::ostream;
-using ::istream;
-using ::ios;
-using ::cout;
-using ::cerr;
-using ::cin;
-using ::ifstream;
-using ::ofstream;
-
-#if !defined(CMAKE_NO_ANSI_STRING_STREAM)
- using ::ostringstream;
- using ::istringstream;
-#else
- using ::ostrstream;
- using ::istrstream;
-#endif
-
-using ::endl;
-using ::ends;
-using ::flush;
-using ::dec;
-using ::hex;
-using ::setw;
-using ::setiosflags;
-using ::setfill;
-using ::setprecision;
-}
-// The string class is missing these operators so add them
-#if !defined(cmsys_STL_STRING_NEQ_CHAR_DEFINED)
-# define cmsys_STL_STRING_NO_NEQ_CHAR
-inline bool operator!=(std::string const& a, const char* b)
-{ return !(a==std::string(b)); }
-#endif
-
-inline bool operator==(std::string const& a, const char* b)
-{ return (a==std::string(b)); }
-# endif // end CM_SGI_CC_720
-
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 1375 /* base class destructor not virtual */
-#endif
-
// use this class to shrink the size of symbols in .o files
// std::string is really basic_string<....lots of stuff....>
// when combined with a map or set, the symbols can be > 2000 chars!
#include <cmsys/String.hxx>
//typedef cmsys::String std::string;
-// Define cmOStringStream and cmIStringStream wrappers to hide
-// differences between std::stringstream and the old strstream.
-#if !defined(CMAKE_NO_ANSI_STRING_STREAM)
-class cmOStringStream: public std::ostringstream
-{
-public:
- cmOStringStream();
- ~cmOStringStream();
-private:
- cmOStringStream(const cmOStringStream&);
- void operator=(const cmOStringStream&);
-};
-class cmIStringStream: public std::istringstream
-{
-public:
- typedef std::istringstream Superclass;
- cmIStringStream() {}
- cmIStringStream(const std::string& s): Superclass(s) {}
-private:
- cmIStringStream(const cmIStringStream&);
- void operator=(const cmIStringStream&);
-};
-#else
-class cmOStrStreamCleanup
-{
-public:
- cmOStrStreamCleanup(std::ostrstream& ostr): OStrStream(ostr) {}
- ~cmOStrStreamCleanup() { this->OStrStream.rdbuf()->freeze(0); }
- static void IgnoreUnusedVariable(const cmOStrStreamCleanup&) {}
-protected:
- std::ostrstream& OStrStream;
-};
-
-class cmOStringStream: public std::ostrstream
-{
-public:
- typedef std::ostrstream Superclass;
- cmOStringStream() {}
- std::string str()
- {
- cmOStrStreamCleanup cleanup(*this);
- cmOStrStreamCleanup::IgnoreUnusedVariable(cleanup);
- int pcount = this->pcount();
- const char* ptr = this->Superclass::str();
- return std::string(ptr?ptr:"", pcount);
- }
-private:
- cmOStringStream(const cmOStringStream&);
- void operator=(const cmOStringStream&);
-};
-
-class cmIStringStream: private std::string, public std::istrstream
-{
-public:
- typedef std::string StdString;
- typedef std::istrstream IStrStream;
- cmIStringStream(): StdString(), IStrStream(StdString::c_str()) {}
- cmIStringStream(const std::string& s):
- StdString(s), IStrStream(StdString::c_str()) {}
- std::string str() const { return *this; }
- void str(const std::string& s)
- {
- // Very dangerous. If this throws, the object is hosed. When the
- // destructor is later called, the program is hosed too.
- this->~cmIStringStream();
- new (this) cmIStringStream(s);
- }
-private:
- cmIStringStream(const cmIStringStream&);
- void operator=(const cmIStringStream&);
-};
-#endif
-
/* Poison this operator to avoid common mistakes. */
-extern void operator << (std::ostream&, const cmOStringStream&);
+extern void operator << (std::ostream&, const std::ostringstream&);
/** Standard documentation entry for cmDocumentation's formatting. */
struct cmDocumentationEntry
@@ -350,10 +116,6 @@ public:
typedef Superclass::const_iterator const_iterator;
};
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma reset woff 1375 /* base class destructor not virtual */
-#endif
-
// All subclasses of cmCommand or cmCTestGenericHandler should
// invoke this macro.
#define cmTypeMacro(thisClass,superclass) \
@@ -381,6 +143,33 @@ static thisClass* SafeDownCast(cmObject *c) \
} \
class cmTypeMacro_UseTrailingSemicolon
+template<typename Range>
+std::string cmJoin(Range const& r, const char* delimiter)
+{
+ if (r.empty())
+ {
+ return std::string();
+ }
+ std::ostringstream os;
+ typedef typename Range::value_type ValueType;
+ typedef typename Range::const_iterator InputIt;
+ InputIt first = r.begin();
+ InputIt last = r.end();
+ --last;
+ std::copy(first, last,
+ std::ostream_iterator<ValueType>(os, delimiter));
+
+ os << *last;
+
+ return os.str();
+}
+
+template<typename Range>
+std::string cmJoin(Range const& r, std::string delimiter)
+{
+ return cmJoin(r, delimiter.c_str());
+};
+
inline bool cmHasLiteralPrefixImpl(const std::string &str1,
const char *str2,
size_t N)
@@ -411,22 +200,6 @@ inline bool cmHasLiteralSuffixImpl(const char* str1,
return len >= N && strcmp(str1 + len - N, str2) == 0;
}
-#if defined(_MSC_VER) && _MSC_VER < 1300 \
- || defined(__GNUC__) && __GNUC__ < 3 \
- || defined(__BORLANDC__)
-
-#define cmArrayBegin(a) a
-#define cmArraySize(a) (sizeof(a)/sizeof(*a))
-#define cmArrayEnd(a) a + cmArraySize(a)
-
-#define cmHasLiteralPrefix(STR1, STR2) \
- cmHasLiteralPrefixImpl(STR1, "" STR2 "", sizeof(STR2) - 1)
-
-#define cmHasLiteralSuffix(STR1, STR2) \
- cmHasLiteralSuffixImpl(STR1, "" STR2 "", sizeof(STR2) - 1)
-
-#else
-
template<typename T, size_t N>
const T* cmArrayBegin(const T (&a)[N]) { return a; }
template<typename T, size_t N>
@@ -446,8 +219,6 @@ bool cmHasLiteralSuffix(T str1, const char (&str2)[N])
return cmHasLiteralSuffixImpl(str1, str2, N - 1);
}
-#endif
-
struct cmStrCmp {
cmStrCmp(const char *test) : m_test(test) {}
cmStrCmp(const std::string &test) : m_test(test) {}
@@ -466,4 +237,44 @@ private:
const std::string m_test;
};
+namespace ContainerAlgorithms {
+
+template<typename T>
+struct cmIsPair
+{
+ enum { value = false };
+};
+
+template<typename K, typename V>
+struct cmIsPair<std::pair<K, V> >
+{
+ enum { value = true };
+};
+
+template<typename Container,
+ bool valueTypeIsPair = cmIsPair<typename Container::value_type>::value>
+struct DefaultDeleter
+{
+ void operator()(typename Container::value_type value) {
+ delete value;
+ }
+};
+
+template<typename Container>
+struct DefaultDeleter<Container, /* valueTypeIsPair = */ true>
+{
+ void operator()(typename Container::value_type value) {
+ delete value.second;
+ }
+};
+
+}
+
+template<typename Container>
+void cmDeleteAll(Container const& c)
+{
+ std::for_each(c.begin(), c.end(),
+ ContainerAlgorithms::DefaultDeleter<Container>());
+}
+
#endif
diff --git a/Source/cmStandardLexer.h b/Source/cmStandardLexer.h
index acd636c..bd08ac7 100644
--- a/Source/cmStandardLexer.h
+++ b/Source/cmStandardLexer.h
@@ -25,31 +25,6 @@
# pragma warning ( disable : 4786 )
#endif
-#if defined(__BORLANDC__)
-# pragma warn -8008 /* condition always returns true */
-# pragma warn -8066 /* unreachable code */
-#endif
-
-/* Borland system header defines these macros without first undef-ing them. */
-#if defined(__BORLANDC__) && __BORLANDC__ >= 0x580
-# undef INT8_MIN
-# undef INT16_MIN
-# undef INT32_MIN
-# undef INT8_MAX
-# undef INT16_MAX
-# undef INT32_MAX
-# undef UINT8_MAX
-# undef UINT16_MAX
-# undef UINT32_MAX
-# include <stdint.h>
-#endif
-
-/* Make sure SGI termios does not define ECHO differently. */
-#if defined(__sgi) && !defined(__GNUC__)
-# include <sys/termios.h>
-# undef ECHO
-#endif
-
/* Define isatty on windows. */
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <io.h>
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 93aa083..3e606d7 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -122,7 +122,7 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
#if defined(CMAKE_BUILD_WITH_CMAKE)
if(args.size() != 3)
{
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " requires an output variable and an input string";
this->SetError(e.str());
return false;
@@ -137,7 +137,7 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
}
return false;
#else
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " not available during bootstrap";
this->SetError(e.str().c_str());
return false;
@@ -233,7 +233,7 @@ bool cmStringCommand::HandleConfigureCommand(
}
else
{
- cmOStringStream err;
+ std::ostringstream err;
err << "Unrecognized argument \"" << args[i] << "\"";
this->SetError(err.str());
return false;
@@ -310,7 +310,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
input += args[i];
}
- this->ClearMatches(this->Makefile);
+ this->Makefile->ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
if(!re.compile(regex.c_str()))
@@ -325,7 +325,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
std::string output;
if(re.find(input.c_str()))
{
- this->StoreMatches(this->Makefile, re);
+ this->Makefile->StoreMatches(re);
std::string::size_type l = re.start();
std::string::size_type r = re.end();
if(r-l == 0)
@@ -359,7 +359,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
input += args[i];
}
- this->ClearMatches(this->Makefile);
+ this->Makefile->ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
if(!re.compile(regex.c_str()))
@@ -376,7 +376,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
const char* p = input.c_str();
while(re.find(p))
{
- this->StoreMatches(this->Makefile, re);
+ this->Makefile->StoreMatches(re);
std::string::size_type l = re.start();
std::string::size_type r = re.end();
if(r-l == 0)
@@ -386,7 +386,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
this->SetError(e);
return false;
}
- if(output.length() > 0)
+ if(!output.empty())
{
output += ";";
}
@@ -463,7 +463,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
input += args[i];
}
- this->ClearMatches(this->Makefile);
+ this->Makefile->ClearMatches();
// Compile the regular expression.
cmsys::RegularExpression re;
if(!re.compile(regex.c_str()))
@@ -480,7 +480,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
std::string::size_type base = 0;
while(re.find(input.c_str()+base))
{
- this->StoreMatches(this->Makefile, re);
+ this->Makefile->StoreMatches(re);
std::string::size_type l2 = re.start();
std::string::size_type r = re.end();
@@ -541,38 +541,6 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
}
//----------------------------------------------------------------------------
-void cmStringCommand::ClearMatches(cmMakefile* mf)
-{
- for (unsigned int i=0; i<10; i++)
- {
- char name[128];
- sprintf(name, "CMAKE_MATCH_%d", i);
- const char* s = mf->GetDefinition(name);
- if(s && *s != 0)
- {
- mf->AddDefinition(name, "");
- mf->MarkVariableAsUsed(name);
- }
- }
-}
-
-//----------------------------------------------------------------------------
-void cmStringCommand::StoreMatches(cmMakefile* mf,cmsys::RegularExpression& re)
-{
- for (unsigned int i=0; i<10; i++)
- {
- std::string m = re.match(i);
- if(m.size() > 0)
- {
- char name[128];
- sprintf(name, "CMAKE_MATCH_%d", i);
- mf->AddDefinition(name, re.match(i).c_str());
- mf->MarkVariableAsUsed(name);
- }
- }
-}
-
-//----------------------------------------------------------------------------
bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
args)
{
@@ -623,7 +591,7 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
}
if(std::string::npos != pos)
{
- cmOStringStream s;
+ std::ostringstream s;
s << pos;
this->Makefile->AddDefinition(outvar, s.str().c_str());
return true;
@@ -737,18 +705,16 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
int intStringLength = static_cast<int>(stringLength);
if ( begin < 0 || begin > intStringLength )
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "begin index: " << begin << " is out of range 0 - "
<< stringLength;
this->SetError(ostr.str());
return false;
}
- int leftOverLength = intStringLength - begin;
- if ( end < -1 || end > leftOverLength )
+ if ( end < -1 )
{
- cmOStringStream ostr;
- ostr << "end index: " << end << " is out of range -1 - "
- << leftOverLength;
+ std::ostringstream ostr;
+ ostr << "end index: " << end << " should be -1 or greater";
this->SetError(ostr.str());
return false;
}
@@ -814,7 +780,7 @@ bool cmStringCommand
const std::string& variableName = args[2];
this->Makefile->AddDefinition(variableName,
- cmSystemTools::MakeCidentifier(input.c_str()).c_str());
+ cmSystemTools::MakeCidentifier(input).c_str());
return true;
}
@@ -932,7 +898,7 @@ bool cmStringCommand
}
}
}
- if ( !alphabet.size() )
+ if (alphabet.empty())
{
alphabet = cmStringCommandDefaultAlphabet;
}
@@ -1123,7 +1089,7 @@ bool cmStringCommand
this->Makefile->AddDefinition(outputVariable, uuid.c_str());
return true;
#else
- cmOStringStream e;
+ std::ostringstream e;
e << args[0] << " not available during bootstrap";
this->SetError(e.str().c_str());
return false;
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index a5fe893..9c75095 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -53,8 +53,6 @@ public:
virtual std::string GetName() const { return "string";}
cmTypeMacro(cmStringCommand, cmCommand);
- static void ClearMatches(cmMakefile* mf);
- static void StoreMatches(cmMakefile* mf, cmsys::RegularExpression& re);
protected:
bool HandleConfigureCommand(std::vector<std::string> const& args);
bool HandleAsciiCommand(std::vector<std::string> const& args);
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index cdde916..93ad4f3 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -42,7 +42,7 @@ bool cmSubdirCommand
std::string srcPath =
std::string(this->Makefile->GetCurrentDirectory()) +
"/" + i->c_str();
- if (cmSystemTools::FileIsDirectory(srcPath.c_str()))
+ if (cmSystemTools::FileIsDirectory(srcPath))
{
std::string binPath =
std::string(this->Makefile->GetCurrentOutputDirectory()) +
@@ -51,7 +51,7 @@ bool cmSubdirCommand
excludeFromAll, preorder, false);
}
// otherwise it is a full path
- else if ( cmSystemTools::FileIsDirectory(i->c_str()) )
+ else if ( cmSystemTools::FileIsDirectory(*i) )
{
// we must compute the binPath from the srcPath, we just take the last
// element from the source path and use that
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index fbb4416..6a7467f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -9,9 +9,7 @@
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
-#if defined(_MSC_VER) && _MSC_VER < 1300
-# define _WIN32_WINNT 0x0400 /* for wincrypt.h */
-#endif
+
#include "cmSystemTools.h"
#include <ctype.h>
#include <errno.h>
@@ -28,6 +26,7 @@
#include <cmsys/Encoding.hxx>
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include "cmArchiveWrite.h"
+# include "cmLocale.h"
# include <cm_libarchive.h>
# include <cmsys/Terminal.h>
#endif
@@ -52,8 +51,7 @@
#include <sys/stat.h>
#if defined(_WIN32) && \
- (defined(_MSC_VER) || defined(__WATCOMC__) || \
- defined(__BORLANDC__) || defined(__MINGW32__))
+ (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__MINGW32__))
# include <io.h>
#endif
@@ -66,6 +64,10 @@
# include "cmELF.h"
#endif
+#if defined(CMAKE_USE_MACH_PARSER)
+# include "cmMachO.h"
+#endif
+
class cmSystemToolsFileTime
{
public:
@@ -78,10 +80,6 @@ public:
#endif
};
-#if defined(__sgi) && !defined(__GNUC__)
-# pragma set woff 1375 /* base class destructor not virtual */
-#endif
-
#if !defined(HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
// For GetEnvironmentVariables
# if defined(_WIN32)
@@ -97,7 +95,7 @@ cm_archive_entry_pathname(struct archive_entry *entry)
{
#if cmsys_STL_HAS_WSTRING
return cmsys::Encoding::ToNarrow(
- archive_entry_pathname_w(entry)).c_str();
+ archive_entry_pathname_w(entry));
#else
return archive_entry_pathname(entry);
#endif
@@ -827,18 +825,12 @@ bool cmSystemTools::RunSingleCommand(
std::string
cmSystemTools::PrintSingleCommand(std::vector<std::string> const& command)
{
- std::string commandStr;
- const char* sep = "";
- for(std::vector<std::string>::const_iterator i = command.begin();
- i != command.end(); ++i)
+ if (command.empty())
{
- commandStr += sep;
- commandStr += "\"";
- commandStr += *i;
- commandStr += "\"";
- sep = " ";
+ return std::string();
}
- return commandStr;
+
+ return "\"" + cmJoin(command, "\" \"") + "\"";
}
bool cmSystemTools::DoesFileExistWithExtensions(
@@ -881,7 +873,7 @@ std::string cmSystemTools::FileExistsInParentDirectories(const char* fname,
break;
}
prevDir = dir;
- dir = cmSystemTools::GetParentDirectory(dir.c_str());
+ dir = cmSystemTools::GetParentDirectory(dir);
}
return "";
}
@@ -1014,7 +1006,7 @@ void cmSystemTools::Glob(const std::string& directory,
cmsys::Directory d;
cmsys::RegularExpression reg(regexp.c_str());
- if (d.Load(directory.c_str()))
+ if (d.Load(directory))
{
size_t numf;
unsigned int i;
@@ -1044,7 +1036,7 @@ void cmSystemTools::GlobDirs(const std::string& path,
std::string finishPath = path.substr(pos+2);
cmsys::Directory d;
- if (d.Load(startPath.c_str()))
+ if (d.Load(startPath))
{
for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i)
{
@@ -1054,7 +1046,7 @@ void cmSystemTools::GlobDirs(const std::string& path,
std::string fname = startPath;
fname +="/";
fname += d.GetFile(i);
- if(cmSystemTools::FileIsDirectory(fname.c_str()))
+ if(cmSystemTools::FileIsDirectory(fname))
{
fname += finishPath;
cmSystemTools::GlobDirs(fname, files);
@@ -1161,14 +1153,14 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
std::string path = cmSystemTools::GetFilenamePath(glob);
std::string ppath = cmSystemTools::GetFilenameName(glob);
ppath = ppath.substr(0, ppath.size()-1);
- if ( path.size() == 0 )
+ if (path.empty())
{
path = "/";
}
bool res = false;
cmsys::Directory d;
- if (d.Load(path.c_str()))
+ if (d.Load(path))
{
for (unsigned int i = 0; i < d.GetNumberOfFiles(); ++i)
{
@@ -1182,11 +1174,11 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
}
fname += d.GetFile(i);
std::string sfname = d.GetFile(i);
- if ( type > 0 && cmSystemTools::FileIsDirectory(fname.c_str()) )
+ if ( type > 0 && cmSystemTools::FileIsDirectory(fname) )
{
continue;
}
- if ( type < 0 && !cmSystemTools::FileIsDirectory(fname.c_str()) )
+ if ( type < 0 && !cmSystemTools::FileIsDirectory(fname) )
{
continue;
}
@@ -1272,11 +1264,7 @@ bool cmSystemTools::Split(const char* s, std::vector<std::string>& l)
{
std::vector<std::string> temp;
bool res = Superclass::Split(s, temp);
- for(std::vector<std::string>::const_iterator i = temp.begin();
- i != temp.end(); ++i)
- {
- l.push_back(*i);
- }
+ l.insert(l.end(), temp.begin(), temp.end());
return res;
}
@@ -1354,8 +1342,8 @@ std::string cmSystemTools::CollapseCombinedPath(std::string const& dir,
std::vector<std::string> dirComponents;
std::vector<std::string> fileComponents;
- cmSystemTools::SplitPath(dir.c_str(), dirComponents);
- cmSystemTools::SplitPath(file.c_str(), fileComponents);
+ cmSystemTools::SplitPath(dir, dirComponents);
+ cmSystemTools::SplitPath(file, fileComponents);
if(fileComponents.empty())
{
@@ -1410,7 +1398,7 @@ void cmSystemTools::AppendEnv(std::vector<std::string> const& env)
for(std::vector<std::string>::const_iterator eit = env.begin();
eit != env.end(); ++eit)
{
- cmSystemTools::PutEnv(eit->c_str());
+ cmSystemTools::PutEnv(*eit);
}
}
@@ -1481,7 +1469,8 @@ bool cmSystemTools::IsPathToFramework(const char* path)
bool cmSystemTools::CreateTar(const char* outFileName,
const std::vector<std::string>& files,
- bool gzip, bool bzip2, bool verbose)
+ cmTarCompression compressType,
+ bool verbose, std::string const& mtime)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
@@ -1495,10 +1484,25 @@ bool cmSystemTools::CreateTar(const char* outFileName,
cmSystemTools::Error(e.c_str());
return false;
}
- cmArchiveWrite a(fout, (gzip? cmArchiveWrite::CompressGZip :
- (bzip2? cmArchiveWrite::CompressBZip2 :
- cmArchiveWrite::CompressNone)),
- cmArchiveWrite::TypeTAR);
+ cmArchiveWrite::Compress compress = cmArchiveWrite::CompressNone;
+ switch (compressType)
+ {
+ case TarCompressGZip:
+ compress = cmArchiveWrite::CompressGZip;
+ break;
+ case TarCompressBZip2:
+ compress = cmArchiveWrite::CompressBZip2;
+ break;
+ case TarCompressXZ:
+ compress = cmArchiveWrite::CompressXZ;
+ break;
+ case TarCompressNone:
+ compress = cmArchiveWrite::CompressNone;
+ break;
+ }
+ cmArchiveWrite a(fout, compress,
+ cmArchiveWrite::TypeTAR);
+ a.SetMTime(mtime);
a.SetVerbose(verbose);
for(std::vector<std::string>::const_iterator i = files.begin();
i != files.end(); ++i)
@@ -1523,7 +1527,6 @@ bool cmSystemTools::CreateTar(const char* outFileName,
#else
(void)outFileName;
(void)files;
- (void)gzip;
(void)verbose;
return false;
#endif
@@ -1649,9 +1652,6 @@ namespace{
fprintf(out, " -> %s", archive_entry_symlink(entry));
}
}
-#ifdef __BORLANDC__
-# pragma warn -8066 /* unreachable code */
-#endif
long copy_data(struct archive *ar, struct archive *aw)
{
@@ -1691,6 +1691,8 @@ long copy_data(struct archive *ar, struct archive *aw)
bool extract_tar(const char* outFileName, bool verbose,
bool extract)
{
+ cmLocaleRAII localeRAII;
+ static_cast<void>(localeRAII);
struct archive* a = archive_read_new();
struct archive *ext = archive_write_disk_new();
archive_read_support_compression_all(a);
@@ -1787,7 +1789,7 @@ bool extract_tar(const char* outFileName, bool verbose,
#endif
bool cmSystemTools::ExtractTar(const char* outFileName,
- bool , bool verbose)
+ bool verbose)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
return extract_tar(outFileName, verbose, true);
@@ -1799,7 +1801,6 @@ bool cmSystemTools::ExtractTar(const char* outFileName,
}
bool cmSystemTools::ListTar(const char* outFileName,
- bool ,
bool verbose)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -2176,7 +2177,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
if(cmSystemTools::FindProgramPath(argv0, exe, errorMsg))
{
// remove symlinks
- exe = cmSystemTools::GetRealPath(exe.c_str());
+ exe = cmSystemTools::GetRealPath(exe);
exe_dir =
cmSystemTools::GetFilenamePath(exe);
}
@@ -2227,7 +2228,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
cmsys::ifstream fin(src_dir_txt.c_str());
std::string src_dir;
if(fin && cmSystemTools::GetLineFromStream(fin, src_dir) &&
- cmSystemTools::FileIsDirectory(src_dir.c_str()))
+ cmSystemTools::FileIsDirectory(src_dir))
{
cmSystemToolsCMakeRoot = src_dir;
}
@@ -2237,7 +2238,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
src_dir_txt = dir + "/CMakeFiles/CMakeSourceDir.txt";
cmsys::ifstream fin2(src_dir_txt.c_str());
if(fin2 && cmSystemTools::GetLineFromStream(fin2, src_dir) &&
- cmSystemTools::FileIsDirectory(src_dir.c_str()))
+ cmSystemTools::FileIsDirectory(src_dir))
{
cmSystemToolsCMakeRoot = src_dir;
}
@@ -2333,11 +2334,11 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
#endif
// If the file is not a symlink we have no guess for its soname.
- if(!cmSystemTools::FileIsSymlink(fullPath.c_str()))
+ if(!cmSystemTools::FileIsSymlink(fullPath))
{
return false;
}
- if(!cmSystemTools::ReadSymlink(fullPath.c_str(), soname))
+ if(!cmSystemTools::ReadSymlink(fullPath, soname))
{
return false;
}
@@ -2363,31 +2364,17 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
std::string& soname)
{
- std::vector<std::string> cmds;
- cmds.push_back("otool");
- cmds.push_back("-D");
- cmds.push_back(fullPath);
-
- std::string output;
- if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
+#if defined(CMAKE_USE_MACH_PARSER)
+ cmMachO macho(fullPath.c_str());
+ if(macho)
{
- cmds.insert(cmds.begin(), "-r");
- cmds.insert(cmds.begin(), "xcrun");
- if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
- {
- return false;
- }
+ return macho.GetInstallName(soname);
}
+#else
+ (void)fullPath;
+ (void)soname;
+#endif
- std::vector<std::string> strs = cmSystemTools::tokenize(output, "\n");
- // otool returns extra lines reporting multiple install names
- // in case the binary is multi-arch and none of the architectures
- // is native (e.g. i386;ppc on x86_64)
- if(strs.size() >= 2)
- {
- soname = strs[1];
- return true;
- }
return false;
}
@@ -2521,7 +2508,7 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
}
if(emsg)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The current " << se_name[i] << " is:\n"
<< " " << se[i]->Value << "\n"
<< "which does not contain:\n"
@@ -2638,29 +2625,37 @@ bool cmSystemTools::ChangeRPath(std::string const& file,
bool cmSystemTools::VersionCompare(cmSystemTools::CompareOp op,
const char* lhss, const char* rhss)
{
- // Parse out up to 8 components.
- unsigned int lhs[8] = {0,0,0,0,0,0,0,0};
- unsigned int rhs[8] = {0,0,0,0,0,0,0,0};
- sscanf(lhss, "%u.%u.%u.%u.%u.%u.%u.%u",
- &lhs[0], &lhs[1], &lhs[2], &lhs[3],
- &lhs[4], &lhs[5], &lhs[6], &lhs[7]);
- sscanf(rhss, "%u.%u.%u.%u.%u.%u.%u.%u",
- &rhs[0], &rhs[1], &rhs[2], &rhs[3],
- &rhs[4], &rhs[5], &rhs[6], &rhs[7]);
+ const char *endl = lhss;
+ const char *endr = rhss;
+ unsigned long lhs, rhs;
- // Do component-wise comparison.
- for(unsigned int i=0; i < 8; ++i)
+ while (((*endl >= '0') && (*endl <= '9')) ||
+ ((*endr >= '0') && (*endr <= '9')))
{
- if(lhs[i] < rhs[i])
+ // Do component-wise comparison.
+ lhs = strtoul(endl, const_cast<char**>(&endl), 10);
+ rhs = strtoul(endr, const_cast<char**>(&endr), 10);
+
+ if(lhs < rhs)
{
// lhs < rhs, so true if operation is LESS
return op == cmSystemTools::OP_LESS;
}
- else if(lhs[i] > rhs[i])
+ else if(lhs > rhs)
{
// lhs > rhs, so true if operation is GREATER
return op == cmSystemTools::OP_GREATER;
}
+
+ if (*endr == '.')
+ {
+ endr++;
+ }
+
+ if (*endl == '.')
+ {
+ endl++;
+ }
}
// lhs == rhs, so true if operation is EQUAL
return op == cmSystemTools::OP_EQUAL;
@@ -2921,3 +2916,12 @@ std::vector<std::string> cmSystemTools::tokenize(const std::string& str,
}
return tokens;
}
+
+//----------------------------------------------------------------------------
+bool cmSystemTools::StringToLong(const char* str, long* value)
+{
+ errno = 0;
+ char *endp;
+ *value = strtol(str, &endp, 10);
+ return (*endp == '\0') && (endp != str) && (errno == 0);
+}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 4455dd1..361f42e 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -383,13 +383,20 @@ public:
static void EnableVSConsoleOutput();
/** Create tar */
+ enum cmTarCompression
+ {
+ TarCompressGZip,
+ TarCompressBZip2,
+ TarCompressXZ,
+ TarCompressNone
+ };
static bool ListTar(const char* outFileName,
- bool gzip, bool verbose);
+ bool verbose);
static bool CreateTar(const char* outFileName,
- const std::vector<std::string>& files, bool gzip,
- bool bzip2, bool verbose);
- static bool ExtractTar(const char* inFileName, bool gzip,
- bool verbose);
+ const std::vector<std::string>& files,
+ cmTarCompression compressType, bool verbose,
+ std::string const& mtime = std::string());
+ static bool ExtractTar(const char* inFileName, bool verbose);
// This should be called first thing in main
// it will keep child processes from inheriting the
// stdin and stdout of this process. This is important
@@ -458,6 +465,9 @@ public:
static std::vector<std::string> tokenize(const std::string& str,
const std::string& sep);
+ /** Convert string to long. Expected that the whole string is an integer */
+ static bool StringToLong(const char* str, long* value);
+
#ifdef _WIN32
struct WindowsFileRetry
{
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 4ebc1ce..98cb75c 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -226,13 +226,7 @@ cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem;
static void deleteAndClear(
std::vector<cmTargetInternals::TargetPropertyEntry*> &entries)
{
- for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
- it = entries.begin(),
- end = entries.end();
- it != end; ++it)
- {
- delete *it;
- }
+ cmDeleteAll(entries);
entries.clear();
}
@@ -325,6 +319,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY)
{
this->SetPropertyDefault("ANDROID_API", 0);
+ this->SetPropertyDefault("ANDROID_API_MIN", 0);
this->SetPropertyDefault("INSTALL_NAME_DIR", 0);
this->SetPropertyDefault("INSTALL_RPATH", "");
this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF");
@@ -423,12 +418,8 @@ void cmTarget::SetMakefile(cmMakefile* mf)
const std::set<std::string> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories();
- for (std::set<std::string>::const_iterator it
- = parentSystemIncludes.begin();
- it != parentSystemIncludes.end(); ++it)
- {
- this->SystemIncludeDirectories.insert(*it);
- }
+ this->SystemIncludeDirectories.insert(parentSystemIncludes.begin(),
+ parentSystemIncludes.end());
const std::vector<cmValueWithOrigin> parentOptions =
this->Makefile->GetCompileOptionsEntries();
@@ -548,12 +539,7 @@ void cmTarget::ClearLinkMaps()
this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear();
this->Internal->LinkClosureMap.clear();
this->Internal->SourceFilesMap.clear();
- for (cmTargetLinkInformationMap::const_iterator it
- = this->LinkInformation.begin();
- it != this->LinkInformation.end(); ++it)
- {
- delete it->second;
- }
+ cmDeleteAll(this->LinkInformation);
this->LinkInformation.clear();
}
@@ -686,7 +672,7 @@ static bool processSources(cmTarget const* tgt,
if (!targetName.empty() && !cmSystemTools::FileIsFullPath(src.c_str()))
{
- cmOStringStream err;
+ std::ostringstream err;
if (!targetName.empty())
{
err << "Target \"" << targetName << "\" contains relative "
@@ -863,7 +849,7 @@ cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const
thisConfigFiles += (*fi)->GetFullPath();
sep = "\n ";
}
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << this->Name << "\" has source files which vary by "
"configuration. This is not supported by the \""
<< this->Makefile->GetLocalGenerator()
@@ -923,16 +909,7 @@ void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
//----------------------------------------------------------------------------
void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
{
- std::string srcFiles;
- const char* sep = "";
- for(std::vector<std::string>::const_iterator i = srcs.begin();
- i != srcs.end(); ++i)
- {
- std::string filename = *i;
- srcFiles += sep;
- srcFiles += filename;
- sep = ";";
- }
+ std::string srcFiles = cmJoin(srcs, ";");
if (!srcFiles.empty())
{
this->Internal->SourceFilesMap.clear();
@@ -996,7 +973,7 @@ std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
this->Makefile->ExpandVariablesInString(src);
if (src != s)
{
- cmOStringStream e;
+ std::ostringstream e;
bool noMessage = false;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0049))
@@ -1279,7 +1256,7 @@ bool cmTarget::PushTLLCommandTrace(TLLSignature signature)
}
//----------------------------------------------------------------------------
-void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
+void cmTarget::GetTllSignatureTraces(std::ostringstream &s,
TLLSignature sig) const
{
std::vector<cmListFileBacktrace> sigs;
@@ -1307,7 +1284,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
if(i != it->end())
{
cmListFileContext const& lfc = *i;
- cmOStringStream line;
+ std::ostringstream line;
line << " * " << (lfc.Line? "": " in ") << lfc << std::endl;
if (emitted.insert(line.str()).second)
{
@@ -1397,22 +1374,14 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
void
cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs)
{
- for(std::set<std::string>::const_iterator li = incs.begin();
- li != incs.end(); ++li)
- {
- this->SystemIncludeDirectories.insert(*li);
- }
+ this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
}
//----------------------------------------------------------------------------
void
cmTarget::AddSystemIncludeDirectories(const std::vector<std::string> &incs)
{
- for(std::vector<std::string>::const_iterator li = incs.begin();
- li != incs.end(); ++li)
- {
- this->SystemIncludeDirectories.insert(*li);
- }
+ this->SystemIncludeDirectories.insert(incs.begin(), incs.end());
}
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -1539,7 +1508,7 @@ cmTarget::AnalyzeLibDependenciesForVS6( const cmMakefile& mf )
{
// skip zero size library entries, this may happen
// if a variable expands to nothing.
- if (lib->first.size() != 0)
+ if (!lib->first.empty())
{
this->EmitForVS6( *lib, dep_map, done, visited, newLinkLibrariesForVS6 );
}
@@ -1679,7 +1648,7 @@ void cmTarget::GatherDependenciesForVS6( const cmMakefile& mf,
while( end != std::string::npos )
{
std::string l = depline.substr( start, end-start );
- if( l.size() != 0 )
+ if(!l.empty())
{
if (l == "debug")
{
@@ -1749,7 +1718,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1757,7 +1726,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
}
else if (prop == "NAME")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
@@ -1800,7 +1769,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
}
else if(prop == "EXPORT_NAME" && this->IsImported())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
<< this->Name << "\")\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1816,7 +1785,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
{
if(this->IsImported())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "SOURCES property can't be set on imported targets (\""
<< this->Name << "\")\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1844,7 +1813,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1852,7 +1821,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
}
else if (prop == "NAME")
{
- cmOStringStream e;
+ std::ostringstream e;
e << "NAME property is read-only\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
@@ -1887,7 +1856,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
}
else if(prop == "EXPORT_NAME" && this->IsImported())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
<< this->Name << "\")\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1902,7 +1871,7 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
{
if(this->IsImported())
{
- cmOStringStream e;
+ std::ostringstream e;
e << "SOURCES property can't be set on imported targets (\""
<< this->Name << "\")\n";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -1931,7 +1900,7 @@ std::string cmTarget::GetExportName() const
{
if (!cmGeneratorExpression::IsValidTargetName(exportName))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "EXPORT_NAME property \"" << exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
cmSystemTools::Error(e.str().c_str());
@@ -2043,7 +2012,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
if (fromImported
&& !cmSystemTools::FileExists(li->c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
cmake::MessageType messageType = cmake::FATAL_ERROR;
if (checkCMP0027)
{
@@ -2076,7 +2045,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
if (!cmSystemTools::FileIsFullPath(li->c_str()))
{
- cmOStringStream e;
+ std::ostringstream e;
bool noMessage = false;
cmake::MessageType messageType = cmake::FATAL_ERROR;
if (!targetName.empty())
@@ -2192,7 +2161,7 @@ cmTarget::GetIncludeDirectories(const std::string& config) const
it = impl->Libraries.begin();
it != impl->Libraries.end(); ++it)
{
- std::string libDir = cmSystemTools::CollapseFullPath(it->c_str());
+ std::string libDir = cmSystemTools::CollapseFullPath(*it);
static cmsys::RegularExpression
frameworkCheck("(.*\\.framework)(/Versions/[^/]+)?/[^/]+$");
@@ -2426,7 +2395,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
{
case cmPolicies::WARN:
{
- cmOStringStream e;
+ std::ostringstream e;
e << this->Makefile->GetCMakeInstance()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0043);
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
@@ -2559,7 +2528,7 @@ static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
"LINK_INTERFACE_LIBRARIES");
// Report an error.
- cmOStringStream e;
+ std::ostringstream e;
e << "Property " << prop << " may not contain link-type keyword \""
<< keys.match(2) << "\". "
<< "The " << base << " property has a per-configuration "
@@ -2596,7 +2565,7 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
}
// Report an error.
- cmOStringStream e;
+ std::ostringstream e;
e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type "
"keyword \"" << keys.match(2) << "\". The INTERFACE_LINK_LIBRARIES "
@@ -2895,7 +2864,7 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const
{
return true;
}
- cmOStringStream e;
+ std::ostringstream e;
const char *modal = 0;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch (context->GetPolicyStatus(cmPolicies::CMP0026))
@@ -2954,7 +2923,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
context->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -3130,7 +3099,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
return 0;
}
- cmOStringStream ss;
+ std::ostringstream ss;
const char* sep = "";
typedef cmTargetInternals::TargetPropertyEntry
TargetPropertyEntry;
@@ -3160,7 +3129,7 @@ const char *cmTarget::GetProperty(const std::string& prop,
bool addContent = false;
bool noMessage = true;
- cmOStringStream e;
+ std::ostringstream e;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(context->GetPolicyStatus(cmPolicies::CMP0051))
{
@@ -3258,7 +3227,7 @@ public:
{
bool noMessage = false;
cmake::MessageType messageType = cmake::FATAL_ERROR;
- cmOStringStream e;
+ std::ostringstream e;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028))
{
case cmPolicies::WARN:
@@ -3379,7 +3348,7 @@ public:
}
else if(this->Preferred.size() > 1)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference"
<< " (" << this->Preference << "):\n";
@@ -3751,7 +3720,7 @@ bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const
if(!this->Makefile->IsSet("CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG"))
{
- cmOStringStream w;
+ std::ostringstream w;
w << "Attempting to use";
if(macosx_rpath)
{
@@ -4057,15 +4026,8 @@ void cmTarget::GetFullNameInternal(const std::string& config,
if(this->IsCFBundleOnApple())
{
- fw_prefix = this->GetOutputName(config, false);
- fw_prefix += ".";
- const char *ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext)
- {
- ext = "bundle";
- }
- fw_prefix += ext;
- fw_prefix += "/Contents/MacOS/";
+ fw_prefix = this->GetCFBundleDirectory(config, false);
+ fw_prefix += "/";
targetPrefix = fw_prefix.c_str();
targetSuffix = 0;
}
@@ -4576,7 +4538,7 @@ bool cmTarget::ComputeOutputDir(const std::string& config,
// specified as a relative path. Treat a relative path as
// relative to the current output directory for this makefile.
out = (cmSystemTools::CollapseFullPath
- (out.c_str(), this->Makefile->GetStartOutputDirectory()));
+ (out, this->Makefile->GetStartOutputDirectory()));
// The generator may add the configuration's subdirectory.
if(!conf.empty())
@@ -4642,7 +4604,7 @@ bool cmTarget::ComputePDBOutputDir(const std::string& kind,
// specified as a relative path. Treat a relative path as
// relative to the current output directory for this makefile.
out = (cmSystemTools::CollapseFullPath
- (out.c_str(), this->Makefile->GetStartOutputDirectory()));
+ (out, this->Makefile->GetStartOutputDirectory()));
// The generator may add the configuration's subdirectory.
if(!conf.empty())
@@ -4734,7 +4696,7 @@ const char* cmTarget::GetExportMacro() const
{
std::string in = this->GetName();
in += "_EXPORTS";
- this->ExportMacro = cmSystemTools::MakeCindentifier(in.c_str());
+ this->ExportMacro = cmSystemTools::MakeCindentifier(in);
}
return this->ExportMacro.c_str();
}
@@ -4802,16 +4764,6 @@ std::pair<bool, const char*> consistentStringProperty(const char *lhs,
return std::make_pair(b, b ? lhs : 0);
}
-#if defined(_MSC_VER) && _MSC_VER <= 1200
-template<typename T> const T&
-cmMaximum(const T& l, const T& r) {return l > r ? l : r;}
-template<typename T> const T&
-cmMinimum(const T& l, const T& r) {return l < r ? l : r;}
-#else
-#define cmMinimum std::min
-#define cmMaximum std::max
-#endif
-
//----------------------------------------------------------------------------
std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
const char *rhs,
@@ -4819,11 +4771,7 @@ std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
{
char *pEnd;
-#if defined(_MSC_VER)
- static const char* const null_ptr = 0;
-#else
-# define null_ptr 0
-#endif
+ const char* const null_ptr = 0;
long lnum = strtol(lhs, &pEnd, 0);
if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE)
@@ -4837,17 +4785,13 @@ std::pair<bool, const char*> consistentNumberProperty(const char *lhs,
return std::pair<bool, const char*>(false, null_ptr);
}
-#if !defined(_MSC_VER)
-#undef null_ptr
-#endif
-
if (t == NumberMaxType)
{
- return std::make_pair(true, cmMaximum(lnum, rnum) == lnum ? lhs : rhs);
+ return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs);
}
else
{
- return std::make_pair(true, cmMinimum(lnum, rnum) == lnum ? lhs : rhs);
+ return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs);
}
}
@@ -4870,16 +4814,12 @@ std::pair<bool, const char*> consistentProperty(const char *lhs,
return std::make_pair(true, lhs);
}
-#if defined(_MSC_VER)
- static const char* const null_ptr = 0;
-#else
-# define null_ptr 0
-#endif
+ const char* const null_ptr = 0;
switch(t)
{
case BoolType:
- assert(!"consistentProperty for strings called with BoolType");
+ assert(0 && "consistentProperty for strings called with BoolType");
return std::pair<bool, const char*>(false, null_ptr);
case StringType:
return consistentStringProperty(lhs, rhs);
@@ -4887,13 +4827,8 @@ std::pair<bool, const char*> consistentProperty(const char *lhs,
case NumberMaxType:
return consistentNumberProperty(lhs, rhs, t);
}
- assert(!"Unreachable!");
+ assert(0 && "Unreachable!");
return std::pair<bool, const char*>(false, null_ptr);
-
-#if !defined(_MSC_VER)
-#undef null_ptr
-#endif
-
}
template<typename PropertyType>
@@ -4977,7 +4912,7 @@ std::string compatibilityType(CompatibleType t)
case NumberMinType:
return "Numeric minimum compatibility";
}
- assert(!"Unreachable!");
+ assert(0 && "Unreachable!");
return "";
}
@@ -4993,7 +4928,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant)
case NumberMinType:
return dominant ? "(Dominant)\n" : "(Ignored)\n";
}
- assert(!"Unreachable!");
+ assert(0 && "Unreachable!");
return "";
}
@@ -5083,7 +5018,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
report += compatibilityAgree(t, propContent != consistent.second);
if (!consistent.first)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Property " << p << " on target \""
<< tgt->GetName() << "\" does\nnot match the "
"INTERFACE_" << p << " property requirement\nof "
@@ -5116,7 +5051,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
report += compatibilityAgree(t, propContent != consistent.second);
if (!consistent.first)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Property " << p << " on target \""
<< tgt->GetName() << "\" is\nimplied to be " << defaultValue
<< " because it was used to determine the link libraries\n"
@@ -5150,7 +5085,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
report += compatibilityAgree(t, propContent != consistent.second);
if (!consistent.first)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The INTERFACE_" << p << " property of \""
<< theTarget->GetName() << "\" does\nnot agree with the value "
"of " << p << " already determined\nfor \""
@@ -5307,7 +5242,7 @@ cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const
{
continue;
}
- cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName.c_str());
+ cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName);
if(objLib)
{
objlibs.push_back(objLib);
@@ -6058,7 +5993,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
if (newExplicitLibraries
&& strcmp(newExplicitLibraries, explicitLibraries) != 0)
{
- cmOStringStream w;
+ std::ostringstream w;
w <<
(thisTarget->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0022)) << "\n"
@@ -6104,8 +6039,8 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
// The link implementation is the default link interface.
cmTarget::LinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget);
- std::copy(impl->Libraries.begin(), impl->Libraries.end(),
- std::back_inserter(iface.Libraries));
+ iface.Libraries.insert(iface.Libraries.end(),
+ impl->Libraries.begin(), impl->Libraries.end());
if(thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN &&
!this->PolicyWarnedCMP0022 && !usage_requirements_only)
{
@@ -6122,30 +6057,14 @@ cmTargetInternals::ComputeLinkInterfaceLibraries(
}
if (ifaceLibs != iface.Libraries)
{
- std::string oldLibraries;
- std::string newLibraries;
- const char *sep = "";
- for(std::vector<cmLinkImplItem>::const_iterator it
- = impl->Libraries.begin(); it != impl->Libraries.end(); ++it)
- {
- oldLibraries += sep;
- oldLibraries += *it;
- sep = ";";
- }
- sep = "";
- for(std::vector<cmLinkItem>::const_iterator it
- = ifaceLibs.begin(); it != ifaceLibs.end(); ++it)
- {
- newLibraries += sep;
- newLibraries += *it;
- sep = ";";
- }
+ std::string oldLibraries = cmJoin(impl->Libraries, ";");
+ std::string newLibraries = cmJoin(ifaceLibs, ";");
if(oldLibraries.empty())
{ oldLibraries = "(empty)"; }
if(newLibraries.empty())
{ newLibraries = "(empty)"; }
- cmOStringStream w;
+ std::ostringstream w;
w <<
(thisTarget->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0022)) << "\n"
@@ -6400,7 +6319,7 @@ cmTargetInternals::ComputeLinkImplementationLibraries(
{
bool noMessage = false;
cmake::MessageType messageType = cmake::FATAL_ERROR;
- cmOStringStream e;
+ std::ostringstream e;
switch(thisTarget->GetPolicyStatusCMP0038())
{
case cmPolicies::WARN:
@@ -6483,11 +6402,8 @@ cmTargetInternals::ComputeLinkImplementationLanguages(
// Get languages used in our source files.
thisTarget->GetLanguages(languages, config);
// Copy the set of langauges to the link implementation.
- for(std::set<std::string>::iterator li = languages.begin();
- li != languages.end(); ++li)
- {
- impl.Languages.push_back(*li);
- }
+ impl.Languages.insert(impl.Languages.begin(),
+ languages.begin(), languages.end());
}
//----------------------------------------------------------------------------
@@ -6506,7 +6422,7 @@ cmTarget const* cmTarget::FindTargetToLink(std::string const& name) const
if(tgt && tgt->GetType() == cmTarget::OBJECT_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << this->GetName() << "\" links to "
"OBJECT library \"" << tgt->GetName() << "\" but this is not "
"allowed. "
@@ -6545,7 +6461,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
{
case cmPolicies::WARN:
{
- cmOStringStream w;
+ std::ostringstream w;
w << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0004)) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \""
@@ -6557,7 +6473,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
break;
case cmPolicies::NEW:
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << this->GetName() << "\" links to item \""
<< item << "\" which has leading or trailing whitespace. "
<< "This is now an error according to policy CMP0004.";
@@ -6567,7 +6483,7 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
{
- cmOStringStream e;
+ std::ostringstream e;
e << (this->Makefile->GetPolicies()
->GetRequiredPolicyError(cmPolicies::CMP0004)) << "\n"
<< "Target \"" << this->GetName() << "\" links to item \""
@@ -6606,7 +6522,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
switch(t)
{
case BoolType:
- assert(!"String compatibility check function called for boolean");
+ assert(0 && "String compatibility check function called for boolean");
return 0;
case StringType:
return tgt->GetLinkInterfaceDependentStringProperty(prop, config);
@@ -6615,7 +6531,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
case NumberMaxType:
return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config);
}
- assert(!"Unreachable!");
+ assert(0 && "Unreachable!");
return 0;
}
@@ -6648,7 +6564,7 @@ void checkPropertyConsistency(cmTarget const* depender,
std::string pfile = pdir + pname + ".rst";
if(cmSystemTools::FileExists(pfile.c_str(), true))
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Target \"" << dependee->GetName() << "\" has property \""
<< *pi << "\" listed in its " << propName << " property. "
"This is not allowed. Only user-defined properties may appear "
@@ -6810,7 +6726,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
{
propsString += " and the " + *props.begin();
}
- cmOStringStream e;
+ std::ostringstream e;
e << "Property \"" << prop << "\" appears in both the "
<< propsString <<
" property in the dependencies of target \"" << this->GetName() <<
@@ -6953,10 +6869,7 @@ cmTargetLinkInformationMap
//----------------------------------------------------------------------------
cmTargetLinkInformationMap::~cmTargetLinkInformationMap()
{
- for(derived::iterator i = this->begin(); i != this->end(); ++i)
- {
- delete i->second;
- }
+ cmDeleteAll(*this);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index a3ecca0..ddd9859 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -202,7 +202,7 @@ public:
PlainTLLSignature
};
bool PushTLLCommandTrace(TLLSignature signature);
- void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
+ void GetTllSignatureTraces(std::ostringstream &s, TLLSignature sig) const;
void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
const LinkLibraryVectorType& libs );
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index 66d8ad3..dc19720 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -20,7 +20,7 @@ bool cmTargetCompileDefinitionsCommand
void cmTargetCompileDefinitionsCommand
::HandleImportedTarget(const std::string &tgt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify compile definitions for imported target \""
<< tgt << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -29,7 +29,7 @@ void cmTargetCompileDefinitionsCommand
void cmTargetCompileDefinitionsCommand
::HandleMissingTarget(const std::string &name)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify compile definitions for target \"" << name << "\" "
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 10daad4..6ebc31e 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -21,7 +21,7 @@ bool cmTargetCompileFeaturesCommand::InitialPass(
void cmTargetCompileFeaturesCommand
::HandleImportedTarget(const std::string &tgt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify compile features for imported target \""
<< tgt << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -30,7 +30,7 @@ void cmTargetCompileFeaturesCommand
void cmTargetCompileFeaturesCommand
::HandleMissingTarget(const std::string &name)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify compile features for target \"" << name << "\" "
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -40,15 +40,7 @@ void cmTargetCompileFeaturesCommand
std::string cmTargetCompileFeaturesCommand
::Join(const std::vector<std::string> &content)
{
- std::string defs;
- std::string sep;
- for(std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it)
- {
- defs += sep + *it;
- sep = ";";
- }
- return defs;
+ return cmJoin(content, ";");
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 3fb76a6..8c6fc06 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -20,7 +20,7 @@ bool cmTargetCompileOptionsCommand
void cmTargetCompileOptionsCommand
::HandleImportedTarget(const std::string &tgt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify compile options for imported target \""
<< tgt << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -29,7 +29,7 @@ void cmTargetCompileOptionsCommand
void cmTargetCompileOptionsCommand
::HandleMissingTarget(const std::string &name)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify compile options for target \"" << name << "\" "
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -39,15 +39,7 @@ void cmTargetCompileOptionsCommand
std::string cmTargetCompileOptionsCommand
::Join(const std::vector<std::string> &content)
{
- std::string defs;
- std::string sep;
- for(std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it)
- {
- defs += sep + *it;
- sep = ";";
- }
- return defs;
+ return cmJoin(content, ";");
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index e9f0e04..b638e57 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -25,7 +25,7 @@ bool cmTargetIncludeDirectoriesCommand
void cmTargetIncludeDirectoriesCommand
::HandleImportedTarget(const std::string &tgt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify include directories for imported target \""
<< tgt << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -35,7 +35,7 @@ void cmTargetIncludeDirectoriesCommand
void cmTargetIncludeDirectoriesCommand
::HandleMissingTarget(const std::string &name)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify include directories for target \"" << name << "\" "
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -91,15 +91,7 @@ void cmTargetIncludeDirectoriesCommand
if (system)
{
- std::string joined;
- std::string sep;
- for(std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it)
- {
- joined += sep;
- sep = ";";
- joined += *it;
- }
+ std::string joined = cmJoin(content, ";");
tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
joined.c_str());
}
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 56e1338..75c94c5 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -43,7 +43,7 @@ bool cmTargetLinkLibrariesCommand
if(!this->Target)
{
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify link libraries for target \"" << args[0] << "\" "
<< "which is not built by this project.";
// The bad target is the only argument. Check how policy CMP0016 is set,
@@ -92,7 +92,7 @@ bool cmTargetLinkLibrariesCommand
if(this->Target->GetType() == cmTarget::OBJECT_LIBRARY)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Object library target \"" << args[0] << "\" "
<< "may not link to anything.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -102,7 +102,7 @@ bool cmTargetLinkLibrariesCommand
if (this->Target->GetType() == cmTarget::UTILITY)
{
- cmOStringStream e;
+ std::ostringstream e;
const char *modal = 0;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0039))
@@ -311,7 +311,7 @@ bool cmTargetLinkLibrariesCommand
// Make sure the last argument was not a library type specifier.
if(haveLLT)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "The \"" << this->LinkLibraryTypeNames[llt]
<< "\" argument must be followed by a library.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -342,7 +342,7 @@ void
cmTargetLinkLibrariesCommand
::LinkLibraryTypeSpecifierWarning(int left, int right)
{
- cmOStringStream w;
+ std::ostringstream w;
w << "Link library type specifier \""
<< this->LinkLibraryTypeNames[left] << "\" is followed by specifier \""
<< this->LinkLibraryTypeNames[right] << "\" instead of a library name. "
@@ -373,7 +373,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
? cmTarget::KeywordTLLSignature : cmTarget::PlainTLLSignature;
if (!this->Target->PushTLLCommandTrace(sig))
{
- cmOStringStream e;
+ std::ostringstream e;
const char *modal = 0;
cmake::MessageType messageType = cmake::AUTHOR_WARNING;
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0023))
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index ce3b11e..0a44d6f 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -24,7 +24,7 @@ bool cmTargetSourcesCommand
void cmTargetSourcesCommand
::HandleImportedTarget(const std::string &tgt)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify sources for imported target \""
<< tgt << "\".";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -34,7 +34,7 @@ void cmTargetSourcesCommand
void cmTargetSourcesCommand
::HandleMissingTarget(const std::string &name)
{
- cmOStringStream e;
+ std::ostringstream e;
e << "Cannot specify sources for target \"" << name << "\" "
"which is not built by this project.";
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -44,15 +44,7 @@ void cmTargetSourcesCommand
std::string cmTargetSourcesCommand
::Join(const std::vector<std::string> &content)
{
- std::string srcs;
- std::string sep;
- for(std::vector<std::string>::const_iterator it = content.begin();
- it != content.end(); ++it)
- {
- srcs += sep + *it;
- sep = ";";
- }
- return srcs;
+ return cmJoin(content, ";");
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index cc6e139..b5280cf 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -48,7 +48,8 @@ bool cmTryRunCommand
{
++i;
while (i < argv.size() && argv[i] != "COMPILE_DEFINITIONS" &&
- argv[i] != "CMAKE_FLAGS")
+ argv[i] != "CMAKE_FLAGS" &&
+ argv[i] != "LINK_LIBRARIES")
{
runArgs += " ";
runArgs += argv[i];
@@ -104,8 +105,8 @@ bool cmTryRunCommand
// although they could be used together, don't allow it, because
// using OUTPUT_VARIABLE makes crosscompiling harder
if (this->OutputVariable.size()
- && ((this->RunOutputVariable.size())
- || (this->CompileOutputVariable.size())))
+ && (!this->RunOutputVariable.empty()
+ || !this->CompileOutputVariable.empty()))
{
cmSystemTools::Error(
"You cannot use OUTPUT_VARIABLE together with COMPILE_OUTPUT_VARIABLE "
@@ -115,18 +116,18 @@ bool cmTryRunCommand
}
bool captureRunOutput = false;
- if (this->OutputVariable.size())
+ if (!this->OutputVariable.empty())
{
captureRunOutput = true;
tryCompile.push_back("OUTPUT_VARIABLE");
tryCompile.push_back(this->OutputVariable);
}
- if (this->CompileOutputVariable.size())
+ if (!this->CompileOutputVariable.empty())
{
tryCompile.push_back("OUTPUT_VARIABLE");
tryCompile.push_back(this->CompileOutputVariable);
}
- if (this->RunOutputVariable.size())
+ if (!this->RunOutputVariable.empty())
{
captureRunOutput = true;
}
@@ -140,7 +141,7 @@ bool cmTryRunCommand
// now try running the command if it compiled
if (!res)
{
- if (this->OutputFile.size() == 0)
+ if (this->OutputFile.empty())
{
cmSystemTools::Error(this->FindErrorMessage.c_str());
}
@@ -160,13 +161,13 @@ bool cmTryRunCommand
}
// now put the output into the variables
- if(this->RunOutputVariable.size())
+ if(!this->RunOutputVariable.empty())
{
this->Makefile->AddDefinition(this->RunOutputVariable,
runOutputContents.c_str());
}
- if(this->OutputVariable.size())
+ if(!this->OutputVariable.empty())
{
// if the TryCompileCore saved output in this outputVariable then
// prepend that output to this output
@@ -196,7 +197,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
int retVal = -1;
std::string finalCommand = cmSystemTools::ConvertToRunCommandPath(
this->OutputFile.c_str());
- if (runArgs.size())
+ if (!runArgs.empty())
{
finalCommand += runArgs;
}
@@ -239,7 +240,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
copyDest += "-";
copyDest += this->RunResultVariable;
copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile);
- cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyDest.c_str());
+ cmSystemTools::CopyFileAlways(this->OutputFile, copyDest);
std::string resultFileName = this->Makefile->GetHomeOutputDirectory();
resultFileName += "/TryRunResults.cmake";
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index 8d26f86..2ee664f 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -44,7 +44,7 @@ bool cmUseMangledMesaCommand
const char* destDir = args[1].c_str();
std::vector<std::string> files;
cmSystemTools::Glob(inputDir, "\\.h$", files);
- if(files.size() == 0)
+ if(files.empty())
{
cmSystemTools::Error("Could not open Mesa Directory ", inputDir);
return false;
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index ba6b4ac..ee1ff29 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -95,7 +95,7 @@ bool cmUtilitySourceCommand
{
exePath = this->Makefile->GetDefinition("EXECUTABLE_OUTPUT_PATH");
}
- if(exePath.size())
+ if(!exePath.empty())
{
utilityDirectory = exePath;
}
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index 8b5b7ae..e2d0049 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -66,7 +66,7 @@ void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace,
{
output = uuidNamespace;
- if(name.size())
+ if(!name.empty())
{
output.resize(output.size() + name.size());
diff --git a/Source/cmVariableWatch.cxx b/Source/cmVariableWatch.cxx
index cb6cb12..b8a6df2 100644
--- a/Source/cmVariableWatch.cxx
+++ b/Source/cmVariableWatch.cxx
@@ -34,21 +34,16 @@ cmVariableWatch::cmVariableWatch()
{
}
-cmVariableWatch::~cmVariableWatch()
+template<typename C>
+void deleteAllSecond(typename C::value_type it)
{
- cmVariableWatch::StringToVectorOfPairs::iterator svp_it;
-
- for ( svp_it = this->WatchMap.begin();
- svp_it != this->WatchMap.end(); ++svp_it )
- {
- cmVariableWatch::VectorOfPairs::iterator p_it;
+ cmDeleteAll(it.second);
+}
- for ( p_it = svp_it->second.begin();
- p_it != svp_it->second.end(); ++p_it )
- {
- delete *p_it;
- }
- }
+cmVariableWatch::~cmVariableWatch()
+{
+ std::for_each(this->WatchMap.begin(), this->WatchMap.end(),
+ deleteAllSecond<cmVariableWatch::StringToVectorOfPairs>);
}
bool cmVariableWatch::AddWatch(const std::string& variable,
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index debe243..9473008 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -70,7 +70,7 @@ static void cmVariableWatchCommandVariableAccessed(
{
arg.FilePath = "Unknown";
arg.Line = 0;
- cmOStringStream error;
+ std::ostringstream error;
error << "Error in cmake code at\n"
<< arg.FilePath << ":" << arg.Line << ":\n"
<< "A command failed during the invocation of callback \""
@@ -83,7 +83,7 @@ static void cmVariableWatchCommandVariableAccessed(
}
if ( !processed )
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Variable \"" << variable << "\" was accessed using "
<< accessString << " with value \"" << (newValue?newValue:"") << "\".";
makefile->IssueMessage(cmake::LOG, msg.str());
@@ -135,7 +135,7 @@ bool cmVariableWatchCommand
}
if ( variable == "CMAKE_CURRENT_LIST_FILE" )
{
- cmOStringStream ostr;
+ std::ostringstream ostr;
ostr << "cannot be set on the variable: " << variable;
this->SetError(ostr.str());
return false;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 92ec421..a286049 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -307,7 +307,7 @@ void cmVisualStudio10TargetGenerator::Generate()
this->BuildFileStream->SetCopyIfDifferent(true);
// Write the encoding header into the file
- char magic[] = {0xEF,0xBB, 0xBF};
+ char magic[] = {char(0xEF), char(0xBB), char(0xBF)};
this->BuildFileStream->write(magic, 3);
//get the tools version to use
@@ -748,6 +748,12 @@ void cmVisualStudio10TargetGenerator
ntv += toolset? toolset : "Default";
ntv += "</NdkToolchainVersion>\n";
this->WriteString(ntv.c_str(), 2);
+ if(const char* minApi = this->Target->GetProperty("ANDROID_API_MIN"))
+ {
+ this->WriteString("<AndroidMinAPI>", 2);
+ (*this->BuildFileStream ) <<
+ "android-" << cmVS10EscapeXML(minApi) << "</AndroidMinAPI>\n";
+ }
if(const char* api = this->Target->GetProperty("ANDROID_API"))
{
this->WriteString("<AndroidTargetAPI>", 2);
@@ -937,7 +943,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
path += ".vcxproj.filters";
cmGeneratedFileStream fout(path.c_str());
fout.SetCopyIfDifferent(true);
- char magic[] = {0xEF,0xBB, 0xBF};
+ char magic[] = {char(0xEF), char(0xBB), char(0xBF)};
fout.write(magic, 3);
cmGeneratedFileStream* save = this->BuildFileStream;
this->BuildFileStream = & fout;
@@ -1205,6 +1211,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
std::string shaderType;
std::string shaderEntryPoint;
std::string shaderModel;
+ std::string shaderAdditionalFlags;
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
if(ext == "hlsl")
{
@@ -1221,12 +1228,18 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
shaderEntryPoint = se;
toolHasSettings = true;
}
- // Figure out which entry point to use if any
+ // Figure out which shader model to use if any
if (const char* sm = sf->GetProperty("VS_SHADER_MODEL"))
{
shaderModel = sm;
toolHasSettings = true;
}
+ // Figure out if there's any additional flags to use
+ if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS"))
+ {
+ shaderAdditionalFlags = saf;
+ toolHasSettings = true;
+ }
}
else if(ext == "jpg" ||
ext == "png")
@@ -1336,6 +1349,12 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(cmSourceFile const* sf)
(*this->BuildFileStream) << cmVS10EscapeXML(shaderModel)
<< "</ShaderModel>\n";
}
+ if(!shaderAdditionalFlags.empty())
+ {
+ this->WriteString("<AdditionalOptions>", 3);
+ (*this->BuildFileStream) << cmVS10EscapeXML(shaderAdditionalFlags)
+ << "</AdditionalOptions>\n";
+ }
this->WriteString("</", 2);
(*this->BuildFileStream) << tool << ">\n";
}
@@ -1637,6 +1656,11 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
clOptions.AppendFlag("AdditionalIncludeDirectories",
"%(AdditionalIncludeDirectories)");
}
+ if(clOptions.HasFlag("DisableSpecificWarnings"))
+ {
+ clOptions.AppendFlag("DisableSpecificWarnings",
+ "%(DisableSpecificWarnings)");
+ }
clOptions.AddDefines(configDefines.c_str());
clOptions.SetConfiguration((*config).c_str());
clOptions.OutputAdditionalOptions(*this->BuildFileStream, " ", "");
@@ -2738,6 +2762,8 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
this->WriteString("<ApplicationTypeRevision>", 2);
(*this->BuildFileStream) << cmVS10EscapeXML(v)
<< "</ApplicationTypeRevision>\n";
+ this->WriteString("<DefaultLanguage>en-US"
+ "</DefaultLanguage>\n", 2);
if(v == "8.1")
{
// Visual Studio 12.0 is necessary for building 8.1 apps
@@ -2772,12 +2798,12 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings()
if(isAppContainer)
{
this->WriteString("<AppContainerApplication>true"
- "</AppContainerApplication>", 2);
+ "</AppContainerApplication>\n", 2);
}
else if (this->Platform == "ARM")
{
this->WriteString("<WindowsSDKDesktopARMSupport>true"
- "</WindowsSDKDesktopARMSupport>", 2);
+ "</WindowsSDKDesktopARMSupport>\n", 2);
}
}
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index cdc8879..00386f6 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -28,6 +28,26 @@ std::string cmVisualStudioGeneratorOptionsEscapeForXML(std::string ret)
cmVisualStudioGeneratorOptions
::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
Tool tool,
+ cmVisualStudio10TargetGenerator* g):
+ cmIDEOptions(),
+ LocalGenerator(lg), Version(lg->GetVersion()), CurrentTool(tool),
+ TargetGenerator(g)
+{
+ // Preprocessor definitions are not allowed for linker tools.
+ this->AllowDefine = (tool != Linker);
+
+ // Slash options are allowed for VS.
+ this->AllowSlash = true;
+
+ this->FortranRuntimeDebug = false;
+ this->FortranRuntimeDLL = false;
+ this->FortranRuntimeMT = false;
+}
+
+//----------------------------------------------------------------------------
+cmVisualStudioGeneratorOptions
+::cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
+ Tool tool,
cmVS7FlagTable const* table,
cmVS7FlagTable const* extraTable,
cmVisualStudio10TargetGenerator* g):
@@ -36,9 +56,8 @@ cmVisualStudioGeneratorOptions
TargetGenerator(g)
{
// Store the given flag tables.
- cmIDEFlagTable const** ft = this->FlagTable;
- if(table) { *ft++ = table; }
- if(extraTable) { *ft++ = extraTable; }
+ this->AddTable(table);
+ this->AddTable(extraTable);
// Preprocessor definitions are not allowed for linker tools.
this->AllowDefine = (tool != Linker);
@@ -52,6 +71,22 @@ cmVisualStudioGeneratorOptions
}
//----------------------------------------------------------------------------
+void cmVisualStudioGeneratorOptions::AddTable(cmVS7FlagTable const* table)
+{
+ if(table)
+ {
+ for(int i=0; i < FlagTableCount; ++i)
+ {
+ if (!this->FlagTable[i])
+ {
+ this->FlagTable[i] = table;
+ break;
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
void cmVisualStudioGeneratorOptions::FixExceptionHandlingDefault()
{
// Exception handling is on by default because the platform file has
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 9951033..5490a43 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -38,6 +38,13 @@ public:
cmVS7FlagTable const* extraTable = 0,
cmVisualStudio10TargetGenerator* g = 0);
+ cmVisualStudioGeneratorOptions(cmLocalVisualStudioGenerator* lg,
+ Tool tool,
+ cmVisualStudio10TargetGenerator* g = 0);
+
+ // Add a table of flags.
+ void AddTable(cmVS7FlagTable const* table);
+
// Store options from command line flags.
void Parse(const char* flags);
void ParseFinish();
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 851c4cb..5170ead 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -27,6 +27,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// if this is the endwhile for this while loop then execute
if (!this->Depth)
{
+ cmMakefile::LoopBlockPop loopBlockPop(&mf);
+
// Remove the function blocker for this scope or bail.
cmsys::auto_ptr<cmFunctionBlocker>
fb(mf.RemoveFunctionBlocker(this, lff));
@@ -45,7 +47,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
while (isTrue)
{
- if (errorString.size())
+ if (!errorString.empty())
{
std::string err = "had incorrect arguments: ";
unsigned int i;
@@ -81,6 +83,10 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
{
return true;
}
+ if (status.GetContinueInvoked())
+ {
+ break;
+ }
if(cmSystemTools::GetFatalErrorOccured() )
{
return true;
@@ -114,7 +120,7 @@ ShouldRemove(const cmListFileFunction& lff, cmMakefile& )
{
// if the endwhile has arguments, then make sure
// they match the arguments of the matching while
- if (lff.Arguments.size() == 0 ||
+ if (lff.Arguments.empty() ||
lff.Arguments == this->Args)
{
return true;
@@ -138,6 +144,8 @@ bool cmWhileCommand
f->Args = args;
this->Makefile->AddFunctionBlocker(f);
+ this->Makefile->PushLoopBlock();
+
return true;
}
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index af955ec..cc9f220 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -63,8 +63,6 @@ bool cmWriteFileCommand
cmSystemTools::SetPermissions(fileName.c_str(),
#if defined( _MSC_VER ) || defined( __MINGW32__ )
mode | S_IWRITE
-#elif defined( __BORLANDC__ )
- mode | S_IWUSR
#else
mode | S_IWUSR | S_IWGRP
#endif
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index 391b874..1d3e0e9 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -54,7 +54,7 @@ int cmXMLParser::ParseFile(const char* file)
return 0;
}
- cmOStringStream str;
+ std::ostringstream str;
str << ifs.rdbuf();
return this->Parse(str.str().c_str());
}
diff --git a/Source/cm_get_date.c b/Source/cm_get_date.c
new file mode 100644
index 0000000..2e0d4bd
--- /dev/null
+++ b/Source/cm_get_date.c
@@ -0,0 +1,16 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cm_get_date.h"
+
+#define __archive_get_date cm_get_date
+
+#include "../Utilities/cmlibarchive/libarchive/archive_getdate.c"
diff --git a/Source/cm_get_date.h b/Source/cm_get_date.h
new file mode 100644
index 0000000..d5f6d3e
--- /dev/null
+++ b/Source/cm_get_date.h
@@ -0,0 +1,28 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2015 Kitware, Inc.
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#ifndef cm_get_date_h
+#define cm_get_date_h
+
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Parse a date/time string. Treat relative times with respect to 'now'. */
+time_t cm_get_date(time_t now, const char *str);
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/Source/cm_sha2.c b/Source/cm_sha2.c
index 24de2b2..b90e060 100644
--- a/Source/cm_sha2.c
+++ b/Source/cm_sha2.c
@@ -103,9 +103,6 @@ typedef cm_sha2_uint32_t sha_word32; /* Exactly 4 bytes */
typedef cm_sha2_uint64_t sha_word64; /* Exactly 8 bytes */
#define SHA_UINT32_C(x) cmIML_INT_UINT32_C(x)
#define SHA_UINT64_C(x) cmIML_INT_UINT64_C(x)
-#if defined(__BORLANDC__)
-# pragma warn -8004 /* variable assigned value that is never used */
-#endif
#if defined(__clang__)
# pragma clang diagnostic ignored "-Wcast-align"
#endif
@@ -666,7 +663,7 @@ void SHA1_Update(SHA_CTX* context, const sha_byte *data, size_t len) {
context->s1.bitcount += freespace << 3;
len -= freespace;
data += freespace;
- SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer);
+ SHA1_Internal_Transform(context, (const sha_word32*)context->s1.buffer);
} else {
/* The buffer is not yet full */
MEMCPY_BCOPY(&context->s1.buffer[usedspace], data, len);
@@ -678,7 +675,7 @@ void SHA1_Update(SHA_CTX* context, const sha_byte *data, size_t len) {
}
while (len >= 64) {
/* Process as many complete blocks as we can */
- SHA1_Internal_Transform(context, (sha_word32*)data);
+ SHA1_Internal_Transform(context, (const sha_word32*)data);
context->s1.bitcount += 512;
len -= 64;
data += 64;
@@ -727,7 +724,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) {
MEMSET_BZERO(&context->s1.buffer[usedspace], 64 - usedspace);
}
/* Do second-to-last transform: */
- SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer);
+ SHA1_Internal_Transform(context, (const sha_word32*)context->s1.buffer);
/* And set-up for the last transform: */
MEMSET_BZERO(context->s1.buffer, 56);
@@ -744,7 +741,7 @@ void SHA1_Final(sha_byte digest[], SHA_CTX* context) {
sizeof(sha_word64));
/* Final transform: */
- SHA1_Internal_Transform(context, (sha_word32*)context->s1.buffer);
+ SHA1_Internal_Transform(context, (const sha_word32*)context->s1.buffer);
/* Save the hash data for output: */
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -1007,7 +1004,7 @@ void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) {
context->s256.bitcount += freespace << 3;
len -= freespace;
data += freespace;
- SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer);
+ SHA256_Internal_Transform(context, (const sha_word32*)context->s256.buffer);
} else {
/* The buffer is not yet full */
MEMCPY_BCOPY(&context->s256.buffer[usedspace], data, len);
@@ -1019,7 +1016,7 @@ void SHA256_Update(SHA_CTX* context, const sha_byte *data, size_t len) {
}
while (len >= 64) {
/* Process as many complete blocks as we can */
- SHA256_Internal_Transform(context, (sha_word32*)data);
+ SHA256_Internal_Transform(context, (const sha_word32*)data);
context->s256.bitcount += 512;
len -= 64;
data += 64;
@@ -1053,7 +1050,7 @@ void SHA256_Internal_Last(SHA_CTX* context) {
MEMSET_BZERO(&context->s256.buffer[usedspace], 64 - usedspace);
}
/* Do second-to-last transform: */
- SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer);
+ SHA256_Internal_Transform(context, (const sha_word32*)context->s256.buffer);
/* And set-up for the last transform: */
MEMSET_BZERO(context->s256.buffer, 56);
@@ -1072,7 +1069,7 @@ void SHA256_Internal_Last(SHA_CTX* context) {
sizeof(sha_word64));
/* Final transform: */
- SHA256_Internal_Transform(context, (sha_word32*)context->s256.buffer);
+ SHA256_Internal_Transform(context, (const sha_word32*)context->s256.buffer);
}
void SHA256_Final(sha_byte digest[], SHA_CTX* context) {
@@ -1415,7 +1412,7 @@ void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) {
ADDINC128(context->s512.bitcount, freespace << 3);
len -= freespace;
data += freespace;
- SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer);
+ SHA512_Internal_Transform(context, (const sha_word64*)context->s512.buffer);
} else {
/* The buffer is not yet full */
MEMCPY_BCOPY(&context->s512.buffer[usedspace], data, len);
@@ -1427,7 +1424,7 @@ void SHA512_Update(SHA_CTX* context, const sha_byte *data, size_t len) {
}
while (len >= 128) {
/* Process as many complete blocks as we can */
- SHA512_Internal_Transform(context, (sha_word64*)data);
+ SHA512_Internal_Transform(context, (const sha_word64*)data);
ADDINC128(context->s512.bitcount, 1024);
len -= 128;
data += 128;
@@ -1462,7 +1459,7 @@ void SHA512_Internal_Last(SHA_CTX* context) {
MEMSET_BZERO(&context->s512.buffer[usedspace], 128 - usedspace);
}
/* Do second-to-last transform: */
- SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer);
+ SHA512_Internal_Transform(context, (const sha_word64*)context->s512.buffer);
/* And set-up for the last transform: */
MEMSET_BZERO(context->s512.buffer, 112);
@@ -1483,7 +1480,7 @@ void SHA512_Internal_Last(SHA_CTX* context) {
sizeof(sha_word64));
/* Final transform: */
- SHA512_Internal_Transform(context, (sha_word64*)context->s512.buffer);
+ SHA512_Internal_Transform(context, (const sha_word64*)context->s512.buffer);
}
void SHA512_Final(sha_byte digest[], SHA_CTX* context) {
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 36a0645..652e451 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -171,16 +171,8 @@ cmake::~cmake()
delete this->GlobalGenerator;
this->GlobalGenerator = 0;
}
- for(RegisteredCommandsMap::iterator j = this->Commands.begin();
- j != this->Commands.end(); ++j)
- {
- delete (*j).second;
- }
- for(RegisteredGeneratorsVector::iterator j = this->Generators.begin();
- j != this->Generators.end(); ++j)
- {
- delete *j;
- }
+ cmDeleteAll(this->Commands);
+ cmDeleteAll(this->Generators);
#ifdef CMAKE_BUILD_WITH_CMAKE
delete this->VariableWatch;
#endif
@@ -324,7 +316,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
if(arg.find("-D",0) == 0)
{
std::string entry = arg.substr(2);
- if(entry.size() == 0)
+ if(entry.empty())
{
++i;
if(i < args.size())
@@ -388,7 +380,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
else if(arg.find("-U",0) == 0)
{
std::string entryPattern = arg.substr(2);
- if(entryPattern.size() == 0)
+ if(entryPattern.empty())
{
++i;
if(i < args.size())
@@ -432,7 +424,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
else if(arg.find("-C",0) == 0)
{
std::string path = arg.substr(2);
- if ( path.size() == 0 )
+ if (path.empty())
{
++i;
if(i < args.size())
@@ -445,7 +437,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
}
- std::cerr << "loading initial cache file " << path << "\n";
+ std::cout << "loading initial cache file " << path << "\n";
this->ReadListFile(args, path.c_str());
}
else if(arg.find("-P",0) == 0)
@@ -457,7 +449,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
std::string path = args[i];
- if ( path.size() == 0 )
+ if (path.empty())
{
cmSystemTools::Error("No cmake script provided.");
return false;
@@ -647,7 +639,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
{
directoriesSet = true;
std::string path = arg.substr(2);
- path = cmSystemTools::CollapseFullPath(path.c_str());
+ path = cmSystemTools::CollapseFullPath(path);
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeDirectory(path);
}
@@ -663,7 +655,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
{
directoriesSet = true;
std::string path = arg.substr(2);
- path = cmSystemTools::CollapseFullPath(path.c_str());
+ path = cmSystemTools::CollapseFullPath(path);
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeOutputDirectory(path);
}
@@ -723,7 +715,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
else if(arg.find("--graphviz=",0) == 0)
{
std::string path = arg.substr(strlen("--graphviz="));
- path = cmSystemTools::CollapseFullPath(path.c_str());
+ path = cmSystemTools::CollapseFullPath(path);
cmSystemTools::ConvertToUnixSlashes(path);
this->GraphVizFile = path;
if ( this->GraphVizFile.empty() )
@@ -771,7 +763,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
else if(arg.find("-A",0) == 0)
{
std::string value = arg.substr(2);
- if(value.size() == 0)
+ if(value.empty())
{
++i;
if(i >= args.size())
@@ -792,7 +784,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
else if(arg.find("-T",0) == 0)
{
std::string value = arg.substr(2);
- if(value.size() == 0)
+ if(value.empty())
{
++i;
if(i >= args.size())
@@ -813,7 +805,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
else if(arg.find("-G",0) == 0)
{
std::string value = arg.substr(2);
- if(value.size() == 0)
+ if(value.empty())
{
++i;
if(i >= args.size())
@@ -917,7 +909,7 @@ void cmake::SetDirectoriesFromFile(const char* arg)
}
// If there is a CMakeCache.txt file, use its settings.
- if(cachePath.length() > 0)
+ if(!cachePath.empty())
{
cmCacheManager* cachem = this->GetCacheManager();
cmCacheManager::CacheIterator it = cachem->NewIterator();
@@ -933,7 +925,7 @@ void cmake::SetDirectoriesFromFile(const char* arg)
}
// If there is a CMakeLists.txt file, use it as the source tree.
- if(listPath.length() > 0)
+ if(!listPath.empty())
{
this->SetHomeDirectory(listPath);
this->SetStartDirectory(listPath);
@@ -1131,17 +1123,17 @@ void cmake::SetGlobalGenerator(cmGlobalGenerator *gg)
// restore the original environment variables CXX and CC
// Restore CC
std::string env = "CC=";
- if(this->CCEnvironment.size())
+ if(!this->CCEnvironment.empty())
{
env += this->CCEnvironment;
}
- cmSystemTools::PutEnv(env.c_str());
+ cmSystemTools::PutEnv(env);
env = "CXX=";
- if(this->CXXEnvironment.size())
+ if(!this->CXXEnvironment.empty())
{
env += this->CXXEnvironment;
}
- cmSystemTools::PutEnv(env.c_str());
+ cmSystemTools::PutEnv(env);
}
// set the new
@@ -1182,7 +1174,7 @@ int cmake::DoPreConfigureChecks()
srcList += "/CMakeLists.txt";
if(!cmSystemTools::FileExists(srcList.c_str()))
{
- cmOStringStream err;
+ std::ostringstream err;
if(cmSystemTools::FileIsDirectory(this->GetHomeDirectory()))
{
err << "The source directory \"" << this->GetHomeDirectory()
@@ -1212,7 +1204,7 @@ int cmake::DoPreConfigureChecks()
cacheStart += "/CMakeLists.txt";
std::string currentStart = this->GetHomeDirectory();
currentStart += "/CMakeLists.txt";
- if(!cmSystemTools::SameFile(cacheStart.c_str(), currentStart.c_str()))
+ if(!cmSystemTools::SameFile(cacheStart, currentStart))
{
std::string message = "The source \"";
message += currentStart;
@@ -1250,7 +1242,7 @@ int cmake::HandleDeleteCacheVariables(const std::string& var)
}
cmCacheManager::CacheIterator ci = this->CacheManager->NewIterator();
std::vector<SaveCacheEntry> saved;
- cmOStringStream warning;
+ std::ostringstream warning;
warning
<< "You have changed variables that require your cache to be deleted.\n"
<< "Configure will be re-run and you may have to reset some variables.\n"
@@ -1377,9 +1369,7 @@ int cmake::ActualConfigure()
}
else
{
-#if defined(__BORLANDC__) && defined(_WIN32)
- this->SetGlobalGenerator(new cmGlobalBorlandMakefileGenerator);
-#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(CMAKE_BOOT_MINGW)
std::string installedCompiler;
// Try to find the newest VS installed on the computer and
// use that as a default if -G is not specified
@@ -1618,7 +1608,7 @@ void cmake::PreLoadCMakeFiles()
{
std::vector<std::string> args;
std::string pre_load = this->GetHomeDirectory();
- if ( pre_load.size() > 0 )
+ if (!pre_load.empty())
{
pre_load += "/PreLoad.cmake";
if ( cmSystemTools::FileExists(pre_load.c_str()) )
@@ -1627,7 +1617,7 @@ void cmake::PreLoadCMakeFiles()
}
}
pre_load = this->GetHomeOutputDirectory();
- if ( pre_load.size() > 0 )
+ if (!pre_load.empty())
{
pre_load += "/PreLoad.cmake";
if ( cmSystemTools::FileExists(pre_load.c_str()) )
@@ -1948,7 +1938,7 @@ void cmake::UpdateConversionPathTable()
{
// two entries per line
table >> a; table >> b;
- cmSystemTools::AddTranslationPath( a.c_str(), b.c_str());
+ cmSystemTools::AddTranslationPath( a, b);
}
}
}
@@ -1969,11 +1959,11 @@ int cmake::CheckBuildSystem()
// determine whether CMake should rerun.
// If no file is provided for the check, we have to rerun.
- if(this->CheckBuildSystemArgument.size() == 0)
+ if(this->CheckBuildSystemArgument.empty())
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake no build system arguments\n";
cmSystemTools::Stdout(msg.str().c_str());
}
@@ -1985,7 +1975,7 @@ int cmake::CheckBuildSystem()
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake missing file: "
<< this->CheckBuildSystemArgument << "\n";
cmSystemTools::Stdout(msg.str().c_str());
@@ -2005,7 +1995,7 @@ int cmake::CheckBuildSystem()
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake error reading : "
<< this->CheckBuildSystemArgument << "\n";
cmSystemTools::Stdout(msg.str().c_str());
@@ -2043,11 +2033,11 @@ int cmake::CheckBuildSystem()
pi != products.end(); ++pi)
{
if(!(cmSystemTools::FileExists(pi->c_str()) ||
- cmSystemTools::FileIsSymlink(pi->c_str())))
+ cmSystemTools::FileIsSymlink(*pi)))
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake, missing byproduct: " << *pi << "\n";
cmSystemTools::Stdout(msg.str().c_str());
}
@@ -2070,7 +2060,7 @@ int cmake::CheckBuildSystem()
// Not enough information was provided to do the test. Just rerun.
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake no CMAKE_MAKEFILE_DEPENDS "
"or CMAKE_MAKEFILE_OUTPUTS :\n";
cmSystemTools::Stdout(msg.str().c_str());
@@ -2096,7 +2086,7 @@ int cmake::CheckBuildSystem()
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake: build system dependency is missing\n";
cmSystemTools::Stdout(msg.str().c_str());
}
@@ -2122,7 +2112,7 @@ int cmake::CheckBuildSystem()
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake: build system output is missing\n";
cmSystemTools::Stdout(msg.str().c_str());
}
@@ -2140,7 +2130,7 @@ int cmake::CheckBuildSystem()
{
if(verbose)
{
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Re-run cmake file: " << out_oldest
<< " older than: " << dep_newest << "\n";
cmSystemTools::Stdout(msg.str().c_str());
@@ -2166,7 +2156,7 @@ void cmake::TruncateOutputLog(const char* fname)
}
if ( !this->CacheManager->GetCacheValue("CMAKE_CACHEFILE_DIR") )
{
- cmSystemTools::RemoveFile(fullPath.c_str());
+ cmSystemTools::RemoveFile(fullPath);
return;
}
off_t fsize = st.st_size;
@@ -2287,7 +2277,7 @@ const char *cmake::GetProperty(const std::string& prop,
this->GetCacheManager()->GetCacheIterator();
for ( cit.Begin(); !cit.IsAtEnd(); cit.Next() )
{
- if ( output.size() )
+ if (!output.empty())
{
output += ";";
}
@@ -2322,14 +2312,7 @@ const char *cmake::GetProperty(const std::string& prop,
{
std::vector<std::string> enLangs;
this->GlobalGenerator->GetEnabledLanguages(enLangs);
- const char* sep = "";
- for(std::vector<std::string>::iterator i = enLangs.begin();
- i != enLangs.end(); ++i)
- {
- lang += sep;
- sep = ";";
- lang += *i;
- }
+ lang = cmJoin(enLangs, ";");
}
this->SetProperty("ENABLED_LANGUAGES", lang.c_str());
}
@@ -2392,7 +2375,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
std::string resultFile;
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
std::string destPath = cwd + "/__cmake_systeminformation";
- cmSystemTools::RemoveADirectory(destPath.c_str());
+ cmSystemTools::RemoveADirectory(destPath);
if (!cmSystemTools::MakeDirectory(destPath.c_str()))
{
std::cerr << "Error: --system-information must be run from a "
@@ -2412,7 +2395,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
else if(arg.find("-G",0) == 0)
{
std::string value = arg.substr(2);
- if(value.size() == 0)
+ if(value.empty())
{
++i;
if(i >= args.size())
@@ -2467,14 +2450,14 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
}
// do we write to a file or to stdout?
- if (resultFile.size() == 0)
+ if (resultFile.empty())
{
resultFile = cwd;
resultFile += "/__cmake_systeminformation/results.txt";
}
// now run cmake on the CMakeLists file
- cmSystemTools::ChangeDirectory(destPath.c_str());
+ cmSystemTools::ChangeDirectory(destPath);
std::vector<std::string> args2;
args2.push_back(args[0]);
args2.push_back(destPath);
@@ -2490,12 +2473,12 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
}
// change back to the original directory
- cmSystemTools::ChangeDirectory(cwd.c_str());
+ cmSystemTools::ChangeDirectory(cwd);
// echo results to stdout if needed
if (writeToStdout)
{
- FILE* fin = cmsys::SystemTools::Fopen(resultFile.c_str(), "r");
+ FILE* fin = cmsys::SystemTools::Fopen(resultFile, "r");
if(fin)
{
const int bufferSize = 4096;
@@ -2514,7 +2497,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
}
// clean up the directory
- cmSystemTools::RemoveADirectory(destPath.c_str());
+ cmSystemTools::RemoveADirectory(destPath);
return 0;
}
@@ -2548,7 +2531,7 @@ static bool cmakeCheckStampFile(const char* stampName)
while(cmSystemTools::GetLineFromStream(fin, dep))
{
int result;
- if(dep.length() >= 1 && dep[0] != '#' &&
+ if(!dep.empty() && dep[0] != '#' &&
(!ftc.FileTimeCompare(stampDepends.c_str(), dep.c_str(), &result)
|| result < 0))
{
@@ -2565,7 +2548,7 @@ static bool cmakeCheckStampFile(const char* stampName)
// The build system is up to date. The stamp file has been removed
// by the VS IDE due to a "rebuild" request. Restore it atomically.
- cmOStringStream stampTempStream;
+ std::ostringstream stampTempStream;
stampTempStream << stampName << ".tmp" << cmSystemTools::RandomSeed();
std::string stampTempString = stampTempStream.str();
const char* stampTemp = stampTempString.c_str();
@@ -2629,7 +2612,7 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
cmListFileBacktrace backtrace = bt;
backtrace.MakeRelative();
- cmOStringStream msg;
+ std::ostringstream msg;
bool isError = false;
// Construct the message header.
if(t == cmake::FATAL_ERROR)
@@ -2770,7 +2753,7 @@ int cmake::Build(const std::string& dir,
const std::vector<std::string>& nativeOptions,
bool clean)
{
- if(!cmSystemTools::FileIsDirectory(dir.c_str()))
+ if(!cmSystemTools::FileIsDirectory(dir))
{
std::cerr << "Error: " << dir << " is not a directory\n";
return 1;
@@ -2837,7 +2820,7 @@ void cmake::RunCheckForUnusedVariables()
{
#ifdef CMAKE_BUILD_WITH_CMAKE
bool haveUnused = false;
- cmOStringStream msg;
+ std::ostringstream msg;
msg << "Manually-specified variables were not used by the project:";
for(std::map<std::string, bool>::const_iterator
it = this->UsedCliVariables.begin();
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 61b175e..e0bd55b 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -25,7 +25,6 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include <cmsys/Encoding.hxx>
-#include <locale.h>
#ifdef CMAKE_BUILD_WITH_CMAKE
//----------------------------------------------------------------------------
@@ -96,11 +95,9 @@ static const char * cmDocumentationOptions[][2] =
static int do_command(int ac, char const* const* av)
{
std::vector<std::string> args;
+ args.reserve(ac - 1);
args.push_back(av[0]);
- for(int i = 2; i < ac; ++i)
- {
- args.push_back(av[i]);
- }
+ args.insert(args.end(), av + 2, av + ac);
return cmcmd::ExecuteCMakeCommand(args);
}
@@ -175,7 +172,6 @@ static void cmakemainProgressCallback(const char *m, float prog,
int main(int ac, char const* const* av)
{
- setlocale(LC_CTYPE, "");
cmsys::Encoding::CommandLineArguments args =
cmsys::Encoding::CommandLineArguments::Main(ac, av);
ac = args.argc();
@@ -203,7 +199,7 @@ int main(int ac, char const* const* av)
int do_cmake(int ac, char const* const* av)
{
- if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
+ if (cmSystemTools::GetCurrentWorkingDirectory().empty())
{
std::cerr << "Current working directory cannot be established."
<< std::endl;
@@ -221,11 +217,7 @@ int do_cmake(int ac, char const* const* av)
// the command line args are processed here so that you can do
// -DCMAKE_MODULE_PATH=/some/path and have this value accessible here
- std::vector<std::string> args;
- for(int i =0; i < ac; ++i)
- {
- args.push_back(av[i]);
- }
+ std::vector<std::string> args(av, av + ac);
hcm.SetCacheArgs(args);
std::vector<cmDocumentationEntry> generators;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index a0c67e0..28fcd27 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -36,7 +36,7 @@
void CMakeCommandUsage(const char* program)
{
- cmOStringStream errorStream;
+ std::ostringstream errorStream;
#ifdef CMAKE_BUILD_WITH_CMAKE
errorStream
@@ -71,7 +71,7 @@ void CMakeCommandUsage(const char* program)
<< " remove_directory dir - remove a directory and its contents\n"
<< " rename oldname newname - rename a file or directory "
"(on one volume)\n"
- << " tar [cxt][vfz][cvfj] file.tar [file/dir1 file/dir2 ...]\n"
+ << " tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
<< " - create or extract a tar or zip archive\n"
<< " sleep <number>... - sleep for given number of seconds\n"
<< " time command [args] ... - run command and return elapsed time\n"
@@ -94,6 +94,51 @@ void CMakeCommandUsage(const char* program)
cmSystemTools::Error(errorStream.str().c_str());
}
+static bool cmTarFilesFrom(std::string const& file,
+ std::vector<std::string>& files)
+{
+ if (cmSystemTools::FileIsDirectory(file))
+ {
+ std::ostringstream e;
+ e << "-E tar --files-from= file '" << file << "' is a directory";
+ cmSystemTools::Error(e.str().c_str());
+ return false;
+ }
+ cmsys::ifstream fin(file.c_str());
+ if (!fin)
+ {
+ std::ostringstream e;
+ e << "-E tar --files-from= file '" << file << "' not found";
+ cmSystemTools::Error(e.str().c_str());
+ return false;
+ }
+ std::string line;
+ while (cmSystemTools::GetLineFromStream(fin, line))
+ {
+ if (line.empty())
+ {
+ continue;
+ }
+ if (cmHasLiteralPrefix(line, "--add-file="))
+ {
+ files.push_back(line.substr(11));
+ }
+ else if (cmHasLiteralPrefix(line, "-"))
+ {
+ std::ostringstream e;
+ e << "-E tar --files-from='" << file << "' file invalid line:\n"
+ << line << "\n";
+ cmSystemTools::Error(e.str().c_str());
+ return false;
+ }
+ else
+ {
+ files.push_back(line);
+ }
+ }
+ return true;
+}
+
int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
// IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx
@@ -128,7 +173,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Copy directory content
if (args[1] == "copy_directory" && args.size() == 4)
{
- if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str()))
+ if(!cmSystemTools::CopyADirectory(args[2], args[3]))
{
std::cerr << "Error copying directory from \""
<< args[2] << "\" to \"" << args[3]
@@ -155,7 +200,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Compare files
if (args[1] == "compare_files" && args.size() == 4)
{
- if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str()))
+ if(cmSystemTools::FilesDiffer(args[2], args[3]))
{
std::cerr << "Files \""
<< args[2] << "\" to \"" << args[3]
@@ -215,7 +260,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
else if(a.find("=") != a.npos)
{
// Set environment variable.
- cmSystemTools::PutEnv(a.c_str());
+ cmSystemTools::PutEnv(a);
}
else
{
@@ -269,8 +314,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
else if (args[1] == "remove_directory" && args.size() == 3)
{
- if(cmSystemTools::FileIsDirectory(args[2].c_str()) &&
- !cmSystemTools::RemoveADirectory(args[2].c_str()))
+ if(cmSystemTools::FileIsDirectory(args[2]) &&
+ !cmSystemTools::RemoveADirectory(args[2]))
{
std::cerr << "Error removing directory \"" << args[2]
<< "\".\n";
@@ -293,7 +338,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
// Complain if the file could not be removed, still exists,
// and the -f option was not given.
- if(!cmSystemTools::RemoveFile(args[cc].c_str()) && !force &&
+ if(!cmSystemTools::RemoveFile(args[cc]) && !force &&
cmSystemTools::FileExists(args[cc].c_str()))
{
return 1;
@@ -309,7 +354,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
// Complain if the file could not be removed, still exists,
// and the -f option was not given.
- if(!cmSystemTools::Touch(args[cc].c_str(), true))
+ if(!cmSystemTools::Touch(args[cc], true))
{
return 1;
}
@@ -323,7 +368,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
// Complain if the file could not be removed, still exists,
// and the -f option was not given.
- if(!cmSystemTools::Touch(args[cc].c_str(), false))
+ if(!cmSystemTools::Touch(args[cc], false))
{
return 1;
}
@@ -453,10 +498,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// basically remove the directory
std::string dirName = args[2];
dirName += "/Progress";
- cmSystemTools::RemoveADirectory(dirName.c_str());
+ cmSystemTools::RemoveADirectory(dirName);
// is the last argument a filename that exists?
- FILE *countFile = cmsys::SystemTools::Fopen(args[3].c_str(),"r");
+ FILE *countFile = cmsys::SystemTools::Fopen(args[3],"r");
int count;
if (countFile)
{
@@ -476,7 +521,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// write the count into the directory
std::string fName = dirName;
fName += "/count.txt";
- FILE *progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w");
+ FILE *progFile = cmsys::SystemTools::Fopen(fName,"w");
if (progFile)
{
fprintf(progFile,"%i\n",count);
@@ -497,7 +542,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// read the count
fName = dirName;
fName += "/count.txt";
- progFile = cmsys::SystemTools::Fopen(fName.c_str(),"r");
+ progFile = cmsys::SystemTools::Fopen(fName,"r");
int count = 0;
if (!progFile)
{
@@ -517,7 +562,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
fName = dirName;
fName += "/";
fName += args[i];
- progFile = cmsys::SystemTools::Fopen(fName.c_str(),"w");
+ progFile = cmsys::SystemTools::Fopen(fName,"w");
if (progFile)
{
fprintf(progFile,"empty");
@@ -525,7 +570,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
}
}
int fileNum = static_cast<int>
- (cmsys::Directory::GetNumberOfFilesInDirectory(dirName.c_str()));
+ (cmsys::Directory::GetNumberOfFilesInDirectory(dirName));
if (count > 0)
{
// print the progress
@@ -549,7 +594,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
"' because existing path cannot be removed: " << emsg << "\n";
return 1;
}
- if(!cmSystemTools::CreateSymlink(args[2].c_str(), args[3].c_str()))
+ if(!cmSystemTools::CreateSymlink(args[2], args[3]))
{
std::string emsg = cmSystemTools::GetLastSystemError();
std::cerr <<
@@ -660,10 +705,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
// Create a local generator configured for the directory in
// which dependencies will be scanned.
- homeDir = cmSystemTools::CollapseFullPath(homeDir.c_str());
- startDir = cmSystemTools::CollapseFullPath(startDir.c_str());
- homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str());
- startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str());
+ homeDir = cmSystemTools::CollapseFullPath(homeDir);
+ startDir = cmSystemTools::CollapseFullPath(startDir);
+ homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir);
+ startOutDir = cmSystemTools::CollapseFullPath(startOutDir);
cm.SetHomeDirectory(homeDir);
cm.SetStartDirectory(startDir);
cm.SetHomeOutputDirectory(homeOutDir);
@@ -729,20 +774,64 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::string flags = args[2];
std::string outFile = args[3];
std::vector<std::string> files;
+ std::string mtime;
+ bool doing_options = true;
for (std::string::size_type cc = 4; cc < args.size(); cc ++)
{
- files.push_back(args[cc]);
+ std::string const& arg = args[cc];
+ if (doing_options && cmHasLiteralPrefix(arg, "--"))
+ {
+ if (arg == "--")
+ {
+ doing_options = false;
+ }
+ else if (cmHasLiteralPrefix(arg, "--mtime="))
+ {
+ mtime = arg.substr(8);
+ }
+ else if (cmHasLiteralPrefix(arg, "--files-from="))
+ {
+ std::string const& files_from = arg.substr(13);
+ if (!cmTarFilesFrom(files_from, files))
+ {
+ return 1;
+ }
+ }
+ else
+ {
+ cmSystemTools::Error("Unknown option to -E tar: ", arg.c_str());
+ return 1;
+ }
+ }
+ else
+ {
+ files.push_back(arg);
+ }
}
- bool gzip = false;
- bool bzip2 = false;
+ cmSystemTools::cmTarCompression compress =
+ cmSystemTools::TarCompressNone;
bool verbose = false;
+ int nCompress = 0;
if ( flags.find_first_of('j') != flags.npos )
{
- bzip2 = true;
+ compress = cmSystemTools::TarCompressBZip2;
+ ++nCompress;
+ }
+ if ( flags.find_first_of('J') != flags.npos )
+ {
+ compress = cmSystemTools::TarCompressXZ;
+ ++nCompress;
}
if ( flags.find_first_of('z') != flags.npos )
{
- gzip = true;
+ compress = cmSystemTools::TarCompressGZip;
+ ++nCompress;
+ }
+ if ( nCompress > 1 )
+ {
+ cmSystemTools::Error("Can only compress a tar file one way; "
+ "at most one flag of z, j, or J may be used");
+ return 1;
}
if ( flags.find_first_of('v') != flags.npos )
{
@@ -751,16 +840,16 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if ( flags.find_first_of('t') != flags.npos )
{
- if ( !cmSystemTools::ListTar(outFile.c_str(), gzip, verbose) )
+ if ( !cmSystemTools::ListTar(outFile.c_str(), verbose) )
{
- cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
+ cmSystemTools::Error("Problem listing tar: ", outFile.c_str());
return 1;
}
}
else if ( flags.find_first_of('c') != flags.npos )
{
if ( !cmSystemTools::CreateTar(
- outFile.c_str(), files, gzip, bzip2, verbose) )
+ outFile.c_str(), files, compress, verbose, mtime) )
{
cmSystemTools::Error("Problem creating tar: ", outFile.c_str());
return 1;
@@ -769,7 +858,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
else if ( flags.find_first_of('x') != flags.npos )
{
if ( !cmSystemTools::ExtractTar(
- outFile.c_str(), gzip, verbose) )
+ outFile.c_str(), verbose) )
{
cmSystemTools::Error("Problem extracting tar: ", outFile.c_str());
return 1;
@@ -885,15 +974,15 @@ int cmcmd::SymlinkExecutable(std::vector<std::string>& args)
bool cmcmd::SymlinkInternal(std::string const& file, std::string const& link)
{
if(cmSystemTools::FileExists(link.c_str()) ||
- cmSystemTools::FileIsSymlink(link.c_str()))
+ cmSystemTools::FileIsSymlink(link))
{
- cmSystemTools::RemoveFile(link.c_str());
+ cmSystemTools::RemoveFile(link);
}
#if defined(_WIN32) && !defined(__CYGWIN__)
return cmSystemTools::CopyFileAlways(file.c_str(), link.c_str());
#else
std::string linktext = cmSystemTools::GetFilenameName(file);
- return cmSystemTools::CreateSymlink(linktext.c_str(), link.c_str());
+ return cmSystemTools::CreateSymlink(linktext, link);
#endif
}
@@ -1214,7 +1303,7 @@ int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args,
targetName = i->substr(5);
}
}
- if(targetName.size() == 0 || command.size() == 0)
+ if(targetName.empty() || command.empty())
{
return -1;
}
@@ -1318,7 +1407,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
}
std::string manifestFile = targetName;
manifestFile += ".embed.manifest";
- std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str());
+ std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile);
fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID "
"*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\"";
fout.close();
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index fb97af6..c0eb8ac 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -19,7 +19,6 @@
#include "CTest/cmCTestScriptHandler.h"
#include "CTest/cmCTestLaunch.h"
#include "cmsys/Encoding.hxx"
-#include <locale.h>
//----------------------------------------------------------------------------
static const char * cmDocumentationName[][2] =
@@ -117,8 +116,6 @@ static const char * cmDocumentationOptions[][2] =
// this is a test driver program for cmCTest.
int main (int argc, char const* const* argv)
{
- setlocale(LC_CTYPE, "");
-
cmsys::Encoding::CommandLineArguments encoding_args =
cmsys::Encoding::CommandLineArguments::Main(argc, argv);
argc = encoding_args.argc();
@@ -136,7 +133,7 @@ int main (int argc, char const* const* argv)
cmCTest inst;
- if ( cmSystemTools::GetCurrentWorkingDirectory().size() == 0 )
+ if (cmSystemTools::GetCurrentWorkingDirectory().empty())
{
cmCTestLog(&inst, ERROR_MESSAGE,
"Current working directory cannot be established." << std::endl);
diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c
index d07bdd0..4b8ede2 100644
--- a/Source/kwsys/Base64.c
+++ b/Source/kwsys/Base64.c
@@ -115,10 +115,10 @@ void kwsysBase64_Encode1(const unsigned char *src, unsigned char *dest)
actually knowing how much data to expect (if the input is not a multiple of
3 bytes then the extra padding needed to complete the encode 4 bytes will
stop the decoding anyway). */
-unsigned long kwsysBase64_Encode(const unsigned char *input,
- unsigned long length,
- unsigned char *output,
- int mark_end)
+size_t kwsysBase64_Encode(const unsigned char *input,
+ size_t length,
+ unsigned char *output,
+ int mark_end)
{
const unsigned char *ptr = input;
const unsigned char *end = input + length;
@@ -157,7 +157,7 @@ unsigned long kwsysBase64_Encode(const unsigned char *input,
optr += 4;
}
- return (unsigned long)(optr - output);
+ return (size_t)(optr - output);
}
/*--------------------------------------------------------------------------*/
@@ -207,10 +207,10 @@ int kwsysBase64_Decode3(const unsigned char *src, unsigned char *dest)
'length' parameter is ignored. This enables the caller to decode a stream
without actually knowing how much decoded data to expect (of course, the
buffer must be large enough). */
-unsigned long kwsysBase64_Decode(const unsigned char *input,
- unsigned long length,
- unsigned char *output,
- unsigned long max_input_length)
+size_t kwsysBase64_Decode(const unsigned char *input,
+ size_t length,
+ unsigned char *output,
+ size_t max_input_length)
{
const unsigned char *ptr = input;
unsigned char *optr = output;
@@ -226,7 +226,7 @@ unsigned long kwsysBase64_Decode(const unsigned char *input,
optr += len;
if(len < 3)
{
- return (unsigned long)(optr - output);
+ return (size_t)(optr - output);
}
ptr += 4;
}
@@ -240,7 +240,7 @@ unsigned long kwsysBase64_Decode(const unsigned char *input,
optr += len;
if(len < 3)
{
- return (unsigned long)(optr - output);
+ return (size_t)(optr - output);
}
ptr += 4;
}
@@ -275,5 +275,5 @@ unsigned long kwsysBase64_Decode(const unsigned char *input,
}
}
- return (unsigned long)(optr - output);
+ return (size_t)(optr - output);
}
diff --git a/Source/kwsys/Base64.h.in b/Source/kwsys/Base64.h.in
index 3468007..36ed3cc 100644
--- a/Source/kwsys/Base64.h.in
+++ b/Source/kwsys/Base64.h.in
@@ -14,6 +14,8 @@
#include <@KWSYS_NAMESPACE@/Configure.h>
+#include <stddef.h> /* size_t */
+
/* Redefine all public interface symbol names to be in the proper
namespace. These macros are used internally to kwsys only, and are
not visible to user code. Use kwsysHeaderDump.pl to reproduce
@@ -68,10 +70,10 @@ kwsysEXPORT void kwsysBase64_Encode1(const unsigned char *src,
* the extra padding needed to complete the encode 4 bytes will stop
* the decoding anyway).
*/
-kwsysEXPORT unsigned long kwsysBase64_Encode(const unsigned char *input,
- unsigned long length,
- unsigned char *output,
- int mark_end);
+kwsysEXPORT size_t kwsysBase64_Encode(const unsigned char *input,
+ size_t length,
+ unsigned char *output,
+ int mark_end);
/**
* Decode 4 bytes into a 3 byte string. Returns the number of bytes
@@ -92,10 +94,10 @@ kwsysEXPORT int kwsysBase64_Decode3(const unsigned char *src,
* much decoded data to expect (of course, the buffer must be large
* enough).
*/
-kwsysEXPORT unsigned long kwsysBase64_Decode(const unsigned char *input,
- unsigned long length,
- unsigned char *output,
- unsigned long max_input_length);
+kwsysEXPORT size_t kwsysBase64_Decode(const unsigned char *input,
+ size_t length,
+ unsigned char *output,
+ size_t max_input_length);
#if defined(__cplusplus)
} /* extern "C" */
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 2067690..8069ee2 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -96,7 +96,7 @@ ENDIF()
IF(NOT KWSYS_NAMESPACE)
SET(KWSYS_NAMESPACE "kwsys")
SET(KWSYS_STANDALONE 1)
-ENDIF(NOT KWSYS_NAMESPACE)
+ENDIF()
#-----------------------------------------------------------------------------
# The project name is that of the specified namespace.
@@ -130,49 +130,49 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_USE_String 1)
SET(KWSYS_USE_SystemInformation 1)
SET(KWSYS_USE_CPU 1)
-ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
+ENDIF()
# Enforce component dependencies.
IF(KWSYS_USE_SystemTools)
SET(KWSYS_USE_Directory 1)
SET(KWSYS_USE_FStream 1)
SET(KWSYS_USE_Encoding 1)
-ENDIF(KWSYS_USE_SystemTools)
+ENDIF()
IF(KWSYS_USE_Glob)
SET(KWSYS_USE_Directory 1)
SET(KWSYS_USE_SystemTools 1)
SET(KWSYS_USE_RegularExpression 1)
SET(KWSYS_USE_FStream 1)
SET(KWSYS_USE_Encoding 1)
-ENDIF(KWSYS_USE_Glob)
+ENDIF()
IF(KWSYS_USE_Process)
SET(KWSYS_USE_System 1)
SET(KWSYS_USE_Encoding 1)
-ENDIF(KWSYS_USE_Process)
+ENDIF()
IF(KWSYS_USE_SystemInformation)
SET(KWSYS_USE_Process 1)
-ENDIF(KWSYS_USE_SystemInformation)
+ENDIF()
IF(KWSYS_USE_System)
SET(KWSYS_USE_Encoding 1)
-ENDIF(KWSYS_USE_System)
+ENDIF()
IF(KWSYS_USE_Directory)
SET(KWSYS_USE_Encoding 1)
-ENDIF(KWSYS_USE_Directory)
+ENDIF()
IF(KWSYS_USE_FStream)
SET(KWSYS_USE_Encoding 1)
-ENDIF(KWSYS_USE_FStream)
+ENDIF()
# Setup the large file support default.
IF(KWSYS_LFS_DISABLE)
SET(KWSYS_LFS_REQUESTED 0)
-ELSE(KWSYS_LFS_DISABLE)
+ELSE()
SET(KWSYS_LFS_REQUESTED 1)
-ENDIF(KWSYS_LFS_DISABLE)
+ENDIF()
# Specify default 8 bit encoding for Windows
IF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
SET(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_ACP)
-ENDIF(NOT KWSYS_ENCODING_DEFAULT_CODEPAGE)
+ENDIF()
# Enable testing if building standalone.
IF(KWSYS_STANDALONE)
@@ -180,8 +180,8 @@ IF(KWSYS_STANDALONE)
MARK_AS_ADVANCED(BUILD_TESTING DART_ROOT TCL_TCLSH)
IF(BUILD_TESTING)
ENABLE_TESTING()
- ENDIF(BUILD_TESTING)
-ENDIF(KWSYS_STANDALONE)
+ ENDIF()
+ENDIF()
# Include helper macros.
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/kwsysPlatformTests.cmake)
@@ -197,15 +197,15 @@ INCLUDE_REGULAR_EXPRESSION("^.*$")
IF(NOT KWSYS_INSTALL_INCLUDE_DIR)
STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_INCLUDE_DIR
"${KWSYS_HEADER_INSTALL_DIR}")
-ENDIF(NOT KWSYS_INSTALL_INCLUDE_DIR)
+ENDIF()
IF(NOT KWSYS_INSTALL_LIB_DIR)
STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_LIB_DIR
"${KWSYS_LIBRARY_INSTALL_DIR}")
-ENDIF(NOT KWSYS_INSTALL_LIB_DIR)
+ENDIF()
IF(NOT KWSYS_INSTALL_BIN_DIR)
STRING(REGEX REPLACE "^/" "" KWSYS_INSTALL_BIN_DIR
"${KWSYS_LIBRARY_INSTALL_DIR}")
-ENDIF(NOT KWSYS_INSTALL_BIN_DIR)
+ENDIF()
# Setup header install rules.
SET(KWSYS_INSTALL_INCLUDE_OPTIONS)
@@ -213,7 +213,7 @@ IF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
SET(KWSYS_INSTALL_INCLUDE_OPTIONS ${KWSYS_INSTALL_INCLUDE_OPTIONS}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
)
-ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
+ENDIF()
# Setup library install rules.
SET(KWSYS_INSTALL_LIBRARY_RULE)
@@ -230,7 +230,7 @@ IF(KWSYS_INSTALL_LIB_DIR)
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
- ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
+ ENDIF()
# Install the archive to the lib directory.
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
@@ -241,8 +241,8 @@ IF(KWSYS_INSTALL_LIB_DIR)
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT}
)
- ENDIF(KWSYS_INSTALL_COMPONENT_NAME_DEVELOPMENT)
-ENDIF(KWSYS_INSTALL_LIB_DIR)
+ ENDIF()
+ENDIF()
IF(KWSYS_INSTALL_BIN_DIR)
# Install the runtime library to the bin directory.
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
@@ -253,8 +253,8 @@ IF(KWSYS_INSTALL_BIN_DIR)
SET(KWSYS_INSTALL_LIBRARY_RULE ${KWSYS_INSTALL_LIBRARY_RULE}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
- ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
-ENDIF(KWSYS_INSTALL_BIN_DIR)
+ ENDIF()
+ENDIF()
# Do not support old KWSYS_*a_INSTALL_DIR variable names.
SET(KWSYS_HEADER_INSTALL_DIR)
@@ -266,7 +266,7 @@ STRING(COMPARE EQUAL "${PROJECT_SOURCE_DIR}" "${PROJECT_BINARY_DIR}"
IF(NOT KWSYS_IN_SOURCE_BUILD)
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsysPrivate.h
${PROJECT_BINARY_DIR}/kwsysPrivate.h COPYONLY IMMEDIATE)
-ENDIF(NOT KWSYS_IN_SOURCE_BUILD)
+ENDIF()
# Select plugin module file name convention.
IF(NOT KWSYS_DynamicLoader_PREFIX)
@@ -280,7 +280,7 @@ ENDIF()
# We require ANSI support from the C compiler. Add any needed flags.
IF(CMAKE_ANSI_CFLAGS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
-ENDIF(CMAKE_ANSI_CFLAGS)
+ENDIF()
#-----------------------------------------------------------------------------
# Adjust compiler flags for some platforms.
@@ -292,11 +292,11 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX)
KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE "${CMAKE_CXX_FLAGS}")
IF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local")
- ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_IMPLICIT_LOCAL)
+ ENDIF()
IF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -no_implicit_include")
- ENDIF(NOT KWSYS_CXX_FLAGS_HAVE_NO_IMPLICIT_INCLUDE)
- ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+ ENDIF()
+ ENDIF()
IF(CMAKE_SYSTEM MATCHES "HP-UX")
SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
IF(CMAKE_CXX_COMPILER_ID MATCHES "HP")
@@ -306,8 +306,8 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
ENDIF()
ENDIF()
- ENDIF(CMAKE_SYSTEM MATCHES "HP-UX")
-ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
+ ENDIF()
+ENDIF()
#-----------------------------------------------------------------------------
# Configure Large File Support.
@@ -327,11 +327,11 @@ IF(KWSYS_LFS_REQUESTED)
IF(KWSYS_LFS_WORKS)
SET(KWSYS_LFS_AVAILABLE 1)
- ENDIF(KWSYS_LFS_WORKS)
-ELSE(KWSYS_LFS_REQUESTED)
+ ENDIF()
+ELSE()
# Large File Support is not requested.
SET(KWSYS_LFS_REQUESTED 0)
-ENDIF(KWSYS_LFS_REQUESTED)
+ENDIF()
#-----------------------------------------------------------------------------
# Configure the standard library header wrappers based on compiler's
@@ -343,34 +343,34 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAVE_STD
IF(KWSYS_IOS_FORCE_OLD)
SET(KWSYS_IOS_USE_ANSI 0)
-ELSE(KWSYS_IOS_FORCE_OLD)
+ELSE()
KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_ANSI
"Checking whether ANSI stream headers are available" DIRECT)
-ENDIF(KWSYS_IOS_FORCE_OLD)
+ENDIF()
IF(KWSYS_IOS_USE_ANSI)
KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_HAVE_STD
"Checking whether ANSI streams are in std namespace" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_SSTREAM
"Checking whether ANSI string stream is available" DIRECT)
-ELSE(KWSYS_IOS_USE_ANSI)
+ELSE()
SET(KWSYS_IOS_HAVE_STD 0)
SET(KWSYS_IOS_USE_SSTREAM 0)
-ENDIF(KWSYS_IOS_USE_ANSI)
+ENDIF()
IF(KWSYS_IOS_USE_SSTREAM)
SET(KWSYS_IOS_USE_STRSTREAM_H 0)
SET(KWSYS_IOS_USE_STRSTREA_H 0)
-ELSE(KWSYS_IOS_USE_SSTREAM)
+ELSE()
KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREAM_H
"Checking whether strstream.h is available" DIRECT)
IF(KWSYS_IOS_USE_STRSTREAM_H)
SET(KWSYS_IOS_USE_STRSTREA_H 0)
- ELSE(KWSYS_IOS_USE_STRSTREAM_H)
+ ELSE()
KWSYS_PLATFORM_CXX_TEST(KWSYS_IOS_USE_STRSTREA_H
"Checking whether strstrea.h is available" DIRECT)
- ENDIF(KWSYS_IOS_USE_STRSTREAM_H)
-ENDIF(KWSYS_IOS_USE_SSTREAM)
+ ENDIF()
+ENDIF()
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_CSTDDEF
"Checking whether header cstddef is available" DIRECT)
@@ -384,16 +384,16 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS
IF(KWSYS_STL_HAS_ITERATOR_TRAITS)
SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0)
SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
-ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS)
+ELSE()
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY
"Checking whether stl has old iterator_category" DIRECT)
IF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0)
- ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY)
+ ELSE()
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY
"Checking whether stl has internal __iterator_category" DIRECT)
- ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY)
-ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS)
+ ENDIF()
+ENDIF()
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE
"Checking whether stl has standard template allocator" DIRECT)
IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
@@ -402,25 +402,25 @@ IF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
"Checking for rebind member of stl allocator" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT
"Checking for non-standard argument to stl allocator<>::max_size" DIRECT)
-ELSE(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
+ELSE()
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE
"Checking whether stl has old non-template allocator" DIRECT)
SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0)
SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0)
-ENDIF(KWSYS_STL_HAS_ALLOCATOR_TEMPLATE)
+ENDIF()
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_OBJECTS
"Checking whether stl containers support allocator objects." DIRECT)
IF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
# ANSI streams always have string operators.
SET(KWSYS_STL_STRING_HAVE_OSTREAM 1)
SET(KWSYS_STL_STRING_HAVE_ISTREAM 1)
-ELSE(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
+ELSE()
# There may not be string operators for old streams.
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_OSTREAM
"Checking whether stl string has ostream operator<<" DIRECT)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_ISTREAM
"Checking whether stl string has istream operator>>" DIRECT)
-ENDIF(KWSYS_IOS_USE_ANSI AND NOT WATCOM)
+ENDIF()
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES
-DKWSYS_IOS_USE_ANSI=${KWSYS_IOS_USE_ANSI}
-DKWSYS_IOS_HAVE_STD=${KWSYS_IOS_HAVE_STD})
@@ -440,7 +440,7 @@ KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP
IF(UNIX)
KWSYS_PLATFORM_CXX_TEST(KWSYS_STAT_HAS_ST_MTIM
"Checking whether struct stat has st_mtim member" DIRECT)
-ENDIF(UNIX)
+ENDIF()
# Check existence and uniqueness of long long and __int64.
KWSYS_PLATFORM_CXX_TEST(KWSYS_CXX_HAS_LONG_LONG
@@ -528,20 +528,20 @@ IF(KWSYS_USE_FundamentalType)
IF(KWSYS_USE___INT64)
KWSYS_PLATFORM_CXX_TEST(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE
"Checking whether unsigned __int64 can convert to double" DIRECT)
- ELSE(KWSYS_USE___INT64)
+ ELSE()
SET(KWSYS_CAN_CONVERT_UI64_TO_DOUBLE 1)
- ENDIF(KWSYS_USE___INT64)
+ ENDIF()
# Check signedness of "char" type.
KWSYS_PLATFORM_CXX_TEST_RUN(KWSYS_CHAR_IS_SIGNED
"Checking whether char is signed" DIRECT)
-ENDIF(KWSYS_USE_FundamentalType)
+ENDIF()
IF(KWSYS_USE_Encoding)
# Look for type size helper macros.
KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_WSTRING
"Checking whether wstring is available" DIRECT)
-ENDIF(KWSYS_USE_Encoding)
+ENDIF()
IF(KWSYS_USE_IOStream)
# Determine whether iostreams support long long.
@@ -567,26 +567,26 @@ IF(KWSYS_USE_IOStream)
SET(KWSYS_IOS_HAS_OSTREAM___INT64 0)
ENDIF()
SET(KWSYS_PLATFORM_CXX_TEST_DEFINES)
-ENDIF(KWSYS_USE_IOStream)
+ENDIF()
IF(KWSYS_NAMESPACE MATCHES "^kwsys$")
SET(KWSYS_NAME_IS_KWSYS 1)
-ELSE(KWSYS_NAMESPACE MATCHES "^kwsys$")
+ELSE()
SET(KWSYS_NAME_IS_KWSYS 0)
-ENDIF(KWSYS_NAMESPACE MATCHES "^kwsys$")
+ENDIF()
# Choose default shared/static build if not specified.
IF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
SET(KWSYS_BUILD_SHARED ${BUILD_SHARED_LIBS})
-ENDIF(KWSYS_BUILD_SHARED MATCHES "^KWSYS_BUILD_SHARED$")
+ENDIF()
IF(KWSYS_BUILD_SHARED)
SET(KWSYS_BUILD_SHARED 1)
SET(KWSYS_LIBRARY_TYPE SHARED)
-ELSE(KWSYS_BUILD_SHARED)
+ELSE()
SET(KWSYS_BUILD_SHARED 0)
SET(KWSYS_LIBRARY_TYPE STATIC)
-ENDIF(KWSYS_BUILD_SHARED)
+ENDIF()
#-----------------------------------------------------------------------------
# Configure some implementation details.
@@ -789,7 +789,7 @@ ENDIF()
# Choose a directory for the generated headers.
IF(NOT KWSYS_HEADER_ROOT)
SET(KWSYS_HEADER_ROOT "${PROJECT_BINARY_DIR}")
-ENDIF(NOT KWSYS_HEADER_ROOT)
+ENDIF()
SET(KWSYS_HEADER_DIR "${KWSYS_HEADER_ROOT}/${KWSYS_NAMESPACE}")
INCLUDE_DIRECTORIES(${KWSYS_HEADER_ROOT})
@@ -801,13 +801,13 @@ IF(KWSYS_INSTALL_DOC_DIR)
SET(KWSYS_INSTALL_LICENSE_OPTIONS ${KWSYS_INSTALL_LICENSE_OPTIONS}
COMPONENT ${KWSYS_INSTALL_COMPONENT_NAME_RUNTIME}
)
- ENDIF(KWSYS_INSTALL_COMPONENT_NAME_RUNTIME)
+ ENDIF()
# Install the license under the documentation directory.
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt
DESTINATION ${KWSYS_INSTALL_DOC_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_LICENSE_OPTIONS})
-ENDIF(KWSYS_INSTALL_DOC_DIR)
+ENDIF()
#-----------------------------------------------------------------------------
# Create STL header wrappers to block warnings in the STL headers and
@@ -844,10 +844,10 @@ FOREACH(header
INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}.hxx
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
- ELSE(KWSYS_STL_HEADER_EXTRA_${header})
+ ENDIF()
+ ELSE()
SET(KWSYS_STL_HEADER_EXTRA "")
- ENDIF(KWSYS_STL_HEADER_EXTRA_${header})
+ ENDIF()
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_stl.hxx.in
${KWSYS_HEADER_DIR}/stl/${header}
@ONLY IMMEDIATE)
@@ -857,8 +857,8 @@ FOREACH(header
INSTALL(FILES ${KWSYS_HEADER_DIR}/stl/${header}
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/stl
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
-ENDFOREACH(header)
+ ENDIF()
+ENDFOREACH()
# Provide cstddef header.
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/kwsys_cstddef.hxx.in
@@ -868,7 +868,7 @@ IF(KWSYS_INSTALL_INCLUDE_DIR)
INSTALL(FILES ${KWSYS_HEADER_DIR}/cstddef
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
-ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
+ENDIF()
#-----------------------------------------------------------------------------
# Create streams header wrappers to give standard names by which they
@@ -884,8 +884,8 @@ FOREACH(header iostream fstream sstream iosfwd)
INSTALL(FILES ${KWSYS_HEADER_DIR}/ios/${header}
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}/ios
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
-ENDFOREACH(header)
+ ENDIF()
+ENDFOREACH()
#-----------------------------------------------------------------------------
# Build a list of classes and headers we need to implement the
@@ -910,9 +910,9 @@ FOREACH(cpp ${cppclasses})
# Load component-specific CMake code.
IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
- ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${cpp}.cmake)
- ENDIF(KWSYS_USE_${cpp})
-ENDFOREACH(cpp)
+ ENDIF()
+ ENDIF()
+ENDFOREACH()
# Add selected C components.
FOREACH(c
@@ -925,9 +925,9 @@ FOREACH(c
# Load component-specific CMake code.
IF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
INCLUDE(${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
- ENDIF(EXISTS ${PROJECT_SOURCE_DIR}/kwsys${c}.cmake)
- ENDIF(KWSYS_USE_${c})
-ENDFOREACH(c)
+ ENDIF()
+ ENDIF()
+ENDFOREACH()
#-----------------------------------------------------------------------------
# Build a list of sources for the library based on components that are
@@ -940,11 +940,11 @@ IF(KWSYS_USE_Process)
IF(NOT UNIX)
# Use the Windows implementation.
SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessWin32.c)
- ELSE(NOT UNIX)
+ ELSE()
# Use the UNIX implementation.
SET(KWSYS_C_SRCS ${KWSYS_C_SRCS} ProcessUNIX.c)
- ENDIF(NOT UNIX)
-ENDIF(KWSYS_USE_Process)
+ ENDIF()
+ENDIF()
# Add selected C sources.
FOREACH(c Base64 Encoding MD5 Terminal System String)
@@ -954,8 +954,8 @@ FOREACH(c Base64 Encoding MD5 Terminal System String)
ELSE()
LIST(APPEND KWSYS_C_SRCS ${c}.c)
ENDIF()
- ENDIF(KWSYS_USE_${c})
-ENDFOREACH(c)
+ ENDIF()
+ENDFOREACH()
# Configure headers of C++ classes and construct the list of sources.
FOREACH(c ${KWSYS_CLASSES})
@@ -976,8 +976,8 @@ FOREACH(c ${KWSYS_CLASSES})
INSTALL(FILES ${KWSYS_HEADER_DIR}/${c}.hxx
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
-ENDFOREACH(c)
+ ENDIF()
+ENDFOREACH()
# Configure C headers.
FOREACH(h ${KWSYS_H_FILES})
@@ -991,8 +991,8 @@ FOREACH(h ${KWSYS_H_FILES})
INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.h
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
-ENDFOREACH(h)
+ ENDIF()
+ENDFOREACH()
# Configure other C++ headers.
FOREACH(h ${KWSYS_HXX_FILES})
@@ -1006,8 +1006,8 @@ FOREACH(h ${KWSYS_HXX_FILES})
INSTALL(FILES ${KWSYS_HEADER_DIR}/${h}.hxx
DESTINATION ${KWSYS_INSTALL_INCLUDE_DIR}/${KWSYS_NAMESPACE}
${KWSYS_INSTALL_INCLUDE_OPTIONS})
- ENDIF(KWSYS_INSTALL_INCLUDE_DIR)
-ENDFOREACH(h)
+ ENDIF()
+ENDFOREACH()
#-----------------------------------------------------------------------------
# Add the library with the configured name and list of sources.
@@ -1018,8 +1018,8 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
IF(KWSYS_USE_DynamicLoader)
IF(UNIX)
TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE} ${CMAKE_DL_LIBS})
- ENDIF(UNIX)
- ENDIF(KWSYS_USE_DynamicLoader)
+ ENDIF()
+ ENDIF()
IF(KWSYS_USE_SystemInformation)
IF(WIN32)
@@ -1044,13 +1044,13 @@ IF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
${KWSYS_PROPERTIES_CXX}
)
- ENDIF(KWSYS_PROPERTIES_CXX)
+ ENDIF()
# Create an install target for the library.
IF(KWSYS_INSTALL_LIBRARY_RULE)
INSTALL(TARGETS ${KWSYS_NAMESPACE} ${KWSYS_INSTALL_LIBRARY_RULE})
- ENDIF(KWSYS_INSTALL_LIBRARY_RULE)
-ENDIF(KWSYS_C_SRCS OR KWSYS_CXX_SRCS)
+ ENDIF()
+ENDIF()
# Add a C-only library if requested.
IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
@@ -1062,20 +1062,20 @@ IF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
SET_TARGET_PROPERTIES(${KWSYS_NAMESPACE} PROPERTIES
${KWSYS_PROPERTIES_C}
)
- ENDIF(KWSYS_PROPERTIES_C)
+ ENDIF()
# Create an install target for the library.
IF(KWSYS_INSTALL_LIBRARY_RULE)
INSTALL(TARGETS ${KWSYS_NAMESPACE}_c ${KWSYS_INSTALL_LIBRARY_RULE})
- ENDIF(KWSYS_INSTALL_LIBRARY_RULE)
-ENDIF(KWSYS_ENABLE_C AND KWSYS_C_SRCS)
+ ENDIF()
+ENDIF()
# For building kwsys itself, we use a macro defined on the command
# line to configure the namespace in the C and C++ source files.
ADD_DEFINITIONS("-DKWSYS_NAMESPACE=${KWSYS_NAMESPACE}")
# Disable deprecation warnings for standard C functions.
-IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$"))
+IF(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "Intel"))
ADD_DEFINITIONS(
-D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_SECURE_NO_DEPRECATE
@@ -1093,13 +1093,13 @@ IF(KWSYS_USE_String)
# Activate code in "String.c". See the comment in the source.
SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
COMPILE_FLAGS "-DKWSYS_STRING_C")
-ENDIF(KWSYS_USE_String)
+ENDIF()
IF(KWSYS_USE_Encoding)
# Set default 8 bit encoding in "EndcodingC.c".
SET_PROPERTY(SOURCE EncodingC.c APPEND PROPERTY COMPILE_DEFINITIONS
KWSYS_ENCODING_DEFAULT_CODEPAGE=${KWSYS_ENCODING_DEFAULT_CODEPAGE})
-ENDIF(KWSYS_USE_Encoding)
+ENDIF()
#-----------------------------------------------------------------------------
# Setup testing if not being built as part of another project.
@@ -1109,7 +1109,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(EXEC_DIR "${CMAKE_CURRENT_BINARY_DIR}")
IF(EXECUTABLE_OUTPUT_PATH)
SET(EXEC_DIR "${EXECUTABLE_OUTPUT_PATH}")
- ENDIF(EXECUTABLE_OUTPUT_PATH)
+ ENDIF()
# C tests
SET(KWSYS_C_TESTS
@@ -1129,7 +1129,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
FOREACH(test ${KWSYS_C_TESTS})
ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsC ${test} ${KWSYS_TEST_ARGS_${test}})
SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
- ENDFOREACH(test)
+ ENDFOREACH()
# C++ tests
IF(NOT WATCOM)
@@ -1137,7 +1137,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
testAutoPtr
testHashSTL
)
- ENDIF(NOT WATCOM)
+ ENDIF()
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testIOS
testSystemTools
@@ -1148,22 +1148,22 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testEncoding
)
- ENDIF(KWSYS_STL_HAS_WSTRING)
+ ENDIF()
IF(KWSYS_USE_FStream)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS}
testFStream
)
- ENDIF(KWSYS_USE_FStream)
+ ENDIF()
IF(KWSYS_USE_SystemInformation)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testSystemInformation)
- ENDIF(KWSYS_USE_SystemInformation)
+ ENDIF()
IF(KWSYS_USE_DynamicLoader)
SET(KWSYS_CXX_TESTS ${KWSYS_CXX_TESTS} testDynamicLoader)
# If kwsys contains the DynamicLoader, need extra library
ADD_LIBRARY(${KWSYS_NAMESPACE}TestDynload MODULE testDynload.c)
SET_PROPERTY(TARGET ${KWSYS_NAMESPACE}TestDynload PROPERTY LABELS ${KWSYS_LABELS_LIB})
ADD_DEPENDENCIES(${KWSYS_NAMESPACE}TestDynload ${KWSYS_NAMESPACE})
- ENDIF(KWSYS_USE_DynamicLoader)
+ ENDIF()
CREATE_TEST_SOURCELIST(
KWSYS_CXX_TEST_SRCS ${KWSYS_NAMESPACE}TestsCxx.cxx
${KWSYS_CXX_TESTS}
@@ -1183,7 +1183,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/ExtraTest.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
SET_DIRECTORY_PROPERTIES(PROPERTIES TEST_INCLUDE_FILE "${CMAKE_CURRENT_BINARY_DIR}/ExtraTest.cmake")
- ENDIF(CTEST_TEST_KWSYS)
+ ENDIF()
SET(KWSYS_TEST_ARGS_testCommandLineArguments
--another-bool-variable
@@ -1216,7 +1216,7 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
FOREACH(test ${KWSYS_CXX_TESTS})
ADD_TEST(kwsys.${test} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestsCxx ${test} ${KWSYS_TEST_ARGS_${test}})
SET_PROPERTY(TEST kwsys.${test} PROPERTY LABELS ${KWSYS_LABELS_TEST})
- ENDFOREACH(test)
+ ENDFOREACH()
# Process tests.
ADD_EXECUTABLE(${KWSYS_NAMESPACE}TestProcess testProcess.c)
@@ -1224,15 +1224,15 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
TARGET_LINK_LIBRARIES(${KWSYS_NAMESPACE}TestProcess ${KWSYS_NAMESPACE}_c)
IF(NOT CYGWIN)
SET(KWSYS_TEST_PROCESS_7 7)
- ENDIF(NOT CYGWIN)
+ ENDIF()
FOREACH(n 1 2 3 4 5 6 ${KWSYS_TEST_PROCESS_7})
ADD_TEST(kwsys.testProcess-${n} ${EXEC_DIR}/${KWSYS_NAMESPACE}TestProcess ${n})
SET_PROPERTY(TEST kwsys.testProcess-${n} PROPERTY LABELS ${KWSYS_LABELS_TEST})
SET_TESTS_PROPERTIES(kwsys.testProcess-${n} PROPERTIES TIMEOUT 120)
- ENDFOREACH(n)
+ ENDFOREACH()
# Some Apple compilers produce bad optimizations in this source.
- IF(APPLE AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(GNU|LLVM)$")
+ IF(APPLE AND CMAKE_C_COMPILER_ID MATCHES "^(GNU|LLVM)$")
SET_SOURCE_FILES_PROPERTIES(testProcess.c PROPERTIES COMPILE_FLAGS -O0)
ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "XL")
# Tell IBM XL not to warn about our test infinite loop
@@ -1263,5 +1263,5 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
SET_TESTS_PROPERTIES(${KWSYS_TEST_BOGUS_FAILURES} PROPERTIES WILL_FAIL ON)
ENDIF()
- ENDIF(BUILD_TESTING)
-ENDIF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
+ ENDIF()
+ENDIF()
diff --git a/Source/kwsys/CONTRIBUTING.rst b/Source/kwsys/CONTRIBUTING.rst
new file mode 100644
index 0000000..e097b76
--- /dev/null
+++ b/Source/kwsys/CONTRIBUTING.rst
@@ -0,0 +1,35 @@
+Contributing to KWSys
+*********************
+
+Overview
+========
+
+KWSys is kept in its own Git repository and shared by several projects
+via copies in their source trees. Changes to KWSys should not be made
+directly in a host project, except perhaps in maintenance branches.
+
+Please visit
+
+ http://public.kitware.com/Wiki/KWSys/Git
+
+to contribute changes directly to KWSys upstream. Once changes are
+reviewed, tested, and integrated there then the copies of KWSys within
+dependent projects can be updated to get the changes.
+
+Issues
+======
+
+KWSys has no independent issue tracker. After encountering an issue
+(bug) please try to submit a patch using the above instructions.
+Otherwise please report the issue to the tracker for the project that
+hosts the copy of KWSys in which the problem was found.
+
+License
+=======
+
+We do not require any formal copyright assignment or contributor license
+agreement. Any contributions intentionally sent upstream are presumed
+to be offerred under terms of the OSI-approved BSD 3-clause License.
+See `Copyright.txt`_ for details.
+
+.. _`Copyright.txt`: Copyright.txt
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index 7041f7b..58cea63 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -203,13 +203,18 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na
#include <sys/types.h>
#include <dirent.h>
-/* There is a problem with the Portland compiler, large file
-support and glibc/Linux system headers:
-http://www.pgroup.com/userforum/viewtopic.php?
-p=1992&sid=f16167f51964f1a68fe5041b8eb213b6
-*/
-#if defined(__PGI) && defined(__USE_FILE_OFFSET64)
-# define dirent dirent64
+// PGI with glibc has trouble with dirent and large file support:
+// http://www.pgroup.com/userforum/viewtopic.php?
+// p=1992&sid=f16167f51964f1a68fe5041b8eb213b6
+// Work around the problem by mapping dirent the same way as readdir.
+#if defined(__PGI) && defined(__GLIBC__)
+# define kwsys_dirent_readdir dirent
+# define kwsys_dirent_readdir64 dirent64
+# define kwsys_dirent kwsys_dirent_lookup(readdir)
+# define kwsys_dirent_lookup(x) kwsys_dirent_lookup_delay(x)
+# define kwsys_dirent_lookup_delay(x) kwsys_dirent_##x
+#else
+# define kwsys_dirent dirent
#endif
namespace KWSYS_NAMESPACE
@@ -226,7 +231,7 @@ bool Directory::Load(const kwsys_stl::string& name)
return 0;
}
- for (dirent* d = readdir(dir); d; d = readdir(dir) )
+ for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) )
{
this->Internal->Files.push_back(d->d_name);
}
@@ -245,7 +250,7 @@ unsigned long Directory::GetNumberOfFilesInDirectory(const kwsys_stl::string& na
}
unsigned long count = 0;
- for (dirent* d = readdir(dir); d; d = readdir(dir) )
+ for (kwsys_dirent* d = readdir(dir); d; d = readdir(dir) )
{
count++;
}
diff --git a/Source/kwsys/Directory.hxx.in b/Source/kwsys/Directory.hxx.in
index 0acb191..1bcf90e 100644
--- a/Source/kwsys/Directory.hxx.in
+++ b/Source/kwsys/Directory.hxx.in
@@ -18,7 +18,6 @@
/* Define these macros temporarily to keep the code readable. */
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# define kwsys_stl @KWSYS_NAMESPACE@_stl
-# define kwsys_ios @KWSYS_NAMESPACE@_ios
#endif
namespace @KWSYS_NAMESPACE@
@@ -87,7 +86,6 @@ private:
/* Undefine temporary macros. */
#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
# undef kwsys_stl
-# undef kwsys_ios
#endif
#endif
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index 44cf6af..66c7d57 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -40,9 +40,9 @@ namespace KWSYS_NAMESPACE
{
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname )
{
- return shl_load(libname, BIND_DEFERRED | DYNAMIC_PATH, 0L);
+ return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L);
}
//----------------------------------------------------------------------------
@@ -53,7 +53,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer
-DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sym)
+DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
void* addr;
int status;
@@ -62,7 +62,7 @@ DynamicLoader::GetSymbolAddress(DynamicLoader::LibraryHandle lib, const char* sy
* TYPE_DATA Look for a symbol in the data segment (for example, variables).
* TYPE_UNDEFINED Look for any symbol.
*/
- status = shl_findsym (&lib, sym, TYPE_UNDEFINED, &addr);
+ status = shl_findsym (&lib, sym.c_str(), TYPE_UNDEFINED, &addr);
void* result = (status < 0) ? (void*)0 : addr;
// Hack to cast pointer-to-data to pointer-to-function.
@@ -111,18 +111,18 @@ namespace KWSYS_NAMESPACE
{
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname )
{
NSObjectFileImageReturnCode rc;
NSObjectFileImage image = 0;
- rc = NSCreateObjectFileImageFromFile(libname, &image);
+ rc = NSCreateObjectFileImageFromFile(libname.c_str(), &image);
// rc == NSObjectFileImageInappropriateFile when trying to load a dylib file
if( rc != NSObjectFileImageSuccess )
{
return 0;
}
- NSModule handle = NSLinkModule(image, libname,
+ NSModule handle = NSLinkModule(image, libname.c_str(),
NSLINKMODULE_OPTION_BINDNOW|NSLINKMODULE_OPTION_RETURN_ON_ERROR);
NSDestroyObjectFileImage(image);
return handle;
@@ -142,14 +142,14 @@ int DynamicLoader::CloseLibrary( DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
- DynamicLoader::LibraryHandle lib, const char* sym)
+ DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
void *result=0;
// Need to prepend symbols with '_' on Apple-gcc compilers
- size_t len = strlen(sym);
+ size_t len = sym.size();
char *rsym = new char[len + 1 + 1];
strcpy(rsym, "_");
- strcat(rsym+1, sym);
+ strcat(rsym+1, sym.c_str());
NSSymbol symbol = NSLookupSymbolInModule(lib, rsym);
if(symbol)
@@ -183,13 +183,13 @@ namespace KWSYS_NAMESPACE
{
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname)
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname)
{
DynamicLoader::LibraryHandle lh;
- int length = MultiByteToWideChar(CP_UTF8, 0, libname, -1, NULL, 0);
+ int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0);
wchar_t* wchars = new wchar_t[length+1];
wchars[0] = '\0';
- MultiByteToWideChar(CP_UTF8, 0, libname, -1, wchars, length);
+ MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length);
lh = LoadLibraryW(wchars);
delete [] wchars;
return lh;
@@ -203,7 +203,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
- DynamicLoader::LibraryHandle lib, const char* sym)
+ DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
// TODO: The calling convention affects the name of the symbol. We
// should have a tool to help get the symbol with the desired
@@ -230,12 +230,12 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
void *result;
#if defined(__BORLANDC__) || defined(__WATCOMC__)
// Need to prepend symbols with '_'
- size_t len = strlen(sym);
+ size_t len = sym.size();
char *rsym = new char[len + 1 + 1];
strcpy(rsym, "_");
- strcat(rsym, sym);
+ strcat(rsym, sym.c_str());
#else
- const char *rsym = sym;
+ const char *rsym = sym.c_str();
#endif
result = (void*)GetProcAddress(lib, rsym);
#if defined(__BORLANDC__) || defined(__WATCOMC__)
@@ -298,11 +298,11 @@ namespace KWSYS_NAMESPACE
static image_id last_dynamic_err = B_OK;
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname )
{
// image_id's are integers, errors are negative. Add one just in case we
// get a valid image_id of zero (is that even possible?).
- image_id rc = load_add_on(libname);
+ image_id rc = load_add_on(libname.c_str());
if (rc < 0)
{
last_dynamic_err = rc;
@@ -336,7 +336,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
- DynamicLoader::LibraryHandle lib, const char* sym)
+ DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
// Hack to cast pointer-to-data to pointer-to-function.
union
@@ -356,7 +356,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
// !!! FIXME: BeOS can do function-only lookups...does this ever
// !!! FIXME: actually _want_ a data symbol lookup, or was this union
// !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only).
- status_t rc = get_image_symbol(lib-1,sym,B_SYMBOL_TYPE_ANY,&result.pvoid);
+ status_t rc = get_image_symbol(lib-1,sym.c_str(),B_SYMBOL_TYPE_ANY,&result.pvoid);
if (rc != B_OK)
{
last_dynamic_err = rc;
@@ -389,7 +389,7 @@ namespace KWSYS_NAMESPACE
{
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname )
{
return 0;
}
@@ -407,7 +407,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
- DynamicLoader::LibraryHandle lib, const char* sym)
+ DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
return 0;
}
@@ -433,12 +433,12 @@ namespace KWSYS_NAMESPACE
{
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname )
{
- char *name = (char *)calloc(1, strlen(libname) + 1);
+ char *name = (char *)calloc(1, libname.size() + 1);
dld_init(program_invocation_name);
- strncpy(name, libname, strlen(libname));
- dld_link(libname);
+ strncpy(name, libname.c_str(), libname.size());
+ dld_link(libname.c_str());
return (void *)name;
}
@@ -452,7 +452,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
- DynamicLoader::LibraryHandle lib, const char* sym)
+ DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
// Hack to cast pointer-to-data to pointer-to-function.
union
@@ -460,7 +460,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
void* pvoid;
DynamicLoader::SymbolPointer psym;
} result;
- result.pvoid = dld_get_symbol(sym);
+ result.pvoid = dld_get_symbol(sym.c_str());
return result.psym;
}
@@ -485,9 +485,9 @@ namespace KWSYS_NAMESPACE
{
//----------------------------------------------------------------------------
-DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const char* libname )
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(const kwsys_stl::string& libname )
{
- return dlopen(libname, RTLD_LAZY);
+ return dlopen(libname.c_str(), RTLD_LAZY);
}
//----------------------------------------------------------------------------
@@ -504,7 +504,7 @@ int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
//----------------------------------------------------------------------------
DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
- DynamicLoader::LibraryHandle lib, const char* sym)
+ DynamicLoader::LibraryHandle lib, const kwsys_stl::string& sym)
{
// Hack to cast pointer-to-data to pointer-to-function.
union
@@ -512,7 +512,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
void* pvoid;
DynamicLoader::SymbolPointer psym;
} result;
- result.pvoid = dlsym(lib, sym);
+ result.pvoid = dlsym(lib, sym.c_str());
return result.psym;
}
diff --git a/Source/kwsys/DynamicLoader.hxx.in b/Source/kwsys/DynamicLoader.hxx.in
index 64468ec..75811ab 100644
--- a/Source/kwsys/DynamicLoader.hxx.in
+++ b/Source/kwsys/DynamicLoader.hxx.in
@@ -13,6 +13,7 @@
#define @KWSYS_NAMESPACE@_DynamicLoader_hxx
#include <@KWSYS_NAMESPACE@/Configure.h>
+#include <@KWSYS_NAMESPACE@/stl/string>
#if defined(__hpux)
#include <dl.h>
@@ -27,6 +28,11 @@
#include <be/kernel/image.h>
#endif
+/* Define these macros temporarily to keep the code readable. */
+#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# define kwsys_stl @KWSYS_NAMESPACE@_stl
+#endif
+
namespace @KWSYS_NAMESPACE@
{
/** \class DynamicLoader
@@ -77,14 +83,14 @@ public:
/** Load a dynamic library into the current process.
* The returned LibraryHandle can be used to access the symbols in the
* library. */
- static LibraryHandle OpenLibrary(const char*);
+ static LibraryHandle OpenLibrary(const kwsys_stl::string&);
/** Attempt to detach a dynamic library from the
* process. A value of true is returned if it is sucessful. */
static int CloseLibrary(LibraryHandle);
/** Find the address of the symbol in the given library. */
- static SymbolPointer GetSymbolAddress(LibraryHandle, const char*);
+ static SymbolPointer GetSymbolAddress(LibraryHandle, const kwsys_stl::string&);
/** Return the default module prefix for the current platform. */
static const char* LibPrefix() { return "@KWSYS_DynamicLoader_PREFIX@"; }
@@ -98,4 +104,9 @@ public:
} // namespace @KWSYS_NAMESPACE@
+/* Undefine temporary macros. */
+#if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
+# undef kwsys_stl
+#endif
+
#endif
diff --git a/Source/kwsys/EncodingC.c b/Source/kwsys/EncodingC.c
index cda78e2..ba2cec2 100644
--- a/Source/kwsys/EncodingC.c
+++ b/Source/kwsys/EncodingC.c
@@ -44,7 +44,7 @@ wchar_t* kwsysEncoding_DupToWide(const char* str)
size_t length = kwsysEncoding_mbstowcs(NULL, str, 0) + 1;
if(length > 0)
{
- ret = malloc((length)*sizeof(wchar_t));
+ ret = (wchar_t*)malloc((length)*sizeof(wchar_t));
ret[0] = 0;
kwsysEncoding_mbstowcs(ret, str, length);
}
@@ -71,7 +71,7 @@ char* kwsysEncoding_DupToNarrow(const wchar_t* str)
size_t length = kwsysEncoding_wcstombs(0, str, 0) + 1;
if(length > 0)
{
- ret = malloc(length);
+ ret = (char*)malloc(length);
ret[0] = 0;
kwsysEncoding_wcstombs(ret, str, length);
}
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index 45425ff..37055d6 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -18,6 +18,11 @@
namespace @KWSYS_NAMESPACE@
{
#if defined(_MSC_VER) && _MSC_VER >= 1400
+# if defined(_NOEXCEPT)
+# define @KWSYS_NAMESPACE@_FStream_NOEXCEPT _NOEXCEPT
+# else
+# define @KWSYS_NAMESPACE@_FStream_NOEXCEPT
+# endif
template<typename CharType,typename Traits>
class basic_filebuf : public std::basic_filebuf<CharType,Traits>
{
@@ -85,7 +90,7 @@ namespace @KWSYS_NAMESPACE@
return buf_;
}
- ~basic_ifstream()
+ ~basic_ifstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT
{
buf_->close();
delete buf_;
@@ -147,7 +152,7 @@ class basic_ofstream : public std::basic_ostream<CharType,Traits>
{
return buf_.get();
}
- ~basic_ofstream()
+ ~basic_ofstream() @KWSYS_NAMESPACE@_FStream_NOEXCEPT
{
buf_->close();
delete buf_;
@@ -160,6 +165,7 @@ class basic_ofstream : public std::basic_ostream<CharType,Traits>
typedef basic_ifstream<char> ifstream;
typedef basic_ofstream<char> ofstream;
+# undef @KWSYS_NAMESPACE@_FStream_NOEXCEPT
#else
using @KWSYS_NAMESPACE@_ios_namespace::ofstream;
using @KWSYS_NAMESPACE@_ios_namespace::ifstream;
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index 0916d2e..5a96aed 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -501,7 +501,7 @@ void Glob::AddFile(kwsys_stl::vector<kwsys_stl::string>& files, const kwsys_stl:
{
if ( !this->Relative.empty() )
{
- files.push_back(kwsys::SystemTools::RelativePath(this->Relative.c_str(), file.c_str()));
+ files.push_back(kwsys::SystemTools::RelativePath(this->Relative, file));
}
else
{
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index ca9d424..1be6d02 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -547,7 +547,7 @@ int kwsysProcess_SetPipeFile(kwsysProcess* cp, int prPipe, const char* file)
}
if(file)
{
- *pfile = malloc(strlen(file)+1);
+ *pfile = (char*)malloc(strlen(file)+1);
if(!*pfile)
{
return 0;
@@ -1468,7 +1468,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
cp->RealWorkingDirectoryLength = 4096;
#endif
cp->RealWorkingDirectory =
- malloc((size_t)(cp->RealWorkingDirectoryLength));
+ (char*)malloc((size_t)(cp->RealWorkingDirectoryLength));
if(!cp->RealWorkingDirectory)
{
return 0;
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index ef71f26..c2965ea 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -340,7 +340,11 @@ kwsysProcess* kwsysProcess_New(void)
osv.dwOSVersionInfoSize = sizeof(osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (push)
-# pragma warning (disable:4996)
+# ifdef __INTEL_COMPILER
+# pragma warning (disable:1478)
+# else
+# pragma warning (disable:4996)
+# endif
#endif
GetVersionEx(&osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
@@ -2382,7 +2386,11 @@ static kwsysProcess_List* kwsysProcess_List_New(void)
osv.dwOSVersionInfoSize = sizeof(osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (push)
-# pragma warning (disable:4996)
+# ifdef __INTEL_COMPILER
+# pragma warning (disable:1478)
+# else
+# pragma warning (disable:4996)
+# endif
#endif
GetVersionEx(&osv);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
diff --git a/Source/kwsys/README.txt b/Source/kwsys/README.txt
index ba03f8d..b8191f7 100644
--- a/Source/kwsys/README.txt
+++ b/Source/kwsys/README.txt
@@ -8,3 +8,5 @@ details.
You are probably reading this file in the source tree of a surrounding
project. In that case, see "../README.kwsys" for details of using
KWSys in your project.
+
+See CONTRIBUTING.rst for instructions to contribute KWSys changes.
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in
index c6f345f..f22fa58 100644
--- a/Source/kwsys/SharedForward.h.in
+++ b/Source/kwsys/SharedForward.h.in
@@ -65,6 +65,15 @@
See the comments below for specific explanations of each macro.
*/
+/* Disable -Wcast-qual warnings since they are too hard to fix in a
+ cross-platform way. */
+#if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wcast-qual")
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Wcast-qual"
+# endif
+#endif
+
/*--------------------------------------------------------------------------*/
/* Full path to the directory in which this executable is built. Do
@@ -917,6 +926,13 @@ static int @KWSYS_NAMESPACE@_shared_forward_to_real(int argc, char** argv_in)
return 1;
}
+/* Restore warning stack. */
+#if defined(__clang__) && defined(__has_warning)
+# if __has_warning("-Wcast-qual")
+# pragma clang diagnostic pop
+# endif
+#endif
+
#else
# error "@KWSYS_NAMESPACE@/SharedForward.h should be included only once."
#endif
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index c4aeb47..9c7ceee 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -443,7 +443,7 @@ public:
};
protected:
- // Functions.
+ // For windows
bool RetrieveCPUFeatures();
bool RetrieveCPUIdentity();
bool RetrieveCPUCacheDetails();
@@ -457,6 +457,7 @@ protected:
bool RetrieveClassicalCPUIdentity();
bool RetrieveExtendedCPUIdentity();
+ // Processor information
Manufacturer ChipManufacturer;
CPUFeatures Features;
ID ChipID;
@@ -464,11 +465,11 @@ protected:
unsigned int NumberOfLogicalCPU;
unsigned int NumberOfPhysicalCPU;
- int CPUCount();
+ int CPUCount(); // For windows
unsigned char LogicalCPUPerPhysicalCPU();
- unsigned char GetAPICId();
+ unsigned char GetAPICId(); // For windows
bool IsHyperThreadingSupported();
- static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int);
+ static LongLong GetCyclesDifference(DELAY_FUNC, unsigned int); // For windows
// For Linux and Cygwin, /proc/cpuinfo formats are slightly different
bool RetreiveInformationFromCpuInfoFile();
@@ -3753,9 +3754,9 @@ bool SystemInformationImplementation::QueryWindowsMemory()
}
# define MEM_VAL(value) ull##value
# endif
- tv = ms.MEM_VAL(TotalVirtual);
+ tv = ms.MEM_VAL(TotalPageFile);
tp = ms.MEM_VAL(TotalPhys);
- av = ms.MEM_VAL(AvailVirtual);
+ av = ms.MEM_VAL(AvailPageFile);
ap = ms.MEM_VAL(AvailPhys);
this->TotalVirtualMemory = tv>>10>>10;
this->TotalPhysicalMemory = tp>>10>>10;
@@ -5068,7 +5069,11 @@ bool SystemInformationImplementation::QueryOSInformation()
osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW);
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (push)
-# pragma warning (disable:4996)
+# ifdef __INTEL_COMPILER
+# pragma warning (disable:1478)
+# else
+# pragma warning (disable:4996)
+# endif
#endif
bOsVersionInfoEx = GetVersionExW ((OSVERSIONINFOW*)&osvi);
if (!bOsVersionInfoEx)
@@ -5156,7 +5161,7 @@ bool SystemInformationImplementation::QueryOSInformation()
}
}
- sprintf (operatingSystem, "%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
+ sprintf (operatingSystem, "%ls (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
this->OSVersion = operatingSystem;
}
else
@@ -5205,7 +5210,7 @@ bool SystemInformationImplementation::QueryOSInformation()
if (osvi.dwMajorVersion <= 4)
{
// NB: NT 4.0 and earlier.
- sprintf (operatingSystem, "version %ld.%ld %s (Build %ld)",
+ sprintf (operatingSystem, "version %ld.%ld %ls (Build %ld)",
osvi.dwMajorVersion,
osvi.dwMinorVersion,
osvi.szCSDVersion,
@@ -5236,7 +5241,7 @@ bool SystemInformationImplementation::QueryOSInformation()
else
{
// Windows 2000 and everything else.
- sprintf (operatingSystem,"%s (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
+ sprintf (operatingSystem,"%ls (Build %ld)", osvi.szCSDVersion, osvi.dwBuildNumber & 0xFFFF);
this->OSVersion = operatingSystem;
}
break;
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index b1221e3..2708211 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -16,6 +16,14 @@
# define _XOPEN_SOURCE_EXTENDED
#endif
+#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
+# define KWSYS_WINDOWS_DIRS
+#else
+# if defined(__SUNPRO_CC)
+# include <fcntl.h>
+# endif
+#endif
+
#include "kwsysPrivate.h"
#include KWSYS_HEADER(RegularExpression.hxx)
#include KWSYS_HEADER(SystemTools.hxx)
@@ -205,8 +213,7 @@ static time_t windows_filetime_to_posix_time(const FILETIME& ft)
}
#endif
-#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
-
+#ifdef KWSYS_WINDOWS_DIRS
#include <wctype.h>
inline int Mkdir(const kwsys_stl::string& dir)
@@ -222,7 +229,7 @@ inline int Rmdir(const kwsys_stl::string& dir)
inline const char* Getcwd(char* buf, unsigned int len)
{
std::vector<wchar_t> w_buf(len);
- if(const wchar_t* ret = _wgetcwd(&w_buf[0], len))
+ if(_wgetcwd(&w_buf[0], len))
{
// make sure the drive letter is capital
if(wcslen(&w_buf[0]) > 1 && w_buf[1] == L':')
@@ -385,6 +392,11 @@ const char* SystemTools::GetEnv(const char* key)
return getenv(key);
}
+const char* SystemTools::GetEnv(const kwsys_stl::string& key)
+{
+ return SystemTools::GetEnv(key.c_str());
+}
+
bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result)
{
const char* v = getenv(key);
@@ -399,6 +411,11 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result)
}
}
+bool SystemTools::GetEnv(const kwsys_stl::string& key, kwsys_stl::string& result)
+{
+ return SystemTools::GetEnv(key.c_str(), result);
+}
+
//----------------------------------------------------------------------------
#if defined(__CYGWIN__) || defined(__GLIBC__)
@@ -410,27 +427,28 @@ bool SystemTools::GetEnv(const char* key, kwsys_stl::string& result)
#if KWSYS_CXX_HAS_UNSETENV
/* unsetenv("A") removes A from the environment.
On older platforms it returns void instead of int. */
-static int kwsysUnPutEnv(const char* env)
+static int kwsysUnPutEnv(const kwsys_stl::string& env)
{
- if(const char* eq = strchr(env, '='))
+ size_t pos = env.find('=');
+ if(pos != env.npos)
{
- std::string name(env, eq-env);
+ std::string name = env.substr(0, pos);
unsetenv(name.c_str());
}
else
{
- unsetenv(env);
+ unsetenv(env.c_str());
}
return 0;
}
#elif defined(KWSYS_PUTENV_EMPTY) || defined(KWSYS_PUTENV_NAME)
/* putenv("A=") or putenv("A") removes A from the environment. */
-static int kwsysUnPutEnv(const char* env)
+static int kwsysUnPutEnv(const kwsys_stl::string& env)
{
int err = 0;
- const char* eq = strchr(env, '=');
- size_t const len = eq? (size_t)(eq-env) : strlen(env);
+ size_t pos = env.find('=');
+ size_t const len = pos == env.npos ? env.size() : pos;
# ifdef KWSYS_PUTENV_EMPTY
size_t const sz = len + 2;
# else
@@ -442,7 +460,7 @@ static int kwsysUnPutEnv(const char* env)
{
return -1;
}
- strncpy(buf, env, len);
+ strncpy(buf, env.c_str(), len);
# ifdef KWSYS_PUTENV_EMPTY
buf[len] = '=';
buf[len+1] = 0;
@@ -471,17 +489,17 @@ static int kwsysUnPutEnv(const char* env)
#else
/* Manipulate the "environ" global directly. */
-static int kwsysUnPutEnv(const char* env)
+static int kwsysUnPutEnv(const kwsys_stl::string& env)
{
- const char* eq = strchr(env, '=');
- size_t const len = eq? (size_t)(eq-env) : strlen(env);
+ size_t pos = env.find('=');
+ size_t const len = pos == env.npos ? env.size() : pos;
int in = 0;
int out = 0;
while(environ[in])
{
if(strlen(environ[in]) > len &&
environ[in][len] == '=' &&
- strncmp(env, environ[in], len) == 0)
+ strncmp(env.c_str(), environ[in], len) == 0)
{
++in;
}
@@ -504,12 +522,13 @@ static int kwsysUnPutEnv(const char* env)
/* setenv("A", "B", 1) will set A=B in the environment and makes its
own copies of the strings. */
-bool SystemTools::PutEnv(const char* env)
+bool SystemTools::PutEnv(const kwsys_stl::string& env)
{
- if(const char* eq = strchr(env, '='))
+ size_t pos = env.find('=');
+ if(pos != env.npos)
{
- std::string name(env, eq-env);
- return setenv(name.c_str(), eq+1, 1) == 0;
+ std::string name = env.substr(0, pos);
+ return setenv(name.c_str(), env.c_str() + pos + 1, 1) == 0;
}
else
{
@@ -517,7 +536,7 @@ bool SystemTools::PutEnv(const char* env)
}
}
-bool SystemTools::UnPutEnv(const char* env)
+bool SystemTools::UnPutEnv(const kwsys_stl::string& env)
{
return kwsysUnPutEnv(env) == 0;
}
@@ -603,14 +622,14 @@ public:
static kwsysEnv kwsysEnvInstance;
-bool SystemTools::PutEnv(const char* env)
+bool SystemTools::PutEnv(const kwsys_stl::string& env)
{
- return kwsysEnvInstance.Put(env);
+ return kwsysEnvInstance.Put(env.c_str());
}
-bool SystemTools::UnPutEnv(const char* env)
+bool SystemTools::UnPutEnv(const kwsys_stl::string& env)
{
- return kwsysEnvInstance.UnPut(env);
+ return kwsysEnvInstance.UnPut(env.c_str());
}
#endif
@@ -689,8 +708,35 @@ bool SystemTools::MakeDirectory(const kwsys_stl::string& path)
// replace replace with with as many times as it shows up in source.
// write the result into source.
void SystemTools::ReplaceString(kwsys_stl::string& source,
- const char* replace,
- const char* with)
+ const kwsys_stl::string& replace,
+ const kwsys_stl::string& with)
+{
+ // do while hangs if replaceSize is 0
+ if (replace.empty())
+ {
+ return;
+ }
+
+ SystemTools::ReplaceString(source, replace.c_str(), replace.size(), with);
+}
+
+void SystemTools::ReplaceString(kwsys_stl::string& source,
+ const char* replace,
+ const char* with)
+{
+ // do while hangs if replaceSize is 0
+ if (!*replace)
+ {
+ return;
+ }
+
+ SystemTools::ReplaceString(source, replace, strlen(replace), with ? with : "");
+}
+
+void SystemTools::ReplaceString(kwsys_stl::string& source,
+ const char* replace,
+ size_t replaceSize,
+ const kwsys_stl::string& with)
{
const char *src = source.c_str();
char *searchPos = const_cast<char *>(strstr(src,replace));
@@ -702,12 +748,6 @@ void SystemTools::ReplaceString(kwsys_stl::string& source,
}
// perform replacements until done
- size_t replaceSize = strlen(replace);
- // do while hangs if replaceSize is 0
- if(replaceSize == 0)
- {
- return;
- }
char *orig = strdup(src);
char *currentPos = orig;
searchPos = searchPos - src + orig;
@@ -739,20 +779,20 @@ void SystemTools::ReplaceString(kwsys_stl::string& source,
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
-static bool SystemToolsParseRegistryKey(const char* key,
+static bool SystemToolsParseRegistryKey(const kwsys_stl::string& key,
HKEY& primaryKey,
kwsys_stl::string& second,
kwsys_stl::string& valuename)
{
kwsys_stl::string primary = key;
- size_t start = primary.find("\\");
+ size_t start = primary.find('\\');
if (start == kwsys_stl::string::npos)
{
return false;
}
- size_t valuenamepos = primary.find(";");
+ size_t valuenamepos = primary.find(';');
if (valuenamepos != kwsys_stl::string::npos)
{
valuename = primary.substr(valuenamepos+1);
@@ -810,7 +850,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode,
#if defined(_WIN32) && !defined(__CYGWIN__)
bool
-SystemTools::GetRegistrySubKeys(const char *key,
+SystemTools::GetRegistrySubKeys(const kwsys_stl::string& key,
kwsys_stl::vector<kwsys_stl::string>& subkeys,
KeyWOW64 view)
{
@@ -849,7 +889,7 @@ SystemTools::GetRegistrySubKeys(const char *key,
return true;
}
#else
-bool SystemTools::GetRegistrySubKeys(const char *,
+bool SystemTools::GetRegistrySubKeys(const kwsys_stl::string&,
kwsys_stl::vector<kwsys_stl::string>&,
KeyWOW64)
{
@@ -865,7 +905,7 @@ bool SystemTools::GetRegistrySubKeys(const char *,
// => will return the data of the "Root" value of the key
#if defined(_WIN32) && !defined(__CYGWIN__)
-bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value,
+bool SystemTools::ReadRegistryValue(const kwsys_stl::string& key, kwsys_stl::string &value,
KeyWOW64 view)
{
bool valueset = false;
@@ -922,7 +962,7 @@ bool SystemTools::ReadRegistryValue(const char *key, kwsys_stl::string &value,
return valueset;
}
#else
-bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &,
+bool SystemTools::ReadRegistryValue(const kwsys_stl::string&, kwsys_stl::string &,
KeyWOW64)
{
return false;
@@ -938,7 +978,8 @@ bool SystemTools::ReadRegistryValue(const char *, kwsys_stl::string &,
// => will set the data of the "Root" value of the key
#if defined(_WIN32) && !defined(__CYGWIN__)
-bool SystemTools::WriteRegistryValue(const char *key, const char *value,
+bool SystemTools::WriteRegistryValue(const kwsys_stl::string& key,
+ const kwsys_stl::string& value,
KeyWOW64 view)
{
HKEY primaryKey = HKEY_CURRENT_USER;
@@ -978,7 +1019,7 @@ bool SystemTools::WriteRegistryValue(const char *key, const char *value,
return false;
}
#else
-bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64)
+bool SystemTools::WriteRegistryValue(const kwsys_stl::string&, const kwsys_stl::string&, KeyWOW64)
{
return false;
}
@@ -992,7 +1033,7 @@ bool SystemTools::WriteRegistryValue(const char *, const char *, KeyWOW64)
// => will delete the data of the "Root" value of the key
#if defined(_WIN32) && !defined(__CYGWIN__)
-bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view)
+bool SystemTools::DeleteRegistryValue(const kwsys_stl::string& key, KeyWOW64 view)
{
HKEY primaryKey = HKEY_CURRENT_USER;
kwsys_stl::string second;
@@ -1023,7 +1064,7 @@ bool SystemTools::DeleteRegistryValue(const char *key, KeyWOW64 view)
return false;
}
#else
-bool SystemTools::DeleteRegistryValue(const char *, KeyWOW64)
+bool SystemTools::DeleteRegistryValue(const kwsys_stl::string&, KeyWOW64)
{
return false;
}
@@ -2245,12 +2286,13 @@ bool SystemTools::CopyFileAlways(const kwsys_stl::string& source, const kwsys_st
SystemTools::MakeDirectory(destination_dir);
// Open files
-
-#if defined(_WIN32) || defined(__CYGWIN__)
- kwsys::ifstream fin(source.c_str(),
- kwsys_ios::ios::binary | kwsys_ios::ios::in);
+#if defined(_WIN32)
+ kwsys::ifstream fin(Encoding::ToNarrow(
+ SystemTools::ConvertToWindowsExtendedPath(source)).c_str(),
+ kwsys_ios::ios::in | kwsys_ios_binary);
#else
- kwsys::ifstream fin(source.c_str());
+ kwsys::ifstream fin(source.c_str(),
+ kwsys_ios::ios::in | kwsys_ios_binary);
#endif
if(!fin)
{
@@ -2263,12 +2305,13 @@ bool SystemTools::CopyFileAlways(const kwsys_stl::string& source, const kwsys_st
// that do not allow file removal can be modified.
SystemTools::RemoveFile(real_destination);
-#if defined(_WIN32) || defined(__CYGWIN__)
- kwsys::ofstream fout(real_destination.c_str(),
- kwsys_ios::ios::binary | kwsys_ios::ios::out | kwsys_ios::ios::trunc);
+#if defined(_WIN32)
+ kwsys::ofstream fout(Encoding::ToNarrow(
+ SystemTools::ConvertToWindowsExtendedPath(real_destination)).c_str(),
+ kwsys_ios::ios::out | kwsys_ios::ios::trunc | kwsys_ios_binary);
#else
kwsys::ofstream fout(real_destination.c_str(),
- kwsys_ios::ios::out | kwsys_ios::ios::trunc);
+ kwsys_ios::ios::out | kwsys_ios::ios::trunc | kwsys_ios_binary);
#endif
if(!fout)
{
@@ -2379,7 +2422,7 @@ bool SystemTools::CopyADirectory(const kwsys_stl::string& source, const kwsys_st
// return size of file; also returns zero if no file exists
-unsigned long SystemTools::FileLength(const char* filename)
+unsigned long SystemTools::FileLength(const kwsys_stl::string& filename)
{
unsigned long length = 0;
#ifdef _WIN32
@@ -2397,7 +2440,7 @@ unsigned long SystemTools::FileLength(const char* filename)
}
#else
struct stat fs;
- if (stat(filename, &fs) == 0)
+ if (stat(filename.c_str(), &fs) == 0)
{
length = static_cast<unsigned long>(fs.st_size);
}
@@ -2663,7 +2706,7 @@ size_t SystemTools::GetMaximumFilePathLength()
* found. Otherwise, the empty string is returned.
*/
kwsys_stl::string SystemTools
-::FindName(const char* name,
+::FindName(const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& userPaths,
bool no_system_path)
{
@@ -2716,7 +2759,7 @@ kwsys_stl::string SystemTools
* found. Otherwise, the empty string is returned.
*/
kwsys_stl::string SystemTools
-::FindFile(const char* name,
+::FindFile(const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& userPaths,
bool no_system_path)
{
@@ -2735,7 +2778,7 @@ kwsys_stl::string SystemTools
* found. Otherwise, the empty string is returned.
*/
kwsys_stl::string SystemTools
-::FindDirectory(const char* name,
+::FindDirectory(const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& userPaths,
bool no_system_path)
{
@@ -3078,29 +3121,29 @@ bool SystemTools::FileIsSymlink(const kwsys_stl::string& name)
}
#if defined(_WIN32) && !defined(__CYGWIN__)
-bool SystemTools::CreateSymlink(const char*, const char*)
+bool SystemTools::CreateSymlink(const kwsys_stl::string&, const kwsys_stl::string&)
{
return false;
}
#else
-bool SystemTools::CreateSymlink(const char* origName, const char* newName)
+bool SystemTools::CreateSymlink(const kwsys_stl::string& origName, const kwsys_stl::string& newName)
{
- return symlink(origName, newName) >= 0;
+ return symlink(origName.c_str(), newName.c_str()) >= 0;
}
#endif
#if defined(_WIN32) && !defined(__CYGWIN__)
-bool SystemTools::ReadSymlink(const char*, kwsys_stl::string&)
+bool SystemTools::ReadSymlink(const kwsys_stl::string&, kwsys_stl::string&)
{
return false;
}
#else
-bool SystemTools::ReadSymlink(const char* newName,
+bool SystemTools::ReadSymlink(const kwsys_stl::string& newName,
kwsys_stl::string& origName)
{
char buf[KWSYS_SYSTEMTOOLS_MAXPATH+1];
int count =
- static_cast<int>(readlink(newName, buf, KWSYS_SYSTEMTOOLS_MAXPATH));
+ static_cast<int>(readlink(newName.c_str(), buf, KWSYS_SYSTEMTOOLS_MAXPATH));
if(count >= 0)
{
// Add null-terminator.
@@ -3136,14 +3179,14 @@ kwsys_stl::string SystemTools::GetCurrentWorkingDirectory(bool collapse)
return path;
}
-kwsys_stl::string SystemTools::GetProgramPath(const char* in_name)
+kwsys_stl::string SystemTools::GetProgramPath(const kwsys_stl::string& in_name)
{
kwsys_stl::string dir, file;
SystemTools::SplitProgramPath(in_name, dir, file);
return dir;
}
-bool SystemTools::SplitProgramPath(const char* in_name,
+bool SystemTools::SplitProgramPath(const kwsys_stl::string& in_name,
kwsys_stl::string& dir,
kwsys_stl::string& file,
bool)
@@ -3409,7 +3452,62 @@ kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path
SystemTools::CheckTranslationPath(newPath);
#ifdef _WIN32
- newPath = SystemTools::GetActualCaseForPath(newPath.c_str());
+ newPath = SystemTools::GetActualCaseForPath(newPath);
+ SystemTools::ConvertToUnixSlashes(newPath);
+#endif
+ // Return the reconstructed path.
+ return newPath;
+}
+
+kwsys_stl::string SystemTools::CollapseFullPath(const kwsys_stl::string& in_path,
+ const kwsys_stl::string& in_base)
+{
+ // Collect the output path components.
+ kwsys_stl::vector<kwsys_stl::string> out_components;
+
+ // Split the input path components.
+ kwsys_stl::vector<kwsys_stl::string> path_components;
+ SystemTools::SplitPath(in_path, path_components);
+
+ // If the input path is relative, start with a base path.
+ if(path_components[0].length() == 0)
+ {
+ kwsys_stl::vector<kwsys_stl::string> base_components;
+ // Use the given base path.
+ SystemTools::SplitPath(in_base, base_components);
+
+ // Append base path components to the output path.
+ out_components.push_back(base_components[0]);
+ SystemToolsAppendComponents(out_components,
+ base_components.begin()+1,
+ base_components.end());
+ }
+
+ // Append input path components to the output path.
+ SystemToolsAppendComponents(out_components,
+ path_components.begin(),
+ path_components.end());
+
+ // Transform the path back to a string.
+ kwsys_stl::string newPath = SystemTools::JoinPath(out_components);
+
+ // Update the translation table with this potentially new path. I am not
+ // sure why this line is here, it seems really questionable, but yet I
+ // would put good money that if I remove it something will break, basically
+ // from what I can see it created a mapping from the collapsed path, to be
+ // replaced by the input path, which almost completely does the opposite of
+ // this function, the only thing preventing this from happening a lot is
+ // that if the in_path has a .. in it, then it is not added to the
+ // translation table. So for most calls this either does nothing due to the
+ // .. or it adds a translation between identical paths as nothing was
+ // collapsed, so I am going to try to comment it out, and see what hits the
+ // fan, hopefully quickly.
+ // Commented out line below:
+ //SystemTools::AddTranslationPath(newPath, in_path);
+
+ SystemTools::CheckTranslationPath(newPath);
+#ifdef _WIN32
+ newPath = SystemTools::GetActualCaseForPath(newPath);
SystemTools::ConvertToUnixSlashes(newPath);
#endif
// Return the reconstructed path.
@@ -3569,7 +3667,7 @@ static int GetCasePathName(const kwsys_stl::string & pathIn,
//----------------------------------------------------------------------------
-kwsys_stl::string SystemTools::GetActualCaseForPath(const char* p)
+kwsys_stl::string SystemTools::GetActualCaseForPath(const kwsys_stl::string& p)
{
#ifndef _WIN32
return p;
@@ -3930,7 +4028,7 @@ kwsys_stl::string SystemTools::GetFilenameName(const kwsys_stl::string& filename
kwsys_stl::string SystemTools::GetFilenameExtension(const kwsys_stl::string& filename)
{
kwsys_stl::string name = SystemTools::GetFilenameName(filename);
- kwsys_stl::string::size_type dot_pos = name.find(".");
+ kwsys_stl::string::size_type dot_pos = name.find('.');
if(dot_pos != kwsys_stl::string::npos)
{
return name.substr(dot_pos);
@@ -3948,7 +4046,7 @@ kwsys_stl::string SystemTools::GetFilenameExtension(const kwsys_stl::string& fil
kwsys_stl::string SystemTools::GetFilenameLastExtension(const kwsys_stl::string& filename)
{
kwsys_stl::string name = SystemTools::GetFilenameName(filename);
- kwsys_stl::string::size_type dot_pos = name.rfind(".");
+ kwsys_stl::string::size_type dot_pos = name.rfind('.');
if(dot_pos != kwsys_stl::string::npos)
{
return name.substr(dot_pos);
@@ -3966,7 +4064,7 @@ kwsys_stl::string SystemTools::GetFilenameLastExtension(const kwsys_stl::string&
kwsys_stl::string SystemTools::GetFilenameWithoutExtension(const kwsys_stl::string& filename)
{
kwsys_stl::string name = SystemTools::GetFilenameName(filename);
- kwsys_stl::string::size_type dot_pos = name.find(".");
+ kwsys_stl::string::size_type dot_pos = name.find('.');
if(dot_pos != kwsys_stl::string::npos)
{
return name.substr(0, dot_pos);
@@ -3987,7 +4085,7 @@ kwsys_stl::string
SystemTools::GetFilenameWithoutLastExtension(const kwsys_stl::string& filename)
{
kwsys_stl::string name = SystemTools::GetFilenameName(filename);
- kwsys_stl::string::size_type dot_pos = name.rfind(".");
+ kwsys_stl::string::size_type dot_pos = name.rfind('.');
if(dot_pos != kwsys_stl::string::npos)
{
return name.substr(0, dot_pos);
@@ -4276,7 +4374,7 @@ bool SystemTools::GetShortPath(const kwsys_stl::string& path, kwsys_stl::string&
#endif
}
-void SystemTools::SplitProgramFromArgs(const char* path,
+void SystemTools::SplitProgramFromArgs(const kwsys_stl::string& path,
kwsys_stl::string& program, kwsys_stl::string& args)
{
// see if this is a full path to a program
@@ -4352,7 +4450,7 @@ kwsys_stl::string SystemTools::GetCurrentDateTime(const char* format)
return kwsys_stl::string(buf);
}
-kwsys_stl::string SystemTools::MakeCidentifier(const char* s)
+kwsys_stl::string SystemTools::MakeCidentifier(const kwsys_stl::string& s)
{
kwsys_stl::string str(s);
if (str.find_first_of("0123456789") == 0)
@@ -4634,7 +4732,11 @@ kwsys_stl::string SystemTools::GetOperatingSystemNameAndVersion()
#ifdef KWSYS_WINDOWS_DEPRECATED_GetVersionEx
# pragma warning (push)
-# pragma warning (disable:4996)
+# ifdef __INTEL_COMPILER
+# pragma warning (disable:1478)
+# else
+# pragma warning (disable:4996)
+# endif
#endif
bOsVersionInfoEx = GetVersionEx((OSVERSIONINFO *)&osvi);
if (!bOsVersionInfoEx)
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index e88bc8f..beb2a7e 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -89,9 +89,9 @@ public:
* then an underscore is prepended. Note that this can produce
* identifiers that the standard reserves (_[A-Z].* and __.*).
*/
- static kwsys_stl::string MakeCidentifier(const char* s);
+ static kwsys_stl::string MakeCidentifier(const kwsys_stl::string& s);
- static kwsys_stl::string MakeCindentifier(const char* s)
+ static kwsys_stl::string MakeCindentifier(const kwsys_stl::string& s)
{
return MakeCidentifier(s);
}
@@ -102,6 +102,9 @@ public:
static void ReplaceString(kwsys_stl::string& source,
const char* replace,
const char* with);
+ static void ReplaceString(kwsys_stl::string& source,
+ const kwsys_stl::string& replace,
+ const kwsys_stl::string& with);
/**
* Return a capitalized string (i.e the first letter is uppercased,
@@ -306,7 +309,7 @@ public:
/**
* Return file length
*/
- static unsigned long FileLength(const char *filename);
+ static unsigned long FileLength(const kwsys_stl::string& filename);
/**
Change the modification time or create a file
@@ -335,15 +338,15 @@ public:
* does not exist path is returned unchanged. This does nothing
* on unix but return path.
*/
- static kwsys_stl::string GetActualCaseForPath(const char* path);
+ static kwsys_stl::string GetActualCaseForPath(const kwsys_stl::string& path);
/**
* Given the path to a program executable, get the directory part of
* the path with the file stripped off. If there is no directory
* part, the empty string is returned.
*/
- static kwsys_stl::string GetProgramPath(const char*);
- static bool SplitProgramPath(const char* in_name,
+ static kwsys_stl::string GetProgramPath(const kwsys_stl::string&);
+ static bool SplitProgramPath(const kwsys_stl::string& in_name,
kwsys_stl::string& dir,
kwsys_stl::string& file,
bool errorReport = true);
@@ -376,6 +379,8 @@ public:
static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative);
static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative,
const char* in_base);
+ static kwsys_stl::string CollapseFullPath(const kwsys_stl::string& in_relative,
+ const kwsys_stl::string& in_base);
/**
* Get the real path for a given path, removing all symlinks. In
@@ -446,7 +451,7 @@ public:
* Split a program from its arguments and handle spaces in the paths
*/
static void SplitProgramFromArgs(
- const char* path,
+ const kwsys_stl::string& path,
kwsys_stl::string& program, kwsys_stl::string& args);
/**
@@ -582,7 +587,7 @@ public:
* Find a file in the system PATH, with optional extra paths
*/
static kwsys_stl::string FindFile(
- const char* name,
+ const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& path =
kwsys_stl::vector<kwsys_stl::string>(),
bool no_system_path = false);
@@ -591,7 +596,7 @@ public:
* Find a directory in the system PATH, with optional extra paths
*/
static kwsys_stl::string FindDirectory(
- const char* name,
+ const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& path =
kwsys_stl::vector<kwsys_stl::string>(),
bool no_system_path = false);
@@ -662,13 +667,13 @@ public:
* Create a symbolic link if the platform supports it. Returns whether
* creation succeded.
*/
- static bool CreateSymlink(const char* origName, const char* newName);
+ static bool CreateSymlink(const kwsys_stl::string& origName, const kwsys_stl::string& newName);
/**
* Read the contents of a symbolic link. Returns whether reading
* succeded.
*/
- static bool ReadSymlink(const char* newName, kwsys_stl::string& origName);
+ static bool ReadSymlink(const kwsys_stl::string& newName, kwsys_stl::string& origName);
/**
* Try to locate the file 'filename' in the directory 'dir'.
@@ -750,26 +755,26 @@ public:
/**
* Get a list of subkeys.
*/
- static bool GetRegistrySubKeys(const char *key,
+ static bool GetRegistrySubKeys(const kwsys_stl::string& key,
kwsys_stl::vector<kwsys_stl::string>& subkeys,
KeyWOW64 view = KeyWOW64_Default);
/**
* Read a registry value
*/
- static bool ReadRegistryValue(const char *key, kwsys_stl::string &value,
+ static bool ReadRegistryValue(const kwsys_stl::string& key, kwsys_stl::string &value,
KeyWOW64 view = KeyWOW64_Default);
/**
* Write a registry value
*/
- static bool WriteRegistryValue(const char *key, const char *value,
+ static bool WriteRegistryValue(const kwsys_stl::string& key, const kwsys_stl::string& value,
KeyWOW64 view = KeyWOW64_Default);
/**
* Delete a registry value
*/
- static bool DeleteRegistryValue(const char *key,
+ static bool DeleteRegistryValue(const kwsys_stl::string& key,
KeyWOW64 view = KeyWOW64_Default);
/** -----------------------------------------------------------------
@@ -789,15 +794,17 @@ public:
* Read an environment variable
*/
static const char* GetEnv(const char* key);
+ static const char* GetEnv(const kwsys_stl::string& key);
static bool GetEnv(const char* key, kwsys_stl::string& result);
+ static bool GetEnv(const kwsys_stl::string& key, kwsys_stl::string& result);
/** Put a string into the environment
of the form var=value */
- static bool PutEnv(const char* env);
+ static bool PutEnv(const kwsys_stl::string& env);
/** Remove a string from the environment.
Input is of the form "var" or "var=value" (value is ignored). */
- static bool UnPutEnv(const char* env);
+ static bool UnPutEnv(const kwsys_stl::string& env);
/**
* Get current working directory CWD
@@ -906,6 +913,14 @@ private:
}
/**
+ * Actual implementation of ReplaceString.
+ */
+ static void ReplaceString(kwsys_stl::string& source,
+ const char* replace,
+ size_t replaceSize,
+ const kwsys_stl::string& with);
+
+ /**
* Actual implementation of FileIsFullPath.
*/
static bool FileIsFullPath(const char*, size_t);
@@ -915,7 +930,7 @@ private:
* optional extra paths.
*/
static kwsys_stl::string FindName(
- const char* name,
+ const kwsys_stl::string& name,
const kwsys_stl::vector<kwsys_stl::string>& path =
kwsys_stl::vector<kwsys_stl::string>(),
bool no_system_path = false);
diff --git a/Source/kwsys/kwsysPlatformTests.cmake b/Source/kwsys/kwsysPlatformTests.cmake
index 16bc969..0da0f63 100644
--- a/Source/kwsys/kwsysPlatformTests.cmake
+++ b/Source/kwsys/kwsysPlatformTests.cmake
@@ -25,39 +25,39 @@ MACRO(KWSYS_PLATFORM_TEST lang var description invert)
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${description} compiled with the following output:\n${OUTPUT}\n\n")
- ELSE(${var}_COMPILED)
+ ELSE()
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
- ENDIF(${var}_COMPILED)
+ ENDIF()
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
MESSAGE(STATUS "${description} - no")
- ELSE(${var}_COMPILED)
+ ELSE()
MESSAGE(STATUS "${description} - yes")
- ENDIF(${var}_COMPILED)
- ELSE(${invert} MATCHES INVERT)
+ ENDIF()
+ ELSE()
IF(${var}_COMPILED)
MESSAGE(STATUS "${description} - yes")
- ELSE(${var}_COMPILED)
+ ELSE()
MESSAGE(STATUS "${description} - no")
- ENDIF(${var}_COMPILED)
- ENDIF(${invert} MATCHES INVERT)
+ ENDIF()
+ ENDIF()
ENDIF()
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
SET(${var} 0)
- ELSE(${var}_COMPILED)
+ ELSE()
SET(${var} 1)
- ENDIF(${var}_COMPILED)
- ELSE(${invert} MATCHES INVERT)
+ ENDIF()
+ ELSE()
IF(${var}_COMPILED)
SET(${var} 1)
- ELSE(${var}_COMPILED)
+ ELSE()
SET(${var} 0)
- ENDIF(${var}_COMPILED)
- ENDIF(${invert} MATCHES INVERT)
-ENDMACRO(KWSYS_PLATFORM_TEST)
+ ENDIF()
+ ENDIF()
+ENDMACRO()
MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
IF(NOT DEFINED ${var})
@@ -74,63 +74,63 @@ MACRO(KWSYS_PLATFORM_TEST_RUN lang var description invert)
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} compiled but failed to run with the following output:\n${OUTPUT}\n\n")
- ELSE(${var})
+ ELSE()
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"${description} compiled and ran with the following output:\n${OUTPUT}\n\n")
- ENDIF(${var})
- ELSE(${var}_COMPILED)
+ ENDIF()
+ ELSE()
FILE(APPEND
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"${description} failed to compile with the following output:\n${OUTPUT}\n\n")
SET(${var} -1 CACHE INTERNAL "${description} failed to compile.")
- ENDIF(${var}_COMPILED)
+ ENDIF()
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
IF(${var})
MESSAGE(STATUS "${description} - yes")
- ELSE(${var})
+ ELSE()
MESSAGE(STATUS "${description} - no")
- ENDIF(${var})
- ELSE(${var}_COMPILED)
+ ENDIF()
+ ELSE()
MESSAGE(STATUS "${description} - failed to compile")
- ENDIF(${var}_COMPILED)
- ELSE(${invert} MATCHES INVERT)
+ ENDIF()
+ ELSE()
IF(${var}_COMPILED)
IF(${var})
MESSAGE(STATUS "${description} - no")
- ELSE(${var})
+ ELSE()
MESSAGE(STATUS "${description} - yes")
- ENDIF(${var})
- ELSE(${var}_COMPILED)
+ ENDIF()
+ ELSE()
MESSAGE(STATUS "${description} - failed to compile")
- ENDIF(${var}_COMPILED)
- ENDIF(${invert} MATCHES INVERT)
+ ENDIF()
+ ENDIF()
ENDIF()
IF(${invert} MATCHES INVERT)
IF(${var}_COMPILED)
IF(${var})
SET(${var} 1)
- ELSE(${var})
+ ELSE()
SET(${var} 0)
- ENDIF(${var})
- ELSE(${var}_COMPILED)
+ ENDIF()
+ ELSE()
SET(${var} 1)
- ENDIF(${var}_COMPILED)
- ELSE(${invert} MATCHES INVERT)
+ ENDIF()
+ ELSE()
IF(${var}_COMPILED)
IF(${var})
SET(${var} 0)
- ELSE(${var})
+ ELSE()
SET(${var} 1)
- ENDIF(${var})
- ELSE(${var}_COMPILED)
+ ENDIF()
+ ELSE()
SET(${var} 0)
- ENDIF(${var}_COMPILED)
- ENDIF(${invert} MATCHES INVERT)
-ENDMACRO(KWSYS_PLATFORM_TEST_RUN)
+ ENDIF()
+ ENDIF()
+ENDMACRO()
MACRO(KWSYS_PLATFORM_C_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
@@ -138,7 +138,7 @@ MACRO(KWSYS_PLATFORM_C_TEST var description invert)
KWSYS_PLATFORM_TEST(C "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO(KWSYS_PLATFORM_C_TEST)
+ENDMACRO()
MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_C_TEST_DEFINES})
@@ -146,7 +146,7 @@ MACRO(KWSYS_PLATFORM_C_TEST_RUN var description invert)
KWSYS_PLATFORM_TEST_RUN(C "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO(KWSYS_PLATFORM_C_TEST_RUN)
+ENDMACRO()
MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
@@ -156,7 +156,7 @@ MACRO(KWSYS_PLATFORM_CXX_TEST var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
SET(KWSYS_PLATFORM_TEST_LINK_LIBRARIES)
-ENDMACRO(KWSYS_PLATFORM_CXX_TEST)
+ENDMACRO()
MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
SET(KWSYS_PLATFORM_TEST_DEFINES ${KWSYS_PLATFORM_CXX_TEST_DEFINES})
@@ -164,7 +164,7 @@ MACRO(KWSYS_PLATFORM_CXX_TEST_RUN var description invert)
KWSYS_PLATFORM_TEST_RUN(CXX "${var}" "${description}" "${invert}")
SET(KWSYS_PLATFORM_TEST_DEFINES)
SET(KWSYS_PLATFORM_TEST_EXTRA_FLAGS)
-ENDMACRO(KWSYS_PLATFORM_CXX_TEST_RUN)
+ENDMACRO()
#-----------------------------------------------------------------------------
# KWSYS_PLATFORM_INFO_TEST(lang var description)
diff --git a/Source/kwsys/kwsysPlatformTestsCXX.cxx b/Source/kwsys/kwsysPlatformTestsCXX.cxx
index 3f947f3..82620da 100644
--- a/Source/kwsys/kwsysPlatformTestsCXX.cxx
+++ b/Source/kwsys/kwsysPlatformTestsCXX.cxx
@@ -548,6 +548,10 @@ int main()
#if (defined(__GNUC__) || defined(__PGI)) && !defined(_GNU_SOURCE)
# define _GNU_SOURCE
#endif
+#if defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x5130 \
+ && __linux && __SUNPRO_CC_COMPAT == 'G'
+# include <iostream>
+#endif
#include <cxxabi.h>
int main()
{
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index b41532b..42b6249 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -124,7 +124,7 @@ static bool CheckFileOperations()
res = false;
}
- if (kwsys::SystemTools::FileLength(testBinFile.c_str()) != 766)
+ if (kwsys::SystemTools::FileLength(testBinFile) != 766)
{
kwsys_ios::cerr
<< "Problem with FileLength - incorrect length for: "
@@ -512,7 +512,7 @@ static bool CheckStringOperations()
//----------------------------------------------------------------------------
-static bool CheckPutEnv(const char* env, const char* name, const char* value)
+static bool CheckPutEnv(const kwsys_stl::string& env, const char* name, const char* value)
{
if(!kwsys::SystemTools::PutEnv(env))
{