summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2014-04-29 13:36:55 (GMT)
committerBrad King <brad.king@kitware.com>2014-04-29 13:36:55 (GMT)
commitbbc358c3fc1f09fe2a483996ae1359dba3f587f4 (patch)
treeacbe60addb92ac90fc7c91f187a9d9226c2a95dd
parent0cce556b5fbe629dccee294aeece7c275343ed64 (diff)
parentc51d07d4397ceed55c534a036ef81df44b741ff6 (diff)
downloadCMake-bbc358c3fc1f09fe2a483996ae1359dba3f587f4.zip
CMake-bbc358c3fc1f09fe2a483996ae1359dba3f587f4.tar.gz
CMake-bbc358c3fc1f09fe2a483996ae1359dba3f587f4.tar.bz2
Merge branch 'master' into osx-init-early
Resolve conflict in Source/cmGlobalGenerator.cxx by integrating changes from both sides.
-rw-r--r--CMakeLists.txt344
-rw-r--r--CTestConfig.cmake5
-rw-r--r--CTestCustom.cmake.in10
-rw-r--r--CTestCustom.ctest.in3
-rw-r--r--CompileFlags.cmake21
-rw-r--r--Help/command/add_custom_command.rst4
-rw-r--r--Help/command/add_executable.rst7
-rw-r--r--Help/command/add_library.rst6
-rw-r--r--Help/command/string.rst5
-rw-r--r--Help/command/target_compile_features.rst30
-rw-r--r--Help/command/target_sources.rst28
-rw-r--r--Help/manual/cmake-buildsystem.7.rst12
-rw-r--r--Help/manual/cmake-commands.7.rst2
-rw-r--r--Help/manual/cmake-developer.7.rst557
-rw-r--r--Help/manual/cmake-generator-expressions.7.rst5
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/manual/cmake-policies.7.rst2
-rw-r--r--Help/manual/cmake-properties.7.rst9
-rw-r--r--Help/manual/cmake-variables.7.rst6
-rw-r--r--Help/module/FindOpenCL.rst1
-rw-r--r--Help/policy/CMP0051.rst24
-rw-r--r--Help/policy/CMP0052.rst24
-rw-r--r--Help/prop_tgt/COMPILE_FEATURES.rst11
-rw-r--r--Help/prop_tgt/COMPILE_PDB_NAME.rst11
-rw-r--r--Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst10
-rw-r--r--Help/prop_tgt/COMPILE_PDB_NOTE.txt8
-rw-r--r--Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst13
-rw-r--r--Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst16
-rw-r--r--Help/prop_tgt/CXX_EXTENSIONS.rst8
-rw-r--r--Help/prop_tgt/CXX_STANDARD.rst14
-rw-r--r--Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst14
-rw-r--r--Help/prop_tgt/INTERFACE_SOURCES.rst15
-rw-r--r--Help/prop_tgt/PDB_NAME.rst4
-rw-r--r--Help/prop_tgt/PDB_NAME_CONFIG.rst4
-rw-r--r--Help/prop_tgt/PDB_NOTE.txt10
-rw-r--r--Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst4
-rw-r--r--Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst4
-rw-r--r--Help/prop_tgt/SOURCES.rst3
-rw-r--r--Help/release/dev/0-sample-topic.rst7
-rw-r--r--Help/release/dev/CMP0052.rst5
-rw-r--r--Help/release/dev/CMakeDetermineVSServicePack.rst6
-rw-r--r--Help/release/dev/ExternalProject-BUILD_ALWAYS.rst6
-rw-r--r--Help/release/dev/ExternalProject-no-download-progress.rst6
-rw-r--r--Help/release/dev/ExternalProject_exclude-from-all.rst11
-rw-r--r--Help/release/dev/FeatureSummary_combine_WHAT_values.rst6
-rw-r--r--Help/release/dev/FindGTest-AUTO-SOURCES.rst7
-rw-r--r--Help/release/dev/FindHg-WC_INFO.rst5
-rw-r--r--Help/release/dev/FindPkgConfig-PKG_CONFIG.rst5
-rw-r--r--Help/release/dev/add-FindOpenCL.rst4
-rw-r--r--Help/release/dev/add_custom_command-DEPENDS-genex.rst5
-rw-r--r--Help/release/dev/compile-language-features.rst18
-rw-r--r--Help/release/dev/cpack-deb-compression-types.rst6
-rw-r--r--Help/release/dev/ctest-coverage-extra.rst5
-rw-r--r--Help/release/dev/ctest-intel-coverage.rst5
-rw-r--r--Help/release/dev/custom-ninja-deptypes.rst5
-rw-r--r--Help/release/dev/faster-parsers.rst6
-rw-r--r--Help/release/dev/link-libraries-response-files.rst5
-rw-r--r--Help/release/dev/msvc-compiler-pdb-files.rst10
-rw-r--r--Help/release/dev/string-GENEX_STRIP.rst6
-rw-r--r--Help/release/dev/target-INTERFACE_SOURCES.rst5
-rw-r--r--Help/release/dev/target-SOURCES-genex.rst12
-rw-r--r--Help/release/dev/target-SOURCES-write.rst6
-rw-r--r--Help/release/dev/target_sources-command.rst5
-rw-r--r--Help/release/index.rst2
-rw-r--r--Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst8
-rw-r--r--Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst11
-rw-r--r--Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst8
-rw-r--r--Help/variable/CMAKE_CXX_EXTENSIONS.rst8
-rw-r--r--Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst238
-rw-r--r--Help/variable/CMAKE_CXX_STANDARD.rst8
-rw-r--r--Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst3
-rw-r--r--Help/variable/CMAKE_HOST_SYSTEM.rst9
-rw-r--r--Help/variable/CMAKE_HOST_SYSTEM_NAME.rst5
-rw-r--r--Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst5
-rw-r--r--Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst7
-rw-r--r--Help/variable/CMAKE_SYSTEM.rst11
-rw-r--r--Help/variable/CMAKE_SYSTEM_NAME.rst7
-rw-r--r--Help/variable/CMAKE_SYSTEM_PROCESSOR.rst6
-rw-r--r--Help/variable/CMAKE_SYSTEM_VERSION.rst8
-rw-r--r--Modules/AutogenInfo.cmake.in1
-rw-r--r--Modules/BasicConfigVersion-ExactVersion.cmake.in4
-rw-r--r--Modules/BundleUtilities.cmake10
-rw-r--r--Modules/CMakeBackwardCompatibilityCXX.cmake6
-rw-r--r--Modules/CMakeCCompiler.cmake.in2
-rw-r--r--Modules/CMakeCCompilerId.c.in17
-rw-r--r--Modules/CMakeCInformation.cmake4
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in5
-rw-r--r--Modules/CMakeCXXCompilerId.cpp.in17
-rw-r--r--Modules/CMakeCXXInformation.cmake4
-rw-r--r--Modules/CMakeCommonLanguageInclude.cmake18
-rw-r--r--Modules/CMakeDetermineASMCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake4
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake4
-rw-r--r--Modules/CMakeDetermineCompileFeatures.cmake43
-rw-r--r--Modules/CMakeDetermineCompilerABI.cmake8
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake31
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake8
-rw-r--r--Modules/CMakeDetermineJavaCompiler.cmake6
-rw-r--r--Modules/CMakeDetermineRCCompiler.cmake2
-rw-r--r--Modules/CMakeDetermineSystem.cmake4
-rw-r--r--Modules/CMakeDetermineVSServicePack.cmake7
-rw-r--r--Modules/CMakeExportBuildSettings.cmake2
-rw-r--r--Modules/CMakeFortranInformation.cmake4
-rw-r--r--Modules/CMakeImportBuildSettings.cmake3
-rw-r--r--Modules/CMakeParseImplicitLinkInfo.cmake10
-rw-r--r--Modules/CMakePlatformId.h.in28
-rw-r--r--Modules/CMakePushCheckState.cmake3
-rw-r--r--Modules/CMakeTestCXXCompiler.cmake3
-rw-r--r--Modules/CPackDeb.cmake15
-rw-r--r--Modules/CPackRPM.cmake4
-rw-r--r--Modules/CPackWIX.cmake17
-rw-r--r--Modules/CheckCSourceCompiles.cmake13
-rw-r--r--Modules/CheckCSourceRuns.cmake13
-rw-r--r--Modules/CheckCXXSourceCompiles.cmake13
-rw-r--r--Modules/CheckCXXSourceRuns.cmake13
-rw-r--r--Modules/CheckCXXSymbolExists.cmake1
-rw-r--r--Modules/CheckFunctionExists.cmake13
-rw-r--r--Modules/CheckIncludeFile.cmake13
-rw-r--r--Modules/CheckIncludeFileCXX.cmake13
-rw-r--r--Modules/CheckIncludeFiles.cmake13
-rw-r--r--Modules/CheckLibraryExists.cmake13
-rw-r--r--Modules/CheckPrototypeDefinition.cmake9
-rw-r--r--Modules/CheckStructHasMember.cmake1
-rw-r--r--Modules/CheckSymbolExists.cmake13
-rw-r--r--Modules/CheckTypeSize.cmake28
-rw-r--r--Modules/CheckVariableExists.cmake13
-rw-r--r--Modules/Compiler/AppleClang-CXX.cmake7
-rw-r--r--Modules/Compiler/Clang-CXX.cmake18
-rw-r--r--Modules/Compiler/GNU-CXX-FeatureTests.cmake77
-rw-r--r--Modules/Compiler/GNU-CXX.cmake25
-rw-r--r--Modules/ExternalData.cmake54
-rw-r--r--Modules/ExternalProject.cmake172
-rw-r--r--Modules/FeatureSummary.cmake62
-rw-r--r--Modules/FindBISON.cmake15
-rw-r--r--Modules/FindBLAS.cmake14
-rw-r--r--Modules/FindBZip2.cmake4
-rw-r--r--Modules/FindBacktrace.cmake1
-rw-r--r--Modules/FindBoost.cmake17
-rw-r--r--Modules/FindCUDA.cmake4
-rw-r--r--Modules/FindCUDA/make2cmake.cmake5
-rw-r--r--Modules/FindCUDA/parse_cubin.cmake15
-rw-r--r--Modules/FindCups.cmake9
-rw-r--r--Modules/FindCurses.cmake4
-rw-r--r--Modules/FindEXPAT.cmake5
-rw-r--r--Modules/FindFLTK.cmake4
-rw-r--r--Modules/FindFLTK2.cmake4
-rw-r--r--Modules/FindFreetype.cmake9
-rw-r--r--Modules/FindGDAL.cmake4
-rw-r--r--Modules/FindGIF.cmake1
-rw-r--r--Modules/FindGTK2.cmake42
-rw-r--r--Modules/FindGTest.cmake28
-rw-r--r--Modules/FindGettext.cmake4
-rw-r--r--Modules/FindHDF5.cmake6
-rw-r--r--Modules/FindHg.cmake37
-rw-r--r--Modules/FindIcotool.cmake2
-rw-r--r--Modules/FindImageMagick.cmake4
-rw-r--r--Modules/FindJava.cmake15
-rw-r--r--Modules/FindKDE3.cmake2
-rw-r--r--Modules/FindLAPACK.cmake11
-rw-r--r--Modules/FindLibLZMA.cmake3
-rw-r--r--Modules/FindMPI.cmake17
-rw-r--r--Modules/FindOpenCL.cmake135
-rw-r--r--Modules/FindOpenMP.cmake12
-rw-r--r--Modules/FindPNG.cmake6
-rw-r--r--Modules/FindPackageMessage.cmake2
-rw-r--r--Modules/FindPerl.cmake4
-rw-r--r--Modules/FindPkgConfig.cmake428
-rw-r--r--Modules/FindPythonInterp.cmake31
-rw-r--r--Modules/FindPythonLibs.cmake16
-rw-r--r--Modules/FindQt.cmake6
-rw-r--r--Modules/FindQt3.cmake4
-rw-r--r--Modules/FindQt4.cmake20
-rw-r--r--Modules/FindSDL_image.cmake4
-rw-r--r--Modules/FindSDL_mixer.cmake4
-rw-r--r--Modules/FindSDL_net.cmake4
-rw-r--r--Modules/FindSDL_sound.cmake4
-rw-r--r--Modules/FindSDL_ttf.cmake4
-rw-r--r--Modules/FindSquish.cmake2
-rw-r--r--Modules/FindThreads.cmake46
-rw-r--r--Modules/FindX11.cmake3
-rw-r--r--Modules/FindXMLRPC.cmake19
-rw-r--r--Modules/FindZLIB.cmake2
-rw-r--r--Modules/FindwxWidgets.cmake4
-rw-r--r--Modules/FortranCInterface.cmake2
-rw-r--r--Modules/FortranCInterface/Detect.cmake5
-rw-r--r--Modules/GetPrerequisites.cmake8
-rw-r--r--Modules/InstallRequiredSystemLibraries.cmake22
-rw-r--r--Modules/Internal/FeatureTesting.cmake57
-rw-r--r--Modules/Platform/Darwin.cmake2
-rw-r--r--Modules/Platform/Haiku.cmake27
-rw-r--r--Modules/Platform/OSF1.cmake4
-rw-r--r--Modules/Platform/OpenBSD.cmake2
-rw-r--r--Modules/Platform/SunOS.cmake2
-rw-r--r--Modules/Platform/Windows-GNU.cmake13
-rw-r--r--Modules/Platform/Windows-MSVC.cmake2
-rw-r--r--Modules/Platform/Windows-wcl386.cmake88
-rw-r--r--Modules/ProcessorCount.cmake12
-rw-r--r--Modules/Qt4Macros.cmake6
-rw-r--r--Modules/UseJava.cmake8
-rw-r--r--Modules/UseQt4.cmake4
-rw-r--r--Modules/UseSWIG.cmake76
-rw-r--r--Modules/UseVTKConfig40.cmake2
-rw-r--r--Modules/WIX.template.in2
-rw-r--r--Source/CMakeLists.txt39
-rw-r--r--Source/CMakeVersion.cmake4
-rw-r--r--Source/CMakeVersionSource.cmake4
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx631
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.h106
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx87
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h42
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx102
-rw-r--r--Source/CPack/WiX/cmWIXFeaturesSourceWriter.h39
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.cxx171
-rw-r--r--Source/CPack/WiX/cmWIXFilesSourceWriter.h66
-rw-r--r--Source/CPack/WiX/cmWIXPatch.cxx91
-rw-r--r--Source/CPack/WiX/cmWIXPatch.h45
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.cxx14
-rw-r--r--Source/CPack/WiX/cmWIXPatchParser.h6
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx8
-rw-r--r--Source/CPack/WiX/cmWIXRichTextFormatWriter.h8
-rw-r--r--Source/CPack/WiX/cmWIXShortcut.h29
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.cxx14
-rw-r--r--Source/CPack/WiX/cmWIXSourceWriter.h16
-rw-r--r--Source/CPack/cmCPackComponentGroup.cxx5
-rw-r--r--Source/CPack/cmCPackComponentGroup.h4
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx68
-rw-r--r--Source/CPack/cmCPackGenerator.cxx169
-rw-r--r--Source/CPack/cmCPackGenerator.h42
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.cxx13
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.h10
-rw-r--r--Source/CPack/cmCPackLog.cxx12
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx44
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.cxx8
-rw-r--r--Source/CPack/cmCPackOSXX11Generator.h5
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx24
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.h11
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx4
-rw-r--r--Source/CPack/cpack.cxx16
-rw-r--r--Source/CTest/cmCTestBZR.cxx40
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx10
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.h2
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx12
-rw-r--r--Source/CTest/cmCTestBuildCommand.h2
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx14
-rw-r--r--Source/CTest/cmCTestBuildHandler.h14
-rw-r--r--Source/CTest/cmCTestCVS.cxx6
-rw-r--r--Source/CTest/cmCTestCVS.h4
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx2
-rw-r--r--Source/CTest/cmCTestConfigureCommand.h2
-rw-r--r--Source/CTest/cmCTestConfigureHandler.cxx4
-rw-r--r--Source/CTest/cmCTestCoverageCommand.cxx3
-rw-r--r--Source/CTest/cmCTestCoverageCommand.h4
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx435
-rw-r--r--Source/CTest/cmCTestCoverageHandler.h16
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx4
-rw-r--r--Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h2
-rw-r--r--Source/CTest/cmCTestGIT.cxx4
-rw-r--r--Source/CTest/cmCTestGenericHandler.cxx24
-rw-r--r--Source/CTest/cmCTestGenericHandler.h8
-rw-r--r--Source/CTest/cmCTestGlobalVC.cxx2
-rw-r--r--Source/CTest/cmCTestGlobalVC.h4
-rw-r--r--Source/CTest/cmCTestHG.cxx26
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx2
-rw-r--r--Source/CTest/cmCTestLaunch.cxx6
-rw-r--r--Source/CTest/cmCTestLaunch.h2
-rw-r--r--Source/CTest/cmCTestMemCheckCommand.h2
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx68
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.h10
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx4
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.h10
-rw-r--r--Source/CTest/cmCTestP4.cxx10
-rw-r--r--Source/CTest/cmCTestReadCustomFilesCommand.h2
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.cxx2
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.h2
-rw-r--r--Source/CTest/cmCTestRunTest.cxx28
-rw-r--r--Source/CTest/cmCTestSVN.cxx26
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx34
-rw-r--r--Source/CTest/cmCTestScriptHandler.h28
-rw-r--r--Source/CTest/cmCTestSleepCommand.h2
-rw-r--r--Source/CTest/cmCTestStartCommand.cxx4
-rw-r--r--Source/CTest/cmCTestStartCommand.h2
-rw-r--r--Source/CTest/cmCTestSubmitCommand.cxx6
-rw-r--r--Source/CTest/cmCTestSubmitCommand.h2
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx162
-rw-r--r--Source/CTest/cmCTestSubmitHandler.h60
-rw-r--r--Source/CTest/cmCTestTestCommand.h2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx82
-rw-r--r--Source/CTest/cmCTestTestHandler.h18
-rw-r--r--Source/CTest/cmCTestUpdateCommand.h2
-rw-r--r--Source/CTest/cmCTestUpdateHandler.cxx2
-rw-r--r--Source/CTest/cmCTestUploadCommand.cxx2
-rw-r--r--Source/CTest/cmCTestUploadCommand.h2
-rw-r--r--Source/CTest/cmCTestUploadHandler.cxx2
-rw-r--r--Source/CTest/cmCTestVC.cxx4
-rw-r--r--Source/CTest/cmParseGTMCoverage.cxx2
-rw-r--r--Source/CTest/cmParseMumpsCoverage.cxx4
-rw-r--r--Source/CTest/cmParseMumpsCoverage.h2
-rw-r--r--Source/CTest/cmParsePHPCoverage.cxx4
-rw-r--r--Source/CTest/cmParsePHPCoverage.h2
-rw-r--r--Source/CTest/cmParsePythonCoverage.cxx8
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.cxx14
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.h5
-rw-r--r--Source/CursesDialog/cmCursesLabelWidget.cxx2
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx10
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h2
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.cxx7
-rw-r--r--Source/CursesDialog/cmCursesOptionsWidget.h2
-rw-r--r--Source/CursesDialog/cmCursesPathWidget.cxx6
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.cxx2
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.h2
-rw-r--r--Source/CursesDialog/cmCursesWidget.cxx4
-rw-r--r--Source/CursesDialog/cmCursesWidget.h2
-rw-r--r--Source/QtDialog/CMakeSetup.cxx6
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx6
-rw-r--r--Source/QtDialog/QCMake.cxx14
-rw-r--r--Source/QtDialog/QCMakeWidgets.cxx6
-rw-r--r--Source/cmAddCompileOptionsCommand.h2
-rw-r--r--Source/cmAddCustomCommandCommand.cxx24
-rw-r--r--Source/cmAddCustomCommandCommand.h2
-rw-r--r--Source/cmAddCustomTargetCommand.cxx10
-rw-r--r--Source/cmAddCustomTargetCommand.h2
-rw-r--r--Source/cmAddDefinitionsCommand.h2
-rw-r--r--Source/cmAddDependenciesCommand.cxx4
-rw-r--r--Source/cmAddDependenciesCommand.h2
-rw-r--r--Source/cmAddExecutableCommand.cxx24
-rw-r--r--Source/cmAddExecutableCommand.h2
-rw-r--r--Source/cmAddLibraryCommand.cxx58
-rw-r--r--Source/cmAddLibraryCommand.h2
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx6
-rw-r--r--Source/cmAddSubDirectoryCommand.h2
-rw-r--r--Source/cmAddTestCommand.cxx14
-rw-r--r--Source/cmAddTestCommand.h2
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx6
-rw-r--r--Source/cmAuxSourceDirectoryCommand.h2
-rw-r--r--Source/cmBreakCommand.h2
-rw-r--r--Source/cmBuildCommand.cxx12
-rw-r--r--Source/cmBuildCommand.h2
-rw-r--r--Source/cmBuildNameCommand.cxx6
-rw-r--r--Source/cmBuildNameCommand.h2
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx4
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.h2
-rw-r--r--Source/cmCMakeMinimumRequired.cxx8
-rw-r--r--Source/cmCMakeMinimumRequired.h2
-rw-r--r--Source/cmCMakePolicyCommand.cxx12
-rw-r--r--Source/cmCMakePolicyCommand.h2
-rw-r--r--Source/cmCPluginAPI.cxx6
-rw-r--r--Source/cmCTest.cxx106
-rw-r--r--Source/cmCTest.h40
-rw-r--r--Source/cmCacheManager.cxx75
-rw-r--r--Source/cmCacheManager.h56
-rw-r--r--Source/cmCommand.h6
-rw-r--r--Source/cmCommandArgumentLexer.cxx2
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx26
-rw-r--r--Source/cmCommandArgumentParserHelper.h6
-rw-r--r--Source/cmComputeLinkDepends.cxx34
-rw-r--r--Source/cmComputeLinkDepends.h12
-rw-r--r--Source/cmComputeLinkInformation.cxx62
-rw-r--r--Source/cmComputeLinkInformation.h18
-rw-r--r--Source/cmComputeTargetDepends.cxx98
-rw-r--r--Source/cmComputeTargetDepends.h14
-rw-r--r--Source/cmConfigure.cmake.h.in1
-rw-r--r--Source/cmConfigureFileCommand.cxx6
-rw-r--r--Source/cmConfigureFileCommand.h2
-rw-r--r--Source/cmCoreTryCompile.cxx38
-rw-r--r--Source/cmCoreTryCompile.h2
-rw-r--r--Source/cmCreateTestSourceList.cxx4
-rw-r--r--Source/cmCreateTestSourceList.h2
-rw-r--r--Source/cmCryptoHash.cxx10
-rw-r--r--Source/cmCryptoHash.h4
-rw-r--r--Source/cmCustomCommand.cxx10
-rw-r--r--Source/cmCustomCommand.h9
-rw-r--r--Source/cmCustomCommandGenerator.cxx46
-rw-r--r--Source/cmCustomCommandGenerator.h12
-rw-r--r--Source/cmDefinePropertyCommand.cxx6
-rw-r--r--Source/cmDefinePropertyCommand.h2
-rw-r--r--Source/cmDefinitions.cxx28
-rw-r--r--Source/cmDefinitions.h32
-rw-r--r--Source/cmDepends.cxx10
-rw-r--r--Source/cmDepends.h6
-rw-r--r--Source/cmDependsC.cxx26
-rw-r--r--Source/cmDependsC.h19
-rw-r--r--Source/cmDependsFortran.cxx74
-rw-r--r--Source/cmDependsJavaLexer.cxx2
-rw-r--r--Source/cmDependsJavaParserHelper.cxx32
-rw-r--r--Source/cmDependsJavaParserHelper.h20
-rw-r--r--Source/cmDocumentation.cxx18
-rw-r--r--Source/cmDocumentation.h2
-rw-r--r--Source/cmDocumentationSection.h4
-rw-r--r--Source/cmDynamicLoader.cxx8
-rw-r--r--Source/cmDynamicLoader.h4
-rw-r--r--Source/cmELF.cxx37
-rw-r--r--Source/cmElseCommand.h2
-rw-r--r--Source/cmElseIfCommand.h2
-rw-r--r--Source/cmEnableLanguageCommand.h2
-rw-r--r--Source/cmEnableTestingCommand.h2
-rw-r--r--Source/cmEndForEachCommand.h2
-rw-r--r--Source/cmEndFunctionCommand.h2
-rw-r--r--Source/cmEndIfCommand.h2
-rw-r--r--Source/cmEndMacroCommand.h2
-rw-r--r--Source/cmEndWhileCommand.h2
-rw-r--r--Source/cmExecProgramCommand.cxx4
-rw-r--r--Source/cmExecProgramCommand.h2
-rw-r--r--Source/cmExecuteProcessCommand.cxx16
-rw-r--r--Source/cmExecuteProcessCommand.h2
-rw-r--r--Source/cmExecutionStatus.h2
-rw-r--r--Source/cmExportBuildFileGenerator.cxx19
-rw-r--r--Source/cmExportBuildFileGenerator.h4
-rw-r--r--Source/cmExportCommand.cxx37
-rw-r--r--Source/cmExportCommand.h2
-rw-r--r--Source/cmExportFileGenerator.cxx99
-rw-r--r--Source/cmExportFileGenerator.h28
-rw-r--r--Source/cmExportInstallFileGenerator.cxx19
-rw-r--r--Source/cmExportInstallFileGenerator.h10
-rw-r--r--Source/cmExportLibraryDependenciesCommand.cxx14
-rw-r--r--Source/cmExportLibraryDependenciesCommand.h2
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx9
-rw-r--r--Source/cmExportTryCompileFileGenerator.h8
-rw-r--r--Source/cmExprLexer.cxx2
-rw-r--r--Source/cmExprParserHelper.h4
-rw-r--r--Source/cmExternalMakefileProjectGenerator.cxx24
-rw-r--r--Source/cmExternalMakefileProjectGenerator.h11
-rw-r--r--Source/cmExtraCodeBlocksGenerator.cxx47
-rw-r--r--Source/cmExtraCodeBlocksGenerator.h10
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx37
-rw-r--r--Source/cmExtraCodeLiteGenerator.h6
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx19
-rw-r--r--Source/cmExtraEclipseCDT4Generator.h6
-rw-r--r--Source/cmExtraKateGenerator.cxx4
-rw-r--r--Source/cmExtraKateGenerator.h6
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx45
-rw-r--r--Source/cmExtraSublimeTextGenerator.h10
-rw-r--r--Source/cmFLTKWrapUICommand.cxx16
-rw-r--r--Source/cmFLTKWrapUICommand.h2
-rw-r--r--Source/cmFileCommand.cxx147
-rw-r--r--Source/cmFileCommand.h2
-rw-r--r--Source/cmFileTimeComparison.cxx4
-rw-r--r--Source/cmFindBase.cxx14
-rw-r--r--Source/cmFindBase.h10
-rw-r--r--Source/cmFindCommon.cxx10
-rw-r--r--Source/cmFindCommon.h6
-rw-r--r--Source/cmFindFileCommand.h2
-rw-r--r--Source/cmFindLibraryCommand.cxx10
-rw-r--r--Source/cmFindLibraryCommand.h2
-rw-r--r--Source/cmFindPackageCommand.cxx117
-rw-r--r--Source/cmFindPackageCommand.h16
-rw-r--r--Source/cmFindPathCommand.cxx16
-rw-r--r--Source/cmFindPathCommand.h2
-rw-r--r--Source/cmFindProgramCommand.cxx6
-rw-r--r--Source/cmFindProgramCommand.h2
-rw-r--r--Source/cmForEachCommand.cxx16
-rw-r--r--Source/cmForEachCommand.h2
-rw-r--r--Source/cmFunctionCommand.cxx18
-rw-r--r--Source/cmFunctionCommand.h2
-rw-r--r--Source/cmGeneratedFileStream.cxx7
-rw-r--r--Source/cmGeneratedFileStream.h2
-rw-r--r--Source/cmGeneratorExpression.cxx41
-rw-r--r--Source/cmGeneratorExpression.h20
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx24
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.h8
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.cxx25
-rw-r--r--Source/cmGeneratorExpressionEvaluationFile.h2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.cxx298
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h5
-rw-r--r--Source/cmGeneratorExpressionLexer.cxx76
-rw-r--r--Source/cmGeneratorExpressionLexer.h2
-rw-r--r--Source/cmGeneratorTarget.cxx740
-rw-r--r--Source/cmGeneratorTarget.h109
-rw-r--r--Source/cmGetCMakePropertyCommand.cxx8
-rw-r--r--Source/cmGetCMakePropertyCommand.h2
-rw-r--r--Source/cmGetDirectoryPropertyCommand.cxx12
-rw-r--r--Source/cmGetDirectoryPropertyCommand.h2
-rw-r--r--Source/cmGetFilenameComponentCommand.cxx12
-rw-r--r--Source/cmGetFilenameComponentCommand.h2
-rw-r--r--Source/cmGetPropertyCommand.cxx52
-rw-r--r--Source/cmGetPropertyCommand.h2
-rw-r--r--Source/cmGetSourceFilePropertyCommand.cxx4
-rw-r--r--Source/cmGetSourceFilePropertyCommand.h2
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx18
-rw-r--r--Source/cmGetTargetPropertyCommand.h2
-rw-r--r--Source/cmGetTestPropertyCommand.cxx8
-rw-r--r--Source/cmGetTestPropertyCommand.h2
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h4
-rw-r--r--Source/cmGlobalGenerator.cxx354
-rw-r--r--Source/cmGlobalGenerator.h133
-rw-r--r--Source/cmGlobalGeneratorFactory.h8
-rw-r--r--Source/cmGlobalJOMMakefileGenerator.h4
-rw-r--r--Source/cmGlobalKdevelopGenerator.cxx37
-rw-r--r--Source/cmGlobalKdevelopGenerator.h6
-rw-r--r--Source/cmGlobalMSYSMakefileGenerator.h4
-rw-r--r--Source/cmGlobalMinGWMakefileGenerator.h4
-rw-r--r--Source/cmGlobalNMakeMakefileGenerator.h4
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx55
-rw-r--r--Source/cmGlobalNinjaGenerator.h18
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx273
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h22
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx51
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h21
-rw-r--r--Source/cmGlobalVisualStudio11Generator.cxx24
-rw-r--r--Source/cmGlobalVisualStudio11Generator.h7
-rw-r--r--Source/cmGlobalVisualStudio12Generator.cxx24
-rw-r--r--Source/cmGlobalVisualStudio12Generator.h7
-rw-r--r--Source/cmGlobalVisualStudio6Generator.cxx39
-rw-r--r--Source/cmGlobalVisualStudio6Generator.h27
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx21
-rw-r--r--Source/cmGlobalVisualStudio71Generator.h18
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx90
-rw-r--r--Source/cmGlobalVisualStudio7Generator.h47
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx46
-rw-r--r--Source/cmGlobalVisualStudio8Generator.h14
-rw-r--r--Source/cmGlobalVisualStudio9Generator.cxx14
-rw-r--r--Source/cmGlobalVisualStudio9Generator.h5
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx72
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h15
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.cxx8
-rw-r--r--Source/cmGlobalWatcomWMakeGenerator.h4
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx380
-rw-r--r--Source/cmGlobalXCodeGenerator.h62
-rw-r--r--Source/cmGraphVizWriter.cxx50
-rw-r--r--Source/cmGraphVizWriter.h20
-rw-r--r--Source/cmIDEFlagTable.h1
-rw-r--r--Source/cmIDEOptions.cxx82
-rw-r--r--Source/cmIDEOptions.h6
-rw-r--r--Source/cmIfCommand.cxx30
-rw-r--r--Source/cmIfCommand.h6
-rw-r--r--Source/cmIncludeCommand.cxx8
-rw-r--r--Source/cmIncludeCommand.h2
-rw-r--r--Source/cmIncludeDirectoryCommand.cxx2
-rw-r--r--Source/cmIncludeDirectoryCommand.h2
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.h2
-rw-r--r--Source/cmIncludeRegularExpressionCommand.cxx2
-rw-r--r--Source/cmIncludeRegularExpressionCommand.h2
-rw-r--r--Source/cmInstallCommand.cxx78
-rw-r--r--Source/cmInstallCommand.h2
-rw-r--r--Source/cmInstallExportGenerator.cxx12
-rw-r--r--Source/cmInstallFilesCommand.cxx4
-rw-r--r--Source/cmInstallFilesCommand.h2
-rw-r--r--Source/cmInstallFilesGenerator.cxx4
-rw-r--r--Source/cmInstallFilesGenerator.h2
-rw-r--r--Source/cmInstallGenerator.cxx4
-rw-r--r--Source/cmInstallGenerator.h2
-rw-r--r--Source/cmInstallProgramsCommand.cxx2
-rw-r--r--Source/cmInstallProgramsCommand.h2
-rw-r--r--Source/cmInstallTargetGenerator.cxx33
-rw-r--r--Source/cmInstallTargetGenerator.h25
-rw-r--r--Source/cmInstallTargetsCommand.cxx2
-rw-r--r--Source/cmInstallTargetsCommand.h2
-rw-r--r--Source/cmLinkDirectoriesCommand.cxx2
-rw-r--r--Source/cmLinkDirectoriesCommand.h2
-rw-r--r--Source/cmLinkLibrariesCommand.cxx6
-rw-r--r--Source/cmLinkLibrariesCommand.h2
-rw-r--r--Source/cmListCommand.cxx66
-rw-r--r--Source/cmListCommand.h6
-rw-r--r--Source/cmListFileCache.cxx4
-rw-r--r--Source/cmLoadCacheCommand.cxx12
-rw-r--r--Source/cmLoadCacheCommand.h4
-rw-r--r--Source/cmLoadCommandCommand.cxx12
-rw-r--r--Source/cmLoadCommandCommand.h2
-rw-r--r--Source/cmLocalGenerator.cxx573
-rw-r--r--Source/cmLocalGenerator.h132
-rw-r--r--Source/cmLocalNinjaGenerator.cxx65
-rw-r--r--Source/cmLocalNinjaGenerator.h21
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx380
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h70
-rw-r--r--Source/cmLocalVisualStudio10Generator.cxx8
-rw-r--r--Source/cmLocalVisualStudio10Generator.h2
-rw-r--r--Source/cmLocalVisualStudio6Generator.cxx177
-rw-r--r--Source/cmLocalVisualStudio6Generator.h21
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx175
-rw-r--r--Source/cmLocalVisualStudio7Generator.h35
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx58
-rw-r--r--Source/cmLocalVisualStudioGenerator.h13
-rw-r--r--Source/cmLocalXCodeGenerator.cxx34
-rw-r--r--Source/cmLocalXCodeGenerator.h6
-rw-r--r--Source/cmMacroCommand.cxx12
-rw-r--r--Source/cmMacroCommand.h2
-rw-r--r--Source/cmMakeDepend.cxx10
-rw-r--r--Source/cmMakeDepend.h8
-rw-r--r--Source/cmMakeDirectoryCommand.cxx2
-rw-r--r--Source/cmMakeDirectoryCommand.h2
-rw-r--r--Source/cmMakefile.cxx662
-rw-r--r--Source/cmMakefile.h163
-rw-r--r--Source/cmMakefileExecutableTargetGenerator.cxx91
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx144
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.h5
-rw-r--r--Source/cmMakefileTargetGenerator.cxx390
-rw-r--r--Source/cmMakefileTargetGenerator.h59
-rw-r--r--Source/cmMakefileUtilityTargetGenerator.cxx2
-rw-r--r--Source/cmMarkAsAdvancedCommand.cxx4
-rw-r--r--Source/cmMarkAsAdvancedCommand.h2
-rw-r--r--Source/cmMathCommand.cxx6
-rw-r--r--Source/cmMathCommand.h2
-rw-r--r--Source/cmMessageCommand.cxx2
-rw-r--r--Source/cmMessageCommand.h2
-rw-r--r--Source/cmNewLineStyle.cxx2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx404
-rw-r--r--Source/cmNinjaNormalTargetGenerator.h2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx132
-rw-r--r--Source/cmNinjaTargetGenerator.h23
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx15
-rw-r--r--Source/cmOSXBundleGenerator.cxx47
-rw-r--r--Source/cmOSXBundleGenerator.h15
-rw-r--r--Source/cmOptionCommand.cxx9
-rw-r--r--Source/cmOptionCommand.h2
-rw-r--r--Source/cmOrderDirectories.cxx22
-rw-r--r--Source/cmOrderDirectories.h10
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx2
-rw-r--r--Source/cmOutputRequiredFilesCommand.h2
-rw-r--r--Source/cmPolicies.cxx17
-rw-r--r--Source/cmPolicies.h3
-rw-r--r--Source/cmProjectCommand.cxx26
-rw-r--r--Source/cmProjectCommand.h2
-rw-r--r--Source/cmProperty.cxx5
-rw-r--r--Source/cmProperty.h7
-rw-r--r--Source/cmPropertyDefinition.cxx2
-rw-r--r--Source/cmPropertyDefinition.h12
-rw-r--r--Source/cmPropertyDefinitionMap.cxx21
-rw-r--r--Source/cmPropertyDefinitionMap.h8
-rw-r--r--Source/cmPropertyMap.cxx16
-rw-r--r--Source/cmPropertyMap.h14
-rw-r--r--Source/cmQTWrapCPPCommand.cxx12
-rw-r--r--Source/cmQTWrapCPPCommand.h2
-rw-r--r--Source/cmQTWrapUICommand.cxx18
-rw-r--r--Source/cmQTWrapUICommand.h2
-rw-r--r--Source/cmQtAutoGenerators.cxx191
-rw-r--r--Source/cmQtAutoGenerators.h13
-rw-r--r--Source/cmRST.cxx4
-rw-r--r--Source/cmRST.h4
-rw-r--r--Source/cmRemoveCommand.h2
-rw-r--r--Source/cmRemoveDefinitionsCommand.h2
-rw-r--r--Source/cmReturnCommand.h2
-rw-r--r--Source/cmScriptGenerator.cxx25
-rw-r--r--Source/cmScriptGenerator.h12
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx8
-rw-r--r--Source/cmSeparateArgumentsCommand.h2
-rw-r--r--Source/cmSetCommand.cxx2
-rw-r--r--Source/cmSetCommand.h2
-rw-r--r--Source/cmSetDirectoryPropertiesCommand.cxx4
-rw-r--r--Source/cmSetDirectoryPropertiesCommand.h2
-rw-r--r--Source/cmSetPropertyCommand.cxx36
-rw-r--r--Source/cmSetPropertyCommand.h4
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.cxx6
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.h2
-rw-r--r--Source/cmSetTargetPropertiesCommand.cxx10
-rw-r--r--Source/cmSetTargetPropertiesCommand.h4
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx8
-rw-r--r--Source/cmSetTestsPropertiesCommand.h4
-rw-r--r--Source/cmSiteNameCommand.cxx4
-rw-r--r--Source/cmSiteNameCommand.h2
-rw-r--r--Source/cmSourceFile.cxx63
-rw-r--r--Source/cmSourceFile.h25
-rw-r--r--Source/cmSourceFileLocation.cxx73
-rw-r--r--Source/cmSourceFileLocation.h11
-rw-r--r--Source/cmSourceGroup.cxx4
-rw-r--r--Source/cmSourceGroup.h4
-rw-r--r--Source/cmSourceGroupCommand.cxx8
-rw-r--r--Source/cmSourceGroupCommand.h2
-rw-r--r--Source/cmStandardIncludes.h22
-rw-r--r--Source/cmStringCommand.cxx101
-rw-r--r--Source/cmStringCommand.h5
-rw-r--r--Source/cmSubdirCommand.cxx8
-rw-r--r--Source/cmSubdirCommand.h2
-rw-r--r--Source/cmSubdirDependsCommand.h2
-rw-r--r--Source/cmSystemTools.cxx134
-rw-r--r--Source/cmSystemTools.h28
-rw-r--r--Source/cmTarget.cxx2102
-rw-r--r--Source/cmTarget.h313
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx3
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.h4
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx70
-rw-r--r--Source/cmTargetCompileFeaturesCommand.h41
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx3
-rw-r--r--Source/cmTargetCompileOptionsCommand.h4
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx3
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.h4
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx23
-rw-r--r--Source/cmTargetLinkLibrariesCommand.h4
-rw-r--r--Source/cmTargetPropCommandBase.cxx27
-rw-r--r--Source/cmTargetPropCommandBase.h7
-rw-r--r--Source/cmTargetSourcesCommand.cxx65
-rw-r--r--Source/cmTargetSourcesCommand.h55
-rw-r--r--Source/cmTest.cxx24
-rw-r--r--Source/cmTest.h19
-rw-r--r--Source/cmTestGenerator.cxx4
-rw-r--r--Source/cmTestGenerator.h2
-rw-r--r--Source/cmTryCompileCommand.h2
-rw-r--r--Source/cmTryRunCommand.cxx26
-rw-r--r--Source/cmTryRunCommand.h2
-rw-r--r--Source/cmUnsetCommand.h2
-rw-r--r--Source/cmUseMangledMesaCommand.cxx6
-rw-r--r--Source/cmUseMangledMesaCommand.h2
-rw-r--r--Source/cmUtilitySourceCommand.cxx6
-rw-r--r--Source/cmUtilitySourceCommand.h2
-rw-r--r--Source/cmVS11CLFlagTable.h9
-rw-r--r--Source/cmVS12CLFlagTable.h9
-rw-r--r--Source/cmVariableRequiresCommand.cxx8
-rw-r--r--Source/cmVariableRequiresCommand.h2
-rw-r--r--Source/cmVariableWatch.h2
-rw-r--r--Source/cmVariableWatchCommand.cxx6
-rw-r--r--Source/cmVariableWatchCommand.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx175
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h22
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx8
-rw-r--r--Source/cmVisualStudioGeneratorOptions.h2
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.cxx20
-rw-r--r--Source/cmVisualStudioWCEPlatformParser.h4
-rw-r--r--Source/cmWhileCommand.h2
-rw-r--r--Source/cmWriteFileCommand.cxx4
-rw-r--r--Source/cmWriteFileCommand.h2
-rw-r--r--Source/cmXCodeObject.cxx8
-rw-r--r--Source/cmXCodeObject.h56
-rw-r--r--Source/cmXMLParser.cxx4
-rw-r--r--Source/cmXMLParser.h4
-rw-r--r--Source/cmake.cxx256
-rw-r--r--Source/cmake.h66
-rw-r--r--Source/cmcldeps.cxx2
-rw-r--r--Source/cmcmd.cxx62
-rw-r--r--Source/cmcmd.h4
-rw-r--r--Source/kwsys/CMakeLists.txt16
-rw-r--r--Source/kwsys/EncodingCXX.cxx19
-rw-r--r--Source/kwsys/FStream.cxx76
-rw-r--r--Source/kwsys/FStream.hxx.in21
-rw-r--r--Source/kwsys/MD5.c9
-rw-r--r--Source/kwsys/SharedForward.h.in8
-rw-r--r--Source/kwsys/System.c30
-rw-r--r--Source/kwsys/System.h.in9
-rw-r--r--Source/kwsys/SystemInformation.cxx34
-rw-r--r--Source/kwsys/SystemTools.cxx7
-rw-r--r--Source/kwsys/testFStream.cxx142
-rw-r--r--Tests/BuildDepends/CMakeLists.txt30
-rw-r--r--Tests/BuildDepends/Project/CMakeLists.txt12
-rw-r--r--Tests/BuildDepends/Project/External/CMakeLists.txt14
-rw-r--r--Tests/CMakeBuildTest.cmake.in4
-rw-r--r--Tests/CMakeCommands/target_compile_features/CMakeLists.txt25
-rw-r--r--Tests/CMakeCommands/target_compile_features/dummy.cpp5
-rw-r--r--Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp6
-rw-r--r--Tests/CMakeCommands/target_compile_features/lib_auto_type.h8
-rw-r--r--Tests/CMakeCommands/target_compile_features/lib_user.cpp7
-rw-r--r--Tests/CMakeCommands/target_compile_features/main.cpp6
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx8
-rw-r--r--Tests/CMakeLists.txt223
-rw-r--r--Tests/CMakeOnly/AllFindModules/CMakeLists.txt3
-rw-r--r--Tests/CMakeOnly/Test.cmake.in4
-rw-r--r--Tests/CMakeTests/CheckCMakeTest.cmake4
-rw-r--r--Tests/CMakeTests/ExecuteScriptTests.cmake4
-rw-r--r--Tests/CPackWiXGenerator/CMakeLists.txt14
-rw-r--r--Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake5
-rw-r--r--Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in2
-rw-r--r--Tests/CTestConfig/dashboard.cmake.in4
-rw-r--r--Tests/CTestConfig/script.cmake.in4
-rw-r--r--Tests/CTestTestBadExe/test.cmake.in4
-rw-r--r--Tests/CTestTestChecksum/test.cmake.in4
-rw-r--r--Tests/CTestTestConfigFileInBuildDir/test1.cmake.in4
-rw-r--r--Tests/CTestTestConfigFileInBuildDir/test2.cmake.in4
-rw-r--r--Tests/CTestTestCostSerial/test.cmake.in4
-rw-r--r--Tests/CTestTestCrash/test.cmake.in4
-rw-r--r--Tests/CTestTestCycle/test.cmake.in4
-rw-r--r--Tests/CTestTestDepends/test.cmake.in4
-rw-r--r--Tests/CTestTestFailure/testNoBuild.cmake.in4
-rw-r--r--Tests/CTestTestFailure/testNoExe.cmake.in4
-rw-r--r--Tests/CTestTestFdSetSize/test.cmake.in4
-rw-r--r--Tests/CTestTestMemcheck/CMakeLists.txt23
-rw-r--r--Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt19
-rw-r--r--Tests/CTestTestMemcheck/test.cmake.in4
-rw-r--r--Tests/CTestTestParallel/test.cmake.in4
-rw-r--r--Tests/CTestTestResourceLock/test.cmake.in4
-rw-r--r--Tests/CTestTestScheduler/test.cmake.in4
-rw-r--r--Tests/CTestTestSkipReturnCode/test.cmake.in4
-rw-r--r--Tests/CTestTestStopTime/test.cmake.in4
-rw-r--r--Tests/CTestTestSubdir/test.cmake.in4
-rw-r--r--Tests/CTestTestTimeout/test.cmake.in4
-rw-r--r--Tests/CTestTestUpload/test.cmake.in4
-rw-r--r--Tests/CTestTestZeroTimeout/test.cmake.in4
-rw-r--r--Tests/CTestUpdateCommon.cmake4
-rw-r--r--Tests/CompileFeatures/CMakeLists.txt44
-rw-r--r--Tests/CompileFeatures/cxx_alias_templates.cpp11
-rw-r--r--Tests/CompileFeatures/cxx_alignas.cpp4
-rw-r--r--Tests/CompileFeatures/cxx_alignof.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_attributes.cpp2
-rw-r--r--Tests/CompileFeatures/cxx_auto_type.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_constexpr.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_decltype.cpp7
-rw-r--r--Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp14
-rw-r--r--Tests/CompileFeatures/cxx_default_function_template_args.cpp12
-rw-r--r--Tests/CompileFeatures/cxx_defaulted_functions.cpp9
-rw-r--r--Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp7
-rw-r--r--Tests/CompileFeatures/cxx_delegating_constructors.cpp15
-rw-r--r--Tests/CompileFeatures/cxx_deleted_functions.cpp6
-rw-r--r--Tests/CompileFeatures/cxx_enum_forward_declarations.cpp8
-rw-r--r--Tests/CompileFeatures/cxx_explicit_conversions.cpp10
-rw-r--r--Tests/CompileFeatures/cxx_extended_friend_declarations.cpp25
-rw-r--r--Tests/CompileFeatures/cxx_extern_templates.cpp12
-rw-r--r--Tests/CompileFeatures/cxx_final.cpp2
-rw-r--r--Tests/CompileFeatures/cxx_func_identifier.cpp6
-rw-r--r--Tests/CompileFeatures/cxx_generalized_initializers.cpp23
-rw-r--r--Tests/CompileFeatures/cxx_inheriting_constructors.cpp18
-rw-r--r--Tests/CompileFeatures/cxx_inline_namespaces.cpp26
-rw-r--r--Tests/CompileFeatures/cxx_lambdas.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_local_type_template_args.cpp21
-rw-r--r--Tests/CompileFeatures/cxx_long_long_type.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_noexcept.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_nonstatic_member_init.cpp4
-rw-r--r--Tests/CompileFeatures/cxx_nullptr.cpp10
-rw-r--r--Tests/CompileFeatures/cxx_override.cpp7
-rw-r--r--Tests/CompileFeatures/cxx_range_for.cpp10
-rw-r--r--Tests/CompileFeatures/cxx_raw_string_literals.cpp7
-rw-r--r--Tests/CompileFeatures/cxx_reference_qualified_functions.cpp11
-rw-r--r--Tests/CompileFeatures/cxx_right_angle_brackets.cpp12
-rw-r--r--Tests/CompileFeatures/cxx_rvalue_references.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_sizeof_member.cpp10
-rw-r--r--Tests/CompileFeatures/cxx_static_assert.cpp2
-rw-r--r--Tests/CompileFeatures/cxx_strong_enums.cpp7
-rw-r--r--Tests/CompileFeatures/cxx_thread_local.cpp2
-rw-r--r--Tests/CompileFeatures/cxx_trailing_return_types.cpp5
-rw-r--r--Tests/CompileFeatures/cxx_unicode_literals.cpp3
-rw-r--r--Tests/CompileFeatures/cxx_uniform_initialization.cpp9
-rw-r--r--Tests/CompileFeatures/cxx_unrestricted_unions.cpp11
-rw-r--r--Tests/CompileFeatures/cxx_user_literals.cpp7
-rw-r--r--Tests/CompileFeatures/cxx_variadic_macros.cpp12
-rw-r--r--Tests/CompileFeatures/cxx_variadic_templates.cpp65
-rw-r--r--Tests/CompileFeatures/main.cpp6
-rw-r--r--Tests/Complex/CMakeLists.txt4
-rw-r--r--Tests/ComplexOneConfig/CMakeLists.txt4
-rw-r--r--Tests/ConfigSources/CMakeLists.txt17
-rw-r--r--Tests/ConfigSources/iface_debug.h4
-rw-r--r--Tests/ConfigSources/iface_debug_src.cpp7
-rw-r--r--Tests/ConfigSources/iface_src.cpp5
-rw-r--r--Tests/ConfigSources/main.cpp7
-rw-r--r--Tests/CustomCommand/CMakeLists.txt11
-rw-r--r--Tests/CxxDialect/CMakeLists.txt14
-rw-r--r--Tests/CxxDialect/use_constexpr.cxx10
-rw-r--r--Tests/CxxDialect/use_constexpr_and_typeof.cxx11
-rw-r--r--Tests/CxxDialect/use_typeof.cxx6
-rw-r--r--Tests/ExportImport/CMakeLists.txt4
-rw-r--r--Tests/ExportImport/Export/Interface/CMakeLists.txt5
-rw-r--r--Tests/ExportImport/Import/CMakeLists.txt1
-rw-r--r--Tests/ExportImport/Import/Interface/CMakeLists.txt17
-rw-r--r--Tests/ExportImport/InitialCache.cmake.in2
-rw-r--r--Tests/ExternalProject/CMakeLists.txt1
-rw-r--r--Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake2
-rw-r--r--Tests/FindPackageModeMakefileTest/CMakeLists.txt2
-rw-r--r--Tests/FindPackageTest/FindLotsOfComponents.cmake2
-rw-r--r--Tests/FindPackageTest/FindSomePackage.cmake2
-rw-r--r--Tests/FindPackageTest/FindUpperCasePackage.cmake2
-rw-r--r--Tests/Fortran/CMakeLists.txt6
-rw-r--r--Tests/FortranC/Flags.cmake.in4
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt2
-rw-r--r--Tests/MacRuntimePath/CMakeLists.txt4
-rw-r--r--Tests/MacRuntimePath/InitialCache.cmake.in2
-rw-r--r--Tests/Module/ExternalData/CMakeLists.txt2
-rw-r--r--Tests/Module/ExternalData/Data1Check.cmake22
-rw-r--r--Tests/Module/FindDependency/CMakeLists.txt11
-rw-r--r--Tests/Module/FindDependency/main.cpp29
-rw-r--r--Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake9
-rw-r--r--Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake11
-rw-r--r--Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake5
-rw-r--r--Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake11
-rw-r--r--Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake5
-rw-r--r--Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake11
-rw-r--r--Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake9
-rw-r--r--Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake11
-rw-r--r--Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake3
-rw-r--r--Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake11
-rw-r--r--Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake3
-rw-r--r--Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake11
-rw-r--r--Tests/PDBDirectoryAndName/CMakeLists.txt30
-rw-r--r--Tests/PerConfig/perconfig.cmake2
-rw-r--r--Tests/Properties/CMakeLists.txt2
-rw-r--r--Tests/Properties/SubDir2/CMakeLists.txt5
-rw-r--r--Tests/Properties/subdirtest.cxx9
-rw-r--r--Tests/Qt4Targets/CMakeLists.txt27
-rw-r--r--Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt13
-rw-r--r--Tests/Qt4Targets/IncrementalMoc/foo.cpp8
-rw-r--r--Tests/Qt4Targets/IncrementalMoc/foo.h9
-rw-r--r--Tests/QtAutogen/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/debug_class.cpp9
-rw-r--r--Tests/QtAutogen/debug_class.h20
-rw-r--r--Tests/QtAutogen/debug_class.ui45
-rw-r--r--Tests/QtAutogen/debug_resource.qrc5
-rw-r--r--Tests/QtAutogen/main.cpp9
-rw-r--r--Tests/QtAutogen/resourcetester.cpp6
-rw-r--r--Tests/QtAutogen/second_resource.qrc5
-rw-r--r--Tests/QtAutogen/second_widget.cpp14
-rw-r--r--Tests/QtAutogen/second_widget.h19
-rw-r--r--Tests/QtAutogen/second_widget.ui32
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt (renamed from Tests/RunCMake/set/PARENT_SCOPE-result.txt)0
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt1
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-NEW.cmake10
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt1
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt1
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-OLD.cmake10
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt1
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt15
-rw-r--r--Tests/RunCMake/CMP0051/CMP0051-WARN.cmake8
-rw-r--r--Tests/RunCMake/CMP0051/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0051/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CMP0051/empty.cpp7
-rw-r--r--Tests/RunCMake/CMakeLists.txt22
-rw-r--r--Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake4
-rw-r--r--Tests/RunCMake/CheckModules/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt14
-rw-r--r--Tests/RunCMake/CompileFeatures/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt (renamed from Tests/RunCMake/ExternalData/MissingData-result.txt)0
-rw-r--r--Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt8
-rw-r--r--Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake3
-rw-r--r--Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt (renamed from Tests/RunCMake/ExternalData/Directory3-result.txt)0
-rw-r--r--Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt6
-rw-r--r--Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake3
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt2
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature.cmake3
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt2
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake3
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt2
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake6
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt11
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake4
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt11
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake4
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt11
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake6
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt1
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt5
-rw-r--r--Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake4
-rw-r--r--Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake20
-rw-r--r--Tests/RunCMake/CompileFeatures/empty.cpp7
-rw-r--r--Tests/RunCMake/CompileFeatures/generate_feature_list.cmake4
-rw-r--r--Tests/RunCMake/ExternalData/Directory1-stderr.txt2
-rw-r--r--Tests/RunCMake/ExternalData/Directory3-stderr.txt3
-rw-r--r--Tests/RunCMake/ExternalData/MissingData-stderr.txt5
-rw-r--r--Tests/RunCMake/ExternalData/MissingData-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/MissingData.cmake13
-rw-r--r--Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt15
-rw-r--r--Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt1
-rw-r--r--Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake10
-rw-r--r--Tests/RunCMake/ExternalData/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/FeatureSummary/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt7
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake9
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt7
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake9
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt1
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt6
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake9
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt1
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt6
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake9
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt1
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake9
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt1
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt6
-rw-r--r--Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake9
-rw-r--r--Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/FindPkgConfig/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake41
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake51
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake51
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake51
-rw-r--r--Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake6
-rwxr-xr-xTests/RunCMake/FindPkgConfig/dummy-pkg-config.bat18
-rwxr-xr-xTests/RunCMake/FindPkgConfig/dummy-pkg-config.sh20
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder0
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt4
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt4
-rw-r--r--Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt4
-rw-r--r--Tests/RunCMake/RunCMake.cmake10
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariable-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariable.cmake9
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake8
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt5
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake9
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake8
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake8
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt5
-rw-r--r--Tests/RunCMake/Syntax/AtWithVariableFile.cmake8
-rw-r--r--Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/EscapeQuotes.cmake9
-rw-r--r--Tests/RunCMake/Syntax/EscapedAt-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/EscapedAt.cmake5
-rw-r--r--Tests/RunCMake/Syntax/ExpandInAt-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/ExpandInAt.cmake6
-rw-r--r--Tests/RunCMake/Syntax/ParenInENV-result.txt1
-rw-r--r--Tests/RunCMake/Syntax/ParenInENV-stderr.txt20
-rw-r--r--Tests/RunCMake/Syntax/ParenInENV.cmake2
-rw-r--r--Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt1
-rw-r--r--Tests/RunCMake/Syntax/ParenInQuotedENV.cmake2
-rw-r--r--Tests/RunCMake/Syntax/RunCMakeTest.cmake13
-rw-r--r--Tests/RunCMake/Syntax/atfile.txt.in4
-rw-r--r--Tests/RunCMake/TargetObjects/BadContext-result.txt1
-rw-r--r--Tests/RunCMake/TargetObjects/BadContext-stderr.txt17
-rw-r--r--Tests/RunCMake/TargetObjects/BadContext.cmake4
-rw-r--r--Tests/RunCMake/TargetObjects/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/TargetObjects/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt1
-rw-r--r--Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt1
-rw-r--r--Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake13
-rw-r--r--Tests/RunCMake/TargetSources/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt14
-rw-r--r--Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake2
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebug-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebug-stderr.txt31
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebug.cmake20
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt1
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt40
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE.cmake4
-rw-r--r--Tests/RunCMake/TargetSources/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/TargetSources/empty_1.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/empty_2.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/empty_3.cpp7
-rw-r--r--Tests/RunCMake/TargetSources/empty_4.cpp7
-rw-r--r--Tests/RunCMake/configure_file/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/configure_file/NO-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/NO-BOM.txt.in1
-rw-r--r--Tests/RunCMake/configure_file/RunCMakeTest.cmake8
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF16BE-BOM.txt.inbin0 -> 26 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF16LE-BOM.txt.inbin0 -> 26 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF32BE-BOM.txt.inbin0 -> 52 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt1
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt6
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF32LE-BOM.txt.inbin0 -> 52 bytes
-rw-r--r--Tests/RunCMake/configure_file/UTF8-BOM.cmake2
-rw-r--r--Tests/RunCMake/configure_file/UTF8-BOM.txt.in1
-rw-r--r--Tests/RunCMake/find_dependency/CMakeLists.txt4
-rw-r--r--Tests/RunCMake/find_dependency/EXACT-no-version-result.txt1
-rw-r--r--Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt6
-rw-r--r--Tests/RunCMake/find_dependency/EXACT-no-version.cmake4
-rw-r--r--Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake2
-rw-r--r--Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake11
-rw-r--r--Tests/RunCMake/find_dependency/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/find_dependency/empty-arg-3-result.txt1
-rw-r--r--Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt5
-rw-r--r--Tests/RunCMake/find_dependency/empty-arg-3.cmake4
-rw-r--r--Tests/RunCMake/find_dependency/empty-version-result.txt1
-rw-r--r--Tests/RunCMake/find_dependency/empty-version-stderr.txt5
-rw-r--r--Tests/RunCMake/find_dependency/empty-version.cmake4
-rw-r--r--Tests/RunCMake/find_dependency/extra-args-result.txt1
-rw-r--r--Tests/RunCMake/find_dependency/extra-args-stderr.txt5
-rw-r--r--Tests/RunCMake/find_dependency/extra-args.cmake4
-rw-r--r--Tests/RunCMake/find_dependency/invalid-arg-3-result.txt1
-rw-r--r--Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt5
-rw-r--r--Tests/RunCMake/find_dependency/invalid-arg-3.cmake4
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt6
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt20
-rw-r--r--Tests/RunCMake/include_directories/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/DirInInstallPrefix.cmake9
-rw-r--r--Tests/RunCMake/include_directories/InstallInBinDir-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt6
-rw-r--r--Tests/RunCMake/include_directories/InstallInSrcDir-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt6
-rw-r--r--Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake11
-rw-r--r--Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/RunCMakeTest.cmake128
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt6
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt1
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt1
-rw-r--r--Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt20
-rw-r--r--Tests/RunCMake/set/ParentScope-result.txt1
-rw-r--r--Tests/RunCMake/set/ParentScope.cmake (renamed from Tests/RunCMake/set/PARENT_SCOPE.cmake)0
-rw-r--r--Tests/RunCMake/set/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/target_compile_features/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/target_compile_features/RunCMakeTest.cmake11
-rw-r--r--Tests/RunCMake/target_compile_features/alias_target-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/alias_target-stderr.txt4
-rw-r--r--Tests/RunCMake/target_compile_features/alias_target.cmake4
-rw-r--r--Tests/RunCMake/target_compile_features/empty.cpp7
-rw-r--r--Tests/RunCMake/target_compile_features/imported_target-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/imported_target-stderr.txt4
-rw-r--r--Tests/RunCMake/target_compile_features/imported_target.cmake3
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args-stderr.txt4
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args.cmake3
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt5
-rw-r--r--Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake3
-rw-r--r--Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt8
-rw-r--r--Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake26
-rw-r--r--Tests/RunCMake/target_compile_features/no_target-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/no_target-stderr.txt5
-rw-r--r--Tests/RunCMake/target_compile_features/no_target.cmake2
-rw-r--r--Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt5
-rw-r--r--Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake6
-rw-r--r--Tests/RunCMake/target_compile_features/not_enough_args-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt4
-rw-r--r--Tests/RunCMake/target_compile_features/not_enough_args.cmake3
-rw-r--r--Tests/RunCMake/target_compile_features/utility_target-result.txt1
-rw-r--r--Tests/RunCMake/target_compile_features/utility_target-stderr.txt4
-rw-r--r--Tests/RunCMake/target_compile_features/utility_target.cmake4
-rw-r--r--Tests/SourcesProperty/CMakeLists.txt12
-rw-r--r--Tests/SourcesProperty/iface.cpp5
-rw-r--r--Tests/SourcesProperty/iface.h4
-rw-r--r--Tests/SourcesProperty/main.cpp7
-rw-r--r--Tests/SourcesProperty/prop.cpp5
-rw-r--r--Tests/StringFileTest/CMakeLists.txt6
-rw-r--r--Tests/SubDirSpaces/CMakeLists.txt2
-rw-r--r--Tests/SystemInformation/CMakeLists.txt2
-rw-r--r--Tests/SystemInformation/SystemInformation.in6
-rw-r--r--Utilities/Release/create-cmake-release.cmake2
-rw-r--r--Utilities/Release/dashmacmini2_release.cmake6
-rw-r--r--Utilities/Release/dashmacmini5_release.cmake6
-rw-r--r--Utilities/Release/ibm_aix_release.cmake (renamed from Utilities/Release/v20n250_aix_release.cmake)13
-rw-r--r--Utilities/Release/magrathea_release.cmake6
-rw-r--r--Utilities/Release/release_cmake.cmake20
-rwxr-xr-xUtilities/Release/release_cmake.sh.in7
-rw-r--r--Utilities/Release/upload_release.cmake15
-rw-r--r--Utilities/Sphinx/CMakeLists.txt33
-rw-r--r--Utilities/Sphinx/apply_qthelp_css_workaround.cmake15
-rw-r--r--Utilities/Sphinx/cmake.py18
-rw-r--r--Utilities/Sphinx/conf.py.in4
-rw-r--r--Utilities/Sphinx/fixup_qthelp_names.cmake32
-rw-r--r--Utilities/cmcurl/CMakeLists.txt7
-rw-r--r--Utilities/cmlibarchive/.gitattributes3
-rw-r--r--Utilities/cmlibarchive/CMakeLists.txt64
-rw-r--r--Utilities/cmlibarchive/README-CMake.txt8
-rw-r--r--Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake31
-rw-r--r--Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake68
-rw-r--r--Utilities/cmlibarchive/build/cmake/config.h.in8
-rw-r--r--Utilities/cmlibarchive/libarchive/CMakeLists.txt4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive.h74
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry.c41
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry.h15
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry_private.h5
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_entry_sparse.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_getdate.c9
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_match.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_pack_dev.c329
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_pack_dev.h49
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_platform.h7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read.c66
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c22
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c8
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_extract.c134
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_extract2.c137
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_private.h33
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_set_options.322
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_set_options.c32
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c9
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c162
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c416
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c79
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c4
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c104
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c16
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c2750
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_util.c109
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_virtual.c16
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_windows.c10
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_windows.h13
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write.c16
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c7
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c16
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_format.35
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format.c3
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c1
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c37
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c125
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c1
-rw-r--r--Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c1082
-rw-r--r--Utilities/cmlibarchive/libarchive/filter_fork_windows.c2
-rw-r--r--Utilities/cmlibarchive/libarchive/mtree.578
-rwxr-xr-xbootstrap26
-rw-r--r--cmake_uninstall.cmake.in2
1213 files changed, 21250 insertions, 10845 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 761ad20..5e4cd15 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,7 +21,9 @@ if(CMAKE_BOOTSTRAP)
unset(CMAKE_BOOTSTRAP CACHE)
endif()
-set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ set(CMake_BIN_DIR ${CMake_BINARY_DIR}/bin)
+endif()
if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
# Disallow architecture-specific try_run. It may not run on the host.
@@ -34,6 +36,13 @@ if("${CMake_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
endmacro()
endif()
+# option to set the internal encoding of CMake to UTF-8
+option(CMAKE_ENCODING_UTF8 "Use UTF-8 encoding internally (experimental)." OFF)
+mark_as_advanced(CMAKE_ENCODING_UTF8)
+if(CMAKE_ENCODING_UTF8)
+ set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
+endif()
+
#-----------------------------------------------------------------------
# a macro to deal with system libraries, implemented as a macro
# simply to improve readability of the main script
@@ -102,9 +111,11 @@ endmacro()
-set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
-if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
- set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ set(CMAKE_BUILD_ON_VISUAL_STUDIO 0)
+ if(WIN32 AND NOT UNIX AND NOT BORLAND AND NOT MINGW )
+ set(CMAKE_BUILD_ON_VISUAL_STUDIO 1)
+ endif()
endif()
@@ -114,29 +125,6 @@ endif()
#-----------------------------------------------------------------------
macro(CMAKE_SETUP_TESTING)
if(BUILD_TESTING)
- set(CMAKE_TEST_GENERATOR "" CACHE STRING
- "Generator used when running tests")
- set(CMAKE_TEST_MAKEPROGRAM "" CACHE FILEPATH
- "Generator used when running tests")
- if(NOT CMAKE_TEST_GENERATOR)
- set(CMAKE_TEST_GENERATOR "${CMAKE_GENERATOR}")
- set(CMAKE_TEST_GENERATOR_TOOLSET "${CMAKE_GENERATOR_TOOLSET}")
- else()
- set(CMAKE_TEST_DIFFERENT_GENERATOR TRUE)
- set(CMAKE_TEST_GENERATOR_TOOLSET "")
- endif()
-
- # Are we testing with the MSVC compiler?
- set(CMAKE_TEST_MSVC 0)
- if(MSVC AND NOT CMAKE_TEST_DIFFERENT_GENERATOR)
- set(CMAKE_TEST_MSVC 1)
- else()
- if("${CMAKE_TEST_GENERATOR}" MATCHES "NMake" OR
- "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio")
- set(CMAKE_TEST_MSVC 1)
- endif()
- endif()
-
set(CMAKE_TEST_SYSTEM_LIBRARIES 0)
foreach(util CURL EXPAT XMLRPC ZLIB)
if(CMAKE_USE_SYSTEM_${util})
@@ -149,9 +137,19 @@ macro(CMAKE_SETUP_TESTING)
# the ctest from this cmake is used for testing
# and not the ctest from the cmake building and testing
# cmake.
- set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
- set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
- set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
+ if(CMake_TEST_EXTERNAL_CMAKE)
+ set(CMAKE_CTEST_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/ctest")
+ set(CMAKE_CMAKE_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cmake")
+ set(CMAKE_CPACK_COMMAND "${CMake_TEST_EXTERNAL_CMAKE}/cpack")
+ foreach(exe cmake ctest cpack)
+ add_executable(${exe} IMPORTED)
+ set_property(TARGET ${exe} PROPERTY IMPORTED_LOCATION ${CMake_TEST_EXTERNAL_CMAKE}/${exe})
+ endforeach()
+ else()
+ set(CMAKE_CTEST_COMMAND "${CMake_BIN_DIR}/ctest")
+ set(CMAKE_CMAKE_COMMAND "${CMake_BIN_DIR}/cmake")
+ set(CMAKE_CPACK_COMMAND "${CMake_BIN_DIR}/cpack")
+ endif()
endif()
# configure some files for testing
@@ -164,8 +162,6 @@ macro(CMAKE_SETUP_TESTING)
${CMake_BINARY_DIR}/Modules/.NoDartCoverage)
configure_file(${CMake_SOURCE_DIR}/CTestCustom.cmake.in
${CMake_BINARY_DIR}/CTestCustom.cmake @ONLY)
- configure_file(${CMake_SOURCE_DIR}/CTestCustom.ctest.in
- ${CMake_BINARY_DIR}/CTestCustom.ctest @ONLY)
if(BUILD_TESTING AND DART_ROOT)
configure_file(${CMake_SOURCE_DIR}/CMakeLogo.gif
${CMake_BINARY_DIR}/Testing/HTML/TestingResults/Icons/Logo.gif COPYONLY)
@@ -325,6 +321,12 @@ macro (CMAKE_BUILD_UTILITIES)
add_definitions(-DLIBARCHIVE_STATIC)
set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
+ set(ENABLE_LZMA OFF CACHE INTERNAL "Enable the use of the system found LZMA library if found")
+ set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system found ZLIB library if found")
+ set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system found BZip2 library if found")
+ set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system found EXPAT library if found")
+ set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system found PCREPOSIX library if found")
+ set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system found LibGCC library if found")
set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
@@ -387,18 +389,20 @@ macro (CMAKE_BUILD_UTILITIES)
endmacro ()
#-----------------------------------------------------------------------
-if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
- execute_process(COMMAND ${CMAKE_CXX_COMPILER}
- ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
- OUTPUT_VARIABLE _GXX_VERSION
- )
- string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
- _GXX_VERSION_SHORT ${_GXX_VERSION})
- if(_GXX_VERSION_SHORT EQUAL 33)
- message(FATAL_ERROR
- "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
- "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
- "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ if(CMAKE_CXX_PLATFORM_ID MATCHES "OpenBSD")
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER}
+ ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
+ OUTPUT_VARIABLE _GXX_VERSION
+ )
+ string(REGEX REPLACE "([0-9])\\.([0-9])(\\.[0-9])?" "\\1\\2"
+ _GXX_VERSION_SHORT ${_GXX_VERSION})
+ if(_GXX_VERSION_SHORT EQUAL 33)
+ message(FATAL_ERROR
+ "GXX 3.3 on OpenBSD is known to cause CPack to Crash.\n"
+ "Please use GXX 4.2 or greater to build CMake on OpenBSD\n"
+ "${CMAKE_CXX_COMPILER} version is: ${_GXX_VERSION}")
+ endif()
endif()
endif()
@@ -417,30 +421,32 @@ include (${CMAKE_ROOT}/Modules/Dart.cmake)
set_directory_properties(PROPERTIES
TEST_INCLUDE_FILE "${CMake_BINARY_DIR}/Tests/EnforceConfig.cmake")
-# where to write the resulting executables and libraries
-set(BUILD_SHARED_LIBS OFF)
-set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
-set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
- "Where to put the libraries for CMake")
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ # where to write the resulting executables and libraries
+ set(BUILD_SHARED_LIBS OFF)
+ set(EXECUTABLE_OUTPUT_PATH "" CACHE INTERNAL "No configurable exe dir.")
+ set(LIBRARY_OUTPUT_PATH "" CACHE INTERNAL
+ "Where to put the libraries for CMake")
-# The CMake executables usually do not need any rpath to run in the build or
-# install tree.
-set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
+ # The CMake executables usually do not need any rpath to run in the build or
+ # install tree.
+ set(CMAKE_SKIP_RPATH ON CACHE INTERNAL "CMake does not need RPATHs.")
-# Load install destinations.
-include(Source/CMakeInstallDestinations.cmake)
+ # Load install destinations.
+ include(Source/CMakeInstallDestinations.cmake)
-if(BUILD_TESTING)
- include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
-endif()
+ if(BUILD_TESTING)
+ include(${CMake_SOURCE_DIR}/Tests/CMakeInstall.cmake)
+ endif()
-# include special compile flags for some compilers
-include(CompileFlags.cmake)
+ # include special compile flags for some compilers
+ include(CompileFlags.cmake)
-# no clue why we are testing for this here
-include(CheckSymbolExists)
-CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
-CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
+ # no clue why we are testing for this here
+ include(CheckSymbolExists)
+ CHECK_SYMBOL_EXISTS(unsetenv "stdlib.h" HAVE_UNSETENV)
+ CHECK_SYMBOL_EXISTS(environ "stdlib.h" HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE)
+endif()
# CMAKE_TESTS_CDASH_SERVER: CDash server used by CMake/Tests.
#
@@ -459,69 +465,72 @@ if("x${CMAKE_TESTS_CDASH_SERVER}" STREQUAL "x")
set(CMAKE_TESTS_CDASH_SERVER "http://www.cdash.org/CDash")
endif()
-# build the utilities (a macro defined in this file)
-CMAKE_BUILD_UTILITIES()
-
-# On NetBSD ncurses is required, since curses doesn't have the wsyncup()
-# function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
-# which isn't in the default linker search path. So without RPATH ccmake
-# doesn't run and the build doesn't succeed since ccmake is executed for
-# generating the documentation.
-if(BUILD_CursesDialog)
- get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
- set(CURSES_NEED_RPATH FALSE)
- if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
- set(CURSES_NEED_RPATH TRUE)
- endif()
-endif()
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ # build the utilities (a macro defined in this file)
+ CMAKE_BUILD_UTILITIES()
-if(BUILD_QtDialog)
- if(APPLE)
- set(CMAKE_BUNDLE_VERSION
- "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
- set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
- # make sure CMAKE_INSTALL_PREFIX ends in /
- string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
- math(EXPR LEN "${LEN} -1" )
- string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
- if(NOT "${ENDCH}" STREQUAL "/")
- set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
+ # On NetBSD ncurses is required, since curses doesn't have the wsyncup()
+ # function. ncurses is installed via pkgsrc, so the library is in /usr/pkg/lib,
+ # which isn't in the default linker search path. So without RPATH ccmake
+ # doesn't run and the build doesn't succeed since ccmake is executed for
+ # generating the documentation.
+ if(BUILD_CursesDialog)
+ get_filename_component(_CURSES_DIR "${CURSES_LIBRARY}" PATH)
+ set(CURSES_NEED_RPATH FALSE)
+ if(NOT "${_CURSES_DIR}" STREQUAL "/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib" AND NOT "${_CURSES_DIR}" STREQUAL "/lib64" AND NOT "${_CURSES_DIR}" STREQUAL "/usr/lib64")
+ set(CURSES_NEED_RPATH TRUE)
endif()
- set(CMAKE_INSTALL_PREFIX
- "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
endif()
- set(QT_NEED_RPATH FALSE)
- if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
- set(QT_NEED_RPATH TRUE)
+ if(BUILD_QtDialog)
+ if(APPLE)
+ set(CMAKE_BUNDLE_VERSION
+ "${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}.${CMake_VERSION_PATCH}")
+ set(CMAKE_BUNDLE_LOCATION "${CMAKE_INSTALL_PREFIX}")
+ # make sure CMAKE_INSTALL_PREFIX ends in /
+ string(LENGTH "${CMAKE_INSTALL_PREFIX}" LEN)
+ math(EXPR LEN "${LEN} -1" )
+ string(SUBSTRING "${CMAKE_INSTALL_PREFIX}" ${LEN} 1 ENDCH)
+ if(NOT "${ENDCH}" STREQUAL "/")
+ set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/")
+ endif()
+ set(CMAKE_INSTALL_PREFIX
+ "${CMAKE_INSTALL_PREFIX}CMake.app/Contents")
+ endif()
+
+ set(QT_NEED_RPATH FALSE)
+ if(NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/lib64" AND NOT "${QT_LIBRARY_DIR}" STREQUAL "/usr/lib64")
+ set(QT_NEED_RPATH TRUE)
+ endif()
endif()
-endif()
-# The same might be true on other systems for other libraries.
-# Then only enable RPATH if we have are building at least with cmake 2.4,
-# since this one has much better RPATH features than cmake 2.2.
-# The executables are then built with the RPATH for the libraries outside
-# the build tree, which is both the build and the install RPATH.
-if (UNIX)
- if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
- OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
- set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
- set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
- set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
- endif()
-endif ()
+ # The same might be true on other systems for other libraries.
+ # Then only enable RPATH if we have are building at least with cmake 2.4,
+ # since this one has much better RPATH features than cmake 2.2.
+ # The executables are then built with the RPATH for the libraries outside
+ # the build tree, which is both the build and the install RPATH.
+ if (UNIX)
+ if( CMAKE_USE_SYSTEM_CURL OR CMAKE_USE_SYSTEM_ZLIB
+ OR CMAKE_USE_SYSTEM_EXPAT OR CTEST_USE_XMLRPC OR CURSES_NEED_RPATH OR QT_NEED_RPATH)
+ set(CMAKE_SKIP_RPATH OFF CACHE INTERNAL "CMake built with RPATH.")
+ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
+ set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
+ endif()
+ endif ()
-# add the uninstall support
-configure_file(
- "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
- @ONLY)
-add_custom_target(uninstall
- "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
+ # add the uninstall support
+ configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
+ @ONLY)
+ add_custom_target(uninstall
+ "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
-include (CMakeCPack.cmake)
+ include (CMakeCPack.cmake)
+
+endif()
# setup some Testing support (a macro defined in this file)
CMAKE_SETUP_TESTING()
@@ -530,62 +539,69 @@ configure_file(
"${CMAKE_CURRENT_BINARY_DIR}/DartLocal.conf"
COPYONLY)
-if(NOT CMake_VERSION_IS_RELEASE)
- if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
- NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
- set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
- -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
- -Wmissing-format-attribute -fno-common -Wundef
- )
- set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
- -Wshadow -Wpointer-arith -Wformat-security -Wundef
- )
-
- foreach(FLAG_LANG C CXX)
- foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST})
- if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
- set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}")
- endif()
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ if(NOT CMake_VERSION_IS_RELEASE)
+ if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND
+ NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS 4.2)
+ set(C_FLAGS_LIST -Wcast-align -Werror-implicit-function-declaration -Wchar-subscripts
+ -Wall -W -Wpointer-arith -Wwrite-strings -Wformat-security
+ -Wmissing-format-attribute -fno-common -Wundef
+ )
+ set(CXX_FLAGS_LIST -Wnon-virtual-dtor -Wcast-align -Wchar-subscripts -Wall -W
+ -Wshadow -Wpointer-arith -Wformat-security -Wundef
+ )
+
+ foreach(FLAG_LANG C CXX)
+ foreach(FLAG ${${FLAG_LANG}_FLAGS_LIST})
+ if(NOT " ${CMAKE_${FLAG_LANG}_FLAGS} " MATCHES " ${FLAG} ")
+ set(CMAKE_${FLAG_LANG}_FLAGS "${CMAKE_${FLAG_LANG}_FLAGS} ${FLAG}")
+ endif()
+ endforeach()
endforeach()
- endforeach()
- unset(C_FLAGS_LIST)
- unset(CXX_FLAGS_LIST)
+ unset(C_FLAGS_LIST)
+ unset(CXX_FLAGS_LIST)
+ endif()
endif()
+
+ # build the remaining subdirectories
+ add_subdirectory(Source)
+ add_subdirectory(Utilities)
endif()
-# build the remaining subdirectories
-add_subdirectory(Source)
-add_subdirectory(Utilities)
add_subdirectory(Tests)
-if(BUILD_TESTING)
- CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
-endif()
-CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
-if(TARGET documentation)
- CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ if(BUILD_TESTING)
+ CMAKE_SET_TARGET_FOLDER(CMakeLibTests "Tests")
+ endif()
+ CMAKE_SET_TARGET_FOLDER(cmw9xcom "Utilities/Win9xCompat")
+ if(TARGET documentation)
+ CMAKE_SET_TARGET_FOLDER(documentation "Documentation")
+ endif()
endif()
# add a test
add_test(SystemInformationNew "${CMAKE_CMAKE_COMMAND}"
- --system-information -G "${CMAKE_TEST_GENERATOR}" )
-
-# Install license file as it requires.
-install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
-
-# Install script directories.
-install(
- DIRECTORY Help Modules Templates
- DESTINATION ${CMAKE_DATA_DIR}
- FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
- DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
- GROUP_READ GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE
- PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
- GROUP_READ GROUP_EXECUTE
- WORLD_READ WORLD_EXECUTE
- )
-
-# Install auxiliary files integrating with other tools.
-add_subdirectory(Auxiliary)
+ --system-information -G "${CMAKE_GENERATOR}" )
+
+if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ # Install license file as it requires.
+ install(FILES Copyright.txt DESTINATION ${CMAKE_DOC_DIR})
+
+ # Install script directories.
+ install(
+ DIRECTORY Help Modules Templates
+ DESTINATION ${CMAKE_DATA_DIR}
+ FILE_PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+ DIRECTORY_PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+ PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE
+ )
+
+ # Install auxiliary files integrating with other tools.
+ add_subdirectory(Auxiliary)
+endif()
diff --git a/CTestConfig.cmake b/CTestConfig.cmake
index 92eacd8..819f9ba 100644
--- a/CTestConfig.cmake
+++ b/CTestConfig.cmake
@@ -18,8 +18,3 @@ set(CTEST_DROP_LOCATION "/CDash/submit.php?project=CMake")
set(CTEST_DROP_SITE_CDASH TRUE)
set(CTEST_CDASH_VERSION "1.6")
set(CTEST_CDASH_QUERY_VERSION TRUE)
-
-# use old trigger stuff so that cmake 2.4 and below will not
-# get errors on trigger
-set (TRIGGER_SITE
- "http://public.kitware.com/cgi-bin/Submit-CMake-TestingResults.cgi")
diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in
index eb0b2f6..f499be1 100644
--- a/CTestCustom.cmake.in
+++ b/CTestCustom.cmake.in
@@ -19,6 +19,7 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"Utilities.cmbzip2."
"Source.CTest.Curl"
"Source.CursesDialog.form"
+ "Source.cm_sha2.*warning.*cast increases required alignment of target type"
"Utilities.cmcurl"
"Utilities.cmexpat."
"Utilities.cmlibarchive"
@@ -39,12 +40,14 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"Warning: public.*BZ2_bz.*in module.*bzlib.*clashes with prior module.*bzlib.*"
"Warning: public.*_archive.*clashes with prior module.*"
"Warning: LINN32: Last line.*is less.*"
+ "Warning: Olimit was exceeded on function.*"
+ "Warning: To override Olimit for all functions in file.*"
"warning.*directory name.*CMake-Xcode.*/bin/.*does not exist.*"
"stl_deque.h:1051"
"(Lexer|Parser).*warning.*conversion.*may (alter its value|change the sign)"
- "(Lexer|Parser).*warning.*statement is unreachable"
+ "(Lexer|Parser).*warning.*(statement is unreachable|will never be executed)"
"PGC-W-0095-Type cast required for this conversion.*ProcessUNIX.c"
- "[Qq]t([Cc]ore|[Gg]ui).*warning.*conversion.*may alter its value"
+ "[Qq]t([Cc]ore|[Gg]ui|[Ww]idgets).*warning.*conversion.*may alter its value"
"warning:.*is.*very unsafe.*consider using.*"
"warning:.*is.*misused, please use.*"
"CMakeSetupManifest.xml.*manifest authoring warning.*Unrecognized Element"
@@ -52,6 +55,9 @@ set(CTEST_CUSTOM_WARNING_EXCEPTION
"ld: warning: directory not found for option .-(F|L)"
"warning.*This version of Mac OS X is unsupported"
"clang.*: warning: argument unused during compilation: .-g"
+ "note: in expansion of macro" # diagnostic context note
+ "cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*rand.*isn.*t random" # we do not do crypto
+ "cm(StringCommand|CTestTestHandler)\\.cxx.*warning.*srand.*seed choices are.*poor" # we do not do crypto
# Ignore clang's summary warning, assuming prior text has matched some
# other warning expression:
diff --git a/CTestCustom.ctest.in b/CTestCustom.ctest.in
deleted file mode 100644
index 6127843..0000000
--- a/CTestCustom.ctest.in
+++ /dev/null
@@ -1,3 +0,0 @@
-# This file is provided for compatibility with CMake 2.2 and lower.
-# Just include the custom file by its new name.
-INCLUDE("CTestCustom.cmake")
diff --git a/CompileFlags.cmake b/CompileFlags.cmake
index 24ac58d..a4a4a78 100644
--- a/CompileFlags.cmake
+++ b/CompileFlags.cmake
@@ -19,7 +19,6 @@ endif()
if(CMAKE_GENERATOR MATCHES "Visual Studio 6")
set(CMAKE_SKIP_COMPATIBILITY_TESTS 1)
endif()
-include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)
if(WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")
set(_INTEL_WINDOWS 1)
@@ -35,25 +34,37 @@ else()
endif()
#silence duplicate symbol warnings on AIX
-if(CMAKE_SYSTEM MATCHES "AIX.*")
+if(CMAKE_SYSTEM_NAME MATCHES "AIX")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -bhalt:5 ")
endif()
endif()
-if(CMAKE_SYSTEM MATCHES "IRIX.*")
+if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,-woff84 -no_auto_include")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-woff15")
endif()
endif()
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
endif()
endif()
+if(CMAKE_SYSTEM_NAME MATCHES "HP-UX" AND CMAKE_CXX_COMPILER_ID MATCHES "HP")
+ # HP aCC since version 3.80 supports the flag +hpxstd98 to get ANSI C++98
+ # template support. It is known that version 6.25 doesn't need that flag.
+ # Versions prior to 3.80 will not be able to build CMake. Current assumption:
+ # it is needed for every version from 3.80 to 4 to get it working.
+ if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4 AND
+ NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.80)
+ # use new C++ library and improved template support
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
+ endif()
+endif()
+
# use the ansi CXX compile flag for building cmake
if (CMAKE_ANSI_CXXFLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_ANSI_CXXFLAGS}")
@@ -68,3 +79,5 @@ endif ()
if (CMAKE_SYSTEM_NAME STREQUAL Linux AND CMAKE_SYSTEM_PROCESSOR STREQUAL parisc)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unique=.text._*")
endif ()
+
+include (${CMAKE_ROOT}/Modules/CMakeBackwardCompatibilityCXX.cmake)
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index b0c5446..028ca5a 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -156,3 +156,7 @@ target is built before any target using this custom command.
Additionally, if the target is an executable or library a file-level
dependency is created to cause the custom command to re-run whenever
the target is recompiled.
+
+Arguments to ``DEPENDS`` may use "generator expressions" with the syntax
+``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for
+available expressions.
diff --git a/Help/command/add_executable.rst b/Help/command/add_executable.rst
index 231eeed..4ed10e1 100644
--- a/Help/command/add_executable.rst
+++ b/Help/command/add_executable.rst
@@ -35,8 +35,11 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on
the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
target property for details.
-See the :manual:`cmake-buildsystem(7)` manual for more on defining
-buildsystem properties.
+Source arguments to ``add_executable`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
+
--------------------------------------------------------------------------
diff --git a/Help/command/add_library.rst b/Help/command/add_library.rst
index 0944269..e93ef53 100644
--- a/Help/command/add_library.rst
+++ b/Help/command/add_library.rst
@@ -39,8 +39,10 @@ If ``EXCLUDE_FROM_ALL`` is given the corresponding property will be set on
the created target. See documentation of the :prop_tgt:`EXCLUDE_FROM_ALL`
target property for details.
-See the :manual:`cmake-buildsystem(7)` manual for more on defining buildsystem
-properties.
+Source arguments to ``add_library`` may use "generator expressions" with
+the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
--------------------------------------------------------------------------
diff --git a/Help/command/string.rst b/Help/command/string.rst
index af18825..abde6ee 100644
--- a/Help/command/string.rst
+++ b/Help/command/string.rst
@@ -35,6 +35,7 @@ String operations.
string(FIND <string> <substring> <output variable> [REVERSE])
string(TIMESTAMP <output variable> [<format string>] [UTC])
string(MAKE_C_IDENTIFIER <input string> <output variable>)
+ string(GENEX_STRIP <input string> <output variable>)
REGEX MATCH will match the regular expression once and store the match
in the output variable.
@@ -154,3 +155,7 @@ If no explicit <format string> is given it will default to:
MAKE_C_IDENTIFIER will write a string which can be used as an
identifier in C.
+
+``GENEX_STRIP`` will strip any
+:manual:`generator expressions <cmake-generator-expressions(7)>` from the
+``input string`` and store the result in the ``output variable``.
diff --git a/Help/command/target_compile_features.rst b/Help/command/target_compile_features.rst
new file mode 100644
index 0000000..f8e5c54
--- /dev/null
+++ b/Help/command/target_compile_features.rst
@@ -0,0 +1,30 @@
+target_compile_features
+-----------------------
+
+Add expected compiler features to a target.
+
+::
+
+ target_compile_features(<target> <PRIVATE|PUBLIC|INTERFACE> <feature> [...])
+
+Specify compiler features required when compiling a given target. If the
+feature is not listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable,
+then an error will be reported by CMake. If the use of the feature requires
+an additional compiler flag, such as ``-std=c++11``, the flag will be added
+automatically.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the features. ``PRIVATE`` and ``PUBLIC`` items will
+populate the :prop_tgt:`COMPILE_FEATURES` property of ``<target>``.
+``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_COMPILE_FEATURES` property of ``<target>``. Repeated
+calls for the same ``<target>`` append items.
+
+The named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be
+an ``IMPORTED`` target.
+
+Arguments to ``target_compile_features`` may use "generator expressions"
+with the syntax ``$<...>``.
+See the :manual:`cmake-generator-expressions(7)` manual for available
+expressions.
diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst
new file mode 100644
index 0000000..ff756b4
--- /dev/null
+++ b/Help/command/target_sources.rst
@@ -0,0 +1,28 @@
+target_sources
+--------------
+
+Add sources to a target.
+
+::
+
+ target_sources(<target>
+ <INTERFACE|PUBLIC|PRIVATE> [items1...]
+ [<INTERFACE|PUBLIC|PRIVATE> [items2...] ...])
+
+Specify sources to use when compiling a given target. The
+named ``<target>`` must have been created by a command such as
+:command:`add_executable` or :command:`add_library` and must not be an
+:prop_tgt:`IMPORTED Target`.
+
+The ``INTERFACE``, ``PUBLIC`` and ``PRIVATE`` keywords are required to
+specify the scope of the following arguments. ``PRIVATE`` and ``PUBLIC``
+items will populate the :prop_tgt:`SOURCES` property of
+``<target>``. ``PUBLIC`` and ``INTERFACE`` items will populate the
+:prop_tgt:`INTERFACE_SOURCES` property of ``<target>``. The
+following arguments specify sources. Repeated calls for the same
+``<target>`` append items in the order called.
+
+Arguments to ``target_sources`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/manual/cmake-buildsystem.7.rst b/Help/manual/cmake-buildsystem.7.rst
index 501b924..3e1f011 100644
--- a/Help/manual/cmake-buildsystem.7.rst
+++ b/Help/manual/cmake-buildsystem.7.rst
@@ -580,7 +580,17 @@ and the install-tree. The ``BUILD_INTERFACE`` and ``INSTALL_INTERFACE``
generator expressions can be used to describe separate usage requirements
based on the usage location. Relative paths are allowed within these
expressions, and are interpreted relative to the current source directory
-or the installation prefix, as appropriate.
+or the installation prefix, as appropriate:
+
+.. code-block:: cmake
+
+ add_library(ClimbingStats climbingstats.cpp)
+ target_include_directories(ClimbingStats INTERFACE
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/generated>
+ $<INSTALL_INTERFACE:/absolute/path>
+ $<INSTALL_INTERFACE:relative/path>
+ $<INSTALL_INTERFACE:$<INSTALL_PREFIX>/$<CONFIG>/generated>
+ )
Two convenience APIs are provided relating to include directories usage
requirements. The :variable:`CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE` variable
diff --git a/Help/manual/cmake-commands.7.rst b/Help/manual/cmake-commands.7.rst
index fb0d2b5..17c3236 100644
--- a/Help/manual/cmake-commands.7.rst
+++ b/Help/manual/cmake-commands.7.rst
@@ -91,9 +91,11 @@ These commands may be used freely in CMake projects.
/command/source_group
/command/string
/command/target_compile_definitions
+ /command/target_compile_features
/command/target_compile_options
/command/target_include_directories
/command/target_link_libraries
+ /command/target_sources
/command/try_compile
/command/try_run
/command/unset
diff --git a/Help/manual/cmake-developer.7.rst b/Help/manual/cmake-developer.7.rst
index 376b56c..7f31970 100644
--- a/Help/manual/cmake-developer.7.rst
+++ b/Help/manual/cmake-developer.7.rst
@@ -55,7 +55,7 @@ used in a comparison with the iterator returned by ``end()``:
.. code-block:: c++
- const std::set<cmStdString>& someSet = getSet();
+ const std::set<std::string>& someSet = getSet();
if (someSet.find("needle") == someSet.end()) // Wrong
{
// ...
@@ -66,8 +66,8 @@ The return value of ``find()`` must be assigned to an intermediate
.. code-block:: c++
- const std::set<cmStdString>& someSet;
- const std::set<cmStdString>::const_iterator i = someSet.find("needle");
+ const std::set<std::string>& someSet;
+ const std::set<std::string>::const_iterator i = someSet.find("needle");
if (i != propSet.end()) // Ok
{
// ...
@@ -110,7 +110,7 @@ conversion is not allowed:
.. code-block:: c++
- std::set<cmStdString> theSet;
+ std::set<const char*> theSet;
std::vector<std::string> theVector;
theVector.insert(theVector.end(), theSet.begin(), theSet.end()); // Wrong
@@ -118,9 +118,9 @@ A loop must be used instead:
.. code-block:: c++
- std::set<cmStdString> theSet;
+ std::set<const char*> theSet;
std::vector<std::string> theVector;
- for(std::set<cmStdString>::iterator li = theSet.begin();
+ for(std::set<const char*>::iterator li = theSet.begin();
li != theSet.end(); ++li)
{
theVector.push_back(*li);
@@ -664,213 +664,408 @@ For example, a ``Modules/Findxxx.cmake`` module may contain:
<code>
endmacro()
+After the top documentation block, leave a *BLANK* line, and then add a
+copyright and licence notice block like this one (change only the year
+range and name)
+
+.. code-block:: cmake
+
+ #=============================================================================
+ # Copyright 2009-2011 Your Name
+ #
+ # 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.
+ #=============================================================================
+ # (To distribute this file outside of CMake, substitute the full
+ # License text for the above reference.)
+
+Test the documentation formatting by running
+``cmake --help-module <module-name>``, and also by enabling the
+``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
+Edit the comments until generated documentation looks satisfactory. To
+have a .cmake file in this directory NOT show up in the modules
+documentation, simply leave out the ``Help/module/<module-name>.rst``
+file and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
+
+
Find Modules
------------
A "find module" is a ``Modules/Find<package>.cmake`` file to be loaded
by the :command:`find_package` command when invoked for ``<package>``.
-We would like all ``FindXxx.cmake`` files to produce consistent variable
-names. Please use the following consistent variable names for general use.
+The primary task of a find module is to determine whether a package
+exists on the system, set the ``<package>_FOUND`` variable to reflect
+this and provide any variables, macros and imported targets required to
+use the package.
+
+The traditional approach is to use variables for everything, including
+libraries and executables: see the `Standard Variable Names`_ section
+below. This is what most of the existing find modules provided by CMake
+do.
-Xxx_INCLUDE_DIRS
- The final set of include directories listed in one variable for use by client
- code. This should not be a cache entry.
+The more modern approach is to behave as much like
+``<package>Config.cmake`` files as possible, by providing imported
+targets. As well as matching how ``*Config.cmake`` files work, the
+libraries, include directories and compile definitions are all set just
+by using the target in a :command:`target_link_libraries` call. The
+disadvantage is that ``*Config.cmake`` files of projects that use
+imported targets from find modules may require more work to make sure
+those imported targets that are in the link interface are available.
+
+In either case (or even when providing both variables and imported
+targets), find modules should provide backwards compatibility with old
+versions that had the same name.
+
+A FindFoo.cmake module will typically be loaded by the command::
+
+ find_package(Foo [major[.minor[.patch[.tweak]]]]
+ [EXACT] [QUIET] [REQUIRED]
+ [[COMPONENTS] [components...]]
+ [OPTIONAL_COMPONENTS components...]
+ [NO_POLICY_SCOPE])
+
+See the :command:`find_package` documentation for details on what
+variables are set for the find module. Most of these are dealt with by
+using :module:`FindPackageHandleStandardArgs`.
+
+Briefly, the module should only locate versions of the package
+compatible with the requested version, as described by the
+``Foo_FIND_VERSION`` family of variables. If ``Foo_FIND_QUIETLY`` is
+set to true, it should avoid printing messages, including anything
+complaining about the package not being found. If ``Foo_FIND_REQUIRED``
+is set to true, the module should issue a ``FATAL_ERROR`` if the package
+cannot be found. If neither are set to true, it should print a
+non-fatal message if it cannot find the package.
+
+Packages that find multiple semi-independent parts (like bundles of
+libraries) should search for the components listed in
+``Foo_FIND_COMPONENTS`` if it is set , and only set ``Foo_FOUND`` to
+true if for each searched-for component ``<c>`` that was not found,
+``Foo_FIND_REQUIRED_<c>`` is not set to true. The ``HANDLE_COMPONENTS``
+argument of ``find_package_handle_standard_args()`` can be used to
+implement this.
+
+If ``Foo_FIND_COMPONENTS`` is not set, which modules are searched for
+and required is up to the find module, but should be documented.
+
+For internal implementation, it is a generally accepted convention that
+variables starting with underscore are for temporary use only.
+
+Like all modules, find modules should be properly documented. To add a
+module to the CMake documentation, follow the steps in the `Module
+Documentation`_ section above.
+
+
+
+Standard Variable Names
+~~~~~~~~~~~~~~~~~~~~~~~
+
+For a ``FindXxx.cmake`` module that takes the approach of setting
+variables (either instead of or in addition to creating imported
+targets), the following variable names should be used to keep things
+consistent between find modules. Note that all variables start with
+``Xxx_`` to make sure they do not interfere with other find modules; the
+same consideration applies to macros, functions and imported targets.
+
+``Xxx_INCLUDE_DIRS``
+ The final set of include directories listed in one variable for use by
+ client code. This should not be a cache entry.
+
+``Xxx_LIBRARIES``
+ The libraries to link against to use Xxx. These should include full
+ paths. This should not be a cache entry.
+
+``Xxx_DEFINITIONS``
+ Definitions to use when compiling code that uses Xxx. This really
+ shouldn't include options such as ``-DHAS_JPEG`` that a client
+ source-code file uses to decide whether to ``#include <jpeg.h>``
+
+``Xxx_EXECUTABLE``
+ Where to find the Xxx tool.
+
+``Xxx_Yyy_EXECUTABLE``
+ Where to find the Yyy tool that comes with Xxx.
+
+``Xxx_LIBRARY_DIRS``
+ Optionally, the final set of library directories listed in one
+ variable for use by client code. This should not be a cache entry.
+
+``Xxx_ROOT_DIR``
+ Where to find the base directory of Xxx.
+
+``Xxx_VERSION_Yy``
+ Expect Version Yy if true. Make sure at most one of these is ever true.
+
+``Xxx_WRAP_Yy``
+ If False, do not try to use the relevant CMake wrapping command.
+
+``Xxx_Yy_FOUND``
+ If False, optional Yy part of Xxx sytem is not available.
-Xxx_LIBRARIES
- The libraries to link against to use Xxx. These should include full paths.
- This should not be a cache entry.
+``Xxx_FOUND``
+ Set to false, or undefined, if we haven't found, or don't want to use
+ Xxx.
-Xxx_DEFINITIONS
- Definitions to use when compiling code that uses Xxx. This really shouldn't
- include options such as (-DHAS_JPEG)that a client source-code file uses to
- decide whether to #include <jpeg.h>
+``Xxx_NOT_FOUND_MESSAGE``
+ Should be set by config-files in the case that it has set
+ ``Xxx_FOUND`` to FALSE. The contained message will be printed by the
+ :command:`find_package` command and by
+ ``find_package_handle_standard_args()`` to inform the user about the
+ problem.
-Xxx_EXECUTABLE
- Where to find the Xxx tool.
+``Xxx_RUNTIME_LIBRARY_DIRS``
+ Optionally, the runtime library search path for use when running an
+ executable linked to shared libraries. The list should be used by
+ user code to create the ``PATH`` on windows or ``LD_LIBRARY_PATH`` on
+ UNIX. This should not be a cache entry.
-Xxx_Yyy_EXECUTABLE
- Where to find the Yyy tool that comes with Xxx.
+``Xxx_VERSION``
+ The full version string of the package found, if any. Note that many
+ existing modules provide ``Xxx_VERSION_STRING`` instead.
-Xxx_LIBRARY_DIRS
- Optionally, the final set of library directories listed in one variable for
- use by client code. This should not be a cache entry.
+``Xxx_VERSION_MAJOR``
+ The major version of the package found, if any.
-Xxx_ROOT_DIR
- Where to find the base directory of Xxx.
+``Xxx_VERSION_MINOR``
+ The minor version of the package found, if any.
-Xxx_VERSION_Yy
- Expect Version Yy if true. Make sure at most one of these is ever true.
+``Xxx_VERSION_PATCH``
+ The patch version of the package found, if any.
-Xxx_WRAP_Yy
- If False, do not try to use the relevant CMake wrapping command.
+The following names should not usually be used in CMakeLists.txt files, but
+are typically cache variables for users to edit and control the
+behaviour of find modules (like entering the path to a library manually)
-Xxx_Yy_FOUND
- If False, optional Yy part of Xxx sytem is not available.
+``Xxx_LIBRARY``
+ The path of the Xxx library (as used with :command:`find_library`, for
+ example).
-Xxx_FOUND
- Set to false, or undefined, if we haven't found, or don't want to use Xxx.
+``Xxx_Yy_LIBRARY``
+ The path of the Yy library that is part of the Xxx system. It may or
+ may not be required to use Xxx.
-Xxx_NOT_FOUND_MESSAGE
- Should be set by config-files in the case that it has set Xxx_FOUND to FALSE.
- The contained message will be printed by the find_package() command and by
- find_package_handle_standard_args() to inform the user about the problem.
+``Xxx_INCLUDE_DIR``
+ Where to find headers for using the Xxx library.
-Xxx_RUNTIME_LIBRARY_DIRS
- Optionally, the runtime library search path for use when running an
- executable linked to shared libraries. The list should be used by user code
- to create the PATH on windows or LD_LIBRARY_PATH on unix. This should not be
- a cache entry.
+``Xxx_Yy_INCLUDE_DIR``
+ Where to find headers for using the Yy library of the Xxx system.
-Xxx_VERSION_STRING
- A human-readable string containing the version of the package found, if any.
+To prevent users being overwhelmed with settings to configure, try to
+keep as many options as possible out of the cache, leaving at least one
+option which can be used to disable use of the module, or locate a
+not-found library (e.g. ``Xxx_ROOT_DIR``). For the same reason, mark
+most cache options as advanced.
-Xxx_VERSION_MAJOR
- The major version of the package found, if any.
+While these are the standard variable names, you should provide
+backwards compatibility for any old names that were actually in use.
+Make sure you comment them as deprecated, so that no-one starts using
+them.
-Xxx_VERSION_MINOR
- The minor version of the package found, if any.
-Xxx_VERSION_PATCH
- The patch version of the package found, if any.
-You do not have to provide all of the above variables. You should provide
-Xxx_FOUND under most circumstances. If Xxx is a library, then Xxx_LIBRARIES,
-should also be defined, and Xxx_INCLUDE_DIRS should usually be defined (I
-guess libm.a might be an exception)
+A Sample Find Module
+~~~~~~~~~~~~~~~~~~~~
-The following names should not usually be used in CMakeLists.txt files, but
-they may be usefully modified in users' CMake Caches to control stuff.
+We will describe how to create a simple find module for a library
+``Foo``.
-Xxx_LIBRARY
- Name of Xxx Library. A User may set this and Xxx_INCLUDE_DIR to ignore to
- force non-use of Xxx.
+The first thing that is needed is documentation. CMake's documentation
+system requires you to start the file with a documentation marker and
+the name of the module. You should follow this with a simple statement
+of what the module does.
-Xxx_Yy_LIBRARY
- Name of Yy library that is part of the Xxx system. It may or may not be
- required to use Xxx.
+.. code-block:: cmake
-Xxx_INCLUDE_DIR
- Where to find xxx.h, etc. (Xxx_INCLUDE_PATH was considered bad because a path
- includes an actual filename.)
+ #.rst:
+ # FindFoo
+ # -------
+ #
+ # Finds the Foo library
+ #
-Xxx_Yy_INCLUDE_DIR
- Where to find xxx_yy.h, etc.
+More description may be required for some packages. If there are
+caveats or other details users of the module should be aware of, you can
+add further paragraphs below this. Then you need to document what
+variables and imported targets are set by the module, such as
-For tidiness's sake, try to keep as many options as possible out of the cache,
-leaving at least one option which can be used to disable use of the module, or
-locate a not-found library (e.g. Xxx_ROOT_DIR). For the same reason, mark
-most cache options as advanced.
+.. code-block:: cmake
-If you need other commands to do special things then it should still begin
-with ``Xxx_``. This gives a sort of namespace effect and keeps things tidy for the
-user. You should put comments describing all the exported settings, plus
-descriptions of any the users can use to control stuff.
+ # This will define the following variables::
+ #
+ # Foo_FOUND - True if the system has the Foo library
+ # Foo_VERSION - The version of the Foo library which was found
+ #
+ # and the following imported targets::
+ #
+ # Foo::Foo - The Foo library
-You really should also provide backwards compatibility any old settings that
-were actually in use. Make sure you comment them as deprecated, so that
-no-one starts using them.
+If the package provides any macros, they should be listed here, but can
+be documented where they are defined. See the `Module
+Documentation`_ section above for more details.
-To add a module to the CMake documentation, follow the steps in the
-`Module Documentation`_ section above. Test the documentation formatting
-by running ``cmake --help-module FindXxx``, and also by enabling the
-``SPHINX_HTML`` and ``SPHINX_MAN`` options to build the documentation.
-Edit the comments until generated documentation looks satisfactory.
-To have a .cmake file in this directory NOT show up in the modules
-documentation, simply leave out the ``Help/module/<module-name>.rst`` file
-and the ``Help/manual/cmake-modules.7.rst`` toctree entry.
+After the documentation, leave a blank line, and then add a copyright and
+licence notice block
-After the documentation, leave a *BLANK* line, and then add a
-copyright and licence notice block like this one::
+.. code-block:: cmake
- #=============================================================================
- # Copyright 2009-2011 Your Name
- #
- # 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.
- #=============================================================================
- # (To distribute this file outside of CMake, substitute the full
- # License text for the above reference.)
-
-The layout of the notice block is strictly enforced by the ``ModuleNotices``
-test. Only the year range and name may be changed freely.
-
-A FindXxx.cmake module will typically be loaded by the command::
-
- FIND_PACKAGE(Xxx [major[.minor[.patch[.tweak]]]] [EXACT]
- [QUIET] [[REQUIRED|COMPONENTS] [components...]])
-
-If any version numbers are given to the command it will set the following
-variables before loading the module:
-
-Xxx_FIND_VERSION
- full requested version string
-
-Xxx_FIND_VERSION_MAJOR
- major version if requested, else 0
-
-Xxx_FIND_VERSION_MINOR
- minor version if requested, else 0
-
-Xxx_FIND_VERSION_PATCH
- patch version if requested, else 0
-
-Xxx_FIND_VERSION_TWEAK
- tweak version if requested, else 0
-
-Xxx_FIND_VERSION_COUNT
- number of version components, 0 to 4
-
-Xxx_FIND_VERSION_EXACT
- true if EXACT option was given
-
-If the find module supports versioning it should locate a version of
-the package that is compatible with the version requested. If a
-compatible version of the package cannot be found the module should
-not report success. The version of the package found should be stored
-in "Xxx_VERSION..." version variables documented by the module.
-
-If the QUIET option is given to the command it will set the variable
-Xxx_FIND_QUIETLY to true before loading the FindXxx.cmake module. If
-this variable is set the module should not complain about not being
-able to find the package. If the
-REQUIRED option is given to the command it will set the variable
-Xxx_FIND_REQUIRED to true before loading the FindXxx.cmake module. If
-this variable is set the module should issue a FATAL_ERROR if the
-package cannot be found.
-If neither the QUIET nor REQUIRED options are given then the
-FindXxx.cmake module should look for the package and complain without
-error if the module is not found.
-
-FIND_PACKAGE() will set the variable CMAKE_FIND_PACKAGE_NAME to
-contain the actual name of the package.
-
-A package can provide sub-components.
-Those components can be listed after the COMPONENTS (or REQUIRED) or
-OPTIONAL_COMPONENTS keywords. The set of all listed components will be
-specified in a Xxx_FIND_COMPONENTS variable.
-For each package-specific component, say Yyy, a variable Xxx_FIND_REQUIRED_Yyy
-will be set to true if it listed after COMPONENTS and it will be set to false
-if it was listed after OPTIONAL_COMPONENTS.
-Using those variables a FindXxx.cmake module and also a XxxConfig.cmake
-package configuration file can determine whether and which components have
-been requested, and whether they were requested as required or as optional.
-For each of the requested components a Xxx_Yyy_FOUND variable should be set
-accordingly.
-The per-package Xxx_FOUND variable should be only set to true if all requested
-required components have been found. A missing optional component should not
-keep the Xxx_FOUND variable from being set to true.
-If the package provides Xxx_INCLUDE_DIRS and Xxx_LIBRARIES variables, the
-include dirs and libraries for all components which were requested and which
-have been found should be added to those two variables.
-
-To get this behavior you can use the FIND_PACKAGE_HANDLE_STANDARD_ARGS()
-macro, as an example see FindJPEG.cmake.
-
-For internal implementation, it's a generally accepted convention that
-variables starting with underscore are for temporary use only. (variable
-starting with an underscore are not intended as a reserved prefix).
+ #=============================================================================
+ # Copyright 2009-2011 Your Name
+ #
+ # 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.
+ #=============================================================================
+ # (To distribute this file outside of CMake, substitute the full
+ # License text for the above reference.)
+
+If the module is new to CMake, you may want to provide a warning for
+projects that do not require a high enough CMake version.
+
+.. code-block:: cmake
+
+ if(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 3.0.0)
+ message(AUTHOR_WARNING "Your project should require at least CMake 3.0.0 to use FindFoo.cmake")
+ endif()
+
+Now the actual libraries and so on have to be found. The code here will
+obviously vary from module to module (dealing with that, after all, is the
+point of find modules), but there tends to be a common pattern for libraries.
+
+First, we try to use ``pkg-config`` to find the library. Note that we
+cannot rely on this, as it may not be available, but it provides a good
+starting point.
+
+.. code-block:: cmake
+
+ find_package(PkgConfig)
+ pkg_check_modules(PC_Foo QUIET Foo)
+
+This should define some variables starting ``PC_Foo_`` that contain the
+information from the ``Foo.pc`` file.
+
+Now we need to find the libraries and include files; we use the
+information from ``pkg-config`` to provide hints to CMake about where to
+look.
+
+.. code-block:: cmake
+
+ find_path(Foo_INCLUDE_DIR
+ NAMES foo.h
+ PATHS ${PC_Foo_INCLUDE_DIRS}
+ # if you need to put #include <Foo/foo.h> in your code, add:
+ PATH_SUFFIXES Foo
+ )
+ find_library(Foo_LIBRARY
+ NAMES foo
+ PATHS ${PC_Foo_LIBRARY_DIRS}
+ )
+
+If you have a good way of getting the version (from a header file, for
+example), you can use that information to set ``Foo_VERSION`` (although
+note that find modules have traditionally used ``Foo_VERSION_STRING``,
+so you may want to set both). Otherwise, attempt to use the information
+from ``pkg-config``
+
+.. code-block:: cmake
+
+ set(Foo_VERSION ${PC_Foo_VERSION})
+
+Now we can use :module:`FindPackageHandleStandardArgs` to do most of the
+rest of the work for us
+
+.. code-block:: cmake
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Foo
+ FOUND_VAR Foo_FOUND
+ REQUIRED_VARS
+ Foo_LIBRARY
+ Foo_INCLUDE_DIR
+ VERSION_VAR Foo_VERSION
+ )
+
+This will check that the ``REQUIRED_VARS`` contain values (that do not
+end in ``-NOTFOUND``) and set ``Foo_FOUND`` appropriately. It will also
+cache those values. If ``Foo_VERSION`` is set, and a required version
+was passed to :command:`find_package`, it will check the requested version
+against the one in ``Foo_VERSION``. It will also print messages as
+appropriate; note that if the package was found, it will print the
+contents of the first required variable to indicate where it was found.
+
+At this point, we have to provide a way for users of the find module to
+link to the library or libraries that were found. There are two
+approaches, as discussed in the `Find Modules`_ section above. The
+traditional variable approach looks like
+
+.. code-block:: cmake
+
+ if(Foo_FOUND)
+ set(Foo_LIBRARIES ${Foo_LIBRARY})
+ set(Foo_INCLUDE_DIRS ${Foo_INCLUDE_DIR})
+ set(Foo_DEFINITIONS ${PC_Foo_CFLAGS_OTHER})
+ endif()
+
+If more than one library was found, all of them should be included in
+these variables (see the `Standard Variable Names`_ section for more
+information).
+
+When providing imported targets, these should be namespaced (hence the
+``Foo::`` prefix); CMake will recognize that values passed to
+:command:`target_link_libraries` that contain ``::`` in their name are
+supposed to be imported targets (rather than just library names), and
+will produce appropriate diagnostic messages if that target does not
+exist (see policy :policy:`CMP0028`).
+
+.. code-block:: cmake
+
+ if(Foo_FOUND AND NOT TARGET Foo::Foo)
+ add_library(Foo::Foo UNKNOWN IMPORTED)
+ set_target_properties(Foo::Foo PROPERTIES
+ IMPORTED_LOCATION "${Foo_LIBRARY}"
+ INTERFACE_COMPILE_OPTIONS "${PC_Foo_CFLAGS_OTHER}"
+ INTERFACE_INCLUDE_DIRECTORIES "${Foo_INCLUDE_DIR}"
+ )
+ endif()
+
+One thing to note about this is that the ``INTERFACE_INCLUDE_DIRECTORIES`` and
+similar properties should only contain information about the target itself, and
+not any of its dependencies. Instead, those dependencies should also be
+targets, and CMake should be told that they are dependencies of this target.
+CMake will then combine all the necessary information automatically.
+
+We should also provide some information about the package, such as where to
+download it.
+
+.. code-block:: cmake
+
+ include(FeatureSummary)
+ set_package_properties(Foo PROPERTIES
+ URL "http://www.foo.example.com/"
+ DESCRIPTION "A library for doing useful things"
+ )
+
+Most of the cache variables should be hidden in the ``ccmake`` interface unless
+the user explicitly asks to edit them.
+
+.. code-block:: cmake
+
+ mark_as_advanced(
+ Foo_INCLUDE_DIR
+ Foo_LIBRARY
+ )
+
+If this module replaces an older version, you should set compatibility variables
+to cause the least disruption possible.
+
+.. code-block:: cmake
+
+ # compatibility variables
+ set(Foo_VERSION_STRING ${Foo_VERSION})
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index ac8c3f8..dfda8dc 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -188,3 +188,8 @@ property is non-empty::
Content of ``...`` converted to upper case.
``$<MAKE_C_IDENTIFIER:...>``
Content of ``...`` converted to a C identifier.
+``$<TARGET_OBJECTS:objLib>``
+ List of objects resulting from build of ``objLib``. ``objLib`` must be an
+ object of type ``OBJECT_LIBRARY``. This expression may only be used in
+ the sources of :command:`add_library` and :command:`add_executable`
+ commands.
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index 7a06be6..2bbe622 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -138,6 +138,7 @@ All Modules
/module/FindMPEG
/module/FindMPI
/module/FindOpenAL
+ /module/FindOpenCL
/module/FindOpenGL
/module/FindOpenMP
/module/FindOpenSceneGraph
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 8650a58..4b895fe 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -102,3 +102,5 @@ All Policies
/policy/CMP0048
/policy/CMP0049
/policy/CMP0050
+ /policy/CMP0051
+ /policy/CMP0052
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index d315fcb..a82522d 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -98,10 +98,17 @@ Properties on Targets
/prop_tgt/COMPATIBLE_INTERFACE_STRING
/prop_tgt/COMPILE_DEFINITIONS_CONFIG
/prop_tgt/COMPILE_DEFINITIONS
+ /prop_tgt/COMPILE_FEATURES
/prop_tgt/COMPILE_FLAGS
/prop_tgt/COMPILE_OPTIONS
+ /prop_tgt/COMPILE_PDB_NAME
+ /prop_tgt/COMPILE_PDB_NAME_CONFIG
+ /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY
+ /prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/prop_tgt/CONFIG_OUTPUT_NAME
/prop_tgt/CONFIG_POSTFIX
+ /prop_tgt/CXX_STANDARD
+ /prop_tgt/CXX_EXTENSIONS
/prop_tgt/DEBUG_POSTFIX
/prop_tgt/DEFINE_SYMBOL
/prop_tgt/EchoString
@@ -144,10 +151,12 @@ Properties on Targets
/prop_tgt/INSTALL_RPATH_USE_LINK_PATH
/prop_tgt/INTERFACE_AUTOUIC_OPTIONS
/prop_tgt/INTERFACE_COMPILE_DEFINITIONS
+ /prop_tgt/INTERFACE_COMPILE_FEATURES
/prop_tgt/INTERFACE_COMPILE_OPTIONS
/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES
/prop_tgt/INTERFACE_LINK_LIBRARIES
/prop_tgt/INTERFACE_POSITION_INDEPENDENT_CODE
+ /prop_tgt/INTERFACE_SOURCES
/prop_tgt/INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
/prop_tgt/INTERPROCEDURAL_OPTIMIZATION_CONFIG
/prop_tgt/INTERPROCEDURAL_OPTIMIZATION
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index f4b9666..dfdd09b 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -201,6 +201,8 @@ Variables that Control the Build
/variable/CMAKE_AUTOUIC
/variable/CMAKE_AUTOUIC_OPTIONS
/variable/CMAKE_BUILD_WITH_INSTALL_RPATH
+ /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
+ /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG
/variable/CMAKE_CONFIG_POSTFIX
/variable/CMAKE_DEBUG_POSTFIX
/variable/CMAKE_EXE_LINKER_FLAGS_CONFIG
@@ -255,6 +257,10 @@ Variables for Languages
:maxdepth: 1
/variable/CMAKE_COMPILER_IS_GNULANG
+ /variable/CMAKE_CXX_COMPILE_FEATURES
+ /variable/CMAKE_CXX_KNOWN_FEATURES
+ /variable/CMAKE_CXX_STANDARD
+ /variable/CMAKE_CXX_EXTENSIONS
/variable/CMAKE_Fortran_MODDIR_DEFAULT
/variable/CMAKE_Fortran_MODDIR_FLAG
/variable/CMAKE_Fortran_MODOUT_FLAG
diff --git a/Help/module/FindOpenCL.rst b/Help/module/FindOpenCL.rst
new file mode 100644
index 0000000..e87e289
--- /dev/null
+++ b/Help/module/FindOpenCL.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindOpenCL.cmake
diff --git a/Help/policy/CMP0051.rst b/Help/policy/CMP0051.rst
new file mode 100644
index 0000000..1b56cb0
--- /dev/null
+++ b/Help/policy/CMP0051.rst
@@ -0,0 +1,24 @@
+CMP0051
+-------
+
+List TARGET_OBJECTS in SOURCES target property.
+
+CMake 3.0 and lower did not include the ``TARGET_OBJECTS``
+:manual:`generator expression <cmake-generator-expressions(7)>` when
+returning the :prop_tgt:`SOURCES` target property.
+
+Configure-time CMake code is not able to handle generator expressions. If
+using the :prop_tgt:`SOURCES` target property at configure time, it may be
+necessary to first remove generator expressions using the
+:command:`string(GENEX_STRIP)` command. Generate-time CMake code such as
+:command:`file(GENERATE)` can handle the content without stripping.
+
+The ``OLD`` behavior for this policy is to omit ``TARGET_OBJECTS``
+expressions from the :prop_tgt:`SOURCES` target property. The ``NEW``
+behavior for this policy is to include ``TARGET_OBJECTS`` expressions
+in the output.
+
+This policy was introduced in CMake version 3.1.
+CMake version |release| warns when the policy is not set and uses
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it
+to ``OLD`` or ``NEW`` explicitly.
diff --git a/Help/policy/CMP0052.rst b/Help/policy/CMP0052.rst
new file mode 100644
index 0000000..48cfc9c
--- /dev/null
+++ b/Help/policy/CMP0052.rst
@@ -0,0 +1,24 @@
+CMP0052
+-------
+
+Reject source and build dirs in installed INTERFACE_INCLUDE_DIRECTORIES.
+
+CMake 3.0 and lower allowed subdirectories of the source directory or build
+directory to be in the :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of
+installed and exported targets, if the directory was also a subdirectory of
+the installation prefix. This makes the installation depend on the
+existence of the source dir or binary dir, and the installation will be
+broken if either are removed after installation.
+
+See :ref:`Include Directories and Usage Requirements` for more on
+specifying include directories for targets.
+
+The OLD behavior for this policy is to export the content of the
+:prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` with the source or binary
+directory. The NEW behavior for this
+policy is to issue an error if such a directory is used.
+
+This policy was introduced in CMake version 3.1.
+CMake version |release| warns when the policy is not set and uses
+``OLD`` behavior. Use the :command:`cmake_policy` command to set it
+to ``OLD`` or ``NEW`` explicitly.
diff --git a/Help/prop_tgt/COMPILE_FEATURES.rst b/Help/prop_tgt/COMPILE_FEATURES.rst
new file mode 100644
index 0000000..dc32825
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_FEATURES.rst
@@ -0,0 +1,11 @@
+COMPILE_FEATURES
+----------------
+
+Compiler features enabled for this target.
+
+The list of features in this property are a subset of the features listed
+in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
+
+Contents of ``COMPILE_FEATURES`` may use "generator expressions" with the
+syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)` manual for
+available expressions.
diff --git a/Help/prop_tgt/COMPILE_PDB_NAME.rst b/Help/prop_tgt/COMPILE_PDB_NAME.rst
new file mode 100644
index 0000000..24a9f62
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_NAME.rst
@@ -0,0 +1,11 @@
+COMPILE_PDB_NAME
+----------------
+
+Output name for the MS debug symbol ``.pdb`` file generated by the
+compiler while building source files.
+
+This property specifies the base name for the debug symbols file.
+If not set, the default is unspecified.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst
new file mode 100644
index 0000000..e4077f5
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_NAME_CONFIG.rst
@@ -0,0 +1,10 @@
+COMPILE_PDB_NAME_<CONFIG>
+-------------------------
+
+Per-configuration output name for the MS debug symbol ``.pdb`` file
+generated by the compiler while building source files.
+
+This is the configuration-specific version of :prop_tgt:`COMPILE_PDB_NAME`.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_NAME_<CONFIG>`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/COMPILE_PDB_NOTE.txt b/Help/prop_tgt/COMPILE_PDB_NOTE.txt
new file mode 100644
index 0000000..5941d72
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_NOTE.txt
@@ -0,0 +1,8 @@
+.. note::
+ The compiler-generated program database files are specified by the
+ ``/Fd`` compiler flag and are not the same as linker-generated
+ program database files specified by the ``/pdb`` linker flag.
+ Use the |PDB_XXX| property to specify the latter.
+
+ This property is not implemented by the :generator:`Visual Studio 6`
+ generator.
diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst
new file mode 100644
index 0000000..34f49be
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY.rst
@@ -0,0 +1,13 @@
+COMPILE_PDB_OUTPUT_DIRECTORY
+----------------------------
+
+Output directory for the MS debug symbol ``.pdb`` file
+generated by the compiler while building source files.
+
+This property specifies the directory into which the MS debug symbols
+will be placed by the compiler. This property is initialized by the
+value of the :variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY` variable
+if it is set when a target is created.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
new file mode 100644
index 0000000..52ef013
--- /dev/null
+++ b/Help/prop_tgt/COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -0,0 +1,16 @@
+COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
+-------------------------------------
+
+Per-configuration output directory for the MS debug symbol ``.pdb`` file
+generated by the compiler while building source files.
+
+This is a per-configuration version of
+:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`,
+but multi-configuration generators (VS, Xcode) do NOT append a
+per-configuration subdirectory to the specified directory. This
+property is initialized by the value of the
+:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable
+if it is set when a target is created.
+
+.. |PDB_XXX| replace:: :prop_tgt:`PDB_OUTPUT_DIRECTORY_<CONFIG>`
+.. include:: COMPILE_PDB_NOTE.txt
diff --git a/Help/prop_tgt/CXX_EXTENSIONS.rst b/Help/prop_tgt/CXX_EXTENSIONS.rst
new file mode 100644
index 0000000..b9c9931
--- /dev/null
+++ b/Help/prop_tgt/CXX_EXTENSIONS.rst
@@ -0,0 +1,8 @@
+CXX_EXTENSIONS
+--------------
+
+Boolean specifying whether compiler specific extensions are requested.
+
+This property specifies whether compiler specific extensions should be
+used. For some compilers, this results in adding a flag such
+as ``-std=gnu++11`` instead of ``-std=c++11`` to the compile line.
diff --git a/Help/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst
new file mode 100644
index 0000000..e1b6e78
--- /dev/null
+++ b/Help/prop_tgt/CXX_STANDARD.rst
@@ -0,0 +1,14 @@
+CXX_STANDARD
+------------
+
+The C++ standard whose features are required to build this target.
+
+This property specifies the C++ standard whose features are required
+to build this target. For some compilers, this results in adding a
+flag such as ``-std=c++11`` to the compile line.
+
+Supported values are ``98`` and ``11``.
+
+This property is initialized by the value of
+the :variable:`CMAKE_CXX_STANDARD` variable if it is set when a target
+is created.
diff --git a/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst
new file mode 100644
index 0000000..a98e362
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_COMPILE_FEATURES.rst
@@ -0,0 +1,14 @@
+INTERFACE_COMPILE_FEATURES
+--------------------------
+
+List of public compile requirements for a library.
+
+Targets may populate this property to publish the compiler features
+required to compile against the headers for the target. Consuming
+targets can add entries to their own :prop_tgt:`COMPILE_FEATURES`
+property such as ``$<TARGET_PROPERTY:foo,INTERFACE_COMPILE_FEATURES>``
+to require the features specified in the interface of ``foo``.
+
+Contents of ``INTERFACE_COMPILE_FEATURES`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions.
diff --git a/Help/prop_tgt/INTERFACE_SOURCES.rst b/Help/prop_tgt/INTERFACE_SOURCES.rst
new file mode 100644
index 0000000..fb28231
--- /dev/null
+++ b/Help/prop_tgt/INTERFACE_SOURCES.rst
@@ -0,0 +1,15 @@
+INTERFACE_SOURCES
+-----------------
+
+List of interface sources to pass to the compiler.
+
+Targets may populate this property to publish the sources
+for consuming targets to compile. Consuming
+targets can add entries to their own :prop_tgt:`SOURCES` property
+such as ``$<TARGET_PROPERTY:foo,INTERFACE_SOURCES>`` to use the
+sources specified in the interface of ``foo``.
+
+Contents of ``INTERFACE_SOURCES`` may use "generator expressions"
+with the syntax ``$<...>``. See the :manual:`cmake-generator-expressions(7)`
+manual for available expressions. See the :manual:`cmake-buildsystem(7)`
+manual for more on defining buildsystem properties.
diff --git a/Help/prop_tgt/PDB_NAME.rst b/Help/prop_tgt/PDB_NAME.rst
index e8fc3be..479dec3 100644
--- a/Help/prop_tgt/PDB_NAME.rst
+++ b/Help/prop_tgt/PDB_NAME.rst
@@ -7,7 +7,5 @@ linker for an executable or shared library target.
This property specifies the base name for the debug symbols file.
If not set, the logical target name is used by default.
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME`
.. include:: PDB_NOTE.txt
-
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
diff --git a/Help/prop_tgt/PDB_NAME_CONFIG.rst b/Help/prop_tgt/PDB_NAME_CONFIG.rst
index c846b57..cb3121c 100644
--- a/Help/prop_tgt/PDB_NAME_CONFIG.rst
+++ b/Help/prop_tgt/PDB_NAME_CONFIG.rst
@@ -6,5 +6,5 @@ generated by the linker for an executable or shared library target.
This is the configuration-specific version of :prop_tgt:`PDB_NAME`.
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_NAME_<CONFIG>`
+.. include:: PDB_NOTE.txt
diff --git a/Help/prop_tgt/PDB_NOTE.txt b/Help/prop_tgt/PDB_NOTE.txt
index e55aba2..f90ea81 100644
--- a/Help/prop_tgt/PDB_NOTE.txt
+++ b/Help/prop_tgt/PDB_NOTE.txt
@@ -3,6 +3,10 @@
is invoked to produce them so they have no linker-generated ``.pdb`` file
containing debug symbols.
- The compiler-generated program database files specified by the MSVC
- ``/Fd`` flag are not the same as linker-generated program database
- files and so are not influenced by this property.
+ The linker-generated program database files are specified by the
+ ``/pdb`` linker flag and are not the same as compiler-generated
+ program database files specified by the ``/Fd`` compiler flag.
+ Use the |COMPILE_PDB_XXX| property to specify the latter.
+
+ This property is not implemented by the :generator:`Visual Studio 6`
+ generator.
diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
index 9a863a1..730cf57 100644
--- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
+++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY.rst
@@ -9,7 +9,5 @@ will be placed by the linker. This property is initialized by the
value of the :variable:`CMAKE_PDB_OUTPUT_DIRECTORY` variable if it is
set when a target is created.
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY`
.. include:: PDB_NOTE.txt
-
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
diff --git a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
index caec2de..6037fa0 100644
--- a/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
+++ b/Help/prop_tgt/PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -11,5 +11,5 @@ property is initialized by the value of the
:variable:`CMAKE_PDB_OUTPUT_DIRECTORY_<CONFIG>` variable if it is
set when a target is created.
-This property is not implemented by the :generator:`Visual Studio 6`
-generator.
+.. |COMPILE_PDB_XXX| replace:: :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
+.. include:: PDB_NOTE.txt
diff --git a/Help/prop_tgt/SOURCES.rst b/Help/prop_tgt/SOURCES.rst
index 833b65a..493643e 100644
--- a/Help/prop_tgt/SOURCES.rst
+++ b/Help/prop_tgt/SOURCES.rst
@@ -3,5 +3,4 @@ SOURCES
Source names specified for a target.
-Read-only list of sources specified for a target. The names returned
-are suitable for passing to the set_source_files_properties command.
+List of sources specified for a target.
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
new file mode 100644
index 0000000..e4cc01e
--- /dev/null
+++ b/Help/release/dev/0-sample-topic.rst
@@ -0,0 +1,7 @@
+0-sample-topic
+--------------
+
+* This is a sample release note for the change in a topic.
+ Developers should add similar notes for each topic branch
+ making a noteworthy change. Each document should be named
+ and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/dev/CMP0052.rst b/Help/release/dev/CMP0052.rst
new file mode 100644
index 0000000..adb3d44
--- /dev/null
+++ b/Help/release/dev/CMP0052.rst
@@ -0,0 +1,5 @@
+CMP0052
+-------
+
+* Policy :policy:`CMP0052` introduced to control directories in the
+ :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` of exported targets.
diff --git a/Help/release/dev/CMakeDetermineVSServicePack.rst b/Help/release/dev/CMakeDetermineVSServicePack.rst
new file mode 100644
index 0000000..d9d7b41
--- /dev/null
+++ b/Help/release/dev/CMakeDetermineVSServicePack.rst
@@ -0,0 +1,6 @@
+CMakeDetermineVSServicePack
+---------------------------
+
+* The :module:`CMakeDetermineVSServicePack` module now warns that
+ it is deprecated and should not longer be used. Use the
+ :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable instead.
diff --git a/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst
new file mode 100644
index 0000000..5384671
--- /dev/null
+++ b/Help/release/dev/ExternalProject-BUILD_ALWAYS.rst
@@ -0,0 +1,6 @@
+ExternalProject-BUILD_ALWAYS
+----------------------------
+
+* The :module:`ExternalProject` module ``ExternalProject_Add`` command
+ learned a new ``BUILD_ALWAYS`` option to cause the external project
+ build step to run every time the host project is built.
diff --git a/Help/release/dev/ExternalProject-no-download-progress.rst b/Help/release/dev/ExternalProject-no-download-progress.rst
new file mode 100644
index 0000000..41db55d
--- /dev/null
+++ b/Help/release/dev/ExternalProject-no-download-progress.rst
@@ -0,0 +1,6 @@
+ExternalProject-no-download-progress
+------------------------------------
+
+* The :module:`ExternalProject` module ``ExternalProject_Add`` command
+ learned a new ``DOWNLOAD_NO_PROGRESS`` option to disable progress
+ output while downloading the source tarball.
diff --git a/Help/release/dev/ExternalProject_exclude-from-all.rst b/Help/release/dev/ExternalProject_exclude-from-all.rst
new file mode 100644
index 0000000..1d62b3a
--- /dev/null
+++ b/Help/release/dev/ExternalProject_exclude-from-all.rst
@@ -0,0 +1,11 @@
+ExternalProject_exclude-from-all
+--------------------------------
+
+* The :module:`ExternalProject` module ``ExternalProject_Add`` command
+ learned a new ``EXCLUDE_FROM_ALL`` option to cause the external
+ project target to have the :prop_tgt:`EXCLUDE_FROM_ALL` target
+ property set.
+
+* The :module:`ExternalProject` module ``ExternalProject_Add_Step`` command
+ learned a new ``EXCLUDE_FROM_MAIN`` option to cause the step to not be
+ a direct dependency of the main external project target.
diff --git a/Help/release/dev/FeatureSummary_combine_WHAT_values.rst b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst
new file mode 100644
index 0000000..174ef15
--- /dev/null
+++ b/Help/release/dev/FeatureSummary_combine_WHAT_values.rst
@@ -0,0 +1,6 @@
+FeatureSummary_combine_WHAT_values
+----------------------------------
+
+* The :module:`FeatureSummary` module ``feature_summary`` API
+ learned to accept multiple values for the ``WHAT`` option and
+ combine them appropriately.
diff --git a/Help/release/dev/FindGTest-AUTO-SOURCES.rst b/Help/release/dev/FindGTest-AUTO-SOURCES.rst
new file mode 100644
index 0000000..17b2a1b
--- /dev/null
+++ b/Help/release/dev/FindGTest-AUTO-SOURCES.rst
@@ -0,0 +1,7 @@
+FindGTest-AUTO-SOURCES
+----------------------
+
+* The :module:`FindGTest` module ``gtest_add_tests`` macro learned
+ a new ``AUTO`` option to automatically read the :prop_tgt:`SOURCES`
+ target property of the test executable and scan the source files
+ for tests to be added.
diff --git a/Help/release/dev/FindHg-WC_INFO.rst b/Help/release/dev/FindHg-WC_INFO.rst
new file mode 100644
index 0000000..0caf2b3
--- /dev/null
+++ b/Help/release/dev/FindHg-WC_INFO.rst
@@ -0,0 +1,5 @@
+FindHg-WC_INFO
+--------------
+
+* The :module:`FindHg` module gained a new ``Hg_WC_INFO`` macro to
+ help run ``hg`` to extract information about a Mercurial work copy.
diff --git a/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst
new file mode 100644
index 0000000..c0f6471
--- /dev/null
+++ b/Help/release/dev/FindPkgConfig-PKG_CONFIG.rst
@@ -0,0 +1,5 @@
+FindPkgConfig-PKG_CONFIG
+------------------------
+
+* The :module:`FindPkgConfig` module learned to use the ``PKG_CONFIG``
+ environment variable value as the ``pkg-config`` executable, if set.
diff --git a/Help/release/dev/add-FindOpenCL.rst b/Help/release/dev/add-FindOpenCL.rst
new file mode 100644
index 0000000..e1e30d1
--- /dev/null
+++ b/Help/release/dev/add-FindOpenCL.rst
@@ -0,0 +1,4 @@
+add-FindOpenCL
+--------------
+
+* The :module:`FindOpenCL` module was introduced.
diff --git a/Help/release/dev/add_custom_command-DEPENDS-genex.rst b/Help/release/dev/add_custom_command-DEPENDS-genex.rst
new file mode 100644
index 0000000..1e528e6
--- /dev/null
+++ b/Help/release/dev/add_custom_command-DEPENDS-genex.rst
@@ -0,0 +1,5 @@
+add_custom_command-DEPENDS-genex
+--------------------------------
+
+* The :command:`add_custom_command` command learned to interpret
+ :manual:`cmake-generator-expressions(7)` in arguments to ``DEPENDS``.
diff --git a/Help/release/dev/compile-language-features.rst b/Help/release/dev/compile-language-features.rst
new file mode 100644
index 0000000..3c5d7ca
--- /dev/null
+++ b/Help/release/dev/compile-language-features.rst
@@ -0,0 +1,18 @@
+target-language-features
+------------------------
+
+* New :prop_tgt:`CXX_STANDARD` and :prop_tgt:`CXX_EXTENSIONS` target
+ properties may specify values which CMake uses to compute required
+ compile options such as ``-std=c++11`` or ``-std=gnu++11``. The
+ :variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_EXTENSIONS`
+ variables may be set to initialize the target properties.
+
+* New :prop_tgt:`COMPILE_FEATURES` target property may contain a list
+ of features required to compile a target. CMake uses this
+ information to ensure that the compiler in use is capable of building
+ the target, and to add any necessary compile flags to support language
+ features.
+
+* New :command:`target_compile_features` command allows populating the
+ :prop_tgt:`COMPILE_FEATURES` target property, just like any other
+ build variable.
diff --git a/Help/release/dev/cpack-deb-compression-types.rst b/Help/release/dev/cpack-deb-compression-types.rst
new file mode 100644
index 0000000..a33e333
--- /dev/null
+++ b/Help/release/dev/cpack-deb-compression-types.rst
@@ -0,0 +1,6 @@
+cpack-deb-compression-types
+---------------------------
+
+* The :module:`CPackDeb` module learned a new
+ :variable:`CPACK_DEBIAN_COMPRESSION_TYPE` variable to set the
+ tarball compression type.
diff --git a/Help/release/dev/ctest-coverage-extra.rst b/Help/release/dev/ctest-coverage-extra.rst
new file mode 100644
index 0000000..85d023b
--- /dev/null
+++ b/Help/release/dev/ctest-coverage-extra.rst
@@ -0,0 +1,5 @@
+ctest-coverage-extra
+--------------------
+
+* The :command:`ctest_coverage` command learned to read variable
+ ``CTEST_COVERAGE_EXTRA_FLAGS`` to set ``CoverageExtraFlags``.
diff --git a/Help/release/dev/ctest-intel-coverage.rst b/Help/release/dev/ctest-intel-coverage.rst
new file mode 100644
index 0000000..11455a5
--- /dev/null
+++ b/Help/release/dev/ctest-intel-coverage.rst
@@ -0,0 +1,5 @@
+ctest-intel-coverage
+--------------------
+
+* The :command:`ctest_coverage` command learned to support
+ Intel coverage files with the ``codecov`` tool.
diff --git a/Help/release/dev/custom-ninja-deptypes.rst b/Help/release/dev/custom-ninja-deptypes.rst
new file mode 100644
index 0000000..7750da8
--- /dev/null
+++ b/Help/release/dev/custom-ninja-deptypes.rst
@@ -0,0 +1,5 @@
+custom-ninja-deptypes
+---------------------
+
+* Add a `CMAKE_NINJA_DEPTYPE_<LANG>` variable so that compilers may set the
+ deptype for use in Ninja other than those CMake itself knows about.
diff --git a/Help/release/dev/faster-parsers.rst b/Help/release/dev/faster-parsers.rst
new file mode 100644
index 0000000..c2a8bfb
--- /dev/null
+++ b/Help/release/dev/faster-parsers.rst
@@ -0,0 +1,6 @@
+faster-parsers
+--------------
+
+* The :manual:`cmake-language(7)` internal implementation of generator
+ expression and list expansion parsers have been optimized and shows
+ non-trivial speedup on large projects.
diff --git a/Help/release/dev/link-libraries-response-files.rst b/Help/release/dev/link-libraries-response-files.rst
new file mode 100644
index 0000000..cecf7f6
--- /dev/null
+++ b/Help/release/dev/link-libraries-response-files.rst
@@ -0,0 +1,5 @@
+link-libraries-response-files
+-----------------------------
+
+* The Makefile generators learned to use response files with GNU tools
+ on Windows to pass library directories and names to the linker.
diff --git a/Help/release/dev/msvc-compiler-pdb-files.rst b/Help/release/dev/msvc-compiler-pdb-files.rst
new file mode 100644
index 0000000..d06d202
--- /dev/null
+++ b/Help/release/dev/msvc-compiler-pdb-files.rst
@@ -0,0 +1,10 @@
+msvc-compiler-pdb-files
+-----------------------
+
+* New :prop_tgt:`COMPILE_PDB_NAME` and
+ :prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` target properties
+ were introduced to specify the MSVC compiler program database
+ file location (``cl /Fd``). This complements the existing
+ :prop_tgt:`PDB_NAME` and :prop_tgt:`PDB_OUTPUT_DIRECTORY`
+ target properties that specify the linker program database
+ file location (``link /pdb``).
diff --git a/Help/release/dev/string-GENEX_STRIP.rst b/Help/release/dev/string-GENEX_STRIP.rst
new file mode 100644
index 0000000..b5b1074
--- /dev/null
+++ b/Help/release/dev/string-GENEX_STRIP.rst
@@ -0,0 +1,6 @@
+string-GENEX_STRIP
+------------------
+
+* The :command:`string` command learned a new ``GENEX_STRIP`` subcommand
+ which removes
+ :manual:`generator expression <cmake-generator-expressions(7)>`.
diff --git a/Help/release/dev/target-INTERFACE_SOURCES.rst b/Help/release/dev/target-INTERFACE_SOURCES.rst
new file mode 100644
index 0000000..4e34943
--- /dev/null
+++ b/Help/release/dev/target-INTERFACE_SOURCES.rst
@@ -0,0 +1,5 @@
+target-INTERFACE_SOURCES
+------------------------
+
+* A new :prop_tgt:`INTERFACE_SOURCES` target property was introduced. This is
+ consumed by dependent targets, which compile and link the listed sources.
diff --git a/Help/release/dev/target-SOURCES-genex.rst b/Help/release/dev/target-SOURCES-genex.rst
new file mode 100644
index 0000000..9a65101
--- /dev/null
+++ b/Help/release/dev/target-SOURCES-genex.rst
@@ -0,0 +1,12 @@
+target-SOURCES-genex
+--------------------
+
+* The :prop_tgt:`SOURCES` target property now contains
+ :manual:`generator expression <cmake-generator-expressions(7)>`
+ such as ``TARGET_OBJECTS`` when read at configure time, if
+ policy :policy:`CMP0051` is ``NEW``.
+
+* The :prop_tgt:`SOURCES` target property now generally supports
+ :manual:`generator expression <cmake-generator-expressions(7)>`. The
+ generator expressions may be used in the :command:`add_library` and
+ :command:`add_executable` commands.
diff --git a/Help/release/dev/target-SOURCES-write.rst b/Help/release/dev/target-SOURCES-write.rst
new file mode 100644
index 0000000..a754a73
--- /dev/null
+++ b/Help/release/dev/target-SOURCES-write.rst
@@ -0,0 +1,6 @@
+target-SOURCES-write.rst
+------------------------
+
+* It is now possible to write and append to the :prop_tgt:`SOURCES` target
+ property. The :variable:`CMAKE_DEBUG_TARGET_PROPERTIES` variable may be
+ used to trace the origin of sources.
diff --git a/Help/release/dev/target_sources-command.rst b/Help/release/dev/target_sources-command.rst
new file mode 100644
index 0000000..abfb303
--- /dev/null
+++ b/Help/release/dev/target_sources-command.rst
@@ -0,0 +1,5 @@
+target_sources-command
+----------------------
+
+* The :command:`target_sources` command was added to add to the
+ :prop_tgt:`SOURCES` target property.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index 752c568..15ce065 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -5,6 +5,8 @@ CMake Release Notes
This file should include the adjacent "dev.txt" file
in development versions but not in release versions.
+.. include:: dev.txt
+
Releases
========
diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst
new file mode 100644
index 0000000..ea33c7d
--- /dev/null
+++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY.rst
@@ -0,0 +1,8 @@
+CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY
+----------------------------------
+
+Output directory for MS debug symbol ``.pdb`` files
+generated by the compiler while building source files.
+
+This variable is used to initialize the
+:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY` property on all the targets.
diff --git a/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
new file mode 100644
index 0000000..fdeb9ab
--- /dev/null
+++ b/Help/variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG.rst
@@ -0,0 +1,11 @@
+CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>
+-------------------------------------------
+
+Per-configuration output directory for MS debug symbol ``.pdb`` files
+generated by the compiler while building source files.
+
+This is a per-configuration version of
+:variable:`CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY`.
+This variable is used to initialize the
+:prop_tgt:`COMPILE_PDB_OUTPUT_DIRECTORY_<CONFIG>`
+property on all the targets.
diff --git a/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
new file mode 100644
index 0000000..6be0124
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_COMPILE_FEATURES.rst
@@ -0,0 +1,8 @@
+CMAKE_CXX_COMPILE_FEATURES
+--------------------------
+
+List of features known to the C++ compiler
+
+These features are known to be available for use with the C++ compiler. This
+list is a subset of the features listed in the :variable:`CMAKE_CXX_KNOWN_FEATURES`
+variable.
diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst
new file mode 100644
index 0000000..734d508
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst
@@ -0,0 +1,8 @@
+CMAKE_CXX_EXTENSIONS
+--------------------
+
+Default value for ``CXX_EXTENSIONS`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`CXX_EXTENSIONS`
+property on all targets. See that target property for additional
+information.
diff --git a/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst
new file mode 100644
index 0000000..6d34a2b
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_KNOWN_FEATURES.rst
@@ -0,0 +1,238 @@
+CMAKE_CXX_KNOWN_FEATURES
+------------------------
+
+List of C++ features known to this version of CMake.
+
+The features listed in this variable may be known to be available to the
+C++ compiler. If the feature is available with the C++ compiler, it will
+be listed in the :variable:`CMAKE_CXX_COMPILE_FEATURES` variable.
+
+The features listed here may be used with the :command:`target_compile_features`
+command.
+
+The features known to this version of CMake are:
+
+``cxx_alias_templates``
+ Template aliases, as defined in N2258_.
+
+ .. _N2258: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2258.pdf
+
+``cxx_alignas``
+ Alignment control ``alignas``, as defined in N2341_.
+
+ .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
+
+``cxx_alignof``
+ Alignment control ``alignof``, as defined in N2341_.
+
+ .. _N2341: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2341.pdf
+
+``cxx_attributes``
+ Generic attributes, as defined in N2761_.
+
+ .. _N2761: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf
+
+``cxx_auto_type``
+ Automatic type deduction, as defined in N1984_.
+
+ .. _N1984: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1984.pdf
+
+``cxx_constexpr``
+ Constant expressions, as defined in N2235_.
+
+ .. _N2235: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2235.pdf
+
+``cxx_decltype_incomplete_return_types``
+ Decltype on incomplete return types, as defined in N3276_.
+
+ .. _N3276 : http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3276.pdf
+
+``cxx_decltype``
+ Decltype, as defined in N2343_.
+
+ .. _N2343: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2343.pdf
+
+``cxx_default_function_template_args``
+ Default template arguments for function templates, as defined in DR226_
+
+ .. _DR226: http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#226
+
+``cxx_defaulted_functions``
+ Defaulted functions, as defined in N2346_.
+
+ .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
+
+``cxx_defaulted_move_initializers``
+ Defaulted move initializers, as defined in N3053_.
+
+ .. _N3053: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3053.html
+
+``cxx_delegating_constructors``
+ Delegating constructors, as defined in N1986_.
+
+ .. _N1986: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1986.pdf
+
+``cxx_deleted_functions``
+ Deleted functions, as defined in N2346_.
+
+ .. _N2346: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm
+
+``cxx_enum_forward_declarations``
+ Enum forward declarations, as defined in N2764_.
+
+ .. _N2764: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2764.pdf
+
+``cxx_explicit_conversions``
+ Explicit conversion operators, as defined in N2437_.
+
+ .. _N2437: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2437.pdf
+
+``cxx_extended_friend_declarations``
+ Extended friend declarations, as defined in N1791_.
+
+ .. _N1791: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1791.pdf
+
+``cxx_extern_templates``
+ Extern templates, as defined in N1987_.
+
+ .. _N1987: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1987.htm
+
+``cxx_final``
+ Override control ``final`` keyword, as defined in N2928_.
+
+ .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
+
+``cxx_func_identifier``
+ Predefined ``__func__`` identifier, as defined in N2340_.
+
+ .. _N2340: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2340.htm
+
+``cxx_generalized_initializers``
+ Initializer lists, as defined in N2672_.
+
+ .. _N2672: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2672.htm
+
+``cxx_inheriting_constructors``
+ Inheriting constructors, as defined in N2540_.
+
+ .. _N2540: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2540.htm
+
+``cxx_inline_namespaces``
+ Inline namespaces, as defined in N2535_.
+
+ .. _N2535: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2535.htm
+
+``cxx_lambdas``
+ Lambda functions, as defined in N2927_.
+
+ .. _N2927: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2927.pdf
+
+``cxx_local_type_template_args``
+ Local and unnamed types as template arguments, as defined in N2657_.
+
+ .. _N2657: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2657.htm
+
+``cxx_long_long_type``
+ ``long long`` type, as defined in N1811_.
+
+ .. _N1811: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1811.pdf
+
+``cxx_noexcept``
+ Exception specifications, as defined in N3050_.
+
+ .. _N3050: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2010/n3050.html
+
+``cxx_nonstatic_member_init``
+ Non-static data member initialization, as defined in N2756.
+
+ .. _N2756: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2756.htm
+
+``cxx_nullptr``
+ Null pointer, as defined in N2431_.
+
+ .. _N2431: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2431.pdf
+
+``cxx_override``
+ Override control ``override`` keyword, as defined in N2928_.
+
+ .. _N2928: http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2009/n2928.htm
+
+``cxx_range_for``
+ Range-based for, as defined in N2930_.
+
+ .. _N2930: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2009/n2930.html
+
+``cxx_raw_string_literals``
+ Raw string literals, as defined in N2442_.
+
+ .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
+
+``cxx_reference_qualified_functions``
+ Reference qualified functions, as defined in N2439_.
+
+ .. _N2439: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2439.htm
+
+``cxx_right_angle_brackets``
+ Right angle bracket parsing, as defined in N1757_.
+
+ .. _N1757: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1757.html
+
+``cxx_rvalue_references``
+ R-value references, as defined in N2118_.
+
+ .. _N2118: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2118.html
+
+``cxx_sizeof_member``
+ Size of non-static data members, as defined in N2253_.
+
+ .. _N2253: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2253.html
+
+``cxx_static_assert``
+ Static assert, as defined in N1720_.
+
+ .. _N1720: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1720.html
+
+``cxx_strong_enums``
+ Strongly typed enums, as defined in N2347_.
+
+ .. _N2347: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2347.pdf
+
+``cxx_thread_local``
+ Thread-local variables, as defined in N2659_.
+
+ .. _N2659: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2659.htm
+
+``cxx_trailing_return_types``
+ Automatic function return type, as defined in N2541_.
+
+ .. _N2541: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2541.htm
+
+``cxx_unicode_literals``
+ Unicode string literals, as defined in N2442_.
+
+ .. _N2442: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2442.htm
+
+``cxx_uniform_initialization``
+ Uniform intialization, as defined in N2640_.
+
+ .. _N2640: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2640.pdf
+
+``cxx_unrestricted_unions``
+ Unrestricted unions, as defined in N2544_.
+
+ .. _N2544: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2544.pdf
+
+``cxx_user_literals``
+ User-defined literals, as defined in N2765_.
+
+ .. _N2765: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2765.pdf
+
+``cxx_variadic_macros``
+ Variadic macros, as defined in N1653_.
+
+ .. _N1653: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2004/n1653.htm
+
+``cxx_variadic_templates``
+ Variadic templates, as defined in N2242_.
+
+ .. _N2242: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2242.pdf
diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst
new file mode 100644
index 0000000..5fd4138
--- /dev/null
+++ b/Help/variable/CMAKE_CXX_STANDARD.rst
@@ -0,0 +1,8 @@
+CMAKE_CXX_STANDARD
+------------------
+
+Default value for ``CXX_STANDARD`` property of targets.
+
+This variable is used to initialize the :prop_tgt:`CXX_STANDARD`
+property on all targets. See that target property for additional
+information.
diff --git a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
index 11aed0c..e200b86 100644
--- a/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
+++ b/Help/variable/CMAKE_DEBUG_TARGET_PROPERTIES.rst
@@ -6,7 +6,8 @@ Enables tracing output for target properties.
This variable can be populated with a list of properties to generate
debug output for when evaluating target properties. Currently it can
only be used when evaluating the :prop_tgt:`INCLUDE_DIRECTORIES`,
-:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`, :prop_tgt:`AUTOUIC_OPTIONS`,
+:prop_tgt:`COMPILE_DEFINITIONS`, :prop_tgt:`COMPILE_OPTIONS`,
+:prop_tgt:`AUTOUIC_OPTIONS`, :prop_tgt:`SOURCES`, :prop_tgt:`COMPILE_FEATURES`,
:prop_tgt:`POSITION_INDEPENDENT_CODE` target properties and any other property
listed in :prop_tgt:`COMPATIBLE_INTERFACE_STRING` and other ``COMPATIBLE_INTERFACE_``
properties. It outputs an origin for each entry in the target property.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM.rst b/Help/variable/CMAKE_HOST_SYSTEM.rst
index 4366ee3..c2a8f1a 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM.rst
@@ -1,7 +1,10 @@
CMAKE_HOST_SYSTEM
-----------------
-Name of system cmake is being run on.
+Composit Name of OS CMake is being run on.
-The same as CMAKE_SYSTEM but for the host system instead of the target
-system when cross compiling.
+This variable is the composite of :variable:`CMAKE_HOST_SYSTEM_NAME` and
+:variable:`CMAKE_HOST_SYSTEM_VERSION`, e.g.
+``${CMAKE_HOST_SYSTEM_NAME}-${CMAKE_HOST_SYSTEM_VERSION}``. If
+:variable:`CMAKE_HOST_SYSTEM_VERSION` is not set, then this variable is
+the same as :variable:`CMAKE_HOST_SYSTEM_NAME`.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
index 718208a..a221de9 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_NAME.rst
@@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_NAME
Name of the OS CMake is running on.
-The same as CMAKE_SYSTEM_NAME but for the host system instead of the
-target system when cross compiling.
+On systems that have the uname command, this variable is set to the
+output of uname -s. ``Linux``, ``Windows``, and ``Darwin`` for Mac OS X
+are the values found on the big three operating systems.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst
index 2700b66..790565a 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_PROCESSOR.rst
@@ -3,5 +3,6 @@ CMAKE_HOST_SYSTEM_PROCESSOR
The name of the CPU CMake is running on.
-The same as CMAKE_SYSTEM_PROCESSOR but for the host system instead of
-the target system when cross compiling.
+On systems that support uname, this variable is set to the output of
+uname -p, on windows it is set to the value of the environment variable
+``PROCESSOR_ARCHITECTURE``.
diff --git a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst
index a8451e8..e7e0052 100644
--- a/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst
+++ b/Help/variable/CMAKE_HOST_SYSTEM_VERSION.rst
@@ -1,7 +1,8 @@
CMAKE_HOST_SYSTEM_VERSION
-------------------------
-OS version CMake is running on.
+The OS version CMake is running on.
-The same as CMAKE_SYSTEM_VERSION but for the host system instead of
-the target system when cross compiling.
+A numeric version string for the system. On systems that support
+uname, this variable is set to the output of uname -r. On other
+systems this is set to major-minor version numbers.
diff --git a/Help/variable/CMAKE_SYSTEM.rst b/Help/variable/CMAKE_SYSTEM.rst
index 283d0be..23f5980 100644
--- a/Help/variable/CMAKE_SYSTEM.rst
+++ b/Help/variable/CMAKE_SYSTEM.rst
@@ -1,9 +1,10 @@
CMAKE_SYSTEM
------------
-Name of system cmake is compiling for.
+Composit Name of OS CMake is compiling for.
-This variable is the composite of CMAKE_SYSTEM_NAME and
-CMAKE_SYSTEM_VERSION, like this
-${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}. If CMAKE_SYSTEM_VERSION
-is not set, then CMAKE_SYSTEM is the same as CMAKE_SYSTEM_NAME.
+This variable is the composite of :variable:`CMAKE_SYSTEM_NAME` and
+:variable:`CMAKE_SYSTEM_VERSION`, e.g.
+``${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_VERSION}``. If
+:variable:`CMAKE_SYSTEM_VERSION` is not set, then this variable is
+the same as :variable:`CMAKE_SYSTEM_NAME`.
diff --git a/Help/variable/CMAKE_SYSTEM_NAME.rst b/Help/variable/CMAKE_SYSTEM_NAME.rst
index 9871dd9..189dc18 100644
--- a/Help/variable/CMAKE_SYSTEM_NAME.rst
+++ b/Help/variable/CMAKE_SYSTEM_NAME.rst
@@ -3,7 +3,6 @@ CMAKE_SYSTEM_NAME
Name of the OS CMake is building for.
-This is the name of the operating system on which CMake is targeting.
-On systems that have the uname command, this variable is set to the
-output of uname -s. Linux, Windows, and Darwin for Mac OS X are the
-values found on the big three operating systems.
+This is the name of the OS on which CMake is targeting. This variable
+is the same as :variable:`CMAKE_HOST_SYSTEM_NAME` if you build for the
+host system instead of the target system when cross compiling.
diff --git a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
index 1655ada..8ad89f1 100644
--- a/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
+++ b/Help/variable/CMAKE_SYSTEM_PROCESSOR.rst
@@ -3,6 +3,6 @@ CMAKE_SYSTEM_PROCESSOR
The name of the CPU CMake is building for.
-On systems that support uname, this variable is set to the output of
-uname -p, on windows it is set to the value of the environment
-variable PROCESSOR_ARCHITECTURE
+This variable is the same as :variable:`CMAKE_HOST_SYSTEM_PROCESSOR` if
+you build for the host system instead of the target system when
+cross compiling.
diff --git a/Help/variable/CMAKE_SYSTEM_VERSION.rst b/Help/variable/CMAKE_SYSTEM_VERSION.rst
index 61bb40e..33510bb 100644
--- a/Help/variable/CMAKE_SYSTEM_VERSION.rst
+++ b/Help/variable/CMAKE_SYSTEM_VERSION.rst
@@ -1,8 +1,8 @@
CMAKE_SYSTEM_VERSION
--------------------
-OS version CMake is building for.
+The OS version CMake is building for.
-A numeric version string for the system, on systems that support
-uname, this variable is set to the output of uname -r. On other
-systems this is set to major-minor version numbers.
+This variable is the same as :variable:`CMAKE_HOST_SYSTEM_VERSION` if
+you build for the host system instead of the target system when
+cross compiling.
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in
index b6f9791..602b065 100644
--- a/Modules/AutogenInfo.cmake.in
+++ b/Modules/AutogenInfo.cmake.in
@@ -16,6 +16,7 @@ set(AM_CMAKE_CURRENT_SOURCE_DIR "@CMAKE_CURRENT_SOURCE_DIR@/")
set(AM_CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@/")
set(AM_QT_VERSION_MAJOR "@_target_qt_version@")
set(AM_TARGET_NAME @_moc_target_name@)
+set(AM_ORIGIN_TARGET_NAME @_origin_target_name@)
set(AM_RELAXED_MODE "@_moc_relaxed_mode@")
set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
set(AM_UIC_OPTIONS_FILES @_qt_uic_options_files@)
diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in
index 63f3f03..9fd0136 100644
--- a/Modules/BasicConfigVersion-ExactVersion.cmake.in
+++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in
@@ -11,13 +11,13 @@
set(PACKAGE_VERSION "@CVF_VERSION@")
-if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version
+if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
set(CVF_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
else()
set(CVF_VERSION_NO_TWEAK "@CVF_VERSION@")
endif()
-if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\..*") # strip the tweak version
+if("${PACKAGE_FIND_VERSION}" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version
set(REQUESTED_VERSION_NO_TWEAK "${CMAKE_MATCH_1}")
else()
set(REQUESTED_VERSION_NO_TWEAK "${PACKAGE_FIND_VERSION}")
diff --git a/Modules/BundleUtilities.cmake b/Modules/BundleUtilities.cmake
index b896de2..0c733fa 100644
--- a/Modules/BundleUtilities.cmake
+++ b/Modules/BundleUtilities.cmake
@@ -235,8 +235,8 @@ function(get_bundle_main_executable bundle result_var)
#
set(eol_char "E")
file(READ "${bundle}/Contents/Info.plist" info_plist)
- string(REGEX REPLACE ";" "\\\\;" info_plist "${info_plist}")
- string(REGEX REPLACE "\n" "${eol_char};" info_plist "${info_plist}")
+ string(REPLACE ";" "\\;" info_plist "${info_plist}")
+ string(REPLACE "\n" "${eol_char};" info_plist "${info_plist}")
# Scan the lines for "<key>CFBundleExecutable</key>" - the line after that
# is the name of the main executable.
@@ -247,7 +247,7 @@ function(get_bundle_main_executable bundle result_var)
break()
endif()
- if(line MATCHES "^.*<key>CFBundleExecutable</key>.*$")
+ if(line MATCHES "<key>CFBundleExecutable</key>")
set(line_is_main_executable 1)
endif()
endforeach()
@@ -287,7 +287,7 @@ endfunction()
function(get_dotapp_dir exe dotapp_dir_var)
set(s "${exe}")
- if(s MATCHES "^.*/.*\\.app/.*$")
+ if(s MATCHES "/.*\\.app/")
# If there is a ".app" parent directory,
# ascend until we hit it:
# (typical of a Mac bundle executable)
@@ -394,7 +394,7 @@ function(get_item_key item key_var)
if(WIN32)
string(TOLOWER "${item_name}" item_name)
endif()
- string(REGEX REPLACE "\\." "_" ${key_var} "${item_name}")
+ string(REPLACE "." "_" ${key_var} "${item_name}")
set(${key_var} ${${key_var}} PARENT_SCOPE)
endfunction()
diff --git a/Modules/CMakeBackwardCompatibilityCXX.cmake b/Modules/CMakeBackwardCompatibilityCXX.cmake
index 343fdb2..f1db46e 100644
--- a/Modules/CMakeBackwardCompatibilityCXX.cmake
+++ b/Modules/CMakeBackwardCompatibilityCXX.cmake
@@ -31,15 +31,15 @@ if(NOT CMAKE_SKIP_COMPATIBILITY_TESTS)
if(NOT CMAKE_COMPILER_IS_GNUCXX)
include(TestCXXAcceptsFlag)
set(CMAKE_TRY_ANSI_CXX_FLAGS "")
- if(CMAKE_SYSTEM MATCHES "IRIX.*")
+ if(CMAKE_SYSTEM_NAME MATCHES "IRIX")
set(CMAKE_TRY_ANSI_CXX_FLAGS "-LANG:std")
endif()
- if(CMAKE_SYSTEM MATCHES "OSF.*")
+ if(CMAKE_SYSTEM_NAME MATCHES "OSF")
set(CMAKE_TRY_ANSI_CXX_FLAGS "-std strict_ansi -nopure_cname")
endif()
# if CMAKE_TRY_ANSI_CXX_FLAGS has something in it, see
# if the compiler accepts it
- if( CMAKE_TRY_ANSI_CXX_FLAGS MATCHES ".+")
+ if(NOT CMAKE_TRY_ANSI_CXX_FLAGS STREQUAL "")
CHECK_CXX_ACCEPTS_FLAG(${CMAKE_TRY_ANSI_CXX_FLAGS} CMAKE_CXX_ACCEPTS_FLAGS)
# if the compiler liked the flag then set CMAKE_ANSI_CXXFLAGS
# to the flag
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index 804cce2..694f8b8 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -26,7 +26,7 @@ if(CMAKE_COMPILER_IS_MINGW)
set(MINGW 1)
endif()
set(CMAKE_C_COMPILER_ID_RUN 1)
-set(CMAKE_C_SOURCE_FILE_EXTENSIONS c)
+set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m)
set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_C_LINKER_PREFERENCE 10)
diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in
index 561ccf2..16e19cd 100644
--- a/Modules/CMakeCCompilerId.c.in
+++ b/Modules/CMakeCCompilerId.c.in
@@ -68,10 +68,19 @@
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
#elif defined(__WATCOMC__)
-# define COMPILER_ID "Watcom"
- /* __WATCOMC__ = VVRR */
-# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
-# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
+# if __WATCOMC__ < 1200
+# define COMPILER_ID "Watcom"
+ /* __WATCOMC__ = VVRP */
+# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# else
+# define COMPILER_ID "OpenWatcom"
+ /* __WATCOMC__ = VVRP + 1100 */
+# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# endif
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
#elif defined(__SUNPRO_C)
# define COMPILER_ID "SunPro"
diff --git a/Modules/CMakeCInformation.cmake b/Modules/CMakeCInformation.cmake
index e0cce45..332b26e 100644
--- a/Modules/CMakeCInformation.cmake
+++ b/Modules/CMakeCInformation.cmake
@@ -175,10 +175,10 @@ endif()
# Create a static archive incrementally for large object file counts.
# If CMAKE_C_CREATE_STATIC_LIBRARY is set it will override these.
if(NOT DEFINED CMAKE_C_ARCHIVE_CREATE)
- set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_C_ARCHIVE_APPEND)
- set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_C_ARCHIVE_FINISH)
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index 35aa6c4..fdee336 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -2,6 +2,9 @@ set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@")
set(CMAKE_CXX_COMPILER_ARG1 "@CMAKE_CXX_COMPILER_ARG1@")
set(CMAKE_CXX_COMPILER_ID "@CMAKE_CXX_COMPILER_ID@")
set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@")
+set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@")
+set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@")
+
set(CMAKE_CXX_PLATFORM_ID "@CMAKE_CXX_PLATFORM_ID@")
set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
@@ -27,7 +30,7 @@ if(CMAKE_COMPILER_IS_MINGW)
endif()
set(CMAKE_CXX_COMPILER_ID_RUN 1)
set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC)
-set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;m;mm;CPP)
+set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP)
set(CMAKE_CXX_LINKER_PREFERENCE 30)
set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1)
diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in
index 6c602d4..d81df77 100644
--- a/Modules/CMakeCXXCompilerId.cpp.in
+++ b/Modules/CMakeCXXCompilerId.cpp.in
@@ -73,10 +73,19 @@
# define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF)
#elif defined(__WATCOMC__)
-# define COMPILER_ID "Watcom"
- /* __WATCOMC__ = VVRR */
-# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
-# define COMPILER_VERSION_MINOR DEC(__WATCOMC__ % 100)
+# if __WATCOMC__ < 1200
+# define COMPILER_ID "Watcom"
+ /* __WATCOMC__ = VVRP */
+# define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100)
+# else
+# define COMPILER_ID "OpenWatcom"
+ /* __WATCOMC__ = VVRP + 1100 */
+# define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100)
+# endif
+# define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10)
+# if (__WATCOMC__ % 10) > 0
+# define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10)
+# endif
#elif defined(__SUNPRO_CC)
# define COMPILER_ID "SunPro"
diff --git a/Modules/CMakeCXXInformation.cmake b/Modules/CMakeCXXInformation.cmake
index 3010a48..72b2857 100644
--- a/Modules/CMakeCXXInformation.cmake
+++ b/Modules/CMakeCXXInformation.cmake
@@ -266,10 +266,10 @@ endif()
# Create a static archive incrementally for large object file counts.
# If CMAKE_CXX_CREATE_STATIC_LIBRARY is set it will override these.
if(NOT DEFINED CMAKE_CXX_ARCHIVE_CREATE)
- set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_CXX_ARCHIVE_APPEND)
- set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_CXX_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_CXX_ARCHIVE_FINISH)
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
diff --git a/Modules/CMakeCommonLanguageInclude.cmake b/Modules/CMakeCommonLanguageInclude.cmake
index 38a6d35..fa025a8 100644
--- a/Modules/CMakeCommonLanguageInclude.cmake
+++ b/Modules/CMakeCommonLanguageInclude.cmake
@@ -16,9 +16,11 @@
# cache values that can be initialized in the platform-compiler.cmake file
# it may be included by more than one language.
-set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
- CACHE STRING "Flags used by the linker.")
-
+if(NOT "x$ENV{LDFLAGS}" STREQUAL "x")
+ set (CMAKE_EXE_LINKER_FLAGS_INIT "${CMAKE_EXE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}")
+ set (CMAKE_SHARED_LINKER_FLAGS_INIT "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}")
+ set (CMAKE_MODULE_LINKER_FLAGS_INIT "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}")
+endif()
if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
# default build type is none
@@ -82,12 +84,17 @@ if(NOT CMAKE_NOT_USING_CONFIG_FLAGS)
${CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO_INIT} CACHE STRING
"Flags used by the linker during Release with Debug Info builds.")
endif()
+
+# executable linker flags
+set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS_INIT}"
+ CACHE STRING "Flags used by the linker.")
+
# shared linker flags
-set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
+set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS_INIT}"
CACHE STRING "Flags used by the linker during the creation of dll's.")
# module linker flags
-set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT} $ENV{LDFLAGS}"
+set (CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS_INIT}"
CACHE STRING "Flags used by the linker during the creation of modules.")
# static linker flags
@@ -124,4 +131,3 @@ CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
CMAKE_STATIC_LINKER_FLAGS_RELEASE
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
)
-
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index 1d9617f..25af3e3 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -18,7 +18,7 @@ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER)
# prefer the environment variable ASM
- if($ENV{ASM${ASM_DIALECT}} MATCHES ".+")
+ if(NOT $ENV{ASM${ASM_DIALECT}} STREQUAL "")
set(CMAKE_ASM${ASM_DIALECT}_COMPILER_INIT "$ENV{ASM${ASM_DIALECT}}")
endif()
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index aa4cdc9..3847b75 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -48,7 +48,7 @@ else()
set(CMAKE_C_COMPILER_INIT NOTFOUND)
# prefer the environment variable CC
- if($ENV{CC} MATCHES ".+")
+ if(NOT $ENV{CC} STREQUAL "")
get_filename_component(CMAKE_C_COMPILER_INIT $ENV{CC} PROGRAM PROGRAM_ARGS CMAKE_C_FLAGS_ENV_INIT)
if(CMAKE_C_FLAGS_ENV_INIT)
set(CMAKE_C_COMPILER_ARG1 "${CMAKE_C_FLAGS_ENV_INIT}" CACHE STRING "First argument to C compiler")
@@ -138,7 +138,7 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
elseif("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_C_COMPILER_TARGET}-)
elseif(COMPILER_BASENAME MATCHES "qcc(\\.exe)?$")
- if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$")
+ if(CMAKE_C_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?")
set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
endif()
endif ()
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index ef8445e..e6a9d9a 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -47,7 +47,7 @@ else()
set(CMAKE_CXX_COMPILER_INIT NOTFOUND)
# prefer the environment variable CXX
- if($ENV{CXX} MATCHES ".+")
+ if(NOT $ENV{CXX} STREQUAL "")
get_filename_component(CMAKE_CXX_COMPILER_INIT $ENV{CXX} PROGRAM PROGRAM_ARGS CMAKE_CXX_FLAGS_ENV_INIT)
if(CMAKE_CXX_FLAGS_ENV_INIT)
set(CMAKE_CXX_COMPILER_ARG1 "${CMAKE_CXX_FLAGS_ENV_INIT}" CACHE STRING "First argument to CXX compiler")
@@ -135,7 +135,7 @@ if (CMAKE_CROSSCOMPILING AND NOT _CMAKE_TOOLCHAIN_PREFIX)
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
set(_CMAKE_TOOLCHAIN_PREFIX ${CMAKE_CXX_COMPILER_TARGET}-)
elseif(COMPILER_BASENAME MATCHES "QCC(\\.exe)?$")
- if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?.*$")
+ if(CMAKE_CXX_COMPILER_TARGET MATCHES "gcc_nto([^_le]+)(le)?")
set(_CMAKE_TOOLCHAIN_PREFIX nto${CMAKE_MATCH_1}-)
endif()
endif ()
diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake
new file mode 100644
index 0000000..40aa9d6
--- /dev/null
+++ b/Modules/CMakeDetermineCompileFeatures.cmake
@@ -0,0 +1,43 @@
+
+#=============================================================================
+# Copyright 2013 Stephen Kelly <steveire@gmail.com>
+#
+# 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.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+function(cmake_determine_compile_features lang)
+
+ if(lang STREQUAL CXX AND COMMAND cmake_record_cxx_compile_features)
+ message(STATUS "Detecting ${lang} compile features")
+
+ set(CMAKE_CXX11_COMPILE_FEATURES)
+
+ include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake")
+
+ cmake_record_cxx_compile_features()
+
+ if(NOT _result EQUAL 0)
+ message(STATUS "Detecting ${lang} compile features - failed")
+ return()
+ endif()
+
+ if(NOT CMAKE_CXX_COMPILE_FEATURES)
+ set(CMAKE_CXX_COMPILE_FEATURES
+ ${CMAKE_CXX11_COMPILE_FEATURES}
+ )
+ endif()
+
+ set(CMAKE_CXX_COMPILE_FEATURES ${CMAKE_CXX_COMPILE_FEATURES} PARENT_SCOPE)
+ set(CMAKE_CXX11_COMPILE_FEATURES ${CMAKE_CXX11_COMPILE_FEATURES} PARENT_SCOPE)
+
+ message(STATUS "Detecting ${lang} compile features - done")
+ endif()
+
+endfunction()
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 5d35ce3..8595b97 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -52,11 +52,11 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src)
"Detecting ${lang} compiler ABI info compiled with the following output:\n${OUTPUT}\n\n")
file(STRINGS "${BIN}" ABI_STRINGS LIMIT_COUNT 2 REGEX "INFO:[^[]*\\[")
foreach(info ${ABI_STRINGS})
- if("${info}" MATCHES ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*")
- string(REGEX REPLACE ".*INFO:sizeof_dptr\\[0*([^]]*)\\].*" "\\1" ABI_SIZEOF_DPTR "${info}")
+ if("${info}" MATCHES "INFO:sizeof_dptr\\[0*([^]]*)\\]")
+ set(ABI_SIZEOF_DPTR "${CMAKE_MATCH_1}")
endif()
- if("${info}" MATCHES ".*INFO:abi\\[([^]]*)\\].*")
- string(REGEX REPLACE ".*INFO:abi\\[([^]]*)\\].*" "\\1" ABI_NAME "${info}")
+ if("${info}" MATCHES "INFO:abi\\[([^]]*)\\]")
+ set(ABI_NAME "${CMAKE_MATCH_1}")
endif()
endforeach()
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 9a256d5..17f27b3 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -27,7 +27,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src)
else()
set(CMAKE_${lang}_COMPILER_ID_FLAGS $ENV{${flagvar}})
endif()
- string(REGEX REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}")
+ string(REPLACE " " ";" CMAKE_${lang}_COMPILER_ID_FLAGS_LIST "${CMAKE_${lang}_COMPILER_ID_FLAGS}")
# Compute the directory in which to run the test.
set(CMAKE_${lang}_COMPILER_ID_DIR ${CMAKE_PLATFORM_INFO_DIR}/CompilerId${lang})
@@ -367,35 +367,30 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file)
CMAKE_${lang}_COMPILER_ID_STRINGS LIMIT_COUNT 6 REGEX "INFO:")
set(COMPILER_ID_TWICE)
foreach(info ${CMAKE_${lang}_COMPILER_ID_STRINGS})
- if("${info}" MATCHES ".*INFO:compiler\\[([^]\"]*)\\].*")
+ if("${info}" MATCHES "INFO:compiler\\[([^]\"]*)\\]")
if(COMPILER_ID)
set(COMPILER_ID_TWICE 1)
endif()
- string(REGEX REPLACE ".*INFO:compiler\\[([^]]*)\\].*" "\\1"
- COMPILER_ID "${info}")
+ set(COMPILER_ID "${CMAKE_MATCH_1}")
endif()
- if("${info}" MATCHES ".*INFO:platform\\[([^]\"]*)\\].*")
- string(REGEX REPLACE ".*INFO:platform\\[([^]]*)\\].*" "\\1"
- PLATFORM_ID "${info}")
+ if("${info}" MATCHES "INFO:platform\\[([^]\"]*)\\]")
+ set(PLATFORM_ID "${CMAKE_MATCH_1}")
endif()
- if("${info}" MATCHES ".*INFO:arch\\[([^]\"]*)\\].*")
- string(REGEX REPLACE ".*INFO:arch\\[([^]]*)\\].*" "\\1"
- ARCHITECTURE_ID "${info}")
+ if("${info}" MATCHES "INFO:arch\\[([^]\"]*)\\]")
+ set(ARCHITECTURE_ID "${CMAKE_MATCH_1}")
endif()
- if("${info}" MATCHES ".*INFO:compiler_version\\[([^]\"]*)\\].*")
- string(REGEX REPLACE ".*INFO:compiler_version\\[([^]]*)\\].*" "\\1" COMPILER_VERSION "${info}")
- string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${COMPILER_VERSION}")
+ if("${info}" MATCHES "INFO:compiler_version\\[([^]\"]*)\\]")
+ string(REGEX REPLACE "^0+([0-9])" "\\1" COMPILER_VERSION "${CMAKE_MATCH_1}")
string(REGEX REPLACE "\\.0+([0-9])" ".\\1" COMPILER_VERSION "${COMPILER_VERSION}")
endif()
- if("${info}" MATCHES ".*INFO:simulate\\[([^]\"]*)\\].*")
+ if("${info}" MATCHES "INFO:simulate\\[([^]\"]*)\\]")
set(SIMULATE_ID "${CMAKE_MATCH_1}")
endif()
- if("${info}" MATCHES ".*INFO:simulate_version\\[([^]\"]*)\\].*")
- set(SIMULATE_VERSION "${CMAKE_MATCH_1}")
- string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
+ if("${info}" MATCHES "INFO:simulate_version\\[([^]\"]*)\\]")
+ string(REGEX REPLACE "^0+([0-9])" "\\1" SIMULATE_VERSION "${CMAKE_MATCH_1}")
string(REGEX REPLACE "\\.0+([0-9])" ".\\1" SIMULATE_VERSION "${SIMULATE_VERSION}")
endif()
- if("${info}" MATCHES ".*INFO:qnxnto")
+ if("${info}" MATCHES "INFO:qnxnto")
set(COMPILER_QNXNTO 1)
endif()
endforeach()
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index d38bf25..96df6a2 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -32,7 +32,7 @@ elseif("${CMAKE_GENERATOR}" MATCHES "Xcode")
else()
if(NOT CMAKE_Fortran_COMPILER)
# prefer the environment variable CC
- if($ENV{FC} MATCHES ".+")
+ if(NOT $ENV{FC} STREQUAL "")
get_filename_component(CMAKE_Fortran_COMPILER_INIT $ENV{FC} PROGRAM PROGRAM_ARGS CMAKE_Fortran_FLAGS_ENV_INIT)
if(CMAKE_Fortran_FLAGS_ENV_INIT)
set(CMAKE_Fortran_COMPILER_ARG1 "${CMAKE_Fortran_FLAGS_ENV_INIT}" CACHE STRING "First argument to Fortran compiler")
@@ -130,7 +130,7 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
ARGS ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "\"${CMAKE_ROOT}/Modules/CMakeTestGNU.c\""
OUTPUT_VARIABLE CMAKE_COMPILER_OUTPUT RETURN_VALUE CMAKE_COMPILER_RETURN)
if(NOT CMAKE_COMPILER_RETURN)
- if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_GNU.*" )
+ if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_GNU")
set(CMAKE_Fortran_COMPILER_ID "GNU")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Fortran compiler is GNU succeeded with "
@@ -141,10 +141,10 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
"the following output:\n${CMAKE_COMPILER_OUTPUT}\n\n")
endif()
if(NOT CMAKE_Fortran_PLATFORM_ID)
- if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_MINGW.*" )
+ if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_MINGW")
set(CMAKE_Fortran_PLATFORM_ID "MinGW")
endif()
- if("${CMAKE_COMPILER_OUTPUT}" MATCHES ".*THIS_IS_CYGWIN.*" )
+ if("${CMAKE_COMPILER_OUTPUT}" MATCHES "THIS_IS_CYGWIN")
set(CMAKE_Fortran_PLATFORM_ID "Cygwin")
endif()
endif()
diff --git a/Modules/CMakeDetermineJavaCompiler.cmake b/Modules/CMakeDetermineJavaCompiler.cmake
index 7ae7856..f657801 100644
--- a/Modules/CMakeDetermineJavaCompiler.cmake
+++ b/Modules/CMakeDetermineJavaCompiler.cmake
@@ -18,7 +18,7 @@
if(NOT CMAKE_Java_COMPILER)
# prefer the environment variable CC
- if($ENV{JAVA_COMPILER} MATCHES ".+")
+ if(NOT $ENV{JAVA_COMPILER} STREQUAL "")
get_filename_component(CMAKE_Java_COMPILER_INIT $ENV{JAVA_COMPILER} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
if(CMAKE_Java_FLAGS_ENV_INIT)
set(CMAKE_Java_COMPILER_ARG1 "${CMAKE_Java_FLAGS_ENV_INIT}" CACHE STRING "First argument to Java compiler")
@@ -28,14 +28,14 @@ if(NOT CMAKE_Java_COMPILER)
endif()
endif()
- if($ENV{JAVA_RUNTIME} MATCHES ".+")
+ if(NOT $ENV{JAVA_RUNTIME} STREQUAL "")
get_filename_component(CMAKE_Java_RUNTIME_INIT $ENV{JAVA_RUNTIME} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
if(NOT EXISTS ${CMAKE_Java_RUNTIME_INIT})
message(SEND_ERROR "Could not find compiler set in environment variable JAVA_RUNTIME:\n$ENV{JAVA_RUNTIME}.")
endif()
endif()
- if($ENV{JAVA_ARCHIVE} MATCHES ".+")
+ if(NOT $ENV{JAVA_ARCHIVE} STREQUAL "")
get_filename_component(CMAKE_Java_ARCHIVE_INIT $ENV{JAVA_ARCHIVE} PROGRAM PROGRAM_ARGS CMAKE_Java_FLAGS_ENV_INIT)
if(NOT EXISTS ${CMAKE_Java_ARCHIVE_INIT})
message(SEND_ERROR "Could not find compiler set in environment variable JAVA_ARCHIVE:\n$ENV{JAVA_ARCHIVE}.")
diff --git a/Modules/CMakeDetermineRCCompiler.cmake b/Modules/CMakeDetermineRCCompiler.cmake
index f23846e..e5414eb 100644
--- a/Modules/CMakeDetermineRCCompiler.cmake
+++ b/Modules/CMakeDetermineRCCompiler.cmake
@@ -20,7 +20,7 @@
# as a default compiler
if(NOT CMAKE_RC_COMPILER)
# prefer the environment variable RC
- if($ENV{RC} MATCHES ".+")
+ if(NOT $ENV{RC} STREQUAL "")
get_filename_component(CMAKE_RC_COMPILER_INIT $ENV{RC} PROGRAM PROGRAM_ARGS CMAKE_RC_FLAGS_ENV_INIT)
if(CMAKE_RC_FLAGS_ENV_INIT)
set(CMAKE_RC_COMPILER_ARG1 "${CMAKE_RC_FLAGS_ENV_INIT}" CACHE STRING "First argument to RC compiler")
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index f1bad99..1c0941a 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -72,8 +72,8 @@ if(CMAKE_HOST_UNIX)
endif()
set(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
# processor may have double quote in the name, and that needs to be removed
- string(REGEX REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
- string(REGEX REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
+ string(REPLACE "\"" "" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
+ string(REPLACE "/" "_" CMAKE_HOST_SYSTEM_PROCESSOR "${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()
else()
if(CMAKE_HOST_WIN32)
diff --git a/Modules/CMakeDetermineVSServicePack.cmake b/Modules/CMakeDetermineVSServicePack.cmake
index 2854387..6886084 100644
--- a/Modules/CMakeDetermineVSServicePack.cmake
+++ b/Modules/CMakeDetermineVSServicePack.cmake
@@ -43,6 +43,13 @@
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
+if(NOT CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.8)
+ message(DEPRECATION
+ "This module is deprecated and should not be used. "
+ "Use the CMAKE_<LANG>_COMPILER_VERSION variable instead."
+ )
+endif()
+
# [INTERNAL]
# Please do not call this function directly
function(_DetermineVSServicePackFromCompiler _OUT_VAR _cl_version)
diff --git a/Modules/CMakeExportBuildSettings.cmake b/Modules/CMakeExportBuildSettings.cmake
index 90a7a89..a8dd8c2 100644
--- a/Modules/CMakeExportBuildSettings.cmake
+++ b/Modules/CMakeExportBuildSettings.cmake
@@ -27,7 +27,7 @@ endif()
# loaded by another project using CMAKE_IMPORT_BUILD_SETTINGS. Now it
# creates a file that refuses to load (with comment explaining why).
macro(CMAKE_EXPORT_BUILD_SETTINGS SETTINGS_FILE)
- if(${SETTINGS_FILE} MATCHES ".+")
+ if(NOT ${SETTINGS_FILE} STREQUAL "")
configure_file(${CMAKE_ROOT}/Modules/CMakeBuildSettings.cmake.in
${SETTINGS_FILE} @ONLY)
else()
diff --git a/Modules/CMakeFortranInformation.cmake b/Modules/CMakeFortranInformation.cmake
index 080dc68..d638207 100644
--- a/Modules/CMakeFortranInformation.cmake
+++ b/Modules/CMakeFortranInformation.cmake
@@ -194,10 +194,10 @@ endif()
# Create a static archive incrementally for large object file counts.
# If CMAKE_Fortran_CREATE_STATIC_LIBRARY is set it will override these.
if(NOT DEFINED CMAKE_Fortran_ARCHIVE_CREATE)
- set(CMAKE_Fortran_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_Fortran_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_Fortran_ARCHIVE_APPEND)
- set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_Fortran_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
endif()
if(NOT DEFINED CMAKE_Fortran_ARCHIVE_FINISH)
set(CMAKE_Fortran_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
diff --git a/Modules/CMakeImportBuildSettings.cmake b/Modules/CMakeImportBuildSettings.cmake
index 60b887a..edecc1f 100644
--- a/Modules/CMakeImportBuildSettings.cmake
+++ b/Modules/CMakeImportBuildSettings.cmake
@@ -17,8 +17,7 @@
# This macro used to load build settings from another project that
# stored settings using the CMAKE_EXPORT_BUILD_SETTINGS macro.
macro(CMAKE_IMPORT_BUILD_SETTINGS SETTINGS_FILE)
- if(${SETTINGS_FILE} MATCHES ".+")
- else()
+ if("${SETTINGS_FILE}" STREQUAL "")
message(SEND_ERROR "CMAKE_IMPORT_BUILD_SETTINGS called with no argument.")
endif()
endmacro()
diff --git a/Modules/CMakeParseImplicitLinkInfo.cmake b/Modules/CMakeParseImplicitLinkInfo.cmake
index 4724a8c..bfcf455 100644
--- a/Modules/CMakeParseImplicitLinkInfo.cmake
+++ b/Modules/CMakeParseImplicitLinkInfo.cmake
@@ -64,10 +64,9 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
string(REGEX REPLACE "^-L" "" dir "${arg}")
list(APPEND implicit_dirs_tmp ${dir})
set(log "${log} arg [${arg}] ==> dir [${dir}]\n")
- elseif("${arg}" MATCHES "^-l[^:]")
+ elseif("${arg}" MATCHES "^-l([^:].*)$")
# Unix library.
- string(REGEX REPLACE "^-l" "" lib "${arg}")
- list(APPEND implicit_libs_tmp ${lib})
+ list(APPEND implicit_libs_tmp ${CMAKE_MATCH_1})
set(log "${log} arg [${arg}] ==> lib [${lib}]\n")
elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
# Unix library full path.
@@ -97,11 +96,10 @@ function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var fwk_var log_var obj
endif()
endforeach()
break()
- elseif("${line}" MATCHES "LPATH(=| is:? )")
+ elseif("${line}" MATCHES "LPATH(=| is:? *)(.*)$")
set(log "${log} LPATH line: [${line}]\n")
# HP search path.
- string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}")
- string(REPLACE ":" ";" paths "${paths}")
+ string(REPLACE ":" ";" paths "${CMAKE_MATCH_2}")
list(APPEND implicit_dirs_tmp ${paths})
set(log "${log} dirs [${paths}]\n")
else()
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 1e41fec..bc26c07 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -74,6 +74,23 @@
#elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX)
# define PLATFORM_ID "Xenix"
+#elif defined(__WATCOMC__)
+# if defined(__LINUX__)
+# define PLATFORM_ID "Linux"
+
+# elif defined(__DOS__)
+# define PLATFORM_ID "DOS"
+
+# elif defined(__OS2__)
+# define PLATFORM_ID "OS2"
+
+# elif defined(__WINDOWS__)
+# define PLATFORM_ID "Windows3x"
+
+# else /* unknown platform */
+# define PLATFORM_ID ""
+# endif
+
#else /* unknown platform */
# define PLATFORM_ID ""
@@ -107,6 +124,17 @@
# define ARCHITECTURE_ID ""
# endif
+#elif defined(__WATCOMC__)
+# if defined(_M_I86)
+# define ARCHITECTURE_ID "I86"
+
+# elif defined(_M_IX86)
+# define ARCHITECTURE_ID "X86"
+
+# else /* unknown architecture */
+# define ARCHITECTURE_ID ""
+# endif
+
#else
# define ARCHITECTURE_ID ""
#endif
diff --git a/Modules/CMakePushCheckState.cmake b/Modules/CMakePushCheckState.cmake
index 39f0023..bf4ec0e 100644
--- a/Modules/CMakePushCheckState.cmake
+++ b/Modules/CMakePushCheckState.cmake
@@ -53,6 +53,7 @@ macro(CMAKE_RESET_CHECK_STATE)
set(CMAKE_REQUIRED_DEFINITIONS)
set(CMAKE_REQUIRED_LIBRARIES)
set(CMAKE_REQUIRED_FLAGS)
+ set(CMAKE_REQUIRED_QUIET)
endmacro()
@@ -68,6 +69,7 @@ macro(CMAKE_PUSH_CHECK_STATE)
set(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
set(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
set(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
+ set(_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_QUIET})
if (ARGC GREATER 0 AND ARGV0 STREQUAL "RESET")
cmake_reset_check_state()
@@ -84,6 +86,7 @@ macro(CMAKE_POP_CHECK_STATE)
set(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
set(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
+ set(CMAKE_REQUIRED_QUIET ${_CMAKE_REQUIRED_QUIET_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
math(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
endif()
diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake
index a06c92a..81561b2 100644
--- a/Modules/CMakeTestCXXCompiler.cmake
+++ b/Modules/CMakeTestCXXCompiler.cmake
@@ -66,6 +66,9 @@ else()
# Try to identify the ABI and configure it into CMakeCXXCompiler.cmake
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerABI.cmake)
CMAKE_DETERMINE_COMPILER_ABI(CXX ${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp)
+ # Try to identify the compiler features
+ include(${CMAKE_ROOT}/Modules/CMakeDetermineCompileFeatures.cmake)
+ CMAKE_DETERMINE_COMPILE_FEATURES(CXX)
# Re-configure to save learned information.
configure_file(
diff --git a/Modules/CPackDeb.cmake b/Modules/CPackDeb.cmake
index c79ef06..458bbed 100644
--- a/Modules/CPackDeb.cmake
+++ b/Modules/CPackDeb.cmake
@@ -67,7 +67,12 @@
# * Mandatory : YES
# * Default : 'devel'
#
-# The debian package section
+# .. variable:: CPACK_DEBIAN_COMPRESSION_TYPE
+#
+# * Mandatory : YES
+# * Default : 'gzip'
+#
+# Possible values are: lzma, xz, bzip2 and gzip.
#
# .. variable:: CPACK_DEBIAN_PACKAGE_PRIORITY
#
@@ -254,7 +259,7 @@ if(CPACK_DEBIAN_PACKAGE_SHLIBDEPS)
OUTPUT_VARIABLE CPACK_DEB_INSTALL_FILES)
# Convert to CMake list
- string(REGEX REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES})
+ string(REPLACE "\n" ";" CPACK_DEB_INSTALL_FILES ${CPACK_DEB_INSTALL_FILES})
# Only dynamically linked ELF files are included
# Extract only file name infront of ":"
@@ -390,6 +395,12 @@ if(NOT CPACK_DEBIAN_PACKAGE_PRIORITY)
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
endif()
+# Compression: (recommended)
+if(NOT CPACK_DEBIAN_COMPRESSION_TYPE)
+ set(CPACK_DEBIAN_COMPRESSION_TYPE "gzip")
+endif()
+
+
# Recommends:
# You should set: CPACK_DEBIAN_PACKAGE_RECOMMENDS
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index a13a46f..2864b21 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -384,7 +384,7 @@ if(CPACK_RPM_PACKAGE_DEBUG)
OUTPUT_VARIABLE _TMP_LSB_RELEASE_OUTPUT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- string(REGEX REPLACE "\n" ", "
+ string(REPLACE "\n" ", "
LSB_RELEASE_OUTPUT
${_TMP_LSB_RELEASE_OUTPUT})
else ()
@@ -397,7 +397,7 @@ endif()
# to shut down warning about space in buildtree
# some recent RPM version should support space in different places.
# not checked [yet].
-if(CPACK_TOPLEVEL_DIRECTORY MATCHES ".* .*")
+if(CPACK_TOPLEVEL_DIRECTORY MATCHES " ")
message(FATAL_ERROR "${RPMBUILD_EXECUTABLE} can't handle paths with spaces, use a build directory without spaces for building RPMs.")
endif()
diff --git a/Modules/CPackWIX.cmake b/Modules/CPackWIX.cmake
index 39183c6..0a47e19 100644
--- a/Modules/CPackWIX.cmake
+++ b/Modules/CPackWIX.cmake
@@ -216,9 +216,24 @@
# allow other CMake projects to find your package with
# the :command:`find_package` command.
#
+# .. variable:: CPACK_WIX_PROPERTY_<PROPERTY>
+#
+# This variable can be used to provide a value for
+# the Windows Installer property ``<PROPERTY>``
+#
+# The follwing list contains some example properties that can be used to
+# customize information under
+# "Programs and Features" (also known as "Add or Remove Programs")
+#
+# * ARPCOMMENTS - Comments
+# * ARPHELPLINK - Help and support information URL
+# * ARPURLINFOABOUT - General information URL
+# * URLUPDATEINFO - Update information URL
+# * ARPHELPTELEPHONE - Help and support telephone number
+# * ARPSIZE - Size (in kilobytes) of the application
#=============================================================================
-# Copyright 2013 Kitware, Inc.
+# Copyright 2014 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
diff --git a/Modules/CheckCSourceCompiles.cmake b/Modules/CheckCSourceCompiles.cmake
index c2f6915..8721d55 100644
--- a/Modules/CheckCSourceCompiles.cmake
+++ b/Modules/CheckCSourceCompiles.cmake
@@ -21,6 +21,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
@@ -67,7 +68,9 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
"${SOURCE}\n")
- message(STATUS "Performing Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
try_compile(${VAR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
@@ -85,13 +88,17 @@ macro(CHECK_C_SOURCE_COMPILES SOURCE VAR)
if(${VAR})
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- message(STATUS "Performing Test ${VAR} - Success")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
"${OUTPUT}\n"
"Source file was:\n${SOURCE}\n")
else()
- message(STATUS "Performing Test ${VAR} - Failed")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
diff --git a/Modules/CheckCSourceRuns.cmake b/Modules/CheckCSourceRuns.cmake
index 2e68454..a4fa57e 100644
--- a/Modules/CheckCSourceRuns.cmake
+++ b/Modules/CheckCSourceRuns.cmake
@@ -21,6 +21,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
@@ -56,7 +57,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c"
"${SOURCE}\n")
- message(STATUS "Performing Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
try_run(${VAR}_EXITCODE ${VAR}_COMPILED
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.c
@@ -73,7 +76,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
# if the return value was 0 then it worked
if("${${VAR}_EXITCODE}" EQUAL 0)
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- message(STATUS "Performing Test ${VAR} - Success")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing C SOURCE FILE Test ${VAR} succeded with the following output:\n"
"${OUTPUT}\n"
@@ -86,7 +91,9 @@ macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
endif()
- message(STATUS "Performing Test ${VAR} - Failed")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing C SOURCE FILE Test ${VAR} failed with the following output:\n"
"${OUTPUT}\n"
diff --git a/Modules/CheckCXXSourceCompiles.cmake b/Modules/CheckCXXSourceCompiles.cmake
index c7ef5ec..6ce64a1 100644
--- a/Modules/CheckCXXSourceCompiles.cmake
+++ b/Modules/CheckCXXSourceCompiles.cmake
@@ -21,6 +21,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
@@ -68,7 +69,9 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx"
"${SOURCE}\n")
- message(STATUS "Performing Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
try_compile(${VAR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
@@ -86,13 +89,17 @@ macro(CHECK_CXX_SOURCE_COMPILES SOURCE VAR)
if(${VAR})
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- message(STATUS "Performing Test ${VAR} - Success")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n"
"${OUTPUT}\n"
"Source file was:\n${SOURCE}\n")
else()
- message(STATUS "Performing Test ${VAR} - Failed")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
diff --git a/Modules/CheckCXXSourceRuns.cmake b/Modules/CheckCXXSourceRuns.cmake
index 4e3ff6c..c655863 100644
--- a/Modules/CheckCXXSourceRuns.cmake
+++ b/Modules/CheckCXXSourceRuns.cmake
@@ -21,6 +21,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
@@ -56,7 +57,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx"
"${SOURCE}\n")
- message(STATUS "Performing Test ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR}")
+ endif()
try_run(${VAR}_EXITCODE ${VAR}_COMPILED
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx
@@ -74,7 +77,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
# if the return value was 0 then it worked
if("${${VAR}_EXITCODE}" EQUAL 0)
set(${VAR} 1 CACHE INTERNAL "Test ${VAR}")
- message(STATUS "Performing Test ${VAR} - Success")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Success")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Performing C++ SOURCE FILE Test ${VAR} succeded with the following output:\n"
"${OUTPUT}\n"
@@ -87,7 +92,9 @@ macro(CHECK_CXX_SOURCE_RUNS SOURCE VAR)
set(${VAR} "" CACHE INTERNAL "Test ${VAR}")
endif()
- message(STATUS "Performing Test ${VAR} - Failed")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Performing Test ${VAR} - Failed")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Performing C++ SOURCE FILE Test ${VAR} failed with the following output:\n"
"${OUTPUT}\n"
diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake
index aa62fbf..084fbb4 100644
--- a/Modules/CheckCXXSymbolExists.cmake
+++ b/Modules/CheckCXXSymbolExists.cmake
@@ -27,6 +27,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2003-2011 Kitware, Inc.
diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake
index e232bd7..bfd1836 100644
--- a/Modules/CheckFunctionExists.cmake
+++ b/Modules/CheckFunctionExists.cmake
@@ -20,6 +20,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2002-2011 Kitware, Inc.
@@ -40,7 +41,9 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
set(MACRO_CHECK_FUNCTION_DEFINITIONS
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
- message(STATUS "Looking for ${FUNCTION}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${FUNCTION}")
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -63,12 +66,16 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE)
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
set(${VARIABLE} 1 CACHE INTERNAL "Have function ${FUNCTION}")
- message(STATUS "Looking for ${FUNCTION} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${FUNCTION} - found")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the function ${FUNCTION} exists passed with the following output:\n"
"${OUTPUT}\n\n")
else()
- message(STATUS "Looking for ${FUNCTION} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${FUNCTION} - not found")
+ endif()
set(${VARIABLE} "" CACHE INTERNAL "Have function ${FUNCTION}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the function ${FUNCTION} exists failed with the following output:\n"
diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake
index 9dc1648..ea73267 100644
--- a/Modules/CheckIncludeFile.cmake
+++ b/Modules/CheckIncludeFile.cmake
@@ -24,6 +24,7 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
@@ -49,7 +50,9 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
set(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c)
- message(STATUS "Looking for ${INCLUDE}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${INCLUDE}")
+ endif()
if(${ARGC} EQUAL 3)
set(CMAKE_C_FLAGS_SAVE ${CMAKE_C_FLAGS})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ARGV2}")
@@ -69,14 +72,18 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE)
endif()
if(${VARIABLE})
- message(STATUS "Looking for ${INCLUDE} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${INCLUDE} - found")
+ endif()
set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the include file ${INCLUDE} "
"exists passed with the following output:\n"
"${OUTPUT}\n\n")
else()
- message(STATUS "Looking for ${INCLUDE} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${INCLUDE} - not found")
+ endif()
set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the include file ${INCLUDE} "
diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake
index fa36a3f..39abeff 100644
--- a/Modules/CheckIncludeFileCXX.cmake
+++ b/Modules/CheckIncludeFileCXX.cmake
@@ -28,6 +28,7 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
@@ -53,7 +54,9 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
set(CHECK_INCLUDE_FILE_VAR ${INCLUDE})
configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx)
- message(STATUS "Looking for C++ include ${INCLUDE}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for C++ include ${INCLUDE}")
+ endif()
if(${ARGC} EQUAL 3)
set(CMAKE_CXX_FLAGS_SAVE ${CMAKE_CXX_FLAGS})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ARGV2}")
@@ -73,14 +76,18 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE)
endif()
if(${VARIABLE})
- message(STATUS "Looking for C++ include ${INCLUDE} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for C++ include ${INCLUDE} - found")
+ endif()
set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the include file ${INCLUDE} "
"exists passed with the following output:\n"
"${OUTPUT}\n\n")
else()
- message(STATUS "Looking for C++ include ${INCLUDE} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for C++ include ${INCLUDE} - not found")
+ endif()
set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the include file ${INCLUDE} "
diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake
index 182067f..6aa0f2b 100644
--- a/Modules/CheckIncludeFiles.cmake
+++ b/Modules/CheckIncludeFiles.cmake
@@ -23,6 +23,7 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2003-2012 Kitware, Inc.
@@ -66,7 +67,9 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
set(_description "include file ${_INCLUDE}")
endif()
- message(STATUS "Looking for ${_description}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${_description}")
+ endif()
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFiles.c
@@ -76,14 +79,18 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE)
"${CHECK_INCLUDE_FILES_INCLUDE_DIRS}"
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
- message(STATUS "Looking for ${_description} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${_description} - found")
+ endif()
set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if files ${INCLUDE} "
"exist passed with the following output:\n"
"${OUTPUT}\n\n")
else()
- message(STATUS "Looking for ${_description} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${_description} - not found")
+ endif()
set(${VARIABLE} "" CACHE INTERNAL "Have includes ${INCLUDE}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if files ${INCLUDE} "
diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake
index f5c563c..2b41379 100644
--- a/Modules/CheckLibraryExists.cmake
+++ b/Modules/CheckLibraryExists.cmake
@@ -23,6 +23,7 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
@@ -43,7 +44,9 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
set(MACRO_CHECK_LIBRARY_EXISTS_DEFINITION
"-DCHECK_FUNCTION_EXISTS=${FUNCTION} ${CMAKE_REQUIRED_FLAGS}")
- message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${FUNCTION} in ${LIBRARY}")
+ endif()
set(CHECK_LIBRARY_EXISTS_LIBRARIES ${LIBRARY})
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_LIBRARY_EXISTS_LIBRARIES
@@ -60,14 +63,18 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE)
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
- message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - found")
+ endif()
set(${VARIABLE} 1 CACHE INTERNAL "Have library ${LIBRARY}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
"passed with the following output:\n"
"${OUTPUT}\n\n")
else()
- message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${FUNCTION} in ${LIBRARY} - not found")
+ endif()
set(${VARIABLE} "" CACHE INTERNAL "Have library ${LIBRARY}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the function ${FUNCTION} exists in the ${LIBRARY} "
diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake
index 25ea7f4..fe00074 100644
--- a/Modules/CheckPrototypeDefinition.cmake
+++ b/Modules/CheckPrototypeDefinition.cmake
@@ -33,6 +33,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
@@ -97,12 +98,16 @@ function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB
if (${_VARIABLE})
set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
- message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
"${OUTPUT}\n\n")
else ()
- message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
+ endif()
set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
diff --git a/Modules/CheckStructHasMember.cmake b/Modules/CheckStructHasMember.cmake
index a864e82..880a688 100644
--- a/Modules/CheckStructHasMember.cmake
+++ b/Modules/CheckStructHasMember.cmake
@@ -28,6 +28,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#
#
#
diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake
index e1ca412..bf2e797 100644
--- a/Modules/CheckSymbolExists.cmake
+++ b/Modules/CheckSymbolExists.cmake
@@ -28,6 +28,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2003-2011 Kitware, Inc.
@@ -74,7 +75,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in"
"${SOURCEFILE}" @ONLY)
- message(STATUS "Looking for ${SYMBOL}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${SYMBOL}")
+ endif()
try_compile(${VARIABLE}
${CMAKE_BINARY_DIR}
"${SOURCEFILE}"
@@ -85,7 +88,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
- message(STATUS "Looking for ${SYMBOL} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${SYMBOL} - found")
+ endif()
set(${VARIABLE} 1 CACHE INTERNAL "Have symbol ${SYMBOL}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the ${SYMBOL} "
@@ -93,7 +98,9 @@ macro(_CHECK_SYMBOL_EXISTS SOURCEFILE SYMBOL FILES VARIABLE)
"${OUTPUT}\nFile ${SOURCEFILE}:\n"
"${CMAKE_CONFIGURABLE_FILE_CONTENT}\n")
else()
- message(STATUS "Looking for ${SYMBOL} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${SYMBOL} - not found")
+ endif()
set(${VARIABLE} "" CACHE INTERNAL "Have symbol ${SYMBOL}")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the ${SYMBOL} "
diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake
index ec28d8b..ad3b6b5 100644
--- a/Modules/CheckTypeSize.cmake
+++ b/Modules/CheckTypeSize.cmake
@@ -59,6 +59,7 @@
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_INCLUDES = list of include directories
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
# CMAKE_EXTRA_INCLUDE_FILES = list of extra headers to include
#=============================================================================
@@ -75,6 +76,7 @@
# License text for the above reference.)
include(CheckIncludeFile)
+include(CheckIncludeFileCXX)
cmake_policy(PUSH)
cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
@@ -84,7 +86,9 @@ get_filename_component(__check_type_size_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
#-----------------------------------------------------------------------------
# Helper function. DO NOT CALL DIRECTLY.
function(__check_type_size_impl type var map builtin language)
- message(STATUS "Check size of ${type}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Check size of ${type}")
+ endif()
# Include header files.
set(headers)
@@ -138,7 +142,7 @@ function(__check_type_size_impl type var map builtin language)
foreach(info ${strings})
if("${info}" MATCHES "${regex_size}")
# Get the type size.
- string(REGEX REPLACE "${regex_size}" "\\1" size "${info}")
+ set(size "${CMAKE_MATCH_1}")
if(first)
set(${var} ${size})
elseif(NOT "${size}" STREQUAL "${${var}}")
@@ -168,13 +172,17 @@ function(__check_type_size_impl type var map builtin language)
message(SEND_ERROR "CHECK_TYPE_SIZE found different results, consider setting CMAKE_OSX_ARCHITECTURES or CMAKE_TRY_COMPILE_OSX_ARCHITECTURES to one or no architecture !")
endif()
- message(STATUS "Check size of ${type} - done")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Check size of ${type} - done")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining size of ${type} passed with the following output:\n${output}\n\n")
set(${var} "${${var}}" CACHE INTERNAL "CHECK_TYPE_SIZE: sizeof(${type})")
else()
# The check failed to compile.
- message(STATUS "Check size of ${type} - failed")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Check size of ${type} - failed")
+ endif()
file(READ ${src} content)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n")
@@ -218,9 +226,15 @@ macro(CHECK_TYPE_SIZE TYPE VARIABLE)
set(_builtin 0)
else()
set(_builtin 1)
- check_include_file(sys/types.h HAVE_SYS_TYPES_H)
- check_include_file(stdint.h HAVE_STDINT_H)
- check_include_file(stddef.h HAVE_STDDEF_H)
+ if("${_language}" STREQUAL "C")
+ check_include_file(sys/types.h HAVE_SYS_TYPES_H)
+ check_include_file(stdint.h HAVE_STDINT_H)
+ check_include_file(stddef.h HAVE_STDDEF_H)
+ elseif("${_language}" STREQUAL "CXX")
+ check_include_file_cxx(sys/types.h HAVE_SYS_TYPES_H)
+ check_include_file_cxx(stdint.h HAVE_STDINT_H)
+ check_include_file_cxx(stddef.h HAVE_STDDEF_H)
+ endif()
endif()
unset(_CHECK_TYPE_SIZE_BUILTIN_TYPES_ONLY)
unset(_CHECK_TYPE_SIZE_LANGUAGE)
diff --git a/Modules/CheckVariableExists.cmake b/Modules/CheckVariableExists.cmake
index 4861ff0..3a7ef13 100644
--- a/Modules/CheckVariableExists.cmake
+++ b/Modules/CheckVariableExists.cmake
@@ -27,6 +27,7 @@
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
+# CMAKE_REQUIRED_QUIET = execute quietly without messages
#=============================================================================
# Copyright 2002-2009 Kitware, Inc.
@@ -47,7 +48,9 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
if("${VARIABLE}" MATCHES "^${VARIABLE}$")
set(MACRO_CHECK_VARIABLE_DEFINITIONS
"-DCHECK_VARIABLE_EXISTS=${VAR} ${CMAKE_REQUIRED_FLAGS}")
- message(STATUS "Looking for ${VAR}")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${VAR}")
+ endif()
if(CMAKE_REQUIRED_LIBRARIES)
set(CHECK_VARIABLE_EXISTS_ADD_LIBRARIES
LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
@@ -63,13 +66,17 @@ macro(CHECK_VARIABLE_EXISTS VAR VARIABLE)
OUTPUT_VARIABLE OUTPUT)
if(${VARIABLE})
set(${VARIABLE} 1 CACHE INTERNAL "Have variable ${VAR}")
- message(STATUS "Looking for ${VAR} - found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${VAR} - found")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the variable ${VAR} exists passed with the following output:\n"
"${OUTPUT}\n\n")
else()
set(${VARIABLE} "" CACHE INTERNAL "Have variable ${VAR}")
- message(STATUS "Looking for ${VAR} - not found")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Looking for ${VAR} - not found")
+ endif()
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the variable ${VAR} exists failed with the following output:\n"
"${OUTPUT}\n\n")
diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake
index 680f720..0372e18 100644
--- a/Modules/Compiler/AppleClang-CXX.cmake
+++ b/Modules/Compiler/AppleClang-CXX.cmake
@@ -1 +1,6 @@
-include(Compiler/Clang-CXX)
+include(Compiler/Clang)
+__compiler_clang(CXX)
+
+if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
+ set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
+endif()
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index 0372e18..a1b3a10 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -4,3 +4,21 @@ __compiler_clang(CXX)
if(NOT CMAKE_CXX_SIMULATE_ID STREQUAL "MSVC")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
+
+cmake_policy(GET CMP0025 appleClangPolicy)
+if(NOT appleClangPolicy STREQUAL NEW)
+ return()
+endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+endif()
diff --git a/Modules/Compiler/GNU-CXX-FeatureTests.cmake b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
new file mode 100644
index 0000000..3f169d2
--- /dev/null
+++ b/Modules/Compiler/GNU-CXX-FeatureTests.cmake
@@ -0,0 +1,77 @@
+
+# Reference: http://gcc.gnu.org/projects/cxx0x.html
+
+set(_oldestSupported "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408")
+# Introduced in GCC 4.8.1
+set(GNU481_CXX11 "((__GNUC__ * 100 + __GNUC_MINOR__) > 408 || __GNUC_PATCHLEVEL__ >= 1) && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype_incomplete_return_types "${GNU481_CXX11}")
+set(_cmake_feature_test_cxx_reference_qualified_functions "${GNU481_CXX11}")
+set(GNU48_CXX11 "(__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_alignas "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_alignof "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_attributes "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_inheriting_constructors "${GNU48_CXX11}")
+set(_cmake_feature_test_cxx_thread_local "${GNU48_CXX11}")
+# TODO: Should be supported by GNU 4.7
+set(GNU47_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_alias_templates "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_delegating_constructors "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_extended_friend_declarations "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_final "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_noexcept "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_nonstatic_member_init "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_override "${GNU47_CXX11}")
+set(_cmake_feature_test_cxx_user_literals "${GNU47_CXX11}")
+# NOTE: C++11 was ratified in September 2011. GNU 4.7 is the first minor
+# release following that (March 2012), and the first minor release to
+# support -std=c++11. Prior to that, support for C++11 features is technically
+# experiemental and possibly incomplete (see for example the note below about
+# cxx_variadic_template_template_parameters)
+# TODO: Should be supported by GNU 4.6
+set(GNU46_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_constexpr "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_move_initializers "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_enum_forward_declarations "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_nullptr "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_range_for "${GNU46_CXX11}")
+set(_cmake_feature_test_cxx_unrestricted_unions "${GNU46_CXX11}")
+# TODO: Should be supported by GNU 4.5
+set(GNU45_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_explicit_conversions "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_lambdas "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_local_type_template_args "${GNU45_CXX11}")
+set(_cmake_feature_test_cxx_raw_string_literals "${GNU45_CXX11}")
+# TODO: Should be supported by GNU 4.4
+set(GNU44_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_auto_type "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_defaulted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_deleted_functions "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_generalized_initializers "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_inline_namespaces "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_sizeof_member "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_strong_enums "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_trailing_return_types "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_unicode_literals "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_uniform_initialization "${GNU44_CXX11}")
+set(_cmake_feature_test_cxx_variadic_templates "${GNU44_CXX11}")
+# TODO: If features are ever recorded for GNU 4.3, there should possibly
+# be a new feature added like cxx_variadic_template_template_parameters,
+# which is implemented by GNU 4.4, but not 4.3. cxx_variadic_templates is
+# actually implemented by GNU 4.3, but variadic template template parameters
+# 'completes' it, so that is the version we record as having the variadic
+# templates capability in CMake. See
+# http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2555.pdf
+# TODO: Should be supported by GNU 4.3
+set(GNU43_CXX11 "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_decltype "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_default_function_template_args "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_long_long_type "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_right_angle_brackets "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_rvalue_references "${GNU43_CXX11}")
+set(_cmake_feature_test_cxx_static_assert "${GNU43_CXX11}")
+# TODO: Should be supported since GNU 3.4?
+set(_cmake_feature_test_cxx_extern_templates "${_oldestSupported} && __cplusplus >= 201103L")
+# TODO: Should be supported forever?
+set(_cmake_feature_test_cxx_func_identifier "${_oldestSupported} && __cplusplus >= 201103L")
+set(_cmake_feature_test_cxx_variadic_macros "${_oldestSupported} && __cplusplus >= 201103L")
+set(_oldestSupported)
diff --git a/Modules/Compiler/GNU-CXX.cmake b/Modules/Compiler/GNU-CXX.cmake
index 33d6093..7acad52 100644
--- a/Modules/Compiler/GNU-CXX.cmake
+++ b/Modules/Compiler/GNU-CXX.cmake
@@ -10,3 +10,28 @@ else()
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
endif()
endif()
+
+if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
+ set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
+ set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+endif()
+
+if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.3)
+ set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
+ set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+endif()
+
+macro(cmake_record_cxx_compile_features)
+ macro(_get_gcc_features std_version list)
+ record_compiler_features(CXX "-std=${std_version}" ${list})
+ endmacro()
+
+ if (UNIX AND NOT APPLE AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
+ _get_gcc_features(c++11 CMAKE_CXX11_COMPILE_FEATURES)
+ else()
+ set(_result 0)
+ endif()
+endmacro()
diff --git a/Modules/ExternalData.cmake b/Modules/ExternalData.cmake
index 1e2698c..73a4990 100644
--- a/Modules/ExternalData.cmake
+++ b/Modules/ExternalData.cmake
@@ -292,8 +292,7 @@ function(ExternalData_expand_arguments target outArgsVar)
foreach(piece IN LISTS pieces)
if("x${piece}" MATCHES "^x${data_regex}$")
# Replace this DATA{}-piece with a file path.
- string(REGEX REPLACE "${data_regex}" "\\1" data "${piece}")
- _ExternalData_arg("${target}" "${piece}" "${data}" file)
+ _ExternalData_arg("${target}" "${piece}" "${CMAKE_MATCH_1}" file)
set(outArg "${outArg}${file}")
else()
# No replacement needed for this piece.
@@ -422,16 +421,16 @@ function(_ExternalData_arg target arg options var_file)
set(external "") # Entries external to the source tree.
set(internal "") # Entries internal to the source tree.
set(have_original ${data_is_directory})
+ set(have_original_as_dir 0)
# Process options.
set(series_option "")
set(associated_files "")
set(associated_regex "")
foreach(opt ${options})
- if("x${opt}" MATCHES "^xREGEX:[^:/]+$")
- # Regular expression to match associated files.
- string(REGEX REPLACE "^REGEX:" "" regex "${opt}")
- list(APPEND associated_regex "${regex}")
+ # Regular expression to match associated files.
+ if("x${opt}" MATCHES "^xREGEX:([^:/]+)$")
+ list(APPEND associated_regex "${CMAKE_MATCH_1}")
elseif(opt STREQUAL ":")
# Activate series matching.
set(series_option "${opt}")
@@ -472,11 +471,18 @@ function(_ExternalData_arg target arg options var_file)
endif()
if(NOT have_original)
- message(FATAL_ERROR "Data file referenced by argument\n"
+ if(have_original_as_dir)
+ set(msg_kind FATAL_ERROR)
+ set(msg "that is directory instead of a file!")
+ else()
+ set(msg_kind AUTHOR_WARNING)
+ set(msg "that does not exist as a file (with or without an extension)!")
+ endif()
+ message(${msg_kind} "Data file referenced by argument\n"
" ${arg}\n"
"corresponds to source tree path\n"
" ${reldata}\n"
- "that does not exist as a file (with or without an extension)!")
+ "${msg}")
endif()
if(external)
@@ -593,27 +599,33 @@ function(_ExternalData_arg_find_files pattern regex)
set(alg "")
endif()
if("x${relname}" MATCHES "^x${regex}$" # matches
- AND NOT IS_DIRECTORY "${top_src}/${entry}" # not a directory
AND NOT "x${relname}" MATCHES "(^x|/)\\.ExternalData_" # not staged obj
)
- set(name "${top_src}/${relname}")
- set(file "${top_bin}/${relname}")
- if(alg)
- list(APPEND external "${file}|${name}|${alg}")
- elseif(ExternalData_LINK_CONTENT)
- _ExternalData_link_content("${name}" alg)
- list(APPEND external "${file}|${name}|${alg}")
- elseif(NOT top_same)
- list(APPEND internal "${file}|${name}")
- endif()
- if("${relname}" STREQUAL "${reldata}")
- set(have_original 1)
+ if(IS_DIRECTORY "${top_src}/${entry}")
+ if("${relname}" STREQUAL "${reldata}")
+ set(have_original_as_dir 1)
+ endif()
+ else()
+ set(name "${top_src}/${relname}")
+ set(file "${top_bin}/${relname}")
+ if(alg)
+ list(APPEND external "${file}|${name}|${alg}")
+ elseif(ExternalData_LINK_CONTENT)
+ _ExternalData_link_content("${name}" alg)
+ list(APPEND external "${file}|${name}|${alg}")
+ elseif(NOT top_same)
+ list(APPEND internal "${file}|${name}")
+ endif()
+ if("${relname}" STREQUAL "${reldata}")
+ set(have_original 1)
+ endif()
endif()
endif()
endforeach()
set(external "${external}" PARENT_SCOPE)
set(internal "${internal}" PARENT_SCOPE)
set(have_original "${have_original}" PARENT_SCOPE)
+ set(have_original_as_dir "${have_original_as_dir}" PARENT_SCOPE)
endfunction()
#-----------------------------------------------------------------------------
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 0df51a8..f587985 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -16,10 +16,12 @@
# [LIST_SEPARATOR sep] # Sep to be replaced by ; in cmd lines
# [TMP_DIR dir] # Directory to store temporary files
# [STAMP_DIR dir] # Directory to store step timestamps
+# [EXCLUDE_FROM_ALL 1] # The "all" target does not depend on this
# #--Download step--------------
# [DOWNLOAD_NAME fname] # File name to store (if not end of URL)
# [DOWNLOAD_DIR dir] # Directory to store downloaded files
# [DOWNLOAD_COMMAND cmd...] # Command to download source tree
+# [DOWNLOAD_NO_PROGRESS 1] # Disable download progress reports
# [CVS_REPOSITORY cvsroot] # CVSROOT of CVS repository
# [CVS_MODULE mod] # Module to checkout from CVS repo
# [CVS_TAG tag] # Tag to checkout from CVS repo
@@ -54,6 +56,7 @@
# [BINARY_DIR dir] # Specify build dir location
# [BUILD_COMMAND cmd...] # Command to drive the native build
# [BUILD_IN_SOURCE 1] # Use source dir for build dir
+# [BUILD_ALWAYS 1] # No stamp file, build step always runs
# #--Install step---------------
# [INSTALL_DIR dir] # Installation prefix
# [INSTALL_COMMAND cmd...] # Command to drive install after build
@@ -117,6 +120,7 @@
# [DEPENDERS steps...] # Steps that depend on this step
# [DEPENDS files...] # Files on which this step depends
# [ALWAYS 1] # No stamp file, step always runs
+# [EXCLUDE_FROM_MAIN 1] # Main target does not depend on this step
# [WORKING_DIRECTORY dir] # Working directory for command
# [LOG 1] # Wrap step in script to log output
# )
@@ -197,11 +201,11 @@ file(STRINGS "${CMAKE_CURRENT_LIST_FILE}" lines
LIMIT_COUNT ${_ep_documentation_line_count}
REGEX "^# ( \\[[A-Z0-9_]+ [^]]*\\] +#.*$|[A-Za-z0-9_]+\\()")
foreach(line IN LISTS lines)
- if("${line}" MATCHES "^# [A-Za-z0-9_]+\\(")
+ if("${line}" MATCHES "^# ([A-Za-z0-9_]+)\\(")
if(_ep_func)
set(_ep_keywords_${_ep_func} "${_ep_keywords_${_ep_func}})$")
endif()
- string(REGEX REPLACE "^# ([A-Za-z0-9_]+)\\(.*" "\\1" _ep_func "${line}")
+ set(_ep_func "${CMAKE_MATCH_1}")
#message("function [${_ep_func}]")
set(_ep_keywords_${_ep_func} "^(")
set(_ep_keyword_sep)
@@ -452,6 +456,7 @@ execute_process(
WORKING_DIRECTORY \"${work_dir}\"
RESULT_VARIABLE error_code
OUTPUT_VARIABLE head_sha
+ OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(error_code)
message(FATAL_ERROR \"Failed to get the hash for HEAD\")
@@ -470,6 +475,17 @@ else()
set(is_remote_ref 0)
endif()
+# Tag is in the form <remote>/<tag> (i.e. origin/master) we must strip
+# the remote from the tag.
+if(\"\${show_ref_output}\" MATCHES \"refs/remotes/${git_tag}\")
+ string(REGEX MATCH \"^([^/]+)/(.+)$\" _unused \"${git_tag}\")
+ set(git_remote \"\${CMAKE_MATCH_1}\")
+ set(git_tag \"\${CMAKE_MATCH_2}\")
+else()
+ set(git_remote \"origin\")
+ set(git_tag \"${git_tag}\")
+endif()
+
# This will fail if the tag does not exist (it probably has not been fetched
# yet).
execute_process(
@@ -477,6 +493,7 @@ execute_process(
WORKING_DIRECTORY \"${work_dir}\"
RESULT_VARIABLE error_code
OUTPUT_VARIABLE tag_sha
+ OUTPUT_STRIP_TRAILING_WHITESPACE
)
# Is the hash checkout out that we want?
@@ -490,13 +507,94 @@ if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"
message(FATAL_ERROR \"Failed to fetch repository '${git_repository}'\")
endif()
- execute_process(
- COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
- WORKING_DIRECTORY \"${work_dir}\"
- RESULT_VARIABLE error_code
- )
- if(error_code)
- message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
+ if(is_remote_ref)
+ # Check if stash is needed
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" status --porcelain
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ OUTPUT_VARIABLE repo_status
+ )
+ if(error_code)
+ message(FATAL_ERROR \"Failed to get the status\")
+ endif()
+ string(LENGTH \"\${repo_status}\" need_stash)
+
+ # If not in clean state, stash changes in order to be able to be able to
+ # perform git pull --rebase
+ if(need_stash)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" stash save --all --quiet
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ )
+ if(error_code)
+ message(FATAL_ERROR \"Failed to stash changes\")
+ endif()
+ endif()
+
+ # Pull changes from the remote branch
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" rebase \${git_remote}/\${git_tag}
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ )
+ if(error_code)
+ # Rebase failed: Restore previous state.
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" rebase --abort
+ WORKING_DIRECTORY \"${work_dir}\"
+ )
+ if(need_stash)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
+ WORKING_DIRECTORY \"${work_dir}\"
+ )
+ endif()
+ message(FATAL_ERROR \"\\nFailed to rebase in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\")
+ endif()
+
+ if(need_stash)
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ )
+ if(error_code)
+ # Stash pop --index failed: Try again dropping the index
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ )
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" stash pop --quiet
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ )
+ if(error_code)
+ # Stash pop failed: Restore previous state.
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" reset --hard --quiet \${head_sha}
+ WORKING_DIRECTORY \"${work_dir}\"
+ )
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" stash pop --index --quiet
+ WORKING_DIRECTORY \"${work_dir}\"
+ )
+ message(FATAL_ERROR \"\\nFailed to unstash changes in: '${work_dir}/${src_name}'.\\nYou will have to resolve the conflicts manually\")
+ endif()
+ endif()
+ endif()
+ else()
+ execute_process(
+ COMMAND \"${git_EXECUTABLE}\" checkout ${git_tag}
+ WORKING_DIRECTORY \"${work_dir}\"
+ RESULT_VARIABLE error_code
+ )
+ if(error_code)
+ message(FATAL_ERROR \"Failed to checkout tag: '${git_tag}'\")
+ endif()
endif()
execute_process(
@@ -514,7 +612,7 @@ endif()
endfunction(_ep_write_gitupdate_script)
-function(_ep_write_downloadfile_script script_filename remote local timeout hash tls_verify tls_cainfo)
+function(_ep_write_downloadfile_script script_filename remote local timeout no_progress hash tls_verify tls_cainfo)
if(timeout)
set(timeout_args TIMEOUT ${timeout})
set(timeout_msg "${timeout} seconds")
@@ -523,6 +621,12 @@ function(_ep_write_downloadfile_script script_filename remote local timeout hash
set(timeout_msg "none")
endif()
+ if(no_progress)
+ set(show_progress "")
+ else()
+ set(show_progress "SHOW_PROGRESS")
+ endif()
+
if("${hash}" MATCHES "${_ep_hash_regex}")
set(hash_args EXPECTED_HASH ${CMAKE_MATCH_1}=${CMAKE_MATCH_2})
else()
@@ -562,7 +666,7 @@ ${tls_cainfo}
file(DOWNLOAD
\"${remote}\"
\"${local}\"
- SHOW_PROGRESS
+ ${show_progress}
${hash_args}
${timeout_args}
STATUS status
@@ -803,7 +907,8 @@ function(_ep_write_initial_cache target_name script_filename args)
set(regex "^([^:]+):([^=]+)=(.*)$")
set(setArg "")
foreach(line ${args})
- if("${line}" MATCHES "^-D")
+ if("${line}" MATCHES "^-D(.*)")
+ set(line "${CMAKE_MATCH_1}")
if(setArg)
# This is required to build up lists in variables, or complete an entry
set(setArg "${setArg}${accumulator}\" CACHE ${type} \"Initial cache\" FORCE)")
@@ -811,9 +916,7 @@ function(_ep_write_initial_cache target_name script_filename args)
set(accumulator "")
set(setArg "")
endif()
- string(REGEX REPLACE "^-D" "" line ${line})
if("${line}" MATCHES "${regex}")
- string(REGEX MATCH "${regex}" match "${line}")
set(name "${CMAKE_MATCH_1}")
set(type "${CMAKE_MATCH_2}")
set(value "${CMAKE_MATCH_3}")
@@ -1090,14 +1193,17 @@ function(ExternalProject_Add_Step name step)
set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
_ep_get_step_stampfile(${name} ${step} stamp_file)
- add_custom_command(APPEND
- OUTPUT ${complete_stamp_file}
- DEPENDS ${stamp_file}
- )
-
_ep_parse_arguments(ExternalProject_Add_Step
${name} _EP_${step}_ "${ARGN}")
+ get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN)
+ if(NOT exclude_from_main)
+ add_custom_command(APPEND
+ OUTPUT ${complete_stamp_file}
+ DEPENDS ${stamp_file}
+ )
+ endif()
+
# Steps depending on this step.
get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS)
foreach(depender IN LISTS dependers)
@@ -1245,7 +1351,7 @@ function(_ep_add_download_command name)
if(cmd_set)
set(work_dir ${download_dir})
elseif(cvs_repository)
- find_package(CVS)
+ find_package(CVS QUIET)
if(NOT CVS_EXECUTABLE)
message(FATAL_ERROR "error: could not find cvs for checkout of ${name}")
endif()
@@ -1272,7 +1378,7 @@ function(_ep_add_download_command name)
set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module})
list(APPEND depends ${stamp_dir}/${name}-cvsinfo.txt)
elseif(svn_repository)
- find_package(Subversion)
+ find_package(Subversion QUIET)
if(NOT Subversion_SVN_EXECUTABLE)
message(FATAL_ERROR "error: could not find svn for checkout of ${name}")
endif()
@@ -1308,7 +1414,7 @@ function(_ep_add_download_command name)
--non-interactive ${svn_trust_cert_args} ${svn_user_pw_args} ${src_name})
list(APPEND depends ${stamp_dir}/${name}-svninfo.txt)
elseif(git_repository)
- find_package(Git)
+ find_package(Git QUIET)
if(NOT GIT_EXECUTABLE)
message(FATAL_ERROR "error: could not find git for clone of ${name}")
endif()
@@ -1356,7 +1462,7 @@ function(_ep_add_download_command name)
set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake)
list(APPEND depends ${stamp_dir}/${name}-gitinfo.txt)
elseif(hg_repository)
- find_package(Hg)
+ find_package(Hg QUIET)
if(NOT HG_EXECUTABLE)
message(FATAL_ERROR "error: could not find hg for clone of ${name}")
endif()
@@ -1442,10 +1548,11 @@ function(_ep_add_download_command name)
string(REPLACE ";" "-" fname "${fname}")
set(file ${download_dir}/${fname})
get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT)
+ get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS)
get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY)
get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO)
set(download_script "${stamp_dir}/download-${name}.cmake")
- _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${hash}" "${tls_verify}" "${tls_cainfo}")
+ _ep_write_downloadfile_script("${download_script}" "${url}" "${file}" "${timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}")
set(cmd ${CMAKE_COMMAND} -P "${download_script}"
COMMAND)
set(retries 3)
@@ -1716,10 +1823,18 @@ function(_ep_add_build_command name)
set(log "")
endif()
+ get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS)
+ if(build_always)
+ set(always 1)
+ else()
+ set(always 0)
+ endif()
+
ExternalProject_Add_Step(${name} build
COMMAND ${cmd}
WORKING_DIRECTORY ${binary_dir}
DEPENDEES configure
+ ALWAYS ${always}
${log}
)
endfunction()
@@ -1798,6 +1913,9 @@ function(ExternalProject_Add name)
set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles)
set(complete_stamp_file "${cmf_dir}${cfgdir}/${name}-complete")
+ # The "ALL" option to add_custom_target just tells it to not set the
+ # EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
+ # argument was passed, we explicitly set it for the target.
add_custom_target(${name} ALL DEPENDS ${complete_stamp_file})
set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1)
_ep_parse_arguments(ExternalProject_Add ${name} _EP_ "${ARGN}")
@@ -1805,6 +1923,12 @@ function(ExternalProject_Add name)
_ep_get_step_stampfile(${name} "done" done_stamp_file)
_ep_get_step_stampfile(${name} "install" install_stamp_file)
+ # Set the EXCLUDE_FROM_ALL target property if required.
+ get_property(exclude_from_all TARGET ${name} PROPERTY _EP_EXCLUDE_FROM_ALL)
+ if(exclude_from_all)
+ set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE)
+ endif()
+
# The 'complete' step depends on all other steps and creates a
# 'done' mark. A dependent external project's 'configure' step
# depends on the 'done' mark so that it rebuilds when this project
diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake
index c0e63d5..12ea384 100644
--- a/Modules/FeatureSummary.cmake
+++ b/Modules/FeatureSummary.cmake
@@ -71,6 +71,13 @@
# RUNTIME_PACKAGES_FOUND: only those packages which have been found which have the type RUNTIME
# RUNTIME_PACKAGES_NOT_FOUND: only those packages which have not been found which have the type RUNTIME
#
+# With the exception of the ``ALL`` value, these values can be combined
+# in order to customize the output. For example:
+#
+# ::
+#
+# feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
+#
#
#
# If a FILENAME is given, the information is printed into this file. If
@@ -417,8 +424,8 @@ endfunction()
function(FEATURE_SUMMARY)
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
set(options APPEND INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
- set(oneValueArgs FILENAME VAR DESCRIPTION WHAT)
- set(multiValueArgs ) # none
+ set(oneValueArgs FILENAME VAR DESCRIPTION)
+ set(multiValueArgs WHAT)
CMAKE_PARSE_ARGUMENTS(_FS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN})
@@ -451,23 +458,42 @@ function(FEATURE_SUMMARY)
set(requiredPackagesNotFound TRUE)
endif()
- elseif("${_FS_WHAT}" STREQUAL "ALL")
-
- set(allWhatParts "ENABLED_FEATURES"
- "RUNTIME_PACKAGES_FOUND"
- "OPTIONAL_PACKAGES_FOUND"
- "RECOMMENDED_PACKAGES_FOUND"
- "REQUIRED_PACKAGES_FOUND"
+ else()
+ if("${_FS_WHAT}" STREQUAL "ALL")
+
+ set(allWhatParts "ENABLED_FEATURES"
+ "RUNTIME_PACKAGES_FOUND"
+ "OPTIONAL_PACKAGES_FOUND"
+ "RECOMMENDED_PACKAGES_FOUND"
+ "REQUIRED_PACKAGES_FOUND"
+
+ "DISABLED_FEATURES"
+ "RUNTIME_PACKAGES_NOT_FOUND"
+ "OPTIONAL_PACKAGES_NOT_FOUND"
+ "RECOMMENDED_PACKAGES_NOT_FOUND"
+ "REQUIRED_PACKAGES_NOT_FOUND"
+ )
- "DISABLED_FEATURES"
- "RUNTIME_PACKAGES_NOT_FOUND"
- "OPTIONAL_PACKAGES_NOT_FOUND"
- "RECOMMENDED_PACKAGES_NOT_FOUND"
- "REQUIRED_PACKAGES_NOT_FOUND"
- )
+ else()
+ set(allWhatParts)
+ foreach(part ${_FS_WHAT})
+ list(FIND validWhatParts "${part}" indexInList)
+ if(NOT "${indexInList}" STREQUAL "-1")
+ list(APPEND allWhatParts "${part}")
+ else()
+ if("${part}" STREQUAL "ALL")
+ message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ALL, which cannot be combined with other values.")
+ else()
+ message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() contains ${part}, which is not a valid value.")
+ endif()
+ endif()
+ endforeach()
+ endif()
set(title_ENABLED_FEATURES "The following features have been enabled:")
set(title_DISABLED_FEATURES "The following features have been disabled:")
+ set(title_PACKAGES_FOUND "The following packages have been found:")
+ set(title_PACKAGES_NOT_FOUND "The following packages have not been found:")
set(title_OPTIONAL_PACKAGES_FOUND "The following OPTIONAL packages have been found:")
set(title_OPTIONAL_PACKAGES_NOT_FOUND "The following OPTIONAL packages have not been found:")
set(title_RECOMMENDED_PACKAGES_FOUND "The following RECOMMENDED packages have been found:")
@@ -488,8 +514,6 @@ function(FEATURE_SUMMARY)
endif()
endif()
endforeach()
- else()
- message(FATAL_ERROR "The WHAT argument of FEATURE_SUMMARY() is set to ${_FS_WHAT}, which is not a valid value.")
endif()
if(_FS_FILENAME)
@@ -522,10 +546,10 @@ function(SET_PACKAGE_INFO _name _desc)
set(_url "${ARGV2}")
set(_purpose "${ARGV3}")
set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
- if(_url MATCHES ".+")
+ if(NOT _url STREQUAL "")
set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_url}" )
endif()
- if(_purpose MATCHES ".+")
+ if(NOT _purpose STREQUAL "")
set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_purpose}" )
endif()
endfunction()
diff --git a/Modules/FindBISON.cmake b/Modules/FindBISON.cmake
index 9ca428e..ec3ee78 100644
--- a/Modules/FindBISON.cmake
+++ b/Modules/FindBISON.cmake
@@ -92,16 +92,13 @@ if(BISON_EXECUTABLE)
message(SEND_ERROR "Command \"${BISON_EXECUTABLE} --version\" failed with output:\n${BISON_version_error}")
else()
# Bison++
- if("${BISON_version_output}" MATCHES "^bison\\+\\+")
- string(REGEX REPLACE "^bison\\+\\+ Version ([^,]+).*" "\\1"
- BISON_VERSION "${BISON_version_output}")
+ if("${BISON_version_output}" MATCHES "^bison\\+\\+ Version ([^,]+)")
+ set(BISON_VERSION "${CMAKE_MATCH_1}")
# GNU Bison
- elseif("${BISON_version_output}" MATCHES "^bison[^+]")
- string(REGEX REPLACE "^bison \\(GNU Bison\\) ([^\n]+)\n.*" "\\1"
- BISON_VERSION "${BISON_version_output}")
- elseif("${BISON_version_output}" MATCHES "^GNU Bison ")
- string(REGEX REPLACE "^GNU Bison (version )?([^\n]+).*" "\\2"
- BISON_VERSION "${BISON_version_output}")
+ elseif("${BISON_version_output}" MATCHES "^bison \\(GNU Bison\\) ([^\n]+)\n")
+ set(BISON_VERSION "${CMAKE_MATCH_1}")
+ elseif("${BISON_version_output}" MATCHES "^GNU Bison (version )?([^\n]+)")
+ set(BISON_VERSION "${CMAKE_MATCH_2}")
endif()
endif()
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 3b658ef..6a583d9 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -52,6 +52,9 @@
include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+cmake_push_check_state()
+set(CMAKE_REQUIRED_QUIET ${BLAS_FIND_QUIETLY})
set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
@@ -147,7 +150,7 @@ endmacro()
set(BLAS_LINKER_FLAGS)
set(BLAS_LIBRARIES)
set(BLAS95_LIBRARIES)
-if ($ENV{BLA_VENDOR} MATCHES ".+")
+if (NOT $ENV{BLA_VENDOR} STREQUAL "")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else ()
if(NOT BLA_VENDOR)
@@ -285,7 +288,7 @@ if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
endif ()
#BLAS in acml library?
-if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
@@ -462,7 +465,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
endif ()
#BLAS in intel mkl 10 library? (em64t 64bit)
-if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
if (NOT WIN32)
set(LM "-lm")
endif ()
@@ -529,7 +532,7 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
"mkl_blas95 mkl_intel_lp64 mkl_intel_thread mkl_core guide")
# mkl >= 10.3
- if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
+ if (CMAKE_C_COMPILER MATCHES ".+gcc")
list(APPEND BLAS_SEARCH_LIBS
"mkl_blas95_lp64 mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
else ()
@@ -597,7 +600,7 @@ if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
"mkl_intel_lp64 mkl_intel_thread mkl_core guide")
# mkl >= 10.3
- if (CMAKE_C_COMPILER MATCHES ".+gcc.*")
+ if (CMAKE_C_COMPILER MATCHES ".+gcc")
list(APPEND BLAS_SEARCH_LIBS
"mkl_intel_lp64 mkl_gnu_thread mkl_core gomp")
else ()
@@ -687,4 +690,5 @@ else()
endif()
endif()
+cmake_pop_check_state()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
diff --git a/Modules/FindBZip2.cmake b/Modules/FindBZip2.cmake
index 3883877..b479332 100644
--- a/Modules/FindBZip2.cmake
+++ b/Modules/FindBZip2.cmake
@@ -57,7 +57,11 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(BZip2
if (BZIP2_FOUND)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_QUIET ${BZip2_FIND_QUIETLY})
CHECK_LIBRARY_EXISTS("${BZIP2_LIBRARIES}" BZ2_bzCompressInit "" BZIP2_NEED_PREFIX)
+ cmake_pop_check_state()
endif ()
mark_as_advanced(BZIP2_INCLUDE_DIR)
diff --git a/Modules/FindBacktrace.cmake b/Modules/FindBacktrace.cmake
index 83789cc..5620661 100644
--- a/Modules/FindBacktrace.cmake
+++ b/Modules/FindBacktrace.cmake
@@ -62,6 +62,7 @@ if (NOT DEFINED Backtrace_LIBRARY)
# First, check if we already have backtrace(), e.g., in libc
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${Backtrace_INCLUDE_DIRS})
+ set(CMAKE_REQUIRED_QUIET ${Backtrace_FIND_QUIETLY})
check_symbol_exists("backtrace" "${_Backtrace_HEADER_TRY}" _Backtrace_SYM_FOUND)
cmake_pop_check_state()
endif()
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index a57e12c..dfd4460 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -631,12 +631,12 @@ if(NOT Boost_INCLUDE_DIR)
set(_boost_BOOSTIFIED_VERSION)
# Transform 1.35 => 1_35 and 1.36.0 => 1_36_0
- if(_boost_VER MATCHES "[0-9]+\\.[0-9]+\\.[0-9]+")
- string(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+)" "\\1_\\2_\\3"
- _boost_BOOSTIFIED_VERSION ${_boost_VER})
- elseif(_boost_VER MATCHES "[0-9]+\\.[0-9]+")
- string(REGEX REPLACE "([0-9]+)\\.([0-9]+)" "\\1_\\2"
- _boost_BOOSTIFIED_VERSION ${_boost_VER})
+ if(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
+ set(_boost_BOOSTIFIED_VERSION
+ "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}_${CMAKE_MATCH_3}")
+ elseif(_boost_VER MATCHES "([0-9]+)\\.([0-9]+)")
+ set(_boost_BOOSTIFIED_VERSION
+ "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
endif()
list(APPEND _boost_PATH_SUFFIXES
@@ -684,7 +684,7 @@ if(Boost_INCLUDE_DIR)
set(_Boost_VERSION_REGEX "([0-9]+)")
set(_Boost_LIB_VERSION_REGEX "\"([0-9_]+)\"")
foreach(v VERSION LIB_VERSION)
- if("${_boost_VERSION_HPP_CONTENTS}" MATCHES ".*#define BOOST_${v} ${_Boost_${v}_REGEX}.*")
+ if("${_boost_VERSION_HPP_CONTENTS}" MATCHES "#define BOOST_${v} ${_Boost_${v}_REGEX}")
set(Boost_${v} "${CMAKE_MATCH_1}")
endif()
endforeach()
@@ -954,7 +954,8 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
# Compute component-specific hints.
set(_Boost_FIND_LIBRARY_HINTS_FOR_COMPONENT "")
- if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python")
+ if(${COMPONENT} STREQUAL "mpi" OR ${COMPONENT} STREQUAL "mpi_python" OR
+ ${COMPONENT} STREQUAL "graph_parallel")
foreach(lib ${MPI_CXX_LIBRARIES} ${MPI_C_LIBRARIES})
if(IS_ABSOLUTE "${lib}")
get_filename_component(libdir "${lib}" PATH)
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index 7bc8d49..c02809d 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -987,7 +987,7 @@ function(CUDA_COMPUTE_BUILD_PATH path build_path)
endif()
endif()
- # This recipie is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
+ # This recipe is from cmLocalGenerator::CreateSafeUniqueObjectFileName in the
# CMake source.
# Remove leading /
@@ -1194,7 +1194,7 @@ macro(CUDA_WRAP_SRCS cuda_target format generated_files)
foreach(file ${ARGN})
# Ignore any file marked as a HEADER_FILE_ONLY
get_source_file_property(_is_header ${file} HEADER_FILE_ONLY)
- if(${file} MATCHES ".*\\.cu$" AND NOT _is_header)
+ if(${file} MATCHES "\\.cu$" AND NOT _is_header)
# Allow per source file overrides of the format.
get_source_file_property(_cuda_source_format ${file} CUDA_SOURCE_PROPERTY_FORMAT)
diff --git a/Modules/FindCUDA/make2cmake.cmake b/Modules/FindCUDA/make2cmake.cmake
index 1b53d17..c433fa8 100644
--- a/Modules/FindCUDA/make2cmake.cmake
+++ b/Modules/FindCUDA/make2cmake.cmake
@@ -37,12 +37,11 @@
file(READ ${input_file} depend_text)
-if (${depend_text} MATCHES ".+")
+if (NOT "${depend_text}" STREQUAL "")
# message("FOUND DEPENDS")
- # Remember, four backslashes is escaped to one backslash in the string.
- string(REGEX REPLACE "\\\\ " " " depend_text ${depend_text})
+ string(REPLACE "\\ " " " depend_text ${depend_text})
# This works for the nvcc -M generated dependency files.
string(REGEX REPLACE "^.* : " "" depend_text ${depend_text})
diff --git a/Modules/FindCUDA/parse_cubin.cmake b/Modules/FindCUDA/parse_cubin.cmake
index 94be7e2..626c8a2 100644
--- a/Modules/FindCUDA/parse_cubin.cmake
+++ b/Modules/FindCUDA/parse_cubin.cmake
@@ -37,11 +37,10 @@
file(READ ${input_file} file_text)
-if (${file_text} MATCHES ".+")
+if (NOT "${file_text}" STREQUAL "")
- # Remember, four backslashes is escaped to one backslash in the string.
- string(REGEX REPLACE ";" "\\\\;" file_text ${file_text})
- string(REGEX REPLACE "\ncode" ";code" file_text ${file_text})
+ string(REPLACE ";" "\\;" file_text ${file_text})
+ string(REPLACE "\ncode" ";code" file_text ${file_text})
list(LENGTH file_text len)
@@ -57,7 +56,7 @@ if (${file_text} MATCHES ".+")
# Extract kernel names.
if (${entry} MATCHES "[^g]name = ([^ ]+)")
- string(REGEX REPLACE ".* = ([^ ]+)" "\\1" entry ${entry})
+ set(entry "${CMAKE_MATCH_1}")
# Check to see if the kernel name starts with "_"
set(skip FALSE)
@@ -76,19 +75,19 @@ if (${file_text} MATCHES ".+")
# Registers
if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)")
- string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
+ set(entry "${CMAKE_MATCH_3}")
message("Registers: ${entry}")
endif()
# Local memory
if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)")
- string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
+ set(entry "${CMAKE_MATCH_3}")
message("Local: ${entry}")
endif()
# Shared memory
if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)")
- string(REGEX REPLACE ".*([ ]+)=([ ]+)([^ ]+)" "\\3" entry ${entry})
+ set(entry "${CMAKE_MATCH_3}")
message("Shared: ${entry}")
endif()
diff --git a/Modules/FindCups.cmake b/Modules/FindCups.cmake
index 4b55d6a..51eb7c5 100644
--- a/Modules/FindCups.cmake
+++ b/Modules/FindCups.cmake
@@ -36,9 +36,13 @@ find_library(CUPS_LIBRARIES NAMES cups )
if (CUPS_INCLUDE_DIR AND CUPS_LIBRARIES AND CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_QUIET ${Cups_FIND_QUIETLY})
# ippDeleteAttribute is new in cups-1.1.19 (and used by kdeprint)
CHECK_LIBRARY_EXISTS(cups ippDeleteAttribute "" CUPS_HAS_IPP_DELETE_ATTRIBUTE)
+ cmake_pop_check_state()
endif ()
if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h")
@@ -48,9 +52,8 @@ if (CUPS_INCLUDE_DIR AND EXISTS "${CUPS_INCLUDE_DIR}/cups/cups.h")
unset(CUPS_VERSION_STRING)
foreach(VPART MAJOR MINOR PATCH)
foreach(VLINE ${cups_version_str})
- if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}")
- string(REGEX REPLACE "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$" "\\1"
- CUPS_VERSION_PART "${VLINE}")
+ if(VLINE MATCHES "^#[\t ]*define[\t ]+CUPS_VERSION_${VPART}[\t ]+([0-9]+)$")
+ set(CUPS_VERSION_PART "${CMAKE_MATCH_1}")
if(CUPS_VERSION_STRING)
set(CUPS_VERSION_STRING "${CUPS_VERSION_STRING}.${CUPS_VERSION_PART}")
else()
diff --git a/Modules/FindCurses.cmake b/Modules/FindCurses.cmake
index 971edb7..fa420c1 100644
--- a/Modules/FindCurses.cmake
+++ b/Modules/FindCurses.cmake
@@ -67,6 +67,9 @@ endif()
# default search paths.
if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+ include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+ cmake_push_check_state()
+ set(CMAKE_REQUIRED_QUIET ${Curses_FIND_QUIETLY})
CHECK_LIBRARY_EXISTS("${CURSES_CURSES_LIBRARY}"
wsyncup "" CURSES_CURSES_HAS_WSYNCUP)
@@ -77,6 +80,7 @@ if(CURSES_CURSES_LIBRARY AND CURSES_NEED_NCURSES)
set(CURSES_USE_NCURSES TRUE)
endif()
endif()
+ cmake_pop_check_state()
endif()
diff --git a/Modules/FindEXPAT.cmake b/Modules/FindEXPAT.cmake
index 6183af8..653094c 100644
--- a/Modules/FindEXPAT.cmake
+++ b/Modules/FindEXPAT.cmake
@@ -38,9 +38,8 @@ if (EXPAT_INCLUDE_DIR AND EXISTS "${EXPAT_INCLUDE_DIR}/expat.h")
unset(EXPAT_VERSION_STRING)
foreach(VPART MAJOR MINOR MICRO)
foreach(VLINE ${expat_version_str})
- if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION")
- string(REGEX REPLACE "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$" "\\1"
- EXPAT_VERSION_PART "${VLINE}")
+ if(VLINE MATCHES "^#[\t ]*define[\t ]+XML_${VPART}_VERSION[\t ]+([0-9]+)$")
+ set(EXPAT_VERSION_PART "${CMAKE_MATCH_1}")
if(EXPAT_VERSION_STRING)
set(EXPAT_VERSION_STRING "${EXPAT_VERSION_STRING}.${EXPAT_VERSION_PART}")
else()
diff --git a/Modules/FindFLTK.cmake b/Modules/FindFLTK.cmake
index b87bc7f..76f702e 100644
--- a/Modules/FindFLTK.cmake
+++ b/Modules/FindFLTK.cmake
@@ -285,9 +285,7 @@ endif()
OUTPUT_VARIABLE FLTK_IMAGES_LDFLAGS)
set(FLTK_LIBS_EXTRACT_REGEX ".*-lfltk_images (.*) -lfltk.*")
if("${FLTK_IMAGES_LDFLAGS}" MATCHES "${FLTK_LIBS_EXTRACT_REGEX}")
- string(REGEX REPLACE "${FLTK_LIBS_EXTRACT_REGEX}" "\\1"
- FLTK_IMAGES_LIBS "${FLTK_IMAGES_LDFLAGS}")
- string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}")
+ string(REGEX REPLACE " +" ";" FLTK_IMAGES_LIBS "${CMAKE_MATCH_1}")
# The EXEC_PROGRAM will not be inherited into subdirectories from
# the file that originally included this module. Save the answer.
set(FLTK_IMAGES_LIBS "${FLTK_IMAGES_LIBS}" CACHE INTERNAL
diff --git a/Modules/FindFLTK2.cmake b/Modules/FindFLTK2.cmake
index 4deffda..930acca 100644
--- a/Modules/FindFLTK2.cmake
+++ b/Modules/FindFLTK2.cmake
@@ -226,9 +226,7 @@ if(FLTK2_DIR)
OUTPUT_VARIABLE FLTK2_IMAGES_LDFLAGS)
set(FLTK2_LIBS_EXTRACT_REGEX ".*-lfltk2_images (.*) -lfltk2.*")
if("${FLTK2_IMAGES_LDFLAGS}" MATCHES "${FLTK2_LIBS_EXTRACT_REGEX}")
- string(REGEX REPLACE "${FLTK2_LIBS_EXTRACT_REGEX}" "\\1"
- FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LDFLAGS}")
- string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}")
+ string(REGEX REPLACE " +" ";" FLTK2_IMAGES_LIBS "${CMAKE_MATCH_1}")
# The EXEC_PROGRAM will not be inherited into subdirectories from
# the file that originally included this module. Save the answer.
set(FLTK2_IMAGES_LIBS "${FLTK2_IMAGES_LIBS}" CACHE INTERNAL
diff --git a/Modules/FindFreetype.cmake b/Modules/FindFreetype.cmake
index 6f03c86..1779b78 100644
--- a/Modules/FindFreetype.cmake
+++ b/Modules/FindFreetype.cmake
@@ -62,7 +62,7 @@ find_path(FREETYPE_INCLUDE_DIR_ft2build ft2build.h
ENV GTKMM_BASEPATH
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
- PATH_SUFFIXES include/freetype2 include
+ PATH_SUFFIXES include/freetype2 include freetype2
)
find_path(FREETYPE_INCLUDE_DIR_freetype2
@@ -79,7 +79,7 @@ find_path(FREETYPE_INCLUDE_DIR_freetype2
ENV GTKMM_BASEPATH
[HKEY_CURRENT_USER\\SOFTWARE\\gtkmm\\2.4;Path]
[HKEY_LOCAL_MACHINE\\SOFTWARE\\gtkmm\\2.4;Path]
- PATH_SUFFIXES include/freetype2 include
+ PATH_SUFFIXES include/freetype2 include freetype2
)
find_library(FREETYPE_LIBRARY
@@ -117,9 +117,8 @@ if(FREETYPE_INCLUDE_DIR_freetype2 AND FREETYPE_H)
unset(FREETYPE_VERSION_STRING)
foreach(VPART MAJOR MINOR PATCH)
foreach(VLINE ${freetype_version_str})
- if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}")
- string(REGEX REPLACE "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$" "\\1"
- FREETYPE_VERSION_PART "${VLINE}")
+ if(VLINE MATCHES "^#[\t ]*define[\t ]+FREETYPE_${VPART}[\t ]+([0-9]+)$")
+ set(FREETYPE_VERSION_PART "${CMAKE_MATCH_1}")
if(FREETYPE_VERSION_STRING)
set(FREETYPE_VERSION_STRING "${FREETYPE_VERSION_STRING}.${FREETYPE_VERSION_PART}")
else()
diff --git a/Modules/FindGDAL.cmake b/Modules/FindGDAL.cmake
index 4e04c31..bf374f9 100644
--- a/Modules/FindGDAL.cmake
+++ b/Modules/FindGDAL.cmake
@@ -90,9 +90,9 @@ if(UNIX)
exec_program(${GDAL_CONFIG} ARGS --libs OUTPUT_VARIABLE GDAL_CONFIG_LIBS)
if(GDAL_CONFIG_LIBS)
string(REGEX MATCHALL "-l[^ ]+" _gdal_dashl ${GDAL_CONFIG_LIBS})
- string(REGEX REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
+ string(REPLACE "-l" "" _gdal_lib "${_gdal_dashl}")
string(REGEX MATCHALL "-L[^ ]+" _gdal_dashL ${GDAL_CONFIG_LIBS})
- string(REGEX REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
+ string(REPLACE "-L" "" _gdal_libpath "${_gdal_dashL}")
endif()
endif()
endif()
diff --git a/Modules/FindGIF.cmake b/Modules/FindGIF.cmake
index 117ded7..7bbb8cf 100644
--- a/Modules/FindGIF.cmake
+++ b/Modules/FindGIF.cmake
@@ -66,6 +66,7 @@ if(GIF_INCLUDE_DIR)
include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/CheckStructHasMember.cmake)
CMAKE_PUSH_CHECK_STATE()
+ set(CMAKE_REQUIRED_QUIET ${GIF_FIND_QUIETLY})
set(GIF_VERSION 3)
set(CMAKE_REQUIRED_INCLUDES "${GIF_INCLUDE_DIR}")
CHECK_STRUCT_HAS_MEMBER(GifFileType UserData gif_lib.h GIF_GifFileType_UserData )
diff --git a/Modules/FindGTK2.cmake b/Modules/FindGTK2.cmake
index a91da33..15bcab8 100644
--- a/Modules/FindGTK2.cmake
+++ b/Modules/FindGTK2.cmake
@@ -267,6 +267,8 @@ function(_GTK2_FIND_INCLUDE_DIR _var _hdr)
/usr/local/lib
/usr/lib64
/usr/lib
+ /usr/X11R6/include
+ /usr/X11R6/lib
/opt/gnome/include
/opt/gnome/lib
/opt/openwin/include
@@ -641,6 +643,10 @@ endif()
foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
if(_GTK2_component STREQUAL "gtk")
+ # Left for compatibility with previous versions.
+ _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h)
+ _GTK2_FIND_INCLUDE_DIR(X11 X11/Xlib.h)
+
_GTK2_FIND_INCLUDE_DIR(GLIB glib.h)
_GTK2_FIND_INCLUDE_DIR(GLIBCONFIG glibconfig.h)
_GTK2_FIND_LIBRARY (GLIB glib false true)
@@ -680,11 +686,15 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
_GTK2_FIND_LIBRARY (PANGOFT2 pangoft2 false true)
_GTK2_ADD_TARGET (PANGOFT2 GTK2_DEPENDS pango gobject glib
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
_GTK2_FIND_LIBRARY (PANGOXFT pangoxft false true)
_GTK2_ADD_TARGET (PANGOXFT GTK2_DEPENDS pangoft2 pango gobject glib
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
_GTK2_FIND_INCLUDE_DIR(GDK gdk/gdk.h)
_GTK2_FIND_INCLUDE_DIR(GDKCONFIG gdkconfig.h)
@@ -715,9 +725,6 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
_GTK2_ADD_TARGET (GTK GTK2_DEPENDS gdk atk pangoft2 pango gdk_pixbuf gthread gobject glib
GTK2_OPTIONAL_DEPENDS gio pangocairo cairo)
- # Left for compatibility with previous versions. It doesn't seem to be required
- _GTK2_FIND_INCLUDE_DIR(FONTCONFIG fontconfig/fontconfig.h)
-
elseif(_GTK2_component STREQUAL "gtkmm")
_GTK2_FIND_INCLUDE_DIR(SIGC++ sigc++/sigc++.h)
@@ -743,29 +750,36 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
_GTK2_FIND_INCLUDE_DIR(CAIROMMCONFIG cairommconfig.h)
_GTK2_FIND_LIBRARY (CAIROMM cairomm true true)
_GTK2_ADD_TARGET (CAIROMM GTK2_DEPENDS cairo sigc++
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
_GTK2_FIND_INCLUDE_DIR(PANGOMM pangomm.h)
_GTK2_FIND_INCLUDE_DIR(PANGOMMCONFIG pangommconfig.h)
_GTK2_FIND_LIBRARY (PANGOMM pangomm true true)
_GTK2_ADD_TARGET (PANGOMM GTK2_DEPENDS glibmm sigc++ pango gobject glib
GTK2_OPTIONAL_DEPENDS cairomm pangocairo cairo
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
-
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
_GTK2_FIND_INCLUDE_DIR(GDKMM gdkmm.h)
_GTK2_FIND_INCLUDE_DIR(GDKMMCONFIG gdkmmconfig.h)
_GTK2_FIND_LIBRARY (GDKMM gdkmm true true)
_GTK2_ADD_TARGET (GDKMM GTK2_DEPENDS pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gobject glib
GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
_GTK2_FIND_INCLUDE_DIR(GTKMM gtkmm.h)
_GTK2_FIND_INCLUDE_DIR(GTKMMCONFIG gtkmmconfig.h)
_GTK2_FIND_LIBRARY (GTKMM gtkmm true true)
_GTK2_ADD_TARGET (GTKMM GTK2_DEPENDS atkmm gdkmm pangomm gtk glibmm sigc++ gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
elseif(_GTK2_component STREQUAL "glade")
@@ -773,7 +787,9 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
_GTK2_FIND_LIBRARY (GLADE glade false true)
_GTK2_ADD_TARGET (GLADE GTK2_DEPENDS gtk gdk atk gio pangoft2 gdk_pixbuf pango gobject glib
GTK2_OPTIONAL_DEPENDS pangocairo cairo
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
elseif(_GTK2_component STREQUAL "glademm")
@@ -782,7 +798,9 @@ foreach(_GTK2_component ${GTK2_FIND_COMPONENTS})
_GTK2_FIND_LIBRARY (GLADEMM glademm true true)
_GTK2_ADD_TARGET (GLADEMM GTK2_DEPENDS gtkmm glade atkmm gdkmm giomm pangomm glibmm sigc++ gtk gdk atk pangoft2 gdk_pixbuf pango gthread gobject glib
GTK2_OPTIONAL_DEPENDS giomm cairomm gio pangocairo cairo
- OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2})
+ OPTIONAL_INCLUDES ${FREETYPE_INCLUDE_DIR_ft2build} ${FREETYPE_INCLUDE_DIR_freetype2}
+ ${GTK2_FONTCONFIG_INCLUDE_DIR}
+ ${GTK2_X11_INCLUDE_DIR})
else()
message(FATAL_ERROR "Unknown GTK2 component ${_component}")
diff --git a/Modules/FindGTest.cmake b/Modules/FindGTest.cmake
index c00a750..6a36ea6 100644
--- a/Modules/FindGTest.cmake
+++ b/Modules/FindGTest.cmake
@@ -79,7 +79,7 @@
# extra_args = Pass a list of extra arguments to be passed to
# executable enclosed in quotes (or "" for none)
# ARGN = A list of source files to search for tests & test
-# fixtures.
+# fixtures. Or AUTO to find them from executable target.
#
#
#
@@ -88,7 +88,7 @@
# Example:
# set(FooTestArgs --foo 1 --bar 2)
# add_executable(FooTest FooUnitTest.cc)
-# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" FooUnitTest.cc)
+# GTEST_ADD_TESTS(FooTest "${FooTestArgs}" AUTO)
#=============================================================================
# Copyright 2009 Kitware, Inc.
@@ -111,12 +111,30 @@ function(GTEST_ADD_TESTS executable extra_args)
if(NOT ARGN)
message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
endif()
+ if(ARGN STREQUAL "AUTO")
+ # obtain sources used for building that executable
+ get_property(ARGN TARGET ${executable} PROPERTY SOURCES)
+ endif()
+ set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*")
+ set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
foreach(source ${ARGN})
file(READ "${source}" contents)
- string(REGEX MATCHALL "TEST_?F?\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+ string(REGEX MATCHALL "${gtest_test_type_regex}\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
foreach(hit ${found_tests})
- string(REGEX REPLACE ".*\\( *([A-Za-z_0-9]+), *([A-Za-z_0-9]+) *\\).*" "\\1.\\2" test_name ${hit})
- add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
+ string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
+
+ # Parameterized tests have a different signature for the filter
+ if(${test_type} STREQUAL "TEST_P")
+ string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit})
+ elseif(${test_type} STREQUAL "TEST_F" OR ${test_type} STREQUAL "TEST")
+ string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit})
+ elseif(${test_type} STREQUAL "TYPED_TEST")
+ string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit})
+ else()
+ message(WARNING "Could not parse GTest ${hit} for adding to CTest.")
+ continue()
+ endif()
+ add_test(${test_name} ${executable} --gtest_filter=${test_name} ${extra_args})
endforeach()
endforeach()
endfunction()
diff --git a/Modules/FindGettext.cmake b/Modules/FindGettext.cmake
index 6a1e36e..7ab867b 100644
--- a/Modules/FindGettext.cmake
+++ b/Modules/FindGettext.cmake
@@ -71,8 +71,8 @@ if(GETTEXT_MSGMERGE_EXECUTABLE)
OUTPUT_VARIABLE gettext_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if (gettext_version MATCHES "^msgmerge \\(.*\\) [0-9]")
- string(REGEX REPLACE "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*" "\\1" GETTEXT_VERSION_STRING "${gettext_version}")
+ if (gettext_version MATCHES "^msgmerge \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
+ set(GETTEXT_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
unset(gettext_version)
endif()
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 2903bf8..0d58e13 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -162,7 +162,7 @@ macro( _HDF5_parse_compile_line
)
foreach( IPATH ${include_path_flags} )
string( REGEX REPLACE "^-I" "" IPATH ${IPATH} )
- string( REGEX REPLACE "//" "/" IPATH ${IPATH} )
+ string( REPLACE "//" "/" IPATH ${IPATH} )
list( APPEND ${include_paths} ${IPATH} )
endforeach()
@@ -179,7 +179,7 @@ macro( _HDF5_parse_compile_line
foreach( LPATH ${library_path_flags} )
string( REGEX REPLACE "^-L" "" LPATH ${LPATH} )
- string( REGEX REPLACE "//" "/" LPATH ${LPATH} )
+ string( REPLACE "//" "/" LPATH ${LPATH} )
list( APPEND ${library_paths} ${LPATH} )
endforeach()
@@ -253,7 +253,7 @@ if( NOT HDF5_FOUND )
list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} )
# find the HDF5 include directories
- if(${LANGUAGE} MATCHES "Fortran.*")
+ if(${LANGUAGE} MATCHES "Fortran")
set(HDF5_INCLUDE_FILENAME hdf5.mod)
else()
set(HDF5_INCLUDE_FILENAME hdf5.h)
diff --git a/Modules/FindHg.cmake b/Modules/FindHg.cmake
index a1fb33f..c418afd 100644
--- a/Modules/FindHg.cmake
+++ b/Modules/FindHg.cmake
@@ -2,7 +2,7 @@
# FindHg
# ------
#
-#
+# Extract information from a mercurial working copy.
#
# The module defines the following variables:
#
@@ -12,6 +12,20 @@
# HG_FOUND - true if the command line client was found
# HG_VERSION_STRING - the version of mercurial found
#
+# If the command line client executable is found the following macro is defined:
+#
+# ::
+#
+# HG_WC_INFO(<dir> <var-prefix>)
+#
+# Hg_WC_INFO extracts information of a mercurial working copy
+# at a given location. This macro defines the following variables:
+#
+# ::
+#
+# <var-prefix>_WC_CHANGESET - current changeset
+# <var-prefix>_WC_REVISION - current revision
+#
# Example usage:
#
# ::
@@ -19,11 +33,15 @@
# find_package(Hg)
# if(HG_FOUND)
# message("hg found: ${HG_EXECUTABLE}")
+# HG_WC_INFO(${PROJECT_SOURCE_DIR} Project)
+# message("Current revision is ${Project_WC_REVISION}")
+# message("Current changeset is ${Project_WC_CHANGESET}")
# endif()
#=============================================================================
# Copyright 2010-2012 Kitware, Inc.
# Copyright 2012 Rolf Eike Beer <eike@sf-mail.de>
+# Copyright 2014 Matthaeus G. Chajdas
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -37,6 +55,8 @@
find_program(HG_EXECUTABLE
NAMES hg
+ PATHS
+ [HKEY_LOCAL_MACHINE\\Software\\TortoiseHG]
PATH_SUFFIXES Mercurial
DOC "hg command line client"
)
@@ -51,6 +71,21 @@ if(HG_EXECUTABLE)
set(HG_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
unset(hg_version)
+
+ macro(HG_WC_INFO dir prefix)
+ execute_process(COMMAND ${HG_EXECUTABLE} id -i -n
+ WORKING_DIRECTORY ${dir}
+ RESULT_VARIABLE hg_id_result
+ ERROR_VARIABLE hg_id_error
+ OUTPUT_VARIABLE ${prefix}_WC_DATA
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(NOT ${hg_id_result} EQUAL 0)
+ message(SEND_ERROR "Command \"${HG_EXECUTBALE} id -n\" in directory ${dir} failed with output:\n${hg_id_error}")
+ endif()
+
+ string(REGEX REPLACE "([0-9a-f]+)\\+? [0-9]+\\+?" "\\1" ${prefix}_WC_CHANGESET ${${prefix}_WC_DATA})
+ string(REGEX REPLACE "[0-9a-f]+\\+? ([0-9]+)\\+?" "\\1" ${prefix}_WC_REVISION ${${prefix}_WC_DATA})
+ endmacro(HG_WC_INFO)
endif()
# Handle the QUIETLY and REQUIRED arguments and set HG_FOUND to TRUE if
diff --git a/Modules/FindIcotool.cmake b/Modules/FindIcotool.cmake
index e29fe2e..a7c5a64 100644
--- a/Modules/FindIcotool.cmake
+++ b/Modules/FindIcotool.cmake
@@ -37,7 +37,7 @@ if(ICOTOOL_EXECUTABLE)
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
- if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*).*")
+ if("${_icotool_version}" MATCHES "^icotool \\([^\\)]*\\) ([0-9\\.]+[^ \n]*)")
set( ICOTOOL_VERSION_STRING
"${CMAKE_MATCH_1}"
)
diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake
index 1e7bda5..4f0e687 100644
--- a/Modules/FindImageMagick.cmake
+++ b/Modules/FindImageMagick.cmake
@@ -221,8 +221,8 @@ if(ImageMagick_mogrify_EXECUTABLE)
OUTPUT_VARIABLE imagemagick_version
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
- if(imagemagick_version MATCHES "^Version: ImageMagick [0-9]")
- string(REGEX REPLACE "^Version: ImageMagick ([-0-9\\.]+).*" "\\1" ImageMagick_VERSION_STRING "${imagemagick_version}")
+ if(imagemagick_version MATCHES "^Version: ImageMagick ([-0-9\\.]+)")
+ set(ImageMagick_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
unset(imagemagick_version)
endif()
diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake
index a488c46..0bd7eb0 100644
--- a/Modules/FindJava.cmake
+++ b/Modules/FindJava.cmake
@@ -128,18 +128,15 @@ if(Java_JAVA_EXECUTABLE)
# 3. GCJ 1.5
# 4. Kaffe 1.4.2
# 5. OpenJDK 1.7.x on OpenBSD
- if(var MATCHES "java version \"[0-9]+\\.[0-9]+\\.[0-9_.]+.*\".*")
+ if(var MATCHES "java version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\"")
# This is most likely Sun / OpenJDK, or maybe GCJ-java compat layer
- string( REGEX REPLACE ".* version \"([0-9]+\\.[0-9]+\\.[0-9_.]+.*)\".*"
- "\\1" Java_VERSION_STRING "${var}" )
- elseif(var MATCHES "java full version \"kaffe-[0-9]+\\.[0-9]+\\.[0-9_]+\".*")
+ set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+ elseif(var MATCHES "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
# Kaffe style
- string( REGEX REPLACE "java full version \"kaffe-([0-9]+\\.[0-9]+\\.[0-9_]+).*"
- "\\1" Java_VERSION_STRING "${var}" )
- elseif(var MATCHES "openjdk version \"[0-9]+\\.[0-9]+\\.[0-9_]+\".*")
+ set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
+ elseif(var MATCHES "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+)\"")
# OpenJDK ver 1.7.x on OpenBSD
- string( REGEX REPLACE "openjdk version \"([0-9]+\\.[0-9]+\\.[0-9_]+).*"
- "\\1" Java_VERSION_STRING "${var}" )
+ set(Java_VERSION_STRING "${CMAKE_MATCH_1}")
else()
if(NOT Java_FIND_QUIETLY)
message(WARNING "regex not supported: ${var}. Please report")
diff --git a/Modules/FindKDE3.cmake b/Modules/FindKDE3.cmake
index 159e29c..ea898a6 100644
--- a/Modules/FindKDE3.cmake
+++ b/Modules/FindKDE3.cmake
@@ -192,7 +192,7 @@ if(KDECONFIG_EXECUTABLE)
if ("${kde_version}" MATCHES "KDE: 3\\.")
execute_process(COMMAND ${KDECONFIG_EXECUTABLE} --prefix
OUTPUT_VARIABLE kdedir )
- string(REGEX REPLACE "\n" "" KDE3PREFIX "${kdedir}")
+ string(REPLACE "\n" "" KDE3PREFIX "${kdedir}")
endif ()
endif()
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index 69da4cd..b11edc3 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -54,6 +54,10 @@ include(${CMAKE_CURRENT_LIST_DIR}/CheckFunctionExists.cmake)
else ()
include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranFunctionExists.cmake)
endif ()
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
+
+cmake_push_check_state()
+set(CMAKE_REQUIRED_QUIET ${LAPACK_FIND_QUIETLY})
set(LAPACK_FOUND FALSE)
set(LAPACK95_FOUND FALSE)
@@ -155,7 +159,7 @@ endif()
if(BLAS_FOUND)
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
- if ($ENV{BLA_VENDOR} MATCHES ".+")
+ if (NOT $ENV{BLA_VENDOR} STREQUAL "")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else ()
if(NOT BLA_VENDOR)
@@ -179,7 +183,7 @@ endif ()
#acml lapack
- if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
+ if (BLA_VENDOR MATCHES "ACML" OR BLA_VENDOR STREQUAL "All")
if (BLAS_LIBRARIES MATCHES ".+acml.+")
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif ()
@@ -229,7 +233,7 @@ if (BLA_VENDOR STREQUAL "Generic" OR
endif ()
endif ()
#intel lapack
-if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
+if (BLA_VENDOR MATCHES "Intel" OR BLA_VENDOR STREQUAL "All")
if (NOT WIN32)
set(LM "-lm")
endif ()
@@ -347,4 +351,5 @@ else()
endif()
endif()
+cmake_pop_check_state()
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake
index be01594..742b851 100644
--- a/Modules/FindLibLZMA.cmake
+++ b/Modules/FindLibLZMA.cmake
@@ -55,9 +55,12 @@ endif()
# Avoid using old codebase
if (LIBLZMA_LIBRARY)
include(${CMAKE_CURRENT_LIST_DIR}/CheckLibraryExists.cmake)
+ set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+ set(CMAKE_REQUIRED_QUIET ${LibLZMA_FIND_QUIETLY})
CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_auto_decoder "" LIBLZMA_HAS_AUTO_DECODER)
CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_easy_encoder "" LIBLZMA_HAS_EASY_ENCODER)
CHECK_LIBRARY_EXISTS(${LIBLZMA_LIBRARY} lzma_lzma_preset "" LIBLZMA_HAS_LZMA_PRESET)
+ set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index c8d46ba..6e15f3b 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -330,7 +330,7 @@ function (interrogate_mpi_compiler lang try_libs)
string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}")
foreach(IPATH ${MPI_ALL_INCLUDE_PATHS})
string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH})
- string(REGEX REPLACE "//" "/" IPATH ${IPATH})
+ string(REPLACE "//" "/" IPATH ${IPATH})
list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH})
endforeach()
@@ -354,7 +354,7 @@ function (interrogate_mpi_compiler lang try_libs)
set(MPI_LINK_PATH)
foreach(LPATH ${MPI_ALL_LINK_PATHS})
string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH})
- string(REGEX REPLACE "//" "/" LPATH ${LPATH})
+ string(REPLACE "//" "/" LPATH ${LPATH})
list(APPEND MPI_LINK_PATH ${LPATH})
endforeach()
@@ -378,19 +378,14 @@ function (interrogate_mpi_compiler lang try_libs)
# Extract the set of libraries to link against from the link command
# line
string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}")
+
# add the compiler implicit directories because some compilers
# such as the intel compiler have libraries that show up
# in the showme list that can only be found in the implicit
- # link directories of the compiler. Do this for C++ and C
- # compilers if the implicit link directories are defined.
- if (DEFINED CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES)
- set(MPI_LINK_PATH
- "${MPI_LINK_PATH};${CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES}")
- endif ()
-
- if (DEFINED CMAKE_C_IMPLICIT_LINK_DIRECTORIES)
+ # link directories of the compiler.
+ if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES)
set(MPI_LINK_PATH
- "${MPI_LINK_PATH};${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}")
+ "${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}")
endif ()
# Determine full path names for all of the libraries that one needs
diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake
new file mode 100644
index 0000000..b5eed9a
--- /dev/null
+++ b/Modules/FindOpenCL.cmake
@@ -0,0 +1,135 @@
+#.rst:
+# FindOpenCL
+# ----------
+#
+# Try to find OpenCL
+#
+# Once done this will define::
+#
+# OpenCL_FOUND - True if OpenCL was found
+# OpenCL_INCLUDE_DIRS - include directories for OpenCL
+# OpenCL_LIBRARIES - link against this library to use OpenCL
+# OpenCL_VERSION_STRING - Highest supported OpenCL version (eg. 1.2)
+# OpenCL_VERSION_MAJOR - The major version of the OpenCL implementation
+# OpenCL_VERSION_MINOR - The minor version of the OpenCL implementation
+#
+# The module will also define two cache variables::
+#
+# OpenCL_INCLUDE_DIR - the OpenCL include directory
+# OpenCL_LIBRARY - the path to the OpenCL library
+#
+
+#=============================================================================
+# Copyright 2014 Matthaeus G. Chajdas
+#
+# 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.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+function(_FIND_OPENCL_VERSION)
+ include(CheckSymbolExists)
+ include(CMakePushCheckState)
+ set(CMAKE_REQUIRED_QUIET ${OpenCL_FIND_QUIETLY})
+
+ CMAKE_PUSH_CHECK_STATE()
+ foreach(VERSION "2_0" "1_2" "1_1" "1_0")
+ set(CMAKE_REQUIRED_INCLUDES "${OpenCL_INCLUDE_DIR}")
+
+ if(APPLE)
+ CHECK_SYMBOL_EXISTS(
+ CL_VERSION_${VERSION}
+ "${OpenCL_INCLUDE_DIR}/OpenCL/cl.h"
+ OPENCL_VERSION_${VERSION})
+ else()
+ CHECK_SYMBOL_EXISTS(
+ CL_VERSION_${VERSION}
+ "${OpenCL_INCLUDE_DIR}/CL/cl.h"
+ OPENCL_VERSION_${VERSION})
+ endif()
+
+ if(OPENCL_VERSION_${VERSION})
+ string(REPLACE "_" "." VERSION "${VERSION}")
+ set(OpenCL_VERSION_STRING ${VERSION} PARENT_SCOPE)
+ string(REGEX MATCHALL "[0-9]+" version_components "${VERSION}")
+ list(GET version_components 0 major_version)
+ list(GET version_components 1 minor_version)
+ set(OpenCL_VERSION_MAJOR ${major_version} PARENT_SCOPE)
+ set(OpenCL_VERSION_MINOR ${minor_version} PARENT_SCOPE)
+ break()
+ endif()
+ endforeach()
+ CMAKE_POP_CHECK_STATE()
+endfunction()
+
+find_path(OpenCL_INCLUDE_DIR
+ NAMES
+ CL/cl.h OpenCL/cl.h
+ PATHS ENV
+ "PROGRAMFILES(X86)"
+ AMDAPPSDKROOT
+ INTELOCLSDKROOT
+ NVSDKCOMPUTE_ROOT
+ CUDA_PATH
+ ATISTREAMSDKROOT
+ PATH_SUFFIXES
+ OpenCL/common/inc
+ "AMD APP/include")
+
+_FIND_OPENCL_VERSION()
+
+if(WIN32)
+ if(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ find_library(OpenCL_LIBRARY
+ NAMES OpenCL
+ PATHS ENV
+ "PROGRAMFILES(X86)"
+ AMDAPPSDKROOT
+ INTELOCLSDKROOT
+ CUDA_PATH
+ NVSDKCOMPUTE_ROOT
+ ATISTREAMSDKROOT
+ PATH_SUFFIXES
+ "AMD APP/lib/x86"
+ lib/x86
+ lib/Win32
+ OpenCL/common/lib/Win32)
+ elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ find_library(OpenCL_LIBRARY
+ NAMES OpenCL
+ PATHS ENV
+ "PROGRAMFILES(X86)"
+ AMDAPPSDKROOT
+ INTELOCLSDKROOT
+ CUDA_PATH
+ NVSDKCOMPUTE_ROOT
+ ATISTREAMSDKROOT
+ PATH_SUFFIXES
+ "AMD APP/lib/x86_64"
+ lib/x86_64
+ lib/x64
+ OpenCL/common/lib/x64)
+ endif()
+else()
+ find_library(OpenCL_LIBRARY
+ NAMES OpenCL)
+endif()
+
+set(OpenCL_LIBRARIES ${OpenCL_LIBRARY})
+set(OpenCL_INCLUDE_DIRS ${OpenCL_INCLUDE_DIR})
+
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(
+ OpenCL
+ FOUND_VAR OpenCL_FOUND
+ REQUIRED_VARS OpenCL_LIBRARY OpenCL_INCLUDE_DIR
+ VERSION_VAR OpenCL_VERSION_STRING)
+
+mark_as_advanced(
+ OpenCL_INCLUDE_DIR
+ OpenCL_LIBRARY)
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index fead4a6..30972ae 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -39,6 +39,8 @@
# License text for the above reference.)
set(_OPENMP_REQUIRED_VARS)
+set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+set(CMAKE_REQUIRED_QUIET ${OpenMP_FIND_QUIETLY})
function(_OPENMP_FLAG_CANDIDATES LANG)
set(OpenMP_FLAG_CANDIDATES
@@ -116,7 +118,9 @@ if(CMAKE_C_COMPILER_LOADED)
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
unset(OpenMP_FLAG_DETECTED CACHE)
- message(STATUS "Try OpenMP C flag = [${FLAG}]")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Try OpenMP C flag = [${FLAG}]")
+ endif()
check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if(OpenMP_FLAG_DETECTED)
@@ -150,7 +154,9 @@ if(CMAKE_CXX_COMPILER_LOADED)
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
unset(OpenMP_FLAG_DETECTED CACHE)
- message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
+ if(NOT CMAKE_REQUIRED_QUIET)
+ message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
+ endif()
check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
if(OpenMP_FLAG_DETECTED)
@@ -167,6 +173,8 @@ if(CMAKE_CXX_COMPILER_LOADED)
unset(OpenMP_CXX_TEST_SOURCE)
endif()
+set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
+
if(_OPENMP_REQUIRED_VARS)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
diff --git a/Modules/FindPNG.cmake b/Modules/FindPNG.cmake
index 873c3de..fa04bf0 100644
--- a/Modules/FindPNG.cmake
+++ b/Modules/FindPNG.cmake
@@ -56,10 +56,8 @@ if(ZLIB_FOUND)
list(APPEND PNG_NAMES png libpng)
unset(PNG_NAMES_DEBUG)
set(_PNG_VERSION_SUFFIXES 17 16 15 14 12)
- if (PNG_FIND_VERSION MATCHES "^[0-9]+\\.[0-9]+(\\..*)?$")
- string(REGEX REPLACE
- "^([0-9]+)\\.([0-9]+).*" "\\1\\2"
- _PNG_VERSION_SUFFIX_MIN "${PNG_FIND_VERSION}")
+ if (PNG_FIND_VERSION MATCHES "^([0-9]+)\\.([0-9]+)(\\..*)?$")
+ set(_PNG_VERSION_SUFFIX_MIN "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
if (PNG_FIND_VERSION_EXACT)
set(_PNG_VERSION_SUFFIXES ${_PNG_VERSION_SUFFIX_MIN})
else ()
diff --git a/Modules/FindPackageMessage.cmake b/Modules/FindPackageMessage.cmake
index b6a58e4..a0349d3 100644
--- a/Modules/FindPackageMessage.cmake
+++ b/Modules/FindPackageMessage.cmake
@@ -42,7 +42,7 @@
function(FIND_PACKAGE_MESSAGE pkg msg details)
# Avoid printing a message repeatedly for the same find result.
if(NOT ${pkg}_FIND_QUIETLY)
- string(REGEX REPLACE "[\n]" "" details "${details}")
+ string(REPLACE "\n" "" details "${details}")
set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg})
if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}")
# The message has not yet been printed.
diff --git a/Modules/FindPerl.cmake b/Modules/FindPerl.cmake
index 3fd5d8e..70284b6 100644
--- a/Modules/FindPerl.cmake
+++ b/Modules/FindPerl.cmake
@@ -70,9 +70,9 @@ if(PERL_EXECUTABLE)
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl.*[ \\(]v([0-9\\._]+)[ \\)]")
- string(REGEX REPLACE ".*This is perl.*[ \\(]v([0-9\\._]+)[ \\)].*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+ set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
elseif(NOT PERL_VERSION_RESULT_VARIABLE AND PERL_VERSION_OUTPUT_VARIABLE MATCHES "This is perl, version ([0-9\\._]+) +")
- string(REGEX REPLACE ".*This is perl, version ([0-9\\._]+) +.*" "\\1" PERL_VERSION_STRING ${PERL_VERSION_OUTPUT_VARIABLE})
+ set(PERL_VERSION_STRING "${CMAKE_MATCH_1}")
endif()
endif()
endif()
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index e6fdefe..d728324 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -2,140 +2,20 @@
# FindPkgConfig
# -------------
#
-# a pkg-config module for CMake
+# A `pkg-config` module for CMake.
#
+# Finds the ``pkg-config`` executable and add the
+# :command:`pkg_check_modules` and :command:`pkg_search_module`
+# commands.
#
-#
-# Usage:
-#
-# ::
-#
-# pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
-# checks for all the given modules
-#
-#
-#
-# ::
-#
-# pkg_search_module(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
-# checks for given modules and uses the first working one
-#
-#
-#
-# When the 'REQUIRED' argument was set, macros will fail with an error
-# when module(s) could not be found
-#
-# When the 'QUIET' argument is set, no status messages will be printed.
-#
-# It sets the following variables:
-#
-# ::
-#
-# PKG_CONFIG_FOUND ... if pkg-config executable was found
-# PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
-# PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
-# (since CMake 2.8.8)
-#
-#
-#
-# For the following variables two sets of values exist; first one is the
-# common one and has the given PREFIX. The second set contains flags
-# which are given out when pkgconfig was called with the '--static'
-# option.
-#
-# ::
-#
-# <XPREFIX>_FOUND ... set to 1 if module(s) exist
-# <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
-# <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
-# <XPREFIX>_LDFLAGS ... all required linker flags
-# <XPREFIX>_LDFLAGS_OTHER ... all other linker flags
-# <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
-# <XPREFIX>_CFLAGS ... all required cflags
-# <XPREFIX>_CFLAGS_OTHER ... the other compiler flags
-#
-#
-#
-# ::
-#
-# <XPREFIX> = <PREFIX> for common case
-# <XPREFIX> = <PREFIX>_STATIC for static linking
-#
-#
-#
-# There are some special variables whose prefix depends on the count of
-# given modules. When there is only one module, <PREFIX> stays
-# unchanged. When there are multiple modules, the prefix will be
-# changed to <PREFIX>_<MODNAME>:
-#
-# ::
-#
-# <XPREFIX>_VERSION ... version of the module
-# <XPREFIX>_PREFIX ... prefix-directory of the module
-# <XPREFIX>_INCLUDEDIR ... include-dir of the module
-# <XPREFIX>_LIBDIR ... lib-dir of the module
-#
-#
-#
-# ::
-#
-# <XPREFIX> = <PREFIX> when |MODULES| == 1, else
-# <XPREFIX> = <PREFIX>_<MODNAME>
-#
-#
-#
-# A <MODULE> parameter can have the following formats:
-#
-# ::
-#
-# {MODNAME} ... matches any version
-# {MODNAME}>={VERSION} ... at least version <VERSION> is required
-# {MODNAME}={VERSION} ... exactly version <VERSION> is required
-# {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
-#
-#
-#
-# Examples
-#
-# ::
-#
-# pkg_check_modules (GLIB2 glib-2.0)
-#
-#
-#
-# ::
-#
-# pkg_check_modules (GLIB2 glib-2.0>=2.10)
-# requires at least version 2.10 of glib2 and defines e.g.
-# GLIB2_VERSION=2.10.3
-#
-#
-#
-# ::
-#
-# pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
-# requires both glib2 and gtk2, and defines e.g.
-# FOO_glib-2.0_VERSION=2.10.3
-# FOO_gtk+-2.0_VERSION=2.8.20
-#
-#
-#
-# ::
-#
-# pkg_check_modules (XRENDER REQUIRED xrender)
-# defines e.g.:
-# XRENDER_LIBRARIES=Xrender;X11
-# XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp
-#
-#
-#
-# ::
-#
-# pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
+# In order to find the ``pkg-config`` executable, it uses the
+# :variable:`PKG_CONFIG_EXECUTABLE` variable or the ``PKG_CONFIG``
+# environment variable first.
#=============================================================================
-# Copyright 2006-2009 Kitware, Inc.
-# Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+# Copyright 2006-2014 Kitware, Inc.
+# Copyright 2014 Christoph Grüninger <foss@grueninger.de>
+# Copyright 2006 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -150,6 +30,10 @@
### Common stuff ####
set(PKG_CONFIG_VERSION 1)
+# find pkg-config, use PKG_CONFIG if set
+if((NOT PKG_CONFIG_EXECUTABLE) AND (NOT "$ENV{PKG_CONFIG}" STREQUAL ""))
+ set(PKG_CONFIG_EXECUTABLE "$ENV{PKG_CONFIG}" CACHE FILEPATH "pkg-config executable")
+endif()
find_program(PKG_CONFIG_EXECUTABLE NAMES pkg-config DOC "pkg-config executable")
mark_as_advanced(PKG_CONFIG_EXECUTABLE)
@@ -215,9 +99,20 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp)
endmacro()
# Splits given arguments into options and a package list
-macro(_pkgconfig_parse_options _result _is_req _is_silent)
+macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path)
set(${_is_req} 0)
set(${_is_silent} 0)
+ set(${_no_cmake_path} 0)
+ set(${_no_cmake_environment_path} 0)
+ if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+ if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH)
+ set(${_no_cmake_path} 1)
+ set(${_no_cmake_environment_path} 1)
+ endif()
+ elseif(${CMAKE_MINIMUM_REQUIRED_VERSION} VERSION_LESS 3.1)
+ set(${_no_cmake_path} 1)
+ set(${_no_cmake_environment_path} 1)
+ endif()
foreach(_pkg ${ARGN})
if (_pkg STREQUAL "REQUIRED")
@@ -226,15 +121,48 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent)
if (_pkg STREQUAL "QUIET")
set(${_is_silent} 1)
endif ()
+ if (_pkg STREQUAL "NO_CMAKE_PATH")
+ set(${_no_cmake_path} 1)
+ endif()
+ if (_pkg STREQUAL "NO_CMAKE_ENVIRONMENT_PATH")
+ set(${_no_cmake_environment_path} 1)
+ endif()
endforeach()
set(${_result} ${ARGN})
list(REMOVE_ITEM ${_result} "REQUIRED")
list(REMOVE_ITEM ${_result} "QUIET")
+ list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH")
+ list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH")
endmacro()
+# Add the content of a variable or an environment variable to a list of
+# paths
+# Usage:
+# - _pkgconfig_add_extra_path(_extra_paths VAR)
+# - _pkgconfig_add_extra_path(_extra_paths ENV VAR)
+function(_pkgconfig_add_extra_path _extra_paths_var _var)
+ set(_is_env 0)
+ if(_var STREQUAL "ENV")
+ set(_var ${ARGV2})
+ set(_is_env 1)
+ endif()
+ if(NOT _is_env)
+ if(NOT "${${_var}}" STREQUAL "")
+ list(APPEND ${_extra_paths_var} ${CMAKE_PREFIX_PATH})
+ endif()
+ else()
+ if(NOT "$ENV{${_var}}" STREQUAL "")
+ file(TO_CMAKE_PATH "$ENV{${_var}}" _path)
+ list(APPEND ${_extra_paths_var} ${_path})
+ unset(_path)
+ endif()
+ endif()
+ set(${_extra_paths_var} ${${_extra_paths_var}} PARENT_SCOPE)
+endfunction()
+
###
-macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
+macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _prefix)
_pkgconfig_unset(${_prefix}_FOUND)
_pkgconfig_unset(${_prefix}_VERSION)
_pkgconfig_unset(${_prefix}_PREFIX)
@@ -273,15 +201,86 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
set(_pkg_check_modules_packages)
set(_pkg_check_modules_failed)
+ set(_extra_paths)
+
+ if(NOT _no_cmake_path)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_PREFIX_PATH)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_FRAMEWORK_PATH)
+ _pkgconfig_add_extra_path(_extra_paths CMAKE_APPBUNDLE_PATH)
+ endif()
+
+ if(NOT _no_cmake_environment_path)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_PREFIX_PATH)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_FRAMEWORK_PATH)
+ _pkgconfig_add_extra_path(_extra_paths ENV CMAKE_APPBUNDLE_PATH)
+ endif()
+
+ if(NOT "${_extra_paths}" STREQUAL "")
+ # Save the PKG_CONFIG_PATH environment variable, and add paths
+ # from the CMAKE_PREFIX_PATH variables
+ set(_pkgconfig_path_old $ENV{PKG_CONFIG_PATH})
+ set(_pkgconfig_path ${_pkgconfig_path_old})
+ if(NOT "${_pkgconfig_path}" STREQUAL "")
+ file(TO_CMAKE_PATH "${_pkgconfig_path}" _pkgconfig_path)
+ endif()
+
+ # Create a list of the possible pkgconfig subfolder (depending on
+ # the system
+ set(_lib_dirs)
+ if(NOT DEFINED CMAKE_SYSTEM_NAME
+ OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+ AND NOT CMAKE_CROSSCOMPILING))
+ if(EXISTS "/etc/debian_version") # is this a debian system ?
+ if(CMAKE_LIBRARY_ARCHITECTURE)
+ list(APPEND _lib_dirs "lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig")
+ endif()
+ else()
+ # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+ get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+ if(uselib64)
+ list(APPEND _lib_dirs "lib64/pkgconfig")
+ endif()
+ endif()
+ endif()
+ list(APPEND _lib_dirs "lib/pkgconfig")
+
+ # Check if directories exist and eventually append them to the
+ # pkgconfig path list
+ foreach(_prefix_dir ${_extra_paths})
+ foreach(_lib_dir ${_lib_dirs})
+ if(EXISTS "${_prefix_dir}/${_lib_dir}")
+ list(APPEND _pkgconfig_path "${_prefix_dir}/${_lib_dir}")
+ list(REMOVE_DUPLICATES _pkgconfig_path)
+ endif()
+ endforeach()
+ endforeach()
+
+ # Prepare and set the environment variable
+ if(NOT "${_pkgconfig_path}" STREQUAL "")
+ # remove empty values from the list
+ list(REMOVE_ITEM _pkgconfig_path "")
+ file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path)
+ if(UNIX)
+ string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}")
+ string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}")
+ endif()
+ set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+ endif()
+
+ # Unset variables
+ unset(_lib_dirs)
+ unset(_pkgconfig_path)
+ endif()
+
# iterate through module list and check whether they exist and match the required version
foreach (_pkg_check_modules_pkg ${_pkg_check_modules_list})
set(_pkg_check_modules_exist_query)
# check whether version is given
- if (_pkg_check_modules_pkg MATCHES ".*(>=|=|<=).*")
- string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\1" _pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
- string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\2" _pkg_check_modules_pkg_op "${_pkg_check_modules_pkg}")
- string(REGEX REPLACE "(.*[^><])(>=|=|<=)(.*)" "\\3" _pkg_check_modules_pkg_ver "${_pkg_check_modules_pkg}")
+ if (_pkg_check_modules_pkg MATCHES "(.*[^><])(>=|=|<=)(.*)")
+ set(_pkg_check_modules_pkg_name "${CMAKE_MATCH_1}")
+ set(_pkg_check_modules_pkg_op "${CMAKE_MATCH_2}")
+ set(_pkg_check_modules_pkg_ver "${CMAKE_MATCH_3}")
else()
set(_pkg_check_modules_pkg_name "${_pkg_check_modules_pkg}")
set(_pkg_check_modules_pkg_op)
@@ -338,7 +337,7 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
if(_pkg_check_modules_failed)
# fail when requested
if (${_is_required})
- message(SEND_ERROR "A required package was not found")
+ message(FATAL_ERROR "A required package was not found")
endif ()
else()
# when we are here, we checked whether requested modules
@@ -376,6 +375,14 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix)
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags )
_pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other )
endif()
+
+ if(NOT "${_extra_paths}" STREQUAL "")
+ # Restore the environment variable
+ set(ENV{PKG_CONFIG_PATH} ${_pkgconfig_path})
+ endif()
+
+ unset(_extra_paths)
+ unset(_pkgconfig_path_old)
else()
if (${_is_required})
message(SEND_ERROR "pkg-config tool not found")
@@ -387,23 +394,138 @@ endmacro()
### User visible macros start here
###
-###
+#[========================================[.rst:
+.. command:: pkg_check_modules
+
+ Checks for all the given modules. ::
+
+ pkg_check_modules(<PREFIX> [REQUIRED] [QUIET]
+ [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
+ <MODULE> [<MODULE>]*)
+
+
+ When the ``REQUIRED`` argument was set, macros will fail with an error
+ when module(s) could not be found.
+
+ When the ``QUIET`` argument is set, no status messages will be printed.
+
+ By default, if :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or
+ later, or if :variable:`PKG_CONFIG_USE_CMAKE_PREFIX_PATH` is set, the
+ :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_FRAMEWORK_PATH`, and
+ :variable:`CMAKE_APPBUNDLE_PATH` cache and environment variables will
+ be added to ``pkg-config`` search path.
+ The ``NO_CMAKE_PATH`` and ``NO_CMAKE_ENVIRONMENT_PATH`` arguments
+ disable this behavior for the cache variables and the environment
+ variables, respectively.
+
+ It sets the following variables: ::
+
+ PKG_CONFIG_FOUND ... if pkg-config executable was found
+ PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program
+ PKG_CONFIG_VERSION_STRING ... the version of the pkg-config program found
+ (since CMake 2.8.8)
+
+ For the following variables two sets of values exist; first one is the
+ common one and has the given PREFIX. The second set contains flags
+ which are given out when ``pkg-config`` was called with the ``--static``
+ option. ::
+
+ <XPREFIX>_FOUND ... set to 1 if module(s) exist
+ <XPREFIX>_LIBRARIES ... only the libraries (w/o the '-l')
+ <XPREFIX>_LIBRARY_DIRS ... the paths of the libraries (w/o the '-L')
+ <XPREFIX>_LDFLAGS ... all required linker flags
+ <XPREFIX>_LDFLAGS_OTHER ... all other linker flags
+ <XPREFIX>_INCLUDE_DIRS ... the '-I' preprocessor flags (w/o the '-I')
+ <XPREFIX>_CFLAGS ... all required cflags
+ <XPREFIX>_CFLAGS_OTHER ... the other compiler flags
+
+ ::
+
+ <XPREFIX> = <PREFIX> for common case
+ <XPREFIX> = <PREFIX>_STATIC for static linking
+
+ There are some special variables whose prefix depends on the count of
+ given modules. When there is only one module, <PREFIX> stays
+ unchanged. When there are multiple modules, the prefix will be
+ changed to <PREFIX>_<MODNAME>: ::
+
+ <XPREFIX>_VERSION ... version of the module
+ <XPREFIX>_PREFIX ... prefix-directory of the module
+ <XPREFIX>_INCLUDEDIR ... include-dir of the module
+ <XPREFIX>_LIBDIR ... lib-dir of the module
+
+ ::
+
+ <XPREFIX> = <PREFIX> when |MODULES| == 1, else
+ <XPREFIX> = <PREFIX>_<MODNAME>
+
+ A <MODULE> parameter can have the following formats: ::
+
+ {MODNAME} ... matches any version
+ {MODNAME}>={VERSION} ... at least version <VERSION> is required
+ {MODNAME}={VERSION} ... exactly version <VERSION> is required
+ {MODNAME}<={VERSION} ... modules must not be newer than <VERSION>
+
+ Examples
+
+ .. code-block:: cmake
+
+ pkg_check_modules (GLIB2 glib-2.0)
+
+ .. code-block:: cmake
+
+ pkg_check_modules (GLIB2 glib-2.0>=2.10)
+
+ Requires at least version 2.10 of glib2 and defines e.g.
+ ``GLIB2_VERSION=2.10.3``
+
+ .. code-block:: cmake
+
+ pkg_check_modules (FOO glib-2.0>=2.10 gtk+-2.0)
+
+ Requires both glib2 and gtk2, and defines e.g.
+ ``FOO_glib-2.0_VERSION=2.10.3`` and ``FOO_gtk+-2.0_VERSION=2.8.20``
+
+ .. code-block:: cmake
+
+ pkg_check_modules (XRENDER REQUIRED xrender)
+
+ Defines e.g.:
+ ``XRENDER_LIBRARIES=Xrender;X11`` and
+ ``XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp``
+#]========================================]
macro(pkg_check_modules _prefix _module0)
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
- _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN})
- _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules})
+ _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN})
+ _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" ${_pkg_modules})
_pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION})
endif()
endmacro()
-###
+
+#[========================================[.rst:
+.. command:: pkg_search_module
+
+ Same as :command:`pkg_check_modules`, but instead it checks for given
+ modules and uses the first working one. ::
+
+ pkg_search_module(<PREFIX> [REQUIRED] [QUIET]
+ [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH]
+ <MODULE> [<MODULE>]*)
+
+ Examples
+
+ .. code-block:: cmake
+
+ pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2)
+#]========================================]
macro(pkg_search_module _prefix _module0)
# check cached value
if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND)
set(_pkg_modules_found 0)
- _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN})
+ _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path "${_module0}" ${ARGN})
if (NOT ${_pkg_is_silent})
message(STATUS "checking for one of the modules '${_pkg_modules_alt}'")
@@ -412,7 +534,7 @@ macro(pkg_search_module _prefix _module0)
# iterate through all modules and stop at the first working one.
foreach(_pkg_alt ${_pkg_modules_alt})
if(NOT _pkg_modules_found)
- _pkg_check_modules_internal(0 1 "${_prefix}" "${_pkg_alt}")
+ _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} "${_prefix}" "${_pkg_alt}")
endif()
if (${_prefix}_FOUND)
@@ -430,6 +552,26 @@ macro(pkg_search_module _prefix _module0)
endif()
endmacro()
+
+#[========================================[.rst:
+.. variable:: PKG_CONFIG_EXECUTABLE
+
+ Path to the pkg-config executable.
+
+
+.. variable:: PKG_CONFIG_USE_CMAKE_PREFIX_PATH
+
+ Whether :command:`pkg_check_modules` and :command:`pkg_search_module`
+ should add the paths in :variable:`CMAKE_PREFIX_PATH`,
+ :variable:`CMAKE_FRAMEWORK_PATH`, and :variable:`CMAKE_APPBUNDLE_PATH`
+ cache and environment variables to ``pkg-config`` search path.
+
+ If this variable is not set, this behavior is enabled by default if
+ :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` is 3.1 or later, disabled
+ otherwise.
+#]========================================]
+
+
### Local Variables:
### mode: cmake
### End:
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index e23a58b..5e5c7b9 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -27,6 +27,10 @@
# of version numbers that should be taken into account when searching
# for Python. You need to set this variable before calling
# find_package(PythonInterp).
+#
+# If also calling find_package(PythonLibs), call find_package(PythonInterp)
+# first to get the currently active Python version by default with a consistent
+# version of PYTHON_LIBRARIES.
#=============================================================================
# Copyright 2005-2010 Kitware, Inc.
@@ -71,18 +75,23 @@ if(PythonInterp_FIND_VERSION)
else()
set(_PYTHON_FIND_OTHER_VERSIONS ${_PYTHON3_VERSIONS} ${_PYTHON2_VERSIONS} ${_PYTHON1_VERSIONS})
endif()
-
-list(APPEND _Python_NAMES python)
-
-# Search for the current active python version first
find_program(PYTHON_EXECUTABLE NAMES ${_Python_NAMES})
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
-set(_Python_VERSIONS
- ${Python_ADDITIONAL_VERSIONS}
- ${_PYTHON_FIND_OTHER_VERSIONS}
- )
+set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
+# If FindPythonInterp has already found the major and minor version,
+# insert that version next to get consistent versions of the interpreter and
+# library.
+if(DEFINED PYTHONLIBS_VERSION_STRING)
+ string(REPLACE "." ";" _PYTHONLIBS_VERSION "${PYTHONLIBS_VERSION_STRING}")
+ list(GET _PYTHONLIBS_VERSION 0 _PYTHONLIBS_VERSION_MAJOR)
+ list(GET _PYTHONLIBS_VERSION 1 _PYTHONLIBS_VERSION_MINOR)
+ list(APPEND _Python_VERSIONS ${_PYTHONLIBS_VERSION_MAJOR}.${_PYTHONLIBS_VERSION_MINOR})
+endif()
+# Search for the current active python version first
+list(APPEND _Python_VERSIONS ";")
+list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
unset(_PYTHON_FIND_OTHER_VERSIONS)
unset(_PYTHON1_VERSIONS)
@@ -91,7 +100,7 @@ unset(_PYTHON3_VERSIONS)
# Search for newest python version if python executable isn't found
if(NOT PYTHON_EXECUTABLE)
- foreach(_CURRENT_VERSION ${_Python_VERSIONS})
+ foreach(_CURRENT_VERSION IN LISTS _Python_VERSIONS)
set(_Python_NAMES python${_CURRENT_VERSION})
if(WIN32)
list(APPEND _Python_NAMES python)
@@ -129,8 +138,8 @@ if(PYTHON_EXECUTABLE)
string(REGEX REPLACE " .*" "" PYTHON_VERSION_STRING "${_VERSION}")
string(REGEX REPLACE "^([0-9]+)\\.[0-9]+.*" "\\1" PYTHON_VERSION_MAJOR "${PYTHON_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9])+.*" "\\1" PYTHON_VERSION_MINOR "${PYTHON_VERSION_STRING}")
- if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.[0-9]+.*")
- string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" PYTHON_VERSION_PATCH "${PYTHON_VERSION_STRING}")
+ if(PYTHON_VERSION_STRING MATCHES "^[0-9]+\\.[0-9]+\\.([0-9]+)")
+ set(PYTHON_VERSION_PATCH "${CMAKE_MATCH_1}")
else()
set(PYTHON_VERSION_PATCH "0")
endif()
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index 1dbc967..cc875ad 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -31,6 +31,10 @@
#
# PYTHON_LIBRARY - path to the python library
# PYTHON_INCLUDE_DIR - path to where Python.h is found
+#
+# If also calling find_package(PythonInterp), call find_package(PythonInterp)
+# first to get the currently active Python version by default with a consistent
+# version of PYTHON_LIBRARIES.
#=============================================================================
# Copyright 2001-2009 Kitware, Inc.
@@ -80,10 +84,14 @@ endif()
# Set up the versions we know about, in the order we will search. Always add
# the user supplied additional versions to the front.
-set(_Python_VERSIONS
- ${Python_ADDITIONAL_VERSIONS}
- ${_PYTHON_FIND_OTHER_VERSIONS}
- )
+# If FindPythonInterp has already found the major and minor version,
+# insert that version between the user supplied versions and the stock
+# version list.
+set(_Python_VERSIONS ${Python_ADDITIONAL_VERSIONS})
+if(DEFINED PYTHON_VERSION_MAJOR AND DEFINED PYTHON_VERSION_MINOR)
+ list(APPEND _Python_VERSIONS ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})
+endif()
+list(APPEND _Python_VERSIONS ${_PYTHON_FIND_OTHER_VERSIONS})
unset(_PYTHON_FIND_OTHER_VERSIONS)
unset(_PYTHON1_VERSIONS)
diff --git a/Modules/FindQt.cmake b/Modules/FindQt.cmake
index e893c7a..1bc0940 100644
--- a/Modules/FindQt.cmake
+++ b/Modules/FindQt.cmake
@@ -87,7 +87,7 @@ find_program(QT_QMAKE_EXECUTABLE_FINDQT NAMES qmake PATHS "${QT_SEARCH_PATH}/bin
if(QT_QMAKE_EXECUTABLE_FINDQT)
exec_program(${QT_QMAKE_EXECUTABLE_FINDQT} ARGS "-query QT_VERSION"
OUTPUT_VARIABLE QTVERSION)
- if(QTVERSION MATCHES "4.*")
+ if(QTVERSION MATCHES "4")
set(QT_QMAKE_EXECUTABLE ${QT_QMAKE_EXECUTABLE_FINDQT} CACHE PATH "Qt4 qmake program.")
set(QT4_INSTALLED TRUE)
endif()
@@ -154,12 +154,12 @@ else()
endif()
endif()
-if(DESIRED_QT_VERSION MATCHES 3)
+if(DESIRED_QT_VERSION EQUAL 3)
set(Qt3_FIND_REQUIRED ${Qt_FIND_REQUIRED})
set(Qt3_FIND_QUIETLY ${Qt_FIND_QUIETLY})
include(${CMAKE_CURRENT_LIST_DIR}/FindQt3.cmake)
endif()
-if(DESIRED_QT_VERSION MATCHES 4)
+if(DESIRED_QT_VERSION EQUAL 4)
set(Qt4_FIND_REQUIRED ${Qt_FIND_REQUIRED})
set(Qt4_FIND_QUIETLY ${Qt_FIND_QUIETLY})
include(${CMAKE_CURRENT_LIST_DIR}/FindQt4.cmake)
diff --git a/Modules/FindQt3.cmake b/Modules/FindQt3.cmake
index 6cd12c6..4fc6829 100644
--- a/Modules/FindQt3.cmake
+++ b/Modules/FindQt3.cmake
@@ -295,12 +295,12 @@ if(QT_UIC_EXECUTABLE)
endif()
set(_QT_UIC_VERSION_3 FALSE)
-if("${QTVERSION_UIC}" MATCHES ".* 3..*")
+if("${QTVERSION_UIC}" MATCHES " 3.")
set(_QT_UIC_VERSION_3 TRUE)
endif()
set(_QT_MOC_VERSION_3 FALSE)
-if("${QTVERSION_MOC}" MATCHES ".* 3..*")
+if("${QTVERSION_MOC}" MATCHES " 3.")
set(_QT_MOC_VERSION_3 TRUE)
endif()
diff --git a/Modules/FindQt4.cmake b/Modules/FindQt4.cmake
index d0515c6..e44d1d9 100644
--- a/Modules/FindQt4.cmake
+++ b/Modules/FindQt4.cmake
@@ -335,6 +335,7 @@ endif()
include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSymbolExists.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/MacroAddFileDependencies.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakePushCheckState.cmake)
set(QT_USE_FILE ${CMAKE_ROOT}/Modules/UseQt4.cmake)
@@ -613,9 +614,13 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
set(QT_LIBRARY_DIR ${QT_LIBRARY_DIR_TMP} CACHE INTERNAL "Qt library dir" FORCE)
set(QT_QTCORE_FOUND 1)
else()
- message(WARNING "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as \"${QT_LIBRARY_DIR_TMP}\" "
- "but QtCore could not be found there. "
- "Qt is NOT installed correctly for the target build environment.")
+ if(NOT Qt4_FIND_QUIETLY)
+ message(WARNING
+ "${QT_QMAKE_EXECUTABLE} reported QT_INSTALL_LIBS as "
+ "\"${QT_LIBRARY_DIR_TMP}\" "
+ "but QtCore could not be found there. "
+ "Qt is NOT installed correctly for the target build environment.")
+ endif()
set(Qt4_FOUND FALSE)
if(Qt4_FIND_REQUIRED)
message( FATAL_ERROR "Could NOT find QtCore. Check ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log for more details.")
@@ -747,11 +752,10 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
# Find out what window system we're using
#
#############################################
- # Save required variable
- set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
- set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
+ cmake_push_check_state()
# Add QT_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${QT_INCLUDE_DIR}")
+ set(CMAKE_REQUIRED_QUIET ${Qt4_FIND_QUIETLY})
# Check for Window system symbols (note: only one should end up being set)
CHECK_CXX_SYMBOL_EXISTS(Q_WS_X11 "QtCore/qglobal.h" Q_WS_X11)
CHECK_CXX_SYMBOL_EXISTS(Q_WS_WIN "QtCore/qglobal.h" Q_WS_WIN)
@@ -771,9 +775,7 @@ if (QT_QMAKE_EXECUTABLE AND QTVERSION)
endif ()
endif ()
- # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables
- set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
+ cmake_pop_check_state()
#
#############################################
diff --git a/Modules/FindSDL_image.cmake b/Modules/FindSDL_image.cmake
index e5173e3..fc2c043 100644
--- a/Modules/FindSDL_image.cmake
+++ b/Modules/FindSDL_image.cmake
@@ -54,7 +54,9 @@ find_path(SDL_IMAGE_INCLUDE_DIR SDL_image.h
HINTS
ENV SDLIMAGEDIR
ENV SDLDIR
- PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+ PATH_SUFFIXES SDL
+ # path suffixes to search inside ENV{SDLDIR}
+ include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSDL_mixer.cmake b/Modules/FindSDL_mixer.cmake
index 8f2f066..176fee6 100644
--- a/Modules/FindSDL_mixer.cmake
+++ b/Modules/FindSDL_mixer.cmake
@@ -54,7 +54,9 @@ find_path(SDL_MIXER_INCLUDE_DIR SDL_mixer.h
HINTS
ENV SDLMIXERDIR
ENV SDLDIR
- PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+ PATH_SUFFIXES SDL
+ # path suffixes to search inside ENV{SDLDIR}
+ include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSDL_net.cmake b/Modules/FindSDL_net.cmake
index e5c2cdb..ef23573 100644
--- a/Modules/FindSDL_net.cmake
+++ b/Modules/FindSDL_net.cmake
@@ -54,7 +54,9 @@ find_path(SDL_NET_INCLUDE_DIR SDL_net.h
HINTS
ENV SDLNETDIR
ENV SDLDIR
- PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+ PATH_SUFFIXES SDL
+ # path suffixes to search inside ENV{SDLDIR}
+ include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSDL_sound.cmake b/Modules/FindSDL_sound.cmake
index 3a6ab7b..8b22ff7 100644
--- a/Modules/FindSDL_sound.cmake
+++ b/Modules/FindSDL_sound.cmake
@@ -98,7 +98,9 @@ find_path(SDL_SOUND_INCLUDE_DIR SDL_sound.h
HINTS
ENV SDLSOUNDDIR
ENV SDLDIR
- PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+ PATH_SUFFIXES SDL
+ # path suffixes to search inside ENV{SDLDIR}
+ include/SDL include/SDL12 include/SDL11 include
)
find_library(SDL_SOUND_LIBRARY
diff --git a/Modules/FindSDL_ttf.cmake b/Modules/FindSDL_ttf.cmake
index 3f58ac1..4b527fa 100644
--- a/Modules/FindSDL_ttf.cmake
+++ b/Modules/FindSDL_ttf.cmake
@@ -54,7 +54,9 @@ find_path(SDL_TTF_INCLUDE_DIR SDL_ttf.h
HINTS
ENV SDLTTFDIR
ENV SDLDIR
- PATH_SUFFIXES include/SDL include/SDL12 include/SDL11 include
+ PATH_SUFFIXES SDL
+ # path suffixes to search inside ENV{SDLDIR}
+ include/SDL include/SDL12 include/SDL11 include
)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
diff --git a/Modules/FindSquish.cmake b/Modules/FindSquish.cmake
index 5cff122..4076521 100644
--- a/Modules/FindSquish.cmake
+++ b/Modules/FindSquish.cmake
@@ -184,7 +184,7 @@ if(SQUISH_CLIENT_EXECUTABLE)
execute_process(COMMAND "${SQUISH_CLIENT_EXECUTABLE}" --version
OUTPUT_VARIABLE _squishVersionOutput
ERROR_QUIET )
- if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+).*$")
+ if("${_squishVersionOutput}" MATCHES "([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(SQUISH_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(SQUISH_VERSION_MINOR "${CMAKE_MATCH_2}")
set(SQUISH_VERSION_PATCH "${CMAKE_MATCH_3}")
diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake
index ec671bf..6050dcd 100644
--- a/Modules/FindThreads.cmake
+++ b/Modules/FindThreads.cmake
@@ -37,9 +37,11 @@ include (CheckIncludeFiles)
include (CheckLibraryExists)
include (CheckSymbolExists)
set(Threads_FOUND FALSE)
+set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+set(CMAKE_REQUIRED_QUIET ${Threads_FIND_QUIETLY})
# Do we have sproc?
-if(CMAKE_SYSTEM MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
+if(CMAKE_SYSTEM_NAME MATCHES IRIX AND NOT CMAKE_THREAD_PREFER_PTHREAD)
CHECK_INCLUDE_FILES("sys/types.h;sys/prctl.h" CMAKE_HAVE_SPROC_H)
endif()
@@ -63,32 +65,31 @@ else()
set(CMAKE_THREAD_LIBS_INIT "")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
- endif()
+ else()
- if(NOT CMAKE_HAVE_THREADS_LIBRARY)
# Do we have -lpthreads
CHECK_LIBRARY_EXISTS(pthreads pthread_create "" CMAKE_HAVE_PTHREADS_CREATE)
if(CMAKE_HAVE_PTHREADS_CREATE)
set(CMAKE_THREAD_LIBS_INIT "-lpthreads")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
- endif()
-
- # Ok, how about -lpthread
- CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
- if(CMAKE_HAVE_PTHREAD_CREATE)
- set(CMAKE_THREAD_LIBS_INIT "-lpthread")
- set(CMAKE_HAVE_THREADS_LIBRARY 1)
- set(Threads_FOUND TRUE)
- endif()
+ else()
- if(CMAKE_SYSTEM MATCHES "SunOS.*")
- # On sun also check for -lthread
- CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
- if(CMAKE_HAVE_THR_CREATE)
- set(CMAKE_THREAD_LIBS_INIT "-lthread")
+ # Ok, how about -lpthread
+ CHECK_LIBRARY_EXISTS(pthread pthread_create "" CMAKE_HAVE_PTHREAD_CREATE)
+ if(CMAKE_HAVE_PTHREAD_CREATE)
+ set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(Threads_FOUND TRUE)
+
+ elseif(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ # On sun also check for -lthread
+ CHECK_LIBRARY_EXISTS(thread thr_create "" CMAKE_HAVE_THR_CREATE)
+ if(CMAKE_HAVE_THR_CREATE)
+ set(CMAKE_THREAD_LIBS_INIT "-lthread")
+ set(CMAKE_HAVE_THREADS_LIBRARY 1)
+ set(Threads_FOUND TRUE)
+ endif()
endif()
endif()
endif()
@@ -96,7 +97,7 @@ else()
if(NOT CMAKE_HAVE_THREADS_LIBRARY)
# If we did not found -lpthread, -lpthread, or -lthread, look for -pthread
- if("THREADS_HAVE_PTHREAD_ARG" MATCHES "^THREADS_HAVE_PTHREAD_ARG")
+ if("x${THREADS_HAVE_PTHREAD_ARG}" STREQUAL "x")
message(STATUS "Check if compiler accepts -pthread")
try_run(THREADS_PTHREAD_ARG THREADS_HAVE_PTHREAD_ARG
${CMAKE_BINARY_DIR}
@@ -137,13 +138,13 @@ if(CMAKE_THREAD_LIBS_INIT OR CMAKE_HAVE_LIBC_CREATE)
set(Threads_FOUND TRUE)
endif()
-if(CMAKE_SYSTEM MATCHES "Windows")
+if(CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CMAKE_USE_WIN32_THREADS_INIT 1)
set(Threads_FOUND TRUE)
endif()
if(CMAKE_USE_PTHREADS_INIT)
- if(CMAKE_SYSTEM MATCHES "HP-UX-*")
+ if(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
# Use libcma if it exists and can be used. It provides more
# symbols than the plain pthread library. CMA threads
# have actually been deprecated:
@@ -161,12 +162,12 @@ if(CMAKE_USE_PTHREADS_INIT)
set(CMAKE_USE_PTHREADS_INIT 1)
endif()
- if(CMAKE_SYSTEM MATCHES "OSF1-V*")
+ if(CMAKE_SYSTEM MATCHES "OSF1-V")
set(CMAKE_USE_PTHREADS_INIT 0)
set(CMAKE_THREAD_LIBS_INIT )
endif()
- if(CMAKE_SYSTEM MATCHES "CYGWIN_NT*")
+ if(CMAKE_SYSTEM MATCHES "CYGWIN_NT")
set(CMAKE_USE_PTHREADS_INIT 1)
set(Threads_FOUND TRUE)
set(CMAKE_THREAD_LIBS_INIT )
@@ -174,5 +175,6 @@ if(CMAKE_USE_PTHREADS_INIT)
endif()
endif()
+set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Threads DEFAULT_MSG Threads_FOUND)
diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake
index 67cecc2..3a31cf0 100644
--- a/Modules/FindX11.cmake
+++ b/Modules/FindX11.cmake
@@ -73,6 +73,8 @@ if (UNIX)
# found in tcl on the mac
set(CMAKE_FIND_FRAMEWORK_SAVE ${CMAKE_FIND_FRAMEWORK})
set(CMAKE_FIND_FRAMEWORK NEVER)
+ set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
+ set(CMAKE_REQUIRED_QUIET ${X11_FIND_QUIETLY})
set(X11_INC_SEARCH_PATH
/usr/pkg/xorg/include
/usr/X11R6/include
@@ -507,6 +509,7 @@ if (UNIX)
X11_XSync_INCLUDE_PATH
)
set(CMAKE_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK_SAVE})
+ set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
endif ()
# X11_FIND_REQUIRED_<component> could be checked too
diff --git a/Modules/FindXMLRPC.cmake b/Modules/FindXMLRPC.cmake
index e855050..1491754 100644
--- a/Modules/FindXMLRPC.cmake
+++ b/Modules/FindXMLRPC.cmake
@@ -77,10 +77,9 @@ if(XMLRPC_FOUND)
# Look for -I options.
set(XMLRPC_INCLUDE_DIRS)
foreach(flag ${XMLRPC_C_CONFIG_CFLAGS})
- if("${flag}" MATCHES "^-I")
- string(REGEX REPLACE "^-I" "" DIR "${flag}")
- file(TO_CMAKE_PATH "${DIR}" DIR)
- set(XMLRPC_INCLUDE_DIRS ${XMLRPC_INCLUDE_DIRS} "${DIR}")
+ if("${flag}" MATCHES "^-I(.+)")
+ file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR)
+ list(APPEND XMLRPC_INCLUDE_DIRS "${DIR}")
endif()
endforeach()
else()
@@ -115,13 +114,11 @@ if(XMLRPC_FOUND)
set(XMLRPC_LIBRARY_DIRS)
set(XMLRPC_LIBRARY_NAMES)
foreach(flag ${XMLRPC_C_CONFIG_LIBS})
- if("${flag}" MATCHES "^-L")
- string(REGEX REPLACE "^-L" "" DIR "${flag}")
- file(TO_CMAKE_PATH "${DIR}" DIR)
- set(XMLRPC_LIBRARY_DIRS ${XMLRPC_LIBRARY_DIRS} "${DIR}")
- elseif("${flag}" MATCHES "^-l")
- string(REGEX REPLACE "^-l" "" NAME "${flag}")
- set(XMLRPC_LIBRARY_NAMES ${XMLRPC_LIBRARY_NAMES} "${NAME}")
+ if("${flag}" MATCHES "^-L(.+)")
+ file(TO_CMAKE_PATH "${CMAKE_MATCH_1}" DIR)
+ list(APPEND XMLRPC_LIBRARY_DIRS "${DIR}")
+ elseif("${flag}" MATCHES "^-l(.+)")
+ list(APPEND XMLRPC_LIBRARY_NAMES "${CMAKE_MATCH_1}")
endif()
endforeach()
diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index 75b0076..8cc382c 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -85,7 +85,7 @@ if(ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
# only append a TWEAK version if it exists:
set(ZLIB_VERSION_TWEAK "")
- if( "${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
+ if( "${ZLIB_H}" MATCHES "ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+)")
set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
endif()
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
index 3c664e7..45596a0 100644
--- a/Modules/FindwxWidgets.cmake
+++ b/Modules/FindwxWidgets.cmake
@@ -560,7 +560,7 @@ if(wxWidgets_FIND_STYLE STREQUAL "win32")
if(WX_LIB_DIR)
# If building shared libs, define WXUSINGDLL to use dllimport.
- if(WX_LIB_DIR MATCHES ".*[dD][lL][lL].*")
+ if(WX_LIB_DIR MATCHES "[dD][lL][lL]")
set(wxWidgets_DEFINITIONS WXUSINGDLL)
DBG_MSG_V("detected SHARED/DLL tree WX_LIB_DIR=${WX_LIB_DIR}")
endif()
@@ -668,7 +668,7 @@ else()
if(_wx_result EQUAL 0)
foreach(_opt_name debug static unicode universal)
string(TOUPPER ${_opt_name} _upper_opt_name)
- if(_wx_selected_config MATCHES ".*${_opt_name}.*")
+ if(_wx_selected_config MATCHES "${_opt_name}")
set(wxWidgets_DEFAULT_${_upper_opt_name} ON)
else()
set(wxWidgets_DEFAULT_${_upper_opt_name} OFF)
diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake
index dccb26f..27f8a82 100644
--- a/Modules/FortranCInterface.cmake
+++ b/Modules/FortranCInterface.cmake
@@ -328,7 +328,7 @@ function(FortranCInterface_VERIFY)
# Error if compilers are incompatible.
if(NOT FortranCInterface_VERIFIED_${lang} AND NOT quiet)
file(READ "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" _output)
- string(REGEX REPLACE "\n" "\n " _output "${_output}")
+ string(REPLACE "\n" "\n " _output "${_output}")
message(FATAL_ERROR
"The Fortran compiler:\n ${CMAKE_Fortran_COMPILER}\n"
"and the ${lang} compiler:\n ${CMAKE_${lang}_COMPILER}\n"
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index afeb9c5..ceb1db4 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -69,9 +69,8 @@ if(FortranCInterface_EXE)
file(STRINGS "${FortranCInterface_EXE}" _info_strings
LIMIT_COUNT 8 REGEX "INFO:[^[]*\\[")
foreach(info ${_info_strings})
- if("${info}" MATCHES ".*INFO:symbol\\[([^]]*)\\].*")
- string(REGEX REPLACE ".*INFO:symbol\\[([^]]*)\\].*" "\\1" symbol "${info}")
- list(APPEND FortranCInterface_SYMBOLS ${symbol})
+ if("${info}" MATCHES "INFO:symbol\\[([^]]*)\\]")
+ list(APPEND FortranCInterface_SYMBOLS ${CMAKE_MATCH_1})
endif()
endforeach()
elseif(NOT _result)
diff --git a/Modules/GetPrerequisites.cmake b/Modules/GetPrerequisites.cmake
index ac649e9..05c2edb 100644
--- a/Modules/GetPrerequisites.cmake
+++ b/Modules/GetPrerequisites.cmake
@@ -509,10 +509,10 @@ function(gp_resolved_file_type original_file file exepath dirs type_var)
if(WIN32)
string(TOLOWER "$ENV{SystemRoot}" sysroot)
- string(REGEX REPLACE "\\\\" "/" sysroot "${sysroot}")
+ file(TO_CMAKE_PATH "${sysroot}" sysroot)
string(TOLOWER "$ENV{windir}" windir)
- string(REGEX REPLACE "\\\\" "/" windir "${windir}")
+ file(TO_CMAKE_PATH "${windir}" windir)
if(lower MATCHES "^(${sysroot}/sys(tem|wow)|${windir}/sys(tem|wow)|(.*/)*msvc[^/]+dll)")
set(is_system 1)
@@ -772,8 +772,8 @@ function(get_prerequisites target prerequisites_var exclude_system recurse exepa
# Convert to a list of lines:
#
- string(REGEX REPLACE ";" "\\\\;" candidates "${gp_cmd_ov}")
- string(REGEX REPLACE "\n" "${eol_char};" candidates "${candidates}")
+ string(REPLACE ";" "\\;" candidates "${gp_cmd_ov}")
+ string(REPLACE "\n" "${eol_char};" candidates "${candidates}")
# check for install id and remove it from list, since otool -L can include a
# reference to itself
diff --git a/Modules/InstallRequiredSystemLibraries.cmake b/Modules/InstallRequiredSystemLibraries.cmake
index 013a028..4b551e6 100644
--- a/Modules/InstallRequiredSystemLibraries.cmake
+++ b/Modules/InstallRequiredSystemLibraries.cmake
@@ -366,18 +366,18 @@ endif()
if(WATCOM)
get_filename_component( CompilerPath ${CMAKE_C_COMPILER} PATH )
- if(WATCOM17)
- set( __install__libs ${CompilerPath}/clbr17.dll
- ${CompilerPath}/mt7r17.dll ${CompilerPath}/plbr17.dll )
- endif()
- if(WATCOM18)
- set( __install__libs ${CompilerPath}/clbr18.dll
- ${CompilerPath}/mt7r18.dll ${CompilerPath}/plbr18.dll )
- endif()
- if(WATCOM19)
- set( __install__libs ${CompilerPath}/clbr19.dll
- ${CompilerPath}/mt7r19.dll ${CompilerPath}/plbr19.dll )
+ if(CMAKE_C_COMPILER_VERSION)
+ set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
+ else()
+ set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
endif()
+ string(REGEX MATCHALL "[0-9]+" _watcom_version_list "${_compiler_version}")
+ list(GET _watcom_version_list 0 _watcom_major)
+ list(GET _watcom_version_list 1 _watcom_minor)
+ set( __install__libs
+ ${CompilerPath}/clbr${_watcom_major}${_watcom_minor}.dll
+ ${CompilerPath}/mt7r${_watcom_major}${_watcom_minor}.dll
+ ${CompilerPath}/plbr${_watcom_major}${_watcom_minor}.dll )
foreach(lib
${__install__libs}
)
diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake
new file mode 100644
index 0000000..92d262c
--- /dev/null
+++ b/Modules/Internal/FeatureTesting.cmake
@@ -0,0 +1,57 @@
+
+macro(record_compiler_features lang compile_flags feature_list)
+ include("${CMAKE_ROOT}/Modules/Compiler/${CMAKE_${lang}_COMPILER_ID}-${lang}-FeatureTests.cmake" OPTIONAL)
+
+ string(TOLOWER ${lang} lang_lc)
+ file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin")
+ file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "
+ extern const char features[] = {\"\"\n")
+ foreach(feature ${CMAKE_${lang}_KNOWN_FEATURES})
+ if (_cmake_feature_test_${feature})
+ if (${_cmake_feature_test_${feature}} STREQUAL 1)
+ set(_feature_condition "\"1\" ")
+ else()
+ set(_feature_condition "#if ${_cmake_feature_test_${feature}}\n\"1\"\n#else\n\"0\"\n#endif\n")
+ endif()
+ file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n")
+ endif()
+ endforeach()
+ file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}"
+ "\n};\n\nint main(int, char **) { return 0; }\n")
+
+ try_compile(CMAKE_${lang}_FEATURE_TEST
+ ${CMAKE_BINARY_DIR} "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}"
+ COMPILE_DEFINITIONS "${compile_flags}"
+ OUTPUT_VARIABLE _output
+ COPY_FILE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin"
+ COPY_FILE_ERROR _copy_error
+ )
+ if(CMAKE_${lang}_FEATURE_TEST AND NOT _copy_error)
+ set(_result 0)
+ else()
+ set(_result 255)
+ endif()
+ unset(CMAKE_${lang}_FEATURE_TEST CACHE)
+
+ if (_result EQUAL 0)
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "\n\nDetecting ${lang} [${compile_flags}] compiler features compiled with the following output:\n${_output}\n\n")
+ if(EXISTS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin")
+ file(STRINGS "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin"
+ features REGEX "${lang}_FEATURE:.*")
+ foreach(info ${features})
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ " Feature record: ${info}\n")
+ string(REPLACE "${lang}_FEATURE:" "" info ${info})
+ string(SUBSTRING ${info} 0 1 has_feature)
+ if(has_feature)
+ string(REGEX REPLACE "^1" "" feature ${info})
+ list(APPEND ${feature_list} ${feature})
+ endif()
+ endforeach()
+ endif()
+ else()
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Detecting ${lang} [${compile_flags}] compiler features failed to compile with the following output:\n${_output}\n${_copy_error}\n\n")
+ endif()
+endmacro()
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 81e8465..e25df1e 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -66,7 +66,7 @@ endif()
# Make sure the combination of SDK and Deployment Target are allowed
if(CMAKE_OSX_DEPLOYMENT_TARGET)
- if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "^.*/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
+ if("${_CMAKE_OSX_SYSROOT_PATH}" MATCHES "/MacOSX([0-9]+\\.[0-9]+)[^/]*\\.sdk")
set(_sdk_ver "${CMAKE_MATCH_1}")
elseif("${_CMAKE_OSX_SYSROOT_ORIG}" MATCHES "^macosx([0-9]+\\.[0-9]+)$")
set(_sdk_ver "${CMAKE_MATCH_1}")
diff --git a/Modules/Platform/Haiku.cmake b/Modules/Platform/Haiku.cmake
index 825f851..dfc2664 100644
--- a/Modules/Platform/Haiku.cmake
+++ b/Modules/Platform/Haiku.cmake
@@ -21,18 +21,26 @@ set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
# "/boot/system/develop/lib/<subdir>/", which we assume to be the secondary
# architecture specific subdirectory and extract the name of the architecture
# accordingly.
-set(__HAIKU_COMPILER ${CMAKE_C_COMPILER})
-if(NOT __HAIKU_COMPILER)
+# First of all, find a C or C++ compiler we can run. The "arg1" is necessary
+# here for compilers such as "distcc gcc-x86" or "ccache gcc-x86"
+# TODO See CMakeDetermineCompilerId.cmake for some more things we may want to do.
+if(CMAKE_C_COMPILER)
+ set(__HAIKU_COMPILER ${CMAKE_C_COMPILER})
+ string (STRIP "${CMAKE_C_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS)
+else()
set(__HAIKU_COMPILER ${CMAKE_CXX_COMPILER})
+ string (STRIP "${CMAKE_CXX_COMPILER_ARG1}" __HAIKU_COMPILER_FLAGS)
endif()
+
execute_process(
- COMMAND ${__HAIKU_COMPILER} -print-search-dirs
+ COMMAND ${__HAIKU_COMPILER} ${__HAIKU_COMPILER_FLAGS} -print-search-dirs
OUTPUT_VARIABLE _HAIKU_SEARCH_DIRS
+ RESULT_VARIABLE _HAIKU_SEARCH_DIRS_FOUND
OUTPUT_STRIP_TRAILING_WHITESPACE)
-string(REGEX MATCH ".*\nlibraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/(:[^\n]*)?\n.*" _dummy "\n${_HAIKU_SEARCH_DIRS}\n")
+string(REGEX MATCH "libraries: =?([^\n]*:)?/boot/system/develop/lib/([^/]*)/?(:?\n+)" _dummy "${_HAIKU_SEARCH_DIRS}\n")
set(CMAKE_HAIKU_SECONDARY_ARCH "${CMAKE_MATCH_2}")
if(NOT CMAKE_HAIKU_SECONDARY_ARCH)
@@ -53,14 +61,12 @@ else()
endif()
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
- /boot/common/non-packaged
- /boot/common
+ /boot/system/non-packaged
/boot/system
)
LIST(APPEND CMAKE_HAIKU_COMMON_INCLUDE_DIRECTORIES
- /boot/common/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
- /boot/common/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
+ /boot/system/non-packaged/develop/headers${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
/boot/system/develop/headers/os
/boot/system/develop/headers/os/app
/boot/system/develop/headers/os/device
@@ -108,8 +114,7 @@ LIST(APPEND CMAKE_HAIKU_CXX_INCLUDE_DIRECTORIES
LIST(APPEND CMAKE_SYSTEM_INCLUDE_PATH ${CMAKE_HAIKU_C_INCLUDE_DIRECTORIES})
LIST(APPEND CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES
- /boot/common/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
- /boot/common/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
+ /boot/system/non-packaged/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
/boot/system/develop/lib${CMAKE_HAIKU_SECONDARY_ARCH_SUBDIR}
)
@@ -120,6 +125,6 @@ LIST(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
LIST(APPEND CMAKE_SYSTEM_LIBRARY_PATH ${CMAKE_HAIKU_DEVELOP_LIB_DIRECTORIES})
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
- set(CMAKE_INSTALL_PREFIX "/boot/common" CACHE PATH
+ set(CMAKE_INSTALL_PREFIX "/boot/system" CACHE PATH
"Install path prefix, prepended onto install directories." FORCE)
endif()
diff --git a/Modules/Platform/OSF1.cmake b/Modules/Platform/OSF1.cmake
index 9c3255e..f2ad612 100644
--- a/Modules/Platform/OSF1.cmake
+++ b/Modules/Platform/OSF1.cmake
@@ -2,7 +2,7 @@ set(CMAKE_DL_LIBS "")
if(CMAKE_SYSTEM MATCHES "OSF1-1.[012]")
endif()
-if(CMAKE_SYSTEM MATCHES "OSF1-1.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-1")
# OSF/1 1.3 from OSF using ELF, and derivatives, including AD2
set(CMAKE_C_COMPILE_OPTIONS_PIC "-fpic")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-fpie")
@@ -12,7 +12,7 @@ endif()
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "-shared -Wl,-expect_unresolved,\\*") # -shared
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_SHARED_LIBRARY_RUNTIME_CXX_FLAG "-Wl,-rpath,")
diff --git a/Modules/Platform/OpenBSD.cmake b/Modules/Platform/OpenBSD.cmake
index 53cabed..a4f6114 100644
--- a/Modules/Platform/OpenBSD.cmake
+++ b/Modules/Platform/OpenBSD.cmake
@@ -10,7 +10,7 @@ if(NOT CMAKE_PLATFORM_RUNTIME_PATH)
ERROR_QUIET)
string(REGEX REPLACE ".*search\\ directories:\\ ([^\n]*).*" "\\1"
LDCONFIG_HINTS "${LDCONFIG_HINTS}")
- string(REGEX REPLACE ":" ";"
+ string(REPLACE ":" ";"
CMAKE_PLATFORM_RUNTIME_PATH
"${LDCONFIG_HINTS}")
endif()
diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake
index da20f97..aaa79c4 100644
--- a/Modules/Platform/SunOS.cmake
+++ b/Modules/Platform/SunOS.cmake
@@ -1,4 +1,4 @@
-if(CMAKE_SYSTEM MATCHES "SunOS-4.*")
+if(CMAKE_SYSTEM MATCHES "SunOS-4")
set(CMAKE_C_COMPILE_OPTIONS_PIC "-PIC")
set(CMAKE_C_COMPILE_OPTIONS_PIE "-PIE")
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-PIC")
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index 2bb7a20..990acea 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -67,8 +67,8 @@ macro(__windows_compiler_gnu lang)
if(MSYS OR MINGW)
# Create archiving rules to support large object file lists for static libraries.
- set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> cr <TARGET> <LINK_FLAGS> <OBJECTS>")
- set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> r <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_CREATE "<CMAKE_AR> cq <TARGET> <LINK_FLAGS> <OBJECTS>")
+ set(CMAKE_${lang}_ARCHIVE_APPEND "<CMAKE_AR> q <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_${lang}_ARCHIVE_FINISH "<CMAKE_RANLIB> <TARGET>")
# Initialize C link type selection flags. These flags are used when
@@ -87,6 +87,7 @@ macro(__windows_compiler_gnu lang)
set(CMAKE_SHARED_LIBRARY_${lang}_FLAGS "")
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS ${__WINDOWS_GNU_LD_RESPONSE})
+ set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES ${__WINDOWS_GNU_LD_RESPONSE})
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 1)
# We prefer "@" for response files but it is not supported by gcc 3.
@@ -103,16 +104,18 @@ macro(__windows_compiler_gnu lang)
endif()
# The GNU 3.x compilers do not support response files (only linkers).
set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_INCLUDES 0)
- elseif(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_OBJECTS)
+ # Link libraries are generated only for the front-end.
+ set(CMAKE_${lang}_USE_RESPONSE_FILE_FOR_LIBRARIES 0)
+ else()
# Use "@" to pass the response file to the front-end.
set(CMAKE_${lang}_RESPONSE_FILE_LINK_FLAG "@")
endif()
# Binary link rules.
set(CMAKE_${lang}_CREATE_SHARED_MODULE
- "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_MODULE_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS> -o <TARGET> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_${lang}_CREATE_SHARED_LIBRARY
- "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
+ "<CMAKE_${lang}_COMPILER> <CMAKE_SHARED_LIBRARY_${lang}_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <OBJECTS> <LINK_LIBRARIES>")
set(CMAKE_${lang}_LINK_EXECUTABLE
"<CMAKE_${lang}_COMPILER> <FLAGS> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> -Wl,--out-implib,<TARGET_IMPLIB> ${CMAKE_GNULD_IMAGE_VERSION} <LINK_LIBRARIES>")
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index e29aaf4..5732170 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -241,7 +241,7 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY "<CMAKE_LINKER> /lib ${CMAKE_CL_NOLOGO} <LINK_FLAGS> /out:<TARGET> <OBJECTS> ")
set(CMAKE_${lang}_COMPILE_OBJECT
- "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<OBJECT_DIR>/${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
+ "<CMAKE_${lang}_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> /Fo<OBJECT> /Fd<TARGET_COMPILE_PDB>${_FS_${lang}} -c <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_CREATE_PREPROCESSED_SOURCE
"<CMAKE_${lang}_COMPILER> > <PREPROCESSED_SOURCE> ${CMAKE_START_TEMP_FILE} ${CMAKE_CL_NOLOGO}${_COMPILE_${lang}} <FLAGS> <DEFINES> -E <SOURCE>${CMAKE_END_TEMP_FILE}")
set(CMAKE_${lang}_CREATE_ASSEMBLY_SOURCE
diff --git a/Modules/Platform/Windows-wcl386.cmake b/Modules/Platform/Windows-wcl386.cmake
index 8a03b29..ac410de 100644
--- a/Modules/Platform/Windows-wcl386.cmake
+++ b/Modules/Platform/Windows-wcl386.cmake
@@ -12,13 +12,15 @@ else()
set(CMAKE_LIB_QUIET "-q")
endif()
+set(CMAKE_EXE_LINKER_FLAGS_INIT)
set(CMAKE_CREATE_WIN32_EXE "system nt_win" )
set(CMAKE_CREATE_CONSOLE_EXE "system nt" )
-
-set (CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT "debug all" )
-set (CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT "debug all" )
-set (CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" )
-set (CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all" )
+set(CMAKE_SHARED_LINKER_FLAGS_INIT "system nt_dll")
+set(CMAKE_MODULE_LINKER_FLAGS_INIT "system nt_dll")
+foreach(type SHARED MODULE EXE)
+ set(CMAKE_${type}_LINKER_FLAGS_DEBUG_INIT "debug all opt map, symfile")
+ set(CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO_INIT "debug all opt map, symfile")
+endforeach()
set(CMAKE_C_COMPILE_OPTIONS_DLL "-bd") # Note: This variable is a ';' separated list
set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated string.
@@ -26,50 +28,54 @@ set(CMAKE_SHARED_LIBRARY_C_FLAGS "-bd") # ... while this is a space separated st
set(CMAKE_RC_COMPILER "rc" )
set(CMAKE_BUILD_TYPE_INIT Debug)
-set (CMAKE_CXX_FLAGS_INIT "-w=3 -xs")
-set (CMAKE_CXX_FLAGS_DEBUG_INIT "-br -bm -d2")
-set (CMAKE_CXX_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG")
-set (CMAKE_CXX_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG")
-set (CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG")
-set (CMAKE_C_FLAGS_INIT "-w=3 ")
-set (CMAKE_C_FLAGS_DEBUG_INIT "-br -bm -d2 -od")
-set (CMAKE_C_FLAGS_MINSIZEREL_INIT "-br -bm -os -dNDEBUG")
-set (CMAKE_C_FLAGS_RELEASE_INIT "-br -bm -ot -dNDEBUG")
-set (CMAKE_C_FLAGS_RELWITHDEBINFO_INIT "-br -bm -d2 -ot -dNDEBUG")
-set (CMAKE_C_STANDARD_LIBRARIES_INIT "library clbrdll.lib library plbrdll.lib library kernel32.lib library user32.lib library gdi32.lib library winspool.lib library comdlg32.lib library advapi32.lib library shell32.lib library ole32.lib library oleaut32.lib library uuid.lib library odbc32.lib library odbccp32.lib")
-set (CMAKE_CXX_STANDARD_LIBRARIES_INIT "${CMAKE_C_STANDARD_LIBRARIES_INIT}")
+
+# single/multi-threaded /-bm
+# static/DLL run-time libraries /-br
+# default is setup for multi-threaded + DLL run-time libraries
+set (CMAKE_C_FLAGS_INIT "-bt=nt -w3 -dWIN32 -br -bm")
+set (CMAKE_CXX_FLAGS_INIT "-bt=nt -xs -w3 -dWIN32 -br -bm")
+foreach(lang C CXX)
+ set (CMAKE_${lang}_FLAGS_DEBUG_INIT "-d2")
+ set (CMAKE_${lang}_FLAGS_MINSIZEREL_INIT "-s -os -d0 -dNDEBUG")
+ set (CMAKE_${lang}_FLAGS_RELEASE_INIT "-s -ot -d0 -dNDEBUG")
+ set (CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT "-s -ot -d1 -dNDEBUG")
+endforeach()
+
+foreach(type CREATE_SHARED_LIBRARY CREATE_SHARED_MODULE LINK_EXECUTABLE)
+ set(CMAKE_C_${type}_USE_WATCOM_QUOTE 1)
+ set(CMAKE_CXX_${type}_USE_WATCOM_QUOTE 1)
+endforeach()
set(CMAKE_C_CREATE_IMPORT_LIBRARY
- "wlib -c -q -n -b <TARGET_IMPLIB> +'<TARGET_UNQUOTED>'")
+ "wlib -c -q -n -b <TARGET_IMPLIB> +<TARGET_QUOTED>")
set(CMAKE_CXX_CREATE_IMPORT_LIBRARY ${CMAKE_C_CREATE_IMPORT_LIBRARY})
set(CMAKE_C_LINK_EXECUTABLE
- "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+ "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
set(CMAKE_CXX_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE})
# compile a C++ file into an object file
set(CMAKE_CXX_COMPILE_OBJECT
- "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<OBJECT> -c -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
+ "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<OBJECT> -c -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
# compile a C file into an object file
set(CMAKE_C_COMPILE_OBJECT
- "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<OBJECT> -c -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
+ "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<OBJECT> -c -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
# preprocess a C source file
set(CMAKE_C_CREATE_PREPROCESSED_SOURCE
- "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
+ "<CMAKE_C_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc <SOURCE>${CMAKE_END_TEMP_FILE}")
# preprocess a C++ source file
set(CMAKE_CXX_CREATE_PREPROCESSED_SOURCE
- "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -dWIN32 -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
+ "<CMAKE_CXX_COMPILER> ${CMAKE_START_TEMP_FILE} ${CMAKE_WCL_QUIET} <FLAGS> -d+ <DEFINES> -fo<PREPROCESSED_SOURCE> -pl -cc++ <SOURCE>${CMAKE_END_TEMP_FILE}")
-set(CMAKE_CXX_CREATE_SHARED_MODULE
- "wlink ${CMAKE_START_TEMP_FILE} system nt_dll ${CMAKE_WLINK_QUIET} name '<TARGET_UNQUOTED>' <LINK_FLAGS> option caseexact file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY
- ${CMAKE_CXX_CREATE_SHARED_MODULE}
- ${CMAKE_CXX_CREATE_IMPORT_LIBRARY})
+ "wlink ${CMAKE_START_TEMP_FILE} ${CMAKE_WLINK_QUIET} name <TARGET> <LINK_FLAGS> option implib=<TARGET_IMPLIB> file {<OBJECTS>} <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
+string(REPLACE " option implib=<TARGET_IMPLIB>" ""
+ CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_LIBRARY}")
# create a C shared library
set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
@@ -78,7 +84,7 @@ set(CMAKE_C_CREATE_SHARED_LIBRARY ${CMAKE_CXX_CREATE_SHARED_LIBRARY})
set(CMAKE_C_CREATE_SHARED_MODULE ${CMAKE_CXX_CREATE_SHARED_MODULE})
# create a C++ static library
-set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b '<TARGET_UNQUOTED>' <LINK_FLAGS> <OBJECTS> ")
+set(CMAKE_CXX_CREATE_STATIC_LIBRARY "wlib ${CMAKE_LIB_QUIET} -c -n -b <TARGET_QUOTED> <LINK_FLAGS> <OBJECTS> ")
# create a C static library
set(CMAKE_C_CREATE_STATIC_LIBRARY ${CMAKE_CXX_CREATE_STATIC_LIBRARY})
@@ -87,23 +93,27 @@ if(NOT _CMAKE_WATCOM_VERSION)
set(_CMAKE_WATCOM_VERSION 1)
if(CMAKE_C_COMPILER_VERSION)
set(_compiler_version ${CMAKE_C_COMPILER_VERSION})
+ set(_compiler_id ${CMAKE_C_COMPILER_ID})
else()
set(_compiler_version ${CMAKE_CXX_COMPILER_VERSION})
+ set(_compiler_id ${CMAKE_CXX_COMPILER_ID})
endif()
set(WATCOM16)
set(WATCOM17)
set(WATCOM18)
set(WATCOM19)
- if("${_compiler_version}" LESS 12.70)
- set(WATCOM16 1)
- endif()
- if("${_compiler_version}" EQUAL 12.70)
- set(WATCOM17 1)
- endif()
- if("${_compiler_version}" EQUAL 12.80)
- set(WATCOM18 1)
- endif()
- if("${_compiler_version}" EQUAL 12.90)
- set(WATCOM19 1)
+ if("${_compiler_id}" STREQUAL "OpenWatcom")
+ if("${_compiler_version}" VERSION_LESS 1.7)
+ set(WATCOM16 1)
+ endif()
+ if("${_compiler_version}" VERSION_EQUAL 1.7)
+ set(WATCOM17 1)
+ endif()
+ if("${_compiler_version}" VERSION_EQUAL 1.8)
+ set(WATCOM18 1)
+ endif()
+ if("${_compiler_version}" VERSION_EQUAL 1.9)
+ set(WATCOM19 1)
+ endif()
endif()
endif()
diff --git a/Modules/ProcessorCount.cmake b/Modules/ProcessorCount.cmake
index 0fe0b32..e034a28 100644
--- a/Modules/ProcessorCount.cmake
+++ b/Modules/ProcessorCount.cmake
@@ -104,6 +104,18 @@ function(ProcessorCount var)
string(REGEX MATCHALL "Number of CPUs = ([0-9]+)" procs "${machinfo_output}")
set(count "${CMAKE_MATCH_1}")
#message("ProcessorCount: trying machinfo '${ProcessorCount_cmd_machinfo}'")
+ else()
+ find_program(ProcessorCount_cmd_mpsched mpsched)
+ mark_as_advanced(ProcessorCount_cmd_mpsched)
+ if(ProcessorCount_cmd_mpsched)
+ execute_process(COMMAND ${ProcessorCount_cmd_mpsched} -s
+ OUTPUT_QUIET
+ ERROR_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE mpsched_output)
+ string(REGEX MATCHALL "Processor Count *: *([0-9]+)" procs "${mpsched_output}")
+ set(count "${CMAKE_MATCH_1}")
+ #message("ProcessorCount: trying mpsched -s '${ProcessorCount_cmd_mpsched}'")
+ endif()
endif()
endif()
diff --git a/Modules/Qt4Macros.cmake b/Modules/Qt4Macros.cmake
index 5ada030..b1b12d6 100644
--- a/Modules/Qt4Macros.cmake
+++ b/Modules/Qt4Macros.cmake
@@ -65,8 +65,8 @@ macro (QT4_MAKE_OUTPUT_FILE infile prefix ext outfile )
else()
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${infile})
endif()
- if(WIN32 AND rel MATCHES "^[a-zA-Z]:") # absolute path
- string(REGEX REPLACE "^([a-zA-Z]):(.*)$" "\\1_\\2" rel "${rel}")
+ if(WIN32 AND rel MATCHES "^([a-zA-Z]):(.*)$") # absolute path
+ set(rel "${CMAKE_MATCH_1}_${CMAKE_MATCH_2}")
endif()
set(_outfile "${CMAKE_CURRENT_BINARY_DIR}/${rel}")
string(REPLACE ".." "__" _outfile ${_outfile})
@@ -141,7 +141,7 @@ function (QT4_CREATE_MOC_COMMAND infile outfile moc_flags moc_options moc_target
set(_moc_extra_parameters_file @${_moc_parameters_file})
add_custom_command(OUTPUT ${outfile}
COMMAND Qt4::moc ${_moc_extra_parameters_file}
- DEPENDS ${infile}
+ DEPENDS ${infile} ${_moc_parameters_file}
${_moc_working_dir}
VERBATIM)
endfunction ()
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 654b4d0..127012f 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -426,6 +426,7 @@ function(add_jar _TARGET_NAME)
set(_JAVA_DEPENDS)
set(_JAVA_COMPILE_DEPENDS)
set(_JAVA_RESOURCE_FILES)
+ set(_JAVA_RESOURCE_FILES_RELATIVE)
foreach(_JAVA_SOURCE_FILE ${_JAVA_SOURCE_FILES})
get_filename_component(_JAVA_EXT ${_JAVA_SOURCE_FILE} EXT)
get_filename_component(_JAVA_FILE ${_JAVA_SOURCE_FILE} NAME_WE)
@@ -462,7 +463,8 @@ function(add_jar _TARGET_NAME)
__java_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/${_JAVA_SOURCE_FILE}
${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE}
"Copying ${_JAVA_SOURCE_FILE} to the build directory")
- list(APPEND _JAVA_RESOURCE_FILES ${_JAVA_SOURCE_FILE})
+ list(APPEND _JAVA_RESOURCE_FILES ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_SOURCE_FILE})
+ list(APPEND _JAVA_RESOURCE_FILES_RELATIVE ${_JAVA_SOURCE_FILE})
endif ()
endforeach()
@@ -529,7 +531,7 @@ function(add_jar _TARGET_NAME)
OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
COMMAND ${Java_JAR_EXECUTABLE}
-cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
- ${_JAVA_RESOURCE_FILES} @java_class_filelist
+ ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
COMMAND ${CMAKE_COMMAND}
-D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
@@ -549,7 +551,7 @@ function(add_jar _TARGET_NAME)
OUTPUT ${_JAVA_JAR_OUTPUT_PATH}
COMMAND ${Java_JAR_EXECUTABLE}
-cf${_ENTRY_POINT_OPTION}${_MANIFEST_OPTION} ${_JAVA_JAR_OUTPUT_PATH} ${_ENTRY_POINT_VALUE} ${_MANIFEST_VALUE}
- ${_JAVA_RESOURCE_FILES} @java_class_filelist
+ ${_JAVA_RESOURCE_FILES_RELATIVE} @java_class_filelist
COMMAND ${CMAKE_COMMAND}
-D_JAVA_TARGET_DIR=${_add_jar_OUTPUT_DIR}
-D_JAVA_TARGET_OUTPUT_NAME=${_JAVA_TARGET_OUTPUT_NAME}
diff --git a/Modules/UseQt4.cmake b/Modules/UseQt4.cmake
index 7478310..cba22af 100644
--- a/Modules/UseQt4.cmake
+++ b/Modules/UseQt4.cmake
@@ -98,7 +98,9 @@ foreach(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN
include_directories(SYSTEM ${QT_${module}_INCLUDE_DIR})
endif(QT_INCLUDE_DIRS_NO_SYSTEM)
endif()
- set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
+ if(QT_USE_${module} OR QT_IS_STATIC)
+ set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIBRARY})
+ endif()
set(QT_LIBRARIES_PLUGINS ${QT_LIBRARIES_PLUGINS} ${QT_${module}_PLUGINS})
if(QT_IS_STATIC)
set(QT_LIBRARIES ${QT_LIBRARIES} ${QT_${module}_LIB_DEPENDENCIES})
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 11ca205..f4fe1df 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -2,9 +2,7 @@
# UseSWIG
# -------
#
-# SWIG module for CMake
-#
-# Defines the following macros:
+# Defines the following macros for use with SWIG:
#
# ::
#
@@ -13,20 +11,38 @@
# SWIG_LINK_LIBRARIES(name [ libraries ])
# - Link libraries to swig module
#
-# All other macros are for internal use only. To get the actual name of
-# the swig module, use: ${SWIG_MODULE_${name}_REAL_NAME}. Set Source
-# files properties such as CPLUSPLUS and SWIG_FLAGS to specify special
-# behavior of SWIG. Also global CMAKE_SWIG_FLAGS can be used to add
-# special flags to all swig calls. Another special variable is
-# CMAKE_SWIG_OUTDIR, it allows one to specify where to write all the
-# swig generated module (swig -outdir option) The name-specific variable
-# SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
-# dependencies for the generated modules. If the source file generated
-# by swig need some special flag you can use::
+# Source files properties on module files can be set before the invocation
+# of the SWIG_ADD_MODULE macro to specify special behavior of SWIG.
#
-# set_source_files_properties( ${swig_generated_file_fullname}
-# PROPERTIES COMPILE_FLAGS "-bla")
-
+# The source file property CPLUSPLUS calls SWIG in c++ mode, e.g.::
+#
+# set_property(SOURCE mymod.i PROPERTY CPLUSPLUS ON)
+# swig_add_module(mymod python mymod.i)
+#
+# The source file property SWIG_FLAGS adds custom flags to the SWIG executable.
+#
+# The source-file property SWIG_MODULE_NAME have to be provided to specify the actual
+# import name of the module in the target language if it cannot be scanned automatically
+# from source or different from the module file basename.::
+#
+# set_property(SOURCE mymod.i PROPERTY SWIG_MODULE_NAME mymod_realname)
+#
+# To get the name of the swig module target library, use: ${SWIG_MODULE_${name}_REAL_NAME}.
+#
+# Also some variables can be set to specify special behavior of SWIG.
+#
+# CMAKE_SWIG_FLAGS can be used to add special flags to all swig calls.
+#
+# Another special variable is CMAKE_SWIG_OUTDIR, it allows one to specify
+# where to write all the swig generated module (swig -outdir option)
+#
+# The name-specific variable SWIG_MODULE_<name>_EXTRA_DEPS may be used to specify extra
+# dependencies for the generated modules.
+#
+# If the source file generated by swig need some special flag you can use::
+#
+# set_source_files_properties( ${swig_generated_file_fullname}
+# PROPERTIES COMPILE_FLAGS "-bla")
#=============================================================================
# Copyright 2004-2009 Kitware, Inc.
@@ -86,7 +102,30 @@ macro(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
get_source_file_property(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename
${infile} SWIG_MODULE_NAME)
if(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename STREQUAL "NOTFOUND")
- get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${infile}" NAME_WE)
+
+ # try to get module name from "%module foo" syntax
+ if ( EXISTS ${infile} )
+ file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*[a-zA-Z0-9_]+.*" )
+ endif ()
+ if ( _MODULE_NAME )
+ string ( REGEX REPLACE "[ ]*%module[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
+ set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+
+ else ()
+ # try to get module name from "%module (options=...) foo" syntax
+ if ( EXISTS ${infile} )
+ file ( STRINGS ${infile} _MODULE_NAME REGEX "[ ]*%module[ ]*\\(.*\\)[ ]*[a-zA-Z0-9_]+.*" )
+ endif ()
+ if ( _MODULE_NAME )
+ string ( REGEX REPLACE "[ ]*%module[ ]*\\(.*\\)[ ]*([a-zA-Z0-9_]+).*" "\\1" _MODULE_NAME "${_MODULE_NAME}" )
+ set(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename "${_MODULE_NAME}")
+
+ else ()
+ # fallback to file basename
+ get_filename_component(SWIG_GET_EXTRA_OUTPUT_FILES_module_basename ${infile} NAME_WE)
+ endif ()
+ endif ()
+
endif()
foreach(it ${SWIG_${language}_EXTRA_FILE_EXTENSION})
set(${outfiles} ${${outfiles}}
@@ -181,7 +220,7 @@ macro(SWIG_ADD_MODULE name language)
set(swig_dot_i_sources)
set(swig_other_sources)
foreach(it ${ARGN})
- if(${it} MATCHES ".*\\.i$")
+ if(${it} MATCHES "\\.i$")
set(swig_dot_i_sources ${swig_dot_i_sources} "${it}")
else()
set(swig_other_sources ${swig_other_sources} "${it}")
@@ -200,6 +239,7 @@ macro(SWIG_ADD_MODULE name language)
MODULE
${swig_generated_sources}
${swig_other_sources})
+ set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES NO_SONAME ON)
string(TOLOWER "${language}" swig_lowercase_language)
if ("${swig_lowercase_language}" STREQUAL "octave")
set_target_properties(${SWIG_MODULE_${name}_REAL_NAME} PROPERTIES PREFIX "")
diff --git a/Modules/UseVTKConfig40.cmake b/Modules/UseVTKConfig40.cmake
index 554b8c4..c5022e4 100644
--- a/Modules/UseVTKConfig40.cmake
+++ b/Modules/UseVTKConfig40.cmake
@@ -312,7 +312,7 @@ else()
if(CMAKE_ANSI_CFLAGS)
set(VTK_REQUIRED_C_FLAGS "${VTK_REQUIRED_C_FLAGS} ${CMAKE_ANSI_CFLAGS}")
endif()
- if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+ if(CMAKE_SYSTEM MATCHES "OSF1-V")
set(VTK_REQUIRED_CXX_FLAGS
"${VTK_REQUIRED_CXX_FLAGS} -timplicit_local -no_implicit_include")
endif()
diff --git a/Modules/WIX.template.in b/Modules/WIX.template.in
index 59a75c7..bbb7c88 100644
--- a/Modules/WIX.template.in
+++ b/Modules/WIX.template.in
@@ -40,5 +40,7 @@
<FeatureRef Id="ProductFeature"/>
<UIRef Id="$(var.CPACK_WIX_UI_REF)" />
+
+ <?include "properties.wxi"?>
</Product>
</Wix>
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 175a034..660c0c5 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -18,12 +18,34 @@ else()
endif()
if(HAVE_ELF_H)
set(CMAKE_USE_ELF_PARSER 1)
+elseif(HAIKU)
+ # On Haiku, we need to include elf32.h from the private headers
+ set(CMake_HAIKU_INCLUDE_DIRS
+ /boot/system/develop/headers/private/system
+ /boot/system/develop/headers/private/system/arch/x86
+ )
+
+ set(CMAKE_REQUIRED_INCLUDES ${CMake_HAIKU_INCLUDE_DIRS})
+ CHECK_INCLUDE_FILE("elf32.h" HAVE_ELF32_H)
+ unset(CMAKE_REQUIRED_INCLUDES)
+
+ if(HAVE_ELF32_H)
+ set(CMAKE_USE_ELF_PARSER 1)
+ else()
+ unset(CMake_HAIKU_INCLUDE_DIRS)
+ set(CMAKE_USE_ELF_PARSER)
+ endif()
else()
set(CMAKE_USE_ELF_PARSER)
endif()
set(EXECUTABLE_OUTPUT_PATH ${CMake_BIN_DIR})
+# ensure Unicode friendly APIs are used on Windows
+if(WIN32)
+ add_definitions(-DUNICODE -D_UNICODE)
+endif()
+
# configure the .h file
configure_file(
"${CMake_SOURCE_DIR}/Source/cmConfigure.cmake.h.in"
@@ -52,6 +74,7 @@ include_directories(
${CMAKE_EXPAT_INCLUDES}
${CMAKE_TAR_INCLUDES}
${CMAKE_COMPRESS_INCLUDES}
+ ${CMake_HAIKU_INCLUDE_DIRS}
)
# let cmake know it is supposed to use it
@@ -323,8 +346,10 @@ foreach(command_file
cmSourceGroupCommand
cmSubdirDependsCommand
cmTargetCompileDefinitionsCommand
+ cmTargetCompileFeaturesCommand
cmTargetCompileOptionsCommand
cmTargetIncludeDirectoriesCommand
+ cmTargetSourcesCommand
cmUseMangledMesaCommand
cmUtilitySourceCommand
cmVariableRequiresCommand
@@ -399,7 +424,6 @@ if (WIN32)
cmGlobalVisualStudio12Generator.cxx
cmGlobalVisualStudioGenerator.cxx
cmGlobalVisualStudioGenerator.h
- cmGlobalWatcomWMakeGenerator.cxx
cmIDEFlagTable.h
cmIDEOptions.cxx
cmIDEOptions.h
@@ -419,6 +443,15 @@ if (WIN32)
endif()
endif ()
+# Watcom support
+if(WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
+ set_property(SOURCE cmake.cxx APPEND PROPERTY COMPILE_DEFINITIONS CMAKE_USE_WMAKE)
+ list(APPEND SRCS
+ cmGlobalWatcomWMakeGenerator.cxx
+ cmGlobalWatcomWMakeGenerator.h
+ )
+endif()
+
# Ninja support
set(SRCS ${SRCS}
cmGlobalNinjaGenerator.cxx
@@ -562,7 +595,11 @@ if(WIN32)
set(CPACK_SRCS ${CPACK_SRCS}
CPack/WiX/cmCPackWIXGenerator.cxx
CPack/WiX/cmWIXSourceWriter.cxx
+ CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+ CPack/WiX/cmWIXFeaturesSourceWriter.cxx
+ CPack/WiX/cmWIXFilesSourceWriter.cxx
CPack/WiX/cmWIXRichTextFormatWriter.cxx
+ CPack/WiX/cmWIXPatch.cxx
CPack/WiX/cmWIXPatchParser.cxx
)
endif()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index a5cf693..1e0d885 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 0)
-set(CMake_VERSION_PATCH 0)
-set(CMake_VERSION_RC 4)
+set(CMake_VERSION_PATCH 20140429)
+#set(CMake_VERSION_RC 1)
diff --git a/Source/CMakeVersionSource.cmake b/Source/CMakeVersionSource.cmake
index 05e265c..888f557 100644
--- a/Source/CMakeVersionSource.cmake
+++ b/Source/CMakeVersionSource.cmake
@@ -30,8 +30,8 @@ if(EXISTS ${CMake_SOURCE_DIR}/.git/HEAD)
elseif(EXISTS ${CMake_SOURCE_DIR}/CVS/Repository)
file(READ ${CMake_SOURCE_DIR}/CVS/Repository repo)
set(branch "")
- if("${repo}" MATCHES "\\.git/")
- string(REGEX REPLACE ".*\\.git/([^\r\n]*).*" "-\\1" branch "${repo}")
+ if("${repo}" MATCHES "\\.git/([^\r\n]*)")
+ set(branch "${CMAKE_MATCH_1}")
endif()
set(CMake_VERSION_SOURCE "cvs${branch}")
endif()
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index 43119d6..ec59715 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -1,6 +1,6 @@
/*============================================================================
CMake - Cross Platform Makefile Generator
- Copyright 2000-2013 Kitware, Inc., Insight Software Consortium
+ Copyright 2000-2014 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
@@ -19,6 +19,9 @@
#include <CPack/cmCPackComponentGroup.h>
#include "cmWIXSourceWriter.h"
+#include "cmWIXDirectoriesSourceWriter.h"
+#include "cmWIXFeaturesSourceWriter.h"
+#include "cmWIXFilesSourceWriter.h"
#include "cmWIXRichTextFormatWriter.h"
#include <cmsys/SystemTools.hxx>
@@ -28,31 +31,32 @@
#include <rpc.h> // for GUID generation
-#include <sys/types.h>
-#include <sys/stat.h>
-
cmCPackWIXGenerator::cmCPackWIXGenerator():
- HasDesktopShortcuts(false)
+ HasDesktopShortcuts(false),
+ Patch(0)
{
}
+cmCPackWIXGenerator::~cmCPackWIXGenerator()
+{
+ if(this->Patch)
+ {
+ delete this->Patch;
+ }
+}
+
int cmCPackWIXGenerator::InitializeInternal()
{
componentPackageMethod = ONE_PACKAGE;
+ this->Patch = new cmWIXPatch(this->Logger);
return this->Superclass::InitializeInternal();
}
-bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
+bool cmCPackWIXGenerator::RunWiXCommand(std::string const& command)
{
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
- {
- return false;
- }
-
- std::string logFileName = cpackTopLevel + "/wix.log";
+ std::string logFileName = this->CPackTopLevel + "/wix.log";
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"Running WiX command: " << command << std::endl);
@@ -81,7 +85,7 @@ bool cmCPackWIXGenerator::RunWiXCommand(const std::string& command)
}
bool cmCPackWIXGenerator::RunCandleCommand(
- const std::string& sourceFile, const std::string& objectFile)
+ std::string const& sourceFile, std::string const& objectFile)
{
std::string executable;
if(!RequireOption("CPACK_WIX_CANDLE_EXECUTABLE", executable))
@@ -108,7 +112,7 @@ bool cmCPackWIXGenerator::RunCandleCommand(
return RunWiXCommand(command.str());
}
-bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
+bool cmCPackWIXGenerator::RunLightCommand(std::string const& objectFiles)
{
std::string executable;
if(!RequireOption("CPACK_WIX_LIGHT_EXECUTABLE", executable))
@@ -121,8 +125,8 @@ bool cmCPackWIXGenerator::RunLightCommand(const std::string& objectFiles)
command << " -nologo";
command << " -out " << QuotePath(packageFileNames.at(0));
- for(extension_set_t::const_iterator i = LightExtensions.begin();
- i != LightExtensions.end(); ++i)
+ for(extension_set_t::const_iterator i = this->LightExtensions.begin();
+ i != this->LightExtensions.end(); ++i)
{
command << " -ext " << QuotePath(*i);
}
@@ -182,15 +186,14 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
"you might want to set this explicitly." << std::endl);
}
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
+ if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", this->CPackTopLevel))
{
return false;
}
if(GetOption("CPACK_WIX_LICENSE_RTF") == 0)
{
- std::string licenseFilename = cpackTopLevel + "/License.rtf";
+ std::string licenseFilename = this->CPackTopLevel + "/License.rtf";
SetOption("CPACK_WIX_LICENSE_RTF", licenseFilename.c_str());
if(!CreateLicenseFile())
@@ -213,7 +216,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
{
std::string defaultRef = "WixUI_InstallDir";
- if(Components.size())
+ if(this->Components.size())
{
defaultRef = "WixUI_FeatureTree";
}
@@ -221,17 +224,24 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration()
SetOption("CPACK_WIX_UI_REF", defaultRef.c_str());
}
- CollectExtensions("CPACK_WIX_EXTENSIONS", CandleExtensions);
- CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", CandleExtensions);
+ const char* packageContact = GetOption("CPACK_PACKAGE_CONTACT");
+ if(packageContact != 0 &&
+ GetOption("CPACK_WIX_PROPERTY_ARPCONTACT") == 0)
+ {
+ SetOption("CPACK_WIX_PROPERTY_ARPCONTACT", packageContact);
+ }
+
+ CollectExtensions("CPACK_WIX_EXTENSIONS", this->CandleExtensions);
+ CollectExtensions("CPACK_WIX_CANDLE_EXTENSIONS", this->CandleExtensions);
- LightExtensions.insert("WixUIExtension");
- CollectExtensions("CPACK_WIX_EXTENSIONS", LightExtensions);
- CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", LightExtensions);
+ this->LightExtensions.insert("WixUIExtension");
+ CollectExtensions("CPACK_WIX_EXTENSIONS", this->LightExtensions);
+ CollectExtensions("CPACK_WIX_LIGHT_EXTENSIONS", this->LightExtensions);
const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE");
if(patchFilePath)
{
- LoadPatchFragments(patchFilePath);
+ this->Patch->LoadFragments(patchFilePath);
}
return true;
@@ -244,10 +254,8 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
return false;
}
- if(!CreateWiXVariablesIncludeFile())
- {
- return false;
- }
+ CreateWiXVariablesIncludeFile();
+ CreateWiXPropertiesIncludeFile();
if(!CreateWiXSourceFiles())
{
@@ -257,9 +265,9 @@ bool cmCPackWIXGenerator::PackageFilesImpl()
AppendUserSuppliedExtraSources();
std::stringstream objectFiles;
- for(size_t i = 0; i < WixSources.size(); ++i)
+ for(size_t i = 0; i < this->WixSources.size(); ++i)
{
- const std::string& sourceFilename = WixSources[i];
+ std::string const& sourceFilename = this->WixSources[i];
std::string objectFilename =
cmSystemTools::GetFilenameWithoutExtension(sourceFilename) + ".wixobj";
@@ -282,7 +290,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources()
const char *cpackWixExtraSources = GetOption("CPACK_WIX_EXTRA_SOURCES");
if(!cpackWixExtraSources) return;
- cmSystemTools::ExpandListArgument(cpackWixExtraSources, WixSources);
+ cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources);
}
void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
@@ -297,22 +305,18 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream)
for(size_t i = 0; i < expandedExtraObjects.size(); ++i)
{
- stream << " " << QuotePath(expandedExtraObjects[i]);
+ stream << " " << QuotePath(expandedExtraObjects[i]);
}
}
-bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
+void cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
{
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
- {
- return false;
- }
-
std::string includeFilename =
- cpackTopLevel + "/cpack_variables.wxi";
+ this->CPackTopLevel + "/cpack_variables.wxi";
+
+ cmWIXSourceWriter includeFile(
+ this->Logger, includeFilename, true);
- cmWIXSourceWriter includeFile(Logger, includeFilename, true);
CopyDefinition(includeFile, "CPACK_WIX_PRODUCT_GUID");
CopyDefinition(includeFile, "CPACK_WIX_UPGRADE_GUID");
CopyDefinition(includeFile, "CPACK_PACKAGE_VENDOR");
@@ -326,12 +330,39 @@ bool cmCPackWIXGenerator::CreateWiXVariablesIncludeFile()
GetOption("CPACK_PACKAGE_NAME"));
CopyDefinition(includeFile, "CPACK_WIX_PROGRAM_MENU_FOLDER");
CopyDefinition(includeFile, "CPACK_WIX_UI_REF");
+}
- return true;
+void cmCPackWIXGenerator::CreateWiXPropertiesIncludeFile()
+{
+ std::string includeFilename =
+ this->CPackTopLevel + "/properties.wxi";
+
+ cmWIXSourceWriter includeFile(
+ this->Logger, includeFilename, true);
+
+ std::string prefix = "CPACK_WIX_PROPERTY_";
+ std::vector<std::string> options = GetOptions();
+
+ for(size_t i = 0; i < options.size(); ++i)
+ {
+ std::string const& name = options[i];
+
+ if(name.length() > prefix.length() &&
+ name.substr(0, prefix.length()) == prefix)
+ {
+ std::string id = name.substr(prefix.length());
+ std::string value = GetOption(name.c_str());
+
+ includeFile.BeginElement("Property");
+ includeFile.AddAttribute("Id", id);
+ includeFile.AddAttribute("Value", value);
+ includeFile.EndElement("Property");
+ }
+ }
}
void cmCPackWIXGenerator::CopyDefinition(
- cmWIXSourceWriter &source, const std::string &name)
+ cmWIXSourceWriter &source, std::string const& name)
{
const char* value = GetOption(name.c_str());
if(value)
@@ -341,7 +372,7 @@ void cmCPackWIXGenerator::CopyDefinition(
}
void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
- const std::string& name, const std::string& value)
+ std::string const& name, std::string const& value)
{
std::stringstream tmp;
tmp << name << "=\"" << value << '"';
@@ -352,81 +383,47 @@ void cmCPackWIXGenerator::AddDefinition(cmWIXSourceWriter& source,
bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
- std::string cpackTopLevel;
- if(!RequireOption("CPACK_TOPLEVEL_DIRECTORY", cpackTopLevel))
- {
- return false;
- }
-
std::string directoryDefinitionsFilename =
- cpackTopLevel + "/directories.wxs";
+ this->CPackTopLevel + "/directories.wxs";
- WixSources.push_back(directoryDefinitionsFilename);
+ this->WixSources.push_back(directoryDefinitionsFilename);
- cmWIXSourceWriter directoryDefinitions(Logger, directoryDefinitionsFilename);
+ cmWIXDirectoriesSourceWriter directoryDefinitions(
+ this->Logger, directoryDefinitionsFilename);
directoryDefinitions.BeginElement("Fragment");
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "TARGETDIR");
- directoryDefinitions.AddAttribute("Name", "SourceDir");
-
- directoryDefinitions.BeginElement("Directory");
- if(GetArchitecture() == "x86")
- {
- directoryDefinitions.AddAttribute("Id", "ProgramFilesFolder");
- }
- else
- {
- directoryDefinitions.AddAttribute("Id", "ProgramFiles64Folder");
- }
-
- std::vector<std::string> install_root;
-
- std::string tmp;
- if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", tmp))
+ std::string installRoot;
+ if(!RequireOption("CPACK_PACKAGE_INSTALL_DIRECTORY", installRoot))
{
return false;
}
- cmSystemTools::SplitPath(tmp.c_str(), install_root);
-
- if(!install_root.empty() && install_root.back().empty())
- {
- install_root.pop_back();
- }
-
- for(size_t i = 1; i < install_root.size(); ++i)
- {
- directoryDefinitions.BeginElement("Directory");
-
- if(i == install_root.size() - 1)
- {
- directoryDefinitions.AddAttribute("Id", "INSTALL_ROOT");
- }
- else
- {
- std::stringstream ss;
- ss << "INSTALL_PREFIX_" << i;
- directoryDefinitions.AddAttribute("Id", ss.str());
- }
+ directoryDefinitions.BeginElement("Directory");
+ directoryDefinitions.AddAttribute("Id", "TARGETDIR");
+ directoryDefinitions.AddAttribute("Name", "SourceDir");
- directoryDefinitions.AddAttribute("Name", install_root[i]);
- }
+ size_t installRootSize =
+ directoryDefinitions.BeginInstallationPrefixDirectory(
+ GetProgramFilesFolderId(), installRoot);
std::string fileDefinitionsFilename =
- cpackTopLevel + "/files.wxs";
+ this->CPackTopLevel + "/files.wxs";
+
+ this->WixSources.push_back(fileDefinitionsFilename);
- WixSources.push_back(fileDefinitionsFilename);
+ cmWIXFilesSourceWriter fileDefinitions(
+ this->Logger, fileDefinitionsFilename);
- cmWIXSourceWriter fileDefinitions(Logger, fileDefinitionsFilename);
fileDefinitions.BeginElement("Fragment");
std::string featureDefinitionsFilename =
- cpackTopLevel +"/features.wxs";
+ this->CPackTopLevel +"/features.wxs";
- WixSources.push_back(featureDefinitionsFilename);
+ this->WixSources.push_back(featureDefinitionsFilename);
+
+ cmWIXFeaturesSourceWriter featureDefinitions(
+ this->Logger, featureDefinitionsFilename);
- cmWIXSourceWriter featureDefinitions(Logger, featureDefinitionsFilename);
featureDefinitions.BeginElement("Fragment");
featureDefinitions.BeginElement("Feature");
@@ -439,13 +436,15 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
{
return false;
}
- featureDefinitions.AddAttribute("Title", cpackPackageName);
+ featureDefinitions.AddAttribute("Title", cpackPackageName);
featureDefinitions.AddAttribute("Level", "1");
- if(!CreateCMakePackageRegistryEntry(featureDefinitions))
+ const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
+ if(package)
{
- return false;
+ featureDefinitions.CreateCMakePackageRegistryEntry(
+ package, GetOption("CPACK_WIX_UPGRADE_GUID"));
}
if(!CreateFeatureHierarchy(featureDefinitions))
@@ -471,7 +470,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
else
{
for(std::map<std::string, cmCPackComponent>::const_iterator
- i = Components.begin(); i != Components.end(); ++i)
+ i = this->Components.begin(); i != this->Components.end(); ++i)
{
cmCPackComponent const& component = i->second;
@@ -513,31 +512,51 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
featureDefinitions.EndElement("Fragment");
fileDefinitions.EndElement("Fragment");
- for(size_t i = 1; i < install_root.size(); ++i)
- {
- directoryDefinitions.EndElement("Directory");
- }
-
- directoryDefinitions.EndElement("Directory");
+ directoryDefinitions.EndInstallationPrefixDirectory(
+ installRootSize);
if(hasShortcuts)
{
- CreateStartMenuFolder(directoryDefinitions);
+ directoryDefinitions.EmitStartMenuFolder(
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER"));
}
if(this->HasDesktopShortcuts)
{
- CreateDesktopFolder(directoryDefinitions);
+ directoryDefinitions.EmitDesktopFolder();
}
directoryDefinitions.EndElement("Directory");
directoryDefinitions.EndElement("Fragment");
+ if(!GenerateMainSourceFileFromTemplate())
+ {
+ return false;
+ }
+
+ return this->Patch->CheckForUnappliedFragments();
+}
+
+std::string cmCPackWIXGenerator::GetProgramFilesFolderId() const
+{
+ if(GetArchitecture() == "x86")
+ {
+ return "ProgramFilesFolder";
+ }
+ else
+ {
+ return "ProgramFiles64Folder";
+ }
+}
+
+bool cmCPackWIXGenerator::GenerateMainSourceFileFromTemplate()
+{
std::string wixTemplate = FindTemplate("WIX.template.in");
if(GetOption("CPACK_WIX_TEMPLATE") != 0)
{
wixTemplate = GetOption("CPACK_WIX_TEMPLATE");
}
+
if(wixTemplate.empty())
{
cmCPackLogger(cmCPackLog::LOG_ERROR,
@@ -545,7 +564,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
- std::string mainSourceFilePath = cpackTopLevel + "/main.wxs";
+ std::string mainSourceFilePath = this->CPackTopLevel + "/main.wxs";
if(!ConfigureFile(wixTemplate.c_str(), mainSourceFilePath .c_str()))
{
@@ -556,68 +575,13 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
return false;
}
- WixSources.push_back(mainSourceFilePath);
-
- std::string fragmentList;
- for(cmWIXPatchParser::fragment_map_t::const_iterator
- i = Fragments.begin(); i != Fragments.end(); ++i)
- {
- if(!fragmentList.empty())
- {
- fragmentList += ", ";
- }
-
- fragmentList += "'";
- fragmentList += i->first;
- fragmentList += "'";
- }
-
- if(fragmentList.size())
- {
- cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Some XML patch fragments did not have matching IDs: " <<
- fragmentList << std::endl);
- return false;
- }
-
- return true;
-}
-
-bool cmCPackWIXGenerator::CreateCMakePackageRegistryEntry(
- cmWIXSourceWriter& featureDefinitions)
-{
- const char* package = GetOption("CPACK_WIX_CMAKE_PACKAGE_REGISTRY");
- if(!package)
- {
- return true;
- }
-
- featureDefinitions.BeginElement("Component");
- featureDefinitions.AddAttribute("Id", "CM_PACKAGE_REGISTRY");
- featureDefinitions.AddAttribute("Directory", "TARGETDIR");
- featureDefinitions.AddAttribute("Guid", "*");
-
- std::string registryKey =
- std::string("Software\\Kitware\\CMake\\Packages\\") + package;
-
- std::string upgradeGuid = GetOption("CPACK_WIX_UPGRADE_GUID");
-
- featureDefinitions.BeginElement("RegistryValue");
- featureDefinitions.AddAttribute("Root", "HKLM");
- featureDefinitions.AddAttribute("Key", registryKey);
- featureDefinitions.AddAttribute("Name", upgradeGuid);
- featureDefinitions.AddAttribute("Type", "string");
- featureDefinitions.AddAttribute("Value", "[INSTALL_ROOT]");
- featureDefinitions.AddAttribute("KeyPath", "yes");
- featureDefinitions.EndElement("RegistryValue");
-
- featureDefinitions.EndElement("Component");
+ this->WixSources.push_back(mainSourceFilePath);
return true;
}
bool cmCPackWIXGenerator::CreateFeatureHierarchy(
- cmWIXSourceWriter& featureDefinitions)
+ cmWIXFeaturesSourceWriter& featureDefinitions)
{
for(std::map<std::string, cmCPackComponentGroup>::const_iterator
i = ComponentGroups.begin(); i != ComponentGroups.end(); ++i)
@@ -625,105 +589,30 @@ bool cmCPackWIXGenerator::CreateFeatureHierarchy(
cmCPackComponentGroup const& group = i->second;
if(group.ParentGroup == 0)
{
- if(!EmitFeatureForComponentGroup(featureDefinitions, group))
- {
- return false;
- }
+ featureDefinitions.EmitFeatureForComponentGroup(group);
}
}
for(std::map<std::string, cmCPackComponent>::const_iterator
- i = Components.begin(); i != Components.end(); ++i)
+ i = this->Components.begin(); i != this->Components.end(); ++i)
{
cmCPackComponent const& component = i->second;
if(!component.Group)
{
- if(!EmitFeatureForComponent(featureDefinitions, component))
- {
- return false;
- }
+ featureDefinitions.EmitFeatureForComponent(component);
}
}
return true;
}
-bool cmCPackWIXGenerator::EmitFeatureForComponentGroup(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponentGroup const& group)
-{
- featureDefinitions.BeginElement("Feature");
- featureDefinitions.AddAttribute("Id", "CM_G_" + group.Name);
-
- if(group.IsExpandedByDefault)
- {
- featureDefinitions.AddAttribute("Display", "expand");
- }
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Title", group.DisplayName);
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Description", group.Description);
-
- for(std::vector<cmCPackComponentGroup*>::const_iterator
- i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
- {
- if(!EmitFeatureForComponentGroup(featureDefinitions, **i))
- {
- return false;
- }
- }
-
- for(std::vector<cmCPackComponent*>::const_iterator
- i = group.Components.begin(); i != group.Components.end(); ++i)
- {
- if(!EmitFeatureForComponent(featureDefinitions, **i))
- {
- return false;
- }
- }
-
- featureDefinitions.EndElement("Feature");
-
- return true;
-}
-
-bool cmCPackWIXGenerator::EmitFeatureForComponent(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponent const& component)
-{
- featureDefinitions.BeginElement("Feature");
- featureDefinitions.AddAttribute("Id", "CM_C_" + component.Name);
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Title", component.DisplayName);
-
- featureDefinitions.AddAttributeUnlessEmpty(
- "Description", component.Description);
-
- if(component.IsRequired)
- {
- featureDefinitions.AddAttribute("Absent", "disallow");
- }
-
- if(component.IsHidden)
- {
- featureDefinitions.AddAttribute("Display", "hidden");
- }
-
- featureDefinitions.EndElement("Feature");
-
- return true;
-}
-
bool cmCPackWIXGenerator::AddComponentsToFeature(
std::string const& rootPath,
std::string const& featureId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
shortcut_map_t& shortcutMap)
{
featureDefinitions.BeginElement("FeatureRef");
@@ -768,8 +657,8 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
std::string const& cpackComponentName,
std::string const& featureId,
shortcut_map_t& shortcutMap,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions)
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions)
{
bool thisHasDesktopShortcuts = false;
@@ -799,6 +688,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
fileDefinitions.BeginElement("DirectoryRef");
fileDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+
fileDefinitions.BeginElement("Component");
fileDefinitions.AddAttribute("Id", componentId);
fileDefinitions.AddAttribute("Guid", "*");
@@ -809,63 +699,34 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
std::string const& id = i->first;
cmWIXShortcut const& shortcut = i->second;
- std::string shortcutId = std::string("CM_S") + id;
- std::string fileId = std::string("CM_F") + id;
+ fileDefinitions.EmitShortcut(id, shortcut, false);
- fileDefinitions.BeginElement("Shortcut");
- fileDefinitions.AddAttribute("Id", shortcutId);
- fileDefinitions.AddAttribute("Name", shortcut.textLabel);
- std::string target = "[#" + fileId + "]";
- fileDefinitions.AddAttribute("Target", target);
- fileDefinitions.AddAttribute("WorkingDirectory",
- shortcut.workingDirectoryId);
- fileDefinitions.EndElement("Shortcut");
-
- if (shortcut.desktop)
+ if(shortcut.desktop)
{
- thisHasDesktopShortcuts = true;
+ thisHasDesktopShortcuts = true;
}
}
if(cpackComponentName.empty())
{
- CreateUninstallShortcut(cpackPackageName, fileDefinitions);
+ fileDefinitions.EmitUninstallShortcut(cpackPackageName);
}
- fileDefinitions.BeginElement("RemoveFolder");
- fileDefinitions.AddAttribute("Id",
+ fileDefinitions.EmitRemoveFolder(
"CM_REMOVE_PROGRAM_MENU_FOLDER" + idSuffix);
- fileDefinitions.AddAttribute("On", "uninstall");
- fileDefinitions.EndElement("RemoveFolder");
std::string registryKey =
std::string("Software\\") + cpackVendor + "\\" + cpackPackageName;
- fileDefinitions.BeginElement("RegistryValue");
- fileDefinitions.AddAttribute("Root", "HKCU");
- fileDefinitions.AddAttribute("Key", registryKey);
-
- std::string valueName;
- if(!cpackComponentName.empty())
- {
- valueName = cpackComponentName + "_";
- }
- valueName += "installed";
-
- fileDefinitions.AddAttribute("Name", valueName);
- fileDefinitions.AddAttribute("Type", "integer");
- fileDefinitions.AddAttribute("Value", "1");
- fileDefinitions.AddAttribute("KeyPath", "yes");
- fileDefinitions.EndElement("RegistryValue");
+ fileDefinitions.EmitStartMenuShortcutRegistryValue(
+ registryKey, cpackComponentName);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
- featureDefinitions.BeginElement("ComponentRef");
- featureDefinitions.AddAttribute("Id", componentId);
- featureDefinitions.EndElement("ComponentRef");
+ featureDefinitions.EmitComponentRef(componentId);
- if (thisHasDesktopShortcuts)
+ if(thisHasDesktopShortcuts)
{
this->HasDesktopShortcuts = true;
componentId = "CM_DESKTOP_SHORTCUT" + idSuffix;
@@ -876,7 +737,7 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
fileDefinitions.AddAttribute("Id", componentId);
fileDefinitions.AddAttribute("Guid", "*");
- for (shortcut_map_t::const_iterator
+ for(shortcut_map_t::const_iterator
i = shortcutMap.begin(); i != shortcutMap.end(); ++i)
{
std::string const& id = i->first;
@@ -885,34 +746,16 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
if (!shortcut.desktop)
continue;
- std::string shortcutId = std::string("CM_DS") + id;
- std::string fileId = std::string("CM_F") + id;
-
- fileDefinitions.BeginElement("Shortcut");
- fileDefinitions.AddAttribute("Id", shortcutId);
- fileDefinitions.AddAttribute("Name", shortcut.textLabel);
- std::string target = "[#" + fileId + "]";
- fileDefinitions.AddAttribute("Target", target);
- fileDefinitions.AddAttribute("WorkingDirectory",
- shortcut.workingDirectoryId);
- fileDefinitions.EndElement("Shortcut");
+ fileDefinitions.EmitShortcut(id, shortcut, true);
}
- fileDefinitions.BeginElement("RegistryValue");
- fileDefinitions.AddAttribute("Root", "HKCU");
- fileDefinitions.AddAttribute("Key", registryKey);
- fileDefinitions.AddAttribute("Name", valueName + "_desktop");
- fileDefinitions.AddAttribute("Type", "integer");
- fileDefinitions.AddAttribute("Value", "1");
- fileDefinitions.AddAttribute("KeyPath", "yes");
- fileDefinitions.EndElement("RegistryValue");
+ fileDefinitions.EmitDesktopShortcutRegistryValue(
+ registryKey, cpackComponentName);
fileDefinitions.EndElement("Component");
fileDefinitions.EndElement("DirectoryRef");
- featureDefinitions.BeginElement("ComponentRef");
- featureDefinitions.AddAttribute("Id", componentId);
- featureDefinitions.EndElement("ComponentRef");
+ featureDefinitions.EmitComponentRef(componentId);
}
featureDefinitions.EndElement("FeatureRef");
@@ -920,19 +763,6 @@ bool cmCPackWIXGenerator::CreateStartMenuShortcuts(
return true;
}
-void cmCPackWIXGenerator::CreateUninstallShortcut(
- std::string const& packageName,
- cmWIXSourceWriter& fileDefinitions)
-{
- fileDefinitions.BeginElement("Shortcut");
- fileDefinitions.AddAttribute("Id", "UNINSTALL");
- fileDefinitions.AddAttribute("Name", "Uninstall " + packageName);
- fileDefinitions.AddAttribute("Description", "Uninstalls " + packageName);
- fileDefinitions.AddAttribute("Target", "[SystemFolder]msiexec.exe");
- fileDefinitions.AddAttribute("Arguments", "/x [ProductCode]");
- fileDefinitions.EndElement("Shortcut");
-}
-
bool cmCPackWIXGenerator::CreateLicenseFile()
{
std::string licenseSourceFilename;
@@ -981,11 +811,11 @@ bool cmCPackWIXGenerator::CreateLicenseFile()
}
void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
- const std::string& topdir,
- const std::string& directoryId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ std::string const& topdir,
+ std::string const& directoryId,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
const std::vector<std::string>& packageExecutables,
const std::vector<std::string>& desktopExecutables,
shortcut_map_t& shortcutMap)
@@ -993,6 +823,16 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
cmsys::Directory dir;
dir.Load(topdir.c_str());
+ if(dir.GetNumberOfFiles() == 2)
+ {
+ std::string componentId = fileDefinitions.EmitComponentCreateFolder(
+ directoryId, GenerateGUID());
+
+ featureDefinitions.EmitComponentRef(componentId);
+
+ return;
+ }
+
for(size_t i = 0; i < dir.GetNumberOfFiles(); ++i)
{
std::string fileName = dir.GetFile(static_cast<unsigned long>(i));
@@ -1026,44 +866,15 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
desktopExecutables,
shortcutMap);
- ApplyPatchFragment(subDirectoryId, directoryDefinitions);
+ this->Patch->ApplyFragment(subDirectoryId, directoryDefinitions);
directoryDefinitions.EndElement("Directory");
}
else
{
- std::string componentId = std::string("CM_C") + id;
- std::string fileId = std::string("CM_F") + id;
+ std::string componentId = fileDefinitions.EmitComponentFile(
+ directoryId, id, fullPath, *(this->Patch));
- fileDefinitions.BeginElement("DirectoryRef");
- fileDefinitions.AddAttribute("Id", directoryId);
-
- fileDefinitions.BeginElement("Component");
- fileDefinitions.AddAttribute("Id", componentId);
- fileDefinitions.AddAttribute("Guid", "*");
-
- fileDefinitions.BeginElement("File");
- fileDefinitions.AddAttribute("Id", fileId);
- fileDefinitions.AddAttribute("Source", fullPath);
- fileDefinitions.AddAttribute("KeyPath", "yes");
-
- mode_t fileMode = 0;
- cmSystemTools::GetPermissions(fullPath.c_str(), fileMode);
-
- if(!(fileMode & S_IWRITE))
- {
- fileDefinitions.AddAttribute("ReadOnly", "yes");
- }
-
- ApplyPatchFragment(fileId, fileDefinitions);
- fileDefinitions.EndElement("File");
-
- ApplyPatchFragment(componentId, fileDefinitions);
- fileDefinitions.EndElement("Component");
- fileDefinitions.EndElement("DirectoryRef");
-
- featureDefinitions.BeginElement("ComponentRef");
- featureDefinitions.AddAttribute("Id", componentId);
- featureDefinitions.EndElement("ComponentRef");
+ featureDefinitions.EmitComponentRef(componentId);
for(size_t j = 0; j < packageExecutables.size(); ++j)
{
@@ -1092,7 +903,7 @@ void cmCPackWIXGenerator::AddDirectoryAndFileDefinitons(
}
bool cmCPackWIXGenerator::RequireOption(
- const std::string& name, std::string &value) const
+ std::string const& name, std::string &value) const
{
const char* tmp = GetOption(name.c_str());
if(tmp)
@@ -1140,13 +951,13 @@ std::string cmCPackWIXGenerator::GenerateGUID()
return cmSystemTools::UpperCase(result);
}
-std::string cmCPackWIXGenerator::QuotePath(const std::string& path)
+std::string cmCPackWIXGenerator::QuotePath(std::string const& path)
{
return std::string("\"") + path + '"';
}
std::string cmCPackWIXGenerator::GetRightmostExtension(
- const std::string& filename)
+ std::string const& filename)
{
std::string extension;
@@ -1159,7 +970,7 @@ std::string cmCPackWIXGenerator::GetRightmostExtension(
return cmSystemTools::LowerCase(extension);
}
-std::string cmCPackWIXGenerator::PathToId(const std::string& path)
+std::string cmCPackWIXGenerator::PathToId(std::string const& path)
{
id_map_t::const_iterator i = PathToIdMap.find(path);
if(i != PathToIdMap.end()) return i->second;
@@ -1168,7 +979,7 @@ std::string cmCPackWIXGenerator::PathToId(const std::string& path)
return id;
}
-std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
+std::string cmCPackWIXGenerator::CreateNewIdForPath(std::string const& path)
{
std::vector<std::string> components;
cmSystemTools::SplitPath(path.c_str(), components, false);
@@ -1222,7 +1033,7 @@ std::string cmCPackWIXGenerator::CreateNewIdForPath(const std::string& path)
}
std::string cmCPackWIXGenerator::CreateHashedId(
- const std::string& path, const std::string& normalizedFilename)
+ std::string const& path, std::string const& normalizedFilename)
{
cmsys::auto_ptr<cmCryptoHash> sha1 = cmCryptoHash::New("SHA1");
std::string hash = sha1->HashString(path.c_str());
@@ -1245,7 +1056,7 @@ std::string cmCPackWIXGenerator::CreateHashedId(
}
std::string cmCPackWIXGenerator::NormalizeComponentForId(
- const std::string& component, size_t& replacementCount)
+ std::string const& component, size_t& replacementCount)
{
std::string result;
result.resize(component.size());
@@ -1276,7 +1087,7 @@ bool cmCPackWIXGenerator::IsLegalIdCharacter(char c)
}
void cmCPackWIXGenerator::CollectExtensions(
- const std::string& variableName, extension_set_t& extensions)
+ std::string const& variableName, extension_set_t& extensions)
{
const char *variableContent = GetOption(variableName.c_str());
if(!variableContent) return;
@@ -1292,7 +1103,7 @@ void cmCPackWIXGenerator::CollectExtensions(
}
void cmCPackWIXGenerator::AddCustomFlags(
- const std::string& variableName, std::ostream& stream)
+ std::string const& variableName, std::ostream& stream)
{
const char *variableContent = GetOption(variableName.c_str());
if(!variableContent) return;
@@ -1306,69 +1117,3 @@ void cmCPackWIXGenerator::AddCustomFlags(
stream << " " << QuotePath(*i);
}
}
-
-void cmCPackWIXGenerator::CreateStartMenuFolder(
- cmWIXSourceWriter& directoryDefinitions)
-{
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "ProgramMenuFolder");
-
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "PROGRAM_MENU_FOLDER");
- const char *startMenuFolder = GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
- directoryDefinitions.AddAttribute("Name", startMenuFolder);
- directoryDefinitions.EndElement("Directory");
-
- directoryDefinitions.EndElement("Directory");
-}
-
-void cmCPackWIXGenerator::CreateDesktopFolder(
- cmWIXSourceWriter& directoryDefinitions)
-{
- directoryDefinitions.BeginElement("Directory");
- directoryDefinitions.AddAttribute("Id", "DesktopFolder");
- directoryDefinitions.AddAttribute("Name", "Desktop");
- directoryDefinitions.EndElement("Directory");
-}
-
-void cmCPackWIXGenerator::LoadPatchFragments(const std::string& patchFilePath)
-{
- cmWIXPatchParser parser(Fragments, Logger);
- parser.ParseFile(patchFilePath.c_str());
-}
-
-void cmCPackWIXGenerator::ApplyPatchFragment(
- const std::string& id, cmWIXSourceWriter& writer)
-{
- cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
- if(i == Fragments.end()) return;
-
- const cmWIXPatchElement& fragment = i->second;
- for(cmWIXPatchElement::child_list_t::const_iterator
- j = fragment.children.begin(); j != fragment.children.end(); ++j)
- {
- ApplyPatchElement(**j, writer);
- }
-
- Fragments.erase(i);
-}
-
-void cmCPackWIXGenerator::ApplyPatchElement(
- const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
-{
- writer.BeginElement(element.name);
-
- for(cmWIXPatchElement::attributes_t::const_iterator
- i = element.attributes.begin(); i != element.attributes.end(); ++i)
- {
- writer.AddAttribute(i->first, i->second);
- }
-
- for(cmWIXPatchElement::child_list_t::const_iterator
- i = element.children.begin(); i != element.children.end(); ++i)
- {
- ApplyPatchElement(**i, writer);
- }
-
- writer.EndElement(element.name);
-}
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.h b/Source/CPack/WiX/cmCPackWIXGenerator.h
index 1de4810..8705d40 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.h
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.h
@@ -13,25 +13,18 @@
#ifndef cmCPackWIXGenerator_h
#define cmCPackWIXGenerator_h
-#include "cmWIXPatchParser.h"
+#include "cmWIXPatch.h"
+#include "cmWIXShortcut.h"
#include <CPack/cmCPackGenerator.h>
#include <string>
#include <map>
-struct cmWIXShortcut
-{
- cmWIXShortcut()
- :desktop(false)
- {}
-
- std::string textLabel;
- std::string workingDirectoryId;
- bool desktop;
-};
-
class cmWIXSourceWriter;
+class cmWIXDirectoriesSourceWriter;
+class cmWIXFilesSourceWriter;
+class cmWIXFeaturesSourceWriter;
/** \class cmCPackWIXGenerator
* \brief A generator for WIX files
@@ -42,6 +35,7 @@ public:
cmCPackTypeMacro(cmCPackWIXGenerator, cmCPackGenerator);
cmCPackWIXGenerator();
+ ~cmCPackWIXGenerator();
protected:
virtual int InitializeInternal();
@@ -78,48 +72,39 @@ private:
bool PackageFilesImpl();
- bool CreateWiXVariablesIncludeFile();
+ void CreateWiXVariablesIncludeFile();
+
+ void CreateWiXPropertiesIncludeFile();
void CopyDefinition(
- cmWIXSourceWriter &source, const std::string &name);
+ cmWIXSourceWriter &source, std::string const& name);
void AddDefinition(cmWIXSourceWriter& source,
- const std::string& name, const std::string& value);
+ std::string const& name, std::string const& value);
bool CreateWiXSourceFiles();
- bool CreateCMakePackageRegistryEntry(
- cmWIXSourceWriter& featureDefinitions);
+ std::string GetProgramFilesFolderId() const;
- bool CreateFeatureHierarchy(
- cmWIXSourceWriter& featureDefinitions);
-
- bool EmitFeatureForComponentGroup(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponentGroup const& group);
+ bool GenerateMainSourceFileFromTemplate();
- bool EmitFeatureForComponent(
- cmWIXSourceWriter& featureDefinitions,
- cmCPackComponent const& component);
+ bool CreateFeatureHierarchy(
+ cmWIXFeaturesSourceWriter& featureDefinitions);
bool AddComponentsToFeature(
std::string const& rootPath,
std::string const& featureId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
shortcut_map_t& shortcutMap);
bool CreateStartMenuShortcuts(
std::string const& cpackComponentName,
std::string const& featureId,
shortcut_map_t& shortcutMap,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions);
-
- void CreateUninstallShortcut(
- std::string const& packageName,
- cmWIXSourceWriter& fileDefinitions);
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions);
void AppendUserSuppliedExtraSources();
@@ -127,60 +112,49 @@ private:
bool CreateLicenseFile();
- bool RunWiXCommand(const std::string& command);
+ bool RunWiXCommand(std::string const& command);
bool RunCandleCommand(
- const std::string& sourceFile, const std::string& objectFile);
+ std::string const& sourceFile, std::string const& objectFile);
- bool RunLightCommand(const std::string& objectFiles);
+ bool RunLightCommand(std::string const& objectFiles);
- void AddDirectoryAndFileDefinitons(const std::string& topdir,
- const std::string& directoryId,
- cmWIXSourceWriter& directoryDefinitions,
- cmWIXSourceWriter& fileDefinitions,
- cmWIXSourceWriter& featureDefinitions,
+ void AddDirectoryAndFileDefinitons(std::string const& topdir,
+ std::string const& directoryId,
+ cmWIXDirectoriesSourceWriter& directoryDefinitions,
+ cmWIXFilesSourceWriter& fileDefinitions,
+ cmWIXFeaturesSourceWriter& featureDefinitions,
const std::vector<std::string>& pkgExecutables,
const std::vector<std::string>& desktopExecutables,
shortcut_map_t& shortcutMap);
- bool RequireOption(const std::string& name, std::string& value) const;
+ bool RequireOption(std::string const& name, std::string& value) const;
std::string GetArchitecture() const;
static std::string GenerateGUID();
- static std::string QuotePath(const std::string& path);
+ static std::string QuotePath(std::string const& path);
- static std::string GetRightmostExtension(const std::string& filename);
+ static std::string GetRightmostExtension(std::string const& filename);
- std::string PathToId(const std::string& path);
+ std::string PathToId(std::string const& path);
- std::string CreateNewIdForPath(const std::string& path);
+ std::string CreateNewIdForPath(std::string const& path);
static std::string CreateHashedId(
- const std::string& path, const std::string& normalizedFilename);
+ std::string const& path, std::string const& normalizedFilename);
std::string NormalizeComponentForId(
- const std::string& component, size_t& replacementCount);
+ std::string const& component, size_t& replacementCount);
static bool IsLegalIdCharacter(char c);
void CollectExtensions(
- const std::string& variableName, extension_set_t& extensions);
+ std::string const& variableName, extension_set_t& extensions);
void AddCustomFlags(
- const std::string& variableName, std::ostream& stream);
-
- void CreateStartMenuFolder(cmWIXSourceWriter& directoryDefinitions);
-
- void CreateDesktopFolder(cmWIXSourceWriter& directoryDefinitions);
-
- void LoadPatchFragments(const std::string& patchFilePath);
-
- void ApplyPatchFragment(const std::string& id, cmWIXSourceWriter& writer);
-
- void ApplyPatchElement(const cmWIXPatchElement& element,
- cmWIXSourceWriter& writer);
+ std::string const& variableName, std::ostream& stream);
std::vector<std::string> WixSources;
id_map_t PathToIdMap;
@@ -189,9 +163,11 @@ private:
extension_set_t CandleExtensions;
extension_set_t LightExtensions;
- cmWIXPatchParser::fragment_map_t Fragments;
-
bool HasDesktopShortcuts;
+
+ std::string CPackTopLevel;
+
+ cmWIXPatch* Patch;
};
#endif
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
new file mode 100644
index 0000000..a93f89b
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -0,0 +1,87 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 "cmWIXDirectoriesSourceWriter.h"
+
+cmWIXDirectoriesSourceWriter::cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
+ std::string const& filename):
+ cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
+ std::string const& startMenuFolder)
+{
+ BeginElement("Directory");
+ AddAttribute("Id", "ProgramMenuFolder");
+
+ BeginElement("Directory");
+ AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+ AddAttribute("Name", startMenuFolder);
+ EndElement("Directory");
+
+ EndElement("Directory");
+}
+
+void cmWIXDirectoriesSourceWriter::EmitDesktopFolder()
+{
+ BeginElement("Directory");
+ AddAttribute("Id", "DesktopFolder");
+ AddAttribute("Name", "Desktop");
+ EndElement("Directory");
+}
+
+size_t cmWIXDirectoriesSourceWriter::BeginInstallationPrefixDirectory(
+ std::string const& programFilesFolderId,
+ std::string const& installRootString)
+{
+ BeginElement("Directory");
+ AddAttribute("Id", programFilesFolderId);
+
+ std::vector<std::string> installRoot;
+
+ cmSystemTools::SplitPath(installRootString.c_str(), installRoot);
+
+ if(!installRoot.empty() && installRoot.back().empty())
+ {
+ installRoot.pop_back();
+ }
+
+ for(size_t i = 1; i < installRoot.size(); ++i)
+ {
+ BeginElement("Directory");
+
+ if(i == installRoot.size() - 1)
+ {
+ AddAttribute("Id", "INSTALL_ROOT");
+ }
+ else
+ {
+ std::stringstream tmp;
+ tmp << "INSTALL_PREFIX_" << i;
+ AddAttribute("Id", tmp.str());
+ }
+
+ AddAttribute("Name", installRoot[i]);
+ }
+
+ return installRoot.size();
+}
+
+void cmWIXDirectoriesSourceWriter::EndInstallationPrefixDirectory(size_t size)
+{
+ for(size_t i = 0; i < size; ++i)
+ {
+ EndElement("Directory");
+ }
+}
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
new file mode 100644
index 0000000..f51fdb4
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.h
@@ -0,0 +1,42 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 cmWIXDirectoriesSourceWriter_h
+#define cmWIXDirectoriesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+#include <string>
+
+/** \class cmWIXDirectoriesSourceWriter
+ * \brief Helper class to generate directories.wxs
+ */
+class cmWIXDirectoriesSourceWriter : public cmWIXSourceWriter
+{
+public:
+ cmWIXDirectoriesSourceWriter(cmCPackLog* logger,
+ std::string const& filename);
+
+ void EmitStartMenuFolder(std::string const& startMenuFolder);
+
+ void EmitDesktopFolder();
+
+ size_t BeginInstallationPrefixDirectory(
+ std::string const& programFilesFolderId,
+ std::string const& installRootString);
+
+ void EndInstallationPrefixDirectory(size_t size);
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
new file mode 100644
index 0000000..0bcfc38
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.cxx
@@ -0,0 +1,102 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 "cmWIXFeaturesSourceWriter.h"
+
+cmWIXFeaturesSourceWriter::cmWIXFeaturesSourceWriter(cmCPackLog* logger,
+ std::string const& filename):
+ cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXFeaturesSourceWriter::CreateCMakePackageRegistryEntry(
+ std::string const& package,
+ std::string const& upgradeGuid)
+{
+ BeginElement("Component");
+ AddAttribute("Id", "CM_PACKAGE_REGISTRY");
+ AddAttribute("Directory", "TARGETDIR");
+ AddAttribute("Guid", "*");
+
+ std::string registryKey =
+ std::string("Software\\Kitware\\CMake\\Packages\\") + package;
+
+ BeginElement("RegistryValue");
+ AddAttribute("Root", "HKLM");
+ AddAttribute("Key", registryKey);
+ AddAttribute("Name", upgradeGuid);
+ AddAttribute("Type", "string");
+ AddAttribute("Value", "[INSTALL_ROOT]");
+ AddAttribute("KeyPath", "yes");
+ EndElement("RegistryValue");
+
+ EndElement("Component");
+}
+
+void cmWIXFeaturesSourceWriter::EmitFeatureForComponentGroup(
+ cmCPackComponentGroup const& group)
+{
+ BeginElement("Feature");
+ AddAttribute("Id", "CM_G_" + group.Name);
+
+ if(group.IsExpandedByDefault)
+ {
+ AddAttribute("Display", "expand");
+ }
+
+ AddAttributeUnlessEmpty("Title", group.DisplayName);
+ AddAttributeUnlessEmpty("Description", group.Description);
+
+ for(std::vector<cmCPackComponentGroup*>::const_iterator
+ i = group.Subgroups.begin(); i != group.Subgroups.end(); ++i)
+ {
+ EmitFeatureForComponentGroup(**i);
+ }
+
+ for(std::vector<cmCPackComponent*>::const_iterator
+ i = group.Components.begin(); i != group.Components.end(); ++i)
+ {
+ EmitFeatureForComponent(**i);
+ }
+
+ EndElement("Feature");
+}
+
+void cmWIXFeaturesSourceWriter::EmitFeatureForComponent(
+ cmCPackComponent const& component)
+{
+ BeginElement("Feature");
+ AddAttribute("Id", "CM_C_" + component.Name);
+
+ AddAttributeUnlessEmpty("Title", component.DisplayName);
+ AddAttributeUnlessEmpty("Description", component.Description);
+
+ if(component.IsRequired)
+ {
+ AddAttribute("Absent", "disallow");
+ }
+
+ if(component.IsHidden)
+ {
+ AddAttribute("Display", "hidden");
+ }
+
+ EndElement("Feature");
+}
+
+void cmWIXFeaturesSourceWriter::EmitComponentRef(std::string const& id)
+{
+ BeginElement("ComponentRef");
+ AddAttribute("Id", id);
+ EndElement("ComponentRef");
+}
diff --git a/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
new file mode 100644
index 0000000..7670417
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFeaturesSourceWriter.h
@@ -0,0 +1,39 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 cmWIXFeaturesSourceWriter_h
+#define cmWIXFeaturesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+#include <CPack/cmCPackGenerator.h>
+
+/** \class cmWIXFeaturesSourceWriter
+ * \brief Helper class to generate features.wxs
+ */
+class cmWIXFeaturesSourceWriter : public cmWIXSourceWriter
+{
+public:
+ cmWIXFeaturesSourceWriter(cmCPackLog* logger,
+ std::string const& filename);
+
+ void CreateCMakePackageRegistryEntry(
+ std::string const& package,
+ std::string const& upgradeGuid);
+
+ void EmitFeatureForComponentGroup(const cmCPackComponentGroup& group);
+
+ void EmitFeatureForComponent(const cmCPackComponent& component);
+
+ void EmitComponentRef(std::string const& id);
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
new file mode 100644
index 0000000..3fd959e
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.cxx
@@ -0,0 +1,171 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 "cmWIXFilesSourceWriter.h"
+
+#include <sys/types.h>
+#include <sys/stat.h>
+
+cmWIXFilesSourceWriter::cmWIXFilesSourceWriter(cmCPackLog* logger,
+ std::string const& filename):
+ cmWIXSourceWriter(logger, filename)
+{
+
+}
+
+void cmWIXFilesSourceWriter::EmitShortcut(
+ std::string const& id,
+ cmWIXShortcut const& shortcut,
+ bool desktop)
+{
+ std::string shortcutId;
+
+ if(desktop)
+ {
+ shortcutId = "CM_DS";
+ }
+ else
+ {
+ shortcutId = "CM_S";
+ }
+
+ shortcutId += id;
+
+ std::string fileId = std::string("CM_F") + id;
+
+ BeginElement("Shortcut");
+ AddAttribute("Id", shortcutId);
+ AddAttribute("Name", shortcut.textLabel);
+ std::string target = "[#" + fileId + "]";
+ AddAttribute("Target", target);
+ AddAttribute("WorkingDirectory", shortcut.workingDirectoryId);
+ EndElement("Shortcut");
+}
+
+void cmWIXFilesSourceWriter::EmitRemoveFolder(std::string const& id)
+{
+ BeginElement("RemoveFolder");
+ AddAttribute("Id", id);
+ AddAttribute("On", "uninstall");
+ EndElement("RemoveFolder");
+}
+
+void cmWIXFilesSourceWriter::EmitStartMenuShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName)
+{
+ EmitInstallRegistryValue(registryKey, cpackComponentName, std::string());
+}
+
+void cmWIXFilesSourceWriter::EmitDesktopShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName)
+{
+ EmitInstallRegistryValue(registryKey, cpackComponentName, "_desktop");
+}
+
+void cmWIXFilesSourceWriter::EmitInstallRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName,
+ std::string const& suffix)
+{
+ std::string valueName;
+ if(!cpackComponentName.empty())
+ {
+ valueName = cpackComponentName + "_";
+ }
+
+ valueName += "installed";
+ valueName += suffix;
+
+ BeginElement("RegistryValue");
+ AddAttribute("Root", "HKCU");
+ AddAttribute("Key", registryKey);
+ AddAttribute("Name", valueName);
+ AddAttribute("Type", "integer");
+ AddAttribute("Value", "1");
+ AddAttribute("KeyPath", "yes");
+ EndElement("RegistryValue");
+}
+
+void cmWIXFilesSourceWriter::EmitUninstallShortcut(
+ std::string const& packageName)
+{
+ BeginElement("Shortcut");
+ AddAttribute("Id", "UNINSTALL");
+ AddAttribute("Name", "Uninstall " + packageName);
+ AddAttribute("Description", "Uninstalls " + packageName);
+ AddAttribute("Target", "[SystemFolder]msiexec.exe");
+ AddAttribute("Arguments", "/x [ProductCode]");
+ EndElement("Shortcut");
+}
+
+std::string cmWIXFilesSourceWriter::EmitComponentCreateFolder(
+ std::string const& directoryId, std::string const& guid)
+{
+ std::string componentId =
+ std::string("CM_C_EMPTY_") + directoryId;
+
+ BeginElement("DirectoryRef");
+ AddAttribute("Id", directoryId);
+
+ BeginElement("Component");
+ AddAttribute("Id", componentId);
+ AddAttribute("Guid", guid);
+
+ BeginElement("CreateFolder");
+
+ EndElement("CreateFolder");
+ EndElement("Component");
+ EndElement("DirectoryRef");
+
+ return componentId;
+}
+
+std::string cmWIXFilesSourceWriter::EmitComponentFile(
+ std::string const& directoryId,
+ std::string const& id,
+ std::string const& filePath,
+ cmWIXPatch &patch)
+{
+ std::string componentId = std::string("CM_C") + id;
+ std::string fileId = std::string("CM_F") + id;
+
+ BeginElement("DirectoryRef");
+ AddAttribute("Id", directoryId);
+
+ BeginElement("Component");
+ AddAttribute("Id", componentId);
+ AddAttribute("Guid", "*");
+
+ BeginElement("File");
+ AddAttribute("Id", fileId);
+ AddAttribute("Source", filePath);
+ AddAttribute("KeyPath", "yes");
+
+ mode_t fileMode = 0;
+ cmSystemTools::GetPermissions(filePath.c_str(), fileMode);
+
+ if(!(fileMode & S_IWRITE))
+ {
+ AddAttribute("ReadOnly", "yes");
+ }
+
+ patch.ApplyFragment(fileId, *this);
+ EndElement("File");
+
+ patch.ApplyFragment(componentId, *this);
+ EndElement("Component");
+ EndElement("DirectoryRef");
+
+ return componentId;
+}
diff --git a/Source/CPack/WiX/cmWIXFilesSourceWriter.h b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
new file mode 100644
index 0000000..13122c2
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXFilesSourceWriter.h
@@ -0,0 +1,66 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 cmWIXFilesSourceWriter_h
+#define cmWIXFilesSourceWriter_h
+
+#include "cmWIXSourceWriter.h"
+#include "cmWIXShortcut.h"
+#include "cmWIXPatch.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+/** \class cmWIXFilesSourceWriter
+ * \brief Helper class to generate files.wxs
+ */
+class cmWIXFilesSourceWriter : public cmWIXSourceWriter
+{
+public:
+ cmWIXFilesSourceWriter(cmCPackLog* logger,
+ std::string const& filename);
+
+ void EmitShortcut(
+ std::string const& id,
+ cmWIXShortcut const& shortcut,
+ bool desktop);
+
+ void EmitRemoveFolder(std::string const& id);
+
+ void EmitStartMenuShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName);
+
+ void EmitDesktopShortcutRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName);
+
+ void EmitUninstallShortcut(std::string const& packageName);
+
+ std::string EmitComponentCreateFolder(
+ std::string const& directoryId,
+ std::string const& guid);
+
+ std::string EmitComponentFile(
+ std::string const& directoryId,
+ std::string const& id,
+ std::string const& filePath,
+ cmWIXPatch &patch);
+
+private:
+ void EmitInstallRegistryValue(
+ std::string const& registryKey,
+ std::string const& cpackComponentName,
+ std::string const& suffix);
+};
+
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXPatch.cxx b/Source/CPack/WiX/cmWIXPatch.cxx
new file mode 100644
index 0000000..b5202e0
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatch.cxx
@@ -0,0 +1,91 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 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 "cmWIXPatch.h"
+
+#include <CPack/cmCPackGenerator.h>
+
+cmWIXPatch::cmWIXPatch(cmCPackLog* logger):
+ Logger(logger)
+{
+
+}
+
+void cmWIXPatch::LoadFragments(std::string const& patchFilePath)
+{
+ cmWIXPatchParser parser(Fragments, Logger);
+ parser.ParseFile(patchFilePath.c_str());
+}
+
+void cmWIXPatch::ApplyFragment(
+ std::string const& id, cmWIXSourceWriter& writer)
+{
+ cmWIXPatchParser::fragment_map_t::iterator i = Fragments.find(id);
+ if(i == Fragments.end()) return;
+
+ const cmWIXPatchElement& fragment = i->second;
+ for(cmWIXPatchElement::child_list_t::const_iterator
+ j = fragment.children.begin(); j != fragment.children.end(); ++j)
+ {
+ ApplyElement(**j, writer);
+ }
+
+ Fragments.erase(i);
+}
+
+void cmWIXPatch::ApplyElement(
+ const cmWIXPatchElement& element, cmWIXSourceWriter& writer)
+{
+ writer.BeginElement(element.name);
+
+ for(cmWIXPatchElement::attributes_t::const_iterator
+ i = element.attributes.begin(); i != element.attributes.end(); ++i)
+ {
+ writer.AddAttribute(i->first, i->second);
+ }
+
+ for(cmWIXPatchElement::child_list_t::const_iterator
+ i = element.children.begin(); i != element.children.end(); ++i)
+ {
+ ApplyElement(**i, writer);
+ }
+
+ writer.EndElement(element.name);
+}
+
+
+bool cmWIXPatch::CheckForUnappliedFragments()
+{
+ std::string fragmentList;
+ for(cmWIXPatchParser::fragment_map_t::const_iterator
+ i = Fragments.begin(); i != Fragments.end(); ++i)
+ {
+ if(!fragmentList.empty())
+ {
+ fragmentList += ", ";
+ }
+
+ fragmentList += "'";
+ fragmentList += i->first;
+ fragmentList += "'";
+ }
+
+ if(fragmentList.size())
+ {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Some XML patch fragments did not have matching IDs: " <<
+ fragmentList << std::endl);
+ return false;
+ }
+
+ return true;
+}
diff --git a/Source/CPack/WiX/cmWIXPatch.h b/Source/CPack/WiX/cmWIXPatch.h
new file mode 100644
index 0000000..7b7b2f1
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXPatch.h
@@ -0,0 +1,45 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 cmWIXPatch_h
+#define cmWIXPatch_h
+
+#include "cmWIXSourceWriter.h"
+#include "cmWIXPatchParser.h"
+
+#include <string>
+
+/** \class cmWIXPatch
+ * \brief Class that maintains and applies patch fragments
+ */
+class cmWIXPatch
+{
+public:
+ cmWIXPatch(cmCPackLog* logger);
+
+ void LoadFragments(std::string const& patchFilePath);
+
+ void ApplyFragment(std::string const& id, cmWIXSourceWriter& writer);
+
+ bool CheckForUnappliedFragments();
+
+private:
+ void ApplyElement(const cmWIXPatchElement& element,
+ cmWIXSourceWriter& writer);
+
+ cmCPackLog* Logger;
+
+ cmWIXPatchParser::fragment_map_t Fragments;
+};
+
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXPatchParser.cxx b/Source/CPack/WiX/cmWIXPatchParser.cxx
index 7ceaf1f..ef67b23 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.cxx
+++ b/Source/CPack/WiX/cmWIXPatchParser.cxx
@@ -34,12 +34,11 @@ cmWIXPatchParser::cmWIXPatchParser(
}
-void cmWIXPatchParser::StartElement(const char *name, const char **atts)
+void cmWIXPatchParser::StartElement(const std::string& name, const char **atts)
{
- std::string name_str = name;
if(State == BEGIN_DOCUMENT)
{
- if(name_str == "CPackWiXPatch")
+ if(name == "CPackWiXPatch")
{
State = BEGIN_FRAGMENTS;
}
@@ -50,7 +49,7 @@ void cmWIXPatchParser::StartElement(const char *name, const char **atts)
}
else if(State == BEGIN_FRAGMENTS)
{
- if(name_str == "CPackWiXFragment")
+ if(name == "CPackWiXFragment")
{
State = INSIDE_FRAGMENT;
StartFragment(atts);
@@ -107,12 +106,11 @@ void cmWIXPatchParser::StartFragment(const char **attributes)
}
}
-void cmWIXPatchParser::EndElement(const char *name)
+void cmWIXPatchParser::EndElement(const std::string& name)
{
- std::string name_str = name;
if(State == INSIDE_FRAGMENT)
{
- if(name_str == "CPackWiXFragment")
+ if(name == "CPackWiXFragment")
{
State = BEGIN_FRAGMENTS;
ElementStack.clear();
@@ -132,7 +130,7 @@ void cmWIXPatchParser::ReportError(int line, int column, const char* msg)
Valid = false;
}
-void cmWIXPatchParser::ReportValidationError(const std::string& message)
+void cmWIXPatchParser::ReportValidationError(std::string const& message)
{
ReportError(XML_GetCurrentLineNumber(Parser),
XML_GetCurrentColumnNumber(Parser),
diff --git a/Source/CPack/WiX/cmWIXPatchParser.h b/Source/CPack/WiX/cmWIXPatchParser.h
index 91b3b66..acfb4c0 100644
--- a/Source/CPack/WiX/cmWIXPatchParser.h
+++ b/Source/CPack/WiX/cmWIXPatchParser.h
@@ -43,14 +43,14 @@ public:
cmWIXPatchParser(fragment_map_t& Fragments, cmCPackLog* logger);
private:
- virtual void StartElement(const char *name, const char **atts);
+ virtual void StartElement(const std::string& name, const char **atts);
void StartFragment(const char **attributes);
- virtual void EndElement(const char *name);
+ virtual void EndElement(const std::string& name);
virtual void ReportError(int line, int column, const char* msg);
- void ReportValidationError(const std::string& message);
+ void ReportValidationError(std::string const& message);
bool IsValid() const;
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
index ddc1d71..f27caa9 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.cxx
@@ -15,7 +15,7 @@
#include <cmVersion.h>
cmWIXRichTextFormatWriter::cmWIXRichTextFormatWriter(
- const std::string& filename):
+ std::string const& filename):
File(filename.c_str(), std::ios::binary)
{
StartGroup();
@@ -33,7 +33,7 @@ cmWIXRichTextFormatWriter::~cmWIXRichTextFormatWriter()
File.put(0);
}
-void cmWIXRichTextFormatWriter::AddText(const std::string& text)
+void cmWIXRichTextFormatWriter::AddText(std::string const& text)
{
typedef unsigned char rtf_byte_t;
@@ -167,12 +167,12 @@ void cmWIXRichTextFormatWriter::WriteDocumentPrefix()
ControlWord("fs20");
}
-void cmWIXRichTextFormatWriter::ControlWord(const std::string& keyword)
+void cmWIXRichTextFormatWriter::ControlWord(std::string const& keyword)
{
File << "\\" << keyword;
}
-void cmWIXRichTextFormatWriter::NewControlWord(const std::string& keyword)
+void cmWIXRichTextFormatWriter::NewControlWord(std::string const& keyword)
{
File << "\\*\\" << keyword;
}
diff --git a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
index 2b665d4..f6327fb 100644
--- a/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
+++ b/Source/CPack/WiX/cmWIXRichTextFormatWriter.h
@@ -22,10 +22,10 @@
class cmWIXRichTextFormatWriter
{
public:
- cmWIXRichTextFormatWriter(const std::string& filename);
+ cmWIXRichTextFormatWriter(std::string const& filename);
~cmWIXRichTextFormatWriter();
- void AddText(const std::string& text);
+ void AddText(std::string const& text);
private:
void WriteHeader();
@@ -35,8 +35,8 @@ private:
void WriteDocumentPrefix();
- void ControlWord(const std::string& keyword);
- void NewControlWord(const std::string& keyword);
+ void ControlWord(std::string const& keyword);
+ void NewControlWord(std::string const& keyword);
void StartGroup();
void EndGroup();
diff --git a/Source/CPack/WiX/cmWIXShortcut.h b/Source/CPack/WiX/cmWIXShortcut.h
new file mode 100644
index 0000000..93095e0
--- /dev/null
+++ b/Source/CPack/WiX/cmWIXShortcut.h
@@ -0,0 +1,29 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 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 cmWIXFilesShortcut_h
+#define cmWIXFilesShortcut_h
+
+#include <string>
+
+struct cmWIXShortcut
+{
+ cmWIXShortcut()
+ :desktop(false)
+ {}
+
+ std::string textLabel;
+ std::string workingDirectoryId;
+ bool desktop;
+};
+
+#endif
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.cxx b/Source/CPack/WiX/cmWIXSourceWriter.cxx
index e83c226..aad19da 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXSourceWriter.cxx
@@ -17,7 +17,7 @@
#include <windows.h>
cmWIXSourceWriter::cmWIXSourceWriter(cmCPackLog* logger,
- const std::string& filename,
+ std::string const& filename,
bool isIncludeFile):
Logger(logger),
File(filename.c_str()),
@@ -51,7 +51,7 @@ cmWIXSourceWriter::~cmWIXSourceWriter()
EndElement(Elements.back());
}
-void cmWIXSourceWriter::BeginElement(const std::string& name)
+void cmWIXSourceWriter::BeginElement(std::string const& name)
{
if(State == BEGIN)
{
@@ -101,7 +101,7 @@ void cmWIXSourceWriter::EndElement(std::string const& name)
}
void cmWIXSourceWriter::AddProcessingInstruction(
- const std::string& target, const std::string& content)
+ std::string const& target, std::string const& content)
{
if(State == BEGIN)
{
@@ -116,7 +116,7 @@ void cmWIXSourceWriter::AddProcessingInstruction(
}
void cmWIXSourceWriter::AddAttribute(
- const std::string& key, const std::string& value)
+ std::string const& key, std::string const& value)
{
std::string utf8 = WindowsCodepageToUtf8(value);
@@ -124,7 +124,7 @@ void cmWIXSourceWriter::AddAttribute(
}
void cmWIXSourceWriter::AddAttributeUnlessEmpty(
- const std::string& key, const std::string& value)
+ std::string const& key, std::string const& value)
{
if(value.size())
{
@@ -132,7 +132,7 @@ void cmWIXSourceWriter::AddAttributeUnlessEmpty(
}
}
-std::string cmWIXSourceWriter::WindowsCodepageToUtf8(const std::string& value)
+std::string cmWIXSourceWriter::WindowsCodepageToUtf8(std::string const& value)
{
if(value.empty())
{
@@ -184,7 +184,7 @@ void cmWIXSourceWriter::Indent(size_t count)
}
std::string cmWIXSourceWriter::EscapeAttributeValue(
- const std::string& value)
+ std::string const& value)
{
std::string result;
result.reserve(value.size());
diff --git a/Source/CPack/WiX/cmWIXSourceWriter.h b/Source/CPack/WiX/cmWIXSourceWriter.h
index 894ad78..65b7240 100644
--- a/Source/CPack/WiX/cmWIXSourceWriter.h
+++ b/Source/CPack/WiX/cmWIXSourceWriter.h
@@ -26,24 +26,24 @@ class cmWIXSourceWriter
{
public:
cmWIXSourceWriter(cmCPackLog* logger,
- const std::string& filename, bool isIncludeFile = false);
+ std::string const& filename, bool isIncludeFile = false);
~cmWIXSourceWriter();
- void BeginElement(const std::string& name);
+ void BeginElement(std::string const& name);
- void EndElement(const std::string& name);
+ void EndElement(std::string const& name);
void AddProcessingInstruction(
- const std::string& target, const std::string& content);
+ std::string const& target, std::string const& content);
void AddAttribute(
- const std::string& key, const std::string& value);
+ std::string const& key, std::string const& value);
void AddAttributeUnlessEmpty(
- const std::string& key, const std::string& value);
+ std::string const& key, std::string const& value);
- static std::string WindowsCodepageToUtf8(const std::string& value);
+ static std::string WindowsCodepageToUtf8(std::string const& value);
private:
enum State
@@ -56,7 +56,7 @@ private:
void Indent(size_t count);
- static std::string EscapeAttributeValue(const std::string& value);
+ static std::string EscapeAttributeValue(std::string const& value);
cmCPackLog* Logger;
diff --git a/Source/CPack/cmCPackComponentGroup.cxx b/Source/CPack/cmCPackComponentGroup.cxx
index f93eca8..77f11cb 100644
--- a/Source/CPack/cmCPackComponentGroup.cxx
+++ b/Source/CPack/cmCPackComponentGroup.cxx
@@ -16,7 +16,8 @@
#include <string>
//----------------------------------------------------------------------
-unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const
+unsigned long cmCPackComponent::GetInstalledSize(
+ const std::string& installDir) const
{
if (this->TotalSize != 0)
{
@@ -37,7 +38,7 @@ unsigned long cmCPackComponent::GetInstalledSize(const char* installDir) const
//----------------------------------------------------------------------
unsigned long
-cmCPackComponent::GetInstalledSizeInKbytes(const char* installDir) const
+cmCPackComponent::GetInstalledSizeInKbytes(const std::string& installDir) const
{
unsigned long result = (GetInstalledSize(installDir) + 512) / 1024;
return result? result : 1;
diff --git a/Source/CPack/cmCPackComponentGroup.h b/Source/CPack/cmCPackComponentGroup.h
index abae372..0679638 100644
--- a/Source/CPack/cmCPackComponentGroup.h
+++ b/Source/CPack/cmCPackComponentGroup.h
@@ -94,11 +94,11 @@ public:
/// Get the total installed size of all of the files in this
/// component, in bytes. installDir is the directory into which the
/// component was installed.
- unsigned long GetInstalledSize(const char* installDir) const;
+ unsigned long GetInstalledSize(const std::string& installDir) const;
/// Identical to GetInstalledSize, but returns the result in
/// kilobytes.
- unsigned long GetInstalledSizeInKbytes(const char* installDir) const;
+ unsigned long GetInstalledSizeInKbytes(const std::string& installDir) const;
private:
mutable unsigned long TotalSize;
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index 0162d55..936942b 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -403,9 +403,39 @@ int cmCPackDebGenerator::createDeb()
if (NULL != this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE")) {
cmd += this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE");
}
- cmd += " \"";
- cmd += cmakeExecutable;
- cmd += "\" -E tar cfz data.tar.gz ";
+
+ const char* debian_compression_type =
+ this->GetOption("CPACK_DEBIAN_COMPRESSION_TYPE");
+ if(!debian_compression_type)
+ {
+ debian_compression_type = "gzip";
+ }
+
+ std::string cmake_tar = " ", compression_modifier = "a", compression_suffix;
+ if(!strcmp(debian_compression_type, "lzma")) {
+ compression_suffix = ".lzma";
+ } else if(!strcmp(debian_compression_type, "xz")) {
+ compression_suffix = ".xz";
+ } else if(!strcmp(debian_compression_type, "bzip2")) {
+ compression_suffix = ".bz2";
+ compression_modifier = "j";
+ cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+ } else if(!strcmp(debian_compression_type, "gzip")) {
+ compression_suffix = ".gz";
+ compression_modifier = "z";
+ cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+ } else if(!strcmp(debian_compression_type, "none")) {
+ compression_suffix = "";
+ compression_modifier = "";
+ cmake_tar += "\"" + std::string(cmakeExecutable) + "\" -E ";
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error unrecognized compression type: "
+ << debian_compression_type << std::endl);
+ }
+
+ cmd += cmake_tar + "tar c" + compression_modifier + "f data.tar"
+ + compression_suffix;
// now add all directories which have to be compressed
// collect all top level install dirs for that
@@ -444,13 +474,13 @@ int cmCPackDebGenerator::createDeb()
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << cmd.c_str() << std::endl
+ ofs << "# Run command: " << cmd << std::endl
<< "# Working directory: " << toplevel << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
- << cmd.c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << cmd << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
@@ -493,9 +523,7 @@ int cmCPackDebGenerator::createDeb()
{
cmd = this->GetOption("CPACK_DEBIAN_FAKEROOT_EXECUTABLE");
}
- cmd += " \"";
- cmd += cmakeExecutable;
- cmd += "\" -E tar cfz control.tar.gz ./control ./md5sums";
+ cmd += cmake_tar + "tar czf control.tar.gz ./control ./md5sums";
const char* controlExtra =
this->GetOption("CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA");
if( controlExtra )
@@ -506,7 +534,7 @@ int cmCPackDebGenerator::createDeb()
controlExtraList.begin(); i != controlExtraList.end(); ++i)
{
std::string filenamename =
- cmsys::SystemTools::GetFilenameName(i->c_str());
+ cmsys::SystemTools::GetFilenameName(*i);
std::string localcopy = this->GetOption("WDIR");
localcopy += "/";
localcopy += filenamename;
@@ -514,7 +542,7 @@ int cmCPackDebGenerator::createDeb()
if( cmsys::SystemTools::CopyFileIfDifferent(
i->c_str(), localcopy.c_str()) )
{
- // debian is picky and need relative to ./ path in the tar.gz
+ // debian is picky and need relative to ./ path in the tar.*
cmd += " ./";
cmd += filenamename;
}
@@ -528,17 +556,17 @@ int cmCPackDebGenerator::createDeb()
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/Deb.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << cmd.c_str() << std::endl
+ ofs << "# Run command: " << cmd << std::endl
<< "# Working directory: " << toplevel << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running tar command: "
- << cmd.c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << cmd << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
- // ar -r your-package-name.deb debian-binary control.tar.gz data.tar.gz
+ // ar -r your-package-name.deb debian-binary control.tar.* data.tar.*
// since debian packages require BSD ar (most Linux distros and even
// FreeBSD and NetBSD ship GNU ar) we use a copy of OpenBSD ar here.
std::vector<std::string> arFiles;
@@ -546,7 +574,7 @@ int cmCPackDebGenerator::createDeb()
topLevelString += "/";
arFiles.push_back(topLevelString + "debian-binary");
arFiles.push_back(topLevelString + "control.tar.gz");
- arFiles.push_back(topLevelString + "data.tar.gz");
+ arFiles.push_back(topLevelString + "data.tar" + compression_suffix);
std::string outputFileName = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
outputFileName += "/";
outputFileName += this->GetOption("CPACK_OUTPUT_FILE_NAME");
@@ -588,9 +616,9 @@ std::string cmCPackDebGenerator::GetComponentInstallDirNameSuffix(
// the current COMPONENT belongs to.
std::string groupVar = "CPACK_COMPONENT_" +
cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (NULL != GetOption(groupVar.c_str()))
+ if (NULL != GetOption(groupVar))
{
- return std::string(GetOption(groupVar.c_str()));
+ return std::string(GetOption(groupVar));
}
else
{
diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx
index 96491aa..9cdf5aa 100644
--- a/Source/CPack/cmCPackGenerator.cxx
+++ b/Source/CPack/cmCPackGenerator.cxx
@@ -254,7 +254,7 @@ int cmCPackGenerator::InstallProject()
// If the project is a CMAKE project then run pre-install
// and then read the cmake_install script to run it
if ( !this->InstallProjectViaInstallCMakeProjects(
- setDestDir, bareTempInstallDirectory.c_str()) )
+ setDestDir, bareTempInstallDirectory) )
{
return 0;
}
@@ -269,7 +269,7 @@ int cmCPackGenerator::InstallProject()
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstallCommands(
- bool setDestDir, const char* tempInstallDirectory)
+ bool setDestDir, const std::string& tempInstallDirectory)
{
(void) setDestDir;
const char* installCommands = this->GetOption("CPACK_INSTALL_COMMANDS");
@@ -285,7 +285,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
it != installCommandsVector.end();
++it )
{
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << it->c_str()
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << *it
<< std::endl);
std::string output;
int retVal = 1;
@@ -296,12 +296,12 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/InstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << it->c_str() << std::endl
+ ofs << "# Run command: " << *it << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running install command: " << it->c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors"
+ "Problem running install command: " << *it << std::endl
+ << "Please check " << tmpFile << " for errors"
<< std::endl);
return 0;
}
@@ -312,7 +312,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands(
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstalledDirectories(
- bool setDestDir, const char* tempInstallDirectory)
+ bool setDestDir, const std::string& tempInstallDirectory)
{
(void)setDestDir;
(void)tempInstallDirectory;
@@ -329,7 +329,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
++it )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
- "Create ignore files regex for: " << it->c_str() << std::endl);
+ "Create ignore files regex for: " << *it << std::endl);
ignoreFilesRegex.push_back(it->c_str());
}
}
@@ -349,7 +349,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
return 0;
}
std::vector<std::string>::iterator it;
- const char* tempDir = tempInstallDirectory;
+ const std::string& tempDir = tempInstallDirectory;
for ( it = installDirectoriesVector.begin();
it != installDirectoriesVector.end();
++it )
@@ -357,9 +357,9 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
std::list<std::pair<std::string,std::string> > symlinkedFiles;
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Find files" << std::endl);
cmsys::Glob gl;
- std::string top = it->c_str();
+ std::string top = *it;
it ++;
- std::string subdir = it->c_str();
+ std::string subdir = *it;
std::string findExpr = top;
findExpr += "/*";
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
@@ -385,7 +385,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
if ( regIt->find(inFile.c_str()) )
{
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Ignore file: "
- << inFile.c_str() << std::endl);
+ << inFile << std::endl);
skip = true;
}
}
@@ -397,7 +397,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
filePath += "/" + subdir + "/"
+ cmSystemTools::RelativePath(top.c_str(), gfit->c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Copy file: "
- << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
+ << inFile << " -> " << filePath << std::endl);
/* If the file is a symlink we will have to re-create it */
if ( cmSystemTools::FileIsSymlink(inFile.c_str()))
{
@@ -416,7 +416,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem copying file: "
- << inFile.c_str() << " -> " << filePath.c_str() << std::endl);
+ << inFile << " -> " << filePath << std::endl);
return 0;
}
}
@@ -457,7 +457,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories(
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstallScript(
- bool setDestDir, const char* tempInstallDirectory)
+ bool setDestDir, const std::string& tempInstallDirectory)
{
const char* cmakeScripts
= this->GetOption("CPACK_INSTALL_SCRIPT");
@@ -473,7 +473,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
it != cmakeScriptsVector.end();
++it )
{
- std::string installScript = it->c_str();
+ std::string installScript = *it;
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
"- Install script: " << installScript << std::endl);
@@ -499,7 +499,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
}
else
{
- this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory);
+ this->SetOption("CMAKE_INSTALL_PREFIX", tempInstallDirectory.c_str());
cmCPackLogger(cmCPackLog::LOG_DEBUG,
"- Using non-DESTDIR install... (this->SetOption)" << std::endl);
@@ -509,9 +509,9 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
}
this->SetOptionIfNotSet("CMAKE_CURRENT_BINARY_DIR",
- tempInstallDirectory);
+ tempInstallDirectory.c_str());
this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
- tempInstallDirectory);
+ tempInstallDirectory.c_str());
int res = this->MakefileMap->ReadListFile(0, installScript.c_str());
if ( cmSystemTools::GetErrorOccuredFlag() || !res )
{
@@ -524,7 +524,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript(
//----------------------------------------------------------------------
int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
- bool setDestDir, const char* baseTempInstallDirectory)
+ bool setDestDir, const std::string& baseTempInstallDirectory)
{
const char* cmakeProjects
= this->GetOption("CPACK_INSTALL_CMAKE_PROJECTS");
@@ -562,13 +562,13 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
<< std::endl);
return 0;
}
- std::string installDirectory = it->c_str();
+ std::string installDirectory = *it;
++it;
- std::string installProjectName = it->c_str();
+ std::string installProjectName = *it;
++it;
- std::string installComponent = it->c_str();
+ std::string installComponent = *it;
++it;
- std::string installSubDirectory = it->c_str();
+ std::string installSubDirectory = *it;
std::string installFile = installDirectory + "/cmake_install.cmake";
std::vector<std::string> componentsVector;
@@ -586,7 +586,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
// Determine the installation types for this project (if provided).
std::string installTypesVar = "CPACK_"
+ cmSystemTools::UpperCase(installComponent) + "_INSTALL_TYPES";
- const char *installTypes = this->GetOption(installTypesVar.c_str());
+ const char *installTypes = this->GetOption(installTypesVar);
if (installTypes && *installTypes)
{
std::vector<std::string> installTypesVector;
@@ -596,15 +596,15 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
installTypeIt != installTypesVector.end();
++installTypeIt)
{
- this->GetInstallationType(installProjectName.c_str(),
- installTypeIt->c_str());
+ this->GetInstallationType(installProjectName,
+ *installTypeIt);
}
}
// Determine the set of components that will be used in this project
std::string componentsVar
= "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(installComponent);
- const char *components = this->GetOption(componentsVar.c_str());
+ const char *components = this->GetOption(componentsVar);
if (components && *components)
{
cmSystemTools::ExpandListArgument(components, componentsVector);
@@ -613,7 +613,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
compIt != componentsVector.end();
++compIt)
{
- GetComponent(installProjectName.c_str(), compIt->c_str());
+ GetComponent(installProjectName, *compIt);
}
componentInstall = true;
}
@@ -623,7 +623,8 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
componentsVector.push_back(installComponent);
}
- const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
+ const char* buildConfigCstr = this->GetOption("CPACK_BUILD_CONFIG");
+ std::string buildConfig = buildConfigCstr ? buildConfigCstr : "";
cmGlobalGenerator* globalGenerator
= this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
cmakeGenerator);
@@ -640,7 +641,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
= this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
std::vector<std::string> buildCommand;
globalGenerator->GenerateBuildCommand(buildCommand, cmakeMakeProgram,
- installProjectName.c_str(), installDirectory.c_str(),
+ installProjectName, installDirectory,
globalGenerator->GetPreinstallTargetName(),
buildConfig, false);
std::string buildCommandStr =
@@ -662,14 +663,14 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/PreinstallOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << buildCommandStr.c_str() << std::endl
- << "# Directory: " << installDirectory.c_str() << std::endl
+ ofs << "# Run command: " << buildCommandStr << std::endl
+ << "# Directory: " << installDirectory << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Problem running install command: " << buildCommandStr.c_str()
+ "Problem running install command: " << buildCommandStr
<< std::endl
- << "Please check " << tmpFile.c_str() << " for errors"
+ << "Please check " << tmpFile << " for errors"
<< std::endl);
return 0;
}
@@ -822,9 +823,9 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
<< "'" << std::endl);
}
- if ( buildConfig && *buildConfig )
+ if (!buildConfig.empty())
{
- mf->AddDefinition("BUILD_TYPE", buildConfig);
+ mf->AddDefinition("BUILD_TYPE", buildConfig.c_str());
}
std::string installComponentLowerCase
= cmSystemTools::LowerCase(installComponent);
@@ -931,19 +932,19 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects(
std::string absoluteDestFileComponent =
std::string("CPACK_ABSOLUTE_DESTINATION_FILES")
+ "_" + GetComponentInstallDirNameSuffix(installComponent);
- if (NULL != this->GetOption(absoluteDestFileComponent.c_str()))
+ if (NULL != this->GetOption(absoluteDestFileComponent))
{
std::string absoluteDestFilesListComponent =
- this->GetOption(absoluteDestFileComponent.c_str());
+ this->GetOption(absoluteDestFileComponent);
absoluteDestFilesListComponent +=";";
absoluteDestFilesListComponent +=
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES");
- this->SetOption(absoluteDestFileComponent.c_str(),
+ this->SetOption(absoluteDestFileComponent,
absoluteDestFilesListComponent.c_str());
}
else
{
- this->SetOption(absoluteDestFileComponent.c_str(),
+ this->SetOption(absoluteDestFileComponent,
mf->GetDefinition("CPACK_ABSOLUTE_DESTINATION_FILES"));
}
}
@@ -972,7 +973,7 @@ bool cmCPackGenerator::ReadListFile(const char* moduleName)
}
//----------------------------------------------------------------------
-void cmCPackGenerator::SetOptionIfNotSet(const char* op,
+void cmCPackGenerator::SetOptionIfNotSet(const std::string& op,
const char* value)
{
const char* def = this->MakefileMap->GetDefinition(op);
@@ -984,12 +985,8 @@ void cmCPackGenerator::SetOptionIfNotSet(const char* op,
}
//----------------------------------------------------------------------
-void cmCPackGenerator::SetOption(const char* op, const char* value)
+void cmCPackGenerator::SetOption(const std::string& op, const char* value)
{
- if ( !op )
- {
- return;
- }
if ( !value )
{
this->MakefileMap->RemoveDefinition(op);
@@ -1004,7 +1001,7 @@ void cmCPackGenerator::SetOption(const char* op, const char* value)
int cmCPackGenerator::DoPackage()
{
cmCPackLogger(cmCPackLog::LOG_OUTPUT,
- "Create package using " << this->Name.c_str() << std::endl);
+ "Create package using " << this->Name << std::endl);
// Prepare CPack internal name and check
// values for many CPACK_xxx vars
@@ -1092,7 +1089,7 @@ int cmCPackGenerator::DoPackage()
* may update this during PackageFiles.
* (either putting several names or updating the provided one)
*/
- packageFileNames.push_back(tempPackageFileName);
+ packageFileNames.push_back(tempPackageFileName ? tempPackageFileName : "");
toplevel = tempDirectory;
if ( !this->PackageFiles() || cmSystemTools::GetErrorOccuredFlag())
{
@@ -1142,7 +1139,7 @@ int cmCPackGenerator::DoPackage()
}
//----------------------------------------------------------------------
-int cmCPackGenerator::Initialize(const char* name, cmMakefile* mf)
+int cmCPackGenerator::Initialize(const std::string& name, cmMakefile* mf)
{
this->MakefileMap = mf;
this->Name = name;
@@ -1176,19 +1173,19 @@ int cmCPackGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
-bool cmCPackGenerator::IsSet(const char* name) const
+bool cmCPackGenerator::IsSet(const std::string& name) const
{
return this->MakefileMap->IsSet(name);
}
//----------------------------------------------------------------------
-bool cmCPackGenerator::IsOn(const char* name) const
+bool cmCPackGenerator::IsOn(const std::string& name) const
{
return cmSystemTools::IsOn(GetOption(name));
}
//----------------------------------------------------------------------
-const char* cmCPackGenerator::GetOption(const char* op) const
+const char* cmCPackGenerator::GetOption(const std::string& op) const
{
const char* ret = this->MakefileMap->GetDefinition(op);
if(!ret)
@@ -1202,6 +1199,12 @@ const char* cmCPackGenerator::GetOption(const char* op) const
}
//----------------------------------------------------------------------
+std::vector<std::string> cmCPackGenerator::GetOptions() const
+{
+ return this->MakefileMap->GetDefinitions();
+}
+
+//----------------------------------------------------------------------
int cmCPackGenerator::PackageFiles()
{
return 0;
@@ -1266,7 +1269,7 @@ std::string cmCPackGenerator::FindTemplate(const char* name)
<< (name ? name : "(NULL)") << std::endl);
std::string ffile = this->MakefileMap->GetModulesFile(name);
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
- << ffile.c_str() << std::endl);
+ << ffile << std::endl);
return ffile;
}
@@ -1425,14 +1428,14 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
std::string suffix="-"+groupOrComponentName;
/* check if we should use DISPLAY name */
std::string dispNameVar = "CPACK_"+Name+"_USE_DISPLAY_NAME_IN_FILENAME";
- if (IsOn(dispNameVar.c_str()))
+ if (IsOn(dispNameVar))
{
/* the component Group case */
if (isGroupName)
{
std::string groupDispVar = "CPACK_COMPONENT_GROUP_"
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
- const char* groupDispName = GetOption(groupDispVar.c_str());
+ const char* groupDispName = GetOption(groupDispVar);
if (groupDispName)
{
suffix = "-"+std::string(groupDispName);
@@ -1443,7 +1446,7 @@ std::string cmCPackGenerator::GetComponentPackageFileName(
{
std::string dispVar = "CPACK_COMPONENT_"
+ cmSystemTools::UpperCase(groupOrComponentName) + "_DISPLAY_NAME";
- const char* dispName = GetOption(dispVar.c_str());
+ const char* dispName = GetOption(dispVar);
if(dispName)
{
suffix = "-"+std::string(dispName);
@@ -1480,8 +1483,8 @@ bool cmCPackGenerator::WantsComponentInstallation() const
//----------------------------------------------------------------------
cmCPackInstallationType*
-cmCPackGenerator::GetInstallationType(const char *projectName,
- const char *name)
+cmCPackGenerator::GetInstallationType(const std::string& projectName,
+ const std::string& name)
{
(void) projectName;
bool hasInstallationType = this->InstallationTypes.count(name) != 0;
@@ -1494,7 +1497,7 @@ cmCPackGenerator::GetInstallationType(const char *projectName,
installType->Name = name;
const char* displayName
- = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
+ = this->GetOption(macroPrefix + "_DISPLAY_NAME");
if (displayName && *displayName)
{
installType->DisplayName = displayName;
@@ -1512,7 +1515,8 @@ cmCPackGenerator::GetInstallationType(const char *projectName,
//----------------------------------------------------------------------
cmCPackComponent*
-cmCPackGenerator::GetComponent(const char *projectName, const char *name)
+cmCPackGenerator::GetComponent(const std::string& projectName,
+ const std::string& name)
{
bool hasComponent = this->Components.count(name) != 0;
cmCPackComponent *component = &this->Components[name];
@@ -1523,7 +1527,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
+ cmsys::SystemTools::UpperCase(name);
component->Name = name;
const char* displayName
- = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
+ = this->GetOption(macroPrefix + "_DISPLAY_NAME");
if (displayName && *displayName)
{
component->DisplayName = displayName;
@@ -1533,23 +1537,23 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
component->DisplayName = component->Name;
}
component->IsHidden
- = this->IsOn((macroPrefix + "_HIDDEN").c_str());
+ = this->IsOn(macroPrefix + "_HIDDEN");
component->IsRequired
- = this->IsOn((macroPrefix + "_REQUIRED").c_str());
+ = this->IsOn(macroPrefix + "_REQUIRED");
component->IsDisabledByDefault
- = this->IsOn((macroPrefix + "_DISABLED").c_str());
+ = this->IsOn(macroPrefix + "_DISABLED");
component->IsDownloaded
- = this->IsOn((macroPrefix + "_DOWNLOADED").c_str())
+ = this->IsOn(macroPrefix + "_DOWNLOADED")
|| cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL"));
- const char* archiveFile = this->GetOption((macroPrefix +
- "_ARCHIVE_FILE").c_str());
+ const char* archiveFile = this->GetOption(macroPrefix +
+ "_ARCHIVE_FILE");
if (archiveFile && *archiveFile)
{
component->ArchiveFile = archiveFile;
}
- const char* groupName = this->GetOption((macroPrefix + "_GROUP").c_str());
+ const char* groupName = this->GetOption(macroPrefix + "_GROUP");
if (groupName && *groupName)
{
component->Group = GetComponentGroup(projectName, groupName);
@@ -1561,7 +1565,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
}
const char* description
- = this->GetOption((macroPrefix + "_DESCRIPTION").c_str());
+ = this->GetOption(macroPrefix + "_DESCRIPTION");
if (description && *description)
{
component->Description = description;
@@ -1569,7 +1573,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
// Determine the installation types.
const char *installTypes
- = this->GetOption((macroPrefix + "_INSTALL_TYPES").c_str());
+ = this->GetOption(macroPrefix + "_INSTALL_TYPES");
if (installTypes && *installTypes)
{
std::vector<std::string> installTypesVector;
@@ -1580,12 +1584,12 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
++installTypesIt)
{
component->InstallationTypes.push_back(
- this->GetInstallationType(projectName, installTypesIt->c_str()));
+ this->GetInstallationType(projectName, *installTypesIt));
}
}
// Determine the component dependencies.
- const char *depends = this->GetOption((macroPrefix + "_DEPENDS").c_str());
+ const char *depends = this->GetOption(macroPrefix + "_DEPENDS");
if (depends && *depends)
{
std::vector<std::string> dependsVector;
@@ -1596,7 +1600,7 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
++dependIt)
{
cmCPackComponent *child = GetComponent(projectName,
- dependIt->c_str());
+ *dependIt);
component->Dependencies.push_back(child);
child->ReverseDependencies.push_back(component);
}
@@ -1607,7 +1611,8 @@ cmCPackGenerator::GetComponent(const char *projectName, const char *name)
//----------------------------------------------------------------------
cmCPackComponentGroup*
-cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
+cmCPackGenerator::GetComponentGroup(const std::string& projectName,
+ const std::string& name)
{
(void) projectName;
std::string macroPrefix = "CPACK_COMPONENT_GROUP_"
@@ -1619,7 +1624,7 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
// Define the group
group->Name = name;
const char* displayName
- = this->GetOption((macroPrefix + "_DISPLAY_NAME").c_str());
+ = this->GetOption(macroPrefix + "_DISPLAY_NAME");
if (displayName && *displayName)
{
group->DisplayName = displayName;
@@ -1630,17 +1635,17 @@ cmCPackGenerator::GetComponentGroup(const char *projectName, const char *name)
}
const char* description
- = this->GetOption((macroPrefix + "_DESCRIPTION").c_str());
+ = this->GetOption(macroPrefix + "_DESCRIPTION");
if (description && *description)
{
group->Description = description;
}
group->IsBold
- = this->IsOn((macroPrefix + "_BOLD_TITLE").c_str());
+ = this->IsOn(macroPrefix + "_BOLD_TITLE");
group->IsExpandedByDefault
- = this->IsOn((macroPrefix + "_EXPANDED").c_str());
+ = this->IsOn(macroPrefix + "_EXPANDED");
const char* parentGroupName
- = this->GetOption((macroPrefix + "_PARENT_GROUP").c_str());
+ = this->GetOption(macroPrefix + "_PARENT_GROUP");
if (parentGroupName && *parentGroupName)
{
group->ParentGroup = GetComponentGroup(projectName, parentGroupName);
diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h
index bb33aa0..e780f0e 100644
--- a/Source/CPack/cmCPackGenerator.h
+++ b/Source/CPack/cmCPackGenerator.h
@@ -22,9 +22,10 @@
// Forward declarations are insufficient since we use them in
// std::map data members below...
-#define cmCPackTypeMacro(class, superclass) \
- cmTypeMacro(class, superclass); \
- static cmCPackGenerator* CreateGenerator() { return new class; }
+#define cmCPackTypeMacro(klass, superclass) \
+ cmTypeMacro(klass, superclass); \
+ static cmCPackGenerator* CreateGenerator() { return new klass; } \
+ class cmCPackTypeMacro_UseTrailingSemicolon
#define cmCPackLogger(logType, msg) \
do { \
@@ -90,7 +91,7 @@ public:
/**
* Initialize generator
*/
- int Initialize(const char* name, cmMakefile* mf);
+ int Initialize(const std::string& name, cmMakefile* mf);
/**
* Construct generator
@@ -99,11 +100,12 @@ public:
virtual ~cmCPackGenerator();
//! Set and get the options
- void SetOption(const char* op, const char* value);
- void SetOptionIfNotSet(const char* op, const char* value);
- const char* GetOption(const char* op) const;
- bool IsSet(const char* name) const;
- bool IsOn(const char* name) const;
+ void SetOption(const std::string& op, const char* value);
+ void SetOptionIfNotSet(const std::string& op, const char* value);
+ const char* GetOption(const std::string& op) const;
+ std::vector<std::string> GetOptions() const;
+ bool IsSet(const std::string& name) const;
+ bool IsOn(const std::string& name) const;
//! Set the logger
void SetLogger(cmCPackLog* log) { this->Logger = log; }
@@ -189,13 +191,13 @@ protected:
//! Run install commands if specified
virtual int InstallProjectViaInstallCommands(
- bool setDestDir, const char* tempInstallDirectory);
+ bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstallScript(
- bool setDestDir, const char* tempInstallDirectory);
+ bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstalledDirectories(
- bool setDestDir, const char* tempInstallDirectory);
+ bool setDestDir, const std::string& tempInstallDirectory);
virtual int InstallProjectViaInstallCMakeProjects(
- bool setDestDir, const char* tempInstallDirectory);
+ bool setDestDir, const std::string& tempInstallDirectory);
/**
* The various level of support of
@@ -244,12 +246,14 @@ protected:
* @return true if component installation is supported and wanted.
*/
virtual bool WantsComponentInstallation() const;
- virtual cmCPackInstallationType* GetInstallationType(const char *projectName,
- const char* name);
- virtual cmCPackComponent* GetComponent(const char *projectName,
- const char* name);
- virtual cmCPackComponentGroup* GetComponentGroup(const char *projectName,
- const char* name);
+ virtual cmCPackInstallationType* GetInstallationType(
+ const std::string& projectName,
+ const std::string& name);
+ virtual cmCPackComponent* GetComponent(const std::string& projectName,
+ const std::string& name);
+ virtual cmCPackComponentGroup* GetComponentGroup(
+ const std::string& projectName,
+ const std::string& name);
cmSystemTools::OutputOption GeneratorVerbose;
std::string Name;
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index b36c2a2..9faf2b0 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -151,7 +151,8 @@ cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
}
//----------------------------------------------------------------------
-cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name)
+cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
+ const std::string& name)
{
cmCPackGenerator* gen = this->NewGeneratorInternal(name);
if ( !gen )
@@ -165,12 +166,8 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(const char* name)
//----------------------------------------------------------------------
cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
- const char* name)
+ const std::string& name)
{
- if ( !name )
- {
- return 0;
- }
cmCPackGeneratorFactory::t_GeneratorCreatorsMap::iterator it
= this->GeneratorCreators.find(name);
if ( it == this->GeneratorCreators.end() )
@@ -181,11 +178,11 @@ cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
}
//----------------------------------------------------------------------
-void cmCPackGeneratorFactory::RegisterGenerator(const char* name,
+void cmCPackGeneratorFactory::RegisterGenerator(const std::string& name,
const char* generatorDescription,
CreateGeneratorCall* createGenerator)
{
- if ( !name || !createGenerator )
+ if ( !createGenerator )
{
cmCPack_Log(this->Logger, cmCPackLog::LOG_ERROR,
"Cannot register generator" << std::endl);
diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h
index dff2e49..010777f 100644
--- a/Source/CPack/cmCPackGeneratorFactory.h
+++ b/Source/CPack/cmCPackGeneratorFactory.h
@@ -31,26 +31,26 @@ public:
~cmCPackGeneratorFactory();
//! Get the generator
- cmCPackGenerator* NewGenerator(const char* name);
+ cmCPackGenerator* NewGenerator(const std::string& name);
void DeleteGenerator(cmCPackGenerator* gen);
typedef cmCPackGenerator* CreateGeneratorCall();
- void RegisterGenerator(const char* name,
+ void RegisterGenerator(const std::string& name,
const char* generatorDescription,
CreateGeneratorCall* createGenerator);
void SetLogger(cmCPackLog* logger) { this->Logger = logger; }
- typedef std::map<cmStdString, cmStdString> DescriptionsMap;
+ typedef std::map<std::string, std::string> DescriptionsMap;
const DescriptionsMap& GetGeneratorsList() const
{ return this->GeneratorDescriptions; }
private:
- cmCPackGenerator* NewGeneratorInternal(const char* name);
+ cmCPackGenerator* NewGeneratorInternal(const std::string& name);
std::vector<cmCPackGenerator*> Generators;
- typedef std::map<cmStdString, CreateGeneratorCall*> t_GeneratorCreatorsMap;
+ typedef std::map<std::string, CreateGeneratorCall*> t_GeneratorCreatorsMap;
t_GeneratorCreatorsMap GeneratorCreators;
DescriptionsMap GeneratorDescriptions;
cmCPackLog* Logger;
diff --git a/Source/CPack/cmCPackLog.cxx b/Source/CPack/cmCPackLog.cxx
index 4e8bf0f..7befca0 100644
--- a/Source/CPack/cmCPackLog.cxx
+++ b/Source/CPack/cmCPackLog.cxx
@@ -169,27 +169,27 @@ void cmCPackLog::Log(int tag, const char* file, int line,
{
if ( error && !this->ErrorPrefix.empty() )
{
- *this->DefaultError << this->ErrorPrefix.c_str();
+ *this->DefaultError << this->ErrorPrefix;
}
else if ( warning && !this->WarningPrefix.empty() )
{
- *this->DefaultError << this->WarningPrefix.c_str();
+ *this->DefaultError << this->WarningPrefix;
}
else if ( output && !this->OutputPrefix.empty() )
{
- *this->DefaultOutput << this->OutputPrefix.c_str();
+ *this->DefaultOutput << this->OutputPrefix;
}
else if ( verbose && !this->VerbosePrefix.empty() )
{
- *this->DefaultOutput << this->VerbosePrefix.c_str();
+ *this->DefaultOutput << this->VerbosePrefix;
}
else if ( debug && !this->DebugPrefix.empty() )
{
- *this->DefaultOutput << this->DebugPrefix.c_str();
+ *this->DefaultOutput << this->DebugPrefix;
}
else if ( !this->Prefix.empty() )
{
- *this->DefaultOutput << this->Prefix.c_str();
+ *this->DefaultOutput << this->Prefix;
}
if ( useFileAndLine )
{
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 62bfa91..0113698 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -83,10 +83,10 @@ int cmCPackNSISGenerator::PackageFiles()
fileN = fileN.substr(fileN.find('/')+1, std::string::npos);
}
cmSystemTools::ReplaceString(fileN, "/", "\\");
- str << " Delete \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
+ str << " Delete \"$INSTDIR\\" << fileN << "\"" << std::endl;
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Files: "
- << str.str().c_str() << std::endl);
+ << str.str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_FILES", str.str().c_str());
std::vector<std::string> dirs;
this->GetListOfSubdirectories(toplevel.c_str(), dirs);
@@ -117,14 +117,14 @@ int cmCPackNSISGenerator::PackageFiles()
}
}
cmSystemTools::ReplaceString(fileN, "/", "\\");
- dstr << " RMDir \"$INSTDIR\\" << fileN.c_str() << "\"" << std::endl;
+ dstr << " RMDir \"$INSTDIR\\" << fileN << "\"" << std::endl;
if (!componentName.empty())
{
this->Components[componentName].Directories.push_back(fileN);
}
}
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Uninstall Dirs: "
- << dstr.str().c_str() << std::endl);
+ << dstr.str() << std::endl);
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_DIRECTORIES",
dstr.str().c_str());
@@ -320,7 +320,7 @@ int cmCPackNSISGenerator::PackageFiles()
std::string nsisCmd = "\"";
nsisCmd += this->GetOption("CPACK_INSTALLER_PROGRAM");
nsisCmd += "\" \"" + nsisFileName + "\"";
- cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd.c_str()
+ cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << nsisCmd
<< std::endl);
std::string output;
int retVal = 1;
@@ -329,12 +329,12 @@ int cmCPackNSISGenerator::PackageFiles()
if ( !res || retVal )
{
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << nsisCmd.c_str() << std::endl
+ ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running NSIS command: "
- << nsisCmd.c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << nsisCmd << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
return 1;
@@ -427,7 +427,7 @@ int cmCPackNSISGenerator::InitializeInternal()
std::string nsisCmd = "\"" + nsisPath + "\" " NSIS_OPT "VERSION";
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: "
- << nsisCmd.c_str() << std::endl);
+ << nsisCmd << std::endl);
std::string output;
int retVal = 1;
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(),
@@ -442,13 +442,13 @@ int cmCPackNSISGenerator::InitializeInternal()
std::string tmpFile = topDir ? topDir : ".";
tmpFile += "/NSISOutput.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << nsisCmd.c_str() << std::endl
+ ofs << "# Run command: " << nsisCmd << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR,
"Problem checking NSIS version with command: "
- << nsisCmd.c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << nsisCmd << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return 0;
}
if ( versionRex.find(output))
@@ -470,7 +470,7 @@ int cmCPackNSISGenerator::InitializeInternal()
{
// No version check for NSIS cvs build
cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: CVS "
- << versionRexCVS.match(1).c_str() << std::endl);
+ << versionRexCVS.match(1) << std::endl);
}
this->SetOptionIfNotSet("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin");
@@ -629,7 +629,7 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str,
// if so add a desktop link
std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
desktop += linkName;
- if(this->IsSet(desktop.c_str()))
+ if(this->IsSet(desktop))
{
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
str << " CreateShortCut \"$DESKTOP\\"
@@ -844,12 +844,12 @@ CreateComponentDescription(cmCPackComponent *component,
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
tmpFile += "/CompressZip.log";
cmGeneratedFileStream ofs(tmpFile.c_str());
- ofs << "# Run command: " << cmd.c_str() << std::endl
+ ofs << "# Run command: " << cmd << std::endl
<< "# Output:" << std::endl
- << output.c_str() << std::endl;
+ << output << std::endl;
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running zip command: "
- << cmd.c_str() << std::endl
- << "Please check " << tmpFile.c_str() << " for errors" << std::endl);
+ << cmd << std::endl
+ << "Please check " << tmpFile << " for errors" << std::endl);
return "";
}
@@ -891,7 +891,7 @@ CreateComponentDescription(cmCPackComponent *component,
path = *pathIt;
cmSystemTools::ReplaceString(path, "/", "\\");
macrosOut << " Delete \"$INSTDIR\\"
- << path.c_str()
+ << path
<< "\"\n";
}
for (pathIt = component->Directories.begin();
@@ -901,7 +901,7 @@ CreateComponentDescription(cmCPackComponent *component,
path = *pathIt;
cmSystemTools::ReplaceString(path, "/", "\\");
macrosOut << " RMDir \"$INSTDIR\\"
- << path.c_str()
+ << path
<< "\"\n";
}
macrosOut << " noremove_" << component->Name << ":\n";
diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx
index 76e15fb..28c7f1d 100644
--- a/Source/CPack/cmCPackOSXX11Generator.cxx
+++ b/Source/CPack/cmCPackOSXX11Generator.cxx
@@ -227,7 +227,7 @@ int cmCPackOSXX11Generator::InitializeInternal()
//----------------------------------------------------------------------
/*
-bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name)
+bool cmCPackOSXX11Generator::CopyCreateResourceFile(const std::string& name)
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@@ -271,8 +271,8 @@ bool cmCPackOSXX11Generator::CopyCreateResourceFile(const char* name)
*/
//----------------------------------------------------------------------
-bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name,
- const char* dir, const char* outputFileName /* = 0 */,
+bool cmCPackOSXX11Generator::CopyResourcePlistFile(const std::string& name,
+ const std::string& dir, const char* outputFileName /* = 0 */,
bool copyOnly /* = false */)
{
std::string inFName = "CPack.";
@@ -288,7 +288,7 @@ bool cmCPackOSXX11Generator::CopyResourcePlistFile(const char* name,
if ( !outputFileName )
{
- outputFileName = name;
+ outputFileName = name.c_str();
}
std::string destFileName = dir;
diff --git a/Source/CPack/cmCPackOSXX11Generator.h b/Source/CPack/cmCPackOSXX11Generator.h
index b7bd243..9d0a6d1 100644
--- a/Source/CPack/cmCPackOSXX11Generator.h
+++ b/Source/CPack/cmCPackOSXX11Generator.h
@@ -37,8 +37,9 @@ protected:
virtual const char* GetPackagingInstallPrefix();
virtual const char* GetOutputExtension() { return ".dmg"; }
- //bool CopyCreateResourceFile(const char* name, const char* dir);
- bool CopyResourcePlistFile(const char* name, const char* dir,
+ //bool CopyCreateResourceFile(const std::string& name,
+ // const std::string& dir);
+ bool CopyResourcePlistFile(const std::string& name, const std::string& dir,
const char* outputFileName = 0, bool copyOnly = false);
std::string InstallPrefix;
};
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index c5b9c6f..d736948 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -43,14 +43,14 @@ bool cmCPackPackageMakerGenerator::SupportsComponentInstallation() const
}
//----------------------------------------------------------------------
-int cmCPackPackageMakerGenerator::CopyInstallScript(const char* resdir,
- const char* script,
- const char* name)
+int cmCPackPackageMakerGenerator::CopyInstallScript(const std::string& resdir,
+ const std::string& script,
+ const std::string& name)
{
std::string dst = resdir;
dst += "/";
dst += name;
- cmSystemTools::CopyFileAlways(script, dst.c_str());
+ cmSystemTools::CopyFileAlways(script.c_str(), dst.c_str());
cmSystemTools::SetPermissions(dst.c_str(),0777);
cmCPackLogger(cmCPackLog::LOG_VERBOSE,
"copy script : " << script << "\ninto " << dst.c_str() <<
@@ -553,8 +553,9 @@ int cmCPackPackageMakerGenerator::InitializeInternal()
}
//----------------------------------------------------------------------
-bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
- const char* dirName)
+bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(
+ const std::string& name,
+ const std::string& dirName)
{
std::string uname = cmSystemTools::UpperCase(name);
std::string cpackVar = "CPACK_RESOURCE_FILE_" + uname;
@@ -563,7 +564,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack option: " << cpackVar.c_str()
<< " not specified. It should point to "
- << (name ? name : "(NULL)")
+ << (!name.empty() ? name : "<empty>")
<< ".rtf, " << name
<< ".html, or " << name << ".txt file" << std::endl);
return false;
@@ -571,7 +572,7 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
if ( !cmSystemTools::FileExists(inFileName) )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find "
- << (name ? name : "(NULL)")
+ << (!name.empty() ? name : "<empty>")
<< " resource file: " << inFileName << std::endl);
return false;
}
@@ -600,12 +601,13 @@ bool cmCPackPackageMakerGenerator::CopyCreateResourceFile(const char* name,
return true;
}
-bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(const char* name,
- const char* outName)
+bool cmCPackPackageMakerGenerator::CopyResourcePlistFile(
+ const std::string& name,
+ const char* outName)
{
if (!outName)
{
- outName = name;
+ outName = name.c_str();
}
std::string inFName = "CPack.";
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.h b/Source/CPack/cmCPackPackageMakerGenerator.h
index ba3d968..e350a60 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.h
+++ b/Source/CPack/cmCPackPackageMakerGenerator.h
@@ -38,9 +38,9 @@ public:
virtual bool SupportsComponentInstallation() const;
protected:
- int CopyInstallScript(const char* resdir,
- const char* script,
- const char* name);
+ int CopyInstallScript(const std::string& resdir,
+ const std::string& script,
+ const std::string& name);
virtual int InitializeInternal();
int PackageFiles();
virtual const char* GetOutputExtension() { return ".dmg"; }
@@ -51,8 +51,9 @@ protected:
// CPACK_RESOURCE_FILE_${NAME} (where ${NAME} is the uppercased
// version of name) specifies the input file to use for this file,
// which will be configured via ConfigureFile.
- bool CopyCreateResourceFile(const char* name, const char *dirName);
- bool CopyResourcePlistFile(const char* name, const char* outName = 0);
+ bool CopyCreateResourceFile(const std::string& name,
+ const std::string& dirName);
+ bool CopyResourcePlistFile(const std::string& name, const char* outName = 0);
// Run PackageMaker with the given command line, which will (if
// successful) produce the given package file. Returns true if
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index 66a4194..c6171dc 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -272,9 +272,9 @@ std::string cmCPackRPMGenerator::GetComponentInstallDirNameSuffix(
// the current COMPONENT belongs to.
std::string groupVar = "CPACK_COMPONENT_" +
cmSystemTools::UpperCase(componentName) + "_GROUP";
- if (NULL != GetOption(groupVar.c_str()))
+ if (NULL != GetOption(groupVar))
{
- return std::string(GetOption(groupVar.c_str()));
+ return std::string(GetOption(groupVar));
}
else
{
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 8342fee..6c1d201 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -43,7 +43,7 @@ int cmCPackSTGZGenerator::InitializeInternal()
if ( inFile.empty() )
{
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find template file: "
- << inFile.c_str() << std::endl);
+ << inFile << std::endl);
return 0;
}
this->SetOptionIfNotSet("CPACK_STGZ_HEADER_FILE", inFile.c_str());
@@ -134,6 +134,6 @@ int cmCPackSTGZGenerator::GenerateHeader(std::ostream* os)
cmSystemTools::ReplaceString(res, headerLengthTag, buffer);
// Write in file
- *os << res.c_str();
+ *os << res;
return this->Superclass::GenerateHeader(os);
}
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index a19b778..9eabdca 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -68,7 +68,7 @@ int cpackUnknownArgument(const char*, void*)
//----------------------------------------------------------------------------
struct cpackDefinitions
{
- typedef std::map<cmStdString, cmStdString> MapType;
+ typedef std::map<std::string, std::string> MapType;
MapType Map;
cmCPackLog *Log;
};
@@ -91,7 +91,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue,
value = value.c_str() + pos + 1;
def->Map[key] = value;
cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: "
- << key.c_str() << " to \"" << value.c_str() << "\"" << std::endl);
+ << key << " to \"" << value << "\"" << std::endl);
return 1;
}
@@ -195,7 +195,7 @@ int main (int argc, char const* const* argv)
}
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
- "Read CPack config file: " << cpackConfigFile.c_str() << std::endl);
+ "Read CPack config file: " << cpackConfigFile << std::endl);
cmake cminst;
cminst.RemoveUnscriptableCommands();
@@ -262,21 +262,21 @@ int main (int argc, char const* const* argv)
cpackConfigFile =
cmSystemTools::CollapseFullPath(cpackConfigFile.c_str());
cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
- "Read CPack configuration file: " << cpackConfigFile.c_str()
+ "Read CPack configuration file: " << cpackConfigFile
<< std::endl);
if ( !globalMF->ReadListFile(0, cpackConfigFile.c_str()) )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
"Problem reading CPack config file: \""
- << cpackConfigFile.c_str() << "\"" << std::endl);
+ << cpackConfigFile << "\"" << std::endl);
return 1;
}
}
else if ( cpackConfigFileSpecified )
{
cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
- "Cannot find CPack config file: \"" << cpackConfigFile.c_str()
- << "\"" << std::endl);
+ "Cannot find CPack config file: \"" <<
+ cpackConfigFile << "\"" << std::endl);
return 1;
}
@@ -326,7 +326,7 @@ int main (int argc, char const* const* argv)
cdit != definitions.Map.end();
++cdit )
{
- globalMF->AddDefinition(cdit->first.c_str(), cdit->second.c_str());
+ globalMF->AddDefinition(cdit->first, cdit->second.c_str());
}
const char* cpackModulesPath =
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 381c70c..3014a93 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -225,35 +225,35 @@ private:
return true;
}
- virtual void StartElement(const char* name, const char**)
+ virtual void StartElement(const std::string& name, const char**)
{
this->CData.clear();
- if(strcmp(name, "log") == 0)
+ if(name == "log")
{
this->Rev = Revision();
this->Changes.clear();
}
// affected-files can contain blocks of
// modified, unknown, renamed, kind-changed, removed, conflicts, added
- else if(strcmp(name, "modified") == 0
- || strcmp(name, "renamed") == 0
- || strcmp(name, "kind-changed") == 0)
+ else if(name == "modified"
+ || name == "renamed"
+ || name == "kind-changed")
{
this->CurChange = Change();
this->CurChange.Action = 'M';
}
- else if(strcmp(name, "added") == 0)
+ else if(name == "added")
{
this->CurChange = Change();
this->CurChange = 'A';
}
- else if(strcmp(name, "removed") == 0)
+ else if(name == "removed")
{
this->CurChange = Change();
this->CurChange = 'D';
}
- else if(strcmp(name, "unknown") == 0
- || strcmp(name, "conflicts") == 0)
+ else if(name == "unknown"
+ || name == "conflicts")
{
// Should not happen here
this->CurChange = Change();
@@ -265,27 +265,27 @@ private:
this->CData.insert(this->CData.end(), data, data+length);
}
- virtual void EndElement(const char* name)
+ virtual void EndElement(const std::string& name)
{
- if(strcmp(name, "log") == 0)
+ if(name == "log")
{
this->BZR->DoRevision(this->Rev, this->Changes);
}
- else if((strcmp(name, "file") == 0 || strcmp(name, "directory") == 0)
- && !this->CData.empty())
+ else if(!this->CData.empty() &&
+ (name == "file" || name == "directory"))
{
this->CurChange.Path.assign(&this->CData[0], this->CData.size());
cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
this->Changes.push_back(this->CurChange);
}
- else if(strcmp(name, "symlink") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "symlink")
{
// symlinks have an arobase at the end in the log
this->CurChange.Path.assign(&this->CData[0], this->CData.size()-1);
cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path);
this->Changes.push_back(this->CurChange);
}
- else if(strcmp(name, "committer") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "committer")
{
this->Rev.Author.assign(&this->CData[0], this->CData.size());
if(this->EmailRegex.find(this->Rev.Author))
@@ -294,15 +294,15 @@ private:
this->Rev.EMail = this->EmailRegex.match(2);
}
}
- else if(strcmp(name, "timestamp") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "timestamp")
{
this->Rev.Date.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "message") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "message")
{
this->Rev.Log.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "revno") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "revno")
{
this->Rev.Rev.assign(&this->CData[0], this->CData.size());
}
@@ -409,7 +409,7 @@ bool cmCTestBZR::UpdateImpl()
{
opts = this->CTest->GetCTestConfiguration("BZRUpdateOptions");
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// TODO: if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -418,7 +418,7 @@ bool cmCTestBZR::UpdateImpl()
bzr_update.push_back(this->CommandLineTool.c_str());
bzr_update.push_back("pull");
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
bzr_update.push_back(ai->c_str());
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index 0fac136..4a3eec5 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -241,11 +241,11 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
{
// Make the generator available for the Build call below.
cm.SetGlobalGenerator(cm.CreateGlobalGenerator(
- this->BuildGenerator.c_str()));
+ this->BuildGenerator));
cm.SetGeneratorToolset(this->BuildGeneratorToolset);
// Load the cache to make CMAKE_MAKE_PROGRAM available.
- cm.GetCacheManager()->LoadCache(this->BinaryDir.c_str());
+ cm.GetCacheManager()->LoadCache(this->BinaryDir);
}
else
{
@@ -295,9 +295,9 @@ int cmCTestBuildAndTestHandler::RunCMakeAndTest(std::string* outstring)
config = "Debug";
}
int retVal = cm.GetGlobalGenerator()->Build(
- this->SourceDir.c_str(), this->BinaryDir.c_str(),
- this->BuildProject.c_str(), tarIt->c_str(),
- &output, this->BuildMakeProgram.c_str(),
+ this->SourceDir, this->BinaryDir,
+ this->BuildProject, *tarIt,
+ &output, this->BuildMakeProgram,
config,
!this->BuildNoClean,
false, remainingTime);
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h
index ca50c64..d1e9a4d 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.h
+++ b/Source/CTest/cmCTestBuildAndTestHandler.h
@@ -54,7 +54,7 @@ protected:
std::string &cmakeOutString,
std::string &cwd, cmake *cm);
- cmStdString Output;
+ std::string Output;
std::string BuildGenerator;
std::string BuildGeneratorToolset;
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index 12ff718..f81083a 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -101,8 +101,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
}
if ( this->GlobalGenerator )
{
- if ( strcmp(this->GlobalGenerator->GetName(),
- cmakeGeneratorName) != 0 )
+ if ( this->GlobalGenerator->GetName() != cmakeGeneratorName )
{
delete this->GlobalGenerator;
this->GlobalGenerator = 0;
@@ -130,11 +129,12 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
std::string dir = this->CTest->GetCTestConfiguration("BuildDirectory");
std::string buildCommand
= this->GlobalGenerator->
- GenerateCMakeBuildCommand(cmakeBuildTarget, cmakeBuildConfiguration,
- cmakeBuildAdditionalFlags, true);
+ GenerateCMakeBuildCommand(cmakeBuildTarget ? cmakeBuildTarget : "",
+ cmakeBuildConfiguration,
+ cmakeBuildAdditionalFlags ? cmakeBuildAdditionalFlags : "", true);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"SetMakeCommand:"
- << buildCommand.c_str() << "\n");
+ << buildCommand << "\n");
this->CTest->SetCTestConfiguration("MakeCommand", buildCommand.c_str());
}
else
@@ -151,7 +151,7 @@ cmCTestGenericHandler* cmCTestBuildCommand::InitializeHandler()
"\n"
"Alternatively, set CTEST_BUILD_COMMAND to build the project "
"with a custom command line.";
- this->SetError(ostr.str().c_str());
+ this->SetError(ostr.str());
return 0;
}
}
diff --git a/Source/CTest/cmCTestBuildCommand.h b/Source/CTest/cmCTestBuildCommand.h
index 08887fe..2632ebc 100644
--- a/Source/CTest/cmCTestBuildCommand.h
+++ b/Source/CTest/cmCTestBuildCommand.h
@@ -43,7 +43,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_build";}
+ virtual std::string GetName() const { return "ctest_build";}
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index c5deb96..7922c9a 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -380,7 +380,7 @@ int cmCTestBuildHandler::ProcessHandler()
// Create lists of regular expression strings for errors, error exceptions,
// warnings and warning exceptions.
- std::vector<cmStdString>::size_type cc;
+ std::vector<std::string>::size_type cc;
for ( cc = 0; cmCTestErrorMatches[cc]; cc ++ )
{
this->CustomErrorMatches.push_back(cmCTestErrorMatches[cc]);
@@ -400,7 +400,7 @@ int cmCTestBuildHandler::ProcessHandler()
}
// Pre-compile regular expressions objects for all regular expressions
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
#define cmCTestBuildHandlerPopulateRegexVector(strings, regexes) \
regexes.clear(); \
@@ -409,7 +409,7 @@ int cmCTestBuildHandler::ProcessHandler()
for ( it = strings.begin(); it != strings.end(); ++it ) \
{ \
cmCTestLog(this->CTest, DEBUG, "Add " #strings ": " \
- << it->c_str() << std::endl); \
+ << *it << std::endl); \
regexes.push_back(it->c_str()); \
}
cmCTestBuildHandlerPopulateRegexVector(
@@ -602,7 +602,7 @@ void cmCTestBuildHandler::GenerateXMLLaunched(std::ostream& os)
// Sort XML fragments in chronological order.
cmFileTimeComparison ftc;
FragmentCompare fragmentCompare(&ftc);
- typedef std::set<cmStdString, FragmentCompare> Fragments;
+ typedef std::set<std::string, FragmentCompare> Fragments;
Fragments fragments(fragmentCompare);
// Identify fragments on disk.
@@ -889,7 +889,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
int* retVal, const char* dir, int timeout, std::ostream& ofs)
{
// First generate the command and arguments
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+ std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if(args.size() < 1)
{
@@ -897,7 +897,7 @@ int cmCTestBuildHandler::RunMakeCommand(const char* command,
}
std::vector<const char*> argv;
- for(std::vector<cmStdString>::const_iterator a = args.begin();
+ for(std::vector<std::string>::const_iterator a = args.begin();
a != args.end(); ++a)
{
argv.push_back(a->c_str());
@@ -1133,7 +1133,7 @@ void cmCTestBuildHandler::ProcessBuffer(const char* data, int length,
errorwarning.PostContext = "";
// Copy pre-context to report
- std::deque<cmStdString>::iterator pcit;
+ std::deque<std::string>::iterator pcit;
for ( pcit = this->PreContext.begin();
pcit != this->PreContext.end();
++pcit )
diff --git a/Source/CTest/cmCTestBuildHandler.h b/Source/CTest/cmCTestBuildHandler.h
index ff7cfd6..09346f9 100644
--- a/Source/CTest/cmCTestBuildHandler.h
+++ b/Source/CTest/cmCTestBuildHandler.h
@@ -97,10 +97,10 @@ private:
double StartBuildTime;
double EndBuildTime;
- std::vector<cmStdString> CustomErrorMatches;
- std::vector<cmStdString> CustomErrorExceptions;
- std::vector<cmStdString> CustomWarningMatches;
- std::vector<cmStdString> CustomWarningExceptions;
+ std::vector<std::string> CustomErrorMatches;
+ std::vector<std::string> CustomErrorExceptions;
+ std::vector<std::string> CustomWarningMatches;
+ std::vector<std::string> CustomWarningExceptions;
std::vector<std::string> ReallyCustomWarningMatches;
std::vector<std::string> ReallyCustomWarningExceptions;
std::vector<cmCTestCompileErrorWarningRex> ErrorWarningFileLineRegex;
@@ -121,8 +121,8 @@ private:
size_t BuildOutputLogSize;
std::vector<char> CurrentProcessingLine;
- cmStdString SimplifySourceDir;
- cmStdString SimplifyBuildDir;
+ std::string SimplifySourceDir;
+ std::string SimplifyBuildDir;
size_t OutputLineCounter;
typedef std::vector<cmCTestBuildErrorWarning> t_ErrorsAndWarningsVector;
t_ErrorsAndWarningsVector ErrorsAndWarnings;
@@ -130,7 +130,7 @@ private:
size_t PostContextCount;
size_t MaxPreContext;
size_t MaxPostContext;
- std::deque<cmStdString> PreContext;
+ std::deque<std::string> PreContext;
int TotalErrors;
int TotalWarnings;
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 17dbb55..ab363d0 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -99,7 +99,7 @@ bool cmCTestCVS::UpdateImpl()
opts = "-dP";
}
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// Specify the start time for nightly testing.
if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -112,7 +112,7 @@ bool cmCTestCVS::UpdateImpl()
cvs_update.push_back(this->CommandLineTool.c_str());
cvs_update.push_back("-z3");
cvs_update.push_back("update");
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
cvs_update.push_back(ai->c_str());
@@ -308,7 +308,7 @@ bool cmCTestCVS::WriteXMLUpdates(std::ostream& xml)
" Gathering version information (one . per updated file):\n"
" " << std::flush);
- for(std::map<cmStdString, Directory>::const_iterator
+ for(std::map<std::string, Directory>::const_iterator
di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
{
this->WriteXMLDirectory(xml, di->first, di->second);
diff --git a/Source/CTest/cmCTestCVS.h b/Source/CTest/cmCTestCVS.h
index b7fe567..64e1747 100644
--- a/Source/CTest/cmCTestCVS.h
+++ b/Source/CTest/cmCTestCVS.h
@@ -32,8 +32,8 @@ private:
virtual bool WriteXMLUpdates(std::ostream& xml);
// Update status for files in each directory.
- class Directory: public std::map<cmStdString, PathStatus> {};
- std::map<cmStdString, Directory> Dirs;
+ class Directory: public std::map<std::string, PathStatus> {};
+ std::map<std::string, Directory> Dirs;
std::string ComputeBranchFlag(std::string const& dir);
void LoadRevisions(std::string const& file, const char* branchFlag,
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index 5eed409..1aa8768 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -69,7 +69,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler()
cmOStringStream e;
e << "CMakeLists.txt file does not exist ["
<< cmakelists_file << "]";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return 0;
}
diff --git a/Source/CTest/cmCTestConfigureCommand.h b/Source/CTest/cmCTestConfigureCommand.h
index b592c5a..7941d4e 100644
--- a/Source/CTest/cmCTestConfigureCommand.h
+++ b/Source/CTest/cmCTestConfigureCommand.h
@@ -38,7 +38,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_configure";}
+ virtual std::string GetName() const { return "ctest_configure";}
cmTypeMacro(cmCTestConfigureCommand, cmCTestHandlerCommand);
diff --git a/Source/CTest/cmCTestConfigureHandler.cxx b/Source/CTest/cmCTestConfigureHandler.cxx
index 7c41298..a6e39a4 100644
--- a/Source/CTest/cmCTestConfigureHandler.cxx
+++ b/Source/CTest/cmCTestConfigureHandler.cxx
@@ -76,7 +76,7 @@ int cmCTestConfigureHandler::ProcessHandler()
cmGeneratedFileStream ofs;
this->StartLogFile("Configure", ofs);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Configure with command: "
- << cCommand.c_str() << std::endl);
+ << cCommand << std::endl);
res = this->CTest->RunMakeCommand(cCommand.c_str(), &output,
&retVal, buildDirectory.c_str(),
0, ofs);
@@ -99,7 +99,7 @@ int cmCTestConfigureHandler::ProcessHandler()
{
os << retVal;
}
- os << "<ConfigureCommand>" << cCommand.c_str() << "</ConfigureCommand>"
+ os << "<ConfigureCommand>" << cCommand << "</ConfigureCommand>"
<< std::endl;
cmCTestLog(this->CTest, DEBUG, "End" << std::endl);
os << "<Log>" << cmXMLSafe(output) << "</Log>" << std::endl;
diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx
index 72ff720..41f016b 100644
--- a/Source/CTest/cmCTestCoverageCommand.cxx
+++ b/Source/CTest/cmCTestCoverageCommand.cxx
@@ -25,7 +25,8 @@ cmCTestGenericHandler* cmCTestCoverageCommand::InitializeHandler()
{
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"CoverageCommand", "CTEST_COVERAGE_COMMAND");
-
+ this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
+ "CoverageExtraFlags", "CTEST_COVERAGE_EXTRA_FLAGS");
cmCTestCoverageHandler* handler = static_cast<cmCTestCoverageHandler*>(
this->CTest->GetInitializedHandler("coverage"));
if ( !handler )
diff --git a/Source/CTest/cmCTestCoverageCommand.h b/Source/CTest/cmCTestCoverageCommand.h
index 11bb411..5762e07 100644
--- a/Source/CTest/cmCTestCoverageCommand.h
+++ b/Source/CTest/cmCTestCoverageCommand.h
@@ -39,7 +39,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_coverage";}
+ virtual std::string GetName() const { return "ctest_coverage";}
cmTypeMacro(cmCTestCoverageCommand, cmCTestHandlerCommand);
@@ -56,7 +56,7 @@ protected:
};
bool LabelsMentioned;
- std::set<cmStdString> Labels;
+ std::set<std::string> Labels;
};
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index 3c65c55..cb6e56e 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -157,7 +157,7 @@ void cmCTestCoverageHandler::CleanCoverageLogFiles(std::ostream& log)
logGlob += this->CTest->GetCurrentTag();
logGlob += "/CoverageLog*";
cmsys::Glob gl;
- gl.FindFiles(logGlob.c_str());
+ gl.FindFiles(logGlob);
std::vector<std::string> const& files = gl.GetFiles();
for(std::vector<std::string>::const_iterator fi = files.begin();
fi != files.end(); ++fi)
@@ -241,7 +241,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
bool buildSubDir = cmSystemTools::IsSubDirectory(fFile.c_str(),
fBinDir.c_str());
// Always check parent directory of the file.
- std::string fileDir = cmSystemTools::GetFilenamePath(fFile.c_str());
+ std::string fileDir = cmSystemTools::GetFilenamePath(fFile);
std::string checkDir;
// We also need to check the binary/source directory pair.
@@ -269,7 +269,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
fFile.c_str(), checkDir.c_str());
if ( ndc.size() )
{
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str()
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
<< " so skip coverage of " << file << std::endl);
return false;
}
@@ -296,7 +296,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
checkDir = fSrcDir;
}
fFile = checkDir + "/" + relPath;
- fFile = cmSystemTools::GetFilenamePath(fFile.c_str());
+ fFile = cmSystemTools::GetFilenamePath(fFile);
if ( fileDir == fFile )
{
@@ -308,7 +308,7 @@ bool cmCTestCoverageHandler::ShouldIDoCoverage(const char* file,
fFile.c_str(), checkDir.c_str());
if ( ndc.size() )
{
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc.c_str()
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found: " << ndc
<< " so skip coverage of: " << file << std::endl);
return false;
}
@@ -363,7 +363,7 @@ int cmCTestCoverageHandler::ProcessHandler()
// setup the regex exclude stuff
this->CustomCoverageExcludeRegex.clear();
- std::vector<cmStdString>::iterator rexIt;
+ std::vector<std::string>::iterator rexIt;
for ( rexIt = this->CustomCoverageExclude.begin();
rexIt != this->CustomCoverageExclude.end();
++ rexIt )
@@ -383,6 +383,12 @@ int cmCTestCoverageHandler::ProcessHandler()
{
return error;
}
+ file_count += this->HandleLCovCoverage(&cont);
+ error = cont.Error;
+ if ( file_count < 0 )
+ {
+ return error;
+ }
file_count += this->HandleTracePyCoverage(&cont);
error = cont.Error;
if ( file_count < 0 )
@@ -477,7 +483,7 @@ int cmCTestCoverageHandler::ProcessHandler()
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
".NoDartCoverage found, so skip coverage check for: "
- << fullFileName.c_str()
+ << fullFileName
<< std::endl);
continue;
}
@@ -488,7 +494,7 @@ int cmCTestCoverageHandler::ProcessHandler()
if ( !cmSystemTools::FileExists(fullFileName.c_str()) )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot find file: "
- << fullFileName.c_str() << std::endl);
+ << fullFileName << std::endl);
continue;
}
@@ -503,7 +509,7 @@ int cmCTestCoverageHandler::ProcessHandler()
}
const std::string fileName
- = cmSystemTools::GetFilenameName(fullFileName.c_str());
+ = cmSystemTools::GetFilenameName(fullFileName);
std::string shortFileName =
this->CTest->GetShortPathToFile(fullFileName.c_str());
const cmCTestCoverageHandlerContainer::SingleFileCoverageVector& fcov
@@ -516,7 +522,7 @@ int cmCTestCoverageHandler::ProcessHandler()
if ( !ifs)
{
cmOStringStream ostr;
- ostr << "Cannot open source file: " << fullFileName.c_str();
+ ostr << "Cannot open source file: " << fullFileName;
errorsWhileAccumulating.push_back(ostr.str());
error ++;
continue;
@@ -535,7 +541,7 @@ int cmCTestCoverageHandler::ProcessHandler()
cc != fcov.size() -1 )
{
cmOStringStream ostr;
- ostr << "Problem reading source file: " << fullFileName.c_str()
+ ostr << "Problem reading source file: " << fullFileName
<< " line:" << cc << " out total: " << fcov.size()-1;
errorsWhileAccumulating.push_back(ostr.str());
error ++;
@@ -605,7 +611,7 @@ int cmCTestCoverageHandler::ProcessHandler()
if (!ifs)
{
cmOStringStream ostr;
- ostr << "Cannot open source file: " << fullPath.c_str();
+ ostr << "Cannot open source file: " << fullPath;
errorsWhileAccumulating.push_back(ostr.str());
error ++;
continue;
@@ -613,7 +619,7 @@ int cmCTestCoverageHandler::ProcessHandler()
int untested = 0;
std::string line;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Actually performing coverage for: " << i->c_str() << std::endl);
+ "Actually performing coverage for: " << *i << std::endl);
while (cmSystemTools::GetLineFromStream(ifs, line))
{
covLogFile << "\t\t<Line Number=\"" << untested << "\" Count=\"0\">"
@@ -647,7 +653,7 @@ int cmCTestCoverageHandler::ProcessHandler()
++ erIt )
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
- " " << erIt->c_str() << std::endl);
+ " " << *erIt << std::endl);
}
}
@@ -713,19 +719,19 @@ void cmCTestCoverageHandler::PopulateCustomVectors(cmMakefile *mf)
this->CustomCoverageExclude);
this->CTest->PopulateCustomVector(mf, "CTEST_EXTRA_COVERAGE_GLOB",
this->ExtraCoverageGlobs);
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for ( it = this->CustomCoverageExclude.begin();
it != this->CustomCoverageExclude.end();
++ it )
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage exclude: "
- << it->c_str() << std::endl);
+ << *it << std::endl);
}
for ( it = this->ExtraCoverageGlobs.begin();
it != this->ExtraCoverageGlobs.end(); ++it)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Add coverage glob: "
- << it->c_str() << std::endl);
+ << *it << std::endl);
}
}
@@ -871,9 +877,22 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
{
std::string gcovCommand
= this->CTest->GetCTestConfiguration("CoverageCommand");
+ if (gcovCommand.empty())
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Could not find gcov." << std::endl);
+ return 0;
+ }
std::string gcovExtraFlags
= this->CTest->GetCTestConfiguration("CoverageExtraFlags");
+ // Immediately skip to next coverage option since codecov is only for Intel
+ // compiler
+ if ( gcovCommand == "codecov" )
+ {
+ return 0;
+ }
+
// Style 1
std::string st1gcovOutputRex1
= "[0-9]+\\.[0-9]+% of [0-9]+ (source |)lines executed in file (.*)$";
@@ -941,7 +960,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
// Call gcov to get coverage data for this *.gcda file:
//
- std::string fileDir = cmSystemTools::GetFilenamePath(it->c_str());
+ std::string fileDir = cmSystemTools::GetFilenamePath(*it);
std::string command = "\"" + gcovCommand + "\" " +
gcovExtraFlags + " " +
"-o \"" + fileDir + "\" " +
@@ -953,17 +972,17 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
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, tempDir.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 ++;
@@ -972,7 +991,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
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);
}
@@ -983,8 +1002,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
<< "--------------------------------------------------------------"
<< std::endl);
- std::vector<cmStdString> lines;
- std::vector<cmStdString>::iterator line;
+ std::vector<std::string> lines;
+ std::vector<std::string>::iterator line;
cmSystemTools::Split(output.c_str(), lines);
@@ -993,7 +1012,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
std::string sourceFile;
std::string gcovFile;
- cmCTestLog(this->CTest, DEBUG, "Line: [" << line->c_str() << "]"
+ cmCTestLog(this->CTest, DEBUG, "Line: [" << *line << "]"
<< std::endl);
if ( line->size() == 0 )
@@ -1139,7 +1158,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
!cmSystemTools::StringStartsWith(line->c_str(), "Removing "))
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Unknown gcov output line: [" << line->c_str() << "]"
+ "Unknown gcov output line: [" << *line << "]"
<< std::endl);
cont->Error ++;
//abort();
@@ -1232,8 +1251,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
if ( IsFileInDir(sourceFile, cont->SourceDir) )
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced s: "
- << sourceFile.c_str() << std::endl);
- *cont->OFS << " produced in source dir: " << sourceFile.c_str()
+ << sourceFile << std::endl);
+ *cont->OFS << " produced in source dir: " << sourceFile
<< std::endl;
actualSourceFile
= cmSystemTools::CollapseFullPath(sourceFile.c_str());
@@ -1241,8 +1260,8 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
else if ( IsFileInDir(sourceFile, cont->BinaryDir) )
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " produced b: "
- << sourceFile.c_str() << std::endl);
- *cont->OFS << " produced in binary dir: " << sourceFile.c_str()
+ << sourceFile << std::endl);
+ *cont->OFS << " produced in binary dir: " << sourceFile
<< std::endl;
actualSourceFile
= cmSystemTools::CollapseFullPath(sourceFile.c_str());
@@ -1256,19 +1275,19 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
"Something went wrong" << std::endl);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Cannot find file: ["
- << sourceFile.c_str() << "]" << std::endl);
+ << sourceFile << "]" << std::endl);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" in source dir: ["
- << cont->SourceDir.c_str() << "]"
+ << cont->SourceDir << "]"
<< std::endl);
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
" or binary dir: ["
<< cont->BinaryDir.size() << "]"
<< std::endl);
*cont->OFS << " Something went wrong. Cannot find file: "
- << sourceFile.c_str()
- << " in source dir: " << cont->SourceDir.c_str()
- << " or binary dir: " << cont->BinaryDir.c_str() << std::endl;
+ << sourceFile
+ << " in source dir: " << cont->SourceDir
+ << " or binary dir: " << cont->BinaryDir << std::endl;
missingFiles.insert(sourceFile);
}
@@ -1290,6 +1309,270 @@ int cmCTestCoverageHandler::HandleGCovCoverage(
return file_count;
}
+//----------------------------------------------------------------------
+int cmCTestCoverageHandler::HandleLCovCoverage(
+ cmCTestCoverageHandlerContainer* cont)
+{
+ std::string lcovCommand
+ = this->CTest->GetCTestConfiguration("CoverageCommand");
+ std::string lcovExtraFlags
+ = this->CTest->GetCTestConfiguration("CoverageExtraFlags");
+ if ( lcovCommand != "codecov" )
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " Not a valid Intel Coverage command."
+ << std::endl);
+ return 0;
+ }
+ // There is only percentage completed output from LCOV
+ std::string st2lcovOutputRex3 = "[0-9]+%";
+ cmsys::RegularExpression st2re3(st2lcovOutputRex3.c_str());
+
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " This is coverage command: " << lcovCommand
+ << std::endl);
+
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " These are coverage command flags: " << lcovExtraFlags
+ << std::endl);
+
+ std::vector<std::string> files;
+ this->FindLCovFiles(files);
+ std::vector<std::string>::iterator it;
+
+ if ( files.size() == 0 )
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " Cannot find any LCov coverage files."
+ << std::endl);
+ // No coverage files is a valid thing, so the exit code is 0
+ return 0;
+ }
+ std::string testingDir = this->CTest->GetBinaryDir();
+ std::string tempDir = testingDir;
+ std::string currentDirectory = cmSystemTools::GetCurrentWorkingDirectory();
+
+ std::set<std::string> missingFiles;
+
+ std::string actualSourceFile = "";
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Processing coverage (each . represents one file):" << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
+ int file_count = 0;
+
+ // make sure output from lcov is in English!
+ cmCTestCoverageHandlerLocale locale_C;
+ static_cast<void>(locale_C);
+
+ // In intel compiler we have to call codecov only once in each executable
+ // directory. It collects all *.dyn files to generate .dpi file.
+ 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 command = "\"" + lcovCommand + "\" " +
+ lcovExtraFlags + " ";
+
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Current coverage dir: "
+ << fileDir.c_str() << 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;
+ 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;
+ if ( ! res )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Problem running coverage on file: " << it->c_str() << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Command produced error: " << errors << std::endl);
+ cont->Error ++;
+ continue;
+ }
+ if ( retVal != 0 )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Coverage command returned: "
+ << retVal << " while processing: " << it->c_str() << std::endl);
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Command produced error: " << cont->Error << std::endl);
+ }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "--------------------------------------------------------------"
+ << std::endl
+ << output << std::endl
+ << "--------------------------------------------------------------"
+ << std::endl);
+
+ std::vector<std::string> lines;
+ std::vector<std::string>::iterator line;
+
+ cmSystemTools::Split(output.c_str(), lines);
+
+ for ( line = lines.begin(); line != lines.end(); ++line)
+ {
+ std::string sourceFile;
+ std::string lcovFile;
+
+ if ( line->size() == 0 )
+ {
+ // Ignore empty line
+ }
+ // Look for LCOV files in binary directory
+ // Intel Compiler creates a CodeCoverage dir for each subfolder and
+ // each subfolder has LCOV files
+ cmsys::Glob gl;
+ gl.RecurseOn();
+ gl.RecurseThroughSymlinksOff();
+ std::string dir;
+ std::vector<std::string> lcovFiles;
+ dir = this->CTest->GetBinaryDir();
+ std::string daGlob;
+ daGlob = dir;
+ daGlob += "/*.LCOV";
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " looking for LCOV files in: " << daGlob << std::endl);
+ gl.FindFiles(daGlob);
+ // Keep a list of all LCOV files
+ lcovFiles.insert(lcovFiles.end(), gl.GetFiles().begin(),
+ gl.GetFiles().end());
+
+ for(std::vector<std::string>::iterator a = lcovFiles.begin();
+ a != lcovFiles.end(); ++a)
+ {
+ lcovFile = *a;
+ cmsys::ifstream srcead(lcovFile.c_str());
+ if ( ! srcead )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
+ << lcovFile << std::endl);
+ }
+ std::string srcname;
+
+ int success = cmSystemTools::GetLineFromStream(srcead, srcname);
+ if ( !success )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE,
+ "Error while parsing lcov file '" << lcovFile << "':"
+ << " No source file name found!" << std::endl);
+ return 0;
+ }
+ srcname = srcname.substr(18);
+ // We can directly read found LCOV files to determine the source
+ // files
+ sourceFile = srcname;
+ actualSourceFile = srcname;
+
+ for(std::vector<std::string>::iterator t = lcovFiles.begin();
+ t != lcovFiles.end(); ++t)
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found LCOV File: "
+ << *t << std::endl);
+ }
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "SourceFile: "
+ << sourceFile << std::endl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "lCovFile: "
+ << lcovFile << std::endl);
+
+ // If we have some LCOV files to process
+ if ( !lcovFile.empty() && !actualSourceFile.empty() )
+ {
+ cmCTestCoverageHandlerContainer::SingleFileCoverageVector& vec
+ = cont->TotalCoverage[actualSourceFile];
+
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " in lcovFile: "
+ << lcovFile << std::endl);
+
+ cmsys::ifstream ifile(lcovFile.c_str());
+ if ( ! ifile )
+ {
+ cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
+ << lcovFile << std::endl);
+ }
+ else
+ {
+ long cnt = -1;
+ std::string nl;
+
+ // Skip the first line
+ cmSystemTools::GetLineFromStream(ifile, nl);
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "File is ready, start reading." << std::endl);
+ while ( cmSystemTools::GetLineFromStream(ifile, nl) )
+ {
+ cnt ++;
+
+ // Skip empty lines
+ if ( !nl.size() )
+ {
+ continue;
+ }
+
+ // Skip unused lines
+ if ( nl.size() < 12 )
+ {
+ continue;
+ }
+
+ // Read the coverage count from the beginning of the lcov
+ // output line
+ std::string prefix = nl.substr(0, 17);
+ int cov = atoi(prefix.c_str());
+
+ // Read the line number starting at the 17th character of the
+ // lcov output line
+ std::string lineNumber = nl.substr(17, 7);
+
+ int lineIdx = atoi(lineNumber.c_str())-1;
+ if ( lineIdx >= 0 )
+ {
+ while ( vec.size() <= static_cast<size_t>(lineIdx) )
+ {
+ vec.push_back(-1);
+ }
+
+ // Initially all entries are -1 (not used). If we get coverage
+ // information, increment it to 0 first.
+ if ( vec[lineIdx] < 0 )
+ {
+ if ( cov > 0 || prefix.find("#") != prefix.npos )
+ {
+ vec[lineIdx] = 0;
+ }
+ }
+
+ vec[lineIdx] += cov;
+ }
+ }
+ }
+
+ actualSourceFile = "";
+ }
+ }
+ }
+
+ file_count++;
+
+ if ( file_count % 50 == 0 )
+ {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " processed: " << file_count
+ << " out of " << files.size() << std::endl);
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
+ }
+ }
+
+ cmSystemTools::ChangeDirectory(currentDirectory.c_str());
+ return file_count;
+}
+
//----------------------------------------------------------------------------
void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
{
@@ -1321,6 +1604,34 @@ void cmCTestCoverageHandler::FindGCovFiles(std::vector<std::string>& files)
}
}
+//----------------------------------------------------------------------------
+void cmCTestCoverageHandler::FindLCovFiles(std::vector<std::string>& files)
+{
+ cmsys::Glob gl;
+ gl.RecurseOff(); // No need of recurse if -prof_dir${BUILD_DIR} flag is
+ // used while compiling.
+ gl.RecurseThroughSymlinksOff();
+ std::string prevBinaryDir;
+ cmSystemTools::ChangeDirectory(
+ this->CTest->GetCTestConfiguration("BuildDirectory").c_str());
+
+ // Run profmerge to merge all *.dyn files into dpi files
+ cmSystemTools::RunSingleCommand("profmerge");
+
+ prevBinaryDir = cmSystemTools::GetCurrentWorkingDirectory().c_str();
+
+ // DPI file should appear in build directory
+ std::string daGlob;
+ daGlob = prevBinaryDir;
+ daGlob += "/*.dpi";
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ " looking for dpi files in: " << daGlob << std::endl);
+ gl.FindFiles(daGlob);
+ files.insert(files.end(), gl.GetFiles().begin(), gl.GetFiles().end());
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ "Now searching in: " << daGlob << std::endl);
+}
+
//----------------------------------------------------------------------
int cmCTestCoverageHandler::HandleTracePyCoverage(
cmCTestCoverageHandlerContainer* cont)
@@ -1358,24 +1669,24 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find source Python file corresponding to: "
- << fileIt->c_str() << std::endl);
+ << *fileIt << std::endl);
continue;
}
std::string actualSourceFile
= cmSystemTools::CollapseFullPath(fileName.c_str());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " Check coverage for file: " << actualSourceFile.c_str()
+ " Check coverage for file: " << actualSourceFile
<< std::endl);
cmCTestCoverageHandlerContainer::SingleFileCoverageVector* vec
= &cont->TotalCoverage[actualSourceFile];
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- " in file: " << fileIt->c_str() << std::endl);
+ " in file: " << *fileIt << std::endl);
cmsys::ifstream ifile(fileIt->c_str());
if ( ! ifile )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot open file: "
- << fileIt->c_str() << std::endl);
+ << *fileIt << std::endl);
}
else
{
@@ -1423,7 +1734,7 @@ int cmCTestCoverageHandler::HandleTracePyCoverage(
// So, this will be set to 0.
cov = 0;
}
- cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix.c_str()
+ cmCTestLog(this->CTest, DEBUG, "Prefix: " << prefix
<< " cov: " << cov
<< std::endl);
// Read the line number starting at the 10th character of the gcov
@@ -1498,7 +1809,7 @@ namespace
//----------------------------------------------------------------------
int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
cmCTestCoverageHandlerContainer* cont,
- std::set<cmStdString>& coveredFileNames,
+ std::set<std::string>& coveredFileNames,
std::vector<std::string>& files,
std::vector<std::string>& filesFullPath)
{
@@ -1536,10 +1847,10 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot open coverage file: " <<
- outputFile.c_str() << std::endl);
+ outputFile << std::endl);
return 0;
}
- std::map<cmStdString, cmStdString> fileMap;
+ std::map<std::string, std::string> fileMap;
std::vector<std::string>::iterator fp = filesFullPath.begin();
for(std::vector<std::string>::iterator f = files.begin();
f != files.end(); ++f, ++fp)
@@ -1552,7 +1863,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
std::string lineIn;
bool valid = false; // are we in a valid output file
int line = 0; // line of the current file
- cmStdString file;
+ std::string file;
while(cmSystemTools::GetLineFromStream(fin, lineIn))
{
bool startFile = false;
@@ -1587,7 +1898,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
}
count++; // move on one
}
- std::map<cmStdString, cmStdString>::iterator
+ std::map<std::string, std::string>::iterator
i = fileMap.find(file);
// if the file should be covered write out the header for that file
if(i != fileMap.end())
@@ -1596,7 +1907,7 @@ int cmCTestCoverageHandler::RunBullseyeCoverageBranch(
count++;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Produce coverage for file: "
- << file.c_str() << " " << count
+ << file << " " << count
<< std::endl);
// start the file output
covLogFile << "\t<File Name=\""
@@ -1657,12 +1968,12 @@ int cmCTestCoverageHandler::RunBullseyeCommand(
if(arg)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run : " << program.c_str() << " " << arg << "\n");
+ "Run : " << program << " " << arg << "\n");
}
else
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Run : " << program.c_str() << "\n");
+ "Run : " << program << "\n");
}
// create a process object and start it
cmCTestRunProcess runCoverageSrc;
@@ -1680,7 +1991,7 @@ int cmCTestCoverageHandler::RunBullseyeCommand(
if(!runCoverageSrc.StartProcess())
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Could not run : "
- << program.c_str() << " " << arg << "\n"
+ << program << " " << arg << "\n"
<< "kwsys process state : "
<< runCoverageSrc.GetProcessState());
return 0;
@@ -1749,10 +2060,10 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot open coverage summary file: " <<
- outputFile.c_str() << std::endl);
+ outputFile << std::endl);
return 0;
}
- std::set<cmStdString> coveredFileNames;
+ std::set<std::string> coveredFileNames;
while(cmSystemTools::GetLineFromStream(fin, stdline))
{
// if we have a line of output from stdout
@@ -1790,14 +2101,14 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
".NoDartCoverage found, so skip coverage check for: "
- << file.c_str()
+ << file
<< std::endl);
continue;
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"Doing coverage for: "
- << file.c_str()
+ << file
<< std::endl);
coveredFiles.push_back(sourceFile);
@@ -1808,7 +2119,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
total_tested += functionsCalled;
total_untested += (totalFunctions - functionsCalled);
- std::string fileName = cmSystemTools::GetFilenameName(file.c_str());
+ std::string fileName = cmSystemTools::GetFilenameName(file);
std::string shortFileName =
this->CTest->GetShortPathToFile(file.c_str());
@@ -1824,7 +2135,7 @@ int cmCTestCoverageHandler::RunBullseyeSourceSummary(
cmet /= 2.0f;
}
cmet /= 100.0f;
- tmpLog << stdline.c_str() << "\n";
+ tmpLog << stdline << "\n";
tmpLog << fileName << "\n";
tmpLog << "functionsCalled: " << functionsCalled/100 << "\n";
tmpLog << "totalFunctions: " << totalFunctions/100 << "\n";
@@ -1951,7 +2262,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
if(pos == inputLine.npos)
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing string : "
- << inputLine.c_str() << "\n");
+ << inputLine << "\n");
return false;
}
// the source file has "" around it so extract out the file name
@@ -1985,7 +2296,7 @@ bool cmCTestCoverageHandler::ParseBullsEyeCovsrcLine(
if(pos != inputLine.npos)
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error parsing input : "
- << inputLine.c_str() << " last pos not npos = " << pos <<
+ << inputLine << " last pos not npos = " << pos <<
"\n");
}
return true;
@@ -2099,10 +2410,10 @@ void cmCTestCoverageHandler::WriteXMLLabels(std::ostream& os,
//----------------------------------------------------------------------------
void
-cmCTestCoverageHandler::SetLabelFilter(std::set<cmStdString> const& labels)
+cmCTestCoverageHandler::SetLabelFilter(std::set<std::string> const& labels)
{
this->LabelFilter.clear();
- for(std::set<cmStdString>::const_iterator li = labels.begin();
+ for(std::set<std::string>::const_iterator li = labels.begin();
li != labels.end(); ++li)
{
this->LabelFilter.insert(this->GetLabelId(*li));
@@ -2152,7 +2463,7 @@ std::set<std::string> cmCTestCoverageHandler::FindUncoveredFiles(
{
std::set<std::string> extraMatches;
- for(std::vector<cmStdString>::iterator i = this->ExtraCoverageGlobs.begin();
+ for(std::vector<std::string>::iterator i = this->ExtraCoverageGlobs.begin();
i != this->ExtraCoverageGlobs.end(); ++i)
{
cmsys::Glob gl;
diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h
index 660f501..0a0fe81 100644
--- a/Source/CTest/cmCTestCoverageHandler.h
+++ b/Source/CTest/cmCTestCoverageHandler.h
@@ -55,7 +55,7 @@ public:
void PopulateCustomVectors(cmMakefile *mf);
/** Report coverage only for sources with these labels. */
- void SetLabelFilter(std::set<cmStdString> const& labels);
+ void SetLabelFilter(std::set<std::string> const& labels);
private:
bool ShouldIDoCoverage(const char* file, const char* srcDir,
@@ -68,6 +68,10 @@ private:
int HandleGCovCoverage(cmCTestCoverageHandlerContainer* cont);
void FindGCovFiles(std::vector<std::string>& files);
+ //! Handle coverage using Intel's LCov
+ int HandleLCovCoverage(cmCTestCoverageHandlerContainer* cont);
+ void FindLCovFiles(std::vector<std::string>& files);
+
//! Handle coverage using xdebug php coverage
int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont);
@@ -81,7 +85,7 @@ private:
int HandleBullseyeCoverage(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeSourceSummary(cmCTestCoverageHandlerContainer* cont);
int RunBullseyeCoverageBranch(cmCTestCoverageHandlerContainer* cont,
- std::set<cmStdString>& coveredFileNames,
+ std::set<std::string>& coveredFileNames,
std::vector<std::string>& files,
std::vector<std::string>& filesFullPath);
@@ -112,19 +116,19 @@ private:
std::set<std::string> FindUncoveredFiles(
cmCTestCoverageHandlerContainer* cont);
- std::vector<cmStdString> CustomCoverageExclude;
+ std::vector<std::string> CustomCoverageExclude;
std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex;
- std::vector<cmStdString> ExtraCoverageGlobs;
+ std::vector<std::string> ExtraCoverageGlobs;
// Map from source file to label ids.
class LabelSet: public std::set<int> {};
- typedef std::map<cmStdString, LabelSet> LabelMapType;
+ typedef std::map<std::string, LabelSet> LabelMapType;
LabelMapType SourceLabels;
LabelMapType TargetDirs;
// Map from label name to label id.
- typedef std::map<cmStdString, int> LabelIdMapType;
+ typedef std::map<std::string, int> LabelIdMapType;
LabelIdMapType LabelIdMap;
std::vector<std::string> Labels;
int GetLabelId(std::string const& label);
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
index abc33de..5ddef01 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.cxx
@@ -25,8 +25,8 @@ bool cmCTestEmptyBinaryDirectoryCommand
if ( !cmCTestScriptHandler::EmptyBinaryDirectory(args[0].c_str()) )
{
cmOStringStream ostr;
- ostr << "problem removing the binary directory: " << args[0].c_str();
- this->SetError(ostr.str().c_str());
+ ostr << "problem removing the binary directory: " << args[0];
+ this->SetError(ostr.str());
return false;
}
diff --git a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
index 07e59a4..d182d17 100644
--- a/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
+++ b/Source/CTest/cmCTestEmptyBinaryDirectoryCommand.h
@@ -48,7 +48,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_empty_binary_directory";}
+ virtual std::string GetName() const { return "ctest_empty_binary_directory";}
cmTypeMacro(cmCTestEmptyBinaryDirectoryCommand, cmCTestCommand);
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 0e0e797..aaa01b2 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -179,8 +179,8 @@ bool cmCTestGIT::UpdateByFetchAndReset()
{
opts = this->CTest->GetCTestConfiguration("GITUpdateOptions");
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
git_fetch.push_back(ai->c_str());
diff --git a/Source/CTest/cmCTestGenericHandler.cxx b/Source/CTest/cmCTestGenericHandler.cxx
index 5338f30..2df2229 100644
--- a/Source/CTest/cmCTestGenericHandler.cxx
+++ b/Source/CTest/cmCTestGenericHandler.cxx
@@ -30,12 +30,8 @@ cmCTestGenericHandler::~cmCTestGenericHandler()
}
//----------------------------------------------------------------------
-void cmCTestGenericHandler::SetOption(const char* op, const char* value)
+void cmCTestGenericHandler::SetOption(const std::string& op, const char* value)
{
- if ( !op )
- {
- return;
- }
if ( !value )
{
cmCTestGenericHandler::t_StringToString::iterator remit
@@ -51,14 +47,10 @@ void cmCTestGenericHandler::SetOption(const char* op, const char* value)
}
//----------------------------------------------------------------------
-void cmCTestGenericHandler::SetPersistentOption(const char* op,
+void cmCTestGenericHandler::SetPersistentOption(const std::string& op,
const char* value)
{
this->SetOption(op, value);
- if ( !op )
- {
- return;
- }
if ( !value )
{
cmCTestGenericHandler::t_StringToString::iterator remit
@@ -83,12 +75,12 @@ void cmCTestGenericHandler::Initialize()
it != this->PersistentOptions.end();
++ it )
{
- this->Options[it->first.c_str()] = it->second.c_str();
+ this->Options[it->first] = it->second.c_str();
}
}
//----------------------------------------------------------------------
-const char* cmCTestGenericHandler::GetOption(const char* op)
+const char* cmCTestGenericHandler::GetOption(const std::string& op)
{
cmCTestGenericHandler::t_StringToString::iterator remit
= this->Options.find(op);
@@ -129,10 +121,10 @@ bool cmCTestGenericHandler::StartResultingXML(cmCTest::Part part,
return false;
}
if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
- ostr.str().c_str(), xofs, true) )
+ ostr.str(), xofs, true) )
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Cannot create resulting XML file: " << ostr.str().c_str()
+ "Cannot create resulting XML file: " << ostr.str()
<< std::endl);
return false;
}
@@ -161,10 +153,10 @@ bool cmCTestGenericHandler::StartLogFile(const char* name,
ostr << "_" << this->CTest->GetCurrentTag();
}
ostr << ".log";
- if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) )
+ if( !this->CTest->OpenOutputFile("Temporary", ostr.str(), xofs) )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: "
- << ostr.str().c_str() << std::endl);
+ << ostr.str() << std::endl);
return false;
}
return true;
diff --git a/Source/CTest/cmCTestGenericHandler.h b/Source/CTest/cmCTestGenericHandler.h
index ba8febb..2788cba 100644
--- a/Source/CTest/cmCTestGenericHandler.h
+++ b/Source/CTest/cmCTestGenericHandler.h
@@ -71,12 +71,12 @@ public:
cmCTestGenericHandler();
virtual ~cmCTestGenericHandler();
- typedef std::map<cmStdString,cmStdString> t_StringToString;
+ typedef std::map<std::string,std::string> t_StringToString;
- void SetPersistentOption(const char* op, const char* value);
- void SetOption(const char* op, const char* value);
- const char* GetOption(const char* op);
+ void SetPersistentOption(const std::string& op, const char* value);
+ void SetOption(const std::string& op, const char* value);
+ const char* GetOption(const std::string& op);
void SetCommand(cmCTestCommand* command)
{
diff --git a/Source/CTest/cmCTestGlobalVC.cxx b/Source/CTest/cmCTestGlobalVC.cxx
index 8c51102..5f570b5 100644
--- a/Source/CTest/cmCTestGlobalVC.cxx
+++ b/Source/CTest/cmCTestGlobalVC.cxx
@@ -132,7 +132,7 @@ bool cmCTestGlobalVC::WriteXMLUpdates(std::ostream& xml)
this->WriteXMLGlobal(xml);
- for(std::map<cmStdString, Directory>::const_iterator
+ for(std::map<std::string, Directory>::const_iterator
di = this->Dirs.begin(); di != this->Dirs.end(); ++di)
{
this->WriteXMLDirectory(xml, di->first, di->second);
diff --git a/Source/CTest/cmCTestGlobalVC.h b/Source/CTest/cmCTestGlobalVC.h
index a648a59..cb0d165 100644
--- a/Source/CTest/cmCTestGlobalVC.h
+++ b/Source/CTest/cmCTestGlobalVC.h
@@ -39,8 +39,8 @@ protected:
};
// Update status for files in each directory.
- class Directory: public std::map<cmStdString, File> {};
- std::map<cmStdString, Directory> Dirs;
+ class Directory: public std::map<std::string, File> {};
+ std::map<std::string, Directory> Dirs;
// Old and new repository revisions.
std::string OldRevision;
diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx
index 86a7617..0f79d68 100644
--- a/Source/CTest/cmCTestHG.cxx
+++ b/Source/CTest/cmCTestHG.cxx
@@ -149,8 +149,8 @@ bool cmCTestHG::UpdateImpl()
{
opts = this->CTest->GetCTestConfiguration("HGUpdateOptions");
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
hg_update.push_back(ai->c_str());
@@ -189,10 +189,10 @@ private:
return true;
}
- virtual void StartElement(const char* name, const char** atts)
+ virtual void StartElement(const std::string& name, const char** atts)
{
this->CData.clear();
- if(strcmp(name, "logentry") == 0)
+ if(name == "logentry")
{
this->Rev = Revision();
if(const char* rev = this->FindAttribute(atts, "revision"))
@@ -208,29 +208,29 @@ private:
this->CData.insert(this->CData.end(), data, data+length);
}
- virtual void EndElement(const char* name)
+ virtual void EndElement(const std::string& name)
{
- if(strcmp(name, "logentry") == 0)
+ if(name == "logentry")
{
this->HG->DoRevision(this->Rev, this->Changes);
}
- else if(strcmp(name, "author") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "author")
{
this->Rev.Author.assign(&this->CData[0], this->CData.size());
}
- else if ( strcmp(name, "email") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "email")
{
this->Rev.EMail.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "date") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "date")
{
this->Rev.Date.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "msg") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "msg")
{
this->Rev.Log.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "files") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "files")
{
std::vector<std::string> paths = this->SplitCData();
for(unsigned int i = 0; i < paths.size(); ++i)
@@ -242,7 +242,7 @@ private:
this->Changes.push_back(this->CurChange);
}
}
- else if(strcmp(name, "file_adds") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "file_adds")
{
std::string added_paths(this->CData.begin(), this->CData.end());
for(unsigned int i = 0; i < this->Changes.size(); ++i)
@@ -253,7 +253,7 @@ private:
}
}
}
- else if(strcmp(name, "file_dels") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "file_dels")
{
std::string added_paths(this->CData.begin(), this->CData.end());
for(unsigned int i = 0; i < this->Changes.size(); ++i)
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 2e2feb0..0e29160 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -48,7 +48,7 @@ bool cmCTestHandlerCommand
{
cmOStringStream e;
e << "called with unknown argument \"" << args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index cd3bd57..10a5199 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -567,7 +567,7 @@ void cmCTestLaunch::WriteXMLLabels(std::ostream& fxml)
fxml << "\n";
fxml << "\t\t<!-- Interested parties -->\n";
fxml << "\t\t<Labels>\n";
- for(std::set<cmStdString>::const_iterator li = this->Labels.begin();
+ for(std::set<std::string>::const_iterator li = this->Labels.begin();
li != this->Labels.end(); ++li)
{
fxml << "\t\t\t<Label>" << cmXMLSafe(*li) << "</Label>\n";
@@ -680,8 +680,8 @@ bool cmCTestLaunch::ScrapeLog(std::string const& fname)
continue;
}
- if(this->Match(line.c_str(), this->RegexWarning) &&
- !this->Match(line.c_str(), this->RegexWarningSuppress))
+ if(this->Match(line, this->RegexWarning) &&
+ !this->Match(line, this->RegexWarningSuppress))
{
return true;
}
diff --git a/Source/CTest/cmCTestLaunch.h b/Source/CTest/cmCTestLaunch.h
index f680d19..bc90d28 100644
--- a/Source/CTest/cmCTestLaunch.h
+++ b/Source/CTest/cmCTestLaunch.h
@@ -73,7 +73,7 @@ private:
bool HaveErr;
// Labels associated with the build rule.
- std::set<cmStdString> Labels;
+ std::set<std::string> Labels;
void LoadLabels();
bool SourceMatches(std::string const& lhs,
std::string const& rhs);
diff --git a/Source/CTest/cmCTestMemCheckCommand.h b/Source/CTest/cmCTestMemCheckCommand.h
index b50170d..e239d46 100644
--- a/Source/CTest/cmCTestMemCheckCommand.h
+++ b/Source/CTest/cmCTestMemCheckCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_memcheck";}
+ virtual std::string GetName() const { return "ctest_memcheck";}
cmTypeMacro(cmCTestMemCheckCommand, cmCTestTestCommand);
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index fdce04d..ecaa474 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -49,21 +49,15 @@ class cmBoundsCheckerParser : public cmXMLParser
{
public:
cmBoundsCheckerParser(cmCTest* c) { this->CTest = c;}
- void StartElement(const char* name, const char** atts)
+ void StartElement(const std::string& name, const char** atts)
{
- if(strcmp(name, "MemoryLeak") == 0)
+ if(name == "MemoryLeak" ||
+ name == "ResourceLeak")
{
this->Errors.push_back(cmCTestMemCheckHandler::MLK);
}
- if(strcmp(name, "ResourceLeak") == 0)
- {
- this->Errors.push_back(cmCTestMemCheckHandler::MLK);
- }
- if(strcmp(name, "Error") == 0)
- {
- this->ParseError(atts);
- }
- if(strcmp(name, "Dangling Pointer") == 0)
+ else if(name == "Error" ||
+ name == "Dangling Pointer")
{
this->ParseError(atts);
}
@@ -79,7 +73,7 @@ public:
ostr << "\n";
this->Log += ostr.str();
}
- void EndElement(const char* )
+ void EndElement(const std::string& )
{
}
@@ -246,8 +240,8 @@ int cmCTestMemCheckHandler::PostProcessHandler()
void cmCTestMemCheckHandler::GenerateTestCommand(
std::vector<std::string>& args, int test)
{
- std::vector<cmStdString>::size_type pp;
- cmStdString index;
+ std::vector<std::string>::size_type pp;
+ std::string index;
cmOStringStream stream;
std::string memcheckcommand
= cmSystemTools::ConvertToOutputPath(this->MemoryTester.c_str());
@@ -255,9 +249,9 @@ void cmCTestMemCheckHandler::GenerateTestCommand(
index = stream.str();
for ( pp = 0; pp < this->MemoryTesterDynamicOptions.size(); pp ++ )
{
- cmStdString arg = this->MemoryTesterDynamicOptions[pp];
- cmStdString::size_type pos = arg.find("??");
- if (pos != cmStdString::npos)
+ std::string arg = this->MemoryTesterDynamicOptions[pp];
+ std::string::size_type pos = arg.find("??");
+ if (pos != std::string::npos)
{
arg.replace(pos, 2, index);
}
@@ -520,7 +514,7 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot find memory checker suppression file: "
<< this->CTest->GetCTestConfiguration(
- "MemoryCheckSuppressionFile").c_str() << std::endl);
+ "MemoryCheckSuppressionFile") << std::endl);
return false;
}
std::string suppressions = "--suppressions="
@@ -575,12 +569,12 @@ bool cmCTestMemCheckHandler::InitializeMemoryChecking()
}
default:
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Do not understand memory checker: " << this->MemoryTester.c_str()
+ "Do not understand memory checker: " << this->MemoryTester
<< std::endl);
return false;
}
- std::vector<cmStdString>::size_type cc;
+ std::vector<std::string>::size_type cc;
for ( cc = 0; cmCTestMemCheckResultStrings[cc]; cc ++ )
{
this->MemoryTesterGlobalResults[cc] = 0;
@@ -627,7 +621,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
const std::string& str, std::string& log,
int* results)
{
- std::vector<cmStdString> lines;
+ std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmOStringStream ostr;
log = "";
@@ -636,7 +630,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckPurifyOutput(
int defects = 0;
- for( std::vector<cmStdString>::iterator i = lines.begin();
+ for( std::vector<std::string>::iterator i = lines.begin();
i != lines.end(); ++i)
{
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
@@ -681,7 +675,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
const std::string& str, std::string& log,
int* results)
{
- std::vector<cmStdString> lines;
+ std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
bool unlimitedOutput = false;
if(str.find("CTEST_FULL_OUTPUT") != str.npos ||
@@ -864,10 +858,10 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
{
log = "";
double sttime = cmSystemTools::GetTime();
- std::vector<cmStdString> lines;
+ std::vector<std::string> lines;
cmSystemTools::Split(str.c_str(), lines);
cmCTestLog(this->CTest, DEBUG, "Start test: " << lines.size() << std::endl);
- std::vector<cmStdString>::size_type cc;
+ std::vector<std::string>::size_type cc;
for ( cc = 0; cc < lines.size(); cc ++ )
{
if(lines[cc] == BOUNDS_CHECKER_MARKER)
@@ -891,7 +885,7 @@ bool cmCTestMemCheckHandler::ProcessMemCheckBoundsCheckerOutput(
else if(!parser.ParseChunk(theLine.c_str(), theLine.size()))
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
- "Error in ParseChunk: " << theLine.c_str()
+ "Error in ParseChunk: " << theLine
<< std::endl);
}
}
@@ -922,8 +916,8 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"PostProcessBoundsCheckerTest for : "
- << res.Name.c_str() << std::endl);
- cmStdString ofile = testOutputFileName(test);
+ << res.Name << std::endl);
+ std::string ofile = testOutputFileName(test);
if ( ofile.empty() )
{
return;
@@ -949,10 +943,10 @@ cmCTestMemCheckHandler::PostProcessBoundsCheckerTest(cmCTestTestResult& res,
cmSystemTools::Delay(1000);
cmSystemTools::RemoveFile(this->BoundsCheckerDPBDFile.c_str());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
- << this->BoundsCheckerDPBDFile.c_str() << std::endl);
+ << this->BoundsCheckerDPBDFile << std::endl);
cmSystemTools::RemoveFile(this->BoundsCheckerXMLFile.c_str());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Remove: "
- << this->BoundsCheckerXMLFile.c_str() << std::endl);
+ << this->BoundsCheckerXMLFile << std::endl);
}
void
@@ -961,7 +955,7 @@ cmCTestMemCheckHandler::PostProcessPurifyTest(cmCTestTestResult& res,
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"PostProcessPurifyTest for : "
- << res.Name.c_str() << std::endl);
+ << res.Name << std::endl);
appendMemTesterOutput(res, test);
}
@@ -971,7 +965,7 @@ cmCTestMemCheckHandler::PostProcessValgrindTest(cmCTestTestResult& res,
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
"PostProcessValgrindTest for : "
- << res.Name.c_str() << std::endl);
+ << res.Name << std::endl);
appendMemTesterOutput(res, test);
}
@@ -979,7 +973,7 @@ void
cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res,
int test)
{
- cmStdString ofile = testOutputFileName(test);
+ std::string ofile = testOutputFileName(test);
if ( ofile.empty() )
{
@@ -1000,15 +994,15 @@ cmCTestMemCheckHandler::appendMemTesterOutput(cmCTestTestResult& res,
}
}
-cmStdString
+std::string
cmCTestMemCheckHandler::testOutputFileName(int test)
{
- cmStdString index;
+ std::string index;
cmOStringStream stream;
stream << test;
index = stream.str();
- cmStdString ofile = this->MemoryTesterOutputFile;
- cmStdString::size_type pos = ofile.find("??");
+ std::string ofile = this->MemoryTesterOutputFile;
+ std::string::size_type pos = ofile.find("??");
ofile.replace(pos, 2, index);
if ( !cmSystemTools::FileExists(ofile.c_str()) )
diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h
index 040d2e0..0521a48 100644
--- a/Source/CTest/cmCTestMemCheckHandler.h
+++ b/Source/CTest/cmCTestMemCheckHandler.h
@@ -89,8 +89,8 @@ private:
std::string BoundsCheckerDPBDFile;
std::string BoundsCheckerXMLFile;
std::string MemoryTester;
- std::vector<cmStdString> MemoryTesterDynamicOptions;
- std::vector<cmStdString> MemoryTesterOptions;
+ std::vector<std::string> MemoryTesterDynamicOptions;
+ std::vector<std::string> MemoryTesterOptions;
int MemoryTesterStyle;
std::string MemoryTesterOutputFile;
int MemoryTesterGlobalResults[NO_MEMORY_FAULT];
@@ -103,8 +103,8 @@ private:
*/
void GenerateDartOutput(std::ostream& os);
- std::vector<cmStdString> CustomPreMemCheck;
- std::vector<cmStdString> CustomPostMemCheck;
+ std::vector<std::string> CustomPreMemCheck;
+ std::vector<std::string> CustomPostMemCheck;
//! Parse Valgrind/Purify/Bounds Checker result out of the output
//string. After running, log holds the output and results hold the
@@ -127,7 +127,7 @@ private:
int test);
///! generate the output filename for the given test index
- cmStdString testOutputFileName(int test);
+ std::string testOutputFileName(int test);
};
#endif
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index ddd1707..b9e6721 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -369,7 +369,7 @@ void cmCTestMultiProcessHandler::UpdateCostData()
// Write list of failed tests
fout << "---\n";
- for(std::vector<cmStdString>::iterator i = this->Failed->begin();
+ for(std::vector<std::string>::iterator i = this->Failed->begin();
i != this->Failed->end(); ++i)
{
fout << i->c_str() << "\n";
@@ -672,7 +672,7 @@ void cmCTestMultiProcessHandler::PrintTestList()
indexStr << " #" << p.Index << ":";
cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
- << indexStr.str().c_str());
+ << indexStr.str());
cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl);
//pop working dir
diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h
index 1b53ec7..605de31 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.h
+++ b/Source/CTest/cmCTestMultiProcessHandler.h
@@ -41,8 +41,8 @@ public:
void PrintTestList();
void PrintLabels();
- void SetPassFailVectors(std::vector<cmStdString>* passed,
- std::vector<cmStdString>* failed)
+ void SetPassFailVectors(std::vector<std::string>* passed,
+ std::vector<std::string>* failed)
{
this->Passed = passed;
this->Failed = failed;
@@ -107,9 +107,9 @@ protected:
PropertiesMap Properties;
std::map<int, bool> TestRunningMap;
std::map<int, bool> TestFinishMap;
- std::map<int, cmStdString> TestOutput;
- std::vector<cmStdString>* Passed;
- std::vector<cmStdString>* Failed;
+ std::map<int, std::string> TestOutput;
+ std::vector<std::string>* Passed;
+ std::vector<std::string>* Failed;
std::vector<std::string> LastTestsFailed;
std::set<std::string> LockedResources;
std::vector<cmCTestTestHandler::cmCTestTestResult>* TestResults;
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index b09d6f5..0bb1a99 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -346,13 +346,13 @@ void cmCTestP4::SetP4Options(std::vector<char const*> &CommandOptions)
//The CTEST_P4_OPTIONS variable adds additional Perforce command line
//options before the main command
std::string opts = this->CTest->GetCTestConfiguration("P4Options");
- std::vector<cmStdString> args =
+ std::vector<std::string> args =
cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
- P4Options.push_back(ai->c_str());
+ P4Options.push_back(*ai);
}
}
@@ -538,8 +538,8 @@ bool cmCTestP4::UpdateImpl()
{
opts = this->CTest->GetCTestConfiguration("P4UpdateOptions");
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
p4_sync.push_back(ai->c_str());
diff --git a/Source/CTest/cmCTestReadCustomFilesCommand.h b/Source/CTest/cmCTestReadCustomFilesCommand.h
index 9c0af81..c95694a 100644
--- a/Source/CTest/cmCTestReadCustomFilesCommand.h
+++ b/Source/CTest/cmCTestReadCustomFilesCommand.h
@@ -46,7 +46,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_read_custom_files";}
+ virtual std::string GetName() const { return "ctest_read_custom_files";}
cmTypeMacro(cmCTestReadCustomFilesCommand, cmCTestCommand);
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index fe429bd..bdf9b9c 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -56,7 +56,7 @@ bool cmCTestRunScriptCommand
&ret);
cmOStringStream str;
str << ret;
- this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str());
+ this->Makefile->AddDefinition(returnVariable, str.str().c_str());
}
}
return true;
diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h
index f34bd13..0998e5c 100644
--- a/Source/CTest/cmCTestRunScriptCommand.h
+++ b/Source/CTest/cmCTestRunScriptCommand.h
@@ -47,7 +47,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_run_script";}
+ virtual std::string GetName() const { return "ctest_run_script";}
cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand);
};
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index cdf90b9..385388d 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -334,9 +334,9 @@ bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
*this->TestHandler->LogFile << "Test Failed.\n";
}
}
- *this->TestHandler->LogFile << "\"" << this->TestProperties->Name.c_str()
+ *this->TestHandler->LogFile << "\"" << this->TestProperties->Name
<< "\" end time: " << this->CTest->CurrentTime() << std::endl
- << "\"" << this->TestProperties->Name.c_str() << "\" time elapsed: "
+ << "\"" << this->TestProperties->Name << "\" time elapsed: "
<< buffer << std::endl
<< "----------------------------------------------------------"
<< std::endl << std::endl;
@@ -388,8 +388,8 @@ void cmCTestRunTest::MemCheckPostProcess()
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, this->Index
<< ": process test output now: "
- << this->TestProperties->Name.c_str() << " "
- << this->TestResult.Name.c_str() << std::endl);
+ << this->TestProperties->Name << " "
+ << this->TestResult.Name << std::endl);
cmCTestMemCheckHandler * handler = static_cast<cmCTestMemCheckHandler*>
(this->TestHandler);
switch ( handler->MemoryTesterStyle )
@@ -465,9 +465,9 @@ bool cmCTestRunTest::StartTest(size_t total)
//Required file was not found
this->TestProcess = new cmProcess;
*this->TestHandler->LogFile << "Unable to find required file: "
- << file.c_str() << std::endl;
+ << file << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: "
- << file.c_str() << std::endl);
+ << file << std::endl);
this->TestResult.Output = "Unable to find required file: " + file;
this->TestResult.FullCommandLine = "";
this->TestResult.CompletionStatus = "Not Run";
@@ -482,9 +482,9 @@ bool cmCTestRunTest::StartTest(size_t total)
// that has that information
this->TestProcess = new cmProcess;
*this->TestHandler->LogFile << "Unable to find executable: "
- << args[1].c_str() << std::endl;
+ << args[1] << std::endl;
cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
- << args[1].c_str() << std::endl);
+ << args[1] << std::endl);
this->TestResult.Output = "Unable to find executable: " + args[1];
this->TestResult.FullCommandLine = "";
this->TestResult.CompletionStatus = "Not Run";
@@ -711,7 +711,7 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
indexStr << " #" << this->Index << ":";
cmCTestLog(this->CTest, HANDLER_OUTPUT,
std::setw(3 + getNumWidth(this->TestHandler->GetMaxIndex()))
- << indexStr.str().c_str());
+ << indexStr.str());
cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
const int maxTestNameWidth = this->CTest->GetMaxTestNameWidth();
std::string outname = this->TestProperties->Name + " ";
@@ -722,18 +722,18 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
<< this->TestProperties->Name << std::endl;
*this->TestHandler->LogFile << this->TestProperties->Index << "/"
<< this->TestHandler->TotalNumberOfTests
- << " Test: " << this->TestProperties->Name.c_str() << std::endl;
+ << " Test: " << this->TestProperties->Name << std::endl;
*this->TestHandler->LogFile << "Command: \"" << this->ActualCommand << "\"";
for (std::vector<std::string>::iterator i = this->Arguments.begin();
i != this->Arguments.end(); ++i)
{
*this->TestHandler->LogFile
- << " \"" << i->c_str() << "\"";
+ << " \"" << *i << "\"";
}
*this->TestHandler->LogFile << std::endl
<< "Directory: " << this->TestProperties->Directory << std::endl
- << "\"" << this->TestProperties->Name.c_str() << "\" start time: "
+ << "\"" << this->TestProperties->Name << "\" start time: "
<< this->StartTime << std::endl;
*this->TestHandler->LogFile
@@ -741,9 +741,9 @@ void cmCTestRunTest::WriteLogOutputTop(size_t completed, size_t total)
<< "----------------------------------------------------------"
<< std::endl;
*this->TestHandler->LogFile
- << this->ProcessOutput.c_str() << "<end of output>" << std::endl;
+ << this->ProcessOutput << "<end of output>" << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
cmCTestLog(this->CTest, DEBUG, "Testing "
- << this->TestProperties->Name.c_str() << " ... ");
+ << this->TestProperties->Name << " ... ");
}
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index 2668c8e..86dc2f2 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -277,7 +277,7 @@ bool cmCTestSVN::UpdateImpl()
{
opts = this->CTest->GetCTestConfiguration("SVNUpdateOptions");
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(opts.c_str());
+ std::vector<std::string> args = cmSystemTools::ParseArguments(opts.c_str());
// Specify the start time for nightly testing.
if(this->CTest->GetTestModel() == cmCTest::NIGHTLY)
@@ -287,7 +287,7 @@ bool cmCTestSVN::UpdateImpl()
std::vector<char const*> svn_update;
svn_update.push_back("update");
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
svn_update.push_back(ai->c_str());
@@ -314,9 +314,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters,
std::string userOptions =
this->CTest->GetCTestConfiguration("SVNOptions");
- std::vector<cmStdString> parsedUserOptions =
+ std::vector<std::string> parsedUserOptions =
cmSystemTools::ParseArguments(userOptions.c_str());
- for(std::vector<cmStdString>::iterator i = parsedUserOptions.begin();
+ for(std::vector<std::string>::iterator i = parsedUserOptions.begin();
i != parsedUserOptions.end(); ++i)
{
args.push_back(i->c_str());
@@ -361,10 +361,10 @@ private:
return true;
}
- virtual void StartElement(const char* name, const char** atts)
+ virtual void StartElement(const std::string& name, const char** atts)
{
this->CData.clear();
- if(strcmp(name, "logentry") == 0)
+ if(name == "logentry")
{
this->Rev = Revision();
this->Rev.SVNInfo = &SVNRepo;
@@ -374,7 +374,7 @@ private:
}
this->Changes.clear();
}
- else if(strcmp(name, "path") == 0)
+ else if(name == "path")
{
this->CurChange = Change();
if(const char* action = this->FindAttribute(atts, "action"))
@@ -389,28 +389,28 @@ private:
this->CData.insert(this->CData.end(), data, data+length);
}
- virtual void EndElement(const char* name)
+ virtual void EndElement(const std::string& name)
{
- if(strcmp(name, "logentry") == 0)
+ if(name == "logentry")
{
this->SVN->DoRevisionSVN(this->Rev, this->Changes);
}
- else if(strcmp(name, "path") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "path")
{
std::string orig_path(&this->CData[0], this->CData.size());
std::string new_path = SVNRepo.BuildLocalPath( orig_path );
this->CurChange.Path.assign(new_path);
this->Changes.push_back(this->CurChange);
}
- else if(strcmp(name, "author") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "author")
{
this->Rev.Author.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "date") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "date")
{
this->Rev.Date.assign(&this->CData[0], this->CData.size());
}
- else if(strcmp(name, "msg") == 0 && !this->CData.empty())
+ else if(!this->CData.empty() && name == "msg")
{
this->Rev.Log.assign(&this->CData[0], this->CData.size());
}
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 00a0a09..567acfc 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -231,7 +231,7 @@ int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
cmSystemTools::GetCTestCommand() << "\n");
// now pass through all the other arguments
- std::vector<cmStdString> &initArgs =
+ std::vector<std::string> &initArgs =
this->CTest->GetInitialCommandLineArguments();
//*** need to make sure this does not have the current script ***
for(size_t i=1; i < initArgs.size(); ++i)
@@ -337,8 +337,8 @@ void cmCTestScriptHandler::CreateCMake()
// Set CMAKE_CURRENT_SOURCE_DIR and CMAKE_CURRENT_BINARY_DIR.
// Also, some commands need Makefile->GetCurrentDirectory().
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->Makefile->SetStartDirectory(cwd.c_str());
- this->Makefile->SetStartOutputDirectory(cwd.c_str());
+ this->Makefile->SetStartDirectory(cwd);
+ this->Makefile->SetStartOutputDirectory(cwd);
// remove all cmake commands which are not scriptable, since they can't be
// used in ctest scripts
@@ -426,7 +426,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
cmSystemTools::GetErrorOccuredFlag())
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:"
- << systemFile.c_str() << "\n");
+ << systemFile << "\n");
return 2;
}
@@ -436,7 +436,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
for (std::map<std::string, std::string>::const_iterator it = defs.begin();
it != defs.end(); ++it)
{
- this->Makefile->AddDefinition(it->first.c_str(), it->second.c_str());
+ this->Makefile->AddDefinition(it->first, it->second.c_str());
}
// finally read in the script
@@ -444,7 +444,7 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
cmSystemTools::GetErrorOccuredFlag())
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: "
- << script.c_str()
+ << script
<< std::endl);
// Reset the error flag so that it can run more than
// one script with an error when you
@@ -646,7 +646,7 @@ int cmCTestScriptHandler::RunCurrentScript()
if (!this->CTestEnv.empty())
{
std::vector<std::string> envArgs;
- cmSystemTools::ExpandListArgument(this->CTestEnv.c_str(),envArgs);
+ cmSystemTools::ExpandListArgument(this->CTestEnv,envArgs);
cmSystemTools::AppendEnv(envArgs);
}
@@ -766,13 +766,13 @@ int cmCTestScriptHandler::PerformExtraUpdates()
// do an initial cvs update as required
command = this->UpdateCmd;
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for (it = this->ExtraUpdates.begin();
it != this->ExtraUpdates.end();
++ it )
{
std::vector<std::string> cvsArgs;
- cmSystemTools::ExpandListArgument(it->c_str(),cvsArgs);
+ cmSystemTools::ExpandListArgument(*it,cvsArgs);
if (cvsArgs.size() == 2)
{
std::string fullCommand = command;
@@ -781,7 +781,7 @@ int cmCTestScriptHandler::PerformExtraUpdates()
output = "";
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run Update: "
- << fullCommand.c_str() << std::endl);
+ << fullCommand << std::endl);
res = cmSystemTools::RunSingleCommand(fullCommand.c_str(), &output,
&retVal, cvsArgs[0].c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
@@ -902,7 +902,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
command += "\"";
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run cmake command: "
- << command.c_str() << std::endl);
+ << command << std::endl);
res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&retVal, this->BinaryDir.c_str(),
this->HandlerVerbose, 0 /*this->TimeOut*/);
@@ -916,7 +916,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
}
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- "Write CMake output to file: " << cmakeOutputFile.c_str()
+ "Write CMake output to file: " << cmakeOutputFile
<< std::endl);
cmGeneratedFileStream fout(cmakeOutputFile.c_str());
if ( fout )
@@ -927,7 +927,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Cannot open CMake output file: "
- << cmakeOutputFile.c_str() << " for writing" << std::endl);
+ << cmakeOutputFile << " for writing" << std::endl);
}
}
if (!res || retVal != 0)
@@ -948,7 +948,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
output = "";
retVal = 0;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Run ctest command: "
- << command.c_str() << std::endl);
+ << command << std::endl);
res = cmSystemTools::RunSingleCommand(command.c_str(), &output,
&retVal, this->BinaryDir.c_str(), this->HandlerVerbose,
0 /*this->TimeOut*/);
@@ -962,13 +962,13 @@ int cmCTestScriptHandler::RunConfigurationDashboard()
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Unable to run cmake:" << std::endl
- << cmakeFailedOuput.c_str() << std::endl);
+ << cmakeFailedOuput << std::endl);
return 10;
}
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Unable to run ctest:" << std::endl
- << "command: " << command.c_str() << std::endl
- << "output: " << output.c_str() << std::endl);
+ << "command: " << command << std::endl
+ << "output: " << output << std::endl);
if (!res)
{
return 11;
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 44e9dd0..42c2f20 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -138,26 +138,26 @@ private:
// Try to remove the binary directory once
static bool TryToRemoveBinaryDirectoryOnce(const std::string& directoryPath);
- std::vector<cmStdString> ConfigurationScripts;
+ std::vector<std::string> ConfigurationScripts;
std::vector<bool> ScriptProcessScope;
bool Backup;
bool EmptyBinDir;
bool EmptyBinDirOnce;
- cmStdString SourceDir;
- cmStdString BinaryDir;
- cmStdString BackupSourceDir;
- cmStdString BackupBinaryDir;
- cmStdString CTestRoot;
- cmStdString CVSCheckOut;
- cmStdString CTestCmd;
- cmStdString UpdateCmd;
- cmStdString CTestEnv;
- cmStdString InitialCache;
- cmStdString CMakeCmd;
- cmStdString CMOutFile;
- std::vector<cmStdString> ExtraUpdates;
+ std::string SourceDir;
+ std::string BinaryDir;
+ std::string BackupSourceDir;
+ std::string BackupBinaryDir;
+ std::string CTestRoot;
+ std::string CVSCheckOut;
+ std::string CTestCmd;
+ std::string UpdateCmd;
+ std::string CTestEnv;
+ std::string InitialCache;
+ std::string CMakeCmd;
+ std::string CMOutFile;
+ std::vector<std::string> ExtraUpdates;
double MinimumInterval;
double ContinuousDuration;
diff --git a/Source/CTest/cmCTestSleepCommand.h b/Source/CTest/cmCTestSleepCommand.h
index c6baf1c..740a7e1 100644
--- a/Source/CTest/cmCTestSleepCommand.h
+++ b/Source/CTest/cmCTestSleepCommand.h
@@ -47,7 +47,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_sleep";}
+ virtual std::string GetName() const { return "ctest_sleep";}
cmTypeMacro(cmCTestSleepCommand, cmCTestCommand);
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index 228a173..da46f4a 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -131,7 +131,7 @@ bool cmCTestStartCommand
<< " " << sourceDir << "\n"
<< "which is not an existing directory. "
<< "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -160,7 +160,7 @@ bool cmCTestStartCommand::InitialCheckout(
{
// Use a generic VC object to run and log the command.
cmCTestVC vc(this->CTest, ofs);
- vc.SetSourceDirectory(sourceDir.c_str());
+ vc.SetSourceDirectory(sourceDir);
if(!vc.InitialCheckout(initialCheckoutCommand))
{
return false;
diff --git a/Source/CTest/cmCTestStartCommand.h b/Source/CTest/cmCTestStartCommand.h
index e5535c1..3b8843f 100644
--- a/Source/CTest/cmCTestStartCommand.h
+++ b/Source/CTest/cmCTestStartCommand.h
@@ -55,7 +55,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_start";}
+ virtual std::string GetName() const { return "ctest_start";}
cmTypeMacro(cmCTestStartCommand, cmCTestCommand);
diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx
index 24974e3..07a994d 100644
--- a/Source/CTest/cmCTestSubmitCommand.cxx
+++ b/Source/CTest/cmCTestSubmitCommand.cxx
@@ -72,7 +72,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
if (notesFilesVariable)
{
std::vector<std::string> notesFiles;
- std::vector<cmStdString> newNotesFiles;
+ cmCTest::VectorOfStrings newNotesFiles;
cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
std::vector<std::string>::iterator it;
for ( it = notesFiles.begin();
@@ -89,7 +89,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
if (extraFilesVariable)
{
std::vector<std::string> extraFiles;
- std::vector<cmStdString> newExtraFiles;
+ cmCTest::VectorOfStrings newExtraFiles;
cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
std::vector<std::string>::iterator it;
for ( it = extraFiles.begin();
@@ -222,7 +222,7 @@ bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
if(this->ArgumentDoing == ArgumentDoingFiles)
{
- cmStdString filename(arg);
+ std::string filename(arg);
if(cmSystemTools::FileExists(filename.c_str()))
{
this->Files.insert(filename);
diff --git a/Source/CTest/cmCTestSubmitCommand.h b/Source/CTest/cmCTestSubmitCommand.h
index 64c6cae..3673fbd 100644
--- a/Source/CTest/cmCTestSubmitCommand.h
+++ b/Source/CTest/cmCTestSubmitCommand.h
@@ -48,7 +48,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_submit";}
+ virtual std::string GetName() const { return "ctest_submit";}
cmTypeMacro(cmCTestSubmitCommand, cmCTestHandlerCommand);
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index 139f515..7c72cba 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -68,10 +68,10 @@ private:
return val;
}
- virtual void StartElement(const char* name, const char** atts)
+ virtual void StartElement(const std::string& name, const char** atts)
{
this->CurrentValue.clear();
- if(strcmp(name, "cdash") == 0)
+ if(name == "cdash")
{
this->CDashVersion = this->FindAttribute(atts, "version");
}
@@ -82,9 +82,9 @@ private:
this->CurrentValue.insert(this->CurrentValue.end(), data, data+length);
}
- virtual void EndElement(const char* name)
+ virtual void EndElement(const std::string& name)
{
- if(strcmp(name, "status") == 0)
+ if(name == "status")
{
std::string status = cmSystemTools::UpperCase(this->GetCurrentValue());
if(status == "OK" || status == "SUCCESS")
@@ -100,15 +100,15 @@ private:
this->Status = STATUS_ERROR;
}
}
- else if(strcmp(name, "filename") == 0)
+ else if(name == "filename")
{
this->Filename = this->GetCurrentValue();
}
- else if(strcmp(name, "md5") == 0)
+ else if(name == "md5")
{
this->MD5 = this->GetCurrentValue();
}
- else if(strcmp(name, "message") == 0)
+ else if(name == "message")
{
this->Message = this->GetCurrentValue();
}
@@ -170,10 +170,10 @@ void cmCTestSubmitHandler::Initialize()
}
//----------------------------------------------------------------------------
-bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url)
+bool cmCTestSubmitHandler::SubmitUsingFTP(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
CURL *curl;
CURLcode res;
@@ -217,30 +217,30 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
::curl_easy_setopt(curl, CURLOPT_UPLOAD, 1);
- cmStdString local_file = *file;
+ std::string local_file = *file;
if ( !cmSystemTools::FileExists(local_file.c_str()) )
{
local_file = localprefix + "/" + *file;
}
- cmStdString upload_as
+ std::string upload_as
= url + "/" + remoteprefix + cmSystemTools::GetFilenameName(*file);
struct stat st;
if ( ::stat(local_file.c_str(), &st) )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
- << local_file.c_str() << std::endl);
+ << local_file << std::endl);
::curl_easy_cleanup(curl);
::curl_global_cleanup();
return false;
}
ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
- *this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
- << upload_as.c_str() << std::endl;
+ *this->LogFile << "\tUpload file: " << local_file << " to "
+ << upload_as << std::endl;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
- << local_file.c_str() << " to "
- << upload_as.c_str() << std::endl);
+ << local_file << " to "
+ << upload_as << std::endl);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
@@ -290,11 +290,11 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Error when uploading file: "
- << local_file.c_str() << std::endl);
+ << local_file << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
<< error_buffer << std::endl);
*this->LogFile << " Error when uploading file: "
- << local_file.c_str()
+ << local_file
<< std::endl
<< " Error message was: "
<< error_buffer << std::endl
@@ -324,10 +324,10 @@ bool cmCTestSubmitHandler::SubmitUsingFTP(const cmStdString& localprefix,
//----------------------------------------------------------------------------
// Uploading files is simpler
-bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url)
+bool cmCTestSubmitHandler::SubmitUsingHTTP(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
CURL *curl;
CURLcode res;
@@ -336,10 +336,10 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
/* In windows, this will init the winsock stuff */
::curl_global_init(CURL_GLOBAL_ALL);
- cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
- cmStdString curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
+ std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
+ std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions"));
std::vector<std::string> args;
- cmSystemTools::ExpandListArgument(curlopt.c_str(), args);
+ cmSystemTools::ExpandListArgument(curlopt, args);
bool verifyPeerOff = false;
bool verifyHostOff = false;
for( std::vector<std::string>::iterator i = args.begin();
@@ -354,7 +354,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
verifyHostOff = true;
}
}
- cmStdString::size_type kk;
+ std::string::size_type kk;
cmCTest::SetOfStrings::const_iterator file;
for ( file = files.begin(); file != files.end(); ++file )
{
@@ -414,18 +414,18 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
::curl_easy_setopt(curl, CURLOPT_PUT, 1);
::curl_easy_setopt(curl, CURLOPT_VERBOSE, 1);
- cmStdString local_file = *file;
+ std::string local_file = *file;
if ( !cmSystemTools::FileExists(local_file.c_str()) )
{
local_file = localprefix + "/" + *file;
}
- cmStdString remote_file
+ std::string remote_file
= remoteprefix + cmSystemTools::GetFilenameName(*file);
- *this->LogFile << "\tUpload file: " << local_file.c_str() << " to "
- << remote_file.c_str() << std::endl;
+ *this->LogFile << "\tUpload file: " << local_file << " to "
+ << remote_file << std::endl;
- cmStdString ofile = "";
+ std::string ofile = "";
for ( kk = 0; kk < remote_file.size(); kk ++ )
{
char c = remote_file[kk];
@@ -448,8 +448,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
ofile.append(hexCh);
}
}
- cmStdString upload_as
- = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
+ std::string upload_as
+ = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
+ "FileName=" + ofile;
upload_as += "&MD5=";
@@ -461,7 +461,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
else
{
char md5[33];
- cmSystemTools::ComputeFileMD5(local_file.c_str(), md5);
+ cmSystemTools::ComputeFileMD5(local_file, md5);
md5[32] = 0;
upload_as += md5;
}
@@ -470,7 +470,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
if ( ::stat(local_file.c_str(), &st) )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, " Cannot find file: "
- << local_file.c_str() << std::endl);
+ << local_file << std::endl);
::curl_easy_cleanup(curl);
::curl_global_cleanup();
return false;
@@ -478,8 +478,8 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
ftpfile = cmsys::SystemTools::Fopen(local_file.c_str(), "rb");
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Upload file: "
- << local_file.c_str() << " to "
- << upload_as.c_str() << " Size: " << st.st_size << std::endl);
+ << local_file << " to "
+ << upload_as << " Size: " << st.st_size << std::endl);
// specify target
::curl_easy_setopt(curl,CURLOPT_URL, upload_as.c_str());
@@ -595,11 +595,11 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP(const cmStdString& localprefix,
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
" Error when uploading file: "
- << local_file.c_str() << std::endl);
+ << local_file << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
<< error_buffer << std::endl);
*this->LogFile << " Error when uploading file: "
- << local_file.c_str()
+ << local_file
<< std::endl
<< " Error message was: " << error_buffer
<< std::endl;
@@ -666,9 +666,9 @@ void cmCTestSubmitHandler
//----------------------------------------------------------------------------
bool cmCTestSubmitHandler::TriggerUsingHTTP(
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url)
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
CURL *curl;
char error_buffer[1024];
@@ -721,10 +721,10 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
::curl_easy_setopt(curl, CURLOPT_FILE, (void *)&chunk);
::curl_easy_setopt(curl, CURLOPT_DEBUGDATA, (void *)&chunkDebug);
- cmStdString rfile
+ std::string rfile
= remoteprefix + cmSystemTools::GetFilenameName(*file);
- cmStdString ofile = "";
- cmStdString::iterator kk;
+ std::string ofile = "";
+ std::string::iterator kk;
for ( kk = rfile.begin(); kk < rfile.end(); ++ kk)
{
char c = *kk;
@@ -747,18 +747,18 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
ofile.append(hexCh);
}
}
- cmStdString turl
- = url + ((url.find("?",0) == cmStdString::npos) ? "?" : "&")
+ std::string turl
+ = url + ((url.find("?",0) == std::string::npos) ? "?" : "&")
+ "xmlfile=" + ofile;
- *this->LogFile << "Trigger url: " << turl.c_str() << std::endl;
+ *this->LogFile << "Trigger url: " << turl << std::endl;
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Trigger url: "
- << turl.c_str() << std::endl);
+ << turl << std::endl);
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_easy_setopt(curl, CURLOPT_URL, turl.c_str());
if ( curl_easy_perform(curl) )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error when triggering: "
- << turl.c_str() << std::endl);
+ << turl << std::endl);
cmCTestLog(this->CTest, ERROR_MESSAGE, " Error message was: "
<< error_buffer << std::endl);
*this->LogFile << "\tTriggering failed with error: " << error_buffer
@@ -805,11 +805,11 @@ bool cmCTestSubmitHandler::TriggerUsingHTTP(
//----------------------------------------------------------------------------
bool cmCTestSubmitHandler::SubmitUsingSCP(
- const cmStdString& scp_command,
- const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url)
+ const std::string& scp_command,
+ const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
if ( !scp_command.size() || !localprefix.size() ||
!files.size() || !remoteprefix.size() || !url.size() )
@@ -906,10 +906,10 @@ bool cmCTestSubmitHandler::SubmitUsingSCP(
//----------------------------------------------------------------------------
bool cmCTestSubmitHandler::SubmitUsingCP(
- const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& destination)
+ const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& destination)
{
if ( !localprefix.size() ||
!files.size() || !remoteprefix.size() || !destination.size() )
@@ -932,8 +932,8 @@ bool cmCTestSubmitHandler::SubmitUsingCP(
std::string rfname = destination + "/" + remoteprefix + *file;
cmSystemTools::CopyFileAlways(lfname.c_str(), rfname.c_str());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Copy file: "
- << lfname.c_str() << " to "
- << rfname.c_str() << std::endl);
+ << lfname << " to "
+ << rfname << std::endl);
}
std::string tagDoneFile = destination + "/" + remoteprefix + "DONE";
cmSystemTools::Touch(tagDoneFile.c_str(), true);
@@ -947,17 +947,17 @@ bool cmCTestSubmitHandler::SubmitUsingCP(
//----------------------------------------------------------------------------
#if defined(CTEST_USE_XMLRPC)
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url)
+bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url)
{
xmlrpc_env env;
char ctestString[] = "CTest";
std::string ctestVersionString = cmVersion::GetCMakeVersion();
char* ctestVersion = const_cast<char*>(ctestVersionString.c_str());
- cmStdString realURL = url + "/" + remoteprefix + "/Command/";
+ std::string realURL = url + "/" + remoteprefix + "/Command/";
/* Start up our XML-RPC client library. */
xmlrpc_client_init(XMLRPC_CLIENT_NO_FLAGS, ctestString, ctestVersion);
@@ -973,7 +973,7 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
{
xmlrpc_value *result;
- cmStdString local_file = *file;
+ std::string local_file = *file;
if ( !cmSystemTools::FileExists(local_file.c_str()) )
{
local_file = localprefix + "/" + *file;
@@ -1045,10 +1045,10 @@ bool cmCTestSubmitHandler::SubmitUsingXMLRPC(const cmStdString& localprefix,
return true;
}
#else
-bool cmCTestSubmitHandler::SubmitUsingXMLRPC(cmStdString const&,
- std::set<cmStdString> const&,
- cmStdString const&,
- cmStdString const&)
+bool cmCTestSubmitHandler::SubmitUsingXMLRPC(std::string const&,
+ std::set<std::string> const&,
+ std::string const&,
+ std::string const&)
{
return false;
}
@@ -1085,7 +1085,7 @@ int cmCTestSubmitHandler::ProcessHandler()
}
if ( getenv("HTTP_PROXY_TYPE") )
{
- cmStdString type = getenv("HTTP_PROXY_TYPE");
+ std::string type = getenv("HTTP_PROXY_TYPE");
// HTTP/SOCKS4/SOCKS5
if ( type == "HTTP" )
{
@@ -1122,7 +1122,7 @@ int cmCTestSubmitHandler::ProcessHandler()
}
if ( getenv("FTP_PROXY_TYPE") )
{
- cmStdString type = getenv("FTP_PROXY_TYPE");
+ std::string type = getenv("FTP_PROXY_TYPE");
// HTTP/SOCKS4/SOCKS5
if ( type == "HTTP" )
{
@@ -1178,12 +1178,12 @@ int cmCTestSubmitHandler::ProcessHandler()
this->CTest->AddIfExists(cmCTest::PartTest, "Test.xml");
if(this->CTest->AddIfExists(cmCTest::PartCoverage, "Coverage.xml"))
{
- cmCTest::VectorOfStrings gfiles;
+ std::vector<std::string> gfiles;
std::string gpath
= buildDirectory + "/Testing/" + this->CTest->GetCurrentTag();
std::string::size_type glen = gpath.size() + 1;
gpath = gpath + "/CoverageLog*";
- cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath.c_str()
+ cmCTestLog(this->CTest, DEBUG, "Globbing for: " << gpath
<< std::endl);
if ( cmSystemTools::SimpleGlob(gpath, gfiles, 1) )
{
@@ -1191,7 +1191,7 @@ int cmCTestSubmitHandler::ProcessHandler()
for ( cc = 0; cc < gfiles.size(); cc ++ )
{
gfiles[cc] = gfiles[cc].substr(glen);
- cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc].c_str()
+ cmCTestLog(this->CTest, DEBUG, "Glob file: " << gfiles[cc]
<< std::endl);
this->CTest->AddSubmitFile(cmCTest::PartCoverage, gfiles[cc].c_str());
}
@@ -1232,7 +1232,7 @@ int cmCTestSubmitHandler::ProcessHandler()
cmCTest::SetOfStrings::iterator it;
for ( it = files.begin(); it != files.end(); ++ it )
{
- ofs << cnt << "\t" << it->c_str() << std::endl;
+ ofs << cnt << "\t" << *it << std::endl;
cnt ++;
}
}
@@ -1247,7 +1247,7 @@ int cmCTestSubmitHandler::ProcessHandler()
}
this->SetLogFile(&ofs);
- cmStdString dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
+ std::string dropMethod(this->CTest->GetCTestConfiguration("DropMethod"));
if ( dropMethod == "" || dropMethod == "ftp" )
{
@@ -1448,7 +1448,7 @@ int cmCTestSubmitHandler::ProcessHandler()
oldWorkingDirectory = cmSystemTools::GetCurrentWorkingDirectory();
cmSystemTools::ChangeDirectory(buildDirectory.c_str());
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " Change directory: "
- << buildDirectory.c_str() << std::endl);
+ << buildDirectory << std::endl);
if ( !this->SubmitUsingCP(
"Testing/"+this->CTest->GetCurrentTag(),
diff --git a/Source/CTest/cmCTestSubmitHandler.h b/Source/CTest/cmCTestSubmitHandler.h
index 14eac80..accabd1 100644
--- a/Source/CTest/cmCTestSubmitHandler.h
+++ b/Source/CTest/cmCTestSubmitHandler.h
@@ -47,33 +47,33 @@ private:
/**
* Submit file using various ways
*/
- bool SubmitUsingFTP(const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url);
- bool SubmitUsingHTTP(const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url);
- bool SubmitUsingSCP(const cmStdString& scp_command,
- const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url);
-
- bool SubmitUsingCP( const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url);
-
- bool TriggerUsingHTTP(const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url);
-
- bool SubmitUsingXMLRPC(const cmStdString& localprefix,
- const std::set<cmStdString>& files,
- const cmStdString& remoteprefix,
- const cmStdString& url);
+ bool SubmitUsingFTP(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
+ bool SubmitUsingHTTP(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
+ bool SubmitUsingSCP(const std::string& scp_command,
+ const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
+
+ bool SubmitUsingCP( const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
+
+ bool TriggerUsingHTTP(const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
+
+ bool SubmitUsingXMLRPC(const std::string& localprefix,
+ const std::set<std::string>& files,
+ const std::string& remoteprefix,
+ const std::string& url);
typedef std::vector<char> cmCTestSubmitHandlerVectorOfChar;
@@ -82,10 +82,10 @@ private:
std::string GetSubmitResultsPrefix();
class ResponseParser;
- cmStdString HTTPProxy;
+ std::string HTTPProxy;
int HTTPProxyType;
- cmStdString HTTPProxyAuth;
- cmStdString FTPProxy;
+ std::string HTTPProxyAuth;
+ std::string FTPProxy;
int FTPProxyType;
std::ostream* LogFile;
bool SubmitPart[cmCTest::PartCount];
diff --git a/Source/CTest/cmCTestTestCommand.h b/Source/CTest/cmCTestTestCommand.h
index 451ac99..a1e5f36 100644
--- a/Source/CTest/cmCTestTestCommand.h
+++ b/Source/CTest/cmCTestTestCommand.h
@@ -39,7 +39,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_test";}
+ virtual std::string GetName() const { return "ctest_test";}
cmTypeMacro(cmCTestTestCommand, cmCTestHandlerCommand);
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 3a04b33..1d1dde4 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -60,7 +60,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "subdirs";}
+ virtual std::string GetName() const { return "subdirs";}
cmTypeMacro(cmCTestSubdirCommand, cmCommand);
@@ -125,7 +125,7 @@ bool cmCTestSubdirCommand
{
std::string m = "Could not find include file: ";
m += fname;
- this->SetError(m.c_str());
+ this->SetError(m);
return false;
}
}
@@ -157,7 +157,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_subdirectory";}
+ virtual std::string GetName() const { return "add_subdirectory";}
cmTypeMacro(cmCTestAddSubdirectoryCommand, cmCommand);
@@ -213,7 +213,7 @@ bool cmCTestAddSubdirectoryCommand
{
std::string m = "Could not find include file: ";
m += fname;
- this->SetError(m.c_str());
+ this->SetError(m);
return false;
}
return true;
@@ -243,7 +243,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_test";}
+ virtual std::string GetName() const { return "add_test";}
cmTypeMacro(cmCTestAddTestCommand, cmCommand);
@@ -287,7 +287,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "set_tests_properties";}
+ virtual std::string GetName() const { return "set_tests_properties";}
cmTypeMacro(cmCTestSetTestsPropertiesCommand, cmCommand);
@@ -540,8 +540,8 @@ int cmCTestTestHandler::ProcessHandler()
this->StartLogFile((this->MemCheck ? "DynamicAnalysis" : "Test"), mLogFile);
this->LogFile = &mLogFile;
- std::vector<cmStdString> passed;
- std::vector<cmStdString> failed;
+ std::vector<std::string> passed;
+ std::vector<std::string> failed;
int total;
//start the real time clock
@@ -569,7 +569,7 @@ int cmCTestTestHandler::ProcessHandler()
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
<< "The following tests passed:" << std::endl);
- for(std::vector<cmStdString>::iterator j = passed.begin();
+ for(std::vector<std::string>::iterator j = passed.begin();
j != passed.end(); ++j)
{
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "\t" << *j
@@ -616,7 +616,7 @@ int cmCTestTestHandler::ProcessHandler()
ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
<< ftit->TestCount << " - "
- << ftit->Name.c_str() << " ("
+ << ftit->Name << " ("
<< this->GetTestStatus(ftit->Status) << ")"
<< std::endl);
}
@@ -661,8 +661,8 @@ void cmCTestTestHandler::PrintLabelSummary()
cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin();
cmCTestTestHandler::TestResultsVector::iterator ri =
this->TestResults.begin();
- std::map<cmStdString, double> labelTimes;
- std::set<cmStdString> labels;
+ std::map<std::string, double> labelTimes;
+ std::set<std::string> labels;
// initialize maps
std::string::size_type maxlen = 0;
for(; it != this->TestList.end(); ++it)
@@ -702,7 +702,7 @@ void cmCTestTestHandler::PrintLabelSummary()
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:");
}
- for(std::set<cmStdString>::const_iterator i = labels.begin();
+ for(std::set<std::string>::const_iterator i = labels.begin();
i != labels.end(); ++i)
{
std::string label = *i;
@@ -1022,7 +1022,7 @@ bool cmCTestTestHandler::GetValue(const char* tag,
{
cmCTestLog(this->CTest, ERROR_MESSAGE,
"parse error: missing tag: "
- << tag << " found [" << line.c_str() << "]" << std::endl);
+ << tag << " found [" << line << "]" << std::endl);
ret = false;
}
return ret;
@@ -1050,8 +1050,8 @@ bool cmCTestTestHandler::GetValue(const char* tag,
}
//---------------------------------------------------------------------
-void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
- std::vector<cmStdString> &failed)
+void cmCTestTestHandler::ProcessDirectory(std::vector<std::string> &passed,
+ std::vector<std::string> &failed)
{
this->ComputeTestList();
this->StartTest = this->CTest->CurrentTime();
@@ -1216,14 +1216,14 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os)
<< "name=\"Command Line\"><Value>"
<< cmXMLSafe(result->FullCommandLine)
<< "</Value></NamedMeasurement>\n";
- std::map<cmStdString,cmStdString>::iterator measureIt;
+ std::map<std::string,std::string>::iterator measureIt;
for ( measureIt = result->Properties->Measurements.begin();
measureIt != result->Properties->Measurements.end();
++ measureIt )
{
os
<< "\t\t\t<NamedMeasurement type=\"text/string\" "
- << "name=\"" << measureIt->first.c_str() << "\"><Value>"
+ << "name=\"" << measureIt->first << "\"><Value>"
<< cmXMLSafe(measureIt->second)
<< "</Value></NamedMeasurement>\n";
}
@@ -1328,9 +1328,9 @@ void cmCTestTestHandler::AttachFiles(std::ostream& os,
}
//----------------------------------------------------------------------
-int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec)
+int cmCTestTestHandler::ExecuteCommands(std::vector<std::string>& vec)
{
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for ( it = vec.begin(); it != vec.end(); ++it )
{
int retVal = 0;
@@ -1506,7 +1506,7 @@ std::string cmCTestTestHandler
// then try with the exe extension
else
{
- failed.push_back(attempted[ai].c_str());
+ failed.push_back(attempted[ai]);
tempPath = attempted[ai];
tempPath += cmSystemTools::GetExecutableExtension();
if(cmSystemTools::FileExists(tempPath.c_str())
@@ -1517,7 +1517,7 @@ std::string cmCTestTestHandler
}
else
{
- failed.push_back(tempPath.c_str());
+ failed.push_back(tempPath);
}
}
}
@@ -1820,7 +1820,7 @@ void cmCTestTestHandler::ExpandTestsToRunInformationForRerunFailed()
else if ( !this->CTest->GetShowOnly() && !this->CTest->ShouldPrintLabels() )
{
cmCTestLog(this->CTest, ERROR_MESSAGE, "Problem reading file: "
- << lastTestsFailedLog.c_str() <<
+ << lastTestsFailedLog <<
" while generating list of previously failed tests." << std::endl);
}
}
@@ -1960,7 +1960,7 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
<< " " << k1 << "=\"" << v1 << "\""
<< " " << k2 << "=\"" << v2 << "\""
<< " encoding=\"none\""
- << "><Value>Image " << filename.c_str()
+ << "><Value>Image " << filename
<< " is empty</Value></NamedMeasurement>";
}
else
@@ -2014,10 +2014,10 @@ std::string cmCTestTestHandler::GenerateRegressionImages(
<< "\t\t\t<NamedMeasurement"
<< " name=\"" << measurementfile.match(idx) << "\""
<< " text=\"text/string\""
- << "><Value>File " << filename.c_str()
+ << "><Value>File " << filename
<< " not found</Value></NamedMeasurement>"
<< std::endl;
- cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename.c_str()
+ cmCTestLog(this->CTest, HANDLER_OUTPUT, "File \"" << filename
<< "\" not found." << std::endl);
}
cxml.erase(measurementfile.start(),
@@ -2112,7 +2112,7 @@ bool cmCTestTestHandler::SetTestsProperties(
const std::vector<std::string>& args)
{
std::vector<std::string>::const_iterator it;
- std::vector<cmStdString> tests;
+ std::vector<std::string> tests;
bool found = false;
for ( it = args.begin(); it != args.end(); ++ it )
{
@@ -2137,7 +2137,7 @@ bool cmCTestTestHandler::SetTestsProperties(
break;
}
std::string val = *it;
- std::vector<cmStdString>::const_iterator tit;
+ std::vector<std::string>::const_iterator tit;
for ( tit = tests.begin(); tit != tests.end(); ++ tit )
{
cmCTestTestHandler::ListOfTests::iterator rtit;
@@ -2154,7 +2154,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "ATTACHED_FILES" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
for(std::vector<std::string>::iterator f = lval.begin();
f != lval.end(); ++f)
@@ -2165,7 +2165,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "ATTACHED_FILES_ON_FAIL" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
for(std::vector<std::string>::iterator f = lval.begin();
f != lval.end(); ++f)
@@ -2176,7 +2176,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "RESOURCE_LOCK" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
for(std::vector<std::string>::iterator f = lval.begin();
f != lval.end(); ++f)
@@ -2196,7 +2196,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "REQUIRED_FILES" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
for(std::vector<std::string>::iterator f = lval.begin();
f != lval.end(); ++f)
@@ -2211,14 +2211,14 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "FAIL_REGULAR_EXPRESSION" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
rtit->ErrorRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(crit->c_str()),
- std::string(crit->c_str())));
+ std::string(*crit)));
}
}
if ( key == "PROCESSORS" )
@@ -2240,7 +2240,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "DEPENDS" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
@@ -2250,7 +2250,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "ENVIRONMENT" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
@@ -2260,7 +2260,7 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "LABELS" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
@@ -2284,14 +2284,14 @@ bool cmCTestTestHandler::SetTestsProperties(
if ( key == "PASS_REGULAR_EXPRESSION" )
{
std::vector<std::string> lval;
- cmSystemTools::ExpandListArgument(val.c_str(), lval);
+ cmSystemTools::ExpandListArgument(val, lval);
std::vector<std::string>::iterator crit;
for ( crit = lval.begin(); crit != lval.end(); ++ crit )
{
rtit->RequiredRegularExpressions.push_back(
std::pair<cmsys::RegularExpression, std::string>(
cmsys::RegularExpression(crit->c_str()),
- std::string(crit->c_str())));
+ std::string(*crit)));
}
}
if ( key == "WORKING_DIRECTORY" )
@@ -2319,7 +2319,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
}
if ( this->MemCheck )
{
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
bool found = false;
for ( it = this->CustomTestsIgnore.begin();
it != this->CustomTestsIgnore.end(); ++ it )
@@ -2339,7 +2339,7 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
}
else
{
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
bool found = false;
for ( it = this->CustomTestsIgnore.begin();
it != this->CustomTestsIgnore.end(); ++ it )
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 63f9c93..fe43bb8 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -87,8 +87,8 @@ public:
// ctest -j N will break for that feature
struct cmCTestTestProperties
{
- cmStdString Name;
- cmStdString Directory;
+ std::string Name;
+ std::string Directory;
std::vector<std::string> Args;
std::vector<std::string> RequiredFiles;
std::vector<std::string> Depends;
@@ -98,7 +98,7 @@ public:
std::string> > ErrorRegularExpressions;
std::vector<std::pair<cmsys::RegularExpression,
std::string> > RequiredRegularExpressions;
- std::map<cmStdString, cmStdString> Measurements;
+ std::map<std::string, std::string> Measurements;
bool IsInBasedOnREOptions;
bool WillFail;
float Cost;
@@ -162,7 +162,7 @@ protected:
virtual int PreProcessHandler();
virtual int PostProcessHandler();
virtual void GenerateTestCommand(std::vector<std::string>& args, int test);
- int ExecuteCommands(std::vector<cmStdString>& vec);
+ int ExecuteCommands(std::vector<std::string>& vec);
void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result);
void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result);
@@ -177,7 +177,7 @@ protected:
typedef std::vector<cmCTestTestResult> TestResultsVector;
TestResultsVector TestResults;
- std::vector<cmStdString> CustomTestsIgnore;
+ std::vector<std::string> CustomTestsIgnore;
std::string StartTest;
std::string EndTest;
unsigned int StartTestTime;
@@ -210,8 +210,8 @@ private:
/**
* Run the tests for a directory and any subdirectories
*/
- void ProcessDirectory(std::vector<cmStdString> &passed,
- std::vector<cmStdString> &failed);
+ void ProcessDirectory(std::vector<std::string> &passed,
+ std::vector<std::string> &failed);
/**
* Get the list of tests in directory and subdirectories.
@@ -251,8 +251,8 @@ private:
void ExpandTestsToRunInformation(size_t numPossibleTests);
void ExpandTestsToRunInformationForRerunFailed();
- std::vector<cmStdString> CustomPreTest;
- std::vector<cmStdString> CustomPostTest;
+ std::vector<std::string> CustomPreTest;
+ std::vector<std::string> CustomPostTest;
std::vector<int> TestsToRun;
diff --git a/Source/CTest/cmCTestUpdateCommand.h b/Source/CTest/cmCTestUpdateCommand.h
index a785bd8..fb80333 100644
--- a/Source/CTest/cmCTestUpdateCommand.h
+++ b/Source/CTest/cmCTestUpdateCommand.h
@@ -39,7 +39,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_update";}
+ virtual std::string GetName() const { return "ctest_update";}
cmTypeMacro(cmCTestUpdateCommand, cmCTestHandlerCommand);
diff --git a/Source/CTest/cmCTestUpdateHandler.cxx b/Source/CTest/cmCTestUpdateHandler.cxx
index 11474ec..fda61ea 100644
--- a/Source/CTest/cmCTestUpdateHandler.cxx
+++ b/Source/CTest/cmCTestUpdateHandler.cxx
@@ -331,7 +331,7 @@ int cmCTestUpdateHandler::DetectVCS(const char* dir)
{
std::string sourceDirectory = dir;
cmCTestLog(this->CTest, DEBUG, "Check directory: "
- << sourceDirectory.c_str() << std::endl);
+ << sourceDirectory << std::endl);
sourceDirectory += "/.svn";
if ( cmSystemTools::FileExists(sourceDirectory.c_str()) )
{
diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx
index 731c1c7..f7de294 100644
--- a/Source/CTest/cmCTestUploadCommand.cxx
+++ b/Source/CTest/cmCTestUploadCommand.cxx
@@ -47,7 +47,7 @@ bool cmCTestUploadCommand::CheckArgumentValue(std::string const& arg)
{
if(this->ArgumentDoing == ArgumentDoingFiles)
{
- cmStdString filename(arg);
+ std::string filename(arg);
if(cmSystemTools::FileExists(filename.c_str()))
{
this->Files.insert(filename);
diff --git a/Source/CTest/cmCTestUploadCommand.h b/Source/CTest/cmCTestUploadCommand.h
index e867fb6..4a07608 100644
--- a/Source/CTest/cmCTestUploadCommand.h
+++ b/Source/CTest/cmCTestUploadCommand.h
@@ -43,7 +43,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "ctest_upload";}
+ virtual std::string GetName() const { return "ctest_upload";}
cmTypeMacro(cmCTestUploadCommand, cmCTestHandlerCommand);
diff --git a/Source/CTest/cmCTestUploadHandler.cxx b/Source/CTest/cmCTestUploadHandler.cxx
index caf2e53..4c3f81b 100644
--- a/Source/CTest/cmCTestUploadHandler.cxx
+++ b/Source/CTest/cmCTestUploadHandler.cxx
@@ -64,7 +64,7 @@ int cmCTestUploadHandler::ProcessHandler()
for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
{
cmCTestLog(this->CTest, OUTPUT,
- "\tUpload file: " << it->c_str() << std::endl);
+ "\tUpload file: " << *it << std::endl);
ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n"
<< "<Content encoding=\"base64\">\n";
ofs << this->CTest->Base64EncodeFile(*it);
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index fbee227..f89fa2b 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -63,9 +63,9 @@ bool cmCTestVC::InitialCheckout(const char* command)
}
// Construct the initial checkout command line.
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+ std::vector<std::string> args = cmSystemTools::ParseArguments(command);
std::vector<char const*> vc_co;
- for(std::vector<cmStdString>::const_iterator ai = args.begin();
+ for(std::vector<std::string>::const_iterator ai = args.begin();
ai != args.end(); ++ai)
{
vc_co.push_back(ai->c_str());
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index 528d0db..5bcfeac 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -182,7 +182,7 @@ bool cmParseGTMCoverage::ParseMCOVLine(std::string const& line,
// ( file , entry ) = "number_executed:timing_info"
// ^COVERAGE("%RSEL","init",8,"FOR_LOOP",1)=1
// ( file , entry, line, IGNORE ) =number_executed
- std::vector<cmStdString> args;
+ std::vector<std::string> args;
std::string::size_type pos = line.find('(', 0);
// if no ( is found, then return line has no coverage
if(pos == std::string::npos)
diff --git a/Source/CTest/cmParseMumpsCoverage.cxx b/Source/CTest/cmParseMumpsCoverage.cxx
index 6226feb..6236211 100644
--- a/Source/CTest/cmParseMumpsCoverage.cxx
+++ b/Source/CTest/cmParseMumpsCoverage.cxx
@@ -122,7 +122,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
glob.RecurseOn();
std::string pat = d;
pat += "/*.m";
- glob.FindFiles(pat.c_str());
+ glob.FindFiles(pat);
std::vector<std::string>& files = glob.GetFiles();
std::vector<std::string>::iterator fileIt;
for ( fileIt = files.begin(); fileIt != files.end();
@@ -140,7 +140,7 @@ bool cmParseMumpsCoverage::LoadPackages(const char* d)
bool cmParseMumpsCoverage::FindMumpsFile(std::string const& routine,
std::string& filepath)
{
- std::map<cmStdString, cmStdString>::iterator i =
+ std::map<std::string, std::string>::iterator i =
this->RoutineToDirectory.find(routine);
if(i != this->RoutineToDirectory.end())
{
diff --git a/Source/CTest/cmParseMumpsCoverage.h b/Source/CTest/cmParseMumpsCoverage.h
index c1effa7..bc71891 100644
--- a/Source/CTest/cmParseMumpsCoverage.h
+++ b/Source/CTest/cmParseMumpsCoverage.h
@@ -44,7 +44,7 @@ protected:
bool FindMumpsFile(std::string const& routine,
std::string& filepath);
protected:
- std::map<cmStdString, cmStdString> RoutineToDirectory;
+ std::map<std::string, std::string> RoutineToDirectory;
cmCTestCoverageHandlerContainer& Coverage;
cmCTest* CTest;
};
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index 1c26c1c..3b7f968 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -34,7 +34,7 @@ bool cmParsePHPCoverage::ReadUntil(std::istream& in, char until)
return true;
}
bool cmParsePHPCoverage::ReadCoverageArray(std::istream& in,
- cmStdString const& fileName)
+ std::string const& fileName)
{
cmCTestCoverageHandlerContainer::SingleFileCoverageVector& coverageVector
= this->Coverage.TotalCoverage[fileName];
@@ -166,7 +166,7 @@ bool cmParsePHPCoverage::ReadFileInformation(std::istream& in)
// read the string data
in.read(s, size-1);
s[size-1] = 0;
- cmStdString fileName = s;
+ std::string fileName = s;
delete [] s;
// read close quote
if(in.get(c) && c != '"')
diff --git a/Source/CTest/cmParsePHPCoverage.h b/Source/CTest/cmParsePHPCoverage.h
index 035a093..92a7634 100644
--- a/Source/CTest/cmParsePHPCoverage.h
+++ b/Source/CTest/cmParsePHPCoverage.h
@@ -35,7 +35,7 @@ private:
bool ReadArraySize(std::istream& in, int& size);
bool ReadFileInformation(std::istream& in);
bool ReadInt(std::istream& in, int& v);
- bool ReadCoverageArray(std::istream& in, cmStdString const&);
+ bool ReadCoverageArray(std::istream& in, std::string const&);
bool ReadUntil(std::istream& in, char until);
cmCTestCoverageHandlerContainer& Coverage;
cmCTest* CTest;
diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx
index 38a770a..2578bb8 100644
--- a/Source/CTest/cmParsePythonCoverage.cxx
+++ b/Source/CTest/cmParsePythonCoverage.cxx
@@ -20,9 +20,9 @@ public:
protected:
- virtual void StartElement(const char* name, const char** atts)
+ virtual void StartElement(const std::string& name, const char** atts)
{
- if(strcmp(name, "class") == 0)
+ if(name == "class")
{
int tagCount = 0;
while(true)
@@ -57,7 +57,7 @@ protected:
++tagCount;
}
}
- else if(strcmp(name, "line") == 0)
+ else if(name == "line")
{
int tagCount = 0;
int curNumber = -1;
@@ -85,7 +85,7 @@ protected:
}
}
- virtual void EndElement(const char*) {}
+ virtual void EndElement(const std::string&) {}
private:
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index 249137f..682f95f 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -19,9 +19,10 @@
#include "cmCursesDummyWidget.h"
#include "../cmSystemTools.h"
-cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
- int labelwidth,
- int entrywidth) :
+cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
+ const std::string& key,
+ int labelwidth,
+ int entrywidth) :
Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
{
this->Label = new cmCursesLabelWidget(this->LabelWidth, 1, 1, 1, key);
@@ -31,7 +32,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(const char* key,
}
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
- const char* key, const cmCacheManager::CacheIterator& it, bool isNew,
+ const std::string& key, const cmCacheManager::CacheIterator& it, bool isNew,
int labelwidth, int entrywidth)
: Key(key), LabelWidth(labelwidth), EntryWidth(entrywidth)
{
@@ -50,7 +51,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
{
case cmCacheManager::BOOL:
this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1);
- if (cmSystemTools::IsOn(it.GetValue()))
+ if (cmSystemTools::IsOn(it.GetValue().c_str()))
{
static_cast<cmCursesBoolWidget*>(this->Entry)->SetValueAsBool(true);
}
@@ -93,7 +94,8 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
}
break;
case cmCacheManager::UNINITIALIZED:
- cmSystemTools::Error("Found an undefined variable: ", it.GetName());
+ cmSystemTools::Error("Found an undefined variable: ",
+ it.GetName().c_str());
break;
default:
// TODO : put warning message here
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.h b/Source/CursesDialog/cmCursesCacheEntryComposite.h
index 1357a02..98107cc 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.h
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.h
@@ -18,8 +18,9 @@
class cmCursesCacheEntryComposite
{
public:
- cmCursesCacheEntryComposite(const char* key, int labelwidth, int entrywidth);
- cmCursesCacheEntryComposite(const char* key,
+ cmCursesCacheEntryComposite(const std::string& key, int labelwidth,
+ int entrywidth);
+ cmCursesCacheEntryComposite(const std::string& key,
const cmCacheManager::CacheIterator& it,
bool isNew, int labelwidth, int entrywidth);
~cmCursesCacheEntryComposite();
diff --git a/Source/CursesDialog/cmCursesLabelWidget.cxx b/Source/CursesDialog/cmCursesLabelWidget.cxx
index b5ed312..b50eb64 100644
--- a/Source/CursesDialog/cmCursesLabelWidget.cxx
+++ b/Source/CursesDialog/cmCursesLabelWidget.cxx
@@ -19,7 +19,7 @@ cmCursesLabelWidget::cmCursesLabelWidget(int width, int height,
field_opts_off(this->Field, O_EDIT);
field_opts_off(this->Field, O_ACTIVE);
field_opts_off(this->Field, O_STATIC);
- this->SetValue(name.c_str());
+ this->SetValue(name);
}
cmCursesLabelWidget::~cmCursesLabelWidget()
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index d94cd37..0734927 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -84,9 +84,9 @@ cmCursesMainForm::~cmCursesMainForm()
}
// See if a cache entry is in the list of entries in the ui.
-bool cmCursesMainForm::LookForCacheEntry(const char* key)
+bool cmCursesMainForm::LookForCacheEntry(const std::string& key)
{
- if (!key || !this->Entries)
+ if (!this->Entries)
{
return false;
}
@@ -94,7 +94,7 @@ bool cmCursesMainForm::LookForCacheEntry(const char* key)
std::vector<cmCursesCacheEntryComposite*>::iterator it;
for (it = this->Entries->begin(); it != this->Entries->end(); ++it)
{
- if (!strcmp(key, (*it)->Key.c_str()))
+ if (key == (*it)->Key)
{
return true;
}
@@ -146,7 +146,7 @@ void cmCursesMainForm::InitializeUI()
this->CMakeInstance->GetCacheManager()->NewIterator();
!i.IsAtEnd(); i.Next())
{
- const char* key = i.GetName();
+ std::string key = i.GetName();
if ( i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED )
@@ -168,7 +168,7 @@ void cmCursesMainForm::InitializeUI()
this->CMakeInstance->GetCacheManager()->NewIterator();
!i.IsAtEnd(); i.Next())
{
- const char* key = i.GetName();
+ std::string key = i.GetName();
if ( i.GetType() == cmCacheManager::INTERNAL ||
i.GetType() == cmCacheManager::STATIC ||
i.GetType() == cmCacheManager::UNINITIALIZED )
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index 883a2b3..fba9bc5 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -51,7 +51,7 @@ public:
* Returns true if an entry with the given key is in the
* list of current composites.
*/
- bool LookForCacheEntry(const char* key);
+ bool LookForCacheEntry(const std::string& key);
enum {
MIN_WIDTH = 65,
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.cxx b/Source/CursesDialog/cmCursesOptionsWidget.cxx
index 652b2df..2f4b59e 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.cxx
+++ b/Source/CursesDialog/cmCursesOptionsWidget.cxx
@@ -59,7 +59,6 @@ bool cmCursesOptionsWidget::HandleInput(int& key, cmCursesMainForm*, WINDOW* w)
{
return false;
}
- return false;
}
void cmCursesOptionsWidget::AddOption(std::string const & option )
@@ -74,7 +73,7 @@ void cmCursesOptionsWidget::NextOption()
{
this->CurrentOption = 0;
}
- this->SetValue(this->Options[this->CurrentOption].c_str());
+ this->SetValue(this->Options[this->CurrentOption]);
}
void cmCursesOptionsWidget::PreviousOption()
{
@@ -86,10 +85,10 @@ void cmCursesOptionsWidget::PreviousOption()
{
this->CurrentOption--;
}
- this->SetValue(this->Options[this->CurrentOption].c_str());
+ this->SetValue(this->Options[this->CurrentOption]);
}
-void cmCursesOptionsWidget::SetOption(const char* value)
+void cmCursesOptionsWidget::SetOption(const std::string& value)
{
this->CurrentOption = 0; // default to 0 index
this->SetValue(value);
diff --git a/Source/CursesDialog/cmCursesOptionsWidget.h b/Source/CursesDialog/cmCursesOptionsWidget.h
index b52ac9d..5cee489 100644
--- a/Source/CursesDialog/cmCursesOptionsWidget.h
+++ b/Source/CursesDialog/cmCursesOptionsWidget.h
@@ -25,7 +25,7 @@ public:
// when this widget has focus. Returns true if the input was
// handled.
virtual bool HandleInput(int& key, cmCursesMainForm* fm, WINDOW* w);
- void SetOption(const char*);
+ void SetOption(const std::string&);
void AddOption(std::string const &);
void NextOption();
void PreviousOption();
diff --git a/Source/CursesDialog/cmCursesPathWidget.cxx b/Source/CursesDialog/cmCursesPathWidget.cxx
index 14c325b..cd93bc3 100644
--- a/Source/CursesDialog/cmCursesPathWidget.cxx
+++ b/Source/CursesDialog/cmCursesPathWidget.cxx
@@ -57,9 +57,9 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
{
glob = cstr + "*";
}
- std::vector<cmStdString> dirs;
+ std::vector<std::string> dirs;
- cmSystemTools::SimpleGlob(glob.c_str(), dirs, (this->Type == cmCacheManager::PATH?-1:0));
+ cmSystemTools::SimpleGlob(glob, dirs, (this->Type == cmCacheManager::PATH?-1:0));
if ( this->CurrentIndex < dirs.size() )
{
cstr = dirs[this->CurrentIndex];
@@ -74,7 +74,7 @@ void cmCursesPathWidget::OnTab(cmCursesMainForm* fm, WINDOW* w)
cstr += "/";
}
- this->SetString(cstr.c_str());
+ this->SetString(cstr);
touchwin(w);
wrefresh(w);
form_driver(form, REQ_END_FIELD);
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index bd1ff71..d25022d 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -195,7 +195,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
return true;
}
-void cmCursesStringWidget::SetString(const char* value)
+void cmCursesStringWidget::SetString(const std::string& value)
{
this->SetValue(value);
}
diff --git a/Source/CursesDialog/cmCursesStringWidget.h b/Source/CursesDialog/cmCursesStringWidget.h
index e939049..dd8c02a 100644
--- a/Source/CursesDialog/cmCursesStringWidget.h
+++ b/Source/CursesDialog/cmCursesStringWidget.h
@@ -37,7 +37,7 @@ public:
/**
* Set/Get the string.
*/
- void SetString(const char* value);
+ void SetString(const std::string& value);
const char* GetString();
virtual const char* GetValue();
diff --git a/Source/CursesDialog/cmCursesWidget.cxx b/Source/CursesDialog/cmCursesWidget.cxx
index 5dffcaa..e5363f4 100644
--- a/Source/CursesDialog/cmCursesWidget.cxx
+++ b/Source/CursesDialog/cmCursesWidget.cxx
@@ -46,10 +46,10 @@ void cmCursesWidget::Move(int x, int y, bool isNewPage)
}
}
-void cmCursesWidget::SetValue(const char* value)
+void cmCursesWidget::SetValue(const std::string& value)
{
this->Value = value;
- set_field_buffer(this->Field, 0, value);
+ set_field_buffer(this->Field, 0, value.c_str());
}
const char* cmCursesWidget::GetValue()
diff --git a/Source/CursesDialog/cmCursesWidget.h b/Source/CursesDialog/cmCursesWidget.h
index 952c67a..d91a0cb 100644
--- a/Source/CursesDialog/cmCursesWidget.h
+++ b/Source/CursesDialog/cmCursesWidget.h
@@ -40,7 +40,7 @@ public:
* Set/Get the value (setting the value also changes the contents
* of the field buffer).
*/
- virtual void SetValue(const char* value);
+ virtual void SetValue(const std::string& value);
virtual const char* GetValue();
/**
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 821121e..82fa3a3 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -14,6 +14,7 @@
#include <QDir>
#include <QTranslator>
#include <QLocale>
+#include <QTextCodec>
#include "QMacInstallDialog.h"
#include "CMakeSetupDialog.h"
#include "cmDocumentation.h"
@@ -78,6 +79,11 @@ int main(int argc, char** argv)
QApplication app(argc, argv);
+#if defined(CMAKE_ENCODING_UTF8)
+ QTextCodec* utf8_codec = QTextCodec::codecForName("UTF-8");
+ QTextCodec::setCodecForLocale(utf8_codec);
+#endif
+
// clean out standard Qt paths for plugins, which we don't use anyway
// when creating Mac bundles, it potentially causes problems
foreach(QString p, QApplication::libraryPaths())
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index f62afd6..1a98cea 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -578,7 +578,8 @@ void CMakeSetupDialog::doInterrupt()
void CMakeSetupDialog::doSourceBrowse()
{
QString dir = QFileDialog::getExistingDirectory(this,
- tr("Enter Path to Source"), this->SourceDirectory->text());
+ tr("Enter Path to Source"), this->SourceDirectory->text(),
+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(!dir.isEmpty())
{
this->setSourceDirectory(dir);
@@ -608,7 +609,8 @@ void CMakeSetupDialog::updateBinaryDirectory(const QString& dir)
void CMakeSetupDialog::doBinaryBrowse()
{
QString dir = QFileDialog::getExistingDirectory(this,
- tr("Enter Path to Build"), this->BinaryDirectory->currentText());
+ tr("Enter Path to Build"), this->BinaryDirectory->currentText(),
+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if(!dir.isEmpty() && dir != this->BinaryDirectory->currentText())
{
this->setBinaryDirectory(dir);
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index 0fe5f8c..5f9ebaf 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -111,13 +111,13 @@ void QCMake::setBinaryDirectory(const QString& _dir)
cmCacheManager::CacheIterator itm = cachem->NewIterator();
if ( itm.Find("CMAKE_HOME_DIRECTORY"))
{
- setSourceDirectory(QString::fromLocal8Bit(itm.GetValue()));
+ setSourceDirectory(QString::fromLocal8Bit(itm.GetValue().c_str()));
}
if ( itm.Find("CMAKE_GENERATOR"))
{
const char* extraGen = cachem->GetCacheValue("CMAKE_EXTRA_GENERATOR");
std::string curGen = cmExternalMakefileProjectGenerator::
- CreateFullGeneratorName(itm.GetValue(), extraGen);
+ CreateFullGeneratorName(itm.GetValue(), extraGen? extraGen : "");
this->setGenerator(QString::fromLocal8Bit(curGen.c_str()));
}
}
@@ -201,11 +201,11 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
}
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(i.GetName());
+ prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
int idx = props.indexOf(prop);
if(idx == -1)
{
- toremove.append(QString::fromLocal8Bit(i.GetName()));
+ toremove.append(QString::fromLocal8Bit(i.GetName().c_str()));
}
else
{
@@ -286,15 +286,15 @@ QCMakePropertyList QCMake::properties() const
}
QCMakeProperty prop;
- prop.Key = QString::fromLocal8Bit(i.GetName());
+ prop.Key = QString::fromLocal8Bit(i.GetName().c_str());
prop.Help = QString::fromLocal8Bit(i.GetProperty("HELPSTRING"));
- prop.Value = QString::fromLocal8Bit(i.GetValue());
+ prop.Value = QString::fromLocal8Bit(i.GetValue().c_str());
prop.Advanced = i.GetPropertyAsBool("ADVANCED");
if(i.GetType() == cmCacheManager::BOOL)
{
prop.Type = QCMakeProperty::BOOL;
- prop.Value = cmSystemTools::IsOn(i.GetValue());
+ prop.Value = cmSystemTools::IsOn(i.GetValue().c_str());
}
else if(i.GetType() == cmCacheManager::PATH)
{
diff --git a/Source/QtDialog/QCMakeWidgets.cxx b/Source/QtDialog/QCMakeWidgets.cxx
index a0c5e17..41f98b5 100644
--- a/Source/QtDialog/QCMakeWidgets.cxx
+++ b/Source/QtDialog/QCMakeWidgets.cxx
@@ -67,7 +67,8 @@ void QCMakeFilePathEditor::chooseFile()
title = title.arg(this->Variable);
}
this->fileDialogExists(true);
- path = QFileDialog::getOpenFileName(this, title, info.absolutePath());
+ path = QFileDialog::getOpenFileName(this, title, info.absolutePath(),
+ QString(), NULL, QFileDialog::DontResolveSymlinks);
this->fileDialogExists(false);
if(!path.isEmpty())
@@ -91,7 +92,8 @@ void QCMakePathEditor::chooseFile()
title = title.arg(this->Variable);
}
this->fileDialogExists(true);
- path = QFileDialog::getExistingDirectory(this, title, this->text());
+ path = QFileDialog::getExistingDirectory(this, title, this->text(),
+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
this->fileDialogExists(false);
if(!path.isEmpty())
{
diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h
index 38ed208..f147ec0 100644
--- a/Source/cmAddCompileOptionsCommand.h
+++ b/Source/cmAddCompileOptionsCommand.h
@@ -35,7 +35,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "add_compile_options";}
+ virtual std::string GetName() const {return "add_compile_options";}
cmTypeMacro(cmAddCompileOptionsCommand, cmCommand);
};
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index 3de04f5..d5f00ff 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -273,7 +273,7 @@ bool cmAddCustomCommandCommand
{
// Lookup an existing command.
if(cmSourceFile* sf =
- this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+ this->Makefile->GetSourceFileWithOutput(output[0]))
{
if(cmCustomCommand* cc = sf->GetCustomCommand())
{
@@ -286,9 +286,9 @@ bool cmAddCustomCommandCommand
// No command for this output exists.
cmOStringStream e;
- e << "given APPEND option with output \"" << output[0].c_str()
+ e << "given APPEND option with output \"" << output[0]
<< "\" which is not already a custom command output.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -305,7 +305,7 @@ bool cmAddCustomCommandCommand
{
// Source is empty, use the target.
std::vector<std::string> no_depends;
- this->Makefile->AddCustomCommandToTarget(target.c_str(), no_depends,
+ this->Makefile->AddCustomCommandToTarget(target, no_depends,
commandLines, cctype,
comment, working.c_str(),
escapeOldStyle);
@@ -314,7 +314,7 @@ bool cmAddCustomCommandCommand
{
// Target is empty, use the output.
this->Makefile->AddCustomCommandToOutput(output, depends,
- main_dependency.c_str(),
+ main_dependency,
commandLines, comment,
working.c_str(), false,
escapeOldStyle);
@@ -324,7 +324,7 @@ bool cmAddCustomCommandCommand
{
bool okay = false;
if(cmSourceFile* sf =
- this->Makefile->GetSourceFileWithOutput(output[0].c_str()))
+ this->Makefile->GetSourceFileWithOutput(output[0]))
{
if(cmCustomCommand* cc = sf->GetCustomCommand())
{
@@ -337,7 +337,7 @@ bool cmAddCustomCommandCommand
cmOStringStream 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().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -367,7 +367,7 @@ bool cmAddCustomCommandCommand
{
e << "The SOURCE signatures of add_custom_command are no longer "
"supported.";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
return false;
@@ -375,8 +375,8 @@ bool cmAddCustomCommandCommand
}
// Use the old-style mode for backward compatibility.
- this->Makefile->AddCustomCommandOldStyle(target.c_str(), outputs, depends,
- source.c_str(), commandLines,
+ this->Makefile->AddCustomCommandOldStyle(target, outputs, depends,
+ source, commandLines,
comment);
}
@@ -397,7 +397,7 @@ cmAddCustomCommandCommand
{
std::string e = "attempted to have a file \"" + *o +
"\" in a source directory as an output of custom command.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -409,7 +409,7 @@ cmAddCustomCommandCommand
cmOStringStream msg;
msg << "called with OUTPUT containing a \"" << (*o)[pos]
<< "\". This character is not allowed.";
- this->SetError(msg.str().c_str());
+ this->SetError(msg.str());
return false;
}
}
diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h
index 114957f..1d6ddb2 100644
--- a/Source/cmAddCustomCommandCommand.h
+++ b/Source/cmAddCustomCommandCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "add_custom_command";}
+ virtual std::string GetName() const {return "add_custom_command";}
cmTypeMacro(cmAddCustomCommandCommand, cmCommand);
protected:
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index e27d830..2fb0eb3 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -34,7 +34,7 @@ bool cmAddCustomTargetCommand
e << "called with invalid target name \"" << targetName
<< "\". Target names may not contain a slash. "
<< "Use ADD_CUSTOM_COMMAND to generate files.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -149,7 +149,7 @@ bool cmAddCustomTargetCommand
cmOStringStream msg;
msg << "called with target name containing a \"" << targetName[pos]
<< "\". This character is not allowed.";
- this->SetError(msg.str().c_str());
+ this->SetError(msg.str());
return false;
}
@@ -187,7 +187,7 @@ bool cmAddCustomTargetCommand
"\" is reserved or not valid for certain "
"CMake features, such as generator expressions, and may result "
"in undefined behavior.";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
@@ -208,7 +208,7 @@ bool cmAddCustomTargetCommand
std::string msg;
if(!this->Makefile->EnforceUniqueName(targetName, msg, true))
{
- this->SetError(msg.c_str());
+ this->SetError(msg);
return false;
}
}
@@ -224,7 +224,7 @@ bool cmAddCustomTargetCommand
// Add the utility target to the makefile.
bool escapeOldStyle = !verbatim;
cmTarget* target =
- this->Makefile->AddUtilityCommand(targetName.c_str(), excludeFromAll,
+ this->Makefile->AddUtilityCommand(targetName, excludeFromAll,
working_directory.c_str(), depends,
commandLines, escapeOldStyle, comment);
diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h
index d0fcdad..d2b00ad 100644
--- a/Source/cmAddCustomTargetCommand.h
+++ b/Source/cmAddCustomTargetCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const
+ virtual std::string GetName() const
{return "add_custom_target";}
cmTypeMacro(cmAddCustomTargetCommand, cmCommand);
diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h
index d05f187..9800fd2 100644
--- a/Source/cmAddDefinitionsCommand.h
+++ b/Source/cmAddDefinitionsCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "add_definitions";}
+ virtual std::string GetName() const {return "add_definitions";}
cmTypeMacro(cmAddDefinitionsCommand, cmCommand);
};
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index b55334f..e897d81 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -38,7 +38,7 @@ bool cmAddDependenciesCommand
cmOStringStream e;
e << "Cannot add target-level dependencies to INTERFACE library "
"target \"" << target_name << "\".\n";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -46,7 +46,7 @@ bool cmAddDependenciesCommand
++s; // skip over target_name
for (; s != args.end(); ++s)
{
- target->AddUtility(s->c_str(), this->Makefile);
+ target->AddUtility(*s, this->Makefile);
}
}
else
diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h
index 247cc54..db3712a 100644
--- a/Source/cmAddDependenciesCommand.h
+++ b/Source/cmAddDependenciesCommand.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_dependencies";}
+ virtual std::string GetName() const { return "add_dependencies";}
cmTypeMacro(cmAddDependenciesCommand, cmCommand);
};
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 3f9400e..c30e764 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -101,7 +101,7 @@ bool cmAddExecutableCommand
"\" is reserved or not valid for certain "
"CMake features, such as generator expressions, and may result "
"in undefined behavior.";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
@@ -132,9 +132,9 @@ bool cmAddExecutableCommand
}
if (isAlias)
{
- if(!cmGeneratorExpression::IsValidTargetName(exename.c_str()))
+ if(!cmGeneratorExpression::IsValidTargetName(exename))
{
- this->SetError(("Invalid name for ALIAS: " + exename).c_str());
+ this->SetError("Invalid name for ALIAS: " + exename);
return false;
}
if(excludeFromAll)
@@ -151,7 +151,7 @@ bool cmAddExecutableCommand
{
cmOStringStream e;
e << "ALIAS requires exactly one target argument.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -161,7 +161,7 @@ bool cmAddExecutableCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmTarget *aliasedTarget =
@@ -172,7 +172,7 @@ bool cmAddExecutableCommand
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" does not already "
"exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmTarget::TargetType type = aliasedTarget->GetType();
@@ -182,7 +182,7 @@ bool cmAddExecutableCommand
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" is not an "
"executable.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if(aliasedTarget->IsImported())
@@ -190,10 +190,10 @@ bool cmAddExecutableCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << exename
<< "\" because target \"" << aliasedName << "\" is IMPORTED.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- this->Makefile->AddAlias(exename.c_str(), aliasedTarget);
+ this->Makefile->AddAlias(exename, aliasedTarget);
return true;
}
@@ -206,12 +206,12 @@ bool cmAddExecutableCommand
cmOStringStream e;
e << "cannot create imported target \"" << exename
<< "\" because another target with the same name already exists.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Create the imported target.
- this->Makefile->AddImportedTarget(exename.c_str(), cmTarget::EXECUTABLE,
+ this->Makefile->AddImportedTarget(exename, cmTarget::EXECUTABLE,
importGlobal);
return true;
}
@@ -221,7 +221,7 @@ bool cmAddExecutableCommand
std::string msg;
if(!this->Makefile->EnforceUniqueName(exename, msg))
{
- this->SetError(msg.c_str());
+ this->SetError(msg);
return false;
}
}
diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h
index 30ecce3..e134077 100644
--- a/Source/cmAddExecutableCommand.h
+++ b/Source/cmAddExecutableCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_executable";}
+ virtual std::string GetName() const { return "add_executable";}
cmTypeMacro(cmAddExecutableCommand, cmCommand);
};
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index e62a40e..cdc9f2a 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -53,7 +53,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting STATIC type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -66,7 +66,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting SHARED type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -79,7 +79,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting MODULE type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -92,7 +92,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting OBJECT type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -105,7 +105,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting UNKNOWN type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -118,7 +118,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -130,21 +130,21 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting/multiple types.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if (isAlias)
{
cmOStringStream e;
e << "INTERFACE library specified with conflicting ALIAS type.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if (excludeFromAll)
{
cmOStringStream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -157,7 +157,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
++s;
@@ -177,7 +177,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "GLOBAL option may only be used with IMPORTED libraries.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
else
@@ -192,14 +192,14 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "INTERFACE library requires no source arguments.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if (importGlobal && !importTarget)
{
cmOStringStream e;
e << "INTERFACE library specified as GLOBAL, but not as IMPORTED.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -239,7 +239,7 @@ bool cmAddLibraryCommand
"\" is reserved or not valid for certain "
"CMake features, such as generator expressions, and may result "
"in undefined behavior.";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
@@ -250,9 +250,9 @@ bool cmAddLibraryCommand
if (isAlias)
{
- if(!cmGeneratorExpression::IsValidTargetName(libName.c_str()))
+ if(!cmGeneratorExpression::IsValidTargetName(libName))
{
- this->SetError(("Invalid name for ALIAS: " + libName).c_str());
+ this->SetError("Invalid name for ALIAS: " + libName);
return false;
}
if(excludeFromAll)
@@ -269,7 +269,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "ALIAS requires exactly one target argument.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -279,7 +279,7 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is itself an ALIAS.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmTarget *aliasedTarget =
@@ -290,7 +290,7 @@ bool cmAddLibraryCommand
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" does not already "
"exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmTarget::TargetType aliasedType = aliasedTarget->GetType();
@@ -303,7 +303,7 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is not a library.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
if(aliasedTarget->IsImported())
@@ -311,10 +311,10 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create ALIAS target \"" << libName
<< "\" because target \"" << aliasedName << "\" is IMPORTED.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- this->Makefile->AddAlias(libName.c_str(), aliasedTarget);
+ this->Makefile->AddAlias(libName, aliasedTarget);
return true;
}
@@ -367,7 +367,7 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -378,12 +378,12 @@ bool cmAddLibraryCommand
cmOStringStream e;
e << "cannot create imported target \"" << libName
<< "\" because another target with the same name already exists.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Create the imported target.
- this->Makefile->AddImportedTarget(libName.c_str(), type, importGlobal);
+ this->Makefile->AddImportedTarget(libName, type, importGlobal);
return true;
}
@@ -402,7 +402,7 @@ bool cmAddLibraryCommand
std::string msg;
if(!this->Makefile->EnforceUniqueName(libName, msg))
{
- this->SetError(msg.c_str());
+ this->SetError(msg);
return false;
}
}
@@ -416,11 +416,11 @@ bool cmAddLibraryCommand
{
cmOStringStream e;
e << "Invalid name for INTERFACE library target: " << libName;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- this->Makefile->AddLibrary(libName.c_str(),
+ this->Makefile->AddLibrary(libName,
type,
srclists,
excludeFromAll);
@@ -442,7 +442,7 @@ bool cmAddLibraryCommand
++s;
}
- this->Makefile->AddLibrary(libName.c_str(), type, srclists, excludeFromAll);
+ this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll);
return true;
}
diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h
index 1001043..350708b 100644
--- a/Source/cmAddLibraryCommand.h
+++ b/Source/cmAddLibraryCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_library";}
+ virtual std::string GetName() const { return "add_library";}
cmTypeMacro(cmAddLibraryCommand, cmCommand);
};
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 5b1c9c6..4ea2524 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -66,7 +66,7 @@ bool cmAddSubDirectoryCommand::InitialPass
std::string error = "given source \"";
error += srcArg;
error += "\" which is not an existing directory.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
srcPath = cmSystemTools::CollapseFullPath(srcPath.c_str());
@@ -87,7 +87,7 @@ bool cmAddSubDirectoryCommand::InitialPass
<< this->Makefile->GetCurrentDirectory() << "\". "
<< "When specifying an out-of-tree source a binary directory "
<< "must be explicitly specified.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -121,7 +121,7 @@ bool cmAddSubDirectoryCommand::InitialPass
binPath = cmSystemTools::CollapseFullPath(binPath.c_str());
// Add the subdirectory using the computed full paths.
- this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
+ this->Makefile->AddSubDirectory(srcPath, binPath,
excludeFromAll, false, true);
return true;
diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h
index 1e5b1ab..abf3efc 100644
--- a/Source/cmAddSubDirectoryCommand.h
+++ b/Source/cmAddSubDirectoryCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_subdirectory";}
+ virtual std::string GetName() const { return "add_subdirectory";}
cmTypeMacro(cmAddSubDirectoryCommand, cmCommand);
};
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index a9165f5..2531a1a 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -44,7 +44,7 @@ bool cmAddTestCommand
// Create the test but add a generator only the first time it is
// seen. This preserves behavior from before test generators.
- cmTest* test = this->Makefile->GetTest(args[0].c_str());
+ cmTest* test = this->Makefile->GetTest(args[0]);
if(test)
{
// If the test was already added by a new-style signature do not
@@ -54,13 +54,13 @@ bool cmAddTestCommand
cmOStringStream e;
e << " given test name \"" << args[0]
<< "\" which already exists in this directory.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
else
{
- test = this->Makefile->CreateTest(args[0].c_str());
+ test = this->Makefile->CreateTest(args[0]);
test->SetOldStyle(true);
this->Makefile->AddTestGenerator(new cmTestGenerator(test));
}
@@ -137,7 +137,7 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
{
cmOStringStream e;
e << " given unknown argument:\n " << args[i] << "\n";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -157,17 +157,17 @@ bool cmAddTestCommand::HandleNameMode(std::vector<std::string> const& args)
}
// Require a unique test name within the directory.
- if(this->Makefile->GetTest(name.c_str()))
+ if(this->Makefile->GetTest(name))
{
cmOStringStream e;
e << " given test NAME \"" << name
<< "\" which already exists in this directory.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Add the test.
- cmTest* test = this->Makefile->CreateTest(name.c_str());
+ cmTest* test = this->Makefile->CreateTest(name);
test->SetOldStyle(false);
test->SetCommand(command);
if(!working_directory.empty())
diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h
index 9173454..624288f 100644
--- a/Source/cmAddTestCommand.h
+++ b/Source/cmAddTestCommand.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "add_test";}
+ virtual std::string GetName() const { return "add_test";}
cmTypeMacro(cmAddTestCommand, cmCommand);
private:
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 01f64b7..d8c3c43 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -40,7 +40,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass
}
// was the list already populated
- const char *def = this->Makefile->GetDefinition(args[1].c_str());
+ const char *def = this->Makefile->GetDefinition(args[1]);
if (def)
{
sourceListValue = def;
@@ -72,7 +72,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass
// add the file as a class file so
// depends can be done
cmSourceFile* sf =
- this->Makefile->GetOrCreateSource(fullname.c_str());
+ this->Makefile->GetOrCreateSource(fullname);
sf->SetProperty("ABSTRACT","0");
if(!sourceListValue.empty())
{
@@ -83,7 +83,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass
}
}
}
- this->Makefile->AddDefinition(args[1].c_str(), sourceListValue.c_str());
+ this->Makefile->AddDefinition(args[1], sourceListValue.c_str());
return true;
}
diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h
index 8b5fa8a..6615273 100644
--- a/Source/cmAuxSourceDirectoryCommand.h
+++ b/Source/cmAuxSourceDirectoryCommand.h
@@ -44,7 +44,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "aux_source_directory";}
+ virtual std::string GetName() const { return "aux_source_directory";}
cmTypeMacro(cmAuxSourceDirectoryCommand, cmCommand);
};
diff --git a/Source/cmBreakCommand.h b/Source/cmBreakCommand.h
index 52f0e9c..1fcae50 100644
--- a/Source/cmBreakCommand.h
+++ b/Source/cmBreakCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "break";}
+ virtual std::string GetName() const {return "break";}
cmTypeMacro(cmBreakCommand, cmCommand);
};
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index c06b8ad..93f7801 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -44,7 +44,7 @@ bool cmBuildCommand
// Parse remaining arguments.
const char* configuration = 0;
const char* project_name = 0;
- const char* target = 0;
+ std::string target;
enum Doing { DoingNone, DoingConfiguration, DoingProjectName, DoingTarget };
Doing doing = DoingNone;
for(unsigned int i=1; i < args.size(); ++i)
@@ -74,13 +74,13 @@ bool cmBuildCommand
else if(doing == DoingTarget)
{
doing = DoingNone;
- target = args[i].c_str();
+ target = args[i];
}
else
{
cmOStringStream e;
e << "unknown argument \"" << args[i] << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -107,7 +107,7 @@ bool cmBuildCommand
std::string makecommand = this->Makefile->GetLocalGenerator()
->GetGlobalGenerator()->GenerateCMakeBuildCommand(target, configuration,
- 0, true);
+ "", true);
this->Makefile->AddDefinition(variable, makecommand.c_str());
@@ -136,8 +136,8 @@ bool cmBuildCommand
}
std::string makecommand = this->Makefile->GetLocalGenerator()
- ->GetGlobalGenerator()->GenerateCMakeBuildCommand(0, configType.c_str(),
- 0, true);
+ ->GetGlobalGenerator()->GenerateCMakeBuildCommand("", configType,
+ "", true);
if(cacheValue)
{
diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h
index 2160655..3fb618f 100644
--- a/Source/cmBuildCommand.h
+++ b/Source/cmBuildCommand.h
@@ -50,7 +50,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "build_command";}
+ virtual std::string GetName() const {return "build_command";}
cmTypeMacro(cmBuildCommand, cmCommand);
};
diff --git a/Source/cmBuildNameCommand.cxx b/Source/cmBuildNameCommand.cxx
index e3528e1..c64209f 100644
--- a/Source/cmBuildNameCommand.cxx
+++ b/Source/cmBuildNameCommand.cxx
@@ -25,7 +25,7 @@ bool cmBuildNameCommand
this->SetError("called with incorrect number of arguments");
return false;
}
- const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str());
+ const char* cacheValue = this->Makefile->GetDefinition(args[0]);
if(cacheValue)
{
// do we need to correct the value?
@@ -36,7 +36,7 @@ bool cmBuildNameCommand
cmSystemTools::ReplaceString(cv,"/", "_");
cmSystemTools::ReplaceString(cv,"(", "_");
cmSystemTools::ReplaceString(cv,")", "_");
- this->Makefile->AddCacheDefinition(args[0].c_str(),
+ this->Makefile->AddCacheDefinition(args[0],
cv.c_str(),
"Name of build.",
cmCacheManager::STRING);
@@ -71,7 +71,7 @@ bool cmBuildNameCommand
cmSystemTools::ReplaceString(buildname,
")", "_");
- this->Makefile->AddCacheDefinition(args[0].c_str(),
+ this->Makefile->AddCacheDefinition(args[0],
buildname.c_str(),
"Name of build.",
cmCacheManager::STRING);
diff --git a/Source/cmBuildNameCommand.h b/Source/cmBuildNameCommand.h
index 2f7acde..8f8038f 100644
--- a/Source/cmBuildNameCommand.h
+++ b/Source/cmBuildNameCommand.h
@@ -21,7 +21,7 @@ public:
virtual cmCommand* Clone() { return new cmBuildNameCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const {return "build_name";}
+ virtual std::string GetName() const {return "build_name";}
virtual bool IsScriptable() const { return true; }
virtual bool IsDiscouraged() const { return true; }
};
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 62f2383..5234538 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -53,7 +53,7 @@ bool cmCMakeHostSystemInformationCommand
result_list += value;
}
- this->Makefile->AddDefinition(variable.c_str(), result_list.c_str());
+ this->Makefile->AddDefinition(variable, result_list.c_str());
return true;
}
@@ -97,7 +97,7 @@ bool cmCMakeHostSystemInformationCommand
else
{
std::string e = "does not recognize <key> " + key;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
diff --git a/Source/cmCMakeHostSystemInformationCommand.h b/Source/cmCMakeHostSystemInformationCommand.h
index 27ba638..463b180 100644
--- a/Source/cmCMakeHostSystemInformationCommand.h
+++ b/Source/cmCMakeHostSystemInformationCommand.h
@@ -48,7 +48,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const
+ virtual std::string GetName() const
{
return "cmake_host_system_information";
}
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index 6e2ca64..58b61de 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -79,8 +79,8 @@ bool cmCMakeMinimumRequired
&required_patch, &required_tweak) < 2)
{
cmOStringStream e;
- e << "could not parse VERSION \"" << version_string.c_str() << "\".";
- this->SetError(e.str().c_str());
+ e << "could not parse VERSION \"" << version_string << "\".";
+ this->SetError(e.str());
return false;
}
@@ -98,7 +98,7 @@ bool cmCMakeMinimumRequired
{
// The current version is too low.
cmOStringStream e;
- e << "CMake " << version_string.c_str()
+ e << "CMake " << version_string
<< " or higher is required. You are running version "
<< cmVersion::GetCMakeVersion();
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
@@ -135,7 +135,7 @@ bool cmCMakeMinimumRequired::EnforceUnknownArguments()
cmOStringStream e;
e << "called with unknown argument \""
<< this->UnknownArguments[0] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
return true;
diff --git a/Source/cmCMakeMinimumRequired.h b/Source/cmCMakeMinimumRequired.h
index 0cdd4c5..31b7271 100644
--- a/Source/cmCMakeMinimumRequired.h
+++ b/Source/cmCMakeMinimumRequired.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "cmake_minimum_required";}
+ virtual std::string GetName() const {return "cmake_minimum_required";}
cmTypeMacro(cmCMakeMinimumRequired, cmCommand);
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index f4be559..ddd5d6a 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -58,7 +58,7 @@ bool cmCMakePolicyCommand
cmOStringStream e;
e << "given unknown first argument \"" << args[0] << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -84,7 +84,7 @@ bool cmCMakePolicyCommand::HandleSetMode(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "SET given unrecognized policy status \"" << args[2] << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -116,7 +116,7 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "GET given policy \"" << id << "\" which is not known to this "
<< "version of CMake.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -126,15 +126,15 @@ bool cmCMakePolicyCommand::HandleGetMode(std::vector<std::string> const& args)
{
case cmPolicies::OLD:
// Report that the policy is set to OLD.
- this->Makefile->AddDefinition(var.c_str(), "OLD");
+ this->Makefile->AddDefinition(var, "OLD");
break;
case cmPolicies::WARN:
// Report that the policy is not set.
- this->Makefile->AddDefinition(var.c_str(), "");
+ this->Makefile->AddDefinition(var, "");
break;
case cmPolicies::NEW:
// Report that the policy is set to NEW.
- this->Makefile->AddDefinition(var.c_str(), "NEW");
+ this->Makefile->AddDefinition(var, "NEW");
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
diff --git a/Source/cmCMakePolicyCommand.h b/Source/cmCMakePolicyCommand.h
index 7e3f4e6..8dc8fbe 100644
--- a/Source/cmCMakePolicyCommand.h
+++ b/Source/cmCMakePolicyCommand.h
@@ -46,7 +46,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "cmake_policy";}
+ virtual std::string GetName() const {return "cmake_policy";}
cmTypeMacro(cmCMakePolicyCommand, cmCommand);
private:
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index cb62f21..dd2a1b8 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -557,9 +557,9 @@ void CCONV *cmGetSource(void *arg, const char *name)
sf->RealSourceFile = rsf;
sf->FullPath = rsf->GetFullPath();
sf->SourceName =
- cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath.c_str());
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->FullPath);
sf->SourceExtension =
- cmSystemTools::GetFilenameLastExtension(sf->FullPath.c_str());
+ cmSystemTools::GetFilenameLastExtension(sf->FullPath);
// Store the proxy in the map so it can be re-used and deleted later.
cmCPluginAPISourceFileMap::value_type entry(rsf, sf);
@@ -583,7 +583,7 @@ void * CCONV cmAddSource(void *arg, void *arg2)
}
// Create the real cmSourceFile instance and copy over saved information.
- cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath.c_str());
+ cmSourceFile* rsf = mf->GetOrCreateSource(osf->FullPath);
rsf->GetProperties() = osf->Properties;
for(std::vector<std::string>::iterator i = osf->Depends.begin();
i != osf->Depends.end(); ++i)
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index acedc1a..d797d3b 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -78,7 +78,7 @@ struct tm* cmCTest::GetNightlyTime(std::string str,
lctime->tm_mday,
str.c_str());
cmCTestLog(this, OUTPUT, "Determine Nightly Start Time" << std::endl
- << " Specified time: " << str.c_str() << std::endl);
+ << " Specified time: " << str << std::endl);
//Convert the nightly start time to seconds. Since we are
//providing only a time and a timezone, the current date of
//the local machine is assumed. Consequently, nightlySeconds
@@ -217,8 +217,6 @@ int cmCTest::HTTPRequest(std::string url, HTTPMethod method,
url += "?" + fields;
}
break;
- default:
- break;
}
::curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
@@ -649,8 +647,8 @@ int cmCTest::Initialize(const char* binary_dir, cmCTestStartCommand* command)
bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{
std::string src_dir
- = this->GetCTestConfiguration("SourceDirectory").c_str();
- std::string bld_dir = this->GetCTestConfiguration("BuildDirectory").c_str();
+ = this->GetCTestConfiguration("SourceDirectory");
+ std::string bld_dir = this->GetCTestConfiguration("BuildDirectory");
this->DartVersion = 1;
this->DropSiteCDash = false;
for(Part p = PartStart; p != PartCount; p = Part(p+1))
@@ -681,14 +679,14 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
if ( !fname.empty() )
{
cmCTestLog(this, OUTPUT, " Reading ctest configuration file: "
- << fname.c_str() << std::endl);
+ << fname << std::endl);
bool readit = mf->ReadListFile(mf->GetCurrentListFile(),
fname.c_str() );
if(!readit)
{
std::string m = "Could not find include file: ";
m += fname;
- command->SetError(m.c_str());
+ command->SetError(m);
return false;
}
}
@@ -696,10 +694,10 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command)
{
cmCTestLog(this, WARNING,
"Cannot locate CTest configuration: in BuildDirectory: "
- << bld_dir_fname.c_str() << std::endl);
+ << bld_dir_fname << std::endl);
cmCTestLog(this, WARNING,
"Cannot locate CTest configuration: in SourceDirectory: "
- << src_dir_fname.c_str() << std::endl);
+ << src_dir_fname << std::endl);
}
this->SetCTestConfigurationFromCMakeVariable(mf, "NightlyStartTime",
@@ -748,13 +746,13 @@ bool cmCTest::UpdateCTestConfiguration()
}
}
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "UpdateCTestConfiguration from :"
- << fileName.c_str() << "\n");
+ << fileName << "\n");
if ( !cmSystemTools::FileExists(fileName.c_str()) )
{
// No need to exit if we are not producing XML
if ( this->ProduceXML )
{
- cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName.c_str()
+ cmCTestLog(this, ERROR_MESSAGE, "Cannot find file: " << fileName
<< std::endl);
return false;
}
@@ -762,7 +760,7 @@ bool cmCTest::UpdateCTestConfiguration()
else
{
cmCTestLog(this, HANDLER_VERBOSE_OUTPUT, "Parse Config file:"
- << fileName.c_str() << "\n");
+ << fileName << "\n");
// parse the dart test file
cmsys::ifstream fin(fileName.c_str());
@@ -930,7 +928,7 @@ bool cmCTest::AddIfExists(Part part, const char* file)
{
std::string name = file;
name += ".gz";
- if ( this->CTestFileExists(name.c_str()) )
+ if ( this->CTestFileExists(name) )
{
this->AddSubmitFile(part, file);
}
@@ -1153,7 +1151,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
int* retVal, const char* dir, int timeout, std::ostream& ofs)
{
// First generate the command and arguments
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+ std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if(args.size() < 1)
{
@@ -1161,7 +1159,7 @@ int cmCTest::RunMakeCommand(const char* command, std::string* output,
}
std::vector<const char*> argv;
- for(std::vector<cmStdString>::const_iterator a = args.begin();
+ for(std::vector<std::string>::const_iterator a = args.begin();
a != args.end(); ++a)
{
argv.push_back(a->c_str());
@@ -1346,7 +1344,7 @@ int cmCTest::RunTest(std::vector<const char*> argv,
*output += oss.str();
if ( log )
{
- *log << output->c_str();
+ *log << *output;
}
cmSystemTools::ChangeDirectory(oldpath.c_str());
@@ -1562,7 +1560,7 @@ void cmCTest::AddSiteProperties(std::ostream& ostr)
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
{
- ostr << " <Label>" << i->c_str() << "</Label>\n";
+ ostr << " <Label>" << *i << "</Label>\n";
}
ostr << " </Labels>\n";
}
@@ -1606,7 +1604,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os,
for ( it = files.begin(); it != files.end(); it ++ )
{
- cmCTestLog(this, OUTPUT, "\tAdd file: " << it->c_str() << std::endl);
+ cmCTestLog(this, OUTPUT, "\tAdd file: " << *it << std::endl);
std::string note_time = this->CurrentTime();
os << "<Note Name=\"" << cmXMLSafe(*it) << "\">\n"
<< "<Time>" << cmSystemTools::GetTime() << "</Time>\n"
@@ -1624,8 +1622,8 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os,
}
else
{
- os << "Problem reading file: " << it->c_str() << std::endl;
- cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << it->c_str()
+ os << "Problem reading file: " << *it << std::endl;
+ cmCTestLog(this, ERROR_MESSAGE, "Problem reading file: " << *it
<< " while creating notes" << std::endl);
}
os << "</Text>\n"
@@ -1637,7 +1635,7 @@ int cmCTest::GenerateCTestNotesOutput(std::ostream& os,
}
//----------------------------------------------------------------------
-int cmCTest::GenerateNotesFile(const std::vector<cmStdString> &files)
+int cmCTest::GenerateNotesFile(const VectorOfStrings &files)
{
cmGeneratedFileStream ofs;
if ( !this->OpenOutputFile(this->CurrentTag, "Notes.xml", ofs) )
@@ -1658,7 +1656,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles)
return 1;
}
- std::vector<cmStdString> files;
+ VectorOfStrings files;
cmCTestLog(this, OUTPUT, "Create notes file" << std::endl);
@@ -1675,7 +1673,7 @@ int cmCTest::GenerateNotesFile(const char* cfiles)
std::string cmCTest::Base64GzipEncodeFile(std::string file)
{
std::string tarFile = file + "_temp.tar.gz";
- std::vector<cmStdString> files;
+ std::vector<std::string> files;
files.push_back(file);
if(!cmSystemTools::CreateTar(tarFile.c_str(), files, true, false, false))
@@ -1722,9 +1720,9 @@ std::string cmCTest::Base64EncodeFile(std::string file)
//----------------------------------------------------------------------
-bool cmCTest::SubmitExtraFiles(const std::vector<cmStdString> &files)
+bool cmCTest::SubmitExtraFiles(const VectorOfStrings &files)
{
- std::vector<cmStdString>::const_iterator it;
+ VectorOfStrings::const_iterator it;
for ( it = files.begin();
it != files.end();
++ it )
@@ -1732,7 +1730,7 @@ bool cmCTest::SubmitExtraFiles(const std::vector<cmStdString> &files)
if ( !cmSystemTools::FileExists(it->c_str()) )
{
cmCTestLog(this, ERROR_MESSAGE, "Cannot find extra file: "
- << it->c_str() << " to submit."
+ << *it << " to submit."
<< std::endl;);
return false;
}
@@ -1749,7 +1747,7 @@ bool cmCTest::SubmitExtraFiles(const char* cfiles)
return 1;
}
- std::vector<cmStdString> files;
+ VectorOfStrings files;
cmCTestLog(this, OUTPUT, "Submit extra files" << std::endl);
@@ -2126,7 +2124,7 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
if(this->CheckArgument(arg, "--overwrite") && i < args.size() - 1)
{
i++;
- this->AddCTestConfigurationOverwrite(args[i].c_str());
+ this->AddCTestConfigurationOverwrite(args[i]);
}
if(this->CheckArgument(arg, "-A", "--add-notes") && i < args.size() - 1)
{
@@ -2246,7 +2244,7 @@ bool cmCTest::AddVariableDefinition(const std::string &arg)
std::string value;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
- if (cmCacheManager::ParseEntry(arg.c_str(), name, value, type))
+ if (cmCacheManager::ParseEntry(arg, name, value, type))
{
this->Definitions[name] = value;
return true;
@@ -2319,7 +2317,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
executeTests = false;
cmCTestLog(this, ERROR_MESSAGE,
"CTest -T called with incorrect option: "
- << args[i].c_str() << std::endl);
+ << args[i] << std::endl);
cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
<< " " << ctestExec << " -T all" << std::endl
<< " " << ctestExec << " -T start" << std::endl
@@ -2356,7 +2354,7 @@ int cmCTest::Run(std::vector<std::string> &args, std::string* output)
{
executeTests = false;
cmCTestLog(this, ERROR_MESSAGE,
- "CTest -M called with incorrect option: " << str.c_str()
+ "CTest -M called with incorrect option: " << str
<< std::endl);
cmCTestLog(this, ERROR_MESSAGE, "Available options are:" << std::endl
<< " " << ctestExec << " -M Continuous" << std::endl
@@ -2527,11 +2525,11 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
std::string fname = dir;
fname += "/CTestCustom.cmake";
cmCTestLog(this, DEBUG, "* Check for file: "
- << fname.c_str() << std::endl);
+ << fname << std::endl);
if ( cmSystemTools::FileExists(fname.c_str()) )
{
cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
- << fname.c_str() << std::endl);
+ << fname << std::endl);
bool erroroc = cmSystemTools::GetErrorOccuredFlag();
cmSystemTools::ResetErrorOccuredFlag();
@@ -2540,7 +2538,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
{
cmCTestLog(this, ERROR_MESSAGE,
"Problem reading custom configuration: "
- << fname.c_str() << std::endl);
+ << fname << std::endl);
}
found = true;
if ( erroroc )
@@ -2552,7 +2550,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
std::string rexpr = dir;
rexpr += "/CTestCustom.ctest";
cmCTestLog(this, DEBUG, "* Check for file: "
- << rexpr.c_str() << std::endl);
+ << rexpr << std::endl);
if ( !found && cmSystemTools::FileExists(rexpr.c_str()) )
{
cmsys::Glob gl;
@@ -2564,13 +2562,13 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
++ fileIt )
{
cmCTestLog(this, DEBUG, "* Read custom CTest configuration file: "
- << fileIt->c_str() << std::endl);
+ << *fileIt << std::endl);
if ( !mf->ReadListFile(0, fileIt->c_str()) ||
cmSystemTools::GetErrorOccuredFlag() )
{
cmCTestLog(this, ERROR_MESSAGE,
"Problem reading custom configuration: "
- << fileIt->c_str() << std::endl);
+ << *fileIt << std::endl);
}
}
found = true;
@@ -2584,7 +2582,7 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
{
cmCTestLog(this, DEBUG,
"* Read custom CTest configuration vectors for handler: "
- << it->first.c_str() << " (" << it->second << ")" << std::endl);
+ << it->first << " (" << it->second << ")" << std::endl);
it->second->PopulateCustomVectors(mf);
}
}
@@ -2593,13 +2591,9 @@ int cmCTest::ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf)
}
//----------------------------------------------------------------------
-void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def,
- VectorOfStrings& vec)
+void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def,
+ std::vector<std::string>& vec)
{
- if ( !def)
- {
- return;
- }
const char* dval = mf->GetDefinition(def);
if ( !dval )
{
@@ -2614,18 +2608,15 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const char* def,
for ( it = slist.begin(); it != slist.end(); ++it )
{
- cmCTestLog(this, DEBUG, " -- " << it->c_str() << std::endl);
- vec.push_back(it->c_str());
+ cmCTestLog(this, DEBUG, " -- " << *it << std::endl);
+ vec.push_back(*it);
}
}
//----------------------------------------------------------------------
-void cmCTest::PopulateCustomInteger(cmMakefile* mf, const char* def, int& val)
+void cmCTest::PopulateCustomInteger(cmMakefile* mf, const std::string& def,
+ int& val)
{
- if ( !def)
- {
- return;
- }
const char* dval = mf->GetDefinition(def);
if ( !dval )
{
@@ -2702,7 +2693,7 @@ std::string cmCTest::GetShortPathToFile(const char* cfname)
}
//----------------------------------------------------------------------
-std::string cmCTest::GetCTestConfiguration(const char *name)
+std::string cmCTest::GetCTestConfiguration(const std::string& name)
{
if ( this->CTestConfigurationOverwrites.find(name) !=
this->CTestConfigurationOverwrites.end() )
@@ -2847,9 +2838,8 @@ void cmCTest::AddSubmitFile(Part part, const char* name)
}
//----------------------------------------------------------------------
-void cmCTest::AddCTestConfigurationOverwrite(const char* encstr)
+void cmCTest::AddCTestConfigurationOverwrite(const std::string& overStr)
{
- std::string overStr = encstr;
size_t epos = overStr.find("=");
if ( epos == overStr.npos )
{
@@ -2857,7 +2847,7 @@ void cmCTest::AddCTestConfigurationOverwrite(const char* encstr)
"CTest configuration overwrite specified in the wrong format."
<< std::endl
<< "Valid format is: --overwrite key=value" << std::endl
- << "The specified was: --overwrite " << overStr.c_str() << std::endl);
+ << "The specified was: --overwrite " << overStr << std::endl);
return;
}
std::string key = overStr.substr(0, epos);
@@ -2877,7 +2867,7 @@ void cmCTest::SetConfigType(const char* ct)
//----------------------------------------------------------------------
bool cmCTest::SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
- const char* dconfig, const char* cmake_var)
+ const char* dconfig, const std::string& cmake_var)
{
const char* ctvar;
ctvar = mf->GetDefinition(cmake_var);
@@ -2900,7 +2890,7 @@ bool cmCTest::RunCommand(
const char* dir,
double timeout)
{
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+ std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if(args.size() < 1)
{
@@ -2908,7 +2898,7 @@ bool cmCTest::RunCommand(
}
std::vector<const char*> argv;
- for(std::vector<cmStdString>::const_iterator a = args.begin();
+ for(std::vector<std::string>::const_iterator a = args.begin();
a != args.end(); ++a)
{
argv.push_back(a->c_str());
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index becb0f5..246294f 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -70,8 +70,8 @@ public:
{
PartInfo(): Enabled(false) {}
- void SetName(const char* name) { this->Name = name; }
- const char* GetName() const { return this->Name.c_str(); }
+ void SetName(const std::string& name) { this->Name = name; }
+ const std::string& GetName() const { return this->Name; }
void Enable() { this->Enabled = true; }
operator bool() const { return this->Enabled; }
@@ -101,8 +101,8 @@ public:
if the string does not name a valid part. */
Part GetPartFromName(const char* name);
- typedef std::vector<cmStdString> VectorOfStrings;
- typedef std::set<cmStdString> SetOfStrings;
+ typedef std::vector<cmsys::String> VectorOfStrings;
+ typedef std::set<std::string> SetOfStrings;
///! Process Command line arguments
int Run(std::vector<std::string> &, std::string* output = 0);
@@ -134,7 +134,7 @@ public:
/*
* Is the tomorrow tag set?
*/
- bool GetTomorrowTag() { return this->TomorrowTag; };
+ bool GetTomorrowTag() { return this->TomorrowTag; }
/**
* Try to run tests of the project
@@ -167,12 +167,12 @@ public:
* Set the cmake test mode (experimental, nightly, continuous).
*/
void SetTestModel(int mode);
- int GetTestModel() { return this->TestModel; };
+ int GetTestModel() { return this->TestModel; }
std::string GetTestModelString();
static int GetTestModelFromString(const char* str);
static std::string CleanString(const std::string& str);
- std::string GetCTestConfiguration(const char *name);
+ std::string GetCTestConfiguration(const std::string& name);
void SetCTestConfiguration(const char *name, const char* value);
void EmptyCTestConfiguration();
@@ -185,9 +185,9 @@ public:
//! Set the notes files to be created.
void SetNotesFiles(const char* notes);
- void PopulateCustomVector(cmMakefile* mf, const char* definition,
- VectorOfStrings& vec);
- void PopulateCustomInteger(cmMakefile* mf, const char* def,
+ void PopulateCustomVector(cmMakefile* mf, const std::string& definition,
+ std::vector<std::string>& vec);
+ void PopulateCustomInteger(cmMakefile* mf, const std::string& def,
int& val);
///! Get the current time as string
@@ -332,7 +332,7 @@ public:
* Set the CTest variable from CMake variable
*/
bool SetCTestConfigurationFromCMakeVariable(cmMakefile* mf,
- const char* dconfig, const char* cmake_var);
+ const char* dconfig, const std::string& cmake_var);
//! Make string safe to be send as an URL
static std::string MakeURLSafe(const std::string&);
@@ -349,14 +349,14 @@ public:
//! Add overwrite to ctest configuration.
// The format is key=value
- void AddCTestConfigurationOverwrite(const char* encstr);
+ void AddCTestConfigurationOverwrite(const std::string& encstr);
//! Create XML file that contains all the notes specified
- int GenerateNotesFile(const std::vector<cmStdString> &files);
+ int GenerateNotesFile(const VectorOfStrings &files);
//! Submit extra files to the server
bool SubmitExtraFiles(const char* files);
- bool SubmitExtraFiles(const std::vector<cmStdString> &files);
+ bool SubmitExtraFiles(const VectorOfStrings &files);
//! Set the output log file name
void SetOutputLogFileName(const char* name);
@@ -391,8 +391,8 @@ public:
//! Read the custom configuration files and apply them to the current ctest
int ReadCustomConfigurationFileTree(const char* dir, cmMakefile* mf);
- std::vector<cmStdString> &GetInitialCommandLineArguments()
- { return this->InitialCommandLineArguments; };
+ std::vector<std::string> &GetInitialCommandLineArguments()
+ { return this->InitialCommandLineArguments; }
//! Set the track to submit to
void SetSpecificTrack(const char* track);
@@ -447,13 +447,13 @@ private:
void DetermineNextDayStop();
// these are helper classes
- typedef std::map<cmStdString,cmCTestGenericHandler*> t_TestingHandlers;
+ typedef std::map<std::string,cmCTestGenericHandler*> t_TestingHandlers;
t_TestingHandlers TestingHandlers;
bool ShowOnly;
//! Map of configuration properties
- typedef std::map<cmStdString, cmStdString> CTestConfigurationMap;
+ typedef std::map<std::string, std::string> CTestConfigurationMap;
std::string CTestConfigFile;
// TODO: The ctest configuration should be a hierarchy of
@@ -463,7 +463,7 @@ private:
CTestConfigurationMap CTestConfiguration;
CTestConfigurationMap CTestConfigurationOverwrites;
PartInfo Parts[PartCount];
- typedef std::map<cmStdString, Part> PartMapType;
+ typedef std::map<std::string, Part> PartMapType;
PartMapType PartMap;
std::string CurrentTag;
@@ -556,7 +556,7 @@ private:
int DartVersion;
bool DropSiteCDash;
- std::vector<cmStdString> InitialCommandLineArguments;
+ std::vector<std::string> InitialCommandLineArguments;
int SubmitIndex;
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index 9e0064e..8f352b1 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -82,19 +82,19 @@ bool cmCacheManager::LoadCache(cmMakefile* mf)
}
-bool cmCacheManager::LoadCache(const char* path)
+bool cmCacheManager::LoadCache(const std::string& path)
{
return this->LoadCache(path,true);
}
-bool cmCacheManager::LoadCache(const char* path,
+bool cmCacheManager::LoadCache(const std::string& path,
bool internal)
{
- std::set<cmStdString> emptySet;
+ std::set<std::string> emptySet;
return this->LoadCache(path, internal, emptySet, emptySet);
}
-static bool ParseEntryWithoutType(const char* entry,
+static bool ParseEntryWithoutType(const std::string& entry,
std::string& var,
std::string& value)
{
@@ -132,7 +132,7 @@ static bool ParseEntryWithoutType(const char* entry,
return flag;
}
-bool cmCacheManager::ParseEntry(const char* entry,
+bool cmCacheManager::ParseEntry(const std::string& entry,
std::string& var,
std::string& value,
CacheEntryType& type)
@@ -178,7 +178,7 @@ bool cmCacheManager::ParseEntry(const char* entry,
return flag;
}
-void cmCacheManager::CleanCMakeFiles(const char* path)
+void cmCacheManager::CleanCMakeFiles(const std::string& path)
{
std::string glob = path;
glob += cmake::GetCMakeFilesDirectory();
@@ -193,10 +193,10 @@ void cmCacheManager::CleanCMakeFiles(const char* path)
}
}
-bool cmCacheManager::LoadCache(const char* path,
+bool cmCacheManager::LoadCache(const std::string& path,
bool internal,
- std::set<cmStdString>& excludes,
- std::set<cmStdString>& includes)
+ std::set<std::string>& excludes,
+ std::set<std::string>& includes)
{
std::string cacheFile = path;
cacheFile += "/CMakeCache.txt";
@@ -428,7 +428,7 @@ bool cmCacheManager::SaveCache(cmMakefile* mf)
}
-bool cmCacheManager::SaveCache(const char* path)
+bool cmCacheManager::SaveCache(const std::string& path)
{
std::string cacheFile = path;
cacheFile += "/CMakeCache.txt";
@@ -500,7 +500,7 @@ bool cmCacheManager::SaveCache(const char* path)
fout << "########################\n";
fout << "\n";
- for( std::map<cmStdString, CacheEntry>::const_iterator i =
+ for( std::map<std::string, CacheEntry>::const_iterator i =
this->Cache.begin(); i != this->Cache.end(); ++i)
{
const CacheEntry& ce = (*i).second;
@@ -578,7 +578,7 @@ bool cmCacheManager::SaveCache(const char* path)
return true;
}
-bool cmCacheManager::DeleteCache(const char* path)
+bool cmCacheManager::DeleteCache(const std::string& path)
{
std::string cacheFile = path;
cmSystemTools::ConvertToUnixSlashes(cacheFile);
@@ -644,13 +644,13 @@ void cmCacheManager::OutputHelpString(std::ostream& fout,
fout << "\\n";
}
oneLine = helpString.substr(pos, i - pos);
- fout << oneLine.c_str() << "\n";
+ fout << oneLine << "\n";
pos = i;
}
}
}
-void cmCacheManager::RemoveCacheEntry(const char* key)
+void cmCacheManager::RemoveCacheEntry(const std::string& key)
{
CacheEntryMap::iterator i = this->Cache.find(key);
if(i != this->Cache.end())
@@ -660,7 +660,8 @@ void cmCacheManager::RemoveCacheEntry(const char* key)
}
-cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(const char* key)
+cmCacheManager::CacheEntry *cmCacheManager::GetCacheEntry(
+ const std::string& key)
{
CacheEntryMap::iterator i = this->Cache.find(key);
if(i != this->Cache.end())
@@ -676,7 +677,7 @@ cmCacheManager::CacheIterator cmCacheManager::GetCacheIterator(
return CacheIterator(*this, key);
}
-const char* cmCacheManager::GetCacheValue(const char* key) const
+const char* cmCacheManager::GetCacheValue(const std::string& key) const
{
CacheEntryMap::const_iterator i = this->Cache.find(key);
if(i != this->Cache.end() &&
@@ -692,12 +693,12 @@ void cmCacheManager::PrintCache(std::ostream& out) const
{
out << "=================================================" << std::endl;
out << "CMakeCache Contents:" << std::endl;
- for(std::map<cmStdString, CacheEntry>::const_iterator i =
+ for(std::map<std::string, CacheEntry>::const_iterator i =
this->Cache.begin(); i != this->Cache.end(); ++i)
{
if((*i).second.Type != INTERNAL)
{
- out << (*i).first.c_str() << " = " << (*i).second.Value.c_str()
+ out << (*i).first << " = " << (*i).second.Value
<< std::endl;
}
}
@@ -708,7 +709,7 @@ void cmCacheManager::PrintCache(std::ostream& out) const
}
-void cmCacheManager::AddCacheEntry(const char* key,
+void cmCacheManager::AddCacheEntry(const std::string& key,
const char* value,
const char* helpString,
CacheEntryType type)
@@ -767,7 +768,7 @@ void cmCacheManager::CacheIterator::Begin()
this->Position = this->Container.Cache.begin();
}
-bool cmCacheManager::CacheIterator::Find(const char* key)
+bool cmCacheManager::CacheIterator::Find(const std::string& key)
{
this->Position = this->Container.Cache.find(key);
return !this->IsAtEnd();
@@ -807,13 +808,13 @@ bool cmCacheManager::CacheIterator::GetValueAsBool() const
//----------------------------------------------------------------------------
const char*
-cmCacheManager::CacheEntry::GetProperty(const char* prop) const
+cmCacheManager::CacheEntry::GetProperty(const std::string& prop) const
{
- if(strcmp(prop, "TYPE") == 0)
+ if(prop == "TYPE")
{
return cmCacheManagerTypes[this->Type];
}
- else if(strcmp(prop, "VALUE") == 0)
+ else if(prop == "VALUE")
{
return this->Value.c_str();
}
@@ -823,14 +824,14 @@ cmCacheManager::CacheEntry::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
-void cmCacheManager::CacheEntry::SetProperty(const char* prop,
+void cmCacheManager::CacheEntry::SetProperty(const std::string& prop,
const char* value)
{
- if(strcmp(prop, "TYPE") == 0)
+ if(prop == "TYPE")
{
this->Type = cmCacheManager::StringToType(value? value : "STRING");
}
- else if(strcmp(prop, "VALUE") == 0)
+ else if(prop == "VALUE")
{
this->Value = value? value : "";
}
@@ -841,15 +842,15 @@ void cmCacheManager::CacheEntry::SetProperty(const char* prop,
}
//----------------------------------------------------------------------------
-void cmCacheManager::CacheEntry::AppendProperty(const char* prop,
+void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop,
const char* value,
bool asString)
{
- if(strcmp(prop, "TYPE") == 0)
+ if(prop == "TYPE")
{
this->Type = cmCacheManager::StringToType(value? value : "STRING");
}
- else if(strcmp(prop, "VALUE") == 0)
+ else if(prop == "VALUE")
{
if(value)
{
@@ -867,7 +868,8 @@ void cmCacheManager::CacheEntry::AppendProperty(const char* prop,
}
//----------------------------------------------------------------------------
-const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const
+const char* cmCacheManager::CacheIterator::GetProperty(
+ const std::string& prop) const
{
if(!this->IsAtEnd())
{
@@ -877,7 +879,8 @@ const char* cmCacheManager::CacheIterator::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
-void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
+void cmCacheManager::CacheIterator::SetProperty(const std::string& p,
+ const char* v)
{
if(!this->IsAtEnd())
{
@@ -886,7 +889,7 @@ void cmCacheManager::CacheIterator::SetProperty(const char* p, const char* v)
}
//----------------------------------------------------------------------------
-void cmCacheManager::CacheIterator::AppendProperty(const char* p,
+void cmCacheManager::CacheIterator::AppendProperty(const std::string& p,
const char* v,
bool asString)
{
@@ -897,7 +900,8 @@ void cmCacheManager::CacheIterator::AppendProperty(const char* p,
}
//----------------------------------------------------------------------------
-bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const
+bool cmCacheManager::CacheIterator::GetPropertyAsBool(
+ const std::string& prop) const
{
if(const char* value = this->GetProperty(prop))
{
@@ -907,13 +911,14 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool(const char* prop) const
}
//----------------------------------------------------------------------------
-void cmCacheManager::CacheIterator::SetProperty(const char* p, bool v)
+void cmCacheManager::CacheIterator::SetProperty(const std::string& p, bool v)
{
this->SetProperty(p, v ? "ON" : "OFF");
}
//----------------------------------------------------------------------------
-bool cmCacheManager::CacheIterator::PropertyExists(const char* prop) const
+bool cmCacheManager::CacheIterator::PropertyExists(
+ const std::string& prop) const
{
return this->GetProperty(prop)? true:false;
}
diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h
index f487e8e..d9a9112 100644
--- a/Source/cmCacheManager.h
+++ b/Source/cmCacheManager.h
@@ -39,9 +39,9 @@ private:
std::string Value;
CacheEntryType Type;
cmPropertyMap Properties;
- const char* GetProperty(const char*) const;
- void SetProperty(const char* property, const char* value);
- void AppendProperty(const char* property, const char* value,
+ const char* GetProperty(const std::string&) const;
+ void SetProperty(const std::string& property, const char* value);
+ void AppendProperty(const std::string& property, const char* value,
bool asString=false);
bool Initialized;
CacheEntry() : Value(""), Type(UNINITIALIZED), Initialized(false)
@@ -53,26 +53,26 @@ public:
{
public:
void Begin();
- bool Find(const char*);
+ bool Find(const std::string&);
bool IsAtEnd() const;
void Next();
- const char *GetName() const {
- return this->Position->first.c_str(); }
- const char* GetProperty(const char*) const ;
- bool GetPropertyAsBool(const char*) const ;
- bool PropertyExists(const char*) const;
- void SetProperty(const char* property, const char* value);
- void AppendProperty(const char* property, const char* value,
+ std::string GetName() const {
+ return this->Position->first; }
+ const char* GetProperty(const std::string&) const ;
+ bool GetPropertyAsBool(const std::string&) const ;
+ bool PropertyExists(const std::string&) const;
+ void SetProperty(const std::string& property, const char* value);
+ void AppendProperty(const std::string& property, const char* value,
bool asString=false);
- void SetProperty(const char* property, bool value);
- const char* GetValue() const { return this->GetEntry().Value.c_str(); }
+ void SetProperty(const std::string& property, bool value);
+ std::string GetValue() const { return this->GetEntry().Value; }
bool GetValueAsBool() const;
void SetValue(const char*);
CacheEntryType GetType() const { return this->GetEntry().Type; }
void SetType(CacheEntryType ty) { this->GetEntry().Type = ty; }
bool Initialized() { return this->GetEntry().Initialized; }
cmCacheManager &Container;
- std::map<cmStdString, CacheEntry>::iterator Position;
+ std::map<std::string, CacheEntry>::iterator Position;
CacheIterator(cmCacheManager &cm) : Container(cm) {
this->Begin();
}
@@ -108,19 +108,19 @@ public:
///! Load a cache for given makefile. Loads from ouput home.
bool LoadCache(cmMakefile*);
///! Load a cache for given makefile. Loads from path/CMakeCache.txt.
- bool LoadCache(const char* path);
- bool LoadCache(const char* path, bool internal);
- bool LoadCache(const char* path, bool internal,
- std::set<cmStdString>& excludes,
- std::set<cmStdString>& includes);
+ bool LoadCache(const std::string& path);
+ bool LoadCache(const std::string& path, bool internal);
+ bool LoadCache(const std::string& path, bool internal,
+ std::set<std::string>& excludes,
+ std::set<std::string>& includes);
///! Save cache for given makefile. Saves to ouput home CMakeCache.txt.
bool SaveCache(cmMakefile*) ;
///! Save cache for given makefile. Saves to ouput path/CMakeCache.txt
- bool SaveCache(const char* path) ;
+ bool SaveCache(const std::string& path) ;
///! Delete the cache given
- bool DeleteCache(const char* path);
+ bool DeleteCache(const std::string& path);
///! Print the cache to a stream
void PrintCache(std::ostream&) const;
@@ -129,20 +129,20 @@ public:
cmCacheManager::CacheIterator GetCacheIterator(const char *key=0);
///! Remove an entry from the cache
- void RemoveCacheEntry(const char* key);
+ void RemoveCacheEntry(const std::string& key);
///! Get the number of entries in the cache
int GetSize() {
return static_cast<int>(this->Cache.size()); }
///! Break up a line like VAR:type="value" into var, type and value
- static bool ParseEntry(const char* entry,
+ static bool ParseEntry(const std::string& entry,
std::string& var,
std::string& value,
CacheEntryType& type);
///! Get a value from the cache given a key
- const char* GetCacheValue(const char* key) const;
+ const char* GetCacheValue(const std::string& key) const;
/** Get the version of CMake that wrote the cache. */
unsigned int GetCacheMajorVersion() const
@@ -153,20 +153,20 @@ public:
protected:
///! Add an entry into the cache
- void AddCacheEntry(const char* key, const char* value,
+ void AddCacheEntry(const std::string& key, const char* value,
const char* helpString, CacheEntryType type);
///! Get a cache entry object for a key
- CacheEntry *GetCacheEntry(const char *key);
+ CacheEntry *GetCacheEntry(const std::string& key);
///! Clean out the CMakeFiles directory if no CMakeCache.txt
- void CleanCMakeFiles(const char* path);
+ void CleanCMakeFiles(const std::string& path);
// Cache version info
unsigned int CacheMajorVersion;
unsigned int CacheMinorVersion;
private:
cmake* CMakeInstance;
- typedef std::map<cmStdString, CacheEntry> CacheEntryMap;
+ typedef std::map<std::string, CacheEntry> CacheEntryMap;
static void OutputHelpString(std::ostream& fout,
const std::string& helpString);
static void OutputKey(std::ostream& fout, std::string const& key);
diff --git a/Source/cmCommand.h b/Source/cmCommand.h
index e148857..a34ea71 100644
--- a/Source/cmCommand.h
+++ b/Source/cmCommand.h
@@ -81,7 +81,7 @@ public:
* not implement this method. At this point, reading and
* writing to the cache can be done.
*/
- virtual void FinalPass() {};
+ virtual void FinalPass() {}
/**
* Does this command have a final pass? Query after InitialPass.
@@ -124,7 +124,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const = 0;
+ virtual std::string GetName() const = 0;
/**
* Enable the command.
@@ -166,7 +166,7 @@ public:
/**
* Set the error message
*/
- void SetError(const char* e)
+ void SetError(const std::string& e)
{
this->Error = this->GetName();
this->Error += " ";
diff --git a/Source/cmCommandArgumentLexer.cxx b/Source/cmCommandArgumentLexer.cxx
index e62e53e..e23ef8a 100644
--- a/Source/cmCommandArgumentLexer.cxx
+++ b/Source/cmCommandArgumentLexer.cxx
@@ -1069,7 +1069,7 @@ case YY_STATE_EOF(NOESCAPES):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
-return 0; /* this should not happend but it should silence a warning */
+return 0; /* this should not happen but it quiets some compilers */
} /* end of cmCommandArgument_yylex */
/* yy_get_next_buffer - try to read in a new buffer
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index dbeeb07..a7f6b49 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -49,14 +49,14 @@ void cmCommandArgumentParserHelper::SetLineFile(long line, const char* file)
this->FileName = file;
}
-char* cmCommandArgumentParserHelper::AddString(const char* str)
+char* cmCommandArgumentParserHelper::AddString(const std::string& str)
{
- if ( !str || !*str )
+ if ( str.empty() )
{
return this->EmptyVariable;
}
- char* stVal = new char[strlen(str)+1];
- strcpy(stVal, str);
+ char* stVal = new char[str.size()+1];
+ strcpy(stVal, str.c_str());
this->Variables.push_back(stVal);
return stVal;
}
@@ -79,7 +79,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
{
if (this->EscapeQuotes)
{
- return this->AddString(cmSystemTools::EscapeQuotes(ptr).c_str());
+ return this->AddString(cmSystemTools::EscapeQuotes(ptr));
}
else
{
@@ -94,7 +94,7 @@ char* cmCommandArgumentParserHelper::ExpandSpecialVariable(const char* key,
{
if(this->EscapeQuotes)
{
- return this->AddString(cmSystemTools::EscapeQuotes(c).c_str());
+ return this->AddString(cmSystemTools::EscapeQuotes(c));
}
else
{
@@ -120,7 +120,7 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
{
cmOStringStream ostr;
ostr << this->FileLine;
- return this->AddString(ostr.str().c_str());
+ return this->AddString(ostr.str());
}
const char* value = this->Makefile->GetDefinition(var);
if(!value && !this->RemoveEmpty)
@@ -144,16 +144,16 @@ char* cmCommandArgumentParserHelper::ExpandVariable(const char* var)
bt.push_back(lfc);
msg << "uninitialized variable \'" << var << "\'";
this->Makefile->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str().c_str(), bt);
+ msg.str(), bt);
}
}
return 0;
}
if (this->EscapeQuotes && value)
{
- return this->AddString(cmSystemTools::EscapeQuotes(value).c_str());
+ return this->AddString(cmSystemTools::EscapeQuotes(value));
}
- return this->AddString(value);
+ return this->AddString(value ? value : "");
}
char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
@@ -166,7 +166,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
// then return an empty string
if(!ret && this->RemoveEmpty)
{
- return this->AddString(ret);
+ return this->AddString("");
}
// if the ret was not 0, then return it
if(ret)
@@ -181,7 +181,7 @@ char* cmCommandArgumentParserHelper::ExpandVariableForAt(const char* var)
std::string ref = "@";
ref += var;
ref += "@";
- return this->AddString(ref.c_str());
+ return this->AddString(ref);
}
char* cmCommandArgumentParserHelper::CombineUnions(char* in1, char* in2)
@@ -293,7 +293,7 @@ int cmCommandArgumentParserHelper::ParseString(const char* str, int verb)
if ( Verbose )
{
std::cerr << "Expanding [" << str << "] produced: ["
- << this->Result.c_str() << "]" << std::endl;
+ << this->Result << "]" << std::endl;
}
return 1;
}
diff --git a/Source/cmCommandArgumentParserHelper.h b/Source/cmCommandArgumentParserHelper.h
index f8c672f..d375ae6 100644
--- a/Source/cmCommandArgumentParserHelper.h
+++ b/Source/cmCommandArgumentParserHelper.h
@@ -77,8 +77,8 @@ public:
char BSLASHVariable[3];
private:
- cmStdString::size_type InputBufferPos;
- cmStdString InputBuffer;
+ std::string::size_type InputBufferPos;
+ std::string InputBuffer;
std::vector<char> OutputBuffer;
int CurrentLine;
int Verbose;
@@ -86,7 +86,7 @@ private:
void Print(const char* place, const char* str);
void SafePrintMissing(const char* str, int line, int cnt);
- char* AddString(const char* str);
+ char* AddString(const std::string& str);
void CleanupParser();
void SetError(std::string const& msg);
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 1be5980..995f191 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -172,7 +172,7 @@ satisfy dependencies.
//----------------------------------------------------------------------------
cmComputeLinkDepends
-::cmComputeLinkDepends(cmTarget const* target, const char* config,
+::cmComputeLinkDepends(cmTarget const* target, const std::string& config,
cmTarget const* head)
{
// Store context information.
@@ -184,7 +184,8 @@ cmComputeLinkDepends
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
// The configuration being linked.
- this->Config = (config && *config)? config : 0;
+ this->HasConfig = !config.empty();
+ this->Config = (this->HasConfig)? config : std::string();
this->LinkType = this->Target->ComputeLinkType(this->Config);
// Enable debug mode if requested.
@@ -254,7 +255,8 @@ cmComputeLinkDepends::Compute()
"---------------------------------------"
"---------------------------------------\n");
fprintf(stderr, "Link dependency analysis for target %s, config %s\n",
- this->Target->GetName(), this->Config?this->Config:"noconfig");
+ this->Target->GetName().c_str(),
+ this->HasConfig?this->Config.c_str():"noconfig");
this->DisplayConstraintGraph();
}
@@ -278,12 +280,12 @@ cmComputeLinkDepends::Compute()
}
//----------------------------------------------------------------------------
-std::map<cmStdString, int>::iterator
+std::map<std::string, int>::iterator
cmComputeLinkDepends::AllocateLinkEntry(std::string const& item)
{
- std::map<cmStdString, int>::value_type
+ std::map<std::string, int>::value_type
index_entry(item, static_cast<int>(this->EntryList.size()));
- std::map<cmStdString, int>::iterator
+ std::map<std::string, int>::iterator
lei = this->LinkEntryIndex.insert(index_entry).first;
this->EntryList.push_back(LinkEntry());
this->InferredDependSets.push_back(0);
@@ -296,7 +298,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index,
std::string const& item)
{
// Check if the item entry has already been added.
- std::map<cmStdString, int>::iterator lei = this->LinkEntryIndex.find(item);
+ std::map<std::string, int>::iterator lei = this->LinkEntryIndex.find(item);
if(lei != this->LinkEntryIndex.end())
{
// Yes. We do not need to follow the item's dependencies again.
@@ -310,7 +312,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index,
int index = lei->second;
LinkEntry& entry = this->EntryList[index];
entry.Item = item;
- entry.Target = this->FindTargetToLink(depender_index, entry.Item.c_str());
+ entry.Target = this->FindTargetToLink(depender_index, entry.Item);
entry.IsFlag = (!entry.Target && item[0] == '-' && item[1] != 'l' &&
item.substr(0, 10) != "-framework");
@@ -326,7 +328,7 @@ int cmComputeLinkDepends::AddLinkEntry(int depender_index,
// Look for an old-style <item>_LIB_DEPENDS variable.
std::string var = entry.Item;
var += "_LIB_DEPENDS";
- if(const char* val = this->Makefile->GetDefinition(var.c_str()))
+ if(const char* val = this->Makefile->GetDefinition(var))
{
// The item dependencies are known. Follow them.
BFSEntry qe = {index, val};
@@ -422,7 +424,7 @@ cmComputeLinkDepends
void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
{
// Check if the target already has an entry.
- std::map<cmStdString, int>::iterator lei =
+ std::map<std::string, int>::iterator lei =
this->LinkEntryIndex.find(dep.Item);
if(lei == this->LinkEntryIndex.end())
{
@@ -433,7 +435,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
LinkEntry& entry = this->EntryList[lei->second];
entry.Item = dep.Item;
entry.Target = this->FindTargetToLink(dep.DependerIndex,
- dep.Item.c_str());
+ dep.Item);
// This item was added specifically because it is a dependent
// shared library. It may get special treatment
@@ -504,7 +506,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index,
{
std::string var = *di;
var += "_LINK_TYPE";
- if(const char* val = this->Makefile->GetDefinition(var.c_str()))
+ if(const char* val = this->Makefile->GetDefinition(var))
{
if(strcmp(val, "debug") == 0)
{
@@ -620,7 +622,7 @@ cmComputeLinkDepends::AddLinkEntries(int depender_index,
//----------------------------------------------------------------------------
cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index,
- const char* name)
+ const std::string& name)
{
// Look for a target in the scope of the depender.
cmMakefile* mf = this->Makefile;
@@ -968,14 +970,14 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl)
//----------------------------------------------------------------------------
void cmComputeLinkDepends::DisplayFinalEntries()
{
- fprintf(stderr, "target [%s] links to:\n", this->Target->GetName());
+ fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
for(std::vector<LinkEntry>::const_iterator lei =
this->FinalLinkEntries.begin();
lei != this->FinalLinkEntries.end(); ++lei)
{
if(lei->Target)
{
- fprintf(stderr, " target [%s]\n", lei->Target->GetName());
+ fprintf(stderr, " target [%s]\n", lei->Target->GetName().c_str());
}
else
{
@@ -998,7 +1000,7 @@ void cmComputeLinkDepends::CheckWrongConfigItem(int depender_index,
// directories of targets linked in another configuration as link
// directories.
if(cmTarget const* tgt
- = this->FindTargetToLink(depender_index, item.c_str()))
+ = this->FindTargetToLink(depender_index, item))
{
if(!tgt->IsImported())
{
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 9776f55..13fc993 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -32,7 +32,7 @@ class cmake;
class cmComputeLinkDepends
{
public:
- cmComputeLinkDepends(cmTarget const* target, const char* config,
+ cmComputeLinkDepends(cmTarget const* target, const std::string& config,
cmTarget const* head);
~cmComputeLinkDepends();
@@ -68,7 +68,8 @@ private:
bool DebugMode;
// Configuration information.
- const char* Config;
+ bool HasConfig;
+ std::string Config;
cmTarget::LinkLibraryType LinkType;
// Output information.
@@ -76,18 +77,19 @@ private:
typedef cmTarget::LinkLibraryVectorType LinkLibraryVectorType;
- std::map<cmStdString, int>::iterator
+ std::map<std::string, int>::iterator
AllocateLinkEntry(std::string const& item);
int AddLinkEntry(int depender_index, std::string const& item);
void AddVarLinkEntries(int depender_index, const char* value);
void AddDirectLinkEntries();
void AddLinkEntries(int depender_index,
std::vector<std::string> const& libs);
- cmTarget const* FindTargetToLink(int depender_index, const char* name);
+ cmTarget const* FindTargetToLink(int depender_index,
+ const std::string& name);
// One entry for each unique item.
std::vector<LinkEntry> EntryList;
- std::map<cmStdString, int> LinkEntryIndex;
+ std::map<std::string, int> LinkEntryIndex;
// BFS of initial dependencies.
struct BFSEntry
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 6986965..ea8536f 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -239,7 +239,7 @@ because this need be done only for shared libraries without soname-s.
//----------------------------------------------------------------------------
cmComputeLinkInformation
-::cmComputeLinkInformation(cmTarget const* target, const char* config,
+::cmComputeLinkInformation(cmTarget const* target, const std::string& config,
cmTarget const* headTarget)
{
// Store context information.
@@ -268,7 +268,7 @@ cmComputeLinkInformation
// Get the language used for linking this target.
this->LinkLanguage = this->Target->GetLinkerLanguage(config, headTarget);
- if(!this->LinkLanguage)
+ if(this->LinkLanguage.empty())
{
// The Compute method will do nothing, so skip the rest of the
// initialization.
@@ -293,7 +293,7 @@ cmComputeLinkInformation
std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_";
loader_flag_var += this->LinkLanguage;
loader_flag_var += "_FLAG";
- this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var.c_str());
+ this->LoaderFlag = this->Makefile->GetDefinition(loader_flag_var);
}
// Get options needed to link libraries.
@@ -317,8 +317,8 @@ cmComputeLinkInformation
rtVar += this->LinkLanguage;
rtVar += "_FLAG";
std::string rtSepVar = rtVar + "_SEP";
- this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar.c_str());
- this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar.c_str());
+ this->RuntimeFlag = this->Makefile->GetSafeDefinition(rtVar);
+ this->RuntimeSep = this->Makefile->GetSafeDefinition(rtSepVar);
this->RuntimeAlways =
(this->Makefile->
GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH"));
@@ -330,7 +330,7 @@ cmComputeLinkInformation
rlVar += "_RPATH_LINK_";
rlVar += this->LinkLanguage;
rlVar += "_FLAG";
- this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar.c_str());
+ this->RPathLinkFlag = this->Makefile->GetSafeDefinition(rlVar);
}
// Check if we need to include the runtime search path at link time.
@@ -338,7 +338,7 @@ cmComputeLinkInformation
std::string var = "CMAKE_SHARED_LIBRARY_LINK_";
var += this->LinkLanguage;
var += "_WITH_RUNTIME_PATH";
- this->LinkWithRuntimePath = this->Makefile->IsOn(var.c_str());
+ this->LinkWithRuntimePath = this->Makefile->IsOn(var);
}
// Check the platform policy for missing soname case.
@@ -496,16 +496,17 @@ bool cmComputeLinkInformation::Compute()
}
// We require a link language for the target.
- if(!this->LinkLanguage)
+ if(this->LinkLanguage.empty())
{
cmSystemTools::
Error("CMake can not determine linker language for target: ",
- this->Target->GetName());
+ this->Target->GetName().c_str());
return false;
}
// Compute the ordered link line items.
- cmComputeLinkDepends cld(this->Target, this->Config, this->HeadTarget);
+ cmComputeLinkDepends cld(this->Target, this->Config,
+ this->HeadTarget);
cld.SetOldLinkDirMode(this->OldLinkDirMode);
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
@@ -592,7 +593,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
std::string libVar = "CMAKE_";
libVar += lang;
libVar += "_IMPLICIT_LINK_LIBRARIES";
- if(const char* libs = this->Makefile->GetDefinition(libVar.c_str()))
+ if(const char* libs = this->Makefile->GetDefinition(libVar))
{
std::vector<std::string> libsVec;
cmSystemTools::ExpandListArgument(libs, libsVec);
@@ -601,7 +602,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
{
if(this->ImplicitLinkLibs.find(*i) == this->ImplicitLinkLibs.end())
{
- this->AddItem(i->c_str(), 0);
+ this->AddItem(*i, 0);
}
}
}
@@ -611,7 +612,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang)
std::string dirVar = "CMAKE_";
dirVar += lang;
dirVar += "_IMPLICIT_LINK_DIRECTORIES";
- if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str()))
+ if(const char* dirs = this->Makefile->GetDefinition(dirVar))
{
std::vector<std::string> dirsVec;
cmSystemTools::ExpandListArgument(dirs, dirsVec);
@@ -624,7 +625,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item,
cmTarget const* tgt)
{
// Compute the proper name to use to link this library.
- const char* config = this->Config;
+ const std::string& config = this->Config;
bool impexe = (tgt && tgt->IsExecutableWithExports());
if(impexe && !this->UseImportLibrary && !this->LoaderFlag)
{
@@ -819,7 +820,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
static_link_type_flag_var += this->LinkLanguage;
static_link_type_flag_var += "_FLAGS";
static_link_type_flag =
- this->Makefile->GetDefinition(static_link_type_flag_var.c_str());
+ this->Makefile->GetDefinition(static_link_type_flag_var);
std::string shared_link_type_flag_var = "CMAKE_";
shared_link_type_flag_var += target_type_str;
@@ -827,7 +828,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
shared_link_type_flag_var += this->LinkLanguage;
shared_link_type_flag_var += "_FLAGS";
shared_link_type_flag =
- this->Makefile->GetDefinition(shared_link_type_flag_var.c_str());
+ this->Makefile->GetDefinition(shared_link_type_flag_var);
}
// We can support link type switching only if all needed flags are
@@ -902,7 +903,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo()
// be the library name. Match index 3 will be the library
// extension.
reg = "^(";
- for(std::set<cmStdString>::iterator p = this->LinkPrefixes.begin();
+ for(std::set<std::string>::iterator p = this->LinkPrefixes.begin();
p != this->LinkPrefixes.end(); ++p)
{
reg += *p;
@@ -1126,9 +1127,10 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item)
// Full path libraries should specify a valid library file name.
// See documentation of CMP0008.
+ std::string generator = this->GlobalGenerator->GetName();
if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW &&
- (strstr(this->GlobalGenerator->GetName(), "Visual Studio") ||
- strstr(this->GlobalGenerator->GetName(), "Xcode")))
+ (generator.find("Visual Studio") != generator.npos ||
+ generator.find("Xcode") != generator.npos))
{
std::string file = cmSystemTools::GetFilenameName(item);
if(!this->ExtractAnyLibraryName.find(file.c_str()))
@@ -1368,7 +1370,7 @@ void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
// Add the item using the -framework option.
this->Items.push_back(Item("-framework", false));
- fw = this->LocalGenerator->EscapeForShell(fw.c_str());
+ fw = this->LocalGenerator->EscapeForShell(fw);
this->Items.push_back(Item(fw, false));
}
@@ -1417,7 +1419,7 @@ void cmComputeLinkInformation::ComputeFrameworkInfo()
implicitDirVar += this->LinkLanguage;
implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES";
if(const char* implicitDirs =
- this->Makefile->GetDefinition(implicitDirVar.c_str()))
+ this->Makefile->GetDefinition(implicitDirVar))
{
cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
}
@@ -1504,9 +1506,9 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
// Print the warning at most once for this item.
std::string wid = "CMP0008-WARNING-GIVEN-";
wid += item;
- if(!this->CMakeInstance->GetPropertyAsBool(wid.c_str()))
+ if(!this->CMakeInstance->GetPropertyAsBool(wid))
{
- this->CMakeInstance->SetProperty(wid.c_str(), "1");
+ this->CMakeInstance->SetProperty(wid, "1");
cmOStringStream w;
w << (this->Makefile->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0008)) << "\n"
@@ -1640,7 +1642,7 @@ void cmComputeLinkInformation::PrintLinkPolicyDiagnosis(std::ostream& os)
// List the paths old behavior is adding.
os << "and other libraries with known full path:\n";
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
for(std::vector<std::string>::const_iterator
i = this->OldLinkDirItems.begin();
i != this->OldLinkDirItems.end(); ++i)
@@ -1690,7 +1692,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
implicitDirVar += this->LinkLanguage;
implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES";
if(const char* implicitDirs =
- this->Makefile->GetDefinition(implicitDirVar.c_str()))
+ this->Makefile->GetDefinition(implicitDirVar))
{
cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec);
}
@@ -1708,7 +1710,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo()
implicitLibVar += this->LinkLanguage;
implicitLibVar += "_IMPLICIT_LINK_LIBRARIES";
if(const char* implicitLibs =
- this->Makefile->GetDefinition(implicitLibVar.c_str()))
+ this->Makefile->GetDefinition(implicitLibVar))
{
cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec);
}
@@ -1856,7 +1858,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath)
//----------------------------------------------------------------------------
static void cmCLI_ExpandListUnique(const char* str,
std::vector<std::string>& out,
- std::set<cmStdString>& emitted)
+ std::set<std::string>& emitted)
{
std::vector<std::string> tmp;
cmSystemTools::ExpandListArgument(str, tmp);
@@ -1894,7 +1896,7 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH");
// Construct the RPATH.
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
if(use_install_rpath)
{
const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH");
@@ -1976,11 +1978,11 @@ void cmComputeLinkInformation::GetRPath(std::vector<std::string>& runtimeDirs,
{
std::string useVar = "CMAKE_" + *li +
"_USE_IMPLICIT_LINK_DIRECTORIES_IN_RUNTIME_PATH";
- if(this->Makefile->IsOn(useVar.c_str()))
+ if(this->Makefile->IsOn(useVar))
{
std::string dirVar = "CMAKE_" + *li +
"_IMPLICIT_LINK_DIRECTORIES";
- if(const char* dirs = this->Makefile->GetDefinition(dirVar.c_str()))
+ if(const char* dirs = this->Makefile->GetDefinition(dirVar))
{
cmCLI_ExpandListUnique(dirs, runtimeDirs, emitted);
}
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 356e6ed..e345fe2 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -29,7 +29,7 @@ class cmOrderDirectories;
class cmComputeLinkInformation
{
public:
- cmComputeLinkInformation(cmTarget const* target, const char* config,
+ cmComputeLinkInformation(cmTarget const* target, const std::string& config,
cmTarget const* headTarget);
~cmComputeLinkInformation();
bool Compute();
@@ -50,7 +50,7 @@ public:
std::vector<std::string> const& GetDirectories();
std::vector<std::string> const& GetDepends();
std::vector<std::string> const& GetFrameworkPaths();
- const char* GetLinkLanguage() const { return this->LinkLanguage; }
+ std::string GetLinkLanguage() const { return this->LinkLanguage; }
std::vector<std::string> const& GetRuntimeSearchPath();
std::string const& GetRuntimeFlag() const { return this->RuntimeFlag; }
std::string const& GetRuntimeSep() const { return this->RuntimeSep; }
@@ -82,8 +82,8 @@ private:
cmake* CMakeInstance;
// Configuration information.
- const char* Config;
- const char* LinkLanguage;
+ std::string Config;
+ std::string LinkLanguage;
bool LinkDependsNoShared;
// Modes for dealing with dependent shared libraries.
@@ -126,7 +126,7 @@ private:
std::vector<std::string> StaticLinkExtensions;
std::vector<std::string> SharedLinkExtensions;
std::vector<std::string> LinkExtensions;
- std::set<cmStdString> LinkPrefixes;
+ std::set<std::string> LinkPrefixes;
cmsys::RegularExpression ExtractStaticLibraryName;
cmsys::RegularExpression ExtractSharedLibraryName;
cmsys::RegularExpression ExtractAnyLibraryName;
@@ -153,7 +153,7 @@ private:
// Framework info.
void ComputeFrameworkInfo();
void AddFrameworkPath(std::string const& p);
- std::set<cmStdString> FrameworkPathsEmmitted;
+ std::set<std::string> FrameworkPathsEmmitted;
cmsys::RegularExpression SplitFramework;
// Linker search path computation.
@@ -165,14 +165,14 @@ private:
void LoadImplicitLinkInfo();
void AddImplicitLinkInfo();
void AddImplicitLinkInfo(std::string const& lang);
- std::set<cmStdString> ImplicitLinkDirs;
- std::set<cmStdString> ImplicitLinkLibs;
+ std::set<std::string> ImplicitLinkDirs;
+ std::set<std::string> ImplicitLinkLibs;
// Additional paths configured by the runtime linker
std::vector<std::string> RuntimeLinkDirs;
// Linker search path compatibility mode.
- std::set<cmStdString> OldLinkDirMask;
+ std::set<std::string> OldLinkDirMask;
std::vector<std::string> OldLinkDirItems;
std::vector<std::string> OldUserFlagItems;
bool OldLinkDirMode;
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index 9136869..eb62455 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -16,6 +16,7 @@
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include "cmSourceFile.h"
#include "cmTarget.h"
#include "cmake.h"
@@ -211,31 +212,45 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// dependencies in all targets, because the generated build-systems can't
// deal with config-specific dependencies.
{
- std::set<cmStdString> emitted;
- {
- std::vector<std::string> tlibs;
- depender->GetDirectLinkLibraries(0, tlibs, depender);
- // A target should not depend on itself.
- emitted.insert(depender->GetName());
- for(std::vector<std::string>::const_iterator lib = tlibs.begin();
- lib != tlibs.end(); ++lib)
- {
- // Don't emit the same library twice for this target.
- if(emitted.insert(*lib).second)
- {
- this->AddTargetDepend(depender_index, lib->c_str(), true);
- this->AddInterfaceDepends(depender_index, lib->c_str(),
- true, emitted);
- }
- }
- }
+ std::set<std::string> emitted;
+ cmGeneratorTarget* gt = depender->GetMakefile()->GetLocalGenerator()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(depender);
+
std::vector<std::string> configs;
depender->GetMakefile()->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
for (std::vector<std::string>::const_iterator it = configs.begin();
it != configs.end(); ++it)
{
+ std::vector<cmSourceFile const*> objectFiles;
+ gt->GetExternalObjects(objectFiles, *it);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ oi = objectFiles.begin(); oi != objectFiles.end(); ++oi)
+ {
+ std::string objLib = (*oi)->GetObjectLibrary();
+ if (!objLib.empty() && emitted.insert(objLib).second)
+ {
+ if(depender->GetType() != cmTarget::EXECUTABLE &&
+ depender->GetType() != cmTarget::STATIC_LIBRARY &&
+ depender->GetType() != cmTarget::SHARED_LIBRARY &&
+ depender->GetType() != cmTarget::MODULE_LIBRARY)
+ {
+ this->GlobalGenerator->GetCMakeInstance()
+ ->IssueMessage(cmake::FATAL_ERROR,
+ "Only executables and non-OBJECT libraries may "
+ "reference target objects.",
+ depender->GetBacktrace());
+ return;
+ }
+ const_cast<cmTarget*>(depender)->AddUtility(objLib);
+ }
+ }
std::vector<std::string> tlibs;
- depender->GetDirectLinkLibraries(it->c_str(), tlibs, depender);
+ depender->GetDirectLinkLibraries(*it, tlibs, depender);
// A target should not depend on itself.
emitted.insert(depender->GetName());
@@ -245,8 +260,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Don't emit the same library twice for this target.
if(emitted.insert(*lib).second)
{
- this->AddTargetDepend(depender_index, lib->c_str(), true);
- this->AddInterfaceDepends(depender_index, lib->c_str(),
+ this->AddTargetDepend(depender_index, *lib, true);
+ this->AddInterfaceDepends(depender_index, *lib,
true, emitted);
}
}
@@ -255,17 +270,17 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
// Loop over all utility dependencies.
{
- std::set<cmStdString> const& tutils = depender->GetUtilities();
- std::set<cmStdString> emitted;
+ std::set<std::string> const& tutils = depender->GetUtilities();
+ std::set<std::string> emitted;
// A target should not depend on itself.
emitted.insert(depender->GetName());
- for(std::set<cmStdString>::const_iterator util = tutils.begin();
+ for(std::set<std::string>::const_iterator util = tutils.begin();
util != tutils.end(); ++util)
{
// Don't emit the same utility twice for this target.
if(emitted.insert(*util).second)
{
- this->AddTargetDepend(depender_index, util->c_str(), false);
+ this->AddTargetDepend(depender_index, *util, false);
}
}
}
@@ -274,8 +289,8 @@ void cmComputeTargetDepends::CollectTargetDepends(int depender_index)
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
cmTarget const* dependee,
- const char *config,
- std::set<cmStdString> &emitted)
+ const std::string& config,
+ std::set<std::string> &emitted)
{
cmTarget const* depender = this->Targets[depender_index];
if(cmTarget::LinkInterface const* iface =
@@ -288,8 +303,8 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
// Don't emit the same library twice for this target.
if(emitted.insert(*lib).second)
{
- this->AddTargetDepend(depender_index, lib->c_str(), true);
- this->AddInterfaceDepends(depender_index, lib->c_str(),
+ this->AddTargetDepend(depender_index, *lib, true);
+ this->AddInterfaceDepends(depender_index, *lib,
true, emitted);
}
}
@@ -298,9 +313,9 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
- const char* dependee_name,
+ const std::string& dependee_name,
bool linking,
- std::set<cmStdString> &emitted)
+ std::set<std::string> &emitted)
{
cmTarget const* depender = this->Targets[depender_index];
cmTarget const* dependee =
@@ -317,7 +332,7 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
if(dependee)
{
- this->AddInterfaceDepends(depender_index, dependee, 0, emitted);
+ this->AddInterfaceDepends(depender_index, dependee, "", emitted);
std::vector<std::string> configs;
depender->GetMakefile()->GetConfigurations(configs);
for (std::vector<std::string>::const_iterator it = configs.begin();
@@ -326,14 +341,14 @@ void cmComputeTargetDepends::AddInterfaceDepends(int depender_index,
// A target should not depend on itself.
emitted.insert(depender->GetName());
this->AddInterfaceDepends(depender_index, dependee,
- it->c_str(), emitted);
+ *it, emitted);
}
}
}
//----------------------------------------------------------------------------
void cmComputeTargetDepends::AddTargetDepend(int depender_index,
- const char* dependee_name,
+ const std::string& dependee_name,
bool linking)
{
// Get the depender.
@@ -407,8 +422,8 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
if(dependee->IsImported())
{
// Skip imported targets but follow their utility dependencies.
- std::set<cmStdString> const& utils = dependee->GetUtilities();
- for(std::set<cmStdString>::const_iterator i = utils.begin();
+ std::set<std::string> const& utils = dependee->GetUtilities();
+ for(std::set<std::string>::const_iterator i = utils.begin();
i != utils.end(); ++i)
{
if(cmTarget const* transitive_dependee =
@@ -435,22 +450,23 @@ void cmComputeTargetDepends::AddTargetDepend(int depender_index,
//----------------------------------------------------------------------------
void
-cmComputeTargetDepends::DisplayGraph(Graph const& graph, const char* name)
+cmComputeTargetDepends::DisplayGraph(Graph const& graph,
+ const std::string& name)
{
- fprintf(stderr, "The %s target dependency graph is:\n", name);
+ fprintf(stderr, "The %s target dependency graph is:\n", name.c_str());
int n = static_cast<int>(graph.size());
for(int depender_index = 0; depender_index < n; ++depender_index)
{
EdgeList const& nl = graph[depender_index];
cmTarget const* depender = this->Targets[depender_index];
fprintf(stderr, "target %d is [%s]\n",
- depender_index, depender->GetName());
+ depender_index, depender->GetName().c_str());
for(EdgeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
int dependee_index = *ni;
cmTarget const* dependee = this->Targets[dependee_index];
fprintf(stderr, " depends on target %d [%s] (%s)\n", dependee_index,
- dependee->GetName(), ni->IsStrong()? "strong" : "weak");
+ dependee->GetName().c_str(), ni->IsStrong()? "strong" : "weak");
}
}
fprintf(stderr, "\n");
@@ -472,7 +488,7 @@ cmComputeTargetDepends
{
int i = *ni;
fprintf(stderr, " contains target %d [%s]\n",
- i, this->Targets[i]->GetName());
+ i, this->Targets[i]->GetName().c_str());
}
}
fprintf(stderr, "\n");
diff --git a/Source/cmComputeTargetDepends.h b/Source/cmComputeTargetDepends.h
index 6cd6da0..7553816 100644
--- a/Source/cmComputeTargetDepends.h
+++ b/Source/cmComputeTargetDepends.h
@@ -45,16 +45,18 @@ private:
void CollectTargets();
void CollectDepends();
void CollectTargetDepends(int depender_index);
- void AddTargetDepend(int depender_index, const char* dependee_name,
+ void AddTargetDepend(int depender_index,
+ const std::string& dependee_name,
bool linking);
void AddTargetDepend(int depender_index, cmTarget const* dependee,
bool linking);
bool ComputeFinalDepends(cmComputeComponentGraph const& ccg);
- void AddInterfaceDepends(int depender_index, const char* dependee_name,
- bool linking, std::set<cmStdString> &emitted);
+ void AddInterfaceDepends(int depender_index,
+ const std::string& dependee_name,
+ bool linking, std::set<std::string> &emitted);
void AddInterfaceDepends(int depender_index, cmTarget const* dependee,
- const char *config,
- std::set<cmStdString> &emitted);
+ const std::string& config,
+ std::set<std::string> &emitted);
cmGlobalGenerator* GlobalGenerator;
bool DebugMode;
bool NoCycles;
@@ -71,7 +73,7 @@ private:
typedef cmGraphAdjacencyList Graph;
Graph InitialGraph;
Graph FinalGraph;
- void DisplayGraph(Graph const& graph, const char* name);
+ void DisplayGraph(Graph const& graph, const std::string& name);
// Deal with connected components.
void DisplayComponents(cmComputeComponentGraph const& ccg);
diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in
index c5e95d0..2b0280d 100644
--- a/Source/cmConfigure.cmake.h.in
+++ b/Source/cmConfigure.cmake.h.in
@@ -16,4 +16,5 @@
#cmakedefine HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE
#cmakedefine HAVE_UNSETENV
#cmakedefine CMAKE_USE_ELF_PARSER
+#cmakedefine CMAKE_ENCODING_UTF8
#define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@"
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index f8ec642..395e6c8 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -38,7 +38,7 @@ bool cmConfigureFileCommand
e << "input location\n"
<< " " << this->InputFile << "\n"
<< "is a directory but a file was expected.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -61,14 +61,14 @@ bool cmConfigureFileCommand
{
std::string e = "attempted to configure a file: " + this->OutputFile
+ " into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
std::string errorMessage;
if (!this->NewLineStyle.ReadFromArguments(args, errorMessage))
{
- this->SetError(errorMessage.c_str());
+ this->SetError(errorMessage);
return false;
}
this->CopyOnly = false;
diff --git a/Source/cmConfigureFileCommand.h b/Source/cmConfigureFileCommand.h
index 86de92c..8155ef7 100644
--- a/Source/cmConfigureFileCommand.h
+++ b/Source/cmConfigureFileCommand.h
@@ -34,7 +34,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "configure_file";}
+ virtual std::string GetName() const { return "configure_file";}
/**
* This determines if the command is invoked when in script mode.
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 7b52069..a3f3277 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -28,7 +28,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
const char* sourceDirectory = argv[2].c_str();
const char* projectName = 0;
- const char* targetName = 0;
+ std::string targetName;
std::vector<std::string> cmakeFlags;
std::vector<std::string> compileDefs;
std::string outputVariable;
@@ -249,7 +249,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
si != sources.end(); ++si)
{
std::string ext = cmSystemTools::GetFilenameLastExtension(*si);
- if(const char* lang = gg->GetLanguageFromExtension(ext.c_str()))
+ std::string lang = gg->GetLanguageFromExtension(ext.c_str());
+ if(!lang.empty())
{
testLangs.insert(lang);
}
@@ -283,7 +284,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
{
cmOStringStream e;
e << "Failed to open\n"
- << " " << outFileName.c_str() << "\n"
+ << " " << outFileName << "\n"
<< cmSystemTools::GetLastSystemError();
this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return -1;
@@ -306,13 +307,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE";
std::string rulesOverrideLang = rulesOverrideBase + "_" + *li;
if(const char* rulesOverridePath =
- this->Makefile->GetDefinition(rulesOverrideLang.c_str()))
+ this->Makefile->GetDefinition(rulesOverrideLang))
{
fprintf(fout, "set(%s \"%s\")\n",
rulesOverrideLang.c_str(), rulesOverridePath);
}
else if(const char* rulesOverridePath2 =
- this->Makefile->GetDefinition(rulesOverrideBase.c_str()))
+ this->Makefile->GetDefinition(rulesOverrideBase))
{
fprintf(fout, "set(%s \"%s\")\n",
rulesOverrideBase.c_str(), rulesOverridePath2);
@@ -324,7 +325,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
li != testLangs.end(); ++li)
{
std::string langFlags = "CMAKE_" + *li + "_FLAGS";
- const char* flags = this->Makefile->GetDefinition(langFlags.c_str());
+ const char* flags = this->Makefile->GetDefinition(langFlags);
fprintf(fout, "set(CMAKE_%s_FLAGS %s)\n", li->c_str(),
lg->EscapeForCMake(flags?flags:"").c_str());
fprintf(fout, "set(CMAKE_%s_FLAGS \"${CMAKE_%s_FLAGS}"
@@ -356,7 +357,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
cmExportTryCompileFileGenerator tcfg;
tcfg.SetExportFile((this->BinaryDirectory + fname).c_str());
tcfg.SetExports(targets);
- tcfg.SetConfig(this->Makefile->GetDefinition(
+ tcfg.SetConfig(this->Makefile->GetSafeDefinition(
"CMAKE_TRY_COMPILE_CONFIGURATION"));
if(!tcfg.GenerateImportFile())
@@ -449,7 +450,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
fprintf(fout, "set(CMAKE_RUNTIME_OUTPUT_DIRECTORY \"%s\")\n",
this->BinaryDirectory.c_str());
/* Create the actual executable. */
- fprintf(fout, "add_executable(%s", targetName);
+ fprintf(fout, "add_executable(%s", targetName.c_str());
for(std::vector<std::string>::iterator si = sources.begin();
si != sources.end(); ++si)
{
@@ -465,12 +466,13 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if (useOldLinkLibs)
{
fprintf(fout,
- "target_link_libraries(%s ${LINK_LIBRARIES})\n",targetName);
+ "target_link_libraries(%s ${LINK_LIBRARIES})\n",
+ targetName.c_str());
}
else
{
fprintf(fout, "target_link_libraries(%s %s)\n",
- targetName,
+ targetName.c_str(),
libsToLink.c_str());
}
fclose(fout);
@@ -482,7 +484,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
std::string output;
// actually do the try compile now that everything is setup
int res = this->Makefile->TryCompile(sourceDirectory,
- this->BinaryDirectory.c_str(),
+ this->BinaryDirectory,
projectName,
targetName,
this->SrcFileSignature,
@@ -494,14 +496,14 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
}
// set the result var to the return value to indicate success or failure
- this->Makefile->AddCacheDefinition(argv[0].c_str(),
+ this->Makefile->AddCacheDefinition(argv[0],
(res == 0 ? "TRUE" : "FALSE"),
"Result of TRY_COMPILE",
cmCacheManager::INTERNAL);
if ( outputVariable.size() > 0 )
{
- this->Makefile->AddDefinition(outputVariable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outputVariable, output.c_str());
}
if (this->SrcFileSignature)
@@ -517,9 +519,9 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
{
cmOStringStream emsg;
emsg << "Cannot copy output executable\n"
- << " '" << this->OutputFile.c_str() << "'\n"
+ << " '" << this->OutputFile << "'\n"
<< "to destination specified by COPY_FILE:\n"
- << " '" << copyFile.c_str() << "'\n";
+ << " '" << copyFile << "'\n";
if(!this->FindErrorMessage.empty())
{
emsg << this->FindErrorMessage.c_str();
@@ -538,7 +540,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv)
if(!copyFileError.empty())
{
- this->Makefile->AddDefinition(copyFileError.c_str(),
+ this->Makefile->AddDefinition(copyFileError,
copyFileErrorMessage.c_str());
}
}
@@ -564,7 +566,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
cmsys::Directory dir;
dir.Load(binDir);
size_t fileNum;
- std::set<cmStdString> deletedFiles;
+ std::set<std::string> deletedFiles;
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum)
{
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)),".") &&
@@ -609,7 +611,7 @@ void cmCoreTryCompile::CleanupFiles(const char* binDir)
}
}
-void cmCoreTryCompile::FindOutputFile(const char* targetName)
+void cmCoreTryCompile::FindOutputFile(const std::string& targetName)
{
this->FindErrorMessage = "";
this->OutputFile = "";
diff --git a/Source/cmCoreTryCompile.h b/Source/cmCoreTryCompile.h
index 5c67f13..3272462 100644
--- a/Source/cmCoreTryCompile.h
+++ b/Source/cmCoreTryCompile.h
@@ -44,7 +44,7 @@ public:
TryCompileCode. The result is stored in OutputFile. If nothing is found,
the error message is stored in FindErrorMessage.
*/
- void FindOutputFile(const char* targetName);
+ void FindOutputFile(const std::string& targetName);
cmTypeMacro(cmCoreTryCompile, cmCommand);
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index de20cb7..02fb8cb 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -169,13 +169,13 @@ bool cmCreateTestSourceList
// Construct the source list.
std::string sourceListValue;
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver.c_str());
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
sf->SetProperty("ABSTRACT","0");
sourceListValue = args[1];
}
for(i = testsBegin; i != tests.end(); ++i)
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(i->c_str());
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
sf->SetProperty("ABSTRACT","0");
sourceListValue += ";";
sourceListValue += *i;
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 8b1e4de..2f6b541 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "create_test_sourcelist";}
+ virtual std::string GetName() const {return "create_test_sourcelist";}
cmTypeMacro(cmCreateTestSourceList, cmCommand);
};
diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx
index 7f4b10f..74e17b6 100644
--- a/Source/cmCryptoHash.cxx
+++ b/Source/cmCryptoHash.cxx
@@ -35,18 +35,18 @@ cmsys::auto_ptr<cmCryptoHash> cmCryptoHash::New(const char* algo)
}
//----------------------------------------------------------------------------
-std::string cmCryptoHash::HashString(const char* input)
+std::string cmCryptoHash::HashString(const std::string& input)
{
this->Initialize();
- this->Append(reinterpret_cast<unsigned char const*>(input),
- static_cast<int>(strlen(input)));
+ this->Append(reinterpret_cast<unsigned char const*>(input.c_str()),
+ static_cast<int>(input.size()));
return this->Finalize();
}
//----------------------------------------------------------------------------
-std::string cmCryptoHash::HashFile(const char* file)
+std::string cmCryptoHash::HashFile(const std::string& file)
{
- cmsys::ifstream fin(file, std::ios::in | cmsys_ios_binary);
+ cmsys::ifstream fin(file.c_str(), std::ios::in | cmsys_ios_binary);
if(!fin)
{
return "";
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 1bea9ab..88cd240 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -21,8 +21,8 @@ class cmCryptoHash
public:
virtual ~cmCryptoHash() {}
static cmsys::auto_ptr<cmCryptoHash> New(const char* algo);
- std::string HashString(const char* input);
- std::string HashFile(const char* file);
+ std::string HashString(const std::string& input);
+ std::string HashFile(const std::string& file);
protected:
virtual void Initialize()=0;
virtual void Append(unsigned char const*, int)=0;
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index b672148..ac2eef8 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -101,16 +101,6 @@ const std::vector<std::string>& cmCustomCommand::GetOutputs() const
}
//----------------------------------------------------------------------------
-const char* cmCustomCommand::GetWorkingDirectory() const
-{
- if(this->WorkingDirectory.size() == 0)
- {
- return 0;
- }
- return this->WorkingDirectory.c_str();
-}
-
-//----------------------------------------------------------------------------
const std::vector<std::string>& cmCustomCommand::GetDepends() const
{
return this->Depends;
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 6851105..b5d7e62 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -42,12 +42,13 @@ public:
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
- /** Get the working directory. */
- const char* GetWorkingDirectory() const;
-
/** Get the vector that holds the list of dependencies. */
const std::vector<std::string>& GetDepends() const;
+ /** Get the working directory. */
+ std::string const& GetWorkingDirectory() const
+ { return this->WorkingDirectory; }
+
/** Get the list of command lines. */
const cmCustomCommandLines& GetCommandLines() const;
@@ -72,7 +73,7 @@ public:
/** Backtrace of the command that created this custom command. */
cmListFileBacktrace const& GetBacktrace() const;
- typedef std::pair<cmStdString, cmStdString> ImplicitDependsPair;
+ typedef std::pair<std::string, std::string> ImplicitDependsPair;
class ImplicitDependsList: public std::vector<ImplicitDependsPair> {};
void SetImplicitDepends(ImplicitDependsList const&);
void AppendImplicitDepends(ImplicitDependsList const&);
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index f24dfa2..cebd9f5 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -18,10 +18,10 @@
//----------------------------------------------------------------------------
cmCustomCommandGenerator::cmCustomCommandGenerator(
- cmCustomCommand const& cc, const char* config, cmMakefile* mf):
+ cmCustomCommand const& cc, const std::string& config, cmMakefile* mf):
CC(cc), Config(config), Makefile(mf), LG(mf->GetLocalGenerator()),
OldStyle(cc.GetEscapeOldStyle()), MakeVars(cc.GetEscapeAllowMakeVars()),
- GE(new cmGeneratorExpression(cc.GetBacktrace()))
+ GE(new cmGeneratorExpression(cc.GetBacktrace())), DependsDone(false)
{
}
@@ -63,11 +63,49 @@ cmCustomCommandGenerator
cmd += " ";
if(this->OldStyle)
{
- cmd += this->LG->EscapeForShellOldStyle(arg.c_str());
+ cmd += this->LG->EscapeForShellOldStyle(arg);
}
else
{
- cmd += this->LG->EscapeForShell(arg.c_str(), this->MakeVars);
+ cmd += this->LG->EscapeForShell(arg, this->MakeVars);
}
}
}
+
+//----------------------------------------------------------------------------
+const char* cmCustomCommandGenerator::GetComment() const
+{
+ return this->CC.GetComment();
+}
+
+//----------------------------------------------------------------------------
+std::string cmCustomCommandGenerator::GetWorkingDirectory() const
+{
+ return this->CC.GetWorkingDirectory();
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
+{
+ return this->CC.GetOutputs();
+}
+
+//----------------------------------------------------------------------------
+std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
+{
+ if (!this->DependsDone)
+ {
+ this->DependsDone = true;
+ std::vector<std::string> depends = this->CC.GetDepends();
+ for(std::vector<std::string>::const_iterator
+ i = depends.begin();
+ i != depends.end(); ++i)
+ {
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
+ = this->GE->Parse(*i);
+ cmSystemTools::ExpandListArgument(
+ cge->Evaluate(this->Makefile, this->Config), this->Depends);
+ }
+ }
+ return this->Depends;
+}
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 4e89f27..0d8a0a4 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -22,19 +22,27 @@ class cmGeneratorExpression;
class cmCustomCommandGenerator
{
cmCustomCommand const& CC;
- const char* Config;
+ std::string Config;
cmMakefile* Makefile;
cmLocalGenerator* LG;
bool OldStyle;
bool MakeVars;
cmGeneratorExpression* GE;
+ mutable bool DependsDone;
+ mutable std::vector<std::string> Depends;
public:
- cmCustomCommandGenerator(cmCustomCommand const& cc, const char* config,
+ cmCustomCommandGenerator(cmCustomCommand const& cc,
+ const std::string& config,
cmMakefile* mf);
~cmCustomCommandGenerator();
+ cmCustomCommand const& GetCC() const { return this->CC; }
unsigned int GetNumberOfCommands() const;
std::string GetCommand(unsigned int c) const;
void AppendArguments(unsigned int c, std::string& cmd) const;
+ const char* GetComment() const;
+ std::string GetWorkingDirectory() const;
+ std::vector<std::string> const& GetOutputs() const;
+ std::vector<std::string> const& GetDepends() const;
};
#endif
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 1ad98af..6b729de 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -58,7 +58,7 @@ bool cmDefinePropertyCommand
<< "Valid scopes are "
<< "GLOBAL, DIRECTORY, TARGET, SOURCE, "
<< "TEST, VARIABLE, CACHED_VARIABLE.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -102,7 +102,7 @@ bool cmDefinePropertyCommand
{
cmOStringStream e;
e << "given invalid argument \"" << args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -128,7 +128,7 @@ bool cmDefinePropertyCommand
// Actually define the property.
this->Makefile->GetCMakeInstance()->DefineProperty
- (this->PropertyName.c_str(), scope,
+ (this->PropertyName, scope,
this->BriefDocs.c_str(), this->FullDocs.c_str(), inherited);
return true;
diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h
index 8dc4d96..bc5c8a4 100644
--- a/Source/cmDefinePropertyCommand.h
+++ b/Source/cmDefinePropertyCommand.h
@@ -32,7 +32,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "define_property";}
+ virtual std::string GetName() const { return "define_property";}
cmTypeMacro(cmDefinePropertyCommand, cmCommand);
private:
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index 9d28700..babf1c4 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -28,7 +28,7 @@ void cmDefinitions::Reset(cmDefinitions* parent)
//----------------------------------------------------------------------------
cmDefinitions::Def const&
-cmDefinitions::GetInternal(const char* key)
+cmDefinitions::GetInternal(const std::string& key)
{
MapType::const_iterator i = this->Map.find(key);
if(i != this->Map.end())
@@ -46,7 +46,7 @@ cmDefinitions::GetInternal(const char* key)
//----------------------------------------------------------------------------
cmDefinitions::Def const&
-cmDefinitions::SetInternal(const char* key, Def const& def)
+cmDefinitions::SetInternal(const std::string& key, Def const& def)
{
if(this->Up || def.Exists)
{
@@ -71,23 +71,23 @@ cmDefinitions::SetInternal(const char* key, Def const& def)
}
//----------------------------------------------------------------------------
-const char* cmDefinitions::Get(const char* key)
+const char* cmDefinitions::Get(const std::string& key)
{
Def const& def = this->GetInternal(key);
return def.Exists? def.c_str() : 0;
}
//----------------------------------------------------------------------------
-const char* cmDefinitions::Set(const char* key, const char* value)
+const char* cmDefinitions::Set(const std::string& key, const char* value)
{
Def const& def = this->SetInternal(key, Def(value));
return def.Exists? def.c_str() : 0;
}
//----------------------------------------------------------------------------
-std::set<cmStdString> cmDefinitions::LocalKeys() const
+std::set<std::string> cmDefinitions::LocalKeys() const
{
- std::set<cmStdString> keys;
+ std::set<std::string> keys;
// Consider local definitions.
for(MapType::const_iterator mi = this->Map.begin();
mi != this->Map.end(); ++mi)
@@ -110,12 +110,12 @@ cmDefinitions cmDefinitions::Closure() const
cmDefinitions::cmDefinitions(ClosureTag const&, cmDefinitions const* root):
Up(0)
{
- std::set<cmStdString> undefined;
+ std::set<std::string> undefined;
this->ClosureImpl(undefined, root);
}
//----------------------------------------------------------------------------
-void cmDefinitions::ClosureImpl(std::set<cmStdString>& undefined,
+void cmDefinitions::ClosureImpl(std::set<std::string>& undefined,
cmDefinitions const* defs)
{
// Consider local definitions.
@@ -145,17 +145,17 @@ void cmDefinitions::ClosureImpl(std::set<cmStdString>& undefined,
}
//----------------------------------------------------------------------------
-std::set<cmStdString> cmDefinitions::ClosureKeys() const
+std::set<std::string> cmDefinitions::ClosureKeys() const
{
- std::set<cmStdString> defined;
- std::set<cmStdString> undefined;
+ std::set<std::string> defined;
+ std::set<std::string> undefined;
this->ClosureKeys(defined, undefined);
return defined;
}
//----------------------------------------------------------------------------
-void cmDefinitions::ClosureKeys(std::set<cmStdString>& defined,
- std::set<cmStdString>& undefined) const
+void cmDefinitions::ClosureKeys(std::set<std::string>& defined,
+ std::set<std::string>& undefined) const
{
// Consider local definitions.
for(MapType::const_iterator mi = this->Map.begin();
@@ -165,7 +165,7 @@ void cmDefinitions::ClosureKeys(std::set<cmStdString>& defined,
if(defined.find(mi->first) == defined.end() &&
undefined.find(mi->first) == undefined.end())
{
- std::set<cmStdString>& m = mi->second.Exists? defined : undefined;
+ std::set<std::string>& m = mi->second.Exists? defined : undefined;
m.insert(mi->first);
}
}
diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h
index 4834d84..d615fb0 100644
--- a/Source/cmDefinitions.h
+++ b/Source/cmDefinitions.h
@@ -35,28 +35,32 @@ public:
/** Get the value associated with a key; null if none.
Store the result locally if it came from a parent. */
- const char* Get(const char* key);
+ const char* Get(const std::string& key);
/** Set (or unset if null) a value associated with a key. */
- const char* Set(const char* key, const char* value);
+ const char* Set(const std::string& key, const char* value);
/** Get the set of all local keys. */
- std::set<cmStdString> LocalKeys() const;
+ std::set<std::string> LocalKeys() const;
/** Compute the closure of all defined keys with values.
This flattens the scope. The result has no parent. */
cmDefinitions Closure() const;
/** Compute the set of all defined keys. */
- std::set<cmStdString> ClosureKeys() const;
+ std::set<std::string> ClosureKeys() const;
private:
// String with existence boolean.
- struct Def: public cmStdString
+ struct Def: public std::string
{
- Def(): cmStdString(), Exists(false) {}
- Def(const char* v): cmStdString(v?v:""), Exists(v?true:false) {}
- Def(Def const& d): cmStdString(d), Exists(d.Exists) {}
+ private:
+ typedef std::string std_string;
+ public:
+ Def(): std_string(), Exists(false) {}
+ Def(const char* v): std_string(v?v:""), Exists(v?true:false) {}
+ Def(const std_string& v): std_string(v), Exists(true) {}
+ Def(Def const& d): std_string(d), Exists(d.Exists) {}
bool Exists;
};
static Def NoDef;
@@ -65,22 +69,22 @@ private:
cmDefinitions* Up;
// Local definitions, set or unset.
- typedef std::map<cmStdString, Def> MapType;
+ typedef std::map<std::string, Def> MapType;
MapType Map;
// Internal query and update methods.
- Def const& GetInternal(const char* key);
- Def const& SetInternal(const char* key, Def const& def);
+ Def const& GetInternal(const std::string& key);
+ Def const& SetInternal(const std::string& key, Def const& def);
// Implementation of Closure() method.
struct ClosureTag {};
cmDefinitions(ClosureTag const&, cmDefinitions const* root);
- void ClosureImpl(std::set<cmStdString>& undefined,
+ void ClosureImpl(std::set<std::string>& undefined,
cmDefinitions const* defs);
// Implementation of ClosureKeys() method.
- void ClosureKeys(std::set<cmStdString>& defined,
- std::set<cmStdString>& undefined) const;
+ void ClosureKeys(std::set<std::string>& defined,
+ std::set<std::string>& undefined) const;
};
#endif
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index 1a0e93f..50a395e 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -47,7 +47,7 @@ bool cmDepends::Write(std::ostream &makeDepends,
std::string srcLang = "CMAKE_DEPENDS_CHECK_";
srcLang += this->Language;
cmMakefile* mf = this->LocalGenerator->GetMakefile();
- const char* srcStr = mf->GetSafeDefinition(srcLang.c_str());
+ const char* srcStr = mf->GetSafeDefinition(srcLang);
std::vector<std::string> pairs;
cmSystemTools::ExpandListArgument(srcStr, pairs);
@@ -61,7 +61,7 @@ bool cmDepends::Write(std::ostream &makeDepends,
std::string obj = *si++;
// Make sure the object file is relative to the top of the build tree.
- obj = this->LocalGenerator->Convert(obj.c_str(),
+ obj = this->LocalGenerator->Convert(obj,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
dependencies[obj].insert(src);
@@ -297,7 +297,7 @@ bool cmDepends::CheckDependencies(std::istream& internalDepends,
}
//----------------------------------------------------------------------------
-void cmDepends::SetIncludePathFromLanguage(const char* lang)
+void cmDepends::SetIncludePathFromLanguage(const std::string& lang)
{
// Look for the new per "TARGET_" variant first:
const char * includePath = 0;
@@ -305,7 +305,7 @@ void cmDepends::SetIncludePathFromLanguage(const char* lang)
includePathVar += lang;
includePathVar += "_TARGET_INCLUDE_PATH";
cmMakefile* mf = this->LocalGenerator->GetMakefile();
- includePath = mf->GetDefinition(includePathVar.c_str());
+ includePath = mf->GetDefinition(includePathVar);
if(includePath)
{
cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
@@ -316,7 +316,7 @@ void cmDepends::SetIncludePathFromLanguage(const char* lang)
includePathVar = "CMAKE_";
includePathVar += lang;
includePathVar += "_INCLUDE_PATH";
- includePath = mf->GetDefinition(includePathVar.c_str());
+ includePath = mf->GetDefinition(includePathVar);
if(includePath)
{
cmSystemTools::ExpandListArgument(includePath, this->IncludePath);
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index d787edd..4f6517e 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -32,7 +32,7 @@ public:
cmDepends(cmLocalGenerator* lg=0, const char* targetDir="");
/** at what level will the compile be done from */
- void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;};
+ void SetCompileDirectory(const char *dir) {this->CompileDirectory = dir;}
/** Set the local generator for the directory in which we are
scanning dependencies. This is not a full local generator; it
@@ -41,7 +41,7 @@ public:
void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
/** Set the specific language to be scanned. */
- void SetLanguage(const char* lang) { this->Language = lang; }
+ void SetLanguage(const std::string& lang) { this->Language = lang; }
/** Set the target build directory. */
void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
@@ -114,7 +114,7 @@ protected:
// The include file search path.
std::vector<std::string> IncludePath;
- void SetIncludePathFromLanguage(const char* lang);
+ void SetIncludePathFromLanguage(const std::string& lang);
private:
cmDepends(cmDepends const&); // Purposely not implemented.
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 4fc5efb..d26d3a9 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -37,7 +37,7 @@ cmDependsC::cmDependsC()
//----------------------------------------------------------------------------
cmDependsC::cmDependsC(cmLocalGenerator* lg,
const char* targetDir,
- const char* lang,
+ const std::string& lang,
const std::map<std::string, DependencyVector>* validDeps)
: cmDepends(lg, targetDir)
, ValidDeps(validDeps)
@@ -54,14 +54,14 @@ cmDependsC::cmDependsC(cmLocalGenerator* lg,
std::string scanRegexVar = "CMAKE_";
scanRegexVar += lang;
scanRegexVar += "_INCLUDE_REGEX_SCAN";
- if(const char* sr = mf->GetDefinition(scanRegexVar.c_str()))
+ if(const char* sr = mf->GetDefinition(scanRegexVar))
{
scanRegex = sr;
}
std::string complainRegexVar = "CMAKE_";
complainRegexVar += lang;
complainRegexVar += "_INCLUDE_REGEX_COMPLAIN";
- if(const char* cr = mf->GetDefinition(complainRegexVar.c_str()))
+ if(const char* cr = mf->GetDefinition(complainRegexVar))
{
complainRegex = cr;
}
@@ -91,7 +91,7 @@ cmDependsC::~cmDependsC()
{
this->WriteCacheFile();
- for (std::map<cmStdString, cmIncludeLines*>::iterator it=
+ for (std::map<std::string, cmIncludeLines*>::iterator it=
this->FileCache.begin(); it!=this->FileCache.end(); ++it)
{
delete it->second;
@@ -116,7 +116,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
return false;
}
- std::set<cmStdString> dependencies;
+ std::set<std::string> dependencies;
bool haveDeps = false;
if (this->ValidDeps != 0)
@@ -149,7 +149,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
this->Encountered.insert(*srcIt);
}
- std::set<cmStdString> scanned;
+ std::set<std::string> scanned;
// Use reserve to allocate enough memory for tempPathStr
// so that during the loops no memory is allocated or freed
@@ -182,7 +182,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
}
else
{
- std::map<cmStdString, cmStdString>::iterator
+ std::map<std::string, std::string>::iterator
headerLocationIt=this->HeaderLocationCache.find(current.FileName);
if (headerLocationIt!=this->HeaderLocationCache.end())
{
@@ -224,7 +224,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
scanned.insert(fullName);
// Check whether this file is already in the cache
- std::map<cmStdString, cmIncludeLines*>::iterator fileIt=
+ std::map<std::string, cmIncludeLines*>::iterator fileIt=
this->FileCache.find(fullName);
if (fileIt!=this->FileCache.end())
{
@@ -270,15 +270,15 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// convert the dependencies to paths relative to the home output
// directory. We must do the same here.
internalDepends << obj << std::endl;
- for(std::set<cmStdString>::const_iterator i=dependencies.begin();
+ for(std::set<std::string>::const_iterator i=dependencies.begin();
i != dependencies.end(); ++i)
{
makeDepends << obj << ": " <<
- this->LocalGenerator->Convert(i->c_str(),
+ this->LocalGenerator->Convert(*i,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< std::endl;
- internalDepends << " " << i->c_str() << std::endl;
+ internalDepends << " " << *i << std::endl;
}
makeDepends << std::endl;
@@ -392,7 +392,7 @@ void cmDependsC::WriteCacheFile() const
cacheOut << this->IncludeRegexComplainString << "\n\n";
cacheOut << this->IncludeRegexTransformString << "\n\n";
- for (std::map<cmStdString, cmIncludeLines*>::const_iterator fileIt=
+ for (std::map<std::string, cmIncludeLines*>::const_iterator fileIt=
this->FileCache.begin();
fileIt!=this->FileCache.end(); ++fileIt)
{
@@ -421,7 +421,7 @@ void cmDependsC::WriteCacheFile() const
//----------------------------------------------------------------------------
void cmDependsC::Scan(std::istream& is, const char* directory,
- const cmStdString& fullName)
+ const std::string& fullName)
{
cmIncludeLines* newCacheEntry=new cmIncludeLines;
newCacheEntry->Used=true;
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index 16dfad7..07d3c21 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -25,7 +25,8 @@ public:
/** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */
cmDependsC();
- cmDependsC(cmLocalGenerator* lg, const char* targetDir, const char* lang,
+ cmDependsC(cmLocalGenerator* lg, const char* targetDir,
+ const std::string& lang,
const std::map<std::string, DependencyVector>* validDeps);
/** Virtual destructor to cleanup subclasses properly. */
@@ -40,7 +41,7 @@ protected:
// Method to scan a single file.
void Scan(std::istream& is, const char* directory,
- const cmStdString& fullName);
+ const std::string& fullName);
// Regular expression to identify C preprocessor include directives.
cmsys::RegularExpression IncludeRegexLine;
@@ -56,7 +57,7 @@ protected:
// Regex to transform #include lines.
std::string IncludeRegexTransformString;
cmsys::RegularExpression IncludeRegexTransform;
- typedef std::map<cmStdString, cmStdString> TransformRulesType;
+ typedef std::map<std::string, std::string> TransformRulesType;
TransformRulesType TransformRules;
void SetupTransforms();
void ParseTransform(std::string const& xform);
@@ -66,8 +67,8 @@ public:
// Data structures for dependency graph walk.
struct UnscannedEntry
{
- cmStdString FileName;
- cmStdString QuotedLocation;
+ std::string FileName;
+ std::string QuotedLocation;
};
struct cmIncludeLines
@@ -78,13 +79,13 @@ public:
};
protected:
const std::map<std::string, DependencyVector>* ValidDeps;
- std::set<cmStdString> Encountered;
+ std::set<std::string> Encountered;
std::queue<UnscannedEntry> Unscanned;
- std::map<cmStdString, cmIncludeLines *> FileCache;
- std::map<cmStdString, cmStdString> HeaderLocationCache;
+ std::map<std::string, cmIncludeLines *> FileCache;
+ std::map<std::string, std::string> HeaderLocationCache;
- cmStdString CacheFileName;
+ std::string CacheFileName;
void WriteCacheFile() const;
void ReadCacheFile();
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index d5472a1..79cb560 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -34,11 +34,11 @@ public:
std::string Source;
// Set of provided and required modules.
- std::set<cmStdString> Provides;
- std::set<cmStdString> Requires;
+ std::set<std::string> Provides;
+ std::set<std::string> Requires;
// Set of files included in the translation unit.
- std::set<cmStdString> Includes;
+ std::set<std::string> Includes;
};
//----------------------------------------------------------------------------
@@ -98,24 +98,24 @@ class cmDependsFortranInternals
{
public:
// The set of modules provided by this target.
- std::set<cmStdString> TargetProvides;
+ std::set<std::string> TargetProvides;
// Map modules required by this target to locations.
- typedef std::map<cmStdString, cmStdString> TargetRequiresMap;
+ typedef std::map<std::string, std::string> TargetRequiresMap;
TargetRequiresMap TargetRequires;
// Information about each object file.
- typedef std::map<cmStdString, cmDependsFortranSourceInfo> ObjectInfoMap;
+ typedef std::map<std::string, cmDependsFortranSourceInfo> ObjectInfoMap;
ObjectInfoMap ObjectInfo;
cmDependsFortranSourceInfo& CreateObjectInfo(const char* obj,
const char* src)
{
- std::map<cmStdString, cmDependsFortranSourceInfo>::iterator i =
+ std::map<std::string, cmDependsFortranSourceInfo>::iterator i =
this->ObjectInfo.find(obj);
if(i == this->ObjectInfo.end())
{
- std::map<cmStdString, cmDependsFortranSourceInfo>::value_type
+ std::map<std::string, cmDependsFortranSourceInfo>::value_type
entry(obj, cmDependsFortranSourceInfo());
i = this->ObjectInfo.insert(entry).first;
i->second.Source = src;
@@ -260,8 +260,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
cmGeneratedFileStream fiStream(fiName.c_str());
fiStream << "# The fortran modules provided by this target.\n";
fiStream << "provides\n";
- std::set<cmStdString> const& provides = this->Internal->TargetProvides;
- for(std::set<cmStdString>::const_iterator i = provides.begin();
+ std::set<std::string> const& provides = this->Internal->TargetProvides;
+ for(std::set<std::string>::const_iterator i = provides.begin();
i != provides.end(); ++i)
{
fiStream << " " << *i << "\n";
@@ -275,7 +275,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
cmGeneratedFileStream fcStream(fcName.c_str());
fcStream << "# Remove fortran modules provided by this target.\n";
fcStream << "FILE(REMOVE";
- for(std::set<cmStdString>::const_iterator i = provides.begin();
+ for(std::set<std::string>::const_iterator i = provides.begin();
i != provides.end(); ++i)
{
std::string mod_upper = mod_dir;
@@ -292,15 +292,15 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
stamp += ".mod.stamp";
fcStream << "\n";
fcStream << " \"" <<
- this->LocalGenerator->Convert(mod_lower.c_str(),
+ this->LocalGenerator->Convert(mod_lower,
cmLocalGenerator::START_OUTPUT)
<< "\"\n";
fcStream << " \"" <<
- this->LocalGenerator->Convert(mod_upper.c_str(),
+ this->LocalGenerator->Convert(mod_upper,
cmLocalGenerator::START_OUTPUT)
<< "\"\n";
fcStream << " \"" <<
- this->LocalGenerator->Convert(stamp.c_str(),
+ this->LocalGenerator->Convert(stamp,
cmLocalGenerator::START_OUTPUT)
<< "\"\n";
}
@@ -319,14 +319,14 @@ void cmDependsFortran::LocateModules()
infoI != objInfo.end(); ++infoI)
{
cmDependsFortranSourceInfo const& info = infoI->second;
- for(std::set<cmStdString>::const_iterator i = info.Provides.begin();
+ 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);
}
- for(std::set<cmStdString>::const_iterator i = info.Requires.begin();
+ 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.
@@ -368,8 +368,8 @@ void cmDependsFortran::LocateModules()
void cmDependsFortran::MatchLocalModules()
{
const char* stampDir = this->TargetDirectory.c_str();
- std::set<cmStdString> const& provides = this->Internal->TargetProvides;
- for(std::set<cmStdString>::const_iterator i = provides.begin();
+ std::set<std::string> const& provides = this->Internal->TargetProvides;
+ for(std::set<std::string>::const_iterator i = provides.begin();
i != provides.end(); ++i)
{
this->ConsiderModule(i->c_str(), stampDir);
@@ -445,24 +445,24 @@ cmDependsFortran
// Write the include dependencies to the output stream.
internalDepends << obj << std::endl;
internalDepends << " " << src << std::endl;
- for(std::set<cmStdString>::const_iterator i = info.Includes.begin();
+ for(std::set<std::string>::const_iterator i = info.Includes.begin();
i != info.Includes.end(); ++i)
{
makeDepends << obj << ": " <<
- this->LocalGenerator->Convert(i->c_str(),
+ this->LocalGenerator->Convert(*i,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< std::endl;
- internalDepends << " " << i->c_str() << std::endl;
+ internalDepends << " " << *i << std::endl;
}
makeDepends << std::endl;
// Write module requirements to the output stream.
- for(std::set<cmStdString>::const_iterator i = info.Requires.begin();
+ for(std::set<std::string>::const_iterator i = info.Requires.begin();
i != info.Requires.end(); ++i)
{
// Require only modules not provided in the same source.
- if(std::set<cmStdString>::const_iterator(info.Provides.find(*i)) !=
+ if(std::set<std::string>::const_iterator(info.Provides.find(*i)) !=
info.Provides.end())
{
continue;
@@ -480,7 +480,7 @@ cmDependsFortran
proxy += "/";
proxy += *i;
proxy += ".mod.proxy";
- proxy = this->LocalGenerator->Convert(proxy.c_str(),
+ proxy = this->LocalGenerator->Convert(proxy,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
@@ -497,7 +497,7 @@ cmDependsFortran
{
// This module is known. Depend on its timestamp file.
std::string stampFile =
- this->LocalGenerator->Convert(required->second.c_str(),
+ this->LocalGenerator->Convert(required->second,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
makeDepends << obj << ": " << stampFile << "\n";
@@ -510,7 +510,7 @@ cmDependsFortran
if(this->FindModule(*i, module))
{
module =
- this->LocalGenerator->Convert(module.c_str(),
+ this->LocalGenerator->Convert(module,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
makeDepends << obj << ": " << module << "\n";
@@ -519,14 +519,14 @@ cmDependsFortran
}
// Write provided modules to the output stream.
- for(std::set<cmStdString>::const_iterator i = info.Provides.begin();
+ for(std::set<std::string>::const_iterator i = info.Provides.begin();
i != info.Provides.end(); ++i)
{
std::string proxy = stamp_dir;
proxy += "/";
proxy += *i;
proxy += ".mod.proxy";
- proxy = this->LocalGenerator->Convert(proxy.c_str(),
+ proxy = this->LocalGenerator->Convert(proxy,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
makeDepends << proxy << ": " << obj << ".provides" << std::endl;
@@ -538,7 +538,7 @@ cmDependsFortran
// Create a target to copy the module after the object file
// changes.
makeDepends << obj << ".provides.build:\n";
- for(std::set<cmStdString>::const_iterator i = info.Provides.begin();
+ 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.
@@ -552,7 +552,7 @@ cmDependsFortran
modFile += "/";
modFile += *i;
modFile =
- this->LocalGenerator->Convert(modFile.c_str(),
+ this->LocalGenerator->Convert(modFile,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::SHELL);
std::string stampFile = stamp_dir;
@@ -560,7 +560,7 @@ cmDependsFortran
stampFile += m;
stampFile += ".mod.stamp";
stampFile =
- this->LocalGenerator->Convert(stampFile.c_str(),
+ this->LocalGenerator->Convert(stampFile,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::SHELL);
makeDepends << "\t$(CMAKE_COMMAND) -E cmake_copy_f90_mod "
@@ -582,7 +582,7 @@ cmDependsFortran
// the target finishes building.
std::string driver = this->TargetDirectory;
driver += "/build";
- driver = this->LocalGenerator->Convert(driver.c_str(),
+ driver = this->LocalGenerator->Convert(driver,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
makeDepends << driver << ": " << obj << ".provides.build\n";
@@ -666,7 +666,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
if(!cmSystemTools::CopyFileAlways(mod_upper.c_str(), stamp.c_str()))
{
std::cerr << "Error copying Fortran module from \""
- << mod_upper.c_str() << "\" to \"" << stamp.c_str()
+ << mod_upper << "\" to \"" << stamp
<< "\".\n";
return false;
}
@@ -681,7 +681,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
if(!cmSystemTools::CopyFileAlways(mod_lower.c_str(), stamp.c_str()))
{
std::cerr << "Error copying Fortran module from \""
- << mod_lower.c_str() << "\" to \"" << stamp.c_str()
+ << mod_lower << "\" to \"" << stamp
<< "\".\n";
return false;
}
@@ -689,9 +689,9 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
return true;
}
- std::cerr << "Error copying Fortran module \"" << args[2].c_str()
- << "\". Tried \"" << mod_upper.c_str()
- << "\" and \"" << mod_lower.c_str() << "\".\n";
+ std::cerr << "Error copying Fortran module \"" << args[2]
+ << "\". Tried \"" << mod_upper
+ << "\" and \"" << mod_lower << "\".\n";
return false;
}
diff --git a/Source/cmDependsJavaLexer.cxx b/Source/cmDependsJavaLexer.cxx
index 1e505a5..f7676d9 100644
--- a/Source/cmDependsJavaLexer.cxx
+++ b/Source/cmDependsJavaLexer.cxx
@@ -1591,7 +1591,7 @@ case YY_STATE_EOF(string):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
-return 0; /* this should not happen but it silences a warning*/
+return 0; /* this should not happen but it quiets some compilers */
} /* end of cmDependsJava_yylex */
/* yy_get_next_buffer - try to read in a new buffer
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index c30d4bd..02f2d21 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -36,10 +36,10 @@ cmDependsJavaParserHelper::~cmDependsJavaParserHelper()
}
void cmDependsJavaParserHelper::CurrentClass
-::AddFileNamesForPrinting(std::vector<cmStdString> *files,
+::AddFileNamesForPrinting(std::vector<std::string> *files,
const char* prefix, const char* sep)
{
- cmStdString rname = "";
+ std::string rname = "";
if ( prefix )
{
rname += prefix;
@@ -76,7 +76,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
{
return;
}
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for ( it = this->ClassesFound.begin();
it != this->ClassesFound.end();
it ++ )
@@ -91,7 +91,7 @@ void cmDependsJavaParserHelper::AddClassFound(const char* sclass)
void cmDependsJavaParserHelper::AddPackagesImport(const char* sclass)
{
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for ( it = this->PackagesImport.begin();
it != this->PackagesImport.end();
it ++ )
@@ -256,19 +256,19 @@ void cmDependsJavaParserHelper::PrintClasses()
std::cerr << "Error when parsing. No classes on class stack" << std::endl;
abort();
}
- std::vector<cmStdString> files = this->GetFilesProduced();
- std::vector<cmStdString>::iterator sit;
+ std::vector<std::string> files = this->GetFilesProduced();
+ std::vector<std::string>::iterator sit;
for ( sit = files.begin();
sit != files.end();
++ sit )
{
- std::cout << " " << sit->c_str() << ".class" << std::endl;
+ std::cout << " " << *sit << ".class" << std::endl;
}
}
-std::vector<cmStdString> cmDependsJavaParserHelper::GetFilesProduced()
+std::vector<std::string> cmDependsJavaParserHelper::GetFilesProduced()
{
- std::vector<cmStdString> files;
+ std::vector<std::string> files;
CurrentClass* toplevel = &(*(this->ClassStack.begin()));
std::vector<CurrentClass>::iterator it;
for ( it = toplevel->NestedClasses->begin();
@@ -308,29 +308,29 @@ int cmDependsJavaParserHelper::ParseString(const char* str, int verb)
if ( this->CurrentPackage.size() > 0 )
{
std::cout << "Current package is: " <<
- this->CurrentPackage.c_str() << std::endl;
+ this->CurrentPackage << std::endl;
}
std::cout << "Imports packages:";
if ( this->PackagesImport.size() > 0 )
{
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for ( it = this->PackagesImport.begin();
it != this->PackagesImport.end();
++ it )
{
- std::cout << " " << it->c_str();
+ std::cout << " " << *it;
}
}
std::cout << std::endl;
std::cout << "Depends on:";
if ( this->ClassesFound.size() > 0 )
{
- std::vector<cmStdString>::iterator it;
+ std::vector<std::string>::iterator it;
for ( it = this->ClassesFound.begin();
it != this->ClassesFound.end();
++ it )
{
- std::cout << " " << it->c_str();
+ std::cout << " " << *it;
}
}
std::cout << std::endl;
@@ -419,8 +419,8 @@ int cmDependsJavaParserHelper::ParseFile(const char* file)
return 0;
}
- cmStdString fullfile = "";
- cmStdString line;
+ std::string fullfile = "";
+ std::string line;
while ( cmSystemTools::GetLineFromStream(ifs, line) )
{
fullfile += line + "\n";
diff --git a/Source/cmDependsJavaParserHelper.h b/Source/cmDependsJavaParserHelper.h
index 9807a04..5542018 100644
--- a/Source/cmDependsJavaParserHelper.h
+++ b/Source/cmDependsJavaParserHelper.h
@@ -59,15 +59,15 @@ public:
const char* GetCurrentCombine() { return this->CurrentCombine.c_str(); }
void UpdateCombine(const char* str1, const char* str2);
- std::vector<cmStdString>& GetClassesFound() { return this->ClassesFound; }
+ std::vector<std::string>& GetClassesFound() { return this->ClassesFound; }
- std::vector<cmStdString> GetFilesProduced();
+ std::vector<std::string> GetFilesProduced();
private:
class CurrentClass
{
public:
- cmStdString Name;
+ std::string Name;
std::vector<CurrentClass>* NestedClasses;
CurrentClass()
{
@@ -93,16 +93,16 @@ private:
{
(*this) = c;
}
- void AddFileNamesForPrinting(std::vector<cmStdString> *files,
+ void AddFileNamesForPrinting(std::vector<std::string> *files,
const char* prefix, const char* sep);
};
- cmStdString CurrentPackage;
- cmStdString::size_type InputBufferPos;
- cmStdString InputBuffer;
+ std::string CurrentPackage;
+ std::string::size_type InputBufferPos;
+ std::string InputBuffer;
std::vector<char> OutputBuffer;
- std::vector<cmStdString> ClassesFound;
- std::vector<cmStdString> PackagesImport;
- cmStdString CurrentCombine;
+ std::vector<std::string> ClassesFound;
+ std::vector<std::string> PackagesImport;
+ std::string CurrentCombine;
std::vector<CurrentClass> ClassStack;
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index 9c27fc1..d421889 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -477,9 +477,9 @@ bool cmDocumentation::CheckOptions(int argc, const char* const* argv,
}
//----------------------------------------------------------------------------
-void cmDocumentation::SetName(const char* name)
+void cmDocumentation::SetName(const std::string& name)
{
- this->NameString = name?name:"";
+ this->NameString = name;
}
//----------------------------------------------------------------------------
@@ -672,7 +672,7 @@ bool cmDocumentation::PrintFiles(std::ostream& os,
for (std::vector<std::string>::const_iterator i = files.begin();
i != files.end(); ++i)
{
- found = r.ProcessFile(i->c_str()) || found;
+ found = r.ProcessFile(*i) || found;
}
return found;
}
@@ -693,7 +693,7 @@ bool cmDocumentation::PrintHelpOneManual(std::ostream& os)
return true;
}
// Argument was not a manual. Complain.
- os << "Argument \"" << this->CurrentArgument.c_str()
+ os << "Argument \"" << this->CurrentArgument
<< "\" to --help-manual is not an available manual. "
<< "Use --help-manual-list to see all available manuals.\n";
return false;
@@ -715,7 +715,7 @@ bool cmDocumentation::PrintHelpOneCommand(std::ostream& os)
return true;
}
// Argument was not a command. Complain.
- os << "Argument \"" << this->CurrentArgument.c_str()
+ os << "Argument \"" << this->CurrentArgument
<< "\" to --help-command is not a CMake command. "
<< "Use --help-command-list to see all commands.\n";
return false;
@@ -737,7 +737,7 @@ bool cmDocumentation::PrintHelpOneModule(std::ostream& os)
return true;
}
// Argument was not a module. Complain.
- os << "Argument \"" << this->CurrentArgument.c_str()
+ os << "Argument \"" << this->CurrentArgument
<< "\" to --help-module is not a CMake module.\n";
return false;
}
@@ -772,7 +772,7 @@ bool cmDocumentation::PrintHelpOneProperty(std::ostream& os)
return true;
}
// Argument was not a property. Complain.
- os << "Argument \"" << this->CurrentArgument.c_str()
+ os << "Argument \"" << this->CurrentArgument
<< "\" to --help-property is not a CMake property. "
<< "Use --help-property-list to see all properties.\n";
return false;
@@ -796,7 +796,7 @@ bool cmDocumentation::PrintHelpOnePolicy(std::ostream& os)
}
// Argument was not a policy. Complain.
- os << "Argument \"" << this->CurrentArgument.c_str()
+ os << "Argument \"" << this->CurrentArgument
<< "\" to --help-policy is not a CMake policy.\n";
return false;
}
@@ -817,7 +817,7 @@ bool cmDocumentation::PrintHelpOneVariable(std::ostream& os)
return true;
}
// Argument was not a variable. Complain.
- os << "Argument \"" << this->CurrentArgument.c_str()
+ os << "Argument \"" << this->CurrentArgument
<< "\" to --help-variable is not a defined variable. "
<< "Use --help-variable-list to see all defined variables.\n";
return false;
diff --git a/Source/cmDocumentation.h b/Source/cmDocumentation.h
index d5a7dd5..56a4151 100644
--- a/Source/cmDocumentation.h
+++ b/Source/cmDocumentation.h
@@ -56,7 +56,7 @@ public:
void SetShowGenerators(bool showGen) { this->ShowGenerators = showGen; }
/** Set the program name for standard document generation. */
- void SetName(const char* name);
+ void SetName(const std::string& name);
/** Set a section of the documentation. Typical sections include Name,
Usage, Description, Options */
diff --git a/Source/cmDocumentationSection.h b/Source/cmDocumentationSection.h
index 636860d..d796da8 100644
--- a/Source/cmDocumentationSection.h
+++ b/Source/cmDocumentationSection.h
@@ -34,8 +34,8 @@ public:
void Clear() { this->Entries.clear(); }
/** Return the name of this section. */
- const char* GetName() const
- { return this->Name.c_str(); }
+ std::string GetName() const
+ { return this->Name; }
/** Return a pointer to the first entry of this section. */
const std::vector<cmDocumentationEntry> &GetEntries() const
diff --git a/Source/cmDynamicLoader.cxx b/Source/cmDynamicLoader.cxx
index 6a0ab7b..944a000 100644
--- a/Source/cmDynamicLoader.cxx
+++ b/Source/cmDynamicLoader.cxx
@@ -23,7 +23,7 @@ public:
static cmDynamicLoaderCache* GetInstance();
private:
- std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle> CacheMap;
+ std::map<std::string, cmsys::DynamicLoader::LibraryHandle> CacheMap;
static cmDynamicLoaderCache* Instance;
};
@@ -47,7 +47,7 @@ void cmDynamicLoaderCache::CacheFile(const char* path,
bool cmDynamicLoaderCache::GetCacheFile(const char* path,
cmsys::DynamicLoader::LibraryHandle& p)
{
- std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle>::iterator it
+ std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
= this->CacheMap.find(path);
if ( it != this->CacheMap.end() )
{
@@ -59,7 +59,7 @@ bool cmDynamicLoaderCache::GetCacheFile(const char* path,
bool cmDynamicLoaderCache::FlushCache(const char* path)
{
- std::map<cmStdString, cmsys::DynamicLoader::LibraryHandle>::iterator it
+ std::map<std::string, cmsys::DynamicLoader::LibraryHandle>::iterator it
= this->CacheMap.find(path);
bool ret = false;
if ( it != this->CacheMap.end() )
@@ -73,7 +73,7 @@ bool cmDynamicLoaderCache::FlushCache(const char* path)
void cmDynamicLoaderCache::FlushCache()
{
- for ( std::map<cmStdString,
+ for ( std::map<std::string,
cmsys::DynamicLoader::LibraryHandle>::iterator it
= this->CacheMap.begin();
it != this->CacheMap.end(); it++ )
diff --git a/Source/cmDynamicLoader.h b/Source/cmDynamicLoader.h
index acf8011..d038b5c 100644
--- a/Source/cmDynamicLoader.h
+++ b/Source/cmDynamicLoader.h
@@ -36,8 +36,8 @@ public:
static void FlushCache();
protected:
- cmDynamicLoader() {};
- ~cmDynamicLoader() {};
+ cmDynamicLoader() {}
+ ~cmDynamicLoader() {}
private:
cmDynamicLoader(const cmDynamicLoader&); // Not implemented.
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 353f2e9..cab23b7 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -23,6 +23,26 @@
#if defined(__OpenBSD__)
# include <stdint.h>
# include <elf_abi.h>
+#elif defined(__HAIKU__)
+# include <elf32.h>
+# include <elf64.h>
+ typedef struct Elf32_Ehdr Elf32_Ehdr;
+ typedef struct Elf32_Shdr Elf32_Shdr;
+ typedef struct Elf32_Sym Elf32_Sym;
+ typedef struct Elf32_Rel Elf32_Rel;
+ typedef struct Elf32_Rela Elf32_Rela;
+# define ELFMAG0 0x7F
+# define ELFMAG1 'E'
+# define ELFMAG2 'L'
+# define ELFMAG3 'F'
+# define ET_NONE 0
+# define ET_REL 1
+# define ET_EXEC 2
+# define ET_DYN 3
+# define ET_CORE 4
+# define EM_386 3
+# define EM_SPARC 2
+# define EM_PPC 20
#else
# include <elf.h>
#endif
@@ -104,7 +124,7 @@ public:
virtual unsigned int GetNumberOfSections() const = 0;
virtual unsigned int GetDynamicEntryCount() = 0;
virtual unsigned long GetDynamicEntryPosition(int j) = 0;
- virtual StringEntry const* GetDynamicSectionString(int tag) = 0;
+ virtual StringEntry const* GetDynamicSectionString(unsigned int tag) = 0;
virtual void PrintInfo(std::ostream& os) const = 0;
bool ReadBytes(unsigned long pos, unsigned long size, char* buf)
@@ -167,7 +187,7 @@ protected:
}
// Store string table entry states.
- std::map<int, StringEntry> DynamicSectionStrings;
+ std::map<unsigned int, StringEntry> DynamicSectionStrings;
};
//----------------------------------------------------------------------------
@@ -178,16 +198,18 @@ struct cmELFTypes32
typedef Elf32_Shdr ELF_Shdr;
typedef Elf32_Dyn ELF_Dyn;
typedef Elf32_Half ELF_Half;
+ typedef cmIML_INT_uint32_t tagtype;
static const char* GetName() { return "32-bit"; }
};
-// Configure the implementation template for 32-bit ELF files.
+// Configure the implementation template for 64-bit ELF files.
struct cmELFTypes64
{
typedef Elf64_Ehdr ELF_Ehdr;
typedef Elf64_Shdr ELF_Shdr;
typedef Elf64_Dyn ELF_Dyn;
typedef Elf64_Half ELF_Half;
+ typedef cmIML_INT_uint64_t tagtype;
static const char* GetName() { return "64-bit"; }
};
@@ -202,6 +224,7 @@ public:
typedef typename Types::ELF_Shdr ELF_Shdr;
typedef typename Types::ELF_Dyn ELF_Dyn;
typedef typename Types::ELF_Half ELF_Half;
+ typedef typename Types::tagtype tagtype;
// Construct with a stream and byte swap indicator.
cmELFInternalImpl(cmELF* external,
@@ -219,7 +242,7 @@ public:
virtual unsigned long GetDynamicEntryPosition(int j);
// Lookup a string from the dynamic section with the given tag.
- virtual StringEntry const* GetDynamicSectionString(int tag);
+ virtual StringEntry const* GetDynamicSectionString(unsigned int tag);
// Print information about the ELF file.
virtual void PrintInfo(std::ostream& os) const
@@ -604,10 +627,10 @@ unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)
//----------------------------------------------------------------------------
template <class Types>
cmELF::StringEntry const*
-cmELFInternalImpl<Types>::GetDynamicSectionString(int tag)
+cmELFInternalImpl<Types>::GetDynamicSectionString(unsigned int tag)
{
// Short-circuit if already checked.
- std::map<int, StringEntry>::iterator dssi =
+ std::map<unsigned int, StringEntry>::iterator dssi =
this->DynamicSectionStrings.find(tag);
if(dssi != this->DynamicSectionStrings.end())
{
@@ -645,7 +668,7 @@ cmELFInternalImpl<Types>::GetDynamicSectionString(int tag)
di != this->DynamicSectionEntries.end(); ++di)
{
ELF_Dyn& dyn = *di;
- if(dyn.d_tag == tag)
+ if(static_cast<tagtype>(dyn.d_tag) == static_cast<tagtype>(tag))
{
// We found the tag requested.
// Make sure the position given is within the string section.
diff --git a/Source/cmElseCommand.h b/Source/cmElseCommand.h
index d472e99..dde5fcc 100644
--- a/Source/cmElseCommand.h
+++ b/Source/cmElseCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "else";}
+ virtual std::string GetName() const { return "else";}
cmTypeMacro(cmElseCommand, cmCommand);
};
diff --git a/Source/cmElseIfCommand.h b/Source/cmElseIfCommand.h
index d811b35..c627cbe 100644
--- a/Source/cmElseIfCommand.h
+++ b/Source/cmElseIfCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "elseif";}
+ virtual std::string GetName() const { return "elseif";}
cmTypeMacro(cmElseIfCommand, cmCommand);
};
diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h
index a248042..2b09e11 100644
--- a/Source/cmEnableLanguageCommand.h
+++ b/Source/cmEnableLanguageCommand.h
@@ -43,7 +43,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "enable_language";}
+ virtual std::string GetName() const {return "enable_language";}
cmTypeMacro(cmEnableLanguageCommand, cmCommand);
};
diff --git a/Source/cmEnableTestingCommand.h b/Source/cmEnableTestingCommand.h
index e102f5e..d028c59 100644
--- a/Source/cmEnableTestingCommand.h
+++ b/Source/cmEnableTestingCommand.h
@@ -48,7 +48,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "enable_testing";}
+ virtual std::string GetName() const { return "enable_testing";}
cmTypeMacro(cmEnableTestingCommand, cmCommand);
diff --git a/Source/cmEndForEachCommand.h b/Source/cmEndForEachCommand.h
index 44d29b5..c3be387 100644
--- a/Source/cmEndForEachCommand.h
+++ b/Source/cmEndForEachCommand.h
@@ -52,7 +52,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "endforeach";}
+ virtual std::string GetName() const { return "endforeach";}
cmTypeMacro(cmEndForEachCommand, cmCommand);
};
diff --git a/Source/cmEndFunctionCommand.h b/Source/cmEndFunctionCommand.h
index 4fdca6b..3a42c17 100644
--- a/Source/cmEndFunctionCommand.h
+++ b/Source/cmEndFunctionCommand.h
@@ -52,7 +52,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "endfunction";}
+ virtual std::string GetName() const { return "endfunction";}
cmTypeMacro(cmEndFunctionCommand, cmCommand);
};
diff --git a/Source/cmEndIfCommand.h b/Source/cmEndIfCommand.h
index 634da60..a8248c8 100644
--- a/Source/cmEndIfCommand.h
+++ b/Source/cmEndIfCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "endif";}
+ virtual std::string GetName() const { return "endif";}
cmTypeMacro(cmEndIfCommand, cmCommand);
};
diff --git a/Source/cmEndMacroCommand.h b/Source/cmEndMacroCommand.h
index db15f27..fdc04ee 100644
--- a/Source/cmEndMacroCommand.h
+++ b/Source/cmEndMacroCommand.h
@@ -52,7 +52,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "endmacro";}
+ virtual std::string GetName() const { return "endmacro";}
cmTypeMacro(cmEndMacroCommand, cmCommand);
};
diff --git a/Source/cmEndWhileCommand.h b/Source/cmEndWhileCommand.h
index 41138d1..ec1cb65 100644
--- a/Source/cmEndWhileCommand.h
+++ b/Source/cmEndWhileCommand.h
@@ -52,7 +52,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "endwhile";}
+ virtual std::string GetName() const { return "endwhile";}
cmTypeMacro(cmEndWhileCommand, cmCommand);
};
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 6c11345..9b59088 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -132,14 +132,14 @@ bool cmExecProgramCommand
}
std::string coutput = std::string(output, first, last-first+1);
- this->Makefile->AddDefinition(output_variable.c_str(), coutput.c_str());
+ this->Makefile->AddDefinition(output_variable, coutput.c_str());
}
if ( return_variable.size() > 0 )
{
char buffer[100];
sprintf(buffer, "%d", retVal);
- this->Makefile->AddDefinition(return_variable.c_str(), buffer);
+ this->Makefile->AddDefinition(return_variable, buffer);
}
return true;
diff --git a/Source/cmExecProgramCommand.h b/Source/cmExecProgramCommand.h
index 6d28cdc..23d10f9 100644
--- a/Source/cmExecProgramCommand.h
+++ b/Source/cmExecProgramCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const
+ virtual std::string GetName() const
{return "exec_program";}
/**
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index 994c170..40f70b8 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -191,7 +191,7 @@ bool cmExecuteProcessCommand
{
cmOStringStream e;
e << " given unknown argument \"" << args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -200,7 +200,7 @@ bool cmExecuteProcessCommand
{
std::string e = "attempted to output into a file: " + output_file
+ " into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -326,12 +326,12 @@ bool cmExecuteProcessCommand
// Store the output obtained.
if(!output_variable.empty() && tempOutput.size())
{
- this->Makefile->AddDefinition(output_variable.c_str(),
+ this->Makefile->AddDefinition(output_variable,
&*tempOutput.begin());
}
if(!merge_output && !error_variable.empty() && tempError.size())
{
- this->Makefile->AddDefinition(error_variable.c_str(),
+ this->Makefile->AddDefinition(error_variable,
&*tempError.begin());
}
@@ -345,19 +345,19 @@ bool cmExecuteProcessCommand
int v = cmsysProcess_GetExitValue(cp);
char buf[100];
sprintf(buf, "%d", v);
- this->Makefile->AddDefinition(result_variable.c_str(), buf);
+ this->Makefile->AddDefinition(result_variable, buf);
}
break;
case cmsysProcess_State_Exception:
- this->Makefile->AddDefinition(result_variable.c_str(),
+ this->Makefile->AddDefinition(result_variable,
cmsysProcess_GetExceptionString(cp));
break;
case cmsysProcess_State_Error:
- this->Makefile->AddDefinition(result_variable.c_str(),
+ this->Makefile->AddDefinition(result_variable,
cmsysProcess_GetErrorString(cp));
break;
case cmsysProcess_State_Expired:
- this->Makefile->AddDefinition(result_variable.c_str(),
+ this->Makefile->AddDefinition(result_variable,
"Process terminated due to timeout");
break;
}
diff --git a/Source/cmExecuteProcessCommand.h b/Source/cmExecuteProcessCommand.h
index bd0f783..6906a08 100644
--- a/Source/cmExecuteProcessCommand.h
+++ b/Source/cmExecuteProcessCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const
+ virtual std::string GetName() const
{return "execute_process";}
/**
diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h
index 1488924..5c94a97 100644
--- a/Source/cmExecutionStatus.h
+++ b/Source/cmExecutionStatus.h
@@ -24,7 +24,7 @@ class cmExecutionStatus : public cmObject
public:
cmTypeMacro(cmExecutionStatus, cmObject);
- cmExecutionStatus() { this->Clear();};
+ cmExecutionStatus() { this->Clear();}
virtual void SetReturnInvoked(bool val)
{ this->ReturnInvoked = val; }
diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx
index 308956a..6c8ebb6 100644
--- a/Source/cmExportBuildFileGenerator.cxx
+++ b/Source/cmExportBuildFileGenerator.cxx
@@ -47,7 +47,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
cmOStringStream e;
e << "given target \"" << te->GetName() << "\" more than once.";
this->Makefile->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace);
+ ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
return false;
}
if (te->GetType() == cmTarget::INTERFACE_LIBRARY)
@@ -85,6 +85,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", te,
cmGeneratorExpression::BuildInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", te,
+ cmGeneratorExpression::BuildInterface,
+ properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE",
te, properties);
const bool newCMP0022Behavior =
@@ -106,7 +109,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
ci = this->Configurations.begin();
ci != this->Configurations.end(); ++ci)
{
- this->GenerateImportConfig(os, ci->c_str(), missingTargets);
+ this->GenerateImportConfig(os, *ci, missingTargets);
}
this->GenerateMissingTargetsCheckCode(os, missingTargets);
@@ -118,8 +121,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os)
void
cmExportBuildFileGenerator
::GenerateImportTargetsConfig(std::ostream& os,
- const char* config, std::string const& suffix,
- std::vector<std::string> &missingTargets)
+ const std::string& config,
+ std::string const& suffix,
+ std::vector<std::string> &missingTargets)
{
for(std::vector<cmTarget*>::const_iterator
tei = this->Exports.begin();
@@ -166,7 +170,8 @@ void cmExportBuildFileGenerator::SetExportSet(cmExportSet *exportSet)
//----------------------------------------------------------------------------
void
cmExportBuildFileGenerator
-::SetImportLocationProperty(const char* config, std::string const& suffix,
+::SetImportLocationProperty(const std::string& config,
+ std::string const& suffix,
cmTarget* target, ImportPropertyMap& properties)
{
// Get the makefile in which to lookup target information.
@@ -313,7 +318,7 @@ cmExportBuildFileGenerator
<< "consider using the APPEND option with multiple separate calls.";
this->Makefile->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(), this->Backtrace);
+ ->IssueMessage(cmake::FATAL_ERROR, e.str(), this->Backtrace);
}
std::string
@@ -326,7 +331,7 @@ cmExportBuildFileGenerator::InstallNameDir(cmTarget* target,
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
install_name_dir =
- target->GetInstallNameDirForBuildTree(config.c_str());
+ target->GetInstallNameDirForBuildTree(config);
}
return install_name_dir;
diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h
index cea2099..c1bdb5b 100644
--- a/Source/cmExportBuildFileGenerator.h
+++ b/Source/cmExportBuildFileGenerator.h
@@ -52,7 +52,7 @@ protected:
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
virtual void GenerateImportTargetsConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
std::string const& suffix,
std::vector<std::string> &missingTargets);
virtual void HandleMissingTarget(std::string& link_libs,
@@ -66,7 +66,7 @@ protected:
int occurrences);
/** Fill in properties indicating built file locations. */
- void SetImportLocationProperty(const char* config,
+ void SetImportLocationProperty(const std::string& config,
std::string const& suffix,
cmTarget* target,
ImportPropertyMap& properties);
diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx
index db56aaf..2536ada 100644
--- a/Source/cmExportCommand.cxx
+++ b/Source/cmExportCommand.cxx
@@ -92,7 +92,7 @@ bool cmExportCommand
cmOStringStream e;
e << "FILE option given filename \"" << this->Filename.GetString()
<< "\" which does not have an extension of \".cmake\".\n";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
fname = this->Filename.GetString();
@@ -106,7 +106,7 @@ bool cmExportCommand
cmOStringStream e;
e << "FILE option given filename \"" << fname
<< "\" which is in the source tree.\n";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -128,7 +128,7 @@ bool cmExportCommand
{
cmOStringStream e;
e << "EXPORT signature does not recognise the APPEND option.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -137,7 +137,7 @@ bool cmExportCommand
cmOStringStream e;
e << "EXPORT signature does not recognise the "
"EXPORT_LINK_INTERFACE_LIBRARIES option.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -147,7 +147,7 @@ bool cmExportCommand
{
cmOStringStream e;
e << "Export set \"" << setName << "\" not found.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
this->ExportSet = setMap[setName];
@@ -164,18 +164,18 @@ bool cmExportCommand
cmOStringStream e;
e << "given ALIAS target \"" << *currentTarget
<< "\" which may not be exported.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- if(cmTarget* target = gg->FindTarget(0, currentTarget->c_str()))
+ if(cmTarget* target = gg->FindTarget(*currentTarget))
{
if(target->GetType() == cmTarget::OBJECT_LIBRARY)
{
cmOStringStream e;
e << "given OBJECT library \"" << *currentTarget
<< "\" which may not be exported.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -184,7 +184,7 @@ bool cmExportCommand
cmOStringStream e;
e << "given target \"" << *currentTarget
<< "\" which is not built by this project.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
targets.push_back(*currentTarget);
@@ -223,18 +223,15 @@ bool cmExportCommand
// Compute the set of configurations exported.
std::vector<std::string> configurationTypes;
this->Makefile->GetConfigurations(configurationTypes);
- if(!configurationTypes.empty())
+ if(configurationTypes.empty())
{
- for(std::vector<std::string>::const_iterator
- ci = configurationTypes.begin();
- ci != configurationTypes.end(); ++ci)
- {
- ebfg->AddConfiguration(ci->c_str());
- }
+ configurationTypes.push_back("");
}
- else
+ for(std::vector<std::string>::const_iterator
+ ci = configurationTypes.begin();
+ ci != configurationTypes.end(); ++ci)
{
- ebfg->AddConfiguration("");
+ ebfg->AddConfiguration(*ci);
}
if (this->ExportSet)
{
@@ -266,7 +263,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "PACKAGE given unknown argument: " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -284,7 +281,7 @@ bool cmExportCommand::HandlePackage(std::vector<std::string> const& args)
cmOStringStream e;
e << "PACKAGE given invalid package name \"" << package << "\". "
<< "Package names must match \"" << packageExpr << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
diff --git a/Source/cmExportCommand.h b/Source/cmExportCommand.h
index c0e445f..f9506bb 100644
--- a/Source/cmExportCommand.h
+++ b/Source/cmExportCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "export";}
+ virtual std::string GetName() const { return "export";}
cmTypeMacro(cmExportCommand, cmCommand);
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 4a161ee..2db4086 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -35,7 +35,7 @@ cmExportFileGenerator::cmExportFileGenerator()
}
//----------------------------------------------------------------------------
-void cmExportFileGenerator::AddConfiguration(const char* config)
+void cmExportFileGenerator::AddConfiguration(const std::string& config)
{
this->Configurations.push_back(config);
}
@@ -117,12 +117,12 @@ bool cmExportFileGenerator::GenerateImportFile()
//----------------------------------------------------------------------------
void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
std::vector<std::string> &missingTargets)
{
// Construct the property configuration suffix.
std::string suffix = "_";
- if(config && *config)
+ if(!config.empty())
{
suffix += cmSystemTools::UpperCase(config);
}
@@ -136,7 +136,8 @@ void cmExportFileGenerator::GenerateImportConfig(std::ostream& os,
}
//----------------------------------------------------------------------------
-void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
+void cmExportFileGenerator::PopulateInterfaceProperty(
+ const std::string& propName,
cmTarget *target,
ImportPropertyMap &properties)
{
@@ -148,8 +149,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
}
//----------------------------------------------------------------------------
-void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
- const char *outputName,
+void cmExportFileGenerator::PopulateInterfaceProperty(
+ const std::string& propName,
+ const std::string& outputName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
@@ -273,27 +275,68 @@ static bool checkInterfaceDirs(const std::string &prepro,
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains relative path:\n"
" \"" << *li << "\"";
- target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+ target->GetMakefile()->IssueMessage(messageType, e.str());
}
+ bool inBinary = isSubDirectory(li->c_str(), topBinaryDir);
+ bool inSource = isSubDirectory(li->c_str(), topSourceDir);
if (isSubDirectory(li->c_str(), installDir))
{
- continue;
+ // The include directory is inside the install tree. If the
+ // install tree is not inside the source tree or build tree then
+ // fall through to the checks below that the include directory is not
+ // also inside the source tree or build tree.
+ bool shouldContinue =
+ (!inBinary || isSubDirectory(installDir, topBinaryDir)) &&
+ (!inSource || isSubDirectory(installDir, topSourceDir));
+
+ if (!shouldContinue)
+ {
+ switch(target->GetPolicyStatusCMP0052())
+ {
+ case cmPolicies::WARN:
+ {
+ cmOStringStream s;
+ s << target->GetMakefile()->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0052) << "\n";
+ s << "Directory:\n \"" << *li << "\"\nin "
+ "INTERFACE_INCLUDE_DIRECTORIES of target \""
+ << target->GetName() << "\" is a subdirectory of the install "
+ "directory:\n \"" << installDir << "\"\nhowever it is also "
+ "a subdirectory of the " << (inBinary ? "build" : "source")
+ << " tree:\n \"" << (inBinary ? topBinaryDir : topSourceDir)
+ << "\"" << std::endl;
+ target->GetMakefile()->IssueMessage(cmake::AUTHOR_WARNING,
+ s.str());
+ }
+ case cmPolicies::OLD:
+ shouldContinue = true;
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ break;
+ }
+ }
+ if (shouldContinue)
+ {
+ continue;
+ }
}
- if (isSubDirectory(li->c_str(), topBinaryDir))
+ if (inBinary)
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the build directory.";
- target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+ target->GetMakefile()->IssueMessage(messageType, e.str());
}
if (!inSourceBuild)
{
- if (isSubDirectory(li->c_str(), topSourceDir))
+ if (inSource)
{
e << "Target \"" << target->GetName() << "\" "
"INTERFACE_INCLUDE_DIRECTORIES property contains path:\n"
" \"" << *li << "\"\nwhich is prefixed in the source directory.";
- target->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+ target->GetMakefile()->IssueMessage(messageType, e.str());
}
}
}
@@ -343,7 +386,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
true);
this->ReplaceInstallPrefix(dirs);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
- std::string exportDirs = cge->Evaluate(target->GetMakefile(), 0,
+ std::string exportDirs = cge->Evaluate(target->GetMakefile(), "",
false, target);
if (cge->GetHadContextSensitiveCondition())
@@ -391,7 +434,8 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
}
//----------------------------------------------------------------------------
-void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
+void cmExportFileGenerator::PopulateInterfaceProperty(
+ const std::string& propName,
cmTarget *target,
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap &properties,
@@ -403,7 +447,7 @@ void cmExportFileGenerator::PopulateInterfaceProperty(const char *propName,
//----------------------------------------------------------------------------
-void getPropertyContents(cmTarget const* tgt, const char *prop,
+void getPropertyContents(cmTarget const* tgt, const std::string& prop,
std::set<std::string> &ifaceProperties)
{
const char *p = tgt->GetProperty(prop);
@@ -423,7 +467,7 @@ void getPropertyContents(cmTarget const* tgt, const char *prop,
//----------------------------------------------------------------------------
void getCompatibleInterfaceProperties(cmTarget *target,
std::set<std::string> &ifaceProperties,
- const char *config)
+ const std::string& config)
{
cmComputeLinkInformation *info = target->GetLinkInformation(config);
@@ -487,7 +531,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
if (target->GetType() != cmTarget::INTERFACE_LIBRARY)
{
- getCompatibleInterfaceProperties(target, ifaceProperties, 0);
+ getCompatibleInterfaceProperties(target, ifaceProperties, "");
std::vector<std::string> configNames;
target->GetMakefile()->GetConfigurations(configNames);
@@ -495,14 +539,14 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties(
for (std::vector<std::string>::const_iterator ci = configNames.begin();
ci != configNames.end(); ++ci)
{
- getCompatibleInterfaceProperties(target, ifaceProperties, ci->c_str());
+ getCompatibleInterfaceProperties(target, ifaceProperties, *ci);
}
}
for (std::set<std::string>::const_iterator it = ifaceProperties.begin();
it != ifaceProperties.end(); ++it)
{
- this->PopulateInterfaceProperty(("INTERFACE_" + *it).c_str(),
+ this->PopulateInterfaceProperty("INTERFACE_" + *it,
target, properties);
}
}
@@ -684,7 +728,7 @@ cmExportFileGenerator::ReplaceInstallPrefix(std::string &)
//----------------------------------------------------------------------------
void
cmExportFileGenerator
-::SetImportLinkInterface(const char* config, std::string const& suffix,
+::SetImportLinkInterface(const std::string& config, std::string const& suffix,
cmGeneratorExpression::PreprocessContext preprocessRule,
cmTarget* target, ImportPropertyMap& properties,
std::vector<std::string>& missingTargets)
@@ -709,7 +753,7 @@ cmExportFileGenerator
const char *propContent;
if (const char *prop_suffixed = target->GetProperty(
- ("LINK_INTERFACE_LIBRARIES" + suffix).c_str()))
+ "LINK_INTERFACE_LIBRARIES" + suffix))
{
propContent = prop_suffixed;
}
@@ -759,7 +803,8 @@ cmExportFileGenerator
//----------------------------------------------------------------------------
void
cmExportFileGenerator
-::SetImportDetailProperties(const char* config, std::string const& suffix,
+::SetImportDetailProperties(const std::string& config,
+ std::string const& suffix,
cmTarget* target, ImportPropertyMap& properties,
std::vector<std::string>& missingTargets
)
@@ -825,7 +870,7 @@ void
cmExportFileGenerator
::SetImportLinkProperty(std::string const& suffix,
cmTarget* target,
- const char* propName,
+ const std::string& propName,
std::vector<std::string> const& entries,
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets
@@ -861,11 +906,11 @@ cmExportFileGenerator
//----------------------------------------------------------------------------
void cmExportFileGenerator::GenerateImportHeaderCode(std::ostream& os,
- const char* config)
+ const std::string& config)
{
os << "#----------------------------------------------------------------\n"
<< "# Generated CMake target import file";
- if(config)
+ if(!config.empty())
{
os << " for configuration \"" << config << "\".\n";
}
@@ -996,7 +1041,7 @@ cmExportFileGenerator
//----------------------------------------------------------------------------
void
cmExportFileGenerator
-::GenerateImportPropertyCode(std::ostream& os, const char* config,
+::GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmTarget const* target,
ImportPropertyMap const& properties)
{
@@ -1010,7 +1055,7 @@ cmExportFileGenerator
<< config << "\"\n";
os << "set_property(TARGET " << targetName
<< " APPEND PROPERTY IMPORTED_CONFIGURATIONS ";
- if(config && *config)
+ if(!config.empty())
{
os << cmSystemTools::UpperCase(config);
}
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 57ab378..abd8ad5 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -50,32 +50,33 @@ public:
const char *GetMainExportFileName() const;
/** Set the namespace in which to place exported target names. */
- void SetNamespace(const char* ns) { this->Namespace = ns; }
+ void SetNamespace(const std::string& ns) { this->Namespace = ns; }
std::string GetNamespace() const { return this->Namespace; }
void SetExportOld(bool exportOld) { this->ExportOld = exportOld; }
/** Add a configuration to be exported. */
- void AddConfiguration(const char* config);
+ void AddConfiguration(const std::string& config);
/** Actually generate the export file. Returns whether there was an
error. */
bool GenerateImportFile();
protected:
- typedef std::map<cmStdString, cmStdString> ImportPropertyMap;
+ typedef std::map<std::string, std::string> ImportPropertyMap;
// Generate per-configuration target information to the given output
// stream.
- void GenerateImportConfig(std::ostream& os, const char* config,
+ void GenerateImportConfig(std::ostream& os, const std::string& config,
std::vector<std::string> &missingTargets);
// Methods to implement export file code generation.
- void GenerateImportHeaderCode(std::ostream& os, const char* config = 0);
+ void GenerateImportHeaderCode(std::ostream& os,
+ const std::string& config = "");
void GenerateImportFooterCode(std::ostream& os);
void GenerateImportVersionCode(std::ostream& os);
void GenerateImportTargetCode(std::ostream& os, cmTarget const* target);
- void GenerateImportPropertyCode(std::ostream& os, const char* config,
+ void GenerateImportPropertyCode(std::ostream& os, const std::string& config,
cmTarget const* target,
ImportPropertyMap const& properties);
void GenerateImportedFileChecksCode(std::ostream& os, cmTarget* target,
@@ -90,12 +91,12 @@ protected:
// Collect properties with detailed information about targets beyond
// their location on disk.
- void SetImportDetailProperties(const char* config,
+ void SetImportDetailProperties(const std::string& config,
std::string const& suffix, cmTarget* target,
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
void SetImportLinkProperty(std::string const& suffix,
- cmTarget* target, const char* propName,
+ cmTarget* target, const std::string& propName,
std::vector<std::string> const& entries,
ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
@@ -105,7 +106,7 @@ protected:
/** Each subclass knows where the target files are located. */
virtual void GenerateImportTargetsConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
std::string const& suffix,
std::vector<std::string> &missingTargets) = 0;
@@ -116,7 +117,7 @@ protected:
cmMakefile* mf,
cmTarget* depender,
cmTarget* dependee) = 0;
- void PopulateInterfaceProperty(const char *,
+ void PopulateInterfaceProperty(const std::string&,
cmTarget *target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
@@ -125,7 +126,7 @@ protected:
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
- void PopulateInterfaceProperty(const char *propName, cmTarget *target,
+ void PopulateInterfaceProperty(const std::string& propName, cmTarget *target,
ImportPropertyMap &properties);
void PopulateCompatibleInterfaceProperties(cmTarget *target,
ImportPropertyMap &properties);
@@ -137,7 +138,8 @@ protected:
ImportPropertyMap &properties,
std::vector<std::string> &missingTargets);
- void SetImportLinkInterface(const char* config, std::string const& suffix,
+ void SetImportLinkInterface(const std::string& config,
+ std::string const& suffix,
cmGeneratorExpression::PreprocessContext preprocessRule,
cmTarget* target, ImportPropertyMap& properties,
std::vector<std::string>& missingTargets);
@@ -174,7 +176,7 @@ protected:
std::set<cmTarget*> ExportedTargets;
private:
- void PopulateInterfaceProperty(const char *, const char *,
+ void PopulateInterfaceProperty(const std::string&, const std::string&,
cmTarget *target,
cmGeneratorExpression::PreprocessContext,
ImportPropertyMap &properties,
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index b579963..89071c0 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -149,6 +149,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
te,
cmGeneratorExpression::InstallInterface,
properties, missingTargets);
+ this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES",
+ te,
+ cmGeneratorExpression::InstallInterface,
+ properties, missingTargets);
const bool newCMP0022Behavior =
te->GetPolicyStatusCMP0022() != cmPolicies::WARN
@@ -211,7 +215,7 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
ci = this->Configurations.begin();
ci != this->Configurations.end(); ++ci)
{
- if(!this->GenerateImportFileConfig(ci->c_str(), missingTargets))
+ if(!this->GenerateImportFileConfig(*ci, missingTargets))
{
result = false;
}
@@ -240,7 +244,8 @@ cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input)
//----------------------------------------------------------------------------
bool
-cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
+cmExportInstallFileGenerator::GenerateImportFileConfig(
+ const std::string& config,
std::vector<std::string> &missingTargets)
{
// Skip configurations not enabled for this export.
@@ -254,7 +259,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
fileName += "/";
fileName += this->FileBase;
fileName += "-";
- if(config && *config)
+ if(!config.empty())
{
fileName += cmSystemTools::LowerCase(config);
}
@@ -270,7 +275,7 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
{
std::string se = cmSystemTools::GetLastSystemError();
cmOStringStream e;
- e << "cannot write to file \"" << fileName.c_str()
+ e << "cannot write to file \"" << fileName
<< "\": " << se;
cmSystemTools::Error(e.str().c_str());
return false;
@@ -296,7 +301,8 @@ cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config,
void
cmExportInstallFileGenerator
::GenerateImportTargetsConfig(std::ostream& os,
- const char* config, std::string const& suffix,
+ const std::string& config,
+ std::string const& suffix,
std::vector<std::string> &missingTargets)
{
// Add each target in the set to the export.
@@ -355,7 +361,8 @@ cmExportInstallFileGenerator
//----------------------------------------------------------------------------
void
cmExportInstallFileGenerator
-::SetImportLocationProperty(const char* config, std::string const& suffix,
+::SetImportLocationProperty(const std::string& config,
+ std::string const& suffix,
cmInstallTargetGenerator* itgen,
ImportPropertyMap& properties,
std::set<std::string>& importedLocations
diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h
index 7c634a4..b851ad5 100644
--- a/Source/cmExportInstallFileGenerator.h
+++ b/Source/cmExportInstallFileGenerator.h
@@ -41,7 +41,7 @@ public:
/** Get the per-config file generated for each configuraiton. This
maps from the configuration name to the file temporary location
for installation. */
- std::map<cmStdString, cmStdString> const& GetConfigImportFiles()
+ std::map<std::string, std::string> const& GetConfigImportFiles()
{ return this->ConfigImportFiles; }
/** Compute the globbing expression used to load per-config import
@@ -52,7 +52,7 @@ protected:
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
virtual void GenerateImportTargetsConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
std::string const& suffix,
std::vector<std::string> &missingTargets);
virtual void HandleMissingTarget(std::string& link_libs,
@@ -72,11 +72,11 @@ protected:
/** Generate a per-configuration file for the targets. */
- bool GenerateImportFileConfig(const char* config,
+ bool GenerateImportFileConfig(const std::string& config,
std::vector<std::string> &missingTargets);
/** Fill in properties indicating installed file locations. */
- void SetImportLocationProperty(const char* config,
+ void SetImportLocationProperty(const std::string& config,
std::string const& suffix,
cmInstallTargetGenerator* itgen,
ImportPropertyMap& properties,
@@ -92,7 +92,7 @@ protected:
std::string ImportPrefix;
// The import file generated for each configuration.
- std::map<cmStdString, cmStdString> ConfigImportFiles;
+ std::map<std::string, std::string> ConfigImportFiles;
};
#endif
diff --git a/Source/cmExportLibraryDependenciesCommand.cxx b/Source/cmExportLibraryDependenciesCommand.cxx
index 5d6f094..688d2eb 100644
--- a/Source/cmExportLibraryDependenciesCommand.cxx
+++ b/Source/cmExportLibraryDependenciesCommand.cxx
@@ -83,9 +83,9 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
cmake* cm = this->Makefile->GetCMakeInstance();
cmGlobalGenerator* global = cm->GetGlobalGenerator();
const std::vector<cmLocalGenerator *>& locals = global->GetLocalGenerators();
- std::map<cmStdString, cmStdString> libDepsOld;
- std::map<cmStdString, cmStdString> libDepsNew;
- std::map<cmStdString, cmStdString> libTypes;
+ std::map<std::string, std::string> libDepsOld;
+ std::map<std::string, std::string> libDepsNew;
+ std::map<std::string, std::string> libTypes;
for(std::vector<cmLocalGenerator *>::const_iterator i = locals.begin();
i != locals.end(); ++i)
{
@@ -138,7 +138,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
break;
}
std::string lib = li->first;
- if(cmTarget* libtgt = global->FindTarget(0, lib.c_str()))
+ if(cmTarget* libtgt = global->FindTarget(lib))
{
// Handle simple output name changes. This command is
// deprecated so we do not support full target name
@@ -175,7 +175,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
fout << "# Generated by CMake " << cmVersion::GetCMakeVersion() << "\n\n";
fout << "if(" << vertest << ")\n";
fout << " # Information for CMake 2.6 and above.\n";
- for(std::map<cmStdString, cmStdString>::const_iterator
+ for(std::map<std::string, std::string>::const_iterator
i = libDepsNew.begin();
i != libDepsNew.end(); ++i)
{
@@ -186,7 +186,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
}
fout << "else()\n";
fout << " # Information for CMake 2.4 and lower.\n";
- for(std::map<cmStdString, cmStdString>::const_iterator
+ for(std::map<std::string, std::string>::const_iterator
i = libDepsOld.begin();
i != libDepsOld.end(); ++i)
{
@@ -195,7 +195,7 @@ void cmExportLibraryDependenciesCommand::ConstFinalPass() const
fout << " set(\"" << i->first << "\" \"" << i->second << "\")\n";
}
}
- for(std::map<cmStdString, cmStdString>::const_iterator i = libTypes.begin();
+ for(std::map<std::string, std::string>::const_iterator i = libTypes.begin();
i != libTypes.end(); ++i)
{
if(i->second != "general")
diff --git a/Source/cmExportLibraryDependenciesCommand.h b/Source/cmExportLibraryDependenciesCommand.h
index 29b568f..2ea4e79 100644
--- a/Source/cmExportLibraryDependenciesCommand.h
+++ b/Source/cmExportLibraryDependenciesCommand.h
@@ -21,7 +21,7 @@ public:
virtual cmCommand* Clone() { return new cmExportLibraryDependenciesCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const { return "export_library_dependencies";}
+ virtual std::string GetName() const { return "export_library_dependencies";}
virtual bool IsDiscouraged() const { return true; }
virtual void FinalPass();
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index a8a91d6..3350d7c 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -46,8 +46,9 @@ bool cmExportTryCompileFileGenerator::GenerateMainFile(std::ostream& os)
return true;
}
-std::string cmExportTryCompileFileGenerator::FindTargets(const char *propName,
- cmTarget const* tgt,
+std::string cmExportTryCompileFileGenerator::FindTargets(
+ const std::string& propName,
+ cmTarget const* tgt,
std::set<cmTarget const*> &emitted)
{
const char *prop = tgt->GetProperty(propName);
@@ -101,7 +102,7 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target,
{
const std::string libs = i->second.GetValue();
- std::string evalResult = this->FindTargets(i->first.c_str(),
+ std::string evalResult = this->FindTargets(i->first,
target, emitted);
std::vector<std::string> depends;
@@ -128,7 +129,7 @@ cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target,
if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME"))
{
install_name_dir =
- target->GetInstallNameDirForBuildTree(config.c_str());
+ target->GetInstallNameDirForBuildTree(config);
}
return install_name_dir;
diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h
index 71ac0dd..ec70d81 100644
--- a/Source/cmExportTryCompileFileGenerator.h
+++ b/Source/cmExportTryCompileFileGenerator.h
@@ -23,14 +23,14 @@ public:
/** Set the list of targets to export. */
void SetExports(const std::vector<cmTarget const*> &exports)
{ this->Exports = exports; }
- void SetConfig(const char *config) { this->Config = config; }
+ void SetConfig(const std::string& config) { this->Config = config; }
protected:
// Implement virtual methods from the superclass.
virtual bool GenerateMainFile(std::ostream& os);
virtual void GenerateImportTargetsConfig(std::ostream&,
- const char*,
+ const std::string&,
std::string const&,
std::vector<std::string>&) {}
virtual void HandleMissingTarget(std::string&,
@@ -46,12 +46,12 @@ protected:
std::string InstallNameDir(cmTarget* target,
const std::string& config);
private:
- std::string FindTargets(const char *prop, cmTarget const* tgt,
+ std::string FindTargets(const std::string& prop, cmTarget const* tgt,
std::set<cmTarget const*> &emitted);
std::vector<cmTarget const*> Exports;
- const char *Config;
+ std::string Config;
};
#endif
diff --git a/Source/cmExprLexer.cxx b/Source/cmExprLexer.cxx
index aa384cd..4704f03 100644
--- a/Source/cmExprLexer.cxx
+++ b/Source/cmExprLexer.cxx
@@ -976,7 +976,7 @@ case YY_STATE_EOF(INITIAL):
"fatal flex scanner internal error--no action found" );
} /* end of action switch */
} /* end of scanning one token */
-return 0; /* this should not happen but it silences a warning*/
+return 0; /* this should not happen but it quiets some compilers */
} /* end of cmExpr_yylex */
/* yy_get_next_buffer - try to read in a new buffer
diff --git a/Source/cmExprParserHelper.h b/Source/cmExprParserHelper.h
index 4b76b33..8d6b2cd 100644
--- a/Source/cmExprParserHelper.h
+++ b/Source/cmExprParserHelper.h
@@ -49,8 +49,8 @@ public:
const char* GetError() { return this->ErrorString.c_str(); }
private:
- cmStdString::size_type InputBufferPos;
- cmStdString InputBuffer;
+ std::string::size_type InputBufferPos;
+ std::string InputBuffer;
std::vector<char> OutputBuffer;
int CurrentLine;
int Verbose;
diff --git a/Source/cmExternalMakefileProjectGenerator.cxx b/Source/cmExternalMakefileProjectGenerator.cxx
index 0d42c35..9264671 100644
--- a/Source/cmExternalMakefileProjectGenerator.cxx
+++ b/Source/cmExternalMakefileProjectGenerator.cxx
@@ -20,13 +20,13 @@ void cmExternalMakefileProjectGenerator
}
std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
- const char* globalGenerator,
- const char* extraGenerator)
+ const std::string& globalGenerator,
+ const std::string& extraGenerator)
{
std::string fullName;
- if (globalGenerator)
+ if (!globalGenerator.empty())
{
- if (extraGenerator && *extraGenerator)
+ if (!extraGenerator.empty())
{
fullName = extraGenerator;
fullName += " - ";
@@ -36,22 +36,22 @@ std::string cmExternalMakefileProjectGenerator::CreateFullGeneratorName(
return fullName;
}
-const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
- const char* fullName)
+std::string cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
+ const std::string& fullName)
{
// at least one global generator must be supported
assert(!this->SupportedGlobalGenerators.empty());
- if (fullName==0)
+ if (fullName.empty())
{
- return 0;
+ return "";
}
std::string currentName = fullName;
// if we get only the short name, take the first global generator as default
if (currentName == this->GetName())
{
- return this->SupportedGlobalGenerators[0].c_str();
+ return this->SupportedGlobalGenerators[0];
}
// otherwise search for the matching global generator
@@ -60,11 +60,11 @@ const char* cmExternalMakefileProjectGenerator::GetGlobalGeneratorName(
it != this->SupportedGlobalGenerators.end();
++it)
{
- if (this->CreateFullGeneratorName(it->c_str(), this->GetName())
+ if (this->CreateFullGeneratorName(*it, this->GetName())
== currentName)
{
- return it->c_str();
+ return *it;
}
}
- return 0;
+ return "";
}
diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h
index bce441d..cba1c76 100644
--- a/Source/cmExternalMakefileProjectGenerator.h
+++ b/Source/cmExternalMakefileProjectGenerator.h
@@ -37,10 +37,10 @@ public:
virtual ~cmExternalMakefileProjectGenerator() {}
///! Get the name for this generator.
- virtual const char* GetName() const = 0;
+ virtual std::string GetName() const = 0;
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const = 0;
+ const std::string& fullName) const = 0;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile *, bool optional);
@@ -53,12 +53,13 @@ public:
{return this->SupportedGlobalGenerators;}
///! Get the name of the global generator for the given full name
- const char* GetGlobalGeneratorName(const char* fullName);
+ std::string GetGlobalGeneratorName(const std::string& fullName);
/** Create a full name from the given global generator name and the
* extra generator name
*/
- static std::string CreateFullGeneratorName(const char* globalGenerator,
- const char* extraGenerator);
+ static std::string CreateFullGeneratorName(
+ const std::string& globalGenerator,
+ const std::string& extraGenerator);
///! Generate the project files, the Makefiles have already been generated
virtual void Generate() = 0;
diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx
index 548c88b..6f76dc4 100644
--- a/Source/cmExtraCodeBlocksGenerator.cxx
+++ b/Source/cmExtraCodeBlocksGenerator.cxx
@@ -38,7 +38,7 @@ http://forums.codeblocks.org/index.php/topic,6789.0.html
//----------------------------------------------------------------------------
void cmExtraCodeBlocksGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates CodeBlocks project files.";
@@ -61,7 +61,7 @@ cmExtraCodeBlocksGenerator::cmExtraCodeBlocksGenerator()
void cmExtraCodeBlocksGenerator::Generate()
{
// for each sub project in the project create a codeblocks project
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it!= this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -243,7 +243,7 @@ void cmExtraCodeBlocksGenerator
Tree tree;
// build tree of virtual folders
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it != this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -334,7 +334,7 @@ void cmExtraCodeBlocksGenerator
if (strcmp(makefile->GetStartOutputDirectory(),
makefile->GetHomeOutputDirectory())==0)
{
- this->AppendTarget(fout, ti->first.c_str(), 0,
+ this->AppendTarget(fout, ti->first, 0,
make.c_str(), makefile, compiler.c_str());
}
}
@@ -350,7 +350,7 @@ void cmExtraCodeBlocksGenerator
break;
}
- this->AppendTarget(fout, ti->first.c_str(), 0,
+ this->AppendTarget(fout, ti->first, 0,
make.c_str(), makefile, compiler.c_str());
break;
case cmTarget::EXECUTABLE:
@@ -359,11 +359,11 @@ void cmExtraCodeBlocksGenerator
case cmTarget::MODULE_LIBRARY:
case cmTarget::OBJECT_LIBRARY:
{
- this->AppendTarget(fout, ti->first.c_str(), &ti->second,
+ this->AppendTarget(fout, ti->first, &ti->second,
make.c_str(), makefile, compiler.c_str());
std::string fastTarget = ti->first;
fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget.c_str(), &ti->second,
+ this->AppendTarget(fout, fastTarget, &ti->second,
make.c_str(), makefile, compiler.c_str());
}
break;
@@ -399,7 +399,8 @@ void cmExtraCodeBlocksGenerator
case cmTarget::UTILITY: // can have sources since 2.6.3
{
std::vector<cmSourceFile*> sources;
- ti->second.GetSourceFiles(sources);
+ ti->second.GetSourceFiles(sources,
+ makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++)
{
@@ -411,14 +412,16 @@ void cmExtraCodeBlocksGenerator
// check whether it is a C/C++ implementation file
bool isCFile = false;
- if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
+ std::string lang = (*si)->GetLanguage();
+ if (lang == "C" || lang == "CXX")
{
+ std::string srcext = (*si)->GetExtension();
for(std::vector<std::string>::const_iterator
ext = mf->GetSourceExtensions().begin();
ext != mf->GetSourceExtensions().end();
++ext)
{
- if ((*si)->GetExtension() == *ext)
+ if (srcext == *ext)
{
isCFile = true;
break;
@@ -497,7 +500,7 @@ void cmExtraCodeBlocksGenerator
sit!=otherFiles.end();
++sit)
{
- fout<<" <Unit filename=\""<< sit->c_str() <<"\">\n"
+ fout<<" <Unit filename=\""<< *sit <<"\">\n"
" </Unit>\n";
}
@@ -536,7 +539,7 @@ std::string cmExtraCodeBlocksGenerator::CreateDummyTargetFile(
// Generate the xml code for one target.
void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
- const char* targetName,
+ const std::string& targetName,
cmTarget* target,
const char* make,
const cmMakefile* makefile,
@@ -624,7 +627,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
if (!systemIncludeDirs.empty())
{
std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+ cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
dirIt != dirs.end();
++dirIt)
@@ -638,7 +641,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
if (!systemIncludeDirs.empty())
{
std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+ cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
for(std::vector<std::string>::const_iterator dirIt=dirs.begin();
dirIt != dirs.end();
++dirIt)
@@ -651,7 +654,7 @@ void cmExtraCodeBlocksGenerator::AppendTarget(cmGeneratedFileStream& fout,
dirIt != uniqIncludeDirs.end();
++dirIt)
{
- fout <<" <Add directory=\"" << dirIt->c_str() << "\" />\n";
+ fout <<" <Add directory=\"" << *dirIt << "\" />\n";
}
fout<<" </Compiler>\n";
@@ -695,7 +698,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
std::string hostSystemName = mf->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME");
- std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str());
+ std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gcc"; // default to gcc
if (compilerId == "MSVC")
{
@@ -713,7 +716,7 @@ std::string cmExtraCodeBlocksGenerator::GetCBCompilerId(const cmMakefile* mf)
{
compiler = "icc";
}
- else if (compilerId == "Watcom")
+ else if (compilerId == "Watcom" || compilerId == "OpenWatcom")
{
compiler = "ow";
}
@@ -756,10 +759,12 @@ int cmExtraCodeBlocksGenerator::GetCBTargetType(cmTarget* target)
// Create the command line for building the given target using the selected
// make
std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
- const std::string& make, const char* makefile, const char* target)
+ const std::string& make, const char* makefile,
+ const std::string& target)
{
std::string command = make;
- if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
+ std::string generator = this->GlobalGenerator->GetName();
+ if (generator == "NMake Makefiles")
{
// For Windows ConvertToOutputPath already adds quotes when required.
// These need to be escaped, see
@@ -770,7 +775,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
command += " VERBOSE=1 ";
command += target;
}
- else if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+ else if (generator == "MinGW Makefiles")
{
// no escaping of spaces in this case, see
// http://public.kitware.com/Bug/view.php?id=10014
@@ -781,7 +786,7 @@ std::string cmExtraCodeBlocksGenerator::BuildMakeCommand(
command += " VERBOSE=1 ";
command += target;
}
- else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+ else if (generator == "Ninja")
{
command += " -v ";
command += target;
diff --git a/Source/cmExtraCodeBlocksGenerator.h b/Source/cmExtraCodeBlocksGenerator.h
index e0a64ca..0435ad8 100644
--- a/Source/cmExtraCodeBlocksGenerator.h
+++ b/Source/cmExtraCodeBlocksGenerator.h
@@ -28,14 +28,14 @@ class cmExtraCodeBlocksGenerator : public cmExternalMakefileProjectGenerator
public:
cmExtraCodeBlocksGenerator();
- virtual const char* GetName() const
+ virtual std::string GetName() const
{ return cmExtraCodeBlocksGenerator::GetActualName();}
- static const char* GetActualName() { return "CodeBlocks";}
+ static std::string GetActualName() { return "CodeBlocks";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraCodeBlocksGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const;
+ const std::string& fullName) const;
virtual void Generate();
private:
@@ -49,9 +49,9 @@ private:
std::string GetCBCompilerId(const cmMakefile* mf);
int GetCBTargetType(cmTarget* target);
std::string BuildMakeCommand(const std::string& make, const char* makefile,
- const char* target);
+ const std::string& target);
void AppendTarget(cmGeneratedFileStream& fout,
- const char* targetName,
+ const std::string& targetName,
cmTarget* target,
const char* make,
const cmMakefile* makefile,
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index ff84fb7..cc42bca 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -23,12 +23,12 @@
#include <cmsys/SystemTools.hxx>
#include <cmsys/SystemInformation.hxx>
#include <cmsys/Directory.hxx>
+#include "cmStandardIncludes.h"
#include "cmXMLSafe.h"
-#include <sstream>
//----------------------------------------------------------------------------
void cmExtraCodeLiteGenerator::GetDocumentation(cmDocumentationEntry& entry,
- const char*) const
+ const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates CodeLite project files.";
@@ -60,7 +60,7 @@ void cmExtraCodeLiteGenerator::Generate()
// loop projects and locate the root project.
// and extract the information for creating the worspace
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it!= this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -85,7 +85,7 @@ void cmExtraCodeLiteGenerator::Generate()
}
// for each sub project in the workspace create a codelite project
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it!= this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -214,20 +214,23 @@ void cmExtraCodeLiteGenerator
case cmTarget::MODULE_LIBRARY:
{
std::vector<cmSourceFile*> sources;
- ti->second.GetSourceFiles(sources);
+ ti->second.GetSourceFiles(sources,
+ makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++)
{
// check whether it is a C/C++ implementation file
bool isCFile = false;
- if ((*si)->GetLanguage() && (*(*si)->GetLanguage() == 'C'))
+ std::string lang = (*si)->GetLanguage();
+ if (lang == "C" || lang == "CXX")
{
+ std::string srcext = (*si)->GetExtension();
for(std::vector<std::string>::const_iterator
ext = mf->GetSourceExtensions().begin();
ext != mf->GetSourceExtensions().end();
++ext)
{
- if ((*si)->GetExtension() == *ext)
+ if (srcext == *ext)
{
isCFile = true;
break;
@@ -309,7 +312,7 @@ void cmExtraCodeLiteGenerator
{
std::string relativePath =
cmSystemTools::RelativePath(projectPath.c_str(), sit->first.c_str());
- fout<< " <File Name=\"" << relativePath.c_str() << "\"/>\n";
+ fout<< " <File Name=\"" << relativePath << "\"/>\n";
}
fout<< " </VirtualDirectory>\n";
fout<< " <VirtualDirectory Name=\"include\">\n";
@@ -320,7 +323,7 @@ void cmExtraCodeLiteGenerator
{
std::string relativePath =
cmSystemTools::RelativePath(projectPath.c_str(), sit->c_str());
- fout << " <File Name=\"" << relativePath.c_str() << "\"/>\n";
+ fout << " <File Name=\"" << relativePath << "\"/>\n";
}
fout << " </VirtualDirectory>\n";
@@ -402,7 +405,7 @@ cmExtraCodeLiteGenerator::GetCodeLiteCompilerName(const cmMakefile* mf) const
compilerIdVar = "CMAKE_C_COMPILER_ID";
}
- std::string compilerId = mf->GetSafeDefinition(compilerIdVar.c_str());
+ std::string compilerId = mf->GetSafeDefinition(compilerIdVar);
std::string compiler = "gnu g++"; // default to g++
// Since we need the compiler for parsing purposes only
@@ -440,26 +443,22 @@ cmExtraCodeLiteGenerator::GetConfigurationName(const cmMakefile* mf) const
std::string
cmExtraCodeLiteGenerator::GetBuildCommand(const cmMakefile* mf) const
{
- std::stringstream ss;
std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
std::string make = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
std::string buildCommand = make; // Default
- if ( generator == "NMake Makefiles" )
+ if ( generator == "NMake Makefiles" ||
+ generator == "Ninja" )
{
buildCommand = make;
}
else if ( generator == "MinGW Makefiles" ||
generator == "Unix Makefiles" )
{
+ cmOStringStream ss;
ss << make << " -j " << this->CpuCount;
buildCommand = ss.str();
}
- else if ( generator == "Ninja" )
- {
- ss << make;
- buildCommand = ss.str();
- }
- return buildCommand;
+ return buildCommand;
}
std::string
@@ -483,7 +482,7 @@ cmExtraCodeLiteGenerator::GetSingleFileBuildCommand
std::string generator = mf->GetSafeDefinition("CMAKE_GENERATOR");
if ( generator == "Unix Makefiles" || generator == "MinGW Makefiles" )
{
- std::stringstream ss;
+ cmOStringStream ss;
ss << make << " -f$(ProjectPath)/Makefile $(CurrentFileName).cpp.o";
buildCommand = ss.str();
}
diff --git a/Source/cmExtraCodeLiteGenerator.h b/Source/cmExtraCodeLiteGenerator.h
index 984313e..6b4965d 100644
--- a/Source/cmExtraCodeLiteGenerator.h
+++ b/Source/cmExtraCodeLiteGenerator.h
@@ -35,14 +35,14 @@ protected:
public:
cmExtraCodeLiteGenerator();
- virtual const char* GetName() const
+ virtual std::string GetName() const
{ return cmExtraCodeLiteGenerator::GetActualName();}
- static const char* GetActualName() { return "CodeLite";}
+ static std::string GetActualName() { return "CodeLite";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraCodeLiteGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const;
+ const std::string& fullName) const;
virtual void Generate();
void CreateProjectFile(const std::vector<cmLocalGenerator*>& lgs);
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 74ba9a6..e23551e 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -45,7 +45,7 @@ cmExtraEclipseCDT4Generator
//----------------------------------------------------------------------------
void cmExtraEclipseCDT4Generator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Eclipse CDT 4.0 project files.";
@@ -205,7 +205,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
std::string cacheEntryName = "CMAKE_ECLIPSE_ENVVAR_";
cacheEntryName += envVar;
const char* cacheValue = mf->GetCacheManager()->GetCacheValue(
- cacheEntryName.c_str());
+ cacheEntryName);
// now we have both, decide which one to use
std::string valueToUse;
@@ -219,7 +219,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
// The variable is in the env, but not in the cache. Use it and put it
// in the cache
valueToUse = envVarValue;
- mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(),
+ mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmCacheManager::STRING,
true);
mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
@@ -240,7 +240,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(cmGeneratedFileStream& fout,
if (valueToUse.find(envVarValue) == std::string::npos)
{
valueToUse = envVarValue;
- mf->AddCacheDefinition(cacheEntryName.c_str(), valueToUse.c_str(),
+ mf->AddCacheDefinition(cacheEntryName, valueToUse.c_str(),
cacheEntryName.c_str(), cmCacheManager::STRING,
true);
mf->GetCacheManager()->SaveCache(mf->GetHomeOutputDirectory());
@@ -560,7 +560,8 @@ void cmExtraEclipseCDT4Generator::CreateLinksForTargets(
// get the files from the source lists then add them to the groups
cmTarget* tgt = const_cast<cmTarget*>(&ti->second);
std::vector<cmSourceFile*> files;
- tgt->GetSourceFiles(files);
+ tgt->GetSourceFiles(files,
+ makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator sfIt = files.begin();
sfIt != files.end();
sfIt++)
@@ -624,7 +625,7 @@ void cmExtraEclipseCDT4Generator::CreateLinksToSubprojects(
this->AppendLinkedResource(fout, "[Subprojects]",
"virtual:/virtual", VirtualFolder);
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it != this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -981,7 +982,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
std::string systemIncludeDirs = mf->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS");
std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+ cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
this->AppendIncludeDirectories(fout, dirs, emmited);
}
compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER");
@@ -990,7 +991,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
std::string systemIncludeDirs = mf->GetSafeDefinition(
"CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS");
std::vector<std::string> dirs;
- cmSystemTools::ExpandListArgument(systemIncludeDirs.c_str(), dirs);
+ cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs);
this->AppendIncludeDirectories(fout, dirs, emmited);
}
@@ -1292,7 +1293,7 @@ void cmExtraEclipseCDT4Generator::AppendTarget(cmGeneratedFileStream& fout,
std::string pathXml = cmExtraEclipseCDT4Generator::EscapeForXML(path);
fout <<
"<target name=\"" << prefix << targetXml << "\""
- " path=\"" << pathXml.c_str() << "\""
+ " path=\"" << pathXml << "\""
" targetID=\"org.eclipse.cdt.make.MakeTargetBuilder\">\n"
"<buildCommand>"
<< cmExtraEclipseCDT4Generator::GetEclipsePath(make)
diff --git a/Source/cmExtraEclipseCDT4Generator.h b/Source/cmExtraEclipseCDT4Generator.h
index d88b247..ef99760 100644
--- a/Source/cmExtraEclipseCDT4Generator.h
+++ b/Source/cmExtraEclipseCDT4Generator.h
@@ -33,14 +33,14 @@ public:
return new cmExtraEclipseCDT4Generator;
}
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmExtraEclipseCDT4Generator::GetActualName();
}
- static const char* GetActualName() { return "Eclipse CDT4"; }
+ static std::string GetActualName() { return "Eclipse CDT4"; }
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const;
+ const std::string& fullName) const;
virtual void EnableLanguage(std::vector<std::string> const& languages,
cmMakefile *, bool optional);
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index a0d37d4..567542e 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -25,7 +25,7 @@
//----------------------------------------------------------------------------
void cmExtraKateGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Kate project files.";
@@ -52,7 +52,7 @@ void cmExtraKateGenerator::Generate()
this->ProjectName = this->GenerateProjectName(mf->GetProjectName(),
mf->GetSafeDefinition("CMAKE_BUILD_TYPE"),
this->GetPathBasename(mf->GetHomeOutputDirectory()));
- this->UseNinja = (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0);
+ this->UseNinja = (this->GlobalGenerator->GetName() == "Ninja");
this->CreateKateProjectFile(mf);
this->CreateDummyKateProjectFile(mf);
diff --git a/Source/cmExtraKateGenerator.h b/Source/cmExtraKateGenerator.h
index 6ced5fe..f800feb 100644
--- a/Source/cmExtraKateGenerator.h
+++ b/Source/cmExtraKateGenerator.h
@@ -28,14 +28,14 @@ class cmExtraKateGenerator : public cmExternalMakefileProjectGenerator
public:
cmExtraKateGenerator();
- virtual const char* GetName() const
+ virtual std::string GetName() const
{ return cmExtraKateGenerator::GetActualName();}
- static const char* GetActualName() { return "Kate";}
+ static std::string GetActualName() { return "Kate";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraKateGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const;
+ const std::string& fullName) const;
virtual void Generate();
private:
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 604bfcc..7fe47c3 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -41,7 +41,7 @@ http://sublimetext.info/docs/en/reference/build_systems.html
//----------------------------------------------------------------------------
void cmExtraSublimeTextGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates Sublime Text 2 project files.";
@@ -64,7 +64,7 @@ cmExtraSublimeTextGenerator::cmExtraSublimeTextGenerator()
void cmExtraSublimeTextGenerator::Generate()
{
// for each sub project in the project create a sublime text 2 project
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it!= this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -177,7 +177,7 @@ void cmExtraSublimeTextGenerator::
if (strcmp(makefile->GetStartOutputDirectory(),
makefile->GetHomeOutputDirectory())==0)
{
- this->AppendTarget(fout, ti->first.c_str(), *lg, 0,
+ this->AppendTarget(fout, ti->first, *lg, 0,
make.c_str(), makefile, compiler.c_str(),
sourceFileFlags, false);
}
@@ -194,7 +194,7 @@ void cmExtraSublimeTextGenerator::
break;
}
- this->AppendTarget(fout, ti->first.c_str(), *lg, 0,
+ this->AppendTarget(fout, ti->first, *lg, 0,
make.c_str(), makefile, compiler.c_str(),
sourceFileFlags, false);
break;
@@ -204,12 +204,12 @@ void cmExtraSublimeTextGenerator::
case cmTarget::MODULE_LIBRARY:
case cmTarget::OBJECT_LIBRARY:
{
- this->AppendTarget(fout, ti->first.c_str(), *lg, &ti->second,
+ this->AppendTarget(fout, ti->first, *lg, &ti->second,
make.c_str(), makefile, compiler.c_str(),
sourceFileFlags, false);
std::string fastTarget = ti->first;
fastTarget += "/fast";
- this->AppendTarget(fout, fastTarget.c_str(), *lg, &ti->second,
+ this->AppendTarget(fout, fastTarget, *lg, &ti->second,
make.c_str(), makefile, compiler.c_str(),
sourceFileFlags, false);
}
@@ -223,7 +223,7 @@ void cmExtraSublimeTextGenerator::
void cmExtraSublimeTextGenerator::
AppendTarget(cmGeneratedFileStream& fout,
- const char* targetName,
+ const std::string& targetName,
cmLocalGenerator* lg,
cmTarget* target,
const char* make,
@@ -238,7 +238,8 @@ void cmExtraSublimeTextGenerator::
cmGeneratorTarget *gtgt = this->GlobalGenerator
->GetGeneratorTarget(target);
std::vector<cmSourceFile*> sourceFiles;
- target->GetSourceFiles(sourceFiles);
+ target->GetSourceFiles(sourceFiles,
+ makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
std::vector<cmSourceFile*>::const_iterator sourceFilesEnd =
sourceFiles.end();
for (std::vector<cmSourceFile*>::const_iterator iter =
@@ -290,7 +291,7 @@ void cmExtraSublimeTextGenerator::
// Ninja uses ninja.build files (look for a way to get the output file name
// from cmMakefile or something)
std::string makefileName;
- if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+ if (this->GlobalGenerator->GetName() == "Ninja")
{
makefileName = "build.ninja";
}
@@ -315,11 +316,13 @@ void cmExtraSublimeTextGenerator::
// Create the command line for building the given target using the selected
// make
std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
- const std::string& make, const char* makefile, const char* target)
+ const std::string& make, const char* makefile,
+ const std::string& target)
{
std::string command = "\"";
command += make + "\"";
- if (strcmp(this->GlobalGenerator->GetName(), "NMake Makefiles")==0)
+ std::string generator = this->GlobalGenerator->GetName();
+ if (generator == "NMake Makefiles")
{
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += ", \"/NOLOGO\", \"/f\", \"";
@@ -328,7 +331,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
command += target;
command += "\"";
}
- else if (strcmp(this->GlobalGenerator->GetName(), "Ninja")==0)
+ else if (generator == "Ninja")
{
std::string makefileName = cmSystemTools::ConvertToOutputPath(makefile);
command += ", \"-f\", \"";
@@ -340,7 +343,7 @@ std::string cmExtraSublimeTextGenerator::BuildMakeCommand(
else
{
std::string makefileName;
- if (strcmp(this->GlobalGenerator->GetName(), "MinGW Makefiles")==0)
+ if (generator == "MinGW Makefiles")
{
// no escaping of spaces in this case, see
// http://public.kitware.com/Bug/view.php?id=10014
@@ -369,12 +372,12 @@ cmExtraSublimeTextGenerator::ComputeFlagsForObject(cmSourceFile* source,
std::string flags;
cmMakefile *makefile = lg->GetMakefile();
- const char* language = source->GetLanguage();
- if (language == NULL)
+ std::string language = source->GetLanguage();
+ if (language.empty())
{
language = "C";
}
- const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
// Add language-specific flags.
lg->AddLanguageFlags(flags, language, config);
@@ -423,12 +426,8 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
{
std::set<std::string> defines;
cmMakefile *makefile = lg->GetMakefile();
- const char* language = source->GetLanguage();
- if (language == NULL)
- {
- language = "";
- }
- const char* config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ const std::string& language = source->GetLanguage();
+ const std::string& config = makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
// Add the export symbol definition for shared library objects.
if(const char* exportMacro = target->GetExportMacro())
@@ -442,7 +441,7 @@ ComputeDefines(cmSourceFile *source, cmLocalGenerator* lg, cmTarget *target,
{
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += cmSystemTools::UpperCase(config);
- lg->AppendDefines(defines, source->GetProperty(defPropName.c_str()));
+ lg->AppendDefines(defines, source->GetProperty(defPropName));
}
std::string definesString;
diff --git a/Source/cmExtraSublimeTextGenerator.h b/Source/cmExtraSublimeTextGenerator.h
index 7902593..4173b7d 100644
--- a/Source/cmExtraSublimeTextGenerator.h
+++ b/Source/cmExtraSublimeTextGenerator.h
@@ -31,15 +31,15 @@ public:
typedef std::map<std::string, std::vector<std::string> > MapSourceFileFlags;
cmExtraSublimeTextGenerator();
- virtual const char* GetName() const
+ virtual std::string GetName() const
{ return cmExtraSublimeTextGenerator::GetActualName();}
- static const char* GetActualName()
+ static std::string GetActualName()
{ return "Sublime Text 2";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmExtraSublimeTextGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const;
+ const std::string& fullName) const;
virtual void Generate();
private:
@@ -60,12 +60,12 @@ private:
* specified target.
*/
std::string BuildMakeCommand(const std::string& make, const char* makefile,
- const char* target);
+ const std::string& target);
/** Appends the specified target to the generated project file as a Sublime
* Text build system.
*/
void AppendTarget(cmGeneratedFileStream& fout,
- const char* targetName,
+ const std::string& targetName,
cmLocalGenerator* lg,
cmTarget* target,
const char* make,
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 4dd81be..f7d8243 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -48,7 +48,7 @@ bool cmFLTKWrapUICommand
for(std::vector<std::string>::iterator i = (newArgs.begin() + 1);
i != newArgs.end(); i++)
{
- cmSourceFile *curr = this->Makefile->GetSource(i->c_str());
+ cmSourceFile *curr = this->Makefile->GetSource(*i);
// if we should use the source GUI
// to generate .cxx and .h files
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE"))
@@ -78,19 +78,19 @@ bool cmFLTKWrapUICommand
commandLines.push_back(commandLine);
// Add command for generating the .h and .cxx files
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
const char* no_comment = 0;
const char* no_working_dir = 0;
- this->Makefile->AddCustomCommandToOutput(cxxres.c_str(),
+ this->Makefile->AddCustomCommandToOutput(cxxres,
depends, no_main_dependency,
commandLines, no_comment,
no_working_dir);
- this->Makefile->AddCustomCommandToOutput(hname.c_str(),
+ this->Makefile->AddCustomCommandToOutput(hname,
depends, no_main_dependency,
commandLines, no_comment,
no_working_dir);
- cmSourceFile *sf = this->Makefile->GetSource(cxxres.c_str());
+ cmSourceFile *sf = this->Makefile->GetSource(cxxres);
sf->AddDepend(hname.c_str());
sf->AddDepend(origname.c_str());
this->GeneratedSourcesClasses.push_back(sf);
@@ -110,7 +110,7 @@ bool cmFLTKWrapUICommand
}
std::string varName = this->Target;
varName += "_FLTK_UI_SRCS";
- this->Makefile->AddDefinition(varName.c_str(), sourceListValue.c_str());
+ this->Makefile->AddDefinition(varName, sourceListValue.c_str());
return true;
}
@@ -133,7 +133,7 @@ void cmFLTKWrapUICommand::FinalPass()
return;
}
std::vector<cmSourceFile*> srcs;
- target->GetSourceFiles(srcs);
+ target->GetSourceFiles(srcs, "");
bool found = false;
for (unsigned int i = 0; i < srcs.size(); ++i)
{
@@ -168,7 +168,7 @@ void cmFLTKWrapUICommand::FinalPass()
for(size_t classNum = 0; classNum < lastHeadersClass; classNum++)
{
this->Makefile->GetTargets()[this->Target]
- .AddSourceFile(this->GeneratedSourcesClasses[classNum]);
+ .AddSource(this->GeneratedSourcesClasses[classNum]->GetFullPath());
}
}
}
diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h
index b94390c..617fcd9 100644
--- a/Source/cmFLTKWrapUICommand.h
+++ b/Source/cmFLTKWrapUICommand.h
@@ -52,7 +52,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "fltk_wrap_ui";}
+ virtual std::string GetName() const { return "fltk_wrap_ui";}
private:
/**
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index e79bc6c..5bfb664 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -174,7 +174,7 @@ bool cmFileCommand
}
std::string e = "does not recognize sub-command "+subCommand;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -205,7 +205,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
std::string e
= "attempted to write a file: " + fileName +
" into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -235,7 +235,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector<std::string> const& args,
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for writing.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
file << message;
@@ -295,7 +295,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for reading.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
@@ -359,7 +359,7 @@ bool cmFileCommand::HandleReadCommand(std::vector<std::string> const& args)
}
}
}
- this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(variable, output.c_str());
return true;
}
@@ -371,23 +371,23 @@ bool cmFileCommand::HandleHashCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << args[0] << " requires a file name and output variable";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
if(hash.get())
{
- std::string out = hash->HashFile(args[1].c_str());
+ std::string out = hash->HashFile(args[1]);
if(!out.empty())
{
- this->Makefile->AddDefinition(args[2].c_str(), out.c_str());
+ this->Makefile->AddDefinition(args[2], out.c_str());
return true;
}
cmOStringStream e;
e << args[0] << " failed to read file \"" << args[1] << "\": "
<< cmSystemTools::GetLastSystemError();
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
}
return false;
#else
@@ -481,7 +481,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LIMIT_INPUT value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
arg_mode = arg_none;
@@ -494,7 +494,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LIMIT_OUTPUT value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
arg_mode = arg_none;
@@ -507,7 +507,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LIMIT_COUNT value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
limit_count = count;
@@ -521,7 +521,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LENGTH_MINIMUM value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
minlen = len;
@@ -535,7 +535,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option LENGTH_MAXIMUM value \""
<< args[i] << "\" is not an unsigned integer.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
maxlen = len;
@@ -548,7 +548,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS option REGEX value \""
<< args[i] << "\" could not be compiled.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
have_regex = true;
@@ -559,7 +559,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
cmOStringStream e;
e << "STRINGS given unknown argument \""
<< args[i] << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -586,7 +586,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "STRINGS file \"" << fileName << "\" cannot be read.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -709,7 +709,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector<std::string> const& args)
}
// Save the output in a makefile variable.
- this->Makefile->AddDefinition(outVar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outVar, output.c_str());
return true;
}
@@ -844,7 +844,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector<std::string> const& args,
}
}
- this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(variable, output.c_str());
return true;
}
@@ -873,14 +873,14 @@ bool cmFileCommand::HandleMakeDirectoryCommand(
{
std::string e = "attempted to create a directory: " + *cdir
+ " into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
if ( !cmSystemTools::MakeDirectory(cdir->c_str()) )
{
std::string error = "problem creating directory: " + *cdir;
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
}
@@ -926,7 +926,7 @@ cmFileCommand::HandleDifferentCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "DIFFERENT given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1041,7 +1041,7 @@ protected:
{
cmOStringStream e;
e << this->Name << " cannot set permissions on \"" << toFile << "\"";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
return true;
@@ -1065,7 +1065,7 @@ protected:
{
cmOStringStream e;
e << this->Name << " given invalid permission \"" << arg << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
return true;
@@ -1092,7 +1092,7 @@ protected:
// The input file does not exist and installation is not optional.
cmOStringStream e;
e << this->Name << " cannot find \"" << fromFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1125,14 +1125,14 @@ protected:
{
cmOStringStream e;
e << "option " << arg << " may not appear before PATTERN or REGEX.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
void NotAfterMatch(std::string const& arg)
{
cmOStringStream e;
e << "option " << arg << " may not appear after PATTERN or REGEX.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
virtual void DefaultFilePermissions()
@@ -1170,7 +1170,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "called with unknown argument \"" << args[i] << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1186,7 +1186,7 @@ bool cmFileCopier::Parse(std::vector<std::string> const& args)
{
cmOStringStream e;
e << this->Name << " given no DESTINATION";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1366,7 +1366,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
{
cmOStringStream e;
e << "could not compile PATTERN \"" << arg << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
}
@@ -1382,7 +1382,7 @@ bool cmFileCopier::CheckValue(std::string const& arg)
{
cmOStringStream e;
e << "could not compile REGEX \"" << arg << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
break;
@@ -1462,7 +1462,7 @@ bool cmFileCopier::Install(const char* fromFile, const char* toFile)
{
cmOStringStream e;
e << "INSTALL encountered an empty string input file name.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1504,7 +1504,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
cmOStringStream e;
e << this->Name << " cannot read symlink \"" << fromFile
<< "\" to duplicate at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1537,7 +1537,7 @@ bool cmFileCopier::InstallSymlink(const char* fromFile, const char* toFile)
cmOStringStream e;
e << this->Name << " cannot duplicate symlink \"" << fromFile
<< "\" at \"" << toFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
}
@@ -1569,7 +1569,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
cmOStringStream e;
e << this->Name << " cannot copy file \"" << fromFile
<< "\" to \"" << toFile << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1588,7 +1588,7 @@ bool cmFileCopier::InstallFile(const char* fromFile, const char* toFile,
cmOStringStream e;
e << this->Name << " cannot set modification time on \""
<< toFile << "\"";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
}
@@ -1619,7 +1619,7 @@ bool cmFileCopier::InstallDirectory(const char* source,
cmOStringStream e;
e << this->Name << " cannot make directory \"" << destination << "\": "
<< cmSystemTools::GetLastSystemError();
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
@@ -1910,7 +1910,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg)
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.";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
this->Doing = DoingError;
}
else
@@ -1976,7 +1976,7 @@ bool cmFileInstaller
{
cmOStringStream e;
e << "Option TYPE given unknown value \"" << stype << "\".";
- this->FileCommand->SetError(e.str().c_str());
+ this->FileCommand->SetError(e.str());
return false;
}
return true;
@@ -2047,7 +2047,7 @@ bool cmFileInstaller::HandleInstallDestination()
"absolute path or remove DESTDIR environment variable."
"\nDESTINATION=\n";
message += destination;
- this->FileCommand->SetError(message.c_str());
+ this->FileCommand->SetError(message);
return false;
}
}
@@ -2061,7 +2061,7 @@ bool cmFileInstaller::HandleInstallDestination()
{
std::string errstring = "cannot create directory: " + destination +
". Maybe need administrative privileges.";
- this->FileCommand->SetError(errstring.c_str());
+ this->FileCommand->SetError(errstring);
return false;
}
}
@@ -2069,7 +2069,7 @@ bool cmFileInstaller::HandleInstallDestination()
{
std::string errstring = "INSTALL destination: " + destination +
" is not a directory.";
- this->FileCommand->SetError(errstring.c_str());
+ this->FileCommand->SetError(errstring);
return false;
}
return true;
@@ -2118,7 +2118,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_CHANGE given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -2141,7 +2141,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
bool success = true;
@@ -2157,7 +2157,7 @@ cmFileCommand::HandleRPathChangeCommand(std::vector<std::string> const& args)
<< "to the file:\n"
<< " " << file << "\n"
<< emsg;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
success = false;
}
if(success)
@@ -2203,7 +2203,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_REMOVE given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -2216,7 +2216,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
bool success = true;
@@ -2230,7 +2230,7 @@ cmFileCommand::HandleRPathRemoveCommand(std::vector<std::string> const& args)
e << "RPATH_REMOVE could not remove RPATH from file:\n"
<< " " << file << "\n"
<< emsg;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
success = false;
}
if(success)
@@ -2284,7 +2284,7 @@ cmFileCommand::HandleRPathCheckCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << "RPATH_CHECK given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -2337,7 +2337,7 @@ bool cmFileCommand::HandleRelativePathCommand(
std::string errstring =
"RELATIVE_PATH must be passed a full path to the directory: "
+ directoryName;
- this->SetError(errstring.c_str());
+ this->SetError(errstring);
return false;
}
if(!cmSystemTools::FileIsFullPath(fileName.c_str()))
@@ -2345,13 +2345,13 @@ bool cmFileCommand::HandleRelativePathCommand(
std::string errstring =
"RELATIVE_PATH must be passed a full path to the file: "
+ fileName;
- this->SetError(errstring.c_str());
+ this->SetError(errstring);
return false;
}
std::string res = cmSystemTools::RelativePath(directoryName.c_str(),
fileName.c_str());
- this->Makefile->AddDefinition(outVar.c_str(),
+ this->Makefile->AddDefinition(outVar,
res.c_str());
return true;
}
@@ -2389,7 +2389,7 @@ bool cmFileCommand::HandleRename(std::vector<std::string> const& args)
<< "to\n"
<< " " << newname << "\n"
<< "because: " << err << "\n";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
return true;
@@ -2539,6 +2539,11 @@ namespace {
if (total > 0.0)
{
this->CurrentPercentage = static_cast<int>(value/total*100.0 + 0.5);
+ if(this->CurrentPercentage > 100)
+ {
+ // Avoid extra progress reports for unexpected data beyond total.
+ this->CurrentPercentage = 100;
+ }
}
bool updated = (OldPercentage != this->CurrentPercentage);
@@ -2649,7 +2654,7 @@ namespace {
{ \
std::string e(errstr); \
e += ::curl_easy_strerror(result); \
- this->SetError(e.c_str()); \
+ this->SetError(e); \
return false; \
}
@@ -2785,7 +2790,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
std::string err =
"DOWNLOAD EXPECTED_HASH expects ALGO=value but got: ";
err += *i;
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
std::string algo = i->substr(0, pos);
@@ -2795,7 +2800,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{
std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: ";
err += algo;
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
hashMatchMSG = algo + " hash";
@@ -2809,7 +2814,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if(cmSystemTools::FileExists(file.c_str()) && hash.get())
{
std::string msg;
- std::string actualHash = hash->HashFile(file.c_str());
+ std::string actualHash = hash->HashFile(file);
if(actualHash == expectedHash)
{
msg = "returning early; file already exists with expected ";
@@ -2819,7 +2824,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{
cmOStringStream result;
result << (int)0 << ";\"" << msg;
- this->Makefile->AddDefinition(statusVar.c_str(),
+ this->Makefile->AddDefinition(statusVar,
result.str().c_str());
}
return true;
@@ -2828,14 +2833,14 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
// Make sure parent directory exists so we can write to the file
// as we receive downloaded bits from curl...
//
- std::string dir = cmSystemTools::GetFilenamePath(file.c_str());
+ std::string dir = cmSystemTools::GetFilenamePath(file);
if(!cmSystemTools::FileExists(dir.c_str()) &&
!cmSystemTools::MakeDirectory(dir.c_str()))
{
std::string errstring = "DOWNLOAD error: cannot create directory '"
+ dir + "' - Specify file by full path name and verify that you "
"have directory creation and file write privileges.";
- this->SetError(errstring.c_str());
+ this->SetError(errstring);
return false;
}
@@ -2954,7 +2959,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
{
cmOStringStream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
- this->Makefile->AddDefinition(statusVar.c_str(),
+ this->Makefile->AddDefinition(statusVar,
result.str().c_str());
}
@@ -2969,7 +2974,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
//
if (hash.get())
{
- std::string actualHash = hash->HashFile(file.c_str());
+ std::string actualHash = hash->HashFile(file);
if (actualHash.size() == 0)
{
this->SetError("DOWNLOAD cannot compute hash on downloaded file");
@@ -2986,7 +2991,7 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
<< " status: [" << (int)res << ";\""
<< ::curl_easy_strerror(res) << "\"]" << std::endl
;
- this->SetError(oss.str().c_str());
+ this->SetError(oss.str());
return false;
}
}
@@ -3000,12 +3005,12 @@ cmFileCommand::HandleDownloadCommand(std::vector<std::string> const& args)
if(verboseLog.size())
{
- this->Makefile->AddDefinition(verboseLog.c_str(),
+ this->Makefile->AddDefinition(verboseLog,
&*chunkDebug.begin());
}
}
- this->Makefile->AddDefinition(verboseLog.c_str(),
+ this->Makefile->AddDefinition(verboseLog,
&*chunkDebug.begin());
}
@@ -3102,7 +3107,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
{
std::string errStr = "UPLOAD cannot open file '";
errStr += filename + "' for reading.";
- this->SetError(errStr.c_str());
+ this->SetError(errStr);
return false;
}
@@ -3111,7 +3116,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
{
std::string errStr = "UPLOAD cannot stat file '";
errStr += filename + "'.";
- this->SetError(errStr.c_str());
+ this->SetError(errStr);
fclose(fin);
return false;
}
@@ -3217,7 +3222,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
{
cmOStringStream result;
result << (int)res << ";\"" << ::curl_easy_strerror(res) << "\"";
- this->Makefile->AddDefinition(statusVar.c_str(),
+ this->Makefile->AddDefinition(statusVar,
result.str().c_str());
}
@@ -3246,7 +3251,7 @@ cmFileCommand::HandleUploadCommand(std::vector<std::string> const& args)
log += "\n";
}
- this->Makefile->AddDefinition(logVar.c_str(), log.c_str());
+ this->Makefile->AddDefinition(logVar, log.c_str());
}
return true;
@@ -3368,7 +3373,7 @@ bool cmFileCommand::HandleTimestampCommand(
{
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
}
@@ -3376,7 +3381,7 @@ bool cmFileCommand::HandleTimestampCommand(
cmTimestamp timestamp;
std::string result = timestamp.FileModificationTime(
filename.c_str(), formatString, utcFlag);
- this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str());
+ this->Makefile->AddDefinition(outputVariable, result.c_str());
return true;
}
diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h
index ba45815..8d66fdf 100644
--- a/Source/cmFileCommand.h
+++ b/Source/cmFileCommand.h
@@ -46,7 +46,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "file";}
+ virtual std::string GetName() const { return "file";}
cmTypeMacro(cmFileCommand, cmCommand);
diff --git a/Source/cmFileTimeComparison.cxx b/Source/cmFileTimeComparison.cxx
index 02f10c0..5727470 100644
--- a/Source/cmFileTimeComparison.cxx
+++ b/Source/cmFileTimeComparison.cxx
@@ -43,13 +43,13 @@ private:
class HashString
{
public:
- size_t operator()(const cmStdString& s) const
+ size_t operator()(const std::string& s) const
{
return h(s.c_str());
}
cmsys::hash<const char*> h;
};
- typedef cmsys::hash_map<cmStdString,
+ typedef cmsys::hash_map<std::string,
cmFileTimeComparison_Type, HashString> FileStatsMap;
FileStatsMap Files;
#endif
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index ae15ee7..e4e819a 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -237,7 +237,7 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
for(std::vector<std::string>::const_iterator it = in_paths.begin();
it != in_paths.end(); ++it)
{
- std::string dir = it->c_str();
+ std::string dir = *it;
if(!subdir.empty() && !dir.empty() && dir[dir.size()-1] != '/')
{
dir += "/";
@@ -268,7 +268,7 @@ void cmFindBase::AddPrefixPaths(std::vector<std::string> const& in_paths,
}
//----------------------------------------------------------------------------
-void cmFindBase::AddCMakePrefixPath(const char* variable)
+void cmFindBase::AddCMakePrefixPath(const std::string& variable)
{
// Get a path from a CMake variable.
if(const char* varPath = this->Makefile->GetDefinition(variable))
@@ -280,11 +280,11 @@ void cmFindBase::AddCMakePrefixPath(const char* variable)
}
//----------------------------------------------------------------------------
-void cmFindBase::AddEnvPrefixPath(const char* variable)
+void cmFindBase::AddEnvPrefixPath(const std::string& variable)
{
// Get a path from the environment.
std::vector<std::string> tmp;
- cmSystemTools::GetPath(tmp, variable);
+ cmSystemTools::GetPath(tmp, variable.c_str());
this->AddPrefixPaths(tmp, EnvPath);
}
@@ -323,7 +323,7 @@ void cmFindBase::AddCMakeVariablePath()
var += this->CMakePathName;
var += "_PATH";
this->AddCMakePrefixPath("CMAKE_PREFIX_PATH");
- this->AddCMakePath(var.c_str());
+ this->AddCMakePath(var);
if(this->CMakePathName == "PROGRAM")
{
@@ -360,7 +360,7 @@ void cmFindBase::AddCMakeSystemVariablePath()
var += this->CMakePathName;
var += "_PATH";
this->AddCMakePrefixPath("CMAKE_SYSTEM_PREFIX_PATH");
- this->AddCMakePath(var.c_str());
+ this->AddCMakePath(var);
if(this->CMakePathName == "PROGRAM")
{
@@ -466,7 +466,7 @@ void cmFindBase::PrintFindStuff()
bool cmFindBase::CheckForVariableInCache()
{
if(const char* cacheValue =
- this->Makefile->GetDefinition(this->VariableName.c_str()))
+ this->Makefile->GetDefinition(this->VariableName))
{
cmCacheManager::CacheIterator it =
this->Makefile->GetCacheManager()->
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 0562b1b..42d9bc1 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -42,14 +42,14 @@ protected:
bool CheckForVariableInCache();
// use by command during find
- cmStdString VariableDocumentation;
- cmStdString VariableName;
+ std::string VariableDocumentation;
+ std::string VariableName;
std::vector<std::string> Names;
bool NamesPerDir;
bool NamesPerDirAllowed;
// CMAKE_*_PATH CMAKE_SYSTEM_*_PATH FRAMEWORK|LIBRARY|INCLUDE|PROGRAM
- cmStdString EnvironmentPath; // LIB,INCLUDE
+ std::string EnvironmentPath; // LIB,INCLUDE
bool AlreadyInCache;
bool AlreadyInCacheWithoutMetaInfo;
@@ -63,8 +63,8 @@ private:
void AddUserGuessPath();
// Helpers.
- void AddCMakePrefixPath(const char* variable);
- void AddEnvPrefixPath(const char* variable);
+ void AddCMakePrefixPath(const std::string& variable);
+ void AddEnvPrefixPath(const std::string& variable);
void AddPrefixPaths(std::vector<std::string> const& in_paths,
PathType pathType);
};
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index e8c8da3..10241f2 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -51,7 +51,7 @@ void cmFindCommon::SelectDefaultRootPathMode()
std::string findRootPathVar = "CMAKE_FIND_ROOT_PATH_MODE_";
findRootPathVar += this->CMakePathName;
std::string rootPathMode =
- this->Makefile->GetSafeDefinition(findRootPathVar.c_str());
+ this->Makefile->GetSafeDefinition(findRootPathVar);
if (rootPathMode=="NEVER")
{
this->FindRootPathMode = RootPathModeNoRootPath;
@@ -361,7 +361,7 @@ void cmFindCommon::AddUserPath(std::string const& p,
// Expand using the view of the target application.
std::string expanded = p;
cmSystemTools::ExpandRegistryValues(expanded, view);
- cmSystemTools::GlobDirs(expanded.c_str(), paths);
+ cmSystemTools::GlobDirs(expanded, paths);
// Executables can be either 32-bit or 64-bit, so expand using the
// alternative view.
@@ -369,12 +369,12 @@ void cmFindCommon::AddUserPath(std::string const& p,
{
expanded = p;
cmSystemTools::ExpandRegistryValues(expanded, other_view);
- cmSystemTools::GlobDirs(expanded.c_str(), paths);
+ cmSystemTools::GlobDirs(expanded, paths);
}
}
//----------------------------------------------------------------------------
-void cmFindCommon::AddCMakePath(const char* variable)
+void cmFindCommon::AddCMakePath(const std::string& variable)
{
// Get a path from a CMake variable.
if(const char* varPath = this->Makefile->GetDefinition(variable))
@@ -433,7 +433,7 @@ void cmFindCommon::AddPathInternal(std::string const& in_path,
// Insert the path if has not already been emitted.
if(this->SearchPathsEmitted.insert(fullPath).second)
{
- this->SearchPaths.push_back(fullPath.c_str());
+ this->SearchPaths.push_back(fullPath);
}
}
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index 6109a9f..5a905cd 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -56,14 +56,14 @@ protected:
/** Compute the current default bundle/framework search policy. */
void SelectDefaultMacMode();
- cmStdString CMakePathName;
+ 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 char* variable);
+ void AddCMakePath(const std::string& variable);
void AddEnvPath(const char* variable);
void AddPathsInternal(std::vector<std::string> const& in_paths,
PathType pathType);
@@ -81,7 +81,7 @@ protected:
std::vector<std::string> UserPaths;
std::vector<std::string> UserHints;
std::vector<std::string> SearchPaths;
- std::set<cmStdString> SearchPathsEmitted;
+ std::set<std::string> SearchPathsEmitted;
bool SearchFrameworkFirst;
bool SearchFrameworkOnly;
diff --git a/Source/cmFindFileCommand.h b/Source/cmFindFileCommand.h
index 3f0baa2..daf1d65 100644
--- a/Source/cmFindFileCommand.h
+++ b/Source/cmFindFileCommand.h
@@ -33,7 +33,7 @@ public:
{
return new cmFindFileCommand;
}
- virtual const char* GetName() const { return "find_file";}
+ virtual std::string GetName() const { return "find_file";}
cmTypeMacro(cmFindFileCommand, cmFindPathCommand);
};
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index de52df7..fe5e45f 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -37,7 +37,7 @@ bool cmFindLibraryCommand
// value.
if(this->AlreadyInCacheWithoutMetaInfo)
{
- this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "",
+ this->Makefile->AddCacheDefinition(this->VariableName, "",
this->VariableDocumentation.c_str(),
cmCacheManager::FILEPATH);
}
@@ -69,14 +69,14 @@ bool cmFindLibraryCommand
if(library != "")
{
// Save the value in the cache
- this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+ this->Makefile->AddCacheDefinition(this->VariableName,
library.c_str(),
this->VariableDocumentation.c_str(),
cmCacheManager::FILEPATH);
return true;
}
std::string notfound = this->VariableName + "-NOTFOUND";
- this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+ this->Makefile->AddCacheDefinition(this->VariableName,
notfound.c_str(),
this->VariableDocumentation.c_str(),
cmCacheManager::FILEPATH);
@@ -368,8 +368,8 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
// Search for a file matching the library name regex.
std::string dir = path;
cmSystemTools::ConvertToUnixSlashes(dir);
- std::set<cmStdString> const& files = this->GG->GetDirectoryContent(dir);
- for(std::set<cmStdString>::const_iterator fi = files.begin();
+ std::set<std::string> const& files = this->GG->GetDirectoryContent(dir);
+ for(std::set<std::string>::const_iterator fi = files.begin();
fi != files.end(); ++fi)
{
std::string const& origName = *fi;
diff --git a/Source/cmFindLibraryCommand.h b/Source/cmFindLibraryCommand.h
index a9ec40e..e257174 100644
--- a/Source/cmFindLibraryCommand.h
+++ b/Source/cmFindLibraryCommand.h
@@ -49,7 +49,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "find_library";}
+ virtual std::string GetName() const {return "find_library";}
cmTypeMacro(cmFindLibraryCommand, cmFindBase);
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 73eba51..a790e00 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -223,7 +223,7 @@ bool cmFindPackageCommand
}
std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
- this->AddFindDefinition(req_var.c_str(), isRequired);
+ this->AddFindDefinition(req_var, isRequired);
// Append to the list of required components.
components += components_sep;
@@ -255,7 +255,7 @@ bool cmFindPackageCommand
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.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
this->Configs.push_back(args[i]);
@@ -268,8 +268,8 @@ bool cmFindPackageCommand
else
{
cmOStringStream e;
- e << "called with invalid argument \"" << args[i].c_str() << "\"";
- this->SetError(e.str().c_str());
+ e << "called with invalid argument \"" << args[i] << "\"";
+ this->SetError(e.str());
return false;
}
}
@@ -286,7 +286,7 @@ bool cmFindPackageCommand
{
e << " " << doubledComponents[i] << "\n";
}
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -309,7 +309,7 @@ bool cmFindPackageCommand
e << " " << args[*si] << "\n";
}
e << "The options are incompatible.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -327,7 +327,7 @@ bool cmFindPackageCommand
// another find_package(<name>) call.
std::string mod = this->Name;
mod += "_FIND_MODULE";
- if(this->Makefile->IsOn(mod.c_str()))
+ if(this->Makefile->IsOn(mod))
{
if(this->Version.empty())
{
@@ -335,17 +335,17 @@ bool cmFindPackageCommand
// Requested version string.
std::string ver = this->Name;
ver += "_FIND_VERSION";
- this->Version = this->Makefile->GetSafeDefinition(ver.c_str());
+ this->Version = this->Makefile->GetSafeDefinition(ver);
// Whether an exact version is required.
std::string exact = this->Name;
exact += "_FIND_VERSION_EXACT";
- this->VersionExact = this->Makefile->IsOn(exact.c_str());
+ this->VersionExact = this->Makefile->IsOn(exact);
}
if(components.empty())
{
std::string components_var = this->Name + "_FIND_COMPONENTS";
- components = this->Makefile->GetSafeDefinition(components_var.c_str());
+ components = this->Makefile->GetSafeDefinition(components_var);
}
}
}
@@ -373,7 +373,7 @@ bool cmFindPackageCommand
std::string disableFindPackageVar = "CMAKE_DISABLE_FIND_PACKAGE_";
disableFindPackageVar += this->Name;
- if(this->Makefile->IsOn(disableFindPackageVar.c_str()))
+ if(this->Makefile->IsOn(disableFindPackageVar))
{
if (this->Required)
{
@@ -381,7 +381,7 @@ bool cmFindPackageCommand
e << "for module " << this->Name << " called with REQUIRED, but "
<< disableFindPackageVar
<< " is enabled. A REQUIRED package cannot be disabled.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -488,7 +488,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
// Store the list of components.
std::string components_var = this->Name + "_FIND_COMPONENTS";
- this->AddFindDefinition(components_var.c_str(), components.c_str());
+ this->AddFindDefinition(components_var, components.c_str());
if(this->Quiet)
{
@@ -496,7 +496,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
// quietly.
std::string quietly = this->Name;
quietly += "_FIND_QUIETLY";
- this->AddFindDefinition(quietly.c_str(), "1");
+ this->AddFindDefinition(quietly, "1");
}
if(this->Required)
@@ -505,7 +505,7 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
// a fatal error if the package is not found.
std::string req = this->Name;
req += "_FIND_REQUIRED";
- this->AddFindDefinition(req.c_str(), "1");
+ this->AddFindDefinition(req, "1");
}
if(!this->Version.empty())
@@ -514,28 +514,29 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
// package has been requested.
std::string ver = this->Name;
ver += "_FIND_VERSION";
- this->AddFindDefinition(ver.c_str(), this->Version.c_str());
+ this->AddFindDefinition(ver, this->Version.c_str());
char buf[64];
sprintf(buf, "%u", this->VersionMajor);
- this->AddFindDefinition((ver+"_MAJOR").c_str(), buf);
+ this->AddFindDefinition(ver+"_MAJOR", buf);
sprintf(buf, "%u", this->VersionMinor);
- this->AddFindDefinition((ver+"_MINOR").c_str(), buf);
+ this->AddFindDefinition(ver+"_MINOR", buf);
sprintf(buf, "%u", this->VersionPatch);
- this->AddFindDefinition((ver+"_PATCH").c_str(), buf);
+ this->AddFindDefinition(ver+"_PATCH", buf);
sprintf(buf, "%u", this->VersionTweak);
- this->AddFindDefinition((ver+"_TWEAK").c_str(), buf);
+ this->AddFindDefinition(ver+"_TWEAK", buf);
sprintf(buf, "%u", this->VersionCount);
- this->AddFindDefinition((ver+"_COUNT").c_str(), buf);
+ this->AddFindDefinition(ver+"_COUNT", buf);
// Tell the module whether an exact version has been requested.
std::string exact = this->Name;
exact += "_FIND_VERSION_EXACT";
- this->AddFindDefinition(exact.c_str(), this->VersionExact? "1":"0");
+ this->AddFindDefinition(exact, this->VersionExact? "1":"0");
}
}
//----------------------------------------------------------------------------
-void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val)
+void cmFindPackageCommand::AddFindDefinition(const std::string& var,
+ const char* val)
{
if(const char* old = this->Makefile->GetDefinition(var))
{
@@ -552,17 +553,17 @@ void cmFindPackageCommand::AddFindDefinition(const char* var, const char* val)
//----------------------------------------------------------------------------
void cmFindPackageCommand::RestoreFindDefinitions()
{
- for(std::map<cmStdString, OriginalDef>::iterator
+ for(std::map<std::string, OriginalDef>::iterator
i = this->OriginalDefs.begin(); i != this->OriginalDefs.end(); ++i)
{
OriginalDef const& od = i->second;
if(od.exists)
{
- this->Makefile->AddDefinition(i->first.c_str(), od.value.c_str());
+ this->Makefile->AddDefinition(i->first, od.value.c_str());
}
else
{
- this->Makefile->RemoveDefinition(i->first.c_str());
+ this->Makefile->RemoveDefinition(i->first);
}
}
}
@@ -581,9 +582,9 @@ bool cmFindPackageCommand::FindModule(bool& found)
found = true;
std::string var = this->Name;
var += "_FIND_MODULE";
- this->Makefile->AddDefinition(var.c_str(), "1");
+ this->Makefile->AddDefinition(var, "1");
bool result = this->ReadListFile(mfile.c_str(), DoPolicyScope);
- this->Makefile->RemoveDefinition(var.c_str());
+ this->Makefile->RemoveDefinition(var);
return result;
}
return true;
@@ -601,7 +602,7 @@ bool cmFindPackageCommand::HandlePackageMode()
upperFound += "_FOUND";
// Try to find the config file.
- const char* def = this->Makefile->GetDefinition(this->Variable.c_str());
+ const char* def = this->Makefile->GetDefinition(this->Variable);
// Try to load the config file if the directory is known
bool fileFound = false;
@@ -626,14 +627,14 @@ bool cmFindPackageCommand::HandlePackageMode()
this->FileFound = file;
fileFound = true;
}
- def = this->Makefile->GetDefinition(this->Variable.c_str());
+ def = this->Makefile->GetDefinition(this->Variable);
}
// Search for the config file if it is not already found.
if(cmSystemTools::IsOff(def) || !fileFound)
{
fileFound = this->FindConfig();
- def = this->Makefile->GetDefinition(this->Variable.c_str());
+ def = this->Makefile->GetDefinition(this->Variable);
}
// Sanity check.
@@ -658,16 +659,16 @@ bool cmFindPackageCommand::HandlePackageMode()
if(fileFound)
{
- if ((this->Makefile->IsDefinitionSet(foundVar.c_str()))
- && (this->Makefile->IsOn(foundVar.c_str()) == false))
+ if ((this->Makefile->IsDefinitionSet(foundVar))
+ && (this->Makefile->IsOn(foundVar) == false))
{
// by removing Foo_FOUND here if it is FALSE, we don't really change
// the situation for the Config file which is about to be included,
// but we make it possible to detect later on whether the Config file
// has set Foo_FOUND to FALSE itself:
- this->Makefile->RemoveDefinition(foundVar.c_str());
+ this->Makefile->RemoveDefinition(foundVar);
}
- this->Makefile->RemoveDefinition(notFoundMessageVar.c_str());
+ this->Makefile->RemoveDefinition(notFoundMessageVar);
// Set the version variables before loading the config file.
// It may override them.
@@ -680,14 +681,14 @@ bool cmFindPackageCommand::HandlePackageMode()
found = true;
// Check whether the Config file has set Foo_FOUND to FALSE:
- if ((this->Makefile->IsDefinitionSet(foundVar.c_str()))
- && (this->Makefile->IsOn(foundVar.c_str()) == false))
+ if ((this->Makefile->IsDefinitionSet(foundVar))
+ && (this->Makefile->IsOn(foundVar) == false))
{
// we get here if the Config file has set Foo_FOUND actively to FALSE
found = false;
configFileSetFOUNDFalse = true;
notFoundMessage = this->Makefile->GetSafeDefinition(
- notFoundMessageVar.c_str());
+ notFoundMessageVar);
}
}
else
@@ -809,18 +810,18 @@ bool cmFindPackageCommand::HandlePackageMode()
}
// Set a variable marking whether the package was found.
- this->Makefile->AddDefinition(foundVar.c_str(), found? "1":"0");
+ this->Makefile->AddDefinition(foundVar, found? "1":"0");
// Set a variable naming the configuration file that was found.
std::string fileVar = this->Name;
fileVar += "_CONFIG";
if(found)
{
- this->Makefile->AddDefinition(fileVar.c_str(), this->FileFound.c_str());
+ this->Makefile->AddDefinition(fileVar, this->FileFound.c_str());
}
else
{
- this->Makefile->RemoveDefinition(fileVar.c_str());
+ this->Makefile->RemoveDefinition(fileVar);
}
std::string consideredConfigsVar = this->Name;
@@ -842,10 +843,10 @@ bool cmFindPackageCommand::HandlePackageMode()
sep = ";";
}
- this->Makefile->AddDefinition(consideredConfigsVar.c_str(),
+ this->Makefile->AddDefinition(consideredConfigsVar,
consideredConfigFiles.c_str());
- this->Makefile->AddDefinition(consideredVersionsVar.c_str(),
+ this->Makefile->AddDefinition(consideredVersionsVar,
consideredVersions.c_str());
return result;
@@ -905,7 +906,7 @@ bool cmFindPackageCommand::FindConfig()
help += this->Name;
help += ".";
// We force the value since we do not get here if it was already set.
- this->Makefile->AddCacheDefinition(this->Variable.c_str(),
+ this->Makefile->AddCacheDefinition(this->Variable,
init.c_str(), help.c_str(),
cmCacheManager::PATH, true);
return found;
@@ -967,7 +968,7 @@ bool cmFindPackageCommand::ReadListFile(const char* f, PolicyScopeRule psr)
std::string e = "Error reading CMake code from \"";
e += f;
e += "\".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -1047,14 +1048,14 @@ void cmFindPackageCommand::AppendSuccessInformation()
std::string transitivePropName = "_CMAKE_";
transitivePropName += this->Name + "_TRANSITIVE_DEPENDENCY";
this->Makefile->GetCMakeInstance()
- ->SetProperty(transitivePropName.c_str(), "False");
+ ->SetProperty(transitivePropName, "False");
}
std::string found = this->Name;
found += "_FOUND";
std::string upperFound = cmSystemTools::UpperCase(found);
- const char* upperResult = this->Makefile->GetDefinition(upperFound.c_str());
- const char* result = this->Makefile->GetDefinition(found.c_str());
+ const char* upperResult = this->Makefile->GetDefinition(upperFound);
+ const char* result = this->Makefile->GetDefinition(found);
bool packageFound = ((cmSystemTools::IsOn(result))
|| (cmSystemTools::IsOn(upperResult)));
@@ -1065,7 +1066,7 @@ void cmFindPackageCommand::AppendSuccessInformation()
std::string quietInfoPropName = "_CMAKE_";
quietInfoPropName += this->Name;
quietInfoPropName += "_QUIET";
- this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName.c_str(),
+ this->Makefile->GetCMakeInstance()->SetProperty(quietInfoPropName,
this->Quiet ? "TRUE" : "FALSE");
// set a global property to record the required version of this package
@@ -1079,7 +1080,7 @@ void cmFindPackageCommand::AppendSuccessInformation()
versionInfo += " ";
versionInfo += this->Version;
}
- this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName.c_str(),
+ this->Makefile->GetCMakeInstance()->SetProperty(versionInfoPropName,
versionInfo.c_str());
if (this->Required)
{
@@ -1087,7 +1088,7 @@ void cmFindPackageCommand::AppendSuccessInformation()
requiredInfoPropName += this->Name;
requiredInfoPropName += "_TYPE";
this->Makefile->GetCMakeInstance()->SetProperty(
- requiredInfoPropName.c_str(), "REQUIRED");
+ requiredInfoPropName, "REQUIRED");
}
@@ -1647,25 +1648,25 @@ void cmFindPackageCommand::StoreVersionFound()
ver += "_VERSION";
if(this->VersionFound.empty())
{
- this->Makefile->RemoveDefinition(ver.c_str());
+ this->Makefile->RemoveDefinition(ver);
}
else
{
- this->Makefile->AddDefinition(ver.c_str(), this->VersionFound.c_str());
+ this->Makefile->AddDefinition(ver, this->VersionFound.c_str());
}
// Store the version components.
char buf[64];
sprintf(buf, "%u", this->VersionFoundMajor);
- this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
+ this->Makefile->AddDefinition(ver+"_MAJOR", buf);
sprintf(buf, "%u", this->VersionFoundMinor);
- this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
+ this->Makefile->AddDefinition(ver+"_MINOR", buf);
sprintf(buf, "%u", this->VersionFoundPatch);
- this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
+ this->Makefile->AddDefinition(ver+"_PATCH", buf);
sprintf(buf, "%u", this->VersionFoundTweak);
- this->Makefile->AddDefinition((ver+"_TWEAK").c_str(), buf);
+ this->Makefile->AddDefinition(ver+"_TWEAK", buf);
sprintf(buf, "%u", this->VersionFoundCount);
- this->Makefile->AddDefinition((ver+"_COUNT").c_str(), buf);
+ this->Makefile->AddDefinition(ver+"_COUNT", buf);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 0d80e48..2249459 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -49,7 +49,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "find_package";}
+ virtual std::string GetName() const { return "find_package";}
cmTypeMacro(cmFindPackageCommand, cmFindCommon);
private:
@@ -57,7 +57,7 @@ private:
void AppendToFoundProperty(bool found);
void SetModuleVariables(const std::string& components);
bool FindModule(bool& found);
- void AddFindDefinition(const char* var, const char* val);
+ void AddFindDefinition(const std::string& var, const char* val);
void RestoreFindDefinitions();
bool HandlePackageMode();
bool FindConfig();
@@ -96,19 +96,19 @@ private:
friend class cmFindPackageFileList;
struct OriginalDef { bool exists; std::string value; };
- std::map<cmStdString, OriginalDef> OriginalDefs;
+ std::map<std::string, OriginalDef> OriginalDefs;
- cmStdString Name;
- cmStdString Variable;
- cmStdString Version;
+ std::string Name;
+ std::string Variable;
+ std::string Version;
unsigned int VersionMajor;
unsigned int VersionMinor;
unsigned int VersionPatch;
unsigned int VersionTweak;
unsigned int VersionCount;
bool VersionExact;
- cmStdString FileFound;
- cmStdString VersionFound;
+ std::string FileFound;
+ std::string VersionFound;
unsigned int VersionFoundMajor;
unsigned int VersionFoundMinor;
unsigned int VersionFoundPatch;
diff --git a/Source/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 8459995..5531cdf 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -38,7 +38,7 @@ bool cmFindPathCommand
if(this->AlreadyInCacheWithoutMetaInfo)
{
this->Makefile->AddCacheDefinition(
- this->VariableName.c_str(), "",
+ this->VariableName, "",
this->VariableDocumentation.c_str(),
(this->IncludeFileInPath ?
cmCacheManager::FILEPATH :cmCacheManager::PATH)
@@ -51,14 +51,14 @@ bool cmFindPathCommand
if(result.size() != 0)
{
this->Makefile->AddCacheDefinition
- (this->VariableName.c_str(), result.c_str(),
+ (this->VariableName, result.c_str(),
this->VariableDocumentation.c_str(),
(this->IncludeFileInPath) ?
cmCacheManager::FILEPATH :cmCacheManager::PATH);
return true;
}
this->Makefile->AddCacheDefinition
- (this->VariableName.c_str(),
+ (this->VariableName,
(this->VariableName + "-NOTFOUND").c_str(),
this->VariableDocumentation.c_str(),
(this->IncludeFileInPath) ?
@@ -89,9 +89,9 @@ std::string
cmFindPathCommand::FindHeaderInFramework(std::string const& file,
std::string const& dir)
{
- cmStdString fileName = file;
- cmStdString frameWorkName;
- cmStdString::size_type pos = fileName.find("/");
+ std::string fileName = file;
+ std::string frameWorkName;
+ std::string::size_type pos = fileName.find("/");
// if there is a / in the name try to find the header as a framework
// For example bar/foo.h would look for:
// bar.framework/Headers/foo.h
@@ -128,7 +128,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file,
}
// if it is not found yet or not a framework header, then do a glob search
// for all frameworks in the directory: dir/*.framework/Headers/<file>
- cmStdString glob = dir;
+ std::string glob = dir;
glob += "*.framework/Headers/";
glob += file;
cmsys::Glob globIt;
@@ -136,7 +136,7 @@ cmFindPathCommand::FindHeaderInFramework(std::string const& file,
std::vector<std::string> files = globIt.GetFiles();
if(files.size())
{
- cmStdString fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
+ std::string fheader = cmSystemTools::CollapseFullPath(files[0].c_str());
if(this->IncludeFileInPath)
{
return fheader;
diff --git a/Source/cmFindPathCommand.h b/Source/cmFindPathCommand.h
index 8df4540..a51da79 100644
--- a/Source/cmFindPathCommand.h
+++ b/Source/cmFindPathCommand.h
@@ -49,7 +49,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "find_path";}
+ virtual std::string GetName() const {return "find_path";}
cmTypeMacro(cmFindPathCommand, cmFindBase);
bool IncludeFileInPath;
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index bb27753..f6e37f6 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -35,7 +35,7 @@ bool cmFindProgramCommand
// value.
if(this->AlreadyInCacheWithoutMetaInfo)
{
- this->Makefile->AddCacheDefinition(this->VariableName.c_str(), "",
+ this->Makefile->AddCacheDefinition(this->VariableName, "",
this->VariableDocumentation.c_str(),
cmCacheManager::FILEPATH);
}
@@ -46,14 +46,14 @@ bool cmFindProgramCommand
if(result != "")
{
// Save the value in the cache
- this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+ this->Makefile->AddCacheDefinition(this->VariableName,
result.c_str(),
this->VariableDocumentation.c_str(),
cmCacheManager::FILEPATH);
return true;
}
- this->Makefile->AddCacheDefinition(this->VariableName.c_str(),
+ this->Makefile->AddCacheDefinition(this->VariableName,
(this->VariableName + "-NOTFOUND").c_str(),
this->VariableDocumentation.c_str(),
cmCacheManager::FILEPATH);
diff --git a/Source/cmFindProgramCommand.h b/Source/cmFindProgramCommand.h
index 7f4811c..70f758f 100644
--- a/Source/cmFindProgramCommand.h
+++ b/Source/cmFindProgramCommand.h
@@ -48,7 +48,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "find_program";}
+ virtual std::string GetName() const { return "find_program";}
cmTypeMacro(cmFindProgramCommand, cmFindBase);
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index d697067..e3f66c1 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -35,9 +35,9 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
// at end of for each execute recorded commands
// store the old value
std::string oldDef;
- if (mf.GetDefinition(this->Args[0].c_str()))
+ if (mf.GetDefinition(this->Args[0]))
{
- oldDef = mf.GetDefinition(this->Args[0].c_str());
+ oldDef = mf.GetDefinition(this->Args[0]);
}
std::vector<std::string>::const_iterator j = this->Args.begin();
++j;
@@ -47,7 +47,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
for( ; j != this->Args.end(); ++j)
{
// set the variable to the loop value
- mf.AddDefinition(this->Args[0].c_str(),j->c_str());
+ mf.AddDefinition(this->Args[0],j->c_str());
// Invoke all the functions that were collected in the block.
cmExecutionStatus status;
for(unsigned int c = 0; c < this->Functions.size(); ++c)
@@ -58,13 +58,13 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
{
inStatus.SetReturnInvoked(true);
// restore the variable to its prior value
- mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
+ mf.AddDefinition(this->Args[0],oldDef.c_str());
return true;
}
if (status.GetBreakInvoked())
{
// restore the variable to its prior value
- mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
+ mf.AddDefinition(this->Args[0],oldDef.c_str());
return true;
}
if(cmSystemTools::GetFatalErrorOccured() )
@@ -74,7 +74,7 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
}
}
// restore the variable to its prior value
- mf.AddDefinition(this->Args[0].c_str(),oldDef.c_str());
+ mf.AddDefinition(this->Args[0],oldDef.c_str());
return true;
}
else
@@ -166,7 +166,7 @@ bool cmForEachCommand
cmOStringStream str;
str << "called with incorrect range specification: start ";
str << start << ", stop " << stop << ", step " << step;
- this->SetError(str.str().c_str());
+ this->SetError(str.str());
return false;
}
std::vector<std::string> range;
@@ -226,7 +226,7 @@ bool cmForEachCommand::HandleInMode(std::vector<std::string> const& args)
}
else if(doing == DoingLists)
{
- const char* value = this->Makefile->GetDefinition(args[i].c_str());
+ const char* value = this->Makefile->GetDefinition(args[i]);
if(value && *value)
{
cmSystemTools::ExpandListArgument(value, f->Args, true);
diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h
index e548ba8..9b7c85a 100644
--- a/Source/cmForEachCommand.h
+++ b/Source/cmForEachCommand.h
@@ -59,7 +59,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "foreach";}
+ virtual std::string GetName() const { return "foreach";}
cmTypeMacro(cmForEachCommand, cmCommand);
private:
diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx
index 85b89d9..3580374 100644
--- a/Source/cmFunctionCommand.cxx
+++ b/Source/cmFunctionCommand.cxx
@@ -20,7 +20,7 @@ public:
cmFunctionHelperCommand() {}
///! clean up any memory allocated by the function
- ~cmFunctionHelperCommand() {};
+ ~cmFunctionHelperCommand() {}
/**
* This is used to avoid including this command
@@ -59,12 +59,12 @@ public:
cmExecutionStatus &);
virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) { return false; };
+ cmExecutionStatus &) { return false; }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return this->Args[0].c_str(); }
+ virtual std::string GetName() const { return this->Args[0]; }
cmTypeMacro(cmFunctionHelperCommand, cmCommand);
@@ -89,7 +89,7 @@ bool cmFunctionHelperCommand::InvokeInitialPass
std::string errorMsg =
"Function invoked with incorrect arguments for function named: ";
errorMsg += this->Args[0];
- this->SetError(errorMsg.c_str());
+ this->SetError(errorMsg);
return false;
}
@@ -113,15 +113,15 @@ bool cmFunctionHelperCommand::InvokeInitialPass
{
cmOStringStream tmpStream;
tmpStream << "ARGV" << t;
- this->Makefile->AddDefinition(tmpStream.str().c_str(),
+ this->Makefile->AddDefinition(tmpStream.str(),
expandedArgs[t].c_str());
- this->Makefile->MarkVariableAsUsed(tmpStream.str().c_str());
+ this->Makefile->MarkVariableAsUsed(tmpStream.str());
}
// define the formal arguments
for (unsigned int j = 1; j < this->Args.size(); ++j)
{
- this->Makefile->AddDefinition(this->Args[j].c_str(),
+ this->Makefile->AddDefinition(this->Args[j],
expandedArgs[j-1].c_str());
}
@@ -219,8 +219,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
}
std::string newName = "_" + this->Args[0];
- mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(),
- newName.c_str());
+ mf.GetCMakeInstance()->RenameCommand(this->Args[0],
+ newName);
mf.AddCommand(f);
// remove the function blocker now that the function is defined
diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h
index a8bd3e7..2df435e 100644
--- a/Source/cmFunctionCommand.h
+++ b/Source/cmFunctionCommand.h
@@ -57,7 +57,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "function";}
+ virtual std::string GetName() const { return "function";}
cmTypeMacro(cmFunctionCommand, cmCommand);
};
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 34efc15..78ad4b2 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -249,12 +249,7 @@ int cmGeneratedFileStreamBase::RenameFile(const char* oldname,
}
//----------------------------------------------------------------------------
-void cmGeneratedFileStream::SetName(const char* fname)
+void cmGeneratedFileStream::SetName(const std::string& fname)
{
- if ( !fname )
- {
- this->Name = "";
- return;
- }
this->Name = fname;
}
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index 99f3b47..7adee7b 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -140,7 +140,7 @@ public:
* Set name of the file that will hold the actual output. This method allows
* the output file to be changed during the use of cmGeneratedFileStream.
*/
- void SetName(const char* fname);
+ void SetName(const std::string& fname);
private:
cmGeneratedFileStream(cmGeneratedFileStream const&); // not implemented
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 2e66d78..d09e950 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -33,17 +33,17 @@ cmGeneratorExpression::cmGeneratorExpression(
cmsys::auto_ptr<cmCompiledGeneratorExpression>
cmGeneratorExpression::Parse(std::string const& input)
{
- return this->Parse(input.c_str());
+ return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
+ new cmCompiledGeneratorExpression(
+ this->Backtrace,
+ input));
}
//----------------------------------------------------------------------------
cmsys::auto_ptr<cmCompiledGeneratorExpression>
cmGeneratorExpression::Parse(const char* input)
{
- return cmsys::auto_ptr<cmCompiledGeneratorExpression>(
- new cmCompiledGeneratorExpression(
- this->Backtrace,
- input));
+ return this->Parse(std::string(input ? input : ""));
}
cmGeneratorExpression::~cmGeneratorExpression()
@@ -52,7 +52,7 @@ cmGeneratorExpression::~cmGeneratorExpression()
//----------------------------------------------------------------------------
const char *cmCompiledGeneratorExpression::Evaluate(
- cmMakefile* mf, const char* config, bool quiet,
+ cmMakefile* mf, const std::string& config, bool quiet,
cmTarget const* headTarget,
cmGeneratorExpressionDAGChecker *dagChecker) const
{
@@ -66,7 +66,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
//----------------------------------------------------------------------------
const char *cmCompiledGeneratorExpression::Evaluate(
- cmMakefile* mf, const char* config, bool quiet,
+ cmMakefile* mf, const std::string& config, bool quiet,
cmTarget const* headTarget,
cmTarget const* currentTarget,
cmGeneratorExpressionDAGChecker *dagChecker) const
@@ -90,6 +90,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
context.HadError = false;
context.HadContextSensitiveCondition = false;
context.HeadTarget = headTarget;
+ context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
context.Backtrace = this->Backtrace;
@@ -97,7 +98,7 @@ const char *cmCompiledGeneratorExpression::Evaluate(
{
this->Output += (*it)->Evaluate(&context, dagChecker);
- for(std::set<cmStdString>::const_iterator
+ for(std::set<std::string>::const_iterator
p = context.SeenTargetProperties.begin();
p != context.SeenTargetProperties.end(); ++p)
{
@@ -122,13 +123,14 @@ const char *cmCompiledGeneratorExpression::Evaluate(
cmCompiledGeneratorExpression::cmCompiledGeneratorExpression(
cmListFileBacktrace const& backtrace,
- const char *input)
- : Backtrace(backtrace), Input(input ? input : ""),
- HadContextSensitiveCondition(false)
+ const std::string& input)
+ : Backtrace(backtrace), Input(input),
+ HadContextSensitiveCondition(false),
+ EvaluateForBuildsystem(false)
{
cmGeneratorExpressionLexer l;
std::vector<cmGeneratorExpressionToken> tokens =
- l.Tokenize(this->Input.c_str());
+ l.Tokenize(this->Input);
this->NeedsEvaluation = l.GetSawGeneratorExpression();
if (this->NeedsEvaluation)
@@ -157,17 +159,24 @@ cmCompiledGeneratorExpression::~cmCompiledGeneratorExpression()
std::string cmGeneratorExpression::StripEmptyListElements(
const std::string &input)
{
+ if (input.find(';') == input.npos)
+ {
+ return input;
+ }
std::string result;
+ result.reserve(input.size());
const char *c = input.c_str();
+ const char *last = c;
bool skipSemiColons = true;
for ( ; *c; ++c)
{
- if(c[0] == ';')
+ if(*c == ';')
{
if(skipSemiColons)
{
- continue;
+ result.append(last, c - last);
+ last = c + 1;
}
skipSemiColons = true;
}
@@ -175,8 +184,8 @@ std::string cmGeneratorExpression::StripEmptyListElements(
{
skipSemiColons = false;
}
- result += *c;
}
+ result.append(last);
if (!result.empty() && *(result.end() - 1) == ';')
{
@@ -372,7 +381,7 @@ void cmGeneratorExpression::Split(const std::string &input,
}
if(!part.empty())
{
- cmSystemTools::ExpandListArgument(part.c_str(), output);
+ cmSystemTools::ExpandListArgument(part, output);
}
}
pos += 2;
diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h
index 4992e93..da64515 100644
--- a/Source/cmGeneratorExpression.h
+++ b/Source/cmGeneratorExpression.h
@@ -16,8 +16,6 @@
#include "cmStandardIncludes.h"
#include "cmListFileCache.h"
-#include <stack>
-
#include <cmsys/RegularExpression.hxx>
#include <cmsys/auto_ptr.hxx>
@@ -78,12 +76,12 @@ private:
class cmCompiledGeneratorExpression
{
public:
- const char* Evaluate(cmMakefile* mf, const char* config,
+ const char* Evaluate(cmMakefile* mf, const std::string& config,
bool quiet = false,
cmTarget const* headTarget = 0,
cmTarget const* currentTarget = 0,
cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
- const char* Evaluate(cmMakefile* mf, const char* config,
+ const char* Evaluate(cmMakefile* mf, const std::string& config,
bool quiet,
cmTarget const* headTarget,
cmGeneratorExpressionDAGChecker *dagChecker) const;
@@ -92,7 +90,7 @@ public:
std::set<cmTarget*> const& GetTargets() const
{ return this->DependTargets; }
- std::set<cmStdString> const& GetSeenTargetProperties() const
+ std::set<std::string> const& GetSeenTargetProperties() const
{ return this->SeenTargetProperties; }
std::set<cmTarget const*> const& GetAllTargetsSeen() const
@@ -100,7 +98,7 @@ public:
~cmCompiledGeneratorExpression();
- std::string GetInput() const
+ std::string const& GetInput() const
{
return this->Input;
}
@@ -114,9 +112,14 @@ public:
return this->HadContextSensitiveCondition;
}
+ void SetEvaluateForBuildsystem(bool eval)
+ {
+ this->EvaluateForBuildsystem = eval;
+ }
+
private:
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
- const char *input);
+ const std::string& input);
friend class cmGeneratorExpression;
@@ -130,9 +133,10 @@ private:
mutable std::set<cmTarget*> DependTargets;
mutable std::set<cmTarget const*> AllTargetsSeen;
- mutable std::set<cmStdString> SeenTargetProperties;
+ mutable std::set<std::string> SeenTargetProperties;
mutable std::string Output;
mutable bool HadContextSensitiveCondition;
+ bool EvaluateForBuildsystem;
};
#endif
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index e7e1d34..7f8e694 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -42,12 +42,12 @@ cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
)
#undef TEST_TRANSITIVE_PROPERTY_METHOD
{
- std::map<cmStdString, std::set<cmStdString> >::const_iterator it
+ std::map<std::string, std::set<std::string> >::const_iterator it
= top->Seen.find(target);
if (it != top->Seen.end())
{
- const std::set<cmStdString> &propSet = it->second;
- const std::set<cmStdString>::const_iterator i = propSet.find(property);
+ const std::set<std::string> &propSet = it->second;
+ const std::set<std::string>::const_iterator i = propSet.find(property);
if (i != propSet.end())
{
this->CheckResult = ALREADY_SEEN;
@@ -92,7 +92,7 @@ void cmGeneratorExpressionDAGChecker::ReportError(
<< "Self reference on target \""
<< context->HeadTarget->GetName() << "\".\n";
context->Makefile->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+ ->IssueMessage(cmake::FATAL_ERROR, e.str(),
parent->Backtrace);
return;
}
@@ -103,7 +103,7 @@ void cmGeneratorExpressionDAGChecker::ReportError(
<< " " << expr << "\n"
<< "Dependency loop found.";
context->Makefile->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+ ->IssueMessage(cmake::FATAL_ERROR, e.str(),
context->Backtrace);
}
@@ -116,7 +116,7 @@ void cmGeneratorExpressionDAGChecker::ReportError(
<< (parent->Content ? parent->Content->GetOriginalExpression() : expr)
<< "\n";
context->Makefile->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+ ->IssueMessage(cmake::FATAL_ERROR, e.str(),
parent->Backtrace);
parent = parent->Parent;
++loopStep;
@@ -179,6 +179,18 @@ bool cmGeneratorExpressionDAGChecker::EvaluatingLinkLibraries(const char *tgt)
|| strcmp(prop, "INTERFACE_LINK_LIBRARIES") == 0;
}
+std::string cmGeneratorExpressionDAGChecker::TopTarget() const
+{
+ const cmGeneratorExpressionDAGChecker *top = this;
+ const cmGeneratorExpressionDAGChecker *parent = this->Parent;
+ while (parent)
+ {
+ top = parent;
+ parent = parent->Parent;
+ }
+ return top->Target;
+}
+
enum TransitiveProperty {
#define DEFINE_ENUM_ENTRY(NAME) NAME,
CM_FOR_EACH_TRANSITIVE_PROPERTY_NAME(DEFINE_ENUM_ENTRY)
diff --git a/Source/cmGeneratorExpressionDAGChecker.h b/Source/cmGeneratorExpressionDAGChecker.h
index b6effa1..7217a56 100644
--- a/Source/cmGeneratorExpressionDAGChecker.h
+++ b/Source/cmGeneratorExpressionDAGChecker.h
@@ -25,7 +25,9 @@
SELECT(F, EvaluatingSystemIncludeDirectories, SYSTEM_INCLUDE_DIRECTORIES) \
SELECT(F, EvaluatingCompileDefinitions, COMPILE_DEFINITIONS) \
SELECT(F, EvaluatingCompileOptions, COMPILE_OPTIONS) \
- SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS)
+ SELECT(F, EvaluatingAutoUicOptions, AUTOUIC_OPTIONS) \
+ SELECT(F, EvaluatingSources, SOURCES) \
+ SELECT(F, EvaluatingCompileFeatures, COMPILE_FEATURES)
#define CM_FOR_EACH_TRANSITIVE_PROPERTY(F) \
CM_FOR_EACH_TRANSITIVE_PROPERTY_IMPL(F, CM_SELECT_BOTH)
@@ -70,6 +72,8 @@ struct cmGeneratorExpressionDAGChecker
void SetTransitivePropertiesOnly()
{ this->TransitivePropertiesOnly = true; }
+ std::string TopTarget() const;
+
private:
Result CheckGraph() const;
@@ -77,7 +81,7 @@ private:
const cmGeneratorExpressionDAGChecker * const Parent;
const std::string Target;
const std::string Property;
- std::map<cmStdString, std::set<cmStdString> > Seen;
+ std::map<std::string, std::set<std::string> > Seen;
const GeneratorExpressionContent * const Content;
const cmListFileBacktrace Backtrace;
Result CheckResult;
diff --git a/Source/cmGeneratorExpressionEvaluationFile.cxx b/Source/cmGeneratorExpressionEvaluationFile.cxx
index bf85870..95a946a 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.cxx
+++ b/Source/cmGeneratorExpressionEvaluationFile.cxx
@@ -33,7 +33,7 @@ cmGeneratorExpressionEvaluationFile::cmGeneratorExpressionEvaluationFile(
}
//----------------------------------------------------------------------------
-void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
+void cmGeneratorExpressionEvaluationFile::Generate(const std::string& config,
cmCompiledGeneratorExpression* inputExpression,
std::map<std::string, std::string> &outputFiles)
{
@@ -50,7 +50,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
cmOStringStream e;
e << "Evaluation file condition \"" << rawCondition << "\" did "
"not evaluate to valid content. Got \"" << condResult << "\".";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
}
@@ -72,7 +72,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
cmOStringStream 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().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
@@ -85,7 +85,7 @@ void cmGeneratorExpressionEvaluationFile::Generate(const char *config,
{
cmOStringStream e;
e << "Evaluation file \"" << outputFileName << "\" cannot be written.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
@@ -109,7 +109,7 @@ void cmGeneratorExpressionEvaluationFile::Generate()
{
cmOStringStream e;
e << "Evaluation file \"" << this->Input << "\" cannot be read.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
@@ -135,18 +135,15 @@ void cmGeneratorExpressionEvaluationFile::Generate()
if (allConfigs.empty())
{
- this->Generate(0, inputExpression.get(), outputFiles);
+ allConfigs.push_back("");
}
- else
+ for(std::vector<std::string>::const_iterator li = allConfigs.begin();
+ li != allConfigs.end(); ++li)
{
- for(std::vector<std::string>::const_iterator li = allConfigs.begin();
- li != allConfigs.end(); ++li)
+ this->Generate(*li, inputExpression.get(), outputFiles);
+ if(cmSystemTools::GetFatalErrorOccured())
{
- this->Generate(li->c_str(), inputExpression.get(), outputFiles);
- if(cmSystemTools::GetFatalErrorOccured())
- {
- return;
- }
+ return;
}
}
}
diff --git a/Source/cmGeneratorExpressionEvaluationFile.h b/Source/cmGeneratorExpressionEvaluationFile.h
index 20ee5cb..f939916 100644
--- a/Source/cmGeneratorExpressionEvaluationFile.h
+++ b/Source/cmGeneratorExpressionEvaluationFile.h
@@ -32,7 +32,7 @@ public:
std::vector<std::string> GetFiles() const { return this->Files; }
private:
- void Generate(const char *config,
+ void Generate(const std::string& config,
cmCompiledGeneratorExpression* inputExpression,
std::map<std::string, std::string> &outputFiles);
diff --git a/Source/cmGeneratorExpressionEvaluator.cxx b/Source/cmGeneratorExpressionEvaluator.cxx
index 7036992..a513921 100644
--- a/Source/cmGeneratorExpressionEvaluator.cxx
+++ b/Source/cmGeneratorExpressionEvaluator.cxx
@@ -15,6 +15,8 @@
#include "cmGeneratorExpressionParser.h"
#include "cmGeneratorExpressionDAGChecker.h"
#include "cmGeneratorExpression.h"
+#include "cmLocalGenerator.h"
+#include "cmSourceFile.h"
#include <cmsys/String.h>
@@ -39,7 +41,7 @@ void reportError(cmGeneratorExpressionContext *context,
<< " " << expr << "\n"
<< result;
context->Makefile->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str().c_str(),
+ ->IssueMessage(cmake::FATAL_ERROR, e.str(),
context->Backtrace);
}
@@ -393,8 +395,8 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
const std::string &lang) const
{
const char *compilerId = context->Makefile ?
- context->Makefile->GetSafeDefinition((
- "CMAKE_" + lang + "_COMPILER_ID").c_str()) : "";
+ context->Makefile->GetSafeDefinition(
+ "CMAKE_" + lang + "_COMPILER_ID") : "";
if (parameters.size() == 0)
{
return compilerId ? compilerId : "";
@@ -428,7 +430,7 @@ struct CompilerIdNode : public cmGeneratorExpressionNode
->GetPolicyWarning(cmPolicies::CMP0044);
context->Makefile->GetCMakeInstance()
->IssueMessage(cmake::AUTHOR_WARNING,
- e.str().c_str(), context->Backtrace);
+ e.str(), context->Backtrace);
}
case cmPolicies::OLD:
return "1";
@@ -500,8 +502,8 @@ struct CompilerVersionNode : public cmGeneratorExpressionNode
const std::string &lang) const
{
const char *compilerVersion = context->Makefile ?
- context->Makefile->GetSafeDefinition((
- "CMAKE_" + lang + "_COMPILER_VERSION").c_str()) : "";
+ context->Makefile->GetSafeDefinition(
+ "CMAKE_" + lang + "_COMPILER_VERSION") : "";
if (parameters.size() == 0)
{
return compilerVersion ? compilerVersion : "";
@@ -689,7 +691,7 @@ static const struct ConfigurationNode : public cmGeneratorExpressionNode
cmGeneratorExpressionDAGChecker *) const
{
context->HadContextSensitiveCondition = true;
- return context->Config ? context->Config : "";
+ return context->Config;
}
} configurationNode;
@@ -718,13 +720,13 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
return std::string();
}
context->HadContextSensitiveCondition = true;
- if (!context->Config)
+ if (context->Config.empty())
{
return parameters.front().empty() ? "1" : "0";
}
if (cmsysString_strcasecmp(parameters.begin()->c_str(),
- context->Config) == 0)
+ context->Config.c_str()) == 0)
{
return "1";
}
@@ -747,7 +749,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
std::string mapProp = "MAP_IMPORTED_CONFIG_";
mapProp += cmSystemTools::UpperCase(context->Config);
if(const char* mapValue =
- context->CurrentTarget->GetProperty(mapProp.c_str()))
+ context->CurrentTarget->GetProperty(mapProp))
{
cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue),
mappedConfigs);
@@ -800,7 +802,7 @@ static const char* targetPropertyTransitiveWhitelist[] = {
#undef TRANSITIVE_PROPERTY_NAME
-std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
+std::string getLinkedTargetsContent(const std::vector<cmTarget*> &targets,
cmTarget const* target,
cmTarget const* headTarget,
cmGeneratorExpressionContext *context,
@@ -811,23 +813,21 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
std::string sep;
std::string depString;
- for (std::vector<std::string>::const_iterator
- it = libraries.begin();
- it != libraries.end(); ++it)
+ for (std::vector<cmTarget*>::const_iterator
+ it = targets.begin();
+ it != targets.end(); ++it)
{
- if (*it == target->GetName())
+ if (*it == target)
{
// Broken code can have a target in its own link interface.
// Don't follow such link interface entries so as not to create a
// self-referencing loop.
continue;
}
- if (context->Makefile->FindTargetToUse(*it))
- {
- depString +=
- sep + "$<TARGET_PROPERTY:" + *it + "," + interfacePropertyName + ">";
- sep = ";";
- }
+ depString +=
+ sep + "$<TARGET_PROPERTY:" +
+ (*it)->GetName() + "," + interfacePropertyName + ">";
+ sep = ";";
}
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(depString);
std::string linkedTargetsContent = cge->Evaluate(context->Makefile,
@@ -843,6 +843,27 @@ std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
return linkedTargetsContent;
}
+std::string getLinkedTargetsContent(const std::vector<std::string> &libraries,
+ cmTarget const* target,
+ cmTarget const* headTarget,
+ cmGeneratorExpressionContext *context,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string &interfacePropertyName)
+{
+ std::vector<cmTarget*> tgts;
+ for (std::vector<std::string>::const_iterator
+ it = libraries.begin();
+ it != libraries.end(); ++it)
+ {
+ if (cmTarget *tgt = context->Makefile->FindTargetToUse(*it))
+ {
+ tgts.push_back(tgt);
+ }
+ }
+ return getLinkedTargetsContent(tgts, target, headTarget, context,
+ dagChecker, interfacePropertyName);
+}
+
//----------------------------------------------------------------------------
static const struct TargetPropertyNode : public cmGeneratorExpressionNode
{
@@ -964,15 +985,15 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
if (propertyName == "LINKER_LANGUAGE")
{
if (target->LinkLanguagePropagatesToDependents() &&
- dagCheckerParent && dagCheckerParent->EvaluatingLinkLibraries())
+ dagCheckerParent && (dagCheckerParent->EvaluatingLinkLibraries()
+ || dagCheckerParent->EvaluatingSources()))
{
reportError(context, content->GetOriginalExpression(),
"LINKER_LANGUAGE target property can not be used while evaluating "
"link libraries for a static library");
return std::string();
}
- const char *lang = target->GetLinkerLanguage(context->Config);
- return lang ? lang : "";
+ return target->GetLinkerLanguage(context->Config);
}
cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace,
@@ -1004,7 +1025,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
break;
}
- const char *prop = target->GetProperty(propertyName.c_str());
+ const char *prop = target->GetProperty(propertyName);
if (dagCheckerParent)
{
@@ -1065,13 +1086,13 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
cmStrCmp(propertyName)) != transEnd)
{
- std::vector<std::string> libs;
- target->GetTransitivePropertyLinkLibraries(context->Config,
- headTarget, libs);
- if (!libs.empty())
+ std::vector<cmTarget*> tgts;
+ target->GetTransitivePropertyTargets(context->Config,
+ headTarget, tgts);
+ if (!tgts.empty())
{
linkedTargetsContent =
- getLinkedTargetsContent(libs, target,
+ getLinkedTargetsContent(tgts, target,
headTarget,
context, &dagChecker,
interfacePropertyName);
@@ -1080,9 +1101,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
else if (std::find_if(transBegin, transEnd,
cmStrCmp(interfacePropertyName)) != transEnd)
{
- const cmTarget::LinkImplementation *impl = target->GetLinkImplementation(
- context->Config,
- headTarget);
+ const cmTarget::LinkImplementation *impl
+ = target->GetLinkImplementationLibraries(context->Config,
+ headTarget);
if(impl)
{
linkedTargetsContent =
@@ -1222,6 +1243,77 @@ static const struct TargetNameNode : public cmGeneratorExpressionNode
} targetNameNode;
//----------------------------------------------------------------------------
+static const struct TargetObjectsNode : public cmGeneratorExpressionNode
+{
+ TargetObjectsNode() {}
+
+ std::string Evaluate(const std::vector<std::string> &parameters,
+ cmGeneratorExpressionContext *context,
+ const GeneratorExpressionContent *content,
+ cmGeneratorExpressionDAGChecker *) const
+ {
+ if (!context->EvaluateForBuildsystem)
+ {
+ cmOStringStream 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.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+
+ std::string tgtName = parameters.front();
+ cmGeneratorTarget* gt =
+ context->Makefile->FindGeneratorTargetToUse(tgtName.c_str());
+ if (!gt)
+ {
+ cmOStringStream e;
+ e << "Objects of target \"" << tgtName
+ << "\" referenced but no such target exists.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+ if (gt->GetType() != cmTarget::OBJECT_LIBRARY)
+ {
+ cmOStringStream e;
+ e << "Objects of target \"" << tgtName
+ << "\" referenced but is not an OBJECT library.";
+ reportError(context, content->GetOriginalExpression(), e.str());
+ return std::string();
+ }
+
+ std::vector<cmSourceFile const*> objectSources;
+ gt->GetObjectSources(objectSources, context->Config);
+ std::map<cmSourceFile const*, std::string> mapping;
+
+ for(std::vector<cmSourceFile const*>::const_iterator it
+ = objectSources.begin(); it != objectSources.end(); ++it)
+ {
+ mapping[*it];
+ }
+
+ gt->LocalGenerator->ComputeObjectFilenames(mapping, gt);
+
+ std::string obj_dir = gt->ObjectDirectory;
+ std::string result;
+ const char* sep = "";
+ for(std::map<cmSourceFile const*, std::string>::const_iterator it
+ = mapping.begin(); it != mapping.end(); ++it)
+ {
+ assert(!it->second.empty());
+ result += sep;
+ std::string objFile = obj_dir + it->second;
+ cmSourceFile* sf = context->Makefile->GetOrCreateSource(objFile, true);
+ sf->SetObjectLibrary(tgtName);
+ sf->SetProperty("EXTERNAL_OBJECT", "1");
+ result += objFile;
+ sep = ";";
+ }
+ return result;
+ }
+} targetObjectsNode;
+
+//----------------------------------------------------------------------------
static const char* targetPolicyWhitelist[] = {
0
#define TARGET_POLICY_STRING(POLICY) \
@@ -1488,7 +1580,9 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode
"Target \"" + name + "\" is not an executable or library.");
return std::string();
}
- if (dagChecker && dagChecker->EvaluatingLinkLibraries(name.c_str()))
+ if (dagChecker && (dagChecker->EvaluatingLinkLibraries(name.c_str())
+ || (dagChecker->EvaluatingSources()
+ && name == dagChecker->TopTarget())))
{
::reportError(context, content->GetOriginalExpression(),
"Expressions which require the linker language may not "
@@ -1536,89 +1630,59 @@ TargetFilesystemArtifact<false, true, true, false> targetSoNameFileDirNode;
static const
cmGeneratorExpressionNode* GetNode(const std::string &identifier)
{
- if (identifier == "0")
- return &zeroNode;
- else if (identifier == "1")
- return &oneNode;
- else if (identifier == "AND")
- return &andNode;
- else if (identifier == "OR")
- return &orNode;
- else if (identifier == "NOT")
- return &notNode;
- else if (identifier == "C_COMPILER_ID")
- return &cCompilerIdNode;
- else if (identifier == "CXX_COMPILER_ID")
- return &cxxCompilerIdNode;
- else if (identifier == "VERSION_GREATER")
- return &versionGreaterNode;
- else if (identifier == "VERSION_LESS")
- return &versionLessNode;
- else if (identifier == "VERSION_EQUAL")
- return &versionEqualNode;
- else if (identifier == "C_COMPILER_VERSION")
- return &cCompilerVersionNode;
- else if (identifier == "CXX_COMPILER_VERSION")
- return &cxxCompilerVersionNode;
- else if (identifier == "PLATFORM_ID")
- return &platformIdNode;
- else if (identifier == "CONFIGURATION")
- return &configurationNode;
- else if (identifier == "CONFIG")
- return &configurationTestNode;
- else if (identifier == "TARGET_FILE")
- return &targetFileNode;
- else if (identifier == "TARGET_LINKER_FILE")
- return &targetLinkerFileNode;
- else if (identifier == "TARGET_SONAME_FILE")
- return &targetSoNameFileNode;
- else if (identifier == "TARGET_FILE_NAME")
- return &targetFileNameNode;
- else if (identifier == "TARGET_LINKER_FILE_NAME")
- return &targetLinkerFileNameNode;
- else if (identifier == "TARGET_SONAME_FILE_NAME")
- return &targetSoNameFileNameNode;
- else if (identifier == "TARGET_FILE_DIR")
- return &targetFileDirNode;
- else if (identifier == "TARGET_LINKER_FILE_DIR")
- return &targetLinkerFileDirNode;
- else if (identifier == "TARGET_SONAME_FILE_DIR")
- return &targetSoNameFileDirNode;
- else if (identifier == "STREQUAL")
- return &strEqualNode;
- else if (identifier == "EQUAL")
- return &equalNode;
- else if (identifier == "LOWER_CASE")
- return &lowerCaseNode;
- else if (identifier == "UPPER_CASE")
- return &upperCaseNode;
- else if (identifier == "MAKE_C_IDENTIFIER")
- return &makeCIdentifierNode;
- else if (identifier == "BOOL")
- return &boolNode;
- else if (identifier == "ANGLE-R")
- return &angle_rNode;
- else if (identifier == "COMMA")
- return &commaNode;
- else if (identifier == "SEMICOLON")
- return &semicolonNode;
- else if (identifier == "TARGET_PROPERTY")
- return &targetPropertyNode;
- else if (identifier == "TARGET_NAME")
- return &targetNameNode;
- else if (identifier == "TARGET_POLICY")
- return &targetPolicyNode;
- else if (identifier == "BUILD_INTERFACE")
- return &buildInterfaceNode;
- else if (identifier == "INSTALL_INTERFACE")
- return &installInterfaceNode;
- else if (identifier == "INSTALL_PREFIX")
- return &installPrefixNode;
- else if (identifier == "JOIN")
- return &joinNode;
- else if (identifier == "LINK_ONLY")
- return &linkOnlyNode;
- return 0;
+ typedef std::map<std::string, const cmGeneratorExpressionNode*> NodeMap;
+ static NodeMap nodeMap;
+ if (nodeMap.empty())
+ {
+ nodeMap["0"] = &zeroNode;
+ nodeMap["1"] = &oneNode;
+ nodeMap["AND"] = &andNode;
+ nodeMap["OR"] = &orNode;
+ nodeMap["NOT"] = &notNode;
+ nodeMap["C_COMPILER_ID"] = &cCompilerIdNode;
+ nodeMap["CXX_COMPILER_ID"] = &cxxCompilerIdNode;
+ nodeMap["VERSION_GREATER"] = &versionGreaterNode;
+ nodeMap["VERSION_LESS"] = &versionLessNode;
+ nodeMap["VERSION_EQUAL"] = &versionEqualNode;
+ nodeMap["C_COMPILER_VERSION"] = &cCompilerVersionNode;
+ nodeMap["CXX_COMPILER_VERSION"] = &cxxCompilerVersionNode;
+ nodeMap["PLATFORM_ID"] = &platformIdNode;
+ nodeMap["CONFIGURATION"] = &configurationNode;
+ nodeMap["CONFIG"] = &configurationTestNode;
+ nodeMap["TARGET_FILE"] = &targetFileNode;
+ nodeMap["TARGET_LINKER_FILE"] = &targetLinkerFileNode;
+ nodeMap["TARGET_SONAME_FILE"] = &targetSoNameFileNode;
+ nodeMap["TARGET_FILE_NAME"] = &targetFileNameNode;
+ nodeMap["TARGET_LINKER_FILE_NAME"] = &targetLinkerFileNameNode;
+ nodeMap["TARGET_SONAME_FILE_NAME"] = &targetSoNameFileNameNode;
+ nodeMap["TARGET_FILE_DIR"] = &targetFileDirNode;
+ nodeMap["TARGET_LINKER_FILE_DIR"] = &targetLinkerFileDirNode;
+ nodeMap["TARGET_SONAME_FILE_DIR"] = &targetSoNameFileDirNode;
+ nodeMap["STREQUAL"] = &strEqualNode;
+ nodeMap["EQUAL"] = &equalNode;
+ nodeMap["LOWER_CASE"] = &lowerCaseNode;
+ nodeMap["UPPER_CASE"] = &upperCaseNode;
+ nodeMap["MAKE_C_IDENTIFIER"] = &makeCIdentifierNode;
+ nodeMap["BOOL"] = &boolNode;
+ nodeMap["ANGLE-R"] = &angle_rNode;
+ nodeMap["COMMA"] = &commaNode;
+ nodeMap["SEMICOLON"] = &semicolonNode;
+ nodeMap["TARGET_PROPERTY"] = &targetPropertyNode;
+ nodeMap["TARGET_NAME"] = &targetNameNode;
+ nodeMap["TARGET_OBJECTS"] = &targetObjectsNode;
+ nodeMap["TARGET_POLICY"] = &targetPolicyNode;
+ nodeMap["BUILD_INTERFACE"] = &buildInterfaceNode;
+ nodeMap["INSTALL_INTERFACE"] = &installInterfaceNode;
+ nodeMap["INSTALL_PREFIX"] = &installPrefixNode;
+ nodeMap["JOIN"] = &joinNode;
+ nodeMap["LINK_ONLY"] = &linkOnlyNode;
+ }
+ NodeMap::const_iterator i = nodeMap.find(identifier);
+ if (i == nodeMap.end())
+ {
+ return 0;
+ }
+ return i->second;
}
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 49e52df..54a2548 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -25,15 +25,16 @@ struct cmGeneratorExpressionContext
cmListFileBacktrace Backtrace;
std::set<cmTarget*> DependTargets;
std::set<cmTarget const*> AllTargets;
- std::set<cmStdString> SeenTargetProperties;
+ std::set<std::string> SeenTargetProperties;
cmMakefile *Makefile;
- const char *Config;
+ std::string Config;
cmTarget const* HeadTarget; // The target whose property is being evaluated.
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
// directly or indirectly in the property.
bool Quiet;
bool HadError;
bool HadContextSensitiveCondition;
+ bool EvaluateForBuildsystem;
};
struct cmGeneratorExpressionDAGChecker;
diff --git a/Source/cmGeneratorExpressionLexer.cxx b/Source/cmGeneratorExpressionLexer.cxx
index cd71ec0..1c83466 100644
--- a/Source/cmGeneratorExpressionLexer.cxx
+++ b/Source/cmGeneratorExpressionLexer.cxx
@@ -32,52 +32,50 @@ static void InsertText(const char *upto, const char *c,
//----------------------------------------------------------------------------
std::vector<cmGeneratorExpressionToken>
-cmGeneratorExpressionLexer::Tokenize(const char *input)
+cmGeneratorExpressionLexer::Tokenize(const std::string& input)
{
std::vector<cmGeneratorExpressionToken> result;
- if (!input)
- return result;
- const char *c = input;
+ const char *c = input.c_str();
const char *upto = c;
for ( ; *c; ++c)
- {
- if(c[0] == '$' && c[1] == '<')
{
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::BeginExpression, upto, 2));
- upto = c + 2;
- ++c;
- SawBeginExpression = true;
- }
- else if(c[0] == '>')
- {
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::EndExpression, upto, 1));
- upto = c + 1;
- SawGeneratorExpression = SawBeginExpression;
- }
- else if(c[0] == ':')
- {
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::ColonSeparator, upto, 1));
- upto = c + 1;
- }
- else if(c[0] == ',')
- {
- InsertText(upto, c, result);
- upto = c;
- result.push_back(cmGeneratorExpressionToken(
- cmGeneratorExpressionToken::CommaSeparator, upto, 1));
- upto = c + 1;
- }
+ switch(*c)
+ {
+ case '$':
+ if(c[1] == '<')
+ {
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::BeginExpression, c, 2));
+ upto = c + 2;
+ ++c;
+ SawBeginExpression = true;
+ }
+ break;
+ case '>':
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::EndExpression, c, 1));
+ upto = c + 1;
+ SawGeneratorExpression = SawBeginExpression;
+ break;
+ case ':':
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::ColonSeparator, c, 1));
+ upto = c + 1;
+ break;
+ case ',':
+ InsertText(upto, c, result);
+ result.push_back(cmGeneratorExpressionToken(
+ cmGeneratorExpressionToken::CommaSeparator, c, 1));
+ upto = c + 1;
+ break;
+ default:
+ break;
+ }
}
InsertText(upto, c, result);
diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h
index 83d661d..1e2e8c2 100644
--- a/Source/cmGeneratorExpressionLexer.h
+++ b/Source/cmGeneratorExpressionLexer.h
@@ -43,7 +43,7 @@ class cmGeneratorExpressionLexer
public:
cmGeneratorExpressionLexer();
- std::vector<cmGeneratorExpressionToken> Tokenize(const char *input);
+ std::vector<cmGeneratorExpressionToken> Tokenize(const std::string& input);
bool GetSawGeneratorExpression() const
{
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 175bb0e..ec5ce9e 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -19,13 +19,203 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionDAGChecker.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
#include <queue>
#include "assert.h"
//----------------------------------------------------------------------------
-cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t)
+void reportBadObjLib(std::vector<cmSourceFile*> const& badObjLib,
+ cmTarget *target, cmake *cm)
+{
+ if(!badObjLib.empty())
+ {
+ cmOStringStream e;
+ e << "OBJECT library \"" << target->GetName() << "\" contains:\n";
+ for(std::vector<cmSourceFile*>::const_iterator i = badObjLib.begin();
+ i != badObjLib.end(); ++i)
+ {
+ e << " " << (*i)->GetLocation().GetName() << "\n";
+ }
+ e << "but may contain only headers and sources that compile.";
+ cm->IssueMessage(cmake::FATAL_ERROR, e.str(),
+ target->GetBacktrace());
+ }
+}
+
+struct ObjectSourcesTag {};
+struct CustomCommandsTag {};
+struct ExtraSourcesTag {};
+struct HeaderSourcesTag {};
+struct ExternalObjectsTag {};
+struct IDLSourcesTag {};
+struct ResxTag {};
+struct ModuleDefinitionFileTag {};
+
+#if !defined(_MSC_VER) || _MSC_VER >= 1310
+template<typename Tag, typename OtherTag>
+struct IsSameTag
+{
+ enum {
+ Result = false
+ };
+};
+
+template<typename Tag>
+struct IsSameTag<Tag, Tag>
+{
+ enum {
+ 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
+{
+ template <typename T> static void Do(T&, cmSourceFile*) {}
+};
+
+template<>
+struct DoAccept<true>
+{
+ static void Do(std::vector<cmSourceFile const*>& files, cmSourceFile* f)
+ {
+ files.push_back(f);
+ }
+ static void Do(cmGeneratorTarget::ResxData& data, cmSourceFile* f)
+ {
+ // Build and save the name of the corresponding .h file
+ // This relationship will be used later when building the project files.
+ // Both names would have been auto generated from Visual Studio
+ // where the user supplied the file name and Visual Studio
+ // appended the suffix.
+ std::string resx = f->GetFullPath();
+ std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
+ data.ExpectedResxHeaders.insert(hFileName);
+ data.ResxSources.push_back(f);
+ }
+ static void Do(std::string& data, cmSourceFile* f)
+ {
+ data = f->GetFullPath();
+ }
+};
+
+//----------------------------------------------------------------------------
+template<typename Tag, typename DataType = std::vector<cmSourceFile const*> >
+struct TagVisitor
+{
+ DataType& Data;
+ std::vector<cmSourceFile*> BadObjLibFiles;
+ cmTarget *Target;
+ cmGlobalGenerator *GlobalGenerator;
+ cmsys::RegularExpression Header;
+ bool IsObjLib;
+
+ TagVisitor(cmTarget *target, DataType& data)
+ : Data(data), Target(target),
+ GlobalGenerator(target->GetMakefile()
+ ->GetLocalGenerator()->GetGlobalGenerator()),
+ Header(CM_HEADER_REGEX),
+ IsObjLib(target->GetType() == cmTarget::OBJECT_LIBRARY)
+ {
+ }
+
+ ~TagVisitor()
+ {
+ reportBadObjLib(this->BadObjLibFiles, this->Target,
+ this->GlobalGenerator->GetCMakeInstance());
+ }
+
+ void Accept(cmSourceFile *sf)
+ {
+ std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
+ if(sf->GetCustomCommand())
+ {
+ DoAccept<IsSameTag<Tag, CustomCommandsTag>::Result>::Do(this->Data, sf);
+ }
+ else if(this->Target->GetType() == cmTarget::UTILITY)
+ {
+ DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
+ {
+ DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
+ {
+ DoAccept<IsSameTag<Tag, ExternalObjectsTag>::Result>::Do(this->Data, sf);
+ if(this->IsObjLib)
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ else if(!sf->GetLanguage().empty())
+ {
+ DoAccept<IsSameTag<Tag, ObjectSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(ext == "def")
+ {
+ DoAccept<IsSameTag<Tag, ModuleDefinitionFileTag>::Result>::Do(this->Data,
+ sf);
+ if(this->IsObjLib)
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ else if(ext == "idl")
+ {
+ DoAccept<IsSameTag<Tag, IDLSourcesTag>::Result>::Do(this->Data, sf);
+ if(this->IsObjLib)
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ else if(ext == "resx")
+ {
+ DoAccept<IsSameTag<Tag, ResxTag>::Result>::Do(this->Data, sf);
+ }
+ else if(this->Header.find(sf->GetFullPath().c_str()))
+ {
+ DoAccept<IsSameTag<Tag, HeaderSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str()))
+ {
+ DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+ }
+ else
+ {
+ DoAccept<IsSameTag<Tag, ExtraSourcesTag>::Result>::Do(this->Data, sf);
+ if(this->IsObjLib && ext != "txt")
+ {
+ this->BadObjLibFiles.push_back(sf);
+ }
+ }
+ }
+};
+
+//----------------------------------------------------------------------------
+cmGeneratorTarget::cmGeneratorTarget(cmTarget* t): Target(t),
+ SourceFileFlagsConstructed(false)
{
this->Makefile = this->Target->GetMakefile();
this->LocalGenerator = this->Makefile->GetLocalGenerator();
@@ -39,20 +229,20 @@ int cmGeneratorTarget::GetType() const
}
//----------------------------------------------------------------------------
-const char *cmGeneratorTarget::GetName() const
+std::string cmGeneratorTarget::GetName() const
{
return this->Target->GetName();
}
//----------------------------------------------------------------------------
-const char *cmGeneratorTarget::GetProperty(const char *prop) const
+const char *cmGeneratorTarget::GetProperty(const std::string& prop) const
{
return this->Target->GetProperty(prop);
}
//----------------------------------------------------------------------------
std::vector<cmSourceFile*> const*
-cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const
+cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const
{
SourceEntriesType::const_iterator i = this->SourceEntries.find(sf);
if(i != this->SourceEntries.end())
@@ -62,19 +252,13 @@ cmGeneratorTarget::GetSourceDepends(cmSourceFile* sf) const
return 0;
}
-static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name,
- const char *config, cmTarget *headTarget,
+static void handleSystemIncludesDep(cmMakefile *mf, cmTarget* depTgt,
+ const std::string& config,
+ cmTarget *headTarget,
cmGeneratorExpressionDAGChecker *dagChecker,
std::vector<std::string>& result,
bool excludeImported)
{
- cmTarget* depTgt = mf->FindTargetToUse(name);
-
- if (!depTgt)
- {
- return;
- }
-
cmListFileBacktrace lfbt;
if (const char* dirs =
@@ -102,26 +286,77 @@ static void handleSystemIncludesDep(cmMakefile *mf, const std::string &name,
}
}
+#define IMPLEMENT_VISIT_IMPL(DATA, DATATYPE) \
+ { \
+ std::vector<cmSourceFile*> sourceFiles; \
+ this->Target->GetSourceFiles(sourceFiles, config); \
+ TagVisitor<DATA ## Tag DATATYPE> visitor(this->Target, data); \
+ for(std::vector<cmSourceFile*>::const_iterator si = sourceFiles.begin(); \
+ si != sourceFiles.end(); ++si) \
+ { \
+ visitor.Accept(*si); \
+ } \
+ } \
+
+
+#define IMPLEMENT_VISIT(DATA) \
+ IMPLEMENT_VISIT_IMPL(DATA, EMPTY) \
+
+#define EMPTY
+#define COMMA ,
+
//----------------------------------------------------------------------------
void
-cmGeneratorTarget::GetObjectSources(std::vector<cmSourceFile*> &objs) const
+cmGeneratorTarget
+::GetObjectSources(std::vector<cmSourceFile const*> &data,
+ const std::string& config) const
+{
+ IMPLEMENT_VISIT(ObjectSources);
+
+ if (!this->Objects.empty())
+ {
+ return;
+ }
+
+ for(std::vector<cmSourceFile const*>::const_iterator it = data.begin();
+ it != data.end(); ++it)
+ {
+ this->Objects[*it];
+ }
+
+ this->LocalGenerator->ComputeObjectFilenames(this->Objects, this);
+}
+
+void cmGeneratorTarget::ComputeObjectMapping()
{
- objs = this->ObjectSources;
+ if(!this->Objects.empty())
+ {
+ return;
+ }
+
+ 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)
+ {
+ std::vector<cmSourceFile const*> sourceFiles;
+ this->GetObjectSources(sourceFiles, *ci);
+ }
}
//----------------------------------------------------------------------------
const std::string& cmGeneratorTarget::GetObjectName(cmSourceFile const* file)
{
+ this->ComputeObjectMapping();
return this->Objects[file];
}
-void cmGeneratorTarget::AddObject(cmSourceFile *sf, std::string const&name)
-{
- this->Objects[sf] = name;
-}
-
//----------------------------------------------------------------------------
-void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf)
+void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile const* sf)
{
this->ExplicitObjectName.insert(sf);
}
@@ -129,64 +364,82 @@ void cmGeneratorTarget::AddExplicitObjectName(cmSourceFile* sf)
//----------------------------------------------------------------------------
bool cmGeneratorTarget::HasExplicitObjectName(cmSourceFile const* file) const
{
+ const_cast<cmGeneratorTarget*>(this)->ComputeObjectMapping();
std::set<cmSourceFile const*>::const_iterator it
= this->ExplicitObjectName.find(file);
return it != this->ExplicitObjectName.end();
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetResxSources(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget
+::GetIDLSources(std::vector<cmSourceFile const*>& data,
+ const std::string& config) const
{
- srcs = this->ResxSources;
+ IMPLEMENT_VISIT(IDLSources);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetIDLSources(std::vector<cmSourceFile*>& srcs) const
+void
+cmGeneratorTarget
+::GetHeaderSources(std::vector<cmSourceFile const*>& data,
+ const std::string& config) const
{
- srcs = this->IDLSources;
+ IMPLEMENT_VISIT(HeaderSources);
}
//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetHeaderSources(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget
+::GetExtraSources(std::vector<cmSourceFile const*>& data,
+ const std::string& config) const
{
- srcs = this->HeaderSources;
+ IMPLEMENT_VISIT(ExtraSources);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetExtraSources(std::vector<cmSourceFile*>& srcs) const
+void
+cmGeneratorTarget
+::GetCustomCommands(std::vector<cmSourceFile const*>& data,
+ const std::string& config) const
{
- srcs = this->ExtraSources;
+ IMPLEMENT_VISIT(CustomCommands);
}
//----------------------------------------------------------------------------
void
-cmGeneratorTarget::GetCustomCommands(std::vector<cmSourceFile*>& srcs) const
+cmGeneratorTarget
+::GetExternalObjects(std::vector<cmSourceFile const*>& data,
+ const std::string& config) const
{
- srcs = this->CustomCommands;
+ IMPLEMENT_VISIT(ExternalObjects);
}
//----------------------------------------------------------------------------
void
-cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs) const
+cmGeneratorTarget::GetExpectedResxHeaders(std::set<std::string>& srcs,
+ const std::string& config) const
{
- srcs = this->ExpectedResxHeaders;
+ ResxData data;
+ IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+ srcs = data.ExpectedResxHeaders;
}
//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::GetExternalObjects(std::vector<cmSourceFile*>& srcs) const
+void cmGeneratorTarget
+::GetResxSources(std::vector<cmSourceFile const*>& srcs,
+ const std::string& config) const
{
- srcs = this->ExternalObjects;
+ ResxData data;
+ IMPLEMENT_VISIT_IMPL(Resx, COMMA cmGeneratorTarget::ResxData)
+ srcs = data.ResxSources;
}
//----------------------------------------------------------------------------
-bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
- const char *config) const
+bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir,
+ const std::string& config) const
{
assert(this->GetType() != cmTarget::INTERFACE_LIBRARY);
std::string config_upper;
- if(config && *config)
+ if(!config.empty())
{
config_upper = cmSystemTools::UpperCase(config);
}
@@ -213,7 +466,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
= this->Target->GetPropertyAsBool("NO_SYSTEM_FROM_IMPORTED");
std::vector<std::string> result;
- for (std::set<cmStdString>::const_iterator
+ for (std::set<std::string>::const_iterator
it = this->Target->GetSystemIncludeDirectories().begin();
it != this->Target->GetSystemIncludeDirectories().end(); ++it)
{
@@ -224,26 +477,25 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
&dagChecker), result);
}
- std::set<cmStdString> uniqueDeps;
+ std::set<cmTarget*> uniqueDeps;
for(std::vector<std::string>::const_iterator li = impl->Libraries.begin();
li != impl->Libraries.end(); ++li)
{
- if (uniqueDeps.insert(*li).second)
+ cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
+ if (!tgt)
{
- cmTarget* tgt = this->Makefile->FindTargetToUse(*li);
-
- if (!tgt)
- {
- continue;
- }
+ continue;
+ }
- handleSystemIncludesDep(this->Makefile, *li, config, this->Target,
+ if (uniqueDeps.insert(tgt).second)
+ {
+ handleSystemIncludesDep(this->Makefile, tgt, config, this->Target,
&dagChecker, result, excludeImported);
- std::vector<std::string> deps;
- tgt->GetTransitivePropertyLinkLibraries(config, this->Target, deps);
+ std::vector<cmTarget*> deps;
+ tgt->GetTransitivePropertyTargets(config, this->Target, deps);
- for(std::vector<std::string>::const_iterator di = deps.begin();
+ for(std::vector<cmTarget*>::const_iterator di = deps.begin();
di != deps.end(); ++di)
{
if (uniqueDeps.insert(*di).second)
@@ -254,7 +506,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
}
}
}
- std::set<cmStdString> unique;
+ std::set<std::string> unique;
for(std::vector<std::string>::iterator li = result.begin();
li != result.end(); ++li)
{
@@ -262,7 +514,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
unique.insert(*li);
}
result.clear();
- for(std::set<cmStdString>::iterator li = unique.begin();
+ for(std::set<std::string>::iterator li = unique.begin();
li != unique.end(); ++li)
{
result.push_back(*li);
@@ -278,179 +530,61 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const char *dir,
}
//----------------------------------------------------------------------------
-bool cmGeneratorTarget::GetPropertyAsBool(const char *prop) const
+bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
{
return this->Target->GetPropertyAsBool(prop);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
+void cmGeneratorTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
+ const std::string& config) const
{
- this->Target->GetSourceFiles(files);
+ this->Target->GetSourceFiles(files, config);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::ClassifySources()
+std::string
+cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const
{
- cmsys::RegularExpression header(CM_HEADER_REGEX);
-
- cmTarget::TargetType targetType = this->Target->GetType();
- bool isObjLib = targetType == cmTarget::OBJECT_LIBRARY;
-
- std::vector<cmSourceFile*> badObjLib;
- std::vector<cmSourceFile*> sources;
- this->Target->GetSourceFiles(sources);
- for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
- if(sf->GetCustomCommand())
- {
- this->CustomCommands.push_back(sf);
- }
- else if(targetType == cmTarget::UTILITY)
- {
- this->ExtraSources.push_back(sf);
- }
- else if(sf->GetPropertyAsBool("HEADER_FILE_ONLY"))
- {
- this->HeaderSources.push_back(sf);
- }
- else if(sf->GetPropertyAsBool("EXTERNAL_OBJECT"))
- {
- this->ExternalObjects.push_back(sf);
- if(isObjLib) { badObjLib.push_back(sf); }
- }
- else if(sf->GetLanguage())
- {
- this->ObjectSources.push_back(sf);
- }
- else if(ext == "def")
- {
- this->ModuleDefinitionFile = sf->GetFullPath();
- if(isObjLib) { badObjLib.push_back(sf); }
- }
- else if(ext == "idl")
- {
- this->IDLSources.push_back(sf);
- if(isObjLib) { badObjLib.push_back(sf); }
- }
- else if(ext == "resx")
- {
- // Build and save the name of the corresponding .h file
- // This relationship will be used later when building the project files.
- // Both names would have been auto generated from Visual Studio
- // where the user supplied the file name and Visual Studio
- // appended the suffix.
- std::string resx = sf->GetFullPath();
- std::string hFileName = resx.substr(0, resx.find_last_of(".")) + ".h";
- this->ExpectedResxHeaders.insert(hFileName);
- this->ResxSources.push_back(sf);
- }
- else if(header.find(sf->GetFullPath().c_str()))
- {
- this->HeaderSources.push_back(sf);
- }
- else if(this->GlobalGenerator->IgnoreFile(sf->GetExtension().c_str()))
- {
- // We only get here if a source file is not an external object
- // and has an extension that is listed as an ignored file type.
- // No message or diagnosis should be given.
- this->ExtraSources.push_back(sf);
- }
- else
- {
- this->ExtraSources.push_back(sf);
- if(isObjLib && ext != "txt")
- {
- badObjLib.push_back(sf);
- }
- }
- }
-
- if(!badObjLib.empty())
- {
- cmOStringStream e;
- e << "OBJECT library \"" << this->Target->GetName() << "\" contains:\n";
- for(std::vector<cmSourceFile*>::iterator i = badObjLib.begin();
- i != badObjLib.end(); ++i)
- {
- e << " " << (*i)->GetLocation().GetName() << "\n";
- }
- e << "but may contain only headers and sources that compile.";
- this->GlobalGenerator->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->Target->GetBacktrace());
- }
+ std::string data;
+ IMPLEMENT_VISIT_IMPL(ModuleDefinitionFile, COMMA std::string)
+ return data;
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::LookupObjectLibraries()
+void
+cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs,
+ const std::string &config) const
{
- std::vector<std::string> const& objLibs =
- this->Target->GetObjectLibraries();
- for(std::vector<std::string>::const_iterator oli = objLibs.begin();
- oli != objLibs.end(); ++oli)
+ std::vector<cmSourceFile const*> objectFiles;
+ this->GetExternalObjects(objectFiles, config);
+ std::vector<cmTarget*> objectLibraries;
+ std::set<cmTarget*> emitted;
+ for(std::vector<cmSourceFile const*>::const_iterator
+ it = objectFiles.begin(); it != objectFiles.end(); ++it)
{
- std::string const& objLibName = *oli;
- if(cmTarget* objLib = this->Makefile->FindTargetToUse(objLibName))
+ std::string objLib = (*it)->GetObjectLibrary();
+ if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
{
- if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
- {
- if(this->Target->GetType() != cmTarget::EXECUTABLE &&
- this->Target->GetType() != cmTarget::STATIC_LIBRARY &&
- this->Target->GetType() != cmTarget::SHARED_LIBRARY &&
- this->Target->GetType() != cmTarget::MODULE_LIBRARY)
- {
- this->GlobalGenerator->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR,
- "Only executables and non-OBJECT libraries may "
- "reference target objects.",
- this->Target->GetBacktrace());
- return;
- }
- this->Target->AddUtility(objLib->GetName());
- this->ObjectLibraries.push_back(objLib);
- }
- else
+ if (emitted.insert(tgt).second)
{
- cmOStringStream e;
- e << "Objects of target \"" << objLibName
- << "\" referenced but is not an OBJECT library.";
- this->GlobalGenerator->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->Target->GetBacktrace());
- return;
+ objectLibraries.push_back(tgt);
}
}
- else
- {
- cmOStringStream e;
- e << "Objects of target \"" << objLibName
- << "\" referenced but no such target exists.";
- this->GlobalGenerator->GetCMakeInstance()
- ->IssueMessage(cmake::FATAL_ERROR, e.str(),
- this->Target->GetBacktrace());
- return;
- }
}
-}
-//----------------------------------------------------------------------------
-void
-cmGeneratorTarget::UseObjectLibraries(std::vector<std::string>& objs) const
-{
for(std::vector<cmTarget*>::const_iterator
- ti = this->ObjectLibraries.begin();
- ti != this->ObjectLibraries.end(); ++ti)
+ ti = objectLibraries.begin();
+ ti != objectLibraries.end(); ++ti)
{
cmTarget* objLib = *ti;
cmGeneratorTarget* ogt =
this->GlobalGenerator->GetGeneratorTarget(objLib);
- for(std::vector<cmSourceFile*>::const_iterator
- si = ogt->ObjectSources.begin();
- si != ogt->ObjectSources.end(); ++si)
+ std::vector<cmSourceFile const*> objectSources;
+ ogt->GetObjectSources(objectSources, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ si = objectSources.begin();
+ si != objectSources.end(); ++si)
{
std::string obj = ogt->ObjectDirectory;
obj += ogt->Objects[*si];
@@ -474,8 +608,9 @@ private:
SourceEntry* CurrentEntry;
std::queue<cmSourceFile*> SourceQueue;
std::set<cmSourceFile*> SourcesQueued;
- typedef std::map<cmStdString, cmSourceFile*> NameMapType;
+ typedef std::map<std::string, cmSourceFile*> NameMapType;
NameMapType NameMap;
+ std::vector<std::string> NewSources;
void QueueSource(cmSourceFile* sf);
void FollowName(std::string const& name);
@@ -483,6 +618,9 @@ private:
bool IsUtility(std::string const& dep);
void CheckCustomCommand(cmCustomCommand const& cc);
void CheckCustomCommands(const std::vector<cmCustomCommand>& commands);
+ void FollowCommandDepends(cmCustomCommand const& cc,
+ const std::string& config,
+ std::set<std::string>& emitted);
};
//----------------------------------------------------------------------------
@@ -497,14 +635,29 @@ cmTargetTraceDependencies
this->CurrentEntry = 0;
// Queue all the source files already specified for the target.
- std::vector<cmSourceFile*> sources;
if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY)
{
- this->Target->GetSourceFiles(sources);
- for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si)
+ std::vector<std::string> configs;
+ this->Makefile->GetConfigurations(configs);
+ if (configs.empty())
{
- this->QueueSource(*si);
+ configs.push_back("");
+ }
+ std::set<cmSourceFile*> emitted;
+ for(std::vector<std::string>::const_iterator ci = configs.begin();
+ ci != configs.end(); ++ci)
+ {
+ std::vector<cmSourceFile*> sources;
+ this->Target->GetSourceFiles(sources, *ci);
+ for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
+ si != sources.end(); ++si)
+ {
+ cmSourceFile* sf = *si;
+ if(emitted.insert(sf).second && this->SourcesQueued.insert(sf).second)
+ {
+ this->SourceQueue.push(sf);
+ }
+ }
}
}
@@ -546,6 +699,8 @@ void cmTargetTraceDependencies::Trace()
}
}
this->CurrentEntry = 0;
+
+ this->Target->AddTracedSources(this->NewSources);
}
//----------------------------------------------------------------------------
@@ -555,8 +710,8 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
{
this->SourceQueue.push(sf);
- // Make sure this file is in the target.
- this->Target->AddSourceFile(sf);
+ // Make sure this file is in the target at the end.
+ this->NewSources.push_back(sf->GetFullPath());
}
}
@@ -567,7 +722,7 @@ void cmTargetTraceDependencies::FollowName(std::string const& name)
if(i == this->NameMap.end())
{
// Check if we know how to generate this file.
- cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name.c_str());
+ cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name);
NameMapType::value_type entry(name, sf);
i = this->NameMap.insert(entry).first;
}
@@ -578,7 +733,6 @@ void cmTargetTraceDependencies::FollowName(std::string const& name)
{
this->CurrentEntry->Depends.push_back(sf);
}
-
this->QueueSource(sf);
}
}
@@ -622,14 +776,14 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
{
// This is really only for compatibility so we do not need to
// worry about configuration names and output names.
- std::string tLocation = t->GetLocation(0);
+ 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());
if(depLocation == tLocation)
{
- this->Target->AddUtility(util.c_str());
+ this->Target->AddUtility(util);
return true;
}
}
@@ -638,7 +792,7 @@ bool cmTargetTraceDependencies::IsUtility(std::string const& dep)
{
// The original name of the dependency was not a full path. It
// must name a target, so add the target-level dependency.
- this->Target->AddUtility(util.c_str());
+ this->Target->AddUtility(util);
return true;
}
}
@@ -672,7 +826,7 @@ cmTargetTraceDependencies
// this project. Add the target-level dependency to make
// sure the executable is up to date before this custom
// command possibly runs.
- this->Target->AddUtility(command.c_str());
+ this->Target->AddUtility(command);
}
}
@@ -682,7 +836,7 @@ cmTargetTraceDependencies
{
const cmsys::auto_ptr<cmCompiledGeneratorExpression> cge
= ge.Parse(*cli);
- cge->Evaluate(this->Makefile, 0, true);
+ cge->Evaluate(this->Makefile, "", true);
std::set<cmTarget*> geTargets = cge->GetTargets();
for(std::set<cmTarget*>::const_iterator it = geTargets.begin();
it != geTargets.end(); ++it)
@@ -699,16 +853,41 @@ cmTargetTraceDependencies
}
// Queue the custom command dependencies.
- std::vector<std::string> const& depends = cc.GetDepends();
+ std::vector<std::string> configs;
+ std::set<std::string> emitted;
+ 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->FollowCommandDepends(cc, *ci, emitted);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTargetTraceDependencies::FollowCommandDepends(cmCustomCommand const& cc,
+ const std::string& config,
+ std::set<std::string>& emitted)
+{
+ cmCustomCommandGenerator ccg(cc, config, this->Makefile);
+
+ const std::vector<std::string>& depends = ccg.GetDepends();
+
for(std::vector<std::string>::const_iterator di = depends.begin();
di != depends.end(); ++di)
{
std::string const& dep = *di;
- if(!this->IsUtility(dep))
+ if(emitted.insert(dep).second)
{
- // The dependency does not name a target and may be a file we
- // know how to generate. Queue it.
- this->FollowName(dep);
+ if(!this->IsUtility(dep))
+ {
+ // The dependency does not name a target and may be a file we
+ // know how to generate. Queue it.
+ this->FollowName(dep);
+ }
}
}
}
@@ -743,15 +922,15 @@ void cmGeneratorTarget::TraceDependencies()
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GetAppleArchs(const char* config,
+void cmGeneratorTarget::GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const
{
const char* archs = 0;
- if(config && *config)
+ if(!config.empty())
{
std::string defVarName = "OSX_ARCHITECTURES_";
defVarName += cmSystemTools::UpperCase(config);
- archs = this->Target->GetProperty(defVarName.c_str());
+ archs = this->Target->GetProperty(defVarName);
}
if(!archs)
{
@@ -784,13 +963,14 @@ const char* cmGeneratorTarget::GetCreateRuleVariable() const
//----------------------------------------------------------------------------
std::vector<std::string>
-cmGeneratorTarget::GetIncludeDirectories(const char *config) const
+cmGeneratorTarget::GetIncludeDirectories(const std::string& config) const
{
return this->Target->GetIncludeDirectories(config);
}
//----------------------------------------------------------------------------
-void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
+void cmGeneratorTarget::GenerateTargetManifest(
+ const std::string& config) const
{
if (this->Target->IsImported())
{
@@ -833,42 +1013,42 @@ void cmGeneratorTarget::GenerateTargetManifest(const char* config) const
f = dir;
f += "/";
f += name;
- gg->AddToManifest(config? config:"", f);
+ gg->AddToManifest(config, f);
}
if(!soName.empty())
{
f = dir;
f += "/";
f += soName;
- gg->AddToManifest(config? config:"", f);
+ gg->AddToManifest(config, f);
}
if(!realName.empty())
{
f = dir;
f += "/";
f += realName;
- gg->AddToManifest(config? config:"", f);
+ gg->AddToManifest(config, f);
}
if(!pdbName.empty())
{
f = dir;
f += "/";
f += pdbName;
- gg->AddToManifest(config? config:"", f);
+ gg->AddToManifest(config, f);
}
if(!impName.empty())
{
f = this->Target->GetDirectory(config, true);
f += "/";
f += impName;
- gg->AddToManifest(config? config:"", f);
+ gg->AddToManifest(config, f);
}
}
bool cmStrictTargetComparison::operator()(cmTarget const* t1,
cmTarget const* t2) const
{
- int nameResult = strcmp(t1->GetName(), t2->GetName());
+ int nameResult = strcmp(t1->GetName().c_str(), t2->GetName().c_str());
if (nameResult == 0)
{
return strcmp(t1->GetMakefile()->GetStartOutputDirectory(),
@@ -876,3 +1056,97 @@ bool cmStrictTargetComparison::operator()(cmTarget const* t1,
}
return nameResult < 0;
}
+
+//----------------------------------------------------------------------------
+struct cmGeneratorTarget::SourceFileFlags
+cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
+{
+ struct SourceFileFlags flags;
+ this->ConstructSourceFileFlags();
+ std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
+ this->SourceFlagsMap.find(sf);
+ if(si != this->SourceFlagsMap.end())
+ {
+ flags = si->second;
+ }
+ else
+ {
+ // Handle the MACOSX_PACKAGE_LOCATION property on source files that
+ // were not listed in one of the other lists.
+ if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
+ {
+ flags.MacFolder = location;
+ if(strcmp(location, "Resources") == 0)
+ {
+ flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+ }
+ else
+ {
+ flags.Type = cmGeneratorTarget::SourceFileTypeMacContent;
+ }
+ }
+ }
+ return flags;
+}
+
+//----------------------------------------------------------------------------
+void cmGeneratorTarget::ConstructSourceFileFlags() const
+{
+ if(this->SourceFileFlagsConstructed)
+ {
+ return;
+ }
+ this->SourceFileFlagsConstructed = true;
+
+ // Process public headers to mark the source files.
+ if(const char* files = this->Target->GetProperty("PUBLIC_HEADER"))
+ {
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(files, relFiles);
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(*it))
+ {
+ SourceFileFlags& flags = this->SourceFlagsMap[sf];
+ flags.MacFolder = "Headers";
+ flags.Type = cmGeneratorTarget::SourceFileTypePublicHeader;
+ }
+ }
+ }
+
+ // Process private headers after public headers so that they take
+ // precedence if a file is listed in both.
+ if(const char* files = this->Target->GetProperty("PRIVATE_HEADER"))
+ {
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(files, relFiles);
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(*it))
+ {
+ SourceFileFlags& flags = this->SourceFlagsMap[sf];
+ flags.MacFolder = "PrivateHeaders";
+ flags.Type = cmGeneratorTarget::SourceFileTypePrivateHeader;
+ }
+ }
+ }
+
+ // Mark sources listed as resources.
+ if(const char* files = this->Target->GetProperty("RESOURCE"))
+ {
+ std::vector<std::string> relFiles;
+ cmSystemTools::ExpandListArgument(files, relFiles);
+ for(std::vector<std::string>::iterator it = relFiles.begin();
+ it != relFiles.end(); ++it)
+ {
+ if(cmSourceFile* sf = this->Makefile->GetSource(*it))
+ {
+ SourceFileFlags& flags = this->SourceFlagsMap[sf];
+ flags.MacFolder = "Resources";
+ flags.Type = cmGeneratorTarget::SourceFileTypeResource;
+ }
+ }
+ }
+}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index a4caba1..9d13e6c 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -27,41 +27,52 @@ public:
cmGeneratorTarget(cmTarget*);
int GetType() const;
- const char *GetName() const;
- const char *GetProperty(const char *prop) const;
- bool GetPropertyAsBool(const char *prop) const;
- void GetSourceFiles(std::vector<cmSourceFile*>& files) const;
-
- void GetObjectSources(std::vector<cmSourceFile*> &) const;
+ std::string GetName() const;
+ const char *GetProperty(const std::string& prop) const;
+ bool GetPropertyAsBool(const std::string& prop) const;
+ void GetSourceFiles(std::vector<cmSourceFile*>& files,
+ const std::string& config) const;
+
+ void GetObjectSources(std::vector<cmSourceFile const*> &,
+ const std::string& config) const;
const std::string& GetObjectName(cmSourceFile const* file);
- void AddObject(cmSourceFile *sf, std::string const&name);
bool HasExplicitObjectName(cmSourceFile const* file) const;
- void AddExplicitObjectName(cmSourceFile* sf);
-
- void GetResxSources(std::vector<cmSourceFile*>&) const;
- void GetIDLSources(std::vector<cmSourceFile*>&) const;
- void GetExternalObjects(std::vector<cmSourceFile*>&) const;
- void GetHeaderSources(std::vector<cmSourceFile*>&) const;
- void GetExtraSources(std::vector<cmSourceFile*>&) const;
- void GetCustomCommands(std::vector<cmSourceFile*>&) const;
- void GetExpectedResxHeaders(std::set<std::string>&) const;
+ void AddExplicitObjectName(cmSourceFile const* sf);
+
+ void GetResxSources(std::vector<cmSourceFile const*>&,
+ const std::string& config) const;
+ void GetIDLSources(std::vector<cmSourceFile const*>&,
+ const std::string& config) const;
+ void GetExternalObjects(std::vector<cmSourceFile const*>&,
+ const std::string& config) const;
+ void GetHeaderSources(std::vector<cmSourceFile const*>&,
+ const std::string& config) const;
+ void GetExtraSources(std::vector<cmSourceFile const*>&,
+ const std::string& config) const;
+ void GetCustomCommands(std::vector<cmSourceFile const*>&,
+ const std::string& config) const;
+ void GetExpectedResxHeaders(std::set<std::string>&,
+ const std::string& config) const;
+
+ void ComputeObjectMapping();
cmTarget* Target;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
cmGlobalGenerator const* GlobalGenerator;
- std::string ModuleDefinitionFile;
+ std::string GetModuleDefinitionFile(const std::string& config) const;
/** Full path with trailing slash to the top-level directory
holding object files for this target. Includes the build
time config name placeholder if needed for the generator. */
std::string ObjectDirectory;
- void UseObjectLibraries(std::vector<std::string>& objs) const;
+ void UseObjectLibraries(std::vector<std::string>& objs,
+ const std::string& config) const;
- void GetAppleArchs(const char* config,
+ void GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const;
///! Return the rule variable used to create this type of target,
@@ -69,12 +80,14 @@ public:
const char* GetCreateRuleVariable() const;
/** Get the include directories for this target. */
- std::vector<std::string> GetIncludeDirectories(const char *config) const;
+ std::vector<std::string> GetIncludeDirectories(
+ const std::string& config) const;
- bool IsSystemIncludeDirectory(const char *dir, const char *config) const;
+ bool IsSystemIncludeDirectory(const std::string& dir,
+ const std::string& config) const;
/** Add the target output files to the global generator manifest. */
- void GenerateTargetManifest(const char* config) const;
+ void GenerateTargetManifest(const std::string& config) const;
/**
* Trace through the source files in this target and add al source files
@@ -82,31 +95,53 @@ public:
*/
void TraceDependencies();
- void ClassifySources();
- void LookupObjectLibraries();
-
/** Get sources that must be built before the given source. */
- std::vector<cmSourceFile*> const* GetSourceDepends(cmSourceFile* sf) const;
+ std::vector<cmSourceFile*> const*
+ GetSourceDepends(cmSourceFile const* sf) const;
+ /**
+ * Flags for a given source file as used in this target. Typically assigned
+ * via SET_TARGET_PROPERTIES when the property is a list of source files.
+ */
+ enum SourceFileType
+ {
+ SourceFileTypeNormal,
+ SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
+ SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
+ SourceFileTypeResource, // is in "RESOURCE" target property *or*
+ // has MACOSX_PACKAGE_LOCATION=="Resources"
+ SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
+ };
+ struct SourceFileFlags
+ {
+ SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
+ SourceFileFlags(SourceFileFlags const& r):
+ Type(r.Type), MacFolder(r.MacFolder) {}
+ SourceFileType Type;
+ const char* MacFolder; // location inside Mac content folders
+ };
+
+ struct SourceFileFlags
+ GetTargetSourceFileFlags(const cmSourceFile* sf) const;
+
+ struct ResxData {
+ mutable std::set<std::string> ExpectedResxHeaders;
+ mutable std::vector<cmSourceFile const*> ResxSources;
+ };
private:
friend class cmTargetTraceDependencies;
struct SourceEntry { std::vector<cmSourceFile*> Depends; };
- typedef std::map<cmSourceFile*, SourceEntry> SourceEntriesType;
+ typedef std::map<cmSourceFile const*, SourceEntry> SourceEntriesType;
SourceEntriesType SourceEntries;
- std::vector<cmSourceFile*> CustomCommands;
- std::vector<cmSourceFile*> ExtraSources;
- std::vector<cmSourceFile*> HeaderSources;
- std::vector<cmSourceFile*> ExternalObjects;
- std::vector<cmSourceFile*> IDLSources;
- std::vector<cmSourceFile*> ResxSources;
- std::map<cmSourceFile const*, std::string> Objects;
+ mutable std::map<cmSourceFile const*, std::string> Objects;
std::set<cmSourceFile const*> ExplicitObjectName;
- std::set<std::string> ExpectedResxHeaders;
- std::vector<cmSourceFile*> ObjectSources;
- std::vector<cmTarget*> ObjectLibraries;
mutable std::map<std::string, std::vector<std::string> > SystemIncludesCache;
+ void ConstructSourceFileFlags() const;
+ mutable bool SourceFileFlagsConstructed;
+ mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
+
cmGeneratorTarget(cmGeneratorTarget const&);
void operator=(cmGeneratorTarget const&);
};
diff --git a/Source/cmGetCMakePropertyCommand.cxx b/Source/cmGetCMakePropertyCommand.cxx
index e7ad91a..e88f498 100644
--- a/Source/cmGetCMakePropertyCommand.cxx
+++ b/Source/cmGetCMakePropertyCommand.cxx
@@ -49,10 +49,10 @@ bool cmGetCMakePropertyCommand
}
else if ( args[1] == "COMPONENTS" )
{
- const std::set<cmStdString>* components
+ const std::set<std::string>* components
= this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
->GetInstallComponents();
- std::set<cmStdString>::const_iterator compIt;
+ std::set<std::string>::const_iterator compIt;
output = "";
for (compIt = components->begin(); compIt != components->end(); ++compIt)
{
@@ -66,14 +66,14 @@ bool cmGetCMakePropertyCommand
else
{
const char *prop =
- this->Makefile->GetCMakeInstance()->GetProperty(args[1].c_str());
+ this->Makefile->GetCMakeInstance()->GetProperty(args[1]);
if (prop)
{
output = prop;
}
}
- this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(variable, output.c_str());
return true;
}
diff --git a/Source/cmGetCMakePropertyCommand.h b/Source/cmGetCMakePropertyCommand.h
index 6c58bb4..1511406 100644
--- a/Source/cmGetCMakePropertyCommand.h
+++ b/Source/cmGetCMakePropertyCommand.h
@@ -37,7 +37,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_cmake_property";}
+ virtual std::string GetName() const { return "get_cmake_property";}
cmTypeMacro(cmGetCMakePropertyCommand, cmCommand);
};
diff --git a/Source/cmGetDirectoryPropertyCommand.cxx b/Source/cmGetDirectoryPropertyCommand.cxx
index 9e76e1b..fcc3da1 100644
--- a/Source/cmGetDirectoryPropertyCommand.cxx
+++ b/Source/cmGetDirectoryPropertyCommand.cxx
@@ -54,7 +54,7 @@ bool cmGetDirectoryPropertyCommand
// lookup the makefile from the directory name
cmLocalGenerator *lg =
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
- FindLocalGenerator(sd.c_str());
+ FindLocalGenerator(sd);
if (!lg)
{
this->SetError
@@ -79,18 +79,18 @@ bool cmGetDirectoryPropertyCommand
"providing the name of the variable to get.");
return false;
}
- output = dir->GetSafeDefinition(i->c_str());
- this->Makefile->AddDefinition(variable.c_str(), output.c_str());
+ output = dir->GetSafeDefinition(*i);
+ this->Makefile->AddDefinition(variable, output.c_str());
return true;
}
- const char *prop = dir->GetProperty(i->c_str());
+ const char *prop = dir->GetProperty(*i);
if (prop)
{
- this->Makefile->AddDefinition(variable.c_str(), prop);
+ this->Makefile->AddDefinition(variable, prop);
return true;
}
- this->Makefile->AddDefinition(variable.c_str(), "");
+ this->Makefile->AddDefinition(variable, "");
return true;
}
diff --git a/Source/cmGetDirectoryPropertyCommand.h b/Source/cmGetDirectoryPropertyCommand.h
index aea04ad..6c5750a 100644
--- a/Source/cmGetDirectoryPropertyCommand.h
+++ b/Source/cmGetDirectoryPropertyCommand.h
@@ -37,7 +37,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_directory_property";}
+ virtual std::string GetName() const { return "get_directory_property";}
cmTypeMacro(cmGetDirectoryPropertyCommand, cmCommand);
};
diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx
index 1d7fefc..10406d2 100644
--- a/Source/cmGetFilenameComponentCommand.cxx
+++ b/Source/cmGetFilenameComponentCommand.cxx
@@ -26,7 +26,7 @@ bool cmGetFilenameComponentCommand
// already, if so use that value
if(args.size() == 4 && args[3] == "CACHE")
{
- const char* cacheValue = this->Makefile->GetDefinition(args[0].c_str());
+ const char* cacheValue = this->Makefile->GetDefinition(args[0]);
if(cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue))
{
return true;
@@ -107,7 +107,7 @@ bool cmGetFilenameComponentCommand
else
{
std::string err = "unknown component " + args[2];
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
@@ -116,12 +116,12 @@ bool cmGetFilenameComponentCommand
if(programArgs.size() && storeArgs.size())
{
this->Makefile->AddCacheDefinition
- (storeArgs.c_str(), programArgs.c_str(),
+ (storeArgs, programArgs.c_str(),
"", args[2] == "PATH" ? cmCacheManager::FILEPATH
: cmCacheManager::STRING);
}
this->Makefile->AddCacheDefinition
- (args[0].c_str(), result.c_str(), "",
+ (args[0], result.c_str(), "",
args[2] == "PATH" ? cmCacheManager::FILEPATH
: cmCacheManager::STRING);
}
@@ -129,9 +129,9 @@ bool cmGetFilenameComponentCommand
{
if(programArgs.size() && storeArgs.size())
{
- this->Makefile->AddDefinition(storeArgs.c_str(), programArgs.c_str());
+ this->Makefile->AddDefinition(storeArgs, programArgs.c_str());
}
- this->Makefile->AddDefinition(args[0].c_str(), result.c_str());
+ this->Makefile->AddDefinition(args[0], result.c_str());
}
return true;
diff --git a/Source/cmGetFilenameComponentCommand.h b/Source/cmGetFilenameComponentCommand.h
index e2cd219..534de53 100644
--- a/Source/cmGetFilenameComponentCommand.h
+++ b/Source/cmGetFilenameComponentCommand.h
@@ -46,7 +46,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_filename_component";}
+ virtual std::string GetName() const { return "get_filename_component";}
cmTypeMacro(cmGetFilenameComponentCommand, cmCommand);
};
diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index 33c43ca..6dd40c9 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -73,7 +73,7 @@ bool cmGetPropertyCommand
e << "given invalid scope " << args[1] << ". "
<< "Valid scopes are "
<< "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -120,7 +120,7 @@ bool cmGetPropertyCommand
{
cmOStringStream e;
e << "given invalid argument \"" << args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -139,7 +139,7 @@ bool cmGetPropertyCommand
std::string output;
if(cmPropertyDefinition* def =
this->Makefile->GetCMakeInstance()->
- GetPropertyDefinition(this->PropertyName.c_str(), scope))
+ GetPropertyDefinition(this->PropertyName, scope))
{
output = def->GetShortDescription();
}
@@ -147,7 +147,7 @@ bool cmGetPropertyCommand
{
output = "NOTFOUND";
}
- this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(this->Variable, output.c_str());
}
else if(this->InfoType == OutFullDoc)
{
@@ -155,7 +155,7 @@ bool cmGetPropertyCommand
std::string output;
if(cmPropertyDefinition* def =
this->Makefile->GetCMakeInstance()->
- GetPropertyDefinition(this->PropertyName.c_str(), scope))
+ GetPropertyDefinition(this->PropertyName, scope))
{
output = def->GetFullDescription();
}
@@ -163,19 +163,19 @@ bool cmGetPropertyCommand
{
output = "NOTFOUND";
}
- this->Makefile->AddDefinition(this->Variable.c_str(), output.c_str());
+ this->Makefile->AddDefinition(this->Variable, output.c_str());
}
else if(this->InfoType == OutDefined)
{
// Lookup if the property is defined
if(this->Makefile->GetCMakeInstance()->
- GetPropertyDefinition(this->PropertyName.c_str(), scope))
+ GetPropertyDefinition(this->PropertyName, scope))
{
- this->Makefile->AddDefinition(this->Variable.c_str(), "1");
+ this->Makefile->AddDefinition(this->Variable, "1");
}
else
{
- this->Makefile->AddDefinition(this->Variable.c_str(), "0");
+ this->Makefile->AddDefinition(this->Variable, "0");
}
}
else
@@ -204,17 +204,17 @@ bool cmGetPropertyCommand::StoreResult(const char* value)
{
if(this->InfoType == OutSet)
{
- this->Makefile->AddDefinition(this->Variable.c_str(), value? "1":"0");
+ this->Makefile->AddDefinition(this->Variable, value? "1":"0");
}
else // if(this->InfoType == OutValue)
{
if(value)
{
- this->Makefile->AddDefinition(this->Variable.c_str(), value);
+ this->Makefile->AddDefinition(this->Variable, value);
}
else
{
- this->Makefile->RemoveDefinition(this->Variable.c_str());
+ this->Makefile->RemoveDefinition(this->Variable);
}
}
return true;
@@ -231,7 +231,7 @@ bool cmGetPropertyCommand::HandleGlobalMode()
// Get the property.
cmake* cm = this->Makefile->GetCMakeInstance();
- return this->StoreResult(cm->GetProperty(this->PropertyName.c_str()));
+ return this->StoreResult(cm->GetProperty(this->PropertyName));
}
//----------------------------------------------------------------------------
@@ -259,7 +259,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
// Lookup the generator.
if(cmLocalGenerator* lg =
(this->Makefile->GetLocalGenerator()
- ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str())))
+ ->GetGlobalGenerator()->FindLocalGenerator(dir)))
{
// Use the makefile for the directory found.
mf = lg->GetMakefile();
@@ -276,7 +276,7 @@ bool cmGetPropertyCommand::HandleDirectoryMode()
}
// Get the property.
- return this->StoreResult(mf->GetProperty(this->PropertyName.c_str()));
+ return this->StoreResult(mf->GetProperty(this->PropertyName));
}
//----------------------------------------------------------------------------
@@ -295,21 +295,21 @@ bool cmGetPropertyCommand::HandleTargetMode()
if(cmTarget* target =
this->Makefile->FindTargetToUse(this->Name))
{
- return this->StoreResult(target->GetName());
+ return this->StoreResult(target->GetName().c_str());
}
}
return this->StoreResult((this->Variable + "-NOTFOUND").c_str());
}
if(cmTarget* target = this->Makefile->FindTargetToUse(this->Name))
{
- return this->StoreResult(target->GetProperty(this->PropertyName.c_str()));
+ return this->StoreResult(target->GetProperty(this->PropertyName));
}
else
{
cmOStringStream e;
e << "could not find TARGET " << this->Name
<< ". Perhaps it has not yet been created.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -325,17 +325,17 @@ bool cmGetPropertyCommand::HandleSourceMode()
// Get the source file.
if(cmSourceFile* sf =
- this->Makefile->GetOrCreateSource(this->Name.c_str()))
+ this->Makefile->GetOrCreateSource(this->Name))
{
return
- this->StoreResult(sf->GetPropertyForUser(this->PropertyName.c_str()));
+ this->StoreResult(sf->GetPropertyForUser(this->PropertyName));
}
else
{
cmOStringStream e;
e << "given SOURCE name that could not be found or created: "
<< this->Name;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -350,15 +350,15 @@ bool cmGetPropertyCommand::HandleTestMode()
}
// Loop over all tests looking for matching names.
- if(cmTest* test = this->Makefile->GetTest(this->Name.c_str()))
+ if(cmTest* test = this->Makefile->GetTest(this->Name))
{
- return this->StoreResult(test->GetProperty(this->PropertyName.c_str()));
+ return this->StoreResult(test->GetProperty(this->PropertyName));
}
// If not found it is an error.
cmOStringStream e;
e << "given TEST name that does not exist: " << this->Name;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -372,7 +372,7 @@ bool cmGetPropertyCommand::HandleVariableMode()
}
return this->StoreResult
- (this->Makefile->GetDefinition(this->PropertyName.c_str()));
+ (this->Makefile->GetDefinition(this->PropertyName));
}
//----------------------------------------------------------------------------
@@ -389,7 +389,7 @@ bool cmGetPropertyCommand::HandleCacheMode()
this->Makefile->GetCacheManager()->GetCacheIterator(this->Name.c_str());
if(!it.IsAtEnd())
{
- value = it.GetProperty(this->PropertyName.c_str());
+ value = it.GetProperty(this->PropertyName);
}
this->StoreResult(value);
return true;
diff --git a/Source/cmGetPropertyCommand.h b/Source/cmGetPropertyCommand.h
index e1630ff..8c3738f 100644
--- a/Source/cmGetPropertyCommand.h
+++ b/Source/cmGetPropertyCommand.h
@@ -39,7 +39,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_property";}
+ virtual std::string GetName() const { return "get_property";}
cmTypeMacro(cmGetPropertyCommand, cmCommand);
private:
diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx
index 3d85e6d..8a96289 100644
--- a/Source/cmGetSourceFilePropertyCommand.cxx
+++ b/Source/cmGetSourceFilePropertyCommand.cxx
@@ -35,10 +35,10 @@ bool cmGetSourceFilePropertyCommand
{
if(args[2] == "LANGUAGE")
{
- this->Makefile->AddDefinition(var, sf->GetLanguage());
+ this->Makefile->AddDefinition(var, sf->GetLanguage().c_str());
return true;
}
- const char *prop = sf->GetPropertyForUser(args[2].c_str());
+ const char *prop = sf->GetPropertyForUser(args[2]);
if (prop)
{
this->Makefile->AddDefinition(var, prop);
diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h
index 338318e..ab8ce36 100644
--- a/Source/cmGetSourceFilePropertyCommand.h
+++ b/Source/cmGetSourceFilePropertyCommand.h
@@ -32,7 +32,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_source_file_property";}
+ virtual std::string GetName() const { return "get_source_file_property";}
cmTypeMacro(cmGetSourceFilePropertyCommand, cmCommand);
};
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 4aa49fe..e3ec0bc 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -20,9 +20,9 @@ bool cmGetTargetPropertyCommand
this->SetError("called with incorrect number of arguments");
return false;
}
- std::string var = args[0].c_str();
+ std::string var = args[0];
const std::string& targetName = args[1];
- const char *prop = 0;
+ std::string prop;
if(args[2] == "ALIASED_TARGET")
{
@@ -38,7 +38,11 @@ bool cmGetTargetPropertyCommand
else if(cmTarget* tgt = this->Makefile->FindTargetToUse(targetName))
{
cmTarget& target = *tgt;
- prop = target.GetProperty(args[2].c_str());
+ const char* prop_cstr = target.GetProperty(args[2]);
+ if(prop_cstr)
+ {
+ prop = prop_cstr;
+ }
}
else
{
@@ -63,19 +67,19 @@ bool cmGetTargetPropertyCommand
{
e << "get_target_property() called with non-existent target \""
<< targetName << "\".";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
return false;
}
}
}
- if (prop)
+ if (!prop.empty())
{
- this->Makefile->AddDefinition(var.c_str(), prop);
+ this->Makefile->AddDefinition(var, prop.c_str());
return true;
}
- this->Makefile->AddDefinition(var.c_str(), (var+"-NOTFOUND").c_str());
+ this->Makefile->AddDefinition(var, (var+"-NOTFOUND").c_str());
return true;
}
diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h
index 4985b3c..a35c6fe 100644
--- a/Source/cmGetTargetPropertyCommand.h
+++ b/Source/cmGetTargetPropertyCommand.h
@@ -32,7 +32,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_target_property";}
+ virtual std::string GetName() const { return "get_target_property";}
cmTypeMacro(cmGetTargetPropertyCommand, cmCommand);
};
diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx
index 0e0e2c0..b3df4c3 100644
--- a/Source/cmGetTestPropertyCommand.cxx
+++ b/Source/cmGetTestPropertyCommand.cxx
@@ -26,17 +26,17 @@ bool cmGetTestPropertyCommand
std::string testName = args[0];
std::string var = args[2];
- cmTest *test = this->Makefile->GetTest(testName.c_str());
+ cmTest *test = this->Makefile->GetTest(testName);
if (test)
{
- const char *prop = test->GetProperty(args[1].c_str());
+ const char *prop = test->GetProperty(args[1]);
if (prop)
{
- this->Makefile->AddDefinition(var.c_str(), prop);
+ this->Makefile->AddDefinition(var, prop);
return true;
}
}
- this->Makefile->AddDefinition(var.c_str(), "NOTFOUND");
+ this->Makefile->AddDefinition(var, "NOTFOUND");
return true;
}
diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h
index 2dccabe..2819492 100644
--- a/Source/cmGetTestPropertyCommand.h
+++ b/Source/cmGetTestPropertyCommand.h
@@ -32,7 +32,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "get_test_property";}
+ virtual std::string GetName() const { return "get_test_property";}
cmTypeMacro(cmGetTestPropertyCommand, cmCommand);
};
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 70004ea..470dea4 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -28,9 +28,9 @@ public:
<cmGlobalBorlandMakefileGenerator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalBorlandMakefileGenerator::GetActualName();}
- static const char* GetActualName() {return "Borland Makefiles";}
+ static std::string GetActualName() {return "Borland Makefiles";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index f933f27..1c48d39 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -89,19 +89,25 @@ bool cmGlobalGenerator::SetGeneratorToolset(std::string const& ts)
return false;
}
-std::string cmGlobalGenerator::SelectMakeProgram(const char* makeProgram,
- std::string makeDefault) const
+std::string cmGlobalGenerator::SelectMakeProgram(
+ const std::string& inMakeProgram,
+ const std::string& makeDefault) const
{
- if(cmSystemTools::IsOff(makeProgram))
+ std::string makeProgram = inMakeProgram;
+ if(cmSystemTools::IsOff(makeProgram.c_str()))
{
- makeProgram =
+ const char* makeProgramCSTR =
this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM");
- if(cmSystemTools::IsOff(makeProgram))
+ if(cmSystemTools::IsOff(makeProgramCSTR))
{
- makeProgram = makeDefault.c_str();
+ makeProgram = makeDefault;
}
- if(cmSystemTools::IsOff(makeProgram) &&
- !(makeProgram && *makeProgram))
+ else
+ {
+ makeProgram = makeProgramCSTR;
+ }
+ if(cmSystemTools::IsOff(makeProgram.c_str()) &&
+ !makeProgram.empty())
{
makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND";
}
@@ -117,7 +123,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
langComp += lang;
langComp += "_COMPILER";
- if(!mf->GetDefinition(langComp.c_str()))
+ if(!mf->GetDefinition(langComp))
{
if(!optional)
{
@@ -126,7 +132,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
}
return;
}
- const char* name = mf->GetRequiredDefinition(langComp.c_str());
+ const char* name = mf->GetRequiredDefinition(langComp);
std::string path;
if(!cmSystemTools::FileIsFullPath(name))
{
@@ -144,7 +150,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
std::string doc = lang;
doc += " compiler.";
const char* cname = this->GetCMakeInstance()->
- GetCacheManager()->GetCacheValue(langComp.c_str());
+ GetCacheManager()->GetCacheValue(langComp);
std::string changeVars;
if(cname && !optional)
{
@@ -179,7 +185,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string &lang,
changeVars.c_str());
}
}
- mf->AddCacheDefinition(langComp.c_str(), path.c_str(),
+ mf->AddCacheDefinition(langComp, path.c_str(),
doc.c_str(), cmCacheManager::FILEPATH);
}
@@ -210,6 +216,11 @@ bool cmGlobalGenerator::GenerateImportFile(const std::string &file)
return false;
}
+void cmGlobalGenerator::ForceLinkerLanguages()
+{
+
+}
+
bool
cmGlobalGenerator::IsExportedTargetsFile(const std::string &filename) const
{
@@ -447,8 +458,8 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
}
}
- std::map<cmStdString, bool> needTestLanguage;
- std::map<cmStdString, bool> needSetLanguageEnabledMaps;
+ std::map<std::string, bool> needTestLanguage;
+ std::map<std::string, bool> needSetLanguageEnabledMaps;
// foreach language
// load the CMakeDetermine(LANG)Compiler.cmake file to find
// the compiler
@@ -466,7 +477,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
std::string loadedLang = "CMAKE_";
loadedLang += lang;
loadedLang += "_COMPILER_LOADED";
- if(!mf->GetDefinition(loadedLang.c_str()))
+ if(!mf->GetDefinition(loadedLang))
{
fpath = rootBin;
fpath += "/CMake";
@@ -527,9 +538,9 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
std::string compilerEnv = "CMAKE_";
compilerEnv += lang;
compilerEnv += "_COMPILER_ENV_VAR";
- std::string envVar = mf->GetRequiredDefinition(compilerEnv.c_str());
+ std::string envVar = mf->GetRequiredDefinition(compilerEnv);
std::string envVarValue =
- mf->GetRequiredDefinition(compilerName.c_str());
+ mf->GetRequiredDefinition(compilerName);
std::string env = envVar;
env += "=";
env += envVarValue;
@@ -587,7 +598,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
compilerEnv += lang;
compilerEnv += "_COMPILER_ENV_VAR";
cmOStringStream noCompiler;
- const char* compilerFile = mf->GetDefinition(compilerName.c_str());
+ const char* compilerFile = mf->GetDefinition(compilerName);
if(!compilerFile || !*compilerFile ||
cmSystemTools::IsNOTFOUND(compilerFile))
{
@@ -630,7 +641,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
if(!this->CMakeInstance->GetIsInTryCompile())
{
this->PrintCompilerAdvice(noCompiler, lang,
- mf->GetDefinition(compilerEnv.c_str()));
+ mf->GetDefinition(compilerEnv));
mf->IssueMessage(cmake::FATAL_ERROR, noCompiler.str());
fatalError = true;
}
@@ -640,7 +651,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
std::string langLoadedVar = "CMAKE_";
langLoadedVar += lang;
langLoadedVar += "_INFORMATION_LOADED";
- if (!mf->GetDefinition(langLoadedVar.c_str()))
+ if (!mf->GetDefinition(langLoadedVar))
{
fpath = "CMake";
fpath += lang;
@@ -687,7 +698,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
// if the compiler did not work, then remove the
// CMake(LANG)Compiler.cmake file so that it will get tested the
// next time cmake is run
- if(!mf->IsOn(compilerWorks.c_str()))
+ if(!mf->IsOn(compilerWorks))
{
std::string compilerLangFile = rootBin;
compilerLangFile += "/CMake";
@@ -702,7 +713,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
sharedLibFlagsVar += lang;
sharedLibFlagsVar += "_FLAGS";
const char* sharedLibFlags =
- mf->GetSafeDefinition(sharedLibFlagsVar.c_str());
+ mf->GetSafeDefinition(sharedLibFlagsVar);
if (sharedLibFlags)
{
this->LanguageToOriginalSharedLibFlags[lang] = sharedLibFlags;
@@ -737,7 +748,7 @@ cmGlobalGenerator::EnableLanguage(std::vector<std::string>const& languages,
//----------------------------------------------------------------------------
void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
- std::string lang,
+ std::string const& lang,
const char* envVar) const
{
// Subclasses override this method if they do not support this advice.
@@ -759,10 +770,10 @@ void cmGlobalGenerator::PrintCompilerAdvice(std::ostream& os,
//----------------------------------------------------------------------------
void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
- std::string lang) const
+ std::string const& lang) const
{
std::string compilerIdVar = "CMAKE_" + lang + "_COMPILER_ID";
- const char* compilerId = mf->GetDefinition(compilerIdVar.c_str());
+ const char* compilerId = mf->GetDefinition(compilerIdVar);
if(!compilerId)
{
return;
@@ -786,7 +797,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
}
case cmPolicies::OLD:
// OLD behavior is to convert AppleClang to Clang.
- mf->AddDefinition(compilerIdVar.c_str(), "Clang");
+ mf->AddDefinition(compilerIdVar, "Clang");
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
@@ -818,7 +829,7 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
}
case cmPolicies::OLD:
// OLD behavior is to convert QCC to GNU.
- mf->AddDefinition(compilerIdVar.c_str(), "GNU");
+ mf->AddDefinition(compilerIdVar, "GNU");
break;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
@@ -834,17 +845,18 @@ void cmGlobalGenerator::CheckCompilerIdCompatibility(cmMakefile* mf,
}
//----------------------------------------------------------------------------
-const char*
+std::string
cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
{
- if(const char* lang = source.GetLanguage())
+ const std::string& lang = source.GetLanguage();
+ if(!lang.empty())
{
- std::map<cmStdString, cmStdString>::const_iterator it =
+ std::map<std::string, std::string>::const_iterator it =
this->LanguageToOutputExtension.find(lang);
if(it != this->LanguageToOutputExtension.end())
{
- return it->second.c_str();
+ return it->second;
}
}
else
@@ -857,7 +869,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
{
if(this->OutputExtensions.count(ext))
{
- return ext.c_str();
+ return ext;
}
}
}
@@ -865,7 +877,7 @@ cmGlobalGenerator::GetLanguageOutputExtension(cmSourceFile const& source) const
}
-const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
+std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
{
// if there is an extension and it starts with . then move past the
// . because the extensions are not stored with a . in the map
@@ -873,13 +885,13 @@ const char* cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const
{
++ext;
}
- std::map<cmStdString, cmStdString>::const_iterator it
+ std::map<std::string, std::string>::const_iterator it
= this->ExtensionToLanguage.find(ext);
if(it != this->ExtensionToLanguage.end())
{
- return it->second.c_str();
+ return it->second;
}
- return 0;
+ return "";
}
/* SetLanguageEnabled() is now split in two parts:
@@ -894,13 +906,15 @@ files could change the object file extension
(CMAKE_<LANG>_OUTPUT_EXTENSION) before the CMake variables were copied
to the C++ maps.
*/
-void cmGlobalGenerator::SetLanguageEnabled(const char* l, cmMakefile* mf)
+void cmGlobalGenerator::SetLanguageEnabled(const std::string& l,
+ cmMakefile* mf)
{
this->SetLanguageEnabledFlag(l, mf);
this->SetLanguageEnabledMaps(l, mf);
}
-void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf)
+void cmGlobalGenerator::SetLanguageEnabledFlag(const std::string& l,
+ cmMakefile* mf)
{
this->LanguageEnabled[l] = true;
@@ -912,7 +926,8 @@ void cmGlobalGenerator::SetLanguageEnabledFlag(const char* l, cmMakefile* mf)
this->FillExtensionToLanguageMap(l, mf);
}
-void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
+void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l,
+ cmMakefile* mf)
{
// use LanguageToLinkerPreference to detect whether this functions has
// run before
@@ -924,7 +939,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
std::string linkerPrefVar = std::string("CMAKE_") +
std::string(l) + std::string("_LINKER_PREFERENCE");
- const char* linkerPref = mf->GetDefinition(linkerPrefVar.c_str());
+ const char* linkerPref = mf->GetDefinition(linkerPrefVar);
int preference = 0;
if(linkerPref)
{
@@ -957,7 +972,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
std::string outputExtensionVar = std::string("CMAKE_") +
std::string(l) + std::string("_OUTPUT_EXTENSION");
- const char* outputExtension = mf->GetDefinition(outputExtensionVar.c_str());
+ const char* outputExtension = mf->GetDefinition(outputExtensionVar);
if(outputExtension)
{
this->LanguageToOutputExtension[l] = outputExtension;
@@ -975,7 +990,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
std::string ignoreExtensionsVar = std::string("CMAKE_") +
std::string(l) + std::string("_IGNORE_EXTENSIONS");
- std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar.c_str());
+ std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar);
std::vector<std::string> extensionList;
cmSystemTools::ExpandListArgument(ignoreExts, extensionList);
for(std::vector<std::string>::iterator i = extensionList.begin();
@@ -986,12 +1001,12 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const char* l, cmMakefile* mf)
}
-void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l,
+void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l,
cmMakefile* mf)
{
std::string extensionsVar = std::string("CMAKE_") +
std::string(l) + std::string("_SOURCE_FILE_EXTENSIONS");
- std::string exts = mf->GetSafeDefinition(extensionsVar.c_str());
+ std::string exts = mf->GetSafeDefinition(extensionsVar);
std::vector<std::string> extensionList;
cmSystemTools::ExpandListArgument(exts, extensionList);
for(std::vector<std::string>::iterator i = extensionList.begin();
@@ -1001,16 +1016,16 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const char* l,
}
}
-bool cmGlobalGenerator::IgnoreFile(const char* l) const
+bool cmGlobalGenerator::IgnoreFile(const char* ext) const
{
- if(this->GetLanguageFromExtension(l))
+ if(!this->GetLanguageFromExtension(ext).empty())
{
return false;
}
- return (this->IgnoreExtensions.count(l) > 0);
+ return (this->IgnoreExtensions.count(ext) > 0);
}
-bool cmGlobalGenerator::GetLanguageEnabled(const char* l) const
+bool cmGlobalGenerator::GetLanguageEnabled(const std::string& l) const
{
return (this->LanguageEnabled.find(l)!= this->LanguageEnabled.end());
}
@@ -1020,11 +1035,11 @@ void cmGlobalGenerator::ClearEnabledLanguages()
this->LanguageEnabled.clear();
}
-bool cmGlobalGenerator::IsDependedOn(const char* project,
+bool cmGlobalGenerator::IsDependedOn(const std::string& project,
cmTarget const* targetIn)
{
// Get all local gens for this project
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator it =
+ std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator it =
this->ProjectMap.find(project);
if (it == this->ProjectMap.end())
{
@@ -1165,12 +1180,6 @@ void cmGlobalGenerator::Generate()
return;
}
- // Check that all targets are valid.
- if(!this->CheckTargets())
- {
- return;
- }
-
this->FinalizeTargetCompileInfo();
#ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1207,6 +1216,8 @@ 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)
@@ -1228,8 +1239,6 @@ void cmGlobalGenerator::Generate()
this->LocalGenerators[i]->GenerateTargetManifest();
}
- this->ComputeGeneratorTargetObjects();
-
this->ProcessEvaluationFiles();
// Compute the inter-target dependencies.
@@ -1323,35 +1332,6 @@ bool cmGlobalGenerator::ComputeTargetDepends()
}
//----------------------------------------------------------------------------
-bool cmGlobalGenerator::CheckTargets()
-{
- // Make sure all targets can find their source files.
- for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
- {
- cmTargets& targets =
- this->LocalGenerators[i]->GetMakefile()->GetTargets();
- for(cmTargets::iterator ti = targets.begin();
- ti != targets.end(); ++ti)
- {
- cmTarget& target = ti->second;
- if(target.GetType() == cmTarget::EXECUTABLE ||
- target.GetType() == cmTarget::STATIC_LIBRARY ||
- target.GetType() == cmTarget::SHARED_LIBRARY ||
- target.GetType() == cmTarget::MODULE_LIBRARY ||
- target.GetType() == cmTarget::OBJECT_LIBRARY ||
- target.GetType() == cmTarget::UTILITY)
- {
- if(!target.FindSourceFiles())
- {
- return false;
- }
- }
- }
- }
- return true;
-}
-
-//----------------------------------------------------------------------------
void cmGlobalGenerator::CreateQtAutoGeneratorsTargets(AutogensType &autogens)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
@@ -1431,8 +1411,8 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
{
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += cmSystemTools::UpperCase(*ci);
- t->AppendProperty(defPropName.c_str(),
- mf->GetProperty(defPropName.c_str()));
+ t->AppendProperty(defPropName,
+ mf->GetProperty(defPropName));
}
}
}
@@ -1449,6 +1429,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(cmMakefile *mf)
{
cmTarget* t = &ti->second;
cmGeneratorTarget* gt = new cmGeneratorTarget(t);
+ this->ComputeTargetObjectDirectory(gt);
this->GeneratorTargets[t] = gt;
generatorTargets[t] = gt;
}
@@ -1474,29 +1455,6 @@ void cmGlobalGenerator::CreateGeneratorTargets()
}
}
-//----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeGeneratorTargetObjects()
-{
- // Construct per-target generator information.
- for(unsigned int i=0; i < this->LocalGenerators.size(); ++i)
- {
- cmMakefile *mf = this->LocalGenerators[i]->GetMakefile();
- cmGeneratorTargetsType targets = mf->GetGeneratorTargets();
- for(cmGeneratorTargetsType::iterator ti = targets.begin();
- ti != targets.end(); ++ti)
- {
- if (ti->second->Target->IsImported()
- || ti->second->Target->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- continue;
- }
- cmGeneratorTarget* gt = ti->second;
- gt->ClassifySources();
- gt->LookupObjectLibraries();
- this->ComputeTargetObjects(gt);
- }
- }
-}
//----------------------------------------------------------------------------
void cmGlobalGenerator::ClearGeneratorMembers()
@@ -1558,15 +1516,14 @@ cmGlobalGenerator::GetGeneratorTarget(cmTarget const* t) const
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::ComputeTargetObjects(cmGeneratorTarget*) const
+void cmGlobalGenerator::ComputeTargetObjectDirectory(cmGeneratorTarget*) const
{
- // Implemented in generator subclasses that need this.
}
void cmGlobalGenerator::CheckLocalGenerators()
{
- std::map<cmStdString, cmStdString> notFoundMap;
-// std::set<cmStdString> notFoundMap;
+ std::map<std::string, std::string> notFoundMap;
+// std::set<std::string> notFoundMap;
// after it is all done do a ConfigureFinalPass
cmCacheManager* manager = 0;
for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i)
@@ -1615,7 +1572,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
std::string incDirs = cmGeneratorExpression::Preprocess(incDirProp,
cmGeneratorExpression::StripAllGeneratorExpressions);
- cmSystemTools::ExpandListArgument(incDirs.c_str(), incs);
+ cmSystemTools::ExpandListArgument(incDirs, incs);
for( std::vector<std::string>::const_iterator incDir = incs.begin();
incDir != incs.end(); ++incDir)
@@ -1646,7 +1603,7 @@ void cmGlobalGenerator::CheckLocalGenerators()
if(notFoundMap.size())
{
std::string notFoundVars;
- for(std::map<cmStdString, cmStdString>::const_iterator
+ for(std::map<std::string, std::string>::const_iterator
ii = notFoundMap.begin();
ii != notFoundMap.end();
++ii)
@@ -1663,9 +1620,10 @@ void cmGlobalGenerator::CheckLocalGenerators()
}
}
-int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
- const char *projectName,
- const char *target, bool fast,
+int cmGlobalGenerator::TryCompile(const std::string& srcdir,
+ const std::string& bindir,
+ const std::string& projectName,
+ const std::string& target, bool fast,
std::string *output, cmMakefile *mf)
{
// if this is not set, then this is a first time configure
@@ -1689,7 +1647,7 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
}
std::string newTarget;
- if (target && strlen(target))
+ if (!target.empty())
{
newTarget += target;
#if 0
@@ -1704,27 +1662,30 @@ int cmGlobalGenerator::TryCompile(const char *srcdir, const char *bindir,
#endif // WIN32
#endif
}
- const char* config = mf->GetDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
+ std::string config =
+ mf->GetSafeDefinition("CMAKE_TRY_COMPILE_CONFIGURATION");
return this->Build(srcdir,bindir,projectName,
- newTarget.c_str(),
- output,0,config,false,fast,
+ newTarget,
+ output,"",config,false,fast,
this->TryCompileTimeout);
}
void cmGlobalGenerator::GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const char*, const char*, const char*,
- const char*, const char*, bool, std::vector<std::string> const&)
+ std::vector<std::string>& makeCommand, const std::string&,
+ const std::string&, const std::string&, const std::string&,
+ const std::string&, bool,
+ std::vector<std::string> const&)
{
makeCommand.push_back(
"cmGlobalGenerator::GenerateBuildCommand not implemented");
}
int cmGlobalGenerator::Build(
- const char *, const char *bindir,
- const char *projectName, const char *target,
+ const std::string&, const std::string& bindir,
+ const std::string& projectName, const std::string& target,
std::string *output,
- const char *makeCommandCSTR,
- const char *config,
+ const std::string& makeCommandCSTR,
+ const std::string& config,
bool clean, bool fast,
double timeout,
cmSystemTools::OutputOption outputflag,
@@ -1734,7 +1695,7 @@ int cmGlobalGenerator::Build(
* Run an executable command and put the stdout in output.
*/
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir);
+ cmSystemTools::ChangeDirectory(bindir.c_str());
if(output)
{
*output += "Change Dir: ";
@@ -1836,19 +1797,20 @@ int cmGlobalGenerator::Build(
//----------------------------------------------------------------------------
std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
- const char* target, const char* config, const char* native,
+ const std::string& target, const std::string& config,
+ const std::string& native,
bool ignoreErrors)
{
std::string makeCommand = cmSystemTools::GetCMakeCommand();
makeCommand = cmSystemTools::ConvertToOutputPath(makeCommand.c_str());
makeCommand += " --build .";
- if(config && *config)
+ if(!config.empty())
{
makeCommand += " --config \"";
makeCommand += config;
makeCommand += "\"";
}
- if(target && *target)
+ if(!target.empty())
{
makeCommand += " --target \"";
makeCommand += target;
@@ -1865,7 +1827,7 @@ std::string cmGlobalGenerator::GenerateCMakeBuildCommand(
sep = " ";
}
}
- if(native && *native)
+ if(!native.empty())
{
makeCommand += sep;
makeCommand += native;
@@ -2004,16 +1966,16 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
void
cmGlobalGenerator::GetEnabledLanguages(std::vector<std::string>& lang) const
{
- for(std::map<cmStdString, bool>::const_iterator i =
+ for(std::map<std::string, bool>::const_iterator i =
this->LanguageEnabled.begin(); i != this->LanguageEnabled.end(); ++i)
{
lang.push_back(i->first);
}
}
-int cmGlobalGenerator::GetLinkerPreference(const char* lang) const
+int cmGlobalGenerator::GetLinkerPreference(const std::string& lang) const
{
- std::map<cmStdString, int>::const_iterator it =
+ std::map<std::string, int>::const_iterator it =
this->LanguageToLinkerPreference.find(lang);
if (it != this->LanguageToLinkerPreference.end())
{
@@ -2090,7 +2052,7 @@ void cmGlobalGenerator::FillLocalGeneratorToTargetMap()
///! Find a local generator by its startdirectory
cmLocalGenerator*
-cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
+cmGlobalGenerator::FindLocalGenerator(const std::string& start_dir) const
{
for(std::vector<cmLocalGenerator*>::const_iterator it =
this->LocalGenerators.begin(); it != this->LocalGenerators.end(); ++it)
@@ -2105,60 +2067,41 @@ cmGlobalGenerator::FindLocalGenerator(const char* start_dir) const
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::AddAlias(const char *name, cmTarget *tgt)
+void cmGlobalGenerator::AddAlias(const std::string& name, cmTarget *tgt)
{
this->AliasTargets[name] = tgt;
}
//----------------------------------------------------------------------------
-bool cmGlobalGenerator::IsAlias(const char *name) const
+bool cmGlobalGenerator::IsAlias(const std::string& name) const
{
return this->AliasTargets.find(name) != this->AliasTargets.end();
}
//----------------------------------------------------------------------------
cmTarget*
-cmGlobalGenerator::FindTarget(const char* project, const char* name,
+cmGlobalGenerator::FindTarget(const std::string& name,
bool excludeAliases) const
{
- // if project specific
- if(project)
+ if (!excludeAliases)
{
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
- gens = this->ProjectMap.find(project);
- for(unsigned int i = 0; i < gens->second.size(); ++i)
+ std::map<std::string, cmTarget*>::const_iterator ai
+ = this->AliasTargets.find(name);
+ if (ai != this->AliasTargets.end())
{
- cmTarget* ret = (gens->second)[i]->GetMakefile()->FindTarget(name,
- excludeAliases);
- if(ret)
- {
- return ret;
- }
+ return ai->second;
}
}
- // if all projects/directories
- else
+ std::map<std::string,cmTarget *>::const_iterator i =
+ this->TotalTargets.find ( name );
+ if ( i != this->TotalTargets.end() )
{
- if (!excludeAliases)
- {
- std::map<cmStdString, cmTarget*>::const_iterator ai
- = this->AliasTargets.find(name);
- if (ai != this->AliasTargets.end())
- {
- return ai->second;
- }
- }
- std::map<cmStdString,cmTarget *>::const_iterator i =
- this->TotalTargets.find ( name );
- if ( i != this->TotalTargets.end() )
- {
- return i->second;
- }
- i = this->ImportedTargets.find(name);
- if ( i != this->ImportedTargets.end() )
- {
- return i->second;
- }
+ return i->second;
+ }
+ i = this->ImportedTargets.find(name);
+ if ( i != this->ImportedTargets.end() )
+ {
+ return i->second;
}
return 0;
}
@@ -2172,7 +2115,7 @@ cmGlobalGenerator::NameResolvesToFramework(const std::string& libname) const
return true;
}
- if(cmTarget* tgt = this->FindTarget(0, libname.c_str()))
+ if(cmTarget* tgt = this->FindTarget(libname))
{
if(tgt->IsFrameworkOnApple())
{
@@ -2361,7 +2304,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
{
if(!cmakeCfgIntDir || !*cmakeCfgIntDir || cmakeCfgIntDir[0] == '.')
{
- std::set<cmStdString>* componentsSet = &this->InstallComponents;
+ std::set<std::string>* componentsSet = &this->InstallComponents;
cpackCommandLines.erase(cpackCommandLines.begin(),
cpackCommandLines.end());
depends.erase(depends.begin(), depends.end());
@@ -2369,20 +2312,20 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
if ( componentsSet->size() > 0 )
{
ostr << "Available install components are:";
- std::set<cmStdString>::iterator it;
+ std::set<std::string>::iterator it;
for (
it = componentsSet->begin();
it != componentsSet->end();
++ it )
{
- ostr << " \"" << it->c_str() << "\"";
+ ostr << " \"" << *it << "\"";
}
}
else
{
ostr << "Only default component available";
}
- singleLine.push_back(ostr.str().c_str());
+ singleLine.push_back(ostr.str());
(*targets)["list_install_components"]
= this->CreateGlobalTarget("list_install_components",
ostr.str().c_str(),
@@ -2413,7 +2356,7 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
// automatically convert this name to the build-time location.
cmd = "cmake";
}
- singleLine.push_back(cmd.c_str());
+ singleLine.push_back(cmd);
if ( cmakeCfgIntDir && *cmakeCfgIntDir && cmakeCfgIntDir[0] != '.' )
{
std::string cfgArg = "-DBUILD_TYPE=";
@@ -2530,7 +2473,7 @@ void cmGlobalGenerator::EnableMinGWLanguage(cmMakefile *mf)
//----------------------------------------------------------------------------
cmTarget cmGlobalGenerator::CreateGlobalTarget(
- const char* name, const char* message,
+ const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends,
const char* workingDirectory)
@@ -2551,7 +2494,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(
std::vector<std::string>::iterator dit;
for ( dit = depends.begin(); dit != depends.end(); ++ dit )
{
- target.AddUtility(dit->c_str());
+ target.AddUtility(*dit);
}
// Organize in the "predefined targets" folder:
@@ -2583,7 +2526,7 @@ cmGlobalGenerator::GenerateRuleFile(std::string const& output) const
std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
std::string const& l) const
{
- std::map<cmStdString, cmStdString>::const_iterator it =
+ std::map<std::string, std::string>::const_iterator it =
this->LanguageToOriginalSharedLibFlags.find(l);
if(it != this->LanguageToOriginalSharedLibFlags.end())
{
@@ -2593,8 +2536,10 @@ std::string cmGlobalGenerator::GetSharedLibFlagsForLanguage(
}
//----------------------------------------------------------------------------
-void cmGlobalGenerator::AppendDirectoryForConfig(const char*, const char*,
- const char*, std::string&)
+void cmGlobalGenerator::AppendDirectoryForConfig(const std::string&,
+ const std::string&,
+ const std::string&,
+ std::string&)
{
// Subclasses that support multiple configurations should implement
// this method to append the subdirectory for the given build
@@ -2661,9 +2606,9 @@ void cmGlobalGenerator::SetExternalMakefileProjectGenerator(
}
}
-const char* cmGlobalGenerator::GetExtraGeneratorName() const
+std::string cmGlobalGenerator::GetExtraGeneratorName() const
{
- return this->ExtraGenerator==0 ? 0 : this->ExtraGenerator->GetName();
+ return this->ExtraGenerator? this->ExtraGenerator->GetName() : std::string();
}
void cmGlobalGenerator::FileReplacedDuringGenerate(const std::string& filename)
@@ -2721,7 +2666,7 @@ void cmGlobalGenerator::GetTargetSets(TargetDependSet& projectTargets,
bool cmGlobalGenerator::IsRootOnlyTarget(cmTarget* target) const
{
return (target->GetType() == cmTarget::GLOBAL_TARGET ||
- strcmp(target->GetName(), this->GetAllTargetName()) == 0);
+ target->GetName() == this->GetAllTargetName());
}
//----------------------------------------------------------------------------
@@ -2744,7 +2689,7 @@ void cmGlobalGenerator::AddTargetDepends(cmTarget const* target,
//----------------------------------------------------------------------------
-void cmGlobalGenerator::AddToManifest(const char* config,
+void cmGlobalGenerator::AddToManifest(const std::string& config,
std::string const& f)
{
// Add to the main manifest for this configuration.
@@ -2757,7 +2702,7 @@ void cmGlobalGenerator::AddToManifest(const char* config,
}
//----------------------------------------------------------------------------
-std::set<cmStdString> const&
+std::set<std::string> const&
cmGlobalGenerator::GetDirectoryContent(std::string const& dir, bool needDisk)
{
DirectoryContent& dc = this->DirectoryContentMap[dir];
@@ -2809,7 +2754,7 @@ cmGlobalGenerator::AddRuleHash(const std::vector<std::string>& outputs,
// Shorten the output name (in expected use case).
cmLocalGenerator* lg = this->GetLocalGenerators()[0];
- std::string fname = lg->Convert(outputs[0].c_str(),
+ std::string fname = lg->Convert(outputs[0],
cmLocalGenerator::HOME_OUTPUT);
// Associate the hash with this output.
@@ -2863,7 +2808,7 @@ void cmGlobalGenerator::CheckRuleHashes(std::string const& pfile,
fname = line.substr(33, line.npos);
// Look for a hash for this file's rule.
- std::map<cmStdString, RuleHash>::const_iterator rhi =
+ std::map<std::string, RuleHash>::const_iterator rhi =
this->RuleHashes.find(fname);
if(rhi != this->RuleHashes.end())
{
@@ -2908,7 +2853,7 @@ void cmGlobalGenerator::WriteRuleHashes(std::string const& pfile)
{
cmGeneratedFileStream fout(pfile.c_str());
fout << "# Hashes of file build rules.\n";
- for(std::map<cmStdString, RuleHash>::const_iterator
+ for(std::map<std::string, RuleHash>::const_iterator
rhi = this->RuleHashes.begin(); rhi != this->RuleHashes.end(); ++rhi)
{
fout.write(rhi->second.Data, 32);
@@ -2929,7 +2874,7 @@ void cmGlobalGenerator::WriteSummary()
cmGeneratedFileStream fout(fname.c_str());
// Generate summary information files for each target.
- for(std::map<cmStdString,cmTarget *>::const_iterator ti =
+ for(std::map<std::string,cmTarget *>::const_iterator ti =
this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
{
if ((ti->second)->GetType() == cmTarget::INTERFACE_LIBRARY)
@@ -2972,10 +2917,25 @@ void cmGlobalGenerator::WriteSummary(cmTarget* target)
// List the source files with any per-source labels.
fout << "# Source files and their labels\n";
std::vector<cmSourceFile*> sources;
- target->GetSourceFiles(sources);
+ std::vector<std::string> configs;
+ target->GetMakefile()->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
+ for(std::vector<std::string>::const_iterator ci = configs.begin();
+ ci != configs.end(); ++ci)
+ {
+ target->GetSourceFiles(sources, *ci);
+ }
+ std::set<cmSourceFile*> emitted;
for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
si != sources.end(); ++si)
{
+ if (!emitted.insert(*si).second)
+ {
+ continue;
+ }
cmSourceFile* sf = *si;
fout << sf->GetFullPath() << "\n";
if(const char* svalue = sf->GetProperty("LABELS"))
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 753eebf..82fb1e5 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -51,11 +51,11 @@ public:
virtual cmLocalGenerator *CreateLocalGenerator();
///! Get the name for this generator
- virtual const char *GetName() const { return "Generic"; };
+ virtual std::string GetName() const { return "Generic"; }
/** Check whether the given name matches the current generator. */
- virtual bool MatchesGeneratorName(const char* name) const
- { return strcmp(this->GetName(), name) == 0; }
+ virtual bool MatchesGeneratorName(const std::string& name) const
+ { return this->GetName() == name; }
/** Set the generator-specific toolset name. Returns true if toolset
is supported and false otherwise. */
@@ -77,8 +77,8 @@ public:
/**
* Set/Get and Clear the enabled languages.
*/
- void SetLanguageEnabled(const char*, cmMakefile* mf);
- bool GetLanguageEnabled(const char*) const;
+ void SetLanguageEnabled(const std::string&, cmMakefile* mf);
+ bool GetLanguageEnabled(const std::string&) const;
void ClearEnabledLanguages();
void GetEnabledLanguages(std::vector<std::string>& lang) const;
/**
@@ -105,8 +105,9 @@ public:
* Try running cmake and building a file. This is used for dynamically
* loaded commands, not as part of the usual build process.
*/
- virtual int TryCompile(const char *srcdir, const char *bindir,
- const char *projectName, const char *targetName,
+ virtual int TryCompile(const std::string& srcdir, const std::string& bindir,
+ const std::string& projectName,
+ const std::string& targetName,
bool fast, std::string *output, cmMakefile* mf);
@@ -116,10 +117,10 @@ public:
* empty then all is assumed. clean indicates if a "make clean" should be
* done first.
*/
- int Build(const char *srcdir, const char *bindir,
- const char *projectName, const char *targetName,
+ int Build(const std::string& srcdir, const std::string& bindir,
+ const std::string& projectName, const std::string& targetName,
std::string *output,
- const char *makeProgram, const char *config,
+ const std::string& makeProgram, const std::string& config,
bool clean, bool fast,
double timeout,
cmSystemTools::OutputOption outputflag=cmSystemTools::OUTPUT_NONE,
@@ -128,16 +129,16 @@ public:
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char *projectName, const char *projectDir,
- const char *targetName, const char* config, bool fast,
+ const std::string& makeProgram,
+ const std::string& projectName, const std::string& projectDir,
+ const std::string& targetName, const std::string& config, bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
/** Generate a "cmake --build" call for a given target and config. */
- std::string GenerateCMakeBuildCommand(const char* target,
- const char* config,
- const char* native,
+ std::string GenerateCMakeBuildCommand(const std::string& target,
+ const std::string& config,
+ const std::string& native,
bool ignoreErrors);
///! Set the CMake instance
@@ -162,17 +163,17 @@ public:
void SetExternalMakefileProjectGenerator(
cmExternalMakefileProjectGenerator *extraGenerator);
- const char* GetExtraGeneratorName() const;
+ std::string GetExtraGeneratorName() const;
void AddInstallComponent(const char* component);
- const std::set<cmStdString>* GetInstallComponents() const
+ const std::set<std::string>* GetInstallComponents() const
{ return &this->InstallComponents; }
cmExportSetMap& GetExportSets() {return this->ExportSets;}
/** Add a file to the manifest of generated targets for a configuration. */
- void AddToManifest(const char* config, std::string const& f);
+ void AddToManifest(const std::string& config, std::string const& f);
void EnableInstallTarget();
@@ -182,13 +183,13 @@ public:
bool GetToolSupportsColor() const { return this->ToolSupportsColor; }
///! return the language for the given extension
- const char* GetLanguageFromExtension(const char* ext) const;
+ std::string GetLanguageFromExtension(const char* ext) const;
///! is an extension to be ignored
bool IgnoreFile(const char* ext) const;
///! What is the preference for linkers and this language (None or Prefered)
- int GetLinkerPreference(const char* lang) const;
+ int GetLinkerPreference(const std::string& lang) const;
///! What is the object file extension for a given source file?
- const char* GetLanguageOutputExtension(cmSourceFile const&) const;
+ std::string GetLanguageOutputExtension(cmSourceFile const&) const;
///! What is the configurations directory variable called?
virtual const char* GetCMakeCFGIntDir() const { return "."; }
@@ -210,11 +211,11 @@ public:
virtual void FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
- cmTarget* FindTarget(const char* project, const char* name,
+ cmTarget* FindTarget(const std::string& name,
bool excludeAliases = false) const;
- void AddAlias(const char *name, cmTarget *tgt);
- bool IsAlias(const char *name) const;
+ void AddAlias(const std::string& name, cmTarget *tgt);
+ bool IsAlias(const std::string& name) const;
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
@@ -222,16 +223,16 @@ public:
/** If check to see if the target is linked to by any other
target in the project */
- bool IsDependedOn(const char* project, cmTarget const* target);
+ bool IsDependedOn(const std::string& project, cmTarget const* target);
///! Find a local generator by its startdirectory
- cmLocalGenerator* FindLocalGenerator(const char* start_dir) const;
+ cmLocalGenerator* FindLocalGenerator(const std::string& start_dir) const;
/** Append the subdirectory for the given configuration. If anything is
appended the given prefix and suffix will be appended around it, which
is useful for leading or trailing slashes. */
- virtual void AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+ virtual void AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir);
/** Get the manifest of all targets that will be built for each
@@ -243,7 +244,7 @@ public:
from disk at most once and cached. During the generation step
the content will include the target files to be built even if
they do not yet exist. */
- std::set<cmStdString> const& GetDirectoryContent(std::string const& dir,
+ std::set<std::string> const& GetDirectoryContent(std::string const& dir,
bool needDisk = true);
void AddTarget(cmTarget* t);
@@ -275,7 +276,7 @@ public:
/** Get per-target generator information. */
cmGeneratorTarget* GetGeneratorTarget(cmTarget const*) const;
- const std::map<cmStdString, std::vector<cmLocalGenerator*> >& GetProjectMap()
+ const std::map<std::string, std::vector<cmLocalGenerator*> >& GetProjectMap()
const {return this->ProjectMap;}
// track files replaced during a Generate
@@ -286,12 +287,12 @@ public:
std::string const& content);
/** Return whether the given binary directory is unused. */
- bool BinaryDirectoryIsNew(const char* dir)
+ bool BinaryDirectoryIsNew(const std::string& dir)
{
return this->BinaryDirectories.insert(dir).second;
}
/** Supported systems creates a GUID for the given name */
- virtual void CreateGUID(const char*) {}
+ virtual void CreateGUID(const std::string&) {}
/** Return true if the generated build tree may contain multiple builds.
i.e. "Can I build Debug and Release in the same tree?" */
@@ -322,6 +323,8 @@ public:
GetExportedTargetsFile(const std::string &filename) const;
void AddCMP0042WarnTarget(const std::string& target);
+ virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
+
protected:
typedef std::vector<cmLocalGenerator*> GeneratorVector;
// for a project collect all its targets by following depend
@@ -332,21 +335,20 @@ protected:
bool IsRootOnlyTarget(cmTarget* target) const;
void AddTargetDepends(cmTarget const* target,
TargetDependSet& projectTargets);
- void SetLanguageEnabledFlag(const char* l, cmMakefile* mf);
- void SetLanguageEnabledMaps(const char* l, cmMakefile* mf);
- void FillExtensionToLanguageMap(const char* l, cmMakefile* mf);
+ void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf);
+ void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf);
+ void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf);
virtual bool ComputeTargetDepends();
virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() const;
- bool CheckTargets();
typedef std::vector<std::pair<cmQtAutoGenerators,
cmTarget const*> > AutogensType;
void CreateQtAutoGeneratorsTargets(AutogensType& autogens);
- std::string SelectMakeProgram(const char* makeProgram,
- std::string makeDefault = "") const;
+ std::string SelectMakeProgram(const std::string& makeProgram,
+ const std::string& makeDefault = "") const;
// Fill the ProjectMap, this must be called after LocalGenerators
// has been populated.
@@ -356,7 +358,7 @@ protected:
bool IsExcluded(cmLocalGenerator* root, cmTarget const& target) const;
void FillLocalGeneratorToTargetMap();
void CreateDefaultGlobalTargets(cmTargets* targets);
- cmTarget CreateGlobalTarget(const char* name, const char* message,
+ cmTarget CreateGlobalTarget(const std::string& name, const char* message,
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, const char* workingDir);
@@ -364,18 +366,18 @@ protected:
bool UseLinkScript;
bool ForceUnixPaths;
bool ToolSupportsColor;
- cmStdString FindMakeProgramFile;
- cmStdString ConfiguredFilesPath;
+ std::string FindMakeProgramFile;
+ std::string ConfiguredFilesPath;
cmake *CMakeInstance;
std::vector<cmLocalGenerator *> LocalGenerators;
cmLocalGenerator* CurrentLocalGenerator;
// map from project name to vector of local generators in that project
- std::map<cmStdString, std::vector<cmLocalGenerator*> > ProjectMap;
+ std::map<std::string, std::vector<cmLocalGenerator*> > ProjectMap;
std::map<cmLocalGenerator*, std::set<cmTarget const*> >
LocalGeneratorToTargetMap;
// Set of named installation components requested by the project.
- std::set<cmStdString> InstallComponents;
+ std::set<std::string> InstallComponents;
bool InstallTargetEnabled;
// Sets of named target exports
cmExportSetMap ExportSets;
@@ -387,9 +389,9 @@ protected:
cmTargetManifest TargetManifest;
// All targets in the entire project.
- std::map<cmStdString,cmTarget *> TotalTargets;
- std::map<cmStdString,cmTarget *> AliasTargets;
- std::map<cmStdString,cmTarget *> ImportedTargets;
+ std::map<std::string,cmTarget *> TotalTargets;
+ std::map<std::string,cmTarget *> AliasTargets;
+ std::map<std::string,cmTarget *> ImportedTargets;
std::vector<cmGeneratorExpressionEvaluationFile*> EvaluationFiles;
virtual const char* GetPredefinedTargetsFolder();
@@ -401,18 +403,18 @@ private:
float FirstTimeProgress;
// If you add a new map here, make sure it is copied
// in EnableLanguagesFromGenerator
- std::map<cmStdString, bool> IgnoreExtensions;
- std::map<cmStdString, bool> LanguageEnabled;
- std::set<cmStdString> LanguagesReady; // Ready for try_compile
- std::map<cmStdString, cmStdString> OutputExtensions;
- std::map<cmStdString, cmStdString> LanguageToOutputExtension;
- std::map<cmStdString, cmStdString> ExtensionToLanguage;
- std::map<cmStdString, int> LanguageToLinkerPreference;
- std::map<cmStdString, cmStdString> LanguageToOriginalSharedLibFlags;
+ std::map<std::string, bool> IgnoreExtensions;
+ std::map<std::string, bool> LanguageEnabled;
+ std::set<std::string> LanguagesReady; // Ready for try_compile
+ std::map<std::string, std::string> OutputExtensions;
+ std::map<std::string, std::string> LanguageToOutputExtension;
+ std::map<std::string, std::string> ExtensionToLanguage;
+ std::map<std::string, int> LanguageToLinkerPreference;
+ std::map<std::string, std::string> LanguageToOriginalSharedLibFlags;
// Record hashes for rules and outputs.
struct RuleHash { char Data[32]; };
- std::map<cmStdString, RuleHash> RuleHashes;
+ std::map<std::string, RuleHash> RuleHashes;
void CheckRuleHashes();
void CheckRuleHashes(std::string const& pfile, std::string const& home);
void WriteRuleHashes(std::string const& pfile);
@@ -421,9 +423,12 @@ private:
void WriteSummary(cmTarget* target);
void FinalizeTargetCompileInfo();
- virtual void PrintCompilerAdvice(std::ostream& os, std::string lang,
+ virtual void ForceLinkerLanguages();
+
+ virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang,
const char* envVar) const;
- void CheckCompilerIdCompatibility(cmMakefile* mf, std::string lang) const;
+ void CheckCompilerIdCompatibility(cmMakefile* mf,
+ std::string const& lang) const;
cmExternalMakefileProjectGenerator* ExtraGenerator;
@@ -439,26 +444,24 @@ private:
friend class cmake;
void CreateGeneratorTargets(cmMakefile* mf);
void CreateGeneratorTargets();
- void ComputeGeneratorTargetObjects();
- virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
void ClearGeneratorMembers();
virtual const char* GetBuildIgnoreErrorsFlag() const { return 0; }
// Cache directory content and target files to be built.
- struct DirectoryContent: public std::set<cmStdString>
+ struct DirectoryContent: public std::set<std::string>
{
- typedef std::set<cmStdString> derived;
+ typedef std::set<std::string> derived;
bool LoadedFromDisk;
DirectoryContent(): LoadedFromDisk(false) {}
DirectoryContent(DirectoryContent const& dc):
derived(dc), LoadedFromDisk(dc.LoadedFromDisk) {}
};
- std::map<cmStdString, DirectoryContent> DirectoryContentMap;
+ std::map<std::string, DirectoryContent> DirectoryContentMap;
// Set of binary directories on disk.
- std::set<cmStdString> BinaryDirectories;
+ std::set<std::string> BinaryDirectories;
// track targets to issue CMP0042 warning for.
std::set<std::string> CMP0042WarnTargets;
diff --git a/Source/cmGlobalGeneratorFactory.h b/Source/cmGlobalGeneratorFactory.h
index fd1d65f..3c2cd60 100644
--- a/Source/cmGlobalGeneratorFactory.h
+++ b/Source/cmGlobalGeneratorFactory.h
@@ -29,7 +29,8 @@ public:
virtual ~cmGlobalGeneratorFactory() {}
/** Create a GlobalGenerator */
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* n) const = 0;
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& n) const = 0;
/** Get the documentation entry for this factory */
virtual void GetDocumentation(cmDocumentationEntry& entry) const = 0;
@@ -43,8 +44,9 @@ class cmGlobalGeneratorSimpleFactory : public cmGlobalGeneratorFactory
{
public:
/** Create a GlobalGenerator */
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
- if (strcmp(name, T::GetActualName())) return 0;
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const {
+ if (name != T::GetActualName()) return 0;
return new T; }
/** Get the documentation entry for this factory */
diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h
index 28893bf..344e013 100644
--- a/Source/cmGlobalJOMMakefileGenerator.h
+++ b/Source/cmGlobalJOMMakefileGenerator.h
@@ -27,11 +27,11 @@ public:
return new cmGlobalGeneratorSimpleFactory
<cmGlobalJOMMakefileGenerator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalJOMMakefileGenerator::GetActualName();}
// use NMake Makefiles in the name so that scripts/tests that depend on the
// name NMake Makefiles will work
- static const char* GetActualName() {return "NMake Makefiles JOM";}
+ static std::string GetActualName() {return "NMake Makefiles JOM";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalKdevelopGenerator.cxx b/Source/cmGlobalKdevelopGenerator.cxx
index ed0e15b..89d25c4 100644
--- a/Source/cmGlobalKdevelopGenerator.cxx
+++ b/Source/cmGlobalKdevelopGenerator.cxx
@@ -25,7 +25,7 @@
//----------------------------------------------------------------------------
void cmGlobalKdevelopGenerator
-::GetDocumentation(cmDocumentationEntry& entry, const char*) const
+::GetDocumentation(cmDocumentationEntry& entry, const std::string&) const
{
entry.Name = this->GetName();
entry.Brief = "Generates KDevelop 3 project files.";
@@ -44,7 +44,7 @@ void cmGlobalKdevelopGenerator::Generate()
{
// for each sub project in the project create
// a kdevelop project
- for (std::map<cmStdString, std::vector<cmLocalGenerator*> >::const_iterator
+ for (std::map<std::string, std::vector<cmLocalGenerator*> >::const_iterator
it = this->GlobalGenerator->GetProjectMap().begin();
it!= this->GlobalGenerator->GetProjectMap().end();
++it)
@@ -76,7 +76,7 @@ void cmGlobalKdevelopGenerator::Generate()
{
if (ti->second.GetType()==cmTarget::EXECUTABLE)
{
- executable = ti->second.GetLocation(0);
+ executable = ti->second.GetLocation("");
break;
}
}
@@ -103,7 +103,7 @@ bool cmGlobalKdevelopGenerator
std::string projectDir = projectDirIn + "/";
std::string filename = outputDir+ "/" + projectname +".kdevelop.filelist";
- std::set<cmStdString> files;
+ std::set<std::string> files;
std::string tmp;
for (std::vector<cmLocalGenerator*>::const_iterator it=lgs.begin();
@@ -139,7 +139,8 @@ bool cmGlobalKdevelopGenerator
ti != targets.end(); ti++)
{
std::vector<cmSourceFile*> sources;
- ti->second.GetSourceFiles(sources);
+ ti->second.GetSourceFiles(sources, ti->second.GetMakefile()
+ ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for (std::vector<cmSourceFile*>::const_iterator si=sources.begin();
si!=sources.end(); si++)
{
@@ -183,7 +184,7 @@ bool cmGlobalKdevelopGenerator
(strstr(tmp.c_str(),
cmake::GetCMakeFilesDirectoryPostSlash())==0))
{
- files.insert(tmp.c_str());
+ files.insert(tmp);
}
}
}
@@ -217,7 +218,7 @@ bool cmGlobalKdevelopGenerator
}
fileToOpen="";
- for (std::set<cmStdString>::const_iterator it=files.begin();
+ for (std::set<std::string>::const_iterator it=files.begin();
it!=files.end(); it++)
{
// get the full path to the file
@@ -360,7 +361,7 @@ void cmGlobalKdevelopGenerator
if (strstr(line, "<general>"))
{
fout<< " <projectmanagement>KDevCustomProject</projectmanagement>\n";
- fout<< " <projectdirectory>" <<projectDir.c_str()
+ fout<< " <projectdirectory>" <<projectDir
<< "</projectdirectory>\n"; //this one is important
fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n";
//and this one
@@ -368,14 +369,14 @@ void cmGlobalKdevelopGenerator
// inside kdevcustomproject the <filelistdirectory> must be put
if (strstr(line, "<kdevcustomproject>"))
{
- fout<<" <filelistdirectory>"<<outputDir.c_str()
+ fout<<" <filelistdirectory>"<<outputDir
<<"</filelistdirectory>\n";
}
// buildtool and builddir go inside <build>
if (strstr(line, "<build>"))
{
fout<<" <buildtool>make</buildtool>\n";
- fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n";
+ fout<<" <builddir>"<<outputDir<<"</builddir>\n";
}
}
}
@@ -417,7 +418,7 @@ void cmGlobalKdevelopGenerator
" <projectmanagement>KDevCustomProject</projectmanagement>\n"
" <primarylanguage>" << primaryLanguage << "</primarylanguage>\n"
" <ignoreparts/>\n"
- " <projectdirectory>" << projectDir.c_str() <<
+ " <projectdirectory>" << projectDir <<
"</projectdirectory>\n"; //this one is important
fout<<" <absoluteprojectpath>true</absoluteprojectpath>\n"; //and this one
@@ -444,12 +445,12 @@ void cmGlobalKdevelopGenerator
fout<<" </general>\n"
" <kdevcustomproject>\n"
- " <filelistdirectory>" << outputDir.c_str() <<
+ " <filelistdirectory>" << outputDir <<
"</filelistdirectory>\n"
" <run>\n"
- " <mainprogram>" << executable.c_str() << "</mainprogram>\n"
+ " <mainprogram>" << executable << "</mainprogram>\n"
" <directoryradio>custom</directoryradio>\n"
- " <customdirectory>"<<outputDir.c_str()<<"</customdirectory>\n"
+ " <customdirectory>"<<outputDir<<"</customdirectory>\n"
" <programargs></programargs>\n"
" <terminal>false</terminal>\n"
" <autocompile>true</autocompile>\n"
@@ -457,7 +458,7 @@ void cmGlobalKdevelopGenerator
" </run>\n"
" <build>\n"
" <buildtool>make</buildtool>\n"; //this one is important
- fout<<" <builddir>"<<outputDir.c_str()<<"</builddir>\n"; //and this one
+ fout<<" <builddir>"<<outputDir<<"</builddir>\n"; //and this one
fout<<" </build>\n"
" <make>\n"
" <abortonerror>false</abortonerror>\n"
@@ -480,7 +481,7 @@ void cmGlobalKdevelopGenerator
dirIt != this->Blacklist.end();
++dirIt)
{
- fout<<" <path>" << dirIt->c_str() << "</path>\n";
+ fout<<" <path>" << *dirIt << "</path>\n";
}
fout<<" </blacklist>\n";
@@ -558,7 +559,7 @@ void cmGlobalKdevelopGenerator
// command
fout<<" <kdevfileview>\n"
" <groups>\n"
- " <group pattern=\"" << cmakeFilePattern.c_str() <<
+ " <group pattern=\"" << cmakeFilePattern <<
"\" name=\"CMake\" />\n";
if (enableCxx)
@@ -601,7 +602,7 @@ void cmGlobalKdevelopGenerator
"<!DOCTYPE KDevPrjSession>\n"
"<KDevPrjSession>\n"
" <DocsAndViews NumberOfDocuments=\"1\" >\n"
- " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen.c_str() <<
+ " <Doc0 NumberOfViews=\"1\" URL=\"file://" << fileToOpen <<
"\" >\n"
" <View0 line=\"0\" Type=\"Source\" />\n"
" </Doc0>\n"
diff --git a/Source/cmGlobalKdevelopGenerator.h b/Source/cmGlobalKdevelopGenerator.h
index a1ad39d..0d59fc5 100644
--- a/Source/cmGlobalKdevelopGenerator.h
+++ b/Source/cmGlobalKdevelopGenerator.h
@@ -33,14 +33,14 @@ class cmGlobalKdevelopGenerator : public cmExternalMakefileProjectGenerator
public:
cmGlobalKdevelopGenerator();
- virtual const char* GetName() const
+ virtual std::string GetName() const
{ return cmGlobalKdevelopGenerator::GetActualName();}
- static const char* GetActualName() { return "KDevelop3";}
+ static std::string GetActualName() { return "KDevelop3";}
static cmExternalMakefileProjectGenerator* New()
{ return new cmGlobalKdevelopGenerator; }
/** Get the documentation entry for this generator. */
virtual void GetDocumentation(cmDocumentationEntry& entry,
- const char* fullName) const;
+ const std::string& fullName) const;
virtual void Generate();
private:
diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h
index 659de11..c4825bd 100644
--- a/Source/cmGlobalMSYSMakefileGenerator.h
+++ b/Source/cmGlobalMSYSMakefileGenerator.h
@@ -28,9 +28,9 @@ public:
<cmGlobalMSYSMakefileGenerator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalMSYSMakefileGenerator::GetActualName();}
- static const char* GetActualName() {return "MSYS Makefiles";}
+ static std::string GetActualName() {return "MSYS Makefiles";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h
index 7951e98..4289422 100644
--- a/Source/cmGlobalMinGWMakefileGenerator.h
+++ b/Source/cmGlobalMinGWMakefileGenerator.h
@@ -27,9 +27,9 @@ public:
return new cmGlobalGeneratorSimpleFactory
<cmGlobalMinGWMakefileGenerator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalMinGWMakefileGenerator::GetActualName();}
- static const char* GetActualName() {return "MinGW Makefiles";}
+ static std::string GetActualName() {return "MinGW Makefiles";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h
index 5756fbd..2ff44e3 100644
--- a/Source/cmGlobalNMakeMakefileGenerator.h
+++ b/Source/cmGlobalNMakeMakefileGenerator.h
@@ -27,9 +27,9 @@ public:
return new cmGlobalGeneratorSimpleFactory
<cmGlobalNMakeMakefileGenerator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalNMakeMakefileGenerator::GetActualName();}
- static const char* GetActualName() {return "NMake Makefiles";}
+ static std::string GetActualName() {return "NMake Makefiles";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 731bc00..88f1b08 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -19,6 +19,7 @@
#include "cmVersion.h"
#include <algorithm>
+#include <assert.h>
const char* cmGlobalNinjaGenerator::NINJA_BUILD_FILE = "build.ninja";
const char* cmGlobalNinjaGenerator::NINJA_RULES_FILE = "rules.ninja";
@@ -551,11 +552,11 @@ bool cmGlobalNinjaGenerator::UsingMinGW = false;
// cmGlobalGenerator::Build()
void cmGlobalNinjaGenerator
::GenerateBuildCommand(std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* /*projectName*/,
- const char* /*projectDir*/,
- const char* targetName,
- const char* /*config*/,
+ const std::string& makeProgram,
+ const std::string& /*projectName*/,
+ const std::string& /*projectDir*/,
+ const std::string& targetName,
+ const std::string& /*config*/,
bool /*fast*/,
std::vector<std::string> const& makeOptions)
{
@@ -565,9 +566,9 @@ void cmGlobalNinjaGenerator
makeCommand.insert(makeCommand.end(),
makeOptions.begin(), makeOptions.end());
- if(targetName && *targetName)
+ if(!targetName.empty())
{
- if(strcmp(targetName, "clean") == 0)
+ if(targetName == "clean")
{
makeCommand.push_back("-t");
makeCommand.push_back("clean");
@@ -631,31 +632,19 @@ std::string cmGlobalNinjaGenerator::GetEditCacheCommand() const
return cmSystemTools::GetCMakeGUICommand();
}
-// TODO: Refactor to combine with cmGlobalUnixMakefileGenerator3 impl.
-void cmGlobalNinjaGenerator::ComputeTargetObjects(cmGeneratorTarget* gt) const
+//----------------------------------------------------------------------------
+void cmGlobalNinjaGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
{
cmTarget* target = gt->Target;
// Compute full path to object file directory for this target.
- std::string dir_max;
- dir_max += gt->Makefile->GetCurrentOutputDirectory();
- dir_max += "/";
- dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
- dir_max += "/";
- gt->ObjectDirectory = dir_max;
-
- std::vector<cmSourceFile*> objectSources;
- gt->GetObjectSources(objectSources);
- // Compute the name of each object file.
- for(std::vector<cmSourceFile*>::iterator
- si = objectSources.begin();
- si != objectSources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- std::string objectName = gt->LocalGenerator
- ->GetObjectFileNameWithoutTarget(*sf, dir_max);
- gt->AddObject(sf, objectName);
- }
+ std::string dir;
+ dir += gt->Makefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += gt->LocalGenerator->GetTargetDirectory(*target);
+ dir += "/";
+ gt->ObjectDirectory = dir;
}
//----------------------------------------------------------------------------
@@ -834,8 +823,8 @@ void
cmGlobalNinjaGenerator
::AppendTargetOutputs(cmTarget const* target, cmNinjaDeps& outputs)
{
- const char* configName =
- target->GetMakefile()->GetDefinition("CMAKE_BUILD_TYPE");
+ std::string configName =
+ target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmLocalNinjaGenerator *ng =
static_cast<cmLocalNinjaGenerator *>(this->LocalGenerators[0]);
@@ -886,7 +875,7 @@ cmGlobalNinjaGenerator
if (target->GetType() == cmTarget::GLOBAL_TARGET) {
// Global targets only depend on other utilities, which may not appear in
// the TargetDepends set (e.g. "all").
- std::set<cmStdString> const& utils = target->GetUtilities();
+ std::set<std::string> const& utils = target->GetUtilities();
std::copy(utils.begin(), utils.end(), std::back_inserter(outputs));
} else {
cmTargetDependSet const& targetDeps =
@@ -1159,7 +1148,7 @@ void cmGlobalNinjaGenerator::WriteTargetClean(std::ostream& os)
{
WriteRule(*this->RulesFileStream,
"CLEAN",
- (ninjaCmd() + " -t clean").c_str(),
+ ninjaCmd() + " -t clean",
"Cleaning all built files...",
"Rule for cleaning all built files.",
/*depfile=*/ "",
@@ -1182,7 +1171,7 @@ void cmGlobalNinjaGenerator::WriteTargetHelp(std::ostream& os)
{
WriteRule(*this->RulesFileStream,
"HELP",
- (ninjaCmd() + " -t targets").c_str(),
+ ninjaCmd() + " -t targets",
"All primary targets available:",
"Rule for printing all primary targets available.",
/*depfile=*/ "",
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 0d5fb44..f2643af 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -173,11 +173,11 @@ public:
virtual cmLocalGenerator* CreateLocalGenerator();
/// Overloaded methods. @see cmGlobalGenerator::GetName().
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalNinjaGenerator::GetActualName(); }
/// @return the name of this generator.
- static const char* GetActualName() { return "Ninja"; }
+ static std::string GetActualName() { return "Ninja"; }
/// Overloaded methods. @see cmGlobalGenerator::GetDocumentation()
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -193,11 +193,11 @@ public:
/// Overloaded methods. @see cmGlobalGenerator::GenerateBuildCommand()
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
@@ -299,7 +299,7 @@ public:
void AddTargetAlias(const std::string& alias, cmTarget* target);
-
+ virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
protected:
/// Overloaded methods.
@@ -310,8 +310,6 @@ protected:
private:
virtual std::string GetEditCacheCommand() const;
- /// @see cmGlobalGenerator::ComputeTargetObjects
- virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
void OpenBuildFileStream();
void CloseBuildFileStream();
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 0b37a07..8dae81b 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -72,7 +72,7 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const
{
// If generating for an extra IDE, the edit_cache target cannot
// launch a terminal-interactive tool, so always use cmake-gui.
- if(this->GetExtraGeneratorName())
+ if(!this->GetExtraGeneratorName().empty())
{
return cmSystemTools::GetCMakeGUICommand();
}
@@ -106,35 +106,17 @@ std::string cmGlobalUnixMakefileGenerator3::GetEditCacheCommand() const
//----------------------------------------------------------------------------
void
cmGlobalUnixMakefileGenerator3
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
{
cmTarget* target = gt->Target;
- cmLocalUnixMakefileGenerator3* lg =
- static_cast<cmLocalUnixMakefileGenerator3*>(gt->LocalGenerator);
// Compute full path to object file directory for this target.
- std::string dir_max;
- dir_max += gt->Makefile->GetCurrentOutputDirectory();
- dir_max += "/";
- dir_max += gt->LocalGenerator->GetTargetDirectory(*target);
- dir_max += "/";
- gt->ObjectDirectory = dir_max;
-
- std::vector<cmSourceFile*> objectSources;
- gt->GetObjectSources(objectSources);
- // Compute the name of each object file.
- for(std::vector<cmSourceFile*>::iterator
- si = objectSources.begin();
- si != objectSources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- bool hasSourceExtension = true;
- std::string objectName = gt->LocalGenerator
- ->GetObjectFileNameWithoutTarget(*sf, dir_max,
- &hasSourceExtension);
- gt->AddObject(sf, objectName);
- lg->AddLocalObjectFile(target, sf, objectName, hasSourceExtension);
- }
+ std::string dir;
+ dir += gt->Makefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += gt->LocalGenerator->GetTargetDirectory(*target);
+ dir += "/";
+ gt->ObjectDirectory = dir;
}
void cmGlobalUnixMakefileGenerator3::Configure()
@@ -356,14 +338,14 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "# The top level Makefile was generated from the following files:\n"
<< "set(CMAKE_MAKEFILE_DEPENDS\n"
<< " \""
- << lg->Convert(cache.c_str(),
- cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
+ << lg->Convert(cache,
+ cmLocalGenerator::START_OUTPUT) << "\"\n";
for(std::vector<std::string>::const_iterator i = lfiles.begin();
i != lfiles.end(); ++i)
{
cmakefileStream
<< " \""
- << lg->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT).c_str()
+ << lg->Convert(*i, cmLocalGenerator::START_OUTPUT)
<< "\"\n";
}
cmakefileStream
@@ -379,11 +361,11 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
<< "# The corresponding makefile is:\n"
<< "set(CMAKE_MAKEFILE_OUTPUTS\n"
<< " \""
- << lg->Convert(makefileName.c_str(),
- cmLocalGenerator::START_OUTPUT).c_str() << "\"\n"
+ << lg->Convert(makefileName,
+ cmLocalGenerator::START_OUTPUT) << "\"\n"
<< " \""
- << lg->Convert(check.c_str(),
- cmLocalGenerator::START_OUTPUT).c_str() << "\"\n";
+ << lg->Convert(check,
+ cmLocalGenerator::START_OUTPUT) << "\"\n";
cmakefileStream << " )\n\n";
// CMake must rerun if a byproduct is missing.
@@ -397,7 +379,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
k != outfiles.end(); ++k)
{
cmakefileStream << " \"" <<
- lg->Convert(k->c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
+ lg->Convert(*k,cmLocalGenerator::HOME_OUTPUT)
<< "\"\n";
}
@@ -411,7 +393,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile()
tmpStr += cmake::GetCMakeFilesDirectory();
tmpStr += "/CMakeDirectoryInformation.cmake";
cmakefileStream << " \"" <<
- lg->Convert(tmpStr.c_str(),cmLocalGenerator::HOME_OUTPUT).c_str()
+ lg->Convert(tmpStr,cmLocalGenerator::HOME_OUTPUT)
<< "\"\n";
}
cmakefileStream << " )\n\n";
@@ -450,7 +432,7 @@ void cmGlobalUnixMakefileGenerator3
std::string tname = lg->GetRelativeTargetDirectory(l->second);
tname += "/DependInfo.cmake";
cmSystemTools::ConvertToUnixSlashes(tname);
- cmakefileStream << " \"" << tname.c_str() << "\"\n";
+ cmakefileStream << " \"" << tname << "\"\n";
}
}
}
@@ -477,24 +459,26 @@ cmGlobalUnixMakefileGenerator3
for(cmGeneratorTargetsType::iterator l = targets.begin();
l != targets.end(); ++l)
{
- if((l->second->GetType() == cmTarget::EXECUTABLE) ||
- (l->second->GetType() == cmTarget::STATIC_LIBRARY) ||
- (l->second->GetType() == cmTarget::SHARED_LIBRARY) ||
- (l->second->GetType() == cmTarget::MODULE_LIBRARY) ||
- (l->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
- (l->second->GetType() == cmTarget::UTILITY))
+ cmGeneratorTarget* gtarget = l->second;
+ int type = gtarget->GetType();
+ if((type == cmTarget::EXECUTABLE) ||
+ (type == cmTarget::STATIC_LIBRARY) ||
+ (type == cmTarget::SHARED_LIBRARY) ||
+ (type == cmTarget::MODULE_LIBRARY) ||
+ (type == cmTarget::OBJECT_LIBRARY) ||
+ (type == cmTarget::UTILITY))
{
- if(l->second->Target->IsImported())
+ if(gtarget->Target->IsImported())
{
continue;
}
// Add this to the list of depends rules in this directory.
- if((!check_all || !l->second->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
+ if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) &&
(!check_relink ||
- l->second->Target
- ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str())))
+ gtarget->Target
+ ->NeedRelinkBeforeInstall(lg->ConfigurationName)))
{
- std::string tname = lg->GetRelativeTargetDirectory(*l->second->Target);
+ std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target);
tname += "/";
tname += pass;
depends.push_back(tname);
@@ -528,7 +512,7 @@ cmGlobalUnixMakefileGenerator3
doc += "\" pass in the directory.";
std::vector<std::string> no_commands;
lg->WriteMakeRule(ruleFileStream, doc.c_str(),
- makeTarget.c_str(), depends, no_commands, true);
+ makeTarget, depends, no_commands, true);
}
//----------------------------------------------------------------------------
@@ -545,7 +529,7 @@ cmGlobalUnixMakefileGenerator3
// Begin the directory-level rules section.
std::string dir = lg->GetMakefile()->GetStartOutputDirectory();
- dir = lg->Convert(dir.c_str(), cmLocalGenerator::HOME_OUTPUT,
+ dir = lg->Convert(dir, cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE);
lg->WriteDivider(ruleFileStream);
ruleFileStream
@@ -565,11 +549,11 @@ cmGlobalUnixMakefileGenerator3
//----------------------------------------------------------------------------
void cmGlobalUnixMakefileGenerator3
::GenerateBuildCommand(std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* /*projectName*/,
- const char* /*projectDir*/,
- const char* targetName,
- const char* /*config*/,
+ const std::string& makeProgram,
+ const std::string& /*projectName*/,
+ const std::string& /*projectDir*/,
+ const std::string& targetName,
+ const std::string& /*config*/,
bool fast,
std::vector<std::string> const& makeOptions)
{
@@ -579,13 +563,13 @@ void cmGlobalUnixMakefileGenerator3
// Since we have full control over the invocation of nmake, let us
// make it quiet.
- if ( strcmp(this->GetName(), "NMake Makefiles") == 0 )
+ if ( this->GetName() == "NMake Makefiles" )
{
makeCommand.push_back("/NOLOGO");
}
makeCommand.insert(makeCommand.end(),
makeOptions.begin(), makeOptions.end());
- if ( targetName && strlen(targetName))
+ if (!targetName.empty())
{
cmLocalUnixMakefileGenerator3 *lg;
if (this->LocalGenerators.size())
@@ -610,7 +594,7 @@ void cmGlobalUnixMakefileGenerator3
{
tname += "/fast";
}
- tname = lg->Convert(tname.c_str(),cmLocalGenerator::HOME_OUTPUT);
+ tname = lg->Convert(tname,cmLocalGenerator::HOME_OUTPUT);
cmSystemTools::ConvertToOutputSlashes(tname);
makeCommand.push_back(tname);
if (!this->LocalGenerators.size())
@@ -624,7 +608,7 @@ void cmGlobalUnixMakefileGenerator3
void
cmGlobalUnixMakefileGenerator3
::WriteConvenienceRules(std::ostream& ruleFileStream,
- std::set<cmStdString> &emitted)
+ std::set<std::string> &emitted)
{
std::vector<std::string> depends;
std::vector<std::string> commands;
@@ -643,46 +627,48 @@ cmGlobalUnixMakefileGenerator3
for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{
- if(t->second->Target->IsImported())
+ cmGeneratorTarget* gtarget = t->second;
+ if(gtarget->Target->IsImported())
{
continue;
}
// Don't emit the same rule twice (e.g. two targets with the same
// simple name)
- if(t->second->GetName() &&
- strlen(t->second->GetName()) &&
- emitted.insert(t->second->GetName()).second &&
+ int type = gtarget->GetType();
+ std::string name = gtarget->GetName();
+ if(!name.empty() &&
+ emitted.insert(name).second &&
// Handle user targets here. Global targets are handled in
// the local generator on a per-directory basis.
- ((t->second->GetType() == cmTarget::EXECUTABLE) ||
- (t->second->GetType() == cmTarget::STATIC_LIBRARY) ||
- (t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
- (t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
- (t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
- (t->second->GetType() == cmTarget::UTILITY)))
+ ((type == cmTarget::EXECUTABLE) ||
+ (type == cmTarget::STATIC_LIBRARY) ||
+ (type == cmTarget::SHARED_LIBRARY) ||
+ (type == cmTarget::MODULE_LIBRARY) ||
+ (type == cmTarget::OBJECT_LIBRARY) ||
+ (type == cmTarget::UTILITY)))
{
// Add a rule to build the target by name.
lg->WriteDivider(ruleFileStream);
ruleFileStream
<< "# Target rules for targets named "
- << t->second->GetName() << "\n\n";
+ << name << "\n\n";
// Write the rule.
commands.clear();
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
tmp += "Makefile2";
commands.push_back(lg->GetRecursiveMakeCall
- (tmp.c_str(),t->second->GetName()));
+ (tmp.c_str(),name));
depends.clear();
depends.push_back("cmake_check_build_system");
lg->WriteMakeRule(ruleFileStream,
"Build rule for target.",
- t->second->GetName(), depends, commands,
+ name, depends, commands,
true);
// Add a fast rule to build the target
std::string localName =
- lg->GetRelativeTargetDirectory(*t->second->Target);
+ lg->GetRelativeTargetDirectory(*gtarget->Target);
std::string makefileName;
makefileName = localName;
makefileName += "/build.make";
@@ -690,29 +676,29 @@ cmGlobalUnixMakefileGenerator3
commands.clear();
std::string makeTargetName = localName;
makeTargetName += "/build";
- localName = t->second->GetName();
+ localName = name;
localName += "/fast";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), makeTargetName.c_str()));
+ (makefileName.c_str(), makeTargetName));
lg->WriteMakeRule(ruleFileStream, "fast build rule for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
// Add a local name for the rule to relink the target before
// installation.
- if(t->second->Target
- ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))
+ if(gtarget->Target
+ ->NeedRelinkBeforeInstall(lg->ConfigurationName))
{
- makeTargetName = lg->GetRelativeTargetDirectory(*t->second->Target);
+ makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target);
makeTargetName += "/preinstall";
- localName = t->second->GetName();
+ localName = name;
localName += "/preinstall";
depends.clear();
commands.clear();
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), makeTargetName.c_str()));
+ (makefileName.c_str(), makeTargetName));
lg->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
}
}
}
@@ -742,26 +728,28 @@ cmGlobalUnixMakefileGenerator3
for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{
- if(t->second->Target->IsImported())
+ cmGeneratorTarget* gtarget = t->second;
+ if(gtarget->Target->IsImported())
{
continue;
}
- if (t->second->GetName()
- && strlen(t->second->GetName())
- && ((t->second->GetType() == cmTarget::EXECUTABLE)
- || (t->second->GetType() == cmTarget::STATIC_LIBRARY)
- || (t->second->GetType() == cmTarget::SHARED_LIBRARY)
- || (t->second->GetType() == cmTarget::MODULE_LIBRARY)
- || (t->second->GetType() == cmTarget::OBJECT_LIBRARY)
- || (t->second->GetType() == cmTarget::UTILITY)))
+ int type = gtarget->GetType();
+ std::string name = gtarget->GetName();
+ if (!name.empty()
+ && ( (type == cmTarget::EXECUTABLE)
+ || (type == cmTarget::STATIC_LIBRARY)
+ || (type == cmTarget::SHARED_LIBRARY)
+ || (type == cmTarget::MODULE_LIBRARY)
+ || (type == cmTarget::OBJECT_LIBRARY)
+ || (type == cmTarget::UTILITY)))
{
std::string makefileName;
// Add a rule to build the target by name.
- localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+ localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
makefileName = localName;
makefileName += "/build.make";
- bool needRequiresStep = this->NeedRequiresStep(*t->second->Target);
+ bool needRequiresStep = this->NeedRequiresStep(*gtarget->Target);
lg->WriteDivider(ruleFileStream);
ruleFileStream
@@ -772,7 +760,7 @@ cmGlobalUnixMakefileGenerator3
makeTargetName = localName;
makeTargetName += "/depend";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
+ (makefileName.c_str(),makeTargetName));
// add requires if we need it for this generator
if (needRequiresStep)
@@ -780,12 +768,12 @@ cmGlobalUnixMakefileGenerator3
makeTargetName = localName;
makeTargetName += "/requires";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
+ (makefileName.c_str(),makeTargetName));
}
makeTargetName = localName;
makeTargetName += "/build";
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(),makeTargetName.c_str()));
+ (makefileName.c_str(),makeTargetName));
// Write the rule.
localName += "/all";
@@ -798,12 +786,12 @@ cmGlobalUnixMakefileGenerator3
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
// all target counts
- progCmd << lg->Convert(progressDir.c_str(),
+ progCmd << lg->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
progCmd << " ";
std::vector<unsigned long>& progFiles =
- this->ProgressMap[t->second->Target].Marks;
+ this->ProgressMap[gtarget->Target].Marks;
for (std::vector<unsigned long>::iterator i = progFiles.begin();
i != progFiles.end(); ++i)
{
@@ -812,15 +800,15 @@ cmGlobalUnixMakefileGenerator3
commands.push_back(progCmd.str());
}
progressDir = "Built target ";
- progressDir += t->second->GetName();
+ progressDir += name;
lg->AppendEcho(commands,progressDir.c_str());
- this->AppendGlobalTargetDepends(depends,*t->second->Target);
+ this->AppendGlobalTargetDepends(depends,*gtarget->Target);
lg->WriteMakeRule(ruleFileStream, "All Build rule for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
// add the all/all dependency
- if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target))
+ if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target))
{
depends.clear();
depends.push_back(localName);
@@ -839,23 +827,23 @@ cmGlobalUnixMakefileGenerator3
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start ";
// # in target
- progCmd << lg->Convert(progressDir.c_str(),
+ progCmd << lg->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
//
std::set<cmTarget const*> emitted;
progCmd << " "
- << this->CountProgressMarksInTarget(t->second->Target, emitted);
+ << this->CountProgressMarksInTarget(gtarget->Target, emitted);
commands.push_back(progCmd.str());
}
std::string tmp = cmake::GetCMakeFilesDirectoryPostSlash();
tmp += "Makefile2";
commands.push_back(lg->GetRecursiveMakeCall
- (tmp.c_str(),localName.c_str()));
+ (tmp.c_str(),localName));
{
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
- progCmd << lg->Convert(progressDir.c_str(),
+ progCmd << lg->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
progCmd << " 0";
@@ -863,34 +851,34 @@ cmGlobalUnixMakefileGenerator3
}
depends.clear();
depends.push_back("cmake_check_build_system");
- localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+ localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
localName += "/rule";
lg->WriteMakeRule(ruleFileStream,
"Build rule for subdir invocation for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
commands.clear();
depends.clear();
depends.push_back(localName);
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
- t->second->GetName(), depends, commands, true);
+ name, depends, commands, true);
// Add rules to prepare the target for installation.
- if(t->second->Target
- ->NeedRelinkBeforeInstall(lg->ConfigurationName.c_str()))
+ if(gtarget->Target
+ ->NeedRelinkBeforeInstall(lg->ConfigurationName))
{
- localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+ localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
localName += "/preinstall";
depends.clear();
commands.clear();
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), localName.c_str()));
+ (makefileName.c_str(), localName));
lg->WriteMakeRule(ruleFileStream,
"Pre-install relink rule for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
- if(!this->IsExcluded(this->LocalGenerators[0], *t->second->Target))
+ if(!this->IsExcluded(this->LocalGenerators[0], *gtarget->Target))
{
depends.clear();
depends.push_back(localName);
@@ -901,15 +889,15 @@ cmGlobalUnixMakefileGenerator3
}
// add the clean rule
- localName = lg->GetRelativeTargetDirectory(*t->second->Target);
+ localName = lg->GetRelativeTargetDirectory(*gtarget->Target);
makeTargetName = localName;
makeTargetName += "/clean";
depends.clear();
commands.clear();
commands.push_back(lg->GetRecursiveMakeCall
- (makefileName.c_str(), makeTargetName.c_str()));
+ (makefileName.c_str(), makeTargetName));
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
- makeTargetName.c_str(), depends, commands, true);
+ makeTargetName, depends, commands, true);
commands.clear();
depends.push_back(makeTargetName);
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
@@ -970,21 +958,6 @@ cmGlobalUnixMakefileGenerator3::RecordTargetProgress(
}
//----------------------------------------------------------------------------
-bool
-cmGlobalUnixMakefileGenerator3::ProgressMapCompare
-::operator()(cmTarget const* l, cmTarget const* r) const
-{
- // Order by target name.
- if(int c = strcmp(l->GetName(), r->GetName()))
- {
- return c < 0;
- }
- // Order duplicate targets by binary directory.
- return strcmp(l->GetMakefile()->GetCurrentOutputDirectory(),
- r->GetMakefile()->GetCurrentOutputDirectory()) < 0;
-}
-
-//----------------------------------------------------------------------------
void
cmGlobalUnixMakefileGenerator3::TargetProgress
::WriteProgressVariables(unsigned long total, unsigned long &current)
@@ -1051,7 +1024,7 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
lg->AppendEcho(commands,"... depend");
// Keep track of targets already listed.
- std::set<cmStdString> emittedTargets;
+ std::set<std::string> emittedTargets;
// for each local generator
unsigned int i;
@@ -1068,26 +1041,29 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
cmTargets& targets = lg2->GetMakefile()->GetTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
{
- if((t->second.GetType() == cmTarget::EXECUTABLE) ||
- (t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
- (t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
- (t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
- (t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
- (t->second.GetType() == cmTarget::GLOBAL_TARGET) ||
- (t->second.GetType() == cmTarget::UTILITY))
+ cmTarget const& target = t->second;
+ cmTarget::TargetType type = target.GetType();
+ if((type == cmTarget::EXECUTABLE) ||
+ (type == cmTarget::STATIC_LIBRARY) ||
+ (type == cmTarget::SHARED_LIBRARY) ||
+ (type == cmTarget::MODULE_LIBRARY) ||
+ (type == cmTarget::OBJECT_LIBRARY) ||
+ (type == cmTarget::GLOBAL_TARGET) ||
+ (type == cmTarget::UTILITY))
{
- if(emittedTargets.insert(t->second.GetName()).second)
+ std::string name = target.GetName();
+ if(emittedTargets.insert(name).second)
{
path = "... ";
- path += t->second.GetName();
+ path += name;
lg->AppendEcho(commands,path.c_str());
}
}
}
}
}
- std::vector<cmStdString> const& localHelp = lg->GetLocalHelp();
- for(std::vector<cmStdString>::const_iterator o = localHelp.begin();
+ std::vector<std::string> const& localHelp = lg->GetLocalHelp();
+ for(std::vector<std::string>::const_iterator o = localHelp.begin();
o != localHelp.end(); ++o)
{
path = "... ";
@@ -1104,15 +1080,16 @@ void cmGlobalUnixMakefileGenerator3::WriteHelpRule
bool cmGlobalUnixMakefileGenerator3
::NeedRequiresStep(cmTarget const& target)
{
- std::set<cmStdString> languages;
- target.GetLanguages(languages);
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ std::set<std::string> languages;
+ target.GetLanguages(languages,
+ target.GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
std::string var = "CMAKE_NEEDS_REQUIRES_STEP_";
var += *l;
var += "_FLAG";
- if(target.GetMakefile()->GetDefinition(var.c_str()))
+ if(target.GetMakefile()->GetDefinition(var))
{
return true;
}
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 9173751..f44dd12 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -60,9 +60,9 @@ public:
<cmGlobalUnixMakefileGenerator3>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalUnixMakefileGenerator3::GetActualName();}
- static const char* GetActualName() {return "Unix Makefiles";}
+ static std::string GetActualName() {return "Unix Makefiles";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -96,7 +96,7 @@ public:
// write the top level target rules
void WriteConvenienceRules(std::ostream& ruleFileStream,
- std::set<cmStdString> &emitted);
+ std::set<std::string> &emitted);
/** Get the command to use for a target that has no rule. This is
used for multiple output dependencies and for cmake_force. */
@@ -109,11 +109,11 @@ public:
// change the build command for speed
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
@@ -128,6 +128,7 @@ public:
/** Does the make tool tolerate .NOTPARALLEL? */
virtual bool AllowNotParallel() const { return true; }
+ virtual void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
protected:
void WriteMainMakefile2();
void WriteMainCMakefile();
@@ -184,10 +185,8 @@ protected:
std::vector<unsigned long> Marks;
void WriteProgressVariables(unsigned long total, unsigned long& current);
};
- struct ProgressMapCompare { bool operator()(cmTarget const*,
- cmTarget const*) const; };
typedef std::map<cmTarget const*, TargetProgress,
- ProgressMapCompare> ProgressMapType;
+ cmStrictTargetComparison> ProgressMapType;
ProgressMapType ProgressMap;
size_t CountProgressMarksInTarget(cmTarget const* target,
@@ -198,7 +197,6 @@ protected:
private:
virtual const char* GetBuildIgnoreErrorsFlag() const { return "-i"; }
virtual std::string GetEditCacheCommand() const;
- virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const;
};
#endif
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 6983ef9..37a416b 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -21,13 +21,14 @@
static const char vs10generatorName[] = "Visual Studio 10 2010";
// Map generator name without year to name with year.
-static const char* cmVS10GenName(const char* name, std::string& genName)
+static const char* cmVS10GenName(const std::string& name, std::string& genName)
{
- if(strncmp(name, vs10generatorName, sizeof(vs10generatorName)-6) != 0)
+ if(strncmp(name.c_str(), vs10generatorName,
+ sizeof(vs10generatorName)-6) != 0)
{
return 0;
}
- const char* p = name + sizeof(vs10generatorName) - 6;
+ const char* p = name.c_str() + sizeof(vs10generatorName) - 6;
if(cmHasLiteralPrefix(p, " 2010"))
{
p += 5;
@@ -40,27 +41,27 @@ class cmGlobalVisualStudio10Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const
{
std::string genName;
const char* p = cmVS10GenName(name, genName);
if(!p)
{ return 0; }
- name = genName.c_str();
if(strcmp(p, "") == 0)
{
return new cmGlobalVisualStudio10Generator(
- name, NULL, NULL);
+ genName, "", "");
}
if(strcmp(p, " Win64") == 0)
{
return new cmGlobalVisualStudio10Generator(
- name, "x64", "CMAKE_FORCE_WIN64");
+ genName, "x64", "CMAKE_FORCE_WIN64");
}
if(strcmp(p, " IA64") == 0)
{
return new cmGlobalVisualStudio10Generator(
- name, "Itanium", "CMAKE_FORCE_IA64");
+ genName, "Itanium", "CMAKE_FORCE_IA64");
}
return 0;
}
@@ -87,8 +88,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio10Generator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
- const char* name, const char* platformName,
- const char* additionalPlatformDefinition)
+ const std::string& name, const std::string& platformName,
+ const std::string& additionalPlatformDefinition)
: cmGlobalVisualStudio8Generator(name, platformName,
additionalPlatformDefinition)
{
@@ -102,7 +103,8 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
//----------------------------------------------------------------------------
bool
-cmGlobalVisualStudio10Generator::MatchesGeneratorName(const char* name) const
+cmGlobalVisualStudio10Generator::MatchesGeneratorName(
+ const std::string& name) const
{
std::string genName;
if(cmVS10GenName(name, genName))
@@ -310,11 +312,11 @@ std::string cmGlobalVisualStudio10Generator::FindDevEnvCommand()
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions)
{
@@ -334,7 +336,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
cmSlnData slnData;
{
std::string slnFile;
- if(projectDir && *projectDir)
+ if(!projectDir.empty())
{
slnFile = projectDir;
slnFile += "/";
@@ -369,25 +371,26 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
makeCommand.push_back(makeProgramSelected);
+ std::string realTarget = targetName;
// msbuild.exe CxxOnly.sln /t:Build /p:Configuration=Debug /target:ALL_BUILD
- if(!targetName || strlen(targetName) == 0)
+ if(realTarget.empty())
{
- targetName = "ALL_BUILD";
+ realTarget = "ALL_BUILD";
}
- if ( targetName && strcmp(targetName, "clean") == 0 )
+ if ( realTarget == "clean" )
{
makeCommand.push_back(std::string(projectName)+".sln");
makeCommand.push_back("/t:Clean");
}
else
{
- std::string targetProject(targetName);
+ std::string targetProject(realTarget);
targetProject += ".vcxproj";
if (targetProject.find('/') == std::string::npos)
{
// it might be in a subdir
if (cmSlnProjectEntry const* proj =
- slnData.GetProjectByName(targetName))
+ slnData.GetProjectByName(realTarget))
{
targetProject = proj->GetRelativePath();
cmSystemTools::ConvertToUnixSlashes(targetProject);
@@ -396,7 +399,7 @@ void cmGlobalVisualStudio10Generator::GenerateBuildCommand(
makeCommand.push_back(targetProject);
}
std::string configArg = "/p:Configuration=";
- if(config && strlen(config))
+ if(!config.empty())
{
configArg += config;
}
@@ -467,7 +470,7 @@ cmGlobalVisualStudio10Generator
//----------------------------------------------------------------------------
void cmGlobalVisualStudio10Generator::PathTooLong(
- cmTarget* target, cmSourceFile* sf, std::string const& sfRel)
+ cmTarget* target, cmSourceFile const* sf, std::string const& sfRel)
{
size_t len = (strlen(target->GetMakefile()->GetCurrentOutputDirectory()) +
1 + sfRel.length());
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 976d41f..ede6b1b 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -24,21 +24,22 @@ class cmGlobalVisualStudio10Generator :
public cmGlobalVisualStudio8Generator
{
public:
- cmGlobalVisualStudio10Generator(const char* name,
- const char* platformName, const char* additionalPlatformDefinition);
+ cmGlobalVisualStudio10Generator(const std::string& name,
+ const std::string& platformName,
+ const std::string& additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const char* name) const;
+ virtual bool MatchesGeneratorName(const std::string& name) const;
virtual bool SetGeneratorToolset(std::string const& ts);
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
@@ -86,7 +87,7 @@ public:
/** Generate an <output>.rule file path for a given command output. */
virtual std::string GenerateRuleFile(std::string const& output) const;
- void PathTooLong(cmTarget* target, cmSourceFile* sf,
+ void PathTooLong(cmTarget* target, cmSourceFile const* sf,
std::string const& sfRel);
virtual const char* GetToolsVersion() { return "4.0"; }
@@ -111,7 +112,7 @@ private:
LongestSourcePath(): Length(0), Target(0), SourceFile(0) {}
size_t Length;
cmTarget* Target;
- cmSourceFile* SourceFile;
+ cmSourceFile const* SourceFile;
std::string SourceRel;
};
LongestSourcePath LongestSource;
diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx
index 1f0c47a..4caa7f2 100644
--- a/Source/cmGlobalVisualStudio11Generator.cxx
+++ b/Source/cmGlobalVisualStudio11Generator.cxx
@@ -16,13 +16,14 @@
static const char vs11generatorName[] = "Visual Studio 11 2012";
// Map generator name without year to name with year.
-static const char* cmVS11GenName(const char* name, std::string& genName)
+static const char* cmVS11GenName(const std::string& name, std::string& genName)
{
- if(strncmp(name, vs11generatorName, sizeof(vs11generatorName)-6) != 0)
+ if(strncmp(name.c_str(), vs11generatorName,
+ sizeof(vs11generatorName)-6) != 0)
{
return 0;
}
- const char* p = name + sizeof(vs11generatorName) - 6;
+ const char* p = name.c_str() + sizeof(vs11generatorName) - 6;
if(cmHasLiteralPrefix(p, " 2012"))
{
p += 5;
@@ -35,27 +36,27 @@ class cmGlobalVisualStudio11Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const
{
std::string genName;
const char* p = cmVS11GenName(name, genName);
if(!p)
{ return 0; }
- name = genName.c_str();
if(strcmp(p, "") == 0)
{
return new cmGlobalVisualStudio11Generator(
- name, NULL, NULL);
+ genName, "", "");
}
if(strcmp(p, " Win64") == 0)
{
return new cmGlobalVisualStudio11Generator(
- name, "x64", "CMAKE_FORCE_WIN64");
+ genName, "x64", "CMAKE_FORCE_WIN64");
}
if(strcmp(p, " ARM") == 0)
{
return new cmGlobalVisualStudio11Generator(
- name, "ARM", NULL);
+ genName, "ARM", "");
}
if(*p++ != ' ')
@@ -107,8 +108,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio11Generator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
- const char* name, const char* platformName,
- const char* additionalPlatformDefinition)
+ const std::string& name, const std::string& platformName,
+ const std::string& additionalPlatformDefinition)
: cmGlobalVisualStudio10Generator(name, platformName,
additionalPlatformDefinition)
{
@@ -121,7 +122,8 @@ cmGlobalVisualStudio11Generator::cmGlobalVisualStudio11Generator(
//----------------------------------------------------------------------------
bool
-cmGlobalVisualStudio11Generator::MatchesGeneratorName(const char* name) const
+cmGlobalVisualStudio11Generator::MatchesGeneratorName(
+ const std::string& name) const
{
std::string genName;
if(cmVS11GenName(name, genName))
diff --git a/Source/cmGlobalVisualStudio11Generator.h b/Source/cmGlobalVisualStudio11Generator.h
index 7ef77e7..48ea489 100644
--- a/Source/cmGlobalVisualStudio11Generator.h
+++ b/Source/cmGlobalVisualStudio11Generator.h
@@ -20,11 +20,12 @@ class cmGlobalVisualStudio11Generator:
public cmGlobalVisualStudio10Generator
{
public:
- cmGlobalVisualStudio11Generator(const char* name,
- const char* platformName, const char* additionalPlatformDefinition);
+ cmGlobalVisualStudio11Generator(const std::string& name,
+ const std::string& platformName,
+ const std::string& additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const char* name) const;
+ virtual bool MatchesGeneratorName(const std::string& name) const;
virtual void WriteSLNHeader(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio12Generator.cxx b/Source/cmGlobalVisualStudio12Generator.cxx
index 3074794..6cd9f12 100644
--- a/Source/cmGlobalVisualStudio12Generator.cxx
+++ b/Source/cmGlobalVisualStudio12Generator.cxx
@@ -16,13 +16,14 @@
static const char vs12generatorName[] = "Visual Studio 12 2013";
// Map generator name without year to name with year.
-static const char* cmVS12GenName(const char* name, std::string& genName)
+static const char* cmVS12GenName(const std::string& name, std::string& genName)
{
- if(strncmp(name, vs12generatorName, sizeof(vs12generatorName)-6) != 0)
+ if(strncmp(name.c_str(), vs12generatorName,
+ sizeof(vs12generatorName)-6) != 0)
{
return 0;
}
- const char* p = name + sizeof(vs12generatorName) - 6;
+ const char* p = name.c_str() + sizeof(vs12generatorName) - 6;
if(cmHasLiteralPrefix(p, " 2013"))
{
p += 5;
@@ -35,27 +36,27 @@ class cmGlobalVisualStudio12Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const
{
std::string genName;
const char* p = cmVS12GenName(name, genName);
if(!p)
{ return 0; }
- name = genName.c_str();
if(strcmp(p, "") == 0)
{
return new cmGlobalVisualStudio12Generator(
- name, NULL, NULL);
+ genName, "", "");
}
if(strcmp(p, " Win64") == 0)
{
return new cmGlobalVisualStudio12Generator(
- name, "x64", "CMAKE_FORCE_WIN64");
+ genName, "x64", "CMAKE_FORCE_WIN64");
}
if(strcmp(p, " ARM") == 0)
{
return new cmGlobalVisualStudio12Generator(
- name, "ARM", NULL);
+ genName, "ARM", "");
}
return 0;
}
@@ -82,8 +83,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio12Generator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
- const char* name, const char* platformName,
- const char* additionalPlatformDefinition)
+ const std::string& name, const std::string& platformName,
+ const std::string& additionalPlatformDefinition)
: cmGlobalVisualStudio11Generator(name, platformName,
additionalPlatformDefinition)
{
@@ -96,7 +97,8 @@ cmGlobalVisualStudio12Generator::cmGlobalVisualStudio12Generator(
//----------------------------------------------------------------------------
bool
-cmGlobalVisualStudio12Generator::MatchesGeneratorName(const char* name) const
+cmGlobalVisualStudio12Generator::MatchesGeneratorName(
+ const std::string& name) const
{
std::string genName;
if(cmVS12GenName(name, genName))
diff --git a/Source/cmGlobalVisualStudio12Generator.h b/Source/cmGlobalVisualStudio12Generator.h
index 5a4a78d..4557f28 100644
--- a/Source/cmGlobalVisualStudio12Generator.h
+++ b/Source/cmGlobalVisualStudio12Generator.h
@@ -20,11 +20,12 @@ class cmGlobalVisualStudio12Generator:
public cmGlobalVisualStudio11Generator
{
public:
- cmGlobalVisualStudio12Generator(const char* name,
- const char* platformName, const char* additionalPlatformDefinition);
+ cmGlobalVisualStudio12Generator(const std::string& name,
+ const std::string& platformName,
+ const std::string& additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory();
- virtual bool MatchesGeneratorName(const char* name) const;
+ virtual bool MatchesGeneratorName(const std::string& name) const;
virtual void WriteSLNHeader(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio6Generator.cxx b/Source/cmGlobalVisualStudio6Generator.cxx
index 6c458c3..7397bbb 100644
--- a/Source/cmGlobalVisualStudio6Generator.cxx
+++ b/Source/cmGlobalVisualStudio6Generator.cxx
@@ -116,11 +116,11 @@ std::string cmGlobalVisualStudio6Generator::FindMSDevCommand()
void
cmGlobalVisualStudio6Generator::GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* /*projectDir*/,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& /*projectDir*/,
+ const std::string& targetName,
+ const std::string& config,
bool /*fast*/,
std::vector<std::string> const& makeOptions
)
@@ -134,21 +134,22 @@ cmGlobalVisualStudio6Generator::GenerateBuildCommand(
makeCommand.push_back("/MAKE");
std::string targetArg;
bool clean = false;
- if ( targetName && strcmp(targetName, "clean") == 0 )
+ std::string realTarget = targetName;
+ if ( realTarget == "clean" )
{
clean = true;
- targetName = "ALL_BUILD";
+ realTarget = "ALL_BUILD";
}
- if (targetName && strlen(targetName))
+ if (!realTarget.empty())
{
- targetArg += targetName;
+ targetArg += realTarget;
}
else
{
targetArg += "ALL_BUILD";
}
targetArg += " - ";
- if(config && strlen(config))
+ if(!config.empty())
{
targetArg += config;
}
@@ -259,7 +260,7 @@ void cmGlobalVisualStudio6Generator
// output the DSW file
void cmGlobalVisualStudio6Generator::OutputDSWFile()
{
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+ std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
{
this->OutputDSWFile(it->second[0], it->second);
@@ -270,7 +271,7 @@ void cmGlobalVisualStudio6Generator::OutputDSWFile()
// Note, that dependencies from executables to
// the libraries it uses are also done here
void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
- const char* dspname,
+ const std::string& dspname,
const char* dir,
cmTarget const& target)
{
@@ -315,9 +316,9 @@ void cmGlobalVisualStudio6Generator::WriteProject(std::ostream& fout,
// Note, that dependencies from executables to
// the libraries it uses are also done here
void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
- const char* name,
+ const std::string& name,
const char* location,
- const std::set<cmStdString>& dependencies)
+ const std::set<std::string>& dependencies)
{
fout << "#########################################################"
"######################\n\n";
@@ -328,7 +329,7 @@ void cmGlobalVisualStudio6Generator::WriteExternalProject(std::ostream& fout,
fout << "{{{\n";
- std::set<cmStdString>::const_iterator i, end;
+ std::set<std::string>::const_iterator i, end;
// write dependencies.
i = dependencies.begin();
end = dependencies.end();
@@ -417,12 +418,12 @@ void cmGlobalVisualStudio6Generator
//----------------------------------------------------------------------------
void
cmGlobalVisualStudio6Generator
-::AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+::AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir)
{
- if(config)
+ if(!config.empty())
{
dir += prefix;
dir += config;
diff --git a/Source/cmGlobalVisualStudio6Generator.h b/Source/cmGlobalVisualStudio6Generator.h
index 5521410..2797e11 100644
--- a/Source/cmGlobalVisualStudio6Generator.h
+++ b/Source/cmGlobalVisualStudio6Generator.h
@@ -31,9 +31,9 @@ public:
<cmGlobalVisualStudio6Generator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalVisualStudio6Generator::GetActualName();}
- static const char* GetActualName() {return "Visual Studio 6";}
+ static std::string GetActualName() {return "Visual Studio 6";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -54,11 +54,11 @@ public:
*/
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
@@ -81,9 +81,9 @@ public:
std::vector<cmLocalGenerator*>& generators);
/** Append the subdirectory for the given configuration. */
- virtual void AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+ virtual void AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir);
///! What is the configurations directory variable called?
@@ -99,10 +99,11 @@ private:
void WriteDSWFile(std::ostream& fout);
void WriteDSWHeader(std::ostream& fout);
void WriteProject(std::ostream& fout,
- const char* name, const char* path, cmTarget const& t);
+ const std::string& name, const char* path,
+ cmTarget const& t);
void WriteExternalProject(std::ostream& fout,
- const char* name, const char* path,
- const std::set<cmStdString>& dependencies);
+ const std::string& name, const char* path,
+ const std::set<std::string>& dependencies);
void WriteDSWFooter(std::ostream& fout);
virtual std::string WriteUtilityDepend(cmTarget const* target);
std::string MSDevCommand;
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index 22e4f08..4bea5ac 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -17,7 +17,8 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudio71Generator::cmGlobalVisualStudio71Generator(
- const char* platformName) : cmGlobalVisualStudio7Generator(platformName)
+ const std::string& platformName)
+ : cmGlobalVisualStudio7Generator(platformName)
{
this->ProjectConfigurationSectionName = "ProjectConfiguration";
}
@@ -155,7 +156,7 @@ cmGlobalVisualStudio71Generator
// the libraries it uses are also done here
void
cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
- const char* dspname,
+ const std::string& dspname,
const char* dir,
cmTarget const& t)
{
@@ -208,7 +209,7 @@ cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
void
cmGlobalVisualStudio71Generator
::WriteProjectDepends(std::ostream& fout,
- const char*,
+ const std::string&,
const char*, cmTarget const& target)
{
VSDependSet const& depends = this->VSTargetDepends[&target];
@@ -234,10 +235,10 @@ cmGlobalVisualStudio71Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
::WriteExternalProject(std::ostream& fout,
- const char* name,
+ const std::string& name,
const char* location,
const char* typeGuid,
- const std::set<cmStdString>& depends)
+ const std::set<std::string>& depends)
{
fout << "Project(\"{"
<< (typeGuid ? typeGuid : this->ExternalProjectType(location))
@@ -252,7 +253,7 @@ void cmGlobalVisualStudio71Generator
if(!depends.empty())
{
fout << "\tProjectSection(ProjectDependencies) = postProject\n";
- std::set<cmStdString>::const_iterator it;
+ std::set<std::string>::const_iterator it;
for(it = depends.begin(); it != depends.end(); ++it)
{
if(it->size() > 0)
@@ -277,12 +278,12 @@ void cmGlobalVisualStudio71Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio71Generator
::WriteProjectConfigurations(
- std::ostream& fout, const char* name, cmTarget::TargetType,
+ std::ostream& fout, const std::string& name, cmTarget::TargetType,
const std::set<std::string>& configsPartOfDefaultBuild,
- const char* platformMapping)
+ std::string const& platformMapping)
{
- const char* platformName =
- platformMapping ? platformMapping : this->GetPlatformName();
+ const std::string& platformName =
+ !platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
diff --git a/Source/cmGlobalVisualStudio71Generator.h b/Source/cmGlobalVisualStudio71Generator.h
index 04e3a55..2b5259a 100644
--- a/Source/cmGlobalVisualStudio71Generator.h
+++ b/Source/cmGlobalVisualStudio71Generator.h
@@ -23,15 +23,15 @@
class cmGlobalVisualStudio71Generator : public cmGlobalVisualStudio7Generator
{
public:
- cmGlobalVisualStudio71Generator(const char* platformName = NULL);
+ cmGlobalVisualStudio71Generator(const std::string& platformName = "");
static cmGlobalGeneratorFactory* NewFactory() {
return new cmGlobalGeneratorSimpleFactory
<cmGlobalVisualStudio71Generator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalVisualStudio71Generator::GetActualName();}
- static const char* GetActualName() {return "Visual Studio 7 .NET 2003";}
+ static std::string GetActualName() {return "Visual Studio 7 .NET 2003";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -59,20 +59,20 @@ protected:
std::vector<cmLocalGenerator*>& generators);
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProject(std::ostream& fout,
- const char* name, const char* path,
+ const std::string& name, const char* path,
cmTarget const& t);
virtual void WriteProjectDepends(std::ostream& fout,
- const char* name, const char* path,
+ const std::string& name, const char* path,
cmTarget const& t);
virtual void WriteProjectConfigurations(
- std::ostream& fout, const char* name, cmTarget::TargetType type,
+ std::ostream& fout, const std::string& name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
- const char* platformMapping = NULL);
+ const std::string& platformMapping = "");
virtual void WriteExternalProject(std::ostream& fout,
- const char* name,
+ const std::string& name,
const char* path,
const char* typeGuid,
- const std::set<cmStdString>& depends);
+ const std::set<std::string>& depends);
virtual void WriteSLNHeader(std::ostream& fout);
std::string ProjectConfigurationSectionName;
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index bb63289..42033c5 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -19,16 +19,19 @@
#include <cmsys/Encoding.hxx>
cmGlobalVisualStudio7Generator::cmGlobalVisualStudio7Generator(
- const char* platformName)
+ const std::string& platformName)
{
this->IntelProjectVersion = 0;
this->DevEnvCommandInitialized = false;
- if (!platformName)
+ if (platformName.empty())
{
- platformName = "Win32";
+ this->PlatformName = "Win32";
+ }
+ else
+ {
+ this->PlatformName = platformName;
}
- this->PlatformName = platformName;
}
cmGlobalVisualStudio7Generator::~cmGlobalVisualStudio7Generator()
@@ -183,11 +186,11 @@ const char* cmGlobalVisualStudio7Generator::ExternalProjectType(
//----------------------------------------------------------------------------
void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* /*projectDir*/,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& /*projectDir*/,
+ const std::string& targetName,
+ const std::string& config,
bool /*fast*/,
std::vector<std::string> const& makeOptions)
{
@@ -208,11 +211,12 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
makeCommand.push_back(makeProgramSelected);
makeCommand.push_back(std::string(projectName) + ".sln");
+ std::string realTarget = targetName;
bool clean = false;
- if ( targetName && strcmp(targetName, "clean") == 0 )
+ if ( realTarget == "clean" )
{
clean = true;
- targetName = "ALL_BUILD";
+ realTarget = "ALL_BUILD";
}
if(clean)
{
@@ -223,7 +227,7 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
makeCommand.push_back("/build");
}
- if(config && strlen(config))
+ if(!config.empty())
{
makeCommand.push_back(config);
}
@@ -233,9 +237,9 @@ void cmGlobalVisualStudio7Generator::GenerateBuildCommand(
}
makeCommand.push_back("/project");
- if (targetName && strlen(targetName))
+ if (!realTarget.empty())
{
- makeCommand.push_back(targetName);
+ makeCommand.push_back(realTarget);
}
else
{
@@ -259,7 +263,7 @@ cmLocalGenerator *cmGlobalVisualStudio7Generator::CreateLocalGenerator()
void cmGlobalVisualStudio7Generator::AddPlatformDefinitions(cmMakefile* mf)
{
cmGlobalVisualStudioGenerator::AddPlatformDefinitions(mf);
- mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName());
+ mf->AddDefinition("CMAKE_VS_PLATFORM_NAME", this->GetPlatformName().c_str());
mf->AddDefinition("CMAKE_VS_INTEL_Fortran_PROJECT_VERSION",
this->GetIntelProjectVersion());
}
@@ -352,7 +356,7 @@ void cmGlobalVisualStudio7Generator
// output the SLN file
void cmGlobalVisualStudio7Generator::OutputSLNFile()
{
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+ std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
{
this->OutputSLNFile(it->second[0], it->second);
@@ -380,9 +384,10 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
{
std::set<std::string> allConfigurations(this->Configurations.begin(),
this->Configurations.end());
+ const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
this->WriteProjectConfigurations(
- fout, target->GetName(), target->GetType(),
- allConfigurations, target->GetProperty("VS_PLATFORM_MAPPING"));
+ fout, target->GetName().c_str(), target->GetType(),
+ allConfigurations, mapping ? mapping : "");
}
else
{
@@ -653,7 +658,7 @@ cmGlobalVisualStudio7Generator::ConvertToSolutionPath(const char* path)
// Note, that dependencies from executables to
// the libraries it uses are also done here
void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
- const char* dspname,
+ const std::string& dspname,
const char* dir, cmTarget const& target)
{
// check to see if this is a fortran build
@@ -693,7 +698,7 @@ void cmGlobalVisualStudio7Generator::WriteProject(std::ostream& fout,
void
cmGlobalVisualStudio7Generator
::WriteProjectDepends(std::ostream& fout,
- const char* dspname,
+ const std::string& dspname,
const char*, cmTarget const& target)
{
int depcount = 0;
@@ -729,12 +734,12 @@ cmGlobalVisualStudio7Generator
// executables to the libraries it uses are also done here
void cmGlobalVisualStudio7Generator
::WriteProjectConfigurations(
- std::ostream& fout, const char* name, cmTarget::TargetType,
+ std::ostream& fout, const std::string& name, cmTarget::TargetType,
const std::set<std::string>& configsPartOfDefaultBuild,
- const char* platformMapping)
+ const std::string& platformMapping)
{
- const char* platformName =
- platformMapping ? platformMapping : this->GetPlatformName();
+ const std::string& platformName =
+ !platformMapping.empty() ? platformMapping : this->GetPlatformName();
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
i != this->Configurations.end(); ++i)
@@ -757,10 +762,10 @@ void cmGlobalVisualStudio7Generator
// Note, that dependencies from executables to
// the libraries it uses are also done here
void cmGlobalVisualStudio7Generator::WriteExternalProject(std::ostream& fout,
- const char* name,
+ const std::string& name,
const char* location,
const char* typeGuid,
- const std::set<cmStdString>&)
+ const std::set<std::string>&)
{
std::string d = cmSystemTools::ConvertToOutputPath(location);
fout << "Project("
@@ -868,7 +873,8 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
std::string guid = this->GetGUID(pname.c_str());
fout <<
- "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
+ "<?xml version=\"1.0\" encoding = \""
+ << this->Encoding() << "\"?>\n"
"<VisualStudioProject\n"
"\tProjectType=\"Visual C++\"\n"
"\tVersion=\"" << this->GetIDEVersion() << "0\"\n"
@@ -907,7 +913,7 @@ cmGlobalVisualStudio7Generator::WriteUtilityDepend(cmTarget const* target)
return pname;
}
-std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name)
+std::string cmGlobalVisualStudio7Generator::GetGUID(const std::string& name)
{
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
@@ -918,12 +924,12 @@ std::string cmGlobalVisualStudio7Generator::GetGUID(const char* name)
return std::string(storedGUID);
}
cmSystemTools::Error("Unknown Target referenced : ",
- name);
+ name.c_str());
return "";
}
-void cmGlobalVisualStudio7Generator::CreateGUID(const char* name)
+void cmGlobalVisualStudio7Generator::CreateGUID(const std::string& name)
{
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
@@ -960,12 +966,12 @@ void cmGlobalVisualStudio7Generator
//----------------------------------------------------------------------------
void
cmGlobalVisualStudio7Generator
-::AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+::AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir)
{
- if(config)
+ if(!config.empty())
{
dir += prefix;
dir += config;
@@ -974,8 +980,9 @@ cmGlobalVisualStudio7Generator
}
std::set<std::string>
-cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(const char* project,
- cmTarget const* target)
+cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild(
+ const std::string& project,
+ cmTarget const* target)
{
std::set<std::string> activeConfigs;
// if it is a utilitiy target then only make it part of the
@@ -1032,3 +1039,14 @@ cmIDEFlagTable const* cmGlobalVisualStudio7Generator::GetExtraFlagTableVS7()
{
return cmVS7ExtraFlagTable;
}
+
+std::string cmGlobalVisualStudio7Generator::Encoding()
+{
+ std::ostringstream encoding;
+#ifdef CMAKE_ENCODING_UTF8
+ encoding << "UTF-8";
+#else
+ encoding << "Windows-1252";
+#endif
+ return encoding.str();
+}
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index f69bd84..1dc709d 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -26,7 +26,7 @@ struct cmIDEFlagTable;
class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator
{
public:
- cmGlobalVisualStudio7Generator(const char* platformName = NULL);
+ cmGlobalVisualStudio7Generator(const std::string& platformName = "");
~cmGlobalVisualStudio7Generator();
static cmGlobalGeneratorFactory* NewFactory() {
@@ -34,12 +34,12 @@ public:
<cmGlobalVisualStudio7Generator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalVisualStudio7Generator::GetActualName();}
- static const char* GetActualName() {return "Visual Studio 7";}
+ static std::string GetActualName() {return "Visual Studio 7";}
///! Get the name for the platform.
- const char* GetPlatformName() const { return this->PlatformName.c_str(); }
+ const std::string& GetPlatformName() const { return this->PlatformName; }
///! Create a local generator appropriate to this Global Generator
virtual cmLocalGenerator *CreateLocalGenerator();
@@ -62,11 +62,11 @@ public:
*/
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
@@ -89,13 +89,13 @@ public:
std::vector<std::string> *GetConfigurations();
///! Create a GUID or get an existing one.
- void CreateGUID(const char* name);
- std::string GetGUID(const char* name);
+ void CreateGUID(const std::string& name);
+ std::string GetGUID(const std::string& name);
/** Append the subdirectory for the given configuration. */
- virtual void AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+ virtual void AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir);
///! What is the configurations directory variable called?
@@ -109,6 +109,9 @@ public:
virtual void FindMakeProgram(cmMakefile*);
+ // Encoding for Visual Studio files
+ virtual std::string Encoding();
+
protected:
virtual const char* GetIDEVersion() { return "7.0"; }
@@ -123,15 +126,15 @@ protected:
virtual void WriteSLNFile(std::ostream& fout, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators);
virtual void WriteProject(std::ostream& fout,
- const char* name, const char* path,
+ const std::string& name, const char* path,
cmTarget const& t);
virtual void WriteProjectDepends(std::ostream& fout,
- const char* name, const char* path,
+ const std::string& name, const char* path,
cmTarget const&t);
virtual void WriteProjectConfigurations(
- std::ostream& fout, const char* name, cmTarget::TargetType type,
+ std::ostream& fout, const std::string& name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
- const char* platformMapping = NULL);
+ const std::string& platformMapping = "");
virtual void WriteSLNGlobalSections(std::ostream& fout,
cmLocalGenerator* root);
virtual void WriteSLNFooter(std::ostream& fout);
@@ -153,18 +156,18 @@ protected:
void GenerateConfigurations(cmMakefile* mf);
virtual void WriteExternalProject(std::ostream& fout,
- const char* name,
+ const std::string& name,
const char* path,
const char* typeGuid,
- const std::set<cmStdString>&
+ const std::set<std::string>&
dependencies);
std::string ConvertToSolutionPath(const char* path);
- std::set<std::string> IsPartOfDefaultBuild(const char* project,
+ std::set<std::string> IsPartOfDefaultBuild(const std::string& project,
cmTarget const* target);
std::vector<std::string> Configurations;
- std::map<cmStdString, cmStdString> GUIDMap;
+ std::map<std::string, std::string> GUIDMap;
virtual void WriteFolders(std::ostream& fout);
virtual void WriteFoldersContent(std::ostream& fout);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 12c240b..e80df84 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -16,6 +16,7 @@
#include "cmVisualStudioWCEPlatformParser.h"
#include "cmake.h"
#include "cmGeneratedFileStream.h"
+#include "cmSourceFile.h"
static const char vs8generatorName[] = "Visual Studio 8 2005";
@@ -23,17 +24,19 @@ class cmGlobalVisualStudio8Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
- if(strstr(name, vs8generatorName) != name)
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const {
+ if(strncmp(name.c_str(), vs8generatorName,
+ sizeof(vs8generatorName) - 1) != 0)
{
return 0;
}
- const char* p = name + sizeof(vs8generatorName) - 1;
+ const char* p = name.c_str() + sizeof(vs8generatorName) - 1;
if(p[0] == '\0')
{
return new cmGlobalVisualStudio8Generator(
- name, NULL, NULL);
+ name, "", "");
}
if(p[0] != ' ')
@@ -57,7 +60,7 @@ public:
}
cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator(
- name, p, NULL);
+ name, p, "");
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
@@ -90,14 +93,14 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio8Generator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalVisualStudio8Generator::cmGlobalVisualStudio8Generator(
- const char* name, const char* platformName,
- const char* additionalPlatformDefinition)
+ const std::string& name, const std::string& platformName,
+ const std::string& additionalPlatformDefinition)
: cmGlobalVisualStudio71Generator(platformName)
{
this->ProjectConfigurationSectionName = "ProjectConfigurationPlatforms";
this->Name = name;
- if (additionalPlatformDefinition)
+ if (!additionalPlatformDefinition.empty())
{
this->AdditionalPlatformDefinition = additionalPlatformDefinition;
}
@@ -314,14 +317,14 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// file as the main dependency because it would get
// overwritten by the CreateVCProjBuildRule.
// (this could be avoided with per-target source files)
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
if(cmSourceFile* file =
mf->AddCustomCommandToOutput(
stamps, listFiles,
no_main_dependency, commandLines, "Checking Build System",
no_working_directory, true))
{
- tgt->AddSourceFile(file);
+ tgt->AddSource(file->GetFullPath());
}
else
{
@@ -338,7 +341,7 @@ void cmGlobalVisualStudio8Generator::Generate()
if(this->AddCheckTarget())
{
// All targets depend on the build-system check target.
- for(std::map<cmStdString,cmTarget *>::const_iterator
+ for(std::map<std::string,cmTarget *>::const_iterator
ti = this->TotalTargets.begin();
ti != this->TotalTargets.end(); ++ti)
{
@@ -372,9 +375,9 @@ cmGlobalVisualStudio8Generator
void
cmGlobalVisualStudio8Generator
::WriteProjectConfigurations(
- std::ostream& fout, const char* name, cmTarget::TargetType type,
+ std::ostream& fout, const std::string& name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
- const char* platformMapping)
+ std::string const& platformMapping)
{
std::string guid = this->GetGUID(name);
for(std::vector<std::string>::iterator i = this->Configurations.begin();
@@ -382,7 +385,8 @@ cmGlobalVisualStudio8Generator
{
fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".ActiveCfg = " << *i << "|"
- << (platformMapping ? platformMapping : this->GetPlatformName())
+ << (!platformMapping.empty()?
+ platformMapping : this->GetPlatformName())
<< "\n";
std::set<std::string>::const_iterator
ci = configsPartOfDefaultBuild.find(*i);
@@ -390,7 +394,8 @@ cmGlobalVisualStudio8Generator
{
fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".Build.0 = " << *i << "|"
- << (platformMapping ? platformMapping : this->GetPlatformName())
+ << (!platformMapping.empty()?
+ platformMapping : this->GetPlatformName())
<< "\n";
}
bool needsDeploy = (type == cmTarget::EXECUTABLE ||
@@ -399,7 +404,8 @@ cmGlobalVisualStudio8Generator
{
fout << "\t\t{" << guid << "}." << *i
<< "|" << this->GetPlatformName() << ".Deploy.0 = " << *i << "|"
- << (platformMapping ? platformMapping : this->GetPlatformName())
+ << (!platformMapping.empty()?
+ platformMapping : this->GetPlatformName())
<< "\n";
}
}
@@ -415,7 +421,7 @@ bool cmGlobalVisualStudio8Generator::ComputeTargetDepends()
//----------------------------------------------------------------------------
void cmGlobalVisualStudio8Generator::WriteProjectDepends(
- std::ostream& fout, const char*, const char*, cmTarget const& t)
+ std::ostream& fout, const std::string&, const char*, cmTarget const& t)
{
TargetDependSet const& unordered = this->GetTargetDirectDepends(t);
OrderedTargetDependSet depends(unordered);
@@ -426,7 +432,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectDepends(
{
continue;
}
- std::string guid = this->GetGUID((*i)->GetName());
+ std::string guid = this->GetGUID((*i)->GetName().c_str());
fout << "\t\t{" << guid << "} = {" << guid << "}\n";
}
}
@@ -436,11 +442,11 @@ bool cmGlobalVisualStudio8Generator::NeedLinkLibraryDependencies(
cmTarget& target)
{
// Look for utility dependencies that magically link.
- for(std::set<cmStdString>::const_iterator ui =
+ for(std::set<std::string>::const_iterator ui =
target.GetUtilities().begin();
ui != target.GetUtilities().end(); ++ui)
{
- if(cmTarget* depTarget = this->FindTarget(0, ui->c_str()))
+ if(cmTarget* depTarget = this->FindTarget(ui->c_str()))
{
if(depTarget->GetType() != cmTarget::INTERFACE_LIBRARY
&& depTarget->GetProperty("EXTERNAL_MSPROJECT"))
diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h
index 5b952c4..2459c05 100644
--- a/Source/cmGlobalVisualStudio8Generator.h
+++ b/Source/cmGlobalVisualStudio8Generator.h
@@ -23,12 +23,13 @@
class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator
{
public:
- cmGlobalVisualStudio8Generator(const char* name,
- const char* platformName, const char* additionalPlatformDefinition);
+ cmGlobalVisualStudio8Generator(const std::string& name,
+ const std::string& platformName,
+ const std::string& additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory();
///! Get the name for the generator.
- virtual const char* GetName() const {return this->Name.c_str();}
+ virtual std::string GetName() const {return this->Name;}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -79,11 +80,12 @@ protected:
virtual void WriteSLNHeader(std::ostream& fout);
virtual void WriteSolutionConfigurations(std::ostream& fout);
virtual void WriteProjectConfigurations(
- std::ostream& fout, const char* name, cmTarget::TargetType type,
+ std::ostream& fout, const std::string& name, cmTarget::TargetType type,
const std::set<std::string>& configsPartOfDefaultBuild,
- const char* platformMapping = NULL);
+ const std::string& platformMapping = "");
virtual bool ComputeTargetDepends();
- virtual void WriteProjectDepends(std::ostream& fout, const char* name,
+ virtual void WriteProjectDepends(std::ostream& fout,
+ const std::string& name,
const char* path, cmTarget const& t);
std::string Name;
diff --git a/Source/cmGlobalVisualStudio9Generator.cxx b/Source/cmGlobalVisualStudio9Generator.cxx
index ccc27ad..c0051c7 100644
--- a/Source/cmGlobalVisualStudio9Generator.cxx
+++ b/Source/cmGlobalVisualStudio9Generator.cxx
@@ -22,17 +22,19 @@ class cmGlobalVisualStudio9Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
- if(strstr(name, vs9generatorName) != name)
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const {
+ if(strncmp(name.c_str(), vs9generatorName,
+ sizeof(vs9generatorName) - 1) != 0)
{
return 0;
}
- const char* p = name + sizeof(vs9generatorName) - 1;
+ const char* p = name.c_str() + sizeof(vs9generatorName) - 1;
if(p[0] == '\0')
{
return new cmGlobalVisualStudio9Generator(
- name, NULL, NULL);
+ name, "", "");
}
if(p[0] != ' ')
@@ -96,8 +98,8 @@ cmGlobalGeneratorFactory* cmGlobalVisualStudio9Generator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalVisualStudio9Generator::cmGlobalVisualStudio9Generator(
- const char* name, const char* platformName,
- const char* additionalPlatformDefinition)
+ const std::string& name, const std::string& platformName,
+ const std::string& additionalPlatformDefinition)
: cmGlobalVisualStudio8Generator(name, platformName,
additionalPlatformDefinition)
{
diff --git a/Source/cmGlobalVisualStudio9Generator.h b/Source/cmGlobalVisualStudio9Generator.h
index 202aa8d..fb87bbe 100644
--- a/Source/cmGlobalVisualStudio9Generator.h
+++ b/Source/cmGlobalVisualStudio9Generator.h
@@ -24,8 +24,9 @@ class cmGlobalVisualStudio9Generator :
public cmGlobalVisualStudio8Generator
{
public:
- cmGlobalVisualStudio9Generator(const char* name,
- const char* platformName, const char* additionalPlatformDefinition);
+ cmGlobalVisualStudio9Generator(const std::string& name,
+ const std::string& platformName,
+ const std::string& additionalPlatformDefinition);
static cmGlobalGeneratorFactory* NewFactory();
///! create the correct local generator
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 0c5f35b..c5a0e29 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -1,3 +1,4 @@
+
/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
@@ -22,7 +23,7 @@
//----------------------------------------------------------------------------
cmGlobalVisualStudioGenerator::cmGlobalVisualStudioGenerator()
{
- this->AdditionalPlatformDefinition = NULL;
+ this->AdditionalPlatformDefinition = "";
}
//----------------------------------------------------------------------------
@@ -53,7 +54,7 @@ void cmGlobalVisualStudioGenerator::Generate()
const char* no_working_dir = 0;
std::vector<std::string> no_depends;
cmCustomCommandLines no_commands;
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+ std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
{
std::vector<cmLocalGenerator*>& gen = it->second;
@@ -118,51 +119,12 @@ void cmGlobalVisualStudioGenerator::Generate()
}
//----------------------------------------------------------------------------
-void
-cmGlobalVisualStudioGenerator
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
+void cmGlobalVisualStudioGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
{
- cmLocalVisualStudioGenerator* lg =
- static_cast<cmLocalVisualStudioGenerator*>(gt->LocalGenerator);
- std::string dir_max = lg->ComputeLongestObjectDirectory(*gt->Target);
-
- // Count the number of object files with each name. Note that
- // windows file names are not case sensitive.
- std::map<cmStdString, int> counts;
- std::vector<cmSourceFile*> objectSources;
- gt->GetObjectSources(objectSources);
- for(std::vector<cmSourceFile*>::const_iterator
- si = objectSources.begin();
- si != objectSources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- std::string objectNameLower = cmSystemTools::LowerCase(
- cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
- objectNameLower += ".obj";
- counts[objectNameLower] += 1;
- }
-
- // For all source files producing duplicate names we need unique
- // object name computation.
- for(std::vector<cmSourceFile*>::const_iterator
- si = objectSources.begin();
- si != objectSources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- std::string objectName =
- cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
- objectName += ".obj";
- if(counts[cmSystemTools::LowerCase(objectName)] > 1)
- {
- gt->AddExplicitObjectName(sf);
- objectName = lg->GetObjectFileNameWithoutTarget(*sf, dir_max);
- }
- gt->AddObject(sf, objectName);
- }
-
std::string dir = gt->Makefile->GetCurrentOutputDirectory();
dir += "/";
- std::string tgtDir = lg->GetTargetDirectory(*gt->Target);
+ std::string tgtDir = gt->LocalGenerator->GetTargetDirectory(*gt->Target);
if(!tgtDir.empty())
{
dir += tgtDir;
@@ -380,7 +342,7 @@ bool cmGlobalVisualStudioGenerator::ComputeTargetDepends()
{
return false;
}
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+ std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
{
std::vector<cmLocalGenerator*>& gen = it->second;
@@ -518,7 +480,7 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
//----------------------------------------------------------------------------
void cmGlobalVisualStudioGenerator::AddPlatformDefinitions(cmMakefile* mf)
{
- if(this->AdditionalPlatformDefinition)
+ if(!this->AdditionalPlatformDefinition.empty())
{
mf->AddDefinition(this->AdditionalPlatformDefinition, "TRUE");
}
@@ -852,8 +814,16 @@ bool
cmGlobalVisualStudioGenerator::TargetIsFortranOnly(cmTarget const& target)
{
// check to see if this is a fortran build
- std::set<cmStdString> languages;
- target.GetLanguages(languages);
+ std::set<std::string> languages;
+ {
+ // Issue diagnostic if the source files depend on the config.
+ std::vector<cmSourceFile*> sources;
+ if (!target.GetConfigCommonSourceFiles(sources))
+ {
+ return false;
+ }
+ }
+ target.GetLanguages(languages, "");
if(languages.size() == 1)
{
if(*languages.begin() == "Fortran")
@@ -870,15 +840,15 @@ cmGlobalVisualStudioGenerator::TargetCompare
::operator()(cmTarget const* l, cmTarget const* r) const
{
// Make sure ALL_BUILD is first so it is the default active project.
- if(strcmp(r->GetName(), "ALL_BUILD") == 0)
+ if(r->GetName() == "ALL_BUILD")
{
return false;
}
- if(strcmp(l->GetName(), "ALL_BUILD") == 0)
+ if(l->GetName() == "ALL_BUILD")
{
return true;
}
- return strcmp(l->GetName(), r->GetName()) < 0;
+ return strcmp(l->GetName().c_str(), r->GetName().c_str()) < 0;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index 9186d65..1ab8990 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -88,6 +88,7 @@ public:
virtual std::string ExpandCFGIntDir(const std::string& str,
const std::string& config) const;
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
protected:
// Does this VS version link targets to each other if there are
// dependencies in the SLN file? This was done for VS versions
@@ -99,23 +100,23 @@ protected:
virtual void AddPlatformDefinitions(cmMakefile* mf);
virtual bool ComputeTargetDepends();
- class VSDependSet: public std::set<cmStdString> {};
+ class VSDependSet: public std::set<std::string> {};
class VSDependMap: public std::map<cmTarget const*, VSDependSet> {};
VSDependMap VSTargetDepends;
void ComputeVSTargetDepends(cmTarget&);
- bool CheckTargetLinks(cmTarget& target, const char* name);
- std::string GetUtilityForTarget(cmTarget& target, const char*);
+ bool CheckTargetLinks(cmTarget& target, const std::string& name);
+ std::string GetUtilityForTarget(cmTarget& target, const std::string&);
virtual std::string WriteUtilityDepend(cmTarget const*) = 0;
std::string GetUtilityDepend(cmTarget const* target);
- typedef std::map<cmTarget const*, cmStdString> UtilityDependsMap;
+ typedef std::map<cmTarget const*, std::string> UtilityDependsMap;
UtilityDependsMap UtilityDepends;
- const char* AdditionalPlatformDefinition;
+ std::string AdditionalPlatformDefinition;
private:
virtual std::string GetVSMakeProgram() = 0;
- void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {}
- void ComputeTargetObjects(cmGeneratorTarget* gt) const;
+ void PrintCompilerAdvice(std::ostream&, std::string const&,
+ const char*) const {}
void FollowLinkDepends(cmTarget const* target,
std::set<cmTarget const*>& linked);
diff --git a/Source/cmGlobalWatcomWMakeGenerator.cxx b/Source/cmGlobalWatcomWMakeGenerator.cxx
index 98ce685..e44ed79 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.cxx
+++ b/Source/cmGlobalWatcomWMakeGenerator.cxx
@@ -16,7 +16,9 @@
cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
{
this->FindMakeProgramFile = "CMakeFindWMake.cmake";
+#ifdef _WIN32
this->ForceUnixPaths = false;
+#endif
this->ToolSupportsColor = true;
this->NeedSymbolicMark = true;
this->EmptyRuleHackCommand = "@cd .";
@@ -33,7 +35,6 @@ void cmGlobalWatcomWMakeGenerator
mf->AddDefinition("CMAKE_MANGLE_OBJECT_FILE_NAMES", "1");
mf->AddDefinition("CMAKE_MAKE_LINE_CONTINUE", "&");
mf->AddDefinition("CMAKE_MAKE_SYMBOLIC_RULE", ".SYMBOLIC");
- mf->AddDefinition("CMAKE_NO_QUOTED_OBJECTS", "1");
mf->AddDefinition("CMAKE_GENERATOR_CC", "wcl386");
mf->AddDefinition("CMAKE_GENERATOR_CXX", "wcl386");
this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional);
@@ -43,11 +44,12 @@ void cmGlobalWatcomWMakeGenerator
cmLocalGenerator *cmGlobalWatcomWMakeGenerator::CreateLocalGenerator()
{
cmLocalUnixMakefileGenerator3* lg = new cmLocalUnixMakefileGenerator3;
- lg->SetSilentNoColon(true);
lg->SetDefineWindowsNULL(true);
+#ifdef _WIN32
lg->SetWindowsShell(true);
+#endif
lg->SetWatcomWMake(true);
- lg->SetMakeSilentFlag("-s -h -e");
+ lg->SetMakeSilentFlag("-h");
lg->SetGlobalGenerator(this);
lg->SetIgnoreLibPrefix(true);
lg->SetPassMakeflags(false);
diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h
index d5350ef..2057a42 100644
--- a/Source/cmGlobalWatcomWMakeGenerator.h
+++ b/Source/cmGlobalWatcomWMakeGenerator.h
@@ -27,9 +27,9 @@ public:
return new cmGlobalGeneratorSimpleFactory
<cmGlobalWatcomWMakeGenerator>(); }
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalWatcomWMakeGenerator::GetActualName();}
- static const char* GetActualName() {return "Watcom WMake";}
+ static std::string GetActualName() {return "Watcom WMake";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 484b28f..b3975b4 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -34,17 +34,17 @@ class cmXcodeVersionParser : public cmXMLParser
{
public:
cmXcodeVersionParser(): Version("1.5") {}
- void StartElement(const char* , const char** )
+ void StartElement(const std::string&, const char**)
{
this->Data = "";
}
- void EndElement(const char* name)
+ void EndElement(const std::string& name)
{
- if(strcmp(name, "key") == 0)
+ if(name == "key")
{
this->Key = this->Data;
}
- else if(strcmp(name, "string") == 0)
+ else if(name == "string")
{
if(this->Key == "CFBundleShortVersionString")
{
@@ -116,7 +116,8 @@ public:
class cmGlobalXCodeGenerator::Factory : public cmGlobalGeneratorFactory
{
public:
- virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const;
+ virtual cmGlobalGenerator* CreateGlobalGenerator(
+ const std::string& name) const;
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
cmGlobalXCodeGenerator::GetDocumentation(entry); }
@@ -152,9 +153,9 @@ cmGlobalGeneratorFactory* cmGlobalXCodeGenerator::NewFactory()
//----------------------------------------------------------------------------
cmGlobalGenerator* cmGlobalXCodeGenerator::Factory
-::CreateGlobalGenerator(const char* name) const
+::CreateGlobalGenerator(const std::string& name) const
{
- if (strcmp(name, GetActualName()))
+ if (name != GetActualName())
return 0;
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmXcodeVersionParser parser;
@@ -260,11 +261,11 @@ void cmGlobalXCodeGenerator::EnableLanguage(std::vector<std::string>const&
void
cmGlobalXCodeGenerator::GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* /*projectDir*/,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& /*projectDir*/,
+ const std::string& targetName,
+ const std::string& config,
bool /*fast*/,
std::vector<std::string> const& makeOptions)
{
@@ -283,10 +284,11 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
makeCommand.push_back(projectArg);
bool clean = false;
- if ( targetName && strcmp(targetName, "clean") == 0 )
+ std::string realTarget = targetName;
+ if ( realTarget == "clean" )
{
clean = true;
- targetName = "ALL_BUILD";
+ realTarget = "ALL_BUILD";
}
if(clean)
{
@@ -297,14 +299,9 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
makeCommand.push_back("build");
}
makeCommand.push_back("-target");
- // if it is a null string for config don't use it
- if(config && *config == 0)
+ if (!realTarget.empty())
{
- config = 0;
- }
- if (targetName && strlen(targetName))
- {
- makeCommand.push_back(targetName);
+ makeCommand.push_back(realTarget);
}
else
{
@@ -318,7 +315,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand(
else
{
makeCommand.push_back("-configuration");
- makeCommand.push_back(config?config:"Debug");
+ makeCommand.push_back(!config.empty()?config:"Debug");
}
makeCommand.insert(makeCommand.end(),
makeOptions.begin(), makeOptions.end());
@@ -336,7 +333,7 @@ cmLocalGenerator *cmGlobalXCodeGenerator::CreateLocalGenerator()
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::Generate()
{
- std::map<cmStdString, std::vector<cmLocalGenerator*> >::iterator it;
+ std::map<std::string, std::vector<cmLocalGenerator*> >::iterator it;
// make sure extra targets are added before calling
// the parent generate which will call trace depends
for(it = this->ProjectMap.begin(); it!= this->ProjectMap.end(); ++it)
@@ -346,7 +343,6 @@ void cmGlobalXCodeGenerator::Generate()
// add ALL_BUILD, INSTALL, etc
this->AddExtraTargets(root, it->second);
}
- this->ForceLinkerLanguages();
this->cmGlobalGenerator::Generate();
if(cmSystemTools::GetErrorOccuredFlag())
{
@@ -415,7 +411,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
std::string listfile = mf->GetStartDirectory();
listfile += "/";
listfile += "CMakeLists.txt";
- allbuild->AddSource(listfile.c_str());
+ allbuild->AddSourceCMP0049(listfile.c_str());
// Add XCODE depend helper
std::string dir = mf->GetCurrentOutputDirectory();
@@ -498,7 +494,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root,
listfile = lg->GetMakefile()->GetStartDirectory();
listfile += "/";
listfile += "CMakeLists.txt";
- target.AddSource(listfile.c_str());
+ target.AddSourceCMP0049(listfile.c_str());
}
}
}
@@ -569,7 +565,7 @@ void cmGlobalXCodeGenerator::addObject(cmXCodeObject *obj)
{
if(obj->GetType() == cmXCodeObject::OBJECT)
{
- cmStdString id = obj->GetId();
+ std::string id = obj->GetId();
// If this is a duplicate id, it's an error:
//
@@ -613,7 +609,7 @@ cmGlobalXCodeGenerator::CreateObject(cmXCodeObject::Type type)
//----------------------------------------------------------------------------
cmXCodeObject*
-cmGlobalXCodeGenerator::CreateString(const char* s)
+cmGlobalXCodeGenerator::CreateString(const std::string& s)
{
cmXCodeObject* obj = this->CreateObject(cmXCodeObject::STRING);
obj->SetString(s);
@@ -630,17 +626,17 @@ cmXCodeObject* cmGlobalXCodeGenerator
}
//----------------------------------------------------------------------------
-cmStdString
+std::string
GetGroupMapKeyFromPath(cmTarget& cmtarget, const std::string& fullpath)
{
- cmStdString key(cmtarget.GetName());
+ std::string key(cmtarget.GetName());
key += "-";
key += fullpath;
return key;
}
//----------------------------------------------------------------------------
-cmStdString
+std::string
GetGroupMapKey(cmTarget& cmtarget, cmSourceFile* sf)
{
return GetGroupMapKeyFromPath(cmtarget, sf->GetFullPath());
@@ -696,12 +692,8 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
flags += flagsBuild.GetString();
}
- const char* lang =
+ std::string lang =
this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
- if (!lang)
- {
- lang = "";
- }
cmXCodeObject* buildFile =
this->CreateXCodeSourceFileFromPath(sf->GetFullPath(), cmtarget, lang);
@@ -713,22 +705,23 @@ cmGlobalXCodeGenerator::CreateXCodeSourceFile(cmLocalGenerator* lg,
// Is this a resource file in this target? Add it to the resources group...
//
- cmTarget::SourceFileFlags tsFlags = cmtarget.GetTargetSourceFileFlags(sf);
- bool isResource = (tsFlags.Type == cmTarget::SourceFileTypeResource);
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ this->GetGeneratorTarget(&cmtarget)->GetTargetSourceFileFlags(sf);
+ bool isResource = tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource;
// Is this a "private" or "public" framework header file?
// Set the ATTRIBUTES attribute appropriately...
//
if(cmtarget.IsFrameworkOnApple())
{
- if(tsFlags.Type == cmTarget::SourceFileTypePrivateHeader)
+ if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader)
{
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
attrs->AddObject(this->CreateString("Private"));
settings->AddAttribute("ATTRIBUTES", attrs);
isResource = true;
}
- else if(tsFlags.Type == cmTarget::SourceFileTypePublicHeader)
+ else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader)
{
cmXCodeObject* attrs = this->CreateObject(cmXCodeObject::OBJECT_LIST);
attrs->AddObject(this->CreateString("Public"));
@@ -846,7 +839,7 @@ cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
fileRef->SetComment(fname.c_str());
this->FileRefs[fname] = fileRef;
}
- cmStdString key = GetGroupMapKeyFromPath(cmtarget, fullpath);
+ std::string key = GetGroupMapKeyFromPath(cmtarget, fullpath);
cmXCodeObject* group = this->GroupMap[key];
cmXCodeObject* children = group->GetObject("children");
if (!children->HasObject(fileRef))
@@ -905,12 +898,8 @@ cmXCodeObject*
cmGlobalXCodeGenerator::CreateXCodeFileReference(cmSourceFile* sf,
cmTarget& cmtarget)
{
- const char* lang =
+ std::string lang =
this->CurrentLocalGenerator->GetSourceFileLanguage(*sf);
- if (!lang)
- {
- lang = "";
- }
return this->CreateXCodeFileReferenceFromPath(
sf->GetFullPath(), cmtarget, lang);
@@ -973,6 +962,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
for(cmTargets::iterator l = tgts.begin(); l != tgts.end(); l++)
{
cmTarget& cmtarget = l->second;
+ cmGeneratorTarget* gtgt = this->GetGeneratorTarget(&cmtarget);
// make sure ALL_BUILD, INSTALL, etc are only done once
if(this->SpecialTargetEmitted(l->first.c_str()))
@@ -994,9 +984,14 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// organize the sources
std::vector<cmSourceFile*> classes;
- cmtarget.GetSourceFiles(classes);
+ if (!cmtarget.GetConfigCommonSourceFiles(classes))
+ {
+ return;
+ }
std::sort(classes.begin(), classes.end(), cmSourceFilePathCompare());
+ gtgt->ComputeObjectMapping();
+
std::vector<cmXCodeObject*> externalObjFiles;
std::vector<cmXCodeObject*> headerFiles;
std::vector<cmXCodeObject*> resourceFiles;
@@ -1011,21 +1006,24 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
cmXCodeObject* filetype =
fr->GetObject()->GetObject("explicitFileType");
- cmTarget::SourceFileFlags tsFlags =
- cmtarget.GetTargetSourceFileFlags(*i);
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(*i);
if(filetype &&
- strcmp(filetype->GetString(), "compiled.mach-o.objfile") == 0)
+ filetype->GetString() == "compiled.mach-o.objfile")
{
- externalObjFiles.push_back(xsf);
+ if ((*i)->GetObjectLibrary().empty())
+ {
+ externalObjFiles.push_back(xsf);
+ }
}
else if(this->IsHeaderFile(*i) ||
- (tsFlags.Type == cmTarget::SourceFileTypePrivateHeader) ||
- (tsFlags.Type == cmTarget::SourceFileTypePublicHeader))
+ (tsFlags.Type == cmGeneratorTarget::SourceFileTypePrivateHeader) ||
+ (tsFlags.Type == cmGeneratorTarget::SourceFileTypePublicHeader))
{
headerFiles.push_back(xsf);
}
- else if(tsFlags.Type == cmTarget::SourceFileTypeResource)
+ else if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeResource)
{
resourceFiles.push_back(xsf);
}
@@ -1034,7 +1032,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// Include this file in the build if it has a known language
// and has not been listed as an ignored extension for this
// generator.
- if(this->CurrentLocalGenerator->GetSourceFileLanguage(**i) &&
+ if(!this->CurrentLocalGenerator->GetSourceFileLanguage(**i).empty() &&
!this->IgnoreFile((*i)->GetExtension().c_str()))
{
sourceFiles.push_back(xsf);
@@ -1048,7 +1046,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
// the externalObjFiles above, except each one is not a cmSourceFile
// within the target.)
std::vector<std::string> objs;
- this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
+ gtgt->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
{
@@ -1132,15 +1130,15 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
std::vector<cmXCodeObject*> contentBuildPhases;
if (isFrameworkTarget || isBundleTarget || isCFBundleTarget)
{
- typedef std::map<cmStdString, std::vector<cmSourceFile*> >
+ typedef std::map<std::string, std::vector<cmSourceFile*> >
mapOfVectorOfSourceFiles;
mapOfVectorOfSourceFiles bundleFiles;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i)
{
- cmTarget::SourceFileFlags tsFlags =
- cmtarget.GetTargetSourceFileFlags(*i);
- if(tsFlags.Type == cmTarget::SourceFileTypeMacContent)
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ gtgt->GetTargetSourceFileFlags(*i);
+ if(tsFlags.Type == cmGeneratorTarget::SourceFileTypeMacContent)
{
bundleFiles[tsFlags.MacFolder].push_back(*i);
}
@@ -1221,7 +1219,7 @@ cmGlobalXCodeGenerator::CreateXCodeTargets(cmLocalGenerator* gen,
void cmGlobalXCodeGenerator::ForceLinkerLanguages()
{
// This makes sure all targets link using the proper language.
- for(std::map<cmStdString, cmTarget*>::const_iterator
+ for(std::map<std::string, cmTarget*>::const_iterator
ti = this->TotalTargets.begin(); ti != this->TotalTargets.end(); ++ti)
{
this->ForceLinkerLanguage(*ti->second);
@@ -1239,8 +1237,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
return;
}
- const char* llang = cmtarget.GetLinkerLanguage("NOCONFIG");
- if(!llang) { return; }
+ std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG");
+ if(llang.empty()) { return; }
// If the language is compiled as a source trust Xcode to link with it.
cmTarget::LinkImplementation const* impl =
@@ -1268,8 +1266,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget)
}
if(cmSourceFile* sf = mf->GetOrCreateSource(fname.c_str()))
{
- sf->SetProperty("LANGUAGE", llang);
- cmtarget.AddSourceFile(sf);
+ sf->SetProperty("LANGUAGE", llang.c_str());
+ cmtarget.AddSource(fname);
}
}
@@ -1364,7 +1362,10 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(cmXCodeObject* buildPhases,
}
std::vector<cmSourceFile*> classes;
- cmtarget.GetSourceFiles(classes);
+ if (!cmtarget.GetConfigCommonSourceFiles(classes))
+ {
+ return;
+ }
// add all the sources
std::vector<cmCustomCommand> commands;
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
@@ -1479,32 +1480,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
const & commands,
const char* name)
{
-
- // collect multiple outputs of custom commands into a set
- // which will be used for every configuration
- std::map<cmStdString, cmStdString> multipleOutputPairs;
- for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
- i != commands.end(); ++i)
- {
- cmCustomCommand const& cc = *i;
- if(!cc.GetCommandLines().empty())
- {
- const std::vector<std::string>& outputs = cc.GetOutputs();
- if(!outputs.empty())
- {
- // If there are more than one outputs 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;
- }
- }
- }
- }
-
+ bool haveMultipleOutputPairs = false;
std::string dir = this->CurrentMakefile->GetCurrentOutputDirectory();
dir += "/CMakeScripts";
cmSystemTools::MakeDirectory(dir.c_str());
@@ -1524,7 +1500,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
target,
commands,
currentConfig->c_str(),
- multipleOutputPairs);
+ haveMultipleOutputPairs);
}
std::string cdir = this->CurrentMakefile->GetCurrentOutputDirectory();
@@ -1534,7 +1510,7 @@ cmGlobalXCodeGenerator::AddCommandsToBuildPhase(cmXCodeObject* buildphase,
makecmd += " -f ";
makecmd += this->ConvertToRelativeForMake(
(makefile+"$CONFIGURATION").c_str());
- if(!multipleOutputPairs.empty())
+ if(haveMultipleOutputPairs)
{
makecmd += " cmake_check_multiple_outputs";
}
@@ -1552,10 +1528,8 @@ void cmGlobalXCodeGenerator
cmTarget& target,
std::vector<cmCustomCommand>
const & commands,
- const char* configName,
- const std::map<cmStdString,
- cmStdString>& multipleOutputPairs
- )
+ const std::string& configName,
+ bool& haveMultipleOutputPairs)
{
std::string makefileName=makefileBasename;
if(this->XcodeVersion > 20)
@@ -1576,15 +1550,16 @@ void cmGlobalXCodeGenerator
// have all depend on all outputs
makefileStream << "all: ";
- std::map<const cmCustomCommand*, cmStdString> tname;
+ 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)
{
- cmCustomCommand const& cc = *i;
- if(!cc.GetCommandLines().empty())
+ cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
+ if(ccg.GetNumberOfCommands() > 0)
{
- const std::vector<std::string>& outputs = cc.GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty())
{
for(std::vector<std::string>::const_iterator o = outputs.begin();
@@ -1593,13 +1568,23 @@ 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;
str << "_buildpart_" << count++ ;
- tname[&cc] = std::string(target.GetName()) + str.str();
- makefileStream << "\\\n\t" << tname[&cc];
+ tname[&ccg.GetCC()] = std::string(target.GetName()) + str.str();
+ makefileStream << "\\\n\t" << tname[&ccg.GetCC()];
}
}
}
@@ -1607,12 +1592,11 @@ void cmGlobalXCodeGenerator
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
- cmCustomCommand const& cc = *i;
- if(!cc.GetCommandLines().empty())
+ cmCustomCommandGenerator ccg(*i, configName, this->CurrentMakefile);
+ if(ccg.GetNumberOfCommands() > 0)
{
- cmCustomCommandGenerator ccg(cc, configName, this->CurrentMakefile);
makefileStream << "\n";
- const std::vector<std::string>& outputs = cc.GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty())
{
// There is at least one output, start the rule for it
@@ -1623,11 +1607,11 @@ void cmGlobalXCodeGenerator
else
{
// There are no outputs. Use the generated force rule name.
- makefileStream << tname[&cc] << ": ";
+ makefileStream << tname[&ccg.GetCC()] << ": ";
}
for(std::vector<std::string>::const_iterator d =
- cc.GetDepends().begin();
- d != cc.GetDepends().end(); ++d)
+ ccg.GetDepends().begin();
+ d != ccg.GetDepends().end(); ++d)
{
std::string dep;
if(this->CurrentLocalGenerator
@@ -1639,11 +1623,11 @@ void cmGlobalXCodeGenerator
}
makefileStream << "\n";
- if(const char* comment = cc.GetComment())
+ if(const char* comment = ccg.GetComment())
{
std::string echo_cmd = "echo ";
echo_cmd += (this->CurrentLocalGenerator->
- EscapeForShell(comment, cc.GetEscapeAllowMakeVars()));
+ EscapeForShell(comment, ccg.GetCC().GetEscapeAllowMakeVars()));
makefileStream << "\t" << echo_cmd.c_str() << "\n";
}
@@ -1655,10 +1639,11 @@ void cmGlobalXCodeGenerator
cmSystemTools::ReplaceString(cmd2, "/./", "/");
cmd2 = this->ConvertToRelativeForMake(cmd2.c_str());
std::string cmd;
- if(cc.GetWorkingDirectory())
+ std::string wd = ccg.GetWorkingDirectory();
+ if(!wd.empty())
{
cmd += "cd ";
- cmd += this->ConvertToRelativeForMake(cc.GetWorkingDirectory());
+ cmd += this->ConvertToRelativeForMake(wd.c_str());
cmd += " && ";
}
cmd += cmd2;
@@ -1674,7 +1659,7 @@ void cmGlobalXCodeGenerator
makefileStream <<
"\n# Dependencies of multiple outputs to their primary outputs \n";
- for(std::map<cmStdString, cmStdString>::const_iterator o =
+ for(std::map<std::string, std::string>::const_iterator o =
multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o)
{
makefileStream << o->first << ": " << o->second << "\n";
@@ -1683,7 +1668,7 @@ void cmGlobalXCodeGenerator
makefileStream <<
"\n"
"cmake_check_multiple_outputs:\n";
- for(std::map<cmStdString, cmStdString>::const_iterator o =
+ for(std::map<std::string, std::string>::const_iterator o =
multipleOutputPairs.begin(); o != multipleOutputPairs.end(); ++o)
{
makefileStream << "\t@if [ ! -f "
@@ -1691,12 +1676,15 @@ void cmGlobalXCodeGenerator
<< o->second << "; fi\n";
}
}
+
+ haveMultipleOutputPairs =
+ haveMultipleOutputPairs || !multipleOutputPairs.empty();
}
//----------------------------------------------------------------------------
void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
- cmXCodeObject* buildSettings,
- const char* configName)
+ cmXCodeObject* buildSettings,
+ const std::string& configName)
{
if(target.GetType() == cmTarget::INTERFACE_LIBRARY)
{
@@ -1712,12 +1700,12 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
(target.GetType() == cmTarget::EXECUTABLE) ||
shared);
- const char* lang = target.GetLinkerLanguage(configName);
+ std::string lang = target.GetLinkerLanguage(configName);
std::string cflags;
- if(lang)
+ if(!lang.empty())
{
// for c++ projects get the c flags as well
- if(strcmp(lang, "CXX") == 0)
+ if(lang == "CXX")
{
this->CurrentLocalGenerator->AddLanguageFlags(cflags, "C", configName);
this->CurrentLocalGenerator->AddCMP0018Flags(cflags, &target,
@@ -1743,7 +1731,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
- target.GetName());
+ target.GetName().c_str());
return;
}
@@ -1809,7 +1797,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
this->CurrentLocalGenerator->
AppendFlags(extraLinkOptions, targetLinkFlags);
}
- if(configName && *configName)
+ if(!configName.empty())
{
std::string linkFlagsVar = "LINK_FLAGS_";
linkFlagsVar += cmSystemTools::UpperCase(configName);
@@ -2093,7 +2081,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
std::vector<std::string> includes;
this->CurrentLocalGenerator->GetIncludeDirectories(includes, gtgt,
"C", configName);
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
emitted.insert("/System/Library/Frameworks");
for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i)
@@ -2176,7 +2164,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
const char* debugStr = "YES";
// We can't set the Xcode flag differently depending on the language,
// so put them back in this case.
- if( (lang && strcmp(lang, "CXX") == 0) && gflag != gflagc )
+ if( (lang == "CXX") && gflag != gflagc )
{
cflags += " ";
cflags += gflagc;
@@ -2199,7 +2187,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
this->CreateString("NO"));
buildSettings->AddAttribute("GCC_INLINES_ARE_PRIVATE_EXTERN",
this->CreateString("NO"));
- if(lang && strcmp(lang, "CXX") == 0)
+ if(lang == "CXX")
{
flags += " ";
flags += defFlags;
@@ -2362,18 +2350,18 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target,
{
if(i->first.find("XCODE_ATTRIBUTE_") == 0)
{
- cmStdString attribute = i->first.substr(16);
+ std::string attribute = i->first.substr(16);
// Handle [variant=<config>] condition explicitly here.
- cmStdString::size_type beginVariant =
+ std::string::size_type beginVariant =
attribute.find("[variant=");
- if (beginVariant != cmStdString::npos)
+ if (beginVariant != std::string::npos)
{
- cmStdString::size_type endVariant =
+ std::string::size_type endVariant =
attribute.find("]", beginVariant+9);
- if (endVariant != cmStdString::npos)
+ if (endVariant != std::string::npos)
{
// Compare the variant to the configuration.
- cmStdString variant =
+ std::string variant =
attribute.substr(beginVariant+9, endVariant-beginVariant-9);
if (variant == configName)
{
@@ -2426,7 +2414,7 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
cmXCodeObject* target =
this->CreateObject(cmXCodeObject::PBXAggregateTarget);
- target->SetComment(cmtarget.GetName());
+ target->SetComment(cmtarget.GetName().c_str());
cmXCodeObject* buildPhases =
this->CreateObject(cmXCodeObject::OBJECT_LIST);
std::vector<cmXCodeObject*> emptyContentVector;
@@ -2457,7 +2445,11 @@ cmGlobalXCodeGenerator::CreateUtilityTarget(cmTarget& cmtarget)
if(cmtarget.GetType() == cmTarget::UTILITY)
{
std::vector<cmSourceFile*> sources;
- cmtarget.GetSourceFiles(sources);
+ if (!cmtarget.GetConfigCommonSourceFiles(sources))
+ {
+ return 0;
+ }
+
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i)
{
@@ -2627,7 +2619,7 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget,
fileRef->AddAttribute("refType", this->CreateString("0"));
fileRef->AddAttribute("sourceTree",
this->CreateString("BUILT_PRODUCTS_DIR"));
- fileRef->SetComment(cmtarget.GetName());
+ fileRef->SetComment(cmtarget.GetName().c_str());
target->AddAttribute("productReference",
this->CreateObjectReference(fileRef));
if(const char* productType = this->GetTargetProductType(cmtarget))
@@ -2660,8 +2652,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::FindXCodeTarget(cmTarget const* t)
}
//----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
- const char* id)
+std::string cmGlobalXCodeGenerator::GetOrCreateId(const std::string& name,
+ const std::string& id)
{
std::string guidStoreName = name;
guidStoreName += "_GUID_CMAKE";
@@ -2674,7 +2666,7 @@ std::string cmGlobalXCodeGenerator::GetOrCreateId(const char* name,
}
this->CMakeInstance->AddCacheEntry(guidStoreName.c_str(),
- id, "Stored Xcode object GUID", cmCacheManager::INTERNAL);
+ id.c_str(), "Stored Xcode object GUID", cmCacheManager::INTERNAL);
return id;
}
@@ -2743,7 +2735,7 @@ void cmGlobalXCodeGenerator
::AppendBuildSettingAttribute(cmXCodeObject* target,
const char* attribute,
const char* value,
- const char* configName)
+ const std::string& configName)
{
if(this->XcodeVersion < 21)
{
@@ -2766,9 +2758,9 @@ void cmGlobalXCodeGenerator
for(std::vector<cmXCodeObject*>::iterator i = list.begin();
i != list.end(); ++i)
{
- if(configName)
+ if(!configName.empty())
{
- if(strcmp((*i)->GetObject("name")->GetString(), configName) == 0)
+ if((*i)->GetObject("name")->GetString() == configName)
{
cmXCodeObject* settings = (*i)->GetObject("buildSettings");
this->AppendOrAddBuildSetting(settings, attribute, value);
@@ -2826,7 +2818,7 @@ void cmGlobalXCodeGenerator
std::string linkObjs;
const char* sep = "";
std::vector<std::string> objs;
- this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs);
+ this->GetGeneratorTarget(cmtarget)->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
{
@@ -2956,13 +2948,15 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
if(cmtarget.GetPropertyAsBool("MACOSX_BUNDLE"))
{
std::string plist = this->ComputeInfoPListLocation(cmtarget);
- cmSourceFile* sf = mf->GetOrCreateSource(plist.c_str(), true);
- cmtarget.AddSourceFile(sf);
+ mf->GetOrCreateSource(plist, true);
+ cmtarget.AddSource(plist);
}
std::vector<cmSourceFile*> classes;
- cmtarget.GetSourceFiles(classes);
-
+ if (!cmtarget.GetConfigCommonSourceFiles(classes))
+ {
+ return;
+ }
// Put cmSourceFile instances in proper groups:
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
s != classes.end(); s++)
@@ -2974,13 +2968,13 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
mf->FindSourceGroup(source.c_str(), sourceGroups);
cmXCodeObject* pbxgroup =
this->CreateOrGetPBXGroup(cmtarget, sourceGroup);
- cmStdString key = GetGroupMapKey(cmtarget, sf);
+ std::string key = GetGroupMapKey(cmtarget, sf);
this->GroupMap[key] = pbxgroup;
}
// Put OBJECT_LIBRARY objects in proper groups:
std::vector<std::string> objs;
- this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs);
+ this->GetGeneratorTarget(&cmtarget)->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
{
@@ -2989,7 +2983,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
mf->FindSourceGroup(source.c_str(), sourceGroups);
cmXCodeObject* pbxgroup =
this->CreateOrGetPBXGroup(cmtarget, sourceGroup);
- cmStdString key = GetGroupMapKeyFromPath(cmtarget, source);
+ std::string key = GetGroupMapKeyFromPath(cmtarget, source);
this->GroupMap[key] = pbxgroup;
}
}
@@ -2997,7 +2991,7 @@ void cmGlobalXCodeGenerator::CreateGroups(cmLocalGenerator* root,
}
cmXCodeObject *cmGlobalXCodeGenerator
-::CreatePBXGroup(cmXCodeObject *parent, cmStdString name)
+::CreatePBXGroup(cmXCodeObject *parent, std::string name)
{
cmXCodeObject* parentChildren = NULL;
if(parent)
@@ -3021,8 +3015,8 @@ cmXCodeObject *cmGlobalXCodeGenerator
cmXCodeObject* cmGlobalXCodeGenerator
::CreateOrGetPBXGroup(cmTarget& cmtarget, cmSourceGroup* sg)
{
- cmStdString s;
- cmStdString target;
+ std::string s;
+ std::string target;
const char *targetFolder= cmtarget.GetProperty("FOLDER");
if(targetFolder) {
target = targetFolder;
@@ -3031,7 +3025,7 @@ cmXCodeObject* cmGlobalXCodeGenerator
target += cmtarget.GetName();
s = target + "/";
s += sg->GetFullName();
- std::map<cmStdString, cmXCodeObject* >::iterator it =
+ std::map<std::string, cmXCodeObject* >::iterator it =
this->GroupNameMap.find(s);
if(it != this->GroupNameMap.end())
{
@@ -3048,7 +3042,7 @@ cmXCodeObject* cmGlobalXCodeGenerator
{
std::vector<std::string> tgt_folders =
cmSystemTools::tokenize(target, "/");
- cmStdString curr_tgt_folder;
+ std::string curr_tgt_folder;
for(std::vector<std::string>::size_type i = 0; i < tgt_folders.size();i++)
{
if (i != 0)
@@ -3075,7 +3069,7 @@ cmXCodeObject* cmGlobalXCodeGenerator
// If it's the default source group (empty name) then put the source file
// directly in the tgroup...
//
- if (cmStdString(sg->GetFullName()) == "")
+ if (std::string(sg->GetFullName()) == "")
{
this->GroupNameMap[s] = tgroup;
return tgroup;
@@ -3086,12 +3080,12 @@ cmXCodeObject* cmGlobalXCodeGenerator
{
std::vector<std::string> folders =
cmSystemTools::tokenize(sg->GetFullName(), "\\");
- cmStdString curr_folder = target;
+ std::string curr_folder = target;
curr_folder += "/";
for(std::vector<std::string>::size_type i = 0; i < folders.size();i++)
{
curr_folder += folders[i];
- std::map<cmStdString, cmXCodeObject* >::iterator i_folder =
+ std::map<std::string, cmXCodeObject* >::iterator i_folder =
this->GroupNameMap.find(curr_folder);
//Create new folder
if(i_folder == this->GroupNameMap.end())
@@ -3471,14 +3465,14 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
makefileStream
<< "# For each target create a dummy rule "
"so the target does not have to exist\n";
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
for(std::vector<cmXCodeObject*>::iterator i = targets.begin();
i != targets.end(); ++i)
{
cmXCodeObject* target = *i;
- std::map<cmStdString, cmXCodeObject::StringVec> const& deplibs =
+ std::map<std::string, cmXCodeObject::StringVec> const& deplibs =
target->GetDependLibraries();
- for(std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator ci
+ for(std::map<std::string, cmXCodeObject::StringVec>::const_iterator ci
= deplibs.begin(); ci != deplibs.end(); ++ci)
{
for(cmXCodeObject::StringVec::const_iterator d = ci->second.begin();
@@ -3534,12 +3528,12 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
std::string trel = this->ConvertToRelativeForMake(tfull.c_str());
// Add this target to the post-build phases of its dependencies.
- std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator
+ std::map<std::string, cmXCodeObject::StringVec>::const_iterator
y = target->GetDependTargets().find(*ct);
if(y != target->GetDependTargets().end())
{
- std::vector<cmStdString> const& deptgts = y->second;
- for(std::vector<cmStdString>::const_iterator d = deptgts.begin();
+ std::vector<std::string> const& deptgts = y->second;
+ for(std::vector<std::string>::const_iterator d = deptgts.begin();
d != deptgts.end(); ++d)
{
makefileStream << this->PostBuildMakeTarget(*d, *ct) << ": "
@@ -3551,12 +3545,12 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget(
makefileStream << trel << ":";
// List dependencies if any exist.
- std::map<cmStdString, cmXCodeObject::StringVec>::const_iterator
+ std::map<std::string, cmXCodeObject::StringVec>::const_iterator
x = target->GetDependLibraries().find(*ct);
if(x != target->GetDependLibraries().end())
{
- std::vector<cmStdString> const& deplibs = x->second;
- for(std::vector<cmStdString>::const_iterator d = deplibs.begin();
+ std::vector<std::string> const& deplibs = x->second;
+ for(std::vector<std::string>::const_iterator d = deplibs.begin();
d != deplibs.end(); ++d)
{
makefileStream << "\\\n\t" <<
@@ -3781,14 +3775,14 @@ std::string cmGlobalXCodeGenerator::XCodeEscapePath(const char* p)
//----------------------------------------------------------------------------
void
cmGlobalXCodeGenerator
-::AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+::AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir)
{
if(this->XcodeVersion > 20)
{
- if(config)
+ if(!config.empty())
{
dir += prefix;
dir += config;
@@ -3798,12 +3792,13 @@ cmGlobalXCodeGenerator
}
//----------------------------------------------------------------------------
-std::string cmGlobalXCodeGenerator::LookupFlags(const char* varNamePrefix,
- const char* varNameLang,
- const char* varNameSuffix,
- const char* default_flags)
+std::string cmGlobalXCodeGenerator::LookupFlags(
+ const std::string& varNamePrefix,
+ const std::string& varNameLang,
+ const std::string& varNameSuffix,
+ const std::string& default_flags)
{
- if(varNameLang)
+ if(!varNameLang.empty())
{
std::string varName = varNamePrefix;
varName += varNameLang;
@@ -3955,37 +3950,10 @@ bool cmGlobalXCodeGenerator::IsMultiConfig()
return true;
}
- //----------------------------------------------------------------------------
-void
-cmGlobalXCodeGenerator
-::ComputeTargetObjects(cmGeneratorTarget* gt) const
+//----------------------------------------------------------------------------
+void cmGlobalXCodeGenerator
+::ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const
{
- // Count the number of object files with each name. Warn about duplicate
- // names since Xcode names them uniquely automatically with a numeric suffix
- // to avoid exact duplicate file names. Note that Mac file names are not
- // typically case sensitive, hence the LowerCase.
- std::map<cmStdString, int> counts;
- std::vector<cmSourceFile*> objectSources;
- gt->GetObjectSources(objectSources);
- for(std::vector<cmSourceFile*>::const_iterator
- si = objectSources.begin();
- si != objectSources.end(); ++si)
- {
- cmSourceFile* sf = *si;
- std::string objectName =
- cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
- objectName += ".o";
-
- std::string objectNameLower = cmSystemTools::LowerCase(objectName);
- counts[objectNameLower] += 1;
- if (2 == counts[objectNameLower])
- {
- // TODO: emit warning about duplicate name?
- }
-
- gt->AddObject(sf, objectName);
- }
-
const char* configName = this->GetCMakeCFGIntDir();
std::string dir = this->GetObjectsNormalDirectory(
"$(PROJECT_NAME)", configName, gt->Target);
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index c9d20c2..23616b4 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -33,9 +33,9 @@ public:
static cmGlobalGeneratorFactory* NewFactory();
///! Get the name for the generator.
- virtual const char* GetName() const {
+ virtual std::string GetName() const {
return cmGlobalXCodeGenerator::GetActualName();}
- static const char* GetActualName() {return "Xcode";}
+ static std::string GetActualName() {return "Xcode";}
/** Get the documentation entry for this generator. */
static void GetDocumentation(cmDocumentationEntry& entry);
@@ -55,11 +55,11 @@ public:
*/
virtual void GenerateBuildCommand(
std::vector<std::string>& makeCommand,
- const char* makeProgram,
- const char* projectName,
- const char* projectDir,
- const char* targetName,
- const char* config,
+ const std::string& makeProgram,
+ const std::string& projectName,
+ const std::string& projectDir,
+ const std::string& targetName,
+ const std::string& config,
bool fast,
std::vector<std::string> const& makeOptions = std::vector<std::string>()
);
@@ -72,9 +72,9 @@ public:
virtual void Generate();
/** Append the subdirectory for the given configuration. */
- virtual void AppendDirectoryForConfig(const char* prefix,
- const char* config,
- const char* suffix,
+ virtual void AppendDirectoryForConfig(const std::string& prefix,
+ const std::string& config,
+ const std::string& suffix,
std::string& dir);
///! What is the configurations directory variable called?
@@ -95,7 +95,7 @@ private:
cmXCodeObject* CreateOrGetPBXGroup(cmTarget& cmtarget,
cmSourceGroup* sg);
cmXCodeObject* CreatePBXGroup(cmXCodeObject *parent,
- cmStdString name);
+ std::string name);
void CreateGroups(cmLocalGenerator* root,
std::vector<cmLocalGenerator*>&
generators);
@@ -123,19 +123,17 @@ private:
void CreateCustomRulesMakefile(const char* makefileBasename,
cmTarget& target,
std::vector<cmCustomCommand> const & commands,
- const char* configName,
- const std::map<cmStdString, cmStdString>&
- multipleOutputPairs
- );
+ const std::string& configName,
+ bool& haveMultipleOutputPairs);
cmXCodeObject* FindXCodeTarget(cmTarget const*);
- std::string GetOrCreateId(const char* name, const char* id);
+ std::string GetOrCreateId(const std::string& name, const std::string& id);
// create cmXCodeObject from these functions so that memory can be managed
// correctly. All objects created are stored in this->XCodeObjects.
cmXCodeObject* CreateObject(cmXCodeObject::PBXType ptype);
cmXCodeObject* CreateObject(cmXCodeObject::Type type);
- cmXCodeObject* CreateString(const char* s);
+ cmXCodeObject* CreateString(const std::string& s);
cmXCodeObject* CreateObjectReference(cmXCodeObject*);
cmXCodeObject* CreateXCodeTarget(cmTarget& target,
cmXCodeObject* buildPhases);
@@ -147,12 +145,13 @@ private:
void AppendOrAddBuildSetting(cmXCodeObject* settings, const char* attr,
const char* value);
void AppendBuildSettingAttribute(cmXCodeObject* target, const char* attr,
- const char* value, const char* configName);
+ const char* value,
+ const std::string& configName);
cmXCodeObject* CreateUtilityTarget(cmTarget& target);
void AddDependAndLinkInformation(cmXCodeObject* target);
void CreateBuildSettings(cmTarget& target,
cmXCodeObject* buildSettings,
- const char* buildType);
+ const std::string& buildType);
std::string ExtractFlag(const char* flag, std::string& flags);
// delete all objects in the this->XCodeObjects vector.
void ClearXCodeObjects();
@@ -190,10 +189,10 @@ private:
void CreateReRunCMakeFile(cmLocalGenerator* root,
std::vector<cmLocalGenerator*> const& gens);
- std::string LookupFlags(const char* varNamePrefix,
- const char* varNameLang,
- const char* varNameSuffix,
- const char* default_flags);
+ std::string LookupFlags(const std::string& varNamePrefix,
+ const std::string& varNameLang,
+ const std::string& varNameSuffix,
+ const std::string& default_flags);
class Factory;
class BuildObjectListOrString;
@@ -205,18 +204,19 @@ private:
std::vector<std::string> const& defines,
bool dflag = false);
+ void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const;
protected:
virtual const char* GetInstallTargetName() const { return "install"; }
virtual const char* GetPackageTargetName() const { return "package"; }
unsigned int XcodeVersion;
std::string VersionString;
- std::set<cmStdString> XCodeObjectIDs;
+ std::set<std::string> XCodeObjectIDs;
std::vector<cmXCodeObject*> XCodeObjects;
cmXCodeObject* RootObject;
private:
- void PrintCompilerAdvice(std::ostream&, std::string, const char*) const {}
- void ComputeTargetObjects(cmGeneratorTarget* gt) const;
+ void PrintCompilerAdvice(std::ostream&, std::string const&,
+ const char*) const {}
std::string GetObjectsNormalDirectory(
const std::string &projName,
@@ -235,14 +235,14 @@ private:
std::string CurrentReRunCMakeMakefile;
std::string CurrentXCodeHackMakefile;
std::string CurrentProject;
- std::set<cmStdString> TargetDoneSet;
+ std::set<std::string> TargetDoneSet;
std::vector<std::string> CurrentOutputDirectoryComponents;
std::vector<std::string> ProjectSourceDirectoryComponents;
std::vector<std::string> ProjectOutputDirectoryComponents;
- std::map<cmStdString, cmXCodeObject* > GroupMap;
- std::map<cmStdString, cmXCodeObject* > GroupNameMap;
- std::map<cmStdString, cmXCodeObject* > TargetGroup;
- std::map<cmStdString, cmXCodeObject* > FileRefs;
+ std::map<std::string, cmXCodeObject* > GroupMap;
+ std::map<std::string, cmXCodeObject* > GroupNameMap;
+ std::map<std::string, cmXCodeObject* > TargetGroup;
+ std::map<std::string, cmXCodeObject* > FileRefs;
std::vector<std::string> Architectures;
std::string PlatformToolset;
};
diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx
index db964a9..601993f 100644
--- a/Source/cmGraphVizWriter.cxx
+++ b/Source/cmGraphVizWriter.cxx
@@ -121,7 +121,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
__set_bool_if_set(this->GeneratePerTarget, "GRAPHVIZ_GENERATE_PER_TARGET");
__set_bool_if_set(this->GenerateDependers, "GRAPHVIZ_GENERATE_DEPENDERS");
- cmStdString ignoreTargetsRegexes;
+ std::string ignoreTargetsRegexes;
__set_if_set(ignoreTargetsRegexes, "GRAPHVIZ_IGNORE_TARGETS");
this->TargetsToIgnoreRegex.clear();
@@ -135,7 +135,7 @@ void cmGraphVizWriter::ReadSettings(const char* settingsFileName,
itvIt != ignoreTargetsRegExVector.end();
++ itvIt )
{
- cmStdString currentRegexString(*itvIt);
+ std::string currentRegexString(*itvIt);
cmsys::RegularExpression currentRegex;
if (!currentRegex.compile(currentRegexString.c_str()))
{
@@ -160,7 +160,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
this->CollectTargetsAndLibs();
- for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
+ for(std::map<std::string, const cmTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end();
++ptrIt)
@@ -192,7 +192,7 @@ void cmGraphVizWriter::WriteTargetDependersFiles(const char* fileName)
std::cout << "Writing " << currentFilename << "..." << std::endl;
this->WriteHeader(str);
- this->WriteDependerConnections(ptrIt->first.c_str(),
+ this->WriteDependerConnections(ptrIt->first,
insertedNodes, insertedConnections, str);
this->WriteFooter(str);
@@ -211,7 +211,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
this->CollectTargetsAndLibs();
- for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
+ for(std::map<std::string, const cmTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end();
++ptrIt)
@@ -241,7 +241,7 @@ void cmGraphVizWriter::WritePerTargetFiles(const char* fileName)
std::cout << "Writing " << currentFilename << "..." << std::endl;
this->WriteHeader(str);
- this->WriteConnections(ptrIt->first.c_str(),
+ this->WriteConnections(ptrIt->first,
insertedNodes, insertedConnections, str);
this->WriteFooter(str);
}
@@ -265,7 +265,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
std::set<std::string> insertedConnections;
std::set<std::string> insertedNodes;
- for(std::map<cmStdString, const cmTarget*>::const_iterator ptrIt =
+ for(std::map<std::string, const cmTarget*>::const_iterator ptrIt =
this->TargetPtrs.begin();
ptrIt != this->TargetPtrs.end();
++ptrIt)
@@ -280,7 +280,7 @@ void cmGraphVizWriter::WriteGlobalFile(const char* fileName)
continue;
}
- this->WriteConnections(ptrIt->first.c_str(),
+ this->WriteConnections(ptrIt->first,
insertedNodes, insertedConnections, str);
}
this->WriteFooter(str);
@@ -300,12 +300,12 @@ void cmGraphVizWriter::WriteFooter(cmGeneratedFileStream& str) const
}
-void cmGraphVizWriter::WriteConnections(const char* targetName,
+void cmGraphVizWriter::WriteConnections(const std::string& targetName,
std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const
{
- std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt =
+ std::map<std::string, const cmTarget* >::const_iterator targetPtrIt =
this->TargetPtrs.find(targetName);
if (targetPtrIt == this->TargetPtrs.end()) // not found at all
@@ -331,7 +331,7 @@ void cmGraphVizWriter::WriteConnections(const char* targetName,
++ llit )
{
const char* libName = llit->first.c_str();
- std::map<cmStdString, cmStdString>::const_iterator libNameIt =
+ std::map<std::string, std::string>::const_iterator libNameIt =
this->TargetNamesNodes.find(libName);
// can happen e.g. if GRAPHVIZ_TARGET_IGNORE_REGEX is used
@@ -349,8 +349,8 @@ void cmGraphVizWriter::WriteConnections(const char* targetName,
this->WriteNode(libName, this->TargetPtrs.find(libName)->second,
insertedNodes, str);
- str << " \"" << myNodeName.c_str() << "\" -> \""
- << libNameIt->second.c_str() << "\"";
+ str << " \"" << myNodeName << "\" -> \""
+ << libNameIt->second << "\"";
str << " // " << targetName << " -> " << libName << std::endl;
this->WriteConnections(libName, insertedNodes, insertedConnections, str);
}
@@ -359,12 +359,12 @@ void cmGraphVizWriter::WriteConnections(const char* targetName,
}
-void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
+void cmGraphVizWriter::WriteDependerConnections(const std::string& targetName,
std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const
{
- std::map<cmStdString, const cmTarget* >::const_iterator targetPtrIt =
+ std::map<std::string, const cmTarget* >::const_iterator targetPtrIt =
this->TargetPtrs.find(targetName);
if (targetPtrIt == this->TargetPtrs.end()) // not found at all
@@ -383,7 +383,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
std::string myNodeName = this->TargetNamesNodes.find(targetName)->second;
// now search who links against me
- for(std::map<cmStdString, const cmTarget*>::const_iterator dependerIt =
+ for(std::map<std::string, const cmTarget*>::const_iterator dependerIt =
this->TargetPtrs.begin();
dependerIt != this->TargetPtrs.end();
++dependerIt)
@@ -407,11 +407,11 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
llit != ll->end();
++ llit )
{
- std::string libName = llit->first.c_str();
+ std::string libName = llit->first;
if (libName == targetName)
{
// So this target links against targetName.
- std::map<cmStdString, cmStdString>::const_iterator dependerNodeNameIt =
+ std::map<std::string, std::string>::const_iterator dependerNodeNameIt =
this->TargetNamesNodes.find(dependerIt->first);
if(dependerNodeNameIt != this->TargetNamesNodes.end())
@@ -424,13 +424,13 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
insertedConnections.end())
{
insertedConnections.insert(connectionName);
- this->WriteNode(dependerIt->first.c_str(), dependerIt->second,
+ this->WriteNode(dependerIt->first, dependerIt->second,
insertedNodes, str);
str << " \"" << dependerNodeNameIt->second << "\" -> \""
<< myNodeName << "\"";
str << " // " <<targetName<< " -> " <<dependerIt->first<<std::endl;
- this->WriteDependerConnections(dependerIt->first.c_str(),
+ this->WriteDependerConnections(dependerIt->first,
insertedNodes, insertedConnections, str);
}
@@ -444,7 +444,7 @@ void cmGraphVizWriter::WriteDependerConnections(const char* targetName,
}
-void cmGraphVizWriter::WriteNode(const char* targetName,
+void cmGraphVizWriter::WriteNode(const std::string& targetName,
const cmTarget* target,
std::set<std::string>& insertedNodes,
cmGeneratedFileStream& str) const
@@ -452,10 +452,10 @@ void cmGraphVizWriter::WriteNode(const char* targetName,
if (insertedNodes.find(targetName) == insertedNodes.end())
{
insertedNodes.insert(targetName);
- std::map<cmStdString, cmStdString>::const_iterator nameIt =
+ std::map<std::string, std::string>::const_iterator nameIt =
this->TargetNamesNodes.find(targetName);
- str << " \"" << nameIt->second.c_str() << "\" [ label=\""
+ str << " \"" << nameIt->second << "\" [ label=\""
<< targetName << "\" shape=\"" << getShapeForTarget(target)
<< "\"];" << std::endl;
}
@@ -540,7 +540,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
continue;
}
- std::map<cmStdString, const cmTarget*>::const_iterator tarIt =
+ std::map<std::string, const cmTarget*>::const_iterator tarIt =
this->TargetPtrs.find(libName);
if ( tarIt == this->TargetPtrs.end() )
{
@@ -558,7 +558,7 @@ int cmGraphVizWriter::CollectAllExternalLibs(int cnt)
}
-bool cmGraphVizWriter::IgnoreThisTarget(const char* name)
+bool cmGraphVizWriter::IgnoreThisTarget(const std::string& name)
{
for(std::vector<cmsys::RegularExpression>::iterator itvIt
= this->TargetsToIgnoreRegex.begin();
diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h
index 17b97f8..a7acd0e 100644
--- a/Source/cmGraphVizWriter.h
+++ b/Source/cmGraphVizWriter.h
@@ -44,30 +44,30 @@ protected:
void WriteHeader(cmGeneratedFileStream& str) const;
- void WriteConnections(const char* targetName,
+ void WriteConnections(const std::string& targetName,
std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const;
- void WriteDependerConnections(const char* targetName,
+ void WriteDependerConnections(const std::string& targetName,
std::set<std::string>& insertedNodes,
std::set<std::string>& insertedConnections,
cmGeneratedFileStream& str) const;
- void WriteNode(const char* targetName, const cmTarget* target,
+ void WriteNode(const std::string& targetName, const cmTarget* target,
std::set<std::string>& insertedNodes,
cmGeneratedFileStream& str) const;
void WriteFooter(cmGeneratedFileStream& str) const;
- bool IgnoreThisTarget(const char* name);
+ bool IgnoreThisTarget(const std::string& name);
bool GenerateForTargetType(cmTarget::TargetType targetType) const;
- cmStdString GraphType;
- cmStdString GraphName;
- cmStdString GraphHeader;
- cmStdString GraphNodePrefix;
+ std::string GraphType;
+ std::string GraphName;
+ std::string GraphHeader;
+ std::string GraphNodePrefix;
bool GenerateForExecutables;
bool GenerateForStaticLibs;
@@ -81,9 +81,9 @@ protected:
const std::vector<cmLocalGenerator*>& LocalGenerators;
- std::map<cmStdString, const cmTarget*> TargetPtrs;
+ std::map<std::string, const cmTarget*> TargetPtrs;
// maps from the actual target names to node names in dot:
- std::map<cmStdString, cmStdString> TargetNamesNodes;
+ std::map<std::string, std::string> TargetNamesNodes;
bool HaveTargetsAndLibs;
};
diff --git a/Source/cmIDEFlagTable.h b/Source/cmIDEFlagTable.h
index e372c0a..d9a045d 100644
--- a/Source/cmIDEFlagTable.h
+++ b/Source/cmIDEFlagTable.h
@@ -31,6 +31,7 @@ struct cmIDEFlagTable
// old value with semicolons (e.g.
// /NODEFAULTLIB: =>
// IgnoreDefaultLibraryNames)
+ UserFollowing = (1<<5), // expect value in following argument
UserValueIgnored = UserValue | UserIgnored,
UserValueRequired = UserValue | UserRequired
diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx
index 34a9c7c..1f3c066 100644
--- a/Source/cmIDEOptions.cxx
+++ b/Source/cmIDEOptions.cxx
@@ -19,6 +19,7 @@ cmIDEOptions::cmIDEOptions()
this->DoingDefine = false;
this->AllowDefine = true;
this->AllowSlash = false;
+ this->DoingFollowing = 0;
for(int i=0; i < FlagTableCount; ++i)
{
this->FlagTable[i] = 0;
@@ -41,6 +42,14 @@ void cmIDEOptions::HandleFlag(const char* flag)
return;
}
+ // If the last option expected a following value, this is it.
+ if(this->DoingFollowing)
+ {
+ this->FlagMapUpdate(this->DoingFollowing, flag);
+ this->DoingFollowing = 0;
+ return;
+ }
+
// Look for known arguments.
if(flag[0] == '-' || (this->AllowSlash && flag[0] == '/'))
{
@@ -99,40 +108,22 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
(!(entry->special & cmIDEFlagTable::UserRequired) ||
static_cast<int>(strlen(flag+1)) > n))
{
- if(entry->special & cmIDEFlagTable::UserIgnored)
- {
- // Ignore the user-specified value.
- this->FlagMap[entry->IDEName] = entry->value;
- }
- else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
- {
- const char *new_value = flag+1+n;
-
- std::map<cmStdString,cmStdString>::iterator itr;
- itr = this->FlagMap.find(entry->IDEName);
- if(itr != this->FlagMap.end())
- {
- // Append to old value (if present) with semicolons;
- itr->second += ";";
- itr->second += new_value;
- }
- else
- {
- this->FlagMap[entry->IDEName] = new_value;
- }
- }
- else
- {
- // Use the user-specified value.
- this->FlagMap[entry->IDEName] = flag+1+n;
- }
+ this->FlagMapUpdate(entry, flag+n+1);
entry_found = true;
}
}
else if(strcmp(flag+1, entry->commandFlag) == 0)
{
- // This flag table entry provides a fixed value.
- this->FlagMap[entry->IDEName] = entry->value;
+ if(entry->special & cmIDEFlagTable::UserFollowing)
+ {
+ // This flag expects a value in the following argument.
+ this->DoingFollowing = entry;
+ }
+ else
+ {
+ // This flag table entry provides a fixed value.
+ this->FlagMap[entry->IDEName] = entry->value;
+ }
entry_found = true;
}
@@ -151,6 +142,37 @@ bool cmIDEOptions::CheckFlagTable(cmIDEFlagTable const* table,
}
//----------------------------------------------------------------------------
+void cmIDEOptions::FlagMapUpdate(cmIDEFlagTable const* entry,
+ const char* new_value)
+{
+ if(entry->special & cmIDEFlagTable::UserIgnored)
+ {
+ // Ignore the user-specified value.
+ this->FlagMap[entry->IDEName] = entry->value;
+ }
+ else if(entry->special & cmIDEFlagTable::SemicolonAppendable)
+ {
+ std::map<std::string,std::string>::iterator itr;
+ itr = this->FlagMap.find(entry->IDEName);
+ if(itr != this->FlagMap.end())
+ {
+ // Append to old value (if present) with semicolons;
+ itr->second += ";";
+ itr->second += new_value;
+ }
+ else
+ {
+ this->FlagMap[entry->IDEName] = new_value;
+ }
+ }
+ else
+ {
+ // Use the user-specified value.
+ this->FlagMap[entry->IDEName] = new_value;
+ }
+}
+
+//----------------------------------------------------------------------------
void cmIDEOptions::AddDefine(const std::string& def)
{
this->Defines.push_back(def);
@@ -186,7 +208,7 @@ void cmIDEOptions::RemoveFlag(const char* flag)
//----------------------------------------------------------------------------
const char* cmIDEOptions::GetFlag(const char* flag)
{
- std::map<cmStdString, cmStdString>::iterator i = this->FlagMap.find(flag);
+ std::map<std::string, std::string>::iterator i = this->FlagMap.find(flag);
if(i != this->FlagMap.end())
{
return i->second.c_str();
diff --git a/Source/cmIDEOptions.h b/Source/cmIDEOptions.h
index e78af3e..e7749ec 100644
--- a/Source/cmIDEOptions.h
+++ b/Source/cmIDEOptions.h
@@ -40,22 +40,24 @@ protected:
// Then parse the command line flags specified in CMAKE_CXX_FLAGS
// and CMAKE_C_FLAGS
// and overwrite or add new values to this map
- std::map<cmStdString, cmStdString> FlagMap;
+ std::map<std::string, std::string> FlagMap;
// Preprocessor definitions.
std::vector<std::string> Defines;
// Unrecognized flags that get no special handling.
- cmStdString FlagString;
+ std::string FlagString;
bool DoingDefine;
bool AllowDefine;
bool AllowSlash;
+ cmIDEFlagTable const* DoingFollowing;
enum { FlagTableCount = 16 };
cmIDEFlagTable const* FlagTable[FlagTableCount];
void HandleFlag(const char* flag);
bool CheckFlagTable(cmIDEFlagTable const* table, const char* flag,
bool& flag_handled);
+ void FlagMapUpdate(cmIDEFlagTable const* entry, const char* new_value);
virtual void StoreUnknownFlag(const char* flag) = 0;
};
diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx
index ee95c05..06c4b89 100644
--- a/Source/cmIfCommand.cxx
+++ b/Source/cmIfCommand.cxx
@@ -26,7 +26,7 @@ static std::string cmIfCommandError(
i != args.end(); ++i)
{
err += " ";
- err += lg->EscapeForCMake(i->c_str());
+ err += lg->EscapeForCMake(*i);
}
err += "\n";
return err;
@@ -199,7 +199,7 @@ bool cmIfCommand
err += errorString;
if (status == cmake::FATAL_ERROR)
{
- this->SetError(err.c_str());
+ this->SetError(err);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -261,7 +261,7 @@ namespace
}
// Check definition.
- const char* def = mf->GetDefinition(arg.c_str());
+ const char* def = mf->GetDefinition(arg);
return !cmSystemTools::IsOff(def);
}
@@ -277,12 +277,12 @@ namespace
else if(arg == "1")
{ return true; }
else
- { return !cmSystemTools::IsOff(mf->GetDefinition(arg.c_str())); }
+ { return !cmSystemTools::IsOff(mf->GetDefinition(arg)); }
}
else
{
// Old GetVariableOrNumber behavior.
- const char* def = mf->GetDefinition(arg.c_str());
+ const char* def = mf->GetDefinition(arg);
if(!def && atoi(arg.c_str()))
{
def = arg.c_str();
@@ -559,7 +559,7 @@ namespace
}
else
{
- bdef = makefile->IsDefinitionSet((argP1)->c_str());
+ bdef = makefile->IsDefinitionSet(*(argP1));
}
HandlePredicate(bdef, reducible, arg, newArgs, argP1, argP2);
}
@@ -593,7 +593,7 @@ namespace
if (argP1 != newArgs.end() && argP2 != newArgs.end() &&
*(argP1) == "MATCHES")
{
- def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
+ def = cmIfCommand::GetVariableOrString(*arg, makefile);
const char* rex = (argP2)->c_str();
cmStringCommand::ClearMatches(makefile);
cmsys::RegularExpression regEntry;
@@ -634,8 +634,8 @@ namespace
(*(argP1) == "LESS" || *(argP1) == "GREATER" ||
*(argP1) == "EQUAL"))
{
- def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
- def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+ def = cmIfCommand::GetVariableOrString(*arg, makefile);
+ def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
double lhs;
double rhs;
bool result;
@@ -665,8 +665,8 @@ namespace
*(argP1) == "STREQUAL" ||
*(argP1) == "STRGREATER"))
{
- def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
- def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+ def = cmIfCommand::GetVariableOrString(*arg, makefile);
+ def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
int val = strcmp(def,def2);
bool result;
if (*(argP1) == "STRLESS")
@@ -689,8 +689,8 @@ namespace
(*(argP1) == "VERSION_LESS" || *(argP1) == "VERSION_GREATER" ||
*(argP1) == "VERSION_EQUAL"))
{
- def = cmIfCommand::GetVariableOrString(arg->c_str(), makefile);
- def2 = cmIfCommand::GetVariableOrString((argP2)->c_str(), makefile);
+ def = cmIfCommand::GetVariableOrString(*arg, makefile);
+ def2 = cmIfCommand::GetVariableOrString(*argP2, makefile);
cmSystemTools::CompareOp op = cmSystemTools::OP_EQUAL;
if(*argP1 == "VERSION_LESS")
{
@@ -907,13 +907,13 @@ bool cmIfCommand::IsTrue(const std::vector<std::string> &args,
}
//=========================================================================
-const char* cmIfCommand::GetVariableOrString(const char* str,
+const char* cmIfCommand::GetVariableOrString(const std::string& str,
const cmMakefile* mf)
{
const char* def = mf->GetDefinition(str);
if(!def)
{
- def = str;
+ def = str.c_str();
}
return def;
}
diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h
index f2633ad..814c052 100644
--- a/Source/cmIfCommand.h
+++ b/Source/cmIfCommand.h
@@ -58,12 +58,12 @@ public:
* the CMakeLists.txt file.
*/
virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) { return false;};
+ cmExecutionStatus &) { return false;}
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "if";}
+ virtual std::string GetName() const { return "if";}
/**
* This determines if the command is invoked when in script mode.
@@ -79,7 +79,7 @@ public:
// Get a definition from the makefile. If it doesn't exist,
// return the original string.
- static const char* GetVariableOrString(const char* str,
+ static const char* GetVariableOrString(const std::string& str,
const cmMakefile* mf);
cmTypeMacro(cmIfCommand, cmCommand);
diff --git a/Source/cmIncludeCommand.cxx b/Source/cmIncludeCommand.cxx
index fbcbc75..0a4f5c9 100644
--- a/Source/cmIncludeCommand.cxx
+++ b/Source/cmIncludeCommand.cxx
@@ -65,7 +65,7 @@ bool cmIncludeCommand
{
std::string errorText = "called with invalid argument: ";
errorText += args[i];
- this->SetError(errorText.c_str());
+ this->SetError(errorText);
return false;
}
}
@@ -121,7 +121,7 @@ bool cmIncludeCommand
"command. It " << modal << " not be used as the argument to the "
"include() command. Use ALIAS targets instead to refer to targets "
"by alternative names.\n";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
return false;
@@ -139,7 +139,7 @@ bool cmIncludeCommand
// add the location of the included file if a result variable was given
if (resultVarName.size())
{
- this->Makefile->AddDefinition(resultVarName.c_str(),
+ this->Makefile->AddDefinition(resultVarName,
readit?fullFilePath.c_str():"NOTFOUND");
}
@@ -149,7 +149,7 @@ bool cmIncludeCommand
"could not find load file:\n"
" ";
m += fname;
- this->SetError(m.c_str());
+ this->SetError(m);
return false;
}
return true;
diff --git a/Source/cmIncludeCommand.h b/Source/cmIncludeCommand.h
index 267723d..0dcd7de 100644
--- a/Source/cmIncludeCommand.h
+++ b/Source/cmIncludeCommand.h
@@ -46,7 +46,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "include";}
+ virtual std::string GetName() const {return "include";}
cmTypeMacro(cmIncludeCommand, cmCommand);
};
diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx
index e20fe02..df5508e 100644
--- a/Source/cmIncludeDirectoryCommand.cxx
+++ b/Source/cmIncludeDirectoryCommand.cxx
@@ -38,7 +38,7 @@ bool cmIncludeDirectoryCommand
std::vector<std::string> beforeIncludes;
std::vector<std::string> afterIncludes;
- std::set<cmStdString> systemIncludes;
+ std::set<std::string> systemIncludes;
for(; i != args.end(); ++i)
{
diff --git a/Source/cmIncludeDirectoryCommand.h b/Source/cmIncludeDirectoryCommand.h
index c621dcb..6cc2c83 100644
--- a/Source/cmIncludeDirectoryCommand.h
+++ b/Source/cmIncludeDirectoryCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "include_directories";}
+ virtual std::string GetName() const { return "include_directories";}
cmTypeMacro(cmIncludeDirectoryCommand, cmCommand);
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 8ca674f..081f77a 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "include_external_msproject";}
+ virtual std::string GetName() const {return "include_external_msproject";}
cmTypeMacro(cmIncludeExternalMSProjectCommand, cmCommand);
};
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx
index ef6e8c6..d6dfdd2 100644
--- a/Source/cmIncludeRegularExpressionCommand.cxx
+++ b/Source/cmIncludeRegularExpressionCommand.cxx
@@ -24,7 +24,7 @@ bool cmIncludeRegularExpressionCommand
if(args.size() > 1)
{
- this->Makefile->SetComplainRegularExpression(args[1].c_str());
+ this->Makefile->SetComplainRegularExpression(args[1]);
}
return true;
diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h
index 0c5fa6f..c58f018 100644
--- a/Source/cmIncludeRegularExpressionCommand.h
+++ b/Source/cmIncludeRegularExpressionCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "include_regular_expression";}
+ virtual std::string GetName() const {return "include_regular_expression";}
cmTypeMacro(cmIncludeRegularExpressionCommand, cmCommand);
};
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 0878aae..0041122 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -97,9 +97,9 @@ bool cmInstallCommand::InitialPass(std::vector<std::string> const& args,
}
// Unknown mode.
- cmStdString e = "called with unknown mode ";
+ std::string e = "called with unknown mode ";
e += args[0];
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -269,7 +269,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
// Unknown argument.
cmOStringStream e;
e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -370,7 +370,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given target \"" << (*targetIt)
<< "\" which is an alias.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Lookup this target in the current directory.
@@ -387,7 +387,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given target \"" << (*targetIt)
<< "\" which is not an executable, library, or module.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
else if(target->GetType() == cmTarget::OBJECT_LIBRARY)
@@ -395,7 +395,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given OBJECT library \"" << (*targetIt)
<< "\" which may not be installed.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Store the target in the list to be installed.
@@ -407,7 +407,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given target \"" << (*targetIt)
<< "\" which does not exist in this directory.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -499,7 +499,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
"FRAMEWORK target \"" << target.GetName() << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -519,7 +519,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given no LIBRARY DESTINATION for shared library "
"target \"" << target.GetName() << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -539,7 +539,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given no ARCHIVE DESTINATION for static library "
"target \"" << target.GetName() << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -560,7 +560,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given no LIBRARY DESTINATION for module target \""
<< target.GetName() << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -595,7 +595,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
"executable target \"" << target.GetName() << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -612,7 +612,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
cmOStringStream e;
e << "TARGETS given no RUNTIME DESTINATION for executable "
"target \"" << target.GetName() << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -851,7 +851,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
// Unknown argument.
cmOStringStream e;
e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -866,7 +866,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
// The rename option works only with one file.
cmOStringStream e;
e << args[0] << " given RENAME option with more than one file.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -886,7 +886,7 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
// A destination is required.
cmOStringStream e;
e << args[0] << " given no DESTINATION!";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -927,7 +927,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -941,7 +941,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -969,7 +969,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
literal_args += " EXCLUDE";
@@ -982,7 +982,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -997,7 +997,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1011,7 +1011,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1025,7 +1025,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1040,7 +1040,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1055,7 +1055,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1069,7 +1069,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " does not allow \""
<< args[i] << "\" after PATTERN or REGEX.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1094,7 +1094,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " given non-directory \""
<< args[i] << "\" to install.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1150,7 +1150,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " given invalid file permission \""
<< args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1162,7 +1162,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " given invalid directory permission \""
<< args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1174,7 +1174,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " given invalid permission \""
<< args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1183,7 +1183,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// Unknown argument.
cmOStringStream e;
e << args[0] << " given unknown argument \"" << args[i] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1204,7 +1204,7 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
// A destination is required.
cmOStringStream e;
e << args[0] << " given no DESTINATION!";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1247,7 +1247,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Unknown argument.
cmOStringStream e;
e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1262,7 +1262,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// A destination is required.
cmOStringStream e;
e << args[0] << " given no DESTINATION!";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1274,7 +1274,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
e << args[0] << " given invalid export file name \"" << fname << "\". "
<< "The FILE argument may not contain a path. "
<< "Specify the path in the DESTINATION argument.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1285,7 +1285,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
cmOStringStream e;
e << args[0] << " given invalid export file name \"" << fname << "\". "
<< "The FILE argument must specify a name ending in \".cmake\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -1302,7 +1302,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
<< "This name cannot be safely converted to a file name. "
<< "Specify a different export name or use the FILE option to set "
<< "a file name explicitly.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1327,7 +1327,7 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
<< "EXPORT_LINK_INTERFACE_LIBRARIES" << "\", but target \""
<< te->Target->GetName()
<< "\" does not have policy CMP0022 set to NEW.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -1368,7 +1368,7 @@ bool cmInstallCommand::MakeFilesFullPath(const char* modeName,
{
cmOStringStream e;
e << modeName << " given directory \"" << (*fileIt) << "\" to install.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
// Store the file for installation.
diff --git a/Source/cmInstallCommand.h b/Source/cmInstallCommand.h
index 9db2490..8e14a08 100644
--- a/Source/cmInstallCommand.h
+++ b/Source/cmInstallCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "install";}
+ virtual std::string GetName() const { return "install";}
cmTypeMacro(cmInstallCommand, cmCommand);
diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx
index 1287ea6..9a17052 100644
--- a/Source/cmInstallExportGenerator.cxx
+++ b/Source/cmInstallExportGenerator.cxx
@@ -94,7 +94,7 @@ void cmInstallExportGenerator::ComputeTempDir()
{
// Replace the destination path with a hash to keep it short.
this->TempDir +=
- cmSystemTools::ComputeStringMD5(this->Destination.c_str());
+ cmSystemTools::ComputeStringMD5(this->Destination);
}
else
{
@@ -138,11 +138,11 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
// Generate the import file for this export set.
this->EFGen->SetExportFile(this->MainImportFile.c_str());
- this->EFGen->SetNamespace(this->Namespace.c_str());
+ this->EFGen->SetNamespace(this->Namespace);
this->EFGen->SetExportOld(this->ExportOld);
if(this->ConfigurationTypes->empty())
{
- if(this->ConfigurationName && *this->ConfigurationName)
+ if(!this->ConfigurationName.empty())
{
this->EFGen->AddConfiguration(this->ConfigurationName);
}
@@ -157,7 +157,7 @@ void cmInstallExportGenerator::GenerateScript(std::ostream& os)
ci = this->ConfigurationTypes->begin();
ci != this->ConfigurationTypes->end(); ++ci)
{
- this->EFGen->AddConfiguration(ci->c_str());
+ this->EFGen->AddConfiguration(*ci);
}
}
this->EFGen->GenerateImportFile();
@@ -177,12 +177,12 @@ cmInstallExportGenerator::GenerateScriptConfigs(std::ostream& os,
// Now create a configuration-specific install rule for the import
// file of each configuration.
std::vector<std::string> files;
- for(std::map<cmStdString, cmStdString>::const_iterator
+ for(std::map<std::string, std::string>::const_iterator
i = this->EFGen->GetConfigImportFiles().begin();
i != this->EFGen->GetConfigImportFiles().end(); ++i)
{
files.push_back(i->second);
- std::string config_test = this->CreateConfigTest(i->first.c_str());
+ std::string config_test = this->CreateConfigTest(i->first);
os << indent << "if(" << config_test << ")\n";
this->AddInstallRule(os, cmInstallType_FILES, files, false,
this->FilePermissions.c_str(), 0, 0, 0,
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 488d486..7eabbef 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -100,9 +100,9 @@ void cmInstallFilesCommand::FinalPass()
else // reg exp list
{
std::vector<std::string> files;
- std::string regex = this->FinalArgs[0].c_str();
+ std::string regex = this->FinalArgs[0];
cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(),
- regex.c_str(), files);
+ regex, files);
std::vector<std::string>::iterator s = files.begin();
// for each argument, get the files
diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h
index 5583fe4..4551ab1 100644
--- a/Source/cmInstallFilesCommand.h
+++ b/Source/cmInstallFilesCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "install_files";}
+ virtual std::string GetName() const { return "install_files";}
/**
* This is called at the end after all the information
diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx
index ec15044..6594218 100644
--- a/Source/cmInstallFilesGenerator.cxx
+++ b/Source/cmInstallFilesGenerator.cxx
@@ -80,8 +80,8 @@ void cmInstallFilesGenerator::GenerateScriptActions(std::ostream& os,
//----------------------------------------------------------------------------
void cmInstallFilesGenerator::GenerateScriptForConfig(std::ostream& os,
- const char* config,
- Indent const& indent)
+ const std::string& config,
+ Indent const& indent)
{
std::vector<std::string> files;
cmListFileBacktrace lfbt;
diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h
index 9dea296..23bf935 100644
--- a/Source/cmInstallFilesGenerator.h
+++ b/Source/cmInstallFilesGenerator.h
@@ -35,7 +35,7 @@ public:
protected:
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
virtual void GenerateScriptForConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
Indent const& indent);
void AddFilesInstallRule(std::ostream& os, Indent const& indent,
std::vector<std::string> const& files);
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx
index d105a0c..9370e48 100644
--- a/Source/cmInstallGenerator.cxx
+++ b/Source/cmInstallGenerator.cxx
@@ -91,7 +91,7 @@ void cmInstallGenerator
<< "${CMAKE_ABSOLUTE_DESTINATION_FILES}\")\n";
os << indent << "endif()\n";
}
- os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype.c_str();
+ os << "file(INSTALL DESTINATION \"" << dest << "\" TYPE " << stype;
if(optional)
{
os << " OPTIONAL";
@@ -163,7 +163,7 @@ void cmInstallGenerator::GenerateScript(std::ostream& os)
}
//----------------------------------------------------------------------------
-bool cmInstallGenerator::InstallsForConfig(const char* config)
+bool cmInstallGenerator::InstallsForConfig(const std::string& config)
{
return this->GeneratesForConfig(config);
}
diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h
index c89ab8a..c72e9e9 100644
--- a/Source/cmInstallGenerator.h
+++ b/Source/cmInstallGenerator.h
@@ -48,7 +48,7 @@ public:
std::string GetInstallDestination() const;
/** Test if this generator installs something for a given configuration. */
- bool InstallsForConfig(const char*);
+ bool InstallsForConfig(const std::string& config);
protected:
virtual void GenerateScript(std::ostream& os);
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 54d903a..597f7ee 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -68,7 +68,7 @@ void cmInstallProgramsCommand::FinalPass()
{
std::vector<std::string> programs;
cmSystemTools::Glob(this->Makefile->GetCurrentDirectory(),
- this->FinalArgs[0].c_str(), programs);
+ this->FinalArgs[0], programs);
std::vector<std::string>::iterator s = programs.begin();
// for each argument, get the programs
diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h
index 95acfa2..90c7ba3 100644
--- a/Source/cmInstallProgramsCommand.h
+++ b/Source/cmInstallProgramsCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "install_programs";}
+ virtual std::string GetName() const { return "install_programs";}
/**
* This is called at the end after all the information
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 7a39f45..ec2b518 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -59,8 +59,8 @@ void cmInstallTargetGenerator::GenerateScript(std::ostream& os)
//----------------------------------------------------------------------------
void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
- const char* config,
- Indent const& indent)
+ const std::string& config,
+ Indent const& indent)
{
// Compute the build tree directory from which to copy the target.
std::string fromDirConfig;
@@ -319,7 +319,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os,
//----------------------------------------------------------------------------
std::string
-cmInstallTargetGenerator::GetInstallFilename(const char* config) const
+cmInstallTargetGenerator::GetInstallFilename(const std::string& config) const
{
NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
return
@@ -330,7 +330,7 @@ cmInstallTargetGenerator::GetInstallFilename(const char* config) const
//----------------------------------------------------------------------------
std::string
cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
- const char* config,
+ const std::string& config,
NameType nameType)
{
std::string fname;
@@ -405,7 +405,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target,
//----------------------------------------------------------------------------
void
cmInstallTargetGenerator
-::AddTweak(std::ostream& os, Indent const& indent, const char* config,
+::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
std::string const& file, TweakMethod tweak)
{
cmOStringStream tw;
@@ -423,7 +423,7 @@ cmInstallTargetGenerator
//----------------------------------------------------------------------------
void
cmInstallTargetGenerator
-::AddTweak(std::ostream& os, Indent const& indent, const char* config,
+::AddTweak(std::ostream& os, Indent const& indent, const std::string& config,
std::vector<std::string> const& files, TweakMethod tweak)
{
if(files.size() == 1)
@@ -470,7 +470,7 @@ std::string cmInstallTargetGenerator::GetDestDirPath(std::string const& file)
//----------------------------------------------------------------------------
void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os,
Indent const& indent,
- const char* config,
+ const std::string& config,
std::string const& file)
{
this->AddRPathCheckRule(os, indent, config, file);
@@ -478,9 +478,9 @@ void cmInstallTargetGenerator::PreReplacementTweaks(std::ostream& os,
//----------------------------------------------------------------------------
void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
- Indent const& indent,
- const char* config,
- std::string const& file)
+ Indent const& indent,
+ const std::string& config,
+ std::string const& file)
{
this->AddInstallNamePatchRule(os, indent, config, file);
this->AddChrpathPatchRule(os, indent, config, file);
@@ -492,7 +492,8 @@ void cmInstallTargetGenerator::PostReplacementTweaks(std::ostream& os,
void
cmInstallTargetGenerator
::AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
- const char* config, std::string const& toDestDirPath)
+ const std::string& config,
+ std::string const& toDestDirPath)
{
if(this->ImportLibrary ||
!(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -513,7 +514,7 @@ cmInstallTargetGenerator
// Build a map of build-tree install_name to install-tree install_name for
// shared libraries linked to this target.
- std::map<cmStdString, cmStdString> install_name_remap;
+ std::map<std::string, std::string> install_name_remap;
if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config))
{
std::set<cmTarget const*> const& sharedLibs
@@ -590,7 +591,7 @@ cmInstallTargetGenerator
{
os << "\n" << indent << " -id \"" << new_id << "\"";
}
- for(std::map<cmStdString, cmStdString>::const_iterator
+ for(std::map<std::string, std::string>::const_iterator
i = install_name_remap.begin();
i != install_name_remap.end(); ++i)
{
@@ -605,7 +606,8 @@ cmInstallTargetGenerator
void
cmInstallTargetGenerator
::AddRPathCheckRule(std::ostream& os, Indent const& indent,
- const char* config, std::string const& toDestDirPath)
+ const std::string& config,
+ std::string const& toDestDirPath)
{
// Skip the chrpath if the target does not need it.
if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
@@ -642,7 +644,8 @@ cmInstallTargetGenerator
void
cmInstallTargetGenerator
::AddChrpathPatchRule(std::ostream& os, Indent const& indent,
- const char* config, std::string const& toDestDirPath)
+ const std::string& config,
+ std::string const& toDestDirPath)
{
// Skip the chrpath if the target does not need it.
if(this->ImportLibrary || !this->Target->IsChrpathUsed(config))
diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h
index 18c3957..0f21da7 100644
--- a/Source/cmInstallTargetGenerator.h
+++ b/Source/cmInstallTargetGenerator.h
@@ -43,7 +43,7 @@ public:
void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; }
NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; }
- std::string GetInstallFilename(const char* config) const;
+ std::string GetInstallFilename(const std::string& config) const;
enum NameType
{
@@ -54,7 +54,7 @@ public:
};
static std::string GetInstallFilename(cmTarget const* target,
- const char* config,
+ const std::string& config,
NameType nameType = NameNormal);
cmTarget* GetTarget() const { return this->Target; }
@@ -63,30 +63,33 @@ public:
protected:
virtual void GenerateScript(std::ostream& os);
virtual void GenerateScriptForConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
Indent const& indent);
typedef void (cmInstallTargetGenerator::*TweakMethod)(
- std::ostream&, Indent const&, const char*, std::string const&
+ std::ostream&, Indent const&, const std::string&, std::string const&
);
void AddTweak(std::ostream& os, Indent const& indent,
- const char* config, std::string const& file,
+ const std::string& config, std::string const& file,
TweakMethod tweak);
void AddTweak(std::ostream& os, Indent const& indent,
- const char* config, std::vector<std::string> const& files,
+ const std::string& config,
+ std::vector<std::string> const& files,
TweakMethod tweak);
std::string GetDestDirPath(std::string const& file);
void PreReplacementTweaks(std::ostream& os, Indent const& indent,
- const char* config, std::string const& file);
+ const std::string& config,
+ std::string const& file);
void PostReplacementTweaks(std::ostream& os, Indent const& indent,
- const char* config, std::string const& file);
+ const std::string& config,
+ std::string const& file);
void AddInstallNamePatchRule(std::ostream& os, Indent const& indent,
- const char* config,
+ const std::string& config,
const std::string& toDestDirPath);
void AddChrpathPatchRule(std::ostream& os, Indent const& indent,
- const char* config,
+ const std::string& config,
std::string const& toDestDirPath);
void AddRPathCheckRule(std::ostream& os, Indent const& indent,
- const char* config,
+ const std::string& config,
std::string const& toDestDirPath);
void AddStripRule(std::ostream& os, Indent const& indent,
diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx
index 277ccea..b738844 100644
--- a/Source/cmInstallTargetsCommand.cxx
+++ b/Source/cmInstallTargetsCommand.cxx
@@ -52,7 +52,7 @@ bool cmInstallTargetsCommand
else
{
std::string str = "Cannot find target: \"" + *s + "\" to install.";
- this->SetError(str.c_str());
+ this->SetError(str);
return false;
}
}
diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h
index 2aa34db..e6cbe6e 100644
--- a/Source/cmInstallTargetsCommand.h
+++ b/Source/cmInstallTargetsCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "install_targets";}
+ virtual std::string GetName() const { return "install_targets";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
diff --git a/Source/cmLinkDirectoriesCommand.cxx b/Source/cmLinkDirectoriesCommand.cxx
index 4412414..3644d93 100644
--- a/Source/cmLinkDirectoriesCommand.cxx
+++ b/Source/cmLinkDirectoriesCommand.cxx
@@ -66,5 +66,5 @@ void cmLinkDirectoriesCommand::AddLinkDir(std::string const& dir)
unixPath = tmp;
}
}
- this->Makefile->AddLinkDirectory(unixPath.c_str());
+ this->Makefile->AddLinkDirectory(unixPath);
}
diff --git a/Source/cmLinkDirectoriesCommand.h b/Source/cmLinkDirectoriesCommand.h
index c6eb40c..8e04baf 100644
--- a/Source/cmLinkDirectoriesCommand.h
+++ b/Source/cmLinkDirectoriesCommand.h
@@ -43,7 +43,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "link_directories";}
+ virtual std::string GetName() const { return "link_directories";}
cmTypeMacro(cmLinkDirectoriesCommand, cmCommand);
private:
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index 2f1db2a..996b538 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -33,7 +33,7 @@ bool cmLinkLibrariesCommand
"a library");
return false;
}
- this->Makefile->AddLinkLibrary(i->c_str(),
+ this->Makefile->AddLinkLibrary(*i,
cmTarget::DEBUG);
}
else if (*i == "optimized")
@@ -45,12 +45,12 @@ bool cmLinkLibrariesCommand
"a library");
return false;
}
- this->Makefile->AddLinkLibrary(i->c_str(),
+ this->Makefile->AddLinkLibrary(*i,
cmTarget::OPTIMIZED);
}
else
{
- this->Makefile->AddLinkLibrary(i->c_str());
+ this->Makefile->AddLinkLibrary(*i);
}
}
diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h
index 74de23c..c572439 100644
--- a/Source/cmLinkLibrariesCommand.h
+++ b/Source/cmLinkLibrariesCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "link_libraries";}
+ virtual std::string GetName() const { return "link_libraries";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index df64695..f1ea088 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -69,17 +69,14 @@ bool cmListCommand
}
std::string e = "does not recognize sub-command "+subCommand;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
//----------------------------------------------------------------------------
-bool cmListCommand::GetListString(std::string& listString, const char* var)
+bool cmListCommand::GetListString(std::string& listString,
+ const std::string& var)
{
- if ( !var )
- {
- return false;
- }
// get the old value
const char* cacheValue
= this->Makefile->GetDefinition(var);
@@ -92,7 +89,8 @@ bool cmListCommand::GetListString(std::string& listString, const char* var)
}
//----------------------------------------------------------------------------
-bool cmListCommand::GetList(std::vector<std::string>& list, const char* var)
+bool cmListCommand::GetList(std::vector<std::string>& list,
+ const std::string& var)
{
std::string listString;
if ( !this->GetListString(listString, var) )
@@ -178,12 +176,12 @@ bool cmListCommand::HandleLengthCommand(std::vector<std::string> const& args)
// do not check the return value here
// if the list var is not found varArgsExpanded will have size 0
// and we will return 0
- this->GetList(varArgsExpanded, listName.c_str());
+ this->GetList(varArgsExpanded, listName);
size_t length = varArgsExpanded.size();
char buffer[1024];
sprintf(buffer, "%d", static_cast<int>(length));
- this->Makefile->AddDefinition(variableName.c_str(), buffer);
+ this->Makefile->AddDefinition(variableName, buffer);
return true;
}
@@ -200,9 +198,9 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
const std::string& variableName = args[args.size() - 1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
- this->Makefile->AddDefinition(variableName.c_str(), "NOTFOUND");
+ this->Makefile->AddDefinition(variableName, "NOTFOUND");
return true;
}
// FIXME: Add policy to make non-existing lists an error like empty lists.
@@ -231,13 +229,13 @@ bool cmListCommand::HandleGetCommand(std::vector<std::string> const& args)
str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
- this->SetError(str.str().c_str());
+ this->SetError(str.str());
return false;
}
value += varArgsExpanded[item];
}
- this->Makefile->AddDefinition(variableName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(variableName, value.c_str());
return true;
}
@@ -255,7 +253,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
const std::string& listName = args[1];
// expand the variable
std::string listString;
- this->GetListString(listString, listName.c_str());
+ this->GetListString(listString, listName);
size_t cc;
for ( cc = 2; cc < args.size(); ++ cc )
{
@@ -266,7 +264,7 @@ bool cmListCommand::HandleAppendCommand(std::vector<std::string> const& args)
listString += args[cc];
}
- this->Makefile->AddDefinition(listName.c_str(), listString.c_str());
+ this->Makefile->AddDefinition(listName, listString.c_str());
return true;
}
@@ -283,9 +281,9 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
const std::string& variableName = args[args.size() - 1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
- this->Makefile->AddDefinition(variableName.c_str(), "-1");
+ this->Makefile->AddDefinition(variableName, "-1");
return true;
}
@@ -297,13 +295,13 @@ bool cmListCommand::HandleFindCommand(std::vector<std::string> const& args)
{
char indexString[32];
sprintf(indexString, "%d", index);
- this->Makefile->AddDefinition(variableName.c_str(), indexString);
+ this->Makefile->AddDefinition(variableName, indexString);
return true;
}
index++;
}
- this->Makefile->AddDefinition(variableName.c_str(), "-1");
+ this->Makefile->AddDefinition(variableName, "-1");
return true;
}
@@ -321,12 +319,12 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
// expand the variable
int item = atoi(args[2].c_str());
std::vector<std::string> varArgsExpanded;
- if((!this->GetList(varArgsExpanded, listName.c_str())
+ if((!this->GetList(varArgsExpanded, listName)
|| varArgsExpanded.empty()) && item != 0)
{
cmOStringStream str;
str << "index: " << item << " out of range (0, 0)";
- this->SetError(str.str().c_str());
+ this->SetError(str.str());
return false;
}
@@ -343,7 +341,7 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< (varArgsExpanded.size() == 0?0:(varArgsExpanded.size()-1)) << ")";
- this->SetError(str.str().c_str());
+ this->SetError(str.str());
return false;
}
}
@@ -364,7 +362,7 @@ bool cmListCommand::HandleInsertCommand(std::vector<std::string> const& args)
sep = ";";
}
- this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -381,7 +379,7 @@ bool cmListCommand
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
this->SetError("sub-command REMOVE_ITEM requires list to be present.");
return false;
@@ -413,7 +411,7 @@ bool cmListCommand
sep = ";";
}
- this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -432,7 +430,7 @@ bool cmListCommand
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
this->SetError("sub-command REVERSE requires list to be present.");
return false;
@@ -448,7 +446,7 @@ bool cmListCommand
sep = ";";
}
- this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -467,7 +465,7 @@ bool cmListCommand
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
this->SetError(
"sub-command REMOVE_DUPLICATES requires list to be present.");
@@ -493,7 +491,7 @@ bool cmListCommand
}
- this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -512,7 +510,7 @@ bool cmListCommand
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
this->SetError("sub-command SORT requires list to be present.");
return false;
@@ -530,7 +528,7 @@ bool cmListCommand
sep = ";";
}
- this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
@@ -548,7 +546,7 @@ bool cmListCommand::HandleRemoveAtCommand(
const std::string& listName = args[1];
// expand the variable
std::vector<std::string> varArgsExpanded;
- if ( !this->GetList(varArgsExpanded, listName.c_str()) )
+ if ( !this->GetList(varArgsExpanded, listName) )
{
this->SetError("sub-command REMOVE_AT requires list to be present.");
return false;
@@ -576,7 +574,7 @@ bool cmListCommand::HandleRemoveAtCommand(
str << "index: " << item << " out of range (-"
<< varArgsExpanded.size() << ", "
<< varArgsExpanded.size()-1 << ")";
- this->SetError(str.str().c_str());
+ this->SetError(str.str());
return false;
}
removed.push_back(static_cast<size_t>(item));
@@ -604,7 +602,7 @@ bool cmListCommand::HandleRemoveAtCommand(
}
}
- this->Makefile->AddDefinition(listName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(listName, value.c_str());
return true;
}
diff --git a/Source/cmListCommand.h b/Source/cmListCommand.h
index 0cb5da2..5ea1d9f 100644
--- a/Source/cmListCommand.h
+++ b/Source/cmListCommand.h
@@ -44,7 +44,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "list";}
+ virtual std::string GetName() const { return "list";}
cmTypeMacro(cmListCommand, cmCommand);
protected:
@@ -60,8 +60,8 @@ protected:
bool HandleReverseCommand(std::vector<std::string> const& args);
- bool GetList(std::vector<std::string>& list, const char* var);
- bool GetListString(std::string& listString, const char* var);
+ bool GetList(std::vector<std::string>& list, const std::string& var);
+ bool GetListString(std::string& listString, const std::string& var);
};
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 7461d37..34781d3 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -397,12 +397,12 @@ bool cmListFileParser::AddArgument(cmListFileLexer_Token* token,
<< "Argument not separated from preceding token by whitespace.";
if(isError)
{
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, m.str());
return false;
}
else
{
- this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str().c_str());
+ this->Makefile->IssueMessage(cmake::AUTHOR_WARNING, m.str());
return true;
}
}
diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx
index dfd98fa..427e29d 100644
--- a/Source/cmLoadCacheCommand.cxx
+++ b/Source/cmLoadCacheCommand.cxx
@@ -33,7 +33,7 @@ bool cmLoadCacheCommand
// and they can not be overridden.
bool excludeFiles=false;
unsigned int i;
- std::set<cmStdString> excludes;
+ std::set<std::string> excludes;
for(i=0; i<args.size(); i++)
{
@@ -55,7 +55,7 @@ bool cmLoadCacheCommand
// If this set is empty, no internal cache entries are
// brought in.
bool includeFiles=false;
- std::set<cmStdString> includes;
+ std::set<std::string> includes;
for(i=0; i<args.size(); i++)
{
@@ -81,7 +81,7 @@ bool cmLoadCacheCommand
{
break;
}
- this->Makefile->GetCacheManager()->LoadCache(args[i].c_str(), false,
+ this->Makefile->GetCacheManager()->LoadCache(args[i], false,
excludes, includes);
}
@@ -104,7 +104,7 @@ bool cmLoadCacheCommand::ReadWithPrefix(std::vector<std::string> const& args)
if(!cmSystemTools::FileExists(cacheFile.c_str()))
{
std::string e = "Cannot load cache file from " + cacheFile;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -186,11 +186,11 @@ void cmLoadCacheCommand::CheckLine(const char* line)
var = this->Prefix + var;
if(value.length())
{
- this->Makefile->AddDefinition(var.c_str(), value.c_str());
+ this->Makefile->AddDefinition(var, value.c_str());
}
else
{
- this->Makefile->RemoveDefinition(var.c_str());
+ this->Makefile->RemoveDefinition(var);
}
}
}
diff --git a/Source/cmLoadCacheCommand.h b/Source/cmLoadCacheCommand.h
index c8f7236..04207d0 100644
--- a/Source/cmLoadCacheCommand.h
+++ b/Source/cmLoadCacheCommand.h
@@ -40,12 +40,12 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "load_cache";}
+ virtual std::string GetName() const { return "load_cache";}
cmTypeMacro(cmLoadCacheCommand, cmCommand);
protected:
- std::set<cmStdString> VariablesToRead;
+ std::set<std::string> VariablesToRead;
std::string Prefix;
bool ReadWithPrefix(std::vector<std::string> const& args);
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 21ee0fe..a4063a6 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -69,7 +69,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return info.Name; }
+ virtual std::string GetName() const { return info.Name; }
static const char* LastName;
static void TrapsForSignals(int sig)
@@ -201,7 +201,7 @@ bool cmLoadCommandCommand
// Start by removing the definition in case of failure.
std::string reportVar = "CMAKE_LOADED_COMMAND_";
reportVar += args[0];
- this->Makefile->RemoveDefinition(reportVar.c_str());
+ this->Makefile->RemoveDefinition(reportVar);
// the file must exist
std::string moduleName =
@@ -219,7 +219,7 @@ bool cmLoadCommandCommand
cmSystemTools::ExpandRegistryValues(exp);
// Glob the entry in case of wildcards.
- cmSystemTools::GlobDirs(exp.c_str(), path);
+ cmSystemTools::GlobDirs(exp, path);
}
// Try to find the program.
@@ -229,7 +229,7 @@ bool cmLoadCommandCommand
cmOStringStream e;
e << "Attempt to load command failed from file \""
<< moduleName << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -246,12 +246,12 @@ bool cmLoadCommandCommand
err += " Additional error info is:\n";
err += error;
}
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
// Report what file was loaded for this command.
- this->Makefile->AddDefinition(reportVar.c_str(), fullPath.c_str());
+ this->Makefile->AddDefinition(reportVar, fullPath.c_str());
// find the init function
std::string initFuncName = args[0] + "Init";
diff --git a/Source/cmLoadCommandCommand.h b/Source/cmLoadCommandCommand.h
index 11bcf09..4581269 100644
--- a/Source/cmLoadCommandCommand.h
+++ b/Source/cmLoadCommandCommand.h
@@ -20,7 +20,7 @@ public:
virtual cmCommand* Clone() { return new cmLoadCommandCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const {return "load_command";}
+ virtual std::string GetName() const {return "load_command";}
virtual bool IsDiscouraged() const { return true; }
cmTypeMacro(cmLoadCommandCommand, cmCommand);
};
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 7890379..f375b5f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -22,6 +22,7 @@
#include "cmSourceFile.h"
#include "cmTest.h"
#include "cmTestGenerator.h"
+#include "cmCustomCommandGenerator.h"
#include "cmVersion.h"
#include "cmake.h"
@@ -281,7 +282,7 @@ void cmLocalGenerator::GenerateTestFiles()
// Compute the set of configurations.
std::vector<std::string> configurationTypes;
- const char* config =
+ const std::string& config =
this->Makefile->GetConfigurations(configurationTypes, false);
std::string file = this->Makefile->GetStartOutputDirectory();
@@ -326,7 +327,7 @@ void cmLocalGenerator::GenerateTestFiles()
fout << "subdirs(";
std::string outP =
this->Children[i]->GetMakefile()->GetStartOutputDirectory();
- fout << this->Convert(outP.c_str(),START_OUTPUT);
+ fout << this->Convert(outP,START_OUTPUT);
fout << ")" << std::endl;
}
}
@@ -385,11 +386,11 @@ void cmLocalGenerator::GenerateInstallRules()
// Compute the set of configurations.
std::vector<std::string> configurationTypes;
- const char* config =
+ const std::string& config =
this->Makefile->GetConfigurations(configurationTypes, false);
// Choose a default install configuration.
- const char* default_config = config;
+ const char* default_config = config.c_str();
const char* default_order[] = {"RELEASE", "MINSIZEREL",
"RELWITHDEBINFO", "DEBUG", 0};
for(const char** c = default_order; *c && !default_config; ++c)
@@ -504,7 +505,7 @@ void cmLocalGenerator::GenerateInstallRules()
{
std::string odir = (*ci)->GetMakefile()->GetStartOutputDirectory();
cmSystemTools::ConvertToUnixSlashes(odir);
- fout << " include(\"" << odir.c_str()
+ fout << " include(\"" << odir
<< "/cmake_install.cmake\")" << std::endl;
}
}
@@ -524,12 +525,12 @@ void cmLocalGenerator::GenerateInstallRules()
"endif()\n\n";
fout
<< "file(WRITE \""
- << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" "
+ << homedir << "/${CMAKE_INSTALL_MANIFEST}\" "
<< "\"\")" << std::endl;
fout
<< "foreach(file ${CMAKE_INSTALL_MANIFEST_FILES})" << std::endl
<< " file(APPEND \""
- << homedir.c_str() << "/${CMAKE_INSTALL_MANIFEST}\" "
+ << homedir << "/${CMAKE_INSTALL_MANIFEST}\" "
<< "\"${file}\\n\")" << std::endl
<< "endforeach()" << std::endl;
}
@@ -541,6 +542,10 @@ void cmLocalGenerator::GenerateTargetManifest()
// Collect the set of configuration types.
std::vector<std::string> configNames;
this->Makefile->GetConfigurations(configNames);
+ if(configNames.empty())
+ {
+ configNames.push_back("");
+ }
// Add our targets to the manifest for each configuration.
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
@@ -556,42 +561,35 @@ void cmLocalGenerator::GenerateTargetManifest()
{
continue;
}
- if(configNames.empty())
+ for(std::vector<std::string>::iterator ci = configNames.begin();
+ ci != configNames.end(); ++ci)
{
- target.GenerateTargetManifest(0);
- }
- else
- {
- for(std::vector<std::string>::iterator ci = configNames.begin();
- ci != configNames.end(); ++ci)
- {
- const char* config = ci->c_str();
- target.GenerateTargetManifest(config);
- }
+ const char* config = ci->c_str();
+ target.GenerateTargetManifest(config);
}
}
}
void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
- const char* lang,
+ const std::string& lang,
cmSourceFile& source,
cmGeneratorTarget& target)
{
std::string objectDir = cmSystemTools::GetFilenamePath(std::string(ofname));
- objectDir = this->Convert(objectDir.c_str(),START_OUTPUT,SHELL);
+ objectDir = this->Convert(objectDir,START_OUTPUT,SHELL);
std::string objectFile = this->Convert(ofname,START_OUTPUT,SHELL);
std::string sourceFile =
- this->Convert(source.GetFullPath().c_str(),START_OUTPUT,SHELL,true);
+ this->Convert(source.GetFullPath(),START_OUTPUT,SHELL,true);
std::string varString = "CMAKE_";
varString += lang;
varString += "_COMPILE_OBJECT";
std::vector<std::string> rules;
- rules.push_back(this->Makefile->GetRequiredDefinition(varString.c_str()));
+ rules.push_back(this->Makefile->GetRequiredDefinition(varString));
varString = "CMAKE_";
varString += lang;
varString += "_FLAGS";
std::string flags;
- flags += this->Makefile->GetSafeDefinition(varString.c_str());
+ flags += this->Makefile->GetSafeDefinition(varString);
flags += " ";
{
std::vector<std::string> includes;
@@ -605,7 +603,7 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
std::vector<std::string> commands;
cmSystemTools::ExpandList(rules, commands);
cmLocalGenerator::RuleVariables vars;
- vars.Language = lang;
+ vars.Language = lang.c_str();
vars.Source = sourceFile.c_str();
vars.Object = objectFile.c_str();
vars.ObjectDir = objectDir.c_str();
@@ -618,8 +616,8 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
// Parse the string to get the custom command line.
cmCustomCommandLine commandLine;
- std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
- for(std::vector<cmStdString>::iterator a = cmd.begin();
+ 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);
@@ -647,21 +645,22 @@ void cmLocalGenerator::AddCustomCommandToCreateObject(const char* ofname,
this->Makefile->AddCustomCommandToOutput(
ofname,
depends,
- source.GetFullPath().c_str(),
+ source.GetFullPath(),
commandLines,
comment.c_str(),
this->Makefile->GetStartOutputDirectory()
);
}
-void cmLocalGenerator::AddBuildTargetRule(const char* llang,
+void cmLocalGenerator::AddBuildTargetRule(const std::string& llang,
cmGeneratorTarget& target)
{
- cmStdString objs;
+ std::string objs;
std::vector<std::string> objVector;
// Add all the sources outputs to the depends of the target
std::vector<cmSourceFile*> classes;
- target.GetSourceFiles(classes);
+ target.GetSourceFiles(classes,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); ++i)
{
@@ -682,7 +681,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
objVector.push_back(ofname);
this->AddCustomCommandToCreateObject(ofname.c_str(),
llang, *(*i), target);
- objs += this->Convert(ofname.c_str(),START_OUTPUT,MAKEFILE);
+ objs += this->Convert(ofname,START_OUTPUT,MAKEFILE);
objs += " ";
}
}
@@ -690,6 +689,7 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
std::string createRule = "CMAKE_";
createRule += llang;
createRule += target.GetCreateRuleVariable();
+ bool useWatcomQuote = this->Makefile->IsOn(createRule+"_USE_WATCOM_QUOTE");
std::string targetName = target.Target->GetFullName();
// Executable :
// Shared Library:
@@ -701,10 +701,10 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
std::string flags; // should be set
std::string linkFlags; // should be set
this->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
- &target);
+ &target, useWatcomQuote);
linkLibs = frameworkPath + linkPath + linkLibs;
cmLocalGenerator::RuleVariables vars;
- vars.Language = llang;
+ vars.Language = llang.c_str();
vars.Objects = objs.c_str();
vars.ObjectDir = ".";
vars.Target = targetName.c_str();
@@ -713,13 +713,13 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
vars.LinkFlags = linkFlags.c_str();
std::string langFlags;
- this->AddLanguageFlags(langFlags, llang, 0);
- this->AddArchitectureFlags(langFlags, &target, llang, 0);
+ this->AddLanguageFlags(langFlags, llang, "");
+ this->AddArchitectureFlags(langFlags, &target, llang, "");
vars.LanguageCompileFlags = langFlags.c_str();
cmCustomCommandLines commandLines;
std::vector<std::string> rules;
- rules.push_back(this->Makefile->GetRequiredDefinition(createRule.c_str()));
+ rules.push_back(this->Makefile->GetRequiredDefinition(createRule));
std::vector<std::string> commands;
cmSystemTools::ExpandList(rules, commands);
for(std::vector<std::string>::iterator i = commands.begin();
@@ -729,8 +729,8 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
this->ExpandRuleVariables(*i, vars);
// Parse the string to get the custom command line.
cmCustomCommandLine commandLine;
- std::vector<cmStdString> cmd = cmSystemTools::ParseArguments(i->c_str());
- for(std::vector<cmStdString>::iterator a = cmd.begin();
+ 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);
@@ -744,22 +744,22 @@ void cmLocalGenerator::AddBuildTargetRule(const char* llang,
std::string comment = "Linking ";
comment += llang;
comment += " target ";
- comment += this->Convert(targetFullPath.c_str(), START_OUTPUT);
+ comment += this->Convert(targetFullPath, START_OUTPUT);
this->Makefile->AddCustomCommandToOutput(
- targetFullPath.c_str(),
+ targetFullPath,
objVector,
- 0,
+ "",
commandLines,
comment.c_str(),
this->Makefile->GetStartOutputDirectory()
);
- target.Target->AddSourceFile
- (this->Makefile->GetSource(targetFullPath.c_str()));
+ this->Makefile->GetSource(targetFullPath);
+ target.Target->AddSource(targetFullPath);
}
void cmLocalGenerator
-::CreateCustomTargetsAndCommands(std::set<cmStdString> const& lang)
+::CreateCustomTargetsAndCommands(std::set<std::string> const& lang)
{
cmGeneratorTargetsType tgts = this->Makefile->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator l = tgts.begin();
@@ -777,12 +777,12 @@ void cmLocalGenerator
case cmTarget::MODULE_LIBRARY:
case cmTarget::EXECUTABLE:
{
- const char* llang = target.Target->GetLinkerLanguage();
- if(!llang)
+ std::string llang = target.Target->GetLinkerLanguage();
+ if(llang.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
- target.Target->GetName());
+ target.Target->GetName().c_str());
return;
}
// if the language is not in the set lang then create custom
@@ -902,6 +902,13 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
return replaceValues.TargetPDB;
}
}
+ if(replaceValues.TargetCompilePDB)
+ {
+ if(variable == "TARGET_COMPILE_PDB")
+ {
+ return replaceValues.TargetCompilePDB;
+ }
+ }
if(replaceValues.DependencyFile )
{
if(variable == "DEP_FILE")
@@ -1075,28 +1082,28 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
{
std::string arg1 = actualReplace + "_ARG1";
cmSystemTools::ReplaceString(arg1, "${LANG}", lang);
- compilerArg1 = this->Makefile->GetDefinition(arg1.c_str());
+ compilerArg1 = this->Makefile->GetDefinition(arg1);
compilerTarget
= this->Makefile->GetDefinition(
- (std::string("CMAKE_") + lang + "_COMPILER_TARGET").c_str());
+ std::string("CMAKE_") + lang + "_COMPILER_TARGET");
compilerOptionTarget
= this->Makefile->GetDefinition(
- (std::string("CMAKE_") + lang +
- "_COMPILE_OPTIONS_TARGET").c_str());
+ std::string("CMAKE_") + lang +
+ "_COMPILE_OPTIONS_TARGET");
compilerExternalToolchain
= this->Makefile->GetDefinition(
- (std::string("CMAKE_") + lang +
- "_COMPILER_EXTERNAL_TOOLCHAIN").c_str());
+ std::string("CMAKE_") + lang +
+ "_COMPILER_EXTERNAL_TOOLCHAIN");
compilerOptionExternalToolchain
= this->Makefile->GetDefinition(
- (std::string("CMAKE_") + lang +
- "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN").c_str());
+ std::string("CMAKE_") + lang +
+ "_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN");
compilerSysroot
= this->Makefile->GetDefinition("CMAKE_SYSROOT");
compilerOptionSysroot
= this->Makefile->GetDefinition(
- (std::string("CMAKE_") + lang +
- "_COMPILE_OPTIONS_SYSROOT").c_str());
+ std::string("CMAKE_") + lang +
+ "_COMPILE_OPTIONS_SYSROOT");
}
if(actualReplace.find("${LANG}") != actualReplace.npos)
{
@@ -1105,11 +1112,11 @@ cmLocalGenerator::ExpandRuleVariable(std::string const& variable,
if(actualReplace == variable)
{
std::string replace =
- this->Makefile->GetSafeDefinition(variable.c_str());
+ this->Makefile->GetSafeDefinition(variable);
// if the variable is not a FLAG then treat it like a path
if(variable.find("_FLAG") == variable.npos)
{
- std::string ret = this->ConvertToOutputForExisting(replace.c_str());
+ std::string ret = this->ConvertToOutputForExisting(replace);
// if there is a required first argument to the compiler add it
// to the compiler string
if(compilerArg1)
@@ -1150,8 +1157,11 @@ void
cmLocalGenerator::ExpandRuleVariables(std::string& s,
const RuleVariables& replaceValues)
{
- this->InsertRuleLauncher(s, replaceValues.CMTarget,
- replaceValues.RuleLauncher);
+ if(replaceValues.RuleLauncher)
+ {
+ this->InsertRuleLauncher(s, replaceValues.CMTarget,
+ replaceValues.RuleLauncher);
+ }
std::string::size_type start = s.find('<');
// no variables to expand
if(start == s.npos)
@@ -1195,7 +1205,7 @@ cmLocalGenerator::ExpandRuleVariables(std::string& s,
//----------------------------------------------------------------------------
const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
- const char* prop)
+ const std::string& prop)
{
if(target)
{
@@ -1209,7 +1219,7 @@ const char* cmLocalGenerator::GetRuleLauncher(cmTarget* target,
//----------------------------------------------------------------------------
void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
- const char* prop)
+ const std::string& prop)
{
if(const char* val = this->GetRuleLauncher(target, prop))
{
@@ -1221,19 +1231,20 @@ void cmLocalGenerator::InsertRuleLauncher(std::string& s, cmTarget* target,
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
- std::string const& result)
+cmLocalGenerator::ConvertToOutputForExistingCommon(const std::string& remote,
+ std::string const& result,
+ OutputFormat format)
{
// If this is a windows shell, the result has a space, and the path
// already exists, we can use a short-path to reference it without a
// space.
if(this->WindowsShell && result.find(' ') != result.npos &&
- cmSystemTools::FileExists(remote))
+ cmSystemTools::FileExists(remote.c_str()))
{
std::string tmp;
- if(cmSystemTools::GetShortPath(remote, tmp))
+ if(cmSystemTools::GetShortPath(remote.c_str(), tmp))
{
- return this->Convert(tmp.c_str(), NONE, SHELL, true);
+ return this->Convert(tmp, NONE, format, true);
}
}
@@ -1243,57 +1254,62 @@ cmLocalGenerator::ConvertToOutputForExistingCommon(const char* remote,
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConvertToOutputForExisting(const char* remote,
- RelativeRoot local)
+cmLocalGenerator::ConvertToOutputForExisting(const std::string& remote,
+ RelativeRoot local,
+ OutputFormat format)
{
// Perform standard conversion.
- std::string result = this->Convert(remote, local, SHELL, true);
+ std::string result = this->Convert(remote, local, format, true);
// Consider short-path.
- return this->ConvertToOutputForExistingCommon(remote, result);
+ return this->ConvertToOutputForExistingCommon(remote, result, format);
}
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConvertToOutputForExisting(RelativeRoot remote,
- const char* local)
+ const std::string& local,
+ OutputFormat format)
{
// Perform standard conversion.
- std::string result = this->Convert(remote, local, SHELL, true);
+ std::string result = this->Convert(remote, local, format, true);
// Consider short-path.
const char* remotePath = this->GetRelativeRootPath(remote);
- return this->ConvertToOutputForExistingCommon(remotePath, result);
+ return this->ConvertToOutputForExistingCommon(remotePath, result, format);
}
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalGenerator::ConvertToIncludeReference(std::string const& path,
+ OutputFormat format)
{
- return this->ConvertToOutputForExisting(path.c_str());
+ return this->ConvertToOutputForExisting(path, START_OUTPUT, format);
}
//----------------------------------------------------------------------------
std::string cmLocalGenerator::GetIncludeFlags(
const std::vector<std::string> &includes,
cmGeneratorTarget* target,
- const char* lang, bool forResponseFile,
- const char *config)
+ const std::string& lang,
+ bool forResponseFile,
+ const std::string& config)
{
- if(!lang)
+ if(lang.empty())
{
return "";
}
+ OutputFormat shellFormat = forResponseFile? RESPONSE : SHELL;
cmOStringStream includeFlags;
std::string flagVar = "CMAKE_INCLUDE_FLAG_";
flagVar += lang;
const char* includeFlag =
- this->Makefile->GetSafeDefinition(flagVar.c_str());
+ this->Makefile->GetSafeDefinition(flagVar);
flagVar = "CMAKE_INCLUDE_FLAG_SEP_";
flagVar += lang;
- const char* sep = this->Makefile->GetDefinition(flagVar.c_str());
+ const char* sep = this->Makefile->GetDefinition(flagVar);
bool quotePaths = false;
if(this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS"))
{
@@ -1319,17 +1335,17 @@ std::string cmLocalGenerator::GetIncludeFlags(
const char* sysIncludeFlag = 0;
if(repeatFlag)
{
- sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar.c_str());
+ sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
}
std::string fwSearchFlagVar = "CMAKE_";
fwSearchFlagVar += lang;
fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
const char* fwSearchFlag =
- this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+ this->Makefile->GetDefinition(fwSearchFlagVar);
bool flagUsed = false;
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
#ifdef __APPLE__
emitted.insert("/System/Library/Frameworks");
#endif
@@ -1344,10 +1360,9 @@ std::string cmLocalGenerator::GetIncludeFlags(
frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir.c_str());
if(emitted.insert(frameworkDir).second)
{
- OutputFormat format = forResponseFile? RESPONSE : SHELL;
includeFlags
- << fwSearchFlag << this->Convert(frameworkDir.c_str(),
- START_OUTPUT, format, true)
+ << fwSearchFlag << this->Convert(frameworkDir,
+ START_OUTPUT, shellFormat, true)
<< " ";
}
continue;
@@ -1356,7 +1371,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
if(!flagUsed || repeatFlag)
{
if(sysIncludeFlag && target &&
- target->IsSystemIncludeDirectory(i->c_str(), config))
+ target->IsSystemIncludeDirectory(*i, config))
{
includeFlags << sysIncludeFlag;
}
@@ -1366,16 +1381,8 @@ std::string cmLocalGenerator::GetIncludeFlags(
}
flagUsed = true;
}
- std::string includePath;
- if(forResponseFile)
- {
- includePath = this->Convert(i->c_str(), START_OUTPUT,
- RESPONSE, true);
- }
- else
- {
- includePath = this->ConvertToIncludeReference(*i);
- }
+ std::string includePath =
+ this->ConvertToIncludeReference(*i, shellFormat);
if(quotePaths && includePath.size() && includePath[0] != '\"')
{
includeFlags << "\"";
@@ -1399,7 +1406,7 @@ std::string cmLocalGenerator::GetIncludeFlags(
//----------------------------------------------------------------------------
void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
cmTarget const* target,
- const char* config)
+ const std::string& config)
{
std::vector<std::string> targetDefines;
target->GetCompileDefinitions(targetDefines,
@@ -1410,12 +1417,12 @@ void cmLocalGenerator::AddCompileDefinitions(std::set<std::string>& defines,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddCompileOptions(
std::string& flags, cmTarget* target,
- const char* lang, const char* config
+ const std::string& lang, const std::string& config
)
{
std::string langFlagRegexVar = std::string("CMAKE_")+lang+"_FLAG_REGEX";
if(const char* langFlagRegexStr =
- this->Makefile->GetDefinition(langFlagRegexVar.c_str()))
+ this->Makefile->GetDefinition(langFlagRegexVar))
{
// Filter flags acceptable to this language.
cmsys::RegularExpression r(langFlagRegexStr);
@@ -1432,7 +1439,7 @@ void cmLocalGenerator::AddCompileOptions(
{
// (Re-)Escape this flag. COMPILE_FLAGS were already parsed
// as a command line above, and COMPILE_OPTIONS are escaped.
- this->AppendFlagEscape(flags, i->c_str());
+ this->AppendFlagEscape(flags, *i);
}
}
}
@@ -1450,16 +1457,27 @@ void cmLocalGenerator::AddCompileOptions(
i != opts.end(); ++i)
{
// COMPILE_OPTIONS are escaped.
- this->AppendFlagEscape(flags, i->c_str());
+ this->AppendFlagEscape(flags, *i);
+ }
+ }
+ std::vector<std::string> features;
+ target->GetCompileFeatures(features, config);
+ for(std::vector<std::string>::const_iterator it = features.begin();
+ it != features.end(); ++it)
+ {
+ if (!this->Makefile->AddRequiredTargetFeature(target, *it))
+ {
+ return;
}
}
+ this->AddCompilerRequirementFlag(flags, target, lang);
}
//----------------------------------------------------------------------------
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget* target,
- const char* lang,
- const char *config,
+ const std::string& lang,
+ const std::string& config,
bool stripImplicitInclDirs
)
{
@@ -1482,7 +1500,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
}
// Do not repeat an include path.
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
// Store the automatic include paths.
if(includeBinaryDir)
@@ -1515,7 +1533,7 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
std::string impDirVar = "CMAKE_";
impDirVar += lang;
impDirVar += "_IMPLICIT_INCLUDE_DIRECTORIES";
- if(const char* value = this->Makefile->GetDefinition(impDirVar.c_str()))
+ if(const char* value = this->Makefile->GetDefinition(impDirVar))
{
std::vector<std::string> impDirVec;
cmSystemTools::ExpandListArgument(value, impDirVec);
@@ -1590,13 +1608,13 @@ void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
if(!config.empty())
{
std::string name = "CMAKE_STATIC_LINKER_FLAGS_" + config;
- this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name.c_str()));
+ this->AppendFlags(flags, this->Makefile->GetSafeDefinition(name));
}
this->AppendFlags(flags, target->GetProperty("STATIC_LIBRARY_FLAGS"));
if(!config.empty())
{
std::string name = "STATIC_LIBRARY_FLAGS_" + config;
- this->AppendFlags(flags, target->GetProperty(name.c_str()));
+ this->AppendFlags(flags, target->GetProperty(name));
}
}
@@ -1605,7 +1623,8 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
std::string& linkFlags,
std::string& frameworkPath,
std::string& linkPath,
- cmGeneratorTarget* target)
+ cmGeneratorTarget* target,
+ bool useWatcomQuote)
{
std::string buildType =
this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
@@ -1629,14 +1648,14 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
std::string build = libraryLinkVariable;
build += "_";
build += buildType;
- linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
+ linkFlags += this->Makefile->GetSafeDefinition(build);
linkFlags += " ";
}
if(this->Makefile->IsOn("WIN32") &&
!(this->Makefile->IsOn("CYGWIN") || this->Makefile->IsOn("MINGW")))
{
std::vector<cmSourceFile*> sources;
- target->GetSourceFiles(sources);
+ target->GetSourceFiles(sources, buildType);
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
i != sources.end(); ++i)
{
@@ -1645,7 +1664,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{
linkFlags +=
this->Makefile->GetSafeDefinition("CMAKE_LINK_DEF_FILE_FLAG");
- linkFlags += this->Convert(sf->GetFullPath().c_str(),
+ linkFlags += this->Convert(sf->GetFullPath(),
FULL, SHELL);
linkFlags += " ";
}
@@ -1661,7 +1680,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{
std::string configLinkFlags = "LINK_FLAGS_";
configLinkFlags += buildType;
- targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
+ targetLinkFlags = target->GetProperty(configLinkFlags);
if(targetLinkFlags)
{
linkFlags += targetLinkFlags;
@@ -1669,7 +1688,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
}
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *target, false);
+ *target, false, false, useWatcomQuote);
}
break;
case cmTarget::EXECUTABLE:
@@ -1681,26 +1700,26 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{
std::string build = "CMAKE_EXE_LINKER_FLAGS_";
build += buildType;
- linkFlags += this->Makefile->GetSafeDefinition(build.c_str());
+ linkFlags += this->Makefile->GetSafeDefinition(build);
linkFlags += " ";
}
- const char* linkLanguage = target->Target->GetLinkerLanguage();
- if(!linkLanguage)
+ std::string linkLanguage = target->Target->GetLinkerLanguage(buildType);
+ if(linkLanguage.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
- target->Target->GetName());
+ target->Target->GetName().c_str());
return;
}
- this->AddLanguageFlags(flags, linkLanguage, buildType.c_str());
+ this->AddLanguageFlags(flags, linkLanguage, buildType);
this->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *target, false);
+ *target, false, false, useWatcomQuote);
if(cmSystemTools::IsOn
(this->Makefile->GetDefinition("BUILD_SHARED_LIBS")))
{
std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_")
+ linkLanguage + std::string("_FLAGS");
- linkFlags += this->Makefile->GetSafeDefinition(sFlagVar.c_str());
+ linkFlags += this->Makefile->GetSafeDefinition(sFlagVar);
linkFlags += " ";
}
if ( target->GetPropertyAsBool("WIN32_EXECUTABLE") )
@@ -1722,7 +1741,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
exportFlagVar += "_FLAG";
linkFlags +=
- this->Makefile->GetSafeDefinition(exportFlagVar.c_str());
+ this->Makefile->GetSafeDefinition(exportFlagVar);
linkFlags += " ";
}
const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
@@ -1735,7 +1754,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
{
std::string configLinkFlags = "LINK_FLAGS_";
configLinkFlags += buildType;
- targetLinkFlags = target->GetProperty(configLinkFlags.c_str());
+ targetLinkFlags = target->GetProperty(configLinkFlags);
if(targetLinkFlags)
{
linkFlags += targetLinkFlags;
@@ -1749,12 +1768,12 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs,
}
}
-std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
+std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib,
+ OutputFormat format)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
- // Work-ardound command line parsing limitations in MSVC 6.0 and
- // Watcom.
- if(this->Makefile->IsOn("MSVC60") || this->Makefile->IsOn("WATCOM"))
+ // Work-ardound command line parsing limitations in MSVC 6.0
+ if(this->Makefile->IsOn("MSVC60"))
{
// Search for the last space.
std::string::size_type pos = lib.rfind(' ');
@@ -1771,14 +1790,14 @@ std::string cmLocalGenerator::ConvertToLinkReference(std::string const& lib)
sp += lib.substr(pos);
// Convert to an output path.
- return this->Convert(sp.c_str(), NONE, SHELL);
+ return this->Convert(sp.c_str(), NONE, format);
}
}
}
#endif
// Normal behavior.
- return this->Convert(lib.c_str(), START_OUTPUT, SHELL);
+ return this->Convert(lib, START_OUTPUT, format);
}
/**
@@ -1790,8 +1809,13 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget &tgt,
- bool relink)
+ bool relink,
+ bool forResponseFile,
+ bool useWatcomQuote)
{
+ OutputFormat shellFormat = (forResponseFile) ? RESPONSE :
+ ((useWatcomQuote) ? WATCOMQUOTE : SHELL);
+ bool escapeAllowMakeVars = !forResponseFile;
cmOStringStream fout;
const char* config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config);
@@ -1804,7 +1828,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
// Collect library linking flags command line options.
std::string linkLibs;
- const char* linkLanguage = cli.GetLinkLanguage();
+ std::string linkLanguage = cli.GetLinkLanguage();
std::string libPathFlag =
this->Makefile->GetRequiredDefinition("CMAKE_LIBRARY_PATH_FLAG");
@@ -1817,7 +1841,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
linkFlagsVar += "_FLAGS";
if( tgt.GetType() == cmTarget::EXECUTABLE )
{
- linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar.c_str());
+ linkLibs = this->Makefile->GetSafeDefinition(linkFlagsVar);
linkLibs += " ";
}
@@ -1826,7 +1850,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
fwSearchFlagVar += linkLanguage;
fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG";
const char* fwSearchFlag =
- this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+ this->Makefile->GetDefinition(fwSearchFlagVar);
if(fwSearchFlag && *fwSearchFlag)
{
std::vector<std::string> const& fwDirs = cli.GetFrameworkPaths();
@@ -1834,7 +1858,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
fdi != fwDirs.end(); ++fdi)
{
frameworkPath += fwSearchFlag;
- frameworkPath += this->Convert(fdi->c_str(), NONE, SHELL, false);
+ frameworkPath += this->Convert(*fdi, NONE, shellFormat, false);
frameworkPath += " ";
}
}
@@ -1844,7 +1868,9 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
for(std::vector<std::string>::const_iterator libDir = libDirs.begin();
libDir != libDirs.end(); ++libDir)
{
- std::string libpath = this->ConvertToOutputForExisting(libDir->c_str());
+ std::string libpath = this->ConvertToOutputForExisting(*libDir,
+ START_OUTPUT,
+ shellFormat);
linkPath += " " + libPathFlag;
linkPath += libpath;
linkPath += libPathTerminator;
@@ -1862,7 +1888,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
}
if(li->IsPath)
{
- linkLibs += this->ConvertToLinkReference(li->Value);
+ linkLibs += this->ConvertToLinkReference(li->Value, shellFormat);
}
else
{
@@ -1887,7 +1913,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
ri != runtimeDirs.end(); ++ri)
{
rpath += cli.GetRuntimeFlag();
- rpath += this->Convert(ri->c_str(), NONE, SHELL, false);
+ rpath += this->Convert(*ri, NONE, shellFormat, false);
rpath += " ";
}
fout << rpath;
@@ -1901,7 +1927,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
if(!rpath.empty())
{
fout << cli.GetRuntimeFlag();
- fout << this->EscapeForShell(rpath.c_str(), true);
+ fout << this->EscapeForShell(rpath, escapeAllowMakeVars);
fout << " ";
}
}
@@ -1911,7 +1937,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
if(!cli.GetRPathLinkFlag().empty() && !rpath_link.empty())
{
fout << cli.GetRPathLinkFlag();
- fout << this->EscapeForShell(rpath_link.c_str(), true);
+ fout << this->EscapeForShell(rpath_link, escapeAllowMakeVars);
fout << " ";
}
@@ -1920,7 +1946,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
standardLibsVar += cli.GetLinkLanguage();
standardLibsVar += "_STANDARD_LIBRARIES";
if(const char* stdLibs =
- this->Makefile->GetDefinition(standardLibsVar.c_str()))
+ this->Makefile->GetDefinition(standardLibsVar))
{
fout << stdLibs << " ";
}
@@ -1932,8 +1958,8 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
cmGeneratorTarget* target,
- const char *lang,
- const char* config)
+ const std::string& lang,
+ const std::string& config)
{
// Only add Mac OS X specific flags on Darwin platforms (OSX and iphone):
if(!this->Makefile->IsOn("APPLE"))
@@ -1951,14 +1977,14 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
std::string sysrootFlagVar =
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
const char* sysrootFlag =
- this->Makefile->GetDefinition(sysrootFlagVar.c_str());
+ this->Makefile->GetDefinition(sysrootFlagVar);
const char* deploymentTarget =
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
std::string deploymentTargetFlagVar =
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
const char* deploymentTargetFlag =
- this->Makefile->GetDefinition(deploymentTargetFlagVar.c_str());
- if(!archs.empty() && lang && (lang[0] =='C' || lang[0] == 'F'))
+ this->Makefile->GetDefinition(deploymentTargetFlagVar);
+ if(!archs.empty() && !lang.empty() && (lang[0] =='C' || lang[0] == 'F'))
{
for(std::vector<std::string>::iterator i = archs.begin();
i != archs.end(); ++i)
@@ -1989,19 +2015,19 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddLanguageFlags(std::string& flags,
- const char* lang,
- const char* config)
+ const std::string& lang,
+ const std::string& config)
{
// Add language-specific flags.
std::string flagsVar = "CMAKE_";
flagsVar += lang;
flagsVar += "_FLAGS";
- this->AddConfigVariableFlags(flags, flagsVar.c_str(), config);
+ this->AddConfigVariableFlags(flags, flagsVar, config);
}
//----------------------------------------------------------------------------
-bool cmLocalGenerator::GetRealDependency(const char* inName,
- const char* config,
+bool cmLocalGenerator::GetRealDependency(const std::string& inName,
+ const std::string& config,
std::string& dep)
{
// Older CMake code may specify the dependency using the target
@@ -2028,7 +2054,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
{
// make sure it is not just a coincidence that the target name
// found is part of the inName
- if(cmSystemTools::FileIsFullPath(inName))
+ if(cmSystemTools::FileIsFullPath(inName.c_str()))
{
std::string tLocation;
if(target->GetType() >= cmTarget::EXECUTABLE &&
@@ -2076,7 +2102,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
}
// The name was not that of a CMake target. It must name a file.
- if(cmSystemTools::FileIsFullPath(inName))
+ if(cmSystemTools::FileIsFullPath(inName.c_str()))
{
// This is a full path. Return it as given.
dep = inName;
@@ -2101,7 +2127,7 @@ bool cmLocalGenerator::GetRealDependency(const char* inName,
//----------------------------------------------------------------------------
void cmLocalGenerator::AddSharedFlags(std::string& flags,
- const char* lang,
+ const std::string& lang,
bool shared)
{
std::string flagsVar;
@@ -2112,23 +2138,52 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
flagsVar = "CMAKE_SHARED_LIBRARY_";
flagsVar += lang;
flagsVar += "_FLAGS";
- this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
+ this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmLocalGenerator::
+AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+ const std::string& lang)
+{
+ if (lang.empty())
+ {
+ return;
+ }
+ std::string stdProp = lang + "_STANDARD";
+ const char *standard = target->GetProperty(stdProp);
+ if (!standard)
+ {
+ return;
+ }
+ std::string extProp = lang + "_EXTENSIONS";
+ bool ext = target->GetPropertyAsBool(extProp);
+ std::string type = ext ? "EXTENSION" : "STANDARD";
+
+ std::string compile_option =
+ "CMAKE_" + lang + std::string(standard)
+ + "_" + type + "_COMPILE_OPTION";
+ if (const char *opt = target->GetMakefile()->GetDefinition(compile_option))
+ {
+ this->AppendFlags(flags, opt);
}
}
static void AddVisibilityCompileOption(std::string &flags, cmTarget* target,
- cmLocalGenerator *lg, const char *lang)
+ cmLocalGenerator *lg,
+ const std::string& lang)
{
std::string l(lang);
std::string compileOption = "CMAKE_" + l + "_COMPILE_OPTIONS_VISIBILITY";
- const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
+ const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
if (!opt)
{
return;
}
std::string flagDefine = l + "_VISIBILITY_PRESET";
- const char *prop = target->GetProperty(flagDefine.c_str());
+ const char *prop = target->GetProperty(flagDefine);
if (!prop)
{
return;
@@ -2154,7 +2209,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags,
{
std::string compileOption
= "CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN";
- const char *opt = lg->GetMakefile()->GetDefinition(compileOption.c_str());
+ const char *opt = lg->GetMakefile()->GetDefinition(compileOption);
if (!opt)
{
return;
@@ -2171,7 +2226,7 @@ static void AddInlineVisibilityCompileOption(std::string &flags,
//----------------------------------------------------------------------------
void cmLocalGenerator
::AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
- const char *lang)
+ const std::string& lang)
{
int targetType = target->GetType();
bool suitableTarget = ((targetType == cmTarget::SHARED_LIBRARY)
@@ -2183,13 +2238,13 @@ void cmLocalGenerator
return;
}
- if (!lang)
+ if (lang.empty())
{
return;
}
AddVisibilityCompileOption(flags, target, this, lang);
- if(strcmp(lang, "CXX") == 0)
+ if(lang == "CXX")
{
AddInlineVisibilityCompileOption(flags, target, this);
}
@@ -2198,7 +2253,7 @@ void cmLocalGenerator
//----------------------------------------------------------------------------
void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target,
std::string const& lang,
- const char *config)
+ const std::string& config)
{
int targetType = target->GetType();
@@ -2207,7 +2262,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target,
if (this->GetShouldUseOldFlags(shared, lang))
{
- this->AddSharedFlags(flags, lang.c_str(), shared);
+ this->AddSharedFlags(flags, lang, shared);
}
else
{
@@ -2228,7 +2283,7 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, cmTarget* target,
}
if (shared)
{
- this->AppendFeatureOptions(flags, lang.c_str(), "DLL");
+ this->AppendFeatureOptions(flags, lang, "DLL");
}
}
}
@@ -2245,7 +2300,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
flagsVar += lang;
flagsVar += "_FLAGS";
const char* flags =
- this->Makefile->GetSafeDefinition(flagsVar.c_str());
+ this->Makefile->GetSafeDefinition(flagsVar);
if (flags && flags != originalFlags)
{
@@ -2270,7 +2325,6 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
- default:
return false;
}
}
@@ -2290,14 +2344,14 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
std::string flagsVar = "CMAKE_";
flagsVar += lang;
flagsVar += "_COMPILE_OPTIONS_PIE";
- picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str());
+ picFlags = this->Makefile->GetSafeDefinition(flagsVar);
}
if (!picFlags)
{
std::string flagsVar = "CMAKE_";
flagsVar += lang;
flagsVar += "_COMPILE_OPTIONS_PIC";
- picFlags = this->Makefile->GetSafeDefinition(flagsVar.c_str());
+ picFlags = this->Makefile->GetSafeDefinition(flagsVar);
}
if (picFlags)
{
@@ -2306,25 +2360,25 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
for(std::vector<std::string>::const_iterator oi = options.begin();
oi != options.end(); ++oi)
{
- this->AppendFlagEscape(flags, oi->c_str());
+ this->AppendFlagEscape(flags, *oi);
}
}
}
//----------------------------------------------------------------------------
void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
- const char* var,
- const char* config)
+ const std::string& var,
+ const std::string& config)
{
// Add the flags from the variable itself.
std::string flagsVar = var;
- this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
+ this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
// Add the flags from the build-type specific variable.
- if(config && *config)
+ if(!config.empty())
{
flagsVar += "_";
flagsVar += cmSystemTools::UpperCase(config);
- this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar.c_str()));
+ this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar));
}
}
@@ -2345,7 +2399,7 @@ void cmLocalGenerator::AppendFlags(std::string& flags,
//----------------------------------------------------------------------------
void cmLocalGenerator::AppendFlagEscape(std::string& flags,
- const char* rawFlag)
+ const std::string& rawFlag)
{
this->AppendFlags(flags, this->EscapeForShell(rawFlag).c_str());
}
@@ -2385,16 +2439,16 @@ void cmLocalGenerator::AppendDefines(std::set<std::string>& defines,
//----------------------------------------------------------------------------
void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
std::string &definesString,
- const char* lang)
+ const std::string& lang)
{
// Lookup the define flag for the current language.
std::string dflag = "-D";
- if(lang)
+ if(!lang.empty())
{
std::string defineFlagVar = "CMAKE_";
defineFlagVar += lang;
defineFlagVar += "_DEFINE_FLAG";
- const char* df = this->Makefile->GetDefinition(defineFlagVar.c_str());
+ const char* df = this->Makefile->GetDefinition(defineFlagVar);
if(df && *df)
{
dflag = df;
@@ -2449,46 +2503,46 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
//----------------------------------------------------------------------------
void cmLocalGenerator::AppendFeatureOptions(
- std::string& flags, const char* lang, const char* feature)
+ std::string& flags, const std::string& lang, const char* feature)
{
std::string optVar = "CMAKE_";
optVar += lang;
optVar += "_COMPILE_OPTIONS_";
optVar += feature;
- if(const char* optionList = this->Makefile->GetDefinition(optVar.c_str()))
+ if(const char* optionList = this->Makefile->GetDefinition(optVar))
{
std::vector<std::string> options;
cmSystemTools::ExpandListArgument(optionList, options);
for(std::vector<std::string>::const_iterator oi = options.begin();
oi != options.end(); ++oi)
{
- this->AppendFlagEscape(flags, oi->c_str());
+ this->AppendFlagEscape(flags, *oi);
}
}
}
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConstructComment(const cmCustomCommand& cc,
+cmLocalGenerator::ConstructComment(cmCustomCommandGenerator const& ccg,
const char* default_comment)
{
// Check for a comment provided with the command.
- if(cc.GetComment())
+ if(ccg.GetComment())
{
- return cc.GetComment();
+ return ccg.GetComment();
}
// Construct a reasonable default comment if possible.
- if(!cc.GetOutputs().empty())
+ if(!ccg.GetOutputs().empty())
{
std::string comment;
comment = "Generating ";
const char* sep = "";
- for(std::vector<std::string>::const_iterator o = cc.GetOutputs().begin();
- o != cc.GetOutputs().end(); ++o)
+ for(std::vector<std::string>::const_iterator o = ccg.GetOutputs().begin();
+ o != ccg.GetOutputs().end(); ++o)
{
comment += sep;
- comment += this->Convert(o->c_str(), cmLocalGenerator::START_OUTPUT);
+ comment += this->Convert(*o, cmLocalGenerator::START_OUTPUT);
sep = ", ";
}
return comment;
@@ -2500,7 +2554,8 @@ cmLocalGenerator::ConstructComment(const cmCustomCommand& cc,
//----------------------------------------------------------------------------
std::string
-cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(const char* remote)
+cmLocalGenerator::ConvertToOptionallyRelativeOutputPath(
+ const std::string& remote)
{
return this->Convert(remote, START_OUTPUT, SHELL, true);
}
@@ -2520,7 +2575,7 @@ const char* cmLocalGenerator::GetRelativeRootPath(RelativeRoot relroot)
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::Convert(const char* source,
+std::string cmLocalGenerator::Convert(const std::string& source,
RelativeRoot relative,
OutputFormat output,
bool optional)
@@ -2542,24 +2597,24 @@ std::string cmLocalGenerator::Convert(const char* source,
case HOME:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->ConvertToRelativePath(this->HomeDirectoryComponents,
- result.c_str());
+ result);
break;
case START:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result = this->ConvertToRelativePath(this->StartDirectoryComponents,
- result.c_str());
+ result);
break;
case HOME_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result =
this->ConvertToRelativePath(this->HomeOutputDirectoryComponents,
- result.c_str());
+ result);
break;
case START_OUTPUT:
//result = cmSystemTools::CollapseFullPath(result.c_str());
result =
this->ConvertToRelativePath(this->StartOutputDirectoryComponents,
- result.c_str());
+ result);
break;
case FULL:
result = cmSystemTools::CollapseFullPath(result.c_str());
@@ -2568,11 +2623,11 @@ std::string cmLocalGenerator::Convert(const char* source,
break;
}
}
- return this->ConvertToOutputFormat(result.c_str(), output);
+ return this->ConvertToOutputFormat(result, output);
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::ConvertToOutputFormat(const char* source,
+std::string cmLocalGenerator::ConvertToOutputFormat(const std::string& source,
OutputFormat output)
{
std::string result = source;
@@ -2581,7 +2636,7 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const char* source,
{
result = cmSystemTools::ConvertToOutputPath(result.c_str());
}
- else if( output == SHELL)
+ else if(output == SHELL || output == WATCOMQUOTE)
{
// For the MSYS shell convert drive letters to posix paths, so
// that c:/some/path becomes /c/some/path. This is needed to
@@ -2603,18 +2658,18 @@ std::string cmLocalGenerator::ConvertToOutputFormat(const char* source,
pos++;
}
}
- result = this->EscapeForShell(result.c_str(), true, false);
+ result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
}
else if(output == RESPONSE)
{
- result = this->EscapeForShell(result.c_str(), false, false);
+ result = this->EscapeForShell(result, false, false, false);
}
return result;
}
//----------------------------------------------------------------------------
std::string cmLocalGenerator::Convert(RelativeRoot remote,
- const char* local,
+ const std::string& local,
OutputFormat output,
bool optional)
{
@@ -2623,12 +2678,12 @@ std::string cmLocalGenerator::Convert(RelativeRoot remote,
// The relative root must have a path (i.e. not FULL or NONE)
assert(remotePath != 0);
- if(local && (!optional || this->UseRelativePaths))
+ if(!local.empty() && (!optional || this->UseRelativePaths))
{
std::vector<std::string> components;
- cmSystemTools::SplitPath(local, components);
+ cmSystemTools::SplitPath(local.c_str(), components);
std::string result = this->ConvertToRelativePath(components, remotePath);
- return this->ConvertToOutputFormat(result.c_str(), output);
+ return this->ConvertToOutputFormat(result, output);
}
else
{
@@ -2709,7 +2764,8 @@ static bool cmLocalGeneratorNotAbove(const char* a, const char* b)
//----------------------------------------------------------------------------
std::string
cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
- const char* in_remote, bool force)
+ const std::string& in_remote,
+ bool force)
{
// The path should never be quoted.
assert(in_remote[0] != '\"');
@@ -2718,7 +2774,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
assert(local.size() > 0 && !(local[local.size()-1] == ""));
// If the path is already relative then just return the path.
- if(!cmSystemTools::FileIsFullPath(in_remote))
+ if(!cmSystemTools::FileIsFullPath(in_remote.c_str()))
{
return in_remote;
}
@@ -2737,11 +2793,11 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
std::string local_path = cmSystemTools::JoinPath(local);
if(!((cmLocalGeneratorNotAbove(local_path.c_str(),
this->RelativePathTopBinary.c_str()) &&
- cmLocalGeneratorNotAbove(in_remote,
+ cmLocalGeneratorNotAbove(in_remote.c_str(),
this->RelativePathTopBinary.c_str())) ||
(cmLocalGeneratorNotAbove(local_path.c_str(),
this->RelativePathTopSource.c_str()) &&
- cmLocalGeneratorNotAbove(in_remote,
+ cmLocalGeneratorNotAbove(in_remote.c_str(),
this->RelativePathTopSource.c_str()))))
{
return in_remote;
@@ -2751,7 +2807,7 @@ 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, remote);
+ cmSystemTools::SplitPath(in_remote.c_str(), remote);
unsigned int common=0;
while(common < remote.size() &&
common < local.size() &&
@@ -2822,7 +2878,7 @@ cmLocalGenerator::ConvertToRelativePath(const std::vector<std::string>& local,
void
cmLocalGenerator
::GenerateTargetInstallRules(
- std::ostream& os, const char* config,
+ std::ostream& os, const std::string& config,
std::vector<std::string> const& configurationTypes)
{
// Convert the old-style install specification from each target to
@@ -2969,11 +3025,11 @@ bool cmLocalGeneratorCheckObjectName(std::string& objName,
//----------------------------------------------------------------------------
std::string&
cmLocalGenerator
-::CreateSafeUniqueObjectFileName(const char* sin,
+::CreateSafeUniqueObjectFileName(const std::string& sin,
std::string const& dir_max)
{
// Look for an existing mapped name for this object file.
- std::map<cmStdString,cmStdString>::iterator it =
+ std::map<std::string,std::string>::iterator it =
this->UniqueObjectNamesMap.find(sin);
// If no entry exists create one.
@@ -3056,7 +3112,7 @@ cmLocalGenerator
#endif
// Insert the newly mapped object file name.
- std::map<cmStdString, cmStdString>::value_type e(sin, ssin);
+ std::map<std::string, std::string>::value_type e(sin, ssin);
it = this->UniqueObjectNamesMap.insert(e).first;
}
@@ -3065,6 +3121,14 @@ cmLocalGenerator
}
//----------------------------------------------------------------------------
+void cmLocalGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>&,
+ cmGeneratorTarget const*)
+{
+
+}
+
+//----------------------------------------------------------------------------
std::string
cmLocalGenerator
::GetObjectFileNameWithoutTarget(const cmSourceFile& source,
@@ -3129,12 +3193,13 @@ cmLocalGenerator
bool replaceExt = this->NeedBackwardsCompatibility_2_4();
if(!replaceExt)
{
- if(const char* lang = source.GetLanguage())
+ std::string lang = source.GetLanguage();
+ if(!lang.empty())
{
std::string repVar = "CMAKE_";
repVar += lang;
repVar += "_OUTPUT_EXTENSION_REPLACE";
- replaceExt = this->Makefile->IsOn(repVar.c_str());
+ replaceExt = this->Makefile->IsOn(repVar);
}
}
@@ -3159,11 +3224,11 @@ cmLocalGenerator
}
// Convert to a safe name.
- return this->CreateSafeUniqueObjectFileName(objectName.c_str(), dir_max);
+ return this->CreateSafeUniqueObjectFileName(objectName, dir_max);
}
//----------------------------------------------------------------------------
-const char*
+std::string
cmLocalGenerator
::GetSourceFileLanguage(const cmSourceFile& source)
{
@@ -3171,7 +3236,7 @@ cmLocalGenerator
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str)
+std::string cmLocalGenerator::EscapeForShellOldStyle(const std::string& str)
{
std::string result;
#if defined(_WIN32) && !defined(__CYGWIN__)
@@ -3187,7 +3252,7 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str)
}
return str;
#else
- for(const char* ch = str; *ch != '\0'; ++ch)
+ for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
{
if(*ch == ' ')
{
@@ -3200,29 +3265,32 @@ std::string cmLocalGenerator::EscapeForShellOldStyle(const char* str)
}
//----------------------------------------------------------------------------
-static bool cmLocalGeneratorIsShellOperator(const char* str)
-{
- if(strcmp(str, "<") == 0 ||
- strcmp(str, ">") == 0 ||
- strcmp(str, "<<") == 0 ||
- strcmp(str, ">>") == 0 ||
- strcmp(str, "|") == 0 ||
- strcmp(str, "||") == 0 ||
- strcmp(str, "&&") == 0 ||
- strcmp(str, "&>") == 0 ||
- strcmp(str, "1>") == 0 ||
- strcmp(str, "2>") == 0 ||
- strcmp(str, "2>&1") == 0 ||
- strcmp(str, "1>&2") == 0)
+static bool cmLocalGeneratorIsShellOperator(const std::string& str)
+{
+ static std::set<std::string> shellOperators;
+ if(shellOperators.empty())
{
- return true;
+ shellOperators.insert("<");
+ shellOperators.insert(">");
+ shellOperators.insert("<<");
+ shellOperators.insert(">>");
+ shellOperators.insert("|");
+ shellOperators.insert("||");
+ shellOperators.insert("&&");
+ shellOperators.insert("&>");
+ shellOperators.insert("1>");
+ shellOperators.insert("2>");
+ shellOperators.insert("2>&1");
+ shellOperators.insert("1>&2");
}
- return false;
+ return shellOperators.count(str) > 0;
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
- bool forEcho)
+std::string cmLocalGenerator::EscapeForShell(const std::string& str,
+ bool makeVars,
+ bool forEcho,
+ bool useWatcomQuote)
{
// Do not escape shell operators.
if(cmLocalGeneratorIsShellOperator(str))
@@ -3248,6 +3316,10 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
{
flags |= cmsysSystem_Shell_Flag_EchoWindows;
}
+ if(useWatcomQuote)
+ {
+ flags |= cmsysSystem_Shell_Flag_WatcomQuote;
+ }
if(this->WatcomWMake)
{
flags |= cmsysSystem_Shell_Flag_WatcomWMake;
@@ -3263,28 +3335,28 @@ std::string cmLocalGenerator::EscapeForShell(const char* str, bool makeVars,
// Compute the buffer size needed.
int size = (this->WindowsShell ?
- cmsysSystem_Shell_GetArgumentSizeForWindows(str, flags) :
- cmsysSystem_Shell_GetArgumentSizeForUnix(str, flags));
+ cmsysSystem_Shell_GetArgumentSizeForWindows(str.c_str(), flags) :
+ cmsysSystem_Shell_GetArgumentSizeForUnix(str.c_str(), flags));
// Compute the shell argument itself.
std::vector<char> arg(size);
if(this->WindowsShell)
{
- cmsysSystem_Shell_GetArgumentForWindows(str, &arg[0], flags);
+ cmsysSystem_Shell_GetArgumentForWindows(str.c_str(), &arg[0], flags);
}
else
{
- cmsysSystem_Shell_GetArgumentForUnix(str, &arg[0], flags);
+ cmsysSystem_Shell_GetArgumentForUnix(str.c_str(), &arg[0], flags);
}
return std::string(&arg[0]);
}
//----------------------------------------------------------------------------
-std::string cmLocalGenerator::EscapeForCMake(const char* str)
+std::string cmLocalGenerator::EscapeForCMake(const std::string& str)
{
// Always double-quote the argument to take care of most escapes.
std::string result = "\"";
- for(const char* c = str; *c; ++c)
+ for(const char* c = str.c_str(); *c; ++c)
{
if(*c == '"')
{
@@ -3447,7 +3519,8 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
}
//----------------------------------------------------------------------------
-static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop)
+static void cmLGInfoProp(cmMakefile* mf, cmTarget* target,
+ const std::string& prop)
{
if(const char* val = target->GetProperty(prop))
{
@@ -3457,7 +3530,7 @@ static void cmLGInfoProp(cmMakefile* mf, cmTarget* target, const char* prop)
//----------------------------------------------------------------------------
void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
- const char* targetName,
+ const std::string& targetName,
const char* fname)
{
// Find the Info.plist template.
@@ -3486,7 +3559,7 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
// back to the directory-level values set by the user.
cmMakefile* mf = this->Makefile;
mf->PushScope();
- mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName);
+ mf->AddDefinition("MACOSX_BUNDLE_EXECUTABLE_NAME", targetName.c_str());
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_INFO_STRING");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_BUNDLE_GUI_IDENTIFIER");
@@ -3501,8 +3574,8 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmTarget* target,
//----------------------------------------------------------------------------
void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
- const char* targetName,
- const char* fname)
+ const std::string& targetName,
+ const char* fname)
{
// Find the Info.plist template.
const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
@@ -3530,7 +3603,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(cmTarget* target,
// back to the directory-level values set by the user.
cmMakefile* mf = this->Makefile;
mf->PushScope();
- mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName);
+ mf->AddDefinition("MACOSX_FRAMEWORK_NAME", targetName.c_str());
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER");
cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING");
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 9764813..cf754aa 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -21,6 +21,7 @@ class cmTarget;
class cmTargetManifest;
class cmSourceFile;
class cmCustomCommand;
+class cmCustomCommandGenerator;
/** \class cmLocalGenerator
* \brief Create required build files for a directory.
@@ -75,17 +76,17 @@ public:
///! Get the makefile for this generator
cmMakefile *GetMakefile() {
- return this->Makefile; };
+ return this->Makefile; }
///! Get the makefile for this generator, const version
const cmMakefile *GetMakefile() const {
- return this->Makefile; };
+ return this->Makefile; }
///! Get the GlobalGenerator this is associated with
cmGlobalGenerator *GetGlobalGenerator() {
- return this->GlobalGenerator; };
+ return this->GlobalGenerator; }
const cmGlobalGenerator *GetGlobalGenerator() const {
- return this->GlobalGenerator; };
+ return this->GlobalGenerator; }
///! Set the Global Generator, done on creation by the GlobalGenerator
void SetGlobalGenerator(cmGlobalGenerator *gg);
@@ -105,12 +106,13 @@ public:
* path setting
*/
enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT };
- enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, RESPONSE };
- std::string ConvertToOutputFormat(const char* source, OutputFormat output);
- std::string Convert(const char* remote, RelativeRoot local,
+ enum OutputFormat { UNCHANGED, MAKEFILE, SHELL, WATCOMQUOTE, RESPONSE };
+ std::string ConvertToOutputFormat(const std::string& source,
+ OutputFormat output);
+ std::string Convert(const std::string& remote, RelativeRoot local,
OutputFormat output = UNCHANGED,
bool optional = false);
- std::string Convert(RelativeRoot remote, const char* local,
+ std::string Convert(RelativeRoot remote, const std::string& local,
OutputFormat output = UNCHANGED,
bool optional = false);
@@ -125,7 +127,7 @@ public:
* remote path must use forward slashes and not already be escaped
* or quoted.
*/
- std::string ConvertToOptionallyRelativeOutputPath(const char* remote);
+ std::string ConvertToOptionallyRelativeOutputPath(const std::string& remote);
///! set/get the parent generator
cmLocalGenerator* GetParent(){return this->Parent;}
@@ -133,28 +135,32 @@ public:
///! set/get the children
void AddChild(cmLocalGenerator* g) { this->Children.push_back(g); }
- std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; };
+ std::vector<cmLocalGenerator*>& GetChildren() { return this->Children; }
void AddArchitectureFlags(std::string& flags, cmGeneratorTarget* target,
- const char *lang, const char* config);
+ const std::string&lang, const std::string& config);
- void AddLanguageFlags(std::string& flags, const char* lang,
- const char* config);
+ void AddLanguageFlags(std::string& flags, const std::string& lang,
+ const std::string& config);
void AddCMP0018Flags(std::string &flags, cmTarget* target,
- std::string const& lang, const char *config);
+ std::string const& lang, const std::string& config);
void AddVisibilityPresetFlags(std::string &flags, cmTarget* target,
- const char *lang);
- void AddConfigVariableFlags(std::string& flags, const char* var,
- const char* config);
+ const std::string& lang);
+ void AddConfigVariableFlags(std::string& flags, const std::string& var,
+ const std::string& config);
+ void AddCompilerRequirementFlag(std::string &flags, cmTarget* target,
+ const std::string& lang);
///! Append flags to a string.
virtual void AppendFlags(std::string& flags, const char* newFlags);
- virtual void AppendFlagEscape(std::string& flags, const char* rawFlag);
+ virtual void AppendFlagEscape(std::string& flags,
+ const std::string& rawFlag);
///! Get the include flags for the current makefile and language
std::string GetIncludeFlags(const std::vector<std::string> &includes,
cmGeneratorTarget* target,
- const char* lang, bool forResponseFile = false,
- const char *config = 0);
+ const std::string& lang,
+ bool forResponseFile = false,
+ const std::string& config = "");
/**
* Encode a list of preprocessor definitions for the compiler
@@ -175,10 +181,10 @@ public:
*/
void JoinDefines(const std::set<std::string>& defines,
std::string &definesString,
- const char* lang);
+ const std::string& lang);
/** Lookup and append options associated with a particular feature. */
- void AppendFeatureOptions(std::string& flags, const char* lang,
+ void AppendFeatureOptions(std::string& flags, const std::string& lang,
const char* feature);
/** \brief Get absolute path to dependency \a name
@@ -193,19 +199,22 @@ public:
* the source directory of this generator. This should only be
* used for dependencies of custom commands.
*/
- bool GetRealDependency(const char* name, const char* config,
+ bool GetRealDependency(const std::string& name, const std::string& config,
std::string& dep);
///! for existing files convert to output path and short path if spaces
- std::string ConvertToOutputForExisting(const char* remote,
- RelativeRoot local = START_OUTPUT);
+ std::string ConvertToOutputForExisting(const std::string& remote,
+ RelativeRoot local = START_OUTPUT,
+ OutputFormat format = SHELL);
/** For existing path identified by RelativeRoot convert to output
path and short path if spaces. */
std::string ConvertToOutputForExisting(RelativeRoot remote,
- const char* local = 0);
+ const std::string& local = "",
+ OutputFormat format = SHELL);
- virtual std::string ConvertToIncludeReference(std::string const& path);
+ virtual std::string ConvertToIncludeReference(std::string const& path,
+ OutputFormat format = SHELL);
/** Called from command-line hook to clear dependencies. */
virtual void ClearDependencies(cmMakefile* /* mf */,
@@ -220,16 +229,17 @@ public:
/** Get the include flags for the current makefile and language. */
void GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget* target,
- const char* lang = "C", const char *config = 0,
+ const std::string& lang = "C",
+ const std::string& config = "",
bool stripImplicitInclDirs = true);
void AddCompileOptions(std::string& flags, cmTarget* target,
- const char* lang, const char* config);
+ const std::string& lang, const std::string& config);
void AddCompileDefinitions(std::set<std::string>& defines,
cmTarget const* target,
- const char* config);
+ const std::string& config);
/** Compute the language used to compile the given source file. */
- const char* GetSourceFileLanguage(const cmSourceFile& source);
+ std::string GetSourceFileLanguage(const cmSourceFile& source);
// Fill the vector with the target names for the object files,
// preprocessed files and assembly files.
@@ -245,6 +255,7 @@ public:
}
cmTarget* CMTarget;
const char* TargetPDB;
+ const char* TargetCompilePDB;
const char* TargetVersionMajor;
const char* TargetVersionMinor;
const char* Language;
@@ -278,14 +289,15 @@ public:
system to replace make variable references. Optionally adjust
escapes for the special case of passing to the native echo
command. */
- std::string EscapeForShell(const char* str, bool makeVars = false,
- bool forEcho = false);
+ std::string EscapeForShell(const std::string& str, bool makeVars = false,
+ bool forEcho = false,
+ bool useWatcomQuote = false);
/** Backwards-compatibility version of EscapeForShell. */
- std::string EscapeForShellOldStyle(const char* str);
+ std::string EscapeForShellOldStyle(const std::string& str);
/** Escape the given string as an argument in a CMake script. */
- static std::string EscapeForCMake(const char* str);
+ static std::string EscapeForCMake(const std::string& str);
enum FortranFormat
{
@@ -303,7 +315,8 @@ public:
* or quoted.
*/
std::string ConvertToRelativePath(const std::vector<std::string>& local,
- const char* remote, bool force=false);
+ const std::string& remote,
+ bool force=false);
/**
* Get the relative path from the generator output directory to a
@@ -331,17 +344,17 @@ public:
/**
* Generate a Mac OS X application bundle Info.plist file.
*/
- void GenerateAppleInfoPList(cmTarget* target, const char* targetName,
+ void GenerateAppleInfoPList(cmTarget* target, const std::string& targetName,
const char* fname);
/**
* Generate a Mac OS X framework Info.plist file.
*/
void GenerateFrameworkInfoPList(cmTarget* target,
- const char* targetName,
+ const std::string& targetName,
const char* fname);
/** Construct a comment for a custom command. */
- std::string ConstructComment(const cmCustomCommand& cc,
+ std::string ConstructComment(cmCustomCommandGenerator const& ccg,
const char* default_comment = "");
// Compute object file names.
std::string GetObjectFileNameWithoutTarget(const cmSourceFile& source,
@@ -360,7 +373,12 @@ public:
std::string& linkFlags,
std::string& frameworkPath,
std::string& linkPath,
- cmGeneratorTarget* target);
+ cmGeneratorTarget* target,
+ bool useWatcomQuote);
+
+ virtual void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = 0);
protected:
///! put all the libraries for a target on into the given stream
@@ -368,7 +386,9 @@ protected:
std::string& frameworkPath,
std::string& linkPath,
cmGeneratorTarget &,
- bool relink);
+ bool relink,
+ bool forResponseFile,
+ bool useWatcomQuote);
// Expand rule variables in CMake of the type found in language rules
void ExpandRuleVariables(std::string& string,
@@ -377,17 +397,18 @@ protected:
std::string ExpandRuleVariable(std::string const& variable,
const RuleVariables& replaceValues);
- const char* GetRuleLauncher(cmTarget* target, const char* prop);
+ const char* GetRuleLauncher(cmTarget* target, const std::string& prop);
void InsertRuleLauncher(std::string& s, cmTarget* target,
- const char* prop);
+ const std::string& prop);
/** Convert a target to a utility target for unsupported
* languages of a generator */
- void AddBuildTargetRule(const char* llang, cmGeneratorTarget& target);
+ void AddBuildTargetRule(const std::string& llang,
+ cmGeneratorTarget& target);
///! add a custom command to build a .o file that is part of a target
void AddCustomCommandToCreateObject(const char* ofname,
- const char* lang,
+ const std::string& lang,
cmSourceFile& source,
cmGeneratorTarget& target);
// Create Custom Targets and commands for unsupported languages
@@ -395,14 +416,14 @@ protected:
// generator directly. Any targets containing files that are not
// of the types listed will be compiled as custom commands and added
// to a custom target.
- void CreateCustomTargetsAndCommands(std::set<cmStdString> const&);
+ void CreateCustomTargetsAndCommands(std::set<std::string> const&);
// Handle old-style install rules stored in the targets.
void GenerateTargetInstallRules(
- std::ostream& os, const char* config,
+ std::ostream& os, const std::string& config,
std::vector<std::string> const& configurationTypes);
- std::string& CreateSafeUniqueObjectFileName(const char* sin,
+ std::string& CreateSafeUniqueObjectFileName(const std::string& sin,
std::string const& dir_max);
void ComputeObjectMaxPath();
@@ -411,7 +432,8 @@ protected:
std::string FindRelativePathTopBinary();
void SetupPathConversions();
- virtual std::string ConvertToLinkReference(std::string const& lib);
+ virtual std::string ConvertToLinkReference(std::string const& lib,
+ OutputFormat format = SHELL);
/** Check whether the native build system supports the given
definition. Issues a warning. */
@@ -431,9 +453,9 @@ protected:
std::vector<std::string> StartOutputDirectoryComponents;
cmLocalGenerator* Parent;
std::vector<cmLocalGenerator*> Children;
- std::map<cmStdString, cmStdString> UniqueObjectNamesMap;
+ std::map<std::string, std::string> UniqueObjectNamesMap;
std::string::size_type ObjectPathMax;
- std::set<cmStdString> ObjectMaxPathViolations;
+ std::set<std::string> ObjectMaxPathViolations;
bool WindowsShell;
bool WindowsVSIDE;
bool WatcomWMake;
@@ -463,10 +485,12 @@ protected:
cmIML_INT_uint64_t BackwardsCompatibility;
bool BackwardsCompatibilityFinal;
private:
- std::string ConvertToOutputForExistingCommon(const char* remote,
- std::string const& result);
+ std::string ConvertToOutputForExistingCommon(const std::string& remote,
+ std::string const& result,
+ OutputFormat format);
- void AddSharedFlags(std::string& flags, const char* lang, bool shared);
+ void AddSharedFlags(std::string& flags, const std::string& lang,
+ bool shared);
bool GetShouldUseOldFlags(bool shared, const std::string &lang) const;
void AddPositionIndependentFlags(std::string& flags, std::string const& l,
int targetType);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index cd12c9d..2f763ce 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -143,15 +143,17 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator()
// Virtual protected methods.
std::string
-cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib)
+cmLocalNinjaGenerator::ConvertToLinkReference(std::string const& lib,
+ OutputFormat format)
{
- return this->Convert(lib.c_str(), HOME_OUTPUT, SHELL);
+ return this->Convert(lib, HOME_OUTPUT, format);
}
std::string
-cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path)
+cmLocalNinjaGenerator::ConvertToIncludeReference(std::string const& path,
+ OutputFormat format)
{
- return this->Convert(path.c_str(), HOME_OUTPUT, SHELL);
+ return this->Convert(path, HOME_OUTPUT, format);
}
//----------------------------------------------------------------------------
@@ -265,6 +267,20 @@ void cmLocalNinjaGenerator::SetConfigName()
}
}
+//----------------------------------------------------------------------------
+void cmLocalNinjaGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
+{
+ for(std::map<cmSourceFile const*, std::string>::iterator
+ si = mapping.begin(); si != mapping.end(); ++si)
+ {
+ cmSourceFile const* sf = si->first;
+ si->second = this->GetObjectFileNameWithoutTarget(*sf,
+ gt->ObjectDirectory);
+ }
+}
+
void cmLocalNinjaGenerator::WriteProcessedMakefile(std::ostream& os)
{
cmGlobalNinjaGenerator::WriteDivider(os);
@@ -301,14 +317,15 @@ cmLocalNinjaGenerator
this->GetGlobalNinjaGenerator()->AppendTargetDepends(target, outputs);
}
-void cmLocalNinjaGenerator::AppendCustomCommandDeps(const cmCustomCommand *cc,
- cmNinjaDeps &ninjaDeps)
+void cmLocalNinjaGenerator::AppendCustomCommandDeps(
+ cmCustomCommandGenerator const& ccg,
+ cmNinjaDeps &ninjaDeps)
{
- const std::vector<std::string> &deps = cc->GetDepends();
+ const std::vector<std::string> &deps = ccg.GetDepends();
for (std::vector<std::string>::const_iterator i = deps.begin();
i != deps.end(); ++i) {
std::string dep;
- if (this->GetRealDependency(i->c_str(), this->GetConfigName(), dep))
+ if (this->GetRealDependency(*i, this->GetConfigName(), dep))
ninjaDeps.push_back(ConvertToNinjaPath(dep.c_str()));
}
}
@@ -357,13 +374,13 @@ std::string cmLocalNinjaGenerator::BuildCommandLine(
return cmd.str();
}
-void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc,
- std::vector<std::string> &cmdLines)
+void cmLocalNinjaGenerator::AppendCustomCommandLines(
+ cmCustomCommandGenerator const& ccg,
+ std::vector<std::string> &cmdLines)
{
- cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
if (ccg.GetNumberOfCommands() > 0) {
- const char* wd = cc->GetWorkingDirectory();
- if (!wd)
+ std::string wd = ccg.GetWorkingDirectory();
+ if (wd.empty())
wd = this->GetMakefile()->GetStartOutputDirectory();
cmOStringStream cdCmd;
@@ -376,11 +393,11 @@ void cmLocalNinjaGenerator::AppendCustomCommandLines(const cmCustomCommand *cc,
cmdLines.push_back(cdCmd.str());
}
- std::string launcher = this->MakeCustomLauncher(*cc);
+ std::string launcher = this->MakeCustomLauncher(ccg);
for (unsigned i = 0; i != ccg.GetNumberOfCommands(); ++i) {
cmdLines.push_back(launcher +
- this->ConvertToOutputFormat(ccg.GetCommand(i).c_str(), SHELL));
+ this->ConvertToOutputFormat(ccg.GetCommand(i), SHELL));
std::string& cmd = cmdLines.back();
ccg.AppendArguments(i, cmd);
@@ -394,19 +411,21 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
if (this->GetGlobalNinjaGenerator()->SeenCustomCommand(cc))
return;
- const std::vector<std::string> &outputs = cc->GetOutputs();
+ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(), this->Makefile);
+
+ const std::vector<std::string> &outputs = ccg.GetOutputs();
cmNinjaDeps ninjaOutputs(outputs.size()), ninjaDeps;
std::transform(outputs.begin(), outputs.end(),
ninjaOutputs.begin(), MapToNinjaPath());
- this->AppendCustomCommandDeps(cc, ninjaDeps);
+ this->AppendCustomCommandDeps(ccg, ninjaDeps);
for (cmNinjaDeps::iterator i = ninjaOutputs.begin(); i != ninjaOutputs.end();
++i)
this->GetGlobalNinjaGenerator()->SeenCustomCommandOutput(*i);
std::vector<std::string> cmdLines;
- this->AppendCustomCommandLines(cc, cmdLines);
+ this->AppendCustomCommandLines(ccg, cmdLines);
if (cmdLines.empty()) {
this->GetGlobalNinjaGenerator()->WritePhonyBuild(
@@ -421,7 +440,7 @@ cmLocalNinjaGenerator::WriteCustomCommandBuildStatement(
} else {
this->GetGlobalNinjaGenerator()->WriteCustomCommandBuild(
this->BuildCommandLine(cmdLines),
- this->ConstructComment(*cc),
+ this->ConstructComment(ccg),
"Custom command for " + ninjaOutputs[0],
ninjaOutputs,
ninjaDeps,
@@ -470,7 +489,7 @@ void cmLocalNinjaGenerator::WriteCustomCommandBuildStatements()
}
std::string cmLocalNinjaGenerator::MakeCustomLauncher(
- const cmCustomCommand& cc)
+ cmCustomCommandGenerator const& ccg)
{
const char* property = "RULE_LAUNCH_CUSTOM";
const char* property_value = this->Makefile->GetProperty(property);
@@ -485,13 +504,13 @@ std::string cmLocalNinjaGenerator::MakeCustomLauncher(
RuleVariables vars;
vars.RuleLauncher = property;
std::string output;
- const std::vector<std::string>& outputs = cc.GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty())
{
RelativeRoot relative_root =
- cc.GetWorkingDirectory() ? NONE : START_OUTPUT;
+ ccg.GetWorkingDirectory().empty() ? START_OUTPUT : NONE;
- output = this->Convert(outputs[0].c_str(), relative_root, SHELL);
+ output = this->Convert(outputs[0], relative_root, SHELL);
}
vars.Output = output.c_str();
diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h
index ea854c6..e91e60b 100644
--- a/Source/cmLocalNinjaGenerator.h
+++ b/Source/cmLocalNinjaGenerator.h
@@ -16,6 +16,7 @@
# include "cmLocalGenerator.h"
# include "cmNinjaTypes.h"
+class cmCustomCommandGenerator;
class cmGlobalNinjaGenerator;
class cmGeneratedFileStream;
class cmake;
@@ -55,8 +56,8 @@ public:
const cmake* GetCMakeInstance() const;
cmake* GetCMakeInstance();
- const char* GetConfigName() const
- { return this->ConfigName.c_str(); }
+ std::string const& GetConfigName() const
+ { return this->ConfigName; }
/// @return whether we are processing the top CMakeLists.txt file.
bool isRootMakefile() const;
@@ -92,16 +93,22 @@ public:
void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target);
- void AppendCustomCommandLines(const cmCustomCommand *cc,
+ void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
std::vector<std::string> &cmdLines);
- void AppendCustomCommandDeps(const cmCustomCommand *cc,
+ void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
cmNinjaDeps &ninjaDeps);
- virtual std::string ConvertToLinkReference(std::string const& lib);
+ virtual std::string ConvertToLinkReference(std::string const& lib,
+ OutputFormat format = SHELL);
+
+ virtual void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = 0);
protected:
- virtual std::string ConvertToIncludeReference(std::string const& path);
+ virtual std::string ConvertToIncludeReference(std::string const& path,
+ OutputFormat format = SHELL);
private:
@@ -122,7 +129,7 @@ private:
void WriteCustomCommandBuildStatements();
- std::string MakeCustomLauncher(const cmCustomCommand& cc);
+ std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
std::string ConfigName;
std::string HomeRelativeOutputPath;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 93722d1..7ffe84d 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -80,7 +80,6 @@ static std::string cmSplitExtension(std::string const& in, std::string& base)
//----------------------------------------------------------------------------
cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3()
{
- this->SilentNoColon = false;
this->WindowsShell = false;
this->IncludeDirective = "include";
this->MakefileVariableSize = 0;
@@ -173,26 +172,72 @@ void cmLocalUnixMakefileGenerator3::Generate()
}
//----------------------------------------------------------------------------
-void cmLocalUnixMakefileGenerator3::AddLocalObjectFile(
- cmTarget* target, cmSourceFile* sf, std::string objNoTargetDir,
- bool hasSourceExtension)
+void cmLocalUnixMakefileGenerator3::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
{
- if(cmSystemTools::FileIsFullPath(objNoTargetDir.c_str()))
+ for(std::map<cmSourceFile const*, std::string>::iterator
+ si = mapping.begin(); si != mapping.end(); ++si)
{
- objNoTargetDir = cmSystemTools::GetFilenameName(objNoTargetDir);
+ cmSourceFile const* sf = si->first;
+ si->second = this->GetObjectFileNameWithoutTarget(*sf,
+ gt->ObjectDirectory);
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmLocalUnixMakefileGenerator3::
+GetLocalObjectFiles(std::map<std::string, LocalObjectInfo> &localObjectFiles)
+{
+ std::set<std::string> emitted;
+ cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
+ for(cmGeneratorTargetsType::iterator ti = targets.begin();
+ ti != targets.end(); ++ti)
+ {
+ cmGeneratorTarget* gt = ti->second;
+ if (gt->GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ continue;
+ }
+ std::vector<cmSourceFile const*> objectSources;
+ gt->GetObjectSources(objectSources, this->Makefile
+ ->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ // Compute full path to object file directory for this target.
+ std::string dir;
+ dir += gt->Makefile->GetCurrentOutputDirectory();
+ dir += "/";
+ dir += this->GetTargetDirectory(*gt->Target);
+ dir += "/";
+ // Compute the name of each object file.
+ for(std::vector<cmSourceFile const*>::iterator
+ si = objectSources.begin();
+ si != objectSources.end(); ++si)
+ {
+ cmSourceFile const* sf = *si;
+ bool hasSourceExtension = true;
+ std::string objectName = this->GetObjectFileNameWithoutTarget(*sf,
+ dir,
+ &hasSourceExtension);
+ if(cmSystemTools::FileIsFullPath(objectName.c_str()))
+ {
+ objectName = cmSystemTools::GetFilenameName(objectName);
+ }
+ LocalObjectInfo& info = localObjectFiles[objectName];
+ info.HasSourceExtension = hasSourceExtension;
+ info.push_back(LocalObjectEntry(gt->Target, sf->GetLanguage()));
+ }
}
- LocalObjectInfo& info = this->LocalObjectFiles[objNoTargetDir];
- info.HasSourceExtension = hasSourceExtension;
- info.push_back(LocalObjectEntry(target, sf->GetLanguage()));
}
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3::GetIndividualFileTargets
(std::vector<std::string>& targets)
{
- for (std::map<cmStdString, LocalObjectInfo>::iterator lo =
- this->LocalObjectFiles.begin();
- lo != this->LocalObjectFiles.end(); ++lo)
+ std::map<std::string, LocalObjectInfo> localObjectFiles;
+ this->GetLocalObjectFiles(localObjectFiles);
+ for (std::map<std::string, LocalObjectInfo>::iterator lo =
+ localObjectFiles.begin();
+ lo != localObjectFiles.end(); ++lo)
{
targets.push_back(lo->first);
@@ -235,7 +280,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
// only write local targets unless at the top Keep track of targets already
// listed.
- std::set<cmStdString> emittedTargets;
+ std::set<std::string> emittedTargets;
if (this->Parent)
{
// write our targets, and while doing it collect up the object
@@ -254,11 +299,14 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefile()
bool do_assembly_rules =
this->GetCreateAssemblySourceRules();
+ std::map<std::string, LocalObjectInfo> localObjectFiles;
+ this->GetLocalObjectFiles(localObjectFiles);
+
// now write out the object rules
// for each object file name
- for (std::map<cmStdString, LocalObjectInfo>::iterator lo =
- this->LocalObjectFiles.begin();
- lo != this->LocalObjectFiles.end(); ++lo)
+ for (std::map<std::string, LocalObjectInfo>::iterator lo =
+ localObjectFiles.begin();
+ lo != localObjectFiles.end(); ++lo)
{
// Add a convenience rule for building the object file.
this->WriteObjectConvenienceRule(ruleFileStream,
@@ -339,7 +387,7 @@ cmLocalUnixMakefileGenerator3
depends.push_back(output);
std::vector<std::string> no_commands;
this->WriteMakeRule(ruleFileStream, 0,
- outNoExt.c_str(), depends, no_commands, true, true);
+ outNoExt, depends, no_commands, true, true);
inHelp = false;
}
@@ -355,7 +403,7 @@ cmLocalUnixMakefileGenerator3
targetName += "/";
targetName += output;
commands.push_back(
- this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName.c_str())
+ this->GetRecursiveMakeCall(tgtMakefileName.c_str(), targetName)
);
}
this->CreateCDCommand(commands,
@@ -371,7 +419,7 @@ cmLocalUnixMakefileGenerator3
//----------------------------------------------------------------------------
void cmLocalUnixMakefileGenerator3
::WriteLocalMakefileTargets(std::ostream& ruleFileStream,
- std::set<cmStdString> &emitted)
+ std::set<std::string> &emitted)
{
std::vector<std::string> depends;
std::vector<std::string> commands;
@@ -407,12 +455,12 @@ void cmLocalUnixMakefileGenerator3
std::string makefile2 = cmake::GetCMakeFilesDirectoryPostSlash();
makefile2 += "Makefile2";
commands.push_back(this->GetRecursiveMakeCall
- (makefile2.c_str(),localName.c_str()));
+ (makefile2.c_str(),localName));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
if(localName != t->second->GetName())
@@ -436,17 +484,17 @@ void cmLocalUnixMakefileGenerator3
depends.clear();
commands.clear();
commands.push_back(this->GetRecursiveMakeCall
- (makefileName.c_str(), makeTargetName.c_str()));
+ (makefileName.c_str(), makeTargetName));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream, "fast build rule for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
// Add a local name for the rule to relink the target before
// installation.
if(t->second->Target
- ->NeedRelinkBeforeInstall(this->ConfigurationName.c_str()))
+ ->NeedRelinkBeforeInstall(this->ConfigurationName))
{
makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target);
makeTargetName += "/preinstall";
@@ -455,13 +503,13 @@ void cmLocalUnixMakefileGenerator3
depends.clear();
commands.clear();
commands.push_back(this->GetRecursiveMakeCall
- (makefile2.c_str(), makeTargetName.c_str()));
+ (makefile2.c_str(), makeTargetName));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
this->WriteMakeRule(ruleFileStream,
"Manual pre-install relink rule for target.",
- localName.c_str(), depends, commands, true);
+ localName, depends, commands, true);
}
}
}
@@ -550,14 +598,14 @@ void
cmLocalUnixMakefileGenerator3
::WriteMakeRule(std::ostream& os,
const char* comment,
- const char* target,
+ const std::string& target,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands,
bool symbolic,
bool in_help)
{
// Make sure there is a target.
- if(!target || !*target)
+ if(target.empty())
{
cmSystemTools::Error("No target for WriteMakeRule! called with comment: ",
comment);
@@ -582,7 +630,7 @@ cmLocalUnixMakefileGenerator3
// Construct the left hand side of the rule.
replace = target;
- std::string tgt = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE);
+ std::string tgt = this->Convert(replace,HOME_OUTPUT,MAKEFILE);
const char* space = "";
if(tgt.size() == 1)
{
@@ -615,7 +663,7 @@ cmLocalUnixMakefileGenerator3
dep != depends.end(); ++dep)
{
replace = *dep;
- replace = this->Convert(replace.c_str(),HOME_OUTPUT,MAKEFILE);
+ replace = this->Convert(replace,HOME_OUTPUT,MAKEFILE);
os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
}
}
@@ -625,7 +673,7 @@ cmLocalUnixMakefileGenerator3
i != commands.end(); ++i)
{
replace = *i;
- os << "\t" << replace.c_str() << "\n";
+ os << "\t" << replace << "\n";
}
if(symbolic && !this->WatcomWMake)
{
@@ -654,10 +702,10 @@ cmLocalUnixMakefileGenerator3
std::string scmd;
if(cmSystemTools::GetShortPath(cmd.c_str(), scmd))
{
- return this->Convert(scmd.c_str(), NONE, SHELL);
+ return this->Convert(scmd, NONE, SHELL);
}
}
- return this->Convert(cmd.c_str(), root, SHELL);
+ return this->Convert(cmd, root, SHELL);
}
//----------------------------------------------------------------------------
@@ -758,15 +806,17 @@ cmLocalUnixMakefileGenerator3
depends.push_back(".hpux_make_needs_suffix_list");
this->WriteMakeRule(makefileStream, 0,
".SUFFIXES", depends, no_commands, false);
-
- cmGlobalUnixMakefileGenerator3* gg =
- static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
- // Write special target to silence make output. This must be after
- // the default target in case VERBOSE is set (which changes the
- // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a
- // "VERBOSE=1" to be added as a make variable which will change the
- // name of this special target. This gives a make-time choice to
- // the user.
+ if(this->WatcomWMake)
+ {
+ // Switch on WMake feature, if an error or interrupt occurs during
+ // makefile processing, the current target being made may be deleted
+ // without prompting (the same as command line -e option).
+ makefileStream <<
+ "\n"
+ ".ERASE\n"
+ "\n"
+ ;
+ }
if(this->Makefile->IsOn("CMAKE_VERBOSE_MAKEFILE"))
{
makefileStream
@@ -774,12 +824,23 @@ cmLocalUnixMakefileGenerator3
<< "VERBOSE = 1\n"
<< "\n";
}
- if(this->SilentNoColon)
+ if(this->WatcomWMake)
{
- makefileStream << "$(VERBOSE).SILENT\n";
+ makefileStream <<
+ "!ifndef VERBOSE\n"
+ ".SILENT\n"
+ "!endif\n"
+ "\n"
+ ;
}
else
{
+ // Write special target to silence make output. This must be after
+ // the default target in case VERBOSE is set (which changes the
+ // name). The setting of CMAKE_VERBOSE_MAKEFILE to ON will cause a
+ // "VERBOSE=1" to be added as a make variable which will change the
+ // name of this special target. This gives a make-time choice to
+ // the user.
this->WriteMakeRule(makefileStream,
"Suppress display of executed commands.",
"$(VERBOSE).SILENT",
@@ -789,6 +850,8 @@ cmLocalUnixMakefileGenerator3
// Work-around for makes that drop rules that have no dependencies
// or commands.
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
std::string hack = gg->GetEmptyRuleHackDepends();
if(!hack.empty())
{
@@ -829,7 +892,7 @@ void cmLocalUnixMakefileGenerator3
std::string runRule =
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
runRule += " --check-build-system ";
- runRule += this->Convert(cmakefileName.c_str(),NONE,SHELL);
+ runRule += this->Convert(cmakefileName,NONE,SHELL);
runRule += " 0";
std::vector<std::string> no_depends;
@@ -859,11 +922,11 @@ void cmLocalUnixMakefileGenerator3
void
cmLocalUnixMakefileGenerator3
::WriteConvenienceRule(std::ostream& ruleFileStream,
- const char* realTarget,
- const char* helpTarget)
+ const std::string& realTarget,
+ const std::string& helpTarget)
{
// A rule is only needed if the names are different.
- if(strcmp(realTarget, helpTarget) != 0)
+ if(realTarget != helpTarget)
{
// The helper target depends on the real target.
std::vector<std::string> depends;
@@ -886,7 +949,7 @@ cmLocalUnixMakefileGenerator3
{
std::string dir = this->HomeRelativeOutputPath;
dir += this->GetTargetDirectory(target);
- return this->Convert(dir.c_str(),NONE,UNCHANGED);
+ return this->Convert(dir,NONE,UNCHANGED);
}
@@ -947,7 +1010,9 @@ cmLocalUnixMakefileGenerator3
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
i != ccs.end(); ++i)
{
- this->AppendCustomDepend(depends, *i);
+ cmCustomCommandGenerator ccg(*i, this->ConfigurationName,
+ this->Makefile);
+ this->AppendCustomDepend(depends, ccg);
}
}
@@ -955,14 +1020,14 @@ cmLocalUnixMakefileGenerator3
void
cmLocalUnixMakefileGenerator3
::AppendCustomDepend(std::vector<std::string>& depends,
- const cmCustomCommand& cc)
+ cmCustomCommandGenerator const& ccg)
{
- for(std::vector<std::string>::const_iterator d = cc.GetDepends().begin();
- d != cc.GetDepends().end(); ++d)
+ for(std::vector<std::string>::const_iterator d = ccg.GetDepends().begin();
+ d != ccg.GetDepends().end(); ++d)
{
// Lookup the real name of the dependency in case it is a CMake target.
std::string dep;
- if(this->GetRealDependency(d->c_str(), this->ConfigurationName.c_str(),
+ if(this->GetRealDependency(*d, this->ConfigurationName,
dep))
{
depends.push_back(dep);
@@ -981,7 +1046,9 @@ cmLocalUnixMakefileGenerator3
for(std::vector<cmCustomCommand>::const_iterator i = ccs.begin();
i != ccs.end(); ++i)
{
- this->AppendCustomCommand(commands, *i, target, true, relative);
+ cmCustomCommandGenerator ccg(*i, this->ConfigurationName,
+ this->Makefile);
+ this->AppendCustomCommand(commands, ccg, target, true, relative);
}
}
@@ -989,7 +1056,7 @@ cmLocalUnixMakefileGenerator3
void
cmLocalUnixMakefileGenerator3
::AppendCustomCommand(std::vector<std::string>& commands,
- const cmCustomCommand& cc,
+ cmCustomCommandGenerator const& ccg,
cmTarget* target,
bool echo_comment,
cmLocalGenerator::RelativeRoot relative,
@@ -1001,8 +1068,8 @@ cmLocalUnixMakefileGenerator3
// their comments generated elsewhere.
if(echo_comment)
{
- const char* comment = cc.GetComment();
- if(comment && *comment)
+ const char* comment = ccg.GetComment();
+ if(comment && !*comment)
{
this->AppendEcho(commands, comment,
cmLocalUnixMakefileGenerator3::EchoGenerate);
@@ -1010,9 +1077,9 @@ cmLocalUnixMakefileGenerator3
}
// if the command specified a working directory use it.
- const char* dir = this->Makefile->GetStartOutputDirectory();
- const char* workingDir = cc.GetWorkingDirectory();
- if(workingDir)
+ std::string dir = this->Makefile->GetStartOutputDirectory();
+ std::string workingDir = ccg.GetWorkingDirectory();
+ if(!workingDir.empty())
{
dir = workingDir;
}
@@ -1020,8 +1087,6 @@ cmLocalUnixMakefileGenerator3
{
*content << dir;
}
- cmCustomCommandGenerator ccg(cc, this->ConfigurationName.c_str(),
- this->Makefile);
// Add each command line to the set of commands.
std::vector<std::string> commands1;
@@ -1053,9 +1118,9 @@ cmLocalUnixMakefileGenerator3
// Convert the command to a relative path only if the current
// working directory will be the start-output directory.
bool had_slash = cmd.find("/") != cmd.npos;
- if(!workingDir)
+ if(workingDir.empty())
{
- cmd = this->Convert(cmd.c_str(),START_OUTPUT);
+ cmd = this->Convert(cmd,START_OUTPUT);
}
bool has_slash = cmd.find("/") != cmd.npos;
if(had_slash && !has_slash)
@@ -1066,7 +1131,8 @@ cmLocalUnixMakefileGenerator3
cmd = "./" + cmd;
}
std::string launcher =
- this->MakeLauncher(cc, target, workingDir? NONE : START_OUTPUT);
+ this->MakeLauncher(ccg, target,
+ workingDir.empty()? START_OUTPUT : NONE);
cmd = launcher + this->ConvertShellCommand(cmd, NONE);
ccg.AppendArguments(c, cmd);
@@ -1112,7 +1178,7 @@ cmLocalUnixMakefileGenerator3
}
// Setup the proper working directory for the commands.
- this->CreateCDCommand(commands1, dir, relative);
+ this->CreateCDCommand(commands1, dir.c_str(), relative);
// push back the custom commands
commands.insert(commands.end(), commands1.begin(), commands1.end());
@@ -1120,9 +1186,9 @@ cmLocalUnixMakefileGenerator3
//----------------------------------------------------------------------------
std::string
-cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc,
- cmTarget* target,
- RelativeRoot relative)
+cmLocalUnixMakefileGenerator3::MakeLauncher(
+ cmCustomCommandGenerator const& ccg,
+ cmTarget* target, RelativeRoot relative)
{
// Short-circuit if there is no launcher.
const char* prop = "RULE_LAUNCH_CUSTOM";
@@ -1138,10 +1204,10 @@ cmLocalUnixMakefileGenerator3::MakeLauncher(const cmCustomCommand& cc,
vars.RuleLauncher = prop;
vars.CMTarget = target;
std::string output;
- const std::vector<std::string>& outputs = cc.GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
if(!outputs.empty())
{
- output = this->Convert(outputs[0].c_str(), relative, SHELL);
+ output = this->Convert(outputs[0], relative, SHELL);
}
vars.Output = output.c_str();
@@ -1171,7 +1237,7 @@ cmLocalUnixMakefileGenerator3
cleanfile += filename;
}
cleanfile += ".cmake";
- std::string cleanfilePath = this->Convert(cleanfile.c_str(), FULL);
+ std::string cleanfilePath = this->Convert(cleanfile, FULL);
cmsys::ofstream fout(cleanfilePath.c_str());
if(!fout)
{
@@ -1183,25 +1249,26 @@ cmLocalUnixMakefileGenerator3
for(std::vector<std::string>::const_iterator f = files.begin();
f != files.end(); ++f)
{
- std::string fc = this->Convert(f->c_str(),START_OUTPUT,UNCHANGED);
- fout << " " << this->EscapeForCMake(fc.c_str()) << "\n";
+ std::string fc = this->Convert(*f,START_OUTPUT,UNCHANGED);
+ fout << " " << this->EscapeForCMake(fc) << "\n";
}
fout << ")\n";
}
std::string remove = "$(CMAKE_COMMAND) -P ";
- remove += this->Convert(cleanfile.c_str(), START_OUTPUT, SHELL);
+ remove += this->Convert(cleanfile, START_OUTPUT, SHELL);
commands.push_back(remove);
// For the main clean rule add per-language cleaning.
if(!filename)
{
// Get the set of source languages in the target.
- std::set<cmStdString> languages;
- target.GetLanguages(languages);
+ std::set<std::string> languages;
+ target.GetLanguages(languages,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
fout << "\n"
<< "# Per-language clean rules from dependency scanning.\n"
<< "foreach(lang";
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
fout << " " << *l;
@@ -1267,14 +1334,14 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
{
// Use the native echo command.
cmd = "@echo ";
- cmd += this->EscapeForShell(line.c_str(), false, true);
+ cmd += this->EscapeForShell(line, false, true);
}
else
{
// Use cmake to echo the text in color.
cmd = "@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) ";
cmd += color_name;
- cmd += this->EscapeForShell(line.c_str());
+ cmd += this->EscapeForShell(line);
}
commands.push_back(cmd);
}
@@ -1299,7 +1366,7 @@ cmLocalUnixMakefileGenerator3::AppendEcho(std::vector<std::string>& commands,
//----------------------------------------------------------------------------
std::string
cmLocalUnixMakefileGenerator3
-::CreateMakeVariable(const char* sin, const char* s2in)
+::CreateMakeVariable(const std::string& sin, const std::string& s2in)
{
std::string s = sin;
std::string s2 = s2in;
@@ -1317,7 +1384,7 @@ cmLocalUnixMakefileGenerator3
// see if the variable has been defined before and return
// the modified version of the variable
- std::map<cmStdString, cmStdString>::iterator i =
+ std::map<std::string, std::string>::iterator i =
this->MakeVariableMap.find(unmodified);
if(i != this->MakeVariableMap.end())
{
@@ -1588,14 +1655,14 @@ cmLocalUnixMakefileGenerator3
langs.begin(); li != langs.end(); ++li)
{
// construct the checker
- std::string lang = li->c_str();
+ std::string lang = *li;
// Create the scanner for this language
cmDepends *scanner = 0;
if(lang == "C" || lang == "CXX" || lang == "RC" || lang == "ASM")
{
// TODO: Handle RC (resource files) dependencies correctly.
- scanner = new cmDependsC(this, targetDir, lang.c_str(), &validDeps);
+ scanner = new cmDependsC(this, targetDir, lang, &validDeps);
}
#ifdef CMAKE_BUILD_WITH_CMAKE
else if(lang == "Fortran")
@@ -1613,7 +1680,7 @@ cmLocalUnixMakefileGenerator3
scanner->SetLocalGenerator(this);
scanner->SetFileComparison
(this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
- scanner->SetLanguage(lang.c_str());
+ scanner->SetLanguage(lang);
scanner->SetTargetDirectory(dir.c_str());
scanner->Write(ruleFileStream, internalRuleFileStream);
@@ -1721,12 +1788,12 @@ void cmLocalUnixMakefileGenerator3
{
text = "Running external command ...";
}
- std::set<cmStdString>::const_iterator dit;
+ std::set<std::string>::const_iterator dit;
for ( dit = glIt->second.GetUtilities().begin();
dit != glIt->second.GetUtilities().end();
++ dit )
{
- depends.push_back(dit->c_str());
+ depends.push_back(*dit);
}
this->AppendEcho(commands, text,
cmLocalUnixMakefileGenerator3::EchoGlobal);
@@ -1746,7 +1813,7 @@ void cmLocalUnixMakefileGenerator3
cmLocalGenerator::START_OUTPUT);
std::string targetName = glIt->second.GetName();
this->WriteMakeRule(ruleFileStream, targetString.c_str(),
- targetName.c_str(), depends, commands, true);
+ targetName, depends, commands, true);
// Provide a "/fast" version of the target.
depends.clear();
@@ -1766,7 +1833,7 @@ void cmLocalUnixMakefileGenerator3
}
targetName += "/fast";
this->WriteMakeRule(ruleFileStream, targetString.c_str(),
- targetName.c_str(), depends, commands, true);
+ targetName, depends, commands, true);
}
}
@@ -1786,15 +1853,15 @@ void cmLocalUnixMakefileGenerator3
cmOStringStream progCmd;
progCmd <<
"$(CMAKE_COMMAND) -E cmake_progress_start ";
- progCmd << this->Convert(progressDir.c_str(),
+ progCmd << this->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
std::string progressFile = cmake::GetCMakeFilesDirectory();
progressFile += "/progress.marks";
std::string progressFileNameFull =
- this->ConvertToFullPath(progressFile.c_str());
- progCmd << " " << this->Convert(progressFileNameFull.c_str(),
+ this->ConvertToFullPath(progressFile);
+ progCmd << " " << this->Convert(progressFileNameFull,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
commands.push_back(progCmd.str());
@@ -1802,14 +1869,14 @@ void cmLocalUnixMakefileGenerator3
std::string mf2Dir = cmake::GetCMakeFilesDirectoryPostSlash();
mf2Dir += "Makefile2";
commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
- recursiveTarget.c_str()));
+ recursiveTarget));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
{
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_start "; // # 0
- progCmd << this->Convert(progressDir.c_str(),
+ progCmd << this->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
progCmd << " 0";
@@ -1824,7 +1891,7 @@ void cmLocalUnixMakefileGenerator3
commands.clear();
depends.clear();
commands.push_back(this->GetRecursiveMakeCall(mf2Dir.c_str(),
- recursiveTarget.c_str()));
+ recursiveTarget));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
@@ -1854,7 +1921,7 @@ void cmLocalUnixMakefileGenerator3
depends.push_back("cmake_check_build_system");
}
commands.push_back
- (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget.c_str()));
+ (this->GetRecursiveMakeCall(mf2Dir.c_str(), recursiveTarget));
this->CreateCDCommand(commands,
this->Makefile->GetHomeOutputDirectory(),
cmLocalGenerator::START_OUTPUT);
@@ -1872,7 +1939,7 @@ void cmLocalUnixMakefileGenerator3
std::string runRule =
"$(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)";
runRule += " --check-build-system ";
- runRule += this->Convert(cmakefileName.c_str(),cmLocalGenerator::NONE,
+ runRule += this->Convert(cmakefileName,cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
runRule += " 1";
commands.push_back(runRule);
@@ -1905,7 +1972,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
for(std::vector<std::string>::iterator l = files.begin();
l != files.end(); ++l)
{
- std::string dir = cmSystemTools::GetFilenamePath(l->c_str());
+ std::string dir = cmSystemTools::GetFilenamePath(*l);
// Clear the implicit dependency makefile.
std::string dependFile = dir + "/depend.make";
@@ -1933,7 +2000,7 @@ void cmLocalUnixMakefileGenerator3
for(ImplicitDependLanguageMap::const_iterator
l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
{
- cmakefileStream << " \"" << l->first.c_str() << "\"\n";
+ cmakefileStream << " \"" << l->first << "\"\n";
}
cmakefileStream << " )\n";
@@ -1944,7 +2011,7 @@ void cmLocalUnixMakefileGenerator3
l = implicitLangs.begin(); l != implicitLangs.end(); ++l)
{
cmakefileStream
- << "set(CMAKE_DEPENDS_CHECK_" << l->first.c_str() << "\n";
+ << "set(CMAKE_DEPENDS_CHECK_" << l->first << "\n";
ImplicitDependFileMap const& implicitPairs = l->second;
// for each file pair
@@ -1964,11 +2031,11 @@ void cmLocalUnixMakefileGenerator3
std::string cidVar = "CMAKE_";
cidVar += l->first;
cidVar += "_COMPILER_ID";
- const char* cid = this->Makefile->GetDefinition(cidVar.c_str());
+ const char* cid = this->Makefile->GetDefinition(cidVar);
if(cid && *cid)
{
cmakefileStream
- << "set(CMAKE_" << l->first.c_str() << "_COMPILER_ID \""
+ << "set(CMAKE_" << l->first << "_COMPILER_ID \""
<< cid << "\")\n";
}
}
@@ -1976,7 +2043,7 @@ void cmLocalUnixMakefileGenerator3
// Build a list of preprocessor definitions for the target.
std::set<std::string> defines;
this->AddCompileDefinitions(defines, &target,
- this->ConfigurationName.c_str());
+ this->ConfigurationName);
if(!defines.empty())
{
cmakefileStream
@@ -1987,7 +2054,7 @@ void cmLocalUnixMakefileGenerator3
di != defines.end(); ++di)
{
cmakefileStream
- << " " << this->EscapeForCMake(di->c_str()) << "\n";
+ << " " << this->EscapeForCMake(*di) << "\n";
}
cmakefileStream
<< " )\n";
@@ -2013,7 +2080,7 @@ void cmLocalUnixMakefileGenerator3
for(std::vector<std::string>::const_iterator tri = transformRules.begin();
tri != transformRules.end(); ++tri)
{
- cmakefileStream << " " << this->EscapeForCMake(tri->c_str()) << "\n";
+ cmakefileStream << " " << this->EscapeForCMake(*tri) << "\n";
}
cmakefileStream
<< " )\n";
@@ -2034,7 +2101,7 @@ void cmLocalUnixMakefileGenerator3::WriteDisclaimer(std::ostream& os)
//----------------------------------------------------------------------------
std::string
cmLocalUnixMakefileGenerator3
-::GetRecursiveMakeCall(const char *makefile, const char* tgt)
+::GetRecursiveMakeCall(const char *makefile, const std::string& tgt)
{
// Call make on the given file.
std::string cmd;
@@ -2059,7 +2126,7 @@ cmLocalUnixMakefileGenerator3
}
// Add the target.
- if (tgt && tgt[0] != '\0')
+ if (!tgt.empty())
{
// The make target is always relative to the top of the build tree.
std::string tgt2 = this->Convert(tgt, HOME_OUTPUT);
@@ -2070,12 +2137,12 @@ cmLocalUnixMakefileGenerator3
// Escape one extra time if the make tool requires it.
if(this->MakeCommandEscapeTargetTwice)
{
- tgt2 = this->EscapeForShell(tgt2.c_str(), true, false);
+ tgt2 = this->EscapeForShell(tgt2, true, false);
}
// The target name is now a string that should be passed verbatim
// on the command line.
- cmd += this->EscapeForShell(tgt2.c_str(), true, false);
+ cmd += this->EscapeForShell(tgt2, true, false);
}
return cmd;
}
@@ -2116,59 +2183,82 @@ cmLocalUnixMakefileGenerator3
//----------------------------------------------------------------------------
std::string
-cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p)
+cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath(const char* p,
+ bool useWatcomQuote)
{
-
// Split the path into its components.
std::vector<std::string> components;
cmSystemTools::SplitPath(p, components);
- // Return an empty path if there are no components.
- if(components.empty())
+ // Open the quoted result.
+ std::string result;
+ if(useWatcomQuote)
{
- return "\"\"";
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ result = "'";
+#else
+ result = "\"'";
+#endif
+ }
+ else
+ {
+ result = "\"";
}
- // Choose a slash direction and fix root component.
- const char* slash = "/";
+ // Return an empty path if there are no components.
+ if(!components.empty())
+ {
+ // Choose a slash direction and fix root component.
+ const char* slash = "/";
#if defined(_WIN32) && !defined(__CYGWIN__)
- if(!cmSystemTools::GetForceUnixPaths())
- {
- slash = "\\";
- for(std::string::iterator i = components[0].begin();
- i != components[0].end(); ++i)
- {
- if(*i == '/')
- {
- *i = '\\';
- }
- }
- }
+ if(!cmSystemTools::GetForceUnixPaths())
+ {
+ slash = "\\";
+ for(std::string::iterator i = components[0].begin();
+ i != components[0].end(); ++i)
+ {
+ if(*i == '/')
+ {
+ *i = '\\';
+ }
+ }
+ }
#endif
- // Begin the quoted result with the root component.
- std::string result = "\"";
- result += components[0];
+ // Begin the quoted result with the root component.
+ result += components[0];
- // Now add the rest of the components separated by the proper slash
- // direction for this platform.
- bool first = true;
- 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)))
+ // Now add the rest of the components separated by the proper slash
+ // direction for this platform.
+ bool first = true;
+ for(unsigned int i=1; i < components.size(); ++i)
{
- if(!first)
+ // Only the last component can be empty to avoid double slashes.
+ if(components[i].length() > 0 || (i == (components.size()-1)))
{
- result += slash;
+ if(!first)
+ {
+ result += slash;
+ }
+ result += components[i];
+ first = false;
}
- result += components[i];
- first = false;
}
}
// Close the quoted result.
- result += "\"";
+ if(useWatcomQuote)
+ {
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ result += "'";
+#else
+ result += "'\"";
+#endif
+ }
+ else
+ {
+ result += "\"";
+ }
return result;
}
@@ -2198,7 +2288,7 @@ cmLocalUnixMakefileGenerator3::GetImplicitDepends(cmTarget const& tgt)
//----------------------------------------------------------------------------
void
cmLocalUnixMakefileGenerator3::AddImplicitDepends(cmTarget const& tgt,
- const char* lang,
+ const std::string& lang,
const char* obj,
const char* src)
{
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 703369e..99974ee 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -18,6 +18,7 @@
#include "cmDepends.h"
class cmCustomCommand;
+class cmCustomCommandGenerator;
class cmDependInformation;
class cmDepends;
class cmMakefileTargetGenerator;
@@ -55,7 +56,7 @@ public:
// Write out a make rule
void WriteMakeRule(std::ostream& os,
const char* comment,
- const char* target,
+ const std::string& target,
const std::vector<std::string>& depends,
const std::vector<std::string>& commands,
bool symbolic,
@@ -75,7 +76,7 @@ public:
/**
* Set the flag used to keep the make program silent.
*/
- void SetMakeSilentFlag(const char* s) { this->MakeSilentFlag = s; }
+ void SetMakeSilentFlag(const std::string& s) { this->MakeSilentFlag = s; }
std::string &GetMakeSilentFlag() { return this->MakeSilentFlag; }
/**
@@ -121,17 +122,12 @@ public:
void SetUnixCD(bool v) {this->UnixCD = v;}
/**
- * Set Support Verbose Variable. If true, then .SILENT will
- * be not end with : i.e. .SILENT: or .SILENT
- */
- void SetSilentNoColon(bool v) {this->SilentNoColon = v;}
-
- /**
* Set the string used to include one makefile into another default
* is include.
*/
- void SetIncludeDirective(const char* s) { this->IncludeDirective = s; }
- const char *GetIncludeDirective() { return this->IncludeDirective.c_str(); }
+ void SetIncludeDirective(const std::string& s)
+ { this->IncludeDirective = s; }
+ const std::string& GetIncludeDirective() { return this->IncludeDirective; }
/**
* Set max makefile variable size, default is 0 which means unlimited.
@@ -168,7 +164,8 @@ public:
void WriteDivider(std::ostream& os);
/** used to create a recursive make call */
- std::string GetRecursiveMakeCall(const char *makefile, const char* tgt);
+ std::string GetRecursiveMakeCall(const char *makefile,
+ const std::string& tgt);
// append flags to a string
virtual void AppendFlags(std::string& flags, const char* newFlags);
@@ -189,9 +186,11 @@ public:
const char *targetDir,
cmLocalGenerator::RelativeRoot returnDir);
- static std::string ConvertToQuotedOutputPath(const char* p);
+ static std::string ConvertToQuotedOutputPath(const char* p,
+ bool useWatcomQuote);
- std::string CreateMakeVariable(const char* sin, const char* s2in);
+ std::string CreateMakeVariable(const std::string& sin,
+ const std::string& s2in);
/** Called from command-line hook to bring dependencies up to date
for a target. */
@@ -210,14 +209,14 @@ public:
// File pairs for implicit dependency scanning. The key of the map
// is the depender and the value is the explicit dependee.
struct ImplicitDependFileMap:
- public std::map<cmStdString, cmDepends::DependencyVector> {};
+ public std::map<std::string, cmDepends::DependencyVector> {};
struct ImplicitDependLanguageMap:
- public std::map<cmStdString, ImplicitDependFileMap> {};
+ public std::map<std::string, ImplicitDependFileMap> {};
struct ImplicitDependTargetMap:
- public std::map<cmStdString, ImplicitDependLanguageMap> {};
+ public std::map<std::string, ImplicitDependLanguageMap> {};
ImplicitDependLanguageMap const& GetImplicitDepends(cmTarget const& tgt);
- void AddImplicitDepends(cmTarget const& tgt, const char* lang,
+ void AddImplicitDepends(cmTarget const& tgt, const std::string& lang,
const char* obj, const char* src);
void AppendGlobalTargetDepends(std::vector<std::string>& depends,
@@ -226,11 +225,7 @@ public:
// write the target rules for the local Makefile into the stream
void WriteLocalAllRules(std::ostream& ruleFileStream);
- void AddLocalObjectFile(cmTarget* target, cmSourceFile* sf,
- std::string objNoTargetDir,
- bool hasSourceExtension);
-
- std::vector<cmStdString> const& GetLocalHelp() { return this->LocalHelp; }
+ std::vector<std::string> const& GetLocalHelp() { return this->LocalHelp; }
/** Get whether to create rules to generate preprocessed and
assembly sources. This could be converted to a variable lookup
@@ -255,7 +250,7 @@ protected:
// write the target rules for the local Makefile into the stream
void WriteLocalMakefileTargets(std::ostream& ruleFileStream,
- std::set<cmStdString> &emitted);
+ std::set<std::string> &emitted);
// this method Writes the Directory information files
void WriteDirectoryInformationFile();
@@ -273,8 +268,8 @@ protected:
void WriteConvenienceRule(std::ostream& ruleFileStream,
- const char* realTarget,
- const char* helpTarget);
+ const std::string& realTarget,
+ const std::string& helpTarget);
void WriteTargetDependRule(std::ostream& ruleFileStream,
cmTarget& target);
@@ -292,14 +287,14 @@ protected:
void AppendCustomDepends(std::vector<std::string>& depends,
const std::vector<cmCustomCommand>& ccs);
void AppendCustomDepend(std::vector<std::string>& depends,
- const cmCustomCommand& cc);
+ cmCustomCommandGenerator const& cc);
void AppendCustomCommands(std::vector<std::string>& commands,
const std::vector<cmCustomCommand>& ccs,
cmTarget* target,
cmLocalGenerator::RelativeRoot relative =
cmLocalGenerator::HOME_OUTPUT);
void AppendCustomCommand(std::vector<std::string>& commands,
- const cmCustomCommand& cc,
+ cmCustomCommandGenerator const& ccg,
cmTarget* target,
bool echo_comment=false,
cmLocalGenerator::RelativeRoot relative =
@@ -316,8 +311,12 @@ protected:
private:
std::string ConvertShellCommand(std::string const& cmd, RelativeRoot root);
- std::string MakeLauncher(const cmCustomCommand& cc, cmTarget* target,
- RelativeRoot relative);
+ std::string MakeLauncher(cmCustomCommandGenerator const& ccg,
+ cmTarget* target, RelativeRoot relative);
+
+ virtual void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = 0);
friend class cmMakefileTargetGenerator;
friend class cmMakefileExecutableTargetGenerator;
@@ -336,7 +335,6 @@ private:
bool DefineWindowsNULL;
bool UnixCD;
bool PassMakeflags;
- bool SilentNoColon;
bool MakeCommandEscapeTargetTwice;
bool BorlandMakeCurlyHack;
//==========================================================================
@@ -358,7 +356,7 @@ private:
cmTarget* Target;
std::string Language;
LocalObjectEntry(): Target(0), Language() {}
- LocalObjectEntry(cmTarget* t, const char* lang):
+ LocalObjectEntry(cmTarget* t, const std::string& lang):
Target(t), Language(lang) {}
};
struct LocalObjectInfo: public std::vector<LocalObjectEntry>
@@ -369,16 +367,18 @@ private:
LocalObjectInfo():HasSourceExtension(false), HasPreprocessRule(false),
HasAssembleRule(false) {}
};
- std::map<cmStdString, LocalObjectInfo> LocalObjectFiles;
+ void GetLocalObjectFiles(
+ std::map<std::string, LocalObjectInfo> &localObjectFiles);
+
void WriteObjectConvenienceRule(std::ostream& ruleFileStream,
const char* comment, const char* output,
LocalObjectInfo const& info);
- std::vector<cmStdString> LocalHelp;
+ std::vector<std::string> LocalHelp;
/* does the work for each target */
- std::map<cmStdString, cmStdString> MakeVariableMap;
- std::map<cmStdString, cmStdString> ShortMakeVariableMap;
+ std::map<std::string, std::string> MakeVariableMap;
+ std::map<std::string, std::string> ShortMakeVariableMap;
};
#endif
diff --git a/Source/cmLocalVisualStudio10Generator.cxx b/Source/cmLocalVisualStudio10Generator.cxx
index aedd6ed..aa70ab9 100644
--- a/Source/cmLocalVisualStudio10Generator.cxx
+++ b/Source/cmLocalVisualStudio10Generator.cxx
@@ -19,7 +19,7 @@
class cmVS10XMLParser : public cmXMLParser
{
public:
- virtual void EndElement(const char* /* name */)
+ virtual void EndElement(const std::string& /* name */)
{
}
virtual void CharacterDataHandler(const char* data, int length)
@@ -30,14 +30,14 @@ class cmVS10XMLParser : public cmXMLParser
this->DoGUID = false;
}
}
- virtual void StartElement(const char* name, const char**)
+ virtual void StartElement(const std::string& name, const char**)
{
// once the GUID is found do nothing
if(this->GUID.size())
{
return;
}
- if(strcmp("ProjectGUID", name) == 0 || strcmp("ProjectGuid", name) == 0)
+ if("ProjectGUID" == name || "ProjectGuid" == name)
{
this->DoGUID = true;
}
@@ -98,7 +98,7 @@ void cmLocalVisualStudio10Generator::Generate()
void cmLocalVisualStudio10Generator
-::ReadAndStoreExternalGUID(const char* name,
+::ReadAndStoreExternalGUID(const std::string& name,
const char* path)
{
cmVS10XMLParser parser;
diff --git a/Source/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h
index 41db735..b50e345 100644
--- a/Source/cmLocalVisualStudio10Generator.h
+++ b/Source/cmLocalVisualStudio10Generator.h
@@ -34,7 +34,7 @@ public:
* Generate the makefile for this directory.
*/
virtual void Generate();
- virtual void ReadAndStoreExternalGUID(const char* name,
+ virtual void ReadAndStoreExternalGUID(const std::string& name,
const char* path);
protected:
diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx
index a5e8294..5db735f 100644
--- a/Source/cmLocalVisualStudio6Generator.cxx
+++ b/Source/cmLocalVisualStudio6Generator.cxx
@@ -16,6 +16,7 @@
#include "cmSourceFile.h"
#include "cmCacheManager.h"
#include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
#include "cmake.h"
#include "cmComputeLinkInformation.h"
@@ -38,7 +39,7 @@ class cmLocalVisualStudio6Generator::EventWriter
{
public:
EventWriter(cmLocalVisualStudio6Generator* lg,
- const char* config, std::string& code):
+ const std::string& config, std::string& code):
LG(lg), Config(config), Code(code), First(true) {}
void Start(const char* event)
{
@@ -59,6 +60,7 @@ public:
}
void Write(cmCustomCommand const& cc)
{
+ cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
if(this->First)
{
this->Code += this->Event + "_Cmds=";
@@ -68,11 +70,11 @@ public:
{
this->Code += "\\\n\t";
}
- this->Code += this->LG->ConstructScript(cc, this->Config, "\\\n\t");
+ this->Code += this->LG->ConstructScript(ccg, "\\\n\t");
}
private:
cmLocalVisualStudio6Generator* LG;
- const char* Config;
+ std::string Config;
std::string& Code;
bool First;
std::string Event;
@@ -80,7 +82,7 @@ private:
void cmLocalVisualStudio6Generator::AddHelperCommands()
{
- std::set<cmStdString> lang;
+ std::set<std::string> lang;
lang.insert("C");
lang.insert("CXX");
this->CreateCustomTargetsAndCommands(lang);
@@ -186,7 +188,7 @@ void cmLocalVisualStudio6Generator::OutputDSPFile()
//
extern std::string GetVS6TargetName(const std::string& targetName);
-void cmLocalVisualStudio6Generator::CreateSingleDSP(const char *lname,
+void cmLocalVisualStudio6Generator::CreateSingleDSP(const std::string& lname,
cmTarget &target)
{
// add to the list of projects
@@ -251,9 +253,9 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
makefileIn.c_str(), commandLines,
comment.c_str(),
no_working_directory, true);
- if(cmSourceFile* file = this->Makefile->GetSource(makefileIn.c_str()))
+ if(this->Makefile->GetSource(makefileIn.c_str()))
{
- tgt.AddSourceFile(file);
+ tgt.AddSource(makefileIn);
}
else
{
@@ -263,7 +265,7 @@ void cmLocalVisualStudio6Generator::AddDSPBuildRule(cmTarget& tgt)
void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
- const char *libName,
+ const std::string& libName,
cmTarget &target)
{
// For utility targets need custom command since pre- and post-
@@ -315,13 +317,21 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups
std::vector<cmSourceFile*> classes;
- target.GetSourceFiles(classes);
+ if (!target.GetConfigCommonSourceFiles(classes))
+ {
+ return;
+ }
// now all of the source files have been properly assigned to the target
// now stick them into source groups using the reg expressions
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++)
{
+ if (!(*i)->GetObjectLibrary().empty())
+ {
+ continue;
+ }
+
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
cmSourceGroup* sourceGroup =
@@ -372,7 +382,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFile(std::ostream& fout,
void cmLocalVisualStudio6Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
- std::ostream &fout, const char *libName)
+ std::ostream &fout, const std::string& libName)
{
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
@@ -396,6 +406,11 @@ void cmLocalVisualStudio6Generator
for(std::vector<const cmSourceFile *>::const_iterator sf =
sourceFiles.begin(); sf != sourceFiles.end(); ++sf)
{
+ if (!(*sf)->GetObjectLibrary().empty())
+ {
+ continue;
+ }
+
std::string source = (*sf)->GetFullPath();
const cmCustomCommand *command =
(*sf)->GetCustomCommand();
@@ -413,23 +428,20 @@ void cmLocalVisualStudio6Generator
compileFlags += cflags;
}
- const char* lang = this->GetSourceFileLanguage(*(*sf));
- if(lang)
+ const std::string& lang = this->GetSourceFileLanguage(*(*sf));
+ if(lang == "CXX")
{
- if(strcmp(lang, "CXX") == 0)
- {
- // force a C++ file type
- compileFlags += " /TP ";
- }
- else if(strcmp(lang, "C") == 0)
- {
- // force to c file type
- compileFlags += " /TC ";
- }
+ // force a C++ file type
+ compileFlags += " /TP ";
+ }
+ else if(lang == "C")
+ {
+ // force to c file type
+ compileFlags += " /TC ";
}
// Add per-source and per-configuration preprocessor definitions.
- std::map<cmStdString, cmStdString> cdmap;
+ std::map<std::string, std::string> cdmap;
{
std::set<std::string> targetCompileDefinitions;
@@ -469,7 +481,7 @@ void cmLocalVisualStudio6Generator
}
bool excludedFromBuild =
- (lang && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
+ (!lang.empty() && (*sf)->GetPropertyAsBool("HEADER_FILE_ONLY"));
// Check for extra object-file dependencies.
const char* dependsValue = (*sf)->GetProperty("OBJECT_DEPENDS");
@@ -529,7 +541,7 @@ void cmLocalVisualStudio6Generator
{
fout << "\n# ADD CPP " << compileFlags << "\n\n";
}
- std::map<cmStdString, cmStdString>::iterator cdi =
+ std::map<std::string, std::string>::iterator cdi =
cdmap.find(cmSystemTools::UpperCase(config));
if(cdi != cdmap.end() && !cdi->second.empty())
{
@@ -575,20 +587,24 @@ cmLocalVisualStudio6Generator
{
// Create a fake output that forces the rule to run.
char* output = new char[(strlen(this->Makefile->GetStartOutputDirectory()) +
- strlen(target.GetName()) + 30)];
+ target.GetName().size() + 30)];
sprintf(output,"%s/%s_force_%i", this->Makefile->GetStartOutputDirectory(),
- target.GetName(), count);
- std::string comment = this->ConstructComment(origCommand, "<hack>");
+ target.GetName().c_str(), count);
+ const char* comment = origCommand.GetComment();
+ if(!comment && origCommand.GetOutputs().empty())
+ {
+ comment = "<hack>";
+ }
// Add the rule with the given dependencies and commands.
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
if(cmSourceFile* outsf =
this->Makefile->AddCustomCommandToOutput(
output, depends, no_main_dependency,
- origCommand.GetCommandLines(), comment.c_str(),
- origCommand.GetWorkingDirectory()))
+ origCommand.GetCommandLines(), comment,
+ origCommand.GetWorkingDirectory().c_str()))
{
- target.AddSourceFile(outsf);
+ target.AddSource(outsf->GetFullPath());
}
// Replace the dependencies with the output of this rule so that the
@@ -607,20 +623,21 @@ cmLocalVisualStudio6Generator
const cmCustomCommand& command,
const char* flags)
{
- std::string comment =
- this->ConstructComment(command, "Building Custom Rule $(InputPath)");
- if(comment == "<hack>")
- {
- comment = "";
- }
-
// Write the rule for each configuration.
std::vector<std::string>::iterator i;
for(i = this->Configurations.begin(); i != this->Configurations.end(); ++i)
{
std::string config = this->GetConfigName(*i);
+ cmCustomCommandGenerator ccg(command, config, this->Makefile);
+ std::string comment =
+ this->ConstructComment(ccg, "Building Custom Rule $(InputPath)");
+ if(comment == "<hack>")
+ {
+ comment = "";
+ }
+
std::string script =
- this->ConstructScript(command, config.c_str(), "\\\n\t");
+ this->ConstructScript(ccg, "\\\n\t");
if (i == this->Configurations.begin())
{
@@ -637,8 +654,8 @@ cmLocalVisualStudio6Generator
// Write out the dependencies for the rule.
fout << "USERDEP__HACK=";
for(std::vector<std::string>::const_iterator d =
- command.GetDepends().begin();
- d != command.GetDepends().end();
+ ccg.GetDepends().begin();
+ d != ccg.GetDepends().end();
++d)
{
// Lookup the real name of the dependency in case it is a CMake target.
@@ -658,7 +675,7 @@ cmLocalVisualStudio6Generator
fout << " " << comment.c_str();
}
fout << "\n\n";
- if(command.GetOutputs().empty())
+ if(ccg.GetOutputs().empty())
{
fout << source
<< "_force : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"\n\t";
@@ -667,8 +684,8 @@ cmLocalVisualStudio6Generator
else
{
for(std::vector<std::string>::const_iterator o =
- command.GetOutputs().begin();
- o != command.GetOutputs().end();
+ ccg.GetOutputs().begin();
+ o != ccg.GetOutputs().end();
++o)
{
// Write a rule for every output generated by this command.
@@ -702,7 +719,7 @@ void cmLocalVisualStudio6Generator::WriteDSPEndGroup(std::ostream& fout)
void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
- const char* libName,
+ const std::string& libName,
cmTarget& target)
{
std::string root= this->Makefile->GetRequiredDefinition("CMAKE_ROOT");
@@ -788,7 +805,7 @@ void cmLocalVisualStudio6Generator::SetBuildType(BuildType b,
//----------------------------------------------------------------------------
cmsys::auto_ptr<cmCustomCommand>
cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
- const char* config)
+ const std::string& config)
{
cmsys::auto_ptr<cmCustomCommand> pcc;
@@ -816,8 +833,8 @@ cmLocalVisualStudio6Generator::MaybeCreateOutputDir(cmTarget& target,
// look for custom rules on a target and collect them together
std::string
cmLocalVisualStudio6Generator::CreateTargetRules(cmTarget &target,
- const char* configName,
- const char * /* libName */)
+ const std::string& configName,
+ const std::string& /* libName */)
{
if (target.GetType() >= cmTarget::UTILITY )
{
@@ -866,7 +883,7 @@ inline std::string removeQuotes(const std::string& s)
std::string
cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target,
- const char *config)
+ const std::string& config)
{
std::string includeOptions;
@@ -929,7 +946,7 @@ cmLocalVisualStudio6Generator::GetTargetIncludeOptions(cmTarget &target,
void cmLocalVisualStudio6Generator
::WriteDSPHeader(std::ostream& fout,
- const char *libName, cmTarget &target,
+ const std::string& libName, cmTarget &target,
std::vector<cmSourceGroup> &)
{
bool targetBuilds = (target.GetType() >= cmTarget::EXECUTABLE &&
@@ -1102,7 +1119,7 @@ void cmLocalVisualStudio6Generator
// Compute the proper name to use to link this library.
std::string lib;
std::string libDebug;
- cmTarget* tgt = this->GlobalGenerator->FindTarget(0, j->first.c_str());
+ cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str());
if(tgt)
{
lib = cmSystemTools::GetFilenameWithoutExtension
@@ -1255,12 +1272,25 @@ void cmLocalVisualStudio6Generator
if(targetBuilds)
{
// Get the language to use for linking.
- const char* linkLanguage = target.GetLinkerLanguage();
- if(!linkLanguage)
+ std::vector<std::string> configs;
+ target.GetMakefile()->GetConfigurations(configs);
+ std::vector<std::string>::const_iterator it = configs.begin();
+ const std::string& linkLanguage = target.GetLinkerLanguage(*it);
+ for ( ; it != configs.end(); ++it)
+ {
+ const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
+ if (configLinkLanguage != linkLanguage)
+ {
+ cmSystemTools::Error
+ ("Linker language must not vary by configuration for target: ",
+ target.GetName().c_str());
+ }
+ }
+ if(linkLanguage.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
- target.GetName());
+ target.GetName().c_str());
return;
}
@@ -1677,12 +1707,25 @@ void cmLocalVisualStudio6Generator
if(target.GetType() >= cmTarget::EXECUTABLE &&
target.GetType() <= cmTarget::OBJECT_LIBRARY)
{
- const char* linkLanguage = target.GetLinkerLanguage();
- if(!linkLanguage)
+ std::vector<std::string> configs;
+ target.GetMakefile()->GetConfigurations(configs);
+ std::vector<std::string>::const_iterator it = configs.begin();
+ const std::string& linkLanguage = target.GetLinkerLanguage(*it);
+ for ( ; it != configs.end(); ++it)
+ {
+ const std::string& configLinkLanguage = target.GetLinkerLanguage(*it);
+ if (configLinkLanguage != linkLanguage)
+ {
+ cmSystemTools::Error
+ ("Linker language must not vary by configuration for target: ",
+ target.GetName().c_str());
+ }
+ }
+ if(linkLanguage.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
- target.GetName());
+ target.GetName().c_str());
return;
}
// if CXX is on and the target contains cxx code then add the cxx flags
@@ -1707,7 +1750,7 @@ void cmLocalVisualStudio6Generator
flagsRelWithDebInfo = this->Makefile->GetSafeDefinition(flagVar.c_str());
flagsRelWithDebInfo += " -DCMAKE_INTDIR=\\\"RelWithDebInfo\\\" ";
- this->AddCompileOptions(flags, &target, linkLanguage, 0);
+ this->AddCompileOptions(flags, &target, linkLanguage, "");
this->AddCompileOptions(flagsDebug, &target, linkLanguage, "Debug");
this->AddCompileOptions(flagsRelease, &target, linkLanguage, "Release");
this->AddCompileOptions(flagsMinSizeRel, &target, linkLanguage,
@@ -1733,7 +1776,7 @@ void cmLocalVisualStudio6Generator
std::set<std::string> minsizeDefinesSet;
std::set<std::string> debugrelDefinesSet;
- this->AddCompileDefinitions(definesSet, &target, 0);
+ this->AddCompileDefinitions(definesSet, &target, "");
this->AddCompileDefinitions(debugDefinesSet, &target, "DEBUG");
this->AddCompileDefinitions(releaseDefinesSet, &target, "RELEASE");
this->AddCompileDefinitions(minsizeDefinesSet, &target, "MINSIZEREL");
@@ -1745,11 +1788,11 @@ void cmLocalVisualStudio6Generator
std::string minsizeDefines = " ";
std::string debugrelDefines = " ";
- this->JoinDefines(definesSet, defines, 0);
- this->JoinDefines(debugDefinesSet, debugDefines, 0);
- this->JoinDefines(releaseDefinesSet, releaseDefines, 0);
- this->JoinDefines(minsizeDefinesSet, minsizeDefines, 0);
- this->JoinDefines(debugrelDefinesSet, debugrelDefines, 0);
+ this->JoinDefines(definesSet, defines, "");
+ this->JoinDefines(debugDefinesSet, debugDefines, "");
+ this->JoinDefines(releaseDefinesSet, releaseDefines, "");
+ this->JoinDefines(minsizeDefinesSet, minsizeDefines, "");
+ this->JoinDefines(debugrelDefinesSet, debugrelDefines, "");
flags += defines;
flagsDebug += debugDefines;
@@ -1803,7 +1846,7 @@ void cmLocalVisualStudio6Generator::WriteDSPFooter(std::ostream& fout)
//----------------------------------------------------------------------------
void cmLocalVisualStudio6Generator
::ComputeLinkOptions(cmTarget& target,
- const char* configName,
+ const std::string& configName,
const std::string extraOptions,
std::string& options)
{
@@ -1875,7 +1918,7 @@ void cmLocalVisualStudio6Generator
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
std::vector<std::string> objs;
- gt->UseObjectLibraries(objs);
+ gt->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
{
diff --git a/Source/cmLocalVisualStudio6Generator.h b/Source/cmLocalVisualStudio6Generator.h
index f45bc17..4771833 100644
--- a/Source/cmLocalVisualStudio6Generator.h
+++ b/Source/cmLocalVisualStudio6Generator.h
@@ -48,7 +48,7 @@ public:
/**
* Specify the type of the build: static, dll, or executable.
*/
- void SetBuildType(BuildType, const char* libName, cmTarget&);
+ void SetBuildType(BuildType, const std::string& libName, cmTarget&);
virtual std::string GetTargetDirectory(cmTarget const& target) const;
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
@@ -56,15 +56,15 @@ private:
std::string DSPHeaderTemplate;
std::string DSPFooterTemplate;
- void CreateSingleDSP(const char *lname, cmTarget &tgt);
- void WriteDSPFile(std::ostream& fout, const char *libName,
+ void CreateSingleDSP(const std::string& lname, cmTarget &tgt);
+ void WriteDSPFile(std::ostream& fout, const std::string& libName,
cmTarget &tgt);
void WriteDSPBeginGroup(std::ostream& fout,
const char* group,
const char* filter);
void WriteDSPEndGroup(std::ostream& fout);
- void WriteDSPHeader(std::ostream& fout, const char *libName,
+ void WriteDSPHeader(std::ostream& fout, const std::string& libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteDSPFooter(std::ostream& fout);
@@ -77,20 +77,21 @@ private:
std::vector<std::string>& depends,
const cmCustomCommand& origCommand);
void WriteGroup(const cmSourceGroup *sg, cmTarget& target,
- std::ostream &fout, const char *libName);
+ std::ostream &fout, const std::string& libName);
class EventWriter;
friend class EventWriter;
cmsys::auto_ptr<cmCustomCommand>
- MaybeCreateOutputDir(cmTarget& target, const char* config);
+ MaybeCreateOutputDir(cmTarget& target, const std::string& config);
std::string CreateTargetRules(cmTarget &target,
- const char* configName,
- const char *libName);
- void ComputeLinkOptions(cmTarget& target, const char* configName,
+ const std::string& configName,
+ const std::string& libName);
+ void ComputeLinkOptions(cmTarget& target, const std::string& configName,
const std::string extraOptions,
std::string& options);
void OutputObjects(cmTarget& target, const char* tool,
std::string& options);
- std::string GetTargetIncludeOptions(cmTarget &target, const char *config);
+ std::string GetTargetIncludeOptions(cmTarget &target,
+ const std::string& config);
std::vector<std::string> Configurations;
std::string GetConfigName(std::string const& configuration) const;
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 212b06b..47f9826 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -18,6 +18,7 @@
#include "cmSourceFile.h"
#include "cmCacheManager.h"
#include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
#include "cmake.h"
#include "cmComputeLinkInformation.h"
@@ -59,7 +60,7 @@ cmLocalVisualStudio7Generator::~cmLocalVisualStudio7Generator()
void cmLocalVisualStudio7Generator::AddHelperCommands()
{
- std::set<cmStdString> lang;
+ std::set<std::string> lang;
lang.insert("C");
lang.insert("CXX");
lang.insert("RC");
@@ -83,7 +84,7 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
if(path)
{
this->ReadAndStoreExternalGUID(
- l->second.GetName(), path);
+ l->second.GetName().c_str(), path);
}
else
{
@@ -116,7 +117,7 @@ void cmLocalVisualStudio7Generator::AddCMakeListsRules()
{
if(l->first != CMAKE_CHECK_BUILD_SYSTEM_TARGET)
{
- l->second.AddSourceFile(sf);
+ l->second.AddSource(sf->GetFullPath());
}
}
}
@@ -141,7 +142,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
force_command.push_back(".");
cmCustomCommandLines force_commands;
force_commands.push_back(force_command);
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
std::string force = this->Makefile->GetStartOutputDirectory();
force += cmake::GetCMakeFilesDirectory();
force += "/";
@@ -152,7 +153,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
force.c_str(), no_depends, no_main_dependency,
force_commands, " ", 0, true))
{
- tgt.AddSourceFile(file);
+ tgt.AddSource(file->GetFullPath());
}
}
}
@@ -228,7 +229,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles()
//----------------------------------------------------------------------------
void cmLocalVisualStudio7Generator
-::CreateSingleVCProj(const char *lname, cmTarget &target)
+::CreateSingleVCProj(const std::string& lname, cmTarget &target)
{
this->FortranProject =
static_cast<cmGlobalVisualStudioGenerator*>(this->GlobalGenerator)
@@ -245,8 +246,7 @@ void cmLocalVisualStudio7Generator
}
// add to the list of projects
- std::string pname = lname;
- target.SetProperty("GENERATOR_FILE_NAME",lname);
+ target.SetProperty("GENERATOR_FILE_NAME",lname.c_str());
// create the dsp.cmake file
std::string fname;
fname = this->Makefile->GetStartOutputDirectory();
@@ -334,8 +334,8 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
}
void cmLocalVisualStudio7Generator::WriteConfigurations(std::ostream& fout,
- const char *libName,
- cmTarget &target)
+ const std::string& libName,
+ cmTarget &target)
{
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
@@ -589,7 +589,7 @@ class cmLocalVisualStudio7Generator::EventWriter
{
public:
EventWriter(cmLocalVisualStudio7Generator* lg,
- const char* config, std::ostream& os):
+ const std::string& config, std::ostream& os):
LG(lg), Config(config), Stream(os), First(true) {}
void Start(const char* tool)
{
@@ -610,9 +610,10 @@ public:
}
void Write(cmCustomCommand const& cc)
{
+ cmCustomCommandGenerator ccg(cc, this->Config, this->LG->GetMakefile());
if(this->First)
{
- const char* comment = cc.GetComment();
+ const char* comment = ccg.GetComment();
if(comment && *comment)
{
this->Stream << "\nDescription=\""
@@ -625,21 +626,21 @@ public:
{
this->Stream << this->LG->EscapeForXML("\n");
}
- std::string script = this->LG->ConstructScript(cc, this->Config);
+ std::string script = this->LG->ConstructScript(ccg);
this->Stream << this->LG->EscapeForXML(script.c_str());
}
private:
cmLocalVisualStudio7Generator* LG;
- const char* Config;
+ std::string Config;
std::ostream& Stream;
bool First;
};
//----------------------------------------------------------------------------
void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
- const char* configName,
- const char *libName,
- cmTarget &target)
+ const std::string& configName,
+ const std::string& libName,
+ cmTarget &target)
{
const char* mfcFlag = this->Makefile->GetDefinition("CMAKE_MFC_FLAG");
if(!mfcFlag)
@@ -660,7 +661,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
switch(target.GetType())
{
case cmTarget::OBJECT_LIBRARY:
- targetBuilds = false; // TODO: PDB for object library?
+ targetBuilds = false; // no manifest tool for object library
case cmTarget::STATIC_LIBRARY:
projectType = "typeStaticLibrary";
configType = "4";
@@ -687,17 +688,18 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
std::string flags;
if(strcmp(configType, "10") != 0)
{
- const char* linkLanguage = (this->FortranProject? "Fortran":
+ const std::string& linkLanguage = (this->FortranProject?
+ std::string("Fortran"):
target.GetLinkerLanguage(configName));
- if(!linkLanguage)
+ if(linkLanguage.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
- target.GetName());
+ target.GetName().c_str());
return;
}
- if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
- || strcmp(linkLanguage, "Fortran") == 0)
+ if(linkLanguage == "C" || linkLanguage == "CXX"
+ || linkLanguage == "Fortran")
{
std::string baseFlagVar = "CMAKE_";
baseFlagVar += linkLanguage;
@@ -709,11 +711,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
flags += this->Makefile->GetRequiredDefinition(flagVar.c_str());
}
// set the correct language
- if(strcmp(linkLanguage, "C") == 0)
+ if(linkLanguage == "C")
{
flags += " /TC ";
}
- if(strcmp(linkLanguage, "CXX") == 0)
+ if(linkLanguage == "CXX")
{
flags += " /TP ";
}
@@ -745,7 +747,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
table,
this->ExtraFlagTable);
targetOptions.FixExceptionHandlingDefault();
- std::string asmLocation = std::string(configName) + "/";
+ std::string asmLocation = configName + "/";
targetOptions.AddFlag("AssemblerListingLocation", asmLocation.c_str());
targetOptions.Parse(flags.c_str());
targetOptions.Parse(defineFlags.c_str());
@@ -846,6 +848,17 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
targetOptions.OutputFlagMap(fout, "\t\t\t\t");
targetOptions.OutputPreprocessorDefinitions(fout, "\t\t\t\t", "\n", "CXX");
fout << "\t\t\t\tObjectFile=\"$(IntDir)\\\"\n";
+ if(target.GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ // Specify the compiler program database file if configured.
+ std::string pdb = target.GetCompilePDBPath(configName);
+ if(!pdb.empty())
+ {
+ fout << "\t\t\t\tProgramDataBaseFileName=\""
+ << this->ConvertToXMLOutputPathSingle(pdb.c_str())
+ << "\"\n";
+ }
+ }
fout << "/>\n"; // end of <Tool Name=VCCLCompilerTool
tool = "VCCustomBuildTool";
if(this->FortranProject)
@@ -933,7 +946,8 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout,
//----------------------------------------------------------------------------
std::string
cmLocalVisualStudio7Generator
-::GetBuildTypeLinkerFlags(std::string rootLinkerFlags, const char* configName)
+::GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
+ const std::string& configName)
{
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
std::string extraLinkOptionsBuildTypeDef =
@@ -947,7 +961,8 @@ cmLocalVisualStudio7Generator
}
void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
- const char* configName, cmTarget &target, const Options& targetOptions)
+ const std::string& configName, cmTarget &target,
+ const Options& targetOptions)
{
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator*>(this->GlobalGenerator);
@@ -1033,7 +1048,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
- if(this->GetVersion() < VS8)
+ if(this->GetVersion() < VS8 || this->FortranProject)
{
cmOStringStream libdeps;
this->Internal->OutputObjects(libdeps, &target);
@@ -1070,7 +1085,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
return;
}
cmComputeLinkInformation& cli = *pcli;
- const char* linkLanguage = cli.GetLinkLanguage();
+ std::string linkLanguage = cli.GetLinkLanguage();
// Compute the variable name to lookup standard libraries for this
// language.
@@ -1093,7 +1108,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
- if(this->GetVersion() < VS8)
+ if(this->GetVersion() < VS8 || this->FortranProject)
{
this->Internal->OutputObjects(fout, &target, " ");
}
@@ -1166,7 +1181,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
return;
}
cmComputeLinkInformation& cli = *pcli;
- const char* linkLanguage = cli.GetLinkLanguage();
+ std::string linkLanguage = cli.GetLinkLanguage();
bool isWin32Executable = target.GetPropertyAsBool("WIN32_EXECUTABLE");
@@ -1191,7 +1206,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout,
// libraries which may be set by the user to something bad.
fout << "\t\t\t\tAdditionalDependencies=\"$(NOINHERIT) "
<< this->Makefile->GetSafeDefinition(standardLibsVar.c_str());
- if(this->GetVersion() < VS8)
+ if(this->GetVersion() < VS8 || this->FortranProject)
{
this->Internal->OutputObjects(fout, &target, " ");
}
@@ -1315,7 +1330,7 @@ cmLocalVisualStudio7GeneratorInternals
cmGeneratorTarget* gt =
lg->GetGlobalGenerator()->GetGeneratorTarget(t);
std::vector<std::string> objs;
- gt->UseObjectLibraries(objs);
+ gt->UseObjectLibraries(objs, "");
const char* sep = isep? isep : "";
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
@@ -1368,7 +1383,7 @@ cmLocalVisualStudio7Generator
}
void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
- const char *libName,
+ const std::string& libName,
cmTarget &target)
{
// get the configurations
@@ -1382,10 +1397,17 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups
this->ModuleDefinitionFile = "";
std::vector<cmSourceFile*> classes;
- target.GetSourceFiles(classes);
+ if (!target.GetConfigCommonSourceFiles(classes))
+ {
+ return;
+ }
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
i != classes.end(); i++)
{
+ if (!(*i)->GetObjectLibrary().empty())
+ {
+ continue;
+ }
// Add the file to the list of sources.
std::string source = (*i)->GetFullPath();
if(cmSystemTools::UpperCase((*i)->GetExtension()) == "DEF")
@@ -1412,14 +1434,14 @@ void cmLocalVisualStudio7Generator::WriteVCProjFile(std::ostream& fout,
this->WriteGroup(&sg, target, fout, libName, configs);
}
- if(this->GetVersion() >= VS8)
+ if(this->GetVersion() >= VS8 && !this->FortranProject)
{
// VS >= 8 support per-config source locations so we
// list object library content as external objects.
cmGeneratorTarget* gt =
this->GlobalGenerator->GetGeneratorTarget(&target);
std::vector<std::string> objs;
- gt->UseObjectLibraries(objs);
+ gt->UseObjectLibraries(objs, "");
if(!objs.empty())
{
// TODO: Separate sub-filter for each object library used?
@@ -1457,7 +1479,7 @@ public:
cmTarget& target,
cmSourceFile const& sf,
std::vector<std::string>* configs);
- std::map<cmStdString, cmLVS7GFileConfig> FileConfigMap;
+ std::map<std::string, cmLVS7GFileConfig> FileConfigMap;
};
cmLocalVisualStudio7GeneratorFCInfo
@@ -1535,14 +1557,14 @@ cmLocalVisualStudio7GeneratorFCInfo
}
}
- const char* lang =
+ std::string lang =
lg->GlobalGenerator->GetLanguageFromExtension
(sf.GetExtension().c_str());
- const char* sourceLang = lg->GetSourceFileLanguage(sf);
- const char* linkLanguage = target.GetLinkerLanguage(i->c_str());
+ const std::string& sourceLang = lg->GetSourceFileLanguage(sf);
+ const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str());
bool needForceLang = false;
// source file does not match its extension language
- if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
+ if(lang != sourceLang)
{
needForceLang = true;
lang = sourceLang;
@@ -1558,16 +1580,15 @@ cmLocalVisualStudio7GeneratorFCInfo
// if the source file does not match the linker language
// then force c or c++
- if(needForceLang || (linkLanguage && lang
- && strcmp(lang, linkLanguage) != 0))
+ if(needForceLang || (linkLanguage != lang))
{
- if(strcmp(lang, "CXX") == 0)
+ if(lang == "CXX")
{
// force a C++ file type
fc.CompileFlags += " /TP ";
needfc = true;
}
- else if(strcmp(lang, "C") == 0)
+ else if(lang == "C")
{
// force to c
fc.CompileFlags += " /TC ";
@@ -1616,7 +1637,7 @@ cmLocalVisualStudio7Generator
bool cmLocalVisualStudio7Generator
::WriteGroup(const cmSourceGroup *sg, cmTarget& target,
- std::ostream &fout, const char *libName,
+ std::ostream &fout, const std::string& libName,
std::vector<std::string> *configs)
{
const std::vector<const cmSourceFile *> &sourceFiles =
@@ -1702,7 +1723,7 @@ bool cmLocalVisualStudio7Generator
aCompilerTool = "VFCustomBuildTool";
}
}
- for(std::map<cmStdString, cmLVS7GFileConfig>::const_iterator
+ for(std::map<std::string, cmLVS7GFileConfig>::const_iterator
fci = fcinfo.FileConfigMap.begin();
fci != fcinfo.FileConfigMap.end(); ++fci)
{
@@ -1779,8 +1800,6 @@ WriteCustomRule(std::ostream& fout,
const cmCustomCommand& command,
FCInfo& fcinfo)
{
- std::string comment = this->ConstructComment(command);
-
// Write the rule for each configuration.
std::vector<std::string>::iterator i;
std::vector<std::string> *configs =
@@ -1798,6 +1817,7 @@ WriteCustomRule(std::ostream& fout,
}
for(i = configs->begin(); i != configs->end(); ++i)
{
+ cmCustomCommandGenerator ccg(command, *i, this->Makefile);
cmLVS7GFileConfig const& fc = fcinfo.FileConfigMap[*i];
fout << "\t\t\t\t<FileConfiguration\n";
fout << "\t\t\t\t\tName=\"" << *i << "|" << this->PlatformName << "\">\n";
@@ -1809,7 +1829,8 @@ WriteCustomRule(std::ostream& fout,
<< this->EscapeForXML(fc.CompileFlags.c_str()) << "\"/>\n";
}
- std::string script = this->ConstructScript(command, i->c_str());
+ std::string comment = this->ConstructComment(ccg);
+ std::string script = this->ConstructScript(ccg);
if(this->FortranProject)
{
cmSystemTools::ReplaceString(script, "$(Configuration)", i->c_str());
@@ -1821,7 +1842,7 @@ WriteCustomRule(std::ostream& fout,
<< "\t\t\t\t\tCommandLine=\""
<< this->EscapeForXML(script.c_str()) << "\"\n"
<< "\t\t\t\t\tAdditionalDependencies=\"";
- if(command.GetDepends().empty())
+ if(ccg.GetDepends().empty())
{
// There are no real dependencies. Produce an artificial one to
// make sure the rule runs reliably.
@@ -1836,8 +1857,8 @@ WriteCustomRule(std::ostream& fout,
{
// Write out the dependencies for the rule.
for(std::vector<std::string>::const_iterator d =
- command.GetDepends().begin();
- d != command.GetDepends().end();
+ ccg.GetDepends().begin();
+ d != ccg.GetDepends().end();
++d)
{
// Get the real name of the dependency in case it is a CMake target.
@@ -1851,7 +1872,7 @@ WriteCustomRule(std::ostream& fout,
}
fout << "\"\n";
fout << "\t\t\t\t\tOutputs=\"";
- if(command.GetOutputs().empty())
+ if(ccg.GetOutputs().empty())
{
fout << source << "_force";
}
@@ -1860,8 +1881,8 @@ WriteCustomRule(std::ostream& fout,
// Write a rule for the output generated by this command.
const char* sep = "";
for(std::vector<std::string>::const_iterator o =
- command.GetOutputs().begin();
- o != command.GetOutputs().end();
+ ccg.GetOutputs().begin();
+ o != ccg.GetOutputs().end();
++o)
{
fout << sep << this->ConvertToXMLOutputPathSingle(o->c_str());
@@ -1893,9 +1914,9 @@ void cmLocalVisualStudio7Generator::WriteVCProjEndGroup(std::ostream& fout)
// look for custom rules on a target and collect them together
void cmLocalVisualStudio7Generator
::OutputTargetRules(std::ostream& fout,
- const char* configName,
+ const std::string& configName,
cmTarget &target,
- const char * /*libName*/)
+ const std::string& /*libName*/)
{
if (target.GetType() > cmTarget::GLOBAL_TARGET)
{
@@ -1955,13 +1976,14 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
void
cmLocalVisualStudio7Generator
::WriteProjectStartFortran(std::ostream& fout,
- const char *libName,
+ const std::string& libName,
cmTarget & target)
{
cmGlobalVisualStudio7Generator* gg =
static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
- fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
+ fout << "<?xml version=\"1.0\" encoding = \""
+ << gg->Encoding() << "\"?>\n"
<< "<VisualStudioProject\n"
<< "\tProjectCreator=\"Intel Fortran\"\n"
<< "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n";
@@ -2006,7 +2028,7 @@ cmLocalVisualStudio7Generator
}
this->WriteProjectSCC(fout, target);
fout<< "\tKeyword=\"" << keyword << "\">\n"
- << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\">\n"
+ << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\">\n"
<< "\t<Platforms>\n"
<< "\t\t<Platform\n\t\t\tName=\"" << this->PlatformName << "\"/>\n"
<< "\t</Platforms>\n";
@@ -2015,7 +2037,7 @@ cmLocalVisualStudio7Generator
void
cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
- const char *libName,
+ const std::string& libName,
cmTarget & target,
std::vector<cmSourceGroup> &)
{
@@ -2024,7 +2046,12 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
this->WriteProjectStartFortran(fout, libName, target);
return;
}
- fout << "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>\n"
+
+ cmGlobalVisualStudio7Generator* gg =
+ static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
+
+ fout << "<?xml version=\"1.0\" encoding = \""
+ << gg->Encoding() << "\"?>\n"
<< "<VisualStudioProject\n"
<< "\tProjectType=\"Visual C++\"\n";
if(this->Version == VS71)
@@ -2038,19 +2065,17 @@ cmLocalVisualStudio7Generator::WriteProjectStart(std::ostream& fout,
const char* projLabel = target.GetProperty("PROJECT_LABEL");
if(!projLabel)
{
- projLabel = libName;
+ projLabel = libName.c_str();
}
const char* keyword = target.GetProperty("VS_KEYWORD");
if(!keyword)
{
keyword = "Win32Proj";
}
- cmGlobalVisualStudio7Generator* gg =
- static_cast<cmGlobalVisualStudio7Generator *>(this->GlobalGenerator);
fout << "\tName=\"" << projLabel << "\"\n";
if(this->Version >= VS8)
{
- fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
+ fout << "\tProjectGUID=\"{" << gg->GetGUID(libName.c_str()) << "}\"\n";
}
this->WriteProjectSCC(fout, target);
if(const char* targetFrameworkVersion =
@@ -2090,7 +2115,7 @@ void cmLocalVisualStudio7Generator::WriteVCProjFooter(std::ostream& fout,
<< "</VisualStudioProject>\n";
}
-std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s)
+std::string cmLocalVisualStudio7GeneratorEscapeForXML(const std::string& s)
{
std::string ret = s;
cmSystemTools::ReplaceString(ret, "&", "&amp;");
@@ -2101,7 +2126,7 @@ std::string cmLocalVisualStudio7GeneratorEscapeForXML(const char* s)
return ret;
}
-std::string cmLocalVisualStudio7Generator::EscapeForXML(const char* s)
+std::string cmLocalVisualStudio7Generator::EscapeForXML(const std::string& s)
{
return cmLocalVisualStudio7GeneratorEscapeForXML(s);
}
@@ -2134,10 +2159,10 @@ std::string cmLocalVisualStudio7Generator
class cmVS7XMLParser : public cmXMLParser
{
public:
- virtual void EndElement(const char* /* name */)
+ virtual void EndElement(const std::string& /* name */)
{
}
- virtual void StartElement(const char* name, const char** atts)
+ virtual void StartElement(const std::string& name, const char** atts)
{
// once the GUID is found do nothing
if(this->GUID.size())
@@ -2145,7 +2170,7 @@ public:
return;
}
int i =0;
- if(strcmp("VisualStudioProject", name) == 0)
+ if("VisualStudioProject" == name)
{
while(atts[i])
{
@@ -2182,7 +2207,7 @@ public:
};
void cmLocalVisualStudio7Generator::ReadAndStoreExternalGUID(
- const char* name,
+ const std::string& name,
const char* path)
{
cmVS7XMLParser parser;
diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h
index 92e4d3c..6c04559 100644
--- a/Source/cmLocalVisualStudio7Generator.h
+++ b/Source/cmLocalVisualStudio7Generator.h
@@ -51,9 +51,9 @@ public:
/**
* Specify the type of the build: static, dll, or executable.
*/
- void SetBuildType(BuildType,const char *name);
+ void SetBuildType(BuildType,const std::string& name);
- void SetPlatformName(const char* n) { this->PlatformName = n;}
+ void SetPlatformName(const std::string& n) { this->PlatformName = n;}
void SetExtraFlagTable(cmVS7FlagTable const* table)
{ this->ExtraFlagTable = table; }
@@ -62,41 +62,41 @@ public:
void WriteStampFiles();
virtual std::string ComputeLongestObjectDirectory(cmTarget&) const;
- virtual void ReadAndStoreExternalGUID(const char* name,
+ virtual void ReadAndStoreExternalGUID(const std::string& name,
const char* path);
virtual void AddCMakeListsRules();
protected:
- void CreateSingleVCProj(const char *lname, cmTarget &tgt);
+ void CreateSingleVCProj(const std::string& lname, cmTarget &tgt);
private:
typedef cmVisualStudioGeneratorOptions Options;
typedef cmLocalVisualStudio7GeneratorFCInfo FCInfo;
std::string GetBuildTypeLinkerFlags(std::string rootLinkerFlags,
- const char* configName);
+ const std::string& configName);
void FixGlobalTargets();
void WriteProjectFiles();
- void WriteVCProjHeader(std::ostream& fout, const char *libName,
+ void WriteVCProjHeader(std::ostream& fout, const std::string& libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
void WriteVCProjFooter(std::ostream& fout, cmTarget &target);
- void WriteVCProjFile(std::ostream& fout, const char *libName,
+ void WriteVCProjFile(std::ostream& fout, const std::string& libName,
cmTarget &tgt);
void WriteConfigurations(std::ostream& fout,
- const char *libName, cmTarget &tgt);
+ const std::string& libName, cmTarget &tgt);
void WriteConfiguration(std::ostream& fout,
- const char* configName,
- const char* libName, cmTarget &tgt);
- std::string EscapeForXML(const char* s);
+ const std::string& configName,
+ const std::string& libName, cmTarget &tgt);
+ std::string EscapeForXML(const std::string& s);
std::string ConvertToXMLOutputPath(const char* path);
std::string ConvertToXMLOutputPathSingle(const char* path);
- void OutputTargetRules(std::ostream& fout, const char* configName,
- cmTarget &target, const char *libName);
- void OutputBuildTool(std::ostream& fout, const char* configName,
+ void OutputTargetRules(std::ostream& fout, const std::string& configName,
+ cmTarget &target, const std::string& libName);
+ void OutputBuildTool(std::ostream& fout, const std::string& configName,
cmTarget& t, const Options& targetOptions);
void OutputLibraryDirectories(std::ostream& fout,
std::vector<std::string> const& dirs);
void WriteProjectSCC(std::ostream& fout, cmTarget& target);
- void WriteProjectStart(std::ostream& fout, const char *libName,
+ void WriteProjectStart(std::ostream& fout, const std::string& libName,
cmTarget &tgt, std::vector<cmSourceGroup> &sgs);
- void WriteProjectStartFortran(std::ostream& fout, const char *libName,
+ void WriteProjectStartFortran(std::ostream& fout, const std::string& libName,
cmTarget &tgt);
void WriteVCProjBeginGroup(std::ostream& fout,
const char* group,
@@ -111,7 +111,8 @@ private:
bool WriteGroup(const cmSourceGroup *sg,
cmTarget& target, std::ostream &fout,
- const char *libName, std::vector<std::string> *configs);
+ const std::string& libName,
+ std::vector<std::string> *configs);
friend class cmLocalVisualStudio7GeneratorFCInfo;
friend class cmLocalVisualStudio7GeneratorInternals;
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index ef2bb1d..9680d43 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -31,9 +31,49 @@ cmLocalVisualStudioGenerator::~cmLocalVisualStudioGenerator()
}
//----------------------------------------------------------------------------
+void cmLocalVisualStudioGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt)
+{
+ std::string dir_max = this->ComputeLongestObjectDirectory(*gt->Target);
+
+ // Count the number of object files with each name. Note that
+ // windows file names are not case sensitive.
+ std::map<std::string, int> counts;
+
+ for(std::map<cmSourceFile const*, std::string>::iterator
+ si = mapping.begin(); si != mapping.end(); ++si)
+ {
+ cmSourceFile const* sf = si->first;
+ std::string objectNameLower = cmSystemTools::LowerCase(
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath()));
+ objectNameLower += ".obj";
+ counts[objectNameLower] += 1;
+ }
+
+ // For all source files producing duplicate names we need unique
+ // object name computation.
+
+ for(std::map<cmSourceFile const*, std::string>::iterator
+ si = mapping.begin(); si != mapping.end(); ++si)
+ {
+ cmSourceFile const* sf = si->first;
+ std::string objectName =
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
+ objectName += ".obj";
+ if(counts[cmSystemTools::LowerCase(objectName)] > 1)
+ {
+ const_cast<cmGeneratorTarget*>(gt)->AddExplicitObjectName(sf);
+ objectName = this->GetObjectFileNameWithoutTarget(*sf, dir_max);
+ }
+ si->second = objectName;
+ }
+}
+
+//----------------------------------------------------------------------------
cmsys::auto_ptr<cmCustomCommand>
cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmTarget& target,
- const char* config,
+ const std::string& config,
bool isFortran)
{
cmsys::auto_ptr<cmCustomCommand> pcc;
@@ -79,17 +119,15 @@ const char* cmLocalVisualStudioGenerator::GetReportErrorLabel() const
//----------------------------------------------------------------------------
std::string
cmLocalVisualStudioGenerator
-::ConstructScript(cmCustomCommand const& cc,
- const char* configName,
- const char* newline_text)
+::ConstructScript(cmCustomCommandGenerator const& ccg,
+ const std::string& newline_text)
{
bool useLocal = this->CustomCommandUseLocal();
- const char* workingDirectory = cc.GetWorkingDirectory();
- cmCustomCommandGenerator ccg(cc, configName, this->Makefile);
- RelativeRoot relativeRoot = workingDirectory? NONE : START_OUTPUT;
+ std::string workingDirectory = ccg.GetWorkingDirectory();
+ RelativeRoot relativeRoot = workingDirectory.empty()? START_OUTPUT : NONE;
// Avoid leading or trailing newlines.
- const char* newline = "";
+ std::string newline = "";
// Line to check for error between commands.
std::string check_error = newline_text;
@@ -114,7 +152,7 @@ cmLocalVisualStudioGenerator
script += "setlocal";
}
- if(workingDirectory)
+ if(!workingDirectory.empty())
{
// Change the working directory.
script += newline;
@@ -124,7 +162,7 @@ cmLocalVisualStudioGenerator
script += check_error;
// Change the working drive.
- if(workingDirectory[0] && workingDirectory[1] == ':')
+ if(workingDirectory.size() > 1 && workingDirectory[1] == ':')
{
script += newline;
newline = newline_text;
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 1a3499a..3bf4f43 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -19,6 +19,7 @@
class cmSourceFile;
class cmSourceGroup;
class cmCustomCommand;
+class cmCustomCommandGenerator;
/** \class cmLocalVisualStudioGenerator
* \brief Base class for Visual Studio generators.
@@ -46,9 +47,8 @@ public:
virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */
- std::string ConstructScript(cmCustomCommand const& cc,
- const char* configName,
- const char* newline = "\n");
+ std::string ConstructScript(cmCustomCommandGenerator const& ccg,
+ const std::string& newline = "\n");
/** Label to which to jump in a batch file after a failed step in a
sequence of custom commands. */
@@ -61,13 +61,18 @@ public:
virtual void AddCMakeListsRules() = 0;
+ virtual void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* = 0);
+
protected:
virtual const char* ReportErrorLabel() const;
virtual bool CustomCommandUseLocal() const { return false; }
/** Construct a custom command to make exe import lib dir. */
cmsys::auto_ptr<cmCustomCommand>
- MaybeCreateImplibDir(cmTarget& target, const char* config, bool isFortran);
+ MaybeCreateImplibDir(cmTarget& target, const std::string& config,
+ bool isFortran);
VSVersion Version;
};
diff --git a/Source/cmLocalXCodeGenerator.cxx b/Source/cmLocalXCodeGenerator.cxx
index a9a27b9..8ff6c87 100644
--- a/Source/cmLocalXCodeGenerator.cxx
+++ b/Source/cmLocalXCodeGenerator.cxx
@@ -37,7 +37,7 @@ cmLocalXCodeGenerator::GetTargetDirectory(cmTarget const&) const
//----------------------------------------------------------------------------
void cmLocalXCodeGenerator::AppendFlagEscape(std::string& flags,
- const char* rawFlag)
+ const std::string& rawFlag)
{
cmGlobalXCodeGenerator* gg =
static_cast<cmGlobalXCodeGenerator*>(this->GlobalGenerator);
@@ -54,7 +54,7 @@ void cmLocalXCodeGenerator::Generate()
iter != targets.end(); ++iter)
{
cmTarget* t = &iter->second;
- t->HasMacOSXRpathInstallNameDir(NULL);
+ t->HasMacOSXRpathInstallNameDir("");
}
}
@@ -68,6 +68,34 @@ void cmLocalXCodeGenerator::GenerateInstallRules()
iter != targets.end(); ++iter)
{
cmTarget* t = &iter->second;
- t->HasMacOSXRpathInstallNameDir(NULL);
+ t->HasMacOSXRpathInstallNameDir("");
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmLocalXCodeGenerator::ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const*)
+{
+ // Count the number of object files with each name. Warn about duplicate
+ // names since Xcode names them uniquely automatically with a numeric suffix
+ // to avoid exact duplicate file names. Note that Mac file names are not
+ // typically case sensitive, hence the LowerCase.
+ std::map<std::string, int> counts;
+ for(std::map<cmSourceFile const*, std::string>::iterator
+ si = mapping.begin(); si != mapping.end(); ++si)
+ {
+ cmSourceFile const* sf = si->first;
+ std::string objectName =
+ cmSystemTools::GetFilenameWithoutLastExtension(sf->GetFullPath());
+ objectName += ".o";
+
+ std::string objectNameLower = cmSystemTools::LowerCase(objectName);
+ counts[objectNameLower] += 1;
+ if (2 == counts[objectNameLower])
+ {
+ // TODO: emit warning about duplicate name?
+ }
+ si->second = objectName;
}
}
diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h
index edd2f5b..f553a17 100644
--- a/Source/cmLocalXCodeGenerator.h
+++ b/Source/cmLocalXCodeGenerator.h
@@ -28,9 +28,13 @@ public:
virtual ~cmLocalXCodeGenerator();
virtual std::string GetTargetDirectory(cmTarget const& target) const;
- virtual void AppendFlagEscape(std::string& flags, const char* rawFlag);
+ virtual void AppendFlagEscape(std::string& flags,
+ const std::string& rawFlag);
virtual void Generate();
virtual void GenerateInstallRules();
+ virtual void ComputeObjectFilenames(
+ std::map<cmSourceFile const*, std::string>& mapping,
+ cmGeneratorTarget const* gt = 0);
private:
};
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 499d3c6..ae81c58 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -20,7 +20,7 @@ public:
cmMacroHelperCommand() {}
///! clean up any memory allocated by the macro
- ~cmMacroHelperCommand() {};
+ ~cmMacroHelperCommand() {}
/**
* This is used to avoid including this command
@@ -60,12 +60,12 @@ public:
cmExecutionStatus &);
virtual bool InitialPass(std::vector<std::string> const&,
- cmExecutionStatus &) { return false; };
+ cmExecutionStatus &) { return false; }
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return this->Args[0].c_str(); }
+ virtual std::string GetName() const { return this->Args[0]; }
cmTypeMacro(cmMacroHelperCommand, cmCommand);
@@ -95,7 +95,7 @@ bool cmMacroHelperCommand::InvokeInitialPass
std::string errorMsg =
"Macro invoked with incorrect arguments for macro named: ";
errorMsg += this->Args[0];
- this->SetError(errorMsg.c_str());
+ this->SetError(errorMsg);
return false;
}
@@ -276,8 +276,8 @@ IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile &mf,
f->Functions = this->Functions;
mf.RecordPolicies(f->Policies);
std::string newName = "_" + this->Args[0];
- mf.GetCMakeInstance()->RenameCommand(this->Args[0].c_str(),
- newName.c_str());
+ mf.GetCMakeInstance()->RenameCommand(this->Args[0],
+ newName);
mf.AddCommand(f);
// remove the function blocker now that the macro is defined
diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h
index 4c585d8..5c1cc00 100644
--- a/Source/cmMacroCommand.h
+++ b/Source/cmMacroCommand.h
@@ -57,7 +57,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "macro";}
+ virtual std::string GetName() const { return "macro";}
cmTypeMacro(cmMacroCommand, cmCommand);
};
diff --git a/Source/cmMakeDepend.cxx b/Source/cmMakeDepend.cxx
index 615e6f2..52832db 100644
--- a/Source/cmMakeDepend.cxx
+++ b/Source/cmMakeDepend.cxx
@@ -74,7 +74,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
cmGeneratorExpression::StripAllGeneratorExpressions);
std::vector<std::string> includes;
- cmSystemTools::ExpandListArgument(incDirs.c_str(), includes);
+ cmSystemTools::ExpandListArgument(incDirs, includes);
for(std::vector<std::string>::const_iterator j = includes.begin();
j != includes.end(); ++j)
@@ -93,7 +93,7 @@ void cmMakeDepend::SetMakefile(cmMakefile* makefile)
it != orderedAndUniqueIncludes.end();
++it)
{
- this->AddSearchPath(it->c_str());
+ this->AddSearchPath(*it);
}
}
@@ -165,7 +165,7 @@ void cmMakeDepend::GenerateDependInformation(cmDependInformation* info)
{
// Try to find the file amongst the sources
cmSourceFile *srcFile = this->Makefile->GetSource
- (cmSystemTools::GetFilenameWithoutExtension(path).c_str());
+ (cmSystemTools::GetFilenameWithoutExtension(path));
if (srcFile)
{
if (srcFile->GetFullPath() == path)
@@ -281,7 +281,7 @@ cmDependInformation* cmMakeDepend::GetDependInformation(const char* file,
// Didn't find an instance. Create a new one and save it.
cmDependInformation* info = new cmDependInformation;
info->FullPath = fullPath;
- info->PathOnly = cmSystemTools::GetFilenamePath(fullPath.c_str());
+ info->PathOnly = cmSystemTools::GetFilenamePath(fullPath);
info->IncludeName = file;
this->DependInformationMap[fullPath] = info;
return info;
@@ -359,7 +359,7 @@ std::string cmMakeDepend::FullPath(const char* fname, const char *extraPath)
}
// Add a directory to the search path
-void cmMakeDepend::AddSearchPath(const char* path)
+void cmMakeDepend::AddSearchPath(const std::string& path)
{
this->IncludeDirectories.push_back(path);
}
diff --git a/Source/cmMakeDepend.h b/Source/cmMakeDepend.h
index b6e3928..2c9d515 100644
--- a/Source/cmMakeDepend.h
+++ b/Source/cmMakeDepend.h
@@ -94,7 +94,7 @@ public:
/**
* Add a directory to the search path for include files.
*/
- virtual void AddSearchPath(const char*);
+ virtual void AddSearchPath(const std::string&);
/**
* Generate dependencies for the file given. Returns a pointer to
@@ -138,10 +138,10 @@ protected:
cmsys::RegularExpression IncludeFileRegularExpression;
cmsys::RegularExpression ComplainFileRegularExpression;
std::vector<std::string> IncludeDirectories;
- typedef std::map<cmStdString, cmStdString> FileToPathMapType;
- typedef std::map<cmStdString, FileToPathMapType>
+ typedef std::map<std::string, std::string> FileToPathMapType;
+ typedef std::map<std::string, FileToPathMapType>
DirectoryToFileToPathMapType;
- typedef std::map<cmStdString, cmDependInformation*>
+ typedef std::map<std::string, cmDependInformation*>
DependInformationMapType;
DependInformationMapType DependInformationMap;
DirectoryToFileToPathMapType DirectoryToFileToPathMap;
diff --git a/Source/cmMakeDirectoryCommand.cxx b/Source/cmMakeDirectoryCommand.cxx
index 63be627..cc871c9 100644
--- a/Source/cmMakeDirectoryCommand.cxx
+++ b/Source/cmMakeDirectoryCommand.cxx
@@ -24,7 +24,7 @@ bool cmMakeDirectoryCommand
{
std::string e = "attempted to create a directory: " + args[0]
+ " into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
diff --git a/Source/cmMakeDirectoryCommand.h b/Source/cmMakeDirectoryCommand.h
index 49a4009..71b97eb 100644
--- a/Source/cmMakeDirectoryCommand.h
+++ b/Source/cmMakeDirectoryCommand.h
@@ -44,7 +44,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "make_directory";}
+ virtual std::string GetName() const { return "make_directory";}
/**
* This determines if the command is invoked when in script mode.
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 27ce999..07cfe12 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -41,12 +41,59 @@
#include <ctype.h> // for isspace
#include <assert.h>
+#define FOR_EACH_CXX_FEATURE(F) \
+ F(cxx_alias_templates) \
+ F(cxx_alignas) \
+ F(cxx_alignof) \
+ F(cxx_attributes) \
+ F(cxx_auto_type) \
+ F(cxx_constexpr) \
+ F(cxx_decltype) \
+ F(cxx_decltype_incomplete_return_types) \
+ F(cxx_default_function_template_args) \
+ F(cxx_defaulted_functions) \
+ F(cxx_defaulted_move_initializers) \
+ F(cxx_delegating_constructors) \
+ F(cxx_deleted_functions) \
+ F(cxx_enum_forward_declarations) \
+ F(cxx_explicit_conversions) \
+ F(cxx_extended_friend_declarations) \
+ F(cxx_extern_templates) \
+ F(cxx_final) \
+ F(cxx_func_identifier) \
+ F(cxx_generalized_initializers) \
+ F(cxx_inheriting_constructors) \
+ F(cxx_inline_namespaces) \
+ F(cxx_lambdas) \
+ F(cxx_local_type_template_args) \
+ F(cxx_long_long_type) \
+ F(cxx_noexcept) \
+ F(cxx_nonstatic_member_init) \
+ F(cxx_nullptr) \
+ F(cxx_override) \
+ F(cxx_range_for) \
+ F(cxx_raw_string_literals) \
+ F(cxx_reference_qualified_functions) \
+ F(cxx_right_angle_brackets) \
+ F(cxx_rvalue_references) \
+ F(cxx_sizeof_member) \
+ F(cxx_static_assert) \
+ F(cxx_strong_enums) \
+ F(cxx_thread_local) \
+ F(cxx_trailing_return_types) \
+ F(cxx_unicode_literals) \
+ F(cxx_uniform_initialization) \
+ F(cxx_unrestricted_unions) \
+ F(cxx_user_literals) \
+ F(cxx_variadic_macros) \
+ F(cxx_variadic_templates)
+
class cmMakefile::Internals
{
public:
std::stack<cmDefinitions, std::list<cmDefinitions> > VarStack;
- std::stack<std::set<cmStdString> > VarInitStack;
- std::stack<std::set<cmStdString> > VarUsageStack;
+ std::stack<std::set<std::string> > VarInitStack;
+ std::stack<std::set<std::string> > VarUsageStack;
bool IsSourceFileTryCompile;
};
@@ -54,7 +101,7 @@ public:
cmMakefile::cmMakefile(): Internal(new Internals)
{
const cmDefinitions& defs = cmDefinitions();
- const std::set<cmStdString> globalKeys = defs.LocalKeys();
+ const std::set<std::string> globalKeys = defs.LocalKeys();
this->Internal->VarStack.push(defs);
this->Internal->VarInitStack.push(globalKeys);
this->Internal->VarUsageStack.push(globalKeys);
@@ -203,7 +250,7 @@ cmMakefile::~cmMakefile()
{
delete *i;
}
- for(std::map<cmStdString, cmTest*>::iterator i = this->Tests.begin();
+ for(std::map<std::string, cmTest*>::iterator i = this->Tests.begin();
i != this->Tests.end(); ++i)
{
delete i->second;
@@ -240,20 +287,20 @@ void cmMakefile::PrintStringVector(const char* s,
for(std::vector<std::string>::const_iterator i = v.begin();
i != v.end(); ++i)
{
- std::cout << (*i).c_str() << " ";
+ std::cout << *i << " ";
}
std::cout << " )\n";
}
void cmMakefile
::PrintStringVector(const char* s,
- const std::vector<std::pair<cmStdString, bool> >& v) const
+ const std::vector<std::pair<std::string, bool> >& v) const
{
std::cout << s << ": ( \n";
- for(std::vector<std::pair<cmStdString, bool> >::const_iterator i
+ for(std::vector<std::pair<std::string, bool> >::const_iterator i
= v.begin(); i != v.end(); ++i)
{
- std::cout << i->first.c_str() << " " << i->second;
+ std::cout << i->first << " " << i->second;
}
std::cout << " )\n";
}
@@ -273,15 +320,15 @@ void cmMakefile::Print() const
}
std::cout << " this->StartOutputDirectory; " <<
- this->StartOutputDirectory.c_str() << std::endl;
+ this->StartOutputDirectory << std::endl;
std::cout << " this->HomeOutputDirectory; " <<
- this->HomeOutputDirectory.c_str() << std::endl;
+ this->HomeOutputDirectory << std::endl;
std::cout << " this->cmStartDirectory; " <<
- this->cmStartDirectory.c_str() << std::endl;
+ this->cmStartDirectory << std::endl;
std::cout << " this->cmHomeDirectory; " <<
- this->cmHomeDirectory.c_str() << std::endl;
+ this->cmHomeDirectory << std::endl;
std::cout << " this->ProjectName; "
- << this->ProjectName.c_str() << std::endl;
+ << this->ProjectName << std::endl;
this->PrintStringVector("this->LinkDirectories", this->LinkDirectories);
#if defined(CMAKE_BUILD_WITH_CMAKE)
for( std::vector<cmSourceGroup>::const_iterator i =
@@ -330,7 +377,7 @@ void cmMakefile::IssueMessage(cmake::MessageType t,
lfc.Line = 0;
if(!this->GetCMakeInstance()->GetIsInTryCompile())
{
- lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(),
+ lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
cmLocalGenerator::HOME);
}
backtrace.push_back(lfc);
@@ -351,7 +398,7 @@ bool cmMakefile::GetBacktrace(cmListFileBacktrace& backtrace) const
i != this->CallStack.rend(); ++i)
{
cmListFileContext lfc = *(*i).Context;
- lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath.c_str(),
+ lfc.FilePath = this->LocalGenerator->Convert(lfc.FilePath,
cmLocalGenerator::HOME);
backtrace.push_back(lfc);
}
@@ -394,7 +441,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff,
static_cast<void>(stack_manager);
// Lookup the command prototype.
- if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name.c_str()))
+ if(cmCommand* proto = this->GetCMakeInstance()->GetCommand(name))
{
// Clone the prototype.
cmsys::auto_ptr<cmCommand> pcmd(proto->Clone());
@@ -756,7 +803,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const
case cmPolicies::WARN:
// Warn because the user did not provide a mimimum required
// version.
- this->IssueMessage(cmake::AUTHOR_WARNING, msg.str().c_str());
+ this->IssueMessage(cmake::AUTHOR_WARNING, msg.str());
case cmPolicies::OLD:
// OLD behavior is to use policy version 2.4 set in
// cmListFileCache.
@@ -765,7 +812,7 @@ void cmMakefile::EnforceDirectoryLevelRules() const
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
// NEW behavior is to issue an error.
- this->IssueMessage(cmake::FATAL_ERROR, msg.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, msg.str());
cmSystemTools::SetFatalErrorOccured();
return;
}
@@ -878,7 +925,7 @@ void cmMakefile::ConfigureFinalPass()
//----------------------------------------------------------------------------
void
-cmMakefile::AddCustomCommandToTarget(const char* target,
+cmMakefile::AddCustomCommandToTarget(const std::string& target,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type,
@@ -912,7 +959,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
if(issueMessage)
{
e << "The target name \"" << target << "\" is unknown in this context.";
- IssueMessage(messageType, e.str().c_str());
+ IssueMessage(messageType, e.str());
}
return;
@@ -958,7 +1005,7 @@ cmMakefile::AddCustomCommandToTarget(const char* target,
cmSourceFile*
cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
- const char* main_dependency,
+ const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment,
const char* workingDir,
@@ -988,7 +1035,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
// Choose a source file on which to store the custom command.
cmSourceFile* file = 0;
- if(main_dependency && main_dependency[0])
+ if(!main_dependency.empty())
{
// The main dependency was specified. Use it unless a different
// custom command already used it.
@@ -1026,7 +1073,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
std::string outName = gg->GenerateRuleFile(outputs[0]);
// Check if the rule file already exists.
- file = this->GetSource(outName.c_str());
+ file = this->GetSource(outName);
if(file && file->GetCustomCommand() && !replace)
{
// The rule file already exists.
@@ -1040,7 +1087,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
}
// Create a cmSourceFile for the rule file.
- file = this->GetOrCreateSource(outName.c_str(), true);
+ file = this->GetOrCreateSource(outName, true);
file->SetProperty("__CMAKE_RULE", "1");
}
@@ -1048,7 +1095,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o)
{
- if(cmSourceFile* out = this->GetOrCreateSource(o->c_str(), true))
+ if(cmSourceFile* out = this->GetOrCreateSource(*o, true))
{
out->SetProperty("GENERATED", "1");
}
@@ -1056,7 +1103,7 @@ cmMakefile::AddCustomCommandToOutput(const std::vector<std::string>& outputs,
// Construct a complete list of dependencies.
std::vector<std::string> depends2(depends);
- if(main_dependency && main_dependency[0])
+ if(!main_dependency.empty())
{
depends2.push_back(main_dependency);
}
@@ -1110,9 +1157,9 @@ cmMakefile::UpdateOutputToSourceMap(std::string const& output,
//----------------------------------------------------------------------------
cmSourceFile*
-cmMakefile::AddCustomCommandToOutput(const char* output,
+cmMakefile::AddCustomCommandToOutput(const std::string& output,
const std::vector<std::string>& depends,
- const char* main_dependency,
+ const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment,
const char* workingDir,
@@ -1128,16 +1175,16 @@ cmMakefile::AddCustomCommandToOutput(const char* output,
//----------------------------------------------------------------------------
void
-cmMakefile::AddCustomCommandOldStyle(const char* target,
+cmMakefile::AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
- const char* source,
+ const std::string& source,
const cmCustomCommandLines& commandLines,
const char* comment)
{
// Translate the old-style signature to one of the new-style
// signatures.
- if(strcmp(source, target) == 0)
+ if(source == 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
@@ -1168,7 +1215,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
else
{
// The source may not be a real file. Do not use a main dependency.
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
std::vector<std::string> depends2 = depends;
depends2.push_back(source);
sf = this->AddCustomCommandToOutput(output, depends2, no_main_dependency,
@@ -1182,12 +1229,13 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
{
if (this->Targets.find(target) != this->Targets.end())
{
- this->Targets[target].AddSourceFile(sf);
+ this->Targets[target].AddSource(sf->GetFullPath());
}
else
{
cmSystemTools::Error("Attempt to add a custom rule to a target "
- "that does not exist yet for target ", target);
+ "that does not exist yet for target ",
+ target.c_str());
return;
}
}
@@ -1195,7 +1243,7 @@ cmMakefile::AddCustomCommandOldStyle(const char* target,
}
//----------------------------------------------------------------------------
-void cmMakefile::AddUtilityCommand(const char* utilityName,
+void cmMakefile::AddUtilityCommand(const std::string& utilityName,
bool excludeFromAll,
const std::vector<std::string>& depends,
const char* workingDirectory,
@@ -1234,7 +1282,7 @@ void cmMakefile::AddUtilityCommand(const char* utilityName,
//----------------------------------------------------------------------------
cmTarget*
-cmMakefile::AddUtilityCommand(const char* utilityName,
+cmMakefile::AddUtilityCommand(const std::string& utilityName,
bool excludeFromAll,
const char* workingDirectory,
const std::vector<std::string>& depends,
@@ -1258,14 +1306,14 @@ cmMakefile::AddUtilityCommand(const char* utilityName,
force += cmake::GetCMakeFilesDirectory();
force += "/";
force += utilityName;
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
bool no_replace = false;
- this->AddCustomCommandToOutput(force.c_str(), depends,
+ this->AddCustomCommandToOutput(force, depends,
no_main_dependency,
commandLines, comment,
workingDirectory, no_replace,
escapeOldStyle);
- cmSourceFile* sf = target->AddSource(force.c_str());
+ cmSourceFile* sf = target->AddSourceCMP0049(force);
// The output is not actually created so mark it symbolic.
if(sf)
@@ -1385,8 +1433,8 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
// VS6 IDE does not support definition values with spaces in
// combination with '"', '$', or ';'.
- if((strcmp(this->LocalGenerator->GetGlobalGenerator()->GetName(),
- "Visual Studio 6") == 0) &&
+ if((this->LocalGenerator->GetGlobalGenerator()->GetName() ==
+ "Visual Studio 6") &&
(def.find(" ") != def.npos && def.find_first_of("\"$;") != def.npos))
{
return false;
@@ -1461,7 +1509,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove)
return true;
}
-void cmMakefile::AddLinkLibrary(const char* lib,
+void cmMakefile::AddLinkLibrary(const std::string& lib,
cmTarget::LinkLibraryType llt)
{
cmTarget::LibraryID tmp;
@@ -1470,15 +1518,15 @@ void cmMakefile::AddLinkLibrary(const char* lib,
this->LinkLibraries.push_back(tmp);
}
-void cmMakefile::AddLinkLibraryForTarget(const char *target,
- const char* lib,
+void cmMakefile::AddLinkLibraryForTarget(const std::string& target,
+ const std::string& lib,
cmTarget::LinkLibraryType llt)
{
cmTargets::iterator i = this->Targets.find(target);
if ( i != this->Targets.end())
{
cmTarget* tgt =
- this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(0,lib);
+ this->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(lib);
if(tgt)
{
// if it is not a static or shared library then you can not link to it
@@ -1493,7 +1541,7 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
<< " may not be linked into another target. "
<< "One may link only to STATIC or SHARED libraries, or "
<< "to executables with the ENABLE_EXPORTS property set.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
}
i->second.AddLinkLibrary( *this, target, lib, llt );
@@ -1504,12 +1552,12 @@ void cmMakefile::AddLinkLibraryForTarget(const char *target,
e << "Attempt to add link library \""
<< lib << "\" to target \""
<< target << "\" which is not built in this directory.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
}
}
-void cmMakefile::AddLinkDirectoryForTarget(const char *target,
- const char* d)
+void cmMakefile::AddLinkDirectoryForTarget(const std::string& target,
+ const std::string& d)
{
cmTargets::iterator i = this->Targets.find(target);
if ( i != this->Targets.end())
@@ -1519,7 +1567,7 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
cmOStringStream e;
e << "ALIAS target \"" << target << "\" "
<< "may not be linked into another target.";
- this->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
i->second.AddLinkDirectory( d );
@@ -1528,46 +1576,37 @@ void cmMakefile::AddLinkDirectoryForTarget(const char *target,
{
cmSystemTools::Error
("Attempt to add link directories to non-existent target: ",
- target, " for directory ", d);
+ target.c_str(), " for directory ", d.c_str());
}
}
-void cmMakefile::AddLinkLibrary(const char* lib)
+void cmMakefile::AddLinkLibrary(const std::string& lib)
{
this->AddLinkLibrary(lib,cmTarget::GENERAL);
}
-void cmMakefile::AddLinkDirectory(const char* dir)
+void cmMakefile::AddLinkDirectory(const std::string& dir)
{
// Don't add a link directory that is already present. Yes, this
// linear search results in n^2 behavior, but n won't be getting
// much bigger than 20. We cannot use a set because of order
// dependency of the link search path.
- if(!dir)
+ if(dir.empty())
{
return;
}
+ std::string newdir = dir;
// remove trailing slashes
- if(dir[strlen(dir)-1] == '/')
+ if(*dir.rbegin() == '/')
{
- std::string newdir = dir;
- newdir = newdir.substr(0, newdir.size()-1);
- if(std::find(this->LinkDirectories.begin(),
- this->LinkDirectories.end(),
- newdir.c_str()) == this->LinkDirectories.end())
- {
- this->LinkDirectories.push_back(newdir);
- }
+ newdir = dir.substr(0, dir.size()-1);
}
- else
+ if(std::find(this->LinkDirectories.begin(),
+ this->LinkDirectories.end(), newdir)
+ == this->LinkDirectories.end())
{
- if(std::find(this->LinkDirectories.begin(),
- this->LinkDirectories.end(), dir)
- == this->LinkDirectories.end())
- {
- this->LinkDirectories.push_back(dir);
- }
+ this->LinkDirectories.push_back(dir);
}
}
@@ -1621,8 +1660,8 @@ void cmMakefile::InitializeFromParent()
{
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += cmSystemTools::UpperCase(*ci);
- const char* prop = parent->GetProperty(defPropName.c_str());
- this->SetProperty(defPropName.c_str(), prop);
+ const char* prop = parent->GetProperty(defPropName);
+ this->SetProperty(defPropName, prop);
}
}
@@ -1664,7 +1703,7 @@ void cmMakefile::ConfigureSubDirectory(cmLocalGenerator *lg2)
}
}
-void cmMakefile::AddSubDirectory(const char* sub,
+void cmMakefile::AddSubDirectory(const std::string& sub,
bool excludeFromAll, bool preorder)
{
// the source path must be made full if it isn't already
@@ -1686,12 +1725,13 @@ void cmMakefile::AddSubDirectory(const char* sub,
}
- this->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
+ this->AddSubDirectory(srcPath, binPath,
excludeFromAll, preorder, false);
}
-void cmMakefile::AddSubDirectory(const char* srcPath, const char *binPath,
+void cmMakefile::AddSubDirectory(const std::string& srcPath,
+ const std::string& binPath,
bool excludeFromAll, bool preorder,
bool immediate)
{
@@ -1761,9 +1801,9 @@ void cmMakefile::AddIncludeDirectories(const std::vector<std::string> &incs,
//----------------------------------------------------------------------------
void
-cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
+cmMakefile::AddSystemIncludeDirectories(const std::set<std::string> &incs)
{
- for(std::set<cmStdString>::const_iterator li = incs.begin();
+ for(std::set<std::string>::const_iterator li = incs.begin();
li != incs.end(); ++li)
{
this->SystemIncludeDirectories.insert(*li);
@@ -1777,7 +1817,7 @@ cmMakefile::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
}
}
-void cmMakefile::AddDefinition(const char* name, const char* value)
+void cmMakefile::AddDefinition(const std::string& name, const char* value)
{
if (!value )
{
@@ -1806,14 +1846,15 @@ void cmMakefile::AddDefinition(const char* name, const char* value)
}
-void cmMakefile::AddCacheDefinition(const char* name, const char* value,
+void cmMakefile::AddCacheDefinition(const std::string& name, const char* value,
const char* doc,
cmCacheManager::CacheEntryType type,
bool force)
{
- const char* val = value;
+ bool haveVal = value ? true : false;
+ std::string val = haveVal ? value : "";
cmCacheManager::CacheIterator it =
- this->GetCacheManager()->GetCacheIterator(name);
+ this->GetCacheManager()->GetCacheIterator(name.c_str());
if(!it.IsAtEnd() && (it.GetType() == cmCacheManager::UNINITIALIZED) &&
it.Initialized())
{
@@ -1822,6 +1863,7 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value,
if(!force)
{
val = it.GetValue();
+ haveVal = true;
}
if ( type == cmCacheManager::PATH || type == cmCacheManager::FILEPATH )
{
@@ -1844,16 +1886,18 @@ void cmMakefile::AddCacheDefinition(const char* name, const char* value,
this->GetCacheManager()->AddCacheEntry(name, nvalue.c_str(), doc, type);
val = it.GetValue();
+ haveVal = true;
}
}
- this->GetCacheManager()->AddCacheEntry(name, val, doc, type);
+ this->GetCacheManager()->AddCacheEntry(name, haveVal ? val.c_str() : 0, doc,
+ type);
// if there was a definition then remove it
this->Internal->VarStack.top().Set(name, 0);
}
-void cmMakefile::AddDefinition(const char* name, bool value)
+void cmMakefile::AddDefinition(const std::string& name, bool value)
{
this->Internal->VarStack.top().Set(name, value? "ON" : "OFF");
if (this->Internal->VarUsageStack.size() &&
@@ -1880,20 +1924,20 @@ void cmMakefile::CheckForUnusedVariables() const
return;
}
const cmDefinitions& defs = this->Internal->VarStack.top();
- const std::set<cmStdString>& locals = defs.LocalKeys();
- std::set<cmStdString>::const_iterator it = locals.begin();
+ const std::set<std::string>& locals = defs.LocalKeys();
+ std::set<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it)
{
- this->CheckForUnused("out of scope", it->c_str());
+ this->CheckForUnused("out of scope", *it);
}
}
-void cmMakefile::MarkVariableAsUsed(const char* var)
+void cmMakefile::MarkVariableAsUsed(const std::string& var)
{
this->Internal->VarUsageStack.top().insert(var);
}
-bool cmMakefile::VariableInitialized(const char* var) const
+bool cmMakefile::VariableInitialized(const std::string& var) const
{
if(this->Internal->VarInitStack.top().find(var) !=
this->Internal->VarInitStack.top().end())
@@ -1903,7 +1947,7 @@ bool cmMakefile::VariableInitialized(const char* var) const
return false;
}
-bool cmMakefile::VariableUsed(const char* var) const
+bool cmMakefile::VariableUsed(const std::string& var) const
{
if(this->Internal->VarUsageStack.top().find(var) !=
this->Internal->VarUsageStack.top().end())
@@ -1913,11 +1957,12 @@ bool cmMakefile::VariableUsed(const char* var) const
return false;
}
-void cmMakefile::CheckForUnused(const char* reason, const char* name) const
+void cmMakefile::CheckForUnused(const char* reason,
+ const std::string& name) const
{
if (this->WarnUnused && !this->VariableUsed(name))
{
- cmStdString path;
+ std::string path;
cmListFileBacktrace bt;
if (this->CallStack.size())
{
@@ -1945,13 +1990,13 @@ void cmMakefile::CheckForUnused(const char* reason, const char* name) const
cmOStringStream msg;
msg << "unused variable (" << reason << ") \'" << name << "\'";
this->GetCMakeInstance()->IssueMessage(cmake::AUTHOR_WARNING,
- msg.str().c_str(),
+ msg.str(),
bt);
}
}
}
-void cmMakefile::RemoveDefinition(const char* name)
+void cmMakefile::RemoveDefinition(const std::string& name)
{
this->Internal->VarStack.top().Set(name, 0);
if (this->Internal->VarUsageStack.size() &&
@@ -1971,7 +2016,7 @@ void cmMakefile::RemoveDefinition(const char* name)
#endif
}
-void cmMakefile::RemoveCacheDefinition(const char* name)
+void cmMakefile::RemoveCacheDefinition(const std::string& name)
{
this->GetCacheManager()->RemoveCacheEntry(name);
}
@@ -1982,7 +2027,8 @@ void cmMakefile::SetProjectName(const char* p)
}
-void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
+void cmMakefile::AddGlobalLinkInformation(const std::string& name,
+ cmTarget& target)
{
// for these targets do not add anything
switch(target.GetType())
@@ -1997,19 +2043,20 @@ void cmMakefile::AddGlobalLinkInformation(const char* name, cmTarget& target)
for(j = this->LinkDirectories.begin();
j != this->LinkDirectories.end(); ++j)
{
- target.AddLinkDirectory(j->c_str());
+ target.AddLinkDirectory(*j);
}
target.MergeLinkLibraries( *this, name, this->LinkLibraries );
}
-void cmMakefile::AddAlias(const char* lname, cmTarget *tgt)
+void cmMakefile::AddAlias(const std::string& lname, cmTarget *tgt)
{
this->AliasTargets[lname] = tgt;
this->LocalGenerator->GetGlobalGenerator()->AddAlias(lname, tgt);
}
-cmTarget* cmMakefile::AddLibrary(const char* lname, cmTarget::TargetType type,
+cmTarget* cmMakefile::AddLibrary(const std::string& lname,
+ cmTarget::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll)
{
@@ -2055,7 +2102,7 @@ cmTarget* cmMakefile::AddExecutable(const char *exeName,
//----------------------------------------------------------------------------
cmTarget*
-cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
+cmMakefile::AddNewTarget(cmTarget::TargetType type, const std::string& name)
{
cmTargets::iterator it =
this->Targets.insert(cmTargets::value_type(name, cmTarget())).first;
@@ -2067,9 +2114,8 @@ cmMakefile::AddNewTarget(cmTarget::TargetType type, const char* name)
}
cmSourceFile*
-cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
+cmMakefile::LinearGetSourceFileWithOutput(const std::string& name) const
{
- std::string name = cname;
std::string out;
// look through all the source files that have custom commands
@@ -2080,7 +2126,7 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
// does this source file have a custom command?
if ((*i)->GetCustomCommand())
{
- // is the output of the custom command match the source files name
+ // Does the output of the custom command match the source file name?
const std::vector<std::string>& outputs =
(*i)->GetCustomCommand()->GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin();
@@ -2103,15 +2149,14 @@ cmMakefile::LinearGetSourceFileWithOutput(const char *cname) const
return 0;
}
-cmSourceFile *cmMakefile::GetSourceFileWithOutput(const char *cname) const
+cmSourceFile *cmMakefile::GetSourceFileWithOutput(
+ const std::string& name) const
{
- std::string name = cname;
-
// If the queried path is not absolute we use the backward compatible
// linear-time search for an output with a matching suffix.
- if(!cmSystemTools::FileIsFullPath(cname))
+ if(!cmSystemTools::FileIsFullPath(name.c_str()))
{
- return LinearGetSourceFileWithOutput(cname);
+ return this->LinearGetSourceFileWithOutput(name);
}
// Otherwise we use an efficient lookup map.
OutputToSourceMap::const_iterator o = this->OutputToSource.find(name);
@@ -2156,15 +2201,12 @@ cmMakefile::GetSourceGroup(const std::vector<std::string>&name) const
return sg;
}
- void cmMakefile::AddSourceGroup(const char* name,
+void cmMakefile::AddSourceGroup(const std::string& name,
const char* regex)
{
- if (name)
- {
- std::vector<std::string> nameVector;
- nameVector.push_back(name);
- AddSourceGroup(nameVector, regex);
- }
+ std::vector<std::string> nameVector;
+ nameVector.push_back(name);
+ AddSourceGroup(nameVector, regex);
}
void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
@@ -2212,7 +2254,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
{
std::string guidName = "SG_Filter_";
guidName += fullname;
- gg->CreateGUID(guidName.c_str());
+ gg->CreateGUID(guidName);
}
for(++i; i<=lastElement; ++i)
{
@@ -2223,7 +2265,7 @@ void cmMakefile::AddSourceGroup(const std::vector<std::string>& name,
{
std::string guidName = "SG_Filter_";
guidName += fullname;
- gg->CreateGUID(guidName.c_str());
+ gg->CreateGUID(guidName);
}
}
@@ -2337,13 +2379,13 @@ void cmMakefile::ExpandVariablesCMP0019()
}
}
-bool cmMakefile::IsOn(const char* name) const
+bool cmMakefile::IsOn(const std::string& name) const
{
const char* value = this->GetDefinition(name);
return cmSystemTools::IsOn(value);
}
-bool cmMakefile::IsSet(const char* name) const
+bool cmMakefile::IsSet(const std::string& name) const
{
const char* value = this->GetDefinition(name);
if ( !value )
@@ -2373,16 +2415,16 @@ bool cmMakefile::PlatformIs64Bit() const
return false;
}
-const char* cmMakefile::GetSONameFlag(const char* language) const
+const char* cmMakefile::GetSONameFlag(const std::string& language) const
{
std::string name = "CMAKE_SHARED_LIBRARY_SONAME";
- if(language)
+ if(!language.empty())
{
name += "_";
name += language;
}
name += "_FLAG";
- return GetDefinition(name.c_str());
+ return GetDefinition(name);
}
bool cmMakefile::CanIWriteThisFile(const char* fileName) const
@@ -2414,7 +2456,7 @@ bool cmMakefile::CanIWriteThisFile(const char* fileName) const
return true;
}
-const char* cmMakefile::GetRequiredDefinition(const char* name) const
+const char* cmMakefile::GetRequiredDefinition(const std::string& name) const
{
const char* ret = this->GetDefinition(name);
if(!ret)
@@ -2422,13 +2464,13 @@ const char* cmMakefile::GetRequiredDefinition(const char* name) const
cmSystemTools::Error("Error required internal CMake variable not "
"set, cmake may be not be built correctly.\n",
"Missing variable is:\n",
- name);
+ name.c_str());
return "";
}
return ret;
}
-bool cmMakefile::IsDefinitionSet(const char* name) const
+bool cmMakefile::IsDefinitionSet(const std::string& name) const
{
const char* def = this->Internal->VarStack.top().Get(name);
this->Internal->VarUsageStack.top().insert(name);
@@ -2450,12 +2492,18 @@ bool cmMakefile::IsDefinitionSet(const char* name) const
return def?true:false;
}
-const char* cmMakefile::GetDefinition(const char* name) const
+const char* cmMakefile::GetDefinition(const std::string& name) const
{
if (this->WarnUnused)
{
this->Internal->VarUsageStack.top().insert(name);
}
+ if (name == "CMAKE_CXX_KNOWN_FEATURES")
+ {
+#define STRING_LIST_ELEMENT(F) ";" #F
+ return FOR_EACH_CXX_FEATURE(STRING_LIST_ELEMENT) + 1;
+#undef STRING_LIST_ELEMENT
+ }
const char* def = this->Internal->VarStack.top().Get(name);
if(!def)
{
@@ -2491,7 +2539,7 @@ const char* cmMakefile::GetDefinition(const char* name) const
return def;
}
-const char* cmMakefile::GetSafeDefinition(const char* def) const
+const char* cmMakefile::GetSafeDefinition(const std::string& def) const
{
const char* ret = this->GetDefinition(def);
if(!ret)
@@ -2504,7 +2552,7 @@ const char* cmMakefile::GetSafeDefinition(const char* def) const
std::vector<std::string> cmMakefile
::GetDefinitions(int cacheonly /* = 0 */) const
{
- std::set<cmStdString> definitions;
+ std::set<std::string> definitions;
if ( !cacheonly )
{
definitions = this->Internal->VarStack.top().ClosureKeys();
@@ -2518,7 +2566,7 @@ std::vector<std::string> cmMakefile
std::vector<std::string> res;
- std::set<cmStdString>::iterator fit;
+ std::set<std::string>::iterator fit;
for ( fit = definitions.begin(); fit != definitions.end(); fit ++ )
{
res.push_back(*fit);
@@ -2577,7 +2625,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
// Lookup the definition of VAR.
std::string var(first+1, last-first-2);
- if(const char* val = this->GetDefinition(var.c_str()))
+ if(const char* val = this->GetDefinition(var))
{
// Store the value in the output escaping as requested.
if(escapeQuotes)
@@ -2632,7 +2680,7 @@ const char *cmMakefile::ExpandVariablesInString(std::string& source,
<< " " << filename << ":" << line << "\n";
}
error << "when parsing string\n"
- << " " << source.c_str() << "\n";
+ << " " << source << "\n";
error << emsg;
// If the parser failed ("res" is false) then this is a real
@@ -2751,7 +2799,7 @@ void cmMakefile::AddDefaultDefinitions()
}
//----------------------------------------------------------------------------
-const char*
+std::string
cmMakefile::GetConfigurations(std::vector<std::string>& configs,
bool single) const
{
@@ -2762,12 +2810,12 @@ cmMakefile::GetConfigurations(std::vector<std::string>& configs,
{
cmSystemTools::ExpandListArgument(configTypes, configs);
}
- return 0;
+ return "";
}
else
{
- const char* buildType = this->GetDefinition("CMAKE_BUILD_TYPE");
- if(single && buildType && *buildType)
+ const std::string& buildType = this->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ if(single && !buildType.empty())
{
configs.push_back(buildType);
}
@@ -2973,7 +3021,7 @@ cmMakefile::LexicalPushPop::~LexicalPushPop()
this->Makefile->PopFunctionBlockerBarrier(this->ReportError);
}
-void cmMakefile::SetHomeDirectory(const char* dir)
+void cmMakefile::SetHomeDirectory(const std::string& dir)
{
this->cmHomeDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory);
@@ -2984,7 +3032,7 @@ void cmMakefile::SetHomeDirectory(const char* dir)
}
}
-void cmMakefile::SetHomeOutputDirectory(const char* lib)
+void cmMakefile::SetHomeOutputDirectory(const std::string& lib)
{
this->HomeOutputDirectory = lib;
cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory);
@@ -3012,13 +3060,13 @@ void cmMakefile::SetArgcArgv(const std::vector<std::string>& args)
{
cmOStringStream tmpStream;
tmpStream << "CMAKE_ARGV" << t;
- this->AddDefinition(tmpStream.str().c_str(), args[t].c_str());
+ this->AddDefinition(tmpStream.str(), args[t].c_str());
//this->MarkVariableAsUsed(tmpStream.str().c_str());
}
}
//----------------------------------------------------------------------------
-cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
+cmSourceFile* cmMakefile::GetSource(const std::string& sourceName) const
{
cmSourceFileLocation sfl(this, sourceName);
for(std::vector<cmSourceFile*>::const_iterator
@@ -3035,7 +3083,7 @@ cmSourceFile* cmMakefile::GetSource(const char* sourceName) const
}
//----------------------------------------------------------------------------
-cmSourceFile* cmMakefile::GetOrCreateSource(const char* sourceName,
+cmSourceFile* cmMakefile::GetOrCreateSource(const std::string& sourceName,
bool generated)
{
if(cmSourceFile* esf = this->GetSource(sourceName))
@@ -3077,23 +3125,25 @@ void cmMakefile::ExpandSourceListArguments(
}
}
-int cmMakefile::TryCompile(const char *srcdir, const char *bindir,
- const char *projectName, const char *targetName,
+int cmMakefile::TryCompile(const std::string& srcdir,
+ const std::string& bindir,
+ const std::string& projectName,
+ const std::string& targetName,
bool fast,
const std::vector<std::string> *cmakeArgs,
std::string *output)
{
this->Internal->IsSourceFileTryCompile = fast;
// does the binary directory exist ? If not create it...
- if (!cmSystemTools::FileIsDirectory(bindir))
+ if (!cmSystemTools::FileIsDirectory(bindir.c_str()))
{
- cmSystemTools::MakeDirectory(bindir);
+ cmSystemTools::MakeDirectory(bindir.c_str());
}
// change to the tests directory and run cmake
// use the cmake object instead of calling cmake
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- cmSystemTools::ChangeDirectory(bindir);
+ cmSystemTools::ChangeDirectory(bindir.c_str());
// make sure the same generator is used
// use this program as the cmake to be run, it should not
@@ -3345,7 +3395,8 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
if ((moduleInCMakeModulePath.size()>0) && (moduleInCMakeRoot.size()>0))
{
const char* currentFile = this->GetDefinition("CMAKE_CURRENT_LIST_FILE");
- if (currentFile && (strstr(currentFile, cmakeRoot) == currentFile))
+ std::string mods = cmakeRoot + std::string("/Modules/");
+ if (currentFile && strncmp(currentFile, mods.c_str(), mods.size()) == 0)
{
switch (this->GetPolicyStatus(cmPolicies::CMP0017))
{
@@ -3367,7 +3418,6 @@ std::string cmMakefile::GetModulesFile(const char* filename) const
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
case cmPolicies::NEW:
- default:
result = moduleInCMakeRoot;
break;
}
@@ -3406,7 +3456,7 @@ void cmMakefile::ConfigureString(const std::string& input,
if(this->cmDefineRegex.find(line))
{
const char* def =
- this->GetDefinition(this->cmDefineRegex.match(1).c_str());
+ this->GetDefinition(this->cmDefineRegex.match(1));
if(!cmSystemTools::IsOff(def))
{
cmSystemTools::ReplaceString(line, "#cmakedefine", "#define");
@@ -3422,7 +3472,7 @@ void cmMakefile::ConfigureString(const std::string& input,
else if(this->cmDefine01Regex.find(line))
{
const char* def =
- this->GetDefinition(this->cmDefine01Regex.match(1).c_str());
+ this->GetDefinition(this->cmDefine01Regex.match(1));
cmSystemTools::ReplaceString(line, "#cmakedefine01", "#define");
output += line;
if(!cmSystemTools::IsOff(def))
@@ -3528,6 +3578,20 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
return 0;
}
+ cmsys::FStream::BOM bom = cmsys::FStream::ReadBOM(fin);
+ if(bom != cmsys::FStream::BOM_None &&
+ bom != cmsys::FStream::BOM_UTF8)
+ {
+ cmOStringStream e;
+ e << "File starts with a Byte-Order-Mark that is not UTF-8:\n "
+ << sinfile;
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return 0;
+ }
+ // rewind to copy BOM to output file
+ fin.seekg(0);
+
+
// now copy input to output and expand variables in the
// input file at the same time
std::string inLine;
@@ -3555,17 +3619,9 @@ int cmMakefile::ConfigureFile(const char* infile, const char* outfile,
return res;
}
-void cmMakefile::SetProperty(const char* prop, const char* value)
+void cmMakefile::SetProperty(const std::string& prop, const char* value)
{
- if (!prop)
- {
- return;
- }
-
- // handle special props
- std::string propname = prop;
-
- if ( propname == "LINK_DIRECTORIES" )
+ if ( prop == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
if(value)
@@ -3575,7 +3631,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->SetLinkDirectories(varArgsExpanded);
return;
}
- if (propname == "INCLUDE_DIRECTORIES")
+ if (prop == "INCLUDE_DIRECTORIES")
{
this->IncludeDirectoriesEntries.clear();
if (!value)
@@ -3588,7 +3644,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
cmValueWithOrigin(value, lfbt));
return;
}
- if (propname == "COMPILE_OPTIONS")
+ if (prop == "COMPILE_OPTIONS")
{
this->CompileOptionsEntries.clear();
if (!value)
@@ -3600,7 +3656,7 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->CompileOptionsEntries.push_back(cmValueWithOrigin(value, lfbt));
return;
}
- if (propname == "COMPILE_DEFINITIONS")
+ if (prop == "COMPILE_DEFINITIONS")
{
this->CompileDefinitionsEntries.clear();
if (!value)
@@ -3614,13 +3670,13 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
return;
}
- if ( propname == "INCLUDE_REGULAR_EXPRESSION" )
+ if ( prop == "INCLUDE_REGULAR_EXPRESSION" )
{
this->SetIncludeRegularExpression(value);
return;
}
- if ( propname == "ADDITIONAL_MAKE_CLEAN_FILES" )
+ if ( prop == "ADDITIONAL_MAKE_CLEAN_FILES" )
{
// This property is not inherrited
if ( strcmp(this->GetCurrentDirectory(),
@@ -3633,18 +3689,11 @@ void cmMakefile::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop,value,cmProperty::DIRECTORY);
}
-void cmMakefile::AppendProperty(const char* prop, const char* value,
+void cmMakefile::AppendProperty(const std::string& prop,
+ const char* value,
bool asString)
{
- if (!prop)
- {
- return;
- }
-
- // handle special props
- std::string propname = prop;
-
- if (propname == "INCLUDE_DIRECTORIES")
+ if (prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt;
this->GetBacktrace(lfbt);
@@ -3652,7 +3701,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
cmValueWithOrigin(value, lfbt));
return;
}
- if (propname == "COMPILE_OPTIONS")
+ if (prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt;
this->GetBacktrace(lfbt);
@@ -3660,7 +3709,7 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
cmValueWithOrigin(value, lfbt));
return;
}
- if (propname == "COMPILE_DEFINITIONS")
+ if (prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt;
this->GetBacktrace(lfbt);
@@ -3668,14 +3717,14 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
cmValueWithOrigin(value, lfbt));
return;
}
- if ( propname == "LINK_DIRECTORIES" )
+ if ( prop == "LINK_DIRECTORIES" )
{
std::vector<std::string> varArgsExpanded;
cmSystemTools::ExpandListArgument(value, varArgsExpanded);
for(std::vector<std::string>::const_iterator vi = varArgsExpanded.begin();
vi != varArgsExpanded.end(); ++vi)
{
- this->AddLinkDirectory(vi->c_str());
+ this->AddLinkDirectory(*vi);
}
return;
}
@@ -3683,32 +3732,18 @@ void cmMakefile::AppendProperty(const char* prop, const char* value,
this->Properties.AppendProperty(prop,value,cmProperty::DIRECTORY,asString);
}
-const char *cmMakefile::GetPropertyOrDefinition(const char* prop) const
-{
- const char *ret = this->GetProperty(prop, cmProperty::DIRECTORY);
- if (!ret)
- {
- ret = this->GetDefinition(prop);
- }
- return ret;
-}
-
-const char *cmMakefile::GetProperty(const char* prop) const
+const char *cmMakefile::GetProperty(const std::string& prop) const
{
return this->GetProperty(prop, cmProperty::DIRECTORY);
}
-const char *cmMakefile::GetProperty(const char* prop,
+const char *cmMakefile::GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const
{
- if(!prop)
- {
- return 0;
- }
// watch for specific properties
static std::string output;
output = "";
- if (!strcmp("PARENT_DIRECTORY",prop))
+ if (prop == "PARENT_DIRECTORY")
{
if(cmLocalGenerator* plg = this->LocalGenerator->GetParent())
{
@@ -3716,14 +3751,14 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
- else if (!strcmp("INCLUDE_REGULAR_EXPRESSION",prop) )
+ else if (prop == "INCLUDE_REGULAR_EXPRESSION" )
{
output = this->GetIncludeRegularExpression();
return output.c_str();
}
- else if (!strcmp("LISTFILE_STACK",prop))
+ else if (prop == "LISTFILE_STACK")
{
- for (std::deque<cmStdString>::const_iterator
+ for (std::deque<std::string>::const_iterator
i = this->ListFileStack.begin();
i != this->ListFileStack.end(); ++i)
{
@@ -3735,10 +3770,10 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
- else if (!strcmp("VARIABLES",prop) || !strcmp("CACHE_VARIABLES",prop))
+ else if (prop == "VARIABLES" || prop == "CACHE_VARIABLES")
{
int cacheonly = 0;
- if ( !strcmp("CACHE_VARIABLES",prop) )
+ if ( prop == "CACHE_VARIABLES" )
{
cacheonly = 1;
}
@@ -3753,17 +3788,17 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
- else if (!strcmp("MACROS",prop))
+ else if (prop == "MACROS")
{
this->GetListOfMacros(output);
return output.c_str();
}
- else if (!strcmp("DEFINITIONS",prop))
+ else if (prop == "DEFINITIONS")
{
output += this->DefineFlagsOrig;
return output.c_str();
}
- else if (!strcmp("LINK_DIRECTORIES",prop))
+ else if (prop == "LINK_DIRECTORIES")
{
cmOStringStream str;
for (std::vector<std::string>::const_iterator
@@ -3780,7 +3815,7 @@ const char *cmMakefile::GetProperty(const char* prop,
output = str.str();
return output.c_str();
}
- else if (!strcmp("INCLUDE_DIRECTORIES",prop))
+ else if (prop == "INCLUDE_DIRECTORIES")
{
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
@@ -3794,7 +3829,7 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
- else if (!strcmp("COMPILE_OPTIONS",prop))
+ else if (prop == "COMPILE_OPTIONS")
{
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
@@ -3808,7 +3843,7 @@ const char *cmMakefile::GetProperty(const char* prop,
}
return output.c_str();
}
- else if (!strcmp("COMPILE_DEFINITIONS",prop))
+ else if (prop == "COMPILE_DEFINITIONS")
{
std::string sep;
for (std::vector<cmValueWithOrigin>::const_iterator
@@ -3839,22 +3874,23 @@ const char *cmMakefile::GetProperty(const char* prop,
return retVal;
}
-bool cmMakefile::GetPropertyAsBool(const char* prop) const
+bool cmMakefile::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
//----------------------------------------------------------------------------
-const char* cmMakefile::GetFeature(const char* feature, const char* config)
+const char* cmMakefile::GetFeature(const std::string& feature,
+ const std::string& config)
{
// TODO: Define accumulation policy for features (prepend, append, replace).
// Currently we always replace.
- if(config && *config)
+ if(!config.empty())
{
std::string featureConfig = feature;
featureConfig += "_";
featureConfig += cmSystemTools::UpperCase(config);
- if(const char* value = this->GetProperty(featureConfig.c_str()))
+ if(const char* value = this->GetProperty(featureConfig))
{
return value;
}
@@ -3892,12 +3928,8 @@ cmTarget* cmMakefile::FindTarget(const std::string& name,
}
//----------------------------------------------------------------------------
-cmTest* cmMakefile::CreateTest(const char* testName)
+cmTest* cmMakefile::CreateTest(const std::string& testName)
{
- if ( !testName )
- {
- return 0;
- }
cmTest* test = this->GetTest(testName);
if ( test )
{
@@ -3910,16 +3942,13 @@ cmTest* cmMakefile::CreateTest(const char* testName)
}
//----------------------------------------------------------------------------
-cmTest* cmMakefile::GetTest(const char* testName) const
+cmTest* cmMakefile::GetTest(const std::string& testName) const
{
- if(testName)
+ std::map<std::string, cmTest*>::const_iterator
+ mi = this->Tests.find(testName);
+ if(mi != this->Tests.end())
{
- std::map<cmStdString, cmTest*>::const_iterator
- mi = this->Tests.find(testName);
- if(mi != this->Tests.end())
- {
- return mi->second;
- }
+ return mi->second;
}
return 0;
}
@@ -3954,7 +3983,7 @@ std::string cmMakefile::GetListFileStack() const
size_t depth = this->ListFileStack.size();
if (depth > 0)
{
- std::deque<cmStdString>::const_iterator it = this->ListFileStack.end();
+ std::deque<std::string>::const_iterator it = this->ListFileStack.end();
do
{
if (depth != this->ListFileStack.size())
@@ -3977,8 +4006,8 @@ std::string cmMakefile::GetListFileStack() const
void cmMakefile::PushScope()
{
cmDefinitions* parent = &this->Internal->VarStack.top();
- const std::set<cmStdString>& init = this->Internal->VarInitStack.top();
- const std::set<cmStdString>& usage = this->Internal->VarUsageStack.top();
+ const std::set<std::string>& init = this->Internal->VarInitStack.top();
+ const std::set<std::string>& usage = this->Internal->VarUsageStack.top();
this->Internal->VarStack.push(cmDefinitions(parent));
this->Internal->VarInitStack.push(init);
this->Internal->VarUsageStack.push(usage);
@@ -3987,18 +4016,18 @@ void cmMakefile::PushScope()
void cmMakefile::PopScope()
{
cmDefinitions* current = &this->Internal->VarStack.top();
- std::set<cmStdString> init = this->Internal->VarInitStack.top();
- std::set<cmStdString> usage = this->Internal->VarUsageStack.top();
- const std::set<cmStdString>& locals = current->LocalKeys();
+ std::set<std::string> init = this->Internal->VarInitStack.top();
+ std::set<std::string> usage = this->Internal->VarUsageStack.top();
+ const std::set<std::string>& locals = current->LocalKeys();
// Remove initialization and usage information for variables in the local
// scope.
- std::set<cmStdString>::const_iterator it = locals.begin();
+ std::set<std::string>::const_iterator it = locals.begin();
for (; it != locals.end(); ++it)
{
init.erase(*it);
- if (!this->VariableUsed(it->c_str()))
+ if (!this->VariableUsed(*it))
{
- this->CheckForUnused("out of scope", it->c_str());
+ this->CheckForUnused("out of scope", *it);
}
else
{
@@ -4021,9 +4050,9 @@ void cmMakefile::PopScope()
}
}
-void cmMakefile::RaiseScope(const char *var, const char *varDef)
+void cmMakefile::RaiseScope(const std::string& var, const char *varDef)
{
- if (!var || !strlen(var))
+ if (var.empty())
{
return;
}
@@ -4077,7 +4106,8 @@ void cmMakefile::DefineProperties(cmake *cm)
//----------------------------------------------------------------------------
cmTarget*
-cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
+cmMakefile::AddImportedTarget(const std::string& name,
+ cmTarget::TargetType type,
bool global)
{
// Create the target.
@@ -4104,7 +4134,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
{
// Look for an imported target. These take priority because they
// are more local in scope and do not have to be globally unique.
- std::map<cmStdString, cmTarget*>::const_iterator
+ std::map<std::string, cmTarget*>::const_iterator
imported = this->ImportedTargets.find(name);
if(imported != this->ImportedTargets.end())
{
@@ -4118,8 +4148,7 @@ cmTarget* cmMakefile::FindTargetToUse(const std::string& name,
}
// Look for a target built in this project.
- return this->LocalGenerator->GetGlobalGenerator()->FindTarget(0,
- name.c_str(),
+ return this->LocalGenerator->GetGlobalGenerator()->FindTarget(name,
excludeAliases);
}
@@ -4129,12 +4158,12 @@ bool cmMakefile::IsAlias(const std::string& name) const
if (this->AliasTargets.find(name) != this->AliasTargets.end())
return true;
return this->GetLocalGenerator()->GetGlobalGenerator()->IsAlias(
- name.c_str());
+ name);
}
//----------------------------------------------------------------------------
cmGeneratorTarget*
-cmMakefile::FindGeneratorTargetToUse(const char* name) const
+cmMakefile::FindGeneratorTargetToUse(const std::string& name) const
{
if (cmTarget *t = this->FindTargetToUse(name))
{
@@ -4223,6 +4252,9 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
case cmTarget::UTILITY:
e << "a custom target ";
break;
+ case cmTarget::INTERFACE_LIBRARY:
+ e << "an interface library ";
+ break;
default: break;
}
e << "created in source directory \""
@@ -4236,8 +4268,8 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg,
}
//----------------------------------------------------------------------------
-bool cmMakefile::EnforceUniqueDir(const char* srcPath,
- const char* binPath) const
+bool cmMakefile::EnforceUniqueDir(const std::string& srcPath,
+ const std::string& binPath) const
{
// Make sure the binary directory is unique.
cmGlobalGenerator* gg = this->LocalGenerator->GetGlobalGenerator();
@@ -4356,7 +4388,7 @@ bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var)
// Check for an explicit CMAKE_POLICY_WARNING_CMP<NNNN> setting.
if(!var.empty())
{
- if(const char* val = this->GetDefinition(var.c_str()))
+ if(const char* val = this->GetDefinition(var))
{
return cmSystemTools::IsOn(val);
}
@@ -4391,7 +4423,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id,
{
std::string msg =
this->GetPolicies()->GetRequiredAlwaysPolicyError(id);
- this->IssueMessage(cmake::FATAL_ERROR, msg.c_str());
+ this->IssueMessage(cmake::FATAL_ERROR, msg);
return false;
}
@@ -4515,3 +4547,147 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm)
pm[pid] = this->GetPolicyStatus(pid);
}
}
+
+#define FEATURE_STRING(F) , #F
+
+static const char * const CXX_FEATURES[] = {
+ 0
+ FOR_EACH_CXX_FEATURE(FEATURE_STRING)
+};
+
+static const char * const CXX_STANDARDS[] = {
+ "98"
+ , "11"
+};
+
+//----------------------------------------------------------------------------
+bool cmMakefile::
+AddRequiredTargetFeature(cmTarget *target, const std::string& feature,
+ std::string *error) const
+{
+ if (cmGeneratorExpression::Find(feature) != std::string::npos)
+ {
+ target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+ return true;
+ }
+ bool isCxxFeature = std::find_if(cmArrayBegin(CXX_FEATURES) + 1,
+ cmArrayEnd(CXX_FEATURES), cmStrCmp(feature))
+ != cmArrayEnd(CXX_FEATURES);
+ if (!isCxxFeature)
+ {
+ cmOStringStream e;
+ if (error)
+ {
+ e << "specified";
+ }
+ else
+ {
+ e << "Specified";
+ }
+ e << " unknown feature \"" << feature << "\" for "
+ "target \"" << target->GetName() << "\".";
+ if (error)
+ {
+ *error = e.str();
+ }
+ else
+ {
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
+ return false;
+ }
+
+ std::string lang = "CXX";
+
+ const char* featuresKnown =
+ this->GetDefinition("CMAKE_" + lang + "_COMPILE_FEATURES");
+
+ if (!featuresKnown || !*featuresKnown)
+ {
+ cmOStringStream e;
+ if (error)
+ {
+ e << "no";
+ }
+ else
+ {
+ e << "No";
+ }
+ e << " known features for compiler\n\""
+ << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
+ << "\"\nversion "
+ << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
+ if (error)
+ {
+ *error = e.str();
+ }
+ else
+ {
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ }
+ return false;
+ }
+
+ std::vector<std::string> availableFeatures;
+ cmSystemTools::ExpandListArgument(featuresKnown, availableFeatures);
+ if (std::find(availableFeatures.begin(),
+ availableFeatures.end(),
+ feature) == availableFeatures.end())
+ {
+ cmOStringStream e;
+ e << "The compiler feature \"" << feature
+ << "\" is not known to compiler\n\""
+ << this->GetDefinition("CMAKE_" + lang + "_COMPILER_ID")
+ << "\"\nversion "
+ << this->GetDefinition("CMAKE_" + lang + "_COMPILER_VERSION") << ".";
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+
+ target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+
+ bool needCxx11 = false;
+
+ if (const char *propCxx11 =
+ this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES"))
+ {
+ std::vector<std::string> props;
+ cmSystemTools::ExpandListArgument(propCxx11, props);
+ needCxx11 = std::find(props.begin(), props.end(), feature) != props.end();
+ }
+
+ const char *existingCxxStandard = target->GetProperty("CXX_STANDARD");
+ if (existingCxxStandard)
+ {
+ if (std::find_if(cmArrayBegin(CXX_STANDARDS), cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp(existingCxxStandard)) == cmArrayEnd(CXX_STANDARDS))
+ {
+ cmOStringStream e;
+ e << "The CXX_STANDARD property on target \"" << target->GetName()
+ << "\" contained an invalid value: \"" << existingCxxStandard << "\".";
+ this->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return false;
+ }
+ }
+ const char * const *existingCxxIt = existingCxxStandard
+ ? std::find_if(cmArrayBegin(CXX_STANDARDS),
+ cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp(existingCxxStandard))
+ : cmArrayEnd(CXX_STANDARDS);
+
+ bool setCxx11 = needCxx11 && !existingCxxStandard;
+
+ if (needCxx11 && existingCxxStandard && existingCxxIt <
+ std::find_if(cmArrayBegin(CXX_STANDARDS),
+ cmArrayEnd(CXX_STANDARDS),
+ cmStrCmp("11")))
+ {
+ setCxx11 = true;
+ }
+
+ if (setCxx11)
+ {
+ target->SetProperty("CXX_STANDARD", "11");
+ }
+ return true;
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index f00fd20..3bccb63 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -69,11 +69,11 @@ public:
/* Check for unused variables in this scope */
void CheckForUnusedVariables() const;
/* Mark a variable as used */
- void MarkVariableAsUsed(const char* var);
+ void MarkVariableAsUsed(const std::string& var);
/* return true if a variable has been initialized */
- bool VariableInitialized(const char* ) const;
+ bool VariableInitialized(const std::string& ) const;
/* return true if a variable has been used */
- bool VariableUsed(const char* ) const;
+ bool VariableUsed(const std::string& ) const;
/** Return whether compatibility features needed for a version of
the cache or lower should be enabled. */
bool NeedCacheCompatibility(int major, int minor) const;
@@ -126,8 +126,8 @@ public:
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
*/
- int TryCompile(const char *srcdir, const char *bindir,
- const char *projectName, const char *targetName,
+ int TryCompile(const std::string& srcdir, const std::string& bindir,
+ const std::string& projectName, const std::string& targetName,
bool fast,
const std::vector<std::string> *cmakeArgs,
std::string *output);
@@ -168,7 +168,7 @@ public:
void Print() const;
/** Add a custom command to the build. */
- void AddCustomCommandToTarget(const char* target,
+ void AddCustomCommandToTarget(const std::string& target,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
cmTarget::CustomCommandType type,
@@ -177,23 +177,23 @@ public:
cmSourceFile* AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
- const char* main_dependency,
+ const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment, const char* workingDir,
bool replace = false,
bool escapeOldStyle = true);
cmSourceFile* AddCustomCommandToOutput(
- const char* output,
+ const std::string& output,
const std::vector<std::string>& depends,
- const char* main_dependency,
+ const std::string& main_dependency,
const cmCustomCommandLines& commandLines,
const char* comment, const char* workingDir,
bool replace = false,
bool escapeOldStyle = true);
- void AddCustomCommandOldStyle(const char* target,
+ void AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
- const char* source,
+ const std::string& source,
const cmCustomCommandLines& commandLines,
const char* comment);
@@ -205,10 +205,11 @@ public:
void AddCompileOption(const char* option);
/** Create a new imported target with the name and type given. */
- cmTarget* AddImportedTarget(const char* name, cmTarget::TargetType type,
+ cmTarget* AddImportedTarget(const std::string& name,
+ cmTarget::TargetType type,
bool global);
- cmTarget* AddNewTarget(cmTarget::TargetType type, const char* name);
+ cmTarget* AddNewTarget(cmTarget::TargetType type, const std::string& name);
/**
* Add an executable to the build.
@@ -221,7 +222,7 @@ public:
* Add a utility to the build. A utiltity target is a command that
* is run every time the target is built.
*/
- void AddUtilityCommand(const char* utilityName, bool excludeFromAll,
+ void AddUtilityCommand(const std::string& utilityName, bool excludeFromAll,
const std::vector<std::string>& depends,
const char* workingDirectory,
const char* command,
@@ -229,7 +230,8 @@ public:
const char* arg2=0,
const char* arg3=0,
const char* arg4=0);
- cmTarget* AddUtilityCommand(const char* utilityName, bool excludeFromAll,
+ cmTarget* AddUtilityCommand(const std::string& utilityName,
+ bool excludeFromAll,
const char* workingDirectory,
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines,
@@ -239,16 +241,16 @@ public:
/**
* Add a link library to the build.
*/
- void AddLinkLibrary(const char*);
- void AddLinkLibrary(const char*, cmTarget::LinkLibraryType type);
- void AddLinkLibraryForTarget(const char *tgt, const char*,
+ void AddLinkLibrary(const std::string&);
+ void AddLinkLibrary(const std::string&, cmTarget::LinkLibraryType type);
+ void AddLinkLibraryForTarget(const std::string& tgt, const std::string&,
cmTarget::LinkLibraryType type);
- void AddLinkDirectoryForTarget(const char *tgt, const char* d);
+ void AddLinkDirectoryForTarget(const std::string& tgt, const std::string& d);
/**
* Add a link directory to the build.
*/
- void AddLinkDirectory(const char*);
+ void AddLinkDirectory(const std::string&);
const std::vector<std::string>& GetLinkDirectories() const
{
@@ -262,9 +264,10 @@ public:
/**
* Add a subdirectory to the build.
*/
- void AddSubDirectory(const char*, bool excludeFromAll=false,
+ void AddSubDirectory(const std::string&, bool excludeFromAll=false,
bool preorder = false);
- void AddSubDirectory(const char* fullSrcDir,const char *fullBinDir,
+ void AddSubDirectory(const std::string& fullSrcDir,
+ const std::string& fullBinDir,
bool excludeFromAll, bool preorder,
bool immediate);
@@ -283,9 +286,9 @@ public:
* Add a variable definition to the build. This variable
* can be used in CMake to refer to lists, directories, etc.
*/
- void AddDefinition(const char* name, const char* value);
+ void AddDefinition(const std::string& name, const char* value);
///! Add a definition to this makefile and the global cmake cache.
- void AddCacheDefinition(const char* name, const char* value,
+ void AddCacheDefinition(const std::string& name, const char* value,
const char* doc,
cmCacheManager::CacheEntryType type,
bool force = false);
@@ -293,15 +296,15 @@ public:
/**
* Add bool variable definition to the build.
*/
- void AddDefinition(const char* name, bool);
+ void AddDefinition(const std::string& name, bool);
/**
* Remove a variable definition from the build. This is not valid
* for cache entries, and will only affect the current makefile.
*/
- void RemoveDefinition(const char* name);
+ void RemoveDefinition(const std::string& name);
///! Remove a definition from the cache.
- void RemoveCacheDefinition(const char* name);
+ void RemoveCacheDefinition(const std::string& name);
/**
* Specify the name of the project for this build.
@@ -317,22 +320,22 @@ public:
}
/** Get the configurations to be generated. */
- const char* GetConfigurations(std::vector<std::string>& configs,
+ std::string GetConfigurations(std::vector<std::string>& configs,
bool single = true) const;
/**
* Set the name of the library.
*/
- cmTarget* AddLibrary(const char *libname, cmTarget::TargetType type,
+ cmTarget* AddLibrary(const std::string& libname, cmTarget::TargetType type,
const std::vector<std::string> &srcs,
bool excludeFromAll = false);
- void AddAlias(const char *libname, cmTarget *tgt);
+ void AddAlias(const std::string& libname, cmTarget *tgt);
#if defined(CMAKE_BUILD_WITH_CMAKE)
/**
* Add a root source group for consideration when adding a new source.
*/
- void AddSourceGroup(const char* name, const char* regex=0);
+ void AddSourceGroup(const std::string& name, const char* regex=0);
/**
* Add a source group for consideration when adding a new source.
@@ -399,12 +402,12 @@ public:
* CMakeLists files by recursing up the tree starting at the StartDirectory
* and going up until it reaches the HomeDirectory.
*/
- void SetHomeDirectory(const char* dir);
+ void SetHomeDirectory(const std::string& dir);
const char* GetHomeDirectory() const
{
return this->cmHomeDirectory.c_str();
}
- void SetHomeOutputDirectory(const char* lib);
+ void SetHomeOutputDirectory(const std::string& lib);
const char* GetHomeOutputDirectory() const
{
return this->HomeOutputDirectory.c_str();
@@ -429,7 +432,7 @@ public:
* recursing up the tree starting at the StartDirectory and going up until
* it reaches the HomeDirectory.
*/
- void SetStartDirectory(const char* dir)
+ void SetStartDirectory(const std::string& dir)
{
this->cmStartDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
@@ -442,7 +445,7 @@ public:
{
return this->cmStartDirectory.c_str();
}
- void SetStartOutputDirectory(const char* lib)
+ void SetStartOutputDirectory(const std::string& lib)
{
this->StartOutputDirectory = lib;
cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
@@ -494,7 +497,7 @@ public:
* Set a regular expression that include files that are not found
* must match in order to be considered a problem.
*/
- void SetComplainRegularExpression(const char* regex)
+ void SetComplainRegularExpression(const std::string& regex)
{
this->ComplainFileRegularExpression = regex;
}
@@ -534,12 +537,12 @@ public:
cmTarget* FindTargetToUse(const std::string& name,
bool excludeAliases = false) const;
bool IsAlias(const std::string& name) const;
- cmGeneratorTarget* FindGeneratorTargetToUse(const char* name) const;
+ cmGeneratorTarget* FindGeneratorTargetToUse(const std::string& name) const;
/**
* Mark include directories as system directories.
*/
- void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
+ void AddSystemIncludeDirectories(const std::set<std::string> &incs);
/** Expand out any arguements in the vector that have ; separated
* strings into multiple arguements. A new vector is created
@@ -555,14 +558,14 @@ public:
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then a null pointer is returned.
*/
- cmSourceFile* GetSource(const char* sourceName) const;
+ cmSourceFile* GetSource(const std::string& sourceName) const;
/** Get a cmSourceFile pointer for a given source name, if the name is
* not found, then create the source file and return it. generated
* indicates if it is a generated file, this is used in determining
* how to create the source file instance e.g. name
*/
- cmSourceFile* GetOrCreateSource(const char* sourceName,
+ cmSourceFile* GetOrCreateSource(const std::string& sourceName,
bool generated = false);
/**
@@ -587,10 +590,10 @@ public:
* If the variable is not found in this makefile instance, the
* cache is then queried.
*/
- const char* GetDefinition(const char*) const;
- const char* GetSafeDefinition(const char*) const;
- const char* GetRequiredDefinition(const char* name) const;
- bool IsDefinitionSet(const char*) const;
+ const char* GetDefinition(const std::string&) const;
+ const char* GetSafeDefinition(const std::string&) const;
+ const char* GetRequiredDefinition(const std::string& name) const;
+ bool IsDefinitionSet(const std::string&) const;
/**
* Get the list of all variables in the current space. If argument
* cacheonly is specified and is greater than 0, then only cache
@@ -598,17 +601,20 @@ public:
*/
std::vector<std::string> GetDefinitions(int cacheonly=0) const;
- /** Test a boolean cache entry to see if it is true or false,
- * returns false if no entry defined.
+ /**
+ * Test a boolean variable to see if it is true or false.
+ * If the variable is not found in this makefile instance, the
+ * cache is then queried.
+ * Returns false if no entry defined.
*/
- bool IsOn(const char* name) const;
- bool IsSet(const char* name) const;
+ bool IsOn(const std::string& name) const;
+ bool IsSet(const std::string& name) const;
/** Return whether the target platform is 64-bit. */
bool PlatformIs64Bit() const;
/** Retrieve soname flag for the specified language if supported */
- const char* GetSONameFlag(const char* language) const;
+ const char* GetSONameFlag(const std::string& language) const;
/**
* Get a list of preprocessor define flags.
@@ -773,7 +779,7 @@ public:
* Is there a source file that has the provided source file as an output?
* if so then return it
*/
- cmSourceFile *GetSourceFileWithOutput(const char *outName) const;
+ cmSourceFile *GetSourceFileWithOutput(const std::string& outName) const;
/**
* Add a macro to the list of macros. The arguments should be name of the
@@ -782,12 +788,12 @@ public:
void AddMacro(const char* name, const char* signature);
///! Add a new cmTest to the list of tests for this makefile.
- cmTest* CreateTest(const char* testName);
+ cmTest* CreateTest(const std::string& testName);
/** Get a cmTest pointer for a given test name, if the name is
* not found, then a null pointer is returned.
*/
- cmTest* GetTest(const char* testName) const;
+ cmTest* GetTest(const std::string& testName) const;
/**
* Get a list of macros as a ; separated string
@@ -800,17 +806,19 @@ public:
std::string GetModulesFile(const char* name) const;
///! Set/Get a property of this directory
- void SetProperty(const char *prop, const char *value);
- void AppendProperty(const char *prop, const char *value,bool asString=false);
- const char *GetProperty(const char *prop) const;
- const char *GetPropertyOrDefinition(const char *prop) const;
- const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
- bool GetPropertyAsBool(const char *prop) const;
+ void SetProperty(const std::string& prop, const char *value);
+ void AppendProperty(const std::string& prop, const char *value,
+ bool asString=false);
+ const char *GetProperty(const std::string& prop) const;
+ const char *GetProperty(const std::string& prop,
+ cmProperty::ScopeType scope) const;
+ bool GetPropertyAsBool(const std::string& prop) const;
- const char* GetFeature(const char* feature, const char* config);
+ const char* GetFeature(const std::string& feature,
+ const std::string& config);
// Get the properties
- cmPropertyMap &GetProperties() { return this->Properties; };
+ cmPropertyMap &GetProperties() { return this->Properties; }
///! Initialize a makefile from its parent
void InitializeFromParent();
@@ -835,7 +843,7 @@ public:
// push and pop variable scopes
void PushScope();
void PopScope();
- void RaiseScope(const char *var, const char *value);
+ void RaiseScope(const std::string& var, const char *value);
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
@@ -872,17 +880,21 @@ public:
void AddQtUiFileWithOptions(cmSourceFile *sf);
std::vector<cmSourceFile*> GetQtUiFilesWithOptions() const;
- std::set<cmStdString> const & GetSystemIncludeDirectories() const
+ std::set<std::string> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
bool PolicyOptionalWarningEnabled(std::string const& var);
+ bool AddRequiredTargetFeature(cmTarget *target,
+ const std::string& feature,
+ std::string *error = 0) const;
+
protected:
// add link libraries and directories to the target
- void AddGlobalLinkInformation(const char* name, cmTarget& target);
+ void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
// Check for a an unused variable
- void CheckForUnused(const char* reason, const char* name) const;
+ void CheckForUnused(const char* reason, const std::string& name) const;
std::string Prefix;
std::vector<std::string> AuxSourceDirectories; //
@@ -902,14 +914,14 @@ protected:
std::vector<cmSourceFile*> SourceFiles;
// Tests
- std::map<cmStdString, cmTest*> Tests;
+ std::map<std::string, cmTest*> Tests;
// The link-library paths. Order matters, use std::vector (not std::set).
std::vector<std::string> LinkDirectories;
// The set of include directories that are marked as system include
// directories.
- std::set<cmStdString> SystemIncludeDirectories;
+ std::set<std::string> SystemIncludeDirectories;
std::vector<std::string> ListFiles; // list of command files loaded
std::vector<std::string> OutputFiles; // list of command files loaded
@@ -949,12 +961,13 @@ private:
bool ParseDefineFlag(std::string const& definition, bool remove);
- bool EnforceUniqueDir(const char* srcPath, const char* binPath) const;
+ bool EnforceUniqueDir(const std::string& srcPath,
+ const std::string& binPath) const;
friend class cmMakeDepend; // make depend needs direct access
// to the Sources array
void PrintStringVector(const char* s, const
- std::vector<std::pair<cmStdString, bool> >& v) const;
+ std::vector<std::pair<std::string, bool> >& v) const;
void PrintStringVector(const char* s,
const std::vector<std::string>& v) const;
@@ -965,10 +978,10 @@ private:
void PushFunctionBlockerBarrier();
void PopFunctionBlockerBarrier(bool reportError = true);
- typedef std::map<cmStdString, cmStdString> StringStringMap;
+ typedef std::map<std::string, std::string> StringStringMap;
StringStringMap MacrosMap;
- std::map<cmStdString, bool> SubDirectoryOrder;
+ std::map<std::string, bool> SubDirectoryOrder;
mutable cmsys::RegularExpression cmDefineRegex;
mutable cmsys::RegularExpression cmDefine01Regex;
@@ -984,7 +997,7 @@ private:
bool CheckSystemVars;
// stack of list files being read
- std::deque<cmStdString> ListFileStack;
+ std::deque<std::string> ListFileStack;
// stack of commands being invoked.
struct CallStackEntry
@@ -997,7 +1010,7 @@ private:
friend class cmMakefileCall;
std::vector<cmTarget*> ImportedTargetsOwned;
- std::map<cmStdString, cmTarget*> ImportedTargets;
+ std::map<std::string, cmTarget*> ImportedTargets;
// Internal policy stack management.
void PushPolicy(bool weak = false,
@@ -1031,12 +1044,12 @@ private:
bool GeneratingBuildSystem;
/**
- * Old version of GetSourceFileWithOutput(const char*) kept for
+ * Old version of GetSourceFileWithOutput(const std::string&) kept for
* backward-compatibility. It implements a linear search and support
* relative file paths. It is used as a fall back by
- * GetSourceFileWithOutput(const char*).
+ * GetSourceFileWithOutput(const std::string&).
*/
- cmSourceFile *LinearGetSourceFileWithOutput(const char *cname) const;
+ cmSourceFile *LinearGetSourceFileWithOutput(const std::string& cname) const;
// A map for fast output to input look up.
#if defined(CMAKE_BUILD_WITH_CMAKE)
diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx
index 69b8092..fc52ccc 100644
--- a/Source/cmMakefileExecutableTargetGenerator.cxx
+++ b/Source/cmMakefileExecutableTargetGenerator.cxx
@@ -129,7 +129,11 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
}
}
- std::string pdbOutputPath = this->Target->GetPDBDirectory();
+ std::string compilePdbOutputPath =
+ this->Target->GetCompilePDBDirectory(this->ConfigName);
+ cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+ std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
pdbOutputPath += "/";
@@ -138,32 +142,32 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string targetFullPathPDB = pdbOutputPath + targetNamePDB;
std::string targetFullPathImport = outpathImp + targetNameImport;
std::string targetOutPathPDB =
- this->Convert(targetFullPathPDB.c_str(),
+ this->Convert(targetFullPathPDB,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
// Convert to the output path to use in constructing commands.
std::string targetOutPath =
- this->Convert(targetFullPath.c_str(),
+ this->Convert(targetFullPath,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathReal =
- this->Convert(targetFullPathReal.c_str(),
+ this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathImport =
- this->Convert(targetFullPathImport.c_str(),
+ this->Convert(targetFullPathImport,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
// Get the language to use for linking this executable.
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
// Make sure we have a link language.
- if(!linkLanguage)
+ if(linkLanguage.empty())
{
cmSystemTools::Error("Cannot determine link language for target \"",
- this->Target->GetName(), "\".");
+ this->Target->GetName().c_str(), "\".");
return;
}
@@ -206,7 +210,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
export_flag_var += linkLanguage;
export_flag_var += "_FLAG";
this->LocalGenerator->AppendFlags
- (linkFlags, this->Makefile->GetDefinition(export_flag_var.c_str()));
+ (linkFlags, this->Makefile->GetDefinition(export_flag_var));
}
// Add language feature flags.
@@ -221,14 +225,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (linkFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (linkFlags, this->Target->GetProperty(linkFlagsConfig));
this->AddModuleDefinitionFlag(linkFlags);
// Construct a list of files associated with this executable that
// may need to be cleaned.
std::vector<std::string> exeCleanFiles;
- exeCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
+ exeCleanFiles.push_back(this->Convert(targetFullPath,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
#ifdef _WIN32
@@ -240,19 +244,19 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
#endif
if(targetNameReal != targetName)
{
- exeCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
+ exeCleanFiles.push_back(this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(!targetNameImport.empty())
{
- exeCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
+ exeCleanFiles.push_back(this->Convert(targetFullPathImport,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
std::string implib;
if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
{
- exeCleanFiles.push_back(this->Convert(implib.c_str(),
+ exeCleanFiles.push_back(this->Convert(implib,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
@@ -262,7 +266,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back
- (this->Convert(targetFullPathPDB.c_str(),
+ (this->Convert(targetFullPathPDB,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
@@ -285,7 +289,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
std::string linkRuleVar = "CMAKE_";
linkRuleVar += linkLanguage;
linkRuleVar += "_LINK_EXECUTABLE";
- std::string linkRule = this->GetLinkRule(linkRuleVar.c_str());
+ std::string linkRule = this->GetLinkRule(linkRuleVar);
std::vector<std::string> commands1;
cmSystemTools::ExpandListArgument(linkRule, real_link_commands);
if(this->Target->IsExecutableWithExports())
@@ -296,54 +300,71 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
implibRuleVar += linkLanguage;
implibRuleVar += "_CREATE_IMPORT_LIBRARY";
if(const char* rule =
- this->Makefile->GetDefinition(implibRuleVar.c_str()))
+ this->Makefile->GetDefinition(implibRuleVar))
{
cmSystemTools::ExpandListArgument(rule, real_link_commands);
}
}
// Select whether to use a response file for objects.
- bool useResponseFile = false;
+ bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
- if(this->Makefile->IsOn(responseVar.c_str()))
+ if(this->Makefile->IsOn(responseVar))
+ {
+ useResponseFileForObjects = true;
+ }
+ }
+
+ // Select whether to use a response file for libraries.
+ bool useResponseFileForLibs = false;
+ {
+ std::string responseVar = "CMAKE_";
+ responseVar += linkLanguage;
+ responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+ if(this->Makefile->IsOn(responseVar))
{
- useResponseFile = true;
+ useResponseFileForLibs = true;
}
}
// Expand the rule variables.
{
+ bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
// Collect up flags to link in needed libraries.
std::string linkLibs;
- std::string frameworkPath;
- std::string linkPath;
- this->LocalGenerator->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *this->GeneratorTarget,
- relink);
- linkLibs = frameworkPath + linkPath + linkLibs;
+ this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+ useWatcomQuote);
+
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
- this->CreateObjectLists(useLinkScript, false, useResponseFile,
- buildObjs, depends);
+ this->CreateObjectLists(useLinkScript, false,
+ useResponseFileForObjects, buildObjs, depends,
+ useWatcomQuote);
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->Target;
- vars.Language = linkLanguage;
+ vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str();
std::string objectDir = this->Target->GetSupportDirectory();
- objectDir = this->Convert(objectDir.c_str(),
+ objectDir = this->Convert(objectDir,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str();
- vars.Target = targetOutPathReal.c_str();
+ cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+ cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+ std::string target = this->Convert(targetFullPathReal,
+ cmLocalGenerator::START_OUTPUT,
+ output);
+ vars.Target = target.c_str();
vars.TargetPDB = targetOutPathPDB.c_str();
// Setup the target version.
@@ -425,7 +446,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
// Write the build rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream,
0,
- targetFullPathReal.c_str(),
+ targetFullPathReal,
depends, commands, false);
// The symlink name for the target should depend on the real target
@@ -435,14 +456,14 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
{
depends.clear();
commands.clear();
- depends.push_back(targetFullPathReal.c_str());
+ depends.push_back(targetFullPathReal);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- targetFullPath.c_str(),
+ targetFullPath,
depends, commands, false);
}
// Write the main driver rule to build everything in this target.
- this->WriteTargetDriverRule(targetFullPath.c_str(), relink);
+ this->WriteTargetDriverRule(targetFullPath, relink);
// Clean all the possible executable names and symlinks.
this->CleanFiles.insert(this->CleanFiles.end(),
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index d6a0cd4..7ac0256 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -131,17 +131,14 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules()
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
{
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_STATIC_LIBRARY";
if(this->GetFeatureAsBool("INTERPROCEDURAL_OPTIMIZATION") &&
- this->Makefile->GetDefinition((linkRuleVar+"_IPO").c_str()))
+ this->Makefile->GetDefinition(linkRuleVar+"_IPO"))
{
linkRuleVar += "_IPO";
}
@@ -149,7 +146,7 @@ void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules()
std::string extraFlags;
this->LocalGenerator->GetStaticLibraryFlags(extraFlags,
cmSystemTools::UpperCase(this->ConfigName), this->Target);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), false);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, false);
}
//----------------------------------------------------------------------------
@@ -160,13 +157,10 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
this->WriteFrameworkRules(relink);
return;
}
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_SHARED_LIBRARY";
std::string extraFlags;
@@ -175,25 +169,22 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (extraFlags, this->Target->GetProperty(linkFlagsConfig));
this->LocalGenerator->AddConfigVariableFlags
(extraFlags, "CMAKE_SHARED_LINKER_FLAGS", this->ConfigName);
this->AddModuleDefinitionFlag(extraFlags);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
}
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
{
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_SHARED_MODULE";
std::string extraFlags;
@@ -202,24 +193,21 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (extraFlags, this->Target->GetProperty(linkFlagsConfig));
this->LocalGenerator->AddConfigVariableFlags
(extraFlags, "CMAKE_MODULE_LINKER_FLAGS", this->ConfigName);
this->AddModuleDefinitionFlag(extraFlags);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
}
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
{
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
std::string linkRuleVar = "CMAKE_";
- if (linkLanguage)
- {
- linkRuleVar += linkLanguage;
- }
+ linkRuleVar += linkLanguage;
linkRuleVar += "_CREATE_MACOSX_FRAMEWORK";
std::string extraFlags;
@@ -228,16 +216,16 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink)
std::string linkFlagsConfig = "LINK_FLAGS_";
linkFlagsConfig += cmSystemTools::UpperCase(this->ConfigName);
this->LocalGenerator->AppendFlags
- (extraFlags, this->Target->GetProperty(linkFlagsConfig.c_str()));
+ (extraFlags, this->Target->GetProperty(linkFlagsConfig));
this->LocalGenerator->AddConfigVariableFlags
(extraFlags, "CMAKE_MACOSX_FRAMEWORK_LINKER_FLAGS", this->ConfigName);
- this->WriteLibraryRules(linkRuleVar.c_str(), extraFlags.c_str(), relink);
+ this->WriteLibraryRules(linkRuleVar, extraFlags, relink);
}
//----------------------------------------------------------------------------
void cmMakefileLibraryTargetGenerator::WriteLibraryRules
-(const char* linkRuleVar, const char* extraFlags, bool relink)
+(const std::string& linkRuleVar, const std::string& extraFlags, bool relink)
{
// TODO: Merge the methods that call this method to avoid
// code duplication.
@@ -248,20 +236,20 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
this->AppendLinkDepends(depends);
// Get the language to use for linking this library.
- const char* linkLanguage =
+ std::string linkLanguage =
this->Target->GetLinkerLanguage(this->ConfigName);
// Make sure we have a link language.
- if(!linkLanguage)
+ if(linkLanguage.empty())
{
cmSystemTools::Error("Cannot determine link language for target \"",
- this->Target->GetName(), "\".");
+ this->Target->GetName().c_str(), "\".");
return;
}
// Create set of linking flags.
std::string linkFlags;
- this->LocalGenerator->AppendFlags(linkFlags, extraFlags);
+ this->LocalGenerator->AppendFlags(linkFlags, extraFlags.c_str());
// Add OSX version flags, if any.
if(this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -321,7 +309,11 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
}
- std::string pdbOutputPath = this->Target->GetPDBDirectory();
+ std::string compilePdbOutputPath =
+ this->Target->GetCompilePDBDirectory(this->ConfigName);
+ cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str());
+
+ std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName);
cmSystemTools::MakeDirectory(pdbOutputPath.c_str());
pdbOutputPath += "/";
@@ -334,19 +326,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Construct the output path version of the names for use in command
// arguments.
std::string targetOutPathPDB =
- this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
+ this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
std::string targetOutPath =
- this->Convert(targetFullPath.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPath,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathSO =
- this->Convert(targetFullPathSO.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPathSO,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathReal =
- this->Convert(targetFullPathReal.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPathReal,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
std::string targetOutPathImport =
- this->Convert(targetFullPathImport.c_str(),cmLocalGenerator::START_OUTPUT,
+ this->Convert(targetFullPathImport,cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
if(!this->NoRuleMessages)
@@ -390,31 +382,31 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Clean files associated with this library.
std::vector<std::string> libCleanFiles;
- libCleanFiles.push_back(this->Convert(targetFullPath.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPath,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
if(targetNameReal != targetName)
{
- libCleanFiles.push_back(this->Convert(targetFullPathReal.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(targetNameSO != targetName &&
targetNameSO != targetNameReal)
{
- libCleanFiles.push_back(this->Convert(targetFullPathSO.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPathSO,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
if(!targetNameImport.empty())
{
- libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
+ libCleanFiles.push_back(this->Convert(targetFullPathImport,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
std::string implib;
if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib))
{
- libCleanFiles.push_back(this->Convert(implib.c_str(),
+ libCleanFiles.push_back(this->Convert(implib,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
@@ -424,7 +416,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// cleaned. We do not want to delete the .pdb file just before
// linking the target.
this->CleanFiles.push_back
- (this->Convert(targetFullPathPDB.c_str(),
+ (this->Convert(targetFullPathPDB,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
@@ -470,14 +462,26 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
bool useLinkScript = this->GlobalGenerator->GetUseLinkScript();
// Select whether to use a response file for objects.
- bool useResponseFile = false;
+ bool useResponseFileForObjects = false;
{
std::string responseVar = "CMAKE_";
responseVar += linkLanguage;
responseVar += "_USE_RESPONSE_FILE_FOR_OBJECTS";
- if(this->Makefile->IsOn(responseVar.c_str()))
+ if(this->Makefile->IsOn(responseVar))
{
- useResponseFile = true;
+ useResponseFileForObjects = true;
+ }
+ }
+
+ // Select whether to use a response file for libraries.
+ bool useResponseFileForLibs = false;
+ {
+ std::string responseVar = "CMAKE_";
+ responseVar += linkLanguage;
+ responseVar += "_USE_RESPONSE_FILE_FOR_LIBRARIES";
+ if(this->Makefile->IsOn(responseVar))
+ {
+ useResponseFileForLibs = true;
}
}
@@ -494,21 +498,21 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string arCreateVar = "CMAKE_";
arCreateVar += linkLanguage;
arCreateVar += "_ARCHIVE_CREATE";
- if(const char* rule = this->Makefile->GetDefinition(arCreateVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(arCreateVar))
{
cmSystemTools::ExpandListArgument(rule, archiveCreateCommands);
}
std::string arAppendVar = "CMAKE_";
arAppendVar += linkLanguage;
arAppendVar += "_ARCHIVE_APPEND";
- if(const char* rule = this->Makefile->GetDefinition(arAppendVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(arAppendVar))
{
cmSystemTools::ExpandListArgument(rule, archiveAppendCommands);
}
std::string arFinishVar = "CMAKE_";
arFinishVar += linkLanguage;
arFinishVar += "_ARCHIVE_FINISH";
- if(const char* rule = this->Makefile->GetDefinition(arFinishVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(arFinishVar))
{
cmSystemTools::ExpandListArgument(rule, archiveFinishCommands);
}
@@ -524,7 +528,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
useLinkScript = true;
// Archiving rules never use a response file.
- useResponseFile = false;
+ useResponseFileForObjects = false;
// Limit the length of individual object lists to less than the
// 32K command line length limit on Windows. We could make this a
@@ -535,6 +539,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Expand the rule variables.
std::vector<std::string> real_link_commands;
{
+ bool useWatcomQuote = this->Makefile->IsOn(linkRuleVar+"_USE_WATCOM_QUOTE");
+
// Set path conversion for link script shells.
this->LocalGenerator->SetLinkScriptShell(useLinkScript);
@@ -542,19 +548,16 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
std::string linkLibs;
if(this->Target->GetType() != cmTarget::STATIC_LIBRARY)
{
- std::string frameworkPath;
- std::string linkPath;
- this->LocalGenerator
- ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
- *this->GeneratorTarget, relink);
- linkLibs = frameworkPath + linkPath + linkLibs;
+ this->CreateLinkLibs(linkLibs, relink, useResponseFileForLibs, depends,
+ useWatcomQuote);
}
// Construct object file lists that may be needed to expand the
// rule.
std::string buildObjs;
- this->CreateObjectLists(useLinkScript, useArchiveRules, useResponseFile,
- buildObjs, depends);
+ this->CreateObjectLists(useLinkScript, useArchiveRules,
+ useResponseFileForObjects, buildObjs, depends,
+ useWatcomQuote);
cmLocalGenerator::RuleVariables vars;
vars.TargetPDB = targetOutPathPDB.c_str();
@@ -578,14 +581,19 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->Target;
- vars.Language = linkLanguage;
+ vars.Language = linkLanguage.c_str();
vars.Objects = buildObjs.c_str();
std::string objectDir = this->Target->GetSupportDirectory();
- objectDir = this->Convert(objectDir.c_str(),
+ objectDir = this->Convert(objectDir,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str();
- vars.Target = targetOutPathReal.c_str();
+ cmLocalGenerator::OutputFormat output = (useWatcomQuote) ?
+ cmLocalGenerator::WATCOMQUOTE : cmLocalGenerator::SHELL;
+ std::string target = this->Convert(targetFullPathReal,
+ cmLocalGenerator::START_OUTPUT,
+ output);
+ vars.Target = target.c_str();
vars.LinkLibraries = linkLibs.c_str();
vars.ObjectsQuoted = buildObjs.c_str();
if (this->Target->HasSOName(this->ConfigName))
@@ -612,7 +620,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
{
// Convert to a path for the native build tool.
install_name_dir =
- this->LocalGenerator->Convert(install_name_dir.c_str(),
+ this->LocalGenerator->Convert(install_name_dir,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL, false);
vars.TargetInstallNameDir = install_name_dir.c_str();
@@ -746,7 +754,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
// Write the build rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- targetFullPathReal.c_str(),
+ targetFullPathReal,
depends, commands, false);
// Some targets have more than one output file. Create rules to
@@ -765,7 +773,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
}
// Write the main driver rule to build everything in this target.
- this->WriteTargetDriverRule(targetFullPath.c_str(), relink);
+ this->WriteTargetDriverRule(targetFullPath, relink);
// Clean all the possible library names and symlinks.
this->CleanFiles.insert(this->CleanFiles.end(),
@@ -775,7 +783,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules
//----------------------------------------------------------------------------
void
cmMakefileLibraryTargetGenerator
-::AppendOSXVerFlag(std::string& flags, const char* lang,
+::AppendOSXVerFlag(std::string& flags, const std::string& lang,
const char* name, bool so)
{
// Lookup the flag to specify the version.
@@ -784,7 +792,7 @@ cmMakefileLibraryTargetGenerator
fvar += "_OSX_";
fvar += name;
fvar += "_VERSION_FLAG";
- const char* flag = this->Makefile->GetDefinition(fvar.c_str());
+ const char* flag = this->Makefile->GetDefinition(fvar);
// Skip if no such flag.
if(!flag)
diff --git a/Source/cmMakefileLibraryTargetGenerator.h b/Source/cmMakefileLibraryTargetGenerator.h
index 1487b56..68980c3 100644
--- a/Source/cmMakefileLibraryTargetGenerator.h
+++ b/Source/cmMakefileLibraryTargetGenerator.h
@@ -30,7 +30,8 @@ protected:
void WriteStaticLibraryRules();
void WriteSharedLibraryRules(bool relink);
void WriteModuleLibraryRules(bool relink);
- void WriteLibraryRules(const char *linkRule, const char *extraFlags,
+ void WriteLibraryRules(const std::string& linkRule,
+ const std::string& extraFlags,
bool relink);
// MacOSX Framework support methods
void WriteFrameworkRules(bool relink);
@@ -38,7 +39,7 @@ protected:
// Store the computd framework version for OS X Frameworks.
std::string FrameworkVersion;
- void AppendOSXVerFlag(std::string& flags, const char* lang,
+ void AppendOSXVerFlag(std::string& flags, const std::string& lang,
const char* name, bool so);
};
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index c3ca85d..d4723ad 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -21,6 +21,7 @@
#include "cmTarget.h"
#include "cmake.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommandGenerator.h"
#include "cmGeneratorExpression.h"
#include "cmMakefileExecutableTargetGenerator.h"
@@ -127,13 +128,15 @@ void cmMakefileTargetGenerator::CreateRuleFile()
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::WriteTargetBuildRules()
{
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+
// write the custom commands for this target
// Look for files registered for cleaning in this directory.
if(const char* additional_clean_files =
this->Makefile->GetProperty
("ADDITIONAL_MAKE_CLEAN_FILES"))
{
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
cmListFileBacktrace lfbt;
cmGeneratorExpression ge(lfbt);
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
@@ -151,56 +154,55 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// First generate the object rule files. Save a list of all object
// files for this target.
- std::vector<cmSourceFile*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
- cmCustomCommand const* cc = (*si)->GetCustomCommand();
- this->GenerateCustomRuleFile(*cc);
+ cmCustomCommandGenerator ccg(*(*si)->GetCustomCommand(),
+ this->ConfigName,
+ this->Makefile);
+ this->GenerateCustomRuleFile(ccg);
if (clean)
{
- const std::vector<std::string>& outputs = cc->GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
for(std::vector<std::string>::const_iterator o = outputs.begin();
o != outputs.end(); ++o)
{
this->CleanFiles.push_back
- (this->Convert(o->c_str(),
+ (this->Convert(*o,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::UNCHANGED));
}
}
}
- std::vector<cmSourceFile*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources);
+ std::vector<cmSourceFile const*> headerSources;
+ this->GeneratorTarget->GetHeaderSources(headerSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources,
this->MacOSXContentGenerator);
- std::vector<cmSourceFile*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources);
+ std::vector<cmSourceFile const*> extraSources;
+ this->GeneratorTarget->GetExtraSources(extraSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources,
this->MacOSXContentGenerator);
- std::vector<cmSourceFile*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> externalObjects;
+ this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
this->ExternalObjects.push_back((*si)->GetFullPath());
}
- std::vector<cmSourceFile*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> objectSources;
+ this->GeneratorTarget->GetObjectSources(objectSources, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si)
{
// Generate this object file's rule file.
this->WriteObjectRuleFiles(**si);
}
-
- // Add object library contents as external objects.
- this->GeneratorTarget->UseObjectLibraries(this->ExternalObjects);
}
//----------------------------------------------------------------------------
@@ -215,7 +217,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
*this->BuildFileStream
<< "# Include any dependencies generated for this target.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(dependFileNameFull.c_str(),
+ << this->Convert(dependFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
@@ -226,7 +228,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
*this->BuildFileStream
<< "# Include the progress variables for this target.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(this->ProgressFileNameFull.c_str(),
+ << this->Convert(this->ProgressFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
@@ -259,7 +261,7 @@ void cmMakefileTargetGenerator::WriteCommonCodeRules()
*this->BuildFileStream
<< "# Include the compile flags for this target's objects.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(this->FlagFileNameFull.c_str(),
+ << this->Convert(this->FlagFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
@@ -328,7 +330,7 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
// Add preprocessor definitions for this target and configuration.
this->LocalGenerator->AddCompileDefinitions(defines, this->Target,
- this->LocalGenerator->ConfigurationName.c_str());
+ this->LocalGenerator->ConfigurationName);
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString, lang);
@@ -342,21 +344,22 @@ std::string cmMakefileTargetGenerator::GetDefines(const std::string &l)
void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
{
// write language flags for target
- std::set<cmStdString> languages;
- this->Target->GetLanguages(languages);
+ std::set<std::string> languages;
+ this->Target->GetLanguages(languages,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
// put the compiler in the rules.make file so that if it changes
// things rebuild
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
- cmStdString compiler = "CMAKE_";
+ std::string compiler = "CMAKE_";
compiler += *l;
compiler += "_COMPILER";
- *this->FlagFileStream << "# compile " << l->c_str() << " with " <<
- this->Makefile->GetSafeDefinition(compiler.c_str()) << "\n";
+ *this->FlagFileStream << "# compile " << *l << " with " <<
+ this->Makefile->GetSafeDefinition(compiler) << "\n";
}
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end(); ++l)
{
*this->FlagFileStream << *l << "_FLAGS = " << this->GetFlags(*l) << "\n\n";
@@ -369,7 +372,7 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
- (cmSourceFile& source, const char* pkgloc)
+ (cmSourceFile const& source, const char* pkgloc)
{
// Skip OS X content when not building a Framework or Bundle.
if(!this->Generator->GetTarget()->IsBundleOnApple())
@@ -388,9 +391,9 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
output += "/";
output += cmSystemTools::GetFilenameName(input);
this->Generator->CleanFiles.push_back(
- this->Generator->Convert(output.c_str(),
+ this->Generator->Convert(output,
cmLocalGenerator::START_OUTPUT));
- output = this->Generator->Convert(output.c_str(),
+ output = this->Generator->Convert(output,
cmLocalGenerator::HOME_OUTPUT);
// Create a rule to copy the content into the bundle.
@@ -403,27 +406,29 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator()
commands, copyEcho.c_str(),
cmLocalUnixMakefileGenerator3::EchoBuild);
std::string copyCommand = "$(CMAKE_COMMAND) -E copy ";
- copyCommand += this->Generator->Convert(input.c_str(),
+ copyCommand += this->Generator->Convert(input,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
copyCommand += " ";
- copyCommand += this->Generator->Convert(output.c_str(),
+ copyCommand += this->Generator->Convert(output,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
commands.push_back(copyCommand);
this->Generator->LocalGenerator->WriteMakeRule(
*this->Generator->BuildFileStream, 0,
- output.c_str(),
+ output,
depends, commands, false);
this->Generator->ExtraFiles.insert(output);
}
//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
+void cmMakefileTargetGenerator
+::WriteObjectRuleFiles(cmSourceFile const& source)
{
// Identify the language of the source file.
- const char* lang = this->LocalGenerator->GetSourceFileLanguage(source);
- if(!lang)
+ const std::string& lang =
+ this->LocalGenerator->GetSourceFileLanguage(source);
+ if(lang.empty())
{
// don't know anything about this file so skip it
return;
@@ -455,7 +460,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
// Create the directory containing the object file. This may be a
// subdirectory under the target's directory.
- std::string dir = cmSystemTools::GetFilenamePath(obj.c_str());
+ std::string dir = cmSystemTools::GetFilenamePath(obj);
cmSystemTools::MakeDirectory
(this->LocalGenerator->ConvertToFullPath(dir).c_str());
@@ -481,9 +486,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
objFullPath += "/";
objFullPath += obj;
objFullPath =
- this->Convert(objFullPath.c_str(), cmLocalGenerator::FULL);
+ this->Convert(objFullPath, cmLocalGenerator::FULL);
std::string srcFullPath =
- this->Convert(source.GetFullPath().c_str(), cmLocalGenerator::FULL);
+ this->Convert(source.GetFullPath(), cmLocalGenerator::FULL);
this->LocalGenerator->
AddImplicitDepends(*this->Target, lang,
objFullPath.c_str(),
@@ -493,7 +498,7 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(cmSourceFile& source)
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
-::AppendFortranFormatFlags(std::string& flags, cmSourceFile& source)
+::AppendFortranFormatFlags(std::string& flags, cmSourceFile const& source)
{
const char* srcfmt = source.GetProperty("Fortran_FORMAT");
cmLocalGenerator::FortranFormat format =
@@ -523,8 +528,8 @@ cmMakefileTargetGenerator
void
cmMakefileTargetGenerator
::WriteObjectBuildFile(std::string &obj,
- const char *lang,
- cmSourceFile& source,
+ const std::string& lang,
+ cmSourceFile const& source,
std::vector<std::string>& depends)
{
this->LocalGenerator->AppendRuleDepend(depends,
@@ -552,7 +557,7 @@ cmMakefileTargetGenerator
cmSystemTools::UpperCase(this->LocalGenerator->ConfigurationName);
// Add Fortran format flags.
- if(strcmp(lang, "Fortran") == 0)
+ if(lang == "Fortran")
{
this->AppendFortranFormatFlags(flags, source);
}
@@ -584,7 +589,7 @@ cmMakefileTargetGenerator
std::string defPropName = "COMPILE_DEFINITIONS_";
defPropName += configUpper;
if(const char* config_compile_defs =
- source.GetProperty(defPropName.c_str()))
+ source.GetProperty(defPropName))
{
this->LocalGenerator->AppendDefines(defines, config_compile_defs);
*this->FlagFileStream
@@ -598,10 +603,10 @@ cmMakefileTargetGenerator
std::string sourceFile = source.GetFullPath();
if(this->LocalGenerator->UseRelativePaths)
{
- sourceFile = this->Convert(sourceFile.c_str(),
+ sourceFile = this->Convert(sourceFile,
cmLocalGenerator::START_OUTPUT);
}
- sourceFile = this->Convert(sourceFile.c_str(),
+ sourceFile = this->Convert(sourceFile,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
@@ -624,9 +629,11 @@ cmMakefileTargetGenerator
std::string targetOutPathReal;
std::string targetOutPathPDB;
+ std::string targetOutPathCompilePDB;
{
std::string targetFullPathReal;
std::string targetFullPathPDB;
+ std::string targetFullPathCompilePDB;
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -638,27 +645,42 @@ cmMakefileTargetGenerator
targetFullPathPDB += "/";
targetFullPathPDB += this->Target->GetPDBName(this->ConfigName);
}
- targetOutPathReal = this->Convert(targetFullPathReal.c_str(),
+ if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ targetFullPathCompilePDB =
+ this->Target->GetCompilePDBPath(this->ConfigName);
+ if(targetFullPathCompilePDB.empty())
+ {
+ targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/";
+ }
+ }
+
+ targetOutPathReal = this->Convert(targetFullPathReal,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
targetOutPathPDB =
- this->Convert(targetFullPathPDB.c_str(),cmLocalGenerator::NONE,
+ this->Convert(targetFullPathPDB,cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL);
+ targetOutPathCompilePDB =
+ this->Convert(targetFullPathCompilePDB,
+ cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
}
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_COMPILE";
vars.CMTarget = this->Target;
- vars.Language = lang;
+ vars.Language = lang.c_str();
vars.Target = targetOutPathReal.c_str();
vars.TargetPDB = targetOutPathPDB.c_str();
+ vars.TargetCompilePDB = targetOutPathCompilePDB.c_str();
vars.Source = sourceFile.c_str();
std::string shellObj =
- this->Convert(obj.c_str(),
+ this->Convert(obj,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL).c_str();
+ cmLocalGenerator::SHELL);
vars.Object = shellObj.c_str();
std::string objectDir = this->Target->GetSupportDirectory();
- objectDir = this->Convert(objectDir.c_str(),
+ objectDir = this->Convert(objectDir,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
vars.ObjectDir = objectDir.c_str();
@@ -672,8 +694,7 @@ cmMakefileTargetGenerator
vars.Defines = definesString.c_str();
- bool lang_is_c_or_cxx = ((strcmp(lang, "C") == 0) ||
- (strcmp(lang, "CXX") == 0));
+ bool lang_is_c_or_cxx = ((lang == "C") || (lang == "CXX"));
// Construct the compile rules.
{
@@ -681,7 +702,7 @@ cmMakefileTargetGenerator
compileRuleVar += lang;
compileRuleVar += "_COMPILE_OBJECT";
std::string compileRule =
- this->Makefile->GetRequiredDefinition(compileRuleVar.c_str());
+ this->Makefile->GetRequiredDefinition(compileRuleVar);
std::vector<std::string> compileCommands;
cmSystemTools::ExpandListArgument(compileRule, compileCommands);
@@ -720,7 +741,7 @@ cmMakefileTargetGenerator
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObj.c_str(),
+ relativeObj,
depends, commands, false);
// Check for extra outputs created by the compilation.
@@ -738,7 +759,7 @@ cmMakefileTargetGenerator
this->GenerateExtraOutput(eoi->c_str(), relativeObj.c_str(), false);
// Register this as an extra file to clean.
- this->CleanFiles.push_back(eoi->c_str());
+ this->CleanFiles.push_back(*eoi);
}
}
@@ -774,15 +795,15 @@ cmMakefileTargetGenerator
preprocessRuleVar += lang;
preprocessRuleVar += "_CREATE_PREPROCESSED_SOURCE";
if(const char* preprocessRule =
- this->Makefile->GetDefinition(preprocessRuleVar.c_str()))
+ this->Makefile->GetDefinition(preprocessRuleVar))
{
std::vector<std::string> preprocessCommands;
cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands);
std::string shellObjI =
- this->Convert(objI.c_str(),
+ this->Convert(objI,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL).c_str();
+ cmLocalGenerator::SHELL);
vars.PreprocessedSource = shellObjI.c_str();
// Expand placeholders in the commands.
@@ -808,7 +829,7 @@ cmMakefileTargetGenerator
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObjI.c_str(),
+ relativeObjI,
force_depends, commands, false);
}
@@ -831,15 +852,15 @@ cmMakefileTargetGenerator
assemblyRuleVar += lang;
assemblyRuleVar += "_CREATE_ASSEMBLY_SOURCE";
if(const char* assemblyRule =
- this->Makefile->GetDefinition(assemblyRuleVar.c_str()))
+ this->Makefile->GetDefinition(assemblyRuleVar))
{
std::vector<std::string> assemblyCommands;
cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands);
std::string shellObjS =
- this->Convert(objS.c_str(),
+ this->Convert(objS,
cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL).c_str();
+ cmLocalGenerator::SHELL);
vars.AssemblySource = shellObjS.c_str();
// Expand placeholders in the commands.
@@ -865,7 +886,7 @@ cmMakefileTargetGenerator
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- relativeObjS.c_str(),
+ relativeObjS,
force_depends, commands, false);
}
}
@@ -877,7 +898,7 @@ cmMakefileTargetGenerator
std::vector<std::string> p_depends;
// always provide an empty requires target
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- objectRequires.c_str(), p_depends,
+ objectRequires, p_depends,
no_commands, true);
// write a build rule to recursively build what this obj provides
@@ -891,19 +912,19 @@ cmMakefileTargetGenerator
tgtMakefileName += "/build.make";
r_commands.push_back
(this->LocalGenerator->GetRecursiveMakeCall(tgtMakefileName.c_str(),
- temp.c_str()));
+ temp));
p_depends.clear();
p_depends.push_back(objectRequires);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- objectProvides.c_str(), p_depends,
+ objectProvides, p_depends,
r_commands, true);
// write the provides.build rule dependency on the obj file
p_depends.clear();
p_depends.push_back(relativeObj);
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- temp.c_str(), p_depends, no_commands,
+ temp, p_depends, no_commands,
false);
}
@@ -932,7 +953,7 @@ void cmMakefileTargetGenerator::WriteTargetRequiresRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- depTarget.c_str(),
+ depTarget,
depends, no_commands, true);
}
@@ -957,7 +978,7 @@ void cmMakefileTargetGenerator::WriteTargetCleanRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- cleanTarget.c_str(),
+ cleanTarget,
depends, commands, true);
}
@@ -993,8 +1014,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
pi != this->MultipleOutputPairs.end(); ++pi)
{
*this->InfoFileStream
- << " " << this->LocalGenerator->EscapeForCMake(pi->first.c_str())
- << " " << this->LocalGenerator->EscapeForCMake(pi->second.c_str())
+ << " " << this->LocalGenerator->EscapeForCMake(pi->first)
+ << " " << this->LocalGenerator->EscapeForCMake(pi->second)
<< "\n";
}
*this->InfoFileStream << " )\n\n";
@@ -1053,7 +1074,8 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< "set(CMAKE_C_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
"C", config);
@@ -1062,7 +1084,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
{
*this->InfoFileStream
<< " \""
- << this->LocalGenerator->Convert(i->c_str(),
+ << this->LocalGenerator->Convert(*i,
cmLocalGenerator::HOME_OUTPUT)
<< "\"\n";
}
@@ -1126,7 +1148,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
<< this->Convert(this->Makefile->GetStartOutputDirectory(),
cmLocalGenerator::FULL, cmLocalGenerator::SHELL)
<< " "
- << this->Convert(this->InfoFileNameFull.c_str(),
+ << this->Convert(this->InfoFileNameFull,
cmLocalGenerator::FULL, cmLocalGenerator::SHELL);
if(this->LocalGenerator->GetColorMakefile())
{
@@ -1142,7 +1164,7 @@ void cmMakefileTargetGenerator::WriteTargetDependRules()
// Write the rule.
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- depTarget.c_str(),
+ depTarget,
depends, commands, true);
}
@@ -1153,13 +1175,15 @@ cmMakefileTargetGenerator
{
// Depend on all custom command outputs.
std::vector<cmSourceFile*> sources;
- this->Target->GetSourceFiles(sources);
+ this->Target->GetSourceFiles(sources,
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source)
{
if(cmCustomCommand* cc = (*source)->GetCustomCommand())
{
- const std::vector<std::string>& outputs = cc->GetOutputs();
+ 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)
{
@@ -1171,7 +1195,7 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator
-::WriteObjectDependRules(cmSourceFile& source,
+::WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends)
{
// Create the list of dependencies known at cmake time. These are
@@ -1184,18 +1208,18 @@ void cmMakefileTargetGenerator
for(std::vector<std::string>::iterator i = deps.begin();
i != deps.end(); ++i)
{
- depends.push_back(i->c_str());
+ depends.push_back(*i);
}
}
}
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator
-::GenerateCustomRuleFile(const cmCustomCommand& cc)
+::GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg)
{
// Collect the commands.
std::vector<std::string> commands;
- std::string comment = this->LocalGenerator->ConstructComment(cc);
+ std::string comment = this->LocalGenerator->ConstructComment(ccg);
if(!comment.empty())
{
// add in a progress call if needed
@@ -1210,37 +1234,37 @@ void cmMakefileTargetGenerator
// Now append the actual user-specified commands.
cmOStringStream content;
- this->LocalGenerator->AppendCustomCommand(commands, cc, this->Target, false,
+ this->LocalGenerator->AppendCustomCommand(commands, ccg, this->Target, false,
cmLocalGenerator::HOME_OUTPUT,
&content);
// Collect the dependencies.
std::vector<std::string> depends;
- this->LocalGenerator->AppendCustomDepend(depends, cc);
+ this->LocalGenerator->AppendCustomDepend(depends, ccg);
// Check whether we need to bother checking for a symbolic output.
bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
// Write the rule.
- const std::vector<std::string>& outputs = cc.GetOutputs();
+ const std::vector<std::string>& outputs = ccg.GetOutputs();
std::vector<std::string>::const_iterator o = outputs.begin();
{
bool symbolic = false;
if(need_symbolic)
{
- if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
+ if(cmSourceFile* sf = this->Makefile->GetSource(*o))
{
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
- o->c_str(), depends, commands,
+ *o, depends, commands,
symbolic);
// If the rule has changed make sure the output is rebuilt.
if(!symbolic)
{
- this->GlobalGenerator->AddRuleHash(cc.GetOutputs(), content.str());
+ this->GlobalGenerator->AddRuleHash(ccg.GetOutputs(), content.str());
}
}
@@ -1251,7 +1275,7 @@ void cmMakefileTargetGenerator
bool symbolic = false;
if(need_symbolic)
{
- if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
+ if(cmSourceFile* sf = this->Makefile->GetSource(*o))
{
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
@@ -1261,15 +1285,15 @@ void cmMakefileTargetGenerator
// Setup implicit dependency scanning.
for(cmCustomCommand::ImplicitDependsList::const_iterator
- idi = cc.GetImplicitDepends().begin();
- idi != cc.GetImplicitDepends().end(); ++idi)
+ idi = ccg.GetCC().GetImplicitDepends().begin();
+ idi != ccg.GetCC().GetImplicitDepends().end(); ++idi)
{
std::string objFullPath =
- this->Convert(outputs[0].c_str(), cmLocalGenerator::FULL);
+ this->Convert(outputs[0], cmLocalGenerator::FULL);
std::string srcFullPath =
- this->Convert(idi->second.c_str(), cmLocalGenerator::FULL);
+ this->Convert(idi->second, cmLocalGenerator::FULL);
this->LocalGenerator->
- AddImplicitDepends(*this->Target, idi->first.c_str(),
+ AddImplicitDepends(*this->Target, idi->first,
objFullPath.c_str(),
srcFullPath.c_str());
}
@@ -1314,7 +1338,7 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
progressDir += cmake::GetCMakeFilesDirectory();
cmOStringStream progCmd;
progCmd << "$(CMAKE_COMMAND) -E cmake_progress_report ";
- progCmd << this->LocalGenerator->Convert(progressDir.c_str(),
+ progCmd << this->LocalGenerator->Convert(progressDir,
cmLocalGenerator::FULL,
cmLocalGenerator::SHELL);
progCmd << " $(CMAKE_PROGRESS_" << this->NumberOfProgressActions << ")";
@@ -1325,7 +1349,8 @@ cmMakefileTargetGenerator::AppendProgress(std::vector<std::string>& commands)
void
cmMakefileTargetGenerator
::WriteObjectsVariable(std::string& variableName,
- std::string& variableNameExternal)
+ std::string& variableNameExternal,
+ bool useWatcomQuote)
{
// Write a make variable assignment that lists all objects for the
// target.
@@ -1334,10 +1359,8 @@ cmMakefileTargetGenerator
"_OBJECTS");
*this->BuildFileStream
<< "# Object files for target " << this->Target->GetName() << "\n"
- << variableName.c_str() << " =";
+ << variableName << " =";
std::string object;
- const char* objName =
- this->Makefile->GetDefinition("CMAKE_NO_QUOTED_OBJECTS");
const char* lineContinue =
this->Makefile->GetDefinition("CMAKE_MAKE_LINE_CONTINUE");
if(!lineContinue)
@@ -1348,17 +1371,9 @@ cmMakefileTargetGenerator
i != this->Objects.end(); ++i)
{
*this->BuildFileStream << " " << lineContinue << "\n";
- if(objName)
- {
- *this->BuildFileStream <<
- this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::MAKEFILE);
- }
- else
- {
- *this->BuildFileStream <<
- this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
- }
+ *this->BuildFileStream <<
+ this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
+ useWatcomQuote);
}
*this->BuildFileStream << "\n";
@@ -1371,26 +1386,18 @@ cmMakefileTargetGenerator
<< "\n"
<< "# External object files for target "
<< this->Target->GetName() << "\n"
- << variableNameExternal.c_str() << " =";
+ << variableNameExternal << " =";
for(std::vector<std::string>::const_iterator i =
this->ExternalObjects.begin();
i != this->ExternalObjects.end(); ++i)
{
- object = this->Convert(i->c_str(),cmLocalGenerator::START_OUTPUT);
+ object = this->Convert(*i,cmLocalGenerator::START_OUTPUT);
*this->BuildFileStream
<< " " << lineContinue << "\n"
<< this->Makefile->GetSafeDefinition("CMAKE_OBJECT_NAME");
- if(objName)
- {
- *this->BuildFileStream <<
- this->Convert(i->c_str(), cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::MAKEFILE);
- }
- else
- {
- *this->BuildFileStream <<
- this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str());
- }
+ *this->BuildFileStream <<
+ this->LocalGenerator->ConvertToQuotedOutputPath(i->c_str(),
+ useWatcomQuote);
}
*this->BuildFileStream << "\n" << "\n";
}
@@ -1420,7 +1427,7 @@ public:
{
// Construct the name of the next object.
this->NextObject =
- this->LocalGenerator->Convert(obj.c_str(),
+ this->LocalGenerator->Convert(obj,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::RESPONSE);
@@ -1477,24 +1484,22 @@ cmMakefileTargetGenerator
}
//----------------------------------------------------------------------------
-void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
- bool relink)
+void cmMakefileTargetGenerator::WriteTargetDriverRule(
+ const std::string& main_output,
+ bool relink)
{
// Compute the name of the driver target.
std::string dir =
this->LocalGenerator->GetRelativeTargetDirectory(*this->Target);
std::string buildTargetRuleName = dir;
buildTargetRuleName += relink?"/preinstall":"/build";
- buildTargetRuleName = this->Convert(buildTargetRuleName.c_str(),
+ buildTargetRuleName = this->Convert(buildTargetRuleName,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::UNCHANGED);
// Build the list of target outputs to drive.
std::vector<std::string> depends;
- if(main_output)
- {
- depends.push_back(main_output);
- }
+ depends.push_back(main_output);
const char* comment = 0;
if(relink)
@@ -1514,7 +1519,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
}
// Make sure the extra files are built.
- for(std::set<cmStdString>::const_iterator i = this->ExtraFiles.begin();
+ for(std::set<std::string>::const_iterator i = this->ExtraFiles.begin();
i != this->ExtraFiles.end(); ++i)
{
depends.push_back(*i);
@@ -1524,7 +1529,7 @@ void cmMakefileTargetGenerator::WriteTargetDriverRule(const char* main_output,
// Write the driver rule.
std::vector<std::string> no_commands;
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, comment,
- buildTargetRuleName.c_str(),
+ buildTargetRuleName,
depends, no_commands, true);
}
@@ -1538,19 +1543,20 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
std::string fwSearchFlagVar = "CMAKE_" + l + "_FRAMEWORK_SEARCH_FLAG";
const char* fwSearchFlag =
- this->Makefile->GetDefinition(fwSearchFlagVar.c_str());
+ this->Makefile->GetDefinition(fwSearchFlagVar);
if(!(fwSearchFlag && *fwSearchFlag))
{
return std::string();
}
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
#ifdef __APPLE__ /* don't insert this when crosscompiling e.g. to iphone */
emitted.insert("/System/Library/Frameworks");
#endif
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
"C", config);
@@ -1559,7 +1565,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
for(std::vector<std::string>::iterator i = includes.begin();
i != includes.end(); ++i)
{
- if(this->Target->NameResolvesToFramework(i->c_str()))
+ if(this->Target->NameResolvesToFramework(*i))
{
std::string frameworkDir = *i;
frameworkDir += "/../";
@@ -1579,7 +1585,7 @@ std::string cmMakefileTargetGenerator::GetFrameworkFlags(std::string const& l)
if(emitted.insert(*i).second)
{
flags += fwSearchFlag;
- flags += this->Convert(i->c_str(),
+ flags += this->Convert(*i,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL, true);
flags += " ";
@@ -1650,9 +1656,11 @@ void cmMakefileTargetGenerator
this->AppendTargetDepends(depends);
// Add a dependency on the link definitions file, if any.
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ if(!def.empty())
{
- depends.push_back(this->GeneratorTarget->ModuleDefinitionFile);
+ depends.push_back(def);
}
// Add user-specified dependencies.
@@ -1664,7 +1672,8 @@ void cmMakefileTargetGenerator
}
//----------------------------------------------------------------------------
-std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
+std::string cmMakefileTargetGenerator::GetLinkRule(
+ const std::string& linkRuleVar)
{
std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
if(this->Target->HasImplibGNUtoMS())
@@ -1672,7 +1681,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(const char* linkRuleVar)
std::string ruleVar = "CMAKE_";
ruleVar += this->Target->GetLinkerLanguage(this->ConfigName);
ruleVar += "_GNUtoMS_RULE";
- if(const char* rule = this->Makefile->GetDefinition(ruleVar.c_str()))
+ if(const char* rule = this->Makefile->GetDefinition(ruleVar))
{
linkRule += rule;
}
@@ -1690,8 +1699,8 @@ void cmMakefileTargetGenerator
}
void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
- const char* linkLang,
- std::string& linkFlags)
+ const std::string& linkLang,
+ std::string& linkFlags)
{
// check for language flags that are not allowed at link time, and
// remove them, -w on darwin for gcc -w -dynamiclib sends -w to libtool
@@ -1701,7 +1710,7 @@ void cmMakefileTargetGenerator::RemoveForbiddenFlags(const char* flagVar,
removeFlags += linkLang;
removeFlags += flagVar;
std::string removeflags =
- this->Makefile->GetSafeDefinition(removeFlags.c_str());
+ this->Makefile->GetSafeDefinition(removeFlags);
std::vector<std::string> removeList;
cmSystemTools::ExpandListArgument(removeflags, removeList);
@@ -1779,7 +1788,7 @@ cmMakefileTargetGenerator
// Create the makefile command to invoke the link script.
std::string link_command = "$(CMAKE_COMMAND) -E cmake_link_script ";
- link_command += this->Convert(linkScriptName.c_str(),
+ link_command += this->Convert(linkScriptName,
cmLocalGenerator::START_OUTPUT,
cmLocalGenerator::SHELL);
link_command += " --verbose=$(VERBOSE)";
@@ -1815,13 +1824,57 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void
cmMakefileTargetGenerator
+::CreateLinkLibs(std::string& linkLibs, bool relink,
+ bool useResponseFile,
+ std::vector<std::string>& makefile_depends,
+ bool useWatcomQuote)
+{
+ std::string frameworkPath;
+ std::string linkPath;
+ this->LocalGenerator
+ ->OutputLinkLibraries(linkLibs, frameworkPath, linkPath,
+ *this->GeneratorTarget, relink,
+ useResponseFile,
+ useWatcomQuote);
+ linkLibs = frameworkPath + linkPath + linkLibs;
+
+ if(useResponseFile)
+ {
+ // Lookup the response file reference flag.
+ std::string responseFlagVar = "CMAKE_";
+ responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
+ responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
+ const char* responseFlag =
+ this->Makefile->GetDefinition(responseFlagVar);
+ if(!responseFlag)
+ {
+ responseFlag = "@";
+ }
+
+ // Create this response file.
+ std::string link_rsp =
+ this->CreateResponseFile("linklibs.rsp", linkLibs, makefile_depends);
+
+ // Reference the response file.
+ linkLibs = responseFlag;
+ linkLibs += this->Convert(link_rsp,
+ cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL);
+ }
+}
+
+//----------------------------------------------------------------------------
+void
+cmMakefileTargetGenerator
::CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
- std::vector<std::string>& makefile_depends)
+ std::vector<std::string>& makefile_depends,
+ bool useWatcomQuote)
{
std::string variableName;
std::string variableNameExternal;
- this->WriteObjectsVariable(variableName, variableNameExternal);
+ this->WriteObjectsVariable(variableName, variableNameExternal,
+ useWatcomQuote);
if(useResponseFile)
{
// MSVC response files cannot exceed 128K.
@@ -1836,7 +1889,7 @@ cmMakefileTargetGenerator
responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName);
responseFlagVar += "_RESPONSE_FILE_LINK_FLAG";
const char* responseFlag =
- this->Makefile->GetDefinition(responseFlagVar.c_str());
+ this->Makefile->GetDefinition(responseFlagVar);
if(!responseFlag)
{
responseFlag = "@";
@@ -1860,7 +1913,7 @@ cmMakefileTargetGenerator
// Reference the response file.
buildObjs += responseFlag;
- buildObjs += this->Convert(objects_rsp.c_str(),
+ buildObjs += this->Convert(objects_rsp,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
}
@@ -1884,16 +1937,17 @@ cmMakefileTargetGenerator
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
- const char* lang)
+ const std::string& lang)
{
std::string responseVar = "CMAKE_";
responseVar += lang;
responseVar += "_USE_RESPONSE_FILE_FOR_INCLUDES";
- bool useResponseFile = this->Makefile->IsOn(responseVar.c_str());
+ bool useResponseFile = this->Makefile->IsOn(responseVar);
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
lang, config);
@@ -2000,7 +2054,8 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
this->Makefile->GetDefinition("CMAKE_Fortran_MODPATH_FLAG"))
{
std::vector<std::string> includes;
- const char *config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE");
+ const std::string& config =
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
"C", config);
@@ -2008,7 +2063,7 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
idi != includes.end(); ++idi)
{
std::string flg = modpath_flag;
- flg += this->Convert(idi->c_str(),
+ flg += this->Convert(*idi,
cmLocalGenerator::NONE,
cmLocalGenerator::SHELL);
this->LocalGenerator->AppendFlags(flags, flg.c_str());
@@ -2019,7 +2074,9 @@ void cmMakefileTargetGenerator::AddFortranFlags(std::string& flags)
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
{
- if(this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile(
+ this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ if(def.empty())
{
return;
}
@@ -2035,26 +2092,25 @@ void cmMakefileTargetGenerator::AddModuleDefinitionFlag(std::string& flags)
// Append the flag and value. Use ConvertToLinkReference to help
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
- flag += (this->LocalGenerator->ConvertToLinkReference(
- this->GeneratorTarget->ModuleDefinitionFile.c_str()));
+ flag += (this->LocalGenerator->ConvertToLinkReference(def));
this->LocalGenerator->AppendFlags(flags, flag.c_str());
}
//----------------------------------------------------------------------------
-const char* cmMakefileTargetGenerator::GetFeature(const char* feature)
+const char* cmMakefileTargetGenerator::GetFeature(const std::string& feature)
{
return this->Target->GetFeature(feature, this->ConfigName);
}
//----------------------------------------------------------------------------
-bool cmMakefileTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmMakefileTargetGenerator::GetFeatureAsBool(const std::string& feature)
{
return cmSystemTools::IsOn(this->GetFeature(feature));
}
//----------------------------------------------------------------------------
void cmMakefileTargetGenerator::AddFeatureFlags(
- std::string& flags, const char* lang
+ std::string& flags, const std::string& lang
)
{
// Add language-specific flags.
diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h
index 4f8fafa..9fac574 100644
--- a/Source/cmMakefileTargetGenerator.h
+++ b/Source/cmMakefileTargetGenerator.h
@@ -15,7 +15,7 @@
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmOSXBundleGenerator.h"
-class cmCustomCommand;
+class cmCustomCommandGenerator;
class cmDependInformation;
class cmDepends;
class cmGeneratorTarget;
@@ -81,7 +81,7 @@ protected:
MacOSXContentGeneratorType(cmMakefileTargetGenerator* gen) :
Generator(gen) {}
- void operator()(cmSourceFile& source, const char* pkgloc);
+ void operator()(cmSourceFile const& source, const char* pkgloc);
private:
cmMakefileTargetGenerator* Generator;
@@ -89,20 +89,20 @@ protected:
friend struct MacOSXContentGeneratorType;
// write the rules for an object
- void WriteObjectRuleFiles(cmSourceFile& source);
+ void WriteObjectRuleFiles(cmSourceFile const& source);
// write the build rule for an object
void WriteObjectBuildFile(std::string &obj,
- const char *lang,
- cmSourceFile& source,
+ const std::string& lang,
+ cmSourceFile const& source,
std::vector<std::string>& depends);
// write the depend.make file for an object
- void WriteObjectDependRules(cmSourceFile& source,
+ void WriteObjectDependRules(cmSourceFile const& source,
std::vector<std::string>& depends);
// write the build rule for a custom command
- void GenerateCustomRuleFile(const cmCustomCommand& cc);
+ void GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg);
// write a rule to drive building of more than one output from
// another rule
@@ -113,20 +113,22 @@ protected:
// write out the variable that lists the objects for this target
void WriteObjectsVariable(std::string& variableName,
- std::string& variableNameExternal);
+ std::string& variableNameExternal,
+ bool useWatcomQuote);
void WriteObjectsString(std::string& buildObjs);
void WriteObjectsStrings(std::vector<std::string>& objStrings,
std::string::size_type limit = std::string::npos);
// write the driver rule to build target outputs
- void WriteTargetDriverRule(const char* main_output, bool relink);
+ void WriteTargetDriverRule(const std::string& main_output, bool relink);
void DriveCustomCommands(std::vector<std::string>& depends);
// Return the a string with -F flags on apple
std::string GetFrameworkFlags(std::string const& l);
- void AppendFortranFormatFlags(std::string& flags, cmSourceFile& source);
+ void AppendFortranFormatFlags(std::string& flags,
+ cmSourceFile const& source);
// append intertarget dependencies
void AppendTargetDepends(std::vector<std::string>& depends);
@@ -138,7 +140,7 @@ protected:
void AppendLinkDepends(std::vector<std::string>& depends);
// Lookup the link rule for this target.
- std::string GetLinkRule(const char* linkRuleVar);
+ 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
@@ -163,22 +165,29 @@ protected:
std::string const& options,
std::vector<std::string>& makefile_depends);
+ /** Create list of flags for link libraries. */
+ void CreateLinkLibs(std::string& linkLibs, bool relink,
+ bool useResponseFile,
+ std::vector<std::string>& makefile_depends,
+ bool useWatcomQuote);
+
/** Create lists of object files for linking and cleaning. */
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
bool useResponseFile, std::string& buildObjs,
- std::vector<std::string>& makefile_depends);
+ std::vector<std::string>& makefile_depends,
+ bool useWatcomQuote);
- void AddIncludeFlags(std::string& flags, const char* lang);
+ void AddIncludeFlags(std::string& flags, const std::string& lang);
virtual void CloseFileStreams();
- void RemoveForbiddenFlags(const char* flagVar, const char* linkLang,
+ void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang,
std::string& linkFlags);
cmTarget *Target;
cmGeneratorTarget* GeneratorTarget;
cmLocalUnixMakefileGenerator3 *LocalGenerator;
cmGlobalUnixMakefileGenerator3 *GlobalGenerator;
cmMakefile *Makefile;
- const char *ConfigName;
+ std::string ConfigName;
enum CustomCommandDriveType { OnBuild, OnDepends, OnUtility };
CustomCommandDriveType CustomCommandDriver;
@@ -203,7 +212,7 @@ protected:
std::string FlagFileNameFull;
cmGeneratedFileStream *FlagFileStream;
class StringList: public std::vector<std::string> {};
- std::map<cmStdString, StringList> FlagFileDepends;
+ std::map<std::string, StringList> FlagFileDepends;
// the stream for the info file
std::string InfoFileNameFull;
@@ -217,12 +226,12 @@ protected:
std::vector<std::string> ExternalObjects;
// Set of object file names that will be built in this directory.
- std::set<cmStdString> ObjectFiles;
+ std::set<std::string> ObjectFiles;
// Set of extra output files to be driven by the build.
- std::set<cmStdString> ExtraFiles;
+ std::set<std::string> ExtraFiles;
- typedef std::map<cmStdString, cmStdString> MultipleOutputPairsType;
+ typedef std::map<std::string, std::string> MultipleOutputPairsType;
MultipleOutputPairsType MultipleOutputPairs;
// Target name info.
@@ -233,11 +242,11 @@ protected:
std::string TargetNamePDB;
// Mac OS X content info.
- std::set<cmStdString> MacContentFolders;
+ std::set<std::string> MacContentFolders;
cmOSXBundleGenerator* OSXBundleGenerator;
MacOSXContentGeneratorType* MacOSXContentGenerator;
- typedef std::map<cmStdString, cmStdString> ByLanguageMap;
+ typedef std::map<std::string, std::string> ByLanguageMap;
std::string GetFlags(const std::string &l);
ByLanguageMap FlagsByLanguage;
std::string GetDefines(const std::string &l);
@@ -255,16 +264,16 @@ protected:
void AddModuleDefinitionFlag(std::string& flags);
// Add language feature flags.
- void AddFeatureFlags(std::string& flags, const char* lang);
+ void AddFeatureFlags(std::string& flags, const std::string& lang);
// Feature query methods.
- const char* GetFeature(const char* feature);
- bool GetFeatureAsBool(const char* feature);
+ const char* GetFeature(const std::string& feature);
+ bool GetFeatureAsBool(const std::string& feature);
//==================================================================
// Convenience routines that do nothing more than forward to
// implementaitons
- std::string Convert(const char* source,
+ std::string Convert(const std::string& source,
cmLocalGenerator::RelativeRoot relative,
cmLocalGenerator::OutputFormat output =
cmLocalGenerator::UNCHANGED,
diff --git a/Source/cmMakefileUtilityTargetGenerator.cxx b/Source/cmMakefileUtilityTargetGenerator.cxx
index 7751ad9..6b039bb 100644
--- a/Source/cmMakefileUtilityTargetGenerator.cxx
+++ b/Source/cmMakefileUtilityTargetGenerator.cxx
@@ -52,7 +52,7 @@ void cmMakefileUtilityTargetGenerator::WriteRuleFiles()
*this->BuildFileStream
<< "# Include the progress variables for this target.\n"
<< this->LocalGenerator->IncludeDirective << " " << root
- << this->Convert(this->ProgressFileNameFull.c_str(),
+ << this->Convert(this->ProgressFileNameFull,
cmLocalGenerator::HOME_OUTPUT,
cmLocalGenerator::MAKEFILE)
<< "\n\n";
diff --git a/Source/cmMarkAsAdvancedCommand.cxx b/Source/cmMarkAsAdvancedCommand.cxx
index 4236d10..f6a2c26 100644
--- a/Source/cmMarkAsAdvancedCommand.cxx
+++ b/Source/cmMarkAsAdvancedCommand.cxx
@@ -42,11 +42,11 @@ bool cmMarkAsAdvancedCommand
if ( it.IsAtEnd() )
{
this->Makefile->GetCacheManager()
- ->AddCacheEntry(variable.c_str(), 0, 0,
+ ->AddCacheEntry(variable, 0, 0,
cmCacheManager::UNINITIALIZED);
overwrite = true;
}
- it.Find(variable.c_str());
+ it.Find(variable);
if ( it.IsAtEnd() )
{
cmSystemTools::Error("This should never happen...");
diff --git a/Source/cmMarkAsAdvancedCommand.h b/Source/cmMarkAsAdvancedCommand.h
index b65e4a8..38064a3 100644
--- a/Source/cmMarkAsAdvancedCommand.h
+++ b/Source/cmMarkAsAdvancedCommand.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "mark_as_advanced";}
+ virtual std::string GetName() const {return "mark_as_advanced";}
/**
* This determines if the command is invoked when in script mode.
diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx
index 9fc4265..f1942c5 100644
--- a/Source/cmMathCommand.cxx
+++ b/Source/cmMathCommand.cxx
@@ -28,7 +28,7 @@ bool cmMathCommand
return this->HandleExprCommand(args);
}
std::string e = "does not recognize sub-command "+subCommand;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -49,13 +49,13 @@ bool cmMathCommand::HandleExprCommand(std::vector<std::string> const& args)
{
std::string e = "cannot parse the expression: \""+expression+"\": ";
e += helper.GetError();
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
char buffer[1024];
sprintf(buffer, "%d", helper.GetResult());
- this->Makefile->AddDefinition(outputVariable.c_str(), buffer);
+ this->Makefile->AddDefinition(outputVariable, buffer);
return true;
}
diff --git a/Source/cmMathCommand.h b/Source/cmMathCommand.h
index c826ef1..76dc102 100644
--- a/Source/cmMathCommand.h
+++ b/Source/cmMathCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "math";}
+ virtual std::string GetName() const { return "math";}
cmTypeMacro(cmMathCommand, cmCommand);
protected:
diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx
index d85e720..88d6a77 100644
--- a/Source/cmMessageCommand.cxx
+++ b/Source/cmMessageCommand.cxx
@@ -77,7 +77,7 @@ bool cmMessageCommand
if (type != cmake::MESSAGE)
{
- this->Makefile->IssueMessage(type, message.c_str());
+ this->Makefile->IssueMessage(type, message);
}
else
{
diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h
index fec9a32..c0ae2a3 100644
--- a/Source/cmMessageCommand.h
+++ b/Source/cmMessageCommand.h
@@ -39,7 +39,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "message";}
+ virtual std::string GetName() const { return "message";}
/**
* This determines if the command is invoked when in script mode.
diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx
index a7d7429..08f0b5b 100644
--- a/Source/cmNewLineStyle.cxx
+++ b/Source/cmNewLineStyle.cxx
@@ -76,8 +76,6 @@ const std::string cmNewLineStyle::GetCharacters() const
return "\n";
case CRLF:
return "\r\n";
- default:
- ;
}
return "";
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 73ba815..b467d22 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -18,6 +18,7 @@
#include "cmMakefile.h"
#include "cmOSXBundleGenerator.h"
#include "cmGeneratorTarget.h"
+#include "cmCustomCommandGenerator.h"
#include <assert.h>
#include <algorithm>
@@ -35,7 +36,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
, TargetNameReal()
, TargetNameImport()
, TargetNamePDB()
- , TargetLinkLanguage(0)
+ , TargetLinkLanguage("")
{
this->TargetLinkLanguage = target->Target
->GetLinkerLanguage(this->GetConfigName());
@@ -72,10 +73,10 @@ cmNinjaNormalTargetGenerator::~cmNinjaNormalTargetGenerator()
void cmNinjaNormalTargetGenerator::Generate()
{
- if (!this->TargetLinkLanguage) {
+ if (this->TargetLinkLanguage.empty()) {
cmSystemTools::Error("CMake can not determine linker language for "
"target: ",
- this->GetTarget()->GetName());
+ this->GetTarget()->GetName().c_str());
return;
}
@@ -109,9 +110,10 @@ void cmNinjaNormalTargetGenerator::WriteLanguagesRules()
<< "\n\n";
#endif
- std::set<cmStdString> languages;
- this->GetTarget()->GetLanguages(languages);
- for(std::set<cmStdString>::const_iterator l = languages.begin();
+ std::set<std::string> languages;
+ this->GetTarget()->GetLanguages(languages,
+ this->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ for(std::set<std::string>::const_iterator l = languages.begin();
l != languages.end();
++l)
this->WriteLanguageRules(*l);
@@ -140,7 +142,7 @@ std::string
cmNinjaNormalTargetGenerator
::LanguageLinkerRule() const
{
- return std::string(this->TargetLinkLanguage)
+ return this->TargetLinkLanguage
+ "_"
+ cmTarget::GetTargetTypeName(this->GetTarget()->GetType())
+ "_LINKER";
@@ -163,7 +165,7 @@ cmNinjaNormalTargetGenerator
cmLocalGenerator::RuleVariables vars;
vars.RuleLauncher = "RULE_LAUNCH_LINK";
vars.CMTarget = this->GetTarget();
- vars.Language = this->TargetLinkLanguage;
+ vars.Language = this->TargetLinkLanguage.c_str();
std::string responseFlag;
if (!useResponseFile) {
@@ -175,7 +177,7 @@ cmNinjaNormalTargetGenerator
// build response file name
std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_LINK_FLAG";
- const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar.c_str());
+ const char * flag = GetMakefile()->GetDefinition(cmakeLinkVar);
if(flag) {
responseFlag = flag;
} else {
@@ -189,7 +191,7 @@ cmNinjaNormalTargetGenerator
linkOptionVar += "_COMPILER_LINKER_OPTION_FLAG_";
linkOptionVar += cmTarget::GetTargetTypeName(targetType);
const std::string linkOption =
- GetMakefile()->GetSafeDefinition(linkOptionVar.c_str());
+ GetMakefile()->GetSafeDefinition(linkOptionVar);
rspcontent = "$in_newline "+linkOption+" $LINK_PATH $LINK_LIBRARIES";
vars.Objects = responseFlag.c_str();
vars.LinkLibraries = "";
@@ -230,13 +232,11 @@ cmNinjaNormalTargetGenerator
vars.LinkFlags = "$LINK_FLAGS";
std::string langFlags;
- if (targetType != cmTarget::EXECUTABLE) {
- this->GetLocalGenerator()->AddLanguageFlags(langFlags,
- this->TargetLinkLanguage,
- this->GetConfigName());
- langFlags += " $ARCH_FLAGS";
+ if (targetType != cmTarget::EXECUTABLE)
+ {
+ langFlags += "$LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS";
vars.LanguageCompileFlags = langFlags.c_str();
- }
+ }
// Rule for linking library/executable.
std::vector<std::string> linkCmds = this->ComputeLinkCmd();
@@ -312,97 +312,88 @@ cmNinjaNormalTargetGenerator
::ComputeLinkCmd()
{
std::vector<std::string> linkCmds;
- cmTarget::TargetType targetType = this->GetTarget()->GetType();
- switch (targetType) {
+ cmMakefile* mf = this->GetMakefile();
+ {
+ std::string linkCmdVar = "CMAKE_";
+ linkCmdVar += this->TargetLinkLanguage;
+ linkCmdVar += this->GetGeneratorTarget()->GetCreateRuleVariable();
+ const char *linkCmd = mf->GetDefinition(linkCmdVar);
+ if (linkCmd)
+ {
+ cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
+ return linkCmds;
+ }
+ }
+ switch (this->GetTarget()->GetType()) {
case cmTarget::STATIC_LIBRARY: {
- // Check if you have a non archive way to create the static library.
- {
- std::string linkCmdVar = "CMAKE_";
- linkCmdVar += this->TargetLinkLanguage;
- linkCmdVar += "_CREATE_STATIC_LIBRARY";
- if (const char *linkCmd =
- this->GetMakefile()->GetDefinition(linkCmdVar.c_str()))
- {
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
- return linkCmds;
- }
- }
-
// We have archive link commands set. First, delete the existing archive.
+ {
std::string cmakeCommand =
this->GetLocalGenerator()->ConvertToOutputFormat(
- this->GetMakefile()->GetRequiredDefinition("CMAKE_COMMAND"),
+ mf->GetRequiredDefinition("CMAKE_COMMAND"),
cmLocalGenerator::SHELL);
linkCmds.push_back(cmakeCommand + " -E remove $out");
-
+ }
// TODO: Use ARCHIVE_APPEND for archives over a certain size.
{
std::string linkCmdVar = "CMAKE_";
linkCmdVar += this->TargetLinkLanguage;
linkCmdVar += "_ARCHIVE_CREATE";
- const char *linkCmd =
- this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
+ const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
}
{
std::string linkCmdVar = "CMAKE_";
linkCmdVar += this->TargetLinkLanguage;
linkCmdVar += "_ARCHIVE_FINISH";
- const char *linkCmd =
- this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
+ const char *linkCmd = mf->GetRequiredDefinition(linkCmdVar);
cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
}
return linkCmds;
}
case cmTarget::SHARED_LIBRARY:
case cmTarget::MODULE_LIBRARY:
- case cmTarget::EXECUTABLE: {
- std::string linkCmdVar = "CMAKE_";
- linkCmdVar += this->TargetLinkLanguage;
- switch (targetType) {
- case cmTarget::SHARED_LIBRARY:
- linkCmdVar += "_CREATE_SHARED_LIBRARY";
- break;
- case cmTarget::MODULE_LIBRARY:
- linkCmdVar += "_CREATE_SHARED_MODULE";
- break;
- case cmTarget::EXECUTABLE:
- linkCmdVar += "_LINK_EXECUTABLE";
- break;
- default:
- assert(0 && "Unexpected target type");
- }
-
- const char *linkCmd =
- this->GetMakefile()->GetRequiredDefinition(linkCmdVar.c_str());
- cmSystemTools::ExpandListArgument(linkCmd, linkCmds);
- return linkCmds;
- }
+ case cmTarget::EXECUTABLE:
+ break;
default:
assert(0 && "Unexpected target type");
}
return std::vector<std::string>();
}
-void cmNinjaNormalTargetGenerator::WriteLinkStatement()
+
+static int calculateCommandLineLengthLimit(int linkRuleLength)
{
- cmTarget::TargetType targetType = this->GetTarget()->GetType();
+#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;
+#endif
+}
+
+void cmNinjaNormalTargetGenerator::WriteLinkStatement()
+{
+ cmTarget& target = *this->GetTarget();
+ const std::string cfgName = this->GetConfigName();
std::string targetOutput = ConvertToNinjaPath(
- this->GetTarget()->GetFullPath(this->GetConfigName()).c_str());
+ target.GetFullPath(cfgName).c_str());
std::string targetOutputReal = ConvertToNinjaPath(
- this->GetTarget()->GetFullPath(this->GetConfigName(),
- /*implib=*/false,
- /*realpath=*/true).c_str());
+ target.GetFullPath(cfgName,
+ /*implib=*/false,
+ /*realpath=*/true).c_str());
std::string targetOutputImplib = ConvertToNinjaPath(
- this->GetTarget()->GetFullPath(this->GetConfigName(),
- /*implib=*/true).c_str());
+ target.GetFullPath(cfgName,
+ /*implib=*/true).c_str());
- if (this->GetTarget()->IsAppBundleOnApple())
+ if (target.IsAppBundleOnApple())
{
// Create the app bundle
- std::string outpath =
- this->GetTarget()->GetDirectory(this->GetConfigName());
+ std::string outpath = target.GetDirectory(cfgName);
this->OSXBundleGenerator->CreateAppBundle(this->TargetNameOut, outpath);
// Calculate the output path
@@ -415,23 +406,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
targetOutputReal += this->TargetNameReal;
targetOutputReal = this->ConvertToNinjaPath(targetOutputReal.c_str());
}
- else if (this->GetTarget()->IsFrameworkOnApple())
+ else if (target.IsFrameworkOnApple())
{
// Create the library framework.
- std::string outpath =
- this->GetTarget()->GetDirectory(this->GetConfigName());
- this->OSXBundleGenerator->CreateFramework(this->TargetNameOut, outpath);
+ this->OSXBundleGenerator->CreateFramework(this->TargetNameOut,
+ target.GetDirectory(cfgName));
}
- else if(this->GetTarget()->IsCFBundleOnApple())
+ else if(target.IsCFBundleOnApple())
{
// Create the core foundation bundle.
- std::string outpath =
- this->GetTarget()->GetDirectory(this->GetConfigName());
- this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut, outpath);
+ this->OSXBundleGenerator->CreateCFBundle(this->TargetNameOut,
+ target.GetDirectory(cfgName));
}
// Write comments.
cmGlobalNinjaGenerator::WriteDivider(this->GetBuildFileStream());
+ const cmTarget::TargetType targetType = target.GetType();
this->GetBuildFileStream()
<< "# Link build statements for "
<< cmTarget::GetTargetTypeName(targetType)
@@ -444,8 +434,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Compute the comment.
cmOStringStream comment;
- comment << "Link the " << this->GetVisibleTypeName() << " "
- << targetOutputReal;
+ comment <<
+ "Link the " << this->GetVisibleTypeName() << " " << targetOutputReal;
// Compute outputs.
cmNinjaDeps outputs;
@@ -455,16 +445,25 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
cmNinjaDeps explicitDeps = this->GetObjects();
cmNinjaDeps implicitDeps = this->ComputeLinkDeps();
+ cmMakefile* mf = this->GetMakefile();
+
std::string frameworkPath;
std::string linkPath;
- this->GetLocalGenerator()->GetTargetFlags(vars["LINK_LIBRARIES"],
- vars["FLAGS"],
- vars["LINK_FLAGS"],
- frameworkPath,
- linkPath,
- this->GetGeneratorTarget());
-
- this->addPoolNinjaVariable("JOB_POOL_LINK", this->GetTarget(), vars);
+ cmGeneratorTarget& genTarget = *this->GetGeneratorTarget();
+
+ std::string createRule = "CMAKE_";
+ createRule += this->TargetLinkLanguage + genTarget.GetCreateRuleVariable();
+ bool useWatcomQuote = mf->IsOn(createRule+"_USE_WATCOM_QUOTE");
+ cmLocalNinjaGenerator& localGen = *this->GetLocalGenerator();
+ localGen.GetTargetFlags(vars["LINK_LIBRARIES"],
+ vars["FLAGS"],
+ vars["LINK_FLAGS"],
+ frameworkPath,
+ linkPath,
+ &genTarget,
+ useWatcomQuote);
+
+ this->addPoolNinjaVariable("JOB_POOL_LINK", &target, vars);
this->AddModuleDefinitionFlag(vars["LINK_FLAGS"]);
vars["LINK_FLAGS"] = cmGlobalNinjaGenerator
@@ -475,44 +474,48 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// Compute architecture specific link flags. Yes, these go into a different
// variable for executables, probably due to a mistake made when duplicating
// code between the Makefile executable and library generators.
- std::string flags = (targetType == cmTarget::EXECUTABLE
- ? vars["FLAGS"]
- : vars["ARCH_FLAGS"]);
- this->GetLocalGenerator()->AddArchitectureFlags(flags,
- this->GetGeneratorTarget(),
- this->TargetLinkLanguage,
- this->GetConfigName());
- if (targetType == cmTarget::EXECUTABLE) {
- vars["FLAGS"] = flags;
- } else {
- vars["ARCH_FLAGS"] = flags;
- }
- if (this->GetTarget()->HasSOName(this->GetConfigName())) {
- vars["SONAME_FLAG"] =
- this->GetMakefile()->GetSONameFlag(this->TargetLinkLanguage);
+ if (targetType == cmTarget::EXECUTABLE)
+ {
+ std::string t = vars["FLAGS"];
+ localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ vars["FLAGS"] = t;
+ }
+ else
+ {
+ std::string t = vars["ARCH_FLAGS"];
+ localGen.AddArchitectureFlags(t, &genTarget, TargetLinkLanguage, cfgName);
+ vars["ARCH_FLAGS"] = t;
+ t = "";
+ localGen.AddLanguageFlags(t, TargetLinkLanguage, cfgName);
+ vars["LANGUAGE_COMPILE_FLAGS"] = t;
+ }
+
+ if (target.HasSOName(cfgName))
+ {
+ vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage);
vars["SONAME"] = this->TargetNameSO;
- if (targetType == cmTarget::SHARED_LIBRARY) {
- std::string install_name_dir = this->GetTarget()
- ->GetInstallNameDirForBuildTree(this->GetConfigName());
-
- if (!install_name_dir.empty()) {
- vars["INSTALLNAME_DIR"] =
- this->GetLocalGenerator()->Convert(install_name_dir.c_str(),
- cmLocalGenerator::NONE,
- cmLocalGenerator::SHELL, false);
+ if (targetType == cmTarget::SHARED_LIBRARY)
+ {
+ std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName);
+ if (!install_dir.empty())
+ {
+ vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir,
+ cmLocalGenerator::NONE,
+ cmLocalGenerator::SHELL,
+ false);
+ }
}
}
- }
- if (!this->TargetNameImport.empty()) {
- const std::string impLibPath = this->GetLocalGenerator()
- ->ConvertToOutputFormat(targetOutputImplib.c_str(),
- cmLocalGenerator::SHELL);
+ if (!this->TargetNameImport.empty())
+ {
+ const std::string impLibPath = localGen.ConvertToOutputFormat(
+ targetOutputImplib,
+ cmLocalGenerator::SHELL);
vars["TARGET_IMPLIB"] = impLibPath;
EnsureParentDirectoryExists(impLibPath);
- }
+ }
- cmMakefile* mf = this->GetMakefile();
if (!this->SetMsvcTargetPdbVariable(vars))
{
// It is common to place debug symbols at a specific place,
@@ -520,11 +523,13 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
std::string prefix;
std::string base;
std::string suffix;
- this->GetTarget()->GetFullNameComponents(prefix, base, suffix);
+ target.GetFullNameComponents(prefix, base, suffix);
std::string dbg_suffix = ".dbg";
// TODO: Where to document?
if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX"))
+ {
dbg_suffix = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX");
+ }
vars["TARGET_PDB"] = base + suffix + dbg_suffix;
}
@@ -536,12 +541,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
// ar.exe can't handle backslashes in rsp files (implicitly used by gcc)
std::string& linkLibraries = vars["LINK_LIBRARIES"];
std::replace(linkLibraries.begin(), linkLibraries.end(), '\\', '/');
+ std::string& link_path = vars["LINK_PATH"];
+ std::replace(link_path.begin(), link_path.end(), '\\', '/');
}
const std::vector<cmCustomCommand> *cmdLists[3] = {
- &this->GetTarget()->GetPreBuildCommands(),
- &this->GetTarget()->GetPreLinkCommands(),
- &this->GetTarget()->GetPostBuildCommands()
+ &target.GetPreBuildCommands(),
+ &target.GetPreLinkCommands(),
+ &target.GetPostBuildCommands()
};
std::vector<std::string> preLinkCmdLines, postBuildCmdLines;
@@ -551,99 +558,97 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
&postBuildCmdLines
};
- for (unsigned i = 0; i != 3; ++i) {
+ for (unsigned i = 0; i != 3; ++i)
+ {
for (std::vector<cmCustomCommand>::const_iterator
ci = cmdLists[i]->begin();
- ci != cmdLists[i]->end(); ++ci) {
- this->GetLocalGenerator()->AppendCustomCommandLines(&*ci,
- *cmdLineLists[i]);
+ ci != cmdLists[i]->end(); ++ci)
+ {
+ cmCustomCommandGenerator ccg(*ci, cfgName, mf);
+ localGen.AppendCustomCommandLines(ccg, *cmdLineLists[i]);
+ }
}
- }
// If we have any PRE_LINK commands, we need to go back to HOME_OUTPUT for
// the link commands.
- if (!preLinkCmdLines.empty()) {
- const std::string homeOutDir = this->GetLocalGenerator()
- ->ConvertToOutputFormat(this->GetMakefile()->GetHomeOutputDirectory(),
- cmLocalGenerator::SHELL);
+ if (!preLinkCmdLines.empty())
+ {
+ const std::string homeOutDir = localGen.ConvertToOutputFormat(
+ mf->GetHomeOutputDirectory(),
+ cmLocalGenerator::SHELL);
preLinkCmdLines.push_back("cd " + homeOutDir);
- }
+ }
- vars["PRE_LINK"] =
- this->GetLocalGenerator()->BuildCommandLine(preLinkCmdLines);
- std::string postBuildCmdLine =
- this->GetLocalGenerator()->BuildCommandLine(postBuildCmdLines);
+ vars["PRE_LINK"] = localGen.BuildCommandLine(preLinkCmdLines);
+ std::string postBuildCmdLine = localGen.BuildCommandLine(postBuildCmdLines);
cmNinjaVars symlinkVars;
- if (targetOutput == targetOutputReal) {
+ if (targetOutput == targetOutputReal)
+ {
vars["POST_BUILD"] = postBuildCmdLine;
- } else {
+ }
+ else
+ {
vars["POST_BUILD"] = ":";
symlinkVars["POST_BUILD"] = postBuildCmdLine;
- }
+ }
- int linkRuleLength = this->GetGlobalGenerator()->
- GetRuleCmdLength(this->LanguageLinkerRule());
+ cmGlobalNinjaGenerator& globalGen = *this->GetGlobalGenerator();
int commandLineLengthLimit = 1;
const char* forceRspFile = "CMAKE_NINJA_FORCE_RESPONSE_FILE";
- if (!this->GetMakefile()->IsDefinitionSet(forceRspFile) &&
- cmSystemTools::GetEnv(forceRspFile) == 0) {
-#ifdef _WIN32
- commandLineLengthLimit = 8000 - linkRuleLength;
-#elif defined(__linux) || defined(__APPLE__)
- // for instance ARG_MAX is 2096152 on Ubuntu or 262144 on Mac
- commandLineLengthLimit = ((int)sysconf(_SC_ARG_MAX))-linkRuleLength-1000;
-#else
- (void)linkRuleLength;
- commandLineLengthLimit = -1;
-#endif
- }
-
- //Get the global generator as we are going to be call WriteBuild numerous
- //times in the following section
- cmGlobalNinjaGenerator* globalGenerator = this->GetGlobalGenerator();
-
+ if (!mf->IsDefinitionSet(forceRspFile) &&
+ cmSystemTools::GetEnv(forceRspFile) == 0)
+ {
+ commandLineLengthLimit = calculateCommandLineLengthLimit(
+ globalGen.GetRuleCmdLength(this->LanguageLinkerRule()));
+ }
- const std::string rspfile = std::string
- (cmake::GetCMakeFilesDirectoryPostSlash()) +
- this->GetTarget()->GetName() + ".rsp";
+ const std::string rspfile =
+ std::string(cmake::GetCMakeFilesDirectoryPostSlash())
+ + target.GetName() + ".rsp";
// Write the build statement for this target.
- globalGenerator->WriteBuild(this->GetBuildFileStream(),
- comment.str(),
- this->LanguageLinkerRule(),
- outputs,
- explicitDeps,
- implicitDeps,
- emptyDeps,
- vars,
- rspfile,
- commandLineLengthLimit);
-
- if (targetOutput != targetOutputReal &&
- !this->GetTarget()->IsFrameworkOnApple()) {
- if (targetType == cmTarget::EXECUTABLE) {
- globalGenerator->WriteBuild(this->GetBuildFileStream(),
- "Create executable symlink " + targetOutput,
- "CMAKE_SYMLINK_EXECUTABLE",
- cmNinjaDeps(1, targetOutput),
- cmNinjaDeps(1, targetOutputReal),
- emptyDeps,
- emptyDeps,
- symlinkVars);
- } else {
+ globalGen.WriteBuild(this->GetBuildFileStream(),
+ comment.str(),
+ this->LanguageLinkerRule(),
+ outputs,
+ explicitDeps,
+ implicitDeps,
+ emptyDeps,
+ vars,
+ rspfile,
+ commandLineLengthLimit);
+
+ if (targetOutput != targetOutputReal && !target.IsFrameworkOnApple())
+ {
+ if (targetType == cmTarget::EXECUTABLE)
+ {
+ globalGen.WriteBuild(this->GetBuildFileStream(),
+ "Create executable symlink " + targetOutput,
+ "CMAKE_SYMLINK_EXECUTABLE",
+ cmNinjaDeps(1, targetOutput),
+ cmNinjaDeps(1, targetOutputReal),
+ emptyDeps,
+ emptyDeps,
+ symlinkVars);
+ }
+ else
+ {
cmNinjaDeps symlinks;
const std::string soName = this->GetTargetFilePath(this->TargetNameSO);
// If one link has to be created.
- if (targetOutputReal == soName || targetOutput == soName) {
+ if (targetOutputReal == soName || targetOutput == soName)
+ {
symlinkVars["SONAME"] = soName;
- } else {
+ }
+ else
+ {
symlinkVars["SONAME"] = "";
symlinks.push_back(soName);
- }
+ }
symlinks.push_back(targetOutput);
- globalGenerator->WriteBuild(this->GetBuildFileStream(),
+ globalGen.WriteBuild(this->GetBuildFileStream(),
"Create library symlink " + targetOutput,
"CMAKE_SYMLINK_LIBRARY",
symlinks,
@@ -651,23 +656,22 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
emptyDeps,
emptyDeps,
symlinkVars);
+ }
}
- }
- if (!this->TargetNameImport.empty()) {
+ if (!this->TargetNameImport.empty())
+ {
// Since using multiple outputs would mess up the $out variable, use an
// alias for the import library.
- globalGenerator->WritePhonyBuild(this->GetBuildFileStream(),
- "Alias for import library.",
- cmNinjaDeps(1, targetOutputImplib),
- cmNinjaDeps(1, targetOutputReal));
- }
+ globalGen.WritePhonyBuild(this->GetBuildFileStream(),
+ "Alias for import library.",
+ cmNinjaDeps(1, targetOutputImplib),
+ cmNinjaDeps(1, targetOutputReal));
+ }
// Add aliases for the file name and the target name.
- globalGenerator->AddTargetAlias(this->TargetNameOut,
- this->GetTarget());
- globalGenerator->AddTargetAlias(this->GetTargetName(),
- this->GetTarget());
+ globalGen.AddTargetAlias(this->TargetNameOut, &target);
+ globalGen.AddTargetAlias(this->GetTargetName(), &target);
}
//----------------------------------------------------------------------------
diff --git a/Source/cmNinjaNormalTargetGenerator.h b/Source/cmNinjaNormalTargetGenerator.h
index c7a089c..556ed5e 100644
--- a/Source/cmNinjaNormalTargetGenerator.h
+++ b/Source/cmNinjaNormalTargetGenerator.h
@@ -47,7 +47,7 @@ private:
std::string TargetNameReal;
std::string TargetNameImport;
std::string TargetNamePDB;
- const char *TargetLinkLanguage;
+ std::string TargetLinkLanguage;
};
#endif // ! cmNinjaNormalTargetGenerator_h
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 900af8d..cb6eb90 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -91,26 +91,26 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const
return this->LocalGenerator->GetGlobalNinjaGenerator();
}
-const char* cmNinjaTargetGenerator::GetConfigName() const
+std::string const& cmNinjaTargetGenerator::GetConfigName() const
{
return this->LocalGenerator->GetConfigName();
}
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
-const char* cmNinjaTargetGenerator::GetFeature(const char* feature)
+const char* cmNinjaTargetGenerator::GetFeature(const std::string& feature)
{
return this->Target->GetFeature(feature, this->GetConfigName());
}
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
-bool cmNinjaTargetGenerator::GetFeatureAsBool(const char* feature)
+bool cmNinjaTargetGenerator::GetFeatureAsBool(const std::string& feature)
{
return cmSystemTools::IsOn(this->GetFeature(feature));
}
// TODO: Picked up from cmMakefileTargetGenerator. Refactor it.
void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
- const char* lang)
+ const std::string& lang)
{
// Add language-specific flags.
this->LocalGenerator->AddLanguageFlags(flags, lang, this->GetConfigName());
@@ -126,7 +126,7 @@ void cmNinjaTargetGenerator::AddFeatureFlags(std::string& flags,
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
// Refactor it.
std::string
-cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
+cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile const* source,
const std::string& language)
{
// TODO: Fortran support.
@@ -140,11 +140,11 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
std::string& languageFlags = this->LanguageFlags[language];
if(!hasLangCached)
{
- this->AddFeatureFlags(languageFlags, language.c_str());
+ this->AddFeatureFlags(languageFlags, language);
this->GetLocalGenerator()->AddArchitectureFlags(languageFlags,
this->GeneratorTarget,
- language.c_str(),
+ language,
this->GetConfigName());
// Add shared-library flags if needed.
@@ -153,17 +153,17 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
this->GetConfigName());
this->LocalGenerator->AddVisibilityPresetFlags(languageFlags, this->Target,
- language.c_str());
+ language);
std::vector<std::string> includes;
this->LocalGenerator->GetIncludeDirectories(includes,
this->GeneratorTarget,
- language.c_str(),
+ language,
this->GetConfigName());
// Add include directory flags.
std::string includeFlags =
this->LocalGenerator->GetIncludeFlags(includes, this->GeneratorTarget,
- language.c_str(),
+ language,
language == "RC" ? true : false); // full include paths for RC
// needed by cmcldeps
if(cmGlobalNinjaGenerator::IsMinGW())
@@ -177,7 +177,7 @@ cmNinjaTargetGenerator::ComputeFlagsForObject(cmSourceFile *source,
// Add target-specific flags.
this->LocalGenerator->AddCompileOptions(languageFlags, this->Target,
- language.c_str(),
+ language,
this->GetConfigName());
}
@@ -211,7 +211,7 @@ bool cmNinjaTargetGenerator::needsDepFile(const std::string& lang)
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags().
std::string
cmNinjaTargetGenerator::
-ComputeDefines(cmSourceFile *source, const std::string& language)
+ComputeDefines(cmSourceFile const* source, const std::string& language)
{
std::set<std::string> defines;
@@ -232,12 +232,12 @@ ComputeDefines(cmSourceFile *source, const std::string& language)
defPropName += cmSystemTools::UpperCase(this->GetConfigName());
this->LocalGenerator->AppendDefines
(defines,
- source->GetProperty(defPropName.c_str()));
+ source->GetProperty(defPropName));
}
std::string definesString;
this->LocalGenerator->JoinDefines(defines, definesString,
- language.c_str());
+ language);
return definesString;
}
@@ -269,14 +269,14 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const
std::string
cmNinjaTargetGenerator
-::GetSourceFilePath(cmSourceFile* source) const
+::GetSourceFilePath(cmSourceFile const* source) const
{
return ConvertToNinjaPath(source->GetFullPath().c_str());
}
std::string
cmNinjaTargetGenerator
-::GetObjectFilePath(cmSourceFile* source) const
+::GetObjectFilePath(cmSourceFile const* source) const
{
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if(!path.empty())
@@ -320,6 +320,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
mf->GetDefinition("MSVC_CXX_ARCHITECTURE_ID"))
{
std::string pdbPath;
+ std::string compilePdbPath;
if(this->Target->GetType() == cmTarget::EXECUTABLE ||
this->Target->GetType() == cmTarget::STATIC_LIBRARY ||
this->Target->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -329,11 +330,25 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const
pdbPath += "/";
pdbPath += this->Target->GetPDBName(this->GetConfigName());
}
+ if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY)
+ {
+ compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName());
+ if(compilePdbPath.empty())
+ {
+ compilePdbPath = this->Target->GetSupportDirectory() + "/";
+ }
+ }
vars["TARGET_PDB"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(pdbPath.c_str()).c_str(),
+ ConvertToNinjaPath(pdbPath.c_str()),
cmLocalGenerator::SHELL);
+ vars["TARGET_COMPILE_PDB"] =
+ this->GetLocalGenerator()->ConvertToOutputFormat(
+ ConvertToNinjaPath(compilePdbPath.c_str()),
+ cmLocalGenerator::SHELL);
+
EnsureParentDirectoryExists(pdbPath);
+ EnsureParentDirectoryExists(compilePdbPath);
return true;
}
return false;
@@ -362,6 +377,7 @@ cmNinjaTargetGenerator
vars.Object = "$out";
vars.Defines = "$DEFINES";
vars.TargetPDB = "$TARGET_PDB";
+ vars.TargetCompilePDB = "$TARGET_COMPILE_PDB";
vars.ObjectDir = "$OBJECT_DIR";
cmMakefile* mf = this->GetMakefile();
@@ -402,9 +418,14 @@ cmNinjaTargetGenerator
else
{
deptype = "gcc";
+ const char* langdeptype = mf->GetDefinition("CMAKE_NINJA_DEPTYPE_" + lang);
+ if (langdeptype)
+ {
+ deptype = langdeptype;
+ }
depfile = "$DEP_FILE";
const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
- std::string depfileFlags = mf->GetSafeDefinition(flagsName.c_str());
+ std::string depfileFlags = mf->GetSafeDefinition(flagsName);
if (!depfileFlags.empty())
{
cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
@@ -420,7 +441,7 @@ cmNinjaTargetGenerator
// Rule for compiling object file.
const std::string cmdVar = std::string("CMAKE_") + lang + "_COMPILE_OBJECT";
- std::string compileCmd = mf->GetRequiredDefinition(cmdVar.c_str());
+ std::string compileCmd = mf->GetRequiredDefinition(cmdVar);
std::vector<std::string> compileCmds;
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
@@ -464,63 +485,56 @@ cmNinjaTargetGenerator
<< this->GetTargetName()
<< "\n\n";
- std::vector<cmSourceFile*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
cmCustomCommand const* cc = (*si)->GetCustomCommand();
this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
+ // Record the custom commands for this target. The container is used
+ // in WriteObjectBuildStatement when called in a loop below.
+ this->CustomCommands.push_back((*si)->GetCustomCommand());
}
- std::vector<cmSourceFile*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources);
+ std::vector<cmSourceFile const*> headerSources;
+ this->GeneratorTarget->GetHeaderSources(headerSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources,
this->MacOSXContentGenerator);
- std::vector<cmSourceFile*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources);
+ std::vector<cmSourceFile const*> extraSources;
+ this->GeneratorTarget->GetExtraSources(extraSources, config);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources,
this->MacOSXContentGenerator);
- std::vector<cmSourceFile*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> externalObjects;
+ this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
this->Objects.push_back(this->GetSourceFilePath(*si));
}
- std::vector<cmSourceFile*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> objectSources;
+ this->GeneratorTarget->GetObjectSources(objectSources, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin(); si != objectSources.end(); ++si)
{
this->WriteObjectBuildStatement(*si);
}
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
- {
- this->ModuleDefinitionFile = this->ConvertToNinjaPath(
- this->GeneratorTarget->ModuleDefinitionFile.c_str());
- }
-
- {
- // Add object library contents as external objects.
- std::vector<std::string> objs;
- this->GeneratorTarget->UseObjectLibraries(objs);
- for(std::vector<std::string>::iterator oi = objs.begin();
- oi != objs.end(); ++oi)
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile(config);
+ if(!def.empty())
{
- this->Objects.push_back(ConvertToNinjaPath(oi->c_str()));
+ this->ModuleDefinitionFile = this->ConvertToNinjaPath(def.c_str());
}
- }
this->GetBuildFileStream() << "\n";
}
void
cmNinjaTargetGenerator
-::WriteObjectBuildStatement(cmSourceFile* source)
+::WriteObjectBuildStatement(cmSourceFile const* source)
{
std::string comment;
const std::string language = source->GetLanguage();
@@ -554,14 +568,14 @@ cmNinjaTargetGenerator
}
// Add order-only dependencies on custom command outputs.
- std::vector<cmSourceFile*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands);
- for(std::vector<cmSourceFile*>::const_iterator
- si = customCommands.begin();
- si != customCommands.end(); ++si)
+ for(std::vector<cmCustomCommand const*>::const_iterator
+ cci = this->CustomCommands.begin();
+ cci != this->CustomCommands.end(); ++cci)
{
- cmCustomCommand const* cc = (*si)->GetCustomCommand();
- const std::vector<std::string>& ccoutputs = cc->GetOutputs();
+ cmCustomCommand const* cc = *cci;
+ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
+ this->GetMakefile());
+ const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
std::transform(ccoutputs.begin(), ccoutputs.end(),
std::back_inserter(orderOnlyDeps), MapToNinjaPath());
}
@@ -587,7 +601,7 @@ cmNinjaTargetGenerator
std::string objectDir = this->Target->GetSupportDirectory();
vars["OBJECT_DIR"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- ConvertToNinjaPath(objectDir.c_str()).c_str(),
+ ConvertToNinjaPath(objectDir.c_str()),
cmLocalGenerator::SHELL);
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetTarget(), vars);
@@ -612,7 +626,7 @@ cmNinjaTargetGenerator
escapedSourceFileName =
this->LocalGenerator->ConvertToOutputFormat(
- escapedSourceFileName.c_str(), cmLocalGenerator::SHELL);
+ escapedSourceFileName, cmLocalGenerator::SHELL);
compileObjectVars.Source = escapedSourceFileName.c_str();
compileObjectVars.Object = objectFileName.c_str();
@@ -625,7 +639,7 @@ cmNinjaTargetGenerator
compileCmdVar += language;
compileCmdVar += "_COMPILE_OBJECT";
std::string compileCmd =
- this->GetMakefile()->GetRequiredDefinition(compileCmdVar.c_str());
+ this->GetMakefile()->GetRequiredDefinition(compileCmdVar);
std::vector<std::string> compileCmds;
cmSystemTools::ExpandListArgument(compileCmd, compileCmds);
@@ -683,7 +697,7 @@ cmNinjaTargetGenerator
// vs6's "cl -link" pass it to the linker.
std::string flag = defFileFlag;
flag += (this->LocalGenerator->ConvertToLinkReference(
- this->ModuleDefinitionFile.c_str()));
+ this->ModuleDefinitionFile));
this->LocalGenerator->AppendFlags(flags, flag.c_str());
}
@@ -715,7 +729,7 @@ cmNinjaTargetGenerator
//----------------------------------------------------------------------------
void
cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()(
- cmSourceFile& source, const char* pkgloc)
+ cmSourceFile const& source, const char* pkgloc)
{
// Skip OS X content when not building a Framework or Bundle.
if(!this->Generator->GetTarget()->IsBundleOnApple())
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 43f2279..8073af2 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -65,24 +65,24 @@ protected:
cmMakefile* GetMakefile() const
{ return this->Makefile; }
- const char* GetConfigName() const;
+ std::string const& GetConfigName() const;
std::string LanguageCompilerRule(const std::string& lang) const
{ return lang + "_COMPILER"; }
- const char* GetFeature(const char* feature);
- bool GetFeatureAsBool(const char* feature);
- void AddFeatureFlags(std::string& flags, const char* lang);
+ const char* GetFeature(const std::string& feature);
+ bool GetFeatureAsBool(const std::string& feature);
+ void AddFeatureFlags(std::string& flags, const std::string& lang);
/**
* Compute the flags for compilation of object files for a given @a language.
* @note Generally it is the value of the variable whose name is computed
* by LanguageFlagsVarName().
*/
- std::string ComputeFlagsForObject(cmSourceFile *source,
+ std::string ComputeFlagsForObject(cmSourceFile const* source,
const std::string& language);
- std::string ComputeDefines(cmSourceFile *source,
+ std::string ComputeDefines(cmSourceFile const* source,
const std::string& language);
std::string ConvertToNinjaPath(const char *path) const {
@@ -96,10 +96,10 @@ protected:
cmNinjaDeps ComputeLinkDeps() const;
/// @return the source file path for the given @a source.
- std::string GetSourceFilePath(cmSourceFile* source) const;
+ std::string GetSourceFilePath(cmSourceFile const* source) const;
/// @return the object file path for the given @a source.
- std::string GetObjectFilePath(cmSourceFile* source) const;
+ std::string GetObjectFilePath(cmSourceFile const* source) const;
/// @return the file path where the target named @a name is generated.
std::string GetTargetFilePath(const std::string& name) const;
@@ -110,7 +110,7 @@ protected:
void WriteLanguageRules(const std::string& language);
void WriteCompileRule(const std::string& language);
void WriteObjectBuildStatements();
- void WriteObjectBuildStatement(cmSourceFile* source);
+ void WriteObjectBuildStatement(cmSourceFile const* source);
void WriteCustomCommandBuildStatement(cmCustomCommand *cc);
cmNinjaDeps GetObjects() const
@@ -129,7 +129,7 @@ protected:
MacOSXContentGeneratorType(cmNinjaTargetGenerator* g) :
Generator(g) {}
- void operator()(cmSourceFile& source, const char* pkgloc);
+ void operator()(cmSourceFile const& source, const char* pkgloc);
private:
cmNinjaTargetGenerator* Generator;
@@ -140,7 +140,7 @@ protected:
MacOSXContentGeneratorType* MacOSXContentGenerator;
// Properly initialized by sub-classes.
cmOSXBundleGenerator* OSXBundleGenerator;
- std::set<cmStdString> MacContentFolders;
+ std::set<std::string> MacContentFolders;
void addPoolNinjaVariable(const char* pool_property,
cmTarget* target,
@@ -153,6 +153,7 @@ private:
cmLocalNinjaGenerator* LocalGenerator;
/// List of object files for this target.
cmNinjaDeps Objects;
+ std::vector<cmCustomCommand const*> CustomCommands;
typedef std::map<std::string, std::string> LanguageFlagMap;
LanguageFlagMap LanguageFlags;
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index 1a7b445..f5d18dc 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -17,6 +17,7 @@
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmTarget.h"
+#include "cmCustomCommandGenerator.h"
cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
cmGeneratorTarget *target)
@@ -37,22 +38,28 @@ void cmNinjaUtilityTargetGenerator::Generate()
for (unsigned i = 0; i != 2; ++i) {
for (std::vector<cmCustomCommand>::const_iterator
ci = cmdLists[i]->begin(); ci != cmdLists[i]->end(); ++ci) {
- this->GetLocalGenerator()->AppendCustomCommandDeps(&*ci, deps);
- this->GetLocalGenerator()->AppendCustomCommandLines(&*ci, commands);
+ cmCustomCommandGenerator ccg(*ci, this->GetConfigName(),
+ this->GetMakefile());
+ this->GetLocalGenerator()->AppendCustomCommandDeps(ccg, deps);
+ this->GetLocalGenerator()->AppendCustomCommandLines(ccg, commands);
}
}
std::vector<cmSourceFile*> sources;
- this->GetTarget()->GetSourceFiles(sources);
+ std::string config = this->GetMakefile()
+ ->GetSafeDefinition("CMAKE_BUILD_TYPE");
+ this->GetTarget()->GetSourceFiles(sources, config);
for(std::vector<cmSourceFile*>::const_iterator source = sources.begin();
source != sources.end(); ++source)
{
if(cmCustomCommand* cc = (*source)->GetCustomCommand())
{
+ cmCustomCommandGenerator ccg(*cc, this->GetConfigName(),
+ this->GetMakefile());
this->GetLocalGenerator()->AddCustomCommandTarget(cc, this->GetTarget());
// Depend on all custom command outputs.
- const std::vector<std::string>& ccOutputs = cc->GetOutputs();
+ const std::vector<std::string>& ccOutputs = ccg.GetOutputs();
std::transform(ccOutputs.begin(), ccOutputs.end(),
std::back_inserter(deps), MapToNinjaPath());
}
diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx
index 448d77c..786e6e2 100644
--- a/Source/cmOSXBundleGenerator.cxx
+++ b/Source/cmOSXBundleGenerator.cxx
@@ -19,8 +19,8 @@
//----------------------------------------------------------------------------
cmOSXBundleGenerator::
cmOSXBundleGenerator(cmGeneratorTarget* target,
- const char* configName)
- : Target(target->Target)
+ const std::string& configName)
+ : GT(target)
, Makefile(target->Target->GetMakefile())
, LocalGenerator(Makefile->GetLocalGenerator())
, ConfigName(configName)
@@ -34,7 +34,7 @@ cmOSXBundleGenerator(cmGeneratorTarget* target,
//----------------------------------------------------------------------------
bool cmOSXBundleGenerator::MustSkip()
{
- return !this->Target->HaveWellDefinedOutputFiles();
+ return !this->GT->Target->HaveWellDefinedOutputFiles();
}
//----------------------------------------------------------------------------
@@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
// Compute bundle directory names.
std::string out = outpath;
out += "/";
- out += this->Target->GetAppBundleDirectory(this->ConfigName, false);
+ out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false);
cmSystemTools::MakeDirectory(out.c_str());
this->Makefile->AddCMakeOutputFile(out);
@@ -57,10 +57,10 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName,
// to be set.
std::string plist = outpath;
plist += "/";
- plist += this->Target->GetAppBundleDirectory(this->ConfigName, true);
+ plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true);
plist += "/Info.plist";
- this->LocalGenerator->GenerateAppleInfoPList(this->Target,
- targetName.c_str(),
+ this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,
+ targetName,
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist);
outpath = newoutpath;
@@ -77,21 +77,21 @@ void cmOSXBundleGenerator::CreateFramework(
// Compute the location of the top-level foo.framework directory.
std::string contentdir = outpath + "/" +
- this->Target->GetFrameworkDirectory(this->ConfigName, true);
+ this->GT->Target->GetFrameworkDirectory(this->ConfigName, true);
contentdir += "/";
std::string newoutpath = outpath + "/" +
- this->Target->GetFrameworkDirectory(this->ConfigName, false);
+ this->GT->Target->GetFrameworkDirectory(this->ConfigName, false);
- std::string frameworkVersion = this->Target->GetFrameworkVersion();
+ std::string frameworkVersion = this->GT->Target->GetFrameworkVersion();
// Configure the Info.plist file into the Resources directory.
this->MacContentFolders->insert("Resources");
std::string plist = newoutpath;
plist += "/Resources/Info.plist";
std::string name = cmSystemTools::GetFilenameName(targetName);
- this->LocalGenerator->GenerateFrameworkInfoPList(this->Target,
- name.c_str(),
+ this->LocalGenerator->GenerateFrameworkInfoPList(this->GT->Target,
+ name,
plist.c_str());
// TODO: Use the cmMakefileTargetGenerator::ExtraFiles vector to
@@ -172,17 +172,17 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
// Compute bundle directory names.
std::string out = root;
out += "/";
- out += this->Target->GetCFBundleDirectory(this->ConfigName, false);
+ out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false);
cmSystemTools::MakeDirectory(out.c_str());
this->Makefile->AddCMakeOutputFile(out);
// Configure the Info.plist file. Note that it needs the executable name
// to be set.
std::string plist = root + "/" +
- this->Target->GetCFBundleDirectory(this->ConfigName, true);
+ this->GT->Target->GetCFBundleDirectory(this->ConfigName, true);
plist += "/Info.plist";
- this->LocalGenerator->GenerateAppleInfoPList(this->Target,
- targetName.c_str(),
+ this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target,
+ targetName,
plist.c_str());
this->Makefile->AddCMakeOutputFile(plist);
}
@@ -190,18 +190,19 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName,
//----------------------------------------------------------------------------
void
cmOSXBundleGenerator::
-GenerateMacOSXContentStatements(std::vector<cmSourceFile*> const& sources,
- MacOSXContentGeneratorType* generator)
+GenerateMacOSXContentStatements(
+ std::vector<cmSourceFile const*> const& sources,
+ MacOSXContentGeneratorType* generator)
{
if (this->MustSkip())
return;
- for(std::vector<cmSourceFile*>::const_iterator
+ for(std::vector<cmSourceFile const*>::const_iterator
si = sources.begin(); si != sources.end(); ++si)
{
- cmTarget::SourceFileFlags tsFlags =
- this->Target->GetTargetSourceFileFlags(*si);
- if(tsFlags.Type != cmTarget::SourceFileTypeNormal)
+ cmGeneratorTarget::SourceFileFlags tsFlags =
+ this->GT->GetTargetSourceFileFlags(*si);
+ if(tsFlags.Type != cmGeneratorTarget::SourceFileTypeNormal)
{
(*generator)(**si, tsFlags.MacFolder);
}
@@ -215,7 +216,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc)
// Construct the full path to the content subdirectory.
std::string macdir =
- this->Target->GetMacContentDirectory(this->ConfigName,
+ this->GT->Target->GetMacContentDirectory(this->ConfigName,
/*implib*/ false);
macdir += "/";
macdir += pkgloc;
diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h
index 29b7611..f945c15 100644
--- a/Source/cmOSXBundleGenerator.h
+++ b/Source/cmOSXBundleGenerator.h
@@ -27,7 +27,7 @@ class cmOSXBundleGenerator
{
public:
cmOSXBundleGenerator(cmGeneratorTarget* target,
- const char* configName);
+ const std::string& configName);
// create an app bundle at a given root, and return
// the directory within the bundle that contains the executable
@@ -44,26 +44,27 @@ public:
struct MacOSXContentGeneratorType
{
virtual ~MacOSXContentGeneratorType() {}
- virtual void operator()(cmSourceFile& source, const char* pkgloc) = 0;
+ virtual void operator()(cmSourceFile const& source,
+ const char* pkgloc) = 0;
};
void GenerateMacOSXContentStatements(
- std::vector<cmSourceFile*> const& sources,
+ std::vector<cmSourceFile const*> const& sources,
MacOSXContentGeneratorType* generator);
std::string InitMacOSXContentDirectory(const char* pkgloc);
- void SetMacContentFolders(std::set<cmStdString>* macContentFolders)
+ void SetMacContentFolders(std::set<std::string>* macContentFolders)
{ this->MacContentFolders = macContentFolders; }
private:
bool MustSkip();
private:
- cmTarget* Target;
+ cmGeneratorTarget* GT;
cmMakefile* Makefile;
cmLocalGenerator* LocalGenerator;
- const char* ConfigName;
- std::set<cmStdString>* MacContentFolders;
+ std::string ConfigName;
+ std::set<std::string>* MacContentFolders;
};
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index 776a3a4..e505440 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -39,7 +39,7 @@ bool cmOptionCommand
m += args[i];
m += " ";
}
- this->SetError(m.c_str());
+ this->SetError(m);
return false;
}
@@ -55,17 +55,14 @@ bool cmOptionCommand
it.SetProperty("HELPSTRING", args[1].c_str());
return true;
}
- if ( it.GetValue() )
- {
- initialValue = it.GetValue();
- }
+ initialValue = it.GetValue();
}
if(args.size() == 3)
{
initialValue = args[2];
}
bool init = cmSystemTools::IsOn(initialValue.c_str());
- this->Makefile->AddCacheDefinition(args[0].c_str(), init? "ON":"OFF",
+ this->Makefile->AddCacheDefinition(args[0], init? "ON":"OFF",
args[1].c_str(), cmCacheManager::BOOL);
return true;
}
diff --git a/Source/cmOptionCommand.h b/Source/cmOptionCommand.h
index 89e3ac1..12a6472 100644
--- a/Source/cmOptionCommand.h
+++ b/Source/cmOptionCommand.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "option";}
+ virtual std::string GetName() const {return "option";}
/**
* This determines if the command is invoked when in script mode.
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index 86beb97..ec671fc 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -138,9 +138,9 @@ bool cmOrderDirectoriesConstraint::FileMayConflict(std::string const& dir,
}
// Check if the file will be built by cmake.
- std::set<cmStdString> const& files =
+ std::set<std::string> const& files =
(this->GlobalGenerator->GetDirectoryContent(dir, false));
- std::set<cmStdString>::const_iterator fi = files.find(name);
+ std::set<std::string>::const_iterator fi = files.find(name);
return fi != files.end();
}
@@ -200,7 +200,7 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir)
{
// We do not have the soname. Look for files in the directory
// that may conflict.
- std::set<cmStdString> const& files =
+ std::set<std::string> const& files =
(this->GlobalGenerator
->GetDirectoryContent(dir, true));
@@ -208,9 +208,9 @@ bool cmOrderDirectoriesConstraintSOName::FindConflict(std::string const& dir)
// know the soname just look at all files that start with the
// file name. Usually the soname starts with the library name.
std::string base = this->FileName;
- std::set<cmStdString>::const_iterator first = files.lower_bound(base);
+ std::set<std::string>::const_iterator first = files.lower_bound(base);
++base[base.size()-1];
- std::set<cmStdString>::const_iterator last = files.upper_bound(base);
+ std::set<std::string>::const_iterator last = files.upper_bound(base);
if(first != last)
{
return true;
@@ -251,8 +251,8 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir)
if(!this->OD->LinkExtensions.empty() &&
this->OD->RemoveLibraryExtension.find(this->FileName))
{
- cmStdString lib = this->OD->RemoveLibraryExtension.match(1);
- cmStdString ext = this->OD->RemoveLibraryExtension.match(2);
+ std::string lib = this->OD->RemoveLibraryExtension.match(1);
+ std::string ext = this->OD->RemoveLibraryExtension.match(2);
for(std::vector<std::string>::iterator
i = this->OD->LinkExtensions.begin();
i != this->OD->LinkExtensions.end(); ++i)
@@ -261,7 +261,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir)
{
std::string fname = lib;
fname += *i;
- if(this->FileMayConflict(dir, fname.c_str()))
+ if(this->FileMayConflict(dir, fname))
{
return true;
}
@@ -407,7 +407,7 @@ cmOrderDirectories
//----------------------------------------------------------------------------
void
cmOrderDirectories
-::SetImplicitDirectories(std::set<cmStdString> const& implicitDirs)
+::SetImplicitDirectories(std::set<std::string> const& implicitDirs)
{
this->ImplicitDirectories = implicitDirs;
}
@@ -444,11 +444,11 @@ void cmOrderDirectories::CollectOriginalDirectories()
int cmOrderDirectories::AddOriginalDirectory(std::string const& dir)
{
// Add the runtime directory with a unique index.
- std::map<cmStdString, int>::iterator i =
+ std::map<std::string, int>::iterator i =
this->DirectoryIndex.find(dir);
if(i == this->DirectoryIndex.end())
{
- std::map<cmStdString, int>::value_type
+ std::map<std::string, int>::value_type
entry(dir, static_cast<int>(this->OriginalDirectories.size()));
i = this->DirectoryIndex.insert(entry).first;
this->OriginalDirectories.push_back(dir);
diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h
index 76bf429..07c85dd 100644
--- a/Source/cmOrderDirectories.h
+++ b/Source/cmOrderDirectories.h
@@ -34,7 +34,7 @@ public:
void AddLinkLibrary(std::string const& fullPath);
void AddUserDirectories(std::vector<std::string> const& extra);
void AddLanguageDirectories(std::vector<std::string> const& dirs);
- void SetImplicitDirectories(std::set<cmStdString> const& implicitDirs);
+ void SetImplicitDirectories(std::set<std::string> const& implicitDirs);
void SetLinkExtensionInfo(std::vector<std::string> const& linkExtensions,
std::string const& removeExtRegex);
@@ -54,11 +54,11 @@ private:
std::vector<std::string> LanguageDirectories;
cmsys::RegularExpression RemoveLibraryExtension;
std::vector<std::string> LinkExtensions;
- std::set<cmStdString> ImplicitDirectories;
- std::set<cmStdString> EmmittedConstraintSOName;
- std::set<cmStdString> EmmittedConstraintLibrary;
+ std::set<std::string> ImplicitDirectories;
+ std::set<std::string> EmmittedConstraintSOName;
+ std::set<std::string> EmmittedConstraintLibrary;
std::vector<std::string> OriginalDirectories;
- std::map<cmStdString, int> DirectoryIndex;
+ std::map<std::string, int> DirectoryIndex;
std::vector<int> DirectoryVisited;
void CollectOriginalDirectories();
int AddOriginalDirectory(std::string const& dir);
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index c0d9e99..5016493 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -202,7 +202,7 @@ bool cmOutputRequiredFilesCommand
{
std::string err = "Can not open output file: ";
err += this->OutputFile;
- this->SetError(err.c_str());
+ this->SetError(err);
return false;
}
std::set<cmDependInformation const*> visited;
diff --git a/Source/cmOutputRequiredFilesCommand.h b/Source/cmOutputRequiredFilesCommand.h
index dd5ed6c..95eba38 100644
--- a/Source/cmOutputRequiredFilesCommand.h
+++ b/Source/cmOutputRequiredFilesCommand.h
@@ -22,7 +22,7 @@ public:
virtual cmCommand* Clone() { return new cmOutputRequiredFilesCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const { return "output_required_files";}
+ virtual std::string GetName() const { return "output_required_files";}
virtual bool IsDiscouraged() const { return true; }
void ListDependencies(cmDependInformation const *info,
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 93072f5..309f280 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -343,6 +343,17 @@ cmPolicies::cmPolicies()
CMP0050, "CMP0050",
"Disallow add_custom_command SOURCE signatures.",
3,0,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0051, "CMP0051",
+ "List TARGET_OBJECTS in SOURCES target property.",
+ 3,1,0, cmPolicies::WARN);
+
+ this->DefinePolicy(
+ CMP0052, "CMP0052",
+ "Reject source and build dirs in installed "
+ "INTERFACE_INCLUDE_DIRECTORIES.",
+ 3,1,0, cmPolicies::WARN);
}
cmPolicies::~cmPolicies()
@@ -488,7 +499,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmPolicies::PolicyStatus* defaultSetting)
{
std::string defaultVar = "CMAKE_POLICY_DEFAULT_" + policy;
- std::string defaultValue = mf->GetSafeDefinition(defaultVar.c_str());
+ std::string defaultValue = mf->GetSafeDefinition(defaultVar);
if(defaultValue == "NEW")
{
*defaultSetting = cmPolicies::NEW;
@@ -506,7 +517,7 @@ bool cmPolicies::GetPolicyDefault(cmMakefile* mf, std::string const& policy,
cmOStringStream e;
e << defaultVar << " has value \"" << defaultValue
<< "\" but must be \"OLD\", \"NEW\", or \"\" (empty).";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
@@ -651,5 +662,5 @@ cmPolicies::DiagnoseAncientPolicies(std::vector<PolicyID> const& ancient,
<< "Please either update your CMakeLists.txt files to conform to "
<< "the new behavior or use an older version of CMake that still "
<< "supports the old behavior.";
- mf->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ mf->IssueMessage(cmake::FATAL_ERROR, e.str());
}
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index b77235d..60f35c2 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -104,6 +104,9 @@ public:
CMP0048, ///< project() command manages VERSION variables
CMP0049, ///< Do not expand variables in target source entries
CMP0050, ///< Disallow add_custom_command SOURCE signatures
+ CMP0051, ///< List TARGET_OBJECTS in SOURCES target property
+ CMP0052, ///< Reject source and build dirs in installed
+ /// INTERFACE_INCLUDE_DIRECTORIES
/** \brief Always the last entry.
*
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index a9ce0cc..12318c8 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -28,20 +28,20 @@ bool cmProjectCommand
srcdir += "_SOURCE_DIR";
this->Makefile->AddCacheDefinition
- (bindir.c_str(),
+ (bindir,
this->Makefile->GetCurrentOutputDirectory(),
"Value Computed by CMake", cmCacheManager::STATIC);
this->Makefile->AddCacheDefinition
- (srcdir.c_str(),
+ (srcdir,
this->Makefile->GetCurrentDirectory(),
"Value Computed by CMake", cmCacheManager::STATIC);
bindir = "PROJECT_BINARY_DIR";
srcdir = "PROJECT_SOURCE_DIR";
- this->Makefile->AddDefinition(bindir.c_str(),
+ this->Makefile->AddDefinition(bindir,
this->Makefile->GetCurrentOutputDirectory());
- this->Makefile->AddDefinition(srcdir.c_str(),
+ this->Makefile->AddDefinition(srcdir,
this->Makefile->GetCurrentDirectory());
this->Makefile->AddDefinition("PROJECT_NAME", args[0].c_str());
@@ -167,19 +167,19 @@ bool cmProjectCommand
std::string vv;
vv = args[0] + "_VERSION";
this->Makefile->AddDefinition("PROJECT_VERSION", vs.c_str());
- this->Makefile->AddDefinition(vv.c_str(), vs.c_str());
+ this->Makefile->AddDefinition(vv, vs.c_str());
vv = args[0] + "_VERSION_MAJOR";
this->Makefile->AddDefinition("PROJECT_VERSION_MAJOR", vb[0]);
- this->Makefile->AddDefinition(vv.c_str(), vb[0]);
+ this->Makefile->AddDefinition(vv, vb[0]);
vv = args[0] + "_VERSION_MINOR";
this->Makefile->AddDefinition("PROJECT_VERSION_MINOR", vb[1]);
- this->Makefile->AddDefinition(vv.c_str(), vb[1]);
+ this->Makefile->AddDefinition(vv, vb[1]);
vv = args[0] + "_VERSION_PATCH";
this->Makefile->AddDefinition("PROJECT_VERSION_PATCH", vb[2]);
- this->Makefile->AddDefinition(vv.c_str(), vb[2]);
+ this->Makefile->AddDefinition(vv, vb[2]);
vv = args[0] + "_VERSION_TWEAK";
this->Makefile->AddDefinition("PROJECT_VERSION_TWEAK", vb[3]);
- this->Makefile->AddDefinition(vv.c_str(), vb[3]);
+ this->Makefile->AddDefinition(vv, vb[3]);
}
else if(cmp0048 != cmPolicies::OLD)
{
@@ -199,7 +199,7 @@ bool cmProjectCommand
for(std::vector<std::string>::iterator i = vv.begin();
i != vv.end(); ++i)
{
- const char* v = this->Makefile->GetDefinition(i->c_str());
+ const char* v = this->Makefile->GetDefinition(*i);
if(v && *v)
{
if(cmp0048 == cmPolicies::WARN)
@@ -209,7 +209,7 @@ bool cmProjectCommand
}
else
{
- this->Makefile->AddDefinition(i->c_str(), "");
+ this->Makefile->AddDefinition(*i, "");
}
}
}
@@ -231,7 +231,7 @@ bool cmProjectCommand
}
this->Makefile->EnableLanguage(languages, false);
std::string extraInclude = "CMAKE_PROJECT_" + args[0] + "_INCLUDE";
- const char* include = this->Makefile->GetDefinition(extraInclude.c_str());
+ const char* include = this->Makefile->GetDefinition(extraInclude);
if(include)
{
std::string fullFilePath;
@@ -244,7 +244,7 @@ bool cmProjectCommand
"could not find file:\n"
" ";
m += include;
- this->SetError(m.c_str());
+ this->SetError(m);
return false;
}
}
diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h
index f7d086d..7aacb55 100644
--- a/Source/cmProjectCommand.h
+++ b/Source/cmProjectCommand.h
@@ -43,7 +43,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "project";}
+ virtual std::string GetName() const {return "project";}
cmTypeMacro(cmProjectCommand, cmCommand);
};
diff --git a/Source/cmProperty.cxx b/Source/cmProperty.cxx
index 3b37cf3..40976db 100644
--- a/Source/cmProperty.cxx
+++ b/Source/cmProperty.cxx
@@ -12,14 +12,15 @@
#include "cmProperty.h"
#include "cmSystemTools.h"
-void cmProperty::Set(const char *name, const char *value)
+void cmProperty::Set(const std::string& name, const char *value)
{
this->Name = name;
this->Value = value;
this->ValueHasBeenSet = true;
}
-void cmProperty::Append(const char *name, const char *value, bool asString)
+void cmProperty::Append(const std::string& name, const char *value,
+ bool asString)
{
this->Name = name;
if(!this->Value.empty() && *value && !asString)
diff --git a/Source/cmProperty.h b/Source/cmProperty.h
index bb75bb0..34897e8 100644
--- a/Source/cmProperty.h
+++ b/Source/cmProperty.h
@@ -21,16 +21,17 @@ public:
TEST, VARIABLE, CACHED_VARIABLE };
// set this property
- void Set(const char *name, const char *value);
+ void Set(const std::string& name, const char *value);
// append to this property
- void Append(const char *name, const char *value, bool asString = false);
+ void Append(const std::string& name, const char *value,
+ bool asString = false);
// get the value
const char *GetValue() const;
// construct with the value not set
- cmProperty() { this->ValueHasBeenSet = false; };
+ cmProperty() { this->ValueHasBeenSet = false; }
protected:
std::string Name;
diff --git a/Source/cmPropertyDefinition.cxx b/Source/cmPropertyDefinition.cxx
index abc57ce..1af967c 100644
--- a/Source/cmPropertyDefinition.cxx
+++ b/Source/cmPropertyDefinition.cxx
@@ -13,7 +13,7 @@
#include "cmSystemTools.h"
void cmPropertyDefinition
-::DefineProperty(const char *name, cmProperty::ScopeType scope,
+::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *shortDescription,
const char *fullDescription,
bool chain)
diff --git a/Source/cmPropertyDefinition.h b/Source/cmPropertyDefinition.h
index 1b6a7a6..098fadb 100644
--- a/Source/cmPropertyDefinition.h
+++ b/Source/cmPropertyDefinition.h
@@ -27,28 +27,28 @@ class cmPropertyDefinition
{
public:
/// Define this property
- void DefineProperty(const char *name, cmProperty::ScopeType scope,
+ void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained);
/// Default constructor
- cmPropertyDefinition() { this->Chained = false; };
+ cmPropertyDefinition() { this->Chained = false; }
/// Is the property chained?
- bool IsChained() const { return this->Chained; };
+ bool IsChained() const { return this->Chained; }
/// Get the scope
cmProperty::ScopeType GetScope() const {
- return this->Scope; };
+ return this->Scope; }
/// Get the documentation (short version)
const std::string &GetShortDescription() const {
- return this->ShortDescription; };
+ return this->ShortDescription; }
/// Get the documentation (full version)
const std::string &GetFullDescription() const {
- return this->FullDescription; };
+ return this->FullDescription; }
protected:
std::string Name;
diff --git a/Source/cmPropertyDefinitionMap.cxx b/Source/cmPropertyDefinitionMap.cxx
index db29504..3875318 100644
--- a/Source/cmPropertyDefinitionMap.cxx
+++ b/Source/cmPropertyDefinitionMap.cxx
@@ -14,16 +14,11 @@
#include "cmDocumentationSection.h"
void cmPropertyDefinitionMap
-::DefineProperty(const char *name, cmProperty::ScopeType scope,
+::DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain)
{
- if (!name)
- {
- return;
- }
-
cmPropertyDefinitionMap::iterator it = this->find(name);
cmPropertyDefinition *prop;
if (it == this->end())
@@ -34,13 +29,8 @@ void cmPropertyDefinitionMap
}
}
-bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
+bool cmPropertyDefinitionMap::IsPropertyDefined(const std::string& name)
{
- if (!name)
- {
- return false;
- }
-
cmPropertyDefinitionMap::iterator it = this->find(name);
if (it == this->end())
{
@@ -50,13 +40,8 @@ bool cmPropertyDefinitionMap::IsPropertyDefined(const char *name)
return true;
}
-bool cmPropertyDefinitionMap::IsPropertyChained(const char *name)
+bool cmPropertyDefinitionMap::IsPropertyChained(const std::string& name)
{
- if (!name)
- {
- return false;
- }
-
cmPropertyDefinitionMap::iterator it = this->find(name);
if (it == this->end())
{
diff --git a/Source/cmPropertyDefinitionMap.h b/Source/cmPropertyDefinitionMap.h
index 736e243..00c7328 100644
--- a/Source/cmPropertyDefinitionMap.h
+++ b/Source/cmPropertyDefinitionMap.h
@@ -17,20 +17,20 @@
class cmDocumentationSection;
class cmPropertyDefinitionMap :
-public std::map<cmStdString,cmPropertyDefinition>
+public std::map<std::string,cmPropertyDefinition>
{
public:
// define the property
- void DefineProperty(const char *name, cmProperty::ScopeType scope,
+ void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain);
// has a named property been defined
- bool IsPropertyDefined(const char *name);
+ bool IsPropertyDefined(const std::string& name);
// is a named property set to chain
- bool IsPropertyChained(const char *name);
+ bool IsPropertyChained(const std::string& name);
};
#endif
diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx
index e94e3e9..e335b3b 100644
--- a/Source/cmPropertyMap.cxx
+++ b/Source/cmPropertyMap.cxx
@@ -13,7 +13,7 @@
#include "cmSystemTools.h"
#include "cmake.h"
-cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
+cmProperty *cmPropertyMap::GetOrCreateProperty(const std::string& name)
{
cmPropertyMap::iterator it = this->find(name);
cmProperty *prop;
@@ -28,13 +28,9 @@ cmProperty *cmPropertyMap::GetOrCreateProperty(const char *name)
return prop;
}
-void cmPropertyMap::SetProperty(const char *name, const char *value,
+void cmPropertyMap::SetProperty(const std::string& name, const char *value,
cmProperty::ScopeType scope)
{
- if (!name)
- {
- return;
- }
if(!value)
{
this->erase(name);
@@ -46,11 +42,11 @@ void cmPropertyMap::SetProperty(const char *name, const char *value,
prop->Set(name,value);
}
-void cmPropertyMap::AppendProperty(const char* name, const char* value,
+void cmPropertyMap::AppendProperty(const std::string& name, const char* value,
cmProperty::ScopeType scope, bool asString)
{
// Skip if nothing to append.
- if(!name || !value || !*value)
+ if(!value || !*value)
{
return;
}
@@ -61,12 +57,12 @@ void cmPropertyMap::AppendProperty(const char* name, const char* value,
}
const char *cmPropertyMap
-::GetPropertyValue(const char *name,
+::GetPropertyValue(const std::string& name,
cmProperty::ScopeType scope,
bool &chain) const
{
chain = false;
- if (!name)
+ if (name.empty())
{
return 0;
}
diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h
index 0c3aad4..02d4235 100644
--- a/Source/cmPropertyMap.h
+++ b/Source/cmPropertyMap.h
@@ -16,24 +16,24 @@
class cmake;
-class cmPropertyMap : public std::map<cmStdString,cmProperty>
+class cmPropertyMap : public std::map<std::string,cmProperty>
{
public:
- cmProperty *GetOrCreateProperty(const char *name);
+ cmProperty *GetOrCreateProperty(const std::string& name);
- void SetProperty(const char *name, const char *value,
+ void SetProperty(const std::string& name, const char *value,
cmProperty::ScopeType scope);
- void AppendProperty(const char* name, const char* value,
+ void AppendProperty(const std::string& name, const char* value,
cmProperty::ScopeType scope, bool asString=false);
- const char *GetPropertyValue(const char *name,
+ const char *GetPropertyValue(const std::string& name,
cmProperty::ScopeType scope,
bool &chain) const;
- void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; };
+ void SetCMakeInstance(cmake *cm) { this->CMakeInstance = cm; }
- cmPropertyMap() { this->CMakeInstance = 0;};
+ cmPropertyMap() { this->CMakeInstance = 0;}
private:
cmake *CMakeInstance;
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index 0d3c994..a984260 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -32,13 +32,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn,
// Get the variable holding the list of sources.
std::string const& sourceList = args[1];
std::string sourceListValue =
- this->Makefile->GetSafeDefinition(sourceList.c_str());
+ this->Makefile->GetSafeDefinition(sourceList);
// Create a rule for all sources listed.
for(std::vector<std::string>::iterator j = (args.begin() + 2);
j != args.end(); ++j)
{
- cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
+ cmSourceFile *curr = this->Makefile->GetSource(*j);
// if we should wrap the class
if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
{
@@ -50,7 +50,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn,
newName += srcName;
newName += ".cxx";
cmSourceFile* sf =
- this->Makefile->GetOrCreateSource(newName.c_str(), true);
+ this->Makefile->GetOrCreateSource(newName, true);
if (curr)
{
sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
@@ -97,9 +97,9 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn,
depends.push_back(moc_exe);
depends.push_back(hname);
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
const char* no_working_dir = 0;
- this->Makefile->AddCustomCommandToOutput(newName.c_str(),
+ this->Makefile->AddCustomCommandToOutput(newName,
depends,
no_main_dependency,
commandLines,
@@ -109,7 +109,7 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& argsIn,
}
// Store the final list of source files.
- this->Makefile->AddDefinition(sourceList.c_str(),
+ this->Makefile->AddDefinition(sourceList,
sourceListValue.c_str());
return true;
}
diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h
index 868eb91..85729dd 100644
--- a/Source/cmQTWrapCPPCommand.h
+++ b/Source/cmQTWrapCPPCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "qt_wrap_cpp";}
+ virtual std::string GetName() const { return "qt_wrap_cpp";}
};
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index a6a4b51..dce59ef 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -35,15 +35,15 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn,
std::string const& headerList = args[1];
std::string const& sourceList = args[2];
std::string headerListValue =
- this->Makefile->GetSafeDefinition(headerList.c_str());
+ this->Makefile->GetSafeDefinition(headerList);
std::string sourceListValue =
- this->Makefile->GetSafeDefinition(sourceList.c_str());
+ this->Makefile->GetSafeDefinition(sourceList);
// Create rules for all sources listed.
for(std::vector<std::string>::iterator j = (args.begin() + 3);
j != args.end(); ++j)
{
- cmSourceFile *curr = this->Makefile->GetSource(j->c_str());
+ cmSourceFile *curr = this->Makefile->GetSource(*j);
// if we should wrap the class
if(!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE")))
{
@@ -128,10 +128,10 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn,
std::vector<std::string> depends;
depends.push_back(uiName);
- const char* no_main_dependency = 0;
+ std::string no_main_dependency = "";
const char* no_comment = 0;
const char* no_working_dir = 0;
- this->Makefile->AddCustomCommandToOutput(hName.c_str(),
+ this->Makefile->AddCustomCommandToOutput(hName,
depends,
no_main_dependency,
hCommandLines,
@@ -139,7 +139,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn,
no_working_dir);
depends.push_back(hName);
- this->Makefile->AddCustomCommandToOutput(cxxName.c_str(),
+ this->Makefile->AddCustomCommandToOutput(cxxName,
depends,
no_main_dependency,
cxxCommandLines,
@@ -148,7 +148,7 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn,
depends.clear();
depends.push_back(hName);
- this->Makefile->AddCustomCommandToOutput(mocName.c_str(),
+ this->Makefile->AddCustomCommandToOutput(mocName,
depends,
no_main_dependency,
mocCommandLines,
@@ -158,9 +158,9 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& argsIn,
}
// Store the final list of source files and headers.
- this->Makefile->AddDefinition(sourceList.c_str(),
+ this->Makefile->AddDefinition(sourceList,
sourceListValue.c_str());
- this->Makefile->AddDefinition(headerList.c_str(),
+ this->Makefile->AddDefinition(headerList,
headerListValue.c_str());
return true;
}
diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h
index 3406dac..4aa9a61 100644
--- a/Source/cmQTWrapUICommand.h
+++ b/Source/cmQTWrapUICommand.h
@@ -43,7 +43,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "qt_wrap_ui";}
+ virtual std::string GetName() const { return "qt_wrap_ui";}
};
diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx
index 2c5dd45..cc6932d 100644
--- a/Source/cmQtAutoGenerators.cxx
+++ b/Source/cmQtAutoGenerators.cxx
@@ -105,7 +105,7 @@ static std::string extractSubDir(const std::string& absPath,
static void copyTargetProperty(cmTarget* destinationTarget,
cmTarget* sourceTarget,
- const char* propertyName)
+ const std::string& propertyName)
{
const char* propertyValue = sourceTarget->GetProperty(propertyName);
if (propertyValue)
@@ -187,13 +187,11 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
mocCppFile += "/";
mocCppFile += automocTargetName;
mocCppFile += ".cpp";
- cmSourceFile* mocCppSource = makefile->GetOrCreateSource(
- mocCppFile.c_str(),
- true);
+ makefile->GetOrCreateSource(mocCppFile, true);
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
mocCppFile.c_str(), false);
- target->AddSourceFile(mocCppSource);
+ target->AddSource(mocCppFile);
}
// create a custom target for running generators at buildtime:
std::string autogenTargetName = getAutogenTargetName(target);
@@ -251,7 +249,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
bool usePRE_BUILD = false;
cmLocalGenerator* localGen = makefile->GetLocalGenerator();
cmGlobalGenerator* gg = localGen->GetGlobalGenerator();
- if(strstr(gg->GetName(), "Visual Studio"))
+ if(gg->GetName().find("Visual Studio") != std::string::npos)
{
cmLocalVisualStudioGenerator* vslg =
static_cast<cmLocalVisualStudioGenerator*>(localGen);
@@ -290,7 +288,7 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
#endif
{
cmTarget* autogenTarget = makefile->AddUtilityCommand(
- autogenTargetName.c_str(), true,
+ autogenTargetName, true,
workingDirectory.c_str(), depends,
commandLines, false, autogenComment.c_str());
// Set target folder
@@ -311,14 +309,14 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmTarget* target)
copyTargetProperty(autogenTarget, target, "FOLDER");
}
- target->AddUtility(autogenTargetName.c_str());
+ target->AddUtility(autogenTargetName);
}
return true;
}
static void GetCompileDefinitionsAndDirectories(cmTarget const* target,
- const char * config,
+ const std::string& config,
std::string &incs,
std::string &defs)
{
@@ -368,7 +366,9 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
std::string autogenTargetName = getAutogenTargetName(target);
makefile->AddDefinition("_moc_target_name",
- cmLocalGenerator::EscapeForCMake(autogenTargetName.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(autogenTargetName).c_str());
+ makefile->AddDefinition("_origin_target_name",
+ cmLocalGenerator::EscapeForCMake(target->GetName()).c_str());
std::string targetDir = getAutogenTargetDir(target);
@@ -378,7 +378,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR");
}
if (const char *targetQtVersion =
- target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", 0))
+ target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", ""))
{
qtVersion = targetQtVersion;
}
@@ -397,7 +397,7 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target)
this->SetupSourceFiles(target);
}
makefile->AddDefinition("_cpp_files",
- cmLocalGenerator::EscapeForCMake(this->Sources.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(this->Sources).c_str());
if (target->GetPropertyAsBool("AUTOMOC"))
{
this->SetupAutoMocTarget(target, autogenTargetName,
@@ -474,12 +474,12 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
const char* sepHeaders = "";
std::vector<cmSourceFile*> srcFiles;
- target->GetSourceFiles(srcFiles);
+ target->GetConfigCommonSourceFiles(srcFiles);
const char *skipMocSep = "";
const char *skipUicSep = "";
- std::vector<cmSourceFile*> newRccFiles;
+ std::vector<std::string> newRccFiles;
for(std::vector<cmSourceFile*>::const_iterator fileIt = srcFiles.begin();
fileIt != srcFiles.end();
@@ -508,13 +508,14 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
std::string basename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(absFile);
- std::string rcc_output_file = makefile->GetCurrentOutputDirectory();
+ 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";
makefile->AppendProperty("ADDITIONAL_MAKE_CLEAN_FILES",
rcc_output_file.c_str(), false);
- cmSourceFile* rccCppSource
- = makefile->GetOrCreateSource(rcc_output_file.c_str(), true);
- newRccFiles.push_back(rccCppSource);
+ makefile->GetOrCreateSource(rcc_output_file, true);
+ newRccFiles.push_back(rcc_output_file);
}
}
@@ -546,11 +547,11 @@ void cmQtAutoGenerators::SetupSourceFiles(cmTarget const* target)
}
}
- for(std::vector<cmSourceFile*>::const_iterator fileIt = newRccFiles.begin();
+ for(std::vector<std::string>::const_iterator fileIt = newRccFiles.begin();
fileIt != newRccFiles.end();
++fileIt)
{
- const_cast<cmTarget*>(target)->AddSourceFile(*fileIt);
+ const_cast<cmTarget*>(target)->AddSource(*fileIt);
}
}
@@ -564,38 +565,38 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
const char* tmp = target->GetProperty("AUTOMOC_MOC_OPTIONS");
std::string _moc_options = (tmp!=0 ? tmp : "");
makefile->AddDefinition("_moc_options",
- cmLocalGenerator::EscapeForCMake(_moc_options.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(_moc_options).c_str());
makefile->AddDefinition("_skip_moc",
- cmLocalGenerator::EscapeForCMake(this->SkipMoc.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(this->SkipMoc).c_str());
makefile->AddDefinition("_moc_headers",
- cmLocalGenerator::EscapeForCMake(this->Headers.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(this->Headers).c_str());
bool relaxedMode = makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE");
makefile->AddDefinition("_moc_relaxed_mode", relaxedMode ? "TRUE" : "FALSE");
std::string _moc_incs;
std::string _moc_compile_defs;
std::vector<std::string> configs;
- const char *config = makefile->GetConfigurations(configs);
+ const std::string& config = makefile->GetConfigurations(configs);
GetCompileDefinitionsAndDirectories(target, config,
_moc_incs, _moc_compile_defs);
makefile->AddDefinition("_moc_incs",
- cmLocalGenerator::EscapeForCMake(_moc_incs.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(_moc_incs).c_str());
makefile->AddDefinition("_moc_compile_defs",
- cmLocalGenerator::EscapeForCMake(_moc_compile_defs.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(_moc_compile_defs).c_str());
for (std::vector<std::string>::const_iterator li = configs.begin();
li != configs.end(); ++li)
{
std::string config_moc_incs;
std::string config_moc_compile_defs;
- GetCompileDefinitionsAndDirectories(target, li->c_str(),
+ GetCompileDefinitionsAndDirectories(target, *li,
config_moc_incs,
config_moc_compile_defs);
if (config_moc_incs != _moc_incs)
{
configIncludes[*li] =
- cmLocalGenerator::EscapeForCMake(config_moc_incs.c_str());
+ cmLocalGenerator::EscapeForCMake(config_moc_incs);
if(_moc_incs.empty())
{
_moc_incs = config_moc_incs;
@@ -604,7 +605,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
if (config_moc_compile_defs != _moc_compile_defs)
{
configDefines[*li] =
- cmLocalGenerator::EscapeForCMake(config_moc_compile_defs.c_str());
+ cmLocalGenerator::EscapeForCMake(config_moc_compile_defs);
if(_moc_compile_defs.empty())
{
_moc_compile_defs = config_moc_compile_defs;
@@ -622,7 +623,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
autogenTargetName.c_str());
return;
}
- makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(0));
+ makefile->AddDefinition("_qt_moc_executable", qt5Moc->GetLocation(""));
}
else if (strcmp(qtVersion, "4") == 0)
{
@@ -633,7 +634,7 @@ void cmQtAutoGenerators::SetupAutoMocTarget(cmTarget const* target,
autogenTargetName.c_str());
return;
}
- makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(0));
+ makefile->AddDefinition("_qt_moc_executable", qt4Moc->GetLocation(""));
}
else
{
@@ -672,7 +673,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts,
++o;
}
if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
- cmStrCmp(o)) != cmArrayEnd(valueOptions))
+ cmStrCmp(*it)) != cmArrayEnd(valueOptions))
{
assert(existingIt + 1 != opts.end());
*(existingIt + 1) = *(it + 1);
@@ -687,7 +688,7 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector<std::string> &opts,
opts.insert(opts.end(), extraOpts.begin(), extraOpts.end());
}
-static void GetUicOpts(cmTarget const* target, const char * config,
+static void GetUicOpts(cmTarget const* target, const std::string& config,
std::string &optString)
{
std::vector<std::string> opts;
@@ -709,9 +710,9 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
{
cmMakefile *makefile = target->GetMakefile();
- std::set<cmStdString> skipped;
+ std::set<std::string> skipped;
std::vector<std::string> skipVec;
- cmSystemTools::ExpandListArgument(this->SkipUic.c_str(), skipVec);
+ cmSystemTools::ExpandListArgument(this->SkipUic, skipVec);
for (std::vector<std::string>::const_iterator li = skipVec.begin();
li != skipVec.end(); ++li)
@@ -720,7 +721,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
}
makefile->AddDefinition("_skip_uic",
- cmLocalGenerator::EscapeForCMake(this->SkipUic.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(this->SkipUic).c_str());
std::vector<cmSourceFile*> uiFilesWithOptions
= makefile->GetQtUiFilesWithOptions();
@@ -729,23 +730,23 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
std::string _uic_opts;
std::vector<std::string> configs;
- const char *config = makefile->GetConfigurations(configs);
+ const std::string& config = makefile->GetConfigurations(configs);
GetUicOpts(target, config, _uic_opts);
if (!_uic_opts.empty())
{
- _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts.c_str());
+ _uic_opts = cmLocalGenerator::EscapeForCMake(_uic_opts);
makefile->AddDefinition("_uic_target_options", _uic_opts.c_str());
}
for (std::vector<std::string>::const_iterator li = configs.begin();
li != configs.end(); ++li)
{
std::string config_uic_opts;
- GetUicOpts(target, li->c_str(), config_uic_opts);
+ GetUicOpts(target, *li, config_uic_opts);
if (config_uic_opts != _uic_opts)
{
configUicOptions[*li] =
- cmLocalGenerator::EscapeForCMake(config_uic_opts.c_str());
+ cmLocalGenerator::EscapeForCMake(config_uic_opts);
if(_uic_opts.empty())
{
_uic_opts = config_uic_opts;
@@ -780,11 +781,11 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
}
makefile->AddDefinition("_qt_uic_options_files",
- cmLocalGenerator::EscapeForCMake(uiFileFiles.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(uiFileFiles).c_str());
makefile->AddDefinition("_qt_uic_options_options",
- cmLocalGenerator::EscapeForCMake(uiFileOptions.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(uiFileOptions).c_str());
- const char* targetName = target->GetName();
+ std::string targetName = target->GetName();
if (strcmp(qtVersion, "5") == 0)
{
cmTarget *qt5Uic = makefile->FindTargetToUse("Qt5::uic");
@@ -794,7 +795,7 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
}
else
{
- makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(0));
+ makefile->AddDefinition("_qt_uic_executable", qt5Uic->GetLocation(""));
}
}
else if (strcmp(qtVersion, "4") == 0)
@@ -803,15 +804,15 @@ void cmQtAutoGenerators::SetupAutoUicTarget(cmTarget const* target,
if (!qt4Uic)
{
cmSystemTools::Error("Qt4::uic target not found ",
- targetName);
+ targetName.c_str());
return;
}
- makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(0));
+ makefile->AddDefinition("_qt_uic_executable", qt4Uic->GetLocation(""));
}
else
{
cmSystemTools::Error("The CMAKE_AUTOUIC feature supports only Qt 4 and "
- "Qt 5 ", targetName);
+ "Qt 5 ", targetName.c_str());
}
}
@@ -843,7 +844,7 @@ void cmQtAutoGenerators::MergeRccOptions(std::vector<std::string> &opts,
++o;
}
if (std::find_if(cmArrayBegin(valueOptions), cmArrayEnd(valueOptions),
- cmStrCmp(o)) != cmArrayEnd(valueOptions))
+ cmStrCmp(*it)) != cmArrayEnd(valueOptions))
{
assert(existingIt + 1 != opts.end());
*(existingIt + 1) = *(it + 1);
@@ -865,7 +866,7 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
cmMakefile *makefile = target->GetMakefile();
std::vector<cmSourceFile*> srcFiles;
- target->GetSourceFiles(srcFiles);
+ target->GetConfigCommonSourceFiles(srcFiles);
std::string rccFileFiles;
std::string rccFileOptions;
@@ -926,24 +927,24 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
}
makefile->AddDefinition("_rcc_files",
- cmLocalGenerator::EscapeForCMake(_rcc_files.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(_rcc_files).c_str());
makefile->AddDefinition("_qt_rcc_options_files",
- cmLocalGenerator::EscapeForCMake(rccFileFiles.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(rccFileFiles).c_str());
makefile->AddDefinition("_qt_rcc_options_options",
- cmLocalGenerator::EscapeForCMake(rccFileOptions.c_str()).c_str());
+ cmLocalGenerator::EscapeForCMake(rccFileOptions).c_str());
- const char* targetName = target->GetName();
+ std::string targetName = target->GetName();
if (strcmp(qtVersion, "5") == 0)
{
cmTarget *qt5Rcc = makefile->FindTargetToUse("Qt5::rcc");
if (!qt5Rcc)
{
cmSystemTools::Error("Qt5::rcc target not found ",
- targetName);
+ targetName.c_str());
return;
}
- makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(0));
+ makefile->AddDefinition("_qt_rcc_executable", qt5Rcc->GetLocation(""));
}
else if (strcmp(qtVersion, "4") == 0)
{
@@ -951,20 +952,20 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target)
if (!qt4Rcc)
{
cmSystemTools::Error("Qt4::rcc target not found ",
- targetName);
+ targetName.c_str());
return;
}
- makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(0));
+ makefile->AddDefinition("_qt_rcc_executable", qt4Rcc->GetLocation(""));
}
else
{
cmSystemTools::Error("The CMAKE_AUTORCC feature supports only Qt 4 and "
- "Qt 5 ", targetName);
+ "Qt 5 ", targetName.c_str());
}
}
static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
- const char* targetDirectory)
+ const std::string& targetDirectory)
{
cmGlobalGenerator* gg = new cmGlobalGenerator();
gg->SetCMakeInstance(cm);
@@ -979,7 +980,8 @@ static cmGlobalGenerator* CreateGlobalGenerator(cmake* cm,
return gg;
}
-bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config)
+bool cmQtAutoGenerators::Run(const std::string& targetDirectory,
+ const std::string& config)
{
bool success = true;
cmake cm;
@@ -1005,10 +1007,11 @@ bool cmQtAutoGenerators::Run(const char* targetDirectory, const char *config)
}
bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
- const char* targetDirectory,
- const char *config)
+ const std::string& targetDirectory,
+ const std::string& config)
{
- std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
+ std::string filename(
+ cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutogenInfo.cmake";
@@ -1039,47 +1042,49 @@ bool cmQtAutoGenerators::ReadAutogenInfoFile(cmMakefile* makefile,
{
std::string compileDefsPropOrig = "AM_MOC_COMPILE_DEFINITIONS";
std::string compileDefsProp = compileDefsPropOrig;
- if(config)
+ if(!config.empty())
{
compileDefsProp += "_";
compileDefsProp += config;
}
- const char *compileDefs = makefile->GetDefinition(compileDefsProp.c_str());
+ const char *compileDefs = makefile->GetDefinition(compileDefsProp);
this->MocCompileDefinitionsStr = compileDefs ? compileDefs
- : makefile->GetSafeDefinition(compileDefsPropOrig.c_str());
+ : makefile->GetSafeDefinition(compileDefsPropOrig);
}
{
std::string includesPropOrig = "AM_MOC_INCLUDES";
std::string includesProp = includesPropOrig;
- if(config)
+ if(!config.empty())
{
includesProp += "_";
includesProp += config;
}
- const char *includes = makefile->GetDefinition(includesProp.c_str());
+ const char *includes = makefile->GetDefinition(includesProp);
this->MocIncludesStr = includes ? includes
- : makefile->GetSafeDefinition(includesPropOrig.c_str());
+ : makefile->GetSafeDefinition(includesPropOrig);
}
this->MocOptionsStr = makefile->GetSafeDefinition("AM_MOC_OPTIONS");
this->ProjectBinaryDir = makefile->GetSafeDefinition("AM_CMAKE_BINARY_DIR");
this->ProjectSourceDir = makefile->GetSafeDefinition("AM_CMAKE_SOURCE_DIR");
this->TargetName = makefile->GetSafeDefinition("AM_TARGET_NAME");
+ this->OriginTargetName
+ = makefile->GetSafeDefinition("AM_ORIGIN_TARGET_NAME");
{
const char *uicOptionsFiles
= makefile->GetSafeDefinition("AM_UIC_OPTIONS_FILES");
std::string uicOptionsPropOrig = "AM_UIC_TARGET_OPTIONS";
std::string uicOptionsProp = uicOptionsPropOrig;
- if(config)
+ if(!config.empty())
{
uicOptionsProp += "_";
uicOptionsProp += config;
}
const char *uicTargetOptions
- = makefile->GetSafeDefinition(uicOptionsProp.c_str());
+ = makefile->GetSafeDefinition(uicOptionsProp);
cmSystemTools::ExpandListArgument(
uicTargetOptions ? uicTargetOptions
- : makefile->GetSafeDefinition(uicOptionsPropOrig.c_str()),
+ : makefile->GetSafeDefinition(uicOptionsPropOrig),
this->UicTargetOptions);
const char *uicOptionsOptions
= makefile->GetSafeDefinition("AM_UIC_OPTIONS_OPTIONS");
@@ -1148,9 +1153,10 @@ std::string cmQtAutoGenerators::MakeCompileSettingsString(cmMakefile* makefile)
bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile,
- const char* targetDirectory)
+ const std::string& targetDirectory)
{
- std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
+ std::string filename(
+ cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutomocOldMocDefinitions.cmake";
@@ -1164,9 +1170,11 @@ bool cmQtAutoGenerators::ReadOldMocDefinitionsFile(cmMakefile* makefile,
void
-cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory)
+cmQtAutoGenerators::WriteOldMocDefinitionsFile(
+ const std::string& targetDirectory)
{
- std::string filename(cmSystemTools::CollapseFullPath(targetDirectory));
+ std::string filename(
+ cmSystemTools::CollapseFullPath(targetDirectory.c_str()));
cmSystemTools::ConvertToUnixSlashes(filename);
filename += "/AutomocOldMocDefinitions.cmake";
@@ -1175,7 +1183,7 @@ cmQtAutoGenerators::WriteOldMocDefinitionsFile(const char* targetDirectory)
std::ios::out | std::ios::trunc);
outfile << "set(AM_OLD_COMPILE_SETTINGS "
<< cmLocalGenerator::EscapeForCMake(
- this->CurrentCompileSettingsStr.c_str()) << ")\n";
+ this->CurrentCompileSettingsStr) << ")\n";
outfile.close();
}
@@ -1786,8 +1794,8 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename,
std::string::size_type matchOffset = 0;
- const std::string absPath = cmsys::SystemTools::GetFilenamePath(
- cmsys::SystemTools::GetRealPath(absFilename.c_str())) + '/';
+ const std::string realName =
+ cmsys::SystemTools::GetRealPath(absFilename.c_str());
matchOffset = 0;
if ((strstr(contentsString.c_str(), "ui_") != NULL)
@@ -1804,7 +1812,7 @@ void cmQtAutoGenerators::ParseForUic(const std::string& absFilename,
// finding the correct header, so we need to remove the ui_ part
basename = basename.substr(3);
- includedUis[absPath] = basename;
+ includedUis[realName] = basename;
matchOffset += uiIncludeRegExp.end();
} while(uiIncludeRegExp.find(contentsString.c_str() + matchOffset));
@@ -1907,7 +1915,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
|cmsysTerminal_Color_ForegroundBold,
msg.c_str(), true, this->ColorOutput);
- std::vector<cmStdString> command;
+ 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();
@@ -1936,7 +1944,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
if (this->Verbose)
{
- for(std::vector<cmStdString>::const_iterator cmdIt = command.begin();
+ for(std::vector<std::string>::const_iterator cmdIt = command.begin();
cmdIt != command.end();
++cmdIt)
{
@@ -1960,7 +1968,7 @@ bool cmQtAutoGenerators::GenerateMoc(const std::string& sourceFile,
return false;
}
-bool cmQtAutoGenerators::GenerateUi(const std::string& path,
+bool cmQtAutoGenerators::GenerateUi(const std::string& realName,
const std::string& uiFileName)
{
if (!cmsys::SystemTools::FileExists(this->Builddir.c_str(), false))
@@ -1968,6 +1976,9 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path,
cmsys::SystemTools::MakeDirectory(this->Builddir.c_str());
}
+ const std::string path = cmsys::SystemTools::GetFilenamePath(
+ realName.c_str()) + '/';
+
std::string ui_output_file = "ui_" + uiFileName + ".h";
std::string ui_input_file = path + uiFileName + ".ui";
@@ -1983,7 +1994,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path,
|cmsysTerminal_Color_ForegroundBold,
msg.c_str(), true, this->ColorOutput);
- std::vector<cmStdString> command;
+ std::vector<std::string> command;
command.push_back(this->UicExecutable);
std::vector<std::string> opts = this->UicTargetOptions;
@@ -2008,7 +2019,7 @@ bool cmQtAutoGenerators::GenerateUi(const std::string& path,
if (this->Verbose)
{
- for(std::vector<cmStdString>::const_iterator cmdIt = command.begin();
+ for(std::vector<std::string>::const_iterator cmdIt = command.begin();
cmdIt != command.end();
++cmdIt)
{
@@ -2046,13 +2057,15 @@ bool cmQtAutoGenerators::GenerateQrc()
{
continue;
}
- std::vector<cmStdString> command;
+ std::vector<std::string> command;
command.push_back(this->RccExecutable);
std::string basename = cmsys::SystemTools::
GetFilenameWithoutLastExtension(*si);
- std::string rcc_output_file = this->Builddir + "qrc_" + basename + ".cpp";
+ std::string rcc_output_file = this->Builddir
+ + "CMakeFiles/" + this->OriginTargetName
+ + ".dir/qrc_" + basename + ".cpp";
int sourceNewerThanQrc = 0;
bool success = cmsys::SystemTools::FileTimeCompare(si->c_str(),
@@ -2074,13 +2087,15 @@ bool cmQtAutoGenerators::GenerateQrc()
}
}
+ command.push_back("-name");
+ command.push_back(basename);
command.push_back("-o");
command.push_back(rcc_output_file);
command.push_back(*si);
if (this->Verbose)
{
- for(std::vector<cmStdString>::const_iterator cmdIt = command.begin();
+ for(std::vector<std::string>::const_iterator cmdIt = command.begin();
cmdIt != command.end();
++cmdIt)
{
diff --git a/Source/cmQtAutoGenerators.h b/Source/cmQtAutoGenerators.h
index 2840fbf..501e13a 100644
--- a/Source/cmQtAutoGenerators.h
+++ b/Source/cmQtAutoGenerators.h
@@ -21,7 +21,7 @@ class cmQtAutoGenerators
{
public:
cmQtAutoGenerators();
- bool Run(const char* targetDirectory, const char *config);
+ bool Run(const std::string& targetDirectory, const std::string& config);
bool InitializeAutogenTarget(cmTarget* target);
void SetupAutoGenerateTarget(cmTarget const* target);
@@ -37,18 +37,18 @@ private:
void SetupAutoRccTarget(cmTarget const* target);
bool ReadAutogenInfoFile(cmMakefile* makefile,
- const char* targetDirectory,
- const char *config);
+ const std::string& targetDirectory,
+ const std::string& config);
bool ReadOldMocDefinitionsFile(cmMakefile* makefile,
- const char* targetDirectory);
- void WriteOldMocDefinitionsFile(const char* targetDirectory);
+ const std::string& targetDirectory);
+ void WriteOldMocDefinitionsFile(const std::string& targetDirectory);
std::string MakeCompileSettingsString(cmMakefile* makefile);
bool RunAutogen(cmMakefile* makefile);
bool GenerateMoc(const std::string& sourceFile,
const std::string& mocFileName);
- bool GenerateUi(const std::string& path, const std::string& uiFileName);
+ bool GenerateUi(const std::string& realName, const std::string& uiFileName);
bool GenerateQrc();
void ParseCppFile(const std::string& absFilename,
const std::vector<std::string>& headerExtensions,
@@ -104,6 +104,7 @@ private:
std::string ProjectBinaryDir;
std::string ProjectSourceDir;
std::string TargetName;
+ std::string OriginTargetName;
std::string CurrentCompileSettingsStr;
std::string OldCompileSettingsStr;
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index 11a9913..7ff12dd 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -326,11 +326,11 @@ std::string cmRST::ReplaceSubstitutions(std::string const& line)
std::string::size_type start = this->Substitution.start(2);
std::string::size_type end = this->Substitution.end(2);
std::string substitute = this->Substitution.match(3);
- std::map<cmStdString, cmStdString>::iterator
+ std::map<std::string, std::string>::iterator
replace = this->Replace.find(substitute);
if(replace != this->Replace.end())
{
- std::pair<std::set<cmStdString>::iterator, bool> replaced =
+ std::pair<std::set<std::string>::iterator, bool> replaced =
this->Replaced.insert(substitute);
if(replaced.second)
{
diff --git a/Source/cmRST.h b/Source/cmRST.h
index 3356008..b9b2366 100644
--- a/Source/cmRST.h
+++ b/Source/cmRST.h
@@ -92,8 +92,8 @@ private:
std::vector<std::string> MarkupLines;
std::string DocDir;
- std::map<cmStdString, cmStdString> Replace;
- std::set<cmStdString> Replaced;
+ std::map<std::string, std::string> Replace;
+ std::set<std::string> Replaced;
std::string ReplaceName;
};
diff --git a/Source/cmRemoveCommand.h b/Source/cmRemoveCommand.h
index ad73908..94161f8 100644
--- a/Source/cmRemoveCommand.h
+++ b/Source/cmRemoveCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "remove";}
+ virtual std::string GetName() const {return "remove";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h
index 4e291fc..cac94be 100644
--- a/Source/cmRemoveDefinitionsCommand.h
+++ b/Source/cmRemoveDefinitionsCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "remove_definitions";}
+ virtual std::string GetName() const {return "remove_definitions";}
cmTypeMacro(cmRemoveDefinitionsCommand, cmCommand);
};
diff --git a/Source/cmReturnCommand.h b/Source/cmReturnCommand.h
index 2822b62..4ff81ef 100644
--- a/Source/cmReturnCommand.h
+++ b/Source/cmReturnCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "return";}
+ virtual std::string GetName() const {return "return";}
cmTypeMacro(cmReturnCommand, cmCommand);
};
diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx
index 3b6a49b..e44b236 100644
--- a/Source/cmScriptGenerator.cxx
+++ b/Source/cmScriptGenerator.cxx
@@ -15,11 +15,11 @@
//----------------------------------------------------------------------------
cmScriptGenerator
-::cmScriptGenerator(const char* config_var,
+::cmScriptGenerator(const std::string& config_var,
std::vector<std::string> const& configurations):
RuntimeConfigVariable(config_var),
Configurations(configurations),
- ConfigurationName(0),
+ ConfigurationName(""),
ConfigurationTypes(0),
ActionsPerConfig(false)
{
@@ -34,21 +34,21 @@ cmScriptGenerator
//----------------------------------------------------------------------------
void
cmScriptGenerator
-::Generate(std::ostream& os, const char* config,
+::Generate(std::ostream& os, const std::string& config,
std::vector<std::string> const& configurationTypes)
{
this->ConfigurationName = config;
this->ConfigurationTypes = &configurationTypes;
this->GenerateScript(os);
- this->ConfigurationName = 0;
+ this->ConfigurationName = "";
this->ConfigurationTypes = 0;
}
//----------------------------------------------------------------------------
-static void cmScriptGeneratorEncodeConfig(const char* config,
+static void cmScriptGeneratorEncodeConfig(const std::string& config,
std::string& result)
{
- for(const char* c = config; *c; ++c)
+ for(const char* c = config.c_str(); *c; ++c)
{
if(*c >= 'a' && *c <= 'z')
{
@@ -73,12 +73,12 @@ static void cmScriptGeneratorEncodeConfig(const char* config,
//----------------------------------------------------------------------------
std::string
-cmScriptGenerator::CreateConfigTest(const char* config)
+cmScriptGenerator::CreateConfigTest(const std::string& config)
{
std::string result = "\"${";
result += this->RuntimeConfigVariable;
result += "}\" MATCHES \"^(";
- if(config && *config)
+ if(!config.empty())
{
cmScriptGeneratorEncodeConfig(config, result);
}
@@ -99,7 +99,7 @@ cmScriptGenerator::CreateConfigTest(std::vector<std::string> const& configs)
{
result += sep;
sep = "|";
- cmScriptGeneratorEncodeConfig(ci->c_str(), result);
+ cmScriptGeneratorEncodeConfig(*ci, result);
}
result += ")$\"";
return result;
@@ -142,14 +142,15 @@ void cmScriptGenerator::GenerateScriptActions(std::ostream& os,
}
//----------------------------------------------------------------------------
-void cmScriptGenerator::GenerateScriptForConfig(std::ostream&, const char*,
+void cmScriptGenerator::GenerateScriptForConfig(std::ostream&,
+ const std::string&,
Indent const&)
{
// No actions for this generator.
}
//----------------------------------------------------------------------------
-bool cmScriptGenerator::GeneratesForConfig(const char* config)
+bool cmScriptGenerator::GeneratesForConfig(const std::string& config)
{
// If this is not a configuration-specific rule then we install.
if(this->Configurations.empty())
@@ -159,7 +160,7 @@ bool cmScriptGenerator::GeneratesForConfig(const char* config)
// This is a configuration-specific rule. Check if the config
// matches this rule.
- std::string config_upper = cmSystemTools::UpperCase(config?config:"");
+ std::string config_upper = cmSystemTools::UpperCase(config);
for(std::vector<std::string>::const_iterator i =
this->Configurations.begin();
i != this->Configurations.end(); ++i)
diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h
index 8b2ca33..9ab04f1 100644
--- a/Source/cmScriptGenerator.h
+++ b/Source/cmScriptGenerator.h
@@ -47,11 +47,11 @@ inline std::ostream& operator<<(std::ostream& os,
class cmScriptGenerator
{
public:
- cmScriptGenerator(const char* config_var,
+ cmScriptGenerator(const std::string& config_var,
std::vector<std::string> const& configurations);
virtual ~cmScriptGenerator();
- void Generate(std::ostream& os, const char* config,
+ void Generate(std::ostream& os, const std::string& config,
std::vector<std::string> const& configurationTypes);
const std::vector<std::string>& GetConfigurations() const
@@ -63,15 +63,15 @@ protected:
virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
virtual void GenerateScriptForConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
Indent const& indent);
virtual void GenerateScriptNoConfig(std::ostream&, Indent const&) {}
virtual bool NeedsScriptNoConfig() const { return false; }
// Test if this generator does something for a given configuration.
- bool GeneratesForConfig(const char*);
+ bool GeneratesForConfig(const std::string&);
- std::string CreateConfigTest(const char* config);
+ std::string CreateConfigTest(const std::string& config);
std::string CreateConfigTest(std::vector<std::string> const& configs);
std::string CreateComponentTest(const char* component);
@@ -80,7 +80,7 @@ protected:
std::vector<std::string> const Configurations;
// Information used during generation.
- const char* ConfigurationName;
+ std::string ConfigurationName;
std::vector<std::string> const* ConfigurationTypes;
// True if the subclass needs to generate an explicit rule for each
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 6f62091..1ee3f29 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -53,7 +53,7 @@ bool cmSeparateArgumentsCommand
{
cmOStringStream e;
e << "given unknown argument " << args[i];
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -61,11 +61,11 @@ bool cmSeparateArgumentsCommand
if(mode == ModeOld)
{
// Original space-replacement version of command.
- if(const char* def = this->Makefile->GetDefinition(var.c_str()))
+ if(const char* def = this->Makefile->GetDefinition(var))
{
std::string value = def;
cmSystemTools::ReplaceString(value, " ", ";");
- this->Makefile->AddDefinition(var.c_str(), value.c_str());
+ this->Makefile->AddDefinition(var, value.c_str());
}
}
else
@@ -102,7 +102,7 @@ bool cmSeparateArgumentsCommand
value += *si;
}
}
- this->Makefile->AddDefinition(var.c_str(), value.c_str());
+ this->Makefile->AddDefinition(var, value.c_str());
}
return true;
diff --git a/Source/cmSeparateArgumentsCommand.h b/Source/cmSeparateArgumentsCommand.h
index ce02360..a527ae7 100644
--- a/Source/cmSeparateArgumentsCommand.h
+++ b/Source/cmSeparateArgumentsCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "separate_arguments";}
+ virtual std::string GetName() const {return "separate_arguments";}
cmTypeMacro(cmSeparateArgumentsCommand, cmCommand);
};
diff --git a/Source/cmSetCommand.cxx b/Source/cmSetCommand.cxx
index 36363a1..0ca36eb 100644
--- a/Source/cmSetCommand.cxx
+++ b/Source/cmSetCommand.cxx
@@ -59,7 +59,7 @@ bool cmSetCommand
// SET (VAR) // Removes the definition of VAR.
if (args.size() == 1)
{
- this->Makefile->RemoveDefinition(args[0].c_str());
+ this->Makefile->RemoveDefinition(args[0]);
return true;
}
// SET (VAR PARENT_SCOPE) // Removes the definition of VAR
diff --git a/Source/cmSetCommand.h b/Source/cmSetCommand.h
index 6cef0a0..4adc2d9 100644
--- a/Source/cmSetCommand.h
+++ b/Source/cmSetCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "set";}
+ virtual std::string GetName() const {return "set";}
cmTypeMacro(cmSetCommand, cmCommand);
};
diff --git a/Source/cmSetDirectoryPropertiesCommand.cxx b/Source/cmSetDirectoryPropertiesCommand.cxx
index 62c9b87..3d4b7a9 100644
--- a/Source/cmSetDirectoryPropertiesCommand.cxx
+++ b/Source/cmSetDirectoryPropertiesCommand.cxx
@@ -30,7 +30,7 @@ bool cmSetDirectoryPropertiesCommand
args.end(), errors);
if (!ret)
{
- this->SetError(errors.c_str());
+ this->SetError(errors);
}
return ret;
}
@@ -62,7 +62,7 @@ bool cmSetDirectoryPropertiesCommand
"Commands and macros cannot be set using SET_CMAKE_PROPERTIES";
return false;
}
- mf->SetProperty(prop.c_str(), value.c_str());
+ mf->SetProperty(prop, value.c_str());
}
return true;
diff --git a/Source/cmSetDirectoryPropertiesCommand.h b/Source/cmSetDirectoryPropertiesCommand.h
index 6240598..f444a1b 100644
--- a/Source/cmSetDirectoryPropertiesCommand.h
+++ b/Source/cmSetDirectoryPropertiesCommand.h
@@ -37,7 +37,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "set_directory_properties";}
+ virtual std::string GetName() const { return "set_directory_properties";}
/**
* Static entry point for use by other commands
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 1a6f1d6..5f970f8 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -66,7 +66,7 @@ bool cmSetPropertyCommand
cmOStringStream e;
e << "given invalid scope " << *arg << ". "
<< "Valid scopes are GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, CACHE.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
@@ -114,7 +114,7 @@ bool cmSetPropertyCommand
{
cmOStringStream e;
e << "given invalid argument \"" << *arg << "\".";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -203,7 +203,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
// Lookup the generator.
if(cmLocalGenerator* lg =
(this->Makefile->GetLocalGenerator()
- ->GetGlobalGenerator()->FindLocalGenerator(dir.c_str())))
+ ->GetGlobalGenerator()->FindLocalGenerator(dir)))
{
// Use the makefile for the directory found.
mf = lg->GetMakefile();
@@ -241,7 +241,7 @@ bool cmSetPropertyCommand::HandleDirectoryMode()
//----------------------------------------------------------------------------
bool cmSetPropertyCommand::HandleTargetMode()
{
- for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+ for(std::set<std::string>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
{
if (this->Makefile->IsAlias(*ni))
@@ -262,7 +262,7 @@ bool cmSetPropertyCommand::HandleTargetMode()
cmOStringStream e;
e << "could not find TARGET " << *ni
<< ". Perhaps it has not yet been created.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -297,11 +297,11 @@ bool cmSetPropertyCommand::HandleTarget(cmTarget* target)
//----------------------------------------------------------------------------
bool cmSetPropertyCommand::HandleSourceMode()
{
- for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+ for(std::set<std::string>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
{
// Get the source file.
- if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(ni->c_str()))
+ if(cmSourceFile* sf = this->Makefile->GetOrCreateSource(*ni))
{
if(!this->HandleSource(sf))
{
@@ -312,7 +312,7 @@ bool cmSetPropertyCommand::HandleSourceMode()
{
cmOStringStream e;
e << "given SOURCE name that could not be found or created: " << *ni;
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -345,13 +345,13 @@ bool cmSetPropertyCommand::HandleSource(cmSourceFile* sf)
bool cmSetPropertyCommand::HandleTestMode()
{
// Look for tests with all names given.
- std::set<cmStdString>::iterator next;
- for(std::set<cmStdString>::iterator ni = this->Names.begin();
+ std::set<std::string>::iterator next;
+ for(std::set<std::string>::iterator ni = this->Names.begin();
ni != this->Names.end(); ni = next)
{
next = ni;
++next;
- if(cmTest* test = this->Makefile->GetTest(ni->c_str()))
+ if(cmTest* test = this->Makefile->GetTest(*ni))
{
if(this->HandleTest(test))
{
@@ -369,12 +369,12 @@ bool cmSetPropertyCommand::HandleTestMode()
{
cmOStringStream e;
e << "given TEST names that do not exist:\n";
- for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+ for(std::set<std::string>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
{
e << " " << *ni << "\n";
}
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
return true;
@@ -414,7 +414,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
cmOStringStream e;
e << "given non-boolean value \"" << this->PropertyValue
<< "\" for CACHE property \"ADVANCED\". ";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -424,7 +424,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
{
cmOStringStream e;
e << "given invalid CACHE entry TYPE \"" << this->PropertyValue << "\"";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
@@ -436,11 +436,11 @@ bool cmSetPropertyCommand::HandleCacheMode()
e << "given invalid CACHE property " << this->PropertyName << ". "
<< "Settable CACHE properties are: "
<< "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
- for(std::set<cmStdString>::const_iterator ni = this->Names.begin();
+ for(std::set<std::string>::const_iterator ni = this->Names.begin();
ni != this->Names.end(); ++ni)
{
// Get the source file.
@@ -460,7 +460,7 @@ bool cmSetPropertyCommand::HandleCacheMode()
cmOStringStream e;
e << "could not find CACHE variable " << *ni
<< ". Perhaps it has not yet been created.";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
}
diff --git a/Source/cmSetPropertyCommand.h b/Source/cmSetPropertyCommand.h
index 5470314..eaa0233 100644
--- a/Source/cmSetPropertyCommand.h
+++ b/Source/cmSetPropertyCommand.h
@@ -34,7 +34,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "set_property";}
+ virtual std::string GetName() const { return "set_property";}
/**
* This determines if the command is invoked when in script mode.
@@ -44,7 +44,7 @@ public:
cmTypeMacro(cmSetPropertyCommand, cmCommand);
private:
- std::set<cmStdString> Names;
+ std::set<std::string> Names;
std::string PropertyName;
std::string PropertyValue;
bool Remove;
diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx
index 619dfc5..19c6819 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.cxx
+++ b/Source/cmSetSourceFilesPropertiesCommand.cxx
@@ -51,7 +51,7 @@ bool cmSetSourceFilesPropertiesCommand
args.end(), errors);
if (!ret)
{
- this->SetError(errors.c_str());
+ this->SetError(errors);
}
return ret;
}
@@ -154,14 +154,14 @@ bool cmSetSourceFilesPropertiesCommand
{
// get the source file
cmSourceFile* sf =
- mf->GetOrCreateSource(j->c_str(), generated);
+ mf->GetOrCreateSource(*j, generated);
if(sf)
{
// now loop through all the props and set them
unsigned int k;
for (k = 0; k < propertyPairs.size(); k = k + 2)
{
- sf->SetProperty(propertyPairs[k].c_str(),propertyPairs[k+1].c_str());
+ sf->SetProperty(propertyPairs[k],propertyPairs[k+1].c_str());
}
}
}
diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h
index 8541a96..5fa5a3a 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.h
+++ b/Source/cmSetSourceFilesPropertiesCommand.h
@@ -32,7 +32,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "set_source_files_properties";}
+ virtual std::string GetName() const { return "set_source_files_properties";}
cmTypeMacro(cmSetSourceFilesPropertiesCommand, cmCommand);
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index dab4180..bf3519c 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -78,12 +78,12 @@ bool cmSetTargetPropertiesCommand
return false;
}
bool ret = cmSetTargetPropertiesCommand::SetOneTarget
- (args[i].c_str(),propertyPairs,this->Makefile);
+ (args[i],propertyPairs,this->Makefile);
if (!ret)
{
std::string message = "Can not find target to add properties to: ";
message += args[i];
- this->SetError(message.c_str());
+ this->SetError(message);
return false;
}
}
@@ -91,7 +91,7 @@ bool cmSetTargetPropertiesCommand
}
bool cmSetTargetPropertiesCommand
-::SetOneTarget(const char *tname,
+::SetOneTarget(const std::string& tname,
std::vector<std::string> &propertyPairs,
cmMakefile *mf)
{
@@ -101,9 +101,9 @@ bool cmSetTargetPropertiesCommand
unsigned int k;
for (k = 0; k < propertyPairs.size(); k = k + 2)
{
- target->SetProperty(propertyPairs[k].c_str(),
+ target->SetProperty(propertyPairs[k],
propertyPairs[k+1].c_str());
- target->CheckProperty(propertyPairs[k].c_str(), mf);
+ target->CheckProperty(propertyPairs[k], mf);
}
}
// if file is not already in the makefile, then add it
diff --git a/Source/cmSetTargetPropertiesCommand.h b/Source/cmSetTargetPropertiesCommand.h
index 6221a18..3981ef3 100644
--- a/Source/cmSetTargetPropertiesCommand.h
+++ b/Source/cmSetTargetPropertiesCommand.h
@@ -32,12 +32,12 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "set_target_properties";}
+ virtual std::string GetName() const { return "set_target_properties";}
/**
* Used by this command and cmSetPropertiesCommand
*/
- static bool SetOneTarget(const char *tname,
+ static bool SetOneTarget(const std::string& tname,
std::vector<std::string> &propertyPairs,
cmMakefile *mf);
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index 3d52cf2..b026ff3 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -76,12 +76,12 @@ bool cmSetTestsPropertiesCommand
{
std::string errors;
bool ret =
- cmSetTestsPropertiesCommand::SetOneTest(args[i].c_str(),
+ cmSetTestsPropertiesCommand::SetOneTest(args[i],
propertyPairs,
this->Makefile, errors);
if (!ret)
{
- this->SetError(errors.c_str());
+ this->SetError(errors);
return ret;
}
}
@@ -91,7 +91,7 @@ bool cmSetTestsPropertiesCommand
bool cmSetTestsPropertiesCommand
-::SetOneTest(const char *tname,
+::SetOneTest(const std::string& tname,
std::vector<std::string> &propertyPairs,
cmMakefile *mf, std::string &errors)
{
@@ -101,7 +101,7 @@ bool cmSetTestsPropertiesCommand
unsigned int k;
for (k = 0; k < propertyPairs.size(); k = k + 2)
{
- test->SetProperty(propertyPairs[k].c_str(),
+ test->SetProperty(propertyPairs[k],
propertyPairs[k+1].c_str());
}
}
diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h
index 9e85495..dabe944 100644
--- a/Source/cmSetTestsPropertiesCommand.h
+++ b/Source/cmSetTestsPropertiesCommand.h
@@ -32,11 +32,11 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "set_tests_properties";}
+ virtual std::string GetName() const { return "set_tests_properties";}
cmTypeMacro(cmSetTestsPropertiesCommand, cmCommand);
- static bool SetOneTest(const char *tname,
+ static bool SetOneTest(const std::string& tname,
std::vector<std::string> &propertyPairs,
cmMakefile *mf,
std::string &errors);
diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx
index 2bdd1ad..e61caab 100644
--- a/Source/cmSiteNameCommand.cxx
+++ b/Source/cmSiteNameCommand.cxx
@@ -31,7 +31,7 @@ bool cmSiteNameCommand
paths.push_back("/usr/local/bin");
const char* cacheValue
- = this->Makefile->GetDefinition(args[0].c_str());
+ = this->Makefile->GetDefinition(args[0]);
if(cacheValue)
{
return true;
@@ -85,7 +85,7 @@ bool cmSiteNameCommand
}
#endif
this->Makefile->
- AddCacheDefinition(args[0].c_str(),
+ AddCacheDefinition(args[0],
siteName.c_str(),
"Name of the computer/site where compile is being run",
cmCacheManager::STRING);
diff --git a/Source/cmSiteNameCommand.h b/Source/cmSiteNameCommand.h
index eb9d4d8..ec63ef8 100644
--- a/Source/cmSiteNameCommand.h
+++ b/Source/cmSiteNameCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "site_name";}
+ virtual std::string GetName() const {return "site_name";}
cmTypeMacro(cmSiteNameCommand, cmCommand);
};
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 23422a2..0ab30a2 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -18,7 +18,7 @@
#include "cmake.h"
//----------------------------------------------------------------------------
-cmSourceFile::cmSourceFile(cmMakefile* mf, const char* name):
+cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name):
Location(mf, name)
{
this->CustomCommand = 0;
@@ -39,7 +39,19 @@ std::string const& cmSourceFile::GetExtension() const
}
//----------------------------------------------------------------------------
-const char* cmSourceFile::GetLanguage()
+void cmSourceFile::SetObjectLibrary(std::string const& objlib)
+{
+ this->ObjectLibrary = objlib;
+}
+
+//----------------------------------------------------------------------------
+std::string cmSourceFile::GetObjectLibrary() const
+{
+ return this->ObjectLibrary;
+}
+
+//----------------------------------------------------------------------------
+std::string cmSourceFile::GetLanguage()
{
// If the language was set explicitly by the user then use it.
if(const char* lang = this->GetProperty("LANGUAGE"))
@@ -76,7 +88,7 @@ const char* cmSourceFile::GetLanguage()
}
//----------------------------------------------------------------------------
-const char* cmSourceFile::GetLanguage() const
+std::string cmSourceFile::GetLanguage() const
{
// If the language was set explicitly by the user then use it.
if(const char* lang = this->GetProperty("LANGUAGE"))
@@ -87,11 +99,11 @@ const char* cmSourceFile::GetLanguage() const
// If the language was determined from the source file extension use it.
if(!this->Language.empty())
{
- return this->Language.c_str();
+ return this->Language;
}
// The language is not known.
- return 0;
+ return "";
}
//----------------------------------------------------------------------------
@@ -164,14 +176,14 @@ bool cmSourceFile::FindFullPath(std::string* error)
}
tryPath += this->Location.GetName();
tryPath = cmSystemTools::CollapseFullPath(tryPath.c_str(), *di);
- if(this->TryFullPath(tryPath.c_str(), 0))
+ if(this->TryFullPath(tryPath, ""))
{
return true;
}
for(std::vector<std::string>::const_iterator ei = srcExts.begin();
ei != srcExts.end(); ++ei)
{
- if(this->TryFullPath(tryPath.c_str(), ei->c_str()))
+ if(this->TryFullPath(tryPath, *ei))
{
return true;
}
@@ -179,7 +191,7 @@ bool cmSourceFile::FindFullPath(std::string* error)
for(std::vector<std::string>::const_iterator ei = hdrExts.begin();
ei != hdrExts.end(); ++ei)
{
- if(this->TryFullPath(tryPath.c_str(), ei->c_str()))
+ if(this->TryFullPath(tryPath, *ei))
{
return true;
}
@@ -217,10 +229,11 @@ bool cmSourceFile::FindFullPath(std::string* error)
}
//----------------------------------------------------------------------------
-bool cmSourceFile::TryFullPath(const char* tp, const char* ext)
+bool cmSourceFile::TryFullPath(const std::string& path,
+ const std::string& ext)
{
- std::string tryPath = tp;
- if(ext && *ext)
+ std::string tryPath = path;
+ if(!ext.empty())
{
tryPath += ".";
tryPath += ext;
@@ -266,7 +279,8 @@ void cmSourceFile::CheckLanguage(std::string const& ext)
// Try to identify the source file language from the extension.
cmMakefile const* mf = this->Location.GetMakefile();
cmGlobalGenerator* gg = mf->GetLocalGenerator()->GetGlobalGenerator();
- if(const char* l = gg->GetLanguageFromExtension(ext.c_str()))
+ std::string l = gg->GetLanguageFromExtension(ext.c_str());
+ if(!l.empty())
{
this->Language = l;
}
@@ -279,13 +293,8 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
}
//----------------------------------------------------------------------------
-void cmSourceFile::SetProperty(const char* prop, const char* value)
+void cmSourceFile::SetProperty(const std::string& prop, const char* value)
{
- if (!prop)
- {
- return;
- }
-
this->Properties.SetProperty(prop, value, cmProperty::SOURCE_FILE);
std::string ext =
@@ -293,7 +302,7 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
if (ext == ".ui")
{
cmMakefile const* mf = this->Location.GetMakefile();
- if (strcmp(prop, "AUTOUIC_OPTIONS") == 0)
+ if (prop == "AUTOUIC_OPTIONS")
{
const_cast<cmMakefile*>(mf)->AddQtUiFileWithOptions(this);
}
@@ -301,19 +310,15 @@ void cmSourceFile::SetProperty(const char* prop, const char* value)
}
//----------------------------------------------------------------------------
-void cmSourceFile::AppendProperty(const char* prop, const char* value,
+void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
- if (!prop)
- {
- return;
- }
this->Properties.AppendProperty(prop, value, cmProperty::SOURCE_FILE,
asString);
}
//----------------------------------------------------------------------------
-const char* cmSourceFile::GetPropertyForUser(const char *prop)
+const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
{
// This method is a consequence of design history and backwards
// compatibility. GetProperty is (and should be) a const method.
@@ -329,7 +334,7 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop)
// cmSourceFileLocation class to commit to a particular full path to
// the source file as late as possible. If the users requests the
// LOCATION property we must commit now.
- if(strcmp(prop, "LOCATION") == 0)
+ if(prop == "LOCATION")
{
// Commit to a location.
this->GetFullPath();
@@ -340,10 +345,10 @@ const char* cmSourceFile::GetPropertyForUser(const char *prop)
}
//----------------------------------------------------------------------------
-const char* cmSourceFile::GetProperty(const char* prop) const
+const char* cmSourceFile::GetProperty(const std::string& prop) const
{
// Check for computed properties.
- if(strcmp(prop, "LOCATION") == 0)
+ if(prop == "LOCATION")
{
if(this->FullPath.empty())
{
@@ -368,7 +373,7 @@ const char* cmSourceFile::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
-bool cmSourceFile::GetPropertyAsBool(const char* prop) const
+bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 4440b05..a1d9de1 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -31,7 +31,7 @@ public:
* Construct with the makefile storing the source and the initial
* name referencing it.
*/
- cmSourceFile(cmMakefile* mf, const char* name);
+ cmSourceFile(cmMakefile* mf, const std::string& name);
~cmSourceFile();
@@ -43,14 +43,15 @@ public:
void SetCustomCommand(cmCustomCommand *cc);
///! Set/Get a property of this source file
- void SetProperty(const char *prop, const char *value);
- void AppendProperty(const char* prop, const char* value,bool asString=false);
- const char *GetProperty(const char *prop) const;
- bool GetPropertyAsBool(const char *prop) const;
+ void SetProperty(const std::string& prop, const char *value);
+ void AppendProperty(const std::string& prop,
+ const char* value,bool asString=false);
+ const char *GetProperty(const std::string& prop) const;
+ bool GetPropertyAsBool(const std::string& prop) const;
/** Implement getting a property when called from a CMake language
command like get_property or get_source_file_property. */
- const char* GetPropertyForUser(const char *prop);
+ const char* GetPropertyForUser(const std::string& prop);
/**
* The full path to the file. The non-const version of this method
@@ -78,8 +79,8 @@ public:
/**
* Get the language of the compiler to use for this source file.
*/
- const char* GetLanguage();
- const char* GetLanguage() const;
+ std::string GetLanguage();
+ std::string GetLanguage() const;
/**
* Return the vector that holds the list of dependencies
@@ -88,7 +89,7 @@ public:
void AddDepend(const char* d) { this->Depends.push_back(d); }
// Get the properties
- cmPropertyMap &GetProperties() { return this->Properties; };
+ cmPropertyMap &GetProperties() { return this->Properties; }
/**
* Check whether the given source file location could refer to this
@@ -96,6 +97,9 @@ public:
*/
bool Matches(cmSourceFileLocation const&);
+ void SetObjectLibrary(std::string const& objlib);
+ std::string GetObjectLibrary() const;
+
private:
cmSourceFileLocation Location;
cmPropertyMap Properties;
@@ -104,9 +108,10 @@ private:
std::string Language;
std::string FullPath;
bool FindFullPathFailed;
+ std::string ObjectLibrary;
bool FindFullPath(std::string* error);
- bool TryFullPath(const char* tryPath, const char* ext);
+ bool TryFullPath(const std::string& path, const std::string& ext);
void CheckExtension();
void CheckLanguage(std::string const& ext);
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 5a8578b..c050202 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -16,28 +16,57 @@
#include "cmGlobalGenerator.h"
#include "cmSystemTools.h"
+#include "assert.h"
+
//----------------------------------------------------------------------------
-cmSourceFileLocation
-::cmSourceFileLocation(cmMakefile const* mf, const char* name): Makefile(mf)
+cmSourceFileLocation::cmSourceFileLocation()
+ : Makefile(0), AmbiguousDirectory(true), AmbiguousExtension(true)
{
- this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name);
- this->AmbiguousExtension = true;
- this->Directory = cmSystemTools::GetFilenamePath(name);
- this->Name = cmSystemTools::GetFilenameName(name);
- this->UpdateExtension(name);
+
}
//----------------------------------------------------------------------------
-void cmSourceFileLocation::Update(const char* name)
+cmSourceFileLocation::cmSourceFileLocation(const cmSourceFileLocation& loc)
+ : Makefile(loc.Makefile)
{
- if(this->AmbiguousDirectory)
+ this->AmbiguousDirectory = loc.AmbiguousDirectory;
+ this->AmbiguousExtension = loc.AmbiguousExtension;
+ this->Directory = loc.Directory;
+ this->Name = loc.Name;
+}
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation&
+cmSourceFileLocation::operator=(const cmSourceFileLocation& loc)
+{
+ if(this == &loc)
{
- this->UpdateDirectory(name);
+ return *this;
}
- if(this->AmbiguousExtension)
+ this->Makefile = loc.Makefile;
+ this->AmbiguousDirectory = loc.AmbiguousDirectory;
+ this->AmbiguousExtension = loc.AmbiguousExtension;
+ this->Directory = loc.Directory;
+ this->Name = loc.Name;
+ this->UpdateExtension(this->Name);
+ return *this;
+}
+
+//----------------------------------------------------------------------------
+cmSourceFileLocation
+::cmSourceFileLocation(cmMakefile const* mf, const std::string& name)
+ : Makefile(mf)
+{
+ this->AmbiguousDirectory = !cmSystemTools::FileIsFullPath(name.c_str());
+ this->AmbiguousExtension = true;
+ this->Directory = cmSystemTools::GetFilenamePath(name);
+ if (cmSystemTools::FileIsFullPath(this->Directory.c_str()))
{
- this->UpdateExtension(name);
+ this->Directory
+ = cmSystemTools::CollapseFullPath(this->Directory.c_str());
}
+ this->Name = cmSystemTools::GetFilenameName(name);
+ this->UpdateExtension(name);
}
//----------------------------------------------------------------------------
@@ -58,6 +87,7 @@ void cmSourceFileLocation::Update(cmSourceFileLocation const& loc)
//----------------------------------------------------------------------------
void cmSourceFileLocation::DirectoryUseSource()
{
+ assert(this->Makefile);
if(this->AmbiguousDirectory)
{
this->Directory =
@@ -70,6 +100,7 @@ void cmSourceFileLocation::DirectoryUseSource()
//----------------------------------------------------------------------------
void cmSourceFileLocation::DirectoryUseBinary()
{
+ assert(this->Makefile);
if(this->AmbiguousDirectory)
{
this->Directory =
@@ -80,8 +111,9 @@ void cmSourceFileLocation::DirectoryUseBinary()
}
//----------------------------------------------------------------------------
-void cmSourceFileLocation::UpdateExtension(const char* name)
+void cmSourceFileLocation::UpdateExtension(const std::string& name)
{
+ assert(this->Makefile);
// Check the extension.
std::string ext = cmSystemTools::GetFilenameLastExtension(name);
if(!ext.empty()) { ext = ext.substr(1); }
@@ -92,7 +124,7 @@ void cmSourceFileLocation::UpdateExtension(const char* name)
cmMakefile const* mf = this->Makefile;
const std::vector<std::string>& srcExts = mf->GetSourceExtensions();
const std::vector<std::string>& hdrExts = mf->GetHeaderExtensions();
- if(gg->GetLanguageFromExtension(ext.c_str()) ||
+ if(!gg->GetLanguageFromExtension(ext.c_str()).empty() ||
std::find(srcExts.begin(), srcExts.end(), ext) != srcExts.end() ||
std::find(hdrExts.begin(), hdrExts.end(), ext) != hdrExts.end())
{
@@ -136,21 +168,11 @@ void cmSourceFileLocation::UpdateExtension(const char* name)
}
//----------------------------------------------------------------------------
-void cmSourceFileLocation::UpdateDirectory(const char* name)
-{
- // If a full path was given we know the directory.
- if(cmSystemTools::FileIsFullPath(name))
- {
- this->Directory = cmSystemTools::GetFilenamePath(name);
- this->AmbiguousDirectory = false;
- }
-}
-
-//----------------------------------------------------------------------------
bool
cmSourceFileLocation
::MatchesAmbiguousExtension(cmSourceFileLocation const& loc) const
{
+ assert(this->Makefile);
// This location's extension is not ambiguous but loc's extension
// is. See if the names match as-is.
if(this->Name == loc.Name)
@@ -187,6 +209,7 @@ cmSourceFileLocation
//----------------------------------------------------------------------------
bool cmSourceFileLocation::Matches(cmSourceFileLocation const& loc)
{
+ assert(this->Makefile);
if(this->AmbiguousExtension && loc.AmbiguousExtension)
{
// Both extensions are ambiguous. Since only the old fixed set of
diff --git a/Source/cmSourceFileLocation.h b/Source/cmSourceFileLocation.h
index c03eee7..c37fb1d 100644
--- a/Source/cmSourceFileLocation.h
+++ b/Source/cmSourceFileLocation.h
@@ -33,7 +33,10 @@ public:
* Construct for a source file created in a given cmMakefile
* instance with an initial name.
*/
- cmSourceFileLocation(cmMakefile const* mf, const char* name);
+ cmSourceFileLocation(cmMakefile const* mf, const std::string& name);
+ cmSourceFileLocation();
+ cmSourceFileLocation(const cmSourceFileLocation& loc);
+ cmSourceFileLocation& operator=(const cmSourceFileLocation& loc);
/**
* Return whether the givne source file location could refers to the
@@ -76,7 +79,7 @@ public:
* final name (but could be). Otherwise the returned name is the
* final name.
*/
- const char* GetName() const { return this->Name.c_str(); }
+ const std::string& GetName() const { return this->Name; }
/**
* Get the cmMakefile instance for which the source file was created.
@@ -93,9 +96,7 @@ private:
// Update the location with additional knowledge.
void Update(cmSourceFileLocation const& loc);
- void Update(const char* name);
- void UpdateExtension(const char* name);
- void UpdateDirectory(const char* name);
+ void UpdateExtension(const std::string& name);
};
#endif
diff --git a/Source/cmSourceGroup.cxx b/Source/cmSourceGroup.cxx
index d272b6c..8fed95e 100644
--- a/Source/cmSourceGroup.cxx
+++ b/Source/cmSourceGroup.cxx
@@ -73,7 +73,7 @@ void cmSourceGroup::SetGroupRegex(const char* regex)
}
//----------------------------------------------------------------------------
-void cmSourceGroup::AddGroupFile(const char* name)
+void cmSourceGroup::AddGroupFile(const std::string& name)
{
this->GroupFiles.insert(name);
}
@@ -99,7 +99,7 @@ bool cmSourceGroup::MatchesRegex(const char* name)
//----------------------------------------------------------------------------
bool cmSourceGroup::MatchesFiles(const char* name)
{
- std::set<cmStdString>::const_iterator i = this->GroupFiles.find(name);
+ std::set<std::string>::const_iterator i = this->GroupFiles.find(name);
if(i != this->GroupFiles.end())
{
return true;
diff --git a/Source/cmSourceGroup.h b/Source/cmSourceGroup.h
index 3bbdef9..e8cf519 100644
--- a/Source/cmSourceGroup.h
+++ b/Source/cmSourceGroup.h
@@ -46,7 +46,7 @@ public:
/**
* Add a file name to the explicit list of files for this group.
*/
- void AddGroupFile(const char* name);
+ void AddGroupFile(const std::string& name);
/**
* Add child to this sourcegroup
@@ -118,7 +118,7 @@ private:
/**
* Set of file names explicitly added to this group.
*/
- std::set<cmStdString> GroupFiles;
+ std::set<std::string> GroupFiles;
/**
* Vector of all source files that have been assigned to
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index 9cb80f6..edba5ba 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -78,7 +78,7 @@ bool cmSourceGroupCommand
else if(doingFiles)
{
// Convert name to full path and add to the group's list.
- std::string src = args[i].c_str();
+ std::string src = args[i];
if(!cmSystemTools::FileIsFullPath(src.c_str()))
{
src = this->Makefile->GetCurrentDirectory();
@@ -86,14 +86,14 @@ bool cmSourceGroupCommand
src += args[i];
}
src = cmSystemTools::CollapseFullPath(src.c_str());
- sg->AddGroupFile(src.c_str());
+ sg->AddGroupFile(src);
}
else
{
cmOStringStream err;
- err << "Unknown argument \"" << args[i].c_str() << "\". "
+ err << "Unknown argument \"" << args[i] << "\". "
<< "Perhaps the FILES keyword is missing.\n";
- this->SetError(err.str().c_str());
+ this->SetError(err.str());
return false;
}
}
diff --git a/Source/cmSourceGroupCommand.h b/Source/cmSourceGroupCommand.h
index 5d8b48c..410411b 100644
--- a/Source/cmSourceGroupCommand.h
+++ b/Source/cmSourceGroupCommand.h
@@ -41,7 +41,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "source_group";}
+ virtual std::string GetName() const {return "source_group";}
cmTypeMacro(cmSourceGroupCommand, cmCommand);
};
diff --git a/Source/cmStandardIncludes.h b/Source/cmStandardIncludes.h
index b4ae657..3731502 100644
--- a/Source/cmStandardIncludes.h
+++ b/Source/cmStandardIncludes.h
@@ -241,7 +241,7 @@ inline bool operator==(std::string const& a, const char* b)
// 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 cmStdString;
+//typedef cmsys::String std::string;
// Define cmOStringStream and cmIStringStream wrappers to hide
// differences between std::stringstream and the old strstream.
@@ -324,12 +324,12 @@ struct cmDocumentationEntry
{
std::string Name;
std::string Brief;
- cmDocumentationEntry(){};
+ cmDocumentationEntry(){}
cmDocumentationEntry(const char *doc[2])
{ if (doc[0]) this->Name = doc[0];
- if (doc[1]) this->Brief = doc[1];};
+ if (doc[1]) this->Brief = doc[1];}
cmDocumentationEntry(const char *n, const char *b)
- { if (n) this->Name = n; if (b) this->Brief = b; };
+ { if (n) this->Name = n; if (b) this->Brief = b; }
};
/** Data structure to represent a single command line. */
@@ -378,7 +378,8 @@ static thisClass* SafeDownCast(cmObject *c) \
return static_cast<thisClass *>(c); \
} \
return 0;\
-}
+} \
+class cmTypeMacro_UseTrailingSemicolon
inline bool cmHasLiteralPrefixImpl(const std::string &str1,
const char *str2,
@@ -449,11 +450,16 @@ bool cmHasLiteralSuffix(T str1, const char (&str2)[N])
struct cmStrCmp {
cmStrCmp(const char *test) : m_test(test) {}
- cmStrCmp(std::string &test) : m_test(test.c_str()) {}
+ cmStrCmp(const std::string &test) : m_test(test) {}
+
+ bool operator()(const std::string& input) const
+ {
+ return m_test == input;
+ }
bool operator()(const char * input) const
{
- return strcmp(input, m_test) == 0;
+ return strcmp(input, m_test.c_str()) == 0;
}
// For use with binary_search
@@ -463,7 +469,7 @@ struct cmStrCmp {
}
private:
- const char * const m_test;
+ const std::string m_test;
};
#endif
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index f9b69e3..ea762eb 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -101,9 +101,13 @@ bool cmStringCommand
{
return this->HandleMakeCIdentifierCommand(args);
}
+ else if(subCommand == "GENEX_STRIP")
+ {
+ return this->HandleGenexStripCommand(args);
+ }
std::string e = "does not recognize sub-command "+subCommand;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -115,15 +119,15 @@ bool cmStringCommand::HandleHashCommand(std::vector<std::string> const& args)
{
cmOStringStream e;
e << args[0] << " requires an output variable and an input string";
- this->SetError(e.str().c_str());
+ this->SetError(e.str());
return false;
}
cmsys::auto_ptr<cmCryptoHash> hash(cmCryptoHash::New(args[0].c_str()));
if(hash.get())
{
- std::string out = hash->HashString(args[2].c_str());
- this->Makefile->AddDefinition(args[1].c_str(), out.c_str());
+ std::string out = hash->HashString(args[2]);
+ this->Makefile->AddDefinition(args[1], out.c_str());
return true;
}
return false;
@@ -158,7 +162,7 @@ bool cmStringCommand::HandleToUpperLowerCommand(
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outvar, output.c_str());
return true;
}
@@ -185,12 +189,12 @@ bool cmStringCommand::HandleAsciiCommand(std::vector<std::string> const& args)
std::string error = "Character with code ";
error += args[cc];
error += " does not exist.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outvar, output.c_str());
return true;
}
@@ -226,7 +230,7 @@ bool cmStringCommand::HandleConfigureCommand(
{
cmOStringStream err;
err << "Unrecognized argument \"" << args[i] << "\"";
- this->SetError(err.str().c_str());
+ this->SetError(err.str());
return false;
}
}
@@ -236,7 +240,7 @@ bool cmStringCommand::HandleConfigureCommand(
this->Makefile->ConfigureString(args[1], output, atOnly, escapeQuotes);
// Store the output in the provided variable.
- this->Makefile->AddDefinition(args[2].c_str(), output.c_str());
+ this->Makefile->AddDefinition(args[2], output.c_str());
return true;
}
@@ -282,7 +286,7 @@ bool cmStringCommand::HandleRegexCommand(std::vector<std::string> const& args)
}
std::string e = "sub-command REGEX does not recognize mode "+mode;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -308,7 +312,7 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
{
std::string e =
"sub-command REGEX, mode MATCH failed to compile regex \""+regex+"\".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -324,14 +328,14 @@ bool cmStringCommand::RegexMatch(std::vector<std::string> const& args)
std::string e =
"sub-command REGEX, mode MATCH regex \""+regex+
"\" matched an empty string.";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
output = input.substr(l, r-l);
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outvar, output.c_str());
return true;
}
@@ -358,7 +362,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
std::string e =
"sub-command REGEX, mode MATCHALL failed to compile regex \""+
regex+"\".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -374,7 +378,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
{
std::string e = "sub-command REGEX, mode MATCHALL regex \""+
regex+"\" matched an empty string.";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
if(output.length() > 0)
@@ -386,7 +390,7 @@ bool cmStringCommand::RegexMatchAll(std::vector<std::string> const& args)
}
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outvar, output.c_str());
return true;
}
@@ -439,7 +443,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
std::string e = "sub-command REGEX, mode REPLACE: Unknown escape \"";
e += replace.substr(r, 2);
e += "\" in replace-expression.";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
r += 2;
@@ -462,7 +466,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
std::string e =
"sub-command REGEX, mode REPLACE failed to compile regex \""+
regex+"\".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -483,7 +487,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
{
std::string e = "sub-command REGEX, mode REPLACE regex \""+
regex+"\" matched an empty string.";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -513,7 +517,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
"sub-command REGEX, mode REPLACE: replace expression \""+
replace+"\" contains an out-of-range escape for regex \""+
regex+"\".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
}
@@ -527,7 +531,7 @@ bool cmStringCommand::RegexReplace(std::vector<std::string> const& args)
output += input.substr(base, input.length()-base);
// Store the output in the provided variable.
- this->Makefile->AddDefinition(outvar.c_str(), output.c_str());
+ this->Makefile->AddDefinition(outvar, output.c_str());
return true;
}
@@ -616,12 +620,12 @@ bool cmStringCommand::HandleFindCommand(std::vector<std::string> const&
{
cmOStringStream s;
s << pos;
- this->Makefile->AddDefinition(outvar.c_str(), s.str().c_str());
+ this->Makefile->AddDefinition(outvar, s.str().c_str());
return true;
}
// the character was not found, but this is not really an error
- this->Makefile->AddDefinition(outvar.c_str(), "-1");
+ this->Makefile->AddDefinition(outvar, "-1");
return true;
}
@@ -643,7 +647,7 @@ bool cmStringCommand::HandleCompareCommand(std::vector<std::string> const&
std::string e = "sub-command COMPARE, mode ";
e += mode;
e += " needs at least 5 arguments total to command.";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -669,16 +673,16 @@ bool cmStringCommand::HandleCompareCommand(std::vector<std::string> const&
}
if(result)
{
- this->Makefile->AddDefinition(outvar.c_str(), "1");
+ this->Makefile->AddDefinition(outvar, "1");
}
else
{
- this->Makefile->AddDefinition(outvar.c_str(), "0");
+ this->Makefile->AddDefinition(outvar, "0");
}
return true;
}
std::string e = "sub-command COMPARE does not recognize mode "+mode;
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
@@ -705,7 +709,7 @@ bool cmStringCommand::HandleReplaceCommand(std::vector<std::string> const&
cmsys::SystemTools::ReplaceString(input, matchExpression.c_str(),
replaceExpression.c_str());
- this->Makefile->AddDefinition(variableName.c_str(), input.c_str());
+ this->Makefile->AddDefinition(variableName, input.c_str());
return true;
}
@@ -731,7 +735,7 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
cmOStringStream ostr;
ostr << "begin index: " << begin << " is out of range 0 - "
<< stringLength;
- this->SetError(ostr.str().c_str());
+ this->SetError(ostr.str());
return false;
}
int leftOverLength = intStringLength - begin;
@@ -740,11 +744,11 @@ bool cmStringCommand::HandleSubstringCommand(std::vector<std::string> const&
cmOStringStream ostr;
ostr << "end index: " << end << " is out of range -1 - "
<< leftOverLength;
- this->SetError(ostr.str().c_str());
+ this->SetError(ostr.str());
return false;
}
- this->Makefile->AddDefinition(variableName.c_str(),
+ this->Makefile->AddDefinition(variableName,
stringValue.substr(begin, end).c_str());
return true;
}
@@ -766,7 +770,7 @@ bool cmStringCommand
char buffer[1024];
sprintf(buffer, "%d", static_cast<int>(length));
- this->Makefile->AddDefinition(variableName.c_str(), buffer);
+ this->Makefile->AddDefinition(variableName, buffer);
return true;
}
@@ -787,7 +791,7 @@ bool cmStringCommand
value += args[i];
}
- this->Makefile->AddDefinition(variableName.c_str(), value.c_str());
+ this->Makefile->AddDefinition(variableName, value.c_str());
return true;
}
@@ -804,12 +808,33 @@ bool cmStringCommand
const std::string& input = args[1];
const std::string& variableName = args[2];
- this->Makefile->AddDefinition(variableName.c_str(),
+ this->Makefile->AddDefinition(variableName,
cmSystemTools::MakeCidentifier(input.c_str()).c_str());
return true;
}
//----------------------------------------------------------------------------
+bool cmStringCommand
+::HandleGenexStripCommand(std::vector<std::string> const& args)
+{
+ if(args.size() != 3)
+ {
+ this->SetError("sub-command GENEX_STRIP requires two arguments.");
+ return false;
+ }
+
+ const std::string& input = args[1];
+
+ std::string result = cmGeneratorExpression::Preprocess(input,
+ cmGeneratorExpression::StripAllGeneratorExpressions);
+
+ const std::string& variableName = args[2];
+
+ this->Makefile->AddDefinition(variableName, result.c_str());
+ return true;
+}
+
+//----------------------------------------------------------------------------
bool cmStringCommand::HandleStripCommand(
std::vector<std::string> const& args)
{
@@ -853,7 +878,7 @@ bool cmStringCommand::HandleStripCommand(
outLength=endPos - startPos + 1;
}
- this->Makefile->AddDefinition(variableName.c_str(),
+ this->Makefile->AddDefinition(variableName,
stringValue.substr(startPos, outLength).c_str());
return true;
}
@@ -937,7 +962,7 @@ bool cmStringCommand
}
result.push_back(0);
- this->Makefile->AddDefinition(variableName.c_str(), &*result.begin());
+ this->Makefile->AddDefinition(variableName, &*result.begin());
return true;
}
@@ -977,14 +1002,14 @@ bool cmStringCommand
{
std::string e = " TIMESTAMP sub-command does not recognize option " +
args[argsIndex] + ".";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
}
cmTimestamp timestamp;
std::string result = timestamp.CurrentTime(formatString, utcFlag);
- this->Makefile->AddDefinition(outputVariable.c_str(), result.c_str());
+ this->Makefile->AddDefinition(outputVariable, result.c_str());
return true;
}
diff --git a/Source/cmStringCommand.h b/Source/cmStringCommand.h
index 66b48e6..51069e7 100644
--- a/Source/cmStringCommand.h
+++ b/Source/cmStringCommand.h
@@ -50,7 +50,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "string";}
+ virtual std::string GetName() const { return "string";}
cmTypeMacro(cmStringCommand, cmCommand);
static void ClearMatches(cmMakefile* mf);
@@ -75,6 +75,7 @@ protected:
bool HandleFindCommand(std::vector<std::string> const& args);
bool HandleTimestampCommand(std::vector<std::string> const& args);
bool HandleMakeCIdentifierCommand(std::vector<std::string> const& args);
+ bool HandleGenexStripCommand(std::vector<std::string> const& args);
class RegexReplacement
{
@@ -82,7 +83,7 @@ protected:
RegexReplacement(const char* s): number(-1), value(s) {}
RegexReplacement(const std::string& s): number(-1), value(s) {}
RegexReplacement(int n): number(n), value() {}
- RegexReplacement() {};
+ RegexReplacement() {}
int number;
std::string value;
};
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index e497b46..cdde916 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -47,7 +47,7 @@ bool cmSubdirCommand
std::string binPath =
std::string(this->Makefile->GetCurrentOutputDirectory()) +
"/" + i->c_str();
- this->Makefile->AddSubDirectory(srcPath.c_str(), binPath.c_str(),
+ this->Makefile->AddSubDirectory(srcPath, binPath,
excludeFromAll, preorder, false);
}
// otherwise it is a full path
@@ -57,15 +57,15 @@ bool cmSubdirCommand
// element from the source path and use that
std::string binPath =
std::string(this->Makefile->GetCurrentOutputDirectory()) +
- "/" + cmSystemTools::GetFilenameName(i->c_str());
- this->Makefile->AddSubDirectory(i->c_str(), binPath.c_str(),
+ "/" + cmSystemTools::GetFilenameName(*i);
+ this->Makefile->AddSubDirectory(*i, binPath,
excludeFromAll, preorder, false);
}
else
{
std::string error = "Incorrect SUBDIRS command. Directory: ";
error += *i + " does not exist.";
- this->SetError(error.c_str());
+ this->SetError(error);
res = false;
}
}
diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h
index 8be8335..6addd8f 100644
--- a/Source/cmSubdirCommand.h
+++ b/Source/cmSubdirCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "subdirs";}
+ virtual std::string GetName() const { return "subdirs";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
diff --git a/Source/cmSubdirDependsCommand.h b/Source/cmSubdirDependsCommand.h
index f78cfb7..75a5685 100644
--- a/Source/cmSubdirDependsCommand.h
+++ b/Source/cmSubdirDependsCommand.h
@@ -20,7 +20,7 @@ public:
virtual cmCommand* Clone() { return new cmSubdirDependsCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const { return "subdir_depends";}
+ virtual std::string GetName() const { return "subdir_depends";}
virtual bool IsDiscouraged() const { return true; }
cmTypeMacro(cmSubdirDependsCommand, cmCommand);
};
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index ff05975..c27b561 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -179,10 +179,11 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, KeyWOW64)
}
#endif
-std::string cmSystemTools::EscapeQuotes(const char* str)
+std::string cmSystemTools::EscapeQuotes(const std::string& str)
{
- std::string result = "";
- for(const char* ch = str; *ch != '\0'; ++ch)
+ std::string result;
+ result.reserve(str.size());
+ for(const char* ch = str.c_str(); *ch != '\0'; ++ch)
{
if(*ch == '"')
{
@@ -476,13 +477,6 @@ public:
args.push_back(*arg);
}
}
- void Store(std::vector<cmStdString>& args) const
- {
- for(char** arg = this->ArgV; arg && *arg; ++arg)
- {
- args.push_back(*arg);
- }
- }
};
//----------------------------------------------------------------------------
@@ -494,15 +488,6 @@ void cmSystemTools::ParseUnixCommandLine(const char* command,
argv.Store(args);
}
-//----------------------------------------------------------------------------
-void cmSystemTools::ParseUnixCommandLine(const char* command,
- std::vector<cmStdString>& args)
-{
- // Invoke the underlying parser.
- cmSystemToolsArgV argv = cmsysSystem_Parse_CommandForUnix(command, 0);
- argv.Store(args);
-}
-
std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
int shell_flags)
{
@@ -522,9 +507,9 @@ std::string cmSystemTools::EscapeWindowsShellArgument(const char* arg,
return result;
}
-std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
+std::vector<std::string> cmSystemTools::ParseArguments(const char* command)
{
- std::vector<cmStdString> args;
+ std::vector<std::string> args;
std::string arg;
bool win_path = false;
@@ -605,22 +590,6 @@ std::vector<cmStdString> cmSystemTools::ParseArguments(const char* command)
}
-bool cmSystemTools::RunSingleCommand(std::vector<cmStdString>const& command,
- std::string* output ,
- int* retVal , const char* dir ,
- OutputOption outputflag ,
- double timeout )
-{
- std::vector<std::string> cmd;
- for(std::vector<cmStdString>::const_iterator i = command.begin();
- i != command.end(); ++i)
- {
- cmd.push_back(*i);
- }
- return cmSystemTools::RunSingleCommand(cmd, output, retVal, dir,
- outputflag, timeout);
-}
-
bool cmSystemTools::RunSingleCommand(std::vector<std::string>const& command,
std::string* output ,
int* retVal , const char* dir ,
@@ -780,7 +749,7 @@ bool cmSystemTools::RunSingleCommand(
outputflag = OUTPUT_NONE;
}
- std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+ std::vector<std::string> args = cmSystemTools::ParseArguments(command);
if(args.size() < 1)
{
@@ -944,7 +913,7 @@ bool cmSystemTools::RenameFile(const char* oldname, const char* newname)
#endif
}
-bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
+bool cmSystemTools::ComputeFileMD5(const std::string& source, char* md5out)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmCryptoHashMD5 md5;
@@ -959,7 +928,7 @@ bool cmSystemTools::ComputeFileMD5(const char* source, char* md5out)
#endif
}
-std::string cmSystemTools::ComputeStringMD5(const char* input)
+std::string cmSystemTools::ComputeStringMD5(const std::string& input)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
cmCryptoHashMD5 md5;
@@ -971,13 +940,14 @@ std::string cmSystemTools::ComputeStringMD5(const char* input)
#endif
}
-void cmSystemTools::Glob(const char *directory, const char *regexp,
+void cmSystemTools::Glob(const std::string& directory,
+ const std::string& regexp,
std::vector<std::string>& files)
{
cmsys::Directory d;
- cmsys::RegularExpression reg(regexp);
+ cmsys::RegularExpression reg(regexp.c_str());
- if (d.Load(directory))
+ if (d.Load(directory.c_str()))
{
size_t numf;
unsigned int i;
@@ -994,14 +964,13 @@ void cmSystemTools::Glob(const char *directory, const char *regexp,
}
-void cmSystemTools::GlobDirs(const char *fullPath,
+void cmSystemTools::GlobDirs(const std::string& path,
std::vector<std::string>& files)
{
- std::string path = fullPath;
std::string::size_type pos = path.find("/*");
if(pos == std::string::npos)
{
- files.push_back(fullPath);
+ files.push_back(path);
return;
}
std::string startPath = path.substr(0, pos);
@@ -1021,7 +990,7 @@ void cmSystemTools::GlobDirs(const char *fullPath,
if(cmSystemTools::FileIsDirectory(fname.c_str()))
{
fname += finishPath;
- cmSystemTools::GlobDirs(fname.c_str(), files);
+ cmSystemTools::GlobDirs(fname, files);
}
}
}
@@ -1044,7 +1013,7 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
bool emptyArgs)
{
// If argument is empty, it is an empty list.
- if(arg.length() == 0 && !emptyArgs)
+ if(!emptyArgs && arg.empty())
{
return;
}
@@ -1054,10 +1023,11 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
newargs.push_back(arg);
return;
}
- std::vector<char> newArgVec;
+ std::string newArg;
+ const char *last = arg.c_str();
// Break the string at non-escaped semicolons not nested in [].
int squareNesting = 0;
- for(const char* c = arg.c_str(); *c; ++c)
+ for(const char* c = last; *c; ++c)
{
switch(*c)
{
@@ -1065,34 +1035,21 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
{
// We only want to allow escaping of semicolons. Other
// escapes should not be processed here.
- ++c;
- if(*c == ';')
- {
- newArgVec.push_back(*c);
- }
- else
+ const char* next = c + 1;
+ if(*next == ';')
{
- newArgVec.push_back('\\');
- if(*c)
- {
- newArgVec.push_back(*c);
- }
- else
- {
- // Terminate the loop properly.
- --c;
- }
+ newArg.append(last, c - last);
+ // Skip over the escape character
+ last = c = next;
}
} break;
case '[':
{
++squareNesting;
- newArgVec.push_back(*c);
} break;
case ']':
{
--squareNesting;
- newArgVec.push_back(*c);
} break;
case ';':
{
@@ -1100,36 +1057,33 @@ void cmSystemTools::ExpandListArgument(const std::string& arg,
// brackets.
if(squareNesting == 0)
{
- if ( newArgVec.size() || emptyArgs )
+ newArg.append(last, c - last);
+ // Skip over the semicolon
+ last = c + 1;
+ if ( !newArg.empty() || emptyArgs )
{
// Add the last argument if the string is not empty.
- newArgVec.push_back(0);
- newargs.push_back(&*newArgVec.begin());
- newArgVec.clear();
+ newargs.push_back(newArg);
+ newArg = "";
}
}
- else
- {
- newArgVec.push_back(*c);
- }
} break;
default:
{
// Just append this character.
- newArgVec.push_back(*c);
} break;
}
}
- if ( newArgVec.size() || emptyArgs )
+ newArg.append(last);
+ if ( !newArg.empty() || emptyArgs )
{
// Add the last argument if the string is not empty.
- newArgVec.push_back(0);
- newargs.push_back(&*newArgVec.begin());
+ newargs.push_back(newArg);
}
}
-bool cmSystemTools::SimpleGlob(const cmStdString& glob,
- std::vector<cmStdString>& files,
+bool cmSystemTools::SimpleGlob(const std::string& glob,
+ std::vector<std::string>& files,
int type /* = 0 */)
{
files.clear();
@@ -1247,7 +1201,7 @@ cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
return cmSystemTools::UNKNOWN_FILE_FORMAT;
}
-bool cmSystemTools::Split(const char* s, std::vector<cmStdString>& l)
+bool cmSystemTools::Split(const char* s, std::vector<std::string>& l)
{
std::vector<std::string> temp;
bool res = Superclass::Split(s, temp);
@@ -1459,7 +1413,7 @@ bool cmSystemTools::IsPathToFramework(const char* path)
}
bool cmSystemTools::CreateTar(const char* outFileName,
- const std::vector<cmStdString>& files,
+ const std::vector<std::string>& files,
bool gzip, bool bzip2, bool verbose)
{
#if defined(CMAKE_BUILD_WITH_CMAKE)
@@ -1479,7 +1433,7 @@ bool cmSystemTools::CreateTar(const char* outFileName,
cmArchiveWrite::CompressNone)),
cmArchiveWrite::TypeTAR);
a.SetVerbose(verbose);
- for(std::vector<cmStdString>::const_iterator i = files.begin();
+ for(std::vector<std::string>::const_iterator i = files.begin();
i != files.end(); ++i)
{
std::string path = *i;
@@ -1662,7 +1616,9 @@ long copy_data(struct archive *ar, struct archive *aw)
return (r);
}
}
- return r;
+#if !defined(__clang__) && !defined(__HP_aCC)
+ return r; /* this should not happen but it quiets some compilers */
+#endif
}
bool extract_tar(const char* outFileName, bool verbose,
@@ -2151,7 +2107,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0)
// remove symlinks
exe = cmSystemTools::GetRealPath(exe.c_str());
exe_dir =
- cmSystemTools::GetFilenamePath(exe.c_str());
+ cmSystemTools::GetFilenamePath(exe);
}
else
{
@@ -2331,10 +2287,10 @@ bool cmSystemTools::GuessLibrarySOName(std::string const& fullPath,
bool cmSystemTools::GuessLibraryInstallName(std::string const& fullPath,
std::string& soname)
{
- std::vector<cmStdString> cmds;
+ std::vector<std::string> cmds;
cmds.push_back("otool");
cmds.push_back("-D");
- cmds.push_back(fullPath.c_str());
+ cmds.push_back(fullPath);
std::string output;
if(!RunSingleCommand(cmds, &output, 0, 0, OUTPUT_NONE))
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 4a5d298..27b4bce 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -47,7 +47,7 @@ public:
KeyWOW64 view = KeyWOW64_Default);
///! Escape quotes in a string.
- static std::string EscapeQuotes(const char* str);
+ static std::string EscapeQuotes(const std::string& str);
/** Map help document name to file name. */
static std::string HelpFileName(std::string);
@@ -158,9 +158,10 @@ public:
static std::string FileExistsInParentDirectories(const char* fname,
const char* directory, const char* toplevel);
- static void Glob(const char *directory, const char *regexp,
+ static void Glob(const std::string& directory, const std::string& regexp,
std::vector<std::string>& files);
- static void GlobDirs(const char *fullPath, std::vector<std::string>& files);
+ static void GlobDirs(const std::string& fullPath,
+ std::vector<std::string>& files);
/**
* Try to find a list of files that match the "simple" globbing
@@ -171,8 +172,8 @@ public:
* want to find. 0 means all files, -1 means directories, 1 means
* files only. This method returns true if search was succesfull.
*/
- static bool SimpleGlob(const cmStdString& glob,
- std::vector<cmStdString>& files,
+ static bool SimpleGlob(const std::string& glob,
+ std::vector<std::string>& files,
int type = 0);
///! Copy a file.
@@ -185,10 +186,10 @@ public:
static bool RenameFile(const char* oldname, const char* newname);
///! Compute the md5sum of a file
- static bool ComputeFileMD5(const char* source, char* md5out);
+ static bool ComputeFileMD5(const std::string& source, char* md5out);
/** Compute the md5sum of a string. */
- static std::string ComputeStringMD5(const char* input);
+ static std::string ComputeStringMD5(const std::string& input);
/**
* Run a single executable command
@@ -233,18 +234,13 @@ public:
int* retVal = 0, const char* dir = 0,
OutputOption outputflag = OUTPUT_MERGE,
double timeout = 0.0);
- static bool RunSingleCommand(std::vector<cmStdString> const& command,
- std::string* output = 0,
- int* retVal = 0, const char* dir = 0,
- OutputOption outputflag = OUTPUT_MERGE,
- double timeout = 0.0);
static std::string PrintSingleCommand(std::vector<std::string> const&);
/**
* Parse arguments out of a single string command
*/
- static std::vector<cmStdString> ParseArguments(const char* command);
+ static std::vector<std::string> ParseArguments(const char* command);
/** Parse arguments out of a windows command line string. */
static void ParseWindowsCommandLine(const char* command,
@@ -253,8 +249,6 @@ public:
/** Parse arguments out of a unix command line string. */
static void ParseUnixCommandLine(const char* command,
std::vector<std::string>& args);
- static void ParseUnixCommandLine(const char* command,
- std::vector<cmStdString>& args);
/** Compute an escaped version of the given argument for use in a
windows shell. See kwsys/System.h.in for details. */
@@ -320,7 +314,7 @@ public:
/** Split a string on its newlines into multiple lines. Returns
false only if the last line stored had no newline. */
- static bool Split(const char* s, std::vector<cmStdString>& l);
+ static bool Split(const char* s, std::vector<std::string>& l);
static void SetForceUnixPaths(bool v)
{
s_ForceUnixPaths = v;
@@ -389,7 +383,7 @@ public:
static bool ListTar(const char* outFileName,
bool gzip, bool verbose);
static bool CreateTar(const char* outFileName,
- const std::vector<cmStdString>& files, bool gzip,
+ const std::vector<std::string>& files, bool gzip,
bool bzip2, bool verbose);
static bool ExtractTar(const char* inFileName, bool gzip,
bool verbose);
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index e2a568b..ee6cb44 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -71,6 +71,12 @@ struct cmTarget::ImportInfo
cmTarget::LinkInterface LinkInterface;
};
+//----------------------------------------------------------------------------
+struct cmTarget::CompileInfo
+{
+ std::string CompilePdbDir;
+};
+
struct TargetConfigPair : public std::pair<cmTarget const* , std::string> {
TargetConfigPair(cmTarget const* tgt, const std::string &config)
: std::pair<cmTarget const* , std::string>(tgt, config) {}
@@ -83,17 +89,12 @@ public:
cmTargetInternals()
{
this->PolicyWarnedCMP0022 = false;
- this->SourceFileFlagsConstructed = false;
}
cmTargetInternals(cmTargetInternals const&)
{
this->PolicyWarnedCMP0022 = false;
- this->SourceFileFlagsConstructed = false;
}
~cmTargetInternals();
- typedef cmTarget::SourceFileFlags SourceFileFlags;
- mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap;
- mutable bool SourceFileFlagsConstructed;
// The backtrace when the target was created.
cmListFileBacktrace Backtrace;
@@ -101,21 +102,33 @@ public:
// Cache link interface computation from each configuration.
struct OptionalLinkInterface: public cmTarget::LinkInterface
{
- OptionalLinkInterface(): Exists(false) {}
+ OptionalLinkInterface():
+ Exists(false), Complete(false), ExplicitLibraries(0) {}
bool Exists;
+ bool Complete;
+ const char* ExplicitLibraries;
};
+ void ComputeLinkInterface(cmTarget const* thisTarget,
+ const std::string& config,
+ OptionalLinkInterface& iface,
+ cmTarget const* head,
+ const char *explicitLibraries) const;
+
typedef std::map<TargetConfigPair, OptionalLinkInterface>
LinkInterfaceMapType;
LinkInterfaceMapType LinkInterfaceMap;
bool PolicyWarnedCMP0022;
- typedef std::map<cmStdString, cmTarget::OutputInfo> OutputInfoMapType;
+ typedef std::map<std::string, cmTarget::OutputInfo> OutputInfoMapType;
OutputInfoMapType OutputInfoMap;
typedef std::map<TargetConfigPair, cmTarget::ImportInfo>
ImportInfoMapType;
ImportInfoMapType ImportInfoMap;
+ typedef std::map<std::string, cmTarget::CompileInfo> CompileInfoMapType;
+ CompileInfoMapType CompileInfoMap;
+
// Cache link implementation computation from each configuration.
typedef std::map<TargetConfigPair,
cmTarget::LinkImplementation> LinkImplMapType;
@@ -125,6 +138,10 @@ public:
LinkClosureMapType;
LinkClosureMapType LinkClosureMap;
+ typedef std::map<TargetConfigPair, std::vector<cmSourceFile*> >
+ SourceFilesMapType;
+ SourceFilesMapType SourceFilesMap;
+
struct TargetPropertyEntry {
TargetPropertyEntry(cmsys::auto_ptr<cmCompiledGeneratorExpression> cge,
const std::string &targetName = std::string())
@@ -136,7 +153,9 @@ public:
};
std::vector<TargetPropertyEntry*> IncludeDirectoriesEntries;
std::vector<TargetPropertyEntry*> CompileOptionsEntries;
+ std::vector<TargetPropertyEntry*> CompileFeaturesEntries;
std::vector<TargetPropertyEntry*> CompileDefinitionsEntries;
+ std::vector<TargetPropertyEntry*> SourceEntries;
std::vector<cmValueWithOrigin> LinkImplementationPropertyEntries;
mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
@@ -145,10 +164,16 @@ public:
CachedLinkInterfaceCompileOptionsEntries;
mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
CachedLinkInterfaceCompileDefinitionsEntries;
+ mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
+ CachedLinkInterfaceSourcesEntries;
+ mutable std::map<std::string, std::vector<TargetPropertyEntry*> >
+ CachedLinkInterfaceCompileFeaturesEntries;
mutable std::map<std::string, bool> CacheLinkInterfaceIncludeDirectoriesDone;
mutable std::map<std::string, bool> CacheLinkInterfaceCompileDefinitionsDone;
mutable std::map<std::string, bool> CacheLinkInterfaceCompileOptionsDone;
+ mutable std::map<std::string, bool> CacheLinkInterfaceSourcesDone;
+ mutable std::map<std::string, bool> CacheLinkInterfaceCompileFeaturesDone;
};
//----------------------------------------------------------------------------
@@ -183,7 +208,9 @@ cmTargetInternals::~cmTargetInternals()
{
deleteAndClear(this->CachedLinkInterfaceIncludeDirectoriesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileOptionsEntries);
+ deleteAndClear(this->CachedLinkInterfaceCompileFeaturesEntries);
deleteAndClear(this->CachedLinkInterfaceCompileDefinitionsEntries);
+ deleteAndClear(this->CachedLinkInterfaceSourcesEntries);
}
//----------------------------------------------------------------------------
@@ -205,7 +232,10 @@ cmTarget::cmTarget()
this->BuildInterfaceIncludesAppended = false;
this->DebugIncludesDone = false;
this->DebugCompileOptionsDone = false;
+ this->DebugCompileFeaturesDone = false;
this->DebugCompileDefinitionsDone = false;
+ this->DebugSourcesDone = false;
+ this->LinkImplementationLanguageIsContextDependent = true;
}
//----------------------------------------------------------------------------
@@ -222,7 +252,7 @@ void cmTarget::DefineProperties(cmake *cm)
"", "", true);
}
-void cmTarget::SetType(TargetType type, const char* name)
+void cmTarget::SetType(TargetType type, const std::string& name)
{
this->Name = name;
// only add dependency information for library targets
@@ -267,6 +297,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("LIBRARY_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("RUNTIME_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("PDB_OUTPUT_DIRECTORY", 0);
+ this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", 0);
this->SetPropertyDefault("Fortran_FORMAT", 0);
this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", 0);
this->SetPropertyDefault("GNUtoMS", 0);
@@ -283,6 +314,8 @@ void cmTarget::SetMakefile(cmMakefile* mf)
this->SetPropertyDefault("MACOSX_BUNDLE", 0);
this->SetPropertyDefault("MACOSX_RPATH", 0);
this->SetPropertyDefault("NO_SYSTEM_FROM_IMPORTED", 0);
+ this->SetPropertyDefault("CXX_STANDARD", 0);
+ this->SetPropertyDefault("CXX_EXTENSIONS", 0);
}
// Collect the set of configuration types.
@@ -295,6 +328,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
"LIBRARY_OUTPUT_DIRECTORY_",
"RUNTIME_OUTPUT_DIRECTORY_",
"PDB_OUTPUT_DIRECTORY_",
+ "COMPILE_PDB_OUTPUT_DIRECTORY_",
"MAP_IMPORTED_CONFIG_",
0};
for(std::vector<std::string>::iterator ci = configNames.begin();
@@ -310,7 +344,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
}
std::string property = *p;
property += configUpper;
- this->SetPropertyDefault(property.c_str(), 0);
+ this->SetPropertyDefault(property, 0);
}
// Initialize per-configuration name postfix property from the
@@ -323,7 +357,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{
std::string property = cmSystemTools::UpperCase(*ci);
property += "_POSTFIX";
- this->SetPropertyDefault(property.c_str(), 0);
+ this->SetPropertyDefault(property, 0);
}
}
@@ -342,10 +376,10 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{
this->InsertInclude(*it);
}
- const std::set<cmStdString> parentSystemIncludes =
+ const std::set<std::string> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories();
- for (std::set<cmStdString>::const_iterator it
+ for (std::set<std::string>::const_iterator it
= parentSystemIncludes.begin();
it != parentSystemIncludes.end(); ++it)
{
@@ -401,7 +435,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
}
//----------------------------------------------------------------------------
-void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
+void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile)
{
if(this->Utilities.insert(u).second && makefile)
{
@@ -410,9 +444,10 @@ void cmTarget::AddUtility(const char *u, cmMakefile *makefile)
}
//----------------------------------------------------------------------------
-cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(const char *u) const
+cmListFileBacktrace const* cmTarget::GetUtilityBacktrace(
+ const std::string& u) const
{
- std::map<cmStdString, cmListFileBacktrace>::const_iterator i =
+ std::map<std::string, cmListFileBacktrace>::const_iterator i =
this->UtilityBacktraces.find(u);
if(i == this->UtilityBacktraces.end()) return 0;
@@ -435,6 +470,7 @@ void cmTarget::FinishConfigure()
//----------------------------------------------------------------------------
void cmTarget::ClearLinkMaps()
{
+ this->LinkImplementationLanguageIsContextDependent = true;
this->Internal->LinkImplMap.clear();
this->Internal->LinkInterfaceMap.clear();
this->Internal->LinkClosureMap.clear();
@@ -526,21 +562,286 @@ bool cmTarget::IsBundleOnApple() const
}
//----------------------------------------------------------------------------
-bool cmTarget::FindSourceFiles()
+static bool processSources(cmTarget const* tgt,
+ const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &srcs,
+ std::set<std::string> &uniqueSrcs,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ cmTarget const* head,
+ std::string const& config, bool debugSources)
{
- for(std::vector<cmSourceFile*>::const_iterator
- si = this->SourceFiles.begin();
- si != this->SourceFiles.end(); ++si)
+ cmMakefile *mf = tgt->GetMakefile();
+
+ bool contextDependent = false;
+
+ for (std::vector<cmTargetInternals::TargetPropertyEntry*>::const_iterator
+ it = entries.begin(), end = entries.end(); it != end; ++it)
{
- std::string e;
- if((*si)->GetFullPath(&e).empty())
+ bool cacheSources = false;
+ std::vector<std::string> entrySources = (*it)->CachedEntries;
+ if(entrySources.empty())
{
- if(!e.empty())
+ cmSystemTools::ExpandListArgument((*it)->ge->Evaluate(mf,
+ config,
+ false,
+ head ? head : tgt,
+ tgt,
+ dagChecker),
+ entrySources);
+
+ if ((*it)->ge->GetHadContextSensitiveCondition())
{
- cmake* cm = this->Makefile->GetCMakeInstance();
- cm->IssueMessage(cmake::FATAL_ERROR, e,
- this->GetBacktrace());
+ contextDependent = true;
+ }
+ else if (mf->IsGeneratingBuildSystem())
+ {
+ cacheSources = true;
+ }
+
+ for(std::vector<std::string>::iterator i = entrySources.begin();
+ i != entrySources.end(); ++i)
+ {
+ std::string& src = *i;
+
+ cmSourceFile* sf = mf->GetOrCreateSource(src);
+ std::string e;
+ src = sf->GetFullPath(&e);
+ if(src.empty())
+ {
+ if(!e.empty())
+ {
+ cmake* cm = mf->GetCMakeInstance();
+ cm->IssueMessage(cmake::FATAL_ERROR, e,
+ tgt->GetBacktrace());
+ }
+ return contextDependent;
+ }
+ }
+ if (cacheSources)
+ {
+ (*it)->CachedEntries = entrySources;
+ }
+ }
+ std::string usedSources;
+ for(std::vector<std::string>::iterator
+ li = entrySources.begin(); li != entrySources.end(); ++li)
+ {
+ std::string src = *li;
+
+ if(uniqueSrcs.insert(src).second)
+ {
+ srcs.push_back(src);
+ if (debugSources)
+ {
+ usedSources += " * " + src + "\n";
+ }
+ }
+ }
+ if (!usedSources.empty())
+ {
+ mf->GetCMakeInstance()->IssueMessage(cmake::LOG,
+ std::string("Used sources for target ")
+ + tgt->GetName() + ":\n"
+ + usedSources, (*it)->ge->GetBacktrace());
+ }
+ }
+ return contextDependent;
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetSourceFiles(std::vector<std::string> &files,
+ const std::string& config,
+ cmTarget const* head) const
+{
+ assert(this->GetType() != INTERFACE_LIBRARY);
+
+ if (this->Makefile->GetGeneratorTargets().empty())
+ {
+ // At configure-time, this method can be called as part of getting the
+ // LOCATION property or to export() a file to be include()d. However
+ // there is no cmGeneratorTarget at configure-time, so search the SOURCES
+ // for TARGET_OBJECTS instead for backwards compatibility with OLD
+ // behavior of CMP0024 and CMP0026 only.
+
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for(std::vector<TargetPropertyEntry*>::const_iterator
+ i = this->Internal->SourceEntries.begin();
+ i != this->Internal->SourceEntries.end(); ++i)
+ {
+ std::string entry = (*i)->ge->GetInput();
+
+ std::vector<std::string> items;
+ cmSystemTools::ExpandListArgument(entry, items);
+ for (std::vector<std::string>::const_iterator
+ li = items.begin(); li != items.end(); ++li)
+ {
+ if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+ (*li)[li->size() - 1] == '>')
+ {
+ continue;
+ }
+ files.push_back(*li);
+ }
+ }
+ return;
+ }
+
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugSources = !this->DebugSourcesDone
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ "SOURCES")
+ != debugProperties.end();
+
+ if (this->Makefile->IsGeneratingBuildSystem())
+ {
+ this->DebugSourcesDone = true;
+ }
+
+ cmListFileBacktrace lfbt;
+
+ cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+ this->GetName(),
+ "SOURCES", 0, 0);
+
+ std::set<std::string> uniqueSrcs;
+ bool contextDependentDirectSources = processSources(this,
+ this->Internal->SourceEntries,
+ files,
+ uniqueSrcs,
+ &dagChecker,
+ head,
+ config,
+ debugSources);
+
+ if (!this->Internal->CacheLinkInterfaceSourcesDone[config])
+ {
+ for (std::vector<cmValueWithOrigin>::const_iterator
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
+ it != end; ++it)
+ {
+ if (!cmGeneratorExpression::IsValidTargetName(it->Value)
+ && cmGeneratorExpression::Find(it->Value) == std::string::npos)
+ {
+ continue;
}
+ {
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(it->Value);
+ std::string targetResult = cge->Evaluate(this->Makefile, config,
+ false, this, 0, &dagChecker);
+ if (!this->Makefile->FindTargetToUse(targetResult))
+ {
+ continue;
+ }
+ }
+ std::string sourceGenex = "$<TARGET_PROPERTY:" +
+ it->Value + ",INTERFACE_SOURCES>";
+ if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+ {
+ // Because it->Value is a generator expression, ensure that it
+ // evaluates to the non-empty string before being used in the
+ // TARGET_PROPERTY expression.
+ sourceGenex = "$<$<BOOL:" + it->Value + ">:" + sourceGenex + ">";
+ }
+ cmGeneratorExpression ge(it->Backtrace);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
+ sourceGenex);
+
+ this->Internal
+ ->CachedLinkInterfaceSourcesEntries[config].push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge,
+ it->Value));
+ }
+ }
+
+ std::vector<std::string>::size_type numFilesBefore = files.size();
+ bool contextDependentInterfaceSources = processSources(this,
+ this->Internal->CachedLinkInterfaceSourcesEntries[config],
+ files,
+ uniqueSrcs,
+ &dagChecker,
+ head,
+ config,
+ debugSources);
+
+ if (!contextDependentDirectSources
+ && !(contextDependentInterfaceSources && numFilesBefore < files.size()))
+ {
+ this->LinkImplementationLanguageIsContextDependent = false;
+ }
+
+ if (!this->Makefile->IsGeneratingBuildSystem())
+ {
+ deleteAndClear(this->Internal->CachedLinkInterfaceSourcesEntries);
+ }
+ else
+ {
+ this->Internal->CacheLinkInterfaceSourcesDone[config] = true;
+ }
+}
+
+//----------------------------------------------------------------------------
+bool
+cmTarget::GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const
+{
+ std::vector<std::string> configs;
+ this->Makefile->GetConfigurations(configs);
+ if (configs.empty())
+ {
+ configs.push_back("");
+ }
+
+ std::vector<std::string>::const_iterator it = configs.begin();
+ const std::string& firstConfig = *it;
+ this->GetSourceFiles(files, firstConfig);
+
+ for ( ; it != configs.end(); ++it)
+ {
+ std::vector<cmSourceFile*> configFiles;
+ this->GetSourceFiles(configFiles, *it);
+ if (configFiles != files)
+ {
+ std::string firstConfigFiles;
+ const char* sep = "";
+ for (std::vector<cmSourceFile*>::const_iterator fi = files.begin();
+ fi != files.end(); ++fi)
+ {
+ firstConfigFiles += sep;
+ firstConfigFiles += (*fi)->GetFullPath();
+ sep = "\n ";
+ }
+
+ std::string thisConfigFiles;
+ sep = "";
+ for (std::vector<cmSourceFile*>::const_iterator fi = configFiles.begin();
+ fi != configFiles.end(); ++fi)
+ {
+ thisConfigFiles += sep;
+ thisConfigFiles += (*fi)->GetFullPath();
+ sep = "\n ";
+ }
+ cmOStringStream e;
+ e << "Target \"" << this->Name << "\" has source files which vary by "
+ "configuration. This is not supported by the \""
+ << this->Makefile->GetLocalGenerator()
+ ->GetGlobalGenerator()->GetName()
+ << "\" generator.\n"
+ "Config \"" << firstConfig << "\":\n"
+ " " << firstConfigFiles << "\n"
+ "Config \"" << *it << "\":\n"
+ " " << thisConfigFiles << "\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return false;
}
}
@@ -548,42 +849,113 @@ bool cmTarget::FindSourceFiles()
}
//----------------------------------------------------------------------------
-void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files) const
+void cmTarget::GetSourceFiles(std::vector<cmSourceFile*> &files,
+ const std::string& config,
+ cmTarget const* head) const
{
- assert(this->GetType() != INTERFACE_LIBRARY);
- files = this->SourceFiles;
+
+ // Lookup any existing link implementation for this configuration.
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
+
+ if(!this->LinkImplementationLanguageIsContextDependent)
+ {
+ files = this->Internal->SourceFilesMap.begin()->second;
+ return;
+ }
+
+ cmTargetInternals::SourceFilesMapType::iterator
+ it = this->Internal->SourceFilesMap.find(key);
+ if(it != this->Internal->SourceFilesMap.end())
+ {
+ files = it->second;
+ }
+ else
+ {
+ std::vector<std::string> srcs;
+ this->GetSourceFiles(srcs, config, head);
+
+ std::set<cmSourceFile*> emitted;
+
+ for(std::vector<std::string>::const_iterator i = srcs.begin();
+ i != srcs.end(); ++i)
+ {
+ cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ if (emitted.insert(sf).second)
+ {
+ files.push_back(sf);
+ }
+ }
+ this->Internal->SourceFilesMap[key] = files;
+ }
}
//----------------------------------------------------------------------------
-void cmTarget::AddSourceFile(cmSourceFile* sf)
+void cmTarget::AddTracedSources(std::vector<std::string> const& srcs)
{
- if (std::find(this->SourceFiles.begin(), this->SourceFiles.end(), sf)
- == this->SourceFiles.end())
+ 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 = ";";
+ }
+ if (!srcFiles.empty())
{
- this->SourceFiles.push_back(sf);
+ this->Internal->SourceFilesMap.clear();
+ this->LinkImplementationLanguageIsContextDependent = true;
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
+ cge->SetEvaluateForBuildsystem(true);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
}
}
//----------------------------------------------------------------------------
void cmTarget::AddSources(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)
{
- const char* src = i->c_str();
- if(src[0] == '$' && src[1] == '<')
- {
- this->ProcessSourceExpression(*i);
- }
- else
+ std::string filename = *i;
+ const char* src = filename.c_str();
+
+ if(!(src[0] == '$' && src[1] == '<'))
{
- this->AddSource(src);
+ filename = this->ProcessSourceItemCMP0049(filename);
+ if (cmSystemTools::GetErrorOccuredFlag())
+ {
+ return;
+ }
+ this->Makefile->GetOrCreateSource(filename);
}
+ srcFiles += sep;
+ srcFiles += filename;
+ sep = ";";
+ }
+ if (!srcFiles.empty())
+ {
+ this->Internal->SourceFilesMap.clear();
+ this->LinkImplementationLanguageIsContextDependent = true;
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(srcFiles);
+ cge->SetEvaluateForBuildsystem(true);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
}
}
//----------------------------------------------------------------------------
-cmSourceFile* cmTarget::AddSource(const char* s)
+std::string cmTarget::ProcessSourceItemCMP0049(const std::string& s)
{
std::string src = s;
@@ -615,143 +987,117 @@ cmSourceFile* cmTarget::AddSource(const char* s)
<< s << "\" expanded to \"" << src << "\" in target \""
<< this->GetName() << "\". This behavior will be removed in a "
"future version of CMake.";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
- return 0;
+ return "";
}
}
}
-
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(src.c_str());
- this->AddSourceFile(sf);
- return sf;
+ return src;
}
//----------------------------------------------------------------------------
-void cmTarget::ProcessSourceExpression(std::string const& expr)
+cmSourceFile* cmTarget::AddSourceCMP0049(const std::string& s)
{
- if(cmHasLiteralPrefix(expr.c_str(), "$<TARGET_OBJECTS:") &&
- expr[expr.size()-1] == '>')
- {
- std::string objLibName = expr.substr(17, expr.size()-18);
- this->ObjectLibraries.push_back(objLibName);
- }
- else
+ std::string src = this->ProcessSourceItemCMP0049(s);
+
+ if (cmSystemTools::GetErrorOccuredFlag())
{
- cmOStringStream e;
- e << "Unrecognized generator expression:\n"
- << " " << expr;
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return 0;
}
+ return this->AddSource(src);
}
//----------------------------------------------------------------------------
-struct cmTarget::SourceFileFlags
-cmTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
+struct CreateLocation
{
- struct SourceFileFlags flags;
- this->ConstructSourceFileFlags();
- std::map<cmSourceFile const*, SourceFileFlags>::iterator si =
- this->Internal->SourceFlagsMap.find(sf);
- if(si != this->Internal->SourceFlagsMap.end())
- {
- flags = si->second;
- }
- return flags;
-}
+ cmMakefile const* Makefile;
+
+ CreateLocation(cmMakefile const* mf)
+ : Makefile(mf)
+ {
+
+ }
+
+ cmSourceFileLocation operator()(const std::string& filename)
+ {
+ return cmSourceFileLocation(this->Makefile, filename);
+ }
+};
//----------------------------------------------------------------------------
-void cmTarget::ConstructSourceFileFlags() const
+struct LocationMatcher
{
- if(this->Internal->SourceFileFlagsConstructed)
- {
- return;
- }
- this->Internal->SourceFileFlagsConstructed = true;
+ const cmSourceFileLocation& Needle;
- // Process public headers to mark the source files.
- if(const char* files = this->GetProperty("PUBLIC_HEADER"))
- {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- flags.MacFolder = "Headers";
- flags.Type = cmTarget::SourceFileTypePublicHeader;
- }
- }
- }
+ LocationMatcher(const cmSourceFileLocation& needle)
+ : Needle(needle)
+ {
- // Process private headers after public headers so that they take
- // precedence if a file is listed in both.
- if(const char* files = this->GetProperty("PRIVATE_HEADER"))
- {
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- flags.MacFolder = "PrivateHeaders";
- flags.Type = cmTarget::SourceFileTypePrivateHeader;
- }
- }
- }
+ }
+
+ bool operator()(cmSourceFileLocation &loc)
+ {
+ return loc.Matches(this->Needle);
+ }
+};
+
+
+//----------------------------------------------------------------------------
+struct TargetPropertyEntryFinder
+{
+private:
+ const cmSourceFileLocation& Needle;
+public:
+ TargetPropertyEntryFinder(const cmSourceFileLocation& needle)
+ : Needle(needle)
+ {
+
+ }
- // Mark sources listed as resources.
- if(const char* files = this->GetProperty("RESOURCE"))
+ bool operator()(cmTargetInternals::TargetPropertyEntry* entry)
+ {
+ std::vector<std::string> files;
+ cmSystemTools::ExpandListArgument(entry->ge->GetInput(), files);
+ std::vector<cmSourceFileLocation> locations(files.size());
+ std::transform(files.begin(), files.end(), locations.begin(),
+ CreateLocation(this->Needle.GetMakefile()));
+
+ return std::find_if(locations.begin(), locations.end(),
+ LocationMatcher(this->Needle)) != locations.end();
+ }
+};
+
+//----------------------------------------------------------------------------
+cmSourceFile* cmTarget::AddSource(const std::string& src)
+{
+ cmSourceFileLocation sfl(this->Makefile, src);
+ if (std::find_if(this->Internal->SourceEntries.begin(),
+ this->Internal->SourceEntries.end(),
+ TargetPropertyEntryFinder(sfl))
+ == this->Internal->SourceEntries.end())
{
- std::vector<std::string> relFiles;
- cmSystemTools::ExpandListArgument(files, relFiles);
- for(std::vector<std::string>::iterator it = relFiles.begin();
- it != relFiles.end(); ++it)
- {
- if(cmSourceFile* sf = this->Makefile->GetSource(it->c_str()))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- flags.MacFolder = "Resources";
- flags.Type = cmTarget::SourceFileTypeResource;
- }
- }
+ this->Internal->SourceFilesMap.clear();
+ this->LinkImplementationLanguageIsContextDependent = true;
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(src);
+ cge->SetEvaluateForBuildsystem(true);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
}
-
- // Handle the MACOSX_PACKAGE_LOCATION property on source files that
- // were not listed in one of the other lists.
- std::vector<cmSourceFile*> sources;
- this->GetSourceFiles(sources);
- for(std::vector<cmSourceFile*>::const_iterator si = sources.begin();
- si != sources.end(); ++si)
+ if (cmGeneratorExpression::Find(src) != std::string::npos)
{
- cmSourceFile* sf = *si;
- if(const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION"))
- {
- SourceFileFlags& flags = this->Internal->SourceFlagsMap[sf];
- if(flags.Type == cmTarget::SourceFileTypeNormal)
- {
- flags.MacFolder = location;
- if(strcmp(location, "Resources") == 0)
- {
- flags.Type = cmTarget::SourceFileTypeResource;
- }
- else
- {
- flags.Type = cmTarget::SourceFileTypeMacContent;
- }
- }
- }
+ return 0;
}
+ return this->Makefile->GetOrCreateSource(src);
}
//----------------------------------------------------------------------------
void cmTarget::MergeLinkLibraries( cmMakefile& mf,
- const char *selfname,
+ const std::string& selfname,
const LinkLibraryVectorType& libs )
{
// Only add on libraries we haven't added on before.
@@ -761,15 +1107,15 @@ void cmTarget::MergeLinkLibraries( cmMakefile& mf,
for( ; i != libs.end(); ++i )
{
// This is equivalent to the target_link_libraries plain signature.
- this->AddLinkLibrary( mf, selfname, i->first.c_str(), i->second );
+ this->AddLinkLibrary( mf, selfname, i->first, i->second );
this->AppendProperty("INTERFACE_LINK_LIBRARIES",
- this->GetDebugGeneratorExpressions(i->first.c_str(), i->second).c_str());
+ this->GetDebugGeneratorExpressions(i->first, i->second).c_str());
}
this->PrevLinkedLibraries = libs;
}
//----------------------------------------------------------------------------
-void cmTarget::AddLinkDirectory(const char* d)
+void cmTarget::AddLinkDirectory(const std::string& d)
{
// Make sure we don't add unnecessary search directories.
if(this->LinkDirectoriesEmmitted.insert(d).second)
@@ -785,10 +1131,11 @@ const std::vector<std::string>& cmTarget::GetLinkDirectories() const
}
//----------------------------------------------------------------------------
-cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const
+cmTarget::LinkLibraryType cmTarget::ComputeLinkType(
+ const std::string& config) const
{
// No configuration is always optimized.
- if(!(config && *config))
+ if(config.empty())
{
return cmTarget::OPTIMIZED;
}
@@ -814,7 +1161,7 @@ cmTarget::LinkLibraryType cmTarget::ComputeLinkType(const char* config) const
//----------------------------------------------------------------------------
void cmTarget::ClearDependencyInformation( cmMakefile& mf,
- const char* target )
+ const std::string& target )
{
// Clear the dependencies. The cache variable must exist iff we are
// recording dependency information for this target.
@@ -822,12 +1169,12 @@ void cmTarget::ClearDependencyInformation( cmMakefile& mf,
depname += "_LIB_DEPENDS";
if (this->RecordDependencies)
{
- mf.AddCacheDefinition(depname.c_str(), "",
+ mf.AddCacheDefinition(depname, "",
"Dependencies for target", cmCacheManager::STATIC);
}
else
{
- if (mf.GetDefinition( depname.c_str() ))
+ if (mf.GetDefinition( depname ))
{
std::string message = "Target ";
message += target;
@@ -848,7 +1195,7 @@ bool cmTarget::NameResolvesToFramework(const std::string& libname) const
}
//----------------------------------------------------------------------------
-void cmTarget::GetDirectLinkLibraries(const char *config,
+void cmTarget::GetDirectLinkLibraries(const std::string& config,
std::vector<std::string> &libs,
cmTarget const* head) const
{
@@ -869,11 +1216,11 @@ void cmTarget::GetDirectLinkLibraries(const char *config,
&dagChecker),
libs);
- std::set<cmStdString> seenProps = cge->GetSeenTargetProperties();
- for (std::set<cmStdString>::const_iterator it = seenProps.begin();
+ std::set<std::string> seenProps = cge->GetSeenTargetProperties();
+ for (std::set<std::string>::const_iterator it = seenProps.begin();
it != seenProps.end(); ++it)
{
- if (!this->GetProperty(it->c_str()))
+ if (!this->GetProperty(*it))
{
this->LinkImplicitNullProperties.insert(*it);
}
@@ -882,7 +1229,7 @@ void cmTarget::GetDirectLinkLibraries(const char *config,
}
//----------------------------------------------------------------------------
-void cmTarget::GetInterfaceLinkLibraries(const char *config,
+void cmTarget::GetInterfaceLinkLibraries(const std::string& config,
std::vector<std::string> &libs,
cmTarget const* head) const
{
@@ -938,9 +1285,9 @@ std::string cmTarget::GetDebugGeneratorExpressions(const std::string &value,
}
//----------------------------------------------------------------------------
-static std::string targetNameGenex(const char *lib)
+static std::string targetNameGenex(const std::string& lib)
{
- return std::string("$<TARGET_NAME:") + lib + ">";
+ return "$<TARGET_NAME:" + lib + ">";
}
//----------------------------------------------------------------------------
@@ -980,7 +1327,7 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
= (sig == cmTarget::KeywordTLLSignature ? "keyword"
: "plain");
s << "The uses of the " << sigString << " signature are here:\n";
- std::set<cmStdString> emitted;
+ std::set<std::string> emitted;
for(std::vector<cmListFileBacktrace>::const_iterator it = sigs.begin();
it != sigs.end(); ++it)
{
@@ -1002,7 +1349,8 @@ void cmTarget::GetTllSignatureTraces(cmOStringStream &s,
//----------------------------------------------------------------------------
void cmTarget::AddLinkLibrary(cmMakefile& mf,
- const char *target, const char* lib,
+ const std::string& target,
+ const std::string& lib,
LinkLibraryType llt)
{
cmTarget *tgt = this->Makefile->FindTargetToUse(lib);
@@ -1011,7 +1359,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
const std::string libName = (isNonImportedTarget && llt != GENERAL)
? targetNameGenex(lib)
- : std::string(lib);
+ : lib;
this->AppendProperty("LINK_LIBRARIES",
this->GetDebugGeneratorExpressions(libName,
llt).c_str());
@@ -1019,7 +1367,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
if (cmGeneratorExpression::Find(lib) != std::string::npos
|| (tgt && tgt->GetType() == INTERFACE_LIBRARY)
- || (strcmp( target, lib ) == 0))
+ || (target == lib ))
{
return;
}
@@ -1044,7 +1392,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
std::string targetEntry = target;
targetEntry += "_LIB_DEPENDS";
std::string dependencies;
- const char* old_val = mf.GetDefinition( targetEntry.c_str() );
+ const char* old_val = mf.GetDefinition( targetEntry );
if( old_val )
{
dependencies += old_val;
@@ -1064,7 +1412,7 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
dependencies += ";";
dependencies += lib;
dependencies += ";";
- mf.AddCacheDefinition( targetEntry.c_str(), dependencies.c_str(),
+ mf.AddCacheDefinition( targetEntry, dependencies.c_str(),
"Dependencies for the target",
cmCacheManager::STATIC );
}
@@ -1073,9 +1421,9 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf,
//----------------------------------------------------------------------------
void
-cmTarget::AddSystemIncludeDirectories(const std::set<cmStdString> &incs)
+cmTarget::AddSystemIncludeDirectories(const std::set<std::string> &incs)
{
- for(std::set<cmStdString>::const_iterator li = incs.begin();
+ for(std::set<std::string>::const_iterator li = incs.begin();
li != incs.end(); ++li)
{
this->SystemIncludeDirectories.insert(*li);
@@ -1338,7 +1686,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf,
return;
}
- const char* deps = mf.GetDefinition( (lib.first+"_LIB_DEPENDS").c_str() );
+ const char* deps = mf.GetDefinition( lib.first+"_LIB_DEPENDS" );
if( deps && strcmp(deps,"") != 0 )
{
// Make sure this library is in the map, even if it has an empty
@@ -1387,7 +1735,7 @@ void cmTarget::GatherDependencies( const cmMakefile& mf,
}
//----------------------------------------------------------------------------
-static bool whiteListedInterfaceProperty(const char *prop)
+static bool whiteListedInterfaceProperty(const std::string& prop)
{
if(cmHasLiteralPrefix(prop, "INTERFACE_"))
{
@@ -1407,7 +1755,7 @@ static bool whiteListedInterfaceProperty(const char *prop)
if (std::binary_search(cmArrayBegin(builtIns),
cmArrayEnd(builtIns),
- prop,
+ prop.c_str(),
cmStrCmp(prop)))
{
return true;
@@ -1422,30 +1770,26 @@ static bool whiteListedInterfaceProperty(const char *prop)
}
//----------------------------------------------------------------------------
-void cmTarget::SetProperty(const char* prop, const char* value)
+void cmTarget::SetProperty(const std::string& prop, const char* value)
{
- if (!prop)
- {
- return;
- }
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
cmOStringStream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if (strcmp(prop, "NAME") == 0)
+ if (prop == "NAME")
{
cmOStringStream e;
e << "NAME property is read-only\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
+ if(prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1456,7 +1800,7 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
- if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+ if(prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1467,7 +1811,18 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
- if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
+ if(prop == "COMPILE_FEATURES")
+ {
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ deleteAndClear(this->Internal->CompileFeaturesEntries);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->CompileFeaturesEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
+ return;
+ }
+ if(prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1478,15 +1833,15 @@ void cmTarget::SetProperty(const char* prop, const char* value)
new cmTargetInternals::TargetPropertyEntry(cge));
return;
}
- if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
+ if(prop == "EXPORT_NAME" && this->IsImported())
{
cmOStringStream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
<< this->Name << "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if (strcmp(prop, "LINK_LIBRARIES") == 0)
+ if (prop == "LINK_LIBRARIES")
{
this->Internal->LinkImplementationPropertyEntries.clear();
cmListFileBacktrace lfbt;
@@ -1495,35 +1850,51 @@ void cmTarget::SetProperty(const char* prop, const char* value)
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return;
}
+ if (prop == "SOURCES")
+ {
+ if(this->IsImported())
+ {
+ cmOStringStream e;
+ e << "SOURCES property can't be set on imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
+ this->Internal->SourceFilesMap.clear();
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ this->Internal->SourceEntries.clear();
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
+ return;
+ }
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
this->MaybeInvalidatePropertyCache(prop);
}
//----------------------------------------------------------------------------
-void cmTarget::AppendProperty(const char* prop, const char* value,
+void cmTarget::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
- if (!prop)
- {
- return;
- }
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
cmOStringStream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if (strcmp(prop, "NAME") == 0)
+ if (prop == "NAME")
{
cmOStringStream e;
e << "NAME property is read-only\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
+ if(prop == "INCLUDE_DIRECTORIES")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1532,7 +1903,7 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
- if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+ if(prop == "COMPILE_OPTIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1541,7 +1912,16 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
- if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
+ if(prop == "COMPILE_FEATURES")
+ {
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ this->Internal->CompileFeaturesEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
+ return;
+ }
+ if(prop == "COMPILE_DEFINITIONS")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1550,15 +1930,15 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
new cmTargetInternals::TargetPropertyEntry(ge.Parse(value)));
return;
}
- if(strcmp(prop,"EXPORT_NAME") == 0 && this->IsImported())
+ if(prop == "EXPORT_NAME" && this->IsImported())
{
cmOStringStream e;
e << "EXPORT_NAME property can't be set on imported targets (\""
<< this->Name << "\")\n";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return;
}
- if (strcmp(prop, "LINK_LIBRARIES") == 0)
+ if (prop == "LINK_LIBRARIES")
{
cmListFileBacktrace lfbt;
this->Makefile->GetBacktrace(lfbt);
@@ -1566,12 +1946,31 @@ void cmTarget::AppendProperty(const char* prop, const char* value,
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return;
}
+ if (prop == "SOURCES")
+ {
+ if(this->IsImported())
+ {
+ cmOStringStream e;
+ e << "SOURCES property can't be set on imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
+ this->Internal->SourceFilesMap.clear();
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
+ return;
+ }
this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
this->MaybeInvalidatePropertyCache(prop);
}
//----------------------------------------------------------------------------
-const char* cmTarget::GetExportName() const
+std::string cmTarget::GetExportName() const
{
const char *exportName = this->GetProperty("EXPORT_NAME");
@@ -1665,7 +2064,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
std::vector<std::string> &includes,
std::set<std::string> &uniqueIncludes,
cmGeneratorExpressionDAGChecker *dagChecker,
- const char *config, bool debugIncludes)
+ const std::string& config, bool debugIncludes)
{
cmMakefile *mf = tgt->GetMakefile();
@@ -1674,7 +2073,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
{
bool testIsOff = true;
bool cacheIncludes = false;
- std::vector<std::string> entryIncludes = (*it)->CachedEntries;
+ std::vector<std::string>& entryIncludes = (*it)->CachedEntries;
if(!entryIncludes.empty())
{
testIsOff = false;
@@ -1752,7 +2151,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
"successfully.\n"
"* The installation package was faulty and references files it "
"does not provide.\n";
- tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+ tgt->GetMakefile()->IssueMessage(messageType, e.str());
return;
}
@@ -1791,7 +2190,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
}
if (!noMessage)
{
- tgt->GetMakefile()->IssueMessage(messageType, e.str().c_str());
+ tgt->GetMakefile()->IssueMessage(messageType, e.str());
if (messageType == cmake::FATAL_ERROR)
{
return;
@@ -1830,7 +2229,7 @@ static void processIncludeDirectories(cmTarget const* tgt,
//----------------------------------------------------------------------------
std::vector<std::string>
-cmTarget::GetIncludeDirectories(const char *config) const
+cmTarget::GetIncludeDirectories(const std::string& config) const
{
std::vector<std::string> includes;
std::set<std::string> uniqueIncludes;
@@ -1867,8 +2266,7 @@ cmTarget::GetIncludeDirectories(const char *config) const
config,
debugIncludes);
- std::string configString = config ? config : "";
- if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString])
+ if (!this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config])
{
for (std::vector<cmValueWithOrigin>::const_iterator
it = this->Internal->LinkImplementationPropertyEntries.begin(),
@@ -1905,7 +2303,7 @@ cmTarget::GetIncludeDirectories(const char *config) const
includeGenex);
this->Internal
- ->CachedLinkInterfaceIncludeDirectoriesEntries[configString].push_back(
+ ->CachedLinkInterfaceIncludeDirectoriesEntries[config].push_back(
new cmTargetInternals::TargetPropertyEntry(cge,
it->Value));
}
@@ -1933,14 +2331,14 @@ cmTarget::GetIncludeDirectories(const char *config) const
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(libDir.c_str());
this->Internal
- ->CachedLinkInterfaceIncludeDirectoriesEntries[configString]
+ ->CachedLinkInterfaceIncludeDirectoriesEntries[config]
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
}
}
processIncludeDirectories(this,
- this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[configString],
+ this->Internal->CachedLinkInterfaceIncludeDirectoriesEntries[config],
includes,
uniqueIncludes,
&dagChecker,
@@ -1954,7 +2352,7 @@ cmTarget::GetIncludeDirectories(const char *config) const
}
else
{
- this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[configString]
+ this->Internal->CacheLinkInterfaceIncludeDirectoriesDone[config]
= true;
}
@@ -1967,7 +2365,7 @@ static void processCompileOptionsInternal(cmTarget const* tgt,
std::vector<std::string> &options,
std::set<std::string> &uniqueOptions,
cmGeneratorExpressionDAGChecker *dagChecker,
- const char *config, bool debugOptions, const char *logName)
+ const std::string& config, bool debugOptions, const char *logName)
{
cmMakefile *mf = tgt->GetMakefile();
@@ -2026,7 +2424,7 @@ static void processCompileOptions(cmTarget const* tgt,
std::vector<std::string> &options,
std::set<std::string> &uniqueOptions,
cmGeneratorExpressionDAGChecker *dagChecker,
- const char *config, bool debugOptions)
+ const std::string& config, bool debugOptions)
{
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
dagChecker, config, debugOptions, "options");
@@ -2034,7 +2432,7 @@ static void processCompileOptions(cmTarget const* tgt,
//----------------------------------------------------------------------------
void cmTarget::GetAutoUicOptions(std::vector<std::string> &result,
- const char *config) const
+ const std::string& config) const
{
const char *prop
= this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS",
@@ -2060,7 +2458,7 @@ void cmTarget::GetAutoUicOptions(std::vector<std::string> &result,
//----------------------------------------------------------------------------
void cmTarget::GetCompileOptions(std::vector<std::string> &result,
- const char *config) const
+ const std::string& config) const
{
std::set<std::string> uniqueOptions;
cmListFileBacktrace lfbt;
@@ -2096,8 +2494,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
config,
debugOptions);
- std::string configString = config ? config : "";
- if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[configString])
+ if (!this->Internal->CacheLinkInterfaceCompileOptionsDone[config])
{
for (std::vector<cmValueWithOrigin>::const_iterator
it = this->Internal->LinkImplementationPropertyEntries.begin(),
@@ -2134,14 +2531,14 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
optionGenex);
this->Internal
- ->CachedLinkInterfaceCompileOptionsEntries[configString].push_back(
+ ->CachedLinkInterfaceCompileOptionsEntries[config].push_back(
new cmTargetInternals::TargetPropertyEntry(cge,
it->Value));
}
}
processCompileOptions(this,
- this->Internal->CachedLinkInterfaceCompileOptionsEntries[configString],
+ this->Internal->CachedLinkInterfaceCompileOptionsEntries[config],
result,
uniqueOptions,
&dagChecker,
@@ -2154,7 +2551,7 @@ void cmTarget::GetCompileOptions(std::vector<std::string> &result,
}
else
{
- this->Internal->CacheLinkInterfaceCompileOptionsDone[configString] = true;
+ this->Internal->CacheLinkInterfaceCompileOptionsDone[config] = true;
}
}
@@ -2164,7 +2561,7 @@ static void processCompileDefinitions(cmTarget const* tgt,
std::vector<std::string> &options,
std::set<std::string> &uniqueOptions,
cmGeneratorExpressionDAGChecker *dagChecker,
- const char *config, bool debugOptions)
+ const std::string& config, bool debugOptions)
{
processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
dagChecker, config, debugOptions,
@@ -2173,7 +2570,7 @@ static void processCompileDefinitions(cmTarget const* tgt,
//----------------------------------------------------------------------------
void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
- const char *config) const
+ const std::string& config) const
{
std::set<std::string> uniqueOptions;
cmListFileBacktrace lfbt;
@@ -2209,8 +2606,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
config,
debugDefines);
- std::string configString = config ? config : "";
- if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString])
+ if (!this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config])
{
for (std::vector<cmValueWithOrigin>::const_iterator
it = this->Internal->LinkImplementationPropertyEntries.begin(),
@@ -2247,15 +2643,15 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
defsGenex);
this->Internal
- ->CachedLinkInterfaceCompileDefinitionsEntries[configString].push_back(
+ ->CachedLinkInterfaceCompileDefinitionsEntries[config].push_back(
new cmTargetInternals::TargetPropertyEntry(cge,
it->Value));
}
- if (config)
+ if (!config.empty())
{
std::string configPropName = "COMPILE_DEFINITIONS_"
+ cmSystemTools::UpperCase(config);
- const char *configProp = this->GetProperty(configPropName.c_str());
+ const char *configProp = this->GetProperty(configPropName);
if (configProp)
{
switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0043))
@@ -2266,7 +2662,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
e << this->Makefile->GetCMakeInstance()->GetPolicies()
->GetPolicyWarning(cmPolicies::CMP0043);
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
- e.str().c_str());
+ e.str());
}
case cmPolicies::OLD:
{
@@ -2274,7 +2670,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
ge.Parse(configProp);
this->Internal
- ->CachedLinkInterfaceCompileDefinitionsEntries[configString]
+ ->CachedLinkInterfaceCompileDefinitionsEntries[config]
.push_back(new cmTargetInternals::TargetPropertyEntry(cge));
}
break;
@@ -2289,7 +2685,7 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
}
processCompileDefinitions(this,
- this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[configString],
+ this->Internal->CachedLinkInterfaceCompileDefinitionsEntries[config],
list,
uniqueOptions,
&dagChecker,
@@ -2303,13 +2699,125 @@ void cmTarget::GetCompileDefinitions(std::vector<std::string> &list,
}
else
{
- this->Internal->CacheLinkInterfaceCompileDefinitionsDone[configString]
+ this->Internal->CacheLinkInterfaceCompileDefinitionsDone[config]
= true;
}
}
//----------------------------------------------------------------------------
-void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
+static void processCompileFeatures(cmTarget const* tgt,
+ const std::vector<cmTargetInternals::TargetPropertyEntry*> &entries,
+ std::vector<std::string> &options,
+ std::set<std::string> &uniqueOptions,
+ cmGeneratorExpressionDAGChecker *dagChecker,
+ const std::string& config, bool debugOptions)
+{
+ processCompileOptionsInternal(tgt, entries, options, uniqueOptions,
+ dagChecker, config, debugOptions, "features");
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetCompileFeatures(std::vector<std::string> &result,
+ const std::string& config) const
+{
+ std::set<std::string> uniqueFeatures;
+ cmListFileBacktrace lfbt;
+
+ cmGeneratorExpressionDAGChecker dagChecker(lfbt,
+ this->GetName(),
+ "COMPILE_FEATURES",
+ 0, 0);
+
+ std::vector<std::string> debugProperties;
+ const char *debugProp =
+ this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES");
+ if (debugProp)
+ {
+ cmSystemTools::ExpandListArgument(debugProp, debugProperties);
+ }
+
+ bool debugFeatures = !this->DebugCompileFeaturesDone
+ && std::find(debugProperties.begin(),
+ debugProperties.end(),
+ "COMPILE_FEATURES")
+ != debugProperties.end();
+
+ if (this->Makefile->IsGeneratingBuildSystem())
+ {
+ this->DebugCompileFeaturesDone = true;
+ }
+
+ processCompileFeatures(this,
+ this->Internal->CompileFeaturesEntries,
+ result,
+ uniqueFeatures,
+ &dagChecker,
+ config,
+ debugFeatures);
+
+ if (!this->Internal->CacheLinkInterfaceCompileFeaturesDone[config])
+ {
+ for (std::vector<cmValueWithOrigin>::const_iterator
+ it = this->Internal->LinkImplementationPropertyEntries.begin(),
+ end = this->Internal->LinkImplementationPropertyEntries.end();
+ it != end; ++it)
+ {
+ if (!cmGeneratorExpression::IsValidTargetName(it->Value)
+ && cmGeneratorExpression::Find(it->Value) == std::string::npos)
+ {
+ continue;
+ }
+ {
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge =
+ ge.Parse(it->Value);
+ std::string targetResult = cge->Evaluate(this->Makefile, config,
+ false, this, 0, 0);
+ if (!this->Makefile->FindTargetToUse(targetResult))
+ {
+ continue;
+ }
+ }
+ std::string featureGenex = "$<TARGET_PROPERTY:" +
+ it->Value + ",INTERFACE_COMPILE_FEATURES>";
+ if (cmGeneratorExpression::Find(it->Value) != std::string::npos)
+ {
+ // Because it->Value is a generator expression, ensure that it
+ // evaluates to the non-empty string before being used in the
+ // TARGET_PROPERTY expression.
+ featureGenex = "$<$<BOOL:" + it->Value + ">:" + featureGenex + ">";
+ }
+ cmGeneratorExpression ge(it->Backtrace);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(
+ featureGenex);
+
+ this->Internal
+ ->CachedLinkInterfaceCompileFeaturesEntries[config].push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge,
+ it->Value));
+ }
+ }
+
+ processCompileFeatures(this,
+ this->Internal->CachedLinkInterfaceCompileFeaturesEntries[config],
+ result,
+ uniqueFeatures,
+ &dagChecker,
+ config,
+ debugFeatures);
+
+ if (!this->Makefile->IsGeneratingBuildSystem())
+ {
+ deleteAndClear(this->Internal->CachedLinkInterfaceCompileFeaturesEntries);
+ }
+ else
+ {
+ this->Internal->CacheLinkInterfaceCompileFeaturesDone[config] = true;
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::MaybeInvalidatePropertyCache(const std::string& prop)
{
// Wipe out maps caching information affected by this property.
if(this->IsImported() && cmHasLiteralPrefix(prop, "IMPORTED"))
@@ -2324,8 +2832,8 @@ void cmTarget::MaybeInvalidatePropertyCache(const char* prop)
//----------------------------------------------------------------------------
static void cmTargetCheckLINK_INTERFACE_LIBRARIES(
- const char* prop, const char* value, cmMakefile* context, bool imported
- )
+ const std::string& prop, const char* value, cmMakefile* context,
+ bool imported)
{
// Look for link-type keywords in the value.
static cmsys::RegularExpression
@@ -2389,7 +2897,8 @@ static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const char* value,
}
//----------------------------------------------------------------------------
-void cmTarget::CheckProperty(const char* prop, cmMakefile* context) const
+void cmTarget::CheckProperty(const std::string& prop,
+ cmMakefile* context) const
{
// Certain properties need checking.
if(cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES"))
@@ -2432,7 +2941,8 @@ bool cmTarget::HaveWellDefinedOutputFiles() const
}
//----------------------------------------------------------------------------
-cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
+cmTarget::OutputInfo const* cmTarget::GetOutputInfo(
+ const std::string& config) const
{
// There is no output information for imported targets.
if(this->IsImported())
@@ -2448,13 +2958,12 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
msg += " which has type ";
msg += cmTarget::GetTargetTypeName(this->GetType());
this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
- abort();
return 0;
}
// Lookup/compute/cache the output information for this configuration.
std::string config_upper;
- if(config && *config)
+ if(!config.empty())
{
config_upper = cmSystemTools::UpperCase(config);
}
@@ -2466,7 +2975,7 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
OutputInfo info;
this->ComputeOutputDir(config, false, info.OutDir);
this->ComputeOutputDir(config, true, info.ImpDir);
- if(!this->ComputePDBOutputDir(config, info.PdbDir))
+ if(!this->ComputePDBOutputDir("PDB", config, info.PdbDir))
{
info.PdbDir = info.OutDir;
}
@@ -2477,7 +2986,47 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo(const char* config) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetDirectory(const char* config, bool implib) const
+cmTarget::CompileInfo const* cmTarget::GetCompileInfo(
+ const std::string& config) const
+{
+ // There is no compile information for imported targets.
+ if(this->IsImported())
+ {
+ return 0;
+ }
+
+ if(this->GetType() > cmTarget::OBJECT_LIBRARY)
+ {
+ std::string msg = "cmTarget::GetCompileInfo called for ";
+ msg += this->GetName();
+ msg += " which has type ";
+ msg += cmTarget::GetTargetTypeName(this->GetType());
+ this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
+ return 0;
+ }
+
+ // Lookup/compute/cache the compile information for this configuration.
+ std::string config_upper;
+ if(!config.empty())
+ {
+ config_upper = cmSystemTools::UpperCase(config);
+ }
+ typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType;
+ CompileInfoMapType::const_iterator i =
+ this->Internal->CompileInfoMap.find(config_upper);
+ if(i == this->Internal->CompileInfoMap.end())
+ {
+ CompileInfo info;
+ this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir);
+ CompileInfoMapType::value_type entry(config_upper, info);
+ i = this->Internal->CompileInfoMap.insert(entry).first;
+ }
+ return &i->second;
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetDirectory(const std::string& config,
+ bool implib) const
{
if (this->IsImported())
{
@@ -2495,7 +3044,7 @@ std::string cmTarget::GetDirectory(const char* config, bool implib) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetPDBDirectory(const char* config) const
+std::string cmTarget::GetPDBDirectory(const std::string& config) const
{
if(OutputInfo const* info = this->GetOutputInfo(config))
{
@@ -2506,34 +3055,37 @@ std::string cmTarget::GetPDBDirectory(const char* config) const
}
//----------------------------------------------------------------------------
-const char* cmTarget::GetLocation(const char* config) const
+std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const
{
- if (this->IsImported())
+ if(CompileInfo const* info = this->GetCompileInfo(config))
{
- return this->ImportedGetLocation(config);
- }
- else
- {
- return this->NormalGetLocation(config);
+ return info->CompilePdbDir;
}
+ return "";
}
//----------------------------------------------------------------------------
-const char* cmTarget::ImportedGetLocation(const char* config) const
+const char* cmTarget::GetLocation(const std::string& config) const
{
static std::string location;
- location = this->ImportedGetFullPath(config, false);
+ if (this->IsImported())
+ {
+ location = this->ImportedGetFullPath(config, false);
+ }
+ else
+ {
+ location = this->GetFullPath(config, false);
+ }
return location.c_str();
}
//----------------------------------------------------------------------------
-const char* cmTarget::NormalGetLocation(const char* config) const
+const char* cmTarget::GetLocationForBuild() const
{
static std::string location;
- // Handle the configuration-specific case first.
- if(config)
+ if(this->IsImported())
{
- location = this->GetFullPath(config, false);
+ location = this->ImportedGetFullPath("", false);
return location.c_str();
}
@@ -2553,7 +3105,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const
if(this->IsAppBundleOnApple())
{
- std::string macdir = this->BuildMacContentDirectory("", config, false);
+ std::string macdir = this->BuildMacContentDirectory("", "", false);
if(!macdir.empty())
{
location += "/";
@@ -2561,7 +3113,7 @@ const char* cmTarget::NormalGetLocation(const char* config) const
}
}
location += "/";
- location += this->GetFullName(config, false);
+ location += this->GetFullName("", false);
return location.c_str();
}
@@ -2604,14 +3156,15 @@ void cmTarget::GetTargetVersion(bool soversion,
}
//----------------------------------------------------------------------------
-const char* cmTarget::GetFeature(const char* feature, const char* config) const
+const char* cmTarget::GetFeature(const std::string& feature,
+ const std::string& config) const
{
- if(config && *config)
+ if(!config.empty())
{
std::string featureConfig = feature;
featureConfig += "_";
featureConfig += cmSystemTools::UpperCase(config);
- if(const char* value = this->GetProperty(featureConfig.c_str()))
+ if(const char* value = this->GetProperty(featureConfig))
{
return value;
}
@@ -2624,7 +3177,7 @@ const char* cmTarget::GetFeature(const char* feature, const char* config) const
}
//----------------------------------------------------------------------------
-const char *cmTarget::GetProperty(const char* prop) const
+const char *cmTarget::GetProperty(const std::string& prop) const
{
return this->GetProperty(prop, cmProperty::TARGET);
}
@@ -2660,34 +3213,29 @@ bool cmTarget::HandleLocationPropertyPolicy() const
<< this->GetName() << "\". Use the target name directly with "
"add_custom_command, or use the generator expression $<TARGET_FILE>, "
"as appropriate.\n";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
}
return messageType != cmake::FATAL_ERROR;
}
//----------------------------------------------------------------------------
-const char *cmTarget::GetProperty(const char* prop,
+const char *cmTarget::GetProperty(const std::string& prop,
cmProperty::ScopeType scope) const
{
- if(!prop)
- {
- return 0;
- }
-
if (this->GetType() == INTERFACE_LIBRARY
&& !whiteListedInterfaceProperty(prop))
{
cmOStringStream e;
e << "INTERFACE_LIBRARY targets may only have whitelisted properties. "
"The property \"" << prop << "\" is not allowed.";
- this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str().c_str());
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
return 0;
}
- if (strcmp(prop, "NAME") == 0)
+ if (prop == "NAME")
{
- return this->GetName();
+ return this->GetName().c_str();
}
// Watch for special "computed" properties that are dependent on
@@ -2698,7 +3246,7 @@ const char *cmTarget::GetProperty(const char* prop,
this->GetType() == cmTarget::MODULE_LIBRARY ||
this->GetType() == cmTarget::UNKNOWN_LIBRARY)
{
- if(strcmp(prop,"LOCATION") == 0)
+ if(prop == "LOCATION")
{
if (!this->HandleLocationPropertyPolicy())
{
@@ -2714,7 +3262,7 @@ const char *cmTarget::GetProperty(const char* prop,
// cannot take into account the per-configuration name of the
// target because the configuration type may not be known at
// CMake time.
- this->Properties.SetProperty("LOCATION", this->GetLocation(0),
+ this->Properties.SetProperty("LOCATION", this->GetLocationForBuild(),
cmProperty::TARGET);
}
@@ -2725,15 +3273,15 @@ const char *cmTarget::GetProperty(const char* prop,
{
return 0;
}
- std::string configName = prop+9;
+ const char* configName = prop.c_str() + 9;
this->Properties.SetProperty(prop,
- this->GetLocation(configName.c_str()),
+ this->GetLocation(configName),
cmProperty::TARGET);
}
// Support "<CONFIG>_LOCATION".
if(cmHasLiteralSuffix(prop, "_LOCATION"))
{
- std::string configName(prop, strlen(prop) - 9);
+ std::string configName(prop.c_str(), prop.size() - 9);
if(configName != "IMPORTED")
{
if (!this->HandleLocationPropertyPolicy())
@@ -2741,12 +3289,12 @@ const char *cmTarget::GetProperty(const char* prop,
return 0;
}
this->Properties.SetProperty(prop,
- this->GetLocation(configName.c_str()),
+ this->GetLocation(configName),
cmProperty::TARGET);
}
}
}
- if(strcmp(prop,"INCLUDE_DIRECTORIES") == 0)
+ if(prop == "INCLUDE_DIRECTORIES")
{
static std::string output;
output = "";
@@ -2764,7 +3312,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
- if(strcmp(prop,"COMPILE_OPTIONS") == 0)
+ if(prop == "COMPILE_OPTIONS")
{
static std::string output;
output = "";
@@ -2782,7 +3330,25 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
- if(strcmp(prop,"COMPILE_DEFINITIONS") == 0)
+ if(prop == "COMPILE_FEATURES")
+ {
+ static std::string output;
+ output = "";
+ std::string sep;
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for (std::vector<TargetPropertyEntry*>::const_iterator
+ it = this->Internal->CompileFeaturesEntries.begin(),
+ end = this->Internal->CompileFeaturesEntries.end();
+ it != end; ++it)
+ {
+ output += sep;
+ output += (*it)->ge->GetInput();
+ sep = ";";
+ }
+ return output.c_str();
+ }
+ if(prop == "COMPILE_DEFINITIONS")
{
static std::string output;
output = "";
@@ -2800,7 +3366,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
return output.c_str();
}
- if(strcmp(prop,"LINK_LIBRARIES") == 0)
+ if(prop == "LINK_LIBRARIES")
{
static std::string output;
output = "";
@@ -2817,41 +3383,106 @@ const char *cmTarget::GetProperty(const char* prop,
return output.c_str();
}
- if (strcmp(prop,"IMPORTED") == 0)
+ if (prop == "IMPORTED")
{
return this->IsImported()?"TRUE":"FALSE";
}
- if(!strcmp(prop,"SOURCES"))
+ if(prop == "SOURCES")
{
cmOStringStream ss;
const char* sep = "";
- for(std::vector<cmSourceFile*>::const_iterator
- i = this->SourceFiles.begin();
- i != this->SourceFiles.end(); ++i)
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for(std::vector<TargetPropertyEntry*>::const_iterator
+ i = this->Internal->SourceEntries.begin();
+ i != this->Internal->SourceEntries.end(); ++i)
{
- // Separate from the previous list entries.
- ss << sep;
- sep = ";";
+ std::string entry = (*i)->ge->GetInput();
- // Construct what is known about this source file location.
- cmSourceFileLocation const& location = (*i)->GetLocation();
- std::string sname = location.GetDirectory();
- if(!sname.empty())
+ std::vector<std::string> files;
+ cmSystemTools::ExpandListArgument(entry, files);
+ for (std::vector<std::string>::const_iterator
+ li = files.begin(); li != files.end(); ++li)
{
- sname += "/";
- }
- sname += location.GetName();
+ if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+ (*li)[li->size() - 1] == '>')
+ {
+ std::string objLibName = li->substr(17, li->size()-18);
+
+ if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ continue;
+ }
- // Append this list entry.
- ss << sname;
+ bool addContent = false;
+ bool noMessage = true;
+ cmOStringStream e;
+ cmake::MessageType messageType = cmake::AUTHOR_WARNING;
+ switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0051))
+ {
+ case cmPolicies::WARN:
+ e << (this->Makefile->GetPolicies()
+ ->GetPolicyWarning(cmPolicies::CMP0051)) << "\n";
+ noMessage = false;
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ addContent = true;
+ }
+ if (!noMessage)
+ {
+ e << "Target \"" << this->Name << "\" contains $<TARGET_OBJECTS> "
+ "generator expression in its sources list. This content was not "
+ "previously part of the SOURCES property when that property was "
+ "read at configure time. Code reading that property needs to be "
+ "adapted to ignore the generator expression using the "
+ "string(GENEX_STRIP) command.";
+ this->Makefile->IssueMessage(messageType, e.str());
+ }
+ if (addContent)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ }
+ }
+ else if (cmGeneratorExpression::Find(*li) == std::string::npos)
+ {
+ ss << sep;
+ sep = ";";
+ ss << *li;
+ }
+ else
+ {
+ cmSourceFile *sf = this->Makefile->GetOrCreateSource(*li);
+ // Construct what is known about this source file location.
+ cmSourceFileLocation const& location = sf->GetLocation();
+ std::string sname = location.GetDirectory();
+ if(!sname.empty())
+ {
+ sname += "/";
+ }
+ sname += location.GetName();
+
+ ss << sep;
+ sep = ";";
+ // Append this list entry.
+ ss << sname;
+ }
+ }
}
this->Properties.SetProperty("SOURCES", ss.str().c_str(),
cmProperty::TARGET);
}
// the type property returns what type the target is
- if (!strcmp(prop,"TYPE"))
+ if (prop == "TYPE")
{
return cmTarget::GetTargetTypeName(this->GetType());
}
@@ -2866,7 +3497,7 @@ const char *cmTarget::GetProperty(const char* prop,
}
//----------------------------------------------------------------------------
-bool cmTarget::GetPropertyAsBool(const char* prop) const
+bool cmTarget::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
@@ -2875,8 +3506,9 @@ bool cmTarget::GetPropertyAsBool(const char* prop) const
class cmTargetCollectLinkLanguages
{
public:
- cmTargetCollectLinkLanguages(cmTarget const* target, const char* config,
- std::set<cmStdString>& languages,
+ cmTargetCollectLinkLanguages(cmTarget const* target,
+ const std::string& config,
+ std::set<std::string>& languages,
cmTarget const* head):
Config(config), Languages(languages), HeadTarget(head),
Makefile(target->GetMakefile()), Target(target)
@@ -2947,8 +3579,8 @@ public:
}
}
private:
- const char* Config;
- std::set<cmStdString>& Languages;
+ std::string Config;
+ std::set<std::string>& Languages;
cmTarget const* HeadTarget;
cmMakefile* Makefile;
const cmTarget* Target;
@@ -2956,20 +3588,19 @@ private:
};
//----------------------------------------------------------------------------
-const char* cmTarget::GetLinkerLanguage(const char* config,
+std::string cmTarget::GetLinkerLanguage(const std::string& config,
cmTarget const* head) const
{
cmTarget const* headTarget = head ? head : this;
- const char* lang = this->GetLinkClosure(config, headTarget)
- ->LinkerLanguage.c_str();
- return *lang? lang : 0;
+ return this->GetLinkClosure(config, headTarget)->LinkerLanguage;
}
//----------------------------------------------------------------------------
-cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const char* config,
+cmTarget::LinkClosure const* cmTarget::GetLinkClosure(
+ const std::string& config,
cmTarget const* head) const
{
- TargetConfigPair key(head, cmSystemTools::UpperCase(config ? config : ""));
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
cmTargetInternals::LinkClosureMapType::iterator
i = this->Internal->LinkClosureMap.find(key);
if(i == this->Internal->LinkClosureMap.end())
@@ -2989,14 +3620,14 @@ class cmTargetSelectLinker
cmTarget const* Target;
cmMakefile* Makefile;
cmGlobalGenerator* GG;
- std::set<cmStdString> Preferred;
+ std::set<std::string> Preferred;
public:
cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target)
{
this->Makefile = this->Target->GetMakefile();
this->GG = this->Makefile->GetLocalGenerator()->GetGlobalGenerator();
}
- void Consider(const char* lang)
+ void Consider(const std::string& lang)
{
int preference = this->GG->GetLinkerPreference(lang);
if(preference > this->Preference)
@@ -3021,7 +3652,7 @@ public:
e << "Target " << this->Target->GetName()
<< " contains multiple languages with the highest linker preference"
<< " (" << this->Preference << "):\n";
- for(std::set<cmStdString>::const_iterator
+ for(std::set<std::string>::const_iterator
li = this->Preferred.begin(); li != this->Preferred.end(); ++li)
{
e << " " << *li << "\n";
@@ -3036,11 +3667,11 @@ public:
};
//----------------------------------------------------------------------------
-void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc,
+void cmTarget::ComputeLinkClosure(const std::string& config, LinkClosure& lc,
cmTarget const* head) const
{
// Get languages built in this target.
- std::set<cmStdString> languages;
+ std::set<std::string> languages;
LinkImplementation const* impl = this->GetLinkImplementation(config, head);
for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
li != impl->Languages.end(); ++li)
@@ -3057,7 +3688,7 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc,
}
// Store the transitive closure of languages.
- for(std::set<cmStdString>::const_iterator li = languages.begin();
+ for(std::set<std::string>::const_iterator li = languages.begin();
li != languages.end(); ++li)
{
lc.Languages.push_back(*li);
@@ -3081,17 +3712,17 @@ void cmTarget::ComputeLinkClosure(const char* config, LinkClosure& lc,
for(std::vector<std::string>::const_iterator li = impl->Languages.begin();
li != impl->Languages.end(); ++li)
{
- tsl.Consider(li->c_str());
+ tsl.Consider(*li);
}
// Now consider languages that propagate from linked targets.
- for(std::set<cmStdString>::const_iterator sit = languages.begin();
+ for(std::set<std::string>::const_iterator sit = languages.begin();
sit != languages.end(); ++sit)
{
std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES";
- if(this->Makefile->IsOn(propagates.c_str()))
+ if(this->Makefile->IsOn(propagates))
{
- tsl.Consider(sit->c_str());
+ tsl.Consider(*sit);
}
}
@@ -3149,7 +3780,7 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetPDBName(const char* config) const
+std::string cmTarget::GetPDBName(const std::string& config) const
{
std::string prefix;
std::string base;
@@ -3157,8 +3788,7 @@ std::string cmTarget::GetPDBName(const char* config) const
this->GetFullNameInternal(config, false, prefix, base, suffix);
std::vector<std::string> props;
- std::string configUpper =
- cmSystemTools::UpperCase(config? config : "");
+ std::string configUpper = cmSystemTools::UpperCase(config);
if(!configUpper.empty())
{
// PDB_NAME_<CONFIG>
@@ -3171,7 +3801,7 @@ std::string cmTarget::GetPDBName(const char* config) const
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
- if(const char* outName = this->GetProperty(i->c_str()))
+ if(const char* outName = this->GetProperty(*i))
{
base = outName;
break;
@@ -3181,7 +3811,50 @@ std::string cmTarget::GetPDBName(const char* config) const
}
//----------------------------------------------------------------------------
-bool cmTarget::HasSOName(const char* config) const
+std::string cmTarget::GetCompilePDBName(const std::string& config) const
+{
+ std::string prefix;
+ std::string base;
+ std::string suffix;
+ this->GetFullNameInternal(config, false, prefix, base, suffix);
+
+ // Check for a per-configuration output directory target property.
+ std::string configUpper = cmSystemTools::UpperCase(config);
+ std::string configProp = "COMPILE_PDB_NAME_";
+ configProp += configUpper;
+ const char* config_name = this->GetProperty(configProp);
+ if(config_name && *config_name)
+ {
+ return prefix + config_name + ".pdb";
+ }
+
+ const char* name = this->GetProperty("COMPILE_PDB_NAME");
+ if(name && *name)
+ {
+ return prefix + name + ".pdb";
+ }
+
+ return "";
+}
+
+//----------------------------------------------------------------------------
+std::string cmTarget::GetCompilePDBPath(const std::string& config) const
+{
+ std::string dir = this->GetCompilePDBDirectory(config);
+ std::string name = this->GetCompilePDBName(config);
+ if(dir.empty() && !name.empty())
+ {
+ dir = this->GetPDBDirectory(config);
+ }
+ if(!dir.empty())
+ {
+ dir += "/";
+ }
+ return dir + name;
+}
+
+//----------------------------------------------------------------------------
+bool cmTarget::HasSOName(const std::string& config) const
{
// soname is supported only for shared libraries and modules,
// and then only when the platform supports an soname flag.
@@ -3193,7 +3866,7 @@ bool cmTarget::HasSOName(const char* config) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetSOName(const char* config) const
+std::string cmTarget::GetSOName(const std::string& config) const
{
if(this->IsImported())
{
@@ -3235,7 +3908,7 @@ std::string cmTarget::GetSOName(const char* config) const
}
//----------------------------------------------------------------------------
-bool cmTarget::HasMacOSXRpathInstallNameDir(const char* config) const
+bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const
{
bool install_name_is_rpath = false;
bool macosx_rpath = false;
@@ -3347,7 +4020,8 @@ bool cmTarget::MacOSXRpathInstallNameDirDefault() const
}
//----------------------------------------------------------------------------
-bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const
+bool cmTarget::IsImportedSharedLibWithoutSOName(
+ const std::string& config) const
{
if(this->IsImported() && this->GetType() == cmTarget::SHARED_LIBRARY)
{
@@ -3360,7 +4034,7 @@ bool cmTarget::IsImportedSharedLibWithoutSOName(const char* config) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::NormalGetRealName(const char* config) const
+std::string cmTarget::NormalGetRealName(const std::string& config) const
{
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
@@ -3371,7 +4045,7 @@ std::string cmTarget::NormalGetRealName(const char* config) const
msg += this->GetName();
this->GetMakefile()->
IssueMessage(cmake::INTERNAL_ERROR,
- msg.c_str());
+ msg);
}
if(this->GetType() == cmTarget::EXECUTABLE)
@@ -3398,7 +4072,8 @@ std::string cmTarget::NormalGetRealName(const char* config) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFullName(const char* config, bool implib) const
+std::string cmTarget::GetFullName(const std::string& config,
+ bool implib) const
{
if(this->IsImported())
{
@@ -3412,7 +4087,7 @@ std::string cmTarget::GetFullName(const char* config, bool implib) const
//----------------------------------------------------------------------------
std::string
-cmTarget::GetFullNameImported(const char* config, bool implib) const
+cmTarget::GetFullNameImported(const std::string& config, bool implib) const
{
return cmSystemTools::GetFilenameName(
this->ImportedGetFullPath(config, implib));
@@ -3420,14 +4095,15 @@ cmTarget::GetFullNameImported(const char* config, bool implib) const
//----------------------------------------------------------------------------
void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base,
- std::string& suffix, const char* config,
+ std::string& suffix,
+ const std::string& config,
bool implib) const
{
this->GetFullNameInternal(config, implib, prefix, base, suffix);
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFullPath(const char* config, bool implib,
+std::string cmTarget::GetFullPath(const std::string& config, bool implib,
bool realname) const
{
if(this->IsImported())
@@ -3441,8 +4117,8 @@ std::string cmTarget::GetFullPath(const char* config, bool implib,
}
//----------------------------------------------------------------------------
-std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
- bool realname) const
+std::string cmTarget::NormalGetFullPath(const std::string& config,
+ bool implib, bool realname) const
{
std::string fpath = this->GetDirectory(config, implib);
fpath += "/";
@@ -3470,7 +4146,7 @@ std::string cmTarget::NormalGetFullPath(const char* config, bool implib,
//----------------------------------------------------------------------------
std::string
-cmTarget::ImportedGetFullPath(const char* config, bool implib) const
+cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const
{
std::string result;
if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, this))
@@ -3487,7 +4163,7 @@ cmTarget::ImportedGetFullPath(const char* config, bool implib) const
//----------------------------------------------------------------------------
std::string
-cmTarget::GetFullNameInternal(const char* config, bool implib) const
+cmTarget::GetFullNameInternal(const std::string& config, bool implib) const
{
std::string prefix;
std::string base;
@@ -3497,7 +4173,7 @@ cmTarget::GetFullNameInternal(const char* config, bool implib) const
}
//----------------------------------------------------------------------------
-void cmTarget::GetFullNameInternal(const char* config,
+void cmTarget::GetFullNameInternal(const std::string& config,
bool implib,
std::string& outPrefix,
std::string& outBase,
@@ -3543,11 +4219,11 @@ void cmTarget::GetFullNameInternal(const char* config,
? this->GetProperty("IMPORT_SUFFIX")
: this->GetProperty("SUFFIX"));
const char* configPostfix = 0;
- if(config && *config)
+ if(!config.empty())
{
std::string configProp = cmSystemTools::UpperCase(config);
configProp += "_POSTFIX";
- configPostfix = this->GetProperty(configProp.c_str());
+ configPostfix = this->GetProperty(configProp);
// Mac application bundles and frameworks have no postfix.
if(configPostfix &&
(this->IsAppBundleOnApple() || this->IsFrameworkOnApple()))
@@ -3559,17 +4235,18 @@ void cmTarget::GetFullNameInternal(const char* config,
const char* suffixVar = this->GetSuffixVariableInternal(implib);
// Check for language-specific default prefix and suffix.
- if(const char* ll = this->GetLinkerLanguage(config, this))
+ std::string ll = this->GetLinkerLanguage(config, this);
+ if(!ll.empty())
{
if(!targetSuffix && suffixVar && *suffixVar)
{
std::string langSuff = suffixVar + std::string("_") + ll;
- targetSuffix = this->Makefile->GetDefinition(langSuff.c_str());
+ targetSuffix = this->Makefile->GetDefinition(langSuff);
}
if(!targetPrefix && prefixVar && *prefixVar)
{
std::string langPrefix = prefixVar + std::string("_") + ll;
- targetPrefix = this->Makefile->GetDefinition(langPrefix.c_str());
+ targetPrefix = this->Makefile->GetDefinition(langPrefix);
}
}
@@ -3639,7 +4316,7 @@ void cmTarget::GetLibraryNames(std::string& name,
std::string& realName,
std::string& impName,
std::string& pdbName,
- const char* config) const
+ const std::string& config) const
{
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
@@ -3649,7 +4326,7 @@ void cmTarget::GetLibraryNames(std::string& name,
std::string msg = "GetLibraryNames called on imported target: ";
msg += this->GetName();
this->Makefile->IssueMessage(cmake::INTERNAL_ERROR,
- msg.c_str());
+ msg);
return;
}
@@ -3743,7 +4420,7 @@ void cmTarget::GetExecutableNames(std::string& name,
std::string& realName,
std::string& impName,
std::string& pdbName,
- const char* config) const
+ const std::string& config) const
{
// This should not be called for imported targets.
// TODO: Split cmTarget into a class hierarchy to get compile-time
@@ -3753,7 +4430,7 @@ void cmTarget::GetExecutableNames(std::string& name,
std::string msg =
"GetExecutableNames called on imported target: ";
msg += this->GetName();
- this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg.c_str());
+ this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg);
}
// This versioning is supported only for executables and then only
@@ -3821,14 +4498,14 @@ bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName,
}
//----------------------------------------------------------------------------
-void cmTarget::SetPropertyDefault(const char* property,
+void cmTarget::SetPropertyDefault(const std::string& property,
const char* default_value)
{
// Compute the name of the variable holding the default value.
std::string var = "CMAKE_";
var += property;
- if(const char* value = this->Makefile->GetDefinition(var.c_str()))
+ if(const char* value = this->Makefile->GetDefinition(var))
{
this->SetProperty(property, value);
}
@@ -3839,7 +4516,7 @@ void cmTarget::SetPropertyDefault(const char* property,
}
//----------------------------------------------------------------------------
-bool cmTarget::HaveBuildTreeRPATH(const char *config) const
+bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const
{
if (this->GetPropertyAsBool("SKIP_BUILD_RPATH"))
{
@@ -3859,7 +4536,7 @@ bool cmTarget::HaveInstallTreeRPATH() const
}
//----------------------------------------------------------------------------
-bool cmTarget::NeedRelinkBeforeInstall(const char* config) const
+bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const
{
// Only executables and shared libraries can have an rpath and may
// need relinking.
@@ -3896,12 +4573,13 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const
}
// Check for rpath support on this platform.
- if(const char* ll = this->GetLinkerLanguage(config, this))
+ std::string ll = this->GetLinkerLanguage(config, this);
+ if(!ll.empty())
{
std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
flagVar += ll;
flagVar += "_FLAG";
- if(!this->Makefile->IsSet(flagVar.c_str()))
+ if(!this->Makefile->IsSet(flagVar))
{
// There is no rpath support on this platform so nothing needs
// relinking.
@@ -3922,7 +4600,8 @@ bool cmTarget::NeedRelinkBeforeInstall(const char* config) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetInstallNameDirForBuildTree(const char* config) const
+std::string cmTarget::GetInstallNameDirForBuildTree(
+ const std::string& config) const
{
// If building directly for installation then the build tree install_name
// is the same as the install tree.
@@ -4044,10 +4723,11 @@ const char* cmTarget::GetOutputTargetType(bool implib) const
}
//----------------------------------------------------------------------------
-bool cmTarget::ComputeOutputDir(const char* config,
+bool cmTarget::ComputeOutputDir(const std::string& config,
bool implib, std::string& out) const
{
bool usesDefaultOutputDir = false;
+ std::string conf = config;
// Look for a target property defining the target output directory
// based on the target type.
@@ -4061,7 +4741,7 @@ bool cmTarget::ComputeOutputDir(const char* config,
}
// Check for a per-configuration output directory target property.
- std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+ std::string configUpper = cmSystemTools::UpperCase(conf);
const char* configProp = 0;
std::string configPropStr = targetTypeName;
if(!configPropStr.empty())
@@ -4078,7 +4758,7 @@ bool cmTarget::ComputeOutputDir(const char* config,
out = config_outdir;
// Skip per-configuration subdirectory.
- config = 0;
+ conf = "";
}
else if(const char* outdir = this->GetProperty(propertyName))
{
@@ -4111,37 +4791,39 @@ bool cmTarget::ComputeOutputDir(const char* config,
(out.c_str(), this->Makefile->GetStartOutputDirectory()));
// The generator may add the configuration's subdirectory.
- if(config && *config)
+ if(!conf.empty())
{
const char *platforms = this->Makefile->GetDefinition(
"CMAKE_XCODE_EFFECTIVE_PLATFORMS");
std::string suffix =
usesDefaultOutputDir && platforms ? "$(EFFECTIVE_PLATFORM_NAME)" : "";
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
- AppendDirectoryForConfig("/", config, suffix.c_str(), out);
+ AppendDirectoryForConfig("/", conf, suffix, out);
}
return usesDefaultOutputDir;
}
//----------------------------------------------------------------------------
-bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const
+bool cmTarget::ComputePDBOutputDir(const std::string& kind,
+ const std::string& config,
+ std::string& out) const
{
// Look for a target property defining the target output directory
// based on the target type.
- std::string targetTypeName = "PDB";
const char* propertyName = 0;
- std::string propertyNameStr = targetTypeName;
+ std::string propertyNameStr = kind;
if(!propertyNameStr.empty())
{
propertyNameStr += "_OUTPUT_DIRECTORY";
propertyName = propertyNameStr.c_str();
}
+ std::string conf = config;
// Check for a per-configuration output directory target property.
- std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+ std::string configUpper = cmSystemTools::UpperCase(conf);
const char* configProp = 0;
- std::string configPropStr = targetTypeName;
+ std::string configPropStr = kind;
if(!configPropStr.empty())
{
configPropStr += "_OUTPUT_DIRECTORY_";
@@ -4156,7 +4838,7 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const
out = config_outdir;
// Skip per-configuration subdirectory.
- config = 0;
+ conf = "";
}
else if(const char* outdir = this->GetProperty(propertyName))
{
@@ -4175,27 +4857,29 @@ bool cmTarget::ComputePDBOutputDir(const char* config, std::string& out) const
(out.c_str(), this->Makefile->GetStartOutputDirectory()));
// The generator may add the configuration's subdirectory.
- if(config && *config)
+ if(!conf.empty())
{
this->Makefile->GetLocalGenerator()->GetGlobalGenerator()->
- AppendDirectoryForConfig("/", config, "", out);
+ AppendDirectoryForConfig("/", conf, "", out);
}
return true;
}
//----------------------------------------------------------------------------
-bool cmTarget::UsesDefaultOutputDir(const char* config, bool implib) const
+bool cmTarget::UsesDefaultOutputDir(const std::string& config,
+ bool implib) const
{
std::string dir;
return this->ComputeOutputDir(config, implib, dir);
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetOutputName(const char* config, bool implib) const
+std::string cmTarget::GetOutputName(const std::string& config,
+ bool implib) const
{
std::vector<std::string> props;
std::string type = this->GetOutputTargetType(implib);
- std::string configUpper = cmSystemTools::UpperCase(config? config : "");
+ std::string configUpper = cmSystemTools::UpperCase(config);
if(!type.empty() && !configUpper.empty())
{
// <ARCHIVE|LIBRARY|RUNTIME>_OUTPUT_NAME_<CONFIG>
@@ -4219,7 +4903,7 @@ std::string cmTarget::GetOutputName(const char* config, bool implib) const
for(std::vector<std::string>::const_iterator i = props.begin();
i != props.end(); ++i)
{
- if(const char* outName = this->GetProperty(i->c_str()))
+ if(const char* outName = this->GetProperty(*i))
{
return outName;
}
@@ -4529,7 +5213,7 @@ std::string compatibilityAgree(CompatibleType t, bool dominant)
template<typename PropertyType>
PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
const std::string &p,
- const char *config,
+ const std::string& config,
const char *defaultValue,
CompatibleType t,
PropertyType *)
@@ -4537,19 +5221,20 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
PropertyType propContent = getTypedProperty<PropertyType>(tgt, p.c_str(),
0);
const bool explicitlySet = tgt->GetProperties()
- .find(p.c_str())
+ .find(p)
!= tgt->GetProperties().end();
const bool impliedByUse =
tgt->IsNullImpliedByLinkLibraries(p);
assert((impliedByUse ^ explicitlySet)
|| (!impliedByUse && !explicitlySet));
- cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
- if(!info)
+ std::vector<cmTarget*> deps;
+ tgt->GetTransitiveTargetClosure(config, tgt, deps);
+
+ if(deps.empty())
{
return propContent;
}
- const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
bool propInitialized = explicitlySet;
std::string report = " * Target \"";
@@ -4569,7 +5254,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
report += "\" property not set.\n";
}
- for(cmComputeLinkInformation::ItemVector::const_iterator li =
+ for(std::vector<cmTarget*>::const_iterator li =
deps.begin();
li != deps.end(); ++li)
{
@@ -4579,23 +5264,20 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
// target itself has a POSITION_INDEPENDENT_CODE which disagrees
// with a dependency.
- if (!li->Target)
- {
- continue;
- }
+ cmTarget const* theTarget = *li;
- const bool ifaceIsSet = li->Target->GetProperties()
+ const bool ifaceIsSet = theTarget->GetProperties()
.find("INTERFACE_" + p)
- != li->Target->GetProperties().end();
+ != theTarget->GetProperties().end();
PropertyType ifacePropContent =
- getTypedProperty<PropertyType>(li->Target,
+ getTypedProperty<PropertyType>(theTarget,
("INTERFACE_" + p).c_str(), 0);
std::string reportEntry;
if (ifaceIsSet)
{
reportEntry += " * Target \"";
- reportEntry += li->Target->GetName();
+ reportEntry += theTarget->GetName();
reportEntry += "\" property value \"";
reportEntry += valueAsString<PropertyType>(ifacePropContent);
reportEntry += "\" ";
@@ -4616,7 +5298,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
e << "Property " << p << " on target \""
<< tgt->GetName() << "\" does\nnot match the "
"INTERFACE_" << p << " property requirement\nof "
- "dependency \"" << li->Target->GetName() << "\".\n";
+ "dependency \"" << theTarget->GetName() << "\".\n";
cmSystemTools::Error(e.str().c_str());
break;
}
@@ -4650,7 +5332,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
<< tgt->GetName() << "\" is\nimplied to be " << defaultValue
<< " because it was used to determine the link libraries\n"
"already. The INTERFACE_" << p << " property on\ndependency \""
- << li->Target->GetName() << "\" is in conflict.\n";
+ << theTarget->GetName() << "\" is in conflict.\n";
cmSystemTools::Error(e.str().c_str());
break;
}
@@ -4681,7 +5363,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
{
cmOStringStream e;
e << "The INTERFACE_" << p << " property of \""
- << li->Target->GetName() << "\" does\nnot agree with the value "
+ << theTarget->GetName() << "\" does\nnot agree with the value "
"of " << p << " already determined\nfor \""
<< tgt->GetName() << "\".\n";
cmSystemTools::Error(e.str().c_str());
@@ -4715,7 +5397,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt,
//----------------------------------------------------------------------------
bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p,
- const char *config) const
+ const std::string& config) const
{
return checkInterfacePropertyCompatibility<bool>(this, p, config, "FALSE",
BoolType, 0);
@@ -4723,8 +5405,8 @@ bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p,
//----------------------------------------------------------------------------
const char * cmTarget::GetLinkInterfaceDependentStringProperty(
- const std::string &p,
- const char *config) const
+ const std::string &p,
+ const std::string& config) const
{
return checkInterfacePropertyCompatibility<const char *>(this,
p,
@@ -4735,8 +5417,8 @@ const char * cmTarget::GetLinkInterfaceDependentStringProperty(
//----------------------------------------------------------------------------
const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty(
- const std::string &p,
- const char *config) const
+ const std::string &p,
+ const std::string& config) const
{
return checkInterfacePropertyCompatibility<const char *>(this,
p,
@@ -4747,8 +5429,8 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty(
//----------------------------------------------------------------------------
const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty(
- const std::string &p,
- const char *config) const
+ const std::string &p,
+ const std::string& config) const
{
return checkInterfacePropertyCompatibility<const char *>(this,
p,
@@ -4759,26 +5441,22 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty(
//----------------------------------------------------------------------------
bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p,
- const char *interfaceProperty,
- const char *config)
+ const std::string& interfaceProperty,
+ const std::string& config)
{
- cmComputeLinkInformation *info = tgt->GetLinkInformation(config);
- if(!info)
+ std::vector<cmTarget*> deps;
+ tgt->GetTransitiveTargetClosure(config, tgt, deps);
+
+ if(deps.empty())
{
return false;
}
- const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
-
- for(cmComputeLinkInformation::ItemVector::const_iterator li =
+ for(std::vector<cmTarget*>::const_iterator li =
deps.begin();
li != deps.end(); ++li)
{
- if (!li->Target)
- {
- continue;
- }
- const char *prop = li->Target->GetProperty(interfaceProperty);
+ const char *prop = (*li)->GetProperty(interfaceProperty);
if (!prop)
{
continue;
@@ -4802,7 +5480,7 @@ bool isLinkDependentProperty(cmTarget const* tgt, const std::string &p,
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p,
- const char *config) const
+ const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4816,7 +5494,7 @@ bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p,
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p,
- const char *config) const
+ const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4830,7 +5508,7 @@ bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p,
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
- const char *config) const
+ const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4843,7 +5521,7 @@ bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
//----------------------------------------------------------------------------
bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
- const char *config) const
+ const std::string& config) const
{
if (this->TargetTypeValue == OBJECT_LIBRARY
|| this->TargetTypeValue == INTERFACE_LIBRARY)
@@ -4855,20 +5533,92 @@ bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
}
//----------------------------------------------------------------------------
-void cmTarget::GetLanguages(std::set<cmStdString>& languages) const
+void
+cmTarget::GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const
+{
+ // At configure-time, this method can be called as part of getting the
+ // LOCATION property or to export() a file to be include()d. However
+ // there is no cmGeneratorTarget at configure-time, so search the SOURCES
+ // for TARGET_OBJECTS instead for backwards compatibility with OLD
+ // behavior of CMP0024 and CMP0026 only.
+ typedef cmTargetInternals::TargetPropertyEntry
+ TargetPropertyEntry;
+ for(std::vector<TargetPropertyEntry*>::const_iterator
+ i = this->Internal->SourceEntries.begin();
+ i != this->Internal->SourceEntries.end(); ++i)
+ {
+ std::string entry = (*i)->ge->GetInput();
+
+ std::vector<std::string> files;
+ cmSystemTools::ExpandListArgument(entry, files);
+ for (std::vector<std::string>::const_iterator
+ li = files.begin(); li != files.end(); ++li)
+ {
+ if(cmHasLiteralPrefix(*li, "$<TARGET_OBJECTS:") &&
+ (*li)[li->size() - 1] == '>')
+ {
+ std::string objLibName = li->substr(17, li->size()-18);
+
+ if (cmGeneratorExpression::Find(objLibName) != std::string::npos)
+ {
+ continue;
+ }
+ cmTarget *objLib = this->Makefile->FindTargetToUse(objLibName.c_str());
+ assert(objLib);
+ objlibs.push_back(objLib);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetLanguages(std::set<std::string>& languages,
+ const std::string& config,
+ cmTarget const* head) const
{
+ std::vector<cmSourceFile*> sourceFiles;
+ this->GetSourceFiles(sourceFiles, config, head);
for(std::vector<cmSourceFile*>::const_iterator
- i = this->SourceFiles.begin(); i != this->SourceFiles.end(); ++i)
+ i = sourceFiles.begin(); i != sourceFiles.end(); ++i)
{
- if(const char* lang = (*i)->GetLanguage())
+ const std::string& lang = (*i)->GetLanguage();
+ if(!lang.empty())
{
languages.insert(lang);
}
}
+
+ std::vector<cmTarget*> objectLibraries;
+ std::vector<cmSourceFile const*> externalObjects;
+ if (this->Makefile->GetGeneratorTargets().empty())
+ {
+ this->GetObjectLibrariesCMP0026(objectLibraries);
+ }
+ else
+ {
+ cmGeneratorTarget* gt = this->Makefile->GetLocalGenerator()
+ ->GetGlobalGenerator()
+ ->GetGeneratorTarget(this);
+ gt->GetExternalObjects(externalObjects, config);
+ for(std::vector<cmSourceFile const*>::const_iterator
+ i = externalObjects.begin(); i != externalObjects.end(); ++i)
+ {
+ std::string objLib = (*i)->GetObjectLibrary();
+ if (cmTarget* tgt = this->Makefile->FindTargetToUse(objLib))
+ {
+ objectLibraries.push_back(tgt);
+ }
+ }
+ }
+ for(std::vector<cmTarget*>::const_iterator
+ i = objectLibraries.begin(); i != objectLibraries.end(); ++i)
+ {
+ (*i)->GetLanguages(languages, config, head);
+ }
}
//----------------------------------------------------------------------------
-bool cmTarget::IsChrpathUsed(const char* config) const
+bool cmTarget::IsChrpathUsed(const std::string& config) const
{
// Only certain target types have an rpath.
if(!(this->GetType() == cmTarget::SHARED_LIBRARY ||
@@ -4911,12 +5661,13 @@ bool cmTarget::IsChrpathUsed(const char* config) const
#if defined(CMAKE_USE_ELF_PARSER)
// Enable if the rpath flag uses a separator and the target uses ELF
// binaries.
- if(const char* ll = this->GetLinkerLanguage(config, this))
+ std::string ll = this->GetLinkerLanguage(config, this);
+ if(!ll.empty())
{
std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_";
sepVar += ll;
sepVar += "_FLAG_SEP";
- const char* sep = this->Makefile->GetDefinition(sepVar.c_str());
+ const char* sep = this->Makefile->GetDefinition(sepVar);
if(sep && *sep)
{
// TODO: Add ELF check to ABI detection and get rid of
@@ -4935,7 +5686,8 @@ bool cmTarget::IsChrpathUsed(const char* config) const
//----------------------------------------------------------------------------
cmTarget::ImportInfo const*
-cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const
+cmTarget::GetImportInfo(const std::string& config,
+ cmTarget const* headTarget) const
{
// There is no imported information for non-imported targets.
if(!this->IsImported())
@@ -4946,7 +5698,7 @@ cmTarget::GetImportInfo(const char* config, cmTarget const* headTarget) const
// Lookup/compute/cache the import information for this
// configuration.
std::string config_upper;
- if(config && *config)
+ if(!config.empty())
{
config_upper = cmSystemTools::UpperCase(config);
}
@@ -5004,7 +5756,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
{
std::string mapProp = "MAP_IMPORTED_CONFIG_";
mapProp += desired_config;
- if(const char* mapValue = this->GetProperty(mapProp.c_str()))
+ if(const char* mapValue = this->GetProperty(mapProp))
{
cmSystemTools::ExpandListArgument(mapValue, mappedConfigs);
}
@@ -5020,15 +5772,15 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
!*loc && !*imp && mci != mappedConfigs.end(); ++mci)
{
// Look for this configuration.
- std::string mcUpper = cmSystemTools::UpperCase(mci->c_str());
+ std::string mcUpper = cmSystemTools::UpperCase(*mci);
std::string locProp = "IMPORTED_LOCATION_";
locProp += mcUpper;
- *loc = this->GetProperty(locProp.c_str());
+ *loc = this->GetProperty(locProp);
if(allowImp)
{
std::string impProp = "IMPORTED_IMPLIB_";
impProp += mcUpper;
- *imp = this->GetProperty(impProp.c_str());
+ *imp = this->GetProperty(impProp);
}
// If it was found, use it for all properties below.
@@ -5053,12 +5805,12 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
{
std::string locProp = "IMPORTED_LOCATION";
locProp += suffix;
- *loc = this->GetProperty(locProp.c_str());
+ *loc = this->GetProperty(locProp);
if(allowImp)
{
std::string impProp = "IMPORTED_IMPLIB";
impProp += suffix;
- *imp = this->GetProperty(impProp.c_str());
+ *imp = this->GetProperty(impProp);
}
}
@@ -5095,12 +5847,12 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config,
suffix += cmSystemTools::UpperCase(*aci);
std::string locProp = "IMPORTED_LOCATION";
locProp += suffix;
- *loc = this->GetProperty(locProp.c_str());
+ *loc = this->GetProperty(locProp);
if(allowImp)
{
std::string impProp = "IMPORTED_IMPLIB";
impProp += suffix;
- *imp = this->GetProperty(impProp.c_str());
+ *imp = this->GetProperty(impProp);
}
}
}
@@ -5136,7 +5888,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
// Get the link interface.
{
std::string linkProp = "INTERFACE_LINK_LIBRARIES";
- const char *propertyLibs = this->GetProperty(linkProp.c_str());
+ const char *propertyLibs = this->GetProperty(linkProp);
if (this->GetType() != INTERFACE_LIBRARY)
{
@@ -5144,13 +5896,13 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
linkProp += suffix;
- propertyLibs = this->GetProperty(linkProp.c_str());
+ propertyLibs = this->GetProperty(linkProp);
}
if(!propertyLibs)
{
linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
- propertyLibs = this->GetProperty(linkProp.c_str());
+ propertyLibs = this->GetProperty(linkProp);
}
}
if(propertyLibs)
@@ -5163,7 +5915,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
linkProp, 0, 0);
cmSystemTools::ExpandListArgument(ge.Parse(propertyLibs)
->Evaluate(this->Makefile,
- desired_config.c_str(),
+ desired_config,
false,
headTarget,
this,
@@ -5188,7 +5940,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string impProp = "IMPORTED_LOCATION";
impProp += suffix;
- if(const char* config_location = this->GetProperty(impProp.c_str()))
+ if(const char* config_location = this->GetProperty(impProp))
{
info.Location = config_location;
}
@@ -5203,7 +5955,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string soProp = "IMPORTED_SONAME";
soProp += suffix;
- if(const char* config_soname = this->GetProperty(soProp.c_str()))
+ if(const char* config_soname = this->GetProperty(soProp))
{
info.SOName = config_soname;
}
@@ -5218,7 +5970,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string soProp = "IMPORTED_NO_SONAME";
soProp += suffix;
- if(const char* config_no_soname = this->GetProperty(soProp.c_str()))
+ if(const char* config_no_soname = this->GetProperty(soProp))
{
info.NoSOName = cmSystemTools::IsOn(config_no_soname);
}
@@ -5238,7 +5990,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string impProp = "IMPORTED_IMPLIB";
impProp += suffix;
- if(const char* config_implib = this->GetProperty(impProp.c_str()))
+ if(const char* config_implib = this->GetProperty(impProp))
{
info.ImportLibrary = config_implib;
}
@@ -5252,7 +6004,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string linkProp = "IMPORTED_LINK_DEPENDENT_LIBRARIES";
linkProp += suffix;
- if(const char* config_libs = this->GetProperty(linkProp.c_str()))
+ if(const char* config_libs = this->GetProperty(linkProp))
{
cmSystemTools::ExpandListArgument(config_libs,
info.LinkInterface.SharedDeps);
@@ -5269,7 +6021,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string linkProp = "IMPORTED_LINK_INTERFACE_LANGUAGES";
linkProp += suffix;
- if(const char* config_libs = this->GetProperty(linkProp.c_str()))
+ if(const char* config_libs = this->GetProperty(linkProp))
{
cmSystemTools::ExpandListArgument(config_libs,
info.LinkInterface.Languages);
@@ -5287,7 +6039,7 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string linkProp = "IMPORTED_LINK_INTERFACE_MULTIPLICITY";
linkProp += suffix;
- if(const char* config_reps = this->GetProperty(linkProp.c_str()))
+ if(const char* config_reps = this->GetProperty(linkProp))
{
sscanf(config_reps, "%u", &info.LinkInterface.Multiplicity);
}
@@ -5300,7 +6052,8 @@ void cmTarget::ComputeImportInfo(std::string const& desired_config,
}
//----------------------------------------------------------------------------
-cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
+cmTarget::LinkInterface const* cmTarget::GetLinkInterface(
+ const std::string& config,
cmTarget const* head) const
{
// Imported targets have their own link interface.
@@ -5322,7 +6075,60 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
}
// Lookup any existing link interface for this configuration.
- TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
+
+ cmTargetInternals::LinkInterfaceMapType::iterator
+ i = this->Internal->LinkInterfaceMap.find(key);
+ if(i == this->Internal->LinkInterfaceMap.end())
+ {
+ // Compute the link interface for this configuration.
+ cmTargetInternals::OptionalLinkInterface iface;
+ iface.ExplicitLibraries =
+ this->ComputeLinkInterfaceLibraries(config, iface, head, iface.Exists);
+ if (iface.Exists)
+ {
+ this->Internal->ComputeLinkInterface(this, config, iface,
+ head, iface.ExplicitLibraries);
+ }
+
+ // Store the information for this configuration.
+ cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
+ i = this->Internal->LinkInterfaceMap.insert(entry).first;
+ }
+ else if(!i->second.Complete && i->second.Exists)
+ {
+ this->Internal->ComputeLinkInterface(this, config, i->second, head,
+ i->second.ExplicitLibraries);
+ }
+
+ return i->second.Exists ? &i->second : 0;
+}
+
+//----------------------------------------------------------------------------
+cmTarget::LinkInterface const*
+cmTarget::GetLinkInterfaceLibraries(const std::string& config,
+ cmTarget const* head) const
+{
+ // Imported targets have their own link interface.
+ if(this->IsImported())
+ {
+ if(cmTarget::ImportInfo const* info = this->GetImportInfo(config, head))
+ {
+ return &info->LinkInterface;
+ }
+ return 0;
+ }
+
+ // Link interfaces are not supported for executables that do not
+ // export symbols.
+ if(this->GetType() == cmTarget::EXECUTABLE &&
+ !this->IsExecutableWithExports())
+ {
+ return 0;
+ }
+
+ // Lookup any existing link interface for this configuration.
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
cmTargetInternals::LinkInterfaceMapType::iterator
i = this->Internal->LinkInterfaceMap.find(key);
@@ -5330,24 +6136,71 @@ cmTarget::LinkInterface const* cmTarget::GetLinkInterface(const char* config,
{
// Compute the link interface for this configuration.
cmTargetInternals::OptionalLinkInterface iface;
- iface.Exists = this->ComputeLinkInterface(config, iface, head);
+ iface.ExplicitLibraries = this->ComputeLinkInterfaceLibraries(config,
+ iface,
+ head,
+ iface.Exists);
// Store the information for this configuration.
cmTargetInternals::LinkInterfaceMapType::value_type entry(key, iface);
i = this->Internal->LinkInterfaceMap.insert(entry).first;
}
- return i->second.Exists? &i->second : 0;
+ return i->second.Exists ? &i->second : 0;
+}
+
+//----------------------------------------------------------------------------
+void processILibs(const std::string& config,
+ cmTarget const* headTarget,
+ std::string const& name,
+ std::vector<cmTarget*>& tgts, std::set<cmTarget*>& emitted)
+{
+ if (cmTarget* tgt = headTarget->GetMakefile()
+ ->FindTargetToUse(name))
+ {
+ if (emitted.insert(tgt).second)
+ {
+ tgts.push_back(tgt);
+ std::vector<std::string> ilibs;
+ cmTarget::LinkInterface const* iface =
+ tgt->GetLinkInterfaceLibraries(config, headTarget);
+ if (iface)
+ {
+ for(std::vector<std::string>::const_iterator
+ it = iface->Libraries.begin();
+ it != iface->Libraries.end(); ++it)
+ {
+ processILibs(config, headTarget, *it, tgts, emitted);
+ }
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void cmTarget::GetTransitiveTargetClosure(const std::string& config,
+ cmTarget const* headTarget,
+ std::vector<cmTarget*> &tgts) const
+{
+ std::set<cmTarget*> emitted;
+
+ cmTarget::LinkImplementation const* impl
+ = this->GetLinkImplementationLibraries(config, headTarget);
+
+ for(std::vector<std::string>::const_iterator it = impl->Libraries.begin();
+ it != impl->Libraries.end(); ++it)
+ {
+ processILibs(config, headTarget, *it, tgts, emitted);
+ }
}
//----------------------------------------------------------------------------
-void cmTarget::GetTransitivePropertyLinkLibraries(
- const char* config,
+void cmTarget::GetTransitivePropertyTargets(const std::string& config,
cmTarget const* headTarget,
- std::vector<std::string> &libs) const
+ std::vector<cmTarget*> &tgts) const
{
- cmTarget::LinkInterface const* iface = this->GetLinkInterface(config,
- headTarget);
+ cmTarget::LinkInterface const* iface
+ = this->GetLinkInterfaceLibraries(config, headTarget);
if (!iface)
{
return;
@@ -5356,7 +6209,15 @@ void cmTarget::GetTransitivePropertyLinkLibraries(
|| this->GetPolicyStatusCMP0022() == cmPolicies::WARN
|| this->GetPolicyStatusCMP0022() == cmPolicies::OLD)
{
- libs = iface->Libraries;
+ for(std::vector<std::string>::const_iterator it = iface->Libraries.begin();
+ it != iface->Libraries.end(); ++it)
+ {
+ if (cmTarget* tgt = headTarget->GetMakefile()
+ ->FindTargetToUse(*it))
+ {
+ tgts.push_back(tgt);
+ }
+ }
return;
}
@@ -5374,21 +6235,34 @@ void cmTarget::GetTransitivePropertyLinkLibraries(
cmGeneratorExpressionDAGChecker dagChecker(lfbt, this->GetName(),
linkIfaceProp, 0, 0);
dagChecker.SetTransitivePropertiesOnly();
+ std::vector<std::string> libs;
cmSystemTools::ExpandListArgument(ge.Parse(interfaceLibs)->Evaluate(
this->Makefile,
config,
false,
headTarget,
this, &dagChecker), libs);
+
+ for(std::vector<std::string>::const_iterator it = libs.begin();
+ it != libs.end(); ++it)
+ {
+ if (cmTarget* tgt = headTarget->GetMakefile()
+ ->FindTargetToUse(*it))
+ {
+ tgts.push_back(tgt);
+ }
+ }
}
//----------------------------------------------------------------------------
-bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
- cmTarget const* headTarget) const
+const char* cmTarget::ComputeLinkInterfaceLibraries(const std::string& config,
+ LinkInterface& iface,
+ cmTarget const* headTarget,
+ bool &exists) const
{
// Construct the property name suffix for this configuration.
std::string suffix = "_";
- if(config && *config)
+ if(!config.empty())
{
suffix += cmSystemTools::UpperCase(config);
}
@@ -5406,7 +6280,7 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
{
// CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES.
linkIfaceProp = "INTERFACE_LINK_LIBRARIES";
- explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
+ explicitLibraries = this->GetProperty(linkIfaceProp);
}
else if(this->GetType() == cmTarget::SHARED_LIBRARY ||
this->IsExecutableWithExports())
@@ -5417,13 +6291,13 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
// Lookup the per-configuration property.
linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
linkIfaceProp += suffix;
- explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
+ explicitLibraries = this->GetProperty(linkIfaceProp);
// If not set, try the generic property.
if(!explicitLibraries)
{
linkIfaceProp = "LINK_INTERFACE_LIBRARIES";
- explicitLibraries = this->GetProperty(linkIfaceProp.c_str());
+ explicitLibraries = this->GetProperty(linkIfaceProp);
}
}
@@ -5460,8 +6334,10 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
(this->GetType() == cmTarget::EXECUTABLE ||
(this->GetType() == cmTarget::MODULE_LIBRARY)))
{
- return false;
+ exists = false;
+ return 0;
}
+ exists = true;
if(explicitLibraries)
{
@@ -5476,52 +6352,6 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
false,
headTarget,
this, &dagChecker), iface.Libraries);
-
- if(this->GetType() == cmTarget::SHARED_LIBRARY
- || this->GetType() == cmTarget::STATIC_LIBRARY
- || this->GetType() == cmTarget::INTERFACE_LIBRARY)
- {
- // Shared libraries may have runtime implementation dependencies
- // on other shared libraries that are not in the interface.
- std::set<cmStdString> emitted;
- for(std::vector<std::string>::const_iterator
- li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
- {
- emitted.insert(*li);
- }
- if (this->GetType() != cmTarget::INTERFACE_LIBRARY)
- {
- LinkImplementation const* impl = this->GetLinkImplementation(config,
- headTarget);
- for(std::vector<std::string>::const_iterator
- li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
- {
- if(emitted.insert(*li).second)
- {
- if(cmTarget* tgt = this->Makefile->FindTargetToUse(*li))
- {
- // This is a runtime dependency on another shared library.
- if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
- {
- iface.SharedDeps.push_back(*li);
- }
- }
- else
- {
- // TODO: Recognize shared library file names. Perhaps this
- // should be moved to cmComputeLinkInformation, but that creates
- // a chicken-and-egg problem since this list is needed for its
- // construction.
- }
- }
- }
- if(this->LinkLanguagePropagatesToDependents())
- {
- // Targets using this archive need its language runtime libraries.
- iface.Languages = impl->Languages;
- }
- }
- }
}
else if (this->PolicyStatusCMP0022 == cmPolicies::WARN
|| this->PolicyStatusCMP0022 == cmPolicies::OLD)
@@ -5531,17 +6361,9 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
// to the link implementation.
{
// The link implementation is the default link interface.
- LinkImplementation const* impl = this->GetLinkImplementation(config,
- headTarget);
- iface.ImplementationIsInterface = true;
+ LinkImplementation const* impl =
+ this->GetLinkImplementationLibraries(config, headTarget);
iface.Libraries = impl->Libraries;
- iface.WrongConfigLibraries = impl->WrongConfigLibraries;
- if(this->LinkLanguagePropagatesToDependents())
- {
- // Targets using this archive need its language runtime libraries.
- iface.Languages = impl->Languages;
- }
-
if(this->PolicyStatusCMP0022 == cmPolicies::WARN &&
!this->Internal->PolicyWarnedCMP0022)
{
@@ -5606,30 +6428,148 @@ bool cmTarget::ComputeLinkInterface(const char* config, LinkInterface& iface,
}
}
}
+ return explicitLibraries;
+}
- if(this->GetType() == cmTarget::STATIC_LIBRARY)
+//----------------------------------------------------------------------------
+void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget,
+ const std::string& config,
+ OptionalLinkInterface& iface,
+ cmTarget const* headTarget,
+ const char* explicitLibraries) const
+{
+ if(explicitLibraries)
+ {
+ if(thisTarget->GetType() == cmTarget::SHARED_LIBRARY
+ || thisTarget->GetType() == cmTarget::STATIC_LIBRARY
+ || thisTarget->GetType() == cmTarget::INTERFACE_LIBRARY)
+ {
+ // Shared libraries may have runtime implementation dependencies
+ // on other shared libraries that are not in the interface.
+ std::set<std::string> emitted;
+ for(std::vector<std::string>::const_iterator
+ li = iface.Libraries.begin(); li != iface.Libraries.end(); ++li)
+ {
+ emitted.insert(*li);
+ }
+ if (thisTarget->GetType() != cmTarget::INTERFACE_LIBRARY)
+ {
+ cmTarget::LinkImplementation const* impl =
+ thisTarget->GetLinkImplementation(config, headTarget);
+ for(std::vector<std::string>::const_iterator
+ li = impl->Libraries.begin(); li != impl->Libraries.end(); ++li)
+ {
+ if(emitted.insert(*li).second)
+ {
+ if(cmTarget* tgt = thisTarget->Makefile->FindTargetToUse(*li))
+ {
+ // This is a runtime dependency on another shared library.
+ if(tgt->GetType() == cmTarget::SHARED_LIBRARY)
+ {
+ iface.SharedDeps.push_back(*li);
+ }
+ }
+ else
+ {
+ // TODO: Recognize shared library file names. Perhaps this
+ // should be moved to cmComputeLinkInformation, but that creates
+ // a chicken-and-egg problem since this list is needed for its
+ // construction.
+ }
+ }
+ }
+ if(thisTarget->LinkLanguagePropagatesToDependents())
+ {
+ // Targets using this archive need its language runtime libraries.
+ iface.Languages = impl->Languages;
+ }
+ }
+ }
+ }
+ else if (thisTarget->PolicyStatusCMP0022 == cmPolicies::WARN
+ || thisTarget->PolicyStatusCMP0022 == cmPolicies::OLD)
+ {
+ // The link implementation is the default link interface.
+ cmTarget::LinkImplementation const*
+ impl = thisTarget->GetLinkImplementation(config, headTarget);
+ iface.ImplementationIsInterface = true;
+ iface.WrongConfigLibraries = impl->WrongConfigLibraries;
+ if(thisTarget->LinkLanguagePropagatesToDependents())
+ {
+ // Targets using this archive need its language runtime libraries.
+ iface.Languages = impl->Languages;
+ }
+ }
+
+ if(thisTarget->GetType() == cmTarget::STATIC_LIBRARY)
{
+ // Construct the property name suffix for this configuration.
+ std::string suffix = "_";
+ if(!config.empty())
+ {
+ suffix += cmSystemTools::UpperCase(config);
+ }
+ else
+ {
+ suffix += "NOCONFIG";
+ }
+
// How many repetitions are needed if this library has cyclic
// dependencies?
std::string propName = "LINK_INTERFACE_MULTIPLICITY";
propName += suffix;
- if(const char* config_reps = this->GetProperty(propName.c_str()))
+ if(const char* config_reps = thisTarget->GetProperty(propName))
{
sscanf(config_reps, "%u", &iface.Multiplicity);
}
else if(const char* reps =
- this->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
+ thisTarget->GetProperty("LINK_INTERFACE_MULTIPLICITY"))
{
sscanf(reps, "%u", &iface.Multiplicity);
}
}
+ iface.Complete = true;
+}
- return true;
+//----------------------------------------------------------------------------
+cmTarget::LinkImplementation const*
+cmTarget::GetLinkImplementation(const std::string& config,
+ cmTarget const* head) const
+{
+ // There is no link implementation for imported targets.
+ if(this->IsImported())
+ {
+ return 0;
+ }
+
+ // Lookup any existing link implementation for this configuration.
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
+
+ cmTargetInternals::LinkImplMapType::iterator
+ i = this->Internal->LinkImplMap.find(key);
+ if(i == this->Internal->LinkImplMap.end())
+ {
+ // Compute the link implementation for this configuration.
+ LinkImplementation impl;
+ this->ComputeLinkImplementation(config, impl, head);
+ this->ComputeLinkImplementationLanguages(config, impl, head);
+
+ // Store the information for this configuration.
+ cmTargetInternals::LinkImplMapType::value_type entry(key, impl);
+ i = this->Internal->LinkImplMap.insert(entry).first;
+ }
+ else if (i->second.Languages.empty())
+ {
+ this->ComputeLinkImplementationLanguages(config, i->second, head);
+ }
+
+ return &i->second;
}
//----------------------------------------------------------------------------
cmTarget::LinkImplementation const*
-cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const
+cmTarget::GetLinkImplementationLibraries(const std::string& config,
+ cmTarget const* head) const
{
// There is no link implementation for imported targets.
if(this->IsImported())
@@ -5638,7 +6578,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const
}
// Lookup any existing link implementation for this configuration.
- TargetConfigPair key(head, cmSystemTools::UpperCase(config? config : ""));
+ TargetConfigPair key(head, cmSystemTools::UpperCase(config));
cmTargetInternals::LinkImplMapType::iterator
i = this->Internal->LinkImplMap.find(key);
@@ -5657,7 +6597,7 @@ cmTarget::GetLinkImplementation(const char* config, cmTarget const* head) const
}
//----------------------------------------------------------------------------
-void cmTarget::ComputeLinkImplementation(const char* config,
+void cmTarget::ComputeLinkImplementation(const std::string& config,
LinkImplementation& impl,
cmTarget const* head) const
{
@@ -5729,26 +6669,20 @@ void cmTarget::ComputeLinkImplementation(const char* config,
impl.WrongConfigLibraries.push_back(item);
}
}
+}
+//----------------------------------------------------------------------------
+void
+cmTarget::ComputeLinkImplementationLanguages(const std::string& config,
+ LinkImplementation& impl,
+ cmTarget const* head) const
+{
// This target needs runtime libraries for its source languages.
- std::set<cmStdString> languages;
+ std::set<std::string> languages;
// Get languages used in our source files.
- this->GetLanguages(languages);
- // Get languages used in object library sources.
- for(std::vector<std::string>::const_iterator
- i = this->ObjectLibraries.begin();
- i != this->ObjectLibraries.end(); ++i)
- {
- if(cmTarget* objLib = this->Makefile->FindTargetToUse(*i))
- {
- if(objLib->GetType() == cmTarget::OBJECT_LIBRARY)
- {
- objLib->GetLanguages(languages);
- }
- }
- }
+ this->GetLanguages(languages, config, head);
// Copy the set of langauges to the link implementation.
- for(std::set<cmStdString>::iterator li = languages.begin();
+ for(std::set<std::string>::iterator li = languages.begin();
li != languages.end(); ++li)
{
impl.Languages.push_back(*li);
@@ -5816,15 +6750,15 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const
template<typename PropertyType>
PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt,
- const std::string prop,
- const char *config,
+ const std::string& prop,
+ const std::string& config,
CompatibleType,
PropertyType *);
template<>
bool getLinkInterfaceDependentProperty(cmTarget const* tgt,
- const std::string prop,
- const char *config,
+ const std::string& prop,
+ const std::string& config,
CompatibleType, bool *)
{
return tgt->GetLinkInterfaceDependentBoolProperty(prop, config);
@@ -5832,8 +6766,8 @@ bool getLinkInterfaceDependentProperty(cmTarget const* tgt,
template<>
const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
- const std::string prop,
- const char *config,
+ const std::string& prop,
+ const std::string& config,
CompatibleType t,
const char **)
{
@@ -5857,9 +6791,9 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt,
template<typename PropertyType>
void checkPropertyConsistency(cmTarget const* depender,
cmTarget const* dependee,
- const char *propName,
- std::set<cmStdString> &emitted,
- const char *config,
+ const std::string& propName,
+ std::set<std::string> &emitted,
+ const std::string& config,
CompatibleType t,
PropertyType *)
{
@@ -5902,10 +6836,10 @@ void checkPropertyConsistency(cmTarget const* depender,
}
}
-static cmStdString intersect(const std::set<cmStdString> &s1,
- const std::set<cmStdString> &s2)
+static std::string intersect(const std::set<std::string> &s1,
+ const std::set<std::string> &s2)
{
- std::set<cmStdString> intersect;
+ std::set<std::string> intersect;
std::set_intersection(s1.begin(),s1.end(),
s2.begin(),s2.end(),
std::inserter(intersect,intersect.begin()));
@@ -5915,11 +6849,11 @@ static cmStdString intersect(const std::set<cmStdString> &s1,
}
return "";
}
-static cmStdString intersect(const std::set<cmStdString> &s1,
- const std::set<cmStdString> &s2,
- const std::set<cmStdString> &s3)
+static std::string intersect(const std::set<std::string> &s1,
+ const std::set<std::string> &s2,
+ const std::set<std::string> &s3)
{
- cmStdString result;
+ std::string result;
result = intersect(s1, s2);
if (!result.empty())
return result;
@@ -5928,12 +6862,12 @@ static cmStdString intersect(const std::set<cmStdString> &s1,
return result;
return intersect(s2, s3);
}
-static cmStdString intersect(const std::set<cmStdString> &s1,
- const std::set<cmStdString> &s2,
- const std::set<cmStdString> &s3,
- const std::set<cmStdString> &s4)
+static std::string intersect(const std::set<std::string> &s1,
+ const std::set<std::string> &s2,
+ const std::set<std::string> &s3,
+ const std::set<std::string> &s4)
{
- cmStdString result;
+ std::string result;
result = intersect(s1, s2);
if (!result.empty())
return result;
@@ -5948,14 +6882,14 @@ static cmStdString intersect(const std::set<cmStdString> &s1,
//----------------------------------------------------------------------------
void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
- const char* config) const
+ const std::string& config) const
{
const cmComputeLinkInformation::ItemVector &deps = info->GetItems();
- std::set<cmStdString> emittedBools;
- std::set<cmStdString> emittedStrings;
- std::set<cmStdString> emittedMinNumbers;
- std::set<cmStdString> emittedMaxNumbers;
+ std::set<std::string> emittedBools;
+ std::set<std::string> emittedStrings;
+ std::set<std::string> emittedMinNumbers;
+ std::set<std::string> emittedMaxNumbers;
for(cmComputeLinkInformation::ItemVector::const_iterator li =
deps.begin();
@@ -5967,32 +6901,32 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
}
checkPropertyConsistency<bool>(this, li->Target,
- "COMPATIBLE_INTERFACE_BOOL",
- emittedBools, config, BoolType, 0);
+ std::string("COMPATIBLE_INTERFACE_BOOL"),
+ emittedBools, config, BoolType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
- "COMPATIBLE_INTERFACE_STRING",
- emittedStrings, config,
- StringType, 0);
+ std::string("COMPATIBLE_INTERFACE_STRING"),
+ emittedStrings, config,
+ StringType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
- "COMPATIBLE_INTERFACE_NUMBER_MIN",
- emittedMinNumbers, config,
- NumberMinType, 0);
+ std::string("COMPATIBLE_INTERFACE_NUMBER_MIN"),
+ emittedMinNumbers, config,
+ NumberMinType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
}
checkPropertyConsistency<const char *>(this, li->Target,
- "COMPATIBLE_INTERFACE_NUMBER_MAX",
- emittedMaxNumbers, config,
- NumberMaxType, 0);
+ std::string("COMPATIBLE_INTERFACE_NUMBER_MAX"),
+ emittedMaxNumbers, config,
+ NumberMaxType, 0);
if (cmSystemTools::GetErrorOccuredFlag())
{
return;
@@ -6007,7 +6941,7 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
if (!prop.empty())
{
std::set<std::string> props;
- std::set<cmStdString>::const_iterator i = emittedBools.find(prop);
+ std::set<std::string>::const_iterator i = emittedBools.find(prop);
if (i != emittedBools.end())
{
props.insert("COMPATIBLE_INTERFACE_BOOL");
@@ -6052,12 +6986,12 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info,
//----------------------------------------------------------------------------
cmComputeLinkInformation*
-cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const
+cmTarget::GetLinkInformation(const std::string& config,
+ cmTarget const* head) const
{
cmTarget const* headTarget = head ? head : this;
// Lookup any existing information for this configuration.
- TargetConfigPair key(headTarget,
- cmSystemTools::UpperCase(config?config:""));
+ TargetConfigPair key(headTarget, cmSystemTools::UpperCase(config));
cmTargetLinkInformationMap::iterator
i = this->LinkInformation.find(key);
if(i == this->LinkInformation.end())
@@ -6084,7 +7018,7 @@ cmTarget::GetLinkInformation(const char* config, cmTarget const* head) const
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetFrameworkDirectory(const char* config,
+std::string cmTarget::GetFrameworkDirectory(const std::string& config,
bool rootDir) const
{
std::string fpath;
@@ -6099,7 +7033,7 @@ std::string cmTarget::GetFrameworkDirectory(const char* config,
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetCFBundleDirectory(const char* config,
+std::string cmTarget::GetCFBundleDirectory(const std::string& config,
bool contentOnly) const
{
std::string fpath;
@@ -6118,7 +7052,7 @@ std::string cmTarget::GetCFBundleDirectory(const char* config,
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetAppBundleDirectory(const char* config,
+std::string cmTarget::GetAppBundleDirectory(const std::string& config,
bool contentOnly) const
{
std::string fpath = this->GetFullName(config, false);
@@ -6130,7 +7064,7 @@ std::string cmTarget::GetAppBundleDirectory(const char* config,
//----------------------------------------------------------------------------
std::string cmTarget::BuildMacContentDirectory(const std::string& base,
- const char* config,
+ const std::string& config,
bool contentOnly) const
{
std::string fpath = base;
@@ -6150,7 +7084,7 @@ std::string cmTarget::BuildMacContentDirectory(const std::string& base,
}
//----------------------------------------------------------------------------
-std::string cmTarget::GetMacContentDirectory(const char* config,
+std::string cmTarget::GetMacContentDirectory(const std::string& config,
bool implib) const
{
// Start with the output directory for the target.
@@ -6211,7 +7145,9 @@ cmTargetInternalPointer::~cmTargetInternalPointer()
{
deleteAndClear(this->Pointer->IncludeDirectoriesEntries);
deleteAndClear(this->Pointer->CompileOptionsEntries);
+ deleteAndClear(this->Pointer->CompileFeaturesEntries);
deleteAndClear(this->Pointer->CompileDefinitionsEntries);
+ deleteAndClear(this->Pointer->SourceEntries);
delete this->Pointer;
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 0e9d682..4d8022e 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -30,7 +30,8 @@
F(CMP0038) \
F(CMP0041) \
F(CMP0042) \
- F(CMP0046)
+ F(CMP0046) \
+ F(CMP0052)
class cmake;
class cmMakefile;
@@ -96,17 +97,17 @@ public:
/**
* Set the target type
*/
- void SetType(TargetType f, const char* name);
+ void SetType(TargetType f, const std::string& name);
void MarkAsImported();
///! Set/Get the name of the target
- const char* GetName() const {return this->Name.c_str();}
- const char* GetExportName() const;
+ const std::string& GetName() const {return this->Name;}
+ std::string GetExportName() const;
///! Set the cmMakefile that owns this target
void SetMakefile(cmMakefile *mf);
- cmMakefile *GetMakefile() const { return this->Makefile;};
+ cmMakefile *GetMakefile() const { return this->Makefile;}
#define DECLARE_TARGET_POLICY(POLICY) \
cmPolicies::PolicyStatus GetPolicyStatus ## POLICY () const \
@@ -135,76 +136,48 @@ public:
/**
* Get the list of the source files used by this target
*/
- void GetSourceFiles(std::vector<cmSourceFile*> &files) const;
- void AddSourceFile(cmSourceFile* sf);
- std::vector<std::string> const& GetObjectLibraries() const
- {
- return this->ObjectLibraries;
- }
-
- /**
- * Flags for a given source file as used in this target. Typically assigned
- * via SET_TARGET_PROPERTIES when the property is a list of source files.
- */
- enum SourceFileType
- {
- SourceFileTypeNormal,
- SourceFileTypePrivateHeader, // is in "PRIVATE_HEADER" target property
- SourceFileTypePublicHeader, // is in "PUBLIC_HEADER" target property
- SourceFileTypeResource, // is in "RESOURCE" target property *or*
- // has MACOSX_PACKAGE_LOCATION=="Resources"
- SourceFileTypeMacContent // has MACOSX_PACKAGE_LOCATION!="Resources"
- };
- struct SourceFileFlags
- {
- SourceFileFlags(): Type(SourceFileTypeNormal), MacFolder(0) {}
- SourceFileFlags(SourceFileFlags const& r):
- Type(r.Type), MacFolder(r.MacFolder) {}
- SourceFileType Type;
- const char* MacFolder; // location inside Mac content folders
- };
-
- /**
- * Get the flags for a given source file as used in this target
- */
- struct SourceFileFlags
- GetTargetSourceFileFlags(const cmSourceFile* sf) const;
+ void GetSourceFiles(std::vector<cmSourceFile*> &files,
+ const std::string& config,
+ cmTarget const* head = 0) const;
+ bool GetConfigCommonSourceFiles(std::vector<cmSourceFile*>& files) const;
/**
* Add sources to the target.
*/
void AddSources(std::vector<std::string> const& srcs);
- cmSourceFile* AddSource(const char* src);
+ void AddTracedSources(std::vector<std::string> const& srcs);
+ cmSourceFile* AddSourceCMP0049(const std::string& src);
+ cmSourceFile* AddSource(const std::string& src);
enum LinkLibraryType {GENERAL, DEBUG, OPTIMIZED};
//* how we identify a library, by name and type
- typedef std::pair<cmStdString, LinkLibraryType> LibraryID;
+ typedef std::pair<std::string, LinkLibraryType> LibraryID;
typedef std::vector<LibraryID > LinkLibraryVectorType;
const LinkLibraryVectorType &GetLinkLibraries() const {
return this->LinkLibraries;}
const LinkLibraryVectorType &GetOriginalLinkLibraries() const
{return this->OriginalLinkLibraries;}
- void GetDirectLinkLibraries(const char *config,
+ void GetDirectLinkLibraries(const std::string& config,
std::vector<std::string> &,
cmTarget const* head) const;
- void GetInterfaceLinkLibraries(const char *config,
+ void GetInterfaceLinkLibraries(const std::string& config,
std::vector<std::string> &,
cmTarget const* head) const;
/** Compute the link type to use for the given configuration. */
- LinkLibraryType ComputeLinkType(const char* config) const;
+ LinkLibraryType ComputeLinkType(const std::string& config) const;
/**
* Clear the dependency information recorded for this target, if any.
*/
- void ClearDependencyInformation(cmMakefile& mf, const char* target);
+ void ClearDependencyInformation(cmMakefile& mf, const std::string& target);
// Check to see if a library is a framework and treat it different on Mac
bool NameResolvesToFramework(const std::string& libname) const;
void AddLinkLibrary(cmMakefile& mf,
- const char *target, const char* lib,
+ const std::string& target, const std::string& lib,
LinkLibraryType llt);
enum TLLSignature {
KeywordTLLSignature,
@@ -213,12 +186,12 @@ public:
bool PushTLLCommandTrace(TLLSignature signature);
void GetTllSignatureTraces(cmOStringStream &s, TLLSignature sig) const;
- void MergeLinkLibraries( cmMakefile& mf, const char* selfname,
+ void MergeLinkLibraries( cmMakefile& mf, const std::string& selfname,
const LinkLibraryVectorType& libs );
const std::vector<std::string>& GetLinkDirectories() const;
- void AddLinkDirectory(const char* d);
+ void AddLinkDirectory(const std::string& d);
/**
* Set the path where this target should be installed. This is relative to
@@ -245,26 +218,31 @@ public:
* name as would be specified to the ADD_EXECUTABLE or UTILITY_SOURCE
* commands. It is not a full path nor does it have an extension.
*/
- void AddUtility(const char* u, cmMakefile *makefile = 0);
+ void AddUtility(const std::string& u, cmMakefile *makefile = 0);
///! Get the utilities used by this target
- std::set<cmStdString>const& GetUtilities() const { return this->Utilities; }
- cmListFileBacktrace const* GetUtilityBacktrace(const char* u) const;
+ std::set<std::string>const& GetUtilities() const { return this->Utilities; }
+ cmListFileBacktrace const* GetUtilityBacktrace(const std::string& u) const;
/** Finalize the target at the end of the Configure step. */
void FinishConfigure();
///! Set/Get a property of this target file
- void SetProperty(const char *prop, const char *value);
- void AppendProperty(const char* prop, const char* value,bool asString=false);
- const char *GetProperty(const char *prop) const;
- const char *GetProperty(const char *prop, cmProperty::ScopeType scope) const;
- bool GetPropertyAsBool(const char *prop) const;
- void CheckProperty(const char* prop, cmMakefile* context) const;
-
- const char* GetFeature(const char* feature, const char* config) const;
+ void SetProperty(const std::string& prop, const char *value);
+ void AppendProperty(const std::string& prop, const char* value,
+ bool asString=false);
+ const char *GetProperty(const std::string& prop) const;
+ const char *GetProperty(const std::string& prop,
+ cmProperty::ScopeType scope) const;
+ bool GetPropertyAsBool(const std::string& prop) const;
+ void CheckProperty(const std::string& prop, cmMakefile* context) const;
+
+ const char* GetFeature(const std::string& feature,
+ const std::string& config) const;
bool IsImported() const {return this->IsImportedTarget;}
+ void GetObjectLibrariesCMP0026(std::vector<cmTarget*>& objlibs) const;
+
/** The link interface specifies transitive library dependencies and
other information needed by targets that link to this target. */
struct LinkInterface
@@ -293,11 +271,16 @@ public:
/** Get the link interface for the given configuration. Returns 0
if the target cannot be linked. */
- LinkInterface const* GetLinkInterface(const char* config,
+ LinkInterface const* GetLinkInterface(const std::string& config,
cmTarget const* headTarget) const;
- void GetTransitivePropertyLinkLibraries(const char* config,
+ LinkInterface const* GetLinkInterfaceLibraries(const std::string& config,
+ cmTarget const* headTarget) const;
+ void GetTransitivePropertyTargets(const std::string& config,
+ cmTarget const* headTarget,
+ std::vector<cmTarget*> &libs) const;
+ void GetTransitiveTargetClosure(const std::string& config,
cmTarget const* headTarget,
- std::vector<std::string> &libs) const;
+ std::vector<cmTarget*> &libs) const;
/** The link implementation specifies the direct library
dependencies needed by the object files of the target. */
@@ -313,7 +296,11 @@ public:
// Needed only for OLD behavior of CMP0003.
std::vector<std::string> WrongConfigLibraries;
};
- LinkImplementation const* GetLinkImplementation(const char* config,
+ LinkImplementation const* GetLinkImplementation(const std::string& config,
+ cmTarget const* head) const;
+
+ LinkImplementation const* GetLinkImplementationLibraries(
+ const std::string& config,
cmTarget const* head) const;
/** Link information from the transitive closure of the link
@@ -326,7 +313,7 @@ public:
// Languages whose runtime libraries must be linked.
std::vector<std::string> Languages;
};
- LinkClosure const* GetLinkClosure(const char* config,
+ LinkClosure const* GetLinkClosure(const std::string& config,
cmTarget const* head) const;
/** Strip off leading and trailing whitespace from an item named in
@@ -337,18 +324,29 @@ public:
configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical
output directory is given. */
- std::string GetDirectory(const char* config = 0, bool implib = false) const;
+ std::string GetDirectory(const std::string& config = "",
+ bool implib = false) const;
/** Get the directory in which this targets .pdb files will be placed.
If the configuration name is given then the generator will add its
subdirectory for that configuration. Otherwise just the canonical
pdb output directory is given. */
- std::string GetPDBDirectory(const char* config = 0) const;
+ std::string GetPDBDirectory(const std::string& config) const;
+
+ /** Get the directory in which to place the target compiler .pdb file.
+ If the configuration name is given then the generator will add its
+ subdirectory for that configuration. Otherwise just the canonical
+ compiler pdb output directory is given. */
+ std::string GetCompilePDBDirectory(const std::string& config = "") const;
/** Get the location of the target in the build tree for the given
- configuration. This location is suitable for use as the LOCATION
- target property. */
- const char* GetLocation(const char* config) const;
+ configuration. */
+ const char* GetLocation(const std::string& config) const;
+
+ /** Get the location of the target in the build tree with a placeholder
+ referencing the configuration in the native build system. This
+ location is suitable for use as the LOCATION target property. */
+ const char* GetLocationForBuild() const;
/** Get the target major and minor version numbers interpreted from
the VERSION property. Version 0 is returned if the property is
@@ -361,44 +359,47 @@ public:
void
GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const;
- /**
- * Make sure the full path to all source files is known.
- */
- bool FindSourceFiles();
-
///! Return the preferred linker language for this target
- const char* GetLinkerLanguage(const char* config = 0,
+ std::string GetLinkerLanguage(const std::string& config = "",
cmTarget const* head = 0) const;
/** Get the full name of the target according to the settings in its
makefile. */
- std::string GetFullName(const char* config=0, bool implib = false) const;
+ std::string GetFullName(const std::string& config="",
+ bool implib = false) const;
void GetFullNameComponents(std::string& prefix,
std::string& base, std::string& suffix,
- const char* config=0, bool implib = false) const;
+ const std::string& config="",
+ bool implib = false) const;
/** Get the name of the pdb file for the target. */
- std::string GetPDBName(const char* config=0) const;
+ std::string GetPDBName(const std::string& config) const;
+
+ /** Get the name of the compiler pdb file for the target. */
+ std::string GetCompilePDBName(const std::string& config="") const;
+
+ /** Get the path for the MSVC /Fd option for this target. */
+ std::string GetCompilePDBPath(const std::string& config="") const;
/** Whether this library has soname enabled and platform supports it. */
- bool HasSOName(const char* config) const;
+ bool HasSOName(const std::string& config) const;
/** Get the soname of the target. Allowed only for a shared library. */
- std::string GetSOName(const char* config) const;
+ std::string GetSOName(const std::string& config) const;
/** Whether this library has \@rpath and platform supports it. */
- bool HasMacOSXRpathInstallNameDir(const char* config) const;
+ bool HasMacOSXRpathInstallNameDir(const std::string& config) const;
/** Whether this library defaults to \@rpath. */
bool MacOSXRpathInstallNameDirDefault() const;
/** Test for special case of a third-party shared library that has
no soname at all. */
- bool IsImportedSharedLibWithoutSOName(const char* config) const;
+ bool IsImportedSharedLibWithoutSOName(const std::string& config) const;
/** Get the full path to the target according to the settings in its
makefile and the configuration type. */
- std::string GetFullPath(const char* config=0, bool implib = false,
+ std::string GetFullPath(const std::string& config="", bool implib = false,
bool realname = false) const;
/** Get the names of the library needed to generate a build rule
@@ -406,14 +407,15 @@ public:
should be called only on a library target. */
void GetLibraryNames(std::string& name, std::string& soName,
std::string& realName, std::string& impName,
- std::string& pdbName, const char* config) const;
+ std::string& pdbName, const std::string& config) const;
/** Get the names of the executable needed to generate a build rule
that takes into account executable version numbers. This should
be called only on an executable target. */
void GetExecutableNames(std::string& name, std::string& realName,
std::string& impName,
- std::string& pdbName, const char* config) const;
+ std::string& pdbName,
+ const std::string& config) const;
/** Does this target have a GNU implib to convert to MS format? */
bool HasImplibGNUtoMS() const;
@@ -426,28 +428,28 @@ public:
/**
* Compute whether this target must be relinked before installing.
*/
- bool NeedRelinkBeforeInstall(const char* config) const;
+ bool NeedRelinkBeforeInstall(const std::string& config) const;
- bool HaveBuildTreeRPATH(const char *config) const;
+ bool HaveBuildTreeRPATH(const std::string& config) const;
bool HaveInstallTreeRPATH() const;
/** Return true if builtin chrpath will work for this target */
- bool IsChrpathUsed(const char* config) const;
+ bool IsChrpathUsed(const std::string& config) const;
/** Return the install name directory for the target in the
* build tree. For example: "\@rpath/", "\@loader_path/",
* or "/full/path/to/library". */
- std::string GetInstallNameDirForBuildTree(const char* config) const;
+ std::string GetInstallNameDirForBuildTree(const std::string& config) const;
/** Return the install name directory for the target in the
* install tree. For example: "\@rpath/" or "\@loader_path/". */
std::string GetInstallNameDirForInstallTree() const;
- cmComputeLinkInformation* GetLinkInformation(const char* config,
+ cmComputeLinkInformation* GetLinkInformation(const std::string& config,
cmTarget const* head = 0) const;
// Get the properties
- cmPropertyMap &GetProperties() const { return this->Properties; };
+ cmPropertyMap &GetProperties() const { return this->Properties; }
bool GetMappedConfig(std::string const& desired_config,
const char** loc,
@@ -462,14 +464,16 @@ public:
const char* GetExportMacro() const;
void GetCompileDefinitions(std::vector<std::string> &result,
- const char *config) const;
+ const std::string& config) const;
// Compute the set of languages compiled by the target. This is
// computed every time it is called because the languages can change
// when source file properties are changed and we do not have enough
// information to forward these property changes to the targets
// until we have per-target object file properties.
- void GetLanguages(std::set<cmStdString>& languages) const;
+ void GetLanguages(std::set<std::string>& languages,
+ std::string const& config,
+ cmTarget const* head = 0) const;
/** Return whether this target is an executable with symbol exports
enabled. */
@@ -510,26 +514,29 @@ public:
/** Return whether this target uses the default value for its output
directory. */
- bool UsesDefaultOutputDir(const char* config, bool implib) const;
+ bool UsesDefaultOutputDir(const std::string& config, bool implib) const;
/** @return the mac content directory for this target. */
- std::string GetMacContentDirectory(const char* config,
+ std::string GetMacContentDirectory(const std::string& config,
bool implib) const;
/** @return whether this target have a well defined output file name. */
bool HaveWellDefinedOutputFiles() const;
/** @return the Mac framework directory without the base. */
- std::string GetFrameworkDirectory(const char* config, bool rootDir) const;
+ std::string GetFrameworkDirectory(const std::string& config,
+ bool rootDir) const;
/** @return the Mac CFBundle directory without the base */
- std::string GetCFBundleDirectory(const char* config, bool contentOnly) const;
+ std::string GetCFBundleDirectory(const std::string& config,
+ bool contentOnly) const;
/** @return the Mac App directory without the base */
- std::string GetAppBundleDirectory(const char* config,
+ std::string GetAppBundleDirectory(const std::string& config,
bool contentOnly) const;
- std::vector<std::string> GetIncludeDirectories(const char *config) const;
+ std::vector<std::string> GetIncludeDirectories(
+ const std::string& config) const;
void InsertInclude(const cmValueWithOrigin &entry,
bool before = false);
void InsertCompileOption(const cmValueWithOrigin &entry,
@@ -539,36 +546,38 @@ public:
void AppendBuildInterfaceIncludes();
void GetCompileOptions(std::vector<std::string> &result,
- const char *config) const;
+ const std::string& config) const;
void GetAutoUicOptions(std::vector<std::string> &result,
- const char *config) const;
+ const std::string& config) const;
+ void GetCompileFeatures(std::vector<std::string> &features,
+ const std::string& config) const;
bool IsNullImpliedByLinkLibraries(const std::string &p) const;
bool IsLinkInterfaceDependentBoolProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
bool IsLinkInterfaceDependentStringProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
bool GetLinkInterfaceDependentBoolProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
const char *GetLinkInterfaceDependentStringProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p,
- const char *config) const;
+ const std::string& config) const;
std::string GetDebugGeneratorExpressions(const std::string &value,
cmTarget::LinkLibraryType llt) const;
- void AddSystemIncludeDirectories(const std::set<cmStdString> &incs);
+ void AddSystemIncludeDirectories(const std::set<std::string> &incs);
void AddSystemIncludeDirectories(const std::vector<std::string> &incs);
- std::set<cmStdString> const & GetSystemIncludeDirectories() const
+ std::set<std::string> const & GetSystemIncludeDirectories() const
{ return this->SystemIncludeDirectories; }
bool LinkLanguagePropagatesToDependents() const
@@ -584,7 +593,7 @@ private:
// The set of include directories that are marked as system include
// directories.
- std::set<cmStdString> SystemIncludeDirectories;
+ std::set<std::string> SystemIncludeDirectories;
std::vector<std::pair<TLLSignature, cmListFileBacktrace> > TLLCommands;
@@ -641,60 +650,62 @@ private:
const char* GetSuffixVariableInternal(bool implib) const;
const char* GetPrefixVariableInternal(bool implib) const;
- std::string GetFullNameInternal(const char* config, bool implib) const;
- void GetFullNameInternal(const char* config, bool implib,
+ std::string GetFullNameInternal(const std::string& config,
+ bool implib) const;
+ void GetFullNameInternal(const std::string& config, bool implib,
std::string& outPrefix, std::string& outBase,
std::string& outSuffix) const;
// Use a makefile variable to set a default for the given property.
// If the variable is not defined use the given default instead.
- void SetPropertyDefault(const char* property, const char* default_value);
+ void SetPropertyDefault(const std::string& property,
+ const char* default_value);
// Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type.
const char* GetOutputTargetType(bool implib) const;
// Get the target base name.
- std::string GetOutputName(const char* config, bool implib) const;
-
- const char* ImportedGetLocation(const char* config) const;
- const char* NormalGetLocation(const char* config) const;
+ std::string GetOutputName(const std::string& config, bool implib) const;
- std::string GetFullNameImported(const char* config, bool implib) const;
+ std::string GetFullNameImported(const std::string& config,
+ bool implib) const;
- std::string ImportedGetFullPath(const char* config, bool implib) const;
- std::string NormalGetFullPath(const char* config, bool implib,
+ std::string ImportedGetFullPath(const std::string& config,
+ bool implib) const;
+ std::string NormalGetFullPath(const std::string& config, bool implib,
bool realname) const;
/** Get the real name of the target. Allowed only for non-imported
targets. When a library or executable file is versioned this is
the full versioned name. If the target is not versioned this is
the same as GetFullName. */
- std::string NormalGetRealName(const char* config) const;
+ std::string NormalGetRealName(const std::string& config) const;
/** Append to @a base the mac content directory and return it. */
std::string BuildMacContentDirectory(const std::string& base,
- const char* config,
+ const std::string& config,
bool contentOnly) const;
+ void GetSourceFiles(std::vector<std::string> &files,
+ const std::string& config,
+ cmTarget const* head = 0) const;
private:
std::string Name;
std::vector<cmCustomCommand> PreBuildCommands;
std::vector<cmCustomCommand> PreLinkCommands;
std::vector<cmCustomCommand> PostBuildCommands;
TargetType TargetTypeValue;
- std::vector<cmSourceFile*> SourceFiles;
- std::vector<std::string> ObjectLibraries;
LinkLibraryVectorType LinkLibraries;
LinkLibraryVectorType PrevLinkedLibraries;
bool LinkLibrariesAnalyzed;
std::vector<std::string> LinkDirectories;
- std::set<cmStdString> LinkDirectoriesEmmitted;
+ std::set<std::string> LinkDirectoriesEmmitted;
bool HaveInstallRule;
std::string InstallPath;
std::string RuntimeInstallPath;
mutable std::string ExportMacro;
- std::set<cmStdString> Utilities;
- std::map<cmStdString, cmListFileBacktrace> UtilityBacktraces;
+ std::set<std::string> Utilities;
+ std::map<std::string, cmListFileBacktrace> UtilityBacktraces;
bool RecordDependencies;
mutable cmPropertyMap Properties;
LinkLibraryVectorType OriginalLinkLibraries;
@@ -705,39 +716,54 @@ private:
mutable std::map<std::string, bool> DebugCompatiblePropertiesDone;
mutable bool DebugCompileOptionsDone;
mutable bool DebugCompileDefinitionsDone;
+ mutable bool DebugSourcesDone;
+ mutable bool DebugCompileFeaturesDone;
mutable std::set<std::string> LinkImplicitNullProperties;
bool BuildInterfaceIncludesAppended;
// Cache target output paths for each configuration.
struct OutputInfo;
- OutputInfo const* GetOutputInfo(const char* config) const;
+ OutputInfo const* GetOutputInfo(const std::string& config) const;
bool
- ComputeOutputDir(const char* config, bool implib, std::string& out) const;
- bool ComputePDBOutputDir(const char* config, std::string& out) const;
+ ComputeOutputDir(const std::string& config,
+ bool implib, std::string& out) const;
+ bool ComputePDBOutputDir(const std::string& kind, const std::string& config,
+ std::string& out) const;
// Cache import information from properties for each configuration.
struct ImportInfo;
- ImportInfo const* GetImportInfo(const char* config,
+ ImportInfo const* GetImportInfo(const std::string& config,
cmTarget const* workingTarget) const;
void ComputeImportInfo(std::string const& desired_config, ImportInfo& info,
cmTarget const* head) const;
+ // Cache target compile paths for each configuration.
+ struct CompileInfo;
+ CompileInfo const* GetCompileInfo(const std::string& config) const;
+
mutable cmTargetLinkInformationMap LinkInformation;
void CheckPropertyCompatibility(cmComputeLinkInformation *info,
- const char* config) const;
+ const std::string& config) const;
- bool ComputeLinkInterface(const char* config, LinkInterface& iface,
- cmTarget const* head) const;
+ const char* ComputeLinkInterfaceLibraries(const std::string& config,
+ LinkInterface& iface,
+ cmTarget const* head,
+ bool &exists) const;
- void ComputeLinkImplementation(const char* config,
+ void ComputeLinkImplementation(const std::string& config,
LinkImplementation& impl,
cmTarget const* head) const;
- void ComputeLinkClosure(const char* config, LinkClosure& lc,
+ void ComputeLinkImplementationLanguages(const std::string& config,
+ LinkImplementation& impl,
+ cmTarget const* head) const;
+ void ComputeLinkClosure(const std::string& config, LinkClosure& lc,
cmTarget const* head) const;
+ std::string ProcessSourceItemCMP0049(const std::string& s);
+
void ClearLinkMaps();
- void MaybeInvalidatePropertyCache(const char* prop);
+ void MaybeInvalidatePropertyCache(const std::string& prop);
void ProcessSourceExpression(std::string const& expr);
@@ -759,18 +785,19 @@ private:
friend class cmTargetTraceDependencies;
cmTargetInternalPointer Internal;
- void ConstructSourceFileFlags() const;
void ComputeVersionedName(std::string& vName,
std::string const& prefix,
std::string const& base,
std::string const& suffix,
std::string const& name,
const char* version) const;
+
+ mutable bool LinkImplementationLanguageIsContextDependent;
};
-typedef std::map<cmStdString,cmTarget> cmTargets;
+typedef std::map<std::string,cmTarget> cmTargets;
-class cmTargetSet: public std::set<cmStdString> {};
-class cmTargetManifest: public std::map<cmStdString, cmTargetSet> {};
+class cmTargetSet: public std::set<std::string> {};
+class cmTargetManifest: public std::map<std::string, cmTargetSet> {};
#endif
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index b567252..66d8ad3 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -58,9 +58,10 @@ std::string cmTargetCompileDefinitionsCommand
}
//----------------------------------------------------------------------------
-void cmTargetCompileDefinitionsCommand
+bool cmTargetCompileDefinitionsCommand
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool, bool)
{
tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
+ return true;
}
diff --git a/Source/cmTargetCompileDefinitionsCommand.h b/Source/cmTargetCompileDefinitionsCommand.h
index 7405e90..b548c70 100644
--- a/Source/cmTargetCompileDefinitionsCommand.h
+++ b/Source/cmTargetCompileDefinitionsCommand.h
@@ -36,7 +36,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "target_compile_definitions";}
+ virtual std::string GetName() const { return "target_compile_definitions";}
cmTypeMacro(cmTargetCompileDefinitionsCommand, cmTargetPropCommandBase);
@@ -44,7 +44,7 @@ private:
virtual void HandleImportedTarget(const std::string &tgt);
virtual void HandleMissingTarget(const std::string &name);
- virtual void HandleDirectContent(cmTarget *tgt,
+ virtual bool HandleDirectContent(cmTarget *tgt,
const std::vector<std::string> &content,
bool prepend, bool system);
virtual std::string Join(const std::vector<std::string> &content);
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
new file mode 100644
index 0000000..10daad4
--- /dev/null
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -0,0 +1,70 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2013 Stephen Kelly <steveire@gmail.com>
+
+ 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 "cmTargetCompileFeaturesCommand.h"
+
+bool cmTargetCompileFeaturesCommand::InitialPass(
+ std::vector<std::string> const& args,
+ cmExecutionStatus &)
+{
+ return this->HandleArguments(args, "COMPILE_FEATURES", NO_FLAGS);
+}
+
+void cmTargetCompileFeaturesCommand
+::HandleImportedTarget(const std::string &tgt)
+{
+ cmOStringStream e;
+ e << "Cannot specify compile features for imported target \""
+ << tgt << "\".";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+void cmTargetCompileFeaturesCommand
+::HandleMissingTarget(const std::string &name)
+{
+ cmOStringStream e;
+ e << "Cannot specify compile features for target \"" << name << "\" "
+ "which is not built by this project.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+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;
+}
+
+//----------------------------------------------------------------------------
+bool cmTargetCompileFeaturesCommand
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
+ bool, bool)
+{
+ for(std::vector<std::string>::const_iterator it = content.begin();
+ it != content.end(); ++it)
+ {
+ std::string error;
+ if(!this->Makefile->AddRequiredTargetFeature(tgt, *it, &error))
+ {
+ this->SetError(error);
+ return false;
+ }
+ }
+ return true;
+}
diff --git a/Source/cmTargetCompileFeaturesCommand.h b/Source/cmTargetCompileFeaturesCommand.h
new file mode 100644
index 0000000..fa7ae8d
--- /dev/null
+++ b/Source/cmTargetCompileFeaturesCommand.h
@@ -0,0 +1,41 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2013 Stephen Kelly <steveire@gmail.com>
+
+ 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 cmTargetCompileFeaturesCommand_h
+#define cmTargetCompileFeaturesCommand_h
+
+#include "cmTargetPropCommandBase.h"
+
+class cmTargetCompileFeaturesCommand : public cmTargetPropCommandBase
+{
+ virtual cmCommand* Clone()
+ {
+ return new cmTargetCompileFeaturesCommand;
+ }
+
+ virtual bool InitialPass(std::vector<std::string> const& args,
+ cmExecutionStatus &status);
+
+ virtual std::string GetName() const { return "target_compile_features";}
+
+ cmTypeMacro(cmTargetCompileFeaturesCommand, cmTargetPropCommandBase);
+
+private:
+ virtual void HandleImportedTarget(const std::string &tgt);
+ virtual void HandleMissingTarget(const std::string &name);
+
+ virtual bool HandleDirectContent(cmTarget *tgt,
+ const std::vector<std::string> &content,
+ bool prepend, bool system);
+ virtual std::string Join(const std::vector<std::string> &content);
+};
+
+#endif
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 254acc7..18499fd 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -51,7 +51,7 @@ std::string cmTargetCompileOptionsCommand
}
//----------------------------------------------------------------------------
-void cmTargetCompileOptionsCommand
+bool cmTargetCompileOptionsCommand
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool, bool)
{
@@ -59,4 +59,5 @@ void cmTargetCompileOptionsCommand
this->Makefile->GetBacktrace(lfbt);
cmValueWithOrigin entry(this->Join(content), lfbt);
tgt->InsertCompileOption(entry);
+ return true;
}
diff --git a/Source/cmTargetCompileOptionsCommand.h b/Source/cmTargetCompileOptionsCommand.h
index 3713e5a..d43534d 100644
--- a/Source/cmTargetCompileOptionsCommand.h
+++ b/Source/cmTargetCompileOptionsCommand.h
@@ -36,7 +36,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "target_compile_options";}
+ virtual std::string GetName() const { return "target_compile_options";}
cmTypeMacro(cmTargetCompileOptionsCommand, cmTargetPropCommandBase);
@@ -44,7 +44,7 @@ private:
virtual void HandleImportedTarget(const std::string &tgt);
virtual void HandleMissingTarget(const std::string &name);
- virtual void HandleDirectContent(cmTarget *tgt,
+ virtual bool HandleDirectContent(cmTarget *tgt,
const std::vector<std::string> &content,
bool prepend, bool system);
virtual std::string Join(const std::vector<std::string> &content);
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index f8e1188..caec7eb 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -66,7 +66,7 @@ std::string cmTargetIncludeDirectoriesCommand
}
//----------------------------------------------------------------------------
-void cmTargetIncludeDirectoriesCommand
+bool cmTargetIncludeDirectoriesCommand
::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
bool prepend, bool system)
{
@@ -78,6 +78,7 @@ void cmTargetIncludeDirectoriesCommand
{
tgt->AddSystemIncludeDirectories(content);
}
+ return true;
}
//----------------------------------------------------------------------------
diff --git a/Source/cmTargetIncludeDirectoriesCommand.h b/Source/cmTargetIncludeDirectoriesCommand.h
index 6863ee5..2a7814e 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.h
+++ b/Source/cmTargetIncludeDirectoriesCommand.h
@@ -37,7 +37,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "target_include_directories";}
+ virtual std::string GetName() const { return "target_include_directories";}
cmTypeMacro(cmTargetIncludeDirectoriesCommand, cmTargetPropCommandBase);
@@ -45,7 +45,7 @@ private:
virtual void HandleImportedTarget(const std::string &tgt);
virtual void HandleMissingTarget(const std::string &name);
- virtual void HandleDirectContent(cmTarget *tgt,
+ virtual bool HandleDirectContent(cmTarget *tgt,
const std::vector<std::string> &content,
bool prepend, bool system);
virtual void HandleInterfaceContent(cmTarget *tgt,
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 95a2cba..56e1338 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -39,7 +39,7 @@ bool cmTargetLinkLibrariesCommand
// Lookup the target for which libraries are specified.
this->Target =
this->Makefile->GetCMakeInstance()
- ->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
+ ->GetGlobalGenerator()->FindTarget(args[0]);
if(!this->Target)
{
cmake::MessageType t = cmake::FATAL_ERROR; // fail by default
@@ -70,7 +70,6 @@ bool cmTargetLinkLibrariesCommand
GetRequiredPolicyError(cmPolicies::CMP0016);
break;
case cmPolicies::NEW: // NEW behavior prints the error.
- default:
break;
}
}
@@ -125,7 +124,7 @@ bool cmTargetLinkLibrariesCommand
e <<
"Utility target \"" << this->Target->GetName() << "\" " << modal
<< " not be used as the target of a target_link_libraries call.";
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if(messageType == cmake::FATAL_ERROR)
{
return false;
@@ -273,7 +272,7 @@ bool cmTargetLinkLibrariesCommand
{
// The link type was specified by the previous argument.
haveLLT = false;
- if (!this->HandleLibrary(args[i].c_str(), llt))
+ if (!this->HandleLibrary(args[i], llt))
{
return false;
}
@@ -290,7 +289,7 @@ bool cmTargetLinkLibrariesCommand
std::string linkType = args[0];
linkType += "_LINK_TYPE";
const char* linkTypeString =
- this->Makefile->GetDefinition( linkType.c_str() );
+ this->Makefile->GetDefinition( linkType );
if(linkTypeString)
{
if(strcmp(linkTypeString, "debug") == 0)
@@ -302,7 +301,7 @@ bool cmTargetLinkLibrariesCommand
llt = cmTarget::OPTIMIZED;
}
}
- if (!this->HandleLibrary(args[i].c_str(), llt))
+ if (!this->HandleLibrary(args[i], llt))
{
return false;
}
@@ -353,7 +352,7 @@ cmTargetLinkLibrariesCommand
//----------------------------------------------------------------------------
bool
-cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
+cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
cmTarget::LinkLibraryType llt)
{
if(this->Target->GetType() == cmTarget::INTERFACE_LIBRARY
@@ -409,7 +408,7 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
sig == cmTarget::KeywordTLLSignature
? cmTarget::PlainTLLSignature
: cmTarget::KeywordTLLSignature);
- this->Makefile->IssueMessage(messageType, e.str().c_str());
+ this->Makefile->IssueMessage(messageType, e.str());
if(messageType == cmake::FATAL_ERROR)
{
return false;
@@ -481,13 +480,13 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
{
prop = "LINK_INTERFACE_LIBRARIES_";
prop += *i;
- this->Target->AppendProperty(prop.c_str(), lib);
+ this->Target->AppendProperty(prop, lib.c_str());
}
}
if(llt == cmTarget::OPTIMIZED || llt == cmTarget::GENERAL)
{
// Put in the non-DEBUG configuration interfaces.
- this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib);
+ this->Target->AppendProperty("LINK_INTERFACE_LIBRARIES", lib.c_str());
// Make sure the DEBUG configuration interfaces exist so that the
// general one will not be used as a fall-back.
@@ -496,9 +495,9 @@ cmTargetLinkLibrariesCommand::HandleLibrary(const char* lib,
{
prop = "LINK_INTERFACE_LIBRARIES_";
prop += *i;
- if(!this->Target->GetProperty(prop.c_str()))
+ if(!this->Target->GetProperty(prop))
{
- this->Target->SetProperty(prop.c_str(), "");
+ this->Target->SetProperty(prop, "");
}
}
}
diff --git a/Source/cmTargetLinkLibrariesCommand.h b/Source/cmTargetLinkLibrariesCommand.h
index 6fbf722..47dd8bd 100644
--- a/Source/cmTargetLinkLibrariesCommand.h
+++ b/Source/cmTargetLinkLibrariesCommand.h
@@ -42,7 +42,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "target_link_libraries";}
+ virtual std::string GetName() const { return "target_link_libraries";}
cmTypeMacro(cmTargetLinkLibrariesCommand, cmCommand);
private:
@@ -62,7 +62,7 @@ private:
ProcessingState CurrentProcessingState;
- bool HandleLibrary(const char* lib, cmTarget::LinkLibraryType llt);
+ bool HandleLibrary(const std::string& lib, cmTarget::LinkLibraryType llt);
};
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 195690e..4696de4 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -16,8 +16,9 @@
//----------------------------------------------------------------------------
bool cmTargetPropCommandBase
-::HandleArguments(std::vector<std::string> const& args, const char *prop,
- ArgumentFlags flags)
+::HandleArguments(std::vector<std::string> const& args,
+ const std::string& prop,
+ ArgumentFlags flags)
{
if(args.size() < 2)
{
@@ -33,7 +34,7 @@ bool cmTargetPropCommandBase
}
this->Target =
this->Makefile->GetCMakeInstance()
- ->GetGlobalGenerator()->FindTarget(0, args[0].c_str());
+ ->GetGlobalGenerator()->FindTarget(args[0]);
if(!this->Target)
{
this->Target = this->Makefile->FindTargetToUse(args[0]);
@@ -131,29 +132,31 @@ bool cmTargetPropCommandBase
|| args[i] == "PRIVATE"
|| args[i] == "INTERFACE" )
{
- this->PopulateTargetProperies(scope, content, prepend, system);
- return true;
+ return this->PopulateTargetProperies(scope, content, prepend, system);
}
content.push_back(args[i]);
}
- this->PopulateTargetProperies(scope, content, prepend, system);
- return true;
+ return this->PopulateTargetProperies(scope, content, prepend, system);
}
//----------------------------------------------------------------------------
-void cmTargetPropCommandBase
+bool cmTargetPropCommandBase
::PopulateTargetProperies(const std::string &scope,
const std::vector<std::string> &content,
bool prepend, bool system)
{
if (scope == "PRIVATE" || scope == "PUBLIC")
{
- this->HandleDirectContent(this->Target, content, prepend, system);
+ if (!this->HandleDirectContent(this->Target, content, prepend, system))
+ {
+ return false;
+ }
}
if (scope == "INTERFACE" || scope == "PUBLIC")
{
this->HandleInterfaceContent(this->Target, content, prepend, system);
}
+ return true;
}
//----------------------------------------------------------------------------
@@ -164,15 +167,15 @@ void cmTargetPropCommandBase::HandleInterfaceContent(cmTarget *tgt,
if (prepend)
{
const std::string propName = std::string("INTERFACE_") + this->Property;
- const char *propValue = tgt->GetProperty(propName.c_str());
+ const char *propValue = tgt->GetProperty(propName);
const std::string totalContent = this->Join(content) + (propValue
? std::string(";") + propValue
: std::string());
- tgt->SetProperty(propName.c_str(), totalContent.c_str());
+ tgt->SetProperty(propName, totalContent.c_str());
}
else
{
- tgt->AppendProperty(("INTERFACE_" + this->Property).c_str(),
+ tgt->AppendProperty("INTERFACE_" + this->Property,
this->Join(content).c_str());
}
}
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index c402836..d42b588 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -29,7 +29,8 @@ public:
};
bool HandleArguments(std::vector<std::string> const& args,
- const char *prop, ArgumentFlags flags = NO_FLAGS);
+ const std::string& prop,
+ ArgumentFlags flags = NO_FLAGS);
cmTypeMacro(cmTargetPropCommandBase, cmCommand);
protected:
@@ -43,7 +44,7 @@ private:
virtual void HandleImportedTarget(const std::string &tgt) = 0;
virtual void HandleMissingTarget(const std::string &name) = 0;
- virtual void HandleDirectContent(cmTarget *tgt,
+ virtual bool HandleDirectContent(cmTarget *tgt,
const std::vector<std::string> &content,
bool prepend, bool system) = 0;
@@ -51,7 +52,7 @@ private:
bool ProcessContentArgs(std::vector<std::string> const& args,
unsigned int &argIndex, bool prepend, bool system);
- void PopulateTargetProperies(const std::string &scope,
+ bool PopulateTargetProperies(const std::string &scope,
const std::vector<std::string> &content,
bool prepend, bool system);
};
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
new file mode 100644
index 0000000..ce3b11e
--- /dev/null
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -0,0 +1,65 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Stephen Kelly <steveire@gmail.com>
+
+ 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 "cmTargetSourcesCommand.h"
+
+#include "cmGeneratorExpression.h"
+
+//----------------------------------------------------------------------------
+bool cmTargetSourcesCommand
+::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
+{
+ return this->HandleArguments(args, "SOURCES");
+}
+
+//----------------------------------------------------------------------------
+void cmTargetSourcesCommand
+::HandleImportedTarget(const std::string &tgt)
+{
+ cmOStringStream e;
+ e << "Cannot specify sources for imported target \""
+ << tgt << "\".";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+void cmTargetSourcesCommand
+::HandleMissingTarget(const std::string &name)
+{
+ cmOStringStream e;
+ e << "Cannot specify sources for target \"" << name << "\" "
+ "which is not built by this project.";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+}
+
+//----------------------------------------------------------------------------
+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;
+}
+
+//----------------------------------------------------------------------------
+bool cmTargetSourcesCommand
+::HandleDirectContent(cmTarget *tgt, const std::vector<std::string> &content,
+ bool, bool)
+{
+ tgt->AppendProperty("SOURCES", this->Join(content).c_str());
+ return true;
+}
diff --git a/Source/cmTargetSourcesCommand.h b/Source/cmTargetSourcesCommand.h
new file mode 100644
index 0000000..a170e36
--- /dev/null
+++ b/Source/cmTargetSourcesCommand.h
@@ -0,0 +1,55 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2014 Stephen Kelly <steveire@gmail.com>
+
+ 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 cmTargetSourcesCommand_h
+#define cmTargetSourcesCommand_h
+
+#include "cmTargetPropCommandBase.h"
+
+//----------------------------------------------------------------------------
+class cmTargetSourcesCommand : public cmTargetPropCommandBase
+{
+public:
+ /**
+ * This is a virtual constructor for the command.
+ */
+ virtual cmCommand* Clone()
+ {
+ return new cmTargetSourcesCommand;
+ }
+
+ /**
+ * 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);
+
+ /**
+ * The name of the command as specified in CMakeList.txt.
+ */
+ virtual std::string GetName() const { return "target_sources";}
+
+ cmTypeMacro(cmTargetSourcesCommand, cmTargetPropCommandBase);
+
+private:
+ virtual void HandleImportedTarget(const std::string &tgt);
+ virtual void HandleMissingTarget(const std::string &name);
+
+ virtual bool HandleDirectContent(cmTarget *tgt,
+ const std::vector<std::string> &content,
+ bool prepend, bool system);
+
+ virtual std::string Join(const std::vector<std::string> &content);
+};
+
+#endif
diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx
index 9cda978..28a7bb1 100644
--- a/Source/cmTest.cxx
+++ b/Source/cmTest.cxx
@@ -38,12 +38,8 @@ cmListFileBacktrace const& cmTest::GetBacktrace() const
}
//----------------------------------------------------------------------------
-void cmTest::SetName(const char* name)
+void cmTest::SetName(const std::string& name)
{
- if ( !name )
- {
- name = "";
- }
this->Name = name;
}
@@ -54,7 +50,7 @@ void cmTest::SetCommand(std::vector<std::string> const& command)
}
//----------------------------------------------------------------------------
-const char *cmTest::GetProperty(const char* prop) const
+const char *cmTest::GetProperty(const std::string& prop) const
{
bool chain = false;
const char *retVal =
@@ -67,28 +63,20 @@ const char *cmTest::GetProperty(const char* prop) const
}
//----------------------------------------------------------------------------
-bool cmTest::GetPropertyAsBool(const char* prop) const
+bool cmTest::GetPropertyAsBool(const std::string& prop) const
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
//----------------------------------------------------------------------------
-void cmTest::SetProperty(const char* prop, const char* value)
+void cmTest::SetProperty(const std::string& prop, const char* value)
{
- if (!prop)
- {
- return;
- }
-
this->Properties.SetProperty(prop, value, cmProperty::TEST);
}
//----------------------------------------------------------------------------
-void cmTest::AppendProperty(const char* prop, const char* value, bool asString)
+void cmTest::AppendProperty(const std::string& prop,
+ const char* value, bool asString)
{
- if (!prop)
- {
- return;
- }
this->Properties.AppendProperty(prop, value, cmProperty::TEST, asString);
}
diff --git a/Source/cmTest.h b/Source/cmTest.h
index 1fe8fc0..a93eff5 100644
--- a/Source/cmTest.h
+++ b/Source/cmTest.h
@@ -31,8 +31,8 @@ public:
~cmTest();
///! Set the test name
- void SetName(const char* name);
- const char* GetName() const { return this->Name.c_str(); }
+ void SetName(const std::string& name);
+ std::string GetName() const { return this->Name; }
void SetCommand(std::vector<std::string> const& command);
std::vector<std::string> const& GetCommand() const
@@ -46,14 +46,15 @@ public:
void Print() const;
///! Set/Get a property of this source file
- void SetProperty(const char *prop, const char *value);
- void AppendProperty(const char* prop, const char* value,bool asString=false);
- const char *GetProperty(const char *prop) const;
- bool GetPropertyAsBool(const char *prop) const;
- cmPropertyMap &GetProperties() { return this->Properties; };
+ void SetProperty(const std::string& prop, const char *value);
+ void AppendProperty(const std::string& prop,
+ const char* value,bool asString=false);
+ const char *GetProperty(const std::string& prop) const;
+ bool GetPropertyAsBool(const std::string& prop) const;
+ cmPropertyMap &GetProperties() { return this->Properties; }
/** Get the cmMakefile instance that owns this test. */
- cmMakefile *GetMakefile() { return this->Makefile;};
+ cmMakefile *GetMakefile() { return this->Makefile;}
/** Get the backtrace of the command that created this test. */
cmListFileBacktrace const& GetBacktrace() const;
@@ -64,7 +65,7 @@ public:
private:
cmPropertyMap Properties;
- cmStdString Name;
+ std::string Name;
std::vector<std::string> Command;
bool OldStyle;
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 5dc3e60..c1b1f8b 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -64,7 +64,7 @@ void cmTestGenerator::GenerateScriptActions(std::ostream& os,
//----------------------------------------------------------------------------
void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
Indent const& indent)
{
this->TestGenerated = true;
@@ -97,7 +97,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
// Generate the command line with full escapes.
cmLocalGenerator* lg = mf->GetLocalGenerator();
- os << lg->EscapeForCMake(exe.c_str());
+ os << lg->EscapeForCMake(exe);
for(std::vector<std::string>::const_iterator ci = command.begin()+1;
ci != command.end(); ++ci)
{
diff --git a/Source/cmTestGenerator.h b/Source/cmTestGenerator.h
index 2c69fc3..5446553 100644
--- a/Source/cmTestGenerator.h
+++ b/Source/cmTestGenerator.h
@@ -32,7 +32,7 @@ protected:
virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
virtual void GenerateScriptForConfig(std::ostream& os,
- const char* config,
+ const std::string& config,
Indent const& indent);
virtual void GenerateScriptNoConfig(std::ostream& os, Indent const& indent);
virtual bool NeedsScriptNoConfig() const;
diff --git a/Source/cmTryCompileCommand.h b/Source/cmTryCompileCommand.h
index 8e6bbc1..a09c47f 100644
--- a/Source/cmTryCompileCommand.h
+++ b/Source/cmTryCompileCommand.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "try_compile";}
+ virtual std::string GetName() const { return "try_compile";}
cmTypeMacro(cmTryCompileCommand, cmCoreTryCompile);
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index cfedaa5..cc6e139 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -162,7 +162,7 @@ bool cmTryRunCommand
// now put the output into the variables
if(this->RunOutputVariable.size())
{
- this->Makefile->AddDefinition(this->RunOutputVariable.c_str(),
+ this->Makefile->AddDefinition(this->RunOutputVariable,
runOutputContents.c_str());
}
@@ -171,12 +171,12 @@ bool cmTryRunCommand
// if the TryCompileCore saved output in this outputVariable then
// prepend that output to this output
const char* compileOutput
- = this->Makefile->GetDefinition(this->OutputVariable.c_str());
+ = this->Makefile->GetDefinition(this->OutputVariable);
if (compileOutput)
{
runOutputContents = std::string(compileOutput) + runOutputContents;
}
- this->Makefile->AddDefinition(this->OutputVariable.c_str(),
+ this->Makefile->AddDefinition(this->OutputVariable,
runOutputContents.c_str());
}
}
@@ -214,7 +214,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs,
{
strcpy(retChar, "FAILED_TO_RUN");
}
- this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(), retChar,
+ this->Makefile->AddCacheDefinition(this->RunResultVariable, retChar,
"Result of TRY_RUN",
cmCacheManager::INTERNAL);
}
@@ -235,10 +235,10 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
copyDest += cmake::GetCMakeFilesDirectory();
copyDest += "/";
copyDest += cmSystemTools::GetFilenameWithoutExtension(
- this->OutputFile.c_str());
+ this->OutputFile);
copyDest += "-";
copyDest += this->RunResultVariable;
- copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile.c_str());
+ copyDest += cmSystemTools::GetFilenameExtension(this->OutputFile);
cmSystemTools::CopyFileAlways(this->OutputFile.c_str(), copyDest.c_str());
std::string resultFileName = this->Makefile->GetHomeOutputDirectory();
@@ -250,7 +250,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
std::string internalRunOutputName=this->RunResultVariable+"__TRYRUN_OUTPUT";
bool error = false;
- if (this->Makefile->GetDefinition(this->RunResultVariable.c_str()) == 0)
+ if (this->Makefile->GetDefinition(this->RunResultVariable) == 0)
{
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced
@@ -258,7 +258,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
comment += "Run result of TRY_RUN(), indicates whether the executable "
"would have been able to run on its target platform.\n";
comment += detailsString;
- this->Makefile->AddCacheDefinition(this->RunResultVariable.c_str(),
+ this->Makefile->AddCacheDefinition(this->RunResultVariable,
"PLEASE_FILL_OUT-FAILED_TO_RUN",
comment.c_str(),
cmCacheManager::STRING);
@@ -276,7 +276,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
// is the output from the executable used ?
if (out!=0)
{
- if (this->Makefile->GetDefinition(internalRunOutputName.c_str()) == 0)
+ if (this->Makefile->GetDefinition(internalRunOutputName) == 0)
{
// if the variables doesn't exist, create it with a helpful error text
// and mark it as advanced
@@ -285,7 +285,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
"would have printed on stdout and stderr on its target platform.\n";
comment += detailsString;
- this->Makefile->AddCacheDefinition(internalRunOutputName.c_str(),
+ this->Makefile->AddCacheDefinition(internalRunOutputName,
"PLEASE_FILL_OUT-NOTFOUND",
comment.c_str(),
cmCacheManager::STRING);
@@ -355,13 +355,13 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
file << comment << "\n\n";
file << "set( " << this->RunResultVariable << " \n \""
- << this->Makefile->GetDefinition(this->RunResultVariable.c_str())
+ << this->Makefile->GetDefinition(this->RunResultVariable)
<< "\"\n CACHE STRING \"Result from TRY_RUN\" FORCE)\n\n";
if (out!=0)
{
file << "set( " << internalRunOutputName << " \n \""
- << this->Makefile->GetDefinition(internalRunOutputName.c_str())
+ << this->Makefile->GetDefinition(internalRunOutputName)
<< "\"\n CACHE STRING \"Output from TRY_RUN\" FORCE)\n\n";
}
file.close();
@@ -383,6 +383,6 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs,
if (out!=0)
{
- (*out) = this->Makefile->GetDefinition(internalRunOutputName.c_str());
+ (*out) = this->Makefile->GetDefinition(internalRunOutputName);
}
}
diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h
index d0bf9ce..9b97b16 100644
--- a/Source/cmTryRunCommand.h
+++ b/Source/cmTryRunCommand.h
@@ -40,7 +40,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "try_run";}
+ virtual std::string GetName() const { return "try_run";}
cmTypeMacro(cmTryRunCommand, cmCoreTryCompile);
private:
diff --git a/Source/cmUnsetCommand.h b/Source/cmUnsetCommand.h
index 2308139..62c2bd3 100644
--- a/Source/cmUnsetCommand.h
+++ b/Source/cmUnsetCommand.h
@@ -45,7 +45,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const {return "unset";}
+ virtual std::string GetName() const {return "unset";}
cmTypeMacro(cmUnsetCommand, cmCommand);
};
diff --git a/Source/cmUseMangledMesaCommand.cxx b/Source/cmUseMangledMesaCommand.cxx
index d4ec20f..8d26f86 100644
--- a/Source/cmUseMangledMesaCommand.cxx
+++ b/Source/cmUseMangledMesaCommand.cxx
@@ -38,7 +38,7 @@ bool cmUseMangledMesaCommand
std::string e = "Bad path to Mesa, could not find: ";
e += glh;
e += " ";
- this->SetError(e.c_str());
+ this->SetError(e);
return false;
}
const char* destDir = args[1].c_str();
@@ -107,12 +107,12 @@ CopyAndFullPathMesaHeader(const char* source,
if(glDirLine.find(includeFile.c_str()))
{
std::string gfile = glDirLine.match(3);
- fout << "#include \"" << outdir << "/" << gfile.c_str() << "\"\n";
+ fout << "#include \"" << outdir << "/" << gfile << "\"\n";
}
else if(glLine.find(includeFile.c_str()))
{
fout << "#include \"" << outdir << "/" <<
- includeLine.match(1).c_str() << "\"\n";
+ includeLine.match(1) << "\"\n";
}
else
{
diff --git a/Source/cmUseMangledMesaCommand.h b/Source/cmUseMangledMesaCommand.h
index dca75a5..da927c7 100644
--- a/Source/cmUseMangledMesaCommand.h
+++ b/Source/cmUseMangledMesaCommand.h
@@ -21,7 +21,7 @@ public:
virtual cmCommand* Clone() { return new cmUseMangledMesaCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const { return "use_mangled_mesa";}
+ virtual std::string GetName() const { return "use_mangled_mesa";}
virtual bool IsScriptable() const { return true; }
virtual bool IsDiscouraged() const { return true; }
protected:
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 11e5108..ba6b4ac 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -29,7 +29,7 @@ bool cmUtilitySourceCommand
// The first argument is the cache entry name.
std::string cacheEntry = *arg++;
const char* cacheValue =
- this->Makefile->GetDefinition(cacheEntry.c_str());
+ this->Makefile->GetDefinition(cacheEntry);
// If it exists already and appears up to date then we are done. If
// the string contains "(IntDir)" but that is not the
// CMAKE_CFG_INTDIR setting then the value is out of date.
@@ -113,14 +113,14 @@ bool cmUtilitySourceCommand
cmSystemTools::ReplaceString(utilityExecutable, "/./", "/");
// Enter the value into the cache.
- this->Makefile->AddCacheDefinition(cacheEntry.c_str(),
+ this->Makefile->AddCacheDefinition(cacheEntry,
utilityExecutable.c_str(),
"Path to an internal program.",
cmCacheManager::FILEPATH);
// add a value into the cache that maps from the
// full path to the name of the project
cmSystemTools::ConvertToUnixSlashes(utilityExecutable);
- this->Makefile->AddCacheDefinition(utilityExecutable.c_str(),
+ this->Makefile->AddCacheDefinition(utilityExecutable,
utilityName.c_str(),
"Executable to project name.",
cmCacheManager::INTERNAL);
diff --git a/Source/cmUtilitySourceCommand.h b/Source/cmUtilitySourceCommand.h
index 83d115c..23afdbe 100644
--- a/Source/cmUtilitySourceCommand.h
+++ b/Source/cmUtilitySourceCommand.h
@@ -21,7 +21,7 @@ public:
virtual cmCommand* Clone() { return new cmUtilitySourceCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const { return "utility_source";}
+ virtual std::string GetName() const { return "utility_source";}
virtual bool IsDiscouraged() const { return true; }
};
diff --git a/Source/cmVS11CLFlagTable.h b/Source/cmVS11CLFlagTable.h
index 5ab8ebb..a61ab16 100644
--- a/Source/cmVS11CLFlagTable.h
+++ b/Source/cmVS11CLFlagTable.h
@@ -248,9 +248,9 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
{"ForcedUsingFiles", "FU",
"Forced #using File",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
- {"PREfastAdditionalOptions", "analyze:",
- "Additional Code Analysis Native options",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+ {"PREfastLog", "analyze:log",
+ "Code Analysis Log",
+ "", cmVS7FlagTable::UserFollowing},
{"PREfastAdditionalPlugins", "analyze:plugin",
"Additional Code Analysis Native plugins",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
@@ -283,9 +283,6 @@ static cmVS7FlagTable cmVS11CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
// Skip [XMLDocumentationFileName] - no command line Switch.
// Skip [BrowseInformationFile] - no command line Switch.
- {"PREfastLog", "analyze:log ",
- "Code Analysis Log",
- "", cmVS7FlagTable::UserValue},
// Skip [AdditionalOptions] - no command line Switch.
{0,0,0,0,0}
};
diff --git a/Source/cmVS12CLFlagTable.h b/Source/cmVS12CLFlagTable.h
index 8f51319..0a7916f 100644
--- a/Source/cmVS12CLFlagTable.h
+++ b/Source/cmVS12CLFlagTable.h
@@ -254,9 +254,9 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
{"ForcedUsingFiles", "FU",
"Forced #using File",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
- {"PREfastAdditionalOptions", "analyze:",
- "Additional Code Analysis Native options",
- "", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
+ {"PREfastLog", "analyze:log",
+ "Code Analysis Log",
+ "", cmVS7FlagTable::UserFollowing},
{"PREfastAdditionalPlugins", "analyze:plugin",
"Additional Code Analysis Native plugins",
"", cmVS7FlagTable::UserValue | cmVS7FlagTable::SemicolonAppendable},
@@ -289,9 +289,6 @@ static cmVS7FlagTable cmVS12CLFlagTable[] =
"", cmVS7FlagTable::UserValue},
// Skip [XMLDocumentationFileName] - no command line Switch.
// Skip [BrowseInformationFile] - no command line Switch.
- {"PREfastLog", "analyze:log ",
- "Code Analysis Log",
- "", cmVS7FlagTable::UserValue},
// Skip [AdditionalOptions] - no command line Switch.
{0,0,0,0,0}
};
diff --git a/Source/cmVariableRequiresCommand.cxx b/Source/cmVariableRequiresCommand.cxx
index ddb4003..80c1286 100644
--- a/Source/cmVariableRequiresCommand.cxx
+++ b/Source/cmVariableRequiresCommand.cxx
@@ -26,7 +26,7 @@ bool cmVariableRequiresCommand
}
std::string testVariable = args[0];
- if(!this->Makefile->IsOn(testVariable.c_str()))
+ if(!this->Makefile->IsOn(testVariable))
{
return true;
}
@@ -36,7 +36,7 @@ bool cmVariableRequiresCommand
bool hasAdvanced = false;
for(unsigned int i = 2; i < args.size(); ++i)
{
- if(!this->Makefile->IsOn(args[i].c_str()))
+ if(!this->Makefile->IsOn(args[i]))
{
requirementsMet = false;
notSet += args[i];
@@ -49,13 +49,13 @@ bool cmVariableRequiresCommand
}
}
}
- const char* reqVar = this->Makefile->GetDefinition(resultVariable.c_str());
+ const char* reqVar = this->Makefile->GetDefinition(resultVariable);
// if reqVar is unset, then set it to requirementsMet
// if reqVar is set to true, but requirementsMet is false , then
// set reqVar to false.
if(!reqVar || (!requirementsMet && this->Makefile->IsOn(reqVar)))
{
- this->Makefile->AddDefinition(resultVariable.c_str(), requirementsMet);
+ this->Makefile->AddDefinition(resultVariable, requirementsMet);
}
if(!requirementsMet)
diff --git a/Source/cmVariableRequiresCommand.h b/Source/cmVariableRequiresCommand.h
index 881b149..7e68de1 100644
--- a/Source/cmVariableRequiresCommand.h
+++ b/Source/cmVariableRequiresCommand.h
@@ -21,7 +21,7 @@ public:
virtual cmCommand* Clone() { return new cmVariableRequiresCommand; }
virtual bool InitialPass(std::vector<std::string> const& args,
cmExecutionStatus &status);
- virtual const char* GetName() const { return "variable_requires";}
+ virtual std::string GetName() const { return "variable_requires";}
virtual bool IsDiscouraged() const { return true; }
};
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h
index 790c75a..c86fad0 100644
--- a/Source/cmVariableWatch.h
+++ b/Source/cmVariableWatch.h
@@ -81,7 +81,7 @@ protected:
};
typedef std::vector< Pair* > VectorOfPairs;
- typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs;
+ typedef std::map<std::string, VectorOfPairs > StringToVectorOfPairs;
StringToVectorOfPairs WatchMap;
};
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index 33e159b..debe243 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -84,7 +84,7 @@ static void cmVariableWatchCommandVariableAccessed(
if ( !processed )
{
cmOStringStream msg;
- msg << "Variable \"" << variable.c_str() << "\" was accessed using "
+ msg << "Variable \"" << variable << "\" was accessed using "
<< accessString << " with value \"" << (newValue?newValue:"") << "\".";
makefile->IssueMessage(cmake::LOG, msg.str());
}
@@ -136,8 +136,8 @@ bool cmVariableWatchCommand
if ( variable == "CMAKE_CURRENT_LIST_FILE" )
{
cmOStringStream ostr;
- ostr << "cannot be set on the variable: " << variable.c_str();
- this->SetError(ostr.str().c_str());
+ ostr << "cannot be set on the variable: " << variable;
+ this->SetError(ostr.str());
return false;
}
diff --git a/Source/cmVariableWatchCommand.h b/Source/cmVariableWatchCommand.h
index fb6062c..c1ee9b1 100644
--- a/Source/cmVariableWatchCommand.h
+++ b/Source/cmVariableWatchCommand.h
@@ -54,7 +54,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "variable_watch";}
+ virtual std::string GetName() const { return "variable_watch";}
cmTypeMacro(cmVariableWatchCommand, cmCommand);
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ed7e243..72bb020 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -19,6 +19,7 @@
#include "cmSourceFile.h"
#include "cmVisualStudioGeneratorOptions.h"
#include "cmLocalVisualStudio7Generator.h"
+#include "cmCustomCommandGenerator.h"
#include "cmVS10CLFlagTable.h"
#include "cmVS10LinkFlagTable.h"
#include "cmVS10LibFlagTable.h"
@@ -140,7 +141,7 @@ cmVisualStudio10TargetGenerator::~cmVisualStudio10TargetGenerator()
void cmVisualStudio10TargetGenerator::WritePlatformConfigTag(
const char* tag,
- const char* config,
+ const std::string& config,
int indentLevel,
const char* attribute,
const char* end,
@@ -221,7 +222,8 @@ void cmVisualStudio10TargetGenerator::Generate()
//get the tools version to use
const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
std::string project_defaults=
- "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n";
+ "<?xml version=\"1.0\" encoding=\"" +
+ this->GlobalGenerator->Encoding() + "\"?>\n";
project_defaults.append("<Project DefaultTargets=\"Build\" ToolsVersion=\"");
project_defaults.append(toolsVer +"\" ");
project_defaults.append(
@@ -376,12 +378,12 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences()
void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup()
{
- std::vector<cmSourceFile*> resxObjs;
- this->GeneratorTarget->GetResxSources(resxObjs);
+ std::vector<cmSourceFile const*> resxObjs;
+ this->GeneratorTarget->GetResxSources(resxObjs, "");
if(!resxObjs.empty())
{
this->WriteString("<ItemGroup>\n", 1);
- for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin();
+ for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
oi != resxObjs.end(); ++oi)
{
std::string obj = (*oi)->GetFullPath();
@@ -550,9 +552,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()
void cmVisualStudio10TargetGenerator::WriteCustomCommands()
{
this->SourcesVisited.clear();
- std::vector<cmSourceFile*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> customCommands;
+ this->GeneratorTarget->GetCustomCommands(customCommands, "");
+ for(std::vector<cmSourceFile const*>::const_iterator
si = customCommands.begin();
si != customCommands.end(); ++si)
{
@@ -561,7 +563,8 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommands()
}
//----------------------------------------------------------------------------
-void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
+void cmVisualStudio10TargetGenerator
+::WriteCustomCommand(cmSourceFile const* sf)
{
if(this->SourcesVisited.insert(sf).second)
{
@@ -584,7 +587,7 @@ void cmVisualStudio10TargetGenerator::WriteCustomCommand(cmSourceFile* sf)
}
void
-cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
+cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
cmCustomCommand const &
command)
{
@@ -616,8 +619,6 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
}
}
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
- std::string comment = lg->ConstructComment(command);
- comment = cmVS10EscapeComment(comment);
std::vector<std::string> *configs =
static_cast<cmGlobalVisualStudio7Generator *>
(this->GlobalGenerator)->GetConfigurations();
@@ -627,8 +628,11 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
for(std::vector<std::string>::iterator i = configs->begin();
i != configs->end(); ++i)
{
+ cmCustomCommandGenerator ccg(command, *i, this->Makefile);
+ std::string comment = lg->ConstructComment(ccg);
+ comment = cmVS10EscapeComment(comment);
std::string script =
- cmVS10EscapeXML(lg->ConstructScript(command, i->c_str()));
+ cmVS10EscapeXML(lg->ConstructScript(ccg));
this->WritePlatformConfigTag("Message",i->c_str(), 3);
(*this->BuildFileStream ) << cmVS10EscapeXML(comment) << "</Message>\n";
this->WritePlatformConfigTag("Command", i->c_str(), 3);
@@ -637,8 +641,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
(*this->BuildFileStream ) << source->GetFullPath();
for(std::vector<std::string>::const_iterator d =
- command.GetDepends().begin();
- d != command.GetDepends().end();
+ ccg.GetDepends().begin();
+ d != ccg.GetDepends().end();
++d)
{
std::string dep;
@@ -652,8 +656,8 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile* source,
this->WritePlatformConfigTag("Outputs", i->c_str(), 3);
const char* sep = "";
for(std::vector<std::string>::const_iterator o =
- command.GetOutputs().begin();
- o != command.GetOutputs().end();
+ ccg.GetOutputs().begin();
+ o != ccg.GetOutputs().end();
++o)
{
std::string out = *o;
@@ -681,7 +685,8 @@ cmVisualStudio10TargetGenerator::ConvertPath(std::string const& path,
this->Makefile->GetCurrentOutputDirectory(), path.c_str())
: this->LocalGenerator->Convert(path.c_str(),
cmLocalGenerator::START_OUTPUT,
- cmLocalGenerator::UNCHANGED);
+ cmLocalGenerator::UNCHANGED,
+ /* optional = */ true);
}
void cmVisualStudio10TargetGenerator::ConvertToWindowsSlash(std::string& s)
@@ -700,7 +705,10 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
std::vector<cmSourceGroup> sourceGroups =
this->Makefile->GetSourceGroups();
std::vector<cmSourceFile*> classes;
- this->Target->GetSourceFiles(classes);
+ if (!this->Target->GetConfigCommonSourceFiles(classes))
+ {
+ return;
+ }
std::set<cmSourceGroup*> groupsUsed;
for(std::vector<cmSourceFile*>::const_iterator s = classes.begin();
@@ -730,7 +738,8 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
//get the tools version to use
const std::string toolsVer(this->GlobalGenerator->GetToolsVersion());
std::string project_defaults=
- "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n";
+ "<?xml version=\"1.0\" encoding=\"" +
+ this->GlobalGenerator->Encoding() + "\"?>\n";
project_defaults.append("<Project ToolsVersion=\"");
project_defaults.append(toolsVer +"\" ");
project_defaults.append(
@@ -743,12 +752,12 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
this->WriteGroupSources(ti->first.c_str(), ti->second, sourceGroups);
}
- std::vector<cmSourceFile*> resxObjs;
- this->GeneratorTarget->GetResxSources(resxObjs);
+ std::vector<cmSourceFile const*> resxObjs;
+ this->GeneratorTarget->GetResxSources(resxObjs, "");
if(!resxObjs.empty())
{
this->WriteString("<ItemGroup>\n", 1);
- for(std::vector<cmSourceFile*>::const_iterator oi = resxObjs.begin();
+ for(std::vector<cmSourceFile const*>::const_iterator oi = resxObjs.begin();
oi != resxObjs.end(); ++oi)
{
std::string obj = (*oi)->GetFullPath();
@@ -763,7 +772,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
// Add object library contents as external objects.
std::vector<std::string> objs;
- this->GeneratorTarget->UseObjectLibraries(objs);
+ this->GeneratorTarget->UseObjectLibraries(objs, "");
if(!objs.empty())
{
this->WriteString("<ItemGroup>\n", 1);
@@ -899,7 +908,7 @@ WriteGroupSources(const char* name,
for(ToolSources::const_iterator s = sources.begin();
s != sources.end(); ++s)
{
- cmSourceFile* sf = s->SourceFile;
+ cmSourceFile const* sf = s->SourceFile;
std::string const& source = sf->GetFullPath();
cmSourceGroup* sourceGroup =
this->Makefile->FindSourceGroup(source.c_str(), sourceGroups);
@@ -926,14 +935,14 @@ WriteGroupSources(const char* name,
}
void cmVisualStudio10TargetGenerator::WriteSource(
- const char* tool, cmSourceFile* sf, const char* end)
+ const char* tool, cmSourceFile const* sf, const char* end)
{
// Visual Studio tools append relative paths to the current dir, as in:
//
// c:\path\to\current\dir\..\..\..\relative\path\to\source.c
//
// and fail if this exceeds the maximum allowed path length. Our path
- // conversion uses full paths outside the build tree to allow deeper trees.
+ // conversion uses full paths when possible to allow deeper trees.
bool forceRelative = false;
std::string sourceFile = this->ConvertPath(sf->GetFullPath(), false);
if(this->LocalGenerator->GetVersion() == cmLocalVisualStudioGenerator::VS10
@@ -982,9 +991,9 @@ void cmVisualStudio10TargetGenerator::WriteSource(
}
void cmVisualStudio10TargetGenerator::WriteSources(
- const char* tool, std::vector<cmSourceFile*> const& sources)
+ const char* tool, std::vector<cmSourceFile const*> const& sources)
{
- for(std::vector<cmSourceFile*>::const_iterator
+ for(std::vector<cmSourceFile const*>::const_iterator
si = sources.begin(); si != sources.end(); ++si)
{
this->WriteSource(tool, *si);
@@ -999,31 +1008,31 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
this->WriteString("<ItemGroup>\n", 1);
- std::vector<cmSourceFile*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources);
+ std::vector<cmSourceFile const*> headerSources;
+ this->GeneratorTarget->GetHeaderSources(headerSources, "");
this->WriteSources("ClInclude", headerSources);
- std::vector<cmSourceFile*> idlSources;
- this->GeneratorTarget->GetIDLSources(idlSources);
+ std::vector<cmSourceFile const*> idlSources;
+ this->GeneratorTarget->GetIDLSources(idlSources, "");
this->WriteSources("Midl", idlSources);
- std::vector<cmSourceFile*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources);
- for(std::vector<cmSourceFile*>::const_iterator
+ std::vector<cmSourceFile const*> objectSources;
+ this->GeneratorTarget->GetObjectSources(objectSources, "");
+ for(std::vector<cmSourceFile const*>::const_iterator
si = objectSources.begin();
si != objectSources.end(); ++si)
{
- const char* lang = (*si)->GetLanguage();
+ const std::string& lang = (*si)->GetLanguage();
const char* tool = NULL;
- if (strcmp(lang, "C") == 0 || strcmp(lang, "CXX") == 0)
+ if (lang == "C"|| lang == "CXX")
{
tool = "ClCompile";
}
- else if (strcmp(lang, "ASM_MASM") == 0 &&
+ else if (lang == "ASM_NASM" &&
this->GlobalGenerator->IsMasmEnabled())
{
tool = "MASM";
}
- else if (strcmp(lang, "RC") == 0)
+ else if (lang == "RC")
{
tool = "ResourceCompile";
}
@@ -1047,8 +1056,21 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
}
- std::vector<cmSourceFile*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects);
+ std::vector<cmSourceFile const*> externalObjects;
+ this->GeneratorTarget->GetExternalObjects(externalObjects, "");
+ for(std::vector<cmSourceFile const*>::iterator
+ si = externalObjects.begin();
+ si != externalObjects.end(); )
+ {
+ if (!(*si)->GetObjectLibrary().empty())
+ {
+ si = externalObjects.erase(si);
+ }
+ else
+ {
+ ++si;
+ }
+ }
if(this->LocalGenerator->GetVersion() > cmLocalVisualStudioGenerator::VS10)
{
// For VS >= 11 we use LinkObjects to avoid linking custom command
@@ -1059,7 +1081,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
{
// If an object file is generated in this target, then vs10 will use
// it in the build, and we have to list it as None instead of Object.
- for(std::vector<cmSourceFile*>::const_iterator
+ for(std::vector<cmSourceFile const*>::const_iterator
si = externalObjects.begin();
si != externalObjects.end(); ++si)
{
@@ -1069,13 +1091,13 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
}
- std::vector<cmSourceFile*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources);
+ std::vector<cmSourceFile const*> extraSources;
+ this->GeneratorTarget->GetExtraSources(extraSources, "");
this->WriteSources("None", extraSources);
// Add object library contents as external objects.
std::vector<std::string> objs;
- this->GeneratorTarget->UseObjectLibraries(objs);
+ this->GeneratorTarget->UseObjectLibraries(objs, "");
for(std::vector<std::string>::const_iterator
oi = objs.begin(); oi != objs.end(); ++oi)
{
@@ -1089,9 +1111,9 @@ void cmVisualStudio10TargetGenerator::WriteAllSources()
}
bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
- cmSourceFile* source)
+ cmSourceFile const* source)
{
- cmSourceFile& sf = *source;
+ cmSourceFile const& sf = *source;
std::string objectName;
if(this->GeneratorTarget->HasExplicitObjectName(&sf))
@@ -1108,29 +1130,28 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
{
defines += cdefs;
}
- const char* lang =
+ std::string lang =
this->GlobalGenerator->GetLanguageFromExtension
(sf.GetExtension().c_str());
- const char* sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
- const char* linkLanguage = this->Target->GetLinkerLanguage();
+ std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf);
+ const std::string& linkLanguage = this->Target->GetLinkerLanguage();
bool needForceLang = false;
// source file does not match its extension language
- if(lang && sourceLang && strcmp(lang, sourceLang) != 0)
+ if(lang != sourceLang)
{
needForceLang = true;
lang = sourceLang;
}
// if the source file does not match the linker language
// then force c or c++
- if(needForceLang || (linkLanguage && lang
- && strcmp(lang, linkLanguage) != 0))
+ if(needForceLang || (linkLanguage != lang))
{
- if(strcmp(lang, "CXX") == 0)
+ if(lang == "CXX")
{
// force a C++ file type
flags += " /TP ";
}
- else if(strcmp(lang, "C") == 0)
+ else if(lang == "C")
{
// force to c
flags += " /TC ";
@@ -1341,17 +1362,17 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
// collect up flags for
if(this->Target->GetType() < cmTarget::UTILITY)
{
- const char* linkLanguage =
+ const std::string& linkLanguage =
this->Target->GetLinkerLanguage(configName.c_str());
- if(!linkLanguage)
+ if(linkLanguage.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
this->Name.c_str());
return false;
}
- if(strcmp(linkLanguage, "C") == 0 || strcmp(linkLanguage, "CXX") == 0
- || strcmp(linkLanguage, "Fortran") == 0)
+ if(linkLanguage == "C" || linkLanguage == "CXX"
+ || linkLanguage == "Fortran")
{
std::string baseFlagVar = "CMAKE_";
baseFlagVar += linkLanguage;
@@ -1365,11 +1386,11 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
Target->GetMakefile()->GetRequiredDefinition(flagVar.c_str());
}
// set the correct language
- if(strcmp(linkLanguage, "C") == 0)
+ if(linkLanguage == "C")
{
flags += " /TC ";
}
- if(strcmp(linkLanguage, "CXX") == 0)
+ if(linkLanguage == "CXX")
{
flags += " /TP ";
}
@@ -1427,6 +1448,17 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
clOptions.OutputPreprocessorDefinitions(*this->BuildFileStream, " ",
"\n", "CXX");
this->WriteString("<ObjectFileName>$(IntDir)</ObjectFileName>\n", 3);
+
+ // Specify the compiler program database file if configured.
+ std::string pdb = this->Target->GetCompilePDBPath(configName.c_str());
+ if(!pdb.empty())
+ {
+ this->ConvertToWindowsSlash(pdb);
+ this->WriteString("<ProgramDataBaseFileName>", 3);
+ *this->BuildFileStream << cmVS10EscapeXML(pdb)
+ << "</ProgramDataBaseFileName>\n";
+ }
+
this->WriteString("</ClCompile>\n", 2);
}
@@ -1514,9 +1546,9 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
cmVSGetLinkFlagTable(this->LocalGenerator), 0, this));
Options& linkOptions = *pOptions;
- const char* linkLanguage =
+ const std::string& linkLanguage =
this->Target->GetLinkerLanguage(config.c_str());
- if(!linkLanguage)
+ if(linkLanguage.empty())
{
cmSystemTools::Error
("CMake can not determine linker language for target: ",
@@ -1666,10 +1698,10 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config)
linkOptions.AddFlag("ImportLibrary", imLib.c_str());
linkOptions.AddFlag("ProgramDataBaseFile", pdb.c_str());
linkOptions.Parse(flags.c_str());
- if(!this->GeneratorTarget->ModuleDefinitionFile.empty())
+ std::string def = this->GeneratorTarget->GetModuleDefinitionFile("");
+ if(!def.empty())
{
- linkOptions.AddFlag("ModuleDefinitionFile",
- this->GeneratorTarget->ModuleDefinitionFile.c_str());
+ linkOptions.AddFlag("ModuleDefinitionFile", def.c_str());
}
this->LinkOptions[config] = pOptions.release();
@@ -1825,13 +1857,12 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
for(std::vector<cmCustomCommand>::const_iterator i = commands.begin();
i != commands.end(); ++i)
{
- const cmCustomCommand& command = *i;
+ cmCustomCommandGenerator ccg(*i, configName, this->Makefile);
comment += pre;
- comment += lg->ConstructComment(command);
+ comment += lg->ConstructComment(ccg);
script += pre;
pre = "\n";
- script +=
- cmVS10EscapeXML(lg->ConstructScript(command, configName.c_str()));
+ script += cmVS10EscapeXML(lg->ConstructScript(ccg));
}
comment = cmVS10EscapeComment(comment);
this->WriteString("<Message>",3);
@@ -1897,7 +1928,7 @@ bool cmVisualStudio10TargetGenerator::
IsResxHeader(const std::string& headerFile)
{
std::set<std::string> expectedResxHeaders;
- this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders);
+ this->GeneratorTarget->GetExpectedResxHeaders(expectedResxHeaders, "");
std::set<std::string>::const_iterator it =
expectedResxHeaders.find(headerFile);
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index d1f3d19..d72c6fd 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -35,7 +35,7 @@ public:
// used by cmVisualStudioGeneratorOptions
void WritePlatformConfigTag(
const char* tag,
- const char* config,
+ const std::string& config,
int indentLevel,
const char* attribute = 0,
const char* end = 0,
@@ -45,7 +45,7 @@ public:
private:
struct ToolSource
{
- cmSourceFile* SourceFile;
+ cmSourceFile const* SourceFile;
bool RelativePath;
};
struct ToolSources: public std::vector<ToolSource> {};
@@ -55,8 +55,10 @@ private:
void WriteString(const char* line, int indentLevel);
void WriteProjectConfigurations();
void WriteProjectConfigurationValues();
- void WriteSource(const char* tool, cmSourceFile* sf, const char* end = 0);
- void WriteSources(const char* tool, std::vector<cmSourceFile*> const&);
+ void WriteSource(const char* tool, cmSourceFile const* sf,
+ const char* end = 0);
+ void WriteSources(const char* tool,
+ std::vector<cmSourceFile const*> const&);
void WriteAllSources();
void WriteDotNetReferences();
void WriteEmbeddedResourceGroup();
@@ -77,13 +79,13 @@ private:
std::vector<std::string> const & includes);
void OutputIncludes(std::vector<std::string> const & includes);
void OutputLinkIncremental(std::string const& configName);
- void WriteCustomRule(cmSourceFile* source,
+ void WriteCustomRule(cmSourceFile const* source,
cmCustomCommand const & command);
void WriteCustomCommands();
- void WriteCustomCommand(cmSourceFile* sf);
+ void WriteCustomCommand(cmSourceFile const* sf);
void WriteGroups();
void WriteProjectReferences();
- bool OutputSourceSpecificFlags(cmSourceFile* source);
+ bool OutputSourceSpecificFlags(cmSourceFile const* source);
void AddLibraries(cmComputeLinkInformation& cli, std::string& libstring);
void WriteLibOptions(std::string const& config);
void WriteEvents(std::string const& configName);
@@ -98,7 +100,7 @@ private:
private:
typedef cmVisualStudioGeneratorOptions Options;
- typedef std::map<cmStdString, Options*> OptionsMap;
+ typedef std::map<std::string, Options*> OptionsMap;
OptionsMap ClOptions;
OptionsMap LinkOptions;
std::string PathToVcxproj;
@@ -111,9 +113,9 @@ private:
cmGlobalVisualStudio10Generator* GlobalGenerator;
cmGeneratedFileStream* BuildFileStream;
cmLocalVisualStudio7Generator* LocalGenerator;
- std::set<cmSourceFile*> SourcesVisited;
+ std::set<cmSourceFile const*> SourcesVisited;
- typedef std::map<cmStdString, ToolSources> ToolSourceMap;
+ typedef std::map<std::string, ToolSources> ToolSourceMap;
ToolSourceMap Tools;
};
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 6aca787..81adb56 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -222,7 +222,7 @@ cmVisualStudioGeneratorOptions
::OutputPreprocessorDefinitions(std::ostream& fout,
const char* prefix,
const char* suffix,
- const char* lang)
+ const std::string& lang)
{
if(this->Defines.empty())
{
@@ -270,7 +270,7 @@ cmVisualStudioGeneratorOptions
{
define = cmVisualStudio10GeneratorOptionsEscapeForXML(define.c_str());
- if(0 == strcmp(lang, "RC"))
+ if(lang == "RC")
{
cmSystemTools::ReplaceString(define, "\"", "\\\"");
}
@@ -300,7 +300,7 @@ cmVisualStudioGeneratorOptions
{
if(this->Version >= cmLocalVisualStudioGenerator::VS10)
{
- for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin();
+ for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
{
fout << indent;
@@ -326,7 +326,7 @@ cmVisualStudioGeneratorOptions
}
else
{
- for(std::map<cmStdString, cmStdString>::iterator m = this->FlagMap.begin();
+ for(std::map<std::string, std::string>::iterator m = this->FlagMap.begin();
m != this->FlagMap.end(); ++m)
{
fout << indent << m->first << "=\"" << m->second << "\"\n";
diff --git a/Source/cmVisualStudioGeneratorOptions.h b/Source/cmVisualStudioGeneratorOptions.h
index 90f7667..214b893 100644
--- a/Source/cmVisualStudioGeneratorOptions.h
+++ b/Source/cmVisualStudioGeneratorOptions.h
@@ -55,7 +55,7 @@ public:
void OutputPreprocessorDefinitions(std::ostream& fout,
const char* prefix,
const char* suffix,
- const char* lang);
+ const std::string& lang);
void OutputFlagMap(std::ostream& fout, const char* indent);
void OutputAdditionalOptions(std::ostream& fout,
const char* prefix,
diff --git a/Source/cmVisualStudioWCEPlatformParser.cxx b/Source/cmVisualStudioWCEPlatformParser.cxx
index 219a5eb..ca226fb 100644
--- a/Source/cmVisualStudioWCEPlatformParser.cxx
+++ b/Source/cmVisualStudioWCEPlatformParser.cxx
@@ -62,7 +62,7 @@ const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
return 0;
}
-void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
+void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
const char** attributes)
{
if(this->FoundRequiredName)
@@ -72,7 +72,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
this->CharacterData = "";
- if(strcmp(name, "PlatformData") == 0)
+ if(name == "PlatformData")
{
this->PlatformName = "";
this->OSMajorVersion = "";
@@ -80,7 +80,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
this->Macros.clear();
}
- if(strcmp(name, "Macro") == 0)
+ if(name == "Macro")
{
std::string macroName;
std::string macroValue;
@@ -102,7 +102,7 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
this->Macros[macroName] = macroValue;
}
}
- else if(strcmp(name, "Directories") == 0)
+ else if(name == "Directories")
{
for(const char** attr = attributes; *attr; attr += 2)
{
@@ -122,11 +122,11 @@ void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
}
}
-void cmVisualStudioWCEPlatformParser::EndElement(const char* name)
+void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
{
if(!this->RequiredName)
{
- if(strcmp(name, "PlatformName") == 0)
+ if(name == "PlatformName")
{
this->AvailablePlatforms.push_back(this->CharacterData);
}
@@ -138,19 +138,19 @@ void cmVisualStudioWCEPlatformParser::EndElement(const char* name)
return;
}
- if(strcmp(name, "PlatformName") == 0)
+ if(name == "PlatformName")
{
this->PlatformName = this->CharacterData;
}
- else if(strcmp(name, "OSMajorVersion") == 0)
+ else if(name == "OSMajorVersion")
{
this->OSMajorVersion = this->CharacterData;
}
- else if(strcmp(name, "OSMinorVersion") == 0)
+ else if(name == "OSMinorVersion")
{
this->OSMinorVersion = this->CharacterData;
}
- else if(strcmp(name, "Platform") == 0)
+ else if(name == "Platform")
{
if(this->PlatformName == this->RequiredName)
{
diff --git a/Source/cmVisualStudioWCEPlatformParser.h b/Source/cmVisualStudioWCEPlatformParser.h
index 466e1dd..042df01 100644
--- a/Source/cmVisualStudioWCEPlatformParser.h
+++ b/Source/cmVisualStudioWCEPlatformParser.h
@@ -41,8 +41,8 @@ public:
return this->AvailablePlatforms; }
protected:
- virtual void StartElement(const char* name, const char** attributes);
- void EndElement(const char* name);
+ virtual void StartElement(const std::string& name, const char** attributes);
+ void EndElement(const std::string& name);
void CharacterDataHandler(const char* data, int length);
private:
diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h
index 45badd0..9fafffc 100644
--- a/Source/cmWhileCommand.h
+++ b/Source/cmWhileCommand.h
@@ -66,7 +66,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "while";}
+ virtual std::string GetName() const { return "while";}
cmTypeMacro(cmWhileCommand, cmCommand);
};
diff --git a/Source/cmWriteFileCommand.cxx b/Source/cmWriteFileCommand.cxx
index aa6b9f8..af955ec 100644
--- a/Source/cmWriteFileCommand.cxx
+++ b/Source/cmWriteFileCommand.cxx
@@ -47,7 +47,7 @@ bool cmWriteFileCommand
{
std::string e = "attempted to write a file: " + fileName
+ " into a source directory.";
- this->SetError(e.c_str());
+ this->SetError(e);
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -79,7 +79,7 @@ bool cmWriteFileCommand
std::string error = "Internal CMake error when trying to open file: ";
error += fileName.c_str();
error += " for writing.";
- this->SetError(error.c_str());
+ this->SetError(error);
return false;
}
file << message << std::endl;
diff --git a/Source/cmWriteFileCommand.h b/Source/cmWriteFileCommand.h
index 84a38fc..0d06878 100644
--- a/Source/cmWriteFileCommand.h
+++ b/Source/cmWriteFileCommand.h
@@ -44,7 +44,7 @@ public:
/**
* The name of the command as specified in CMakeList.txt.
*/
- virtual const char* GetName() const { return "write_file";}
+ virtual std::string GetName() const { return "write_file";}
/** This command is kept for compatibility with older CMake versions. */
virtual bool IsDiscouraged() const
diff --git a/Source/cmXCodeObject.cxx b/Source/cmXCodeObject.cxx
index 6abf6bf..3302a8d 100644
--- a/Source/cmXCodeObject.cxx
+++ b/Source/cmXCodeObject.cxx
@@ -108,7 +108,7 @@ void cmXCodeObject::Print(std::ostream& out)
{
out << separator;
}
- std::map<cmStdString, cmXCodeObject*>::iterator i;
+ std::map<std::string, cmXCodeObject*>::iterator i;
cmXCodeObject::Indent(3*indentFactor, out);
out << "isa = " << PBXTypeNames[this->IsA] << ";" << separator;
for(i = this->ObjectAttributes.begin();
@@ -138,7 +138,7 @@ void cmXCodeObject::Print(std::ostream& out)
}
else if(object->TypeValue == ATTRIBUTE_GROUP)
{
- std::map<cmStdString, cmXCodeObject*>::iterator j;
+ std::map<std::string, cmXCodeObject*>::iterator j;
out << i->first << " = {" << separator;
for(j = object->ObjectAttributes.begin(); j !=
object->ObjectAttributes.end(); ++j)
@@ -236,7 +236,7 @@ void cmXCodeObject::CopyAttributes(cmXCodeObject* copy)
}
//----------------------------------------------------------------------------
-void cmXCodeObject::PrintString(std::ostream& os,cmStdString String)
+void cmXCodeObject::PrintString(std::ostream& os,std::string String)
{
// The string needs to be quoted if it contains any characters
// considered special by the Xcode project file parser.
@@ -266,7 +266,7 @@ void cmXCodeObject::PrintString(std::ostream& os) const
}
//----------------------------------------------------------------------------
-void cmXCodeObject::SetString(const char* s)
+void cmXCodeObject::SetString(const std::string& s)
{
this->String = s;
}
diff --git a/Source/cmXCodeObject.h b/Source/cmXCodeObject.h
index b89f78c..ed2940a 100644
--- a/Source/cmXCodeObject.h
+++ b/Source/cmXCodeObject.h
@@ -30,20 +30,20 @@ public:
PBXCopyFilesBuildPhase,
None
};
- class StringVec: public std::vector<cmStdString> {};
+ class StringVec: public std::vector<std::string> {};
static const char* PBXTypeNames[];
virtual ~cmXCodeObject();
cmXCodeObject(PBXType ptype, Type type);
Type GetType() { return this->TypeValue;}
PBXType GetIsA() { return this->IsA;}
- void SetString(const char* s);
- const char* GetString()
+ void SetString(const std::string& s);
+ const std::string& GetString()
{
- return this->String.c_str();
+ return this->String;
}
- void AddAttribute(const char* name, cmXCodeObject* value)
+ void AddAttribute(const std::string& name, cmXCodeObject* value)
{
this->ObjectAttributes[name] = value;
}
@@ -79,11 +79,11 @@ public:
static void PrintList(std::vector<cmXCodeObject*> const&,
std::ostream& out);
- const char* GetId()
+ const std::string& GetId()
{
- return this->Id.c_str();
+ return this->Id;
}
- void SetId(const char* id)
+ void SetId(const std::string& id)
{
this->Id = id;
}
@@ -95,8 +95,8 @@ public:
{
this->Target = t;
}
- const char* GetComment() {return this->Comment.c_str();}
- bool HasComment() { return (this->Comment.size() != 0);}
+ const std::string& GetComment() {return this->Comment;}
+ bool HasComment() { return (!this->Comment.empty());}
cmXCodeObject* GetObject(const char* name)
{
if(this->ObjectAttributes.count(name))
@@ -122,49 +122,41 @@ public:
void CopyAttributes(cmXCodeObject* );
- void AddDependLibrary(const char* configName,
- const char* l)
+ void AddDependLibrary(const std::string& configName,
+ const std::string& l)
{
- if(!configName)
- {
- configName = "";
- }
this->DependLibraries[configName].push_back(l);
}
- std::map<cmStdString, StringVec> const& GetDependLibraries()
+ std::map<std::string, StringVec> const& GetDependLibraries()
{
return this->DependLibraries;
}
- void AddDependTarget(const char* configName,
- const char* tName)
+ void AddDependTarget(const std::string& configName,
+ const std::string& tName)
{
- if(!configName)
- {
- configName = "";
- }
this->DependTargets[configName].push_back(tName);
}
- std::map<cmStdString, StringVec> const& GetDependTargets()
+ std::map<std::string, StringVec> const& GetDependTargets()
{
return this->DependTargets;
}
std::vector<cmXCodeObject*> const& GetObjectList() { return this->List;}
- void SetComment(const char* c) { this->Comment = c;}
- static void PrintString(std::ostream& os,cmStdString String);
+ void SetComment(const std::string& c) { this->Comment = c;}
+ static void PrintString(std::ostream& os,std::string String);
protected:
void PrintString(std::ostream& os) const;
cmTarget* Target;
Type TypeValue;
- cmStdString Id;
+ std::string Id;
PBXType IsA;
int Version;
- cmStdString Comment;
- cmStdString String;
+ std::string Comment;
+ std::string String;
cmXCodeObject* Object;
std::vector<cmXCodeObject*> List;
- std::map<cmStdString, StringVec> DependLibraries;
- std::map<cmStdString, StringVec> DependTargets;
- std::map<cmStdString, cmXCodeObject*> ObjectAttributes;
+ std::map<std::string, StringVec> DependLibraries;
+ std::map<std::string, StringVec> DependTargets;
+ std::map<std::string, cmXCodeObject*> ObjectAttributes;
};
#endif
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index 0c53440..a73fd70 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -152,14 +152,14 @@ int cmXMLParser::ParsingComplete()
}
//----------------------------------------------------------------------------
-void cmXMLParser::StartElement(const char * name,
+void cmXMLParser::StartElement(const std::string& name,
const char ** /*atts*/)
{
std::cout << "Start element: " << name << std::endl;
}
//----------------------------------------------------------------------------
-void cmXMLParser::EndElement(const char * name)
+void cmXMLParser::EndElement(const std::string& name)
{
std::cout << "End element: " << name << std::endl;
}
diff --git a/Source/cmXMLParser.h b/Source/cmXMLParser.h
index d916075..84a5a7d 100644
--- a/Source/cmXMLParser.h
+++ b/Source/cmXMLParser.h
@@ -74,11 +74,11 @@ protected:
* element. atts = Null-terminated array of attribute name/value pairs.
* Even indices are attribute names, and odd indices are values.
*/
- virtual void StartElement(const char* name, const char** atts);
+ virtual void StartElement(const std::string& name, const char** atts);
//! Called at the end of an element in the XML source opened when
//StartElement was called.
- virtual void EndElement(const char* name);
+ virtual void EndElement(const std::string& name);
//! Called when there is character data to handle.
virtual void CharacterDataHandler(const char* data, int length);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index abbabe7..7aada4b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -24,6 +24,7 @@
#if defined(CMAKE_BUILD_WITH_CMAKE)
# include "cmGraphVizWriter.h"
# include "cmVariableWatch.h"
+# include <cmsys/SystemInformation.hxx>
#endif
#include <cmsys/Glob.hxx>
@@ -60,13 +61,15 @@
# include "cmGlobalBorlandMakefileGenerator.h"
# include "cmGlobalNMakeMakefileGenerator.h"
# include "cmGlobalJOMMakefileGenerator.h"
-# include "cmGlobalWatcomWMakeGenerator.h"
# define CMAKE_HAVE_VS_GENERATORS
# endif
# include "cmGlobalMSYSMakefileGenerator.h"
# include "cmGlobalMinGWMakefileGenerator.h"
#else
#endif
+#if defined(CMAKE_USE_WMAKE)
+# include "cmGlobalWatcomWMakeGenerator.h"
+#endif
#include "cmGlobalUnixMakefileGenerator3.h"
#include "cmGlobalNinjaGenerator.h"
#include "cmExtraCodeLiteGenerator.h"
@@ -221,13 +224,13 @@ void cmake::CleanupCommandsAndMacros()
}
}
-bool cmake::CommandExists(const char* name) const
+bool cmake::CommandExists(const std::string& name) const
{
std::string sName = cmSystemTools::LowerCase(name);
return (this->Commands.find(sName) != this->Commands.end());
}
-cmCommand *cmake::GetCommand(const char *name)
+cmCommand *cmake::GetCommand(const std::string& name)
{
cmCommand* rm = 0;
std::string sName = cmSystemTools::LowerCase(name);
@@ -239,7 +242,8 @@ cmCommand *cmake::GetCommand(const char *name)
return rm;
}
-void cmake::RenameCommand(const char*oldName, const char* newName)
+void cmake::RenameCommand(const std::string& oldName,
+ const std::string& newName)
{
// if the command already exists, free the old one
std::string sOldName = cmSystemTools::LowerCase(oldName);
@@ -262,7 +266,7 @@ void cmake::RenameCommand(const char*oldName, const char* newName)
this->Commands.erase(pos);
}
-void cmake::RemoveCommand(const char* name)
+void cmake::RemoveCommand(const std::string& name)
{
std::string sName = cmSystemTools::LowerCase(name);
RegisteredCommandsMap::iterator pos = this->Commands.find(sName);
@@ -305,7 +309,7 @@ void cmake::RemoveUnscriptableCommands()
it != unscriptableCommands.end();
++it)
{
- this->RemoveCommand(it->c_str());
+ this->RemoveCommand(*it);
}
}
@@ -334,23 +338,23 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
std::string var, value;
cmCacheManager::CacheEntryType type = cmCacheManager::UNINITIALIZED;
- if(cmCacheManager::ParseEntry(entry.c_str(), var, value, type))
+ if(cmCacheManager::ParseEntry(entry, var, value, type))
{
// The value is transformed if it is a filepath for example, so
// we can't compare whether the value is already in the cache until
// after we call AddCacheEntry.
const char *cachedValue =
- this->CacheManager->GetCacheValue(var.c_str());
+ this->CacheManager->GetCacheValue(var);
- this->CacheManager->AddCacheEntry(var.c_str(), value.c_str(),
+ this->CacheManager->AddCacheEntry(var, value.c_str(),
"No help, variable specified on the command line.", type);
if(this->WarnUnusedCli)
{
if (!cachedValue
- || strcmp(this->CacheManager->GetCacheValue(var.c_str()),
+ || strcmp(this->CacheManager->GetCacheValue(var),
cachedValue) != 0)
{
- this->WatchUnusedCli(var.c_str());
+ this->WatchUnusedCli(var);
}
}
}
@@ -389,7 +393,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
}
}
cmsys::RegularExpression regex(
- cmsys::Glob::PatternToRegex(entryPattern.c_str(), true, true).c_str());
+ cmsys::Glob::PatternToRegex(entryPattern, true, true).c_str());
//go through all cache entries and collect the vars which will be removed
std::vector<std::string> entriesToDelete;
cmCacheManager::CacheIterator it =
@@ -413,7 +417,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
currentEntry != entriesToDelete.end();
++currentEntry)
{
- this->CacheManager->RemoveCacheEntry(currentEntry->c_str());
+ this->CacheManager->RemoveCacheEntry(*currentEntry);
}
}
else if(arg.find("-C",0) == 0)
@@ -432,7 +436,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args)
return false;
}
}
- std::cerr << "loading initial cache file " << path.c_str() << "\n";
+ std::cerr << "loading initial cache file " << path << "\n";
this->ReadListFile(args, path.c_str());
}
else if(arg.find("-P",0) == 0)
@@ -485,13 +489,13 @@ void cmake::ReadListFile(const std::vector<std::string>& args,
{
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
lg->GetMakefile()->SetHomeOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetStartOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetHomeDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
lg->GetMakefile()->SetStartDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
if (this->GetWorkingMode() != NORMAL_MODE)
{
std::string file(cmSystemTools::CollapseFullPath(path));
@@ -525,13 +529,13 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmsys::auto_ptr<cmLocalGenerator> lg(gg->CreateLocalGenerator());
cmMakefile* mf = lg->GetMakefile();
mf->SetHomeOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
mf->SetStartOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
mf->SetHomeDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
mf->SetStartDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
mf->SetArgcArgv(args);
@@ -565,7 +569,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
cmSystemTools::ExpandListArgument(includes, includeDirs);
std::string includeFlags = lg->GetIncludeFlags(includeDirs, 0,
- language.c_str(), false);
+ language, false);
std::string definitions = mf->GetSafeDefinition("PACKAGE_DEFINITIONS");
printf("%s %s\n", includeFlags.c_str(), definitions.c_str());
@@ -584,7 +588,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
libIt != libList.end();
++libIt)
{
- mf->AddLinkLibraryForTarget(targetName, libIt->c_str(),
+ mf->AddLinkLibraryForTarget(targetName, *libIt,
cmTarget::GENERAL);
}
@@ -597,7 +601,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
gg->CreateGeneratorTargets(mf);
cmGeneratorTarget *gtgt = gg->GetGeneratorTarget(tgt);
lg->GetTargetFlags(linkLibs, frameworkPath, linkPath, flags, linkFlags,
- gtgt);
+ gtgt, false);
linkLibs = frameworkPath + linkPath + linkLibs;
printf("%s\n", linkLibs.c_str() );
@@ -635,7 +639,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
std::string path = arg.substr(2);
path = cmSystemTools::CollapseFullPath(path.c_str());
cmSystemTools::ConvertToUnixSlashes(path);
- this->SetHomeDirectory(path.c_str());
+ this->SetHomeDirectory(path);
}
else if(arg.find("-S",0) == 0)
{
@@ -651,7 +655,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
std::string path = arg.substr(2);
path = cmSystemTools::CollapseFullPath(path.c_str());
cmSystemTools::ConvertToUnixSlashes(path);
- this->SetHomeOutputDirectory(path.c_str());
+ this->SetHomeOutputDirectory(path);
}
else if((i < args.size()-2) && (arg.find("--check-build-system",0) == 0))
{
@@ -789,7 +793,7 @@ void cmake::SetArgs(const std::vector<std::string>& args,
value = args[i];
}
cmGlobalGenerator* gen =
- this->CreateGlobalGenerator(value.c_str());
+ this->CreateGlobalGenerator(value);
if(!gen)
{
cmSystemTools::Error("Could not create named generator ",
@@ -810,13 +814,13 @@ void cmake::SetArgs(const std::vector<std::string>& args,
if(!directoriesSet)
{
this->SetHomeOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
this->SetStartOutputDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
this->SetHomeDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
this->SetStartDirectory
- (cmSystemTools::GetCurrentWorkingDirectory().c_str());
+ (cmSystemTools::GetCurrentWorkingDirectory());
}
this->SetStartDirectory(this->GetHomeDirectory());
@@ -852,15 +856,15 @@ void cmake::SetDirectoriesFromFile(const char* arg)
{
argIsFile = true;
std::string fullPath = cmSystemTools::CollapseFullPath(arg);
- std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
+ std::string name = cmSystemTools::GetFilenameName(fullPath);
name = cmSystemTools::LowerCase(name);
if(name == "cmakecache.txt")
{
- cachePath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+ cachePath = cmSystemTools::GetFilenamePath(fullPath);
}
else if(name == "cmakelists.txt")
{
- listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+ listPath = cmSystemTools::GetFilenamePath(fullPath);
}
}
else
@@ -868,12 +872,12 @@ void cmake::SetDirectoriesFromFile(const char* arg)
// Specified file or directory does not exist. Try to set things
// up to produce a meaningful error message.
std::string fullPath = cmSystemTools::CollapseFullPath(arg);
- std::string name = cmSystemTools::GetFilenameName(fullPath.c_str());
+ std::string name = cmSystemTools::GetFilenameName(fullPath);
name = cmSystemTools::LowerCase(name);
if(name == "cmakecache.txt" || name == "cmakelists.txt")
{
argIsFile = true;
- listPath = cmSystemTools::GetFilenamePath(fullPath.c_str());
+ listPath = cmSystemTools::GetFilenamePath(fullPath);
}
else
{
@@ -886,11 +890,11 @@ void cmake::SetDirectoriesFromFile(const char* arg)
{
cmCacheManager* cachem = this->GetCacheManager();
cmCacheManager::CacheIterator it = cachem->NewIterator();
- if(cachem->LoadCache(cachePath.c_str()) &&
+ if(cachem->LoadCache(cachePath) &&
it.Find("CMAKE_HOME_DIRECTORY"))
{
- this->SetHomeOutputDirectory(cachePath.c_str());
- this->SetStartOutputDirectory(cachePath.c_str());
+ this->SetHomeOutputDirectory(cachePath);
+ this->SetStartOutputDirectory(cachePath);
this->SetHomeDirectory(it.GetValue());
this->SetStartDirectory(it.GetValue());
return;
@@ -900,23 +904,23 @@ void cmake::SetDirectoriesFromFile(const char* arg)
// If there is a CMakeLists.txt file, use it as the source tree.
if(listPath.length() > 0)
{
- this->SetHomeDirectory(listPath.c_str());
- this->SetStartDirectory(listPath.c_str());
+ this->SetHomeDirectory(listPath);
+ this->SetStartDirectory(listPath);
if(argIsFile)
{
// Source CMakeLists.txt file given. It was probably dropped
// onto the executable in a GUI. Default to an in-source build.
- this->SetHomeOutputDirectory(listPath.c_str());
- this->SetStartOutputDirectory(listPath.c_str());
+ this->SetHomeOutputDirectory(listPath);
+ this->SetStartOutputDirectory(listPath);
}
else
{
// Source directory given on command line. Use current working
// directory as build tree.
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeOutputDirectory(cwd.c_str());
- this->SetStartOutputDirectory(cwd.c_str());
+ this->SetHomeOutputDirectory(cwd);
+ this->SetStartOutputDirectory(cwd);
}
return;
}
@@ -926,10 +930,10 @@ void cmake::SetDirectoriesFromFile(const char* arg)
// current working directory as the build tree.
std::string full = cmSystemTools::CollapseFullPath(arg);
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
- this->SetHomeDirectory(full.c_str());
- this->SetStartDirectory(full.c_str());
- this->SetHomeOutputDirectory(cwd.c_str());
- this->SetStartOutputDirectory(cwd.c_str());
+ this->SetHomeDirectory(full);
+ this->SetStartDirectory(full);
+ this->SetHomeOutputDirectory(cwd);
+ this->SetStartOutputDirectory(cwd);
}
// at the end of this CMAKE_ROOT and CMAKE_COMMAND should be added to the
@@ -965,7 +969,7 @@ int cmake::AddCMakePaths()
return 1;
}
-void cmake::AddExtraGenerator(const char* name,
+void cmake::AddExtraGenerator(const std::string& name,
CreateExtraGeneratorFunctionType newFunction)
{
cmExternalMakefileProjectGenerator* extraGenerator = newFunction();
@@ -978,8 +982,8 @@ void cmake::AddExtraGenerator(const char* name,
++it )
{
std::string fullName = cmExternalMakefileProjectGenerator::
- CreateFullGeneratorName(it->c_str(), name);
- this->ExtraGenerators[fullName.c_str()] = newFunction;
+ CreateFullGeneratorName(*it, name);
+ this->ExtraGenerators[fullName] = newFunction;
}
delete extraGenerator;
}
@@ -1034,9 +1038,10 @@ void cmake::GetRegisteredGenerators(std::vector<std::string>& names)
}
}
-cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
+cmGlobalGenerator* cmake::CreateGlobalGenerator(const std::string& gname)
{
cmExternalMakefileProjectGenerator* extraGenerator = 0;
+ std::string name = gname;
RegisteredExtraGeneratorsMap::const_iterator extraGenIt =
this->ExtraGenerators.find(name);
if (extraGenIt != this->ExtraGenerators.end())
@@ -1069,13 +1074,13 @@ cmGlobalGenerator* cmake::CreateGlobalGenerator(const char* name)
return generator;
}
-void cmake::SetHomeDirectory(const char* dir)
+void cmake::SetHomeDirectory(const std::string& dir)
{
this->cmHomeDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(this->cmHomeDirectory);
}
-void cmake::SetHomeOutputDirectory(const char* lib)
+void cmake::SetHomeOutputDirectory(const std::string& lib)
{
this->HomeOutputDirectory = lib;
cmSystemTools::ConvertToUnixSlashes(this->HomeOutputDirectory);
@@ -1202,7 +1207,7 @@ struct SaveCacheEntry
cmCacheManager::CacheEntryType type;
};
-int cmake::HandleDeleteCacheVariables(const char* var)
+int cmake::HandleDeleteCacheVariables(const std::string& var)
{
std::vector<std::string> argsSplit;
cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true);
@@ -1228,7 +1233,7 @@ int cmake::HandleDeleteCacheVariables(const char* var)
i++;
save.value = *i;
warning << *i << "\n";
- if(ci.Find(save.key.c_str()))
+ if(ci.Find(save.key))
{
save.type = ci.GetType();
save.help = ci.GetProperty("HELPSTRING");
@@ -1244,7 +1249,7 @@ int cmake::HandleDeleteCacheVariables(const char* var)
for(std::vector<SaveCacheEntry>::iterator i = saved.begin();
i != saved.end(); ++i)
{
- this->AddCacheEntry(i->key.c_str(), i->value.c_str(),
+ this->AddCacheEntry(i->key, i->value.c_str(),
i->help.c_str(), i->type);
}
cmSystemTools::Message(warning.str().c_str());
@@ -1324,8 +1329,9 @@ int cmake::ActualConfigure()
if(genName)
{
std::string fullName = cmExternalMakefileProjectGenerator::
- CreateFullGeneratorName(genName, extraGenName);
- this->GlobalGenerator = this->CreateGlobalGenerator(fullName.c_str());
+ CreateFullGeneratorName(genName,
+ extraGenName ? extraGenName : "");
+ this->GlobalGenerator = this->CreateGlobalGenerator(fullName);
}
if(this->GlobalGenerator)
{
@@ -1408,8 +1414,8 @@ int cmake::ActualConfigure()
message += "\nDoes not match the generator used previously: ";
message += genName;
message +=
- "\nEither remove the CMakeCache.txt file or choose a different"
- " binary directory.";
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
return -2;
}
@@ -1417,13 +1423,13 @@ int cmake::ActualConfigure()
if(!this->CacheManager->GetCacheValue("CMAKE_GENERATOR"))
{
this->CacheManager->AddCacheEntry("CMAKE_GENERATOR",
- this->GlobalGenerator->GetName(),
+ this->GlobalGenerator->GetName().c_str(),
"Name of generator.",
cmCacheManager::INTERNAL);
this->CacheManager->AddCacheEntry("CMAKE_EXTRA_GENERATOR",
- this->GlobalGenerator->GetExtraGeneratorName(),
- "Name of external makefile project generator.",
- cmCacheManager::INTERNAL);
+ this->GlobalGenerator->GetExtraGeneratorName().c_str(),
+ "Name of external makefile project generator.",
+ cmCacheManager::INTERNAL);
}
if(const char* tsName =
@@ -1440,8 +1446,8 @@ int cmake::ActualConfigure()
message += "\nDoes not match the toolset used previously: ";
message += tsName;
message +=
- "\nEither remove the CMakeCache.txt file or choose a different"
- " binary directory.";
+ "\nEither remove the CMakeCache.txt file and CMakeFiles "
+ "directory or choose a different binary directory.";
cmSystemTools::Error(message.c_str());
return -2;
}
@@ -1689,8 +1695,8 @@ int cmake::Run(const std::vector<std::string>& args, bool noconfigure)
{
return ret;
}
- this->SetStartDirectory(oldstartdir.c_str());
- this->SetStartOutputDirectory(oldstartoutputdir.c_str());
+ this->SetStartDirectory(oldstartdir);
+ this->SetStartOutputDirectory(oldstartoutputdir);
return ret;
}
@@ -1725,7 +1731,7 @@ int cmake::Generate()
return 0;
}
-void cmake::AddCacheEntry(const char* key, const char* value,
+void cmake::AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
int type)
{
@@ -1734,7 +1740,7 @@ void cmake::AddCacheEntry(const char* key, const char* value,
cmCacheManager::CacheEntryType(type));
}
-const char* cmake::GetCacheDefinition(const char* name) const
+const char* cmake::GetCacheDefinition(const std::string& name) const
{
return this->CacheManager->GetCacheValue(name);
}
@@ -1778,8 +1784,6 @@ void cmake::AddDefaultGenerators()
cmGlobalNMakeMakefileGenerator::NewFactory());
this->Generators.push_back(
cmGlobalJOMMakefileGenerator::NewFactory());
- this->Generators.push_back(
- cmGlobalWatcomWMakeGenerator::NewFactory());
# endif
this->Generators.push_back(
cmGlobalMSYSMakefileGenerator::NewFactory());
@@ -1790,6 +1794,10 @@ void cmake::AddDefaultGenerators()
cmGlobalUnixMakefileGenerator3::NewFactory());
this->Generators.push_back(
cmGlobalNinjaGenerator::NewFactory());
+#if defined(CMAKE_USE_WMAKE)
+ this->Generators.push_back(
+ cmGlobalWatcomWMakeGenerator::NewFactory());
+#endif
#ifdef CMAKE_USE_XCODE
this->Generators.push_back(
cmGlobalXCodeGenerator::NewFactory());
@@ -1851,7 +1859,7 @@ void cmake::GetGeneratorDocumentation(std::vector<cmDocumentationEntry>& v)
{
cmDocumentationEntry e;
cmExternalMakefileProjectGenerator* generator = (i->second)();
- generator->GetDocumentation(e, i->first.c_str());
+ generator->GetDocumentation(e, i->first);
e.Name = i->first;
delete generator;
v.push_back(e);
@@ -1919,7 +1927,7 @@ int cmake::CheckBuildSystem()
{
cmOStringStream msg;
msg << "Re-run cmake missing file: "
- << this->CheckBuildSystemArgument.c_str() << "\n";
+ << this->CheckBuildSystemArgument << "\n";
cmSystemTools::Stdout(msg.str().c_str());
}
return 1;
@@ -1939,7 +1947,7 @@ int cmake::CheckBuildSystem()
{
cmOStringStream msg;
msg << "Re-run cmake error reading : "
- << this->CheckBuildSystemArgument.c_str() << "\n";
+ << this->CheckBuildSystemArgument << "\n";
cmSystemTools::Stdout(msg.str().c_str());
}
// There was an error reading the file. Just rerun.
@@ -2073,8 +2081,8 @@ int cmake::CheckBuildSystem()
if(verbose)
{
cmOStringStream msg;
- msg << "Re-run cmake file: " << out_oldest.c_str()
- << " older than: " << dep_newest.c_str() << "\n";
+ msg << "Re-run cmake file: " << out_oldest
+ << " older than: " << dep_newest << "\n";
cmSystemTools::Stdout(msg.str().c_str());
}
return 1;
@@ -2144,7 +2152,8 @@ void cmake::GenerateGraphViz(const char* fileName) const
#endif
}
-void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope,
+void cmake::DefineProperty(const std::string& name,
+ cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chained)
@@ -2155,7 +2164,7 @@ void cmake::DefineProperty(const char *name, cmProperty::ScopeType scope,
}
cmPropertyDefinition *cmake
-::GetPropertyDefinition(const char *name,
+::GetPropertyDefinition(const std::string& name,
cmProperty::ScopeType scope)
{
if (this->IsPropertyDefined(name,scope))
@@ -2165,25 +2174,22 @@ cmPropertyDefinition *cmake
return 0;
}
-bool cmake::IsPropertyDefined(const char *name, cmProperty::ScopeType scope)
+bool cmake::IsPropertyDefined(const std::string& name,
+ cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyDefined(name);
}
-bool cmake::IsPropertyChained(const char *name, cmProperty::ScopeType scope)
+bool cmake::IsPropertyChained(const std::string& name,
+ cmProperty::ScopeType scope)
{
return this->PropertyDefinitions[scope].IsPropertyChained(name);
}
-void cmake::SetProperty(const char* prop, const char* value)
+void cmake::SetProperty(const std::string& prop, const char* value)
{
- if (!prop)
- {
- return;
- }
-
// Special hook to invalidate cached value.
- if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
+ if(prop == "DEBUG_CONFIGURATIONS")
{
this->DebugConfigs.clear();
}
@@ -2191,15 +2197,11 @@ void cmake::SetProperty(const char* prop, const char* value)
this->Properties.SetProperty(prop, value, cmProperty::GLOBAL);
}
-void cmake::AppendProperty(const char* prop, const char* value, bool asString)
+void cmake::AppendProperty(const std::string& prop,
+ const char* value, bool asString)
{
- if (!prop)
- {
- return;
- }
-
// Special hook to invalidate cached value.
- if(strcmp(prop, "DEBUG_CONFIGURATIONS") == 0)
+ if(prop == "DEBUG_CONFIGURATIONS")
{
this->DebugConfigs.clear();
}
@@ -2207,23 +2209,19 @@ void cmake::AppendProperty(const char* prop, const char* value, bool asString)
this->Properties.AppendProperty(prop, value, cmProperty::GLOBAL, asString);
}
-const char *cmake::GetProperty(const char* prop)
+const char *cmake::GetProperty(const std::string& prop)
{
return this->GetProperty(prop, cmProperty::GLOBAL);
}
-const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
+const char *cmake::GetProperty(const std::string& prop,
+ cmProperty::ScopeType scope)
{
- if(!prop)
- {
- return 0;
- }
bool chain = false;
// watch for special properties
- std::string propname = prop;
std::string output = "";
- if ( propname == "CACHE_VARIABLES" )
+ if ( prop == "CACHE_VARIABLES" )
{
cmCacheManager::CacheIterator cit =
this->GetCacheManager()->GetCacheIterator();
@@ -2237,7 +2235,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
}
this->SetProperty("CACHE_VARIABLES", output.c_str());
}
- else if ( propname == "COMMANDS" )
+ else if ( prop == "COMMANDS" )
{
cmake::RegisteredCommandsMap::iterator cmds
= this->GetCommands()->begin();
@@ -2252,12 +2250,12 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
}
this->SetProperty("COMMANDS",output.c_str());
}
- else if ( propname == "IN_TRY_COMPILE" )
+ else if ( prop == "IN_TRY_COMPILE" )
{
this->SetProperty("IN_TRY_COMPILE",
this->GetIsInTryCompile()? "1":"0");
}
- else if ( propname == "ENABLED_LANGUAGES" )
+ else if ( prop == "ENABLED_LANGUAGES" )
{
std::string lang;
if(this->GlobalGenerator)
@@ -2278,7 +2276,7 @@ const char *cmake::GetProperty(const char* prop, cmProperty::ScopeType scope)
return this->Properties.GetPropertyValue(prop, scope, chain);
}
-bool cmake::GetPropertyAsBool(const char* prop)
+bool cmake::GetPropertyAsBool(const std::string& prop)
{
return cmSystemTools::IsOn(this->GetProperty(prop));
}
@@ -2320,7 +2318,7 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
value = args[i];
}
cmGlobalGenerator* gen =
- this->CreateGlobalGenerator(value.c_str());
+ this->CreateGlobalGenerator(value);
if(!gen)
{
cmSystemTools::Error("Could not create named generator ",
@@ -2358,8 +2356,8 @@ int cmake::GetSystemInformation(std::vector<std::string>& args)
// Copy file
if(!cmSystemTools::cmCopyFile(inFile.c_str(), outFile.c_str()))
{
- std::cerr << "Error copying file \"" << inFile.c_str()
- << "\" to \"" << outFile.c_str() << "\".\n";
+ std::cerr << "Error copying file \"" << inFile
+ << "\" to \"" << outFile << "\".\n";
return 1;
}
@@ -2604,6 +2602,22 @@ void cmake::IssueMessage(cmake::MessageType t, std::string const& text,
// Add a terminating blank line.
msg << "\n";
+#if defined(CMAKE_BUILD_WITH_CMAKE)
+ // Add a C++ stack trace to internal errors.
+ if(t == cmake::INTERNAL_ERROR)
+ {
+ std::string stack = cmsys::SystemInformation::GetProgramStack(0,0);
+ if(!stack.empty())
+ {
+ if(cmHasLiteralPrefix(stack, "WARNING:"))
+ {
+ stack = "Note:" + stack.substr(8);
+ }
+ msg << stack << "\n";
+ }
+ }
+#endif
+
// Output the message.
if(isError)
{
@@ -2657,7 +2671,7 @@ int cmake::Build(const std::string& dir,
cmSystemTools::ConvertToUnixSlashes(cachePath);
cmCacheManager* cachem = this->GetCacheManager();
cmCacheManager::CacheIterator it = cachem->NewIterator();
- if(!cachem->LoadCache(cachePath.c_str()))
+ if(!cachem->LoadCache(cachePath))
{
std::cerr << "Error: could not load cache\n";
return 1;
@@ -2677,16 +2691,16 @@ int cmake::Build(const std::string& dir,
return 1;
}
projName = it.GetValue();
- return gen->Build(0, dir.c_str(),
- projName.c_str(), target.c_str(),
+ return gen->Build("", dir,
+ projName, target,
&output,
- 0,
- config.c_str(), clean, false, 0,
+ "",
+ config, clean, false, 0,
cmSystemTools::OUTPUT_PASSTHROUGH,
nativeOptions);
}
-void cmake::WatchUnusedCli(const char* var)
+void cmake::WatchUnusedCli(const std::string& var)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this);
@@ -2697,7 +2711,7 @@ void cmake::WatchUnusedCli(const char* var)
#endif
}
-void cmake::UnwatchUnusedCli(const char* var)
+void cmake::UnwatchUnusedCli(const std::string& var)
{
#ifdef CMAKE_BUILD_WITH_CMAKE
this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning);
@@ -2711,7 +2725,7 @@ void cmake::RunCheckForUnusedVariables()
bool haveUnused = false;
cmOStringStream msg;
msg << "Manually-specified variables were not used by the project:";
- for(std::map<cmStdString, bool>::const_iterator
+ for(std::map<std::string, bool>::const_iterator
it = this->UsedCliVariables.begin();
it != this->UsedCliVariables.end(); ++it)
{
diff --git a/Source/cmake.h b/Source/cmake.h
index dfec55c..76a3179 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -91,16 +91,16 @@ class cmake
*/
FIND_PACKAGE_MODE
};
- typedef std::map<cmStdString, cmCommand*> RegisteredCommandsMap;
+ typedef std::map<std::string, cmCommand*> RegisteredCommandsMap;
/// Default constructor
cmake();
/// Destructor
~cmake();
- static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";};
+ static const char *GetCMakeFilesDirectory() {return "/CMakeFiles";}
static const char *GetCMakeFilesDirectoryPostSlash() {
- return "CMakeFiles/";};
+ return "CMakeFiles/";}
//@{
/**
@@ -110,12 +110,12 @@ class cmake
* CMakeLists files by recursing up the tree starting at the StartDirectory
* and going up until it reaches the HomeDirectory.
*/
- void SetHomeDirectory(const char* dir);
+ void SetHomeDirectory(const std::string& dir);
const char* GetHomeDirectory() const
{
return this->cmHomeDirectory.c_str();
}
- void SetHomeOutputDirectory(const char* lib);
+ void SetHomeOutputDirectory(const std::string& lib);
const char* GetHomeOutputDirectory() const
{
return this->HomeOutputDirectory.c_str();
@@ -130,7 +130,7 @@ class cmake
* recursing up the tree starting at the StartDirectory and going up until
* it reaches the HomeDirectory.
*/
- void SetStartDirectory(const char* dir)
+ void SetStartDirectory(const std::string& dir)
{
this->cmStartDirectory = dir;
cmSystemTools::ConvertToUnixSlashes(this->cmStartDirectory);
@@ -139,7 +139,7 @@ class cmake
{
return this->cmStartDirectory.c_str();
}
- void SetStartOutputDirectory(const char* lib)
+ void SetStartOutputDirectory(const std::string& lib)
{
this->StartOutputDirectory = lib;
cmSystemTools::ConvertToUnixSlashes(this->StartOutputDirectory);
@@ -175,7 +175,7 @@ class cmake
void PreLoadCMakeFiles();
///! Create a GlobalGenerator
- cmGlobalGenerator* CreateGlobalGenerator(const char* name);
+ cmGlobalGenerator* CreateGlobalGenerator(const std::string& name);
///! Return the global generator assigned to this instance of cmake
cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; }
@@ -203,9 +203,9 @@ class cmake
/**
* Given a variable name, return its value (as a string).
*/
- const char* GetCacheDefinition(const char*) const;
+ const char* GetCacheDefinition(const std::string&) const;
///! Add an entry into the cache
- void AddCacheEntry(const char* key, const char* value,
+ void AddCacheEntry(const std::string& key, const char* value,
const char* helpString,
int type);
@@ -218,20 +218,20 @@ class cmake
* Add a command to this cmake instance
*/
void AddCommand(cmCommand* );
- void RenameCommand(const char* oldName, const char* newName);
- void RemoveCommand(const char* name);
+ void RenameCommand(const std::string& oldName, const std::string& newName);
+ void RemoveCommand(const std::string& name);
void RemoveUnscriptableCommands();
/**
* Get a command by its name
*/
- cmCommand *GetCommand(const char *name);
+ cmCommand *GetCommand(const std::string& name);
/** Get list of all commands */
RegisteredCommandsMap* GetCommands() { return &this->Commands; }
/** Check if a command exists. */
- bool CommandExists(const char* name) const;
+ bool CommandExists(const std::string& name) const;
///! Parse command line arguments
void SetArgs(const std::vector<std::string>&,
@@ -261,7 +261,7 @@ class cmake
void UpdateProgress(const char *msg, float prog);
///! get the cmake policies instance
- cmPolicies *GetPolicies() {return this->Policies;} ;
+ cmPolicies *GetPolicies() {return this->Policies;}
///! Get the variable watch object
cmVariableWatch* GetVariableWatch() { return this->VariableWatch; }
@@ -269,14 +269,16 @@ class cmake
void GetGeneratorDocumentation(std::vector<cmDocumentationEntry>&);
///! Set/Get a property of this target file
- void SetProperty(const char *prop, const char *value);
- void AppendProperty(const char *prop, const char *value,bool asString=false);
- const char *GetProperty(const char *prop);
- const char *GetProperty(const char *prop, cmProperty::ScopeType scope);
- bool GetPropertyAsBool(const char *prop);
+ void SetProperty(const std::string& prop, const char *value);
+ void AppendProperty(const std::string& prop,
+ const char *value,bool asString=false);
+ const char *GetProperty(const std::string& prop);
+ const char *GetProperty(const std::string& prop,
+ cmProperty::ScopeType scope);
+ bool GetPropertyAsBool(const std::string& prop);
// Get the properties
- cmPropertyMap &GetProperties() { return this->Properties; };
+ cmPropertyMap &GetProperties() { return this->Properties; }
///! Do all the checks before running configure
int DoPreConfigureChecks();
@@ -317,18 +319,18 @@ class cmake
void MarkCliAsUsed(const std::string& variable);
// Define a property
- void DefineProperty(const char *name, cmProperty::ScopeType scope,
+ void DefineProperty(const std::string& name, cmProperty::ScopeType scope,
const char *ShortDescription,
const char *FullDescription,
bool chain = false);
// get property definition
cmPropertyDefinition *GetPropertyDefinition
- (const char *name, cmProperty::ScopeType scope);
+ (const std::string& name, cmProperty::ScopeType scope);
// Is a property defined?
- bool IsPropertyDefined(const char *name, cmProperty::ScopeType scope);
- bool IsPropertyChained(const char *name, cmProperty::ScopeType scope);
+ bool IsPropertyDefined(const std::string& name, cmProperty::ScopeType scope);
+ bool IsPropertyChained(const std::string& name, cmProperty::ScopeType scope);
/** Get the list of configurations (in upper case) considered to be
debugging configurations.*/
@@ -355,21 +357,21 @@ class cmake
const std::vector<std::string>& nativeOptions,
bool clean);
- void UnwatchUnusedCli(const char* var);
- void WatchUnusedCli(const char* var);
+ void UnwatchUnusedCli(const std::string& var);
+ void WatchUnusedCli(const std::string& var);
protected:
void RunCheckForUnusedVariables();
void InitializeProperties();
- int HandleDeleteCacheVariables(const char* var);
+ int HandleDeleteCacheVariables(const std::string& var);
cmPropertyMap Properties;
- std::set<std::pair<cmStdString,cmProperty::ScopeType> > AccessedProperties;
+ std::set<std::pair<std::string,cmProperty::ScopeType> > AccessedProperties;
std::map<cmProperty::ScopeType, cmPropertyDefinitionMap>
PropertyDefinitions;
typedef
cmExternalMakefileProjectGenerator* (*CreateExtraGeneratorFunctionType)();
- typedef std::map<cmStdString,
+ typedef std::map<std::string,
CreateExtraGeneratorFunctionType> RegisteredExtraGeneratorsMap;
typedef std::vector<cmGlobalGeneratorFactory*> RegisteredGeneratorsVector;
RegisteredCommandsMap Commands;
@@ -378,7 +380,7 @@ protected:
void AddDefaultCommands();
void AddDefaultGenerators();
void AddDefaultExtraGenerators();
- void AddExtraGenerator(const char* name,
+ void AddExtraGenerator(const std::string& name,
CreateExtraGeneratorFunctionType newFunction);
cmPolicies *Policies;
@@ -430,7 +432,7 @@ private:
bool WarnUnused;
bool WarnUnusedCli;
bool CheckSystemVars;
- std::map<cmStdString, bool> UsedCliVariables;
+ std::map<std::string, bool> UsedCliVariables;
std::string CMakeEditCommand;
std::string CXXEnvironment;
std::string CCEnvironment;
diff --git a/Source/cmcldeps.cxx b/Source/cmcldeps.cxx
index faa5fa7..55fc633 100644
--- a/Source/cmcldeps.cxx
+++ b/Source/cmcldeps.cxx
@@ -198,7 +198,7 @@ static int process( const std::string& srcfilename,
std::vector<std::string> args;
cmSystemTools::ParseWindowsCommandLine(cmd.c_str(), args);
// convert to correct vector type for RunSingleCommand
- std::vector<cmStdString> command;
+ std::vector<std::string> command;
for(std::vector<std::string>::iterator i = args.begin();
i != args.end(); ++i)
{
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 4ac1986..9aee975 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -102,8 +102,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
if(!cmSystemTools::cmCopyFile(args[2].c_str(), args[3].c_str()))
{
- std::cerr << "Error copying file \"" << args[2].c_str()
- << "\" to \"" << args[3].c_str() << "\".\n";
+ std::cerr << "Error copying file \"" << args[2]
+ << "\" to \"" << args[3] << "\".\n";
return 1;
}
return 0;
@@ -116,7 +116,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
args[3].c_str()))
{
std::cerr << "Error copying file (if different) from \""
- << args[2].c_str() << "\" to \"" << args[3].c_str()
+ << args[2] << "\" to \"" << args[3]
<< "\".\n";
return 1;
}
@@ -129,7 +129,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if(!cmSystemTools::CopyADirectory(args[2].c_str(), args[3].c_str()))
{
std::cerr << "Error copying directory from \""
- << args[2].c_str() << "\" to \"" << args[3].c_str()
+ << args[2] << "\" to \"" << args[3]
<< "\".\n";
return 1;
}
@@ -143,7 +143,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
std::string e = cmSystemTools::GetLastSystemError();
std::cerr << "Error renaming from \""
- << args[2].c_str() << "\" to \"" << args[3].c_str()
+ << args[2] << "\" to \"" << args[3]
<< "\": " << e << "\n";
return 1;
}
@@ -156,7 +156,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if(cmSystemTools::FilesDiffer(args[2].c_str(), args[3].c_str()))
{
std::cerr << "Files \""
- << args[2].c_str() << "\" to \"" << args[3].c_str()
+ << args[2] << "\" to \"" << args[3]
<< "\" are different.\n";
return 1;
}
@@ -199,7 +199,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
std::vector<std::string>::iterator it;
for ( it = env.begin(); it != env.end(); ++ it )
{
- std::cout << it->c_str() << std::endl;
+ std::cout << *it << std::endl;
}
return 0;
}
@@ -209,7 +209,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
if(!cmSystemTools::MakeDirectory(args[2].c_str()))
{
- std::cerr << "Error making directory \"" << args[2].c_str()
+ std::cerr << "Error making directory \"" << args[2]
<< "\".\n";
return 1;
}
@@ -221,7 +221,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
if(cmSystemTools::FileIsDirectory(args[2].c_str()) &&
!cmSystemTools::RemoveADirectory(args[2].c_str()))
{
- std::cerr << "Error removing directory \"" << args[2].c_str()
+ std::cerr << "Error removing directory \"" << args[2]
<< "\".\n";
return 1;
}
@@ -613,16 +613,16 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
startDir = cmSystemTools::CollapseFullPath(startDir.c_str());
homeOutDir = cmSystemTools::CollapseFullPath(homeOutDir.c_str());
startOutDir = cmSystemTools::CollapseFullPath(startOutDir.c_str());
- cm.SetHomeDirectory(homeDir.c_str());
- cm.SetStartDirectory(startDir.c_str());
- cm.SetHomeOutputDirectory(homeOutDir.c_str());
- cm.SetStartOutputDirectory(startOutDir.c_str());
- if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen.c_str()))
+ cm.SetHomeDirectory(homeDir);
+ cm.SetStartDirectory(startDir);
+ cm.SetHomeOutputDirectory(homeOutDir);
+ cm.SetStartOutputDirectory(startOutDir);
+ if(cmGlobalGenerator* ggd = cm.CreateGlobalGenerator(gen))
{
cm.SetGlobalGenerator(ggd);
cmsys::auto_ptr<cmLocalGenerator> lgd(ggd->CreateLocalGenerator());
- lgd->GetMakefile()->SetStartDirectory(startDir.c_str());
- lgd->GetMakefile()->SetStartOutputDirectory(startOutDir.c_str());
+ lgd->GetMakefile()->SetStartDirectory(startDir);
+ lgd->GetMakefile()->SetStartOutputDirectory(startOutDir);
lgd->GetMakefile()->MakeStartDirectoriesCurrent();
// Actually scan dependencies.
@@ -666,8 +666,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
else if (args[1] == "cmake_autogen" && args.size() >= 4)
{
cmQtAutoGenerators autogen;
- const char *config = args[3].empty() ? 0 : args[3].c_str();
- bool autogenSuccess = autogen.Run(args[2].c_str(), config);
+ std::string const& config = args[3];
+ bool autogenSuccess = autogen.Run(args[2], config);
return autogenSuccess ? 0 : 1;
}
#endif
@@ -677,7 +677,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
{
std::string flags = args[2];
std::string outFile = args[3];
- std::vector<cmStdString> files;
+ std::vector<std::string> files;
for (std::string::size_type cc = 4; cc < args.size(); cc ++)
{
files.push_back(args[cc]);
@@ -1143,7 +1143,7 @@ int cmcmd::VisualStudioLink(std::vector<std::string>& args, int type)
}
int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args,
- std::vector<cmStdString>& command,
+ std::vector<std::string>& command,
std::string& targetName)
{
std::vector<std::string>::iterator i = args.begin();
@@ -1171,17 +1171,17 @@ int cmcmd::ParseVisualStudioLinkCommand(std::vector<std::string>& args,
}
bool cmcmd::RunCommand(const char* comment,
- std::vector<cmStdString>& command,
+ std::vector<std::string>& command,
bool verbose,
int* retCodeOut)
{
if(verbose)
{
std::cout << comment << ":\n";
- for(std::vector<cmStdString>::iterator i = command.begin();
+ for(std::vector<std::string>::iterator i = command.begin();
i != command.end(); ++i)
{
- std::cout << i->c_str() << " ";
+ std::cout << *i << " ";
}
std::cout << "\n";
}
@@ -1239,16 +1239,16 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
// 7. Finally, the Linker does another incremental link, but since the
// only thing that has changed is the *.res file that contains the
// manifest it is a short link.
- std::vector<cmStdString> linkCommand;
+ std::vector<std::string> linkCommand;
std::string targetName;
if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1)
{
return -1;
}
std::string manifestArg = "/MANIFESTFILE:";
- std::vector<cmStdString> rcCommand;
+ std::vector<std::string> rcCommand;
rcCommand.push_back(cmSystemTools::FindProgram("rc.exe"));
- std::vector<cmStdString> mtCommand;
+ std::vector<std::string> mtCommand;
mtCommand.push_back(cmSystemTools::FindProgram("mt.exe"));
std::string tempManifest;
tempManifest = targetName;
@@ -1257,7 +1257,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
resourceInputFile += ".resource.txt";
if(verbose)
{
- std::cout << "Create " << resourceInputFile.c_str() << "\n";
+ std::cout << "Create " << resourceInputFile << "\n";
}
// Create input file for rc command
cmsys::ofstream fout(resourceInputFile.c_str());
@@ -1269,7 +1269,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
manifestFile += ".embed.manifest";
std::string fullPath= cmSystemTools::CollapseFullPath(manifestFile.c_str());
fout << type << " /* CREATEPROCESS_MANIFEST_RESOURCE_ID "
- "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath.c_str() << "\"";
+ "*/ 24 /* RT_MANIFEST */ " << "\"" << fullPath << "\"";
fout.close();
manifestArg += tempManifest;
// add the manifest arg to the linkCommand
@@ -1281,7 +1281,7 @@ int cmcmd::VisualStudioLinkIncremental(std::vector<std::string>& args,
{
if(verbose)
{
- std::cout << "Create empty: " << manifestFile.c_str() << "\n";
+ std::cout << "Create empty: " << manifestFile << "\n";
}
cmsys::ofstream foutTmp(manifestFile.c_str());
}
@@ -1349,7 +1349,7 @@ int cmcmd::VisualStudioLinkNonIncremental(std::vector<std::string>& args,
bool hasManifest,
bool verbose)
{
- std::vector<cmStdString> linkCommand;
+ std::vector<std::string> linkCommand;
std::string targetName;
if(cmcmd::ParseVisualStudioLinkCommand(args, linkCommand, targetName) == -1)
{
@@ -1368,7 +1368,7 @@ int cmcmd::VisualStudioLinkNonIncremental(std::vector<std::string>& args,
{
return 0;
}
- std::vector<cmStdString> mtCommand;
+ std::vector<std::string> mtCommand;
mtCommand.push_back(cmSystemTools::FindProgram("mt.exe"));
mtCommand.push_back("/nologo");
mtCommand.push_back("/manifest");
diff --git a/Source/cmcmd.h b/Source/cmcmd.h
index 4517ebf..2bfbae7 100644
--- a/Source/cmcmd.h
+++ b/Source/cmcmd.h
@@ -43,10 +43,10 @@ protected:
bool hasManifest,
bool verbose);
static int ParseVisualStudioLinkCommand(std::vector<std::string>& args,
- std::vector<cmStdString>& command,
+ std::vector<std::string>& command,
std::string& targetName);
static bool RunCommand(const char* comment,
- std::vector<cmStdString>& command,
+ std::vector<std::string>& command,
bool verbose,
int* retCodeOut = 0);
};
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt
index 24ea518..5e6a226 100644
--- a/Source/kwsys/CMakeLists.txt
+++ b/Source/kwsys/CMakeLists.txt
@@ -299,6 +299,13 @@ IF(NOT CMAKE_COMPILER_IS_GNUCXX)
ENDIF(CMAKE_SYSTEM MATCHES "OSF1-V.*")
IF(CMAKE_SYSTEM MATCHES "HP-UX")
SET(KWSYS_PLATFORM_CXX_TEST_EXTRA_FLAGS "+p")
+ IF(CMAKE_CXX_COMPILER_ID MATCHES "HP")
+ # it is known that version 3.85 fails and 6.25 works without these flags
+ IF(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4)
+ # use new C++ library and improved template support
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -AA +hpxstd98")
+ ENDIF()
+ ENDIF()
ENDIF(CMAKE_SYSTEM MATCHES "HP-UX")
ENDIF(NOT CMAKE_COMPILER_IS_GNUCXX)
@@ -685,6 +692,7 @@ IF(KWSYS_USE_SystemInformation)
# usually it's in libc but on FreeBSD
# it's in libexecinfo
FIND_LIBRARY(EXECINFO_LIB "execinfo")
+ MARK_AS_ADVANCED(EXECINFO_LIB)
IF (NOT EXECINFO_LIB)
SET(EXECINFO_LIB "")
ENDIF()
@@ -1076,6 +1084,11 @@ IF(MSVC OR (WIN32 AND "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$"))
)
ENDIF()
+IF(WIN32)
+ # Help enforce the use of wide Windows apis.
+ ADD_DEFINITIONS(-DUNICODE -D_UNICODE)
+ENDIF()
+
IF(KWSYS_USE_String)
# Activate code in "String.c". See the comment in the source.
SET_SOURCE_FILES_PROPERTIES(String.c PROPERTIES
@@ -1222,6 +1235,9 @@ IF(KWSYS_STANDALONE OR CMake_SOURCE_DIR)
# Some Apple compilers produce bad optimizations in this source.
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
+ SET_PROPERTY(SOURCE testProcess.c PROPERTY COMPILE_FLAGS -qsuppress=1500-010)
ENDIF()
# Test SharedForward
diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx
index f76deb5..251a56d 100644
--- a/Source/kwsys/EncodingCXX.cxx
+++ b/Source/kwsys/EncodingCXX.cxx
@@ -110,16 +110,19 @@ Encoding::CommandLineArguments::
Encoding::CommandLineArguments&
Encoding::CommandLineArguments::operator=(const CommandLineArguments& other)
{
- size_t i;
- for(i=0; i<this->argv_.size(); i++)
+ if(this != &other)
{
- free(this->argv_[i]);
- }
+ size_t i;
+ for(i=0; i<this->argv_.size(); i++)
+ {
+ free(this->argv_[i]);
+ }
- this->argv_.resize(other.argv_.size());
- for(i=0; i<this->argv_.size(); i++)
- {
- this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+ this->argv_.resize(other.argv_.size());
+ for(i=0; i<this->argv_.size(); i++)
+ {
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : 0;
+ }
}
return *this;
diff --git a/Source/kwsys/FStream.cxx b/Source/kwsys/FStream.cxx
new file mode 100644
index 0000000..018652c
--- /dev/null
+++ b/Source/kwsys/FStream.cxx
@@ -0,0 +1,76 @@
+/*============================================================================
+ KWSys - Kitware System Library
+ 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 "kwsysPrivate.h"
+#include KWSYS_HEADER(FStream.hxx)
+
+// Work-around CMake dependency scanning limitation. This must
+// duplicate the above list of headers.
+#if 0
+# include "FStream.hxx.in"
+#endif
+
+namespace KWSYS_NAMESPACE
+{
+namespace FStream
+{
+
+BOM ReadBOM(std::istream& in)
+{
+ if(!in.good())
+ {
+ return BOM_None;
+ }
+ unsigned long orig = in.tellg();
+ unsigned char bom[4];
+ in.read(reinterpret_cast<char*>(bom), 2);
+ if(!in.good())
+ {
+ in.seekg(orig);
+ return BOM_None;
+ }
+ if(bom[0] == 0xEF && bom[1] == 0xBB)
+ {
+ in.read(reinterpret_cast<char*>(bom+2), 1);
+ if(in.good() && bom[2] == 0xBF)
+ {
+ return BOM_UTF8;
+ }
+ }
+ else if(bom[0] == 0xFE && bom[1] == 0xFF)
+ {
+ return BOM_UTF16BE;
+ }
+ else if(bom[0] == 0x00 && bom[1] == 0x00)
+ {
+ in.read(reinterpret_cast<char*>(bom+2), 2);
+ if(in.good() && bom[2] == 0xFE && bom[3] == 0xFF)
+ {
+ return BOM_UTF32BE;
+ }
+ }
+ else if(bom[0] == 0xFF && bom[1] == 0xFE)
+ {
+ unsigned long p = in.tellg();
+ in.read(reinterpret_cast<char*>(bom+2), 2);
+ if(in.good() && bom[2] == 0x00 && bom[3] == 0x00)
+ {
+ return BOM_UTF32LE;
+ }
+ in.seekg(p);
+ return BOM_UTF16LE;
+ }
+ in.seekg(orig);
+ return BOM_None;
+}
+
+} // FStream namespace
+} //KWSYS_NAMESPACE
diff --git a/Source/kwsys/FStream.hxx.in b/Source/kwsys/FStream.hxx.in
index 916a93e..45425ff 100644
--- a/Source/kwsys/FStream.hxx.in
+++ b/Source/kwsys/FStream.hxx.in
@@ -161,13 +161,28 @@ class basic_ofstream : public std::basic_ostream<CharType,Traits>
typedef basic_ofstream<char> ofstream;
#else
- using @KWSYS_NAMESPACE@_ios_namespace::basic_filebuf;
using @KWSYS_NAMESPACE@_ios_namespace::ofstream;
using @KWSYS_NAMESPACE@_ios_namespace::ifstream;
#endif
+ namespace FStream
+ {
+ enum BOM
+ {
+ BOM_None,
+ BOM_UTF8,
+ BOM_UTF16BE,
+ BOM_UTF16LE,
+ BOM_UTF32BE,
+ BOM_UTF32LE
+ };
+
+ // Read a BOM, if one exists.
+ // If a BOM exists, the stream is advanced to after the BOM.
+ // This function requires a seekable stream (but not a relative
+ // seekable stream).
+ BOM ReadBOM(std::istream& in);
+ }
}
-
-
#endif
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index 56776a3..a147057 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -478,11 +478,16 @@ void kwsysMD5_Initialize(kwsysMD5* md5)
/*--------------------------------------------------------------------------*/
void kwsysMD5_Append(kwsysMD5* md5, unsigned char const* data, int length)
{
+ size_t dlen;
if(length < 0)
{
- length = (int)strlen((char const*)data);
+ dlen = strlen((char const*)data);
}
- md5_append(&md5->md5_state, (md5_byte_t const*)data, (size_t)length);
+ else
+ {
+ dlen = (size_t)length;
+ }
+ md5_append(&md5->md5_state, (md5_byte_t const*)data, dlen);
}
/*--------------------------------------------------------------------------*/
diff --git a/Source/kwsys/SharedForward.h.in b/Source/kwsys/SharedForward.h.in
index 8bbc74a..dd4d462 100644
--- a/Source/kwsys/SharedForward.h.in
+++ b/Source/kwsys/SharedForward.h.in
@@ -415,7 +415,7 @@ static int kwsys_shared_forward_realpath(const char* in_path, char* out_path)
{
#if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */
- DWORD n = GetFullPathName(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
+ DWORD n = GetFullPathNameA(in_path, KWSYS_SHARED_FORWARD_MAXPATH,
out_path, 0);
return n > 0 && n <= KWSYS_SHARED_FORWARD_MAXPATH;
#else
@@ -429,9 +429,9 @@ static int kwsys_shared_forward_samepath(const char* file1, const char* file2)
{
#if defined(_WIN32)
int result = 0;
- HANDLE h1 = CreateFile(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
+ HANDLE h1 = CreateFileA(file1, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
- HANDLE h2 = CreateFile(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
+ HANDLE h2 = CreateFileA(file2, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if(h1 != INVALID_HANDLE_VALUE && h2 != INVALID_HANDLE_VALUE)
{
@@ -462,7 +462,7 @@ static void kwsys_shared_forward_strerror(char* message)
#if defined(_WIN32) && !defined(__CYGWIN__)
/* Implementation for Windows. */
DWORD original = GetLastError();
- DWORD length = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
+ DWORD length = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS, 0, original,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
message, KWSYS_SHARED_FORWARD_MAXPATH, 0);
diff --git a/Source/kwsys/System.c b/Source/kwsys/System.c
index 5d178bf..1ee26fa 100644
--- a/Source/kwsys/System.c
+++ b/Source/kwsys/System.c
@@ -353,6 +353,10 @@ static int kwsysSystem_Shell__GetArgumentSize(const char* in,
if(kwsysSystem_Shell__ArgumentNeedsQuotes(in, isUnix, flags))
{
/* Surrounding quotes are needed. Allocate space for them. */
+ if((flags & kwsysSystem_Shell_Flag_WatcomQuote) && (isUnix))
+ {
+ size += 2;
+ }
size += 2;
/* We must escape all ending backslashes when quoting on windows. */
@@ -377,7 +381,18 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
if(needQuotes)
{
/* Add the opening quote for this argument. */
- *out++ = '"';
+ if(flags & kwsysSystem_Shell_Flag_WatcomQuote)
+ {
+ if(isUnix)
+ {
+ *out++ = '"';
+ }
+ *out++ = '\'';
+ }
+ else
+ {
+ *out++ = '"';
+ }
}
/* Scan the string for characters that require escaping or quoting. */
@@ -549,7 +564,18 @@ static char* kwsysSystem_Shell__GetArgument(const char* in, char* out,
}
/* Add the closing quote for this argument. */
- *out++ = '"';
+ if(flags & kwsysSystem_Shell_Flag_WatcomQuote)
+ {
+ *out++ = '\'';
+ if(isUnix)
+ {
+ *out++ = '"';
+ }
+ }
+ else
+ {
+ *out++ = '"';
+ }
}
/* Store a terminating null without incrementing. */
diff --git a/Source/kwsys/System.h.in b/Source/kwsys/System.h.in
index 549db90..f21bf0d 100644
--- a/Source/kwsys/System.h.in
+++ b/Source/kwsys/System.h.in
@@ -36,6 +36,7 @@
# define kwsysSystem_Shell_Flag_MinGWMake kwsys_ns(System_Shell_Flag_MinGWMake)
# define kwsysSystem_Shell_Flag_NMake kwsys_ns(System_Shell_Flag_NMake)
# define kwsysSystem_Shell_Flag_AllowMakeVariables kwsys_ns(System_Shell_Flag_AllowMakeVariables)
+# define kwsysSystem_Shell_Flag_WatcomQuote kwsys_ns(System_Shell_Flag_WatcomQuote)
#endif
#ifdef __VMS
@@ -102,14 +103,17 @@ enum kwsysSystem_Shell_Flag_e
kwsysSystem_Shell_Flag_MinGWMake = (1<<4),
/** The target shell is in a NMake makefile. */
- kwsysSystem_Shell_Flag_NMake = (1<<6),
+ kwsysSystem_Shell_Flag_NMake = (1<<5),
/** Make variable reference syntax $(MAKEVAR) should not be escaped
to allow a build tool to replace it. Replacement values
containing spaces, quotes, backslashes, or other
non-alphanumeric characters that have significance to some makes
or shells produce undefined behavior. */
- kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<5)
+ kwsysSystem_Shell_Flag_AllowMakeVariables = (1<<6),
+
+ /** The target shell quoting uses extra single Quotes for Watcom tools. */
+ kwsysSystem_Shell_Flag_WatcomQuote = (1<<7)
};
/**
@@ -156,6 +160,7 @@ kwsysEXPORT char** kwsysSystem_Parse_CommandForUnix(const char* command,
# undef kwsysSystem_Shell_Flag_MinGWMake
# undef kwsysSystem_Shell_Flag_NMake
# undef kwsysSystem_Shell_Flag_AllowMakeVariables
+# undef kwsysSystem_Shell_Flag_WatcomQuote
# endif
#endif
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 5f20853..720a7c3 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -4698,11 +4698,28 @@ bool SystemInformationImplementation::QueryHaikuInfo()
{
#if defined(__HAIKU__)
+ // CPU count
system_info info;
get_system_info(&info);
-
this->NumberOfPhysicalCPU = info.cpu_count;
- this->CPUSpeedInMHz = info.cpu_clock_speed / 1000000.0F;
+
+ // CPU speed
+ uint32 topologyNodeCount = 0;
+ cpu_topology_node_info* topology = 0;
+ get_cpu_topology_info(0, &topologyNodeCount);
+ if (topologyNodeCount != 0)
+ topology = new cpu_topology_node_info[topologyNodeCount];
+ get_cpu_topology_info(topology, &topologyNodeCount);
+
+ for (uint32 i = 0; i < topologyNodeCount; i++) {
+ if (topology[i].type == B_TOPOLOGY_CORE) {
+ this->CPUSpeedInMHz = topology[i].data.core.default_frequency /
+ 1000000.0f;
+ break;
+ }
+ }
+
+ delete[] topology;
// Physical Memory
this->TotalPhysicalMemory = (info.max_pages * B_PAGE_SIZE) / (1024 * 1024) ;
@@ -5006,21 +5023,26 @@ bool SystemInformationImplementation::QueryHPUXProcessor()
case CPU_PA_RISC1_0:
this->ChipID.Vendor = "Hewlett-Packard";
this->ChipID.Family = 0x100;
+ break;
case CPU_PA_RISC1_1:
this->ChipID.Vendor = "Hewlett-Packard";
this->ChipID.Family = 0x110;
+ break;
case CPU_PA_RISC2_0:
this->ChipID.Vendor = "Hewlett-Packard";
this->ChipID.Family = 0x200;
-# ifdef CPU_HP_INTEL_EM_1_0
+ break;
+# if defined(CPU_HP_INTEL_EM_1_0) || defined(CPU_IA64_ARCHREV_0)
+# ifdef CPU_HP_INTEL_EM_1_0
case CPU_HP_INTEL_EM_1_0:
-# endif
-# ifdef CPU_IA64_ARCHREV_0
+# endif
+# ifdef CPU_IA64_ARCHREV_0
case CPU_IA64_ARCHREV_0:
-# endif
+# endif
this->ChipID.Vendor = "GenuineIntel";
this->Features.HasIA64 = true;
break;
+# endif
default:
return false;
}
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index f4a443f..32e79e6 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -188,6 +188,9 @@ static inline char *realpath(const char *path, char *resolved_path)
#endif
#if defined(_WIN32) && (defined(_MSC_VER) || defined(__WATCOMC__) || defined(__BORLANDC__) || defined(__MINGW32__))
+
+#include <wctype.h>
+
inline int Mkdir(const char* dir)
{
return _wmkdir(KWSYS_NAMESPACE::Encoding::ToWide(dir).c_str());
@@ -4915,8 +4918,8 @@ void SystemTools::ClassInitialize()
// Strip off one directory level and see if the logical
// mapping still works.
- pwd_str = SystemTools::GetFilenamePath(pwd_str.c_str());
- cwd_str = SystemTools::GetFilenamePath(cwd_str.c_str());
+ pwd_str = SystemTools::GetFilenamePath(pwd_str);
+ cwd_str = SystemTools::GetFilenamePath(cwd_str);
Realpath(pwd_str.c_str(), pwd_path);
}
diff --git a/Source/kwsys/testFStream.cxx b/Source/kwsys/testFStream.cxx
index 8942549..9abfd4c 100644
--- a/Source/kwsys/testFStream.cxx
+++ b/Source/kwsys/testFStream.cxx
@@ -16,11 +16,17 @@
#endif
#include KWSYS_HEADER(FStream.hxx)
+#include KWSYS_HEADER(ios/iostream)
+#include <string.h>
+#ifdef __BORLANDC__
+# include <mem.h> /* memcmp */
+#endif
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
#if 0
# include "FStream.hxx.in"
+# include "kwsys_ios_iostream.h.in"
#endif
@@ -36,6 +42,141 @@ static int testNoFile()
return 0;
}
+static kwsys::FStream::BOM expected_bom[5] =
+{
+ kwsys::FStream::BOM_UTF8,
+ kwsys::FStream::BOM_UTF16LE,
+ kwsys::FStream::BOM_UTF16BE,
+ kwsys::FStream::BOM_UTF32LE,
+ kwsys::FStream::BOM_UTF32BE
+};
+
+static unsigned char expected_bom_data[5][5] =
+{
+ {3, 0xEF, 0xBB, 0xBF},
+ {2, 0xFF, 0xFE},
+ {2, 0xFE, 0xFF},
+ {4, 0xFF, 0xFE, 0x00, 0x00},
+ {4, 0x00, 0x00, 0xFE, 0xFF},
+};
+
+static unsigned char file_data[5][45] =
+{
+ {11, 'H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd'},
+ {22, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20, 0x00,
+ 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64, 0x00},
+ {22, 0x00, 0x48, 0x00, 0x65, 0x00, 0x6C, 0x00, 0x6C, 0x00, 0x6F, 0x00, 0x20,
+ 0x00, 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6C, 0x00, 0x64},
+ {44, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00,
+ 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00,
+ 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00,
+ 0x6C, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00},
+ {44, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x6C,
+ 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x20,
+ 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x6F, 0x00, 0x00, 0x00, 0x72,
+ 0x00, 0x00, 0x00, 0x6C, 0x00, 0x00, 0x00, 0x64},
+};
+
+//----------------------------------------------------------------------------
+static int testBOM()
+{
+ // test various encodings in binary mode
+ for(int i=0; i<5; i++)
+ {
+ {
+ kwsys::ofstream out("bom.txt", kwsys::ofstream::binary);
+ out.write(reinterpret_cast<const char*>(expected_bom_data[i]+1),
+ *expected_bom_data[i]);
+ out.write(reinterpret_cast<const char*>(file_data[i]+1),
+ file_data[i][0]);
+ }
+
+ kwsys::ifstream in("bom.txt", kwsys::ofstream::binary);
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+ if(bom != expected_bom[i])
+ {
+ kwsys_ios::cout << "Unexpected BOM " << i << std::endl;
+ return 1;
+ }
+ char data[45];
+ in.read(data, file_data[i][0]);
+ if(!in.good())
+ {
+ kwsys_ios::cout << "Unable to read data " << i << std::endl;
+ return 1;
+ }
+
+ if(memcmp(data, file_data[i]+1, file_data[i][0]) != 0)
+ {
+ kwsys_ios::cout << "Incorrect read data " << i << std::endl;
+ return 1;
+ }
+
+ }
+
+ // test text file without bom
+ {
+ {
+ kwsys::ofstream out("bom.txt");
+ out << "Hello World";
+ }
+
+ kwsys::ifstream in("bom.txt");
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+ if(bom != kwsys::FStream::BOM_None)
+ {
+ kwsys_ios::cout << "Unexpected BOM for none case" << std::endl;
+ return 1;
+ }
+ char data[45];
+ in.read(data, file_data[0][0]);
+ if(!in.good())
+ {
+ kwsys_ios::cout << "Unable to read data for none case" << std::endl;
+ return 1;
+ }
+
+ if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0)
+ {
+ kwsys_ios::cout << "Incorrect read data for none case" << std::endl;
+ return 1;
+ }
+ }
+
+ // test text file with utf-8 bom
+ {
+ {
+ kwsys::ofstream out("bom.txt");
+ out.write(reinterpret_cast<const char*>(expected_bom_data[0]+1),
+ *expected_bom_data[0]);
+ out << "Hello World";
+ }
+
+ kwsys::ifstream in("bom.txt");
+ kwsys::FStream::BOM bom = kwsys::FStream::ReadBOM(in);
+ if(bom != kwsys::FStream::BOM_UTF8)
+ {
+ kwsys_ios::cout << "Unexpected BOM for utf-8 case" << std::endl;
+ return 1;
+ }
+ char data[45];
+ in.read(data, file_data[0][0]);
+ if(!in.good())
+ {
+ kwsys_ios::cout << "Unable to read data for utf-8 case" << std::endl;
+ return 1;
+ }
+
+ if(memcmp(data, file_data[0]+1, file_data[0][0]) != 0)
+ {
+ kwsys_ios::cout << "Incorrect read data for utf-8 case" << std::endl;
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
//----------------------------------------------------------------------------
int testFStream(int, char*[])
@@ -43,6 +184,7 @@ int testFStream(int, char*[])
int ret = 0;
ret |= testNoFile();
+ ret |= testBOM();
return ret;
}
diff --git a/Tests/BuildDepends/CMakeLists.txt b/Tests/BuildDepends/CMakeLists.txt
index 9727930..a875f07 100644
--- a/Tests/BuildDepends/CMakeLists.txt
+++ b/Tests/BuildDepends/CMakeLists.txt
@@ -68,6 +68,8 @@ file(WRITE ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_exe.h
"#define link_depends_no_shared_exe_value 0\n")
set(link_depends_no_shared_check_txt ${BuildDepends_BINARY_DIR}/Project/link_depends_no_shared_check.txt)
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external original\n")
+
help_xcode_depends()
message("Building project first time")
@@ -166,6 +168,19 @@ else()
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
endif()
+if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
+ file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
+ if("${external_out}" STREQUAL "external original")
+ message(STATUS "external.out contains '${external_out}'")
+ else()
+ message(SEND_ERROR "Project did not initially build properly: "
+ "external.out contains '${external_out}'")
+ endif()
+else()
+ message(SEND_ERROR "Project did not initially build properly: "
+ "external.out is missing")
+endif()
+
message("Waiting 3 seconds...")
# any additional argument will cause ${bar} to wait forever
execute_process(COMMAND ${bar} -infinite TIMEOUT 3 OUTPUT_VARIABLE out)
@@ -191,6 +206,8 @@ if(TEST_LINK_DEPENDS)
file(WRITE ${TEST_LINK_DEPENDS} "2")
endif()
+file(WRITE ${BuildDepends_BINARY_DIR}/Project/external.in "external changed\n")
+
help_xcode_depends()
message("Building project second time")
@@ -294,3 +311,16 @@ else()
message(SEND_ERROR "Project did not rebuild properly. "
"Targets link_depends_no_shared_lib and link_depends_no_shared_exe not both built.")
endif()
+
+if(EXISTS ${BuildDepends_BINARY_DIR}/Project/external.out)
+ file(STRINGS ${BuildDepends_BINARY_DIR}/Project/external.out external_out)
+ if("${external_out}" STREQUAL "external changed")
+ message(STATUS "external.out contains '${external_out}'")
+ else()
+ message(SEND_ERROR "Project did not rebuild properly: "
+ "external.out contains '${external_out}'")
+ endif()
+else()
+ message(SEND_ERROR "Project did not rebuild properly: "
+ "external.out is missing")
+endif()
diff --git a/Tests/BuildDepends/Project/CMakeLists.txt b/Tests/BuildDepends/Project/CMakeLists.txt
index 8806ecd..9ee4a43 100644
--- a/Tests/BuildDepends/Project/CMakeLists.txt
+++ b/Tests/BuildDepends/Project/CMakeLists.txt
@@ -139,3 +139,15 @@ add_custom_target(header_tgt DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/dir/header.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_executable(ninjadep ninjadep.cpp)
add_dependencies(ninjadep header_tgt)
+
+include(ExternalProject)
+ExternalProject_Add(ExternalBuild
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/External
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/External
+ STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/External/Stamp
+ BUILD_ALWAYS 1
+ CMAKE_ARGS
+ -Dexternal_in=${CMAKE_CURRENT_BINARY_DIR}/external.in
+ -Dexternal_out=${CMAKE_CURRENT_BINARY_DIR}/external.out
+ INSTALL_COMMAND ""
+ )
diff --git a/Tests/BuildDepends/Project/External/CMakeLists.txt b/Tests/BuildDepends/Project/External/CMakeLists.txt
new file mode 100644
index 0000000..c6015b6
--- /dev/null
+++ b/Tests/BuildDepends/Project/External/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 3.0)
+project(BuildDependsExternal NONE)
+if(NOT DEFINED external_in)
+ message(FATAL_ERROR "Define external_in")
+endif()
+if(NOT DEFINED external_out)
+ message(FATAL_ERROR "Define external_out")
+endif()
+add_custom_command(
+ OUTPUT ${external_out}
+ COMMAND ${CMAKE_COMMAND} -E copy ${external_in} ${external_out}
+ DEPENDS ${external_in}
+ )
+add_custom_target(drive ALL DEPENDS ${external_out})
diff --git a/Tests/CMakeBuildTest.cmake.in b/Tests/CMakeBuildTest.cmake.in
index 0f7074b..aaefe43 100644
--- a/Tests/CMakeBuildTest.cmake.in
+++ b/Tests/CMakeBuildTest.cmake.in
@@ -11,8 +11,8 @@ file(REMOVE "@CMAKE_BUILD_TEST_SOURCE_DIR@/CMakeCache.txt")
message("running: ${CMAKE_COMMAND}")
execute_process(COMMAND "${CMAKE_COMMAND}"
"@CMAKE_BUILD_TEST_SOURCE_DIR@"
- "-G@CMAKE_TEST_GENERATOR@"
- -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+ "-G@CMAKE_GENERATOR@"
+ -T "@CMAKE_GENERATOR_TOOLSET@"
WORKING_DIRECTORY "@CMAKE_BUILD_TEST_BINARY_DIR@"
RESULT_VARIABLE RESULT)
if(RESULT)
diff --git a/Tests/CMakeCommands/target_compile_features/CMakeLists.txt b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
new file mode 100644
index 0000000..62e3ce0
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.0)
+project(target_compile_features)
+
+if (NOT CMAKE_CXX_COMPILE_FEATURES)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp"
+ "int main(int,char**) { return 0; }\n"
+ )
+ add_executable(target_compile_features "${CMAKE_CURRENT_BINARY_DIR}/test_dummy.cpp")
+ return()
+endif()
+
+set(CMAKE_VERBOSE_MAKEFILE ON)
+
+add_executable(target_compile_features main.cpp)
+target_compile_features(target_compile_features
+ PRIVATE cxx_auto_type
+)
+
+add_library(lib_auto_type lib_auto_type.cpp)
+target_compile_features(lib_auto_type
+ PUBLIC cxx_auto_type
+)
+
+add_executable(lib_user lib_user.cpp)
+target_link_libraries(lib_user lib_auto_type)
diff --git a/Tests/CMakeCommands/target_compile_features/dummy.cpp b/Tests/CMakeCommands/target_compile_features/dummy.cpp
new file mode 100644
index 0000000..341aaaf
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/dummy.cpp
@@ -0,0 +1,5 @@
+
+int main(int, char **)
+{
+ return 0;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp b/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp
new file mode 100644
index 0000000..71b2215
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_auto_type.cpp
@@ -0,0 +1,6 @@
+
+int getAutoTypeImpl()
+{
+ auto i = 0;
+ return i;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_auto_type.h b/Tests/CMakeCommands/target_compile_features/lib_auto_type.h
new file mode 100644
index 0000000..c825b10
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_auto_type.h
@@ -0,0 +1,8 @@
+
+int getAutoTypeImpl();
+
+int getAutoType()
+{
+ auto i = getAutoTypeImpl();
+ return i;
+}
diff --git a/Tests/CMakeCommands/target_compile_features/lib_user.cpp b/Tests/CMakeCommands/target_compile_features/lib_user.cpp
new file mode 100644
index 0000000..976068a
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/lib_user.cpp
@@ -0,0 +1,7 @@
+
+#include "lib_auto_type.h"
+
+int main(int argc, char **argv)
+{
+ return getAutoType();
+}
diff --git a/Tests/CMakeCommands/target_compile_features/main.cpp b/Tests/CMakeCommands/target_compile_features/main.cpp
new file mode 100644
index 0000000..fe29b04
--- /dev/null
+++ b/Tests/CMakeCommands/target_compile_features/main.cpp
@@ -0,0 +1,6 @@
+
+int main(int, char **)
+{
+ auto i = 0;
+ return i;
+}
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index dc1ce24..279bcd5 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -2,14 +2,14 @@
class CompileCommandParser {
public:
- class CommandType: public std::map<cmStdString, cmStdString>
+ class CommandType: public std::map<std::string, std::string>
{
public:
- cmStdString const& at(cmStdString const& k) const
+ std::string const& at(std::string const& k) const
{
const_iterator i = this->find(k);
if(i != this->end()) { return i->second; }
- static cmStdString emptyString;
+ static std::string emptyString;
return emptyString;
}
};
@@ -127,7 +127,7 @@ int main ()
it = parser.GetTranslationUnits().begin(),
end = parser.GetTranslationUnits().end(); it != end; ++it)
{
- std::vector<cmStdString> command;
+ std::vector<std::string> command;
cmSystemTools::ParseUnixCommandLine(it->at("command").c_str(), command);
if (!cmSystemTools::RunSingleCommand(
command, 0, 0, it->at("directory").c_str()))
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 8074a01..9d642cc 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -45,26 +45,27 @@ configure_file(${CMake_SOURCE_DIR}/Tests/EnforceConfig.cmake.in
# Testing
if(BUILD_TESTING)
- set(CMAKE_TEST_DEVENV "")
- if(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
- if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio")
- set(CMAKE_TEST_MAKEPROGRAM "")
- else()
- set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
- endif()
- if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio [7-9] " AND
- NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
- set(CMAKE_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
- endif()
+ set(CMake_TEST_DEVENV "")
+ if(CMAKE_GENERATOR MATCHES "Visual Studio [7-9] " AND
+ NOT CMAKE_MAKE_PROGRAM MATCHES "[mM][sS][bB][uU][iI][lL][dD]\\.[eE][xX][eE]")
+ set(CMake_TEST_DEVENV "${CMAKE_MAKE_PROGRAM}")
+ endif()
+
+ if(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "")
+ else()
+ set(CMake_TEST_EXPLICIT_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
endif()
- if("${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_TEST_GENERATOR}" MATCHES Ninja AND NOT WIN32))
- set(TEST_CompileCommandOutput 1)
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles" OR ("${CMAKE_GENERATOR}" MATCHES Ninja AND NOT WIN32))
+ set(TEST_CompileCommandOutput 1)
+ endif()
endif()
set(MAKE_IS_GNU )
- if(CMAKE_TEST_MAKEPROGRAM MATCHES make)
- execute_process(COMMAND ${CMAKE_TEST_MAKEPROGRAM} no_such_target --version
+ if(CMAKE_MAKE_PROGRAM MATCHES make)
+ execute_process(COMMAND ${CMAKE_MAKE_PROGRAM} no_such_target --version
RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE out)
if("${res}" STREQUAL "0")
if("${out}" MATCHES "GNU")
@@ -75,34 +76,38 @@ if(BUILD_TESTING)
# some old versions of make simply cannot handle spaces in paths
if (MAKE_IS_GNU OR
- CMAKE_TEST_MAKEPROGRAM MATCHES "nmake|gmake|wmake" OR
- CMAKE_TEST_GENERATOR MATCHES "Visual Studio|XCode|Borland")
+ CMAKE_MAKE_PROGRAM MATCHES "nmake|gmake|wmake" OR
+ CMAKE_GENERATOR MATCHES "Visual Studio|XCode|Borland")
set(MAKE_SUPPORTS_SPACES 1)
else()
set(MAKE_SUPPORTS_SPACES 0)
endif()
set(build_generator_args
- --build-generator ${CMAKE_TEST_GENERATOR}
+ --build-generator ${CMAKE_GENERATOR}
)
- if(CMAKE_TEST_GENERATOR_TOOLSET)
+ if(CMAKE_GENERATOR_TOOLSET)
list(APPEND build_generator_args
- --build-generator-toolset ${CMAKE_TEST_GENERATOR_TOOLSET}
+ --build-generator-toolset ${CMAKE_GENERATOR_TOOLSET}
)
endif()
set(build_options)
- if(CMAKE_TEST_MAKEPROGRAM)
- list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
+ if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
+ list(APPEND build_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
endif()
- add_subdirectory(CMakeLib)
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ add_subdirectory(CMakeLib)
+ endif()
add_subdirectory(CMakeOnly)
add_subdirectory(RunCMake)
add_subdirectory(FindPackageModeMakefileTest)
- add_subdirectory(CTestTestMemcheck)
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ add_subdirectory(CTestTestMemcheck)
+ endif()
# Collect a list of all test build directories.
set(TEST_BUILD_DIRS)
@@ -192,6 +197,9 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(TarTest TarTest)
ADD_TEST_MACRO(SystemInformation SystemInformation)
ADD_TEST_MACRO(MathTest MathTest)
+ ADD_TEST_MACRO(CompileFeatures CompileFeatures)
+ ADD_TEST_MACRO(CMakeCommands.target_compile_features target_compile_features)
+
# assume no resources building to test
set(TEST_RESOURCES FALSE)
# for windows and cygwin assume we have resources
@@ -199,8 +207,8 @@ if(BUILD_TESTING)
set(TEST_RESOURCES TRUE)
endif()
# for borland and watcom there is no resource support
- if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake" OR
- "${CMAKE_TEST_GENERATOR}" MATCHES "Borland")
+ if("${CMAKE_GENERATOR}" MATCHES "WMake" OR
+ "${CMAKE_GENERATOR}" MATCHES "Borland")
set(TEST_RESOURCES FALSE)
endif()
if(TEST_RESOURCES)
@@ -249,7 +257,9 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(SetLang SetLang)
ADD_TEST_MACRO(EmptyProperty EmptyProperty)
ADD_TEST_MACRO(ExternalOBJ ExternalOBJ)
- ADD_TEST_MACRO(LoadCommand LoadedCommand)
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ ADD_TEST_MACRO(LoadCommand LoadedCommand)
+ endif()
ADD_TEST_MACRO(LinkDirectory bin/LinkDirectory)
ADD_TEST_MACRO(LinkLanguage LinkLanguage)
ADD_TEST_MACRO(LinkLine LinkLine)
@@ -260,7 +270,7 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(Assembler HelloAsm)
ADD_TEST_MACRO(SourceGroups SourceGroups)
ADD_TEST_MACRO(Preprocess Preprocess)
- set(ExportImport_BUILD_OPTIONS -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
+ set(ExportImport_BUILD_OPTIONS -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
ADD_TEST_MACRO(ExportImport ExportImport)
ADD_TEST_MACRO(Unset Unset)
ADD_TEST_MACRO(PolicyScope PolicyScope)
@@ -271,12 +281,30 @@ if(BUILD_TESTING)
ADD_TEST_MACRO(AliasTarget AliasTarget)
ADD_TEST_MACRO(StagingPrefix StagingPrefix)
ADD_TEST_MACRO(InterfaceLibrary InterfaceLibrary)
+ if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
+ set(ConfigSources_BUILD_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ ADD_TEST_MACRO(ConfigSources ConfigSources)
+ endif()
+ ADD_TEST_MACRO(SourcesProperty SourcesProperty)
+ if(CMAKE_CXX_COMPILER_ID STREQUAL GNU
+ AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
+ set(runCxxDialectTest 1)
+ endif()
+ if(CMAKE_CXX_COMPILER_ID STREQUAL Clang
+ AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.9)
+ if(NOT APPLE OR POLICY CMP0025)
+ set(runCxxDialectTest 1)
+ endif()
+ endif()
+ if(runCxxDialectTest)
+ ADD_TEST_MACRO(CxxDialect CxxDialect)
+ endif()
set_tests_properties(EmptyLibrary PROPERTIES
PASS_REGULAR_EXPRESSION "CMake Error: CMake can not determine linker language for target: test")
ADD_TEST_MACRO(CrossCompile CrossCompile)
set_tests_properties(CrossCompile PROPERTIES
PASS_REGULAR_EXPRESSION "TRY_RUN.. invoked in cross-compiling mode")
- if("${CMAKE_TEST_GENERATOR}" MATCHES "Make")
+ if("${CMAKE_GENERATOR}" MATCHES "Make")
ADD_TEST_MACRO(Policy0002 Policy0002)
endif()
if(CTEST_TEST_OSX_ARCH)
@@ -315,7 +343,7 @@ if(BUILD_TESTING)
MINGW OR
CMAKE_SYSTEM_NAME MATCHES "Linux" OR
CMAKE_SYSTEM_NAME MATCHES "Darwin")
- if(NOT "${CMAKE_TEST_GENERATOR}" STREQUAL "Watcom WMake")
+ if(NOT "${CMAKE_GENERATOR}" STREQUAL "Watcom WMake")
add_test(BundleUtilities ${CMAKE_CTEST_COMMAND}
--build-and-test
@@ -381,6 +409,7 @@ if(BUILD_TESTING)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Module/ExternalData")
ADD_TEST_MACRO(Module.GenerateExportHeader GenerateExportHeader)
+ ADD_TEST_MACRO(Module.FindDependency FindDependency)
if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU")
include(CheckCXXCompilerFlag)
@@ -465,7 +494,7 @@ if(BUILD_TESTING)
# build the "Simple" test with the ExtraGenerators, if available
# This doesn't test whether the generated project files work (unfortunately),
# mainly it tests that cmake doesn't crash when generating these project files.
- if(${CMAKE_TEST_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_TEST_GENERATOR} MATCHES "KDevelop")
+ if(${CMAKE_GENERATOR} MATCHES "Unix Makefiles" OR ${CMAKE_GENERATOR} MATCHES "KDevelop")
# check which generators we have
execute_process(COMMAND ${CMAKE_CMAKE_COMMAND} --help
OUTPUT_VARIABLE cmakeOutput ERROR_VARIABLE cmakeOutput)
@@ -477,7 +506,7 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/Simple_EclipseGenerator"
--build-two-config
--build-generator "Eclipse CDT4 - Unix Makefiles"
- --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project Simple
--build-options ${build_options}
--test-command Simple)
@@ -492,7 +521,7 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/Simple_CodeBlocksGenerator"
--build-two-config
--build-generator "CodeBlocks - Unix Makefiles"
- --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project Simple
--build-options ${build_options}
--test-command Simple)
@@ -506,7 +535,7 @@ if(BUILD_TESTING)
"${CMake_BINARY_DIR}/Tests/Simple_KDevelop3Generator"
--build-two-config
--build-generator "KDevelop3 - Unix Makefiles"
- --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project Simple
--build-options ${build_options}
--test-command Simple)
@@ -517,7 +546,7 @@ if(BUILD_TESTING)
# test for correct sub-project generation
# not implemented in VS 6, VS 7.0, Xcode, or Ninja
- if(NOT CMAKE_TEST_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
+ if(NOT CMAKE_GENERATOR MATCHES "Visual Studio [67]$|Xcode|Ninja")
# run cmake and configure all of SubProject
# but only build the independent executable car
add_test(SubProject ${CMAKE_CTEST_COMMAND}
@@ -536,17 +565,17 @@ if(BUILD_TESTING)
# the bar library which should be referenced because
# foo links to the static library bar, but bar is not
# directly in the foo sub project
- if(CMAKE_TEST_MAKEPROGRAM)
+ if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
set(SubProject-Stage2_BUILD_MAKEPROGRAM
- --build-makeprogram ${CMAKE_TEST_MAKEPROGRAM}
+ --build-makeprogram ${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
)
endif()
add_test(SubProject-Stage2 ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/SubProject/foo"
"${CMake_BINARY_DIR}/Tests/SubProject/foo"
- --build-generator ${CMAKE_TEST_GENERATOR}
- --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
${SubProject-Stage2_BUILD_MAKEPROGRAM}
--build-nocmake
--build-project foo
@@ -567,7 +596,7 @@ if(BUILD_TESTING)
file(WRITE "${_TEST_DIR}/nightly-cmake.sh"
"cd ${_TEST_DIR}
${CMake_BINARY_DIR}/bin/cmake -DCMAKE_CREATE_VERSION=nightly -P ${CMake_SOURCE_DIR}/Utilities/Release/${script}
-${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
+${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release/upload_release.cmake
")
add_test(${name} /bin/sh ${_TEST_DIR}/nightly-cmake.sh)
if(COMMAND SET_TESTS_PROPERTIES AND COMMAND GET_TEST_PROPERTY)
@@ -785,7 +814,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
set(CTEST_package_X11_TEST ${CTEST_TEST_CPACK})
set(CTEST_RUN_CPackComponentsForAll ${CTEST_TEST_CPACK})
- if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*")
+ if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
find_program(RPMBUILD NAMES rpmbuild)
endif()
# Do not try to build RPM
@@ -821,6 +850,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
if(WIX_LIGHT_EXECUTABLE)
add_test(CPackWiXGenerator ${CMAKE_CTEST_COMMAND}
+ -C \${CTEST_CONFIGURATION_TYPE}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator"
"${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
@@ -829,6 +859,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--build-options ${build_options}
--test-command ${CMAKE_CMAKE_COMMAND}
"-DCPackWiXGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackWiXGenerator"
+ "-Dconfig=\${CTEST_CONFIGURATION_TYPE}"
-P "${CMake_SOURCE_DIR}/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake")
endif()
endif()
@@ -884,7 +915,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
if(APPLE)
list(APPEND GENLST "DragNDrop")
endif()
- if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES ".* .*")
+ if (NOT CMAKE_CURRENT_BINARY_DIR MATCHES " ")
list(FIND ACTIVE_CPACK_GENERATORS "RPM" RPM_ACTIVE)
if (NOT ${RPM_ACTIVE} EQUAL -1)
list(APPEND GENLST "RPM")
@@ -995,7 +1026,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
if(CTEST_RUN_CMakeTestBadCommandLines)
add_test(CMakeTestBadCommandLines ${CMAKE_CMAKE_COMMAND}
-D dir=${CMake_BINARY_DIR}/Tests/CMakeTestBadCommandLines
- -D gen=${CMAKE_TEST_GENERATOR}
+ -D gen=${CMAKE_GENERATOR}
-D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
-P ${CMake_SOURCE_DIR}/Tests/CMakeTestBadCommandLines/RunCMake.cmake
)
@@ -1010,7 +1041,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
if(CTEST_RUN_CMakeTestMultipleConfigures)
add_test(CMakeTestMultipleConfigures ${CMAKE_CMAKE_COMMAND}
-D dir=${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures
- -D gen=${CMAKE_TEST_GENERATOR}
+ -D gen=${CMAKE_GENERATOR}
-D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
-P ${CMake_SOURCE_DIR}/Tests/CMakeTestMultipleConfigures/RunCMake.cmake
)
@@ -1018,16 +1049,18 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
"${CMake_BINARY_DIR}/Tests/CMakeTestMultipleConfigures")
endif()
- add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
- "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
- ${build_generator_args}
- --build-project LoadCommand
- --build-options ${build_options}
- --test-command LoadedCommand
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ add_test(LoadedCommandOneConfig ${CMAKE_CTEST_COMMAND}
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/LoadCommandOneConfig"
+ "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig"
+ ${build_generator_args}
+ --build-project LoadCommand
+ --build-options ${build_options}
+ --test-command LoadedCommand
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/LoadCommandOneConfig")
+ endif()
add_test(complex ${CMAKE_CTEST_COMMAND}
--build-and-test
@@ -1233,8 +1266,8 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
COMMAND ${CMAKE_CMAKE_COMMAND}
-DExternalProjectUpdate_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate
-DExternalProjectUpdate_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/ExternalProjectUpdate
- -DCMAKE_TEST_GENERATOR=${CMAKE_TEST_GENERATOR}
- -DCMAKE_TEST_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET}
+ -DCMAKE_GENERATOR=${CMAKE_GENERATOR}
+ -DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DCMAKE_CTEST_COMMAND=${CMAKE_CTEST_COMMAND}
-P ${CMake_SOURCE_DIR}/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
)
@@ -1405,7 +1438,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
${build_generator_args}
--build-project MacRuntimePath
--build-options ${build_options}
- -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
+ -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
)
endif()
@@ -1452,19 +1485,6 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
)
endif()
- if(NOT CMAKE_TEST_DIFFERENT_GENERATOR)
- add_test(kwsys ${CMAKE_CTEST_COMMAND}
- --build-and-test
- "${CMake_SOURCE_DIR}/Source/kwsys"
- "${CMake_BINARY_DIR}/Tests/kwsys"
- ${build_generator_args}
- --build-project kwsys
- --build-options ${build_options}
- --test-command kwsysTestsCxx testIOS
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/kwsys")
- endif()
-
if(MAKE_SUPPORTS_SPACES)
add_test(SubDirSpaces ${CMAKE_CTEST_COMMAND}
--build-and-test
@@ -1511,19 +1531,19 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif ()
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/SubDir")
- if(CMAKE_TEST_MSVC)
+ if(MSVC)
ADD_TEST_MACRO(ForceInclude foo)
ADD_TEST_MACRO(PDBDirectoryAndName myexe)
ADD_TEST_MACRO(PrecompiledHeader foo)
endif()
- if(CMAKE_TEST_MSVC OR
- "${CMAKE_TEST_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
+ if(MSVC OR
+ "${CMAKE_GENERATOR}" MATCHES "(MSYS|MinGW) Makefiles")
ADD_TEST_MACRO(ModuleDefinition example_exe)
endif()
ADD_TEST_MACRO(CheckCompilerRelatedVariables CheckCompilerRelatedVariables)
- if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile")
+ if("${CMAKE_GENERATOR}" MATCHES "Makefile")
add_test(MakeClean ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/MakeClean"
@@ -1545,10 +1565,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
# Look for evidence that this is a VCExpress build. If so, avoid
# the MFC test by default.
- string(TOLOWER "${CMAKE_MAKE_PROGRAM};${CMAKE_TEST_MAKEPROGRAM}" mkprog)
+ string(TOLOWER "${CMAKE_MAKE_PROGRAM}" mkprog)
if(mkprog MATCHES "vcexpress")
message(STATUS
- "CMAKE_TEST_MAKEPROGRAM indicates vcexpress, avoiding MFC test")
+ "CMAKE_MAKE_PROGRAM indicates vcexpress, avoiding MFC test")
set(CTEST_RUN_MFC OFF)
endif()
@@ -1569,7 +1589,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
# For the Watcom WMake generator, avoid the MFC test by default.
if(CTEST_RUN_MFC)
- if("${CMAKE_TEST_GENERATOR}" MATCHES "WMake")
+ if("${CMAKE_GENERATOR}" MATCHES "WMake")
message(STATUS
"using the Watcom WMake generator, avoiding MFC test")
set(CTEST_RUN_MFC OFF)
@@ -1642,13 +1662,13 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/MFC")
endif()
- if(${CMAKE_TEST_GENERATOR} MATCHES "Visual Studio")
+ if(${CMAKE_GENERATOR} MATCHES "Visual Studio")
if(NOT MSVC60)
ADD_TEST_MACRO(SBCS SBCS)
endif()
- if(NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
- AND NOT CMAKE_TEST_GENERATOR_TOOLSET)
+ if(NOT "${CMAKE_GENERATOR}" MATCHES "Visual Studio [6789]( |$)"
+ AND NOT CMAKE_GENERATOR_TOOLSET)
ADD_TEST_MACRO(VSWindowsFormsResx VSWindowsFormsResx)
endif()
@@ -1674,7 +1694,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--test-command VSMidl)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSMidl")
- if(CMAKE_TEST_DEVENV)
+ if(CMake_TEST_DEVENV)
# The test (and tested property) works with .sln files, so it's skipped when:
# * Using VS6, which doesn't use .sln files
# * cmake --build is set up to use MSBuild, since the MSBuild invocation does not use the .sln file
@@ -1686,9 +1706,9 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
"${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild"
--build-config ${config}
--build-two-config
- --build-generator ${CMAKE_TEST_GENERATOR}
- --build-makeprogram ${CMAKE_TEST_DEVENV}
- --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ --build-generator ${CMAKE_GENERATOR}
+ --build-makeprogram ${CMake_TEST_DEVENV}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project VSExcludeFromDefaultBuild
--test-command ${CMAKE_COMMAND}
-D "activeConfig=${config}"
@@ -1704,15 +1724,15 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSExcludeFromDefaultBuild")
endif()
- if(CMAKE_TEST_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
+ if(CMAKE_GENERATOR MATCHES "Visual Studio ([0-5]|[6-9][0-9])")
# This is Visual Studio 10 or above, so the default build tool is MSBuild.
add_test(NAME VSProjectInSubdir COMMAND ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/VSProjectInSubdir"
"${CMake_BINARY_DIR}/Tests/VSProjectInSubdir"
--build-two-config
- --build-generator ${CMAKE_TEST_GENERATOR}
- --build-generator-toolset "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ --build-generator ${CMAKE_GENERATOR}
+ --build-generator-toolset "${CMAKE_GENERATOR_TOOLSET}"
--build-project VSProjectInSubdir
--build-target test)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/VSProjectInSubdir")
@@ -1750,7 +1770,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--test-command
${CMAKE_CMAKE_COMMAND} -DCTEST_CONFIGURATION_TYPE=\${CTEST_CONFIGURATION_TYPE}
-Ddir=${CMake_BINARY_DIR}/Tests/CFBundleTest
- -Dgen=${CMAKE_TEST_GENERATOR}
+ -Dgen=${CMAKE_GENERATOR}
-P ${CMake_SOURCE_DIR}/Tests/CFBundleTest/VerifyResult.cmake)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CFBundleTest")
@@ -1803,7 +1823,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
FAIL_REGULAR_EXPRESSION "CMake Warning .*VariableUnusedViaUnset.CMakeLists.txt:5 \\(set\\):")
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/WarnUnusedUnusedViaUnset")
- if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
+ if("${CMAKE_GENERATOR}" MATCHES "Makefile" AND NOT WIN32)
# Ninja does not support ADDITIONAL_MAKE_CLEAN_FILES and therefore fails
# this test. (See #13371)
# Apparently Visual Studio does not support it either. As the MakeClean
@@ -1876,11 +1896,11 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
# A test for ctest_build() with targets in subdirectories
set(ctest_configure_options)
- if(CMAKE_TEST_GENERATOR_TOOLSET)
- list(APPEND ctest_configure_options -T ${CMAKE_TEST_GENERATOR_TOOLSET})
+ if(CMAKE_GENERATOR_TOOLSET)
+ list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
endif()
- if(CMAKE_TEST_MAKEPROGRAM)
- list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM})
+ if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
+ list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
endif()
configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
@@ -2219,7 +2239,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--output-log "${CMake_BINARY_DIR}/Tests/CTestTestCrash/testOutput.log"
)
# with watcom the SEGFAULT is not found, it just fails
- if(CMAKE_TEST_GENERATOR MATCHES "Watcom WMake")
+ if(CMAKE_GENERATOR MATCHES "Watcom WMake")
set_tests_properties(CTestTestCrash PROPERTIES
PASS_REGULAR_EXPRESSION "Failed")
else()
@@ -2436,6 +2456,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
set(regex "${regex}|Error message was: ")
set(regex "${regex}([Cc]ould *n.t resolve host")
set(regex "${regex}|[Cc]ould *n.t connect to host")
+ set(regex "${regex}|Failed connect to")
set(regex "${regex}|Empty reply from server")
set(regex "${regex}|The requested URL returned error")
set(regex "${regex}|libcurl was built with SSL disabled. https: not supported)")
@@ -2498,7 +2519,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--output-log "${CMake_BINARY_DIR}/Tests/CTestTest2/testOutput.log"
)
- if("${CMAKE_TEST_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_TEST_GENERATOR}" MATCHES "Ninja")
+ if("${CMAKE_GENERATOR}" MATCHES "Makefiles" OR "${CMAKE_GENERATOR}" MATCHES "Ninja")
configure_file("${CMake_SOURCE_DIR}/Tests/CTestTestLaunchers/test.cmake.in"
"${CMake_BINARY_DIR}/Tests/CTestTestLaunchers/test.cmake" @ONLY ESCAPE_QUOTES)
add_test(CTestTestLaunchers ${CMAKE_CTEST_COMMAND}
@@ -2535,7 +2556,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif ()
endif ()
- if("${CMAKE_TEST_GENERATOR}" MATCHES Xcode)
+ if("${CMAKE_GENERATOR}" MATCHES Xcode)
set(CMAKE_SKIP_BOOTSTRAP_TEST 1)
endif()
if(EXISTS "${CMake_BINARY_DIR}/CMakeLists.txt")
@@ -2580,7 +2601,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
--build-project testf
--build-two-config
--build-options ${build_options}
- -DCMAKE_TEST_MAKEPROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
+ -DCMake_TEST_NESTED_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM}
--test-command testf)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/Fortran")
@@ -2607,7 +2628,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
find_package(Java COMPONENTS Development QUIET)
if(Java_JAVA_EXECUTABLE AND Java_JAVAC_EXECUTABLE AND Java_JAR_EXECUTABLE AND NOT MINGW
- AND NOT "${CMAKE_TEST_GENERATOR}" MATCHES "Xcode")
+ AND NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
get_filename_component(JNIPATH ${JAVA_COMPILE} PATH)
find_file(JNI_H jni.h
"${JNIPATH}/../include"
@@ -2631,7 +2652,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
endif()
# add some cross compiler tests, for now only with makefile based generators
- if(CMAKE_TEST_GENERATOR MATCHES "Makefiles" OR CMAKE_TEST_GENERATOR MATCHES "KDevelop")
+ if(CMAKE_GENERATOR MATCHES "Makefiles" OR CMAKE_GENERATOR MATCHES "KDevelop")
# if sdcc is found, build the SimpleCOnly project with sdcc
find_program(SDCC_EXECUTABLE sdcc)
@@ -2784,5 +2805,7 @@ ${CMake_BINARY_DIR}/bin/cmake -DVERSION=master -P ${CMake_SOURCE_DIR}/Utilities/
WORKING_DIRECTORY ${CMake_BINARY_DIR}/Utilities/KWStyle)
endif()
- add_subdirectory(CMakeTests)
+ if(NOT CMake_TEST_EXTERNAL_CMAKE)
+ add_subdirectory(CMakeTests)
+ endif()
endif()
diff --git a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
index 691728a..15493be 100644
--- a/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
+++ b/Tests/CMakeOnly/AllFindModules/CMakeLists.txt
@@ -8,11 +8,14 @@ endif ()
# Avoid ctest truncation of output
message(STATUS "CTEST_FULL_OUTPUT")
+set(ORIGINAL_MODULE_PATH "${CMAKE_MODULE_PATH}")
+
file(GLOB FIND_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules/Find*.cmake" )
macro(do_find MODULE_NAME)
message(STATUS " Checking Find${MODULE_NAME}")
find_package(${MODULE_NAME})
+ set(CMAKE_MODULE_PATH "${ORIGINAL_MODULE_PATH}")
endmacro()
# It is only possible to use either Qt3 or Qt4 in one project.
diff --git a/Tests/CMakeOnly/Test.cmake.in b/Tests/CMakeOnly/Test.cmake.in
index a266415..285643a 100644
--- a/Tests/CMakeOnly/Test.cmake.in
+++ b/Tests/CMakeOnly/Test.cmake.in
@@ -8,8 +8,8 @@ file(REMOVE_RECURSE "${binary_dir}")
file(MAKE_DIRECTORY "${binary_dir}")
execute_process(
COMMAND ${CMAKE_COMMAND} ${CMAKE_ARGS}
- "${source_dir}" -G "@CMAKE_TEST_GENERATOR@"
- -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+ "${source_dir}" -G "@CMAKE_GENERATOR@"
+ -T "@CMAKE_GENERATOR_TOOLSET@"
WORKING_DIRECTORY "${binary_dir}"
RESULT_VARIABLE result
)
diff --git a/Tests/CMakeTests/CheckCMakeTest.cmake b/Tests/CMakeTests/CheckCMakeTest.cmake
index 7be7b30..1565394 100644
--- a/Tests/CMakeTests/CheckCMakeTest.cmake
+++ b/Tests/CMakeTests/CheckCMakeTest.cmake
@@ -9,8 +9,8 @@ function(check_cmake_test_single prefix test testfile)
ERROR_VARIABLE stderr
RESULT_VARIABLE result
)
- string(REGEX REPLACE "\n" "\n out> " out " out> ${stdout}")
- string(REGEX REPLACE "\n" "\n err> " err " err> ${stderr}")
+ string(REPLACE "\n" "\n out> " out " out> ${stdout}")
+ string(REPLACE "\n" "\n err> " err " err> ${stderr}")
if(NOT "${result}" STREQUAL "${${test}-RESULT}")
message(FATAL_ERROR
"Test ${test} result is [${result}], not [${${test}-RESULT}].\n"
diff --git a/Tests/CMakeTests/ExecuteScriptTests.cmake b/Tests/CMakeTests/ExecuteScriptTests.cmake
index c71585a..bceac33 100644
--- a/Tests/CMakeTests/ExecuteScriptTests.cmake
+++ b/Tests/CMakeTests/ExecuteScriptTests.cmake
@@ -52,9 +52,9 @@ function(execute_all_script_tests scriptname result)
foreach(line ${script})
if(line MATCHES "${regex}")
+ set(testname "${CMAKE_MATCH_2}")
+ set(expected_result "${CMAKE_MATCH_3}")
math(EXPR count "${count} + 1")
- string(REGEX REPLACE "${regex}" "\\2" testname "${line}")
- string(REGEX REPLACE "${regex}" "\\3" expected_result "${line}")
execute_one_script_test(${scriptname} ${testname} ${expected_result})
endif()
endforeach()
diff --git a/Tests/CPackWiXGenerator/CMakeLists.txt b/Tests/CPackWiXGenerator/CMakeLists.txt
index d673d14..638e788 100644
--- a/Tests/CPackWiXGenerator/CMakeLists.txt
+++ b/Tests/CPackWiXGenerator/CMakeLists.txt
@@ -9,6 +9,11 @@ target_link_libraries(my-libapp mylib)
add_executable(my-other-app myotherapp.cpp)
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty)
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty
+ DESTINATION extras
+ COMPONENT extras)
+
install(TARGETS mylib
ARCHIVE
DESTINATION lib
@@ -58,6 +63,9 @@ set(CPACK_WIX_PATCH_FILE "${CMAKE_CURRENT_SOURCE_DIR}/patch.xml")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/license.txt")
+set(CPACK_WIX_PROPERTY_ARPCOMMENTS "My Custom ARPCOMMENTS")
+set(CPACK_WIX_PROPERTY_ARPHELPLINK "http://www.cmake.org")
+
include(CPack)
cpack_add_install_type(Full DISPLAY_NAME "Everything")
@@ -69,6 +77,12 @@ cpack_add_component_group(Development
EXPANDED
DESCRIPTION "All of the tools you'll ever need to develop software")
+cpack_add_component(extras
+ DISPLAY_NAME "Extras"
+ DESCRIPTION "Extras"
+ GROUP Runtime
+ INSTALL_TYPES Full)
+
cpack_add_component(applications
REQUIRED
DISPLAY_NAME "MyLib Application"
diff --git a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
index 30e33cf2..ca9fd90 100644
--- a/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
+++ b/Tests/CPackWiXGenerator/RunCPackVerifyResult.cmake
@@ -10,7 +10,12 @@ message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}")
message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}")
message(STATUS "CPackWiXGenerator_BINARY_DIR: ${CPackWiXGenerator_BINARY_DIR}")
+if(config)
+ set(_C_config -C ${config})
+endif()
+
execute_process(COMMAND "${CMAKE_CPACK_COMMAND}"
+ ${_C_config}
RESULT_VARIABLE CPack_result
OUTPUT_VARIABLE CPack_output
ERROR_VARIABLE CPack_error
diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
index abf010b..670a874 100644
--- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
+++ b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
@@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.8.10)
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
set(CTEST_PROJECT_NAME "VSProjectInSubdir")
set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@")
diff --git a/Tests/CTestConfig/dashboard.cmake.in b/Tests/CTestConfig/dashboard.cmake.in
index 0bba6d6..608501c 100644
--- a/Tests/CTestConfig/dashboard.cmake.in
+++ b/Tests/CTestConfig/dashboard.cmake.in
@@ -18,8 +18,8 @@ endif()
message("cmake initial configure")
execute_process(COMMAND ${CMAKE_COMMAND}
${arg}
- -G "@CMAKE_TEST_GENERATOR@"
- -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+ -G "@CMAKE_GENERATOR@"
+ -T "@CMAKE_GENERATOR_TOOLSET@"
${CTEST_SOURCE_DIRECTORY}
WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY}
RESULT_VARIABLE rv)
diff --git a/Tests/CTestConfig/script.cmake.in b/Tests/CTestConfig/script.cmake.in
index 83267a4..166de3b 100644
--- a/Tests/CTestConfig/script.cmake.in
+++ b/Tests/CTestConfig/script.cmake.in
@@ -1,5 +1,5 @@
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_PROJECT_NAME "CTestConfig")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestConfig")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestConfig/@cfg@-script")
diff --git a/Tests/CTestTestBadExe/test.cmake.in b/Tests/CTestTestBadExe/test.cmake.in
index a7420fc..601aab4 100644
--- a/Tests/CTestTestBadExe/test.cmake.in
+++ b/Tests/CTestTestBadExe/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-BadExe")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestBadExe")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestBadExe")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestChecksum/test.cmake.in b/Tests/CTestTestChecksum/test.cmake.in
index b18cdf3..8413443 100644
--- a/Tests/CTestTestChecksum/test.cmake.in
+++ b/Tests/CTestTestChecksum/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Checksum")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in
index 42225d3..d3510bb 100644
--- a/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in
+++ b/Tests/CTestTestConfigFileInBuildDir/test1.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuild
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir1")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in
index 010fe1c..99b002c 100644
--- a/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in
+++ b/Tests/CTestTestConfigFileInBuildDir/test2.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ConfigFileInBuild
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestConfigFileInBuildDir")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestConfigFileInBuildDir2")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestCostSerial/test.cmake.in b/Tests/CTestTestCostSerial/test.cmake.in
index e2dda95..ce8720c 100644
--- a/Tests/CTestTestCostSerial/test.cmake.in
+++ b/Tests/CTestTestCostSerial/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-CostSerial")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCostSerial")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCostSerial")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestCrash/test.cmake.in b/Tests/CTestTestCrash/test.cmake.in
index 7ac1bb9..5906d12 100644
--- a/Tests/CTestTestCrash/test.cmake.in
+++ b/Tests/CTestTestCrash/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Crash")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCrash")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCrash")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestCycle/test.cmake.in b/Tests/CTestTestCycle/test.cmake.in
index 94b9cac..478badb 100644
--- a/Tests/CTestTestCycle/test.cmake.in
+++ b/Tests/CTestTestCycle/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Cycle")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestCycle")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestCycle")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestDepends/test.cmake.in b/Tests/CTestTestDepends/test.cmake.in
index 98b2a27..a7de8cc 100644
--- a/Tests/CTestTestDepends/test.cmake.in
+++ b/Tests/CTestTestDepends/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Depends")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestDepends")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestDepends")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestFailure/testNoBuild.cmake.in b/Tests/CTestTestFailure/testNoBuild.cmake.in
index 1dee1ae..143daf8 100644
--- a/Tests/CTestTestFailure/testNoBuild.cmake.in
+++ b/Tests/CTestTestFailure/testNoBuild.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoBuild")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestFailure/testNoExe.cmake.in b/Tests/CTestTestFailure/testNoExe.cmake.in
index 04e444d..11a1930 100644
--- a/Tests/CTestTestFailure/testNoExe.cmake.in
+++ b/Tests/CTestTestFailure/testNoExe.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-NoExe")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFailure")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFailure")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestFdSetSize/test.cmake.in b/Tests/CTestTestFdSetSize/test.cmake.in
index c24f505..fbe0e82 100644
--- a/Tests/CTestTestFdSetSize/test.cmake.in
+++ b/Tests/CTestTestFdSetSize/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-FdSetSize")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestFdSetSize")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestFdSetSize")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestMemcheck/CMakeLists.txt b/Tests/CTestTestMemcheck/CMakeLists.txt
index 9bd7249..8984463 100644
--- a/Tests/CTestTestMemcheck/CMakeLists.txt
+++ b/Tests/CTestTestMemcheck/CMakeLists.txt
@@ -19,14 +19,6 @@ add_executable(pseudo_valgrind "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
set_target_properties(pseudo_valgrind PROPERTIES OUTPUT_NAME valgrind)
target_link_libraries(pseudo_valgrind CMakeLib)
-# Xcode 2.x forgets to create the output directory before linking
-# the individual architectures.
-if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
- add_custom_command(TARGET pseudo_valgrind
- PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
- )
-endif()
-
add_executable(pseudo_purify "${CMAKE_CURRENT_BINARY_DIR}/ret0.cxx")
set_target_properties(pseudo_purify PROPERTIES OUTPUT_NAME purify)
target_link_libraries(pseudo_purify CMakeLib)
@@ -196,3 +188,18 @@ set_tests_properties(CTestTestMemcheckDummyValgrindCustomOptions PROPERTIES
set_tests_properties(CTestTestMemcheckDummyValgrindTwoTargets PROPERTIES
PASS_REGULAR_EXPRESSION
"\nMemory check project ${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets\n.*\n *Start 1: RunCMake\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.1.log\" \"-q\".*\n *Start 2: RunCMakeAgain\n(.*\n)?Memory check command: .* \"--log-file=${CTEST_ESCAPED_CMAKE_CURRENT_BINARY_DIR}/DummyValgrindTwoTargets/Testing/Temporary/MemoryChecker.2.log\" \"-q\".*\n")
+
+# Xcode 2.x forgets to create the output directory before linking
+# the individual architectures.
+if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
+ foreach(t
+ memcheck_fail
+ pseudo_BC
+ pseudo_purify
+ pseudo_valgrind
+ )
+ add_custom_command(TARGET ${t}
+ PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
+ )
+ endforeach()
+endif()
diff --git a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt
index c5aa2cd..3a45bfe 100644
--- a/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt
+++ b/Tests/CTestTestMemcheck/NoLogDummyChecker/CMakeLists.txt
@@ -1,17 +1,22 @@
# A dummy checker implementation that does not write the requested output file
# so it triggers an error for every checker.
-file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c" "int main(){return 0;}\n")
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in" "int main(){return 0;}\n")
+
+configure_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/ret0.c.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ret0.c"
+ )
foreach(_pseudo IN ITEMS valgrind purify BC)
add_executable(pseudonl_${_pseudo} "${CMAKE_CURRENT_BINARY_DIR}/ret0.c")
set_target_properties(pseudonl_${_pseudo} PROPERTIES OUTPUT_NAME ${_pseudo})
-endforeach()
-# Xcode 2.x forgets to create the output directory before linking
-# the individual architectures.
-if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
- add_custom_command(TARGET pseudonl_valgrind
+ # Xcode 2.x forgets to create the output directory before linking
+ # the individual architectures.
+ if(CMAKE_OSX_ARCHITECTURES AND XCODE AND NOT "${XCODE_VERSION}" MATCHES "^[^12]")
+ add_custom_command(TARGET pseudonl_${_pseudo}
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CFG_INTDIR}"
)
-endif()
+ endif()
+endforeach()
diff --git a/Tests/CTestTestMemcheck/test.cmake.in b/Tests/CTestTestMemcheck/test.cmake.in
index 6c388c5..471e5a5 100644
--- a/Tests/CTestTestMemcheck/test.cmake.in
+++ b/Tests/CTestTestMemcheck/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Memcheck@SUBTEST_
set(CTEST_SOURCE_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@")
set(CTEST_BINARY_DIRECTORY "@CMAKE_CURRENT_BINARY_DIR@/@SUBTEST_NAME@")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestParallel/test.cmake.in b/Tests/CTestTestParallel/test.cmake.in
index 5826342..48631ca 100644
--- a/Tests/CTestTestParallel/test.cmake.in
+++ b/Tests/CTestTestParallel/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Parallel")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestParallel")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestParallel")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestResourceLock/test.cmake.in b/Tests/CTestTestResourceLock/test.cmake.in
index f69b519..6ec6dfe 100644
--- a/Tests/CTestTestResourceLock/test.cmake.in
+++ b/Tests/CTestTestResourceLock/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ResourceLock")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestResourceLock")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestResourceLock")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestScheduler/test.cmake.in b/Tests/CTestTestScheduler/test.cmake.in
index 26d8058..06ba33e 100644
--- a/Tests/CTestTestScheduler/test.cmake.in
+++ b/Tests/CTestTestScheduler/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Scheduler")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestScheduler")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestScheduler")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestSkipReturnCode/test.cmake.in b/Tests/CTestTestSkipReturnCode/test.cmake.in
index ebee01b..d3c44f5 100644
--- a/Tests/CTestTestSkipReturnCode/test.cmake.in
+++ b/Tests/CTestTestSkipReturnCode/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-SkipReturnCode")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSkipReturnCode")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSkipReturnCode")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestStopTime/test.cmake.in b/Tests/CTestTestStopTime/test.cmake.in
index d4e5a25..8adf941 100644
--- a/Tests/CTestTestStopTime/test.cmake.in
+++ b/Tests/CTestTestStopTime/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-StopTime")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestStopTime")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestStopTime")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestSubdir/test.cmake.in b/Tests/CTestTestSubdir/test.cmake.in
index 2b4ef4f..5a6caf1 100644
--- a/Tests/CTestTestSubdir/test.cmake.in
+++ b/Tests/CTestTestSubdir/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Subdir")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestSubdir")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestSubdir")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestTimeout/test.cmake.in b/Tests/CTestTestTimeout/test.cmake.in
index d3d0888..4178849 100644
--- a/Tests/CTestTestTimeout/test.cmake.in
+++ b/Tests/CTestTestTimeout/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Timeout")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestTimeout")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestTimeout")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestTestUpload/test.cmake.in b/Tests/CTestTestUpload/test.cmake.in
index 340877f..bb6ba25 100644
--- a/Tests/CTestTestUpload/test.cmake.in
+++ b/Tests/CTestTestUpload/test.cmake.in
@@ -7,8 +7,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-Upload")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestUpload")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestUpload")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
CTEST_START(Experimental)
diff --git a/Tests/CTestTestZeroTimeout/test.cmake.in b/Tests/CTestTestZeroTimeout/test.cmake.in
index 3252754..beb6d90 100644
--- a/Tests/CTestTestZeroTimeout/test.cmake.in
+++ b/Tests/CTestTestZeroTimeout/test.cmake.in
@@ -8,8 +8,8 @@ set(CTEST_BUILD_NAME "CTestTest-@BUILDNAME@-ZeroTimeout")
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestZeroTimeout")
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestZeroTimeout")
set(CTEST_CVS_COMMAND "@CVSCOMMAND@")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_TEST_GENERATOR@")
-set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_TEST_GENERATOR_TOOLSET@")
+set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+set(CTEST_CMAKE_GENERATOR_TOOLSET "@CMAKE_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
set(CTEST_COVERAGE_COMMAND "@COVERAGE_COMMAND@")
set(CTEST_NOTES_FILES "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}")
diff --git a/Tests/CTestUpdateCommon.cmake b/Tests/CTestUpdateCommon.cmake
index 642a618..857c6f5 100644
--- a/Tests/CTestUpdateCommon.cmake
+++ b/Tests/CTestUpdateCommon.cmake
@@ -9,7 +9,7 @@ function(run_child)
ERROR_STRIP_TRAILING_WHITESPACE
)
if(FAILED)
- string(REGEX REPLACE "\n" "\n " OUTPUT "${OUTPUT}")
+ string(REPLACE "\n" "\n " OUTPUT "${OUTPUT}")
message(FATAL_ERROR "Child failed (${FAILED}), output is\n ${OUTPUT}\n"
"Command = [${ARGN}]\n")
endif()
@@ -108,7 +108,7 @@ function(check_updates build)
${TOP}/${build}/Testing/Temporary/LastUpdate*.log)
if(UPDATE_LOG_FILE)
file(READ ${UPDATE_LOG_FILE} UPDATE_LOG LIMIT ${max_update_xml_size})
- string(REGEX REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}")
+ string(REPLACE "\n" "\n " UPDATE_LOG "${UPDATE_LOG}")
set(MSG "${MSG}Update log:\n ${UPDATE_LOG}")
else()
set(MSG "${MSG}No update log found!")
diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt
new file mode 100644
index 0000000..ce5004b
--- /dev/null
+++ b/Tests/CompileFeatures/CMakeLists.txt
@@ -0,0 +1,44 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(CompileFeatures)
+
+if (NOT CMAKE_CXX_COMPILE_FEATURES)
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp"
+ "int main(int,char**) { return 0; }\n"
+ )
+ add_executable(CompileFeatures "${CMAKE_CURRENT_BINARY_DIR}/dummy.cpp")
+ return()
+endif()
+
+macro(run_test feature)
+ if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ${feature})
+ add_library(test_${feature} OBJECT ${feature}.cpp)
+ set_property(TARGET test_${feature}
+ PROPERTY COMPILE_FEATURES "${feature}"
+ )
+ else()
+ message("Not supported: ${feature}")
+ endif()
+endmacro()
+
+foreach(feature ${CMAKE_CXX_KNOWN_FEATURES})
+ run_test(${feature})
+endforeach()
+
+add_executable(CompileFeatures main.cpp)
+set_property(TARGET CompileFeatures
+ PROPERTY COMPILE_FEATURES "cxx_auto_type"
+)
+
+add_executable(GenexCompileFeatures main.cpp)
+set_property(TARGET GenexCompileFeatures
+ PROPERTY COMPILE_FEATURES "$<1:cxx_auto_type>;$<0:not_a_feature>"
+)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface
+ PROPERTY INTERFACE_COMPILE_FEATURES "cxx_auto_type"
+)
+add_executable(IfaceCompileFeatures main.cpp)
+target_link_libraries(IfaceCompileFeatures iface)
diff --git a/Tests/CompileFeatures/cxx_alias_templates.cpp b/Tests/CompileFeatures/cxx_alias_templates.cpp
new file mode 100644
index 0000000..a47e27d
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_alias_templates.cpp
@@ -0,0 +1,11 @@
+
+template <typename T1, typename T2>
+struct A
+{
+ typedef T1 MyT1;
+ using MyT2 = T2;
+};
+
+using B = A<int, char>;
+template<typename T>
+using C = A<int, T>;
diff --git a/Tests/CompileFeatures/cxx_alignas.cpp b/Tests/CompileFeatures/cxx_alignas.cpp
new file mode 100644
index 0000000..35b7c82
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_alignas.cpp
@@ -0,0 +1,4 @@
+
+struct S1 {
+ alignas(8) int n;
+};
diff --git a/Tests/CompileFeatures/cxx_alignof.cpp b/Tests/CompileFeatures/cxx_alignof.cpp
new file mode 100644
index 0000000..63b14fe
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_alignof.cpp
@@ -0,0 +1,5 @@
+
+int someFunc()
+{
+ return alignof(int);
+}
diff --git a/Tests/CompileFeatures/cxx_attributes.cpp b/Tests/CompileFeatures/cxx_attributes.cpp
new file mode 100644
index 0000000..a3c89ea
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_attributes.cpp
@@ -0,0 +1,2 @@
+
+void unusedFunc [[noreturn]] () { throw 1; }
diff --git a/Tests/CompileFeatures/cxx_auto_type.cpp b/Tests/CompileFeatures/cxx_auto_type.cpp
new file mode 100644
index 0000000..7dbf04f
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_auto_type.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+ auto x = 3.14;
+}
diff --git a/Tests/CompileFeatures/cxx_constexpr.cpp b/Tests/CompileFeatures/cxx_constexpr.cpp
new file mode 100644
index 0000000..570c10f
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_constexpr.cpp
@@ -0,0 +1,5 @@
+
+constexpr int getNum()
+{
+ return 42;
+}
diff --git a/Tests/CompileFeatures/cxx_decltype.cpp b/Tests/CompileFeatures/cxx_decltype.cpp
new file mode 100644
index 0000000..24ec51e
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_decltype.cpp
@@ -0,0 +1,7 @@
+
+int someFunc()
+{
+ int i = 0;
+ decltype(i) other = 0;
+ return other;
+}
diff --git a/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
new file mode 100644
index 0000000..109d038
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_decltype_incomplete_return_types.cpp
@@ -0,0 +1,14 @@
+
+template<class T>
+struct A
+{
+ ~A() = delete;
+};
+
+template<class T> auto h() -> A<T>;
+template<class T> auto i(T) -> T;
+template<class T> auto f(T) -> decltype(i(h<T>()));
+template<class T> auto f(T) -> void;
+auto g() -> void {
+ f(42);
+}
diff --git a/Tests/CompileFeatures/cxx_default_function_template_args.cpp b/Tests/CompileFeatures/cxx_default_function_template_args.cpp
new file mode 100644
index 0000000..3d14c52
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_default_function_template_args.cpp
@@ -0,0 +1,12 @@
+
+template<typename T = int>
+int someFunc()
+{
+ T t = 0;
+ return t;
+}
+
+void otherFunc()
+{
+ someFunc();
+}
diff --git a/Tests/CompileFeatures/cxx_defaulted_functions.cpp b/Tests/CompileFeatures/cxx_defaulted_functions.cpp
new file mode 100644
index 0000000..b679a92
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_defaulted_functions.cpp
@@ -0,0 +1,9 @@
+
+struct A {
+ A() = default;
+};
+
+void someFunc()
+{
+ A a;
+}
diff --git a/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp b/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp
new file mode 100644
index 0000000..14f9871
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_defaulted_move_initializers.cpp
@@ -0,0 +1,7 @@
+
+struct A
+{
+ A() = default;
+ A& operator=(A&&) = default;
+ A(A&&) = default;
+};
diff --git a/Tests/CompileFeatures/cxx_delegating_constructors.cpp b/Tests/CompileFeatures/cxx_delegating_constructors.cpp
new file mode 100644
index 0000000..4b41615
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_delegating_constructors.cpp
@@ -0,0 +1,15 @@
+
+class Foo
+{
+public:
+ Foo(int i);
+
+ Foo(double d)
+ : Foo(static_cast<int>(d))
+ {
+
+ }
+
+private:
+ int m_i;
+};
diff --git a/Tests/CompileFeatures/cxx_deleted_functions.cpp b/Tests/CompileFeatures/cxx_deleted_functions.cpp
new file mode 100644
index 0000000..4ecb1e9
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_deleted_functions.cpp
@@ -0,0 +1,6 @@
+
+struct A
+{
+ A(const A&) = delete;
+ A& operator=(const A&) = delete;
+};
diff --git a/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp b/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp
new file mode 100644
index 0000000..a7e1445
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_enum_forward_declarations.cpp
@@ -0,0 +1,8 @@
+
+enum SomeEnum : short;
+
+void someFunc()
+{
+ SomeEnum value;
+ int i = value;
+}
diff --git a/Tests/CompileFeatures/cxx_explicit_conversions.cpp b/Tests/CompileFeatures/cxx_explicit_conversions.cpp
new file mode 100644
index 0000000..0decdcd
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_explicit_conversions.cpp
@@ -0,0 +1,10 @@
+
+class A
+{
+ int m_i;
+public:
+ explicit operator bool()
+ {
+ return m_i != 0;
+ }
+};
diff --git a/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
new file mode 100644
index 0000000..631c699
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_extended_friend_declarations.cpp
@@ -0,0 +1,25 @@
+
+template <typename T>
+struct B
+{
+ B() : m_i(42) {}
+private:
+ int m_i;
+ friend T;
+};
+
+struct A
+{
+ template<typename T>
+ int getBValue(B<T> b)
+ {
+ return b.m_i;
+ }
+};
+
+void someFunc()
+{
+ A a;
+ B<A> b;
+ a.getBValue(b);
+}
diff --git a/Tests/CompileFeatures/cxx_extern_templates.cpp b/Tests/CompileFeatures/cxx_extern_templates.cpp
new file mode 100644
index 0000000..9fa4aa4
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_extern_templates.cpp
@@ -0,0 +1,12 @@
+
+template<typename T>
+void someFunc()
+{
+}
+
+extern template void someFunc<int>();
+
+void otherFunc()
+{
+ someFunc<int>();
+}
diff --git a/Tests/CompileFeatures/cxx_final.cpp b/Tests/CompileFeatures/cxx_final.cpp
new file mode 100644
index 0000000..598cb94
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_final.cpp
@@ -0,0 +1,2 @@
+
+struct A final {};
diff --git a/Tests/CompileFeatures/cxx_func_identifier.cpp b/Tests/CompileFeatures/cxx_func_identifier.cpp
new file mode 100644
index 0000000..0c3595c
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_func_identifier.cpp
@@ -0,0 +1,6 @@
+
+void someFunc()
+{
+ bool b = sizeof(__func__);
+ (void)b;
+}
diff --git a/Tests/CompileFeatures/cxx_generalized_initializers.cpp b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
new file mode 100644
index 0000000..8013ef5
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_generalized_initializers.cpp
@@ -0,0 +1,23 @@
+
+// Dummy implementation. Test only the compiler feature.
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+ template <class _E>
+ class initializer_list
+ {
+ const _E* __begin_;
+ size_t __size_;
+
+ };
+}
+
+template <typename T>
+struct A
+{
+ A(std::initializer_list<T>) {}
+};
+
+void someFunc()
+{
+ A<int> as = { 1, 2, 3, 4 };
+}
diff --git a/Tests/CompileFeatures/cxx_inheriting_constructors.cpp b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
new file mode 100644
index 0000000..a83b624
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_inheriting_constructors.cpp
@@ -0,0 +1,18 @@
+
+struct A
+{
+ int m_i;
+
+ A(int i) : m_i(i) {}
+};
+
+struct B : public A
+{
+ using A::A;
+};
+
+void someFunc()
+{
+ int i;
+ B b(i);
+}
diff --git a/Tests/CompileFeatures/cxx_inline_namespaces.cpp b/Tests/CompileFeatures/cxx_inline_namespaces.cpp
new file mode 100644
index 0000000..59fa9c8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_inline_namespaces.cpp
@@ -0,0 +1,26 @@
+namespace Lib
+{
+inline namespace Lib_1
+{
+ template <typename T> class A;
+}
+
+template <typename T> void g(T);
+}
+
+struct MyClass {
+
+};
+namespace Lib
+{
+template<>
+class A<MyClass> {
+
+};
+}
+
+void someFunc()
+{
+ Lib::A<MyClass> a;
+ g(a); // ok, Lib is an associated namespace of A
+}
diff --git a/Tests/CompileFeatures/cxx_lambdas.cpp b/Tests/CompileFeatures/cxx_lambdas.cpp
new file mode 100644
index 0000000..eecaa23
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_lambdas.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+ [](){}();
+}
diff --git a/Tests/CompileFeatures/cxx_local_type_template_args.cpp b/Tests/CompileFeatures/cxx_local_type_template_args.cpp
new file mode 100644
index 0000000..802ea7a
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_local_type_template_args.cpp
@@ -0,0 +1,21 @@
+
+template <typename T>
+class X { };
+template <typename T>
+void f(T t) { }
+struct {} unnamed_obj;
+void f() {
+ struct A { };
+ enum { e1 };
+ typedef struct {} B;
+ B b;
+ X<A> x1;
+ X<A*> x2;
+ X<B> x3;
+ f(e1);
+ f(unnamed_obj);
+ f(b);
+ (void)x1;
+ (void)x2;
+ (void)x3;
+}
diff --git a/Tests/CompileFeatures/cxx_long_long_type.cpp b/Tests/CompileFeatures/cxx_long_long_type.cpp
new file mode 100644
index 0000000..670324c
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_long_long_type.cpp
@@ -0,0 +1,5 @@
+
+void someFunc()
+{
+ long long ll = 9223372036854775807LL;
+}
diff --git a/Tests/CompileFeatures/cxx_noexcept.cpp b/Tests/CompileFeatures/cxx_noexcept.cpp
new file mode 100644
index 0000000..a3c05b8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_noexcept.cpp
@@ -0,0 +1,5 @@
+
+void someFunc() noexcept
+{
+
+}
diff --git a/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp b/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp
new file mode 100644
index 0000000..6b7fa70
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_nonstatic_member_init.cpp
@@ -0,0 +1,4 @@
+class A
+{
+ int m_i = 42;
+};
diff --git a/Tests/CompileFeatures/cxx_nullptr.cpp b/Tests/CompileFeatures/cxx_nullptr.cpp
new file mode 100644
index 0000000..96307df
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_nullptr.cpp
@@ -0,0 +1,10 @@
+
+void someFunc(int*)
+{
+
+}
+
+void otherFunc()
+{
+ someFunc(nullptr);
+}
diff --git a/Tests/CompileFeatures/cxx_override.cpp b/Tests/CompileFeatures/cxx_override.cpp
new file mode 100644
index 0000000..55bec13
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_override.cpp
@@ -0,0 +1,7 @@
+
+struct A {
+ virtual void doNothing() {}
+};
+struct B : A {
+ void doNothing() override {}
+};
diff --git a/Tests/CompileFeatures/cxx_range_for.cpp b/Tests/CompileFeatures/cxx_range_for.cpp
new file mode 100644
index 0000000..892109e
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_range_for.cpp
@@ -0,0 +1,10 @@
+
+void someFunc()
+{
+ int accumulated = 0;
+ int numbers[] = { 1, 2, 5 };
+ for (int i : numbers)
+ {
+ accumulated += i;
+ }
+}
diff --git a/Tests/CompileFeatures/cxx_raw_string_literals.cpp b/Tests/CompileFeatures/cxx_raw_string_literals.cpp
new file mode 100644
index 0000000..ea4d231
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_raw_string_literals.cpp
@@ -0,0 +1,7 @@
+
+void someFunc()
+{
+const char p[] = R"(a\
+b
+c)";
+}
diff --git a/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
new file mode 100644
index 0000000..83a2361
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_reference_qualified_functions.cpp
@@ -0,0 +1,11 @@
+
+struct test{
+ void f() & { }
+ void f() && { }
+};
+
+void someFunc(){
+ test t;
+ t.f(); // lvalue
+ test().f(); // rvalue
+}
diff --git a/Tests/CompileFeatures/cxx_right_angle_brackets.cpp b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
new file mode 100644
index 0000000..2713fd8
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_right_angle_brackets.cpp
@@ -0,0 +1,12 @@
+
+template<typename T>
+struct A
+{
+ typedef T Result;
+};
+
+void someFunc()
+{
+ A<A<int>> object;
+ (void)object;
+}
diff --git a/Tests/CompileFeatures/cxx_rvalue_references.cpp b/Tests/CompileFeatures/cxx_rvalue_references.cpp
new file mode 100644
index 0000000..787026a
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_rvalue_references.cpp
@@ -0,0 +1,5 @@
+
+void someFunc(int&&)
+{
+
+}
diff --git a/Tests/CompileFeatures/cxx_sizeof_member.cpp b/Tests/CompileFeatures/cxx_sizeof_member.cpp
new file mode 100644
index 0000000..ae143d2
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_sizeof_member.cpp
@@ -0,0 +1,10 @@
+
+struct A
+{
+ int m_i;
+};
+
+int someFunc()
+{
+ return sizeof(A::m_i) > 0 ? 1 : 2;
+}
diff --git a/Tests/CompileFeatures/cxx_static_assert.cpp b/Tests/CompileFeatures/cxx_static_assert.cpp
new file mode 100644
index 0000000..6aa8678
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_static_assert.cpp
@@ -0,0 +1,2 @@
+
+static_assert(true, "static_assert test");
diff --git a/Tests/CompileFeatures/cxx_strong_enums.cpp b/Tests/CompileFeatures/cxx_strong_enums.cpp
new file mode 100644
index 0000000..6262456
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_strong_enums.cpp
@@ -0,0 +1,7 @@
+
+enum class Colors
+{
+ RedColor,
+ GreenColor,
+ BlueColor
+};
diff --git a/Tests/CompileFeatures/cxx_thread_local.cpp b/Tests/CompileFeatures/cxx_thread_local.cpp
new file mode 100644
index 0000000..1fb27e2
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_thread_local.cpp
@@ -0,0 +1,2 @@
+
+thread_local unsigned int rage = 1;
diff --git a/Tests/CompileFeatures/cxx_trailing_return_types.cpp b/Tests/CompileFeatures/cxx_trailing_return_types.cpp
new file mode 100644
index 0000000..01a76cb
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_trailing_return_types.cpp
@@ -0,0 +1,5 @@
+
+auto someFunc() -> int
+{
+ return 42;
+}
diff --git a/Tests/CompileFeatures/cxx_unicode_literals.cpp b/Tests/CompileFeatures/cxx_unicode_literals.cpp
new file mode 100644
index 0000000..a7b7df0
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_unicode_literals.cpp
@@ -0,0 +1,3 @@
+
+const char16_t lit_16[] = u"\u00DA";
+const char32_t lit_32[] = U"\u00DA";
diff --git a/Tests/CompileFeatures/cxx_uniform_initialization.cpp b/Tests/CompileFeatures/cxx_uniform_initialization.cpp
new file mode 100644
index 0000000..82c76e2
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_uniform_initialization.cpp
@@ -0,0 +1,9 @@
+struct A {};
+struct B {
+ B(A) {}
+};
+
+void Func()
+{
+ B b{A{}};
+}
diff --git a/Tests/CompileFeatures/cxx_unrestricted_unions.cpp b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
new file mode 100644
index 0000000..698fd61
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_unrestricted_unions.cpp
@@ -0,0 +1,11 @@
+
+struct point {
+ point() {}
+ point(int x, int y) : x_(x), y_(y) {}
+ int x_, y_;
+};
+union u {
+ point p_;
+ int i_;
+ const char* s_;
+};
diff --git a/Tests/CompileFeatures/cxx_user_literals.cpp b/Tests/CompileFeatures/cxx_user_literals.cpp
new file mode 100644
index 0000000..9e5a588
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_user_literals.cpp
@@ -0,0 +1,7 @@
+
+long double operator "" _meters(long double);
+
+void someFunc()
+{
+ long double i = 1.2_meters;
+}
diff --git a/Tests/CompileFeatures/cxx_variadic_macros.cpp b/Tests/CompileFeatures/cxx_variadic_macros.cpp
new file mode 100644
index 0000000..4d007a5
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_variadic_macros.cpp
@@ -0,0 +1,12 @@
+
+int someFunc(int, char, int)
+{
+ return 0;
+}
+
+#define FUNC_WRAPPER(...) someFunc(__VA_ARGS__)
+
+void otherFunc()
+{
+ FUNC_WRAPPER(42, 'a', 7);
+}
diff --git a/Tests/CompileFeatures/cxx_variadic_templates.cpp b/Tests/CompileFeatures/cxx_variadic_templates.cpp
new file mode 100644
index 0000000..1d5a706
--- /dev/null
+++ b/Tests/CompileFeatures/cxx_variadic_templates.cpp
@@ -0,0 +1,65 @@
+template<int I, int... Is>
+struct Interface;
+
+template<int I>
+struct Interface<I>
+{
+ static int accumulate()
+ {
+ return I;
+ }
+};
+
+template<int I, int... Is>
+struct Interface
+{
+ static int accumulate()
+ {
+ return I + Interface<Is...>::accumulate();
+ }
+};
+
+// Note: split this into a separate test if a
+// cxx_variadic_template_template_parameters feature is added.
+
+template<typename T>
+struct eval {
+ enum {
+ Matched = 0
+ };
+};
+
+template<template<typename...> class T, typename... U>
+struct eval<T<U...> > {
+ enum {
+ Matched = 1
+ };
+};
+
+template<typename...>
+struct A {
+
+};
+template<typename T>
+struct B {
+
+};
+template<typename T, typename U>
+struct C {
+
+};
+template<typename T, typename U, typename...>
+struct D {
+
+};
+
+// Note: This test assumes that a compiler supporting this feature
+// supports static_assert. Add a workaround if that does not hold.
+static_assert(eval<A<> >::Matched, "A Matches");
+static_assert(eval<A<int> >::Matched, "A Matches");
+static_assert(eval<A<int, char> >::Matched, "A Matches");
+static_assert(eval<B<int> >::Matched, "B Matches");
+static_assert(eval<C<int, char> >::Matched, "C Matches");
+static_assert(eval<D<int, char> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool> >::Matched, "D Matches");
+static_assert(eval<D<int, char, bool, double> >::Matched, "D Matches");
diff --git a/Tests/CompileFeatures/main.cpp b/Tests/CompileFeatures/main.cpp
new file mode 100644
index 0000000..3a8e0fc
--- /dev/null
+++ b/Tests/CompileFeatures/main.cpp
@@ -0,0 +1,6 @@
+
+int main(int,char**)
+{
+ auto value = 0;
+ return value;
+}
diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt
index fcde44d..d250f53 100644
--- a/Tests/Complex/CMakeLists.txt
+++ b/Tests/Complex/CMakeLists.txt
@@ -36,7 +36,7 @@ ASSERT(Complex_BINARY_DIR "The PROJECT command is broken")
#
macro(TEST_ARGC value1 value2)
add_definitions(${value1} ${value2})
- if (${ARGC} MATCHES 4)
+ if (${ARGC} EQUAL 4)
add_definitions(${ARGV2} ${ARGV3})
endif ()
endmacro()
@@ -70,7 +70,7 @@ if(NOT 2.4 EQUAL 2.4)
message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4")
endif()
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
endif()
diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt
index a4a0e0e..bb00341 100644
--- a/Tests/ComplexOneConfig/CMakeLists.txt
+++ b/Tests/ComplexOneConfig/CMakeLists.txt
@@ -36,7 +36,7 @@ ASSERT(Complex_BINARY_DIR "The PROJECT command is broken")
#
macro(TEST_ARGC value1 value2)
add_definitions(${value1} ${value2})
- if (${ARGC} MATCHES 4)
+ if (${ARGC} EQUAL 4)
add_definitions(${ARGV2} ${ARGV3})
endif ()
endmacro()
@@ -70,7 +70,7 @@ if(NOT 2.4 EQUAL 2.4)
message(FATAL_ERROR "Failed: NOT 2.4 EQUAL 2.4")
endif()
-if(CMAKE_SYSTEM MATCHES "OSF1-V.*")
+if(CMAKE_SYSTEM MATCHES "OSF1-V")
if(NOT CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -timplicit_local -no_implicit_include ")
endif()
diff --git a/Tests/ConfigSources/CMakeLists.txt b/Tests/ConfigSources/CMakeLists.txt
new file mode 100644
index 0000000..c272257
--- /dev/null
+++ b/Tests/ConfigSources/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(ConfigSources)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_SOURCES
+ iface_src.cpp
+ $<$<CONFIG:Debug>:iface_debug_src.cpp>
+ $<$<CONFIG:Release>:does_not_exist.cpp>
+)
+
+add_executable(ConfigSources
+ $<$<CONFIG:Debug>:main.cpp>
+ $<$<CONFIG:Release>:does_not_exist.cpp>
+)
+target_link_libraries(ConfigSources iface)
diff --git a/Tests/ConfigSources/iface_debug.h b/Tests/ConfigSources/iface_debug.h
new file mode 100644
index 0000000..a23d737
--- /dev/null
+++ b/Tests/ConfigSources/iface_debug.h
@@ -0,0 +1,4 @@
+
+int iface_src();
+
+int iface_debug();
diff --git a/Tests/ConfigSources/iface_debug_src.cpp b/Tests/ConfigSources/iface_debug_src.cpp
new file mode 100644
index 0000000..63b22fc
--- /dev/null
+++ b/Tests/ConfigSources/iface_debug_src.cpp
@@ -0,0 +1,7 @@
+
+#include "iface_debug.h"
+
+int iface_debug()
+{
+ return 0;
+}
diff --git a/Tests/ConfigSources/iface_src.cpp b/Tests/ConfigSources/iface_src.cpp
new file mode 100644
index 0000000..c3a0c8f
--- /dev/null
+++ b/Tests/ConfigSources/iface_src.cpp
@@ -0,0 +1,5 @@
+
+int iface_src()
+{
+ return 0;
+}
diff --git a/Tests/ConfigSources/main.cpp b/Tests/ConfigSources/main.cpp
new file mode 100644
index 0000000..71af72f
--- /dev/null
+++ b/Tests/ConfigSources/main.cpp
@@ -0,0 +1,7 @@
+
+#include "iface_debug.h"
+
+int main(int argc, char** argv)
+{
+ return iface_src() + iface_debug();
+}
diff --git a/Tests/CustomCommand/CMakeLists.txt b/Tests/CustomCommand/CMakeLists.txt
index bbae387..e0854ce 100644
--- a/Tests/CustomCommand/CMakeLists.txt
+++ b/Tests/CustomCommand/CMakeLists.txt
@@ -185,7 +185,7 @@ add_executable(CustomCommand
# here to test adding the generation rule after referencing the
# generated source in a target.
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/generated.c
- DEPENDS generator
+ DEPENDS $<1:generator> $<0:does_not_exist>
COMMAND generator
ARGS ${PROJECT_BINARY_DIR}/generated.c
)
@@ -221,8 +221,11 @@ add_subdirectory(GeneratorInExtraDir)
add_executable(tcat tcat.cxx)
+# Test that list expansion from a generator expression works.
+set_property(TARGET tcat PROPERTY DEPSLIST tcat gen_redirect_in.c)
+
add_custom_command(OUTPUT gen_redirect.c
- DEPENDS tcat gen_redirect_in.c
+ DEPENDS $<TARGET_PROPERTY:tcat,DEPSLIST>
COMMAND tcat < ${CMAKE_CURRENT_SOURCE_DIR}/gen_redirect_in.c > gen_redirect.c
COMMAND ${CMAKE_COMMAND} -E echo "#endif" >> gen_redirect.c
VERBATIM
@@ -364,8 +367,8 @@ endif()
foreach(arg ${CHECK_ARGS} "")
set(ARG "${arg}")
- string(REGEX REPLACE "\\\\" "\\\\\\\\" ARG "${ARG}")
- string(REGEX REPLACE "\"" "\\\\\"" ARG "${ARG}")
+ string(REPLACE "\\" "\\\\" ARG "${ARG}")
+ string(REPLACE "\"" "\\\"" ARG "${ARG}")
set(EXPECTED_ARGUMENTS
"${EXPECTED_ARGUMENTS} \"${ARG}\",
")
diff --git a/Tests/CxxDialect/CMakeLists.txt b/Tests/CxxDialect/CMakeLists.txt
new file mode 100644
index 0000000..0eb6f8f
--- /dev/null
+++ b/Tests/CxxDialect/CMakeLists.txt
@@ -0,0 +1,14 @@
+cmake_minimum_required(VERSION 2.8.12)
+cmake_policy(SET CMP0025 NEW)
+project(CxxDialect)
+
+add_executable(use_typeof use_typeof.cxx)
+set_property(TARGET use_typeof PROPERTY CXX_STANDARD 98)
+set_property(TARGET use_typeof PROPERTY CXX_EXTENSIONS ON)
+
+add_executable(use_constexpr use_constexpr.cxx)
+set_property(TARGET use_constexpr PROPERTY CXX_STANDARD 11)
+
+add_executable(CxxDialect use_constexpr_and_typeof.cxx)
+set_property(TARGET CxxDialect PROPERTY CXX_STANDARD 11)
+set_property(TARGET CxxDialect PROPERTY CXX_EXTENSIONS ON)
diff --git a/Tests/CxxDialect/use_constexpr.cxx b/Tests/CxxDialect/use_constexpr.cxx
new file mode 100644
index 0000000..30ccc4c
--- /dev/null
+++ b/Tests/CxxDialect/use_constexpr.cxx
@@ -0,0 +1,10 @@
+
+constexpr int foo()
+{
+ return 0;
+}
+
+int main(int argc, char**)
+{
+ return foo();
+}
diff --git a/Tests/CxxDialect/use_constexpr_and_typeof.cxx b/Tests/CxxDialect/use_constexpr_and_typeof.cxx
new file mode 100644
index 0000000..af217b6
--- /dev/null
+++ b/Tests/CxxDialect/use_constexpr_and_typeof.cxx
@@ -0,0 +1,11 @@
+
+constexpr int foo()
+{
+ return 0;
+}
+
+int main(int argc, char**)
+{
+ typeof(argc) ret = foo();
+ return ret;
+}
diff --git a/Tests/CxxDialect/use_typeof.cxx b/Tests/CxxDialect/use_typeof.cxx
new file mode 100644
index 0000000..dabb61f
--- /dev/null
+++ b/Tests/CxxDialect/use_typeof.cxx
@@ -0,0 +1,6 @@
+
+int main(int argc, char**)
+{
+ typeof(argc) ret = 0;
+ return ret;
+}
diff --git a/Tests/ExportImport/CMakeLists.txt b/Tests/ExportImport/CMakeLists.txt
index 02a0371..a6f8921 100644
--- a/Tests/ExportImport/CMakeLists.txt
+++ b/Tests/ExportImport/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.7.20090711)
project(ExportImport C CXX)
-if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
endif()
# Wipe out the install tree to make sure the exporter works.
diff --git a/Tests/ExportImport/Export/Interface/CMakeLists.txt b/Tests/ExportImport/Export/Interface/CMakeLists.txt
index 9d4793d..1b653eb 100644
--- a/Tests/ExportImport/Export/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Export/Interface/CMakeLists.txt
@@ -23,7 +23,10 @@ set_property(TARGET sharedlib PROPERTY INTERFACE_COMPILE_DEFINITIONS "SHAREDLIB_
add_library(sharediface INTERFACE)
target_link_libraries(sharediface INTERFACE sharedlib)
-install(TARGETS headeronly sharediface
+add_library(use_auto_type INTERFACE)
+target_compile_features(use_auto_type INTERFACE cxx_auto_type)
+
+install(TARGETS headeronly sharediface use_auto_type
EXPORT expInterface
)
install(TARGETS sharedlib
diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt
index 5e809a2..189f7a2 100644
--- a/Tests/ExportImport/Import/CMakeLists.txt
+++ b/Tests/ExportImport/Import/CMakeLists.txt
@@ -1,4 +1,5 @@
cmake_minimum_required (VERSION 2.7.20090711)
+cmake_policy(SET CMP0025 NEW)
project(Import C CXX)
# Import everything in a subdirectory.
diff --git a/Tests/ExportImport/Import/Interface/CMakeLists.txt b/Tests/ExportImport/Import/Interface/CMakeLists.txt
index cf7e2bc..1f30c67 100644
--- a/Tests/ExportImport/Import/Interface/CMakeLists.txt
+++ b/Tests/ExportImport/Import/Interface/CMakeLists.txt
@@ -40,6 +40,23 @@ macro(do_try_compile prefix)
if(NOT ${prefix}IFACE_TRY_COMPILE)
message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
endif()
+
+ if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";cxx_auto_type;")
+ set(CMAKE_REQUIRED_LIBRARIES ${prefix}::use_auto_type)
+ check_cxx_source_compiles(
+ "
+ int main(int,char**)
+ {
+ auto value = 0;
+ return value;
+ }
+ " ${prefix}IMPORTED_IFACE_CONSTEXPR)
+
+ if(NOT ${prefix}IMPORTED_IFACE_CONSTEXPR)
+ message(SEND_ERROR "${prefix} try_compile with IMPORTED INTERFACE target failed!\n\n${OUTPUT}")
+ endif()
+ endif()
+
endmacro()
do_try_compile(bld)
diff --git a/Tests/ExportImport/InitialCache.cmake.in b/Tests/ExportImport/InitialCache.cmake.in
index fba6ee2..f600d90 100644
--- a/Tests/ExportImport/InitialCache.cmake.in
+++ b/Tests/ExportImport/InitialCache.cmake.in
@@ -1,4 +1,4 @@
-set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program")
+set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program")
set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler")
set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags")
set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags")
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index d9344ec..0ed5561 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -98,6 +98,7 @@ ExternalProject_Add(${proj}
CVS_TAG ""
DEPENDS "MinimalNoOpProject" NonExternalProjectTarget
DOWNLOAD_COMMAND ""
+ DOWNLOAD_NO_PROGRESS 1
INSTALL_COMMAND ""
PATCH_COMMAND ""
STEP_TARGETS install update
diff --git a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
index b6f848a..ea59a8e 100644
--- a/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
+++ b/Tests/ExternalProjectUpdate/ExternalProjectUpdateTest.cmake
@@ -12,7 +12,7 @@ macro(check_a_tag desired_tag resulting_sha fetch_expected)
# Configure
execute_process(COMMAND ${CMAKE_COMMAND}
- -G ${CMAKE_TEST_GENERATOR} -T "${CMAKE_TEST_GENERATOR_TOOLSET}"
+ -G ${CMAKE_GENERATOR} -T "${CMAKE_GENERATOR_TOOLSET}"
-DTEST_GIT_TAG:STRING=${desired_tag}
${ExternalProjectUpdate_SOURCE_DIR}
WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}
diff --git a/Tests/FindPackageModeMakefileTest/CMakeLists.txt b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
index 5d1b376..8e21c32 100644
--- a/Tests/FindPackageModeMakefileTest/CMakeLists.txt
+++ b/Tests/FindPackageModeMakefileTest/CMakeLists.txt
@@ -10,7 +10,7 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Makefile")
ERROR_QUIET
TIMEOUT 10)
string(TOUPPER "${makeVersionOutput}" MAKE_VERSION_OUTPUT)
- if("${MAKE_VERSION_OUTPUT}" MATCHES ".*GNU MAKE.*")
+ if("${MAKE_VERSION_OUTPUT}" MATCHES "GNU MAKE")
# build a library which we can search during the test
add_library(foo STATIC foo.cpp)
diff --git a/Tests/FindPackageTest/FindLotsOfComponents.cmake b/Tests/FindPackageTest/FindLotsOfComponents.cmake
index 9076d86..5d959c5 100644
--- a/Tests/FindPackageTest/FindLotsOfComponents.cmake
+++ b/Tests/FindPackageTest/FindLotsOfComponents.cmake
@@ -4,7 +4,7 @@ set(LotsOfComponents_AComp_FOUND TRUE)
set(LotsOfComponents_BComp_FOUND FALSE)
set(LotsOfComponents_CComp_FOUND TRUE)
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(LotsOfComponents REQUIRED_VARS LOC_FOO
HANDLE_COMPONENTS)
diff --git a/Tests/FindPackageTest/FindSomePackage.cmake b/Tests/FindPackageTest/FindSomePackage.cmake
index 83d1d0e..7283d24 100644
--- a/Tests/FindPackageTest/FindSomePackage.cmake
+++ b/Tests/FindPackageTest/FindSomePackage.cmake
@@ -1,6 +1,6 @@
set(SOP_FOO TRUE)
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(SomePackage REQUIRED_VARS SOP_FOO
FOUND_VAR SomePackage_FOUND )
diff --git a/Tests/FindPackageTest/FindUpperCasePackage.cmake b/Tests/FindPackageTest/FindUpperCasePackage.cmake
index 66c2fea..425d417 100644
--- a/Tests/FindPackageTest/FindUpperCasePackage.cmake
+++ b/Tests/FindPackageTest/FindUpperCasePackage.cmake
@@ -1,6 +1,6 @@
set(UCP_FOO TRUE)
-include(FindPackageHandleStandardArgs)
+include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(UpperCasePackage REQUIRED_VARS UCP_FOO
FOUND_VAR UPPERCASEPACKAGE_FOUND )
diff --git a/Tests/Fortran/CMakeLists.txt b/Tests/Fortran/CMakeLists.txt
index adc4308..bf6d629 100644
--- a/Tests/Fortran/CMakeLists.txt
+++ b/Tests/Fortran/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.6)
project(testf C CXX Fortran)
-if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
endif()
message("CTEST_FULL_OUTPUT ")
@@ -208,7 +208,7 @@ if(TEST_MODULE_DEPENDS)
-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}
-DCMAKE_Fortran_FLAGS_MINSIZEREL:STRING=${CMAKE_Fortran_FLAGS_MINSIZEREL}
-DCMAKE_Fortran_FLAGS_RELWITHDEBINFO:STRING=${CMAKE_Fortran_FLAGS_RELWITHDEBINFO}
- -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMAKE_TEST_MAKEPROGRAM}
+ -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_NESTED_MAKE_PROGRAM}
${External_BUILD_TYPE}
VERBATIM
)
diff --git a/Tests/FortranC/Flags.cmake.in b/Tests/FortranC/Flags.cmake.in
index 3436309..28c38e4 100644
--- a/Tests/FortranC/Flags.cmake.in
+++ b/Tests/FortranC/Flags.cmake.in
@@ -14,8 +14,8 @@ set(COMMAND)
execute_process(
WORKING_DIRECTORY "${bld}"
- COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_TEST_GENERATOR@"
- -T "@CMAKE_TEST_GENERATOR_TOOLSET@"
+ COMMAND ${CMAKE_COMMAND} "${src}" -G "@CMAKE_GENERATOR@"
+ -T "@CMAKE_GENERATOR_TOOLSET@"
"-DFortranC_TEST_FLAGS=1"
"-DCMAKE_C_COMPILER=${bld}/cc.sh"
"-DCMAKE_C_FLAGS:STRING=@CMAKE_C_FLAGS@"
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index a0e34ef..758165c 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -166,7 +166,7 @@ add_library(imported4 SHARED IMPORTED)
set_property(TARGET imported4 APPEND PROPERTY
INCLUDE_DIRECTORIES $<TARGET_PROPERTY:imported3,INTERFACE_INCLUDE_DIRECTORIES>)
-add_executable(someexe empty.cpp)
+add_executable(someexe $<1:empty.cpp> $<0:does_not_exist>)
add_executable(Alias::SomeExe ALIAS someexe)
add_library(Alias::SomeLib ALIAS empty1)
diff --git a/Tests/MacRuntimePath/CMakeLists.txt b/Tests/MacRuntimePath/CMakeLists.txt
index 5c7b921..eeb3653 100644
--- a/Tests/MacRuntimePath/CMakeLists.txt
+++ b/Tests/MacRuntimePath/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required (VERSION 2.8)
project(MacRuntimePath)
-if(NOT DEFINED CMAKE_TEST_MAKEPROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
- set(CMAKE_TEST_MAKEPROGRAM "${CMAKE_MAKE_PROGRAM}")
+if(NOT DEFINED CMake_TEST_NESTED_MAKE_PROGRAM AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(CMake_TEST_NESTED_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM}")
endif()
# Wipe out the install tree to make sure the exporter works.
diff --git a/Tests/MacRuntimePath/InitialCache.cmake.in b/Tests/MacRuntimePath/InitialCache.cmake.in
index 3dc9041..a9f6a3c 100644
--- a/Tests/MacRuntimePath/InitialCache.cmake.in
+++ b/Tests/MacRuntimePath/InitialCache.cmake.in
@@ -1,4 +1,4 @@
-set(CMAKE_MAKE_PROGRAM "@CMAKE_TEST_MAKEPROGRAM@" CACHE FILEPATH "Make Program")
+set(CMAKE_MAKE_PROGRAM "@CMake_TEST_NESTED_MAKE_PROGRAM@" CACHE FILEPATH "Make Program")
set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@" CACHE STRING "C Compiler")
set(CMAKE_C_FLAGS "@CMAKE_C_FLAGS@" CACHE STRING "C Flags")
set(CMAKE_C_FLAGS_DEBUG "@CMAKE_C_FLAGS_DEBUG@" CACHE STRING "C Flags")
diff --git a/Tests/Module/ExternalData/CMakeLists.txt b/Tests/Module/ExternalData/CMakeLists.txt
index 5a6f3d5..ebca48e 100644
--- a/Tests/Module/ExternalData/CMakeLists.txt
+++ b/Tests/Module/ExternalData/CMakeLists.txt
@@ -23,6 +23,8 @@ ExternalData_Add_Test(Data1
COMMAND ${CMAKE_COMMAND}
-D Data=DATA{Data.dat}
${Data1CheckSpaces}
+ -D DataMissing=DATA{DataMissing.dat}
+ -D DataMissingWithAssociated=DATA{DataMissing.dat,Data.dat}
-D SeriesA=DATA{SeriesA.dat,:}
-D SeriesB=DATA{SeriesB.dat,:}
-D SeriesC=DATA{SeriesC.dat,:}
diff --git a/Tests/Module/ExternalData/Data1Check.cmake b/Tests/Module/ExternalData/Data1Check.cmake
index 5770245..485b5c6 100644
--- a/Tests/Module/ExternalData/Data1Check.cmake
+++ b/Tests/Module/ExternalData/Data1Check.cmake
@@ -8,6 +8,28 @@ if(DEFINED DataSpace)
message(SEND_ERROR "Input file:\n ${DataSpace}\ndoes not have expected content, but [[${lines}]]")
endif()
endif()
+if(DataMissing)
+ if(EXISTS "${DataMissing}")
+ message(SEND_ERROR
+ "Input file:\n"
+ " ${DataMissing}\n"
+ "exists but should not."
+ )
+ endif()
+else()
+ message(SEND_ERROR "DataMissing is not set!")
+endif()
+if(DataMissingWithAssociated)
+ if(EXISTS "${DataMissingWithAssociated}")
+ message(SEND_ERROR
+ "Input file:\n"
+ " ${DataMissingWithAssociated}\n"
+ "exists but should not."
+ )
+ endif()
+else()
+ message(SEND_ERROR "DataMissingWithAssociated is not set!")
+endif()
set(SeriesAn1 "1\\.dat")
set(SeriesBn1 "_1\\.dat")
set(SeriesCn1 "\\.1\\.dat")
diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt
new file mode 100644
index 0000000..dcb998a
--- /dev/null
+++ b/Tests/Module/FindDependency/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+cmake_minimum_required(VERSION 3.0)
+project(FindDependency)
+
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages")
+
+find_package(Pack1 REQUIRED)
+find_package(Pack4 4.3 EXACT REQUIRED)
+
+add_executable(FindDependency main.cpp)
+target_link_libraries(FindDependency Pack1::Lib Pack4::Lib)
diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp
new file mode 100644
index 0000000..50c5958
--- /dev/null
+++ b/Tests/Module/FindDependency/main.cpp
@@ -0,0 +1,29 @@
+
+#ifndef HAVE_PACK1
+#error Expected HAVE_PACK1
+#endif
+
+#ifndef HAVE_PACK2
+#error Expected HAVE_PACK2
+#endif
+
+#ifndef HAVE_PACK3
+#error Expected HAVE_PACK3
+#endif
+
+#ifndef HAVE_PACK4
+#error Expected HAVE_PACK4
+#endif
+
+#ifndef HAVE_PACK5
+#error Expected HAVE_PACK5
+#endif
+
+#ifndef HAVE_PACK6
+#error Expected HAVE_PACK6
+#endif
+
+int main(int argc, char** argv)
+{
+ return 0;
+}
diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake
new file mode 100644
index 0000000..ff533c2
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack1/Pack1Config.cmake
@@ -0,0 +1,9 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack2 2.3)
+find_dependency(Pack3)
+
+add_library(Pack1::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack1::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK1)
+set_property(TARGET Pack1::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack2::Lib Pack3::Lib)
diff --git a/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake
new file mode 100644
index 0000000..dfb7b6c
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack1/Pack1ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "1.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake
new file mode 100644
index 0000000..672288e
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack2/Pack2Config.cmake
@@ -0,0 +1,5 @@
+
+set(PACK2_VAR ON)
+
+add_library(Pack2::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack2::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK2)
diff --git a/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake
new file mode 100644
index 0000000..42f58c0
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack2/Pack2ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "2.4")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake
new file mode 100644
index 0000000..25c32f3
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack3/Pack3Config.cmake
@@ -0,0 +1,5 @@
+
+set(PACK3_VAR ON)
+
+add_library(Pack3::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack3::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK3)
diff --git a/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake
new file mode 100644
index 0000000..870f747
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack3/Pack3ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "1.4")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake
new file mode 100644
index 0000000..62fddb1
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack4/Pack4Config.cmake
@@ -0,0 +1,9 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack5 3.1) # Actual version is 3.3. EXACT not propagated.
+find_dependency(Pack6 5.5 EXACT)
+
+add_library(Pack4::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack4::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK4)
+set_property(TARGET Pack4::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack5::Lib Pack6::Lib)
diff --git a/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake
new file mode 100644
index 0000000..ae982b0
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack4/Pack4ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "4.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake
new file mode 100644
index 0000000..1edda9a
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack5/Pack5Config.cmake
@@ -0,0 +1,3 @@
+
+add_library(Pack5::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack5::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK5)
diff --git a/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake
new file mode 100644
index 0000000..e944f96
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack5/Pack5ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "3.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake
new file mode 100644
index 0000000..d6c85fb
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack6/Pack6Config.cmake
@@ -0,0 +1,3 @@
+
+add_library(Pack6::Lib INTERFACE IMPORTED)
+set_property(TARGET Pack6::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK6)
diff --git a/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake
new file mode 100644
index 0000000..0dd00d2
--- /dev/null
+++ b/Tests/Module/FindDependency/packages/Pack6/Pack6ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "5.5")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/PDBDirectoryAndName/CMakeLists.txt b/Tests/PDBDirectoryAndName/CMakeLists.txt
index 28e46b1..90af600 100644
--- a/Tests/PDBDirectoryAndName/CMakeLists.txt
+++ b/Tests/PDBDirectoryAndName/CMakeLists.txt
@@ -6,6 +6,13 @@ if(NOT MSVC AND NOT "${CMAKE_C_COMPILER_ID}" MATCHES "^(Intel)$")
message(FATAL_ERROR "The PDBDirectoryAndName test works only with MSVC or Intel")
endif()
+# Intel 11.1 does not support /Fd but Intel 14.0 does.
+# TODO: Did a version in between these add it?
+if(CMAKE_C_COMPILER_ID STREQUAL Intel AND
+ CMAKE_C_COMPILER_VERSION VERSION_LESS 14.0)
+ set(NO_COMPILE_PDB 1)
+endif()
+
set(my_targets "")
add_library(mylibA SHARED mylibA.c)
@@ -17,12 +24,12 @@ list(APPEND my_targets mylibA)
add_library(mylibB STATIC mylibB.c)
set_target_properties(mylibB PROPERTIES
- PDB_NAME "mylibB_Special"
- PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB"
+ COMPILE_PDB_NAME "mylibB_Special"
+ COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/mylibB_PDB"
)
-# TODO: The only .pdb available for a static library is that generated
-# by the compiler /Fd option which is not the same as the linker /pdb.
-# list(APPEND my_targets mylibB)
+if(NOT NO_COMPILE_PDB)
+ list(APPEND my_targets mylibB)
+endif()
add_library(mylibC SHARED mylibC.c)
set_target_properties(mylibC PROPERTIES
@@ -32,10 +39,11 @@ list(APPEND my_targets mylibC)
add_library(mylibD STATIC mylibD.c)
set_target_properties(mylibD PROPERTIES
- PDB_NAME "mylibD_Special"
+ COMPILE_PDB_NAME "mylibD_Special"
)
-# TODO: See comment for mylibB.
-# list(APPEND my_targets mylibD)
+if(NOT NO_COMPILE_PDB)
+ list(APPEND my_targets mylibD)
+endif()
add_executable(myexe myexe.c)
set_target_properties(myexe PROPERTIES
@@ -66,6 +74,12 @@ set(pdbs "")
foreach(t ${my_targets})
get_property(pdb_name TARGET ${t} PROPERTY PDB_NAME)
get_property(pdb_dir TARGET ${t} PROPERTY PDB_OUTPUT_DIRECTORY)
+ if(NOT pdb_name)
+ get_property(pdb_name TARGET ${t} PROPERTY COMPILE_PDB_NAME)
+ endif()
+ if(NOT pdb_dir)
+ get_property(pdb_dir TARGET ${t} PROPERTY COMPILE_PDB_OUTPUT_DIRECTORY)
+ endif()
if(NOT pdb_dir)
set(pdb_dir ${CMAKE_CURRENT_BINARY_DIR})
endif()
diff --git a/Tests/PerConfig/perconfig.cmake b/Tests/PerConfig/perconfig.cmake
index 6a710ca..0731041 100644
--- a/Tests/PerConfig/perconfig.cmake
+++ b/Tests/PerConfig/perconfig.cmake
@@ -30,7 +30,7 @@ endif()
# Verify that the implementation files are named correctly.
foreach(lib pcStatic pcShared)
file(STRINGS "${${lib}_file}" info LIMIT_COUNT 1 REGEX "INFO:[^[]*\\[")
- if(NOT "${info}" MATCHES ".*INFO:symbol\\[${lib}\\].*")
+ if(NOT "${info}" MATCHES "INFO:symbol\\[${lib}\\]")
message(SEND_ERROR "No INFO:symbol[${lib}] found in:\n ${${lib}_file}")
endif()
endforeach()
diff --git a/Tests/Properties/CMakeLists.txt b/Tests/Properties/CMakeLists.txt
index 285d596..11fca45 100644
--- a/Tests/Properties/CMakeLists.txt
+++ b/Tests/Properties/CMakeLists.txt
@@ -143,3 +143,5 @@ set_property(CACHE SOME_ENTRY PROPERTY VALUE "${expect_VALUE}")
set_property(CACHE SOME_ENTRY PROPERTY ADVANCED "${expect_ADVANCED}")
set_property(CACHE SOME_ENTRY PROPERTY STRINGS "${expect_STRINGS}")
check_cache_props()
+
+add_subdirectory(SubDir2)
diff --git a/Tests/Properties/SubDir2/CMakeLists.txt b/Tests/Properties/SubDir2/CMakeLists.txt
new file mode 100644
index 0000000..377dc83
--- /dev/null
+++ b/Tests/Properties/SubDir2/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx"
+ PROPERTIES COMPILE_DEFINITIONS SUBDIR_TEST)
+
+add_executable(subdirtest "${CMAKE_CURRENT_SOURCE_DIR}/../subdirtest.cxx")
diff --git a/Tests/Properties/subdirtest.cxx b/Tests/Properties/subdirtest.cxx
new file mode 100644
index 0000000..02d8f3d
--- /dev/null
+++ b/Tests/Properties/subdirtest.cxx
@@ -0,0 +1,9 @@
+
+#ifndef SUBDIR_TEST
+#error Expected SUBDIR_TEST
+#endif
+
+int main(int, char**)
+{
+ return 0;
+}
diff --git a/Tests/Qt4Targets/CMakeLists.txt b/Tests/Qt4Targets/CMakeLists.txt
index af9fc3f..7430084 100644
--- a/Tests/Qt4Targets/CMakeLists.txt
+++ b/Tests/Qt4Targets/CMakeLists.txt
@@ -36,3 +36,30 @@ add_executable(Qt4WrapMacroTest WIN32 main_wrap_test.cpp ${moc_file})
set_property(TARGET Qt4WrapMacroTest PROPERTY AUTOMOC OFF)
target_include_directories(Qt4WrapMacroTest PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/interface")
target_link_libraries(Qt4WrapMacroTest Qt4::QtGui)
+
+set(timeformat "%Y%j%H%M%S")
+try_compile(RESULT
+ "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild"
+ "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
+ IncrementalMoc
+ CMAKE_FLAGS -DADD_DEF=0 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}")
+file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_before "${timeformat}")
+if (NOT tsvar_before)
+ message(SEND_ERROR "Unable to read timestamp from moc file from first build!")
+endif()
+
+execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep 2) # Ensure that the timestamp will change.
+
+try_compile(RESULT
+ "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild"
+ "${CMAKE_CURRENT_SOURCE_DIR}/IncrementalMoc"
+ IncrementalMoc
+ CMAKE_FLAGS -DADD_DEF=1 "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}")
+file(TIMESTAMP "${CMAKE_CURRENT_BINARY_DIR}/IncrementalMocBuild/moc_foo.cpp" tsvar_after "${timeformat}")
+if (NOT tsvar_after)
+ message(SEND_ERROR "Unable to read timestamp from moc file from second build!")
+endif()
+
+if (NOT tsvar_after GREATER tsvar_before)
+ message(SEND_ERROR "Rebuild did not re-create moc file. Before: ${tsvar_before}. After: ${tsvar_after}")
+endif()
diff --git a/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
new file mode 100644
index 0000000..4ba0ced
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/CMakeLists.txt
@@ -0,0 +1,13 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(IncrementalMoc)
+
+find_package(Qt4 REQUIRED)
+
+qt4_generate_moc(foo.h moc_foo.cpp)
+
+add_library(testlib foo.cpp moc_foo.cpp)
+target_link_libraries(testlib Qt4::QtCore)
+if (ADD_DEF)
+ target_compile_definitions(testlib PRIVATE NEW_DEF)
+endif()
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.cpp b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
new file mode 100644
index 0000000..e924f7e
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.cpp
@@ -0,0 +1,8 @@
+
+#include "foo.h"
+
+Foo::Foo()
+ : QObject(0)
+{
+
+}
diff --git a/Tests/Qt4Targets/IncrementalMoc/foo.h b/Tests/Qt4Targets/IncrementalMoc/foo.h
new file mode 100644
index 0000000..38d899f
--- /dev/null
+++ b/Tests/Qt4Targets/IncrementalMoc/foo.h
@@ -0,0 +1,9 @@
+
+#include <QObject>
+
+class Foo : QObject
+{
+ Q_OBJECT
+public:
+ Foo();
+};
diff --git a/Tests/QtAutogen/CMakeLists.txt b/Tests/QtAutogen/CMakeLists.txt
index 0821b45..3973653 100644
--- a/Tests/QtAutogen/CMakeLists.txt
+++ b/Tests/QtAutogen/CMakeLists.txt
@@ -64,9 +64,15 @@ add_custom_command(
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/myotherinterface.h.in"
)
-add_executable(QtAutogen main.cpp calwidget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
+message("CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE}")
+if (CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]" AND NOT CMAKE_CONFIGURATION_TYPES)
+ set(debug_srcs "$<$<CONFIG:Debug>:debug_class.cpp>" $<$<CONFIG:Debug>:debug_resource.qrc>)
+ add_definitions(-DTEST_DEBUG_CLASS)
+endif()
+
+add_executable(QtAutogen main.cpp calwidget.cpp second_widget.cpp foo.cpp blub.cpp bar.cpp abc.cpp
xyz.cpp yaf.cpp gadget.cpp $<TARGET_OBJECTS:privateSlot>
- test.qrc resourcetester.cpp generated.cpp
+ test.qrc second_resource.qrc resourcetester.cpp generated.cpp ${debug_srcs}
)
set_property(TARGET QtAutogen APPEND PROPERTY AUTOGEN_TARGET_DEPENDS generate_moc_input "${CMAKE_CURRENT_BINARY_DIR}/myotherinterface.h")
diff --git a/Tests/QtAutogen/debug_class.cpp b/Tests/QtAutogen/debug_class.cpp
new file mode 100644
index 0000000..58e72e4
--- /dev/null
+++ b/Tests/QtAutogen/debug_class.cpp
@@ -0,0 +1,9 @@
+
+#include "debug_class.h"
+#include "ui_debug_class.h"
+
+DebugClass::DebugClass(QWidget *parent)
+ : QWidget(parent), ui(new Ui::DebugClass)
+{
+ ui->setupUi(this);
+}
diff --git a/Tests/QtAutogen/debug_class.h b/Tests/QtAutogen/debug_class.h
new file mode 100644
index 0000000..71bc104
--- /dev/null
+++ b/Tests/QtAutogen/debug_class.h
@@ -0,0 +1,20 @@
+
+#include <QWidget>
+
+namespace Ui
+{
+class DebugClass;
+}
+
+class DebugClass : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit DebugClass(QWidget *parent = 0);
+
+signals:
+ void someSignal();
+
+private:
+ Ui::DebugClass *ui;
+};
diff --git a/Tests/QtAutogen/debug_class.ui b/Tests/QtAutogen/debug_class.ui
new file mode 100644
index 0000000..dc2e1ac
--- /dev/null
+++ b/Tests/QtAutogen/debug_class.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DebugClass</class>
+ <widget class="QWidget" name="DebugClass">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>DebugClass</string>
+ </property>
+ <widget class="QCheckBox" name="checkBox">
+ <property name="geometry">
+ <rect>
+ <x>50</x>
+ <y>20</y>
+ <width>82</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>CheckBox</string>
+ </property>
+ </widget>
+ <widget class="QPushButton" name="pushButton">
+ <property name="geometry">
+ <rect>
+ <x>40</x>
+ <y>70</y>
+ <width>94</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/QtAutogen/debug_resource.qrc b/Tests/QtAutogen/debug_resource.qrc
new file mode 100644
index 0000000..db98b9b
--- /dev/null
+++ b/Tests/QtAutogen/debug_resource.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>debug_class.ui</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/main.cpp b/Tests/QtAutogen/main.cpp
index c8a036e..eb59665 100644
--- a/Tests/QtAutogen/main.cpp
+++ b/Tests/QtAutogen/main.cpp
@@ -51,6 +51,11 @@
#include "yaf.h"
#include "libC.h"
#include "resourcetester.h"
+#ifdef TEST_DEBUG_CLASS
+#include "debug_class.h"
+#include <iostream>
+#endif
+
int main(int argv, char **args)
{
@@ -81,5 +86,9 @@ int main(int argv, char **args)
QTimer::singleShot(0, &rt, SLOT(doTest()));
+#ifdef TEST_DEBUG_CLASS
+ std::cout << DebugClass::staticMetaObject.className() << std::endl;
+#endif
+
return app.exec();
}
diff --git a/Tests/QtAutogen/resourcetester.cpp b/Tests/QtAutogen/resourcetester.cpp
index 43314e1..043ec75 100644
--- a/Tests/QtAutogen/resourcetester.cpp
+++ b/Tests/QtAutogen/resourcetester.cpp
@@ -16,6 +16,12 @@ void ResourceTester::doTest()
{
if (!QFile::exists(":/CMakeLists.txt"))
qApp->exit(EXIT_FAILURE);
+ if (!QFile::exists(":/main.cpp"))
+ qApp->exit(EXIT_FAILURE);
+#ifdef TEST_DEBUG_CLASS
+ if (!QFile::exists(":/debug_class.ui"))
+ qApp->exit(EXIT_FAILURE);
+#endif
QTimer::singleShot(0, qApp, SLOT(quit()));
}
diff --git a/Tests/QtAutogen/second_resource.qrc b/Tests/QtAutogen/second_resource.qrc
new file mode 100644
index 0000000..27bfb14
--- /dev/null
+++ b/Tests/QtAutogen/second_resource.qrc
@@ -0,0 +1,5 @@
+<!DOCTYPE RCC><RCC version="1.0">
+<qresource>
+ <file>main.cpp</file>
+</qresource>
+</RCC>
diff --git a/Tests/QtAutogen/second_widget.cpp b/Tests/QtAutogen/second_widget.cpp
new file mode 100644
index 0000000..65ba962
--- /dev/null
+++ b/Tests/QtAutogen/second_widget.cpp
@@ -0,0 +1,14 @@
+
+#include "second_widget.h"
+#include "ui_second_widget.h"
+
+SecondWidget::SecondWidget(QWidget *parent)
+ : QWidget(parent), ui(new Ui::SecondWidget)
+{
+ ui->setupUi(this);
+}
+
+SecondWidget::~SecondWidget()
+{
+ delete ui;
+}
diff --git a/Tests/QtAutogen/second_widget.h b/Tests/QtAutogen/second_widget.h
new file mode 100644
index 0000000..fe4d175
--- /dev/null
+++ b/Tests/QtAutogen/second_widget.h
@@ -0,0 +1,19 @@
+
+#include <QWidget>
+
+namespace Ui
+{
+class SecondWidget;
+}
+
+class SecondWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ explicit SecondWidget(QWidget *parent = 0);
+
+ ~SecondWidget();
+
+private:
+ Ui::SecondWidget* ui;
+};
diff --git a/Tests/QtAutogen/second_widget.ui b/Tests/QtAutogen/second_widget.ui
new file mode 100644
index 0000000..4effa58
--- /dev/null
+++ b/Tests/QtAutogen/second_widget.ui
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SecondWidget</class>
+ <widget class="QWidget" name="SecondWidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <widget class="QPushButton" name="pushButton">
+ <property name="geometry">
+ <rect>
+ <x>80</x>
+ <y>20</y>
+ <width>94</width>
+ <height>24</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>PushButton</string>
+ </property>
+ </widget>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/Tests/RunCMake/set/PARENT_SCOPE-result.txt b/Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt
index 573541a..573541a 100644
--- a/Tests/RunCMake/set/PARENT_SCOPE-result.txt
+++ b/Tests/RunCMake/CMP0051/CMP0051-NEW-result.txt
diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt
new file mode 100644
index 0000000..e5578ba
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-NEW-stderr.txt
@@ -0,0 +1 @@
+^Sources: "empty.cpp;\$<TARGET_OBJECTS:objects>"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake
new file mode 100644
index 0000000..f304bf1
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-NEW.cmake
@@ -0,0 +1,10 @@
+
+cmake_policy(SET CMP0051 NEW)
+
+add_library(objects OBJECT empty.cpp)
+
+add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
+
+get_target_property(srcs empty SOURCES)
+
+message("Sources: \"${srcs}\"")
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
new file mode 100644
index 0000000..cc17f33
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-OLD-stderr.txt
@@ -0,0 +1 @@
+^Sources: "empty.cpp"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake
new file mode 100644
index 0000000..0243e94
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-OLD.cmake
@@ -0,0 +1,10 @@
+
+cmake_policy(SET CMP0051 OLD)
+
+add_library(objects OBJECT empty.cpp)
+
+add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
+
+get_target_property(srcs empty SOURCES)
+
+message("Sources: \"${srcs}\"")
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
new file mode 100644
index 0000000..f1b0357
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN-stderr.txt
@@ -0,0 +1,15 @@
+CMake Warning \(dev\) at CMP0051-WARN.cmake:6 \(get_target_property\):
+ Policy CMP0051 is not set: List TARGET_OBJECTS in SOURCES target property.
+ Run "cmake --help-policy CMP0051" for policy details. Use the cmake_policy
+ command to set the policy and suppress this warning.
+
+ Target "empty" contains \$<TARGET_OBJECTS> generator expression in its
+ sources list. This content was not previously part of the SOURCES property
+ when that property was read at configure time. Code reading that property
+ needs to be adapted to ignore the generator expression using the
+ string\(GENEX_STRIP\) command.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+Sources: "empty.cpp"$
diff --git a/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake
new file mode 100644
index 0000000..fd595ce
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMP0051-WARN.cmake
@@ -0,0 +1,8 @@
+
+add_library(objects OBJECT empty.cpp)
+
+add_library(empty empty.cpp $<TARGET_OBJECTS:objects>)
+
+get_target_property(srcs empty SOURCES)
+
+message("Sources: \"${srcs}\"")
diff --git a/Tests/RunCMake/CMP0051/CMakeLists.txt b/Tests/RunCMake/CMP0051/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0051/RunCMakeTest.cmake b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake
new file mode 100644
index 0000000..621192d
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0051-OLD)
+run_cmake(CMP0051-NEW)
+run_cmake(CMP0051-WARN)
diff --git a/Tests/RunCMake/CMP0051/empty.cpp b/Tests/RunCMake/CMP0051/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CMP0051/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 9bb097b..e797a73 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -3,8 +3,8 @@
macro(add_RunCMake_test test)
add_test(RunCMake.${test} ${CMAKE_CMAKE_COMMAND}
-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_SOURCE_DIR}
- -DRunCMake_GENERATOR=${CMAKE_TEST_GENERATOR}
- -DRunCMake_GENERATOR_TOOLSET=${CMAKE_TEST_GENERATOR_TOOLSET}
+ -DRunCMake_GENERATOR=${CMAKE_GENERATOR}
+ -DRunCMake_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET}
-DRunCMake_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${test}
-DRunCMake_BINARY_DIR=${CMAKE_CURRENT_BINARY_DIR}/${test}
${${test}_ARGS}
@@ -34,20 +34,26 @@ add_RunCMake_test(CMP0045)
add_RunCMake_test(CMP0046)
add_RunCMake_test(CMP0049)
add_RunCMake_test(CMP0050)
+add_RunCMake_test(CMP0051)
add_RunCMake_test(CTest)
-if(UNIX AND "${CMAKE_TEST_GENERATOR}" MATCHES "Unix Makefiles")
+if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles")
add_RunCMake_test(CompilerChange)
endif()
add_RunCMake_test(CompilerNotFound)
add_RunCMake_test(Configure)
add_RunCMake_test(DisallowedCommands)
add_RunCMake_test(ExternalData)
+add_RunCMake_test(FeatureSummary)
add_RunCMake_test(FPHSA)
add_RunCMake_test(GeneratorExpression)
add_RunCMake_test(GeneratorToolset)
add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
add_RunCMake_test(ObjectLibrary)
+add_RunCMake_test(TargetObjects)
+add_RunCMake_test(TargetSources)
+add_RunCMake_test(find_dependency)
+add_RunCMake_test(CompileFeatures)
if(NOT WIN32)
add_RunCMake_test(PositionIndependentCode)
set(SKIP_VISIBILITY 0)
@@ -94,6 +100,7 @@ add_RunCMake_test(TargetPolicies)
add_RunCMake_test(alias_targets)
add_RunCMake_test(interface_library)
add_RunCMake_test(no_install_prefix)
+add_RunCMake_test(configure_file)
find_package(Qt4 QUIET)
find_package(Qt5Core QUIET)
@@ -105,7 +112,12 @@ if (QT4_FOUND)
add_RunCMake_test(ObsoleteQtMacros)
endif()
-if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
+find_package(PkgConfig QUIET)
+if(PKG_CONFIG_FOUND)
+ add_RunCMake_test(FindPkgConfig)
+endif()
+
+if("${CMAKE_GENERATOR}" MATCHES "Visual Studio [^6]")
add_RunCMake_test(include_external_msproject)
add_RunCMake_test(SolutionGlobalSections)
endif()
@@ -113,6 +125,8 @@ endif()
add_RunCMake_test(File_Generate)
add_RunCMake_test(ExportWithoutLanguage)
add_RunCMake_test(target_link_libraries)
+
+add_RunCMake_test(target_compile_features)
add_RunCMake_test(CheckModules)
add_RunCMake_test(CommandLine)
diff --git a/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake
new file mode 100644
index 0000000..b2dcd7f
--- /dev/null
+++ b/Tests/RunCMake/CheckModules/CheckTypeSizeOkNoC.cmake
@@ -0,0 +1,4 @@
+enable_language(CXX)
+include(CheckTypeSize)
+check_type_size(int SIZEOF_INT LANGUAGE CXX)
+check_type_size(int SIZEOF_INT BUILTIN_TYPES_ONLY LANGUAGE CXX)
diff --git a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
index fda7ebf..5b4e57e 100644
--- a/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckModules/RunCMakeTest.cmake
@@ -12,3 +12,5 @@ run_cmake(CheckTypeSizeUnknownLanguage)
run_cmake(CheckTypeSizeMissingLanguage)
run_cmake(CheckTypeSizeUnknownArgument)
run_cmake(CheckTypeSizeMixedArgs)
+
+run_cmake(CheckTypeSizeOkNoC)
diff --git a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
index 17b8a5c..82a34d5 100644
--- a/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
+++ b/Tests/RunCMake/CompatibleInterface/DebugProperties-stderr.txt
@@ -1,4 +1,11 @@
CMake Debug Log:
+ Boolean compatibility of property "BOOL_PROP7" for target
+ "CompatibleInterface" \(result: "FALSE"\):
+
+ \* Target "CompatibleInterface" property is implied by use.
+ \* Target "iface1" property value "FALSE" \(Agree\)
++
+CMake Debug Log:
Boolean compatibility of property "BOOL_PROP1" for target
"CompatibleInterface" \(result: "TRUE"\):
@@ -40,13 +47,6 @@ CMake Debug Log:
\* Target "iface2" property value "FALSE" \(Agree\)
+
CMake Debug Log:
- Boolean compatibility of property "BOOL_PROP7" for target
- "CompatibleInterface" \(result: "FALSE"\):
-
- \* Target "CompatibleInterface" property is implied by use.
- \* Target "iface1" property value "FALSE" \(Agree\)
-+
-CMake Debug Log:
String compatibility of property "STRING_PROP1" for target
"CompatibleInterface" \(result: "prop1"\):
diff --git a/Tests/RunCMake/CompileFeatures/CMakeLists.txt b/Tests/RunCMake/CompileFeatures/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/ExternalData/MissingData-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/ExternalData/MissingData-result.txt
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt
new file mode 100644
index 0000000..8b029ac
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at NoSupportedCxxFeatures.cmake:3 \(target_compile_features\):
+ target_compile_features no known features for compiler
+
+ "[^"]*"
+
+ version *[.0-9]+\.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake
new file mode 100644
index 0000000..5121948
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeatures.cmake
@@ -0,0 +1,3 @@
+
+add_library(no_features empty.cpp)
+target_compile_features(no_features PRIVATE cxx_constexpr)
diff --git a/Tests/RunCMake/ExternalData/Directory3-result.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/ExternalData/Directory3-result.txt
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-result.txt
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt
new file mode 100644
index 0000000..d8366b2
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+ No known features for compiler
+
+ "[^"]*"
+
+ version *[.0-9]+\.
diff --git a/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake
new file mode 100644
index 0000000..490f187
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NoSupportedCxxFeaturesGenex.cmake
@@ -0,0 +1,3 @@
+
+add_library(no_features empty.cpp)
+target_compile_features(no_features PRIVATE $<1:cxx_constexpr>)
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake
new file mode 100644
index 0000000..35246c8
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature.cmake
@@ -0,0 +1,3 @@
+
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature")
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake
new file mode 100644
index 0000000..ad2bd37
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureGenex.cmake
@@ -0,0 +1,3 @@
+
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "$<1:not_a_feature>")
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt
new file mode 100644
index 0000000..ff60e50
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake
new file mode 100644
index 0000000..7311aec
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeatureTransitive.cmake
@@ -0,0 +1,6 @@
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_COMPILE_FEATURES "not_a_feature")
+
+add_library(somelib STATIC empty.cpp)
+target_link_libraries(somelib iface)
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt
new file mode 100644
index 0000000..60a8e51
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug-stderr.txt
@@ -0,0 +1,11 @@
+CMake Debug Log at NotAFeature_OriginDebug.cmake:4 \(set_property\):
+ Used compile features for target somelib:
+
+ \* not_a_feature
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake
new file mode 100644
index 0000000..350c2ea
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "not_a_feature")
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt
new file mode 100644
index 0000000..08e20a8
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex-stderr.txt
@@ -0,0 +1,11 @@
+CMake Debug Log at NotAFeature_OriginDebugGenex.cmake:4 \(set_property\):
+ Used compile features for target somelib:
+
+ \* not_a_feature
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake
new file mode 100644
index 0000000..2122981
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugGenex.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(somelib STATIC empty.cpp)
+set_property(TARGET somelib PROPERTY COMPILE_FEATURES "$<1:not_a_feature>")
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt
new file mode 100644
index 0000000..23c3305
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive-stderr.txt
@@ -0,0 +1,11 @@
+CMake Debug Log at NotAFeature_OriginDebugTransitive.cmake:6 \(target_link_libraries\):
+ Used compile features for target somelib:
+
+ \* not_a_feature
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
+
+
+CMake Error in CMakeLists.txt:
+ Specified unknown feature "not_a_feature" for target "somelib".
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake
new file mode 100644
index 0000000..05d0073
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebugTransitive.cmake
@@ -0,0 +1,6 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_COMPILE_FEATURES "not_a_feature")
+add_library(somelib STATIC empty.cpp)
+target_link_libraries(somelib iface)
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt
new file mode 100644
index 0000000..d819d15
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at NotAFeature_OriginDebug_target_compile_features.cmake:4 \(target_compile_features\):
+ target_compile_features specified unknown feature "not_a_feature" for
+ target "somelib".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake
new file mode 100644
index 0000000..467d9a1
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/NotAFeature_OriginDebug_target_compile_features.cmake
@@ -0,0 +1,4 @@
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES COMPILE_FEATURES)
+add_library(somelib STATIC empty.cpp)
+target_compile_features(somelib PRIVATE not_a_feature)
diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
new file mode 100644
index 0000000..43d4cb3
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake
@@ -0,0 +1,20 @@
+include(RunCMake)
+
+run_cmake(NotAFeature)
+run_cmake(NotAFeatureGenex)
+run_cmake(NotAFeatureTransitive)
+run_cmake(NotAFeature_OriginDebug)
+run_cmake(NotAFeature_OriginDebugGenex)
+run_cmake(NotAFeature_OriginDebugTransitive)
+run_cmake(NotAFeature_OriginDebug_target_compile_features)
+
+run_cmake(generate_feature_list)
+file(READ
+ "${RunCMake_BINARY_DIR}/generate_feature_list-build/features.txt"
+ FEATURES
+)
+
+if (NOT FEATURES)
+ run_cmake(NoSupportedCxxFeatures)
+ run_cmake(NoSupportedCxxFeaturesGenex)
+endif()
diff --git a/Tests/RunCMake/CompileFeatures/empty.cpp b/Tests/RunCMake/CompileFeatures/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
new file mode 100644
index 0000000..2bbbd17
--- /dev/null
+++ b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake
@@ -0,0 +1,4 @@
+
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/features.txt"
+ "${CMAKE_CXX_COMPILE_FEATURES}"
+)
diff --git a/Tests/RunCMake/ExternalData/Directory1-stderr.txt b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
index 85c250f..2bc3c60 100644
--- a/Tests/RunCMake/ExternalData/Directory1-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory1-stderr.txt
@@ -7,7 +7,7 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Directory1
- that does not exist as a file \(with or without an extension\)!
+ that is directory instead of a file!
Call Stack \(most recent call first\):
.*
Directory1.cmake:3 \(ExternalData_Add_Test\)
diff --git a/Tests/RunCMake/ExternalData/Directory3-stderr.txt b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
index 56a341e..ceed2a0 100644
--- a/Tests/RunCMake/ExternalData/Directory3-stderr.txt
+++ b/Tests/RunCMake/ExternalData/Directory3-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Data file referenced by argument
DATA{Directory3/\*}
@@ -12,3 +12,4 @@ Call Stack \(most recent call first\):
.*
Directory3.cmake:3 \(ExternalData_Add_Test\)
CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingData-stderr.txt b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
index e794f95..39ed2f1 100644
--- a/Tests/RunCMake/ExternalData/MissingData-stderr.txt
+++ b/Tests/RunCMake/ExternalData/MissingData-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
Data file referenced by argument
DATA{MissingData.txt}
@@ -10,5 +10,6 @@ CMake Error at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
that does not exist as a file \(with or without an extension\)!
Call Stack \(most recent call first\):
.*
- MissingData.cmake:2 \(ExternalData_Add_Test\)
+ MissingData.cmake:4 \(ExternalData_Expand_Arguments\)
CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingData-stdout.txt b/Tests/RunCMake/ExternalData/MissingData-stdout.txt
new file mode 100644
index 0000000..addd40e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingData-stdout.txt
@@ -0,0 +1 @@
+-- Missing data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/MissingData.cmake b/Tests/RunCMake/ExternalData/MissingData.cmake
index b3c8a5c..f5fefd5 100644
--- a/Tests/RunCMake/ExternalData/MissingData.cmake
+++ b/Tests/RunCMake/ExternalData/MissingData.cmake
@@ -1,5 +1,10 @@
include(ExternalData)
-ExternalData_Add_Test(Data
- NAME Test
- COMMAND ${CMAKE_COMMAND} -E echo DATA{MissingData.txt}
- )
+
+set(output "${CMAKE_SOURCE_DIR}/MissingData.txt")
+ExternalData_Expand_Arguments(Data args DATA{MissingData.txt})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Missing data reference correctly transformed!")
+else()
+ message(FATAL_ERROR "Missing data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
new file mode 100644
index 0000000..315af5e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stderr.txt
@@ -0,0 +1,15 @@
+CMake Warning \(dev\) at .*/Modules/ExternalData.cmake:[0-9]+ \(message\):
+ Data file referenced by argument
+
+ DATA{MissingData.txt,Data.txt}
+
+ corresponds to source tree path
+
+ MissingData.txt
+
+ that does not exist as a file \(with or without an extension\)!
+Call Stack \(most recent call first\):
+ .*
+ MissingDataWithAssociated.cmake:4 \(ExternalData_Expand_Arguments\)
+ CMakeLists.txt:3 \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt
new file mode 100644
index 0000000..addd40e
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated-stdout.txt
@@ -0,0 +1 @@
+-- Missing data reference correctly transformed!
diff --git a/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake b/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake
new file mode 100644
index 0000000..a4c4638
--- /dev/null
+++ b/Tests/RunCMake/ExternalData/MissingDataWithAssociated.cmake
@@ -0,0 +1,10 @@
+include(ExternalData)
+
+set(output "${CMAKE_BINARY_DIR}/MissingData.txt")
+ExternalData_Expand_Arguments(Data args DATA{MissingData.txt,Data.txt})
+if("x${args}" STREQUAL "x${output}")
+ message(STATUS "Missing data reference correctly transformed!")
+else()
+ message(FATAL_ERROR "Missing data reference transformed to:\n ${args}\n"
+ "but we expected:\n ${output}")
+endif()
diff --git a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
index 93ff08f..04e3d59 100644
--- a/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalData/RunCMakeTest.cmake
@@ -15,6 +15,7 @@ run_cmake(LinkContentMD5)
run_cmake(LinkContentSHA1)
run_cmake(LinkDirectory1)
run_cmake(MissingData)
+run_cmake(MissingDataWithAssociated)
run_cmake(NoLinkInSource)
run_cmake(NoURLTemplates)
run_cmake(NormalData1)
diff --git a/Tests/RunCMake/FeatureSummary/CMakeLists.txt b/Tests/RunCMake/FeatureSummary/CMakeLists.txt
new file mode 100644
index 0000000..72abfc8
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt
new file mode 100644
index 0000000..9a3f023
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll-stdout.txt
@@ -0,0 +1,7 @@
+-- The following features have been enabled:
+
+ \* Foo , Foo\.
+
+-- The following features have been disabled:
+
+ \* Bar , Bar\.
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake
new file mode 100644
index 0000000..ec5ebcb
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatAll.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ALL)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt
new file mode 100644
index 0000000..4d8f25f
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList-stdout.txt
@@ -0,0 +1,7 @@
+-- The following features have been disabled:
+
+ \* Bar , Bar\.
+
+-- The following features have been enabled:
+
+ \* Foo , Foo\.
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake
new file mode 100644
index 0000000..d04ba88
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatList.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT DISABLED_FEATURES ENABLED_FEATURES)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt
new file mode 100644
index 0000000..18d9ebd
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
+ The WHAT argument of FEATURE_SUMMARY\(\) contains ALL, which cannot be
+ combined with other values\.
+Call Stack \(most recent call first\):
+ FeatureSummaryWhatListAll\.cmake:[0-9]+ \(feature_summary\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake
new file mode 100644
index 0000000..1877ea5
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListAll.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ENABLED_FEATURES ALL)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt
new file mode 100644
index 0000000..3ad3750
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
+ The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid
+ value\.
+Call Stack \(most recent call first\):
+ FeatureSummaryWhatListUnknown\.cmake:[0-9]+ \(feature_summary\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake
new file mode 100644
index 0000000..46088d4
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatListUnknown.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ENABLED_FEATURES FOO)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt
new file mode 100644
index 0000000..240632d
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle-stdout.txt
@@ -0,0 +1 @@
+ \* Foo , Foo\.
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake
new file mode 100644
index 0000000..593dfb6
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingle.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT ENABLED_FEATURES)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt
new file mode 100644
index 0000000..c78853c
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*/Modules/FeatureSummary\.cmake:[0-9]+. \(message\):
+ The WHAT argument of FEATURE_SUMMARY\(\) contains FOO, which is not a valid
+ value\.
+Call Stack \(most recent call first\):
+ FeatureSummaryWhatSingleUnknown\.cmake:[0-9]+ \(feature_summary\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake
new file mode 100644
index 0000000..c2d6d2e
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/FeatureSummaryWhatSingleUnknown.cmake
@@ -0,0 +1,9 @@
+include(FeatureSummary)
+
+set(WITH_FOO 1)
+set(WITH_BAR 0)
+
+add_feature_info(Foo WITH_FOO "Foo.")
+add_feature_info(Bar WITH_BAR "Bar.")
+
+feature_summary(WHAT FOO)
diff --git a/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake
new file mode 100644
index 0000000..1417338
--- /dev/null
+++ b/Tests/RunCMake/FeatureSummary/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(FeatureSummaryWhatAll)
+run_cmake(FeatureSummaryWhatSingle)
+run_cmake(FeatureSummaryWhatSingleUnknown)
+run_cmake(FeatureSummaryWhatList)
+run_cmake(FeatureSummaryWhatListUnknown)
+run_cmake(FeatureSummaryWhatListAll)
diff --git a/Tests/RunCMake/FindPkgConfig/CMakeLists.txt b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt
new file mode 100644
index 0000000..72abfc8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.11)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake
new file mode 100644
index 0000000..924976e
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_NO_PKGCONFIG_PATH.cmake
@@ -0,0 +1,41 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH FALSE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+ set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+ set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+if(WIN32)
+ set(expected_path "C:\\baz")
+else()
+ set(expected_path "/baz")
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}")
+
+if(NOT "FOO_FOUND")
+ message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
+
+
+
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+
+pkg_check_modules(BAR "${expected_path}" NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH)
+
+if(NOT "BAR_FOUND")
+ message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
new file mode 100644
index 0000000..4a66e85
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH.cmake
@@ -0,0 +1,51 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+ set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+ set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+ OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+ AND NOT CMAKE_CROSSCOMPILING))
+ if(EXISTS "/etc/debian_version") # is this a debian system ?
+ if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+ # Cannot create directories for all the existing architectures...
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+ else()
+ # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+ get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+ if(uselib64)
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+ endif()
+else()
+ if(WIN32)
+ set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}")
+
+if(NOT "FOO_FOUND")
+ message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake
new file mode 100644
index 0000000..0b057b8
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH.cmake
@@ -0,0 +1,51 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+ set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+ set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+ OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+ AND NOT CMAKE_CROSSCOMPILING))
+ if(EXISTS "/etc/debian_version") # is this a debian system ?
+ if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+ # Cannot create directories for all the existing architectures...
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+ endif()
+ else()
+ # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+ get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+ if(uselib64)
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+ endif()
+ endif()
+else()
+ if(WIN32)
+ set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-foo\\lib\\pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-foo/lib/pkgconfig")
+ endif()
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}" NO_CMAKE_ENVIRONMENT_PATH)
+
+if(NOT "FOO_FOUND")
+ message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake
new file mode 100644
index 0000000..a3154f1
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH.cmake
@@ -0,0 +1,51 @@
+# Needed for CMAKE_SYSTEM_NAME, CMAKE_LIBRARY_ARCHITECTURE and FIND_LIBRARY_USE_LIB64_PATHS
+enable_language(C)
+
+# Prepare environment and variables
+set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-foo")
+if(WIN32)
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}\\dummy-pkg-config.bat")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar;X:\\this\\directory\\should\\not\\exist\\in\\the\\filesystem")
+ set(ENV{PKG_CONFIG_PATH} "C:\\baz")
+else()
+ set(PKG_CONFIG_EXECUTABLE "${CMAKE_CURRENT_SOURCE_DIR}/dummy-pkg-config.sh")
+ set(ENV{CMAKE_PREFIX_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/pc-bar:/this/directory/should/not/exist/in/the/filesystem")
+ set(ENV{PKG_CONFIG_PATH} "/baz")
+endif()
+
+
+find_package(PkgConfig)
+
+
+if(NOT DEFINED CMAKE_SYSTEM_NAME
+ OR (CMAKE_SYSTEM_NAME MATCHES "^(Linux|kFreeBSD|GNU)$"
+ AND NOT CMAKE_CROSSCOMPILING))
+ if(EXISTS "/etc/debian_version") # is this a debian system ?
+ if(CMAKE_LIBRARY_ARCHITECTURE MATCHES "^(i386-linux-gnu|x86_64-linux-gnu)$")
+ # Cannot create directories for all the existing architectures...
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/${CMAKE_LIBRARY_ARCHITECTURE}/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+ else()
+ # not debian, chech the FIND_LIBRARY_USE_LIB64_PATHS property
+ get_property(uselib64 GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS)
+ if(uselib64)
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib64/pkgconfig:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+ endif()
+else()
+ if(WIN32)
+ set(expected_path "C:\\baz;${CMAKE_CURRENT_SOURCE_DIR}\\pc-bar\\lib\\pkgconfig")
+ else()
+ set(expected_path "/baz:${CMAKE_CURRENT_SOURCE_DIR}/pc-bar/lib/pkgconfig")
+ endif()
+endif()
+
+
+pkg_check_modules(FOO "${expected_path}" NO_CMAKE_PATH)
+
+if(NOT "FOO_FOUND")
+ message(FATAL_ERROR "Expected PKG_CONFIG_PATH: \"${expected_path}\".")
+endif()
diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
new file mode 100644
index 0000000..bca93bb
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake
@@ -0,0 +1,6 @@
+include(RunCMake)
+
+run_cmake(FindPkgConfig_NO_PKGCONFIG_PATH)
+run_cmake(FindPkgConfig_PKGCONFIG_PATH)
+run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_PATH)
+run_cmake(FindPkgConfig_PKGCONFIG_PATH_NO_CMAKE_ENVIRONMENT_PATH)
diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
new file mode 100755
index 0000000..f2f86b0
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.bat
@@ -0,0 +1,18 @@
+@ECHO OFF
+IF "%1"=="" (
+ EXIT /B 255
+)
+IF "%1"=="--version" (
+ ECHO 0.0-cmake-dummy
+ EXIT /B 0
+)
+
+IF "%1"=="--exists" (
+ SHIFT
+ ECHO Expected: %*
+ ECHO Found: %PKG_CONFIG_PATH%
+ IF NOT "%*"=="%PKG_CONFIG_PATH%" (
+ EXIT /B 1
+ )
+)
+EXIT /B 0
diff --git a/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh
new file mode 100755
index 0000000..852e841
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/dummy-pkg-config.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# This is a replacement for pkg-config that compares the string passed
+# to the --exists argument with the PKG_CONFIG_PATH environment variable
+# and returns 1 if they are different.
+
+case $1 in
+ --version)
+ echo "0.0-cmake-dummy"
+ ;;
+ --exists)
+ shift
+ echo "Expected: $@"
+ echo "Found: ${PKG_CONFIG_PATH}"
+ [ "$@" = "${PKG_CONFIG_PATH}" ] || exit 1
+ ;;
+ *)
+ exit 255
+ ;;
+esac
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/i386-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib/x86_64-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-bar/lib64/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/i386-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib/x86_64-linux-gnu/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/FindPkgConfig/pc-foo/lib64/pkgconfig/.placeholder
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
index a1cac36..859dc3f 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression1-stderr.txt
@@ -1,6 +1,8 @@
CMake Error at BadSourceExpression1.cmake:1 \(add_library\):
- Unrecognized generator expression:
+ Error evaluating generator expression:
\$<BAD_EXPRESSION>
+
+ Expression did not evaluate to a known generator expression
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
index f1fcbe8..7060c61 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression2-stderr.txt
@@ -1,4 +1,8 @@
CMake Error at BadSourceExpression2.cmake:1 \(add_library\):
+ Error evaluating generator expression:
+
+ \$<TARGET_OBJECTS:DoesNotExist>
+
Objects of target "DoesNotExist" referenced but no such target exists.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
index ad14a35..838b3d8 100644
--- a/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
+++ b/Tests/RunCMake/ObjectLibrary/BadSourceExpression3-stderr.txt
@@ -1,4 +1,8 @@
CMake Error at BadSourceExpression3.cmake:2 \(add_library\):
+ Error evaluating generator expression:
+
+ \$<TARGET_OBJECTS:NotObjLib>
+
Objects of target "NotObjLib" referenced but is not an OBJECT library.
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 1d1c523..4ed2f43 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -25,7 +25,9 @@ function(run_cmake test)
unset(expect_std${o})
endif()
endforeach()
- set(RunCMake_TEST_SOURCE_DIR "${top_src}")
+ if (NOT RunCMake_TEST_SOURCE_DIR)
+ set(RunCMake_TEST_SOURCE_DIR "${top_src}")
+ endif()
if(NOT RunCMake_TEST_BINARY_DIR)
set(RunCMake_TEST_BINARY_DIR "${top_bin}/${test}-build")
endif()
@@ -36,6 +38,9 @@ function(run_cmake test)
if(NOT DEFINED RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS "")
endif()
+ if (NOT RunCMake_TEST_FILE)
+ set(RunCMake_TEST_FILE "${test}")
+ endif()
if(APPLE)
list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0025=NEW)
endif()
@@ -52,7 +57,8 @@ function(run_cmake test)
COMMAND ${CMAKE_COMMAND} "${RunCMake_TEST_SOURCE_DIR}"
-G "${RunCMake_GENERATOR}"
-T "${RunCMake_GENERATOR_TOOLSET}"
- -DRunCMake_TEST=${test}
+ -DRunCMake_TEST=${RunCMake_TEST_FILE}
+ --no-warn-unused-cli
${RunCMake_TEST_OPTIONS}
WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}"
OUTPUT_VARIABLE actual_stdout
diff --git a/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
new file mode 100644
index 0000000..5dcd4d7
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariable-stderr.txt
@@ -0,0 +1 @@
+-->wrong<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariable.cmake b/Tests/RunCMake/Syntax/AtWithVariable.cmake
new file mode 100644
index 0000000..2bbf61d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariable.cmake
@@ -0,0 +1,9 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here.
+set(ref "@var@")
+
+# 'right' is dereferenced because 'var' was dereferenced when
+# assigning to 'ref' above.
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
new file mode 100644
index 0000000..e06484c
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnly.cmake
@@ -0,0 +1,8 @@
+set(right "wrong")
+set(var "\${right}")
+# Expanded here.
+set(ref "@var@")
+
+# No dereference done at all.
+string(CONFIGURE "${ref}" output @ONLY)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt
new file mode 100644
index 0000000..90bffb6
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile-stderr.txt
@@ -0,0 +1,5 @@
+-->==>\${right}<==
+==><==
+==>\${var}<==
+==>\${empty}<==
+<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
new file mode 100644
index 0000000..bdd7bcd
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableAtOnlyFile.cmake
@@ -0,0 +1,9 @@
+set(right "wrong")
+set(var "\${right}")
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt"
+ @ONLY)
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
new file mode 100644
index 0000000..840c7f0
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansion.cmake
@@ -0,0 +1,8 @@
+# Literal since 'var' is not defined.
+set(ref "@var@")
+set(right "wrong")
+set(var "\${right}")
+
+# 'var' is dereferenced here.
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt
new file mode 100644
index 0000000..cbd1be4
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly-stderr.txt
@@ -0,0 +1 @@
+-->\${right}<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake
new file mode 100644
index 0000000..b657506
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableEmptyExpansionAtOnly.cmake
@@ -0,0 +1,8 @@
+# Literal since 'var' is not defined.
+set(ref "@var@")
+set(right "wrong")
+set(var "\${right}")
+
+# 'var' is dereferenced, but now 'right'
+string(CONFIGURE "${ref}" output @ONLY)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
new file mode 100644
index 0000000..43f029f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableFile-stderr.txt
@@ -0,0 +1,5 @@
+-->==>\${right}<==
+==><==
+==>\${right}<==
+==><==
+<--
diff --git a/Tests/RunCMake/Syntax/AtWithVariableFile.cmake b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake
new file mode 100644
index 0000000..c709099
--- /dev/null
+++ b/Tests/RunCMake/Syntax/AtWithVariableFile.cmake
@@ -0,0 +1,8 @@
+set(right "wrong")
+set(var "\${right}")
+
+configure_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/atfile.txt.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt")
+file(READ "${CMAKE_CURRENT_BINARY_DIR}/atfile.txt" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
new file mode 100644
index 0000000..077272d
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeQuotes-stderr.txt
@@ -0,0 +1 @@
+-->"<--
diff --git a/Tests/RunCMake/Syntax/EscapeQuotes.cmake b/Tests/RunCMake/Syntax/EscapeQuotes.cmake
new file mode 100644
index 0000000..46d2b6f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapeQuotes.cmake
@@ -0,0 +1,9 @@
+set(var "\"")
+set(ref "@var@")
+set(rref "\${var}")
+
+string(CONFIGURE "${ref}" output ESCAPE_QUOTES)
+message("-->${output}<--")
+
+string(CONFIGURE "${rref}" output ESCAPE_QUOTES)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/EscapedAt-stderr.txt b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt
new file mode 100644
index 0000000..a51c0d3
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapedAt-stderr.txt
@@ -0,0 +1 @@
+-->\\n<--
diff --git a/Tests/RunCMake/Syntax/EscapedAt.cmake b/Tests/RunCMake/Syntax/EscapedAt.cmake
new file mode 100644
index 0000000..1ced620
--- /dev/null
+++ b/Tests/RunCMake/Syntax/EscapedAt.cmake
@@ -0,0 +1,5 @@
+set(var "n")
+set(ref "\\@var@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
new file mode 100644
index 0000000..5da8b60
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ExpandInAt-stderr.txt
@@ -0,0 +1 @@
+-->@foo@<--
diff --git a/Tests/RunCMake/Syntax/ExpandInAt.cmake b/Tests/RunCMake/Syntax/ExpandInAt.cmake
new file mode 100644
index 0000000..98f0277
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ExpandInAt.cmake
@@ -0,0 +1,6 @@
+set("\${varname}" bar)
+set(var foo)
+set(ref "@\${var}@")
+
+string(CONFIGURE "${ref}" output)
+message("-->${output}<--")
diff --git a/Tests/RunCMake/Syntax/ParenInENV-result.txt b/Tests/RunCMake/Syntax/ParenInENV-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/Syntax/ParenInENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt
new file mode 100644
index 0000000..7ecfe11
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) at CMakeLists.txt:3 \(include\):
+ Syntax Warning in cmake code at
+
+ .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2:21
+
+ Argument not separated from preceding token by whitespace.
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at ParenInENV.cmake:2 \(message\):
+ Syntax error in cmake code at
+
+ .*/Tests/RunCMake/Syntax/ParenInENV.cmake:2
+
+ when parsing string
+
+ -->\$ENV{e
+
+ syntax error, unexpected \$end, expecting } \(9\)
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/Syntax/ParenInENV.cmake b/Tests/RunCMake/Syntax/ParenInENV.cmake
new file mode 100644
index 0000000..148f726
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInENV.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message(-->$ENV{e(x)}<--)
diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
new file mode 100644
index 0000000..7020c7e
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInQuotedENV-stderr.txt
@@ -0,0 +1 @@
+-->value<--
diff --git a/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
new file mode 100644
index 0000000..6333717
--- /dev/null
+++ b/Tests/RunCMake/Syntax/ParenInQuotedENV.cmake
@@ -0,0 +1,2 @@
+set("ENV{e(x)}" value)
+message("-->$ENV{e(x)}<--")
diff --git a/Tests/RunCMake/Syntax/RunCMakeTest.cmake b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
index 5f05cfc..dcabd8a 100644
--- a/Tests/RunCMake/Syntax/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Syntax/RunCMakeTest.cmake
@@ -52,3 +52,16 @@ run_cmake(UnterminatedString)
run_cmake(UnterminatedBracket0)
run_cmake(UnterminatedBracket1)
run_cmake(UnterminatedBracketComment)
+
+# Variable expansion tests
+run_cmake(ExpandInAt)
+run_cmake(EscapedAt)
+run_cmake(EscapeQuotes)
+run_cmake(AtWithVariable)
+run_cmake(AtWithVariableEmptyExpansion)
+run_cmake(AtWithVariableAtOnly)
+run_cmake(AtWithVariableEmptyExpansionAtOnly)
+run_cmake(AtWithVariableFile)
+run_cmake(AtWithVariableAtOnlyFile)
+run_cmake(ParenInENV)
+run_cmake(ParenInQuotedENV)
diff --git a/Tests/RunCMake/Syntax/atfile.txt.in b/Tests/RunCMake/Syntax/atfile.txt.in
new file mode 100644
index 0000000..3775919
--- /dev/null
+++ b/Tests/RunCMake/Syntax/atfile.txt.in
@@ -0,0 +1,4 @@
+==>@var@<==
+==>@empty@<==
+==>${var}<==
+==>${empty}<==
diff --git a/Tests/RunCMake/TargetObjects/BadContext-result.txt b/Tests/RunCMake/TargetObjects/BadContext-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/BadContext-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetObjects/BadContext-stderr.txt b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt
new file mode 100644
index 0000000..92f2c91
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/BadContext-stderr.txt
@@ -0,0 +1,17 @@
+CMake Error at BadContext.cmake:2 \(file\):
+ Error evaluating generator expression:
+
+ \$<TARGET_OBJECTS:NoTarget>
+
+ The evaluation of the TARGET_OBJECTS generator expression is only suitable
+ for consumption by CMake. It is not suitable for writing out elsewhere.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Error:
+ Error evaluating generator expression:
+
+ \$<TARGET_OBJECTS:NoTarget>
+
+ The evaluation of the TARGET_OBJECTS generator expression is only suitable
+ for consumption by CMake. It is not suitable for writing out elsewhere.
diff --git a/Tests/RunCMake/TargetObjects/BadContext.cmake b/Tests/RunCMake/TargetObjects/BadContext.cmake
new file mode 100644
index 0000000..67962a4
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/BadContext.cmake
@@ -0,0 +1,4 @@
+
+file(GENERATE OUTPUT test_output CONTENT $<TARGET_OBJECTS:NoTarget>)
+
+install(FILES $<TARGET_OBJECTS:NoTarget> DESTINATION objects)
diff --git a/Tests/RunCMake/TargetObjects/CMakeLists.txt b/Tests/RunCMake/TargetObjects/CMakeLists.txt
new file mode 100644
index 0000000..be9d403
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST})
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
new file mode 100644
index 0000000..85c76e2
--- /dev/null
+++ b/Tests/RunCMake/TargetObjects/RunCMakeTest.cmake
@@ -0,0 +1,3 @@
+include(RunCMake)
+
+run_cmake(BadContext)
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index f30c9a9..f4b744b 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -16,6 +16,7 @@
\* CMP0041
\* CMP0042
\* CMP0046
+ \* CMP0052
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake b/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake
new file mode 100644
index 0000000..464df36
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMP0026-LOCATION.cmake
@@ -0,0 +1,13 @@
+
+cmake_policy(SET CMP0026 OLD)
+
+add_library(objlib OBJECT
+ empty_1.cpp
+)
+
+add_executable(my_exe
+ empty_2.cpp
+ $<TARGET_OBJECTS:objlib>
+)
+
+get_target_property( loc my_exe LOCATION)
diff --git a/Tests/RunCMake/TargetSources/CMakeLists.txt b/Tests/RunCMake/TargetSources/CMakeLists.txt
new file mode 100644
index 0000000..f452db1
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
new file mode 100644
index 0000000..1de5dd7
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed-stderr.txt
@@ -0,0 +1,14 @@
+CMake Error in CMakeLists.txt:
+ Target "somelib" has source files which vary by configuration. This is not
+ supported by the "[^"]+" generator.
+
+ Config "Debug":
+
+ .*/Tests/RunCMake/TargetSources/empty_1.cpp
+ .*/Tests/RunCMake/TargetSources/empty_2.cpp
+ .*/Tests/RunCMake/TargetSources/CMakeLists.txt
+
+ Config "Release":
+
+ .*/Tests/RunCMake/TargetSources/empty_1.cpp
+ .*/Tests/RunCMake/TargetSources/CMakeLists.txt
diff --git a/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake b/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake
new file mode 100644
index 0000000..02af379
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/ConfigNotAllowed.cmake
@@ -0,0 +1,2 @@
+
+add_library(somelib empty_1.cpp $<$<CONFIG:Debug>:empty_2.cpp>)
diff --git a/Tests/RunCMake/TargetSources/OriginDebug-result.txt b/Tests/RunCMake/TargetSources/OriginDebug-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebug-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
new file mode 100644
index 0000000..0200dcb
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
@@ -0,0 +1,31 @@
+CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_2.cpp
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_3.cpp
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_4.cpp
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_1.cpp
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake
new file mode 100644
index 0000000..5fe9ba7
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake
@@ -0,0 +1,20 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(OriginDebug)
+
+set(CMAKE_DEBUG_TARGET_PROPERTIES SOURCES)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_SOURCES
+ empty_1.cpp
+)
+
+add_library(OriginDebug empty_2.cpp)
+target_link_libraries(OriginDebug iface)
+
+set_property(TARGET OriginDebug APPEND PROPERTY SOURCES
+ empty_3.cpp
+)
+
+target_sources(OriginDebug PRIVATE empty_4.cpp)
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
new file mode 100644
index 0000000..fad7073
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
@@ -0,0 +1,40 @@
+CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_2.cpp
+
+Call Stack \(most recent call first\):
+ OriginDebugIDE.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_3.cpp
+
+Call Stack \(most recent call first\):
+ OriginDebugIDE.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
++
+CMake Debug Log at OriginDebug.cmake:20 \(target_sources\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_4.cpp
+
+Call Stack \(most recent call first\):
+ OriginDebugIDE.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
++
+CMake Debug Log:
+ Used sources for target OriginDebug:
+
+ * .*CMakeLists.txt
++
+CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_1.cpp
+
+Call Stack \(most recent call first\):
+ OriginDebugIDE.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake
new file mode 100644
index 0000000..a3cc3a8
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE.cmake
@@ -0,0 +1,4 @@
+
+# Separate test for the IDEs, because they show the CMakeLists.txt file
+# as a source file.
+include(${CMAKE_CURRENT_LIST_DIR}/OriginDebug.cmake)
diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
new file mode 100644
index 0000000..01e505c
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake
@@ -0,0 +1,11 @@
+include(RunCMake)
+
+if(RunCMake_GENERATOR MATCHES Xcode
+ OR RunCMake_GENERATOR MATCHES "Visual Studio")
+ run_cmake(ConfigNotAllowed)
+ run_cmake(OriginDebugIDE)
+else()
+ run_cmake(OriginDebug)
+endif()
+
+run_cmake(CMP0026-LOCATION)
diff --git a/Tests/RunCMake/TargetSources/empty_1.cpp b/Tests/RunCMake/TargetSources/empty_1.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_1.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/empty_2.cpp b/Tests/RunCMake/TargetSources/empty_2.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_2.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/empty_3.cpp b/Tests/RunCMake/TargetSources/empty_3.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_3.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetSources/empty_4.cpp b/Tests/RunCMake/TargetSources/empty_4.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_4.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/configure_file/CMakeLists.txt b/Tests/RunCMake/configure_file/CMakeLists.txt
new file mode 100644
index 0000000..2897109
--- /dev/null
+++ b/Tests/RunCMake/configure_file/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/configure_file/NO-BOM.cmake b/Tests/RunCMake/configure_file/NO-BOM.cmake
new file mode 100644
index 0000000..003d526
--- /dev/null
+++ b/Tests/RunCMake/configure_file/NO-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(NO-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/NO-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/NO-BOM.txt.in b/Tests/RunCMake/configure_file/NO-BOM.txt.in
new file mode 100644
index 0000000..557db03
--- /dev/null
+++ b/Tests/RunCMake/configure_file/NO-BOM.txt.in
@@ -0,0 +1 @@
+Hello World
diff --git a/Tests/RunCMake/configure_file/RunCMakeTest.cmake b/Tests/RunCMake/configure_file/RunCMakeTest.cmake
new file mode 100644
index 0000000..c8bfa57
--- /dev/null
+++ b/Tests/RunCMake/configure_file/RunCMakeTest.cmake
@@ -0,0 +1,8 @@
+include(RunCMake)
+
+run_cmake(NO-BOM)
+run_cmake(UTF8-BOM)
+run_cmake(UTF16LE-BOM)
+run_cmake(UTF16BE-BOM)
+run_cmake(UTF32LE-BOM)
+run_cmake(UTF32BE-BOM)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
new file mode 100644
index 0000000..5132c4d
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF16BE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
new file mode 100644
index 0000000..c570742
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF16BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16BE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
new file mode 100644
index 0000000..70fd9cb
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16BE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
new file mode 100644
index 0000000..8f997bc
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF16LE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
new file mode 100644
index 0000000..05c9cd7
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF16LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF16LE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
new file mode 100644
index 0000000..036f8c5
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF16LE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
new file mode 100644
index 0000000..12811aa
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF32BE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
new file mode 100644
index 0000000..0c6ea87
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF32BE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32BE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
new file mode 100644
index 0000000..c87cfd5
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32BE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
new file mode 100644
index 0000000..fa9e01a
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at UTF32LE-BOM.cmake:2 \(configure_file\):
+ File starts with a Byte-Order-Mark that is not UTF-8:
+
+ .*/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
new file mode 100644
index 0000000..b6351b0
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF32LE-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF32LE-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
new file mode 100644
index 0000000..27c8183
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF32LE-BOM.txt.in
Binary files differ
diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.cmake b/Tests/RunCMake/configure_file/UTF8-BOM.cmake
new file mode 100644
index 0000000..af2adae
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF8-BOM.cmake
@@ -0,0 +1,2 @@
+
+configure_file(UTF8-BOM.txt.in ${CMAKE_CURRENT_BINARY_DIR}/UTF8-BOM.txt)
diff --git a/Tests/RunCMake/configure_file/UTF8-BOM.txt.in b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in
new file mode 100644
index 0000000..abc0aca
--- /dev/null
+++ b/Tests/RunCMake/configure_file/UTF8-BOM.txt.in
@@ -0,0 +1 @@
+Hello World
diff --git a/Tests/RunCMake/find_dependency/CMakeLists.txt b/Tests/RunCMake/find_dependency/CMakeLists.txt
new file mode 100644
index 0000000..04d09f2
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/CMakeLists.txt
@@ -0,0 +1,4 @@
+cmake_minimum_required(VERSION 2.8.4)
+project(${RunCMake_TEST} NONE)
+set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/EXACT-no-version-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt
new file mode 100644
index 0000000..348f8bb
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/EXACT-no-version-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+ Invalid arguments to find_dependency. EXACT may only be specified if a
+ VERSION is specified
+Call Stack \(most recent call first\):
+ EXACT-no-version.cmake:4 \(find_dependency\)
+ CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/EXACT-no-version.cmake b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake
new file mode 100644
index 0000000..b05665b7
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/EXACT-no-version.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 EXACT)
diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake
new file mode 100644
index 0000000..7d55ef6
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/Pack1/Pack1Config.cmake
@@ -0,0 +1,2 @@
+
+add_library(Pack1::Lib INTERFACE IMPORTED)
diff --git a/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake
new file mode 100644
index 0000000..dfb7b6c
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/Pack1/Pack1ConfigVersion.cmake
@@ -0,0 +1,11 @@
+
+set(PACKAGE_VERSION "1.3")
+
+if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
+ set(PACKAGE_VERSION_COMPATIBLE FALSE)
+else()
+ set(PACKAGE_VERSION_COMPATIBLE TRUE)
+ if( "${PACKAGE_FIND_VERSION}" STREQUAL "${PACKAGE_VERSION}")
+ set(PACKAGE_VERSION_EXACT TRUE)
+ endif()
+endif()
diff --git a/Tests/RunCMake/find_dependency/RunCMakeTest.cmake b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake
new file mode 100644
index 0000000..9403136
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/RunCMakeTest.cmake
@@ -0,0 +1,7 @@
+include(RunCMake)
+
+run_cmake(EXACT-no-version)
+run_cmake(empty-version)
+run_cmake(empty-arg-3)
+run_cmake(invalid-arg-3)
+run_cmake(extra-args)
diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-result.txt b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-arg-3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt
new file mode 100644
index 0000000..bf9b02b
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-arg-3-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+ Invalid arguments to find_dependency
+Call Stack \(most recent call first\):
+ empty-arg-3.cmake:4 \(find_dependency\)
+ CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/empty-arg-3.cmake b/Tests/RunCMake/find_dependency/empty-arg-3.cmake
new file mode 100644
index 0000000..b08200a
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-arg-3.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 1.2 "")
diff --git a/Tests/RunCMake/find_dependency/empty-version-result.txt b/Tests/RunCMake/find_dependency/empty-version-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-version-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_dependency/empty-version-stderr.txt b/Tests/RunCMake/find_dependency/empty-version-stderr.txt
new file mode 100644
index 0000000..b5e9f46
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-version-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*/Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+ Invalid arguments to find_dependency. VERSION is empty
+Call Stack \(most recent call first\):
+ empty-version.cmake:4 \(find_dependency\)
+ CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/empty-version.cmake b/Tests/RunCMake/find_dependency/empty-version.cmake
new file mode 100644
index 0000000..e6f17cd
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/empty-version.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 "")
diff --git a/Tests/RunCMake/find_dependency/extra-args-result.txt b/Tests/RunCMake/find_dependency/extra-args-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/extra-args-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_dependency/extra-args-stderr.txt b/Tests/RunCMake/find_dependency/extra-args-stderr.txt
new file mode 100644
index 0000000..83a7f02
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/extra-args-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+ Invalid arguments to find_dependency
+Call Stack \(most recent call first\):
+ extra-args.cmake:4 \(find_dependency\)
+ CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/extra-args.cmake b/Tests/RunCMake/find_dependency/extra-args.cmake
new file mode 100644
index 0000000..209645a
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/extra-args.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 1.2 EXACT PATHS "${CMAKE_BINARY_DIR}")
diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/invalid-arg-3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt
new file mode 100644
index 0000000..fee8d5d
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/invalid-arg-3-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at .*Modules/CMakeFindDependencyMacro.cmake:[0-9]+ \(message\):
+ Invalid arguments to find_dependency
+Call Stack \(most recent call first\):
+ invalid-arg-3.cmake:4 \(find_dependency\)
+ CMakeLists.txt:4 \(include\)
diff --git a/Tests/RunCMake/find_dependency/invalid-arg-3.cmake b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake
new file mode 100644
index 0000000..40ede07
--- /dev/null
+++ b/Tests/RunCMake/find_dependency/invalid-arg-3.cmake
@@ -0,0 +1,4 @@
+
+include(CMakeFindDependencyMacro)
+
+find_dependency(Pack1 1.2 EXACTYPO)
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt
new file mode 100644
index 0000000..f0adc9f
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-NEW-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+ Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+ ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-NEW-build/foo"
+
+ which is prefixed in the build directory.
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-OLD-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
new file mode 100644
index 0000000..054bff5
--- /dev/null
+++ b/Tests/RunCMake/include_directories/BinInInstallPrefix-CMP0052-WARN-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0052 is not set: Reject source and build dirs in installed
+ INTERFACE_INCLUDE_DIRECTORIES. Run "cmake --help-policy CMP0052" for
+ policy details. Use the cmake_policy command to set the policy and
+ suppress this warning.
+
+ Directory:
+
+ ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build/foo"
+
+ in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
+ of the install directory:
+
+ ".*Tests/RunCMake/include_directories/prefix"
+
+ however it is also a subdirectory of the build tree:
+
+ ".*Tests/RunCMake/include_directories/prefix/BinInInstallPrefix-CMP0052-WARN-build"
+
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/include_directories/CMakeLists.txt b/Tests/RunCMake/include_directories/CMakeLists.txt
index f452db1..3482e6b 100644
--- a/Tests/RunCMake/include_directories/CMakeLists.txt
+++ b/Tests/RunCMake/include_directories/CMakeLists.txt
@@ -1,3 +1,3 @@
-cmake_minimum_required(VERSION 2.8.4)
+cmake_minimum_required(VERSION 3.0)
project(${RunCMake_TEST} CXX)
include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake
new file mode 100644
index 0000000..d6f08bd
--- /dev/null
+++ b/Tests/RunCMake/include_directories/DirInInstallPrefix.cmake
@@ -0,0 +1,9 @@
+
+add_library(testTarget empty.cpp)
+target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/dir")
+
+install(TARGETS testTarget EXPORT testTargets
+ DESTINATION lib
+)
+
+install(EXPORT testTargets DESTINATION lib/cmake)
diff --git a/Tests/RunCMake/include_directories/InstallInBinDir-result.txt b/Tests/RunCMake/include_directories/InstallInBinDir-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallInBinDir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt b/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt
new file mode 100644
index 0000000..254fae1
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallInBinDir-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+ Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+ ".*Tests/RunCMake/include_directories/InstallInBinDir-build/foo"
+
+ which is prefixed in the build directory.
diff --git a/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt b/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallInSrcDir-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt b/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt
new file mode 100644
index 0000000..7be3044
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallInSrcDir-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+ Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+ ".*Tests/RunCMake/include_directories/copy/foo"
+
+ which is prefixed in the source directory.
diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt b/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt b/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake b/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake
new file mode 100644
index 0000000..0f08e58
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallPrefixInInterface.cmake
@@ -0,0 +1,11 @@
+
+project(InstallPrefixInInterface)
+
+add_library(testTarget "${CMAKE_CURRENT_SOURCE_DIR}/empty.cpp")
+target_include_directories(testTarget INTERFACE "${CMAKE_INSTALL_PREFIX}/foo")
+
+install(TARGETS testTarget EXPORT testTargets
+ DESTINATION lib
+)
+
+install(EXPORT testTargets DESTINATION lib/cmake)
diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirInSource-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/InstallToPrefixInSrcDirOutOfSource-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake
index c00b924..c5b29d0 100644
--- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake
+++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake
@@ -12,3 +12,131 @@ run_cmake(CMP0021)
run_cmake(install_config)
run_cmake(incomplete-genex)
run_cmake(export-NOWARN)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/DirInInstallPrefix/prefix")
+run_cmake(DirInInstallPrefix)
+
+configure_file(
+ "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+ "${RunCMake_BINARY_DIR}/copy/CMakeLists.txt"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/empty.cpp"
+ "${RunCMake_BINARY_DIR}/copy/empty.cpp"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
+ "${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface.cmake"
+ COPYONLY
+)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface/prefix")
+set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/copy/SourceDirectoryInInterface")
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/copy")
+run_cmake(InstallInSrcDir)
+unset(RunCMake_TEST_SOURCE_DIR)
+unset(RunCMake_TEST_FILE)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallInBinDir-build/prefix")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/InstallInBinDir-build")
+set(RunCMake_TEST_FILE "${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface")
+run_cmake(InstallInBinDir)
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_FILE)
+
+configure_file(
+ "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+ "${RunCMake_BINARY_DIR}/prefix/src/CMakeLists.txt"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/empty.cpp"
+ "${RunCMake_BINARY_DIR}/prefix/src/empty.cpp"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/SourceDirectoryInInterface.cmake"
+ "${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface.cmake"
+ COPYONLY
+)
+
+foreach(policyStatus "" NEW OLD)
+ if (NOT "${policyStatus}" STREQUAL "")
+ set(policyOption -DCMAKE_POLICY_DEFAULT_CMP0052=${policyStatus})
+ else()
+ unset(policyOption)
+ set(policyStatus WARN)
+ endif()
+ set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix" ${policyOption})
+ # Set the RunCMake_TEST_SOURCE_DIR here to the copy too. This is needed to run
+ # the test suite in-source properly. Otherwise the install directory would be
+ # a subdirectory or the source directory, which is allowed and tested separately
+ # below.
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/prefix/src")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/prefix/BinInInstallPrefix-CMP0052-${policyStatus}-build")
+ set(RunCMake_TEST_FILE "${RunCMake_SOURCE_DIR}/BinaryDirectoryInInterface")
+ run_cmake(BinInInstallPrefix-CMP0052-${policyStatus})
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_FILE)
+
+ set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/prefix/src/SourceDirectoryInInterface")
+ run_cmake(SrcInInstallPrefix-CMP0052-${policyStatus})
+ unset(RunCMake_TEST_SOURCE_DIR)
+ unset(RunCMake_TEST_FILE)
+endforeach()
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/InstallPrefixInInterface-build/prefix")
+run_cmake(InstallPrefixInInterface)
+
+configure_file(
+ "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+ "${RunCMake_BINARY_DIR}/installToSrc/CMakeLists.txt"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/empty.cpp"
+ "${RunCMake_BINARY_DIR}/installToSrc/empty.cpp"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
+ "${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface.cmake"
+ COPYONLY
+)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface/prefix")
+set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/installToSrc/InstallPrefixInInterface")
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrc")
+run_cmake(InstallToPrefixInSrcDirOutOfSource)
+unset(RunCMake_TEST_SOURCE_DIR)
+unset(RunCMake_TEST_FILE)
+
+
+file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}/installToSrcInSrc")
+set(RunCMake_TEST_NO_CLEAN ON)
+
+configure_file(
+ "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
+ "${RunCMake_BINARY_DIR}/installToSrcInSrc/CMakeLists.txt"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/empty.cpp"
+ "${RunCMake_BINARY_DIR}/installToSrcInSrc/empty.cpp"
+ COPYONLY
+)
+configure_file(
+ "${RunCMake_SOURCE_DIR}/InstallPrefixInInterface.cmake"
+ "${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface.cmake"
+ COPYONLY
+)
+
+set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface/prefix")
+set(RunCMake_TEST_FILE "${RunCMake_BINARY_DIR}/installToSrcInSrc/InstallPrefixInInterface")
+set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
+set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/installToSrcInSrc")
+run_cmake(InstallToPrefixInSrcDirInSource)
+unset(RunCMake_TEST_SOURCE_DIR)
+unset(RunCMake_TEST_BINARY_DIR)
+unset(RunCMake_TEST_FILE)
+unset(RunCMake_TEST_NO_CLEAN)
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt
new file mode 100644
index 0000000..afa43e0
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-NEW-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error in CMakeLists.txt:
+ Target "testTarget" INTERFACE_INCLUDE_DIRECTORIES property contains path:
+
+ ".*Tests/RunCMake/include_directories/prefix/src/foo"
+
+ which is prefixed in the source directory.
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
new file mode 100644
index 0000000..10f3293
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-OLD-stderr.txt
@@ -0,0 +1 @@
+^$
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
new file mode 100644
index 0000000..0b13fd8
--- /dev/null
+++ b/Tests/RunCMake/include_directories/SrcInInstallPrefix-CMP0052-WARN-stderr.txt
@@ -0,0 +1,20 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0052 is not set: Reject source and build dirs in installed
+ INTERFACE_INCLUDE_DIRECTORIES. Run "cmake --help-policy CMP0052" for
+ policy details. Use the cmake_policy command to set the policy and
+ suppress this warning.
+
+ Directory:
+
+ ".*Tests/RunCMake/include_directories/prefix/src/foo"
+
+ in INTERFACE_INCLUDE_DIRECTORIES of target "testTarget" is a subdirectory
+ of the install directory:
+
+ ".*Tests/RunCMake/include_directories/prefix"
+
+ however it is also a subdirectory of the source tree:
+
+ ".*Tests/RunCMake/include_directories/prefix/src"
+
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/set/ParentScope-result.txt b/Tests/RunCMake/set/ParentScope-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/set/ParentScope-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/set/PARENT_SCOPE.cmake b/Tests/RunCMake/set/ParentScope.cmake
index 9bd6bca..9bd6bca 100644
--- a/Tests/RunCMake/set/PARENT_SCOPE.cmake
+++ b/Tests/RunCMake/set/ParentScope.cmake
diff --git a/Tests/RunCMake/set/RunCMakeTest.cmake b/Tests/RunCMake/set/RunCMakeTest.cmake
index 5d036e3..1b51ea2 100644
--- a/Tests/RunCMake/set/RunCMakeTest.cmake
+++ b/Tests/RunCMake/set/RunCMakeTest.cmake
@@ -1,3 +1,3 @@
include(RunCMake)
-run_cmake(PARENT_SCOPE)
+run_cmake(ParentScope)
diff --git a/Tests/RunCMake/target_compile_features/CMakeLists.txt b/Tests/RunCMake/target_compile_features/CMakeLists.txt
new file mode 100644
index 0000000..3482e6b
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.0)
+project(${RunCMake_TEST} CXX)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
new file mode 100644
index 0000000..f2abef7
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/RunCMakeTest.cmake
@@ -0,0 +1,11 @@
+include(RunCMake)
+
+run_cmake(not_enough_args)
+run_cmake(alias_target)
+run_cmake(utility_target)
+run_cmake(invalid_args)
+run_cmake(invalid_args_on_interface)
+run_cmake(imported_target)
+run_cmake(no_target)
+run_cmake(not_a_cxx_feature)
+run_cmake(no_matching_cxx_feature)
diff --git a/Tests/RunCMake/target_compile_features/alias_target-result.txt b/Tests/RunCMake/target_compile_features/alias_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/alias_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/alias_target-stderr.txt b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
new file mode 100644
index 0000000..417bf62
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/alias_target-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at alias_target.cmake:4 \(target_compile_features\):
+ target_compile_features can not be used on an ALIAS target.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/alias_target.cmake b/Tests/RunCMake/target_compile_features/alias_target.cmake
new file mode 100644
index 0000000..d35ddba
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/alias_target.cmake
@@ -0,0 +1,4 @@
+
+add_executable(main empty.cpp)
+add_executable(Alias::Main ALIAS main)
+target_compile_features(Alias::Main PRIVATE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/empty.cpp b/Tests/RunCMake/target_compile_features/empty.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/empty.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/target_compile_features/imported_target-result.txt b/Tests/RunCMake/target_compile_features/imported_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/imported_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/imported_target-stderr.txt b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
new file mode 100644
index 0000000..c6ff5ec
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/imported_target-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at imported_target.cmake:3 \(target_compile_features\):
+ Cannot specify compile features for imported target "main".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/imported_target.cmake b/Tests/RunCMake/target_compile_features/imported_target.cmake
new file mode 100644
index 0000000..e248c2f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/imported_target.cmake
@@ -0,0 +1,3 @@
+
+add_library(main INTERFACE IMPORTED)
+target_compile_features(main INTERFACE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args-result.txt b/Tests/RunCMake/target_compile_features/invalid_args-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
new file mode 100644
index 0000000..bd5b7b9
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at invalid_args.cmake:3 \(target_compile_features\):
+ target_compile_features called with invalid arguments
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args.cmake b/Tests/RunCMake/target_compile_features/invalid_args.cmake
new file mode 100644
index 0000000..1a7fb37
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args.cmake
@@ -0,0 +1,3 @@
+
+add_executable(main empty.cpp)
+target_compile_features(main INVALID cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
new file mode 100644
index 0000000..c30209a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at invalid_args_on_interface.cmake:3 \(target_compile_features\):
+ target_compile_features may only be set INTERFACE properties on INTERFACE
+ targets
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake
new file mode 100644
index 0000000..324d0f3
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/invalid_args_on_interface.cmake
@@ -0,0 +1,3 @@
+
+add_library(main INTERFACE)
+target_compile_features(main PRIVATE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
new file mode 100644
index 0000000..4c76c7a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at no_matching_cxx_feature.cmake:[0-9][0-9]? \((target_compile_features|message)\):
+ The compiler feature "[^"]+" is not known to compiler
+
+ "[^"]*"
+
+ version *[.0-9]+\.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake
new file mode 100644
index 0000000..0452dbf
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_matching_cxx_feature.cmake
@@ -0,0 +1,26 @@
+
+if (NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;"
+ AND NOT ";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;" )
+ # Simulate passing the test.
+ message(SEND_ERROR
+ "The compiler feature \"gnu_cxx_dummy\" is not known to compiler\n\"GNU\"\nversion 4.8.1."
+ )
+ return()
+endif()
+
+if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";gnu_cxx_typeof;")
+ set(feature msvc_cxx_sealed)
+ if (";${CMAKE_CXX_COMPILE_FEATURES};" MATCHES ";msvc_cxx_sealed;")
+ # If a compiler supports both extensions, remove one of them.
+ list(REMOVE_ITEM CMAKE_CXX_COMPILE_FEATURES msvc_cxx_sealed)
+ endif()
+else()
+ set(feature gnu_cxx_typeof)
+endif()
+
+add_executable(main empty.cpp)
+
+target_compile_features(main
+ PRIVATE
+ ${feature}
+)
diff --git a/Tests/RunCMake/target_compile_features/no_target-result.txt b/Tests/RunCMake/target_compile_features/no_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/no_target-stderr.txt b/Tests/RunCMake/target_compile_features/no_target-stderr.txt
new file mode 100644
index 0000000..323ba7a
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_target-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at no_target.cmake:2 \(target_compile_features\):
+ Cannot specify compile features for target "main" which is not built by
+ this project.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/no_target.cmake b/Tests/RunCMake/target_compile_features/no_target.cmake
new file mode 100644
index 0000000..3f0afe2
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/no_target.cmake
@@ -0,0 +1,2 @@
+
+target_compile_features(main INTERFACE cxx_delegating_constructors)
diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
new file mode 100644
index 0000000..efa2bad
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at not_a_cxx_feature.cmake:3 \(target_compile_features\):
+ target_compile_features specified unknown feature "cxx_not_a_feature" for
+ target "main".
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake
new file mode 100644
index 0000000..0207b72
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_a_cxx_feature.cmake
@@ -0,0 +1,6 @@
+
+add_executable(main empty.cpp)
+target_compile_features(main
+ PRIVATE
+ cxx_not_a_feature
+)
diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-result.txt b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_enough_args-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
new file mode 100644
index 0000000..2f8d812
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_enough_args-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at not_enough_args.cmake:3 \(target_compile_features\):
+ target_compile_features called with incorrect number of arguments
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/not_enough_args.cmake b/Tests/RunCMake/target_compile_features/not_enough_args.cmake
new file mode 100644
index 0000000..9561230
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/not_enough_args.cmake
@@ -0,0 +1,3 @@
+
+add_executable(main empty.cpp)
+target_compile_features(main)
diff --git a/Tests/RunCMake/target_compile_features/utility_target-result.txt b/Tests/RunCMake/target_compile_features/utility_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/utility_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_compile_features/utility_target-stderr.txt b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
new file mode 100644
index 0000000..d239059
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/utility_target-stderr.txt
@@ -0,0 +1,4 @@
+CMake Error at utility_target.cmake:4 \(target_compile_features\):
+ target_compile_features called with non-compilable target type
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/target_compile_features/utility_target.cmake b/Tests/RunCMake/target_compile_features/utility_target.cmake
new file mode 100644
index 0000000..8919056
--- /dev/null
+++ b/Tests/RunCMake/target_compile_features/utility_target.cmake
@@ -0,0 +1,4 @@
+
+add_custom_target(utility)
+
+target_compile_features(utility PRIVATE cxx_delegating_constructors)
diff --git a/Tests/SourcesProperty/CMakeLists.txt b/Tests/SourcesProperty/CMakeLists.txt
new file mode 100644
index 0000000..6c99e00
--- /dev/null
+++ b/Tests/SourcesProperty/CMakeLists.txt
@@ -0,0 +1,12 @@
+
+cmake_minimum_required(VERSION 3.0)
+
+project(SourcesProperty)
+
+add_library(iface INTERFACE)
+set_property(TARGET iface PROPERTY INTERFACE_SOURCES iface.cpp)
+
+add_executable(SourcesProperty main.cpp)
+target_link_libraries(SourcesProperty iface)
+
+set_property(TARGET SourcesProperty APPEND PROPERTY SOURCES prop.cpp)
diff --git a/Tests/SourcesProperty/iface.cpp b/Tests/SourcesProperty/iface.cpp
new file mode 100644
index 0000000..e38ac37
--- /dev/null
+++ b/Tests/SourcesProperty/iface.cpp
@@ -0,0 +1,5 @@
+
+int iface()
+{
+ return 0;
+}
diff --git a/Tests/SourcesProperty/iface.h b/Tests/SourcesProperty/iface.h
new file mode 100644
index 0000000..6da80a4
--- /dev/null
+++ b/Tests/SourcesProperty/iface.h
@@ -0,0 +1,4 @@
+
+int iface();
+
+int prop();
diff --git a/Tests/SourcesProperty/main.cpp b/Tests/SourcesProperty/main.cpp
new file mode 100644
index 0000000..33a97f4
--- /dev/null
+++ b/Tests/SourcesProperty/main.cpp
@@ -0,0 +1,7 @@
+
+#include "iface.h"
+
+int main(int argc, char** argv)
+{
+ return iface() + prop();
+}
diff --git a/Tests/SourcesProperty/prop.cpp b/Tests/SourcesProperty/prop.cpp
new file mode 100644
index 0000000..e343431
--- /dev/null
+++ b/Tests/SourcesProperty/prop.cpp
@@ -0,0 +1,5 @@
+
+int prop()
+{
+ return 0;
+}
diff --git a/Tests/StringFileTest/CMakeLists.txt b/Tests/StringFileTest/CMakeLists.txt
index 00383ab..be6d8fe 100644
--- a/Tests/StringFileTest/CMakeLists.txt
+++ b/Tests/StringFileTest/CMakeLists.txt
@@ -286,3 +286,9 @@ string(MAKE_C_IDENTIFIER "1one-two$" MCI_1)
if(NOT MCI_1 STREQUAL _1one_two_)
message(SEND_ERROR "MAKE_C_IDENTIFIER did not create expected result.")
endif()
+
+string(GENEX_STRIP "one;$<1:two;three>;four;$<TARGET_OBJECTS:some_target>" strip_result)
+
+if (NOT strip_result STREQUAL "one;four")
+ message(SEND_ERROR "GENEX_STRIP did not create expected result: ${strip_result}")
+endif()
diff --git a/Tests/SubDirSpaces/CMakeLists.txt b/Tests/SubDirSpaces/CMakeLists.txt
index 69f1d68..40c265e 100644
--- a/Tests/SubDirSpaces/CMakeLists.txt
+++ b/Tests/SubDirSpaces/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project(SUBDIR)
# Some systems do not seem to support rpath with spaces.
-if("${CMAKE_SYSTEM}" MATCHES "IRIX|QNX")
+if(CMAKE_SYSTEM_NAME MATCHES "IRIX|QNX")
set(CMAKE_SKIP_BUILD_RPATH 1)
endif()
diff --git a/Tests/SystemInformation/CMakeLists.txt b/Tests/SystemInformation/CMakeLists.txt
index c33380f..db54612 100644
--- a/Tests/SystemInformation/CMakeLists.txt
+++ b/Tests/SystemInformation/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 2.6)
+cmake_minimum_required (VERSION 3.0)
project(SystemInformation)
include_directories("This does not exists")
diff --git a/Tests/SystemInformation/SystemInformation.in b/Tests/SystemInformation/SystemInformation.in
index df3bf49..954a2fe 100644
--- a/Tests/SystemInformation/SystemInformation.in
+++ b/Tests/SystemInformation/SystemInformation.in
@@ -21,6 +21,12 @@ CMAKE_C_COMPILER_ID == "${CMAKE_C_COMPILER_ID}"
CMAKE_C_COMPILER_VERSION == "${CMAKE_C_COMPILER_VERSION}"
CMAKE_CXX_COMPILER_ID == "${CMAKE_CXX_COMPILER_ID}"
CMAKE_CXX_COMPILER_VERSION == "${CMAKE_CXX_COMPILER_VERSION}"
+CMAKE_CXX98_STANDARD_COMPILE_OPTION == "${CMAKE_CXX98_STANDARD_COMPILE_OPTION}"
+CMAKE_CXX11_STANDARD_COMPILE_OPTION == "${CMAKE_CXX11_STANDARD_COMPILE_OPTION}"
+CMAKE_CXX98_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX98_EXTENSION_COMPILE_OPTION}"
+CMAKE_CXX11_EXTENSION_COMPILE_OPTION == "${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}"
+CMAKE_CXX_COMPILE_FEATURES == "${CMAKE_CXX_COMPILE_FEATURES}"
+CMAKE_CXX11_COMPILE_FEATURES == "${CMAKE_CXX11_COMPILE_FEATURES}"
// C shared library flag
CMAKE_SHARED_LIBRARY_C_FLAGS == "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
diff --git a/Utilities/Release/create-cmake-release.cmake b/Utilities/Release/create-cmake-release.cmake
index 95428b6..841aba5 100644
--- a/Utilities/Release/create-cmake-release.cmake
+++ b/Utilities/Release/create-cmake-release.cmake
@@ -10,7 +10,7 @@ set(RELEASE_SCRIPTS_BATCH_1
dashmacmini2_release.cmake # Mac Darwin universal ppc;i386
dashmacmini5_release.cmake # Mac Darwin64 universal x86_64;i386
magrathea_release.cmake # Linux
- v20n250_aix_release.cmake # AIX 5.3
+ ibm_aix_release.cmake # AIX
ferrari_sgi64_release.cmake # IRIX 64
ferrari_sgi_release.cmake # IRIX
)
diff --git a/Utilities/Release/dashmacmini2_release.cmake b/Utilities/Release/dashmacmini2_release.cmake
index 9d418d9..89c99bc 100644
--- a/Utilities/Release/dashmacmini2_release.cmake
+++ b/Utilities/Release/dashmacmini2_release.cmake
@@ -10,9 +10,9 @@ set(INITIAL_CACHE "
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_OSX_ARCHITECTURES:STRING=ppc;i386
CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1c-install/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a
CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
CPACK_SYSTEM_NAME:STRING=Darwin-universal
BUILD_QtDialog:BOOL=TRUE
diff --git a/Utilities/Release/dashmacmini5_release.cmake b/Utilities/Release/dashmacmini5_release.cmake
index aba68f8..f777718 100644
--- a/Utilities/Release/dashmacmini5_release.cmake
+++ b/Utilities/Release/dashmacmini5_release.cmake
@@ -9,9 +9,9 @@ set(CPACK_BINARY_GENERATORS "PackageMaker TGZ TZ")
set(CPACK_SOURCE_GENERATORS "TGZ TZ")
set(INITIAL_CACHE "
CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1c-install/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1c-install/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/Users/kitware/openssl-1.0.1g-install/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/Users/kitware/openssl-1.0.1g-install/lib/libssl.a
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_OSX_ARCHITECTURES:STRING=x86_64;i386
CMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.5
diff --git a/Utilities/Release/v20n250_aix_release.cmake b/Utilities/Release/ibm_aix_release.cmake
index cc8cd05..5a6efe6 100644
--- a/Utilities/Release/v20n250_aix_release.cmake
+++ b/Utilities/Release/ibm_aix_release.cmake
@@ -1,8 +1,7 @@
set(CMAKE_RELEASE_DIRECTORY "/bench1/noibm34/CMakeReleaseDirectory")
-set(FINAL_PATH /u/noibm34/cmake-release)
-set(PROCESSORS 2)
-set(HOST "sshserv.centers.ihost.com")
-set(EXTRA_HOP "rsh p90n03")
+set(PROCESSORS 64)
+set(HOST "ibm-backend")
+set(SCRIPT_NAME aix)
set(MAKE_PROGRAM "make")
set(CC "xlc_r")
set(CXX "xlC_r")
@@ -12,11 +11,5 @@ set(INITIAL_CACHE "
CMAKE_BUILD_TYPE:STRING=Release
CMAKE_SKIP_BOOTSTRAP_TEST:STRING=TRUE
")
-set(EXTRA_COPY "
-rm -rf ~/cmake-release
-mkdir ~/cmake-release
-mv *.sh ~/cmake-release
-mv *.Z ~/cmake-release
-mv *.gz ~/cmake-release")
get_filename_component(path "${CMAKE_CURRENT_LIST_FILE}" PATH)
include(${path}/release_cmake.cmake)
diff --git a/Utilities/Release/magrathea_release.cmake b/Utilities/Release/magrathea_release.cmake
index 93916e2..1bf75dd 100644
--- a/Utilities/Release/magrathea_release.cmake
+++ b/Utilities/Release/magrathea_release.cmake
@@ -11,9 +11,9 @@ CURSES_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libncurses.a
CURSES_INCLUDE_PATH:PATH=/usr/i686-gcc-332s/include/ncurses
FORM_LIBRARY:FILEPATH=/usr/i686-gcc-332s/lib/libform.a
CMAKE_USE_OPENSSL:BOOL=ON
-OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libcrypto.a
-OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1c-install/include
-OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1c-install/lib/libssl.a
+OPENSSL_CRYPTO_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1g-install/lib/libcrypto.a
+OPENSSL_INCLUDE_DIR:PATH=/home/kitware/openssl-1.0.1g-install/include
+OPENSSL_SSL_LIBRARY:FILEPATH=/home/kitware/openssl-1.0.1g-install/lib/libssl.a
CPACK_SYSTEM_NAME:STRING=Linux-i386
BUILD_QtDialog:BOOL:=TRUE
CMake_GUI_DISTRIBUTE_WITH_Qt_LGPL:BOOL=TRUE
diff --git a/Utilities/Release/release_cmake.cmake b/Utilities/Release/release_cmake.cmake
index 630f54f..7a1652d 100644
--- a/Utilities/Release/release_cmake.cmake
+++ b/Utilities/Release/release_cmake.cmake
@@ -4,9 +4,6 @@ get_filename_component(SCRIPT_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(NOT DEFINED CPACK_BINARY_GENERATORS)
set(CPACK_BINARY_GENERATORS "STGZ TGZ TZ")
endif()
-if(DEFINED EXTRA_COPY)
- set(HAS_EXTRA_COPY 1)
-endif()
if(NOT DEFINED CMAKE_RELEASE_DIRECTORY)
set(CMAKE_RELEASE_DIRECTORY "~/CMakeReleaseDirectory")
endif()
@@ -55,11 +52,11 @@ message("Creating CMake release ${CMAKE_CREATE_VERSION} on ${HOST} with parallel
macro(remote_command comment command)
message("${comment}")
if(${ARGC} GREATER 2)
- message("ssh ${HOST} ${EXTRA_HOP} ${command}")
- execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
+ message("ssh ${HOST} ${command}")
+ execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result INPUT_FILE ${ARGV2})
else()
- message("ssh ${HOST} ${EXTRA_HOP} ${command}")
- execute_process(COMMAND ssh ${HOST} ${EXTRA_HOP} ${command} RESULT_VARIABLE result)
+ message("ssh ${HOST} ${command}")
+ execute_process(COMMAND ssh ${HOST} ${command} RESULT_VARIABLE result)
endif()
if(${result} GREATER 0)
message(FATAL_ERROR "Error running command: ${command}, return value = ${result}")
@@ -67,14 +64,15 @@ macro(remote_command comment command)
endmacro()
if(CMAKE_DOC_TARBALL)
- message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:'")
+ get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME)
+ string(REPLACE ".tar.gz" "-${SCRIPT_NAME}.tar.gz" CMAKE_DOC_TARBALL_STAGED "${CMAKE_DOC_TARBALL_NAME}")
+ message("scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'")
execute_process(COMMAND
- scp ${CMAKE_DOC_TARBALL} ${HOST}:
+ scp ${CMAKE_DOC_TARBALL} ${HOST}:${CMAKE_DOC_TARBALL_STAGED}
RESULT_VARIABLE result)
if(${result} GREATER 0)
- message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:'")
+ message("error sending doc tarball with scp '${CMAKE_DOC_TARBALL}' '${HOST}:${CMAKE_DOC_TARBALL_STAGED}'")
endif()
- get_filename_component(CMAKE_DOC_TARBALL_NAME "${CMAKE_DOC_TARBALL}" NAME)
endif()
# set this so configure file will work from script mode
diff --git a/Utilities/Release/release_cmake.sh.in b/Utilities/Release/release_cmake.sh.in
index f41bda8..76fdb3a 100755
--- a/Utilities/Release/release_cmake.sh.in
+++ b/Utilities/Release/release_cmake.sh.in
@@ -18,7 +18,7 @@ check_exit_value()
CMAKE_DOC_TARBALL=""
if [ ! -z "@CMAKE_DOC_TARBALL_NAME@" ] ; then
CMAKE_DOC_TARBALL=@CMAKE_RELEASE_DIRECTORY@/@CMAKE_DOC_TARBALL_NAME@
- mv "$HOME/@CMAKE_DOC_TARBALL_NAME@" "$CMAKE_DOC_TARBALL"
+ mv "$HOME/@CMAKE_DOC_TARBALL_STAGED@" "$CMAKE_DOC_TARBALL"
check_exit_value $? "mv doc tarball" || exit 1
fi
@@ -155,11 +155,6 @@ done
-# need to add an extra copy thing here
-if [ ! -z "@EXTRA_COPY@" ]; then
- @EXTRA_COPY@
- check_exit_value $? "Extra copy step @EXTRA_COPY@" || exit 1
-fi
echo "End release"
date
echo ""
diff --git a/Utilities/Release/upload_release.cmake b/Utilities/Release/upload_release.cmake
index 9bf3523..5f4da8f 100644
--- a/Utilities/Release/upload_release.cmake
+++ b/Utilities/Release/upload_release.cmake
@@ -1,20 +1,19 @@
set(CTEST_RUN_CURRENT_SCRIPT 0)
-if(NOT DEFINED PROJECT_PREFIX)
- set(PROJECT_PREFIX cmake-)
-endif()
if(NOT VERSION)
- set(VERSION 2.8)
+ set(VERSION 3.0)
+endif()
+if(NOT DEFINED PROJECT_PREFIX)
+ set(PROJECT_PREFIX cmake-${VERSION})
endif()
-set(dir "v${VERSION}")
-if("${VERSION}" MATCHES "master")
- set(dir "dev")
+if(NOT DEFINED DIR)
+ set(DIR "v${VERSION}")
endif()
file(GLOB FILES ${CMAKE_CURRENT_SOURCE_DIR} "${PROJECT_PREFIX}*")
list(SORT FILES)
list(REVERSE FILES)
message("${FILES}")
set(UPLOAD_LOC
- "kitware@www.cmake.org:/projects/FTP/pub/cmake/${dir}")
+ "kitware@www.cmake.org:/projects/FTP/pub/cmake/${DIR}")
set(count 0)
foreach(file ${FILES})
if(NOT IS_DIRECTORY ${file})
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index 23dc6ae..132ce60 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -24,6 +24,7 @@ project(CMakeHelp NONE)
option(SPHINX_MAN "Build man pages with Sphinx" OFF)
option(SPHINX_HTML "Build html help with Sphinx" OFF)
+option(SPHINX_QTHELP "Build Qt help with Sphinx" OFF)
option(SPHINX_TEXT "Build text help with Sphinx (not installed)" OFF)
find_program(SPHINX_EXECUTABLE
NAMES sphinx-build
@@ -32,7 +33,7 @@ find_program(SPHINX_EXECUTABLE
mark_as_advanced(SPHINX_TEXT)
-if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_TEXT)
+if(NOT SPHINX_MAN AND NOT SPHINX_HTML AND NOT SPHINX_QTHELP AND NOT SPHINX_TEXT)
return()
elseif(NOT SPHINX_EXECUTABLE)
message(FATAL_ERROR "SPHINX_EXECUTABLE (sphinx-build) is not found!")
@@ -63,6 +64,30 @@ endif()
if(SPHINX_TEXT)
list(APPEND doc_formats text)
endif()
+if(SPHINX_QTHELP)
+ find_program(QCOLLECTIONGENERATOR_EXECUTABLE
+ NAMES qcollectiongenerator
+ DOC "qcollectiongenerator tool"
+ )
+ if (NOT QCOLLECTIONGENERATOR_EXECUTABLE)
+ message(FATAL_ERROR "QCOLLECTIONGENERATOR_EXECUTABLE (qcollectiongenerator) not found!")
+ endif()
+ list(APPEND doc_formats qthelp)
+
+ set(qthelp_extra_commands
+ # Workaround for assistant prior to
+ # https://codereview.qt-project.org/#change,82250 in Qt 4.
+ COMMAND ${CMAKE_COMMAND} "-DCSS_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/_static"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/apply_qthelp_css_workaround.cmake"
+ # Workaround sphinx configurability:
+ # https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
+ COMMAND ${CMAKE_COMMAND} "-DQTHELP_DIR=${CMAKE_CURRENT_BINARY_DIR}/qthelp/"
+ "-DCMake_VERSION=${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/fixup_qthelp_names.cmake"
+ COMMAND qcollectiongenerator ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake.qhcp
+ )
+endif()
+
set(doc_format_outputs "")
set(doc_format_last "")
@@ -78,6 +103,7 @@ foreach(format ${doc_formats})
${CMake_SOURCE_DIR}/Help
${CMAKE_CURRENT_BINARY_DIR}/${format}
> ${doc_format_log} # log stdout, pass stderr
+ ${${format}_extra_commands}
DEPENDS ${doc_format_last}
COMMENT "sphinx-build ${format}: see Utilities/Sphinx/${doc_format_log}"
VERBATIM
@@ -122,3 +148,8 @@ if(SPHINX_HTML)
PATTERN objects.inv EXCLUDE
)
endif()
+if(SPHINX_QTHELP)
+ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qthelp/CMake-${CMake_VERSION_MAJOR}${CMake_VERSION_MINOR}${CMake_VERSION_PATCH}.qch
+ DESTINATION ${CMAKE_DOC_DIR}
+ )
+endif()
diff --git a/Utilities/Sphinx/apply_qthelp_css_workaround.cmake b/Utilities/Sphinx/apply_qthelp_css_workaround.cmake
new file mode 100644
index 0000000..8b74d12
--- /dev/null
+++ b/Utilities/Sphinx/apply_qthelp_css_workaround.cmake
@@ -0,0 +1,15 @@
+
+file(READ "${CSS_DIR}/basic.css" BasicCssContent)
+
+file(READ "${CSS_DIR}/default.css" DefaultCssContent)
+string(REPLACE
+ "@import url(\"basic.css\")" "${BasicCssContent}"
+ DefaultCssContent "${DefaultCssContent}"
+)
+
+file(READ "${CSS_DIR}/cmake.css" CMakeCssContent)
+string(REPLACE
+ "@import url(\"default.css\")" "${DefaultCssContent}"
+ CMakeCssContent "${CMakeCssContent}"
+)
+file(WRITE "${CSS_DIR}/cmake.css" "${CMakeCssContent}")
diff --git a/Utilities/Sphinx/cmake.py b/Utilities/Sphinx/cmake.py
index 0e8f280..6e6e48a 100644
--- a/Utilities/Sphinx/cmake.py
+++ b/Utilities/Sphinx/cmake.py
@@ -21,6 +21,24 @@ from pygments.lexer import bygroups
CMakeLexer.tokens["args"].append(('(\\$<)(.+?)(>)',
bygroups(Operator, Name.Variable, Operator)))
+# Monkey patch for sphinx generating invalid content for qcollectiongenerator
+# https://bitbucket.org/birkenfeld/sphinx/issue/1435/qthelp-builder-should-htmlescape-keywords
+from sphinx.util.pycompat import htmlescape
+from sphinx.builders.qthelp import QtHelpBuilder
+old_build_keywords = QtHelpBuilder.build_keywords
+def new_build_keywords(self, title, refs, subitems):
+ old_items = old_build_keywords(self, title, refs, subitems)
+ new_items = []
+ for item in old_items:
+ before, rest = item.split("ref=\"", 1)
+ ref, after = rest.split("\"")
+ if ("<" in ref and ">" in ref):
+ new_items.append(before + "ref=\"" + htmlescape(ref) + "\"" + after)
+ else:
+ new_items.append(item)
+ return new_items
+QtHelpBuilder.build_keywords = new_build_keywords
+
from docutils.parsers.rst import Directive, directives
from docutils.transforms import Transform
diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in
index e334389..d81bbcf 100644
--- a/Utilities/Sphinx/conf.py.in
+++ b/Utilities/Sphinx/conf.py.in
@@ -61,3 +61,7 @@ html_theme = 'default'
html_title = 'CMake %s Documentation' % release
html_short_title = '%s Documentation' % release
html_favicon = 'cmake-favicon.ico'
+# Not supported yet by sphinx:
+# https://bitbucket.org/birkenfeld/sphinx/issue/1448/make-qthelp-more-configurable
+# qthelp_namespace = "org.cmake"
+# qthelp_qch_name = "CMake-300.qch"
diff --git a/Utilities/Sphinx/fixup_qthelp_names.cmake b/Utilities/Sphinx/fixup_qthelp_names.cmake
new file mode 100644
index 0000000..e35ef25
--- /dev/null
+++ b/Utilities/Sphinx/fixup_qthelp_names.cmake
@@ -0,0 +1,32 @@
+
+file(READ "${QTHELP_DIR}/CMake.qhcp" QHCP_CONTENT)
+
+string(REPLACE
+ "<homePage>qthelp://org.sphinx.cmake" "<homePage>qthelp://org.cmake"
+ QHCP_CONTENT "${QHCP_CONTENT}"
+)
+string(REPLACE
+ "<startPage>qthelp://org.sphinx.cmake" "<startPage>qthelp://org.cmake"
+ QHCP_CONTENT "${QHCP_CONTENT}"
+)
+
+string(REPLACE
+ "<output>CMake.qch" "<output>CMake-${CMake_VERSION}.qch"
+ QHCP_CONTENT "${QHCP_CONTENT}"
+)
+string(REPLACE
+ "<file>CMake.qch" "<file>CMake-${CMake_VERSION}.qch"
+ QHCP_CONTENT "${QHCP_CONTENT}"
+)
+
+file(WRITE "${QTHELP_DIR}/CMake.qhcp" "${QHCP_CONTENT}")
+
+
+file(READ "${QTHELP_DIR}/CMake.qhp" QHP_CONTENT)
+
+string(REPLACE
+ "<namespace>org.sphinx.cmake" "<namespace>org.cmake"
+ QHP_CONTENT "${QHP_CONTENT}"
+)
+
+file(WRITE "${QTHELP_DIR}/CMake.qhp" "${QHP_CONTENT}")
diff --git a/Utilities/cmcurl/CMakeLists.txt b/Utilities/cmcurl/CMakeLists.txt
index abf04d8..1b918c9 100644
--- a/Utilities/cmcurl/CMakeLists.txt
+++ b/Utilities/cmcurl/CMakeLists.txt
@@ -172,6 +172,11 @@ IF(NOT CURL_SPECIAL_LIBZ)
CHECK_LIBRARY_EXISTS_CONCAT("z" inflateEnd HAVE_LIBZ)
ENDIF(NOT CURL_SPECIAL_LIBZ)
+# Include the local directories before any others so that we do not end up
+# including system curl's include directory first by mistake.
+INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR})
+
OPTION(CMAKE_USE_OPENSSL "Use OpenSSL code with curl." OFF)
MARK_AS_ADVANCED(CMAKE_USE_OPENSSL)
IF(CMAKE_USE_OPENSSL)
@@ -679,8 +684,6 @@ INCLUDE(CMake/OtherTests.cmake)
# The rest of the build
-INCLUDE_DIRECTORIES(${LIBCURL_SOURCE_DIR})
-INCLUDE_DIRECTORIES(${LIBCURL_BINARY_DIR})
OPTION(CMAKE_BUILD_CURL_SHARED "Should curl be built shared" TRUE)
IF(CMAKE_BUILD_CURL_SHARED)
SET(LIBRARY_TYPE SHARED)
diff --git a/Utilities/cmlibarchive/.gitattributes b/Utilities/cmlibarchive/.gitattributes
index be7062b..562b12e 100644
--- a/Utilities/cmlibarchive/.gitattributes
+++ b/Utilities/cmlibarchive/.gitattributes
@@ -1,2 +1 @@
-*.h whitespace=indent-with-non-tab,-blank-at-eol
-*.c whitespace=indent-with-non-tab,-blank-at-eol
+* -whitespace
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 132bfeb..9b1533d 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -28,11 +28,12 @@ STRING(REGEX REPLACE "[0]*([^0]*[0-9])$" "\\1" _trimmed_revision ${_revision})
SET(VERSION "${_major}.${_trimmed_minor}.${_trimmed_revision}${_quality}")
SET(BSDCPIO_VERSION_STRING "${VERSION}")
SET(BSDTAR_VERSION_STRING "${VERSION}")
+SET(BSDCAT_VERSION_STRING "${VERSION}")
SET(LIBARCHIVE_VERSION_NUMBER "${_version_number}")
SET(LIBARCHIVE_VERSION_STRING "${VERSION}")
# INTERFACE_VERSION increments with every release
-# libarchive 2.7 == interface version 9 = 2 + 7
+# libarchive 2.7 == interface version 9 = 2 + 7
# libarchive 2.8 == interface version 10 = 2 + 8
# libarchive 2.9 == interface version 11 = 2 + 9
# libarchive 3.0 == interface version 12
@@ -69,6 +70,13 @@ include(CTest)
OPTION(ENABLE_NETTLE "Enable use of Nettle" ON)
OPTION(ENABLE_OPENSSL "Enable use of OpenSSL" ON)
+OPTION(ENABLE_LZMA "Enable the use of the system found LZMA library if found" ON)
+OPTION(ENABLE_ZLIB "Enable the use of the system found ZLIB library if found" ON)
+OPTION(ENABLE_BZip2 "Enable the use of the system found BZip2 library if found" ON)
+OPTION(ENABLE_EXPAT "Enable the use of the system found EXPAT library if found" ON)
+OPTION(ENABLE_PCREPOSIX "Enable the use of the system found PCREPOSIX library if found" ON)
+OPTION(ENABLE_LibGCC "Enable the use of the system found LibGCC library if found" ON)
+
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
OPTION(ENABLE_ACL "Enable ACL support" ON)
OPTION(ENABLE_ICONV "Enable iconv support" ON)
@@ -190,7 +198,7 @@ IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
#--- zconf.h.orig 2005-07-21 00:40:26.000000000
#+++ zconf.h 2009-01-19 11:39:10.093750000
#@@ -286,7 +286,7 @@
- #
+ #
# #if 1 /* HAVE_UNISTD_H -- this line is updated by ./configure */
# # include <sys/types.h> /* for off_t */
#-# include <unistd.h> /* for SEEK_* and off_t */
@@ -204,7 +212,11 @@ SET(ADDITIONAL_LIBS "")
#
# Find ZLIB
#
-FIND_PACKAGE(ZLIB)
+IF(ENABLE_ZLIB)
+ FIND_PACKAGE(ZLIB)
+ELSE()
+ SET(ZLIB_FOUND FALSE) # Override cached value
+ENDIF()
IF(ZLIB_FOUND)
SET(HAVE_LIBZ 1)
SET(HAVE_ZLIB_H 1)
@@ -239,7 +251,11 @@ ENDIF(ZLIB_FOUND)
#
# Find BZip2
#
-FIND_PACKAGE(BZip2)
+IF(ENABLE_BZip2)
+ FIND_PACKAGE(BZip2)
+ELSE()
+ SET(BZIP2_FOUND FALSE) # Override cached value
+ENDIF()
IF(BZIP2_FOUND)
SET(HAVE_LIBBZ2 1)
SET(HAVE_BZLIB_H 1)
@@ -263,7 +279,13 @@ IF(0) # CMake does not need LZMA or LZO2 support in libarchive
#
# Find LZMA
#
-FIND_PACKAGE(LZMA)
+IF(ENABLE_LZMA)
+ FIND_PACKAGE(LZMA)
+ELSE()
+ SET(LZMA_FOUND FALSE) # Override cached value
+ SET(LZMADEC_FOUND FALSE) # Override cached value
+ENDIF()
+
IF(LZMA_FOUND)
SET(HAVE_LIBLZMA 1)
SET(HAVE_LZMA_H 1)
@@ -283,6 +305,8 @@ ELSEIF(LZMADEC_FOUND)
SET(HAVE_LZMADEC_H 1)
INCLUDE_DIRECTORIES(${LZMADEC_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${LZMADEC_LIBRARIES})
+ELSE(LZMA_FOUND)
+# LZMA not found and will not be used.
ENDIF(LZMA_FOUND)
#
# Find LZO2
@@ -327,7 +351,11 @@ ENDMACRO (LA_CHECK_INCLUDE_FILE)
LA_CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
# Alphabetize the rest unless there's a compelling reason
-LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H)
+IF(ENABLE_ACL)
+ LA_CHECK_INCLUDE_FILE("acl/libacl.h" HAVE_ACL_LIBACL_H)
+ELSE(ENABLE_ACL)
+ SET(HAVE_ACL_LIBACL_H FALSE)
+ENDIF(ENABLE_ACL)
LA_CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H)
LA_CHECK_INCLUDE_FILE("copyfile.h" HAVE_COPYFILE_H)
LA_CHECK_INCLUDE_FILE("direct.h" HAVE_DIRECT_H)
@@ -510,16 +538,10 @@ main(int argc, char **argv)
FILE(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c" "${SOURCE}")
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}")
- IF(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_ADD_LINKER_FLAGS
- "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
- ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_ADD_LINKER_FLAGS)
- ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
TRY_COMPILE(ARCHIVE_CRYPTO_${ALGORITHM}_${IMPLEMENTATION}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/check_crypto_md.c
- CMAKE_FLAGS ${CHECK_CRYPTO_ADD_LINKER_FLAGS}
+ CMAKE_FLAGS
"${TRY_CRYPTO_REQUIRED_LIBS}"
"${TRY_CRYPTO_REQUIRED_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
@@ -604,16 +626,10 @@ main(int argc, char **argv)
FILE(WRITE "${SOURCE_FILE}" "${SOURCE}")
MESSAGE(STATUS "Checking support for ARCHIVE_CRYPTO_${CRYPTO}_WIN")
- IF(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS
- "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS} -DCMAKE_MODULE_LINKER_FLAGS:STRING=${CMAKE_REQUIRED_LINKER_FLAGS}")
- ELSE(CMAKE_REQUIRED_LINKER_FLAGS)
- SET(CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS)
- ENDIF(CMAKE_REQUIRED_LINKER_FLAGS)
TRY_COMPILE(ARCHIVE_CRYPTO_${CRYPTO}_WIN
${CMAKE_BINARY_DIR}
${SOURCE_FILE}
- CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive" ${CHECK_CRYPTO_WIN_ADD_LINKER_FLAGS}
+ CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}/libarchive"
OUTPUT_VARIABLE OUTPUT)
IF (ARCHIVE_CRYPTO_${CRYPTO}_WIN)
@@ -1030,13 +1046,13 @@ CHECK_TYPE_SIZE("unsigned long long" SIZE_OF_UNSIGNED_LONG_LONG)
CHECK_TYPE_SIZE("__int64" __INT64)
CHECK_TYPE_SIZE("unsigned __int64" UNSIGNED___INT64)
-CHECK_TYPE_SIZE(int16_t INT16_T)
+CHECK_TYPE_SIZE(int16_t INT16_T)
CHECK_TYPE_SIZE(int32_t INT32_T)
CHECK_TYPE_SIZE(int64_t INT64_T)
CHECK_TYPE_SIZE(intmax_t INTMAX_T)
-CHECK_TYPE_SIZE(uint8_t UINT8_T)
-CHECK_TYPE_SIZE(uint16_t UINT16_T)
-CHECK_TYPE_SIZE(uint32_t UINT32_T)
+CHECK_TYPE_SIZE(uint8_t UINT8_T)
+CHECK_TYPE_SIZE(uint16_t UINT16_T)
+CHECK_TYPE_SIZE(uint32_t UINT32_T)
CHECK_TYPE_SIZE(uint64_t UINT64_T)
CHECK_TYPE_SIZE(uintmax_t UINTMAX_T)
diff --git a/Utilities/cmlibarchive/README-CMake.txt b/Utilities/cmlibarchive/README-CMake.txt
index ab105f0..8f3b29b 100644
--- a/Utilities/cmlibarchive/README-CMake.txt
+++ b/Utilities/cmlibarchive/README-CMake.txt
@@ -11,7 +11,7 @@ branch, but it is merged into our history.
Update libarchive from upstream as follows. Create a local branch to
explicitly reference the upstream snapshot branch head:
- git branch libarchive-upstream 35df7c8b
+ git branch libarchive-upstream 37f225b7
Use a temporary directory to checkout the branch:
@@ -24,7 +24,7 @@ Use a temporary directory to checkout the branch:
Now place the (reduced) libarchive content in this directory. See
instructions shown by
- git log 35df7c8b
+ git log 37f225b7
for help extracting the content from the upstream svn repo. Then run
the following commands to commit the new version. Substitute the
@@ -34,8 +34,8 @@ appropriate date and version number:
GIT_AUTHOR_NAME='LibArchive Upstream' \
GIT_AUTHOR_EMAIL='libarchive-discuss@googlegroups.com' \
- GIT_AUTHOR_DATE='2013-02-09 12:17:57 -0500' \
- git commit -m 'libarchive 3.1.2 (reduced)' &&
+ GIT_AUTHOR_DATE='Mon Apr 14 19:19:05 2014 -0700' \
+ git commit -m 'libarchive 3.1.2-246-ga5a5d28b (reduced)' &&
git commit --amend
Edit the commit message to describe the procedure used to obtain the
diff --git a/Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake b/Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake
new file mode 100644
index 0000000..f96bbef
--- /dev/null
+++ b/Utilities/cmlibarchive/build/cmake/CreatePkgConfigFile.cmake
@@ -0,0 +1,31 @@
+# - Generate a libarchive.pc like autotools for pkg-config
+#
+
+# Set the required variables (we use the same input file as autotools)
+SET(prefix ${CMAKE_INSTALL_PREFIX})
+SET(exec_prefix \${prefix})
+SET(libdir \${exec_prefix}/lib)
+SET(includedir \${prefix}/include)
+# Now, this is not particularly pretty, nor is it terribly accurate...
+# Loop over all our additional libs
+FOREACH(mylib ${ADDITIONAL_LIBS})
+ # Extract the filename from the absolute path
+ GET_FILENAME_COMPONENT(mylib_name ${mylib} NAME_WE)
+ # Strip the lib prefix
+ STRING(REGEX REPLACE "^lib" "" mylib_name ${mylib_name})
+ # Append it to our LIBS string
+ SET(LIBS "${LIBS} -l${mylib_name}")
+ENDFOREACH()
+# libxml2 is easier, since it's already using pkg-config
+FOREACH(mylib ${PC_LIBXML_STATIC_LDFLAGS})
+ SET(LIBS "${LIBS} ${mylib}")
+ENDFOREACH()
+# FIXME: The order of the libraries doesn't take dependencies into account,
+# thus there's a good chance it'll make some binutils versions unhappy...
+# This only affects Libs.private (looked up for static builds) though.
+CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+ @ONLY)
+# And install it, of course ;).
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/build/pkgconfig/libarchive.pc
+ DESTINATION "lib/pkgconfig")
diff --git a/Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake b/Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake
new file mode 100644
index 0000000..297b886
--- /dev/null
+++ b/Utilities/cmlibarchive/build/cmake/LibarchiveCodeCoverage.cmake
@@ -0,0 +1,68 @@
+#################################################################
+# Adds a build target called "coverage" for code coverage.
+#
+# This compiles the code using special GCC flags, run the tests,
+# and then generates a nice HTML output. This new "coverage" make
+# target will only be available if you build using GCC in Debug
+# mode. If any of the required programs (lcov and genhtml) were
+# not found, a FATAL_ERROR message is printed.
+#
+# If not already done, this code will set ENABLE_TEST to ON.
+#
+# To build the code coverage and open it in your browser do this:
+#
+# mkdir debug
+# cd debug
+# cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_COVERAGE=ON ..
+# make -j4
+# make coverage
+# xdg-open coverage/index.html
+#################################################################
+
+# Find programs we need
+FIND_PROGRAM(LCOV_EXECUTABLE lcov DOC "Full path to lcov executable")
+FIND_PROGRAM(GENHTML_EXECUTABLE genhtml DOC "Full path to genhtml executable")
+MARK_AS_ADVANCED(LCOV_EXECUTABLE GENHTML_EXECUTABLE)
+
+# Check, compiler, build types and programs are available
+IF(NOT CMAKE_COMPILER_IS_GNUCC)
+MESSAGE(FATAL_ERROR "Coverage can only be built on GCC")
+ELSEIF(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+MESSAGE(FATAL_ERROR "Coverage can only be built in Debug mode")
+ELSEIF(NOT LCOV_EXECUTABLE)
+MESSAGE(FATAL_ERROR "lcov executable not found")
+ELSEIF(NOT GENHTML_EXECUTABLE)
+MESSAGE(FATAL_ERROR "genhtml executable not found")
+ENDIF(NOT CMAKE_COMPILER_IS_GNUCC)
+
+# Enable testing if not already done
+SET(ENABLE_TEST ON)
+
+#################################################################
+# Set special compiler and linker flags for test coverage
+#################################################################
+# 0. Enable debug: -g
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g")
+# 1. Disable optimizations: -O0
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
+# 2. Enable all kind of warnings:
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W")
+# 3. Enable special coverage flag (HINT: --coverage is a synonym for -fprofile-arcs -ftest-coverage)
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --coverage")
+SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
+#################################################################
+
+ADD_CUSTOM_TARGET(coverage
+COMMAND ${CMAKE_COMMAND} -E echo "Beginning test coverage. Output is written to coverage.log."
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-1/5: Reset all execution counts to zero"
+COMMAND ${LCOV_EXECUTABLE} --directory . --zerocounters > coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-2/5: Run testrunner"
+COMMAND ${CMAKE_CTEST_COMMAND} >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-3/5: Collect coverage data"
+COMMAND ${LCOV_EXECUTABLE} --capture --directory . --output-file "./coverage.info" >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-4/5: Generate HTML from coverage data"
+COMMAND ${GENHTML_EXECUTABLE} "coverage.info" --title="libarchive-${LIBARCHIVE_VERSION_STRING}" --show-details --legend --output-directory "./coverage" >> coverage.log 2>&1
+COMMAND ${CMAKE_COMMAND} -E echo "COVERAGE-STEP-5/5: Open test coverage HTML output in browser: xdg-open ./coverage/index.html"
+COMMENT "Runs testrunner and generates coverage output (formats: .info and .html)")
+
diff --git a/Utilities/cmlibarchive/build/cmake/config.h.in b/Utilities/cmlibarchive/build/cmake/config.h.in
index 750ae66..32a29d0 100644
--- a/Utilities/cmlibarchive/build/cmake/config.h.in
+++ b/Utilities/cmlibarchive/build/cmake/config.h.in
@@ -292,6 +292,9 @@ typedef uint64_t uintmax_t;
/* Version number of bsdtar */
#cmakedefine BSDTAR_VERSION_STRING "${BSDTAR_VERSION_STRING}"
+/* Version number of bsdcat */
+#cmakedefine BSDCAT_VERSION_STRING "${BSDCAT_VERSION_STRING}"
+
/* Define to 1 if you have the `acl_create_entry' function. */
#cmakedefine HAVE_ACL_CREATE_ENTRY 1
@@ -1112,8 +1115,13 @@ typedef uint64_t uintmax_t;
#cmakedefine _LARGE_FILES ${_LARGE_FILES}
/* Define for Windows to use Windows 2000+ APIs. */
+#ifndef _WIN32_WINNT
#cmakedefine _WIN32_WINNT ${_WIN32_WINNT}
+#endif // _WIN32_WINNT
+
+#ifndef WINVER
#cmakedefine WINVER ${WINVER}
+#endif // WINVER
/* Define to empty if `const' does not conform to ANSI C. */
#cmakedefine const ${const}
diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
index 42781bc..8908a62 100644
--- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
@@ -35,6 +35,8 @@ SET(libarchive_SOURCES
archive_match.c
archive_options.c
archive_options_private.h
+ archive_pack_dev.h
+ archive_pack_dev.c
archive_pathmatch.c
archive_pathmatch.h
archive_platform.h
@@ -52,6 +54,7 @@ SET(libarchive_SOURCES
archive_read_disk_private.h
archive_read_disk_set_standard_lookup.c
archive_read_extract.c
+ archive_read_extract2.c
archive_read_open_fd.c
archive_read_open_file.c
archive_read_open_filename.c
@@ -125,6 +128,7 @@ SET(libarchive_SOURCES
archive_write_set_format_iso9660.c
archive_write_set_format_mtree.c
archive_write_set_format_pax.c
+ archive_write_set_format_raw.c
archive_write_set_format_shar.c
archive_write_set_format_ustar.c
archive_write_set_format_v7tar.c
diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h
index 1a1d32a..9cf762d 100644
--- a/Utilities/cmlibarchive/libarchive/archive.h
+++ b/Utilities/cmlibarchive/libarchive/archive.h
@@ -54,7 +54,7 @@
/* Get appropriate definitions of standard POSIX-style types. */
/* These should match the types used in 'struct stat' */
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
# define __LA_INT64_T __int64
# if defined(_SSIZE_T_DEFINED) || defined(_SSIZE_T_)
# define __LA_SSIZE_T ssize_t
@@ -137,6 +137,11 @@ __LA_DECL int archive_version_number(void);
#define ARCHIVE_VERSION_STRING "libarchive 3.1.2"
__LA_DECL const char * archive_version_string(void);
+/*
+ * Detailed textual name/version of the library and its dependencies.
+ */
+__LA_DECL const char * archive_version_details(void);
+
/* Declare our basic types. */
struct archive;
struct archive_entry;
@@ -289,6 +294,30 @@ typedef int archive_switch_callback(struct archive *, void *_client_data1,
#define ARCHIVE_FORMAT_RAR 0xD0000
#define ARCHIVE_FORMAT_7ZIP 0xE0000
+/*
+ * Codes returned by archive_read_format_capabilities().
+ *
+ * This list can be extended with values between 0 and 0xffff.
+ * The original purpose of this list was to let different archive
+ * format readers expose their general capabilities in terms of
+ * encryption.
+ */
+#define ARCHIVE_READ_FORMAT_CAPS_NONE (0) /* no special capabilities */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA (1<<0) /* reader can detect encrypted data */
+#define ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA (1<<1) /* reader can detect encryptable metadata (pathname, mtime, etc.) */
+
+/*
+ * Codes returned by archive_read_has_encrypted_entries().
+ *
+ * In case the archive does not support encryption detection at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned. If the reader
+ * for some other reason (e.g. not enough bytes read) cannot say if
+ * there are encrypted entries, ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW
+ * is returned.
+ */
+#define ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED -2
+#define ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW -1
+
/*-
* Basic outline for reading an archive:
* 1) Ask archive_read_new for an archive reader object.
@@ -374,7 +403,15 @@ __LA_DECL int archive_read_support_format_rar(struct archive *);
__LA_DECL int archive_read_support_format_raw(struct archive *);
__LA_DECL int archive_read_support_format_tar(struct archive *);
__LA_DECL int archive_read_support_format_xar(struct archive *);
+/* archive_read_support_format_zip() enables both streamable and seekable
+ * zip readers. */
__LA_DECL int archive_read_support_format_zip(struct archive *);
+/* Reads Zip archives as stream from beginning to end. Doesn't
+ * correctly handle SFX ZIP files or ZIP archives that have been modified
+ * in-place. */
+__LA_DECL int archive_read_support_format_zip_streamable(struct archive *);
+/* Reads starting from central directory; requires seekable input. */
+__LA_DECL int archive_read_support_format_zip_seekable(struct archive *);
/* Functions to manually set the format and filters to be used. This is
* useful to bypass the bidding process when the format and filters to use
@@ -470,6 +507,32 @@ __LA_DECL int archive_read_next_header2(struct archive *,
*/
__LA_DECL __LA_INT64_T archive_read_header_position(struct archive *);
+/*
+ * Returns 1 if the archive contains at least one encrypted entry.
+ * If the archive format not support encryption at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
+ * If for any other reason (e.g. not enough data read so far)
+ * we cannot say whether there are encrypted entries, then
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
+ * In general, this function will return values below zero when the
+ * reader is uncertain or totally uncapable of encryption support.
+ * When this function returns 0 you can be sure that the reader
+ * supports encryption detection but no encrypted entries have
+ * been found yet.
+ *
+ * NOTE: If the metadata/header of an archive is also encrypted, you
+ * cannot rely on the number of encrypted entries. That is why this
+ * function does not return the number of encrypted entries but#
+ * just shows that there are some.
+ */
+__LA_DECL int archive_read_has_encrypted_entries(struct archive *);
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+__LA_DECL int archive_read_format_capabilities(struct archive *);
+
/* Read data from the body of an entry. Similar to read(2). */
__LA_DECL __LA_SSIZE_T archive_read_data(struct archive *,
void *, size_t);
@@ -674,6 +737,7 @@ __LA_DECL int archive_write_set_format_mtree_classic(struct archive *);
/* TODO: int archive_write_set_format_old_tar(struct archive *); */
__LA_DECL int archive_write_set_format_pax(struct archive *);
__LA_DECL int archive_write_set_format_pax_restricted(struct archive *);
+__LA_DECL int archive_write_set_format_raw(struct archive *);
__LA_DECL int archive_write_set_format_shar(struct archive *);
__LA_DECL int archive_write_set_format_shar_dump(struct archive *);
__LA_DECL int archive_write_set_format_ustar(struct archive *);
@@ -883,6 +947,10 @@ __LA_DECL int archive_read_disk_set_metadata_filter_callback(struct archive *,
int (*_metadata_filter_func)(struct archive *, void *,
struct archive_entry *), void *_client_data);
+/* Simplified cleanup interface;
+ * This calls archive_read_free() or archive_write_free() as needed. */
+__LA_DECL int archive_free(struct archive *);
+
/*
* Accessor functions to read/set various information in
* the struct archive object:
@@ -1029,6 +1097,10 @@ __LA_DECL int archive_match_include_gname(struct archive *, const char *);
__LA_DECL int archive_match_include_gname_w(struct archive *,
const wchar_t *);
+/* Utility functions */
+/* Convenience function to sort a NULL terminated list of strings */
+__LA_DECL int archive_utility_string_sort(char **);
+
#ifdef __cplusplus
}
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.c b/Utilities/cmlibarchive/libarchive/archive_entry.c
index 386e51d..293c701 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.c
@@ -201,6 +201,9 @@ archive_entry_clone(struct archive_entry *entry)
entry2->ae_set = entry->ae_set;
archive_mstring_copy(&entry2->ae_uname, &entry->ae_uname);
+ /* Copy encryption status */
+ entry2->encryption = entry->encryption;
+
/* Copy ACL data over. */
archive_acl_copy(&entry2->acl, &entry->acl);
@@ -695,6 +698,24 @@ _archive_entry_uname_l(struct archive_entry *entry,
return (archive_mstring_get_mbs_l(&entry->ae_uname, p, len, sc));
}
+int
+archive_entry_is_data_encrypted(struct archive_entry *entry)
+{
+ return ((entry->encryption & AE_ENCRYPTION_DATA) == AE_ENCRYPTION_DATA);
+}
+
+int
+archive_entry_is_metadata_encrypted(struct archive_entry *entry)
+{
+ return ((entry->encryption & AE_ENCRYPTION_METADATA) == AE_ENCRYPTION_METADATA);
+}
+
+int
+archive_entry_is_encrypted(struct archive_entry *entry)
+{
+ return (entry->encryption & (AE_ENCRYPTION_DATA|AE_ENCRYPTION_METADATA));
+}
+
/*
* Functions to set archive_entry properties.
*/
@@ -1216,6 +1237,26 @@ archive_entry_update_uname_utf8(struct archive_entry *entry, const char *name)
return (0);
}
+void
+archive_entry_set_is_data_encrypted(struct archive_entry *entry, char is_encrypted)
+{
+ if (is_encrypted) {
+ entry->encryption |= AE_ENCRYPTION_DATA;
+ } else {
+ entry->encryption &= ~AE_ENCRYPTION_DATA;
+ }
+}
+
+void
+archive_entry_set_is_metadata_encrypted(struct archive_entry *entry, char is_encrypted)
+{
+ if (is_encrypted) {
+ entry->encryption |= AE_ENCRYPTION_METADATA;
+ } else {
+ entry->encryption &= ~AE_ENCRYPTION_METADATA;
+ }
+}
+
int
_archive_entry_copy_uname_l(struct archive_entry *entry,
const char *name, size_t len, struct archive_string_conv *sc)
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h
index 85ea885..efc4d73 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.h
@@ -43,12 +43,8 @@
#include <stddef.h> /* for wchar_t */
#include <time.h>
-#if defined(_WIN32) && !defined(__CYGWIN__)
-#include <windows.h>
-#endif
-
/* Get a suitable 64-bit integer type. */
-#if defined(_WIN32) && !defined(__CYGWIN__)
+#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__WATCOMC__)
# define __LA_INT64_T __int64
#else
#include <unistd.h>
@@ -63,7 +59,7 @@
#if ARCHIVE_VERSION_NUMBER >= 3999000
/* Switch to plain 'int' for libarchive 4.0. It's less broken than 'mode_t' */
# define __LA_MODE_T int
-#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__)
+#elif defined(_WIN32) && !defined(__CYGWIN__) && !defined(__BORLANDC__) && !defined(__WATCOMC__)
# define __LA_MODE_T unsigned short
#else
# define __LA_MODE_T mode_t
@@ -235,6 +231,9 @@ __LA_DECL const wchar_t *archive_entry_symlink_w(struct archive_entry *);
__LA_DECL __LA_INT64_T archive_entry_uid(struct archive_entry *);
__LA_DECL const char *archive_entry_uname(struct archive_entry *);
__LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
+__LA_DECL int archive_entry_is_data_encrypted(struct archive_entry *);
+__LA_DECL int archive_entry_is_metadata_encrypted(struct archive_entry *);
+__LA_DECL int archive_entry_is_encrypted(struct archive_entry *);
/*
* Set fields in an archive_entry.
@@ -248,7 +247,7 @@ __LA_DECL const wchar_t *archive_entry_uname_w(struct archive_entry *);
__LA_DECL void archive_entry_set_atime(struct archive_entry *, time_t, long);
__LA_DECL void archive_entry_unset_atime(struct archive_entry *);
#if defined(_WIN32) && !defined(__CYGWIN__)
-__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, BY_HANDLE_FILE_INFORMATION *);
+__LA_DECL void archive_entry_copy_bhfi(struct archive_entry *, struct _BY_HANDLE_FILE_INFORMATION *);
#endif
__LA_DECL void archive_entry_set_birthtime(struct archive_entry *, time_t, long);
__LA_DECL void archive_entry_unset_birthtime(struct archive_entry *);
@@ -306,6 +305,8 @@ __LA_DECL void archive_entry_set_uname(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_uname(struct archive_entry *, const char *);
__LA_DECL void archive_entry_copy_uname_w(struct archive_entry *, const wchar_t *);
__LA_DECL int archive_entry_update_uname_utf8(struct archive_entry *, const char *);
+__LA_DECL void archive_entry_set_is_data_encrypted(struct archive_entry *, char is_encrypted);
+__LA_DECL void archive_entry_set_is_metadata_encrypted(struct archive_entry *, char is_encrypted);
/*
* Routines to bulk copy fields to/from a platform-native "struct
* stat." Libarchive used to just store a struct stat inside of each
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_private.h b/Utilities/cmlibarchive/libarchive/archive_entry_private.h
index e3547c3..c69233e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_private.h
@@ -154,6 +154,11 @@ struct archive_entry {
/* Not used within libarchive; useful for some clients. */
struct archive_mstring ae_sourcepath; /* Path this entry is sourced from. */
+#define AE_ENCRYPTION_NONE 0
+#define AE_ENCRYPTION_DATA 1
+#define AE_ENCRYPTION_METADATA 2
+ char encryption;
+
void *mac_metadata;
size_t mac_metadata_size;
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
index 10c5447..fed74f5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
+++ b/Utilities/cmlibarchive/libarchive/archive_entry_sparse.c
@@ -58,7 +58,7 @@ archive_entry_sparse_add_entry(struct archive_entry *entry,
if (offset < 0 || length < 0)
/* Invalid value */
return;
- if (offset + length < 0 ||
+ if (offset > INT64_MAX - length ||
offset + length > archive_entry_size(entry))
/* A value of "length" parameter is too large. */
return;
diff --git a/Utilities/cmlibarchive/libarchive/archive_getdate.c b/Utilities/cmlibarchive/libarchive/archive_getdate.c
index f8b5a28..aaa9d6f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_getdate.c
+++ b/Utilities/cmlibarchive/libarchive/archive_getdate.c
@@ -369,8 +369,8 @@ relunitphrase(struct gdstate *gds)
&& gds->tokenp[1].token == tSEC_UNIT) {
/* "1 day" */
gds->HaveRel++;
- gds->RelSeconds += gds->tokenp[1].value * gds->tokenp[2].value;
- gds->tokenp += 3;
+ gds->RelSeconds += gds->tokenp[0].value * gds->tokenp[1].value;
+ gds->tokenp += 2;
return 1;
}
if (gds->tokenp[0].token == '-'
@@ -403,7 +403,7 @@ relunitphrase(struct gdstate *gds)
/* "now", "tomorrow" */
gds->HaveRel++;
gds->RelSeconds += gds->tokenp[0].value;
- ++gds->tokenp;
+ gds->tokenp += 1;
return 1;
}
if (gds->tokenp[0].token == tMONTH_UNIT) {
@@ -1022,10 +1022,11 @@ int
main(int argc, char **argv)
{
time_t d;
+ time_t now = time(NULL);
while (*++argv != NULL) {
(void)printf("Input: %s\n", *argv);
- d = get_date(*argv);
+ d = get_date(now, *argv);
if (d == -1)
(void)printf("Bad format - couldn't convert.\n");
else
diff --git a/Utilities/cmlibarchive/libarchive/archive_match.c b/Utilities/cmlibarchive/libarchive/archive_match.c
index 6b6be9c..6fb8644 100644
--- a/Utilities/cmlibarchive/libarchive/archive_match.c
+++ b/Utilities/cmlibarchive/libarchive/archive_match.c
@@ -1152,7 +1152,7 @@ set_timefilter_pathname_mbs(struct archive_match *a, int timetype,
{
/* NOTE: stat() on Windows cannot handle nano seconds. */
HANDLE h;
- WIN32_FIND_DATA d;
+ WIN32_FIND_DATAA d;
if (path == NULL || *path == '\0') {
archive_set_error(&(a->archive), EINVAL, "pathname is empty");
diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
new file mode 100644
index 0000000..6b7b472
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
@@ -0,0 +1,329 @@
+/* $NetBSD: pack_dev.c,v 1.12 2013/06/14 16:28:20 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Originally from NetBSD's mknod(8) source. */
+
+#include "archive_platform.h"
+
+#if HAVE_SYS_CDEFS_H
+#include <sys/cdefs.h>
+#endif
+#if !defined(lint)
+__RCSID("$NetBSD$");
+#endif /* not lint */
+
+#ifdef HAVE_LIMITS_H
+#include <limits.h>
+#endif
+
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include "archive_pack_dev.h"
+
+static pack_t pack_netbsd;
+static pack_t pack_freebsd;
+static pack_t pack_8_8;
+static pack_t pack_12_20;
+static pack_t pack_14_18;
+static pack_t pack_8_24;
+static pack_t pack_bsdos;
+static int compare_format(const void *, const void *);
+
+static const char iMajorError[] = "invalid major number";
+static const char iMinorError[] = "invalid minor number";
+static const char tooManyFields[] = "too many fields for format";
+
+/* This is blatantly stolen from libarchive/archive_entry.c,
+ * in an attempt to get this to play nice on MinGW... */
+#if !defined(HAVE_MAJOR) && !defined(major)
+/* Replacement for major/minor/makedev. */
+#define major(x) ((int)(0x00ff & ((x) >> 8)))
+#define minor(x) ((int)(0xffff00ff & (x)))
+#define makedev(maj,min) ((0xff00 & ((maj)<<8)) | (0xffff00ff & (min)))
+#endif
+
+/* Play games to come up with a suitable makedev() definition. */
+#ifdef __QNXNTO__
+/* QNX. <sigh> */
+#include <sys/netmgr.h>
+#define apd_makedev(maj, min) makedev(ND_LOCAL_NODE, (maj), (min))
+#elif defined makedev
+/* There's a "makedev" macro. */
+#define apd_makedev(maj, min) makedev((maj), (min))
+#elif defined mkdev || ((defined _WIN32 || defined __WIN32__) && !defined(__CYGWIN__))
+/* Windows. <sigh> */
+#define apd_makedev(maj, min) mkdev((maj), (min))
+#else
+/* There's a "makedev" function. */
+#define apd_makedev(maj, min) makedev((maj), (min))
+#endif
+
+/* exported */
+dev_t
+pack_native(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = apd_makedev(numbers[0], numbers[1]);
+ if ((unsigned long)major(dev) != numbers[0])
+ *error = iMajorError;
+ else if ((unsigned long)minor(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+static dev_t
+pack_netbsd(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_netbsd(numbers[0], numbers[1]);
+ if ((unsigned long)major_netbsd(dev) != numbers[0])
+ *error = iMajorError;
+ else if ((unsigned long)minor_netbsd(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+#define major_freebsd(x) ((int32_t)(((x) & 0x0000ff00) >> 8))
+#define minor_freebsd(x) ((int32_t)(((x) & 0xffff00ff) >> 0))
+#define makedev_freebsd(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \
+ (((y) << 0) & 0xffff00ff)))
+
+static dev_t
+pack_freebsd(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_freebsd(numbers[0], numbers[1]);
+ if ((unsigned long)major_freebsd(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)minor_freebsd(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+#define major_8_8(x) ((int32_t)(((x) & 0x0000ff00) >> 8))
+#define minor_8_8(x) ((int32_t)(((x) & 0x000000ff) >> 0))
+#define makedev_8_8(x,y) ((dev_t)((((x) << 8) & 0x0000ff00) | \
+ (((y) << 0) & 0x000000ff)))
+
+static dev_t
+pack_8_8(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_8_8(numbers[0], numbers[1]);
+ if ((unsigned long)major_8_8(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)minor_8_8(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+#define major_12_20(x) ((int32_t)(((x) & 0xfff00000) >> 20))
+#define minor_12_20(x) ((int32_t)(((x) & 0x000fffff) >> 0))
+#define makedev_12_20(x,y) ((dev_t)((((x) << 20) & 0xfff00000) | \
+ (((y) << 0) & 0x000fffff)))
+
+static dev_t
+pack_12_20(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_12_20(numbers[0], numbers[1]);
+ if ((unsigned long)major_12_20(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)minor_12_20(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+#define major_14_18(x) ((int32_t)(((x) & 0xfffc0000) >> 18))
+#define minor_14_18(x) ((int32_t)(((x) & 0x0003ffff) >> 0))
+#define makedev_14_18(x,y) ((dev_t)((((x) << 18) & 0xfffc0000) | \
+ (((y) << 0) & 0x0003ffff)))
+
+static dev_t
+pack_14_18(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_14_18(numbers[0], numbers[1]);
+ if ((unsigned long)major_14_18(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)minor_14_18(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+#define major_8_24(x) ((int32_t)(((x) & 0xff000000) >> 24))
+#define minor_8_24(x) ((int32_t)(((x) & 0x00ffffff) >> 0))
+#define makedev_8_24(x,y) ((dev_t)((((x) << 24) & 0xff000000) | \
+ (((y) << 0) & 0x00ffffff)))
+
+static dev_t
+pack_8_24(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_8_24(numbers[0], numbers[1]);
+ if ((unsigned long)major_8_24(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)minor_8_24(dev) != numbers[1])
+ *error = iMinorError;
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+#define major_12_12_8(x) ((int32_t)(((x) & 0xfff00000) >> 20))
+#define unit_12_12_8(x) ((int32_t)(((x) & 0x000fff00) >> 8))
+#define subunit_12_12_8(x) ((int32_t)(((x) & 0x000000ff) >> 0))
+#define makedev_12_12_8(x,y,z) ((dev_t)((((x) << 20) & 0xfff00000) | \
+ (((y) << 8) & 0x000fff00) | \
+ (((z) << 0) & 0x000000ff)))
+
+static dev_t
+pack_bsdos(int n, unsigned long numbers[], const char **error)
+{
+ dev_t dev = 0;
+
+ if (n == 2) {
+ dev = makedev_12_20(numbers[0], numbers[1]);
+ if ((unsigned long)major_12_20(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)minor_12_20(dev) != numbers[1])
+ *error = iMinorError;
+ } else if (n == 3) {
+ dev = makedev_12_12_8(numbers[0], numbers[1], numbers[2]);
+ if ((unsigned long)major_12_12_8(dev) != numbers[0])
+ *error = iMajorError;
+ if ((unsigned long)unit_12_12_8(dev) != numbers[1])
+ *error = "invalid unit number";
+ if ((unsigned long)subunit_12_12_8(dev) != numbers[2])
+ *error = "invalid subunit number";
+ } else
+ *error = tooManyFields;
+ return (dev);
+}
+
+
+ /* list of formats and pack functions */
+ /* this list must be sorted lexically */
+static struct format {
+ const char *name;
+ pack_t *pack;
+} formats[] = {
+ {"386bsd", pack_8_8},
+ {"4bsd", pack_8_8},
+ {"bsdos", pack_bsdos},
+ {"freebsd", pack_freebsd},
+ {"hpux", pack_8_24},
+ {"isc", pack_8_8},
+ {"linux", pack_8_8},
+ {"native", pack_native},
+ {"netbsd", pack_netbsd},
+ {"osf1", pack_12_20},
+ {"sco", pack_8_8},
+ {"solaris", pack_14_18},
+ {"sunos", pack_8_8},
+ {"svr3", pack_8_8},
+ {"svr4", pack_14_18},
+ {"ultrix", pack_8_8},
+};
+
+static int
+compare_format(const void *key, const void *element)
+{
+ const char *name;
+ const struct format *format;
+
+ name = key;
+ format = element;
+
+ return (strcmp(name, format->name));
+}
+
+
+pack_t *
+pack_find(const char *name)
+{
+ struct format *format;
+
+ format = bsearch(name, formats,
+ sizeof(formats)/sizeof(formats[0]),
+ sizeof(formats[0]), compare_format);
+ if (format == 0)
+ return (NULL);
+ return (format->pack);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.h b/Utilities/cmlibarchive/libarchive/archive_pack_dev.h
new file mode 100644
index 0000000..749fd3d
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.h
@@ -0,0 +1,49 @@
+/* $NetBSD: pack_dev.h,v 1.8 2013/06/14 16:28:20 tsutsui Exp $ */
+
+/*-
+ * Copyright (c) 1998, 2001 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/* Originally from NetBSD's mknod(8) source. */
+
+#ifndef _PACK_DEV_H
+#define _PACK_DEV_H
+
+typedef dev_t pack_t(int, unsigned long [], const char **);
+
+pack_t *pack_find(const char *);
+pack_t pack_native;
+
+#define major_netbsd(x) ((int32_t)((((x) & 0x000fff00) >> 8)))
+#define minor_netbsd(x) ((int32_t)((((x) & 0xfff00000) >> 12) | \
+ (((x) & 0x000000ff) >> 0)))
+#define makedev_netbsd(x,y) ((dev_t)((((x) << 8) & 0x000fff00) | \
+ (((y) << 12) & 0xfff00000) | \
+ (((y) << 0) & 0x000000ff)))
+
+#endif /* _PACK_DEV_H */
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform.h b/Utilities/cmlibarchive/libarchive/archive_platform.h
index cdd9c7c..cbe08ec 100644
--- a/Utilities/cmlibarchive/libarchive/archive_platform.h
+++ b/Utilities/cmlibarchive/libarchive/archive_platform.h
@@ -66,15 +66,18 @@
* headers as required.
*/
-/* Get a real definition for __FBSDID if we can */
+/* Get a real definition for __FBSDID or __RCSID if we can */
#if HAVE_SYS_CDEFS_H
#include <sys/cdefs.h>
#endif
-/* If not, define it so as to avoid dangling semicolons. */
+/* If not, define them so as to avoid dangling semicolons. */
#ifndef __FBSDID
#define __FBSDID(a) struct _undefined_hack
#endif
+#ifndef __RCSID
+#define __RCSID(a) struct _undefined_hack
+#endif
/* Old glibc mbsnrtowcs fails assertions in our use case. */
#if defined(__GLIBC__) && __GLIBC__ == 2 && __GLIBC_MINOR__ <= 1
diff --git a/Utilities/cmlibarchive/libarchive/archive_read.c b/Utilities/cmlibarchive/libarchive/archive_read.c
index 796d37d..a65b94d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read.c
@@ -747,6 +747,59 @@ archive_read_header_position(struct archive *_a)
}
/*
+ * Returns 1 if the archive contains at least one encrypted entry.
+ * If the archive format not support encryption at all
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED is returned.
+ * If for any other reason (e.g. not enough data read so far)
+ * we cannot say whether there are encrypted entries, then
+ * ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW is returned.
+ * In general, this function will return values below zero when the
+ * reader is uncertain or totally uncapable of encryption support.
+ * When this function returns 0 you can be sure that the reader
+ * supports encryption detection but no encrypted entries have
+ * been found yet.
+ *
+ * NOTE: If the metadata/header of an archive is also encrypted, you
+ * cannot rely on the number of encrypted entries. That is why this
+ * function does not return the number of encrypted entries but#
+ * just shows that there are some.
+ */
+int
+archive_read_has_encrypted_entries(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ int format_supports_encryption = archive_read_format_capabilities(_a)
+ & (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+
+ if (!_a || !format_supports_encryption) {
+ /* Format in general doesn't support encryption */
+ return ARCHIVE_READ_FORMAT_ENCRYPTION_UNSUPPORTED;
+ }
+
+ /* A reader potentially has read enough data now. */
+ if (a->format && a->format->has_encrypted_entries) {
+ return (a->format->has_encrypted_entries)(a);
+ }
+
+ /* For any other reason we cannot say how many entries are there. */
+ return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+/*
+ * Returns a bitmask of capabilities that are supported by the archive format reader.
+ * If the reader has no special capabilities, ARCHIVE_READ_FORMAT_CAPS_NONE is returned.
+ */
+int
+archive_read_format_capabilities(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ if (a && a->format && a->format->format_capabilties) {
+ return (a->format->format_capabilties)(a);
+ }
+ return ARCHIVE_READ_FORMAT_CAPS_NONE;
+}
+
+/*
* Read data from an archive entry, using a read(2)-style interface.
* This is a convenience routine that just calls
* archive_read_data_block and copies the results into the client
@@ -1094,7 +1147,9 @@ __archive_read_register_format(struct archive_read *a,
int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
int (*read_data_skip)(struct archive_read *),
int64_t (*seek_data)(struct archive_read *, int64_t, int),
- int (*cleanup)(struct archive_read *))
+ int (*cleanup)(struct archive_read *),
+ int (*format_capabilities)(struct archive_read *),
+ int (*has_encrypted_entries)(struct archive_read *))
{
int i, number_slots;
@@ -1117,6 +1172,8 @@ __archive_read_register_format(struct archive_read *a,
a->formats[i].cleanup = cleanup;
a->formats[i].data = format_data;
a->formats[i].name = name;
+ a->formats[i].format_capabilties = format_capabilities;
+ a->formats[i].has_encrypted_entries = has_encrypted_entries;
return (ARCHIVE_OK);
}
}
@@ -1557,10 +1614,9 @@ __archive_read_filter_seek(struct archive_read_filter *filter, int64_t offset,
client->dataset[++cursor].begin_position = r;
}
offset -= client->dataset[cursor].begin_position;
- if (offset < 0)
- offset = 0;
- else if (offset > client->dataset[cursor].total_size - 1)
- offset = client->dataset[cursor].total_size - 1;
+ if (offset < 0
+ || offset > client->dataset[cursor].total_size)
+ return ARCHIVE_FATAL;
if ((r = client_seek_proxy(filter, offset, SEEK_SET)) < 0)
return r;
break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
index e984aaa..e81cbec 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -399,7 +399,7 @@ setup_mac_metadata(struct archive_read_disk *a,
#endif
-#if defined(HAVE_POSIX_ACL) && defined(ACL_TYPE_NFS4)
+#ifdef HAVE_POSIX_ACL
static int translate_acl(struct archive_read_disk *a,
struct archive_entry *entry, acl_t acl, int archive_entry_acl_type);
@@ -419,6 +419,7 @@ setup_acls(struct archive_read_disk *a,
archive_entry_acl_clear(entry);
+#ifdef ACL_TYPE_NFS4
/* Try NFS4 ACL first. */
if (*fd >= 0)
acl = acl_get_fd(*fd);
@@ -447,6 +448,7 @@ setup_acls(struct archive_read_disk *a,
acl_free(acl);
return (ARCHIVE_OK);
}
+#endif
/* Retrieve access ACL from file. */
if (*fd >= 0)
@@ -492,6 +494,7 @@ static struct {
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
{ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+#ifdef ACL_TYPE_NFS4
{ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
@@ -508,8 +511,10 @@ static struct {
{ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#endif
};
+#ifdef ACL_TYPE_NFS4
static struct {
int archive_inherit;
int platform_inherit;
@@ -519,21 +524,25 @@ static struct {
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}
};
-
+#endif
static int
translate_acl(struct archive_read_disk *a,
struct archive_entry *entry, acl_t acl, int default_entry_acl_type)
{
acl_tag_t acl_tag;
+#ifdef ACL_TYPE_NFS4
acl_entry_type_t acl_type;
acl_flagset_t acl_flagset;
+ int brand, r;
+#endif
acl_entry_t acl_entry;
acl_permset_t acl_permset;
- int brand, i, r, entry_acl_type;
+ int i, entry_acl_type;
int s, ae_id, ae_tag, ae_perm;
const char *ae_name;
+#ifdef ACL_TYPE_NFS4
// FreeBSD "brands" ACLs as POSIX.1e or NFSv4
// Make sure the "brand" on this ACL is consistent
// with the default_entry_acl_type bits provided.
@@ -560,6 +569,7 @@ translate_acl(struct archive_read_disk *a,
return ARCHIVE_FAILED;
break;
}
+#endif
s = acl_get_entry(acl, ACL_FIRST_ENTRY, &acl_entry);
@@ -592,9 +602,11 @@ translate_acl(struct archive_read_disk *a,
case ACL_OTHER:
ae_tag = ARCHIVE_ENTRY_ACL_OTHER;
break;
+#ifdef ACL_TYPE_NFS4
case ACL_EVERYONE:
ae_tag = ARCHIVE_ENTRY_ACL_EVERYONE;
break;
+#endif
default:
/* Skip types that libarchive can't support. */
s = acl_get_entry(acl, ACL_NEXT_ENTRY, &acl_entry);
@@ -605,6 +617,7 @@ translate_acl(struct archive_read_disk *a,
// XXX acl_get_entry_type_np on FreeBSD returns EINVAL for
// non-NFSv4 ACLs
entry_acl_type = default_entry_acl_type;
+#ifdef ACL_TYPE_NFS4
r = acl_get_entry_type_np(acl_entry, &acl_type);
if (r == 0) {
switch (acl_type) {
@@ -634,9 +647,10 @@ translate_acl(struct archive_read_disk *a,
ae_perm |= acl_inherit_map[i].archive_inherit;
}
+#endif
acl_get_permset(acl_entry, &acl_permset);
- for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
+ for (i = 0; i < (int)(sizeof(acl_perm_map) / sizeof(acl_perm_map[0])); ++i) {
/*
* acl_get_perm() is spelled differently on different
* platforms; see above.
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
index a13dbbf..94eb5e7 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
@@ -1973,7 +1973,7 @@ tree_dup(int fd)
static volatile int can_dupfd_cloexec = 1;
if (can_dupfd_cloexec) {
- new_fd = fcntl(fd, F_DUPFD_CLOEXEC);
+ new_fd = fcntl(fd, F_DUPFD_CLOEXEC, 0);
if (new_fd != -1)
return (new_fd);
/* Linux 2.6.18 - 2.6.23 declare F_DUPFD_CLOEXEC,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
index 9c5420d..5c0f366 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
@@ -929,7 +929,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
else
flags |= FILE_FLAG_SEQUENTIAL_SCAN;
t->entry_fh = CreateFileW(tree_current_access_path(t),
- GENERIC_READ, 0, NULL, OPEN_EXISTING, flags, NULL);
+ GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, flags, NULL);
if (t->entry_fh == INVALID_HANDLE_VALUE) {
archive_set_error(&a->archive, errno,
"Couldn't open %ls", tree_current_path(a->tree));
@@ -1886,7 +1886,7 @@ tree_current_file_information(struct tree *t, BY_HANDLE_FILE_INFORMATION *st,
if (sim_lstat && tree_current_is_physical_link(t))
flag |= FILE_FLAG_OPEN_REPARSE_POINT;
- h = CreateFileW(tree_current_access_path(t), 0, 0, NULL,
+ h = CreateFileW(tree_current_access_path(t), 0, FILE_SHARE_READ, NULL,
OPEN_EXISTING, flag, NULL);
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
@@ -2115,7 +2115,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
} else
desiredAccess = GENERIC_READ;
- h = CreateFileW(path, desiredAccess, 0, NULL,
+ h = CreateFileW(path, desiredAccess, FILE_SHARE_READ, NULL,
OPEN_EXISTING, flag, NULL);
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
@@ -2162,7 +2162,7 @@ archive_read_disk_entry_from_file(struct archive *_a,
if (fd >= 0) {
h = (HANDLE)_get_osfhandle(fd);
} else {
- h = CreateFileW(path, GENERIC_READ, 0, NULL,
+ h = CreateFileW(path, GENERIC_READ, FILE_SHARE_READ, NULL,
OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract.c b/Utilities/cmlibarchive/libarchive/archive_read_extract.c
index 795f2ab..ce76a6c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_extract.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_extract.c
@@ -26,146 +26,40 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $");
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
#include "archive.h"
#include "archive_entry.h"
#include "archive_private.h"
#include "archive_read_private.h"
-#include "archive_write_disk_private.h"
-
-struct extract {
- struct archive *ad; /* archive_write_disk object */
-
- /* Progress function invoked during extract. */
- void (*extract_progress)(void *);
- void *extract_progress_user_data;
-};
static int archive_read_extract_cleanup(struct archive_read *);
-static int copy_data(struct archive *ar, struct archive *aw);
-static struct extract *get_extract(struct archive_read *);
-
-static struct extract *
-get_extract(struct archive_read *a)
-{
- /* If we haven't initialized, do it now. */
- /* This also sets up a lot of global state. */
- if (a->extract == NULL) {
- a->extract = (struct extract *)malloc(sizeof(*a->extract));
- if (a->extract == NULL) {
- archive_set_error(&a->archive, ENOMEM, "Can't extract");
- return (NULL);
- }
- memset(a->extract, 0, sizeof(*a->extract));
- a->extract->ad = archive_write_disk_new();
- if (a->extract->ad == NULL) {
- archive_set_error(&a->archive, ENOMEM, "Can't extract");
- return (NULL);
- }
- archive_write_disk_set_standard_lookup(a->extract->ad);
- a->cleanup_archive_extract = archive_read_extract_cleanup;
- }
- return (a->extract);
-}
int
archive_read_extract(struct archive *_a, struct archive_entry *entry, int flags)
{
- struct extract *extract;
+ struct archive_read_extract *extract;
+ struct archive_read * a = (struct archive_read *)_a;
- extract = get_extract((struct archive_read *)_a);
+ extract = __archive_read_get_extract(a);
if (extract == NULL)
return (ARCHIVE_FATAL);
- archive_write_disk_set_options(extract->ad, flags);
- return (archive_read_extract2(_a, entry, extract->ad));
-}
-
-int
-archive_read_extract2(struct archive *_a, struct archive_entry *entry,
- struct archive *ad)
-{
- struct archive_read *a = (struct archive_read *)_a;
- int r, r2;
- /* Set up for this particular entry. */
- if (a->skip_file_set)
- archive_write_disk_set_skip_file(ad,
- a->skip_file_dev, a->skip_file_ino);
- r = archive_write_header(ad, entry);
- if (r < ARCHIVE_WARN)
- r = ARCHIVE_WARN;
- if (r != ARCHIVE_OK)
- /* If _write_header failed, copy the error. */
- archive_copy_error(&a->archive, ad);
- else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0)
- /* Otherwise, pour data into the entry. */
- r = copy_data(_a, ad);
- r2 = archive_write_finish_entry(ad);
- if (r2 < ARCHIVE_WARN)
- r2 = ARCHIVE_WARN;
- /* Use the first message. */
- if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
- archive_copy_error(&a->archive, ad);
- /* Use the worst error return. */
- if (r2 < r)
- r = r2;
- return (r);
-}
-
-void
-archive_read_extract_set_progress_callback(struct archive *_a,
- void (*progress_func)(void *), void *user_data)
-{
- struct archive_read *a = (struct archive_read *)_a;
- struct extract *extract = get_extract(a);
- if (extract != NULL) {
- extract->extract_progress = progress_func;
- extract->extract_progress_user_data = user_data;
- }
-}
-
-static int
-copy_data(struct archive *ar, struct archive *aw)
-{
- int64_t offset;
- const void *buff;
- struct extract *extract;
- size_t size;
- int r;
-
- extract = get_extract((struct archive_read *)ar);
- if (extract == NULL)
- return (ARCHIVE_FATAL);
- for (;;) {
- r = archive_read_data_block(ar, &buff, &size, &offset);
- if (r == ARCHIVE_EOF)
- return (ARCHIVE_OK);
- if (r != ARCHIVE_OK)
- return (r);
- r = (int)archive_write_data_block(aw, buff, size, offset);
- if (r < ARCHIVE_WARN)
- r = ARCHIVE_WARN;
- if (r != ARCHIVE_OK) {
- archive_set_error(ar, archive_errno(aw),
- "%s", archive_error_string(aw));
- return (r);
+ /* If we haven't initialized the archive_write_disk object, do it now. */
+ if (extract->ad == NULL) {
+ extract->ad = archive_write_disk_new();
+ if (extract->ad == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't extract");
+ return (ARCHIVE_FATAL);
}
- if (extract->extract_progress)
- (extract->extract_progress)
- (extract->extract_progress_user_data);
+ archive_write_disk_set_standard_lookup(extract->ad);
+ a->cleanup_archive_extract = archive_read_extract_cleanup;
}
+
+ archive_write_disk_set_options(extract->ad, flags);
+ return (archive_read_extract2(&a->archive, entry, extract->ad));
}
/*
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_extract2.c b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c
new file mode 100644
index 0000000..3c65e80
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_read_extract2.c
@@ -0,0 +1,137 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: src/lib/libarchive/archive_read_extract.c,v 1.61 2008/05/26 17:00:22 kientzle Exp $");
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_private.h"
+#include "archive_read_private.h"
+
+static int copy_data(struct archive *ar, struct archive *aw);
+
+/* Retrieve an extract object without initialising the associated
+ * archive_write_disk object.
+ */
+struct archive_read_extract *
+__archive_read_get_extract(struct archive_read *a)
+{
+ if (a->extract == NULL) {
+ a->extract = (struct archive_read_extract *)malloc(sizeof(*a->extract));
+ if (a->extract == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't extract");
+ return (NULL);
+ }
+ memset(a->extract, 0, sizeof(*a->extract));
+ }
+ return (a->extract);
+}
+
+int
+archive_read_extract2(struct archive *_a, struct archive_entry *entry,
+ struct archive *ad)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ int r, r2;
+
+ /* Set up for this particular entry. */
+ if (a->skip_file_set)
+ archive_write_disk_set_skip_file(ad,
+ a->skip_file_dev, a->skip_file_ino);
+ r = archive_write_header(ad, entry);
+ if (r < ARCHIVE_WARN)
+ r = ARCHIVE_WARN;
+ if (r != ARCHIVE_OK)
+ /* If _write_header failed, copy the error. */
+ archive_copy_error(&a->archive, ad);
+ else if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) > 0)
+ /* Otherwise, pour data into the entry. */
+ r = copy_data(_a, ad);
+ r2 = archive_write_finish_entry(ad);
+ if (r2 < ARCHIVE_WARN)
+ r2 = ARCHIVE_WARN;
+ /* Use the first message. */
+ if (r2 != ARCHIVE_OK && r == ARCHIVE_OK)
+ archive_copy_error(&a->archive, ad);
+ /* Use the worst error return. */
+ if (r2 < r)
+ r = r2;
+ return (r);
+}
+
+void
+archive_read_extract_set_progress_callback(struct archive *_a,
+ void (*progress_func)(void *), void *user_data)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct archive_read_extract *extract = __archive_read_get_extract(a);
+ if (extract != NULL) {
+ extract->extract_progress = progress_func;
+ extract->extract_progress_user_data = user_data;
+ }
+}
+
+static int
+copy_data(struct archive *ar, struct archive *aw)
+{
+ int64_t offset;
+ const void *buff;
+ struct archive_read_extract *extract;
+ size_t size;
+ int r;
+
+ extract = __archive_read_get_extract((struct archive_read *)ar);
+ if (extract == NULL)
+ return (ARCHIVE_FATAL);
+ for (;;) {
+ r = archive_read_data_block(ar, &buff, &size, &offset);
+ if (r == ARCHIVE_EOF)
+ return (ARCHIVE_OK);
+ if (r != ARCHIVE_OK)
+ return (r);
+ r = (int)archive_write_data_block(aw, buff, size, offset);
+ if (r < ARCHIVE_WARN)
+ r = ARCHIVE_WARN;
+ if (r != ARCHIVE_OK) {
+ archive_set_error(ar, archive_errno(aw),
+ "%s", archive_error_string(aw));
+ return (r);
+ }
+ if (extract->extract_progress)
+ (extract->extract_progress)
+ (extract->extract_progress_user_data);
+ }
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_private.h b/Utilities/cmlibarchive/libarchive/archive_read_private.h
index 8a6c859..27e203b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_read_private.h
@@ -142,6 +142,14 @@ struct archive_read_client {
struct archive_read_data_node *dataset;
};
+struct archive_read_extract {
+ struct archive *ad; /* archive_write_disk object */
+
+ /* Progress function invoked during extract. */
+ void (*extract_progress)(void *);
+ void *extract_progress_user_data;
+};
+
struct archive_read {
struct archive archive;
@@ -207,26 +215,30 @@ struct archive_read {
int (*read_data_skip)(struct archive_read *);
int64_t (*seek_data)(struct archive_read *, int64_t, int);
int (*cleanup)(struct archive_read *);
+ int (*format_capabilties)(struct archive_read *);
+ int (*has_encrypted_entries)(struct archive_read *);
} formats[16];
struct archive_format_descriptor *format; /* Active format. */
/*
* Various information needed by archive_extract.
*/
- struct extract *extract;
+ struct archive_read_extract *extract;
int (*cleanup_archive_extract)(struct archive_read *);
};
int __archive_read_register_format(struct archive_read *a,
- void *format_data,
- const char *name,
- int (*bid)(struct archive_read *, int),
- int (*options)(struct archive_read *, const char *, const char *),
- int (*read_header)(struct archive_read *, struct archive_entry *),
- int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
- int (*read_data_skip)(struct archive_read *),
- int64_t (*seek_data)(struct archive_read *, int64_t, int),
- int (*cleanup)(struct archive_read *));
+ void *format_data,
+ const char *name,
+ int (*bid)(struct archive_read *, int),
+ int (*options)(struct archive_read *, const char *, const char *),
+ int (*read_header)(struct archive_read *, struct archive_entry *),
+ int (*read_data)(struct archive_read *, const void **, size_t *, int64_t *),
+ int (*read_data_skip)(struct archive_read *),
+ int64_t (*seek_data)(struct archive_read *, int64_t, int),
+ int (*cleanup)(struct archive_read *),
+ int (*format_capabilities)(struct archive_read *),
+ int (*has_encrypted_entries)(struct archive_read *));
int __archive_read_get_bidder(struct archive_read *a,
struct archive_read_filter_bidder **bidder);
@@ -241,4 +253,5 @@ int64_t __archive_read_filter_consume(struct archive_read_filter *, int64_t);
int __archive_read_program(struct archive_read_filter *, const char *);
void __archive_read_free_filters(struct archive_read *);
int __archive_read_close_filters(struct archive_read *);
+struct archive_read_extract *__archive_read_get_extract(struct archive_read *);
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_set_options.3 b/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
index 6fe9f90..1a251ce 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
@@ -193,6 +193,28 @@ Defaults to enabled, use
.Cm !rockridge
to disable.
.El
+.It Format tar
+.Bl -tag -compact -width indent
+.It Cm compat-2x
+Libarchive 2.x incorrectly encoded Unicode filenames on
+some platforms.
+This option mimics the libarchive 2.x filename handling
+so that such archives can be read correctly.
+.It Cm hdrcharset
+The value is used as a character set name that will be
+used when translating filenames.
+.It Cm mac-ext
+Support Mac OS metadata extension that records data in special
+files beginning with a period and underscore.
+Defaults to enabled on Mac OS, disabled on other platforms.
+Use
+.Cm !mac-ext
+to disable.
+.It Cm read_concatenated_archives
+Ignore zeroed blocks in the archive, which occurs when multiple tar archives
+have been concatenated together. Without this option, only the contents of
+the first concatenated archive would be read.
+.El
.El
.\"
.Sh ERRORS
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_set_options.c b/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
index 793f8f7..46678b1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
@@ -78,7 +78,7 @@ archive_set_format_option(struct archive *_a, const char *m, const char *o,
struct archive_read *a = (struct archive_read *)_a;
struct archive_format_descriptor *format;
size_t i;
- int r, rv = ARCHIVE_WARN;
+ int r, rv = ARCHIVE_WARN, matched_modules = 0;
for (i = 0; i < sizeof(a->formats)/sizeof(a->formats[0]); i++) {
format = &a->formats[i];
@@ -86,8 +86,11 @@ archive_set_format_option(struct archive *_a, const char *m, const char *o,
format->name == NULL)
/* This format does not support option. */
continue;
- if (m != NULL && strcmp(format->name, m) != 0)
- continue;
+ if (m != NULL) {
+ if (strcmp(format->name, m) != 0)
+ continue;
+ ++matched_modules;
+ }
a->format = format;
r = format->options(a, o, v);
@@ -96,16 +99,13 @@ archive_set_format_option(struct archive *_a, const char *m, const char *o,
if (r == ARCHIVE_FATAL)
return (ARCHIVE_FATAL);
- if (m != NULL)
- return (r);
-
if (r == ARCHIVE_OK)
rv = ARCHIVE_OK;
}
/* If the format name didn't match, return a special code for
* _archive_set_option[s]. */
- if (rv == ARCHIVE_WARN && m != NULL)
- rv = ARCHIVE_WARN - 1;
+ if (m != NULL && matched_modules == 0)
+ return ARCHIVE_WARN - 1;
return (rv);
}
@@ -116,7 +116,7 @@ archive_set_filter_option(struct archive *_a, const char *m, const char *o,
struct archive_read *a = (struct archive_read *)_a;
struct archive_read_filter *filter;
struct archive_read_filter_bidder *bidder;
- int r, rv = ARCHIVE_WARN;
+ int r, rv = ARCHIVE_WARN, matched_modules = 0;
for (filter = a->filter; filter != NULL; filter = filter->upstream) {
bidder = filter->bidder;
@@ -125,24 +125,24 @@ archive_set_filter_option(struct archive *_a, const char *m, const char *o,
if (bidder->options == NULL)
/* This bidder does not support option */
continue;
- if (m != NULL && strcmp(filter->name, m) != 0)
- continue;
+ if (m != NULL) {
+ if (strcmp(filter->name, m) != 0)
+ continue;
+ ++matched_modules;
+ }
r = bidder->options(bidder, o, v);
if (r == ARCHIVE_FATAL)
return (ARCHIVE_FATAL);
- if (m != NULL)
- return (r);
-
if (r == ARCHIVE_OK)
rv = ARCHIVE_OK;
}
/* If the filter name didn't match, return a special code for
* _archive_set_option[s]. */
- if (rv == ARCHIVE_WARN && m != NULL)
- rv = ARCHIVE_WARN - 1;
+ if (m != NULL && matched_modules == 0)
+ return ARCHIVE_WARN - 1;
return (rv);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
index 7958fa5..9ef2054 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
@@ -242,10 +242,11 @@ consume_header(struct archive_read_filter *self)
if (version >= 0x940) {
unsigned level = *p++;
- if (method == 1 && level == 0) level = 3;
- if (method == 2 && level == 0) level = 1;
- if (method == 3 && level == 0) level = 9;
- if (level < 1 && level > 9) {
+ unsigned default_level[] = {0, 3, 1, 9};
+ if (level == 0)
+ /* Method is 1..3 here due to check above. */
+ level = default_level[method];
+ else if (level > 9) {
archive_set_error(&self->archive->archive,
ARCHIVE_ERRNO_MISC, "Invalid level");
return (ARCHIVE_FAILED);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
index 15824b1..7bda263 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
@@ -601,7 +601,7 @@ lzip_init(struct archive_read_filter *self)
return (ARCHIVE_FATAL);
}
ret = lzma_raw_decoder(&(state->stream), filters);
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
free(filters[0].options);
#endif
if (ret != LZMA_OK) {
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
index 54ea245..8cd241b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
@@ -69,7 +69,11 @@ __FBSDID("$FreeBSD$");
#define _7Z_BZ2 0x040202
#define _7Z_PPMD 0x030401
#define _7Z_DELTA 0x03
-#define _7Z_CRYPTO 0x06F10701
+#define _7Z_CRYPTO_MAIN_ZIP 0x06F10101 /* Main Zip crypto algo */
+#define _7Z_CRYPTO_RAR_29 0x06F10303 /* Rar29 AES-128 + (modified SHA-1) */
+#define _7Z_CRYPTO_AES_256_SHA_256 0x06F10701 /* AES-256 + SHA-256 */
+
+
#define _7Z_X86 0x03030103
#define _7Z_X86_BCJ2 0x0303011B
#define _7Z_POWERPC 0x03030205
@@ -322,8 +326,13 @@ struct _7zip {
struct archive_string_conv *sconv;
char format_name[64];
+
+ /* Custom value that is non-zero if this archive contains encrypted entries. */
+ int has_encrypted_entries;
};
+static int archive_read_format_7zip_has_encrypted_entries(struct archive_read *);
+static int archive_read_support_format_7zip_capabilities(struct archive_read *a);
static int archive_read_format_7zip_bid(struct archive_read *, int);
static int archive_read_format_7zip_cleanup(struct archive_read *);
static int archive_read_format_7zip_read_data(struct archive_read *,
@@ -401,6 +410,13 @@ archive_read_support_format_7zip(struct archive *_a)
return (ARCHIVE_FATAL);
}
+ /*
+ * Until enough data has been read, we cannot tell about
+ * any encrypted entries yet.
+ */
+ zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+
+
r = __archive_read_register_format(a,
zip,
"7zip",
@@ -410,7 +426,9 @@ archive_read_support_format_7zip(struct archive *_a)
archive_read_format_7zip_read_data,
archive_read_format_7zip_read_data_skip,
NULL,
- archive_read_format_7zip_cleanup);
+ archive_read_format_7zip_cleanup,
+ archive_read_support_format_7zip_capabilities,
+ archive_read_format_7zip_has_encrypted_entries);
if (r != ARCHIVE_OK)
free(zip);
@@ -418,6 +436,27 @@ archive_read_support_format_7zip(struct archive *_a)
}
static int
+archive_read_support_format_7zip_capabilities(struct archive_read * a)
+{
+ (void)a; /* UNUSED */
+ return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA |
+ ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+
+static int
+archive_read_format_7zip_has_encrypted_entries(struct archive_read *_a)
+{
+ if (_a && _a->format) {
+ struct _7zip * zip = (struct _7zip *)_a->format->data;
+ if (zip) {
+ return zip->has_encrypted_entries;
+ }
+ }
+ return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+static int
archive_read_format_7zip_bid(struct archive_read *a, int best_bid)
{
const char *p;
@@ -476,7 +515,7 @@ check_7zip_header_in_sfx(const char *p)
switch ((unsigned char)p[5]) {
case 0x1C:
if (memcmp(p, _7ZIP_SIGNATURE, 6) != 0)
- return (6);
+ return (6);
/*
* Test the CRC because its extraction code has 7-Zip
* Magic Code, so we should do this in order not to
@@ -484,15 +523,15 @@ check_7zip_header_in_sfx(const char *p)
*/
if (crc32(0, (const unsigned char *)p + 12, 20)
!= archive_le32dec(p + 8))
- return (6);
+ return (6);
/* Hit the header! */
return (0);
- case 0x37: return (5);
- case 0x7A: return (4);
- case 0xBC: return (3);
- case 0xAF: return (2);
- case 0x27: return (1);
- default: return (6);
+ case 0x37: return (5);
+ case 0x7A: return (4);
+ case 0xBC: return (3);
+ case 0xAF: return (2);
+ case 0x27: return (1);
+ default: return (6);
}
}
@@ -568,6 +607,19 @@ archive_read_format_7zip_read_header(struct archive_read *a,
struct _7zip *zip = (struct _7zip *)a->format->data;
struct _7zip_entry *zip_entry;
int r, ret = ARCHIVE_OK;
+ struct _7z_folder *folder = 0;
+ uint64_t fidx = 0;
+
+ /*
+ * It should be sufficient to call archive_read_next_header() for
+ * a reader to determine if an entry is encrypted or not. If the
+ * encryption of an entry is only detectable when calling
+ * archive_read_data(), so be it. We'll do the same check there
+ * as well.
+ */
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
a->archive.archive_format = ARCHIVE_FORMAT_7ZIP;
if (a->archive.archive_format_name == NULL)
@@ -604,6 +656,32 @@ archive_read_format_7zip_read_header(struct archive_read *a,
return (ARCHIVE_FATAL);
}
+ /* Figure out if the entry is encrypted by looking at the folder
+ that is associated to the current 7zip entry. If the folder
+ has a coder with a _7Z_CRYPTO codec then the folder is encrypted.
+ Hence the entry must also be encrypted. */
+ if (zip_entry && zip_entry->folderIndex < zip->si.ci.numFolders) {
+ folder = &(zip->si.ci.folders[zip_entry->folderIndex]);
+ for (fidx=0; folder && fidx<folder->numCoders; fidx++) {
+ switch(folder->coders[fidx].codec) {
+ case _7Z_CRYPTO_MAIN_ZIP:
+ case _7Z_CRYPTO_RAR_29:
+ case _7Z_CRYPTO_AES_256_SHA_256: {
+ archive_entry_set_is_data_encrypted(entry, 1);
+ zip->has_encrypted_entries = 1;
+ break;
+ }
+ }
+ }
+ }
+
+ /* Now that we've checked for encryption, if there were still no
+ * encrypted entries found we can say for sure that there are none.
+ */
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
+
if (archive_entry_copy_pathname_l(entry,
(const char *)zip_entry->utf16name,
zip_entry->name_len, zip->sconv) != 0) {
@@ -707,6 +785,10 @@ archive_read_format_7zip_read_data(struct archive_read *a,
zip = (struct _7zip *)(a->format->data);
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
+
if (zip->pack_stream_bytes_unconsumed)
read_consume(a);
@@ -969,7 +1051,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
{
lzma_options_delta delta_opt;
lzma_filter filters[LZMA_FILTERS_MAX];
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
lzma_filter *ff;
#endif
int fi = 0;
@@ -994,7 +1076,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
* for BCJ+LZMA. If we were able to tell the uncompressed
* size to liblzma when using lzma_raw_decoder() liblzma
* could correctly deal with BCJ+LZMA. But unfortunately
- * there is no way to do that.
+ * there is no way to do that.
* Discussion about this can be found at XZ Utils forum.
*/
if (coder2 != NULL) {
@@ -1056,7 +1138,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
else
filters[fi].id = LZMA_FILTER_LZMA1;
filters[fi].options = NULL;
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
ff = &filters[fi];
#endif
r = lzma_properties_decode(&filters[fi], NULL,
@@ -1070,7 +1152,7 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
filters[fi].id = LZMA_VLI_UNKNOWN;
filters[fi].options = NULL;
r = lzma_raw_decoder(&(zip->lzstream), filters);
-#if LZMA_VERSION < 50000030
+#if LZMA_VERSION < 50010000
free(ff->options);
#endif
if (r != LZMA_OK) {
@@ -1203,6 +1285,17 @@ init_decompression(struct archive_read *a, struct _7zip *zip,
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Unexpected codec ID: %lX", zip->codec);
return (ARCHIVE_FAILED);
+ case _7Z_CRYPTO_MAIN_ZIP:
+ case _7Z_CRYPTO_RAR_29:
+ case _7Z_CRYPTO_AES_256_SHA_256:
+ if (a->entry) {
+ archive_entry_set_is_metadata_encrypted(a->entry, 1);
+ archive_entry_set_is_data_encrypted(a->entry, 1);
+ zip->has_encrypted_entries = 1;
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Crypto codec not supported yet (ID: 0x%lX)", zip->codec);
+ return (ARCHIVE_FAILED);
default:
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Unknown codec ID: %lX", zip->codec);
@@ -1426,7 +1519,7 @@ decompress(struct archive_read *a, struct _7zip *zip,
do {
int sym;
-
+
sym = __archive_ppmd7_functions.Ppmd7_DecodeSymbol(
&(zip->ppmd7_context), &(zip->range_dec.p));
if (sym < 0) {
@@ -2755,6 +2848,7 @@ slurp_central_directory(struct archive_read *a, struct _7zip *zip,
zip->header_crc32 = 0;
zip->header_is_encoded = 0;
zip->header_is_being_read = 1;
+ zip->has_encrypted_entries = 0;
check_header_crc = 1;
if ((p = header_bytes(a, 1)) == NULL) {
@@ -3170,7 +3264,7 @@ read_stream(struct archive_read *a, const void **buff, size_t size,
return (r);
/*
- * Skip the bytes we alrady has skipped in skip_stream().
+ * Skip the bytes we alrady has skipped in skip_stream().
*/
while (skip_bytes) {
ssize_t skipped;
@@ -3235,16 +3329,36 @@ setup_decode_folder(struct archive_read *a, struct _7z_folder *folder,
* Check coder types.
*/
for (i = 0; i < folder->numCoders; i++) {
- if (folder->coders[i].codec == _7Z_CRYPTO) {
- archive_set_error(&(a->archive),
- ARCHIVE_ERRNO_MISC,
- "The %s is encrypted, "
- "but currently not supported", cname);
- return (ARCHIVE_FATAL);
+ switch(folder->coders[i].codec) {
+ case _7Z_CRYPTO_MAIN_ZIP:
+ case _7Z_CRYPTO_RAR_29:
+ case _7Z_CRYPTO_AES_256_SHA_256: {
+ /* For entry that is associated with this folder, mark
+ it as encrypted (data+metadata). */
+ zip->has_encrypted_entries = 1;
+ if (a->entry) {
+ archive_entry_set_is_data_encrypted(a->entry, 1);
+ archive_entry_set_is_metadata_encrypted(a->entry, 1);
+ }
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "The %s is encrypted, "
+ "but currently not supported", cname);
+ return (ARCHIVE_FATAL);
+ }
+ case _7Z_X86_BCJ2: {
+ found_bcj2++;
+ break;
+ }
}
- if (folder->coders[i].codec == _7Z_X86_BCJ2)
- found_bcj2++;
}
+ /* Now that we've checked for encryption, if there were still no
+ * encrypted entries found we can say for sure that there are none.
+ */
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
+
if ((folder->numCoders > 2 && !found_bcj2) || found_bcj2 > 1) {
archive_set_error(&(a->archive),
ARCHIVE_ERRNO_MISC,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c
index 40be18c..82756c9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_ar.c
@@ -122,7 +122,9 @@ archive_read_support_format_ar(struct archive *_a)
archive_read_format_ar_read_data,
archive_read_format_ar_skip,
NULL,
- archive_read_format_ar_cleanup);
+ archive_read_format_ar_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK) {
free(ar);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
index 4dd38db..6356963 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
@@ -383,7 +383,9 @@ archive_read_support_format_cab(struct archive *_a)
archive_read_format_cab_read_data,
archive_read_format_cab_read_data_skip,
NULL,
- archive_read_format_cab_cleanup);
+ archive_read_format_cab_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(cab);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
index 819f4a4..0b69689 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
@@ -243,7 +243,9 @@ archive_read_support_format_cpio(struct archive *_a)
archive_read_format_cpio_read_data,
archive_read_format_cpio_skip,
NULL,
- archive_read_format_cpio_cleanup);
+ archive_read_format_cpio_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(cpio);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c
index 3660738..c641eb9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_empty.c
@@ -54,6 +54,8 @@ archive_read_support_format_empty(struct archive *_a)
archive_read_format_empty_read_data,
NULL,
NULL,
+ NULL,
+ NULL,
NULL);
return (r);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
index 8147461..2219e61 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_iso9660.c
@@ -478,7 +478,9 @@ archive_read_support_format_iso9660(struct archive *_a)
archive_read_format_iso9660_read_data,
archive_read_format_iso9660_read_data_skip,
NULL,
- archive_read_format_iso9660_cleanup);
+ archive_read_format_iso9660_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK) {
free(iso9660);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
index f702949..b88731a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_lha.c
@@ -320,7 +320,9 @@ archive_read_support_format_lha(struct archive *_a)
archive_read_format_lha_read_data,
archive_read_format_lha_read_data_skip,
NULL,
- archive_read_format_lha_cleanup);
+ archive_read_format_lha_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(lha);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
index c4e7021..d82d4c1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
@@ -51,6 +51,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_mtree.c 2011
#include "archive_private.h"
#include "archive_read_private.h"
#include "archive_string.h"
+#include "archive_pack_dev.h"
#ifndef O_BINARY
#define O_BINARY 0
@@ -103,6 +104,7 @@ struct mtree {
struct archive_entry_linkresolver *resolver;
int64_t cur_size;
+ char checkfs;
};
static int bid_keycmp(const char *, const char *, ssize_t);
@@ -173,6 +175,29 @@ get_time_t_min(void)
#endif
}
+static int
+archive_read_format_mtree_options(struct archive_read *a,
+ const char *key, const char *val)
+{
+ struct mtree *mtree;
+
+ mtree = (struct mtree *)(a->format->data);
+ if (strcmp(key, "checkfs") == 0) {
+ /* Allows to read information missing from the mtree from the file system */
+ if (val == NULL || val[0] == 0) {
+ mtree->checkfs = 0;
+ } else {
+ mtree->checkfs = 1;
+ }
+ return (ARCHIVE_OK);
+ }
+
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if no one used this option. */
+ return (ARCHIVE_WARN);
+}
+
static void
free_options(struct mtree_option *head)
{
@@ -205,7 +230,7 @@ archive_read_support_format_mtree(struct archive *_a)
mtree->fd = -1;
r = __archive_read_register_format(a, mtree, "mtree",
- mtree_bid, NULL, read_header, read_data, skip, NULL, cleanup);
+ mtree_bid, archive_read_format_mtree_options, read_header, read_data, skip, NULL, cleanup, NULL, NULL);
if (r != ARCHIVE_OK)
free(mtree);
@@ -367,7 +392,7 @@ bid_keyword(const char *p, ssize_t len)
"gid", "gname", NULL
};
static const char *keys_il[] = {
- "ignore", "link", NULL
+ "ignore", "inode", "link", NULL
};
static const char *keys_m[] = {
"md5", "md5digest", "mode", NULL
@@ -376,7 +401,7 @@ bid_keyword(const char *p, ssize_t len)
"nlink", "nochange", "optional", NULL
};
static const char *keys_r[] = {
- "rmd160", "rmd160digest", NULL
+ "resdevice", "rmd160", "rmd160digest", NULL
};
static const char *keys_s[] = {
"sha1", "sha1digest",
@@ -1103,162 +1128,164 @@ parse_file(struct archive_read *a, struct archive_entry *entry,
mtree->current_dir.length = n;
}
- /*
- * Try to open and stat the file to get the real size
- * and other file info. It would be nice to avoid
- * this here so that getting a listing of an mtree
- * wouldn't require opening every referenced contents
- * file. But then we wouldn't know the actual
- * contents size, so I don't see a really viable way
- * around this. (Also, we may want to someday pull
- * other unspecified info from the contents file on
- * disk.)
- */
- mtree->fd = -1;
- if (archive_strlen(&mtree->contents_name) > 0)
- path = mtree->contents_name.s;
- else
- path = archive_entry_pathname(entry);
-
- if (archive_entry_filetype(entry) == AE_IFREG ||
- archive_entry_filetype(entry) == AE_IFDIR) {
- mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
- __archive_ensure_cloexec_flag(mtree->fd);
- if (mtree->fd == -1 &&
- (errno != ENOENT ||
- archive_strlen(&mtree->contents_name) > 0)) {
- archive_set_error(&a->archive, errno,
- "Can't open %s", path);
- r = ARCHIVE_WARN;
+ if (mtree->checkfs) {
+ /*
+ * Try to open and stat the file to get the real size
+ * and other file info. It would be nice to avoid
+ * this here so that getting a listing of an mtree
+ * wouldn't require opening every referenced contents
+ * file. But then we wouldn't know the actual
+ * contents size, so I don't see a really viable way
+ * around this. (Also, we may want to someday pull
+ * other unspecified info from the contents file on
+ * disk.)
+ */
+ mtree->fd = -1;
+ if (archive_strlen(&mtree->contents_name) > 0)
+ path = mtree->contents_name.s;
+ else
+ path = archive_entry_pathname(entry);
+
+ if (archive_entry_filetype(entry) == AE_IFREG ||
+ archive_entry_filetype(entry) == AE_IFDIR) {
+ mtree->fd = open(path, O_RDONLY | O_BINARY | O_CLOEXEC);
+ __archive_ensure_cloexec_flag(mtree->fd);
+ if (mtree->fd == -1 &&
+ (errno != ENOENT ||
+ archive_strlen(&mtree->contents_name) > 0)) {
+ archive_set_error(&a->archive, errno,
+ "Can't open %s", path);
+ r = ARCHIVE_WARN;
+ }
}
- }
- st = &st_storage;
- if (mtree->fd >= 0) {
- if (fstat(mtree->fd, st) == -1) {
- archive_set_error(&a->archive, errno,
- "Could not fstat %s", path);
- r = ARCHIVE_WARN;
- /* If we can't stat it, don't keep it open. */
- close(mtree->fd);
- mtree->fd = -1;
+ st = &st_storage;
+ if (mtree->fd >= 0) {
+ if (fstat(mtree->fd, st) == -1) {
+ archive_set_error(&a->archive, errno,
+ "Could not fstat %s", path);
+ r = ARCHIVE_WARN;
+ /* If we can't stat it, don't keep it open. */
+ close(mtree->fd);
+ mtree->fd = -1;
+ st = NULL;
+ }
+ } else if (lstat(path, st) == -1) {
st = NULL;
}
- } else if (lstat(path, st) == -1) {
- st = NULL;
- }
- /*
- * Check for a mismatch between the type in the specification and
- * the type of the contents object on disk.
- */
- if (st != NULL) {
- if (
- ((st->st_mode & S_IFMT) == S_IFREG &&
- archive_entry_filetype(entry) == AE_IFREG)
+ /*
+ * Check for a mismatch between the type in the specification and
+ * the type of the contents object on disk.
+ */
+ if (st != NULL) {
+ if (
+ ((st->st_mode & S_IFMT) == S_IFREG &&
+ archive_entry_filetype(entry) == AE_IFREG)
#ifdef S_IFLNK
- || ((st->st_mode & S_IFMT) == S_IFLNK &&
- archive_entry_filetype(entry) == AE_IFLNK)
+ || ((st->st_mode & S_IFMT) == S_IFLNK &&
+ archive_entry_filetype(entry) == AE_IFLNK)
#endif
#ifdef S_IFSOCK
- || ((st->st_mode & S_IFSOCK) == S_IFSOCK &&
- archive_entry_filetype(entry) == AE_IFSOCK)
+ || ((st->st_mode & S_IFSOCK) == S_IFSOCK &&
+ archive_entry_filetype(entry) == AE_IFSOCK)
#endif
#ifdef S_IFCHR
- || ((st->st_mode & S_IFMT) == S_IFCHR &&
- archive_entry_filetype(entry) == AE_IFCHR)
+ || ((st->st_mode & S_IFMT) == S_IFCHR &&
+ archive_entry_filetype(entry) == AE_IFCHR)
#endif
#ifdef S_IFBLK
- || ((st->st_mode & S_IFMT) == S_IFBLK &&
- archive_entry_filetype(entry) == AE_IFBLK)
+ || ((st->st_mode & S_IFMT) == S_IFBLK &&
+ archive_entry_filetype(entry) == AE_IFBLK)
#endif
- || ((st->st_mode & S_IFMT) == S_IFDIR &&
- archive_entry_filetype(entry) == AE_IFDIR)
+ || ((st->st_mode & S_IFMT) == S_IFDIR &&
+ archive_entry_filetype(entry) == AE_IFDIR)
#ifdef S_IFIFO
- || ((st->st_mode & S_IFMT) == S_IFIFO &&
- archive_entry_filetype(entry) == AE_IFIFO)
+ || ((st->st_mode & S_IFMT) == S_IFIFO &&
+ archive_entry_filetype(entry) == AE_IFIFO)
#endif
- ) {
- /* Types match. */
- } else {
- /* Types don't match; bail out gracefully. */
- if (mtree->fd >= 0)
- close(mtree->fd);
- mtree->fd = -1;
- if (parsed_kws & MTREE_HAS_OPTIONAL) {
- /* It's not an error for an optional entry
- to not match disk. */
- *use_next = 1;
- } else if (r == ARCHIVE_OK) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_MISC,
- "mtree specification has different type for %s",
- archive_entry_pathname(entry));
- r = ARCHIVE_WARN;
- }
- return r;
+ ) {
+ /* Types match. */
+ } else {
+ /* Types don't match; bail out gracefully. */
+ if (mtree->fd >= 0)
+ close(mtree->fd);
+ mtree->fd = -1;
+ if (parsed_kws & MTREE_HAS_OPTIONAL) {
+ /* It's not an error for an optional entry
+ to not match disk. */
+ *use_next = 1;
+ } else if (r == ARCHIVE_OK) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "mtree specification has different type for %s",
+ archive_entry_pathname(entry));
+ r = ARCHIVE_WARN;
+ }
+ return r;
+ }
}
- }
- /*
- * If there is a contents file on disk, pick some of the metadata
- * from that file. For most of these, we only set it from the contents
- * if it wasn't already parsed from the specification.
- */
- if (st != NULL) {
- if (((parsed_kws & MTREE_HAS_DEVICE) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0) &&
- (archive_entry_filetype(entry) == AE_IFCHR ||
- archive_entry_filetype(entry) == AE_IFBLK))
- archive_entry_set_rdev(entry, st->st_rdev);
- if ((parsed_kws & (MTREE_HAS_GID | MTREE_HAS_GNAME)) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
- archive_entry_set_gid(entry, st->st_gid);
- if ((parsed_kws & (MTREE_HAS_UID | MTREE_HAS_UNAME)) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
- archive_entry_set_uid(entry, st->st_uid);
- if ((parsed_kws & MTREE_HAS_MTIME) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0) {
+ /*
+ * If there is a contents file on disk, pick some of the metadata
+ * from that file. For most of these, we only set it from the contents
+ * if it wasn't already parsed from the specification.
+ */
+ if (st != NULL) {
+ if (((parsed_kws & MTREE_HAS_DEVICE) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0) &&
+ (archive_entry_filetype(entry) == AE_IFCHR ||
+ archive_entry_filetype(entry) == AE_IFBLK))
+ archive_entry_set_rdev(entry, st->st_rdev);
+ if ((parsed_kws & (MTREE_HAS_GID | MTREE_HAS_GNAME)) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+ archive_entry_set_gid(entry, st->st_gid);
+ if ((parsed_kws & (MTREE_HAS_UID | MTREE_HAS_UNAME)) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+ archive_entry_set_uid(entry, st->st_uid);
+ if ((parsed_kws & MTREE_HAS_MTIME) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0) {
#if HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
- archive_entry_set_mtime(entry, st->st_mtime,
- st->st_mtimespec.tv_nsec);
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_mtimespec.tv_nsec);
#elif HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
- archive_entry_set_mtime(entry, st->st_mtime,
- st->st_mtim.tv_nsec);
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_mtim.tv_nsec);
#elif HAVE_STRUCT_STAT_ST_MTIME_N
- archive_entry_set_mtime(entry, st->st_mtime,
- st->st_mtime_n);
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_mtime_n);
#elif HAVE_STRUCT_STAT_ST_UMTIME
- archive_entry_set_mtime(entry, st->st_mtime,
- st->st_umtime*1000);
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_umtime*1000);
#elif HAVE_STRUCT_STAT_ST_MTIME_USEC
- archive_entry_set_mtime(entry, st->st_mtime,
- st->st_mtime_usec*1000);
+ archive_entry_set_mtime(entry, st->st_mtime,
+ st->st_mtime_usec*1000);
#else
- archive_entry_set_mtime(entry, st->st_mtime, 0);
+ archive_entry_set_mtime(entry, st->st_mtime, 0);
#endif
+ }
+ if ((parsed_kws & MTREE_HAS_NLINK) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+ archive_entry_set_nlink(entry, st->st_nlink);
+ if ((parsed_kws & MTREE_HAS_PERM) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+ archive_entry_set_perm(entry, st->st_mode);
+ if ((parsed_kws & MTREE_HAS_SIZE) == 0 ||
+ (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
+ archive_entry_set_size(entry, st->st_size);
+ archive_entry_set_ino(entry, st->st_ino);
+ archive_entry_set_dev(entry, st->st_dev);
+
+ archive_entry_linkify(mtree->resolver, &entry, &sparse_entry);
+ } else if (parsed_kws & MTREE_HAS_OPTIONAL) {
+ /*
+ * Couldn't open the entry, stat it or the on-disk type
+ * didn't match. If this entry is optional, just ignore it
+ * and read the next header entry.
+ */
+ *use_next = 1;
+ return ARCHIVE_OK;
}
- if ((parsed_kws & MTREE_HAS_NLINK) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
- archive_entry_set_nlink(entry, st->st_nlink);
- if ((parsed_kws & MTREE_HAS_PERM) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
- archive_entry_set_perm(entry, st->st_mode);
- if ((parsed_kws & MTREE_HAS_SIZE) == 0 ||
- (parsed_kws & MTREE_HAS_NOCHANGE) != 0)
- archive_entry_set_size(entry, st->st_size);
- archive_entry_set_ino(entry, st->st_ino);
- archive_entry_set_dev(entry, st->st_dev);
-
- archive_entry_linkify(mtree->resolver, &entry, &sparse_entry);
- } else if (parsed_kws & MTREE_HAS_OPTIONAL) {
- /*
- * Couldn't open the entry, stat it or the on-disk type
- * didn't match. If this entry is optional, just ignore it
- * and read the next header entry.
- */
- *use_next = 1;
- return ARCHIVE_OK;
}
mtree->cur_size = archive_entry_size(entry);
@@ -1292,33 +1319,82 @@ parse_line(struct archive_read *a, struct archive_entry *entry,
/*
* Device entries have one of the following forms:
- * raw dev_t
- * format,major,minor[,subdevice]
- *
- * Just use major and minor, no translation etc is done
- * between formats.
+ * - raw dev_t
+ * - format,major,minor[,subdevice]
+ * When parsing succeeded, `pdev' will contain the appropriate dev_t value.
*/
-static int
-parse_device(struct archive *a, struct archive_entry *entry, char *val)
+
+/* strsep() is not in C90, but strcspn() is. */
+/* Taken from http://unixpapa.com/incnote/string.html */
+static char *
+la_strsep(char **sp, char *sep)
{
- char *comma1, *comma2;
+ char *p, *s;
+ if (sp == NULL || *sp == NULL || **sp == '\0')
+ return(NULL);
+ s = *sp;
+ p = s + strcspn(s, sep);
+ if (*p != '\0')
+ *p++ = '\0';
+ *sp = p;
+ return(s);
+}
- comma1 = strchr(val, ',');
- if (comma1 == NULL) {
- archive_entry_set_dev(entry, (dev_t)mtree_atol10(&val));
- return (ARCHIVE_OK);
- }
- ++comma1;
- comma2 = strchr(comma1, ',');
- if (comma2 == NULL) {
- archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
- "Malformed device attribute");
- return (ARCHIVE_WARN);
+static int
+parse_device(dev_t *pdev, struct archive *a, char *val)
+{
+#define MAX_PACK_ARGS 3
+ unsigned long numbers[MAX_PACK_ARGS];
+ char *p, *dev;
+ int argc;
+ pack_t *pack;
+ dev_t result;
+ const char *error = NULL;
+
+ memset(pdev, 0, sizeof(*pdev));
+ if ((dev = strchr(val, ',')) != NULL) {
+ /*
+ * Device's major/minor are given in a specified format.
+ * Decode and pack it accordingly.
+ */
+ *dev++ = '\0';
+ if ((pack = pack_find(val)) == NULL) {
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unknown format `%s'", val);
+ return ARCHIVE_WARN;
+ }
+ argc = 0;
+ while ((p = la_strsep(&dev, ",")) != NULL) {
+ if (*p == '\0') {
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Missing number");
+ return ARCHIVE_WARN;
+ }
+ numbers[argc++] = mtree_atol(&p);
+ if (argc > MAX_PACK_ARGS) {
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Too many arguments");
+ return ARCHIVE_WARN;
+ }
+ }
+ if (argc < 2) {
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Not enough arguments");
+ return ARCHIVE_WARN;
+ }
+ result = (*pack)(argc, numbers, &error);
+ if (error != NULL) {
+ archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT,
+ "%s", error);
+ return ARCHIVE_WARN;
+ }
+ } else {
+ /* file system raw value. */
+ result = (dev_t)mtree_atol(&val);
}
- ++comma2;
- archive_entry_set_rdevmajor(entry, (dev_t)mtree_atol(&comma1));
- archive_entry_set_rdevminor(entry, (dev_t)mtree_atol(&comma2));
- return (ARCHIVE_OK);
+ *pdev = result;
+ return ARCHIVE_OK;
+#undef MAX_PACK_ARGS
}
/*
@@ -1374,8 +1450,16 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
break;
case 'd':
if (strcmp(key, "device") == 0) {
+ /* stat(2) st_rdev field, e.g. the major/minor IDs
+ * of a char/block special file */
+ int r;
+ dev_t dev;
+
*parsed_kws |= MTREE_HAS_DEVICE;
- return parse_device(&a->archive, entry, val);
+ r = parse_device(&dev, &a->archive, val);
+ if (r == ARCHIVE_OK)
+ archive_entry_set_rdev(entry, dev);
+ return r;
}
case 'f':
if (strcmp(key, "flags") == 0) {
@@ -1394,6 +1478,11 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
archive_entry_copy_gname(entry, val);
break;
}
+ case 'i':
+ if (strcmp(key, "inode") == 0) {
+ archive_entry_set_ino(entry, mtree_atol10(&val));
+ break;
+ }
case 'l':
if (strcmp(key, "link") == 0) {
archive_entry_copy_symlink(entry, val);
@@ -1423,6 +1512,17 @@ parse_keyword(struct archive_read *a, struct mtree *mtree,
break;
}
case 'r':
+ if (strcmp(key, "resdevice") == 0) {
+ /* stat(2) st_dev field, e.g. the device ID where the
+ * inode resides */
+ int r;
+ dev_t dev;
+
+ r = parse_device(&dev, &a->archive, val);
+ if (r == ARCHIVE_OK)
+ archive_entry_set_dev(entry, dev);
+ return r;
+ }
if (strcmp(key, "rmd160") == 0 ||
strcmp(key, "rmd160digest") == 0)
break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
index dc1563d..4c56834 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
@@ -304,8 +304,15 @@ struct rar
ssize_t avail_in;
const unsigned char *next_in;
} br;
+
+ /*
+ * Custom field to denote that this archive contains encrypted entries
+ */
+ int has_encrypted_entries;
};
+static int archive_read_support_format_rar_capabilities(struct archive_read *);
+static int archive_read_format_rar_has_encrypted_entries(struct archive_read *);
static int archive_read_format_rar_bid(struct archive_read *, int);
static int archive_read_format_rar_options(struct archive_read *,
const char *, const char *);
@@ -646,6 +653,12 @@ archive_read_support_format_rar(struct archive *_a)
}
memset(rar, 0, sizeof(*rar));
+ /*
+ * Until enough data has been read, we cannot tell about
+ * any encrypted entries yet.
+ */
+ rar->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+
r = __archive_read_register_format(a,
rar,
"rar",
@@ -655,7 +668,9 @@ archive_read_support_format_rar(struct archive *_a)
archive_read_format_rar_read_data,
archive_read_format_rar_read_data_skip,
archive_read_format_rar_seek_data,
- archive_read_format_rar_cleanup);
+ archive_read_format_rar_cleanup,
+ archive_read_support_format_rar_capabilities,
+ archive_read_format_rar_has_encrypted_entries);
if (r != ARCHIVE_OK)
free(rar);
@@ -663,6 +678,27 @@ archive_read_support_format_rar(struct archive *_a)
}
static int
+archive_read_support_format_rar_capabilities(struct archive_read * a)
+{
+ (void)a; /* UNUSED */
+ return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA
+ | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+static int
+archive_read_format_rar_has_encrypted_entries(struct archive_read *_a)
+{
+ if (_a && _a->format) {
+ struct rar * rar = (struct rar *)_a->format->data;
+ if (rar) {
+ return rar->has_encrypted_entries;
+ }
+ }
+ return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+
+static int
archive_read_format_rar_bid(struct archive_read *a, int best_bid)
{
const char *p;
@@ -755,7 +791,7 @@ archive_read_format_rar_options(struct archive_read *a,
{
struct rar *rar;
int ret = ARCHIVE_FAILED;
-
+
rar = (struct rar *)(a->format->data);
if (strcmp(key, "hdrcharset") == 0) {
if (val == NULL || val[0] == 0)
@@ -797,6 +833,17 @@ archive_read_format_rar_read_header(struct archive_read *a,
rar = (struct rar *)(a->format->data);
+ /*
+ * It should be sufficient to call archive_read_next_header() for
+ * a reader to determine if an entry is encrypted or not. If the
+ * encryption of an entry is only detectable when calling
+ * archive_read_data(), so be it. We'll do the same check there
+ * as well.
+ */
+ if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ rar->has_encrypted_entries = 0;
+ }
+
/* RAR files can be generated without EOF headers, so return ARCHIVE_EOF if
* this fails.
*/
@@ -857,9 +904,14 @@ archive_read_format_rar_read_header(struct archive_read *a,
sizeof(rar->reserved2));
}
+ /* Main header is password encrytped, so we cannot read any
+ file names or any other info about files from the header. */
if (rar->main_flags & MHD_PASSWORD)
{
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ archive_entry_set_is_metadata_encrypted(entry, 1);
+ archive_entry_set_is_data_encrypted(entry, 1);
+ rar->has_encrypted_entries = 1;
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"RAR encryption support unavailable.");
return (ARCHIVE_FATAL);
}
@@ -938,6 +990,10 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
struct rar *rar = (struct rar *)(a->format->data);
int ret;
+ if (rar->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ rar->has_encrypted_entries = 0;
+ }
+
if (rar->bytes_unconsumed > 0) {
/* Consume as much as the decompressor actually used. */
__archive_read_consume(a, rar->bytes_unconsumed);
@@ -957,7 +1013,7 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
{
case COMPRESS_METHOD_STORE:
ret = read_data_stored(a, buff, size, offset);
- break;
+ break;
case COMPRESS_METHOD_FASTEST:
case COMPRESS_METHOD_FAST:
@@ -967,13 +1023,13 @@ archive_read_format_rar_read_data(struct archive_read *a, const void **buff,
ret = read_data_compressed(a, buff, size, offset);
if (ret != ARCHIVE_OK && ret != ARCHIVE_WARN)
__archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context, &g_szalloc);
- break;
+ break;
default:
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"Unsupported compression method for RAR file.");
ret = ARCHIVE_FATAL;
- break;
+ break;
}
return (ret);
}
@@ -1290,9 +1346,14 @@ read_header(struct archive_read *a, struct archive_entry *entry,
if (rar->file_flags & FHD_PASSWORD)
{
+ archive_entry_set_is_data_encrypted(entry, 1);
+ rar->has_encrypted_entries = 1;
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
"RAR encryption support unavailable.");
- return (ARCHIVE_FATAL);
+ /* Since it is only the data part itself that is encrypted we can at least
+ extract information about the currently processed entry and don't need
+ to return ARCHIVE_FATAL here. */
+ /*return (ARCHIVE_FATAL);*/
}
if (rar->file_flags & FHD_LARGE)
@@ -1377,7 +1438,7 @@ read_header(struct archive_read *a, struct archive_entry *entry,
flagbyte = *(p + offset++);
flagbits = 8;
}
-
+
flagbits -= 2;
switch((flagbyte >> flagbits) & 3)
{
@@ -2611,7 +2672,7 @@ expand(struct archive_read *a, int64_t end)
if ((symbol = read_next_symbol(a, &rar->maincode)) < 0)
return (ARCHIVE_FATAL);
rar->output_last_match = 0;
-
+
if (symbol < 256)
{
lzss_emit_literal(rar, symbol);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c
index 8434978..efa2c6a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_raw.c
@@ -78,7 +78,9 @@ archive_read_support_format_raw(struct archive *_a)
archive_read_format_raw_read_data,
archive_read_format_raw_read_data_skip,
NULL,
- archive_read_format_raw_cleanup);
+ archive_read_format_raw_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(info);
return (r);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
index c7c808f..734424d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
@@ -151,6 +151,8 @@ struct tar {
struct archive_string_conv *sconv_default;
int init_default_conversion;
int compat_2x;
+ int process_mac_extensions;
+ int read_concatenated_archives;
};
static int archive_block_is_null(const char *p);
@@ -241,6 +243,10 @@ archive_read_support_format_tar(struct archive *_a)
ARCHIVE_STATE_NEW, "archive_read_support_format_tar");
tar = (struct tar *)calloc(1, sizeof(*tar));
+#ifdef HAVE_COPYFILE_H
+ /* Set this by default on Mac OS. */
+ tar->process_mac_extensions = 1;
+#endif
if (tar == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate tar data");
@@ -254,7 +260,9 @@ archive_read_support_format_tar(struct archive *_a)
archive_read_format_tar_read_data,
archive_read_format_tar_skip,
NULL,
- archive_read_format_tar_cleanup);
+ archive_read_format_tar_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(tar);
@@ -368,7 +376,7 @@ archive_read_format_tar_options(struct archive_read *a,
tar = (struct tar *)(a->format->data);
if (strcmp(key, "compat-2x") == 0) {
/* Handle UTF-8 filnames as libarchive 2.x */
- tar->compat_2x = (val != NULL)?1:0;
+ tar->compat_2x = (val != NULL && val[0] != 0);
tar->init_default_conversion = tar->compat_2x;
return (ARCHIVE_OK);
} else if (strcmp(key, "hdrcharset") == 0) {
@@ -385,6 +393,12 @@ archive_read_format_tar_options(struct archive_read *a,
ret = ARCHIVE_FATAL;
}
return (ret);
+ } else if (strcmp(key, "mac-ext") == 0) {
+ tar->process_mac_extensions = (val != NULL && val[0] != 0);
+ return (ARCHIVE_OK);
+ } else if (strcmp(key, "read_concatenated_archives") == 0) {
+ tar->read_concatenated_archives = (val != NULL && val[0] != 0);
+ return (ARCHIVE_OK);
}
/* Note: The "warn" return is just to inform the options
@@ -397,7 +411,7 @@ archive_read_format_tar_options(struct archive_read *a,
* how much unconsumed data we have floating around, and to consume
* anything outstanding since we're going to do read_aheads
*/
-static void
+static void
tar_flush_unconsumed(struct archive_read *a, size_t *unconsumed)
{
if (*unconsumed) {
@@ -590,7 +604,7 @@ archive_read_format_tar_skip(struct archive_read *a)
tar = (struct tar *)(a->format->data);
bytes_skipped = __archive_read_consume(a,
- tar->entry_bytes_remaining + tar->entry_padding +
+ tar->entry_bytes_remaining + tar->entry_padding +
tar->entry_bytes_unconsumed);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
@@ -619,36 +633,50 @@ tar_read_header(struct archive_read *a, struct tar *tar,
const struct archive_entry_header_ustar *header;
const struct archive_entry_header_gnutar *gnuheader;
- tar_flush_unconsumed(a, unconsumed);
+ /* Loop until we find a workable header record. */
+ for (;;) {
+ tar_flush_unconsumed(a, unconsumed);
- /* Read 512-byte header record */
- h = __archive_read_ahead(a, 512, &bytes);
- if (bytes < 0)
- return ((int)bytes);
- if (bytes == 0) { /* EOF at a block boundary. */
- /* Some writers do omit the block of nulls. <sigh> */
- return (ARCHIVE_EOF);
- }
- if (bytes < 512) { /* Short block at EOF; this is bad. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated tar archive");
- return (ARCHIVE_FATAL);
- }
- *unconsumed = 512;
+ /* Read 512-byte header record */
+ h = __archive_read_ahead(a, 512, &bytes);
+ if (bytes < 0)
+ return ((int)bytes);
+ if (bytes == 0) { /* EOF at a block boundary. */
+ /* Some writers do omit the block of nulls. <sigh> */
+ return (ARCHIVE_EOF);
+ }
+ if (bytes < 512) { /* Short block at EOF; this is bad. */
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated tar archive");
+ return (ARCHIVE_FATAL);
+ }
+ *unconsumed = 512;
- /* Check for end-of-archive mark. */
- if (h[0] == 0 && archive_block_is_null(h)) {
- /* Try to consume a second all-null record, as well. */
- tar_flush_unconsumed(a, unconsumed);
- h = __archive_read_ahead(a, 512, NULL);
- if (h != NULL)
- __archive_read_consume(a, 512);
- archive_clear_error(&a->archive);
+ /* Header is workable if it's not an end-of-archive mark. */
+ if (h[0] != 0 || !archive_block_is_null(h))
+ break;
+
+ /* Ensure format is set for archives with only null blocks. */
if (a->archive.archive_format_name == NULL) {
a->archive.archive_format = ARCHIVE_FORMAT_TAR;
a->archive.archive_format_name = "tar";
}
- return (ARCHIVE_EOF);
+
+ if (!tar->read_concatenated_archives) {
+ /* Try to consume a second all-null record, as well. */
+ tar_flush_unconsumed(a, unconsumed);
+ h = __archive_read_ahead(a, 512, NULL);
+ if (h != NULL && h[0] == 0 && archive_block_is_null(h))
+ __archive_read_consume(a, 512);
+ archive_clear_error(&a->archive);
+ return (ARCHIVE_EOF);
+ }
+
+ /*
+ * We're reading concatenated archives, ignore this block and
+ * loop to get the next.
+ */
}
/*
@@ -683,6 +711,8 @@ tar_read_header(struct archive_read *a, struct tar *tar,
a->archive.archive_format = ARCHIVE_FORMAT_TAR_PAX_INTERCHANGE;
a->archive.archive_format_name = "POSIX pax interchange format";
err = header_pax_global(a, tar, entry, h, unconsumed);
+ if (err == ARCHIVE_EOF)
+ return (err);
break;
case 'K': /* Long link name (GNU tar, others) */
err = header_longlink(a, tar, entry, h, unconsumed);
@@ -735,9 +765,9 @@ tar_read_header(struct archive_read *a, struct tar *tar,
* extensions for both the AppleDouble extension entry and the
* regular entry.
*/
- /* TODO: Should this be disabled on non-Mac platforms? */
if ((err == ARCHIVE_WARN || err == ARCHIVE_OK) &&
- tar->header_recursion_depth == 0) {
+ tar->header_recursion_depth == 0 &&
+ tar->process_mac_extensions) {
int err2 = read_mac_metadata_blob(a, tar, entry, h, unconsumed);
if (err2 < err)
err = err2;
@@ -780,12 +810,20 @@ checksum(struct archive_read *a, const void *h)
{
const unsigned char *bytes;
const struct archive_entry_header_ustar *header;
- int check, i, sum;
+ int check, sum;
+ size_t i;
(void)a; /* UNUSED */
bytes = (const unsigned char *)h;
header = (const struct archive_entry_header_ustar *)h;
+ /* Checksum field must hold an octal number */
+ for (i = 0; i < sizeof(header->checksum); ++i) {
+ char c = header->checksum[i];
+ if (c != ' ' && c != '\0' && (c < '0' || c > '7'))
+ return 0;
+ }
+
/*
* Test the checksum. Note that POSIX specifies _unsigned_
* bytes for this calculation.
@@ -1277,7 +1315,7 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar,
if (wp[0] == '/' && wp[1] != L'\0')
wname = wp + 1;
}
- /*
+ /*
* If last path element starts with "._", then
* this is a Mac extension.
*/
@@ -1292,7 +1330,7 @@ read_mac_metadata_blob(struct archive_read *a, struct tar *tar,
if (p[0] == '/' && p[1] != '\0')
name = p + 1;
}
- /*
+ /*
* If last path element starts with "._", then
* this is a Mac extension.
*/
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
index 2530e34..af89ded 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_xar.c
@@ -468,7 +468,9 @@ archive_read_support_format_xar(struct archive *_a)
xar_read_data,
xar_read_data_skip,
NULL,
- xar_cleanup);
+ xar_cleanup,
+ NULL,
+ NULL);
if (r != ARCHIVE_OK)
free(xar);
return (r);
@@ -967,10 +969,14 @@ move_reading_point(struct archive_read *a, uint64_t offset)
return ((int)step);
xar->offset += step;
} else {
- archive_set_error(&(a->archive),
- ARCHIVE_ERRNO_MISC,
- "Cannot seek.");
- return (ARCHIVE_FAILED);
+ int64_t pos = __archive_read_seek(a, offset, SEEK_SET);
+ if (pos == ARCHIVE_FAILED) {
+ archive_set_error(&(a->archive),
+ ARCHIVE_ERRNO_MISC,
+ "Cannot seek.");
+ return (ARCHIVE_FAILED);
+ }
+ xar->offset = pos;
}
}
return (ARCHIVE_OK);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
index 2fdc08b..5ef2952 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
@@ -1,6 +1,7 @@
/*-
- * Copyright (c) 2004 Tim Kientzle
+ * Copyright (c) 2004-2013 Tim Kientzle
* Copyright (c) 2011-2012 Michihiro NAKAJIMA
+ * Copyright (c) 2013 Konrad Kleine
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -27,6 +28,20 @@
#include "archive_platform.h"
__FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102 2009-12-28 03:11:36Z kientzle $");
+/*
+ * The definitive documentation of the Zip file format is:
+ * http://www.pkware.com/documents/casestudies/APPNOTE.TXT
+ *
+ * The Info-Zip project has pioneered various extensions to better
+ * support Zip on Unix, including the 0x5455 "UT", 0x5855 "UX", 0x7855
+ * "Ux", and 0x7875 "ux" extensions for time and ownership
+ * information.
+ *
+ * History of this code: The streaming Zip reader was first added to
+ * libarchive in January 2005. Support for seekable input sources was
+ * added in Nov 2011.
+ */
+
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
@@ -49,44 +64,61 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_read_support_format_zip.c 201102
#include "archive_crc32.h"
#endif
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# define snprintf _snprintf
+#endif
+
struct zip_entry {
struct archive_rb_node node;
+ struct zip_entry *next;
int64_t local_header_offset;
int64_t compressed_size;
int64_t uncompressed_size;
int64_t gid;
int64_t uid;
- struct archive_entry *entry;
struct archive_string rsrcname;
time_t mtime;
time_t atime;
time_t ctime;
uint32_t crc32;
uint16_t mode;
- uint16_t flags;
- char compression;
- char system;
+ uint16_t zip_flags; /* From GP Flags Field */
+ unsigned char compression;
+ unsigned char system; /* From "version written by" */
+ unsigned char flags; /* Our extra markers. */
};
+/* Bits used in zip_flags. */
+#define ZIP_ENCRYPTED (1 << 0)
+#define ZIP_LENGTH_AT_END (1 << 3)
+#define ZIP_STRONG_ENCRYPTED (1 << 6)
+#define ZIP_UTF8_NAME (1 << 11)
+/* See "7.2 Single Password Symmetric Encryption Method"
+ in http://www.pkware.com/documents/casestudies/APPNOTE.TXT */
+#define ZIP_CENTRAL_DIRECTORY_ENCRYPTED (1 << 13)
+
+/* Bits used in flags. */
+#define LA_USED_ZIP64 (1 << 0)
+#define LA_FROM_CENTRAL_DIRECTORY (1 << 1)
+
struct zip {
/* Structural information about the archive. */
- int64_t end_of_central_directory_offset;
+ char format_name[64];
int64_t central_directory_offset;
- size_t central_directory_size;
- size_t central_directory_entries;
- char have_central_directory;
- int64_t offset;
+ size_t central_directory_entries_total;
+ size_t central_directory_entries_on_this_disk;
+ int has_encrypted_entries;
/* List of entries (seekable Zip only) */
- size_t entries_remaining;
struct zip_entry *zip_entries;
- struct zip_entry *entry;
struct archive_rb_tree tree;
struct archive_rb_tree tree_rsrc;
+ /* Bytes read but not yet consumed via __archive_read_consume() */
size_t unconsumed;
- /* entry_bytes_remaining is the number of bytes we expect. */
+ /* Information about entry we're currently reading. */
+ struct zip_entry *entry;
int64_t entry_bytes_remaining;
/* These count the number of bytes actually read for the entry. */
@@ -95,852 +127,364 @@ struct zip {
/* Running CRC32 of the decompressed data */
unsigned long entry_crc32;
+ unsigned long (*crc32func)(unsigned long, const void *, size_t);
+ char ignore_crc32;
/* Flags to mark progress of decompression. */
char decompress_init;
char end_of_entry;
- ssize_t filename_length;
- ssize_t extra_length;
-
+#ifdef HAVE_ZLIB_H
unsigned char *uncompressed_buffer;
size_t uncompressed_buffer_size;
-#ifdef HAVE_ZLIB_H
z_stream stream;
char stream_valid;
#endif
- struct archive_string extra;
struct archive_string_conv *sconv;
struct archive_string_conv *sconv_default;
struct archive_string_conv *sconv_utf8;
int init_default_conversion;
- char format_name[64];
+ int process_mac_extensions;
};
-#define ZIP_LENGTH_AT_END 8
-#define ZIP_ENCRYPTED (1<<0)
-#define ZIP_STRONG_ENCRYPTED (1<<6)
-#define ZIP_UTF8_NAME (1<<11)
-
-static int archive_read_format_zip_streamable_bid(struct archive_read *,
- int);
-static int archive_read_format_zip_seekable_bid(struct archive_read *,
- int);
-static int archive_read_format_zip_options(struct archive_read *,
- const char *, const char *);
-static int archive_read_format_zip_cleanup(struct archive_read *);
-static int archive_read_format_zip_read_data(struct archive_read *,
- const void **, size_t *, int64_t *);
-static int archive_read_format_zip_read_data_skip(struct archive_read *a);
-static int archive_read_format_zip_seekable_read_header(
- struct archive_read *, struct archive_entry *);
-static int archive_read_format_zip_streamable_read_header(
- struct archive_read *, struct archive_entry *);
-static ssize_t zip_get_local_file_header_size(struct archive_read *, size_t);
-#ifdef HAVE_ZLIB_H
-static int zip_deflate_init(struct archive_read *, struct zip *);
-static int zip_read_data_deflate(struct archive_read *a, const void **buff,
- size_t *size, int64_t *offset);
-#endif
-static int zip_read_data_none(struct archive_read *a, const void **buff,
- size_t *size, int64_t *offset);
-static int zip_read_local_file_header(struct archive_read *a,
- struct archive_entry *entry, struct zip *);
-static time_t zip_time(const char *);
-static const char *compression_name(int compression);
-static void process_extra(const char *, size_t, struct zip_entry *);
-
-int archive_read_support_format_zip_streamable(struct archive *);
-int archive_read_support_format_zip_seekable(struct archive *);
-
-int
-archive_read_support_format_zip_streamable(struct archive *_a)
-{
- struct archive_read *a = (struct archive_read *)_a;
- struct zip *zip;
- int r;
-
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_format_zip");
-
- zip = (struct zip *)malloc(sizeof(*zip));
- if (zip == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate zip data");
- return (ARCHIVE_FATAL);
- }
- memset(zip, 0, sizeof(*zip));
-
- r = __archive_read_register_format(a,
- zip,
- "zip",
- archive_read_format_zip_streamable_bid,
- archive_read_format_zip_options,
- archive_read_format_zip_streamable_read_header,
- archive_read_format_zip_read_data,
- archive_read_format_zip_read_data_skip,
- NULL,
- archive_read_format_zip_cleanup);
+/* Many systems define min or MIN, but not all. */
+#define zipmin(a,b) ((a) < (b) ? (a) : (b))
- if (r != ARCHIVE_OK)
- free(zip);
- return (ARCHIVE_OK);
-}
-
-int
-archive_read_support_format_zip_seekable(struct archive *_a)
-{
- struct archive_read *a = (struct archive_read *)_a;
- struct zip *zip;
- int r;
-
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable");
-
- zip = (struct zip *)malloc(sizeof(*zip));
- if (zip == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate zip data");
- return (ARCHIVE_FATAL);
- }
- memset(zip, 0, sizeof(*zip));
-
- r = __archive_read_register_format(a,
- zip,
- "zip",
- archive_read_format_zip_seekable_bid,
- archive_read_format_zip_options,
- archive_read_format_zip_seekable_read_header,
- archive_read_format_zip_read_data,
- archive_read_format_zip_read_data_skip,
- NULL,
- archive_read_format_zip_cleanup);
-
- if (r != ARCHIVE_OK)
- free(zip);
- return (ARCHIVE_OK);
-}
-
-int
-archive_read_support_format_zip(struct archive *a)
-{
- int r;
- r = archive_read_support_format_zip_streamable(a);
- if (r != ARCHIVE_OK)
- return r;
- return (archive_read_support_format_zip_seekable(a));
-}
+/* ------------------------------------------------------------------------ */
/*
- * TODO: This is a performance sink because it forces the read core to
- * drop buffered data from the start of file, which will then have to
- * be re-read again if this bidder loses.
+ * Common code for streaming or seeking modes.
*
- * We workaround this a little by passing in the best bid so far so
- * that later bidders can do nothing if they know they'll never
- * outbid. But we can certainly do better...
+ * Includes code to read local file headers, decompress data
+ * from entry bodies, and common API.
*/
-static int
-archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
-{
- struct zip *zip = (struct zip *)a->format->data;
- int64_t filesize;
- const char *p;
-
- /* If someone has already bid more than 32, then avoid
- trashing the look-ahead buffers with a seek. */
- if (best_bid > 32)
- return (-1);
-
- filesize = __archive_read_seek(a, -22, SEEK_END);
- /* If we can't seek, then we can't bid. */
- if (filesize <= 0)
- return 0;
-
- /* TODO: More robust search for end of central directory record. */
- if ((p = __archive_read_ahead(a, 22, NULL)) == NULL)
- return 0;
- /* First four bytes are signature for end of central directory
- record. Four zero bytes ensure this isn't a multi-volume
- Zip file (which we don't yet support). */
- if (memcmp(p, "PK\005\006\000\000\000\000", 8) != 0) {
- int64_t i, tail;
- int found;
-
- /*
- * If there is a comment in end of central directory
- * record, 22 bytes are too short. we have to read more
- * to properly detect the record. Hopefully, a length
- * of the comment is not longer than 16362 bytes(16K-22).
- */
- if (filesize + 22 > 1024 * 16) {
- tail = 1024 * 16;
- filesize = __archive_read_seek(a, tail * -1, SEEK_END);
- } else {
- tail = filesize + 22;
- filesize = __archive_read_seek(a, 0, SEEK_SET);
- }
- if (filesize < 0)
- return 0;
- if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL)
- return 0;
- for (found = 0, i = 0;!found && i < tail - 22;) {
- switch (p[i]) {
- case 'P':
- if (memcmp(p+i,
- "PK\005\006\000\000\000\000", 8) == 0) {
- p += i;
- filesize += tail -
- (22 + archive_le16dec(p+20));
- found = 1;
- } else
- i += 8;
- break;
- case 'K': i += 7; break;
- case 005: i += 6; break;
- case 006: i += 5; break;
- default: i += 1; break;
- }
- }
- if (!found)
- return 0;
- }
-
- /* Since we've already done the hard work of finding the
- end of central directory record, let's save the important
- information. */
- zip->central_directory_entries = archive_le16dec(p + 10);
- zip->central_directory_size = archive_le32dec(p + 12);
- zip->central_directory_offset = archive_le32dec(p + 16);
- zip->end_of_central_directory_offset = filesize;
-
- /* Just one volume, so central dir must all be on this volume. */
- if (zip->central_directory_entries != archive_le16dec(p + 8))
- return 0;
- /* Central directory can't extend beyond end of this file. */
- if (zip->central_directory_offset +
- (int64_t)zip->central_directory_size > filesize)
- return 0;
-
- /* This is just a tiny bit higher than the maximum returned by
- the streaming Zip bidder. This ensures that the more accurate
- seeking Zip parser wins whenever seek is available. */
- return 32;
-}
-static int
-cmp_node(const struct archive_rb_node *n1, const struct archive_rb_node *n2)
-{
- const struct zip_entry *e1 = (const struct zip_entry *)n1;
- const struct zip_entry *e2 = (const struct zip_entry *)n2;
-
- return ((int)(e2->local_header_offset - e1->local_header_offset));
-}
-
-static int
-cmp_key(const struct archive_rb_node *n, const void *key)
+static unsigned long
+real_crc32(unsigned long crc, const void *buff, size_t len)
{
- /* This function won't be called */
- (void)n; /* UNUSED */
- (void)key; /* UNUSED */
- return 1;
+ return crc32(crc, buff, len);
}
-static int
-rsrc_cmp_node(const struct archive_rb_node *n1,
- const struct archive_rb_node *n2)
+static unsigned long
+fake_crc32(unsigned long crc, const void *buff, size_t len)
{
- const struct zip_entry *e1 = (const struct zip_entry *)n1;
- const struct zip_entry *e2 = (const struct zip_entry *)n2;
-
- return (strcmp(e2->rsrcname.s, e1->rsrcname.s));
+ (void)crc; /* UNUSED */
+ (void)buff; /* UNUSED */
+ (void)len; /* UNUSED */
+ return 0;
}
-static int
-rsrc_cmp_key(const struct archive_rb_node *n, const void *key)
-{
- const struct zip_entry *e = (const struct zip_entry *)n;
- return (strcmp((const char *)key, e->rsrcname.s));
-}
+static struct {
+ int id;
+ const char * name;
+} compression_methods[] = {
+ {0, "uncompressed"}, /* The file is stored (no compression) */
+ {1, "shrinking"}, /* The file is Shrunk */
+ {2, "reduced-1"}, /* The file is Reduced with compression factor 1 */
+ {3, "reduced-2"}, /* The file is Reduced with compression factor 2 */
+ {4, "reduced-3"}, /* The file is Reduced with compression factor 3 */
+ {5, "reduced-4"}, /* The file is Reduced with compression factor 4 */
+ {6, "imploded"}, /* The file is Imploded */
+ {7, "reserved"}, /* Reserved for Tokenizing compression algorithm */
+ {8, "deflation"}, /* The file is Deflated */
+ {9, "deflation-64-bit"}, /* Enhanced Deflating using Deflate64(tm) */
+ {10, "ibm-terse"}, /* PKWARE Data Compression Library Imploding (old IBM TERSE) */
+ {11, "reserved"}, /* Reserved by PKWARE */
+ {12, "bzip"}, /* File is compressed using BZIP2 algorithm */
+ {13, "reserved"}, /* Reserved by PKWARE */
+ {14, "lzma"}, /* LZMA (EFS) */
+ {15, "reserved"}, /* Reserved by PKWARE */
+ {16, "reserved"}, /* Reserved by PKWARE */
+ {17, "reserved"}, /* Reserved by PKWARE */
+ {18, "ibm-terse-new"}, /* File is compressed using IBM TERSE (new) */
+ {19, "ibm-lz777"}, /* IBM LZ77 z Architecture (PFS) */
+ {97, "wav-pack"}, /* WavPack compressed data */
+ {98, "ppmd-1"} /* PPMd version I, Rev 1 */
+};
static const char *
-rsrc_basename(const char *name, size_t name_length)
+compression_name(const int compression)
{
- const char *s, *r;
-
- r = s = name;
- for (;;) {
- s = memchr(s, '/', name_length - (s - name));
- if (s == NULL)
- break;
- r = ++s;
- }
- return (r);
-}
-
-static void
-expose_parent_dirs(struct zip *zip, const char *name, size_t name_length)
-{
- struct archive_string str;
- struct zip_entry *dir;
- char *s;
-
- archive_string_init(&str);
- archive_strncpy(&str, name, name_length);
- for (;;) {
- s = strrchr(str.s, '/');
- if (s == NULL)
- break;
- *s = '\0';
- /* Transfer the parent directory from zip->tree_rsrc RB
- * tree to zip->tree RB tree to expose. */
- dir = (struct zip_entry *)
- __archive_rb_tree_find_node(&zip->tree_rsrc, str.s);
- if (dir == NULL)
- break;
- __archive_rb_tree_remove_node(&zip->tree_rsrc, &dir->node);
- archive_string_free(&dir->rsrcname);
- __archive_rb_tree_insert_node(&zip->tree, &dir->node);
- }
- archive_string_free(&str);
-}
-
-static int
-slurp_central_directory(struct archive_read *a, struct zip *zip)
-{
- unsigned i;
- int64_t correction;
- static const struct archive_rb_tree_ops rb_ops = {
- &cmp_node, &cmp_key
- };
- static const struct archive_rb_tree_ops rb_rsrc_ops = {
- &rsrc_cmp_node, &rsrc_cmp_key
- };
-
- /*
- * Consider the archive file we are reading may be SFX.
- * So we have to calculate a SFX header size to revise
- * ZIP header offsets.
- */
- correction = zip->end_of_central_directory_offset -
- (zip->central_directory_offset + zip->central_directory_size);
- /* The central directory offset is relative value, and so
- * we revise this offset for SFX. */
- zip->central_directory_offset += correction;
-
- __archive_read_seek(a, zip->central_directory_offset, SEEK_SET);
- zip->offset = zip->central_directory_offset;
- __archive_rb_tree_init(&zip->tree, &rb_ops);
- __archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops);
-
- zip->zip_entries = calloc(zip->central_directory_entries,
- sizeof(struct zip_entry));
- for (i = 0; i < zip->central_directory_entries; ++i) {
- struct zip_entry *zip_entry = &zip->zip_entries[i];
- size_t filename_length, extra_length, comment_length;
- uint32_t external_attributes;
- const char *name, *p, *r;
-
- if ((p = __archive_read_ahead(a, 46, NULL)) == NULL)
- return ARCHIVE_FATAL;
- if (memcmp(p, "PK\001\002", 4) != 0) {
- archive_set_error(&a->archive,
- -1, "Invalid central directory signature");
- return ARCHIVE_FATAL;
- }
- zip->have_central_directory = 1;
- /* version = p[4]; */
- zip_entry->system = p[5];
- /* version_required = archive_le16dec(p + 6); */
- zip_entry->flags = archive_le16dec(p + 8);
- zip_entry->compression = (char)archive_le16dec(p + 10);
- zip_entry->mtime = zip_time(p + 12);
- zip_entry->crc32 = archive_le32dec(p + 16);
- zip_entry->compressed_size = archive_le32dec(p + 20);
- zip_entry->uncompressed_size = archive_le32dec(p + 24);
- filename_length = archive_le16dec(p + 28);
- extra_length = archive_le16dec(p + 30);
- comment_length = archive_le16dec(p + 32);
- /* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */
- /* internal_attributes = archive_le16dec(p + 36); */ /* text bit */
- external_attributes = archive_le32dec(p + 38);
- zip_entry->local_header_offset =
- archive_le32dec(p + 42) + correction;
-
- /* If we can't guess the mode, leave it zero here;
- when we read the local file header we might get
- more information. */
- zip_entry->mode = 0;
- if (zip_entry->system == 3) {
- zip_entry->mode = external_attributes >> 16;
+ static const int num_compression_methods = sizeof(compression_methods)/sizeof(compression_methods[0]);
+ int i=0;
+ while(compression >= 0 && i < num_compression_methods) {
+ if (compression_methods[i].id == compression) {
+ return compression_methods[i].name;
}
-
- /*
- * Mac resource fork files are stored under the
- * "__MACOSX/" directory, so we should check if
- * it is.
- */
- /* Make sure we have the file name. */
- if ((p = __archive_read_ahead(a, 46 + filename_length, NULL))
- == NULL)
- return ARCHIVE_FATAL;
- name = p + 46;
- r = rsrc_basename(name, filename_length);
- if (filename_length >= 9 &&
- strncmp("__MACOSX/", name, 9) == 0) {
- /* If this file is not a resource fork nor
- * a directory. We should treat it as a non
- * resource fork file to expose it. */
- if (name[filename_length-1] != '/' &&
- (r - name < 3 || r[0] != '.' || r[1] != '_')) {
- __archive_rb_tree_insert_node(&zip->tree,
- &zip_entry->node);
- /* Expose its parent directories. */
- expose_parent_dirs(zip, name, filename_length);
- } else {
- /* This file is a resource fork file or
- * a directory. */
- archive_strncpy(&(zip_entry->rsrcname), name,
- filename_length);
- __archive_rb_tree_insert_node(&zip->tree_rsrc,
- &zip_entry->node);
- }
- } else {
- /* Generate resource fork name to find its resource
- * file at zip->tree_rsrc. */
- archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/");
- archive_strncat(&(zip_entry->rsrcname), name, r - name);
- archive_strcat(&(zip_entry->rsrcname), "._");
- archive_strncat(&(zip_entry->rsrcname),
- name + (r - name), filename_length - (r - name));
- /* Register an entry to RB tree to sort it by
- * file offset. */
- __archive_rb_tree_insert_node(&zip->tree,
- &zip_entry->node);
- }
-
- /* We don't read the filename until we get to the
- local file header. Reading it here would speed up
- table-of-contents operations (removing the need to
- find and read local file header to get the
- filename) at the cost of requiring a lot of extra
- space. */
- /* We don't read the extra block here. We assume it
- will be duplicated at the local file header. */
- __archive_read_consume(a,
- 46 + filename_length + extra_length + comment_length);
+ i++;
}
-
- return ARCHIVE_OK;
+ return "??";
}
-static int64_t
-zip_read_consume(struct archive_read *a, int64_t bytes)
+/* Convert an MSDOS-style date/time into Unix-style time. */
+static time_t
+zip_time(const char *p)
{
- struct zip *zip = (struct zip *)a->format->data;
- int64_t skip;
+ int msTime, msDate;
+ struct tm ts;
- skip = __archive_read_consume(a, bytes);
- if (skip > 0)
- zip->offset += skip;
- return (skip);
+ msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]);
+ msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]);
+
+ memset(&ts, 0, sizeof(ts));
+ ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */
+ ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */
+ ts.tm_mday = msDate & 0x1f; /* Day of month. */
+ ts.tm_hour = (msTime >> 11) & 0x1f;
+ ts.tm_min = (msTime >> 5) & 0x3f;
+ ts.tm_sec = (msTime << 1) & 0x3e;
+ ts.tm_isdst = -1;
+ return mktime(&ts);
}
-static int
-zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
- struct zip_entry *rsrc)
+/*
+ * The extra data is stored as a list of
+ * id1+size1+data1 + id2+size2+data2 ...
+ * triplets. id and size are 2 bytes each.
+ */
+static void
+process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
{
- struct zip *zip = (struct zip *)a->format->data;
- unsigned char *metadata, *mp;
- int64_t offset = zip->offset;
- size_t remaining_bytes, metadata_bytes;
- ssize_t hsize;
- int ret = ARCHIVE_OK, eof;
+ unsigned offset = 0;
- switch(rsrc->compression) {
- case 0: /* No compression. */
-#ifdef HAVE_ZLIB_H
- case 8: /* Deflate compression. */
+ while (offset < extra_length - 4)
+ {
+ unsigned short headerid = archive_le16dec(p + offset);
+ unsigned short datasize = archive_le16dec(p + offset + 2);
+ offset += 4;
+ if (offset + datasize > extra_length)
+ break;
+#ifdef DEBUG
+ fprintf(stderr, "Header id 0x%x, length %d\n",
+ headerid, datasize);
#endif
- break;
- default: /* Unsupported compression. */
- /* Return a warning. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Unsupported ZIP compression method (%s)",
- compression_name(rsrc->compression));
- /* We can't decompress this entry, but we will
- * be able to skip() it and try the next entry. */
- return (ARCHIVE_WARN);
- }
-
- if (rsrc->uncompressed_size > (128 * 1024)) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Mac metadata is too large: %jd > 128K bytes",
- (intmax_t)rsrc->uncompressed_size);
- return (ARCHIVE_WARN);
- }
-
- metadata = malloc((size_t)rsrc->uncompressed_size);
- if (metadata == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for Mac metadata");
- return (ARCHIVE_FATAL);
- }
-
- if (zip->offset < rsrc->local_header_offset)
- zip_read_consume(a, rsrc->local_header_offset - zip->offset);
- else if (zip->offset != rsrc->local_header_offset) {
- __archive_read_seek(a, rsrc->local_header_offset, SEEK_SET);
- zip->offset = zip->entry->local_header_offset;
- }
-
- hsize = zip_get_local_file_header_size(a, 0);
- zip_read_consume(a, hsize);
-
- remaining_bytes = (size_t)rsrc->compressed_size;
- metadata_bytes = (size_t)rsrc->uncompressed_size;
- mp = metadata;
- eof = 0;
- while (!eof && remaining_bytes) {
- const unsigned char *p;
- ssize_t bytes_avail;
- size_t bytes_used;
-
- p = __archive_read_ahead(a, 1, &bytes_avail);
- if (p == NULL) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated ZIP file header");
- ret = ARCHIVE_WARN;
- goto exit_mac_metadata;
- }
- if ((size_t)bytes_avail > remaining_bytes)
- bytes_avail = remaining_bytes;
- switch(rsrc->compression) {
- case 0: /* No compression. */
- memcpy(mp, p, bytes_avail);
- bytes_used = (size_t)bytes_avail;
- metadata_bytes -= bytes_used;
- mp += bytes_used;
- if (metadata_bytes == 0)
- eof = 1;
+ switch (headerid) {
+ case 0x0001:
+ /* Zip64 extended information extra field. */
+ zip_entry->flags |= LA_USED_ZIP64;
+ if (zip_entry->uncompressed_size == 0xffffffff) {
+ if (datasize < 8)
+ break;
+ zip_entry->uncompressed_size =
+ archive_le64dec(p + offset);
+ offset += 8;
+ datasize -= 8;
+ }
+ if (zip_entry->compressed_size == 0xffffffff) {
+ if (datasize < 8)
+ break;
+ zip_entry->compressed_size =
+ archive_le64dec(p + offset);
+ offset += 8;
+ datasize -= 8;
+ }
+ if (zip_entry->local_header_offset == 0xffffffff) {
+ if (datasize < 8)
+ break;
+ zip_entry->local_header_offset =
+ archive_le64dec(p + offset);
+ offset += 8;
+ datasize -= 8;
+ }
+ /* archive_le32dec(p + offset) gives disk
+ * on which file starts, but we don't handle
+ * multi-volume Zip files. */
break;
-#ifdef HAVE_ZLIB_H
- case 8: /* Deflate compression. */
+ case 0x5455:
{
- int r;
-
- ret = zip_deflate_init(a, zip);
- if (ret != ARCHIVE_OK)
- goto exit_mac_metadata;
- zip->stream.next_in =
- (Bytef *)(uintptr_t)(const void *)p;
- zip->stream.avail_in = (uInt)bytes_avail;
- zip->stream.total_in = 0;
- zip->stream.next_out = mp;
- zip->stream.avail_out = (uInt)metadata_bytes;
- zip->stream.total_out = 0;
-
- r = inflate(&zip->stream, 0);
- switch (r) {
- case Z_OK:
- break;
- case Z_STREAM_END:
- eof = 1;
- break;
- case Z_MEM_ERROR:
- archive_set_error(&a->archive, ENOMEM,
- "Out of memory for ZIP decompression");
- ret = ARCHIVE_FATAL;
- goto exit_mac_metadata;
- default:
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_MISC,
- "ZIP decompression failed (%d)", r);
- ret = ARCHIVE_FATAL;
- goto exit_mac_metadata;
+ /* Extended time field "UT". */
+ int flags = p[offset];
+ offset++;
+ datasize--;
+ /* Flag bits indicate which dates are present. */
+ if (flags & 0x01)
+ {
+#ifdef DEBUG
+ fprintf(stderr, "mtime: %lld -> %d\n",
+ (long long)zip_entry->mtime,
+ archive_le32dec(p + offset));
+#endif
+ if (datasize < 4)
+ break;
+ zip_entry->mtime = archive_le32dec(p + offset);
+ offset += 4;
+ datasize -= 4;
+ }
+ if (flags & 0x02)
+ {
+ if (datasize < 4)
+ break;
+ zip_entry->atime = archive_le32dec(p + offset);
+ offset += 4;
+ datasize -= 4;
+ }
+ if (flags & 0x04)
+ {
+ if (datasize < 4)
+ break;
+ zip_entry->ctime = archive_le32dec(p + offset);
+ offset += 4;
+ datasize -= 4;
}
- bytes_used = zip->stream.total_in;
- metadata_bytes -= zip->stream.total_out;
- mp += zip->stream.total_out;
break;
}
-#endif
- default:
- bytes_used = 0;
+ case 0x5855:
+ {
+ /* Info-ZIP Unix Extra Field (old version) "UX". */
+ if (datasize >= 8) {
+ zip_entry->atime = archive_le32dec(p + offset);
+ zip_entry->mtime =
+ archive_le32dec(p + offset + 4);
+ }
+ if (datasize >= 12) {
+ zip_entry->uid =
+ archive_le16dec(p + offset + 8);
+ zip_entry->gid =
+ archive_le16dec(p + offset + 10);
+ }
break;
}
- zip_read_consume(a, bytes_used);
- remaining_bytes -= bytes_used;
- }
- archive_entry_copy_mac_metadata(entry, metadata,
- (size_t)rsrc->uncompressed_size - metadata_bytes);
-
- __archive_read_seek(a, offset, SEEK_SET);
- zip->offset = offset;
-exit_mac_metadata:
- zip->decompress_init = 0;
- free(metadata);
- return (ret);
-}
-
-static int
-archive_read_format_zip_seekable_read_header(struct archive_read *a,
- struct archive_entry *entry)
-{
- struct zip *zip = (struct zip *)a->format->data;
- struct zip_entry *rsrc;
- int r, ret = ARCHIVE_OK;
-
- a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
- if (a->archive.archive_format_name == NULL)
- a->archive.archive_format_name = "ZIP";
-
- if (zip->zip_entries == NULL) {
- r = slurp_central_directory(a, zip);
- zip->entries_remaining = zip->central_directory_entries;
- if (r != ARCHIVE_OK)
- return r;
- /* Get first entry whose local header offset is lower than
- * other entries in the archive file. */
- zip->entry =
- (struct zip_entry *)ARCHIVE_RB_TREE_MIN(&zip->tree);
- } else if (zip->entry != NULL) {
- /* Get next entry in local header offset order. */
- zip->entry = (struct zip_entry *)__archive_rb_tree_iterate(
- &zip->tree, &zip->entry->node, ARCHIVE_RB_DIR_RIGHT);
- }
-
- if (zip->entries_remaining <= 0 || zip->entry == NULL)
- return ARCHIVE_EOF;
- --zip->entries_remaining;
-
- if (zip->entry->rsrcname.s)
- rsrc = (struct zip_entry *)__archive_rb_tree_find_node(
- &zip->tree_rsrc, zip->entry->rsrcname.s);
- else
- rsrc = NULL;
-
- /* File entries are sorted by the header offset, we should mostly
- * use zip_read_consume to advance a read point to avoid redundant
- * data reading. */
- if (zip->offset < zip->entry->local_header_offset)
- zip_read_consume(a,
- zip->entry->local_header_offset - zip->offset);
- else if (zip->offset != zip->entry->local_header_offset) {
- __archive_read_seek(a, zip->entry->local_header_offset,
- SEEK_SET);
- zip->offset = zip->entry->local_header_offset;
- }
- zip->unconsumed = 0;
- r = zip_read_local_file_header(a, entry, zip);
- if (r != ARCHIVE_OK)
- return r;
- if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) {
- const void *p;
- struct archive_string_conv *sconv;
- size_t linkname_length = (size_t)archive_entry_size(entry);
-
- archive_entry_set_size(entry, 0);
- p = __archive_read_ahead(a, linkname_length, NULL);
- if (p == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Truncated Zip file");
- return ARCHIVE_FATAL;
- }
-
- sconv = zip->sconv;
- if (sconv == NULL && (zip->entry->flags & ZIP_UTF8_NAME))
- sconv = zip->sconv_utf8;
- if (sconv == NULL)
- sconv = zip->sconv_default;
- if (archive_entry_copy_symlink_l(entry, p, linkname_length,
- sconv) != 0) {
- if (errno != ENOMEM && sconv == zip->sconv_utf8 &&
- (zip->entry->flags & ZIP_UTF8_NAME))
- archive_entry_copy_symlink_l(entry, p,
- linkname_length, NULL);
- if (errno == ENOMEM) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for Symlink");
- return (ARCHIVE_FATAL);
- }
+ case 0x6c65:
+ {
+ /* Experimental 'el' field */
/*
- * Since there is no character-set regulation for
- * symlink name, do not report the conversion error
- * in an automatic conversion.
+ * Introduced Dec 2013 to provide a way to
+ * include external file attributes in local file
+ * header. This provides file type and permission
+ * information necessary to support full streaming
+ * extraction. Currently being discussed with
+ * other Zip developers... subject to change.
*/
- if (sconv != zip->sconv_utf8 ||
- (zip->entry->flags & ZIP_UTF8_NAME) == 0) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Symlink cannot be converted "
- "from %s to current locale.",
- archive_string_conversion_charset_name(
- sconv));
- ret = ARCHIVE_WARN;
- }
- }
- }
- if (rsrc) {
- int ret2 = zip_read_mac_metadata(a, entry, rsrc);
- if (ret2 < ret)
- ret = ret2;
- }
- return (ret);
-}
-
-static int
-archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid)
-{
- const char *p;
-
- (void)best_bid; /* UNUSED */
-
- if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
- return (-1);
-
- /*
- * Bid of 30 here is: 16 bits for "PK",
- * next 16-bit field has four options (-2 bits).
- * 16 + 16-2 = 30.
- */
- if (p[0] == 'P' && p[1] == 'K') {
- if ((p[2] == '\001' && p[3] == '\002')
- || (p[2] == '\003' && p[3] == '\004')
- || (p[2] == '\005' && p[3] == '\006')
- || (p[2] == '\007' && p[3] == '\010')
- || (p[2] == '0' && p[3] == '0'))
- return (30);
- }
-
- /* TODO: It's worth looking ahead a little bit for a valid
- * PK signature. In particular, that would make it possible
- * to read some UUEncoded SFX files or SFX files coming from
- * a network socket. */
-
- return (0);
-}
-
-static int
-archive_read_format_zip_options(struct archive_read *a,
- const char *key, const char *val)
-{
- struct zip *zip;
- int ret = ARCHIVE_FAILED;
-
- zip = (struct zip *)(a->format->data);
- if (strcmp(key, "compat-2x") == 0) {
- /* Handle filnames as libarchive 2.x */
- zip->init_default_conversion = (val != NULL) ? 1 : 0;
- return (ARCHIVE_OK);
- } else if (strcmp(key, "hdrcharset") == 0) {
- if (val == NULL || val[0] == 0)
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "zip: hdrcharset option needs a character-set name"
- );
- else {
- zip->sconv = archive_string_conversion_from_charset(
- &a->archive, val, 0);
- if (zip->sconv != NULL) {
- if (strcmp(val, "UTF-8") == 0)
- zip->sconv_utf8 = zip->sconv;
- ret = ARCHIVE_OK;
- } else
- ret = ARCHIVE_FATAL;
- }
- return (ret);
- }
-
- /* Note: The "warn" return is just to inform the options
- * supervisor that we didn't handle it. It will generate
- * a suitable error if no one used this option. */
- return (ARCHIVE_WARN);
-}
+ int bitmap, bitmap_last;
-static int
-archive_read_format_zip_streamable_read_header(struct archive_read *a,
- struct archive_entry *entry)
-{
- struct zip *zip;
-
- a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
- if (a->archive.archive_format_name == NULL)
- a->archive.archive_format_name = "ZIP";
+ if (datasize < 1)
+ break;
+ bitmap_last = bitmap = 0xff & p[offset];
+ offset += 1;
+ datasize -= 1;
+
+ /* We only support first 7 bits of bitmap; skip rest. */
+ while ((bitmap_last & 0x80) != 0
+ && datasize >= 1) {
+ bitmap_last = p[offset];
+ offset += 1;
+ datasize -= 1;
+ }
- zip = (struct zip *)(a->format->data);
+ if (bitmap & 1) {
+ // 2 byte "version made by"
+ if (datasize < 2)
+ break;
+ zip_entry->system
+ = archive_le16dec(p + offset) >> 8;
+ offset += 2;
+ datasize -= 2;
+ }
+ if (bitmap & 2) {
+ // 2 byte "internal file attributes"
+ uint32_t internal_attributes;
+ if (datasize < 2)
+ break;
+ internal_attributes
+ = archive_le16dec(p + offset);
+ // Not used by libarchive at present.
+ (void)internal_attributes; /* UNUSED */
+ offset += 2;
+ datasize -= 2;
+ }
+ if (bitmap & 4) {
+ // 4 byte "external file attributes"
+ uint32_t external_attributes;
+ if (datasize < 4)
+ break;
+ external_attributes
+ = archive_le32dec(p + offset);
+ if (zip_entry->system == 3) {
+ zip_entry->mode
+ = external_attributes >> 16;
+ }
+ offset += 4;
+ datasize -= 4;
+ }
+ if (bitmap & 8) {
+ // 2 byte comment length + comment
+ uint32_t comment_length;
+ if (datasize < 2)
+ break;
+ comment_length
+ = archive_le16dec(p + offset);
+ offset += 2;
+ datasize -= 2;
- /* Make sure we have a zip_entry structure to use. */
- if (zip->zip_entries == NULL) {
- zip->zip_entries = malloc(sizeof(struct zip_entry));
- if (zip->zip_entries == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Out of memory");
- return ARCHIVE_FATAL;
+ if (datasize < comment_length)
+ break;
+ // Comment is not supported by libarchive
+ offset += comment_length;
+ datasize -= comment_length;
+ }
+ break;
}
- }
- zip->entry = zip->zip_entries;
- memset(zip->entry, 0, sizeof(struct zip_entry));
-
- /* Search ahead for the next local file header. */
- zip_read_consume(a, zip->unconsumed);
- zip->unconsumed = 0;
- for (;;) {
- int64_t skipped = 0;
- const char *p, *end;
- ssize_t bytes;
-
- p = __archive_read_ahead(a, 4, &bytes);
- if (p == NULL)
- return (ARCHIVE_FATAL);
- end = p + bytes;
-
- while (p + 4 <= end) {
- if (p[0] == 'P' && p[1] == 'K') {
- if (p[2] == '\001' && p[3] == '\002')
- /* Beginning of central directory. */
- return (ARCHIVE_EOF);
+ case 0x7855:
+ /* Info-ZIP Unix Extra Field (type 2) "Ux". */
+#ifdef DEBUG
+ fprintf(stderr, "uid %d gid %d\n",
+ archive_le16dec(p + offset),
+ archive_le16dec(p + offset + 2));
+#endif
+ if (datasize >= 2)
+ zip_entry->uid = archive_le16dec(p + offset);
+ if (datasize >= 4)
+ zip_entry->gid =
+ archive_le16dec(p + offset + 2);
+ break;
+ case 0x7875:
+ {
+ /* Info-Zip Unix Extra Field (type 3) "ux". */
+ int uidsize = 0, gidsize = 0;
- if (p[2] == '\003' && p[3] == '\004') {
- /* Regular file entry. */
- zip_read_consume(a, skipped);
- return zip_read_local_file_header(a,
- entry, zip);
+ /* TODO: support arbitrary uidsize/gidsize. */
+ if (datasize >= 1 && p[offset] == 1) {/* version=1 */
+ if (datasize >= 4) {
+ /* get a uid size. */
+ uidsize = p[offset+1];
+ if (uidsize == 2)
+ zip_entry->uid =
+ archive_le16dec(
+ p + offset + 2);
+ else if (uidsize == 4 && datasize >= 6)
+ zip_entry->uid =
+ archive_le32dec(
+ p + offset + 2);
+ }
+ if (datasize >= (2 + uidsize + 3)) {
+ /* get a gid size. */
+ gidsize = p[offset+2+uidsize];
+ if (gidsize == 2)
+ zip_entry->gid =
+ archive_le16dec(
+ p+offset+2+uidsize+1);
+ else if (gidsize == 4 &&
+ datasize >= (2 + uidsize + 5))
+ zip_entry->gid =
+ archive_le32dec(
+ p+offset+2+uidsize+1);
}
-
- if (p[2] == '\005' && p[3] == '\006')
- /* End of central directory. */
- return (ARCHIVE_EOF);
}
- ++p;
- ++skipped;
+ break;
}
- zip_read_consume(a, skipped);
- }
-}
-
-static ssize_t
-zip_get_local_file_header_size(struct archive_read *a, size_t extra)
-{
- const char *p;
- ssize_t filename_length, extra_length;
-
- if ((p = __archive_read_ahead(a, extra + 30, NULL)) == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated ZIP file header");
- return (ARCHIVE_WARN);
+ default:
+ break;
+ }
+ offset += datasize;
}
- p += extra;
-
- if (memcmp(p, "PK\003\004", 4) != 0) {
- archive_set_error(&a->archive, -1, "Damaged Zip archive");
- return ARCHIVE_WARN;
+#ifdef DEBUG
+ if (offset != extra_length)
+ {
+ fprintf(stderr,
+ "Extra data field contents do not match reported size!\n");
}
- filename_length = archive_le16dec(p + 26);
- extra_length = archive_le16dec(p + 28);
-
- return (30 + filename_length + extra_length);
+#endif
}
/*
@@ -957,16 +501,18 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
size_t len, filename_length, extra_length;
struct archive_string_conv *sconv;
struct zip_entry *zip_entry = zip->entry;
- uint32_t local_crc32;
- int64_t compressed_size, uncompressed_size;
+ struct zip_entry zip_entry_central_dir;
int ret = ARCHIVE_OK;
char version;
+ /* Save a copy of the original for consistency checks. */
+ zip_entry_central_dir = *zip_entry;
+
zip->decompress_init = 0;
zip->end_of_entry = 0;
zip->entry_uncompressed_bytes_read = 0;
zip->entry_compressed_bytes_read = 0;
- zip->entry_crc32 = crc32(0, NULL, 0);
+ zip->entry_crc32 = zip->crc32func(0, NULL, 0);
/* Setup default conversion. */
if (zip->sconv == NULL && !zip->init_default_conversion) {
@@ -987,52 +533,26 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
}
version = p[4];
zip_entry->system = p[5];
- zip_entry->flags = archive_le16dec(p + 6);
+ zip_entry->zip_flags = archive_le16dec(p + 6);
+ if (zip_entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+ zip->has_encrypted_entries = 1;
+ archive_entry_set_is_data_encrypted(entry, 1);
+ if (zip_entry->zip_flags & ZIP_CENTRAL_DIRECTORY_ENCRYPTED &&
+ zip_entry->zip_flags & ZIP_ENCRYPTED &&
+ zip_entry->zip_flags & ZIP_STRONG_ENCRYPTED) {
+ archive_entry_set_is_metadata_encrypted(entry, 1);
+ return ARCHIVE_FATAL;
+ }
+ }
zip_entry->compression = (char)archive_le16dec(p + 8);
zip_entry->mtime = zip_time(p + 10);
- local_crc32 = archive_le32dec(p + 14);
- compressed_size = archive_le32dec(p + 18);
- uncompressed_size = archive_le32dec(p + 22);
+ zip_entry->crc32 = archive_le32dec(p + 14);
+ zip_entry->compressed_size = archive_le32dec(p + 18);
+ zip_entry->uncompressed_size = archive_le32dec(p + 22);
filename_length = archive_le16dec(p + 26);
extra_length = archive_le16dec(p + 28);
- zip_read_consume(a, 30);
-
- if (zip->have_central_directory) {
- /* If we read the central dir entry, we must have size
- * information as well, so ignore the length-at-end flag. */
- zip_entry->flags &= ~ZIP_LENGTH_AT_END;
- /* If we have values from both the local file header
- and the central directory, warn about mismatches
- which might indicate a damaged file. But some
- writers always put zero in the local header; don't
- bother warning about that. */
- if (local_crc32 != 0 && local_crc32 != zip_entry->crc32) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Inconsistent CRC32 values");
- ret = ARCHIVE_WARN;
- }
- if (compressed_size != 0
- && compressed_size != zip_entry->compressed_size) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Inconsistent compressed size");
- ret = ARCHIVE_WARN;
- }
- if (uncompressed_size != 0
- && uncompressed_size != zip_entry->uncompressed_size) {
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Inconsistent uncompressed size");
- ret = ARCHIVE_WARN;
- }
- } else {
- /* If we don't have the CD info, use whatever we do have. */
- zip_entry->crc32 = local_crc32;
- zip_entry->compressed_size = compressed_size;
- zip_entry->uncompressed_size = uncompressed_size;
- }
+ __archive_read_consume(a, 30);
/* Read the filename. */
if ((h = __archive_read_ahead(a, filename_length, NULL)) == NULL) {
@@ -1040,7 +560,7 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
"Truncated ZIP file header");
return (ARCHIVE_FATAL);
}
- if (zip_entry->flags & ZIP_UTF8_NAME) {
+ if (zip_entry->zip_flags & ZIP_UTF8_NAME) {
/* The filename is stored to be UTF-8. */
if (zip->sconv_utf8 == NULL) {
zip->sconv_utf8 =
@@ -1069,26 +589,38 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
archive_string_conversion_charset_name(sconv));
ret = ARCHIVE_WARN;
}
- zip_read_consume(a, filename_length);
+ __archive_read_consume(a, filename_length);
+
+ /* Work around a bug in Info-Zip: When reading from a pipe, it
+ * stats the pipe instead of synthesizing a file entry. */
+ if ((zip_entry->mode & AE_IFMT) == AE_IFIFO) {
+ zip_entry->mode &= ~ AE_IFMT;
+ zip_entry->mode |= AE_IFREG;
+ }
- if (zip_entry->mode == 0) {
+ if ((zip_entry->mode & AE_IFMT) == 0) {
/* Especially in streaming mode, we can end up
- here without having seen any mode information.
+ here without having seen proper mode information.
Guess from the filename. */
wp = archive_entry_pathname_w(entry);
if (wp != NULL) {
len = wcslen(wp);
if (len > 0 && wp[len - 1] == L'/')
- zip_entry->mode = AE_IFDIR | 0777;
+ zip_entry->mode |= AE_IFDIR;
else
- zip_entry->mode = AE_IFREG | 0666;
+ zip_entry->mode |= AE_IFREG;
} else {
cp = archive_entry_pathname(entry);
len = (cp != NULL)?strlen(cp):0;
if (len > 0 && cp[len - 1] == '/')
- zip_entry->mode = AE_IFDIR | 0777;
+ zip_entry->mode |= AE_IFDIR;
else
- zip_entry->mode = AE_IFREG | 0666;
+ zip_entry->mode |= AE_IFREG;
+ }
+ if (zip_entry->mode == AE_IFDIR) {
+ zip_entry->mode |= 0775;
+ } else if (zip_entry->mode == AE_IFREG) {
+ zip_entry->mode |= 0664;
}
}
@@ -1098,8 +630,53 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
"Truncated ZIP file header");
return (ARCHIVE_FATAL);
}
+
process_extra(h, extra_length, zip_entry);
- zip_read_consume(a, extra_length);
+ __archive_read_consume(a, extra_length);
+
+ if (zip_entry->flags & LA_FROM_CENTRAL_DIRECTORY) {
+ /* If this came from the central dir, it's size info
+ * is definitive, so ignore the length-at-end flag. */
+ zip_entry->zip_flags &= ~ZIP_LENGTH_AT_END;
+ /* If local header is missing a value, use the one from
+ the central directory. If both have it, warn about
+ mismatches. */
+ if (zip_entry->crc32 == 0) {
+ zip_entry->crc32 = zip_entry_central_dir.crc32;
+ } else if (!zip->ignore_crc32
+ && zip_entry->crc32 != zip_entry_central_dir.crc32) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Inconsistent CRC32 values");
+ ret = ARCHIVE_WARN;
+ }
+ if (zip_entry->compressed_size == 0) {
+ zip_entry->compressed_size
+ = zip_entry_central_dir.compressed_size;
+ } else if (zip_entry->compressed_size
+ != zip_entry_central_dir.compressed_size) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Inconsistent compressed size: "
+ "%jd in central directory, %jd in local header",
+ (intmax_t)zip_entry_central_dir.compressed_size,
+ (intmax_t)zip_entry->compressed_size);
+ ret = ARCHIVE_WARN;
+ }
+ if (zip_entry->uncompressed_size == 0) {
+ zip_entry->uncompressed_size
+ = zip_entry_central_dir.uncompressed_size;
+ } else if (zip_entry->uncompressed_size
+ != zip_entry_central_dir.uncompressed_size) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Inconsistent uncompressed size: "
+ "%jd in central directory, %jd in local header",
+ (intmax_t)zip_entry_central_dir.uncompressed_size,
+ (intmax_t)zip_entry->uncompressed_size);
+ ret = ARCHIVE_WARN;
+ }
+ }
/* Populate some additional entry fields: */
archive_entry_set_mode(entry, zip_entry->mode);
@@ -1108,19 +685,70 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
archive_entry_set_mtime(entry, zip_entry->mtime, 0);
archive_entry_set_ctime(entry, zip_entry->ctime, 0);
archive_entry_set_atime(entry, zip_entry->atime, 0);
- /* Set the size only if it's meaningful. */
- if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END))
- archive_entry_set_size(entry, zip_entry->uncompressed_size);
+ if ((zip->entry->mode & AE_IFMT) == AE_IFLNK) {
+ size_t linkname_length = zip_entry->compressed_size;
+
+ archive_entry_set_size(entry, 0);
+ p = __archive_read_ahead(a, linkname_length, NULL);
+ if (p == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Truncated Zip file");
+ return ARCHIVE_FATAL;
+ }
+ if (__archive_read_consume(a, linkname_length) < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Read error skipping symlink target name");
+ return ARCHIVE_FATAL;
+ }
+
+ sconv = zip->sconv;
+ if (sconv == NULL && (zip->entry->zip_flags & ZIP_UTF8_NAME))
+ sconv = zip->sconv_utf8;
+ if (sconv == NULL)
+ sconv = zip->sconv_default;
+ if (archive_entry_copy_symlink_l(entry, p, linkname_length,
+ sconv) != 0) {
+ if (errno != ENOMEM && sconv == zip->sconv_utf8 &&
+ (zip->entry->zip_flags & ZIP_UTF8_NAME))
+ archive_entry_copy_symlink_l(entry, p,
+ linkname_length, NULL);
+ if (errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Symlink");
+ return (ARCHIVE_FATAL);
+ }
+ /*
+ * Since there is no character-set regulation for
+ * symlink name, do not report the conversion error
+ * in an automatic conversion.
+ */
+ if (sconv != zip->sconv_utf8 ||
+ (zip->entry->zip_flags & ZIP_UTF8_NAME) == 0) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Symlink cannot be converted "
+ "from %s to current locale.",
+ archive_string_conversion_charset_name(
+ sconv));
+ ret = ARCHIVE_WARN;
+ }
+ }
+ zip_entry->uncompressed_size = zip_entry->compressed_size = 0;
+ } else if (0 == (zip_entry->zip_flags & ZIP_LENGTH_AT_END)
+ || zip_entry->uncompressed_size > 0) {
+ /* Set the size only if it's meaningful. */
+ archive_entry_set_size(entry, zip_entry->uncompressed_size);
+ }
zip->entry_bytes_remaining = zip_entry->compressed_size;
/* If there's no body, force read_data() to return EOF immediately. */
- if (0 == (zip_entry->flags & ZIP_LENGTH_AT_END)
+ if (0 == (zip_entry->zip_flags & ZIP_LENGTH_AT_END)
&& zip->entry_bytes_remaining < 1)
zip->end_of_entry = 1;
/* Set up a more descriptive format name. */
- sprintf(zip->format_name, "ZIP %d.%d (%s)",
+ snprintf(zip->format_name, sizeof(zip->format_name), "ZIP %d.%d (%s)",
version / 10, version % 10,
compression_name(zip->entry->compression));
a->archive.archive_format_name = zip->format_name;
@@ -1128,138 +756,6 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
return (ret);
}
-static const char *
-compression_name(int compression)
-{
- static const char *compression_names[] = {
- "uncompressed",
- "shrinking",
- "reduced-1",
- "reduced-2",
- "reduced-3",
- "reduced-4",
- "imploded",
- "reserved",
- "deflation"
- };
-
- if (0 <= compression && compression <
- (int)(sizeof(compression_names)/sizeof(compression_names[0])))
- return compression_names[compression];
- else
- return "??";
-}
-
-/* Convert an MSDOS-style date/time into Unix-style time. */
-static time_t
-zip_time(const char *p)
-{
- int msTime, msDate;
- struct tm ts;
-
- msTime = (0xff & (unsigned)p[0]) + 256 * (0xff & (unsigned)p[1]);
- msDate = (0xff & (unsigned)p[2]) + 256 * (0xff & (unsigned)p[3]);
-
- memset(&ts, 0, sizeof(ts));
- ts.tm_year = ((msDate >> 9) & 0x7f) + 80; /* Years since 1900. */
- ts.tm_mon = ((msDate >> 5) & 0x0f) - 1; /* Month number. */
- ts.tm_mday = msDate & 0x1f; /* Day of month. */
- ts.tm_hour = (msTime >> 11) & 0x1f;
- ts.tm_min = (msTime >> 5) & 0x3f;
- ts.tm_sec = (msTime << 1) & 0x3e;
- ts.tm_isdst = -1;
- return mktime(&ts);
-}
-
-static int
-archive_read_format_zip_read_data(struct archive_read *a,
- const void **buff, size_t *size, int64_t *offset)
-{
- int r;
- struct zip *zip = (struct zip *)(a->format->data);
-
- *offset = zip->entry_uncompressed_bytes_read;
- *size = 0;
- *buff = NULL;
-
- /* If we hit end-of-entry last time, return ARCHIVE_EOF. */
- if (zip->end_of_entry)
- return (ARCHIVE_EOF);
-
- /* Return EOF immediately if this is a non-regular file. */
- if (AE_IFREG != (zip->entry->mode & AE_IFMT))
- return (ARCHIVE_EOF);
-
- if (zip->entry->flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Encrypted file is unsupported");
- return (ARCHIVE_FAILED);
- }
-
- zip_read_consume(a, zip->unconsumed);
- zip->unconsumed = 0;
-
- switch(zip->entry->compression) {
- case 0: /* No compression. */
- r = zip_read_data_none(a, buff, size, offset);
- break;
-#ifdef HAVE_ZLIB_H
- case 8: /* Deflate compression. */
- r = zip_read_data_deflate(a, buff, size, offset);
- break;
-#endif
- default: /* Unsupported compression. */
- /* Return a warning. */
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Unsupported ZIP compression method (%s)",
- compression_name(zip->entry->compression));
- /* We can't decompress this entry, but we will
- * be able to skip() it and try the next entry. */
- return (ARCHIVE_FAILED);
- break;
- }
- if (r != ARCHIVE_OK)
- return (r);
- /* Update checksum */
- if (*size)
- zip->entry_crc32 = crc32(zip->entry_crc32, *buff,
- (unsigned)*size);
- /* If we hit the end, swallow any end-of-data marker. */
- if (zip->end_of_entry) {
- /* Check file size, CRC against these values. */
- if (zip->entry->compressed_size !=
- zip->entry_compressed_bytes_read) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "ZIP compressed data is wrong size "
- "(read %jd, expected %jd)",
- (intmax_t)zip->entry_compressed_bytes_read,
- (intmax_t)zip->entry->compressed_size);
- return (ARCHIVE_WARN);
- }
- /* Size field only stores the lower 32 bits of the actual
- * size. */
- if ((zip->entry->uncompressed_size & UINT32_MAX)
- != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "ZIP uncompressed data is wrong size "
- "(read %jd, expected %jd)",
- (intmax_t)zip->entry_uncompressed_bytes_read,
- (intmax_t)zip->entry->uncompressed_size);
- return (ARCHIVE_WARN);
- }
- /* Check computed CRC against header */
- if (zip->entry->crc32 != zip->entry_crc32) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "ZIP bad CRC: 0x%lx should be 0x%lx",
- (unsigned long)zip->entry_crc32,
- (unsigned long)zip->entry->crc32);
- return (ARCHIVE_WARN);
- }
- }
-
- return (ARCHIVE_OK);
-}
-
/*
* Read "uncompressed" data. There are three cases:
* 1) We know the size of the data. This is always true for the
@@ -1276,9 +772,10 @@ archive_read_format_zip_read_data(struct archive_read *a,
* TODO: Technically, the PK\007\010 signature is optional.
* In the original spec, the data descriptor contained CRC
* and size fields but had no leading signature. In practice,
- * newer writers seem to provide the signature pretty consistently,
- * but we might need to do something more complex here if
- * we want to handle older archives that lack that signature.
+ * newer writers seem to provide the signature pretty consistently.
+ *
+ * For uncompressed data, the PK\007\010 marker seems essential
+ * to be sure we've actually seen the end of the entry.
*
* Returns ARCHIVE_OK if successful, ARCHIVE_FATAL otherwise, sets
* zip->end_of_entry if it consumes all of the data.
@@ -1295,35 +792,40 @@ zip_read_data_none(struct archive_read *a, const void **_buff,
zip = (struct zip *)(a->format->data);
- if (zip->entry->flags & ZIP_LENGTH_AT_END) {
+ if (zip->entry->zip_flags & ZIP_LENGTH_AT_END) {
const char *p;
- /* Grab at least 16 bytes. */
- buff = __archive_read_ahead(a, 16, &bytes_avail);
- if (bytes_avail < 16) {
+ /* Grab at least 24 bytes. */
+ buff = __archive_read_ahead(a, 24, &bytes_avail);
+ if (bytes_avail < 24) {
/* Zip archives have end-of-archive markers
that are longer than this, so a failure to get at
- least 16 bytes really does indicate a truncated
+ least 24 bytes really does indicate a truncated
file. */
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP file data");
return (ARCHIVE_FATAL);
}
- /* Check for a complete PK\007\010 signature. */
+ /* Check for a complete PK\007\010 signature, followed
+ * by the correct 4-byte CRC. */
p = buff;
- if (p[0] == 'P' && p[1] == 'K'
+ if (p[0] == 'P' && p[1] == 'K'
&& p[2] == '\007' && p[3] == '\010'
- && archive_le32dec(p + 4) == zip->entry_crc32
- && archive_le32dec(p + 8) ==
- zip->entry_compressed_bytes_read
- && archive_le32dec(p + 12) ==
- zip->entry_uncompressed_bytes_read) {
- zip->entry->crc32 = archive_le32dec(p + 4);
- zip->entry->compressed_size = archive_le32dec(p + 8);
- zip->entry->uncompressed_size = archive_le32dec(p + 12);
+ && (archive_le32dec(p + 4) == zip->entry_crc32
+ || zip->ignore_crc32)) {
+ if (zip->entry->flags & LA_USED_ZIP64) {
+ zip->entry->crc32 = archive_le32dec(p + 4);
+ zip->entry->compressed_size = archive_le64dec(p + 8);
+ zip->entry->uncompressed_size = archive_le64dec(p + 16);
+ zip->unconsumed = 24;
+ } else {
+ zip->entry->crc32 = archive_le32dec(p + 4);
+ zip->entry->compressed_size = archive_le32dec(p + 8);
+ zip->entry->uncompressed_size = archive_le32dec(p + 12);
+ zip->unconsumed = 16;
+ }
zip->end_of_entry = 1;
- zip->unconsumed = 16;
return (ARCHIVE_OK);
}
/* If not at EOF, ensure we consume at least one byte. */
@@ -1430,7 +932,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
* decompressor to combine reads by copying data.
*/
compressed_buff = __archive_read_ahead(a, 1, &bytes_avail);
- if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)
+ if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END)
&& bytes_avail > zip->entry_bytes_remaining) {
bytes_avail = (ssize_t)zip->entry_bytes_remaining;
}
@@ -1472,7 +974,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
/* Consume as much as the compressor actually used. */
bytes_avail = zip->stream.total_in;
- zip_read_consume(a, bytes_avail);
+ __archive_read_consume(a, bytes_avail);
zip->entry_bytes_remaining -= bytes_avail;
zip->entry_compressed_bytes_read += bytes_avail;
@@ -1480,10 +982,10 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
zip->entry_uncompressed_bytes_read += zip->stream.total_out;
*buff = zip->uncompressed_buffer;
- if (zip->end_of_entry && (zip->entry->flags & ZIP_LENGTH_AT_END)) {
+ if (zip->end_of_entry && (zip->entry->zip_flags & ZIP_LENGTH_AT_END)) {
const char *p;
- if (NULL == (p = __archive_read_ahead(a, 16, NULL))) {
+ if (NULL == (p = __archive_read_ahead(a, 24, NULL))) {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
"Truncated ZIP end-of-file record");
@@ -1492,36 +994,378 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
/* Consume the optional PK\007\010 marker. */
if (p[0] == 'P' && p[1] == 'K' &&
p[2] == '\007' && p[3] == '\010') {
- zip->entry->crc32 = archive_le32dec(p + 4);
- zip->entry->compressed_size = archive_le32dec(p + 8);
- zip->entry->uncompressed_size = archive_le32dec(p + 12);
- zip->unconsumed = 16;
+ p += 4;
+ zip->unconsumed = 4;
+ }
+ if (zip->entry->flags & LA_USED_ZIP64) {
+ zip->entry->crc32 = archive_le32dec(p);
+ zip->entry->compressed_size = archive_le64dec(p + 4);
+ zip->entry->uncompressed_size = archive_le64dec(p + 12);
+ zip->unconsumed += 20;
+ } else {
+ zip->entry->crc32 = archive_le32dec(p);
+ zip->entry->compressed_size = archive_le32dec(p + 4);
+ zip->entry->uncompressed_size = archive_le32dec(p + 8);
+ zip->unconsumed += 12;
+ }
+ }
+
+ return (ARCHIVE_OK);
+}
+#endif
+
+static int
+archive_read_format_zip_read_data(struct archive_read *a,
+ const void **buff, size_t *size, int64_t *offset)
+{
+ int r;
+ struct zip *zip = (struct zip *)(a->format->data);
+
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
+
+ *offset = zip->entry_uncompressed_bytes_read;
+ *size = 0;
+ *buff = NULL;
+
+ /* If we hit end-of-entry last time, return ARCHIVE_EOF. */
+ if (zip->end_of_entry)
+ return (ARCHIVE_EOF);
+
+ /* Return EOF immediately if this is a non-regular file. */
+ if (AE_IFREG != (zip->entry->mode & AE_IFMT))
+ return (ARCHIVE_EOF);
+
+ if (zip->entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)) {
+ zip->has_encrypted_entries = 1;
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Encrypted file is unsupported");
+ return (ARCHIVE_FAILED);
+ }
+
+ __archive_read_consume(a, zip->unconsumed);
+ zip->unconsumed = 0;
+
+ switch(zip->entry->compression) {
+ case 0: /* No compression. */
+ r = zip_read_data_none(a, buff, size, offset);
+ break;
+#ifdef HAVE_ZLIB_H
+ case 8: /* Deflate compression. */
+ r = zip_read_data_deflate(a, buff, size, offset);
+ break;
+#endif
+ default: /* Unsupported compression. */
+ /* Return a warning. */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unsupported ZIP compression method (%s)",
+ compression_name(zip->entry->compression));
+ /* We can't decompress this entry, but we will
+ * be able to skip() it and try the next entry. */
+ return (ARCHIVE_FAILED);
+ break;
+ }
+ if (r != ARCHIVE_OK)
+ return (r);
+ /* Update checksum */
+ if (*size)
+ zip->entry_crc32 = zip->crc32func(zip->entry_crc32, *buff,
+ (unsigned)*size);
+ /* If we hit the end, swallow any end-of-data marker. */
+ if (zip->end_of_entry) {
+ /* Check file size, CRC against these values. */
+ if (zip->entry->compressed_size !=
+ zip->entry_compressed_bytes_read) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "ZIP compressed data is wrong size "
+ "(read %jd, expected %jd)",
+ (intmax_t)zip->entry_compressed_bytes_read,
+ (intmax_t)zip->entry->compressed_size);
+ return (ARCHIVE_WARN);
+ }
+ /* Size field only stores the lower 32 bits of the actual
+ * size. */
+ if ((zip->entry->uncompressed_size & UINT32_MAX)
+ != (zip->entry_uncompressed_bytes_read & UINT32_MAX)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "ZIP uncompressed data is wrong size "
+ "(read %jd, expected %jd)\n",
+ (intmax_t)zip->entry_uncompressed_bytes_read,
+ (intmax_t)zip->entry->uncompressed_size);
+ return (ARCHIVE_WARN);
+ }
+ /* Check computed CRC against header */
+ if (zip->entry->crc32 != zip->entry_crc32
+ && !zip->ignore_crc32) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "ZIP bad CRC: 0x%lx should be 0x%lx",
+ (unsigned long)zip->entry_crc32,
+ (unsigned long)zip->entry->crc32);
+ return (ARCHIVE_WARN);
}
}
return (ARCHIVE_OK);
}
+
+static int
+archive_read_format_zip_cleanup(struct archive_read *a)
+{
+ struct zip *zip;
+ struct zip_entry *zip_entry, *next_zip_entry;
+
+ zip = (struct zip *)(a->format->data);
+#ifdef HAVE_ZLIB_H
+ if (zip->stream_valid)
+ inflateEnd(&zip->stream);
+ free(zip->uncompressed_buffer);
#endif
+ if (zip->zip_entries) {
+ zip_entry = zip->zip_entries;
+ while (zip_entry != NULL) {
+ next_zip_entry = zip_entry->next;
+ archive_string_free(&zip_entry->rsrcname);
+ free(zip_entry);
+ zip_entry = next_zip_entry;
+ }
+ }
+ free(zip);
+ (a->format->data) = NULL;
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_read_format_zip_has_encrypted_entries(struct archive_read *_a)
+{
+ if (_a && _a->format) {
+ struct zip * zip = (struct zip *)_a->format->data;
+ if (zip) {
+ return zip->has_encrypted_entries;
+ }
+ }
+ return ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+}
+
+static int
+archive_read_format_zip_options(struct archive_read *a,
+ const char *key, const char *val)
+{
+ struct zip *zip;
+ int ret = ARCHIVE_FAILED;
+
+ zip = (struct zip *)(a->format->data);
+ if (strcmp(key, "compat-2x") == 0) {
+ /* Handle filenames as libarchive 2.x */
+ zip->init_default_conversion = (val != NULL) ? 1 : 0;
+ return (ARCHIVE_OK);
+ } else if (strcmp(key, "hdrcharset") == 0) {
+ if (val == NULL || val[0] == 0)
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "zip: hdrcharset option needs a character-set name"
+ );
+ else {
+ zip->sconv = archive_string_conversion_from_charset(
+ &a->archive, val, 0);
+ if (zip->sconv != NULL) {
+ if (strcmp(val, "UTF-8") == 0)
+ zip->sconv_utf8 = zip->sconv;
+ ret = ARCHIVE_OK;
+ } else
+ ret = ARCHIVE_FATAL;
+ }
+ return (ret);
+ } else if (strcmp(key, "ignorecrc32") == 0) {
+ /* Mostly useful for testing. */
+ if (val == NULL || val[0] == 0) {
+ zip->crc32func = real_crc32;
+ zip->ignore_crc32 = 0;
+ } else {
+ zip->crc32func = fake_crc32;
+ zip->ignore_crc32 = 1;
+ }
+ return (ARCHIVE_OK);
+ } else if (strcmp(key, "mac-ext") == 0) {
+ zip->process_mac_extensions = (val != NULL && val[0] != 0);
+ return (ARCHIVE_OK);
+ }
+
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if no one used this option. */
+ return (ARCHIVE_WARN);
+}
+
+int
+archive_read_support_format_zip(struct archive *a)
+{
+ int r;
+ r = archive_read_support_format_zip_streamable(a);
+ if (r != ARCHIVE_OK)
+ return r;
+ return (archive_read_support_format_zip_seekable(a));
+}
+
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Streaming-mode support
+ */
+
+
+static int
+archive_read_support_format_zip_capabilities_streamable(struct archive_read * a)
+{
+ (void)a; /* UNUSED */
+ return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
+static int
+archive_read_format_zip_streamable_bid(struct archive_read *a, int best_bid)
+{
+ const char *p;
+
+ (void)best_bid; /* UNUSED */
+
+ if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
+ return (-1);
+
+ /*
+ * Bid of 29 here comes from:
+ * + 16 bits for "PK",
+ * + next 16-bit field has 6 options so contributes
+ * about 16 - log_2(6) ~= 16 - 2.6 ~= 13 bits
+ *
+ * So we've effectively verified ~29 total bits of check data.
+ */
+ if (p[0] == 'P' && p[1] == 'K') {
+ if ((p[2] == '\001' && p[3] == '\002')
+ || (p[2] == '\003' && p[3] == '\004')
+ || (p[2] == '\005' && p[3] == '\006')
+ || (p[2] == '\006' && p[3] == '\006')
+ || (p[2] == '\007' && p[3] == '\010')
+ || (p[2] == '0' && p[3] == '0'))
+ return (29);
+ }
+
+ /* TODO: It's worth looking ahead a little bit for a valid
+ * PK signature. In particular, that would make it possible
+ * to read some UUEncoded SFX files or SFX files coming from
+ * a network socket. */
+
+ return (0);
+}
static int
-archive_read_format_zip_read_data_skip(struct archive_read *a)
+archive_read_format_zip_streamable_read_header(struct archive_read *a,
+ struct archive_entry *entry)
{
struct zip *zip;
+ a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
+ if (a->archive.archive_format_name == NULL)
+ a->archive.archive_format_name = "ZIP";
+
zip = (struct zip *)(a->format->data);
+ /*
+ * It should be sufficient to call archive_read_next_header() for
+ * a reader to determine if an entry is encrypted or not. If the
+ * encryption of an entry is only detectable when calling
+ * archive_read_data(), so be it. We'll do the same check there
+ * as well.
+ */
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
+
+ /* Make sure we have a zip_entry structure to use. */
+ if (zip->zip_entries == NULL) {
+ zip->zip_entries = malloc(sizeof(struct zip_entry));
+ if (zip->zip_entries == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Out of memory");
+ return ARCHIVE_FATAL;
+ }
+ }
+ zip->entry = zip->zip_entries;
+ memset(zip->entry, 0, sizeof(struct zip_entry));
+
+ /* Search ahead for the next local file header. */
+ __archive_read_consume(a, zip->unconsumed);
+ zip->unconsumed = 0;
+ for (;;) {
+ int64_t skipped = 0;
+ const char *p, *end;
+ ssize_t bytes;
+
+ p = __archive_read_ahead(a, 4, &bytes);
+ if (p == NULL)
+ return (ARCHIVE_FATAL);
+ end = p + bytes;
+
+ while (p + 4 <= end) {
+ if (p[0] == 'P' && p[1] == 'K') {
+ if (p[2] == '\003' && p[3] == '\004') {
+ /* Regular file entry. */
+ __archive_read_consume(a, skipped);
+ return zip_read_local_file_header(a,
+ entry, zip);
+ }
+
+ /*
+ * TODO: We cannot restore permissions
+ * based only on the local file headers.
+ * Consider scanning the central
+ * directory and returning additional
+ * entries for at least directories.
+ * This would allow us to properly set
+ * directory permissions.
+ *
+ * This won't help us fix symlinks
+ * and may not help with regular file
+ * permissions, either. <sigh>
+ */
+ if (p[2] == '\001' && p[3] == '\002') {
+ return (ARCHIVE_EOF);
+ }
+
+ /* End of central directory? Must be an
+ * empty archive. */
+ if ((p[2] == '\005' && p[3] == '\006')
+ || (p[2] == '\006' && p[3] == '\006'))
+ return (ARCHIVE_EOF);
+ }
+ ++p;
+ ++skipped;
+ }
+ __archive_read_consume(a, skipped);
+ }
+}
+
+static int
+archive_read_format_zip_read_data_skip_streamable(struct archive_read *a)
+{
+ struct zip *zip;
+ int64_t bytes_skipped;
+
+ zip = (struct zip *)(a->format->data);
+ bytes_skipped = __archive_read_consume(a, zip->unconsumed);
+ zip->unconsumed = 0;
+ if (bytes_skipped < 0)
+ return (ARCHIVE_FATAL);
+
/* If we've already read to end of data, we're done. */
if (zip->end_of_entry)
return (ARCHIVE_OK);
/* So we know we're streaming... */
- if (0 == (zip->entry->flags & ZIP_LENGTH_AT_END)) {
+ if (0 == (zip->entry->zip_flags & ZIP_LENGTH_AT_END)
+ || zip->entry->compressed_size > 0) {
/* We know the compressed length, so we can just skip. */
- int64_t bytes_skipped = zip_read_consume(a,
- zip->entry_bytes_remaining + zip->unconsumed);
+ bytes_skipped = __archive_read_consume(a, zip->entry_bytes_remaining);
if (bytes_skipped < 0)
return (ARCHIVE_FATAL);
- zip->unconsumed = 0;
return (ARCHIVE_OK);
}
@@ -1544,8 +1388,6 @@ archive_read_format_zip_read_data_skip(struct archive_read *a)
#endif
default: /* Uncompressed or unknown. */
/* Scan for a PK\007\010 signature. */
- zip_read_consume(a, zip->unconsumed);
- zip->unconsumed = 0;
for (;;) {
const char *p, *buff;
ssize_t bytes_avail;
@@ -1563,180 +1405,772 @@ archive_read_format_zip_read_data_skip(struct archive_read *a)
else if (p[3] == '\007') { p += 1; }
else if (p[3] == '\010' && p[2] == '\007'
&& p[1] == 'K' && p[0] == 'P') {
- zip_read_consume(a, p - buff + 16);
+ if (zip->entry->flags & LA_USED_ZIP64)
+ __archive_read_consume(a, p - buff + 24);
+ else
+ __archive_read_consume(a, p - buff + 16);
return ARCHIVE_OK;
} else { p += 4; }
}
- zip_read_consume(a, p - buff);
+ __archive_read_consume(a, p - buff);
}
}
}
-static int
-archive_read_format_zip_cleanup(struct archive_read *a)
+int
+archive_read_support_format_zip_streamable(struct archive *_a)
{
+ struct archive_read *a = (struct archive_read *)_a;
struct zip *zip;
+ int r;
- zip = (struct zip *)(a->format->data);
-#ifdef HAVE_ZLIB_H
- if (zip->stream_valid)
- inflateEnd(&zip->stream);
-#endif
- if (zip->zip_entries && zip->central_directory_entries) {
- unsigned i;
- for (i = 0; i < zip->central_directory_entries; i++)
- archive_string_free(&(zip->zip_entries[i].rsrcname));
+ archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_read_support_format_zip");
+
+ zip = (struct zip *)malloc(sizeof(*zip));
+ if (zip == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate zip data");
+ return (ARCHIVE_FATAL);
}
- free(zip->zip_entries);
- free(zip->uncompressed_buffer);
- archive_string_free(&(zip->extra));
- free(zip);
- (a->format->data) = NULL;
+ memset(zip, 0, sizeof(*zip));
+
+ /* Streamable reader doesn't support mac extensions. */
+ zip->process_mac_extensions = 0;
+
+ /*
+ * Until enough data has been read, we cannot tell about
+ * any encrypted entries yet.
+ */
+ zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+ zip->crc32func = real_crc32;
+
+ r = __archive_read_register_format(a,
+ zip,
+ "zip",
+ archive_read_format_zip_streamable_bid,
+ archive_read_format_zip_options,
+ archive_read_format_zip_streamable_read_header,
+ archive_read_format_zip_read_data,
+ archive_read_format_zip_read_data_skip_streamable,
+ NULL,
+ archive_read_format_zip_cleanup,
+ archive_read_support_format_zip_capabilities_streamable,
+ archive_read_format_zip_has_encrypted_entries);
+
+ if (r != ARCHIVE_OK)
+ free(zip);
return (ARCHIVE_OK);
}
+/* ------------------------------------------------------------------------ */
+
+/*
+ * Seeking-mode support
+ */
+
+static int
+archive_read_support_format_zip_capabilities_seekable(struct archive_read * a)
+{
+ (void)a; /* UNUSED */
+ return (ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_DATA | ARCHIVE_READ_FORMAT_CAPS_ENCRYPT_METADATA);
+}
+
/*
- * The extra data is stored as a list of
- * id1+size1+data1 + id2+size2+data2 ...
- * triplets. id and size are 2 bytes each.
+ * TODO: This is a performance sink because it forces the read core to
+ * drop buffered data from the start of file, which will then have to
+ * be re-read again if this bidder loses.
+ *
+ * We workaround this a little by passing in the best bid so far so
+ * that later bidders can do nothing if they know they'll never
+ * outbid. But we can certainly do better...
*/
+static int
+read_eocd(struct zip *zip, const char *p, int64_t current_offset)
+{
+ /* Sanity-check the EOCD we've found. */
+
+ /* This must be the first volume. */
+ if (archive_le16dec(p + 4) != 0)
+ return 0;
+ /* Central directory must be on this volume. */
+ if (archive_le16dec(p + 4) != archive_le16dec(p + 6))
+ return 0;
+ /* All central directory entries must be on this volume. */
+ if (archive_le16dec(p + 10) != archive_le16dec(p + 8))
+ return 0;
+ /* Central directory can't extend beyond start of EOCD record. */
+ if (archive_le32dec(p + 16) + archive_le32dec(p + 12)
+ > current_offset)
+ return 0;
+
+ /* Save the central directory location for later use. */
+ zip->central_directory_offset = archive_le32dec(p + 16);
+
+ /* This is just a tiny bit higher than the maximum
+ returned by the streaming Zip bidder. This ensures
+ that the more accurate seeking Zip parser wins
+ whenever seek is available. */
+ return 32;
+}
+
+static int
+read_zip64_eocd(struct archive_read *a, struct zip *zip, const char *p)
+{
+ int64_t eocd64_offset;
+ int64_t eocd64_size;
+
+ /* Sanity-check the locator record. */
+
+ /* Central dir must be on first volume. */
+ if (archive_le32dec(p + 4) != 0)
+ return 0;
+ /* Must be only a single volume. */
+ if (archive_le32dec(p + 16) != 1)
+ return 0;
+
+ /* Find the Zip64 EOCD record. */
+ eocd64_offset = archive_le64dec(p + 8);
+ if (__archive_read_seek(a, eocd64_offset, SEEK_SET) < 0)
+ return 0;
+ if ((p = __archive_read_ahead(a, 56, NULL)) == NULL)
+ return 0;
+ /* Make sure we can read all of it. */
+ eocd64_size = archive_le64dec(p + 4) + 12;
+ if (eocd64_size < 56 || eocd64_size > 16384)
+ return 0;
+ if ((p = __archive_read_ahead(a, eocd64_size, NULL)) == NULL)
+ return 0;
+
+ /* Sanity-check the EOCD64 */
+ if (archive_le32dec(p + 16) != 0) /* Must be disk #0 */
+ return 0;
+ if (archive_le32dec(p + 20) != 0) /* CD must be on disk #0 */
+ return 0;
+ /* CD can't be split. */
+ if (archive_le64dec(p + 24) != archive_le64dec(p + 32))
+ return 0;
+
+ /* Save the central directory offset for later use. */
+ zip->central_directory_offset = archive_le64dec(p + 48);
+
+ return 32;
+}
+
+static int
+archive_read_format_zip_seekable_bid(struct archive_read *a, int best_bid)
+{
+ struct zip *zip = (struct zip *)a->format->data;
+ int64_t file_size, current_offset;
+ const char *p;
+ int i, tail;
+
+ /* If someone has already bid more than 32, then avoid
+ trashing the look-ahead buffers with a seek. */
+ if (best_bid > 32)
+ return (-1);
+
+ file_size = __archive_read_seek(a, 0, SEEK_END);
+ if (file_size <= 0)
+ return 0;
+
+ /* Search last 16k of file for end-of-central-directory
+ * record (which starts with PK\005\006) or Zip64 locator
+ * record (which begins with PK\006\007) */
+ tail = zipmin(1024 * 16, file_size);
+ current_offset = __archive_read_seek(a, -tail, SEEK_END);
+ if (current_offset < 0)
+ return 0;
+ if ((p = __archive_read_ahead(a, (size_t)tail, NULL)) == NULL)
+ return 0;
+ /* TODO: Rework this to search backwards from the end. We
+ * normally expect the EOCD record to be at the very end, so
+ * that should be significantly faster. Tricky part: Make
+ * sure we still prefer the Zip64 locator if it's present. */
+ for (i = 0; i <= tail - 22;) {
+ switch (p[i + 3]) {
+ case 'P': i += 3; break;
+ case 'K': i += 2; break;
+ case 005: i += 1; break;
+ case 006:
+ if (memcmp(p + i, "PK\005\006", 4) == 0) {
+ int ret = read_eocd(zip, p + i, current_offset + i);
+ if (ret > 0)
+ return (ret);
+ }
+ i += 1; /* Look for PK\006\007 next */
+ break;
+ case 007:
+ if (memcmp(p + i, "PK\006\007", 4) == 0) {
+ int ret = read_zip64_eocd(a, zip, p + i);
+ if (ret > 0)
+ return (ret);
+ }
+ i += 4;
+ break;
+ default: i += 4; break;
+ }
+ }
+ return 0;
+}
+
+/* The red-black trees are only used in seeking mode to manage
+ * the in-memory copy of the central directory. */
+
+static int
+cmp_node(const struct archive_rb_node *n1, const struct archive_rb_node *n2)
+{
+ const struct zip_entry *e1 = (const struct zip_entry *)n1;
+ const struct zip_entry *e2 = (const struct zip_entry *)n2;
+
+ if (e1->local_header_offset > e2->local_header_offset)
+ return -1;
+ if (e1->local_header_offset < e2->local_header_offset)
+ return 1;
+ return 0;
+}
+
+static int
+cmp_key(const struct archive_rb_node *n, const void *key)
+{
+ /* This function won't be called */
+ (void)n; /* UNUSED */
+ (void)key; /* UNUSED */
+ return 1;
+}
+
+static const struct archive_rb_tree_ops rb_ops = {
+ &cmp_node, &cmp_key
+};
+
+static int
+rsrc_cmp_node(const struct archive_rb_node *n1,
+ const struct archive_rb_node *n2)
+{
+ const struct zip_entry *e1 = (const struct zip_entry *)n1;
+ const struct zip_entry *e2 = (const struct zip_entry *)n2;
+
+ return (strcmp(e2->rsrcname.s, e1->rsrcname.s));
+}
+
+static int
+rsrc_cmp_key(const struct archive_rb_node *n, const void *key)
+{
+ const struct zip_entry *e = (const struct zip_entry *)n;
+ return (strcmp((const char *)key, e->rsrcname.s));
+}
+
+static const struct archive_rb_tree_ops rb_rsrc_ops = {
+ &rsrc_cmp_node, &rsrc_cmp_key
+};
+
+static const char *
+rsrc_basename(const char *name, size_t name_length)
+{
+ const char *s, *r;
+
+ r = s = name;
+ for (;;) {
+ s = memchr(s, '/', name_length - (s - name));
+ if (s == NULL)
+ break;
+ r = ++s;
+ }
+ return (r);
+}
+
static void
-process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
+expose_parent_dirs(struct zip *zip, const char *name, size_t name_length)
{
- unsigned offset = 0;
+ struct archive_string str;
+ struct zip_entry *dir;
+ char *s;
- while (offset < extra_length - 4)
- {
- unsigned short headerid = archive_le16dec(p + offset);
- unsigned short datasize = archive_le16dec(p + offset + 2);
- offset += 4;
- if (offset + datasize > extra_length)
+ archive_string_init(&str);
+ archive_strncpy(&str, name, name_length);
+ for (;;) {
+ s = strrchr(str.s, '/');
+ if (s == NULL)
break;
-#ifdef DEBUG
- fprintf(stderr, "Header id 0x%x, length %d\n",
- headerid, datasize);
-#endif
- switch (headerid) {
- case 0x0001:
- /* Zip64 extended information extra field. */
- if (datasize >= 8)
- zip_entry->uncompressed_size =
- archive_le64dec(p + offset);
- if (datasize >= 16)
- zip_entry->compressed_size =
- archive_le64dec(p + offset + 8);
+ *s = '\0';
+ /* Transfer the parent directory from zip->tree_rsrc RB
+ * tree to zip->tree RB tree to expose. */
+ dir = (struct zip_entry *)
+ __archive_rb_tree_find_node(&zip->tree_rsrc, str.s);
+ if (dir == NULL)
break;
- case 0x5455:
- {
- /* Extended time field "UT". */
- int flags = p[offset];
- offset++;
- datasize--;
- /* Flag bits indicate which dates are present. */
- if (flags & 0x01)
- {
-#ifdef DEBUG
- fprintf(stderr, "mtime: %lld -> %d\n",
- (long long)zip_entry->mtime,
- archive_le32dec(p + offset));
-#endif
- if (datasize < 4)
- break;
- zip_entry->mtime = archive_le32dec(p + offset);
- offset += 4;
- datasize -= 4;
- }
- if (flags & 0x02)
- {
- if (datasize < 4)
- break;
- zip_entry->atime = archive_le32dec(p + offset);
- offset += 4;
- datasize -= 4;
- }
- if (flags & 0x04)
- {
- if (datasize < 4)
- break;
- zip_entry->ctime = archive_le32dec(p + offset);
- offset += 4;
- datasize -= 4;
+ __archive_rb_tree_remove_node(&zip->tree_rsrc, &dir->node);
+ archive_string_free(&dir->rsrcname);
+ __archive_rb_tree_insert_node(&zip->tree, &dir->node);
+ }
+ archive_string_free(&str);
+}
+
+static int
+slurp_central_directory(struct archive_read *a, struct zip *zip)
+{
+ ssize_t i;
+ unsigned found;
+ int64_t correction;
+ ssize_t bytes_avail;
+ const char *p;
+
+ /*
+ * Find the start of the central directory. The end-of-CD
+ * record has our starting point, but there are lots of
+ * Zip archives which have had other data prepended to the
+ * file, which makes the recorded offsets all too small.
+ * So we search forward from the specified offset until we
+ * find the real start of the central directory. Then we
+ * know the correction we need to apply to account for leading
+ * padding.
+ */
+ if (__archive_read_seek(a, zip->central_directory_offset, SEEK_SET) < 0)
+ return ARCHIVE_FATAL;
+
+ found = 0;
+ while (!found) {
+ if ((p = __archive_read_ahead(a, 20, &bytes_avail)) == NULL)
+ return ARCHIVE_FATAL;
+ for (found = 0, i = 0; !found && i < bytes_avail - 4;) {
+ switch (p[i + 3]) {
+ case 'P': i += 3; break;
+ case 'K': i += 2; break;
+ case 001: i += 1; break;
+ case 002:
+ if (memcmp(p + i, "PK\001\002", 4) == 0) {
+ p += i;
+ found = 1;
+ } else
+ i += 4;
+ break;
+ case 005: i += 1; break;
+ case 006:
+ if (memcmp(p + i, "PK\005\006", 4) == 0) {
+ p += i;
+ found = 1;
+ } else if (memcmp(p + i, "PK\006\006", 4) == 0) {
+ p += i;
+ found = 1;
+ } else
+ i += 1;
+ break;
+ default: i += 4; break;
}
+ }
+ __archive_read_consume(a, i);
+ }
+ correction = archive_filter_bytes(&a->archive, 0) - zip->central_directory_offset;
+
+ __archive_rb_tree_init(&zip->tree, &rb_ops);
+ __archive_rb_tree_init(&zip->tree_rsrc, &rb_rsrc_ops);
+
+ zip->central_directory_entries_total = 0;
+ while (1) {
+ struct zip_entry *zip_entry;
+ size_t filename_length, extra_length, comment_length;
+ uint32_t external_attributes;
+ const char *name, *r;
+
+ if ((p = __archive_read_ahead(a, 4, NULL)) == NULL)
+ return ARCHIVE_FATAL;
+ if (memcmp(p, "PK\006\006", 4) == 0
+ || memcmp(p, "PK\005\006", 4) == 0) {
break;
+ } else if (memcmp(p, "PK\001\002", 4) != 0) {
+ archive_set_error(&a->archive,
+ -1, "Invalid central directory signature");
+ return ARCHIVE_FATAL;
}
- case 0x5855:
- {
- /* Info-ZIP Unix Extra Field (old version) "UX". */
- if (datasize >= 8) {
- zip_entry->atime = archive_le32dec(p + offset);
- zip_entry->mtime =
- archive_le32dec(p + offset + 4);
- }
- if (datasize >= 12) {
- zip_entry->uid =
- archive_le16dec(p + offset + 8);
- zip_entry->gid =
- archive_le16dec(p + offset + 10);
+ if ((p = __archive_read_ahead(a, 46, NULL)) == NULL)
+ return ARCHIVE_FATAL;
+
+ zip_entry = calloc(1, sizeof(struct zip_entry));
+ zip_entry->next = zip->zip_entries;
+ zip_entry->flags |= LA_FROM_CENTRAL_DIRECTORY;
+ zip->zip_entries = zip_entry;
+ zip->central_directory_entries_total++;
+
+ /* version = p[4]; */
+ zip_entry->system = p[5];
+ /* version_required = archive_le16dec(p + 6); */
+ zip_entry->zip_flags = archive_le16dec(p + 8);
+ if (zip_entry->zip_flags & (ZIP_ENCRYPTED | ZIP_STRONG_ENCRYPTED)){
+ zip->has_encrypted_entries = 1;
+ }
+ zip_entry->compression = (char)archive_le16dec(p + 10);
+ zip_entry->mtime = zip_time(p + 12);
+ zip_entry->crc32 = archive_le32dec(p + 16);
+ zip_entry->compressed_size = archive_le32dec(p + 20);
+ zip_entry->uncompressed_size = archive_le32dec(p + 24);
+ filename_length = archive_le16dec(p + 28);
+ extra_length = archive_le16dec(p + 30);
+ comment_length = archive_le16dec(p + 32);
+ /* disk_start = archive_le16dec(p + 34); */ /* Better be zero. */
+ /* internal_attributes = archive_le16dec(p + 36); */ /* text bit */
+ external_attributes = archive_le32dec(p + 38);
+ zip_entry->local_header_offset =
+ archive_le32dec(p + 42) + correction;
+
+ /* If we can't guess the mode, leave it zero here;
+ when we read the local file header we might get
+ more information. */
+ zip_entry->mode = 0;
+ if (zip_entry->system == 3) {
+ zip_entry->mode = external_attributes >> 16;
+ }
+
+ /* We're done with the regular data; get the filename and
+ * extra data. */
+ __archive_read_consume(a, 46);
+ if ((p = __archive_read_ahead(a, filename_length + extra_length, NULL))
+ == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated ZIP file header");
+ return ARCHIVE_FATAL;
+ }
+ process_extra(p + filename_length, extra_length, zip_entry);
+
+ /*
+ * Mac resource fork files are stored under the
+ * "__MACOSX/" directory, so we should check if
+ * it is.
+ */
+ if (!zip->process_mac_extensions) {
+ /* Treat every entry as a regular entry. */
+ __archive_rb_tree_insert_node(&zip->tree,
+ &zip_entry->node);
+ } else {
+ name = p;
+ r = rsrc_basename(name, filename_length);
+ if (filename_length >= 9 &&
+ strncmp("__MACOSX/", name, 9) == 0) {
+ /* If this file is not a resource fork nor
+ * a directory. We should treat it as a non
+ * resource fork file to expose it. */
+ if (name[filename_length-1] != '/' &&
+ (r - name < 3 || r[0] != '.' || r[1] != '_')) {
+ __archive_rb_tree_insert_node(&zip->tree,
+ &zip_entry->node);
+ /* Expose its parent directories. */
+ expose_parent_dirs(zip, name, filename_length);
+ } else {
+ /* This file is a resource fork file or
+ * a directory. */
+ archive_strncpy(&(zip_entry->rsrcname), name,
+ filename_length);
+ __archive_rb_tree_insert_node(&zip->tree_rsrc,
+ &zip_entry->node);
+ }
+ } else {
+ /* Generate resource fork name to find its resource
+ * file at zip->tree_rsrc. */
+ archive_strcpy(&(zip_entry->rsrcname), "__MACOSX/");
+ archive_strncat(&(zip_entry->rsrcname), name, r - name);
+ archive_strcat(&(zip_entry->rsrcname), "._");
+ archive_strncat(&(zip_entry->rsrcname),
+ name + (r - name), filename_length - (r - name));
+ /* Register an entry to RB tree to sort it by
+ * file offset. */
+ __archive_rb_tree_insert_node(&zip->tree,
+ &zip_entry->node);
}
- break;
}
- case 0x7855:
- /* Info-ZIP Unix Extra Field (type 2) "Ux". */
-#ifdef DEBUG
- fprintf(stderr, "uid %d gid %d\n",
- archive_le16dec(p + offset),
- archive_le16dec(p + offset + 2));
+
+ /* Skip the comment too ... */
+ __archive_read_consume(a,
+ filename_length + extra_length + comment_length);
+ }
+
+ return ARCHIVE_OK;
+}
+
+static ssize_t
+zip_get_local_file_header_size(struct archive_read *a, size_t extra)
+{
+ const char *p;
+ ssize_t filename_length, extra_length;
+
+ if ((p = __archive_read_ahead(a, extra + 30, NULL)) == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated ZIP file header");
+ return (ARCHIVE_WARN);
+ }
+ p += extra;
+
+ if (memcmp(p, "PK\003\004", 4) != 0) {
+ archive_set_error(&a->archive, -1, "Damaged Zip archive");
+ return ARCHIVE_WARN;
+ }
+ filename_length = archive_le16dec(p + 26);
+ extra_length = archive_le16dec(p + 28);
+
+ return (30 + filename_length + extra_length);
+}
+
+static int
+zip_read_mac_metadata(struct archive_read *a, struct archive_entry *entry,
+ struct zip_entry *rsrc)
+{
+ struct zip *zip = (struct zip *)a->format->data;
+ unsigned char *metadata, *mp;
+ int64_t offset = archive_filter_bytes(&a->archive, 0);
+ size_t remaining_bytes, metadata_bytes;
+ ssize_t hsize;
+ int ret = ARCHIVE_OK, eof;
+
+ switch(rsrc->compression) {
+ case 0: /* No compression. */
+#ifdef HAVE_ZLIB_H
+ case 8: /* Deflate compression. */
#endif
- if (datasize >= 2)
- zip_entry->uid = archive_le16dec(p + offset);
- if (datasize >= 4)
- zip_entry->gid =
- archive_le16dec(p + offset + 2);
+ break;
+ default: /* Unsupported compression. */
+ /* Return a warning. */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unsupported ZIP compression method (%s)",
+ compression_name(rsrc->compression));
+ /* We can't decompress this entry, but we will
+ * be able to skip() it and try the next entry. */
+ return (ARCHIVE_WARN);
+ }
+
+ if (rsrc->uncompressed_size > (4 * 1024 * 1024)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Mac metadata is too large: %jd > 4M bytes",
+ (intmax_t)rsrc->uncompressed_size);
+ return (ARCHIVE_WARN);
+ }
+
+ metadata = malloc((size_t)rsrc->uncompressed_size);
+ if (metadata == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Mac metadata");
+ return (ARCHIVE_FATAL);
+ }
+
+ if (offset < rsrc->local_header_offset)
+ __archive_read_consume(a, rsrc->local_header_offset - offset);
+ else if (offset != rsrc->local_header_offset) {
+ __archive_read_seek(a, rsrc->local_header_offset, SEEK_SET);
+ }
+
+ hsize = zip_get_local_file_header_size(a, 0);
+ __archive_read_consume(a, hsize);
+
+ remaining_bytes = (size_t)rsrc->compressed_size;
+ metadata_bytes = (size_t)rsrc->uncompressed_size;
+ mp = metadata;
+ eof = 0;
+ while (!eof && remaining_bytes) {
+ const unsigned char *p;
+ ssize_t bytes_avail;
+ size_t bytes_used;
+
+ p = __archive_read_ahead(a, 1, &bytes_avail);
+ if (p == NULL) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated ZIP file header");
+ ret = ARCHIVE_WARN;
+ goto exit_mac_metadata;
+ }
+ if ((size_t)bytes_avail > remaining_bytes)
+ bytes_avail = remaining_bytes;
+ switch(rsrc->compression) {
+ case 0: /* No compression. */
+ memcpy(mp, p, bytes_avail);
+ bytes_used = (size_t)bytes_avail;
+ metadata_bytes -= bytes_used;
+ mp += bytes_used;
+ if (metadata_bytes == 0)
+ eof = 1;
break;
- case 0x7875:
+#ifdef HAVE_ZLIB_H
+ case 8: /* Deflate compression. */
{
- /* Info-Zip Unix Extra Field (type 3) "ux". */
- int uidsize = 0, gidsize = 0;
+ int r;
- if (datasize >= 1 && p[offset] == 1) {/* version=1 */
- if (datasize >= 4) {
- /* get a uid size. */
- uidsize = p[offset+1];
- if (uidsize == 2)
- zip_entry->uid =
- archive_le16dec(
- p + offset + 2);
- else if (uidsize == 4 && datasize >= 6)
- zip_entry->uid =
- archive_le32dec(
- p + offset + 2);
- }
- if (datasize >= (2 + uidsize + 3)) {
- /* get a gid size. */
- gidsize = p[offset+2+uidsize];
- if (gidsize == 2)
- zip_entry->gid =
- archive_le16dec(
- p+offset+2+uidsize+1);
- else if (gidsize == 4 &&
- datasize >= (2 + uidsize + 5))
- zip_entry->gid =
- archive_le32dec(
- p+offset+2+uidsize+1);
- }
+ ret = zip_deflate_init(a, zip);
+ if (ret != ARCHIVE_OK)
+ goto exit_mac_metadata;
+ zip->stream.next_in =
+ (Bytef *)(uintptr_t)(const void *)p;
+ zip->stream.avail_in = (uInt)bytes_avail;
+ zip->stream.total_in = 0;
+ zip->stream.next_out = mp;
+ zip->stream.avail_out = (uInt)metadata_bytes;
+ zip->stream.total_out = 0;
+
+ r = inflate(&zip->stream, 0);
+ switch (r) {
+ case Z_OK:
+ break;
+ case Z_STREAM_END:
+ eof = 1;
+ break;
+ case Z_MEM_ERROR:
+ archive_set_error(&a->archive, ENOMEM,
+ "Out of memory for ZIP decompression");
+ ret = ARCHIVE_FATAL;
+ goto exit_mac_metadata;
+ default:
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_MISC,
+ "ZIP decompression failed (%d)", r);
+ ret = ARCHIVE_FATAL;
+ goto exit_mac_metadata;
}
+ bytes_used = zip->stream.total_in;
+ metadata_bytes -= zip->stream.total_out;
+ mp += zip->stream.total_out;
break;
}
+#endif
default:
+ bytes_used = 0;
break;
}
- offset += datasize;
+ __archive_read_consume(a, bytes_used);
+ remaining_bytes -= bytes_used;
}
-#ifdef DEBUG
- if (offset != extra_length)
- {
- fprintf(stderr,
- "Extra data field contents do not match reported size!\n");
+ archive_entry_copy_mac_metadata(entry, metadata,
+ (size_t)rsrc->uncompressed_size - metadata_bytes);
+
+exit_mac_metadata:
+ __archive_read_seek(a, offset, SEEK_SET);
+ zip->decompress_init = 0;
+ free(metadata);
+ return (ret);
+}
+
+static int
+archive_read_format_zip_seekable_read_header(struct archive_read *a,
+ struct archive_entry *entry)
+{
+ struct zip *zip = (struct zip *)a->format->data;
+ struct zip_entry *rsrc;
+ int64_t offset;
+ int r, ret = ARCHIVE_OK;
+
+ /*
+ * It should be sufficient to call archive_read_next_header() for
+ * a reader to determine if an entry is encrypted or not. If the
+ * encryption of an entry is only detectable when calling
+ * archive_read_data(), so be it. We'll do the same check there
+ * as well.
+ */
+ if (zip->has_encrypted_entries == ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW) {
+ zip->has_encrypted_entries = 0;
+ }
+
+ a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
+ if (a->archive.archive_format_name == NULL)
+ a->archive.archive_format_name = "ZIP";
+
+ if (zip->zip_entries == NULL) {
+ r = slurp_central_directory(a, zip);
+ if (r != ARCHIVE_OK)
+ return r;
+ /* Get first entry whose local header offset is lower than
+ * other entries in the archive file. */
+ zip->entry =
+ (struct zip_entry *)ARCHIVE_RB_TREE_MIN(&zip->tree);
+ } else if (zip->entry != NULL) {
+ /* Get next entry in local header offset order. */
+ zip->entry = (struct zip_entry *)__archive_rb_tree_iterate(
+ &zip->tree, &zip->entry->node, ARCHIVE_RB_DIR_RIGHT);
+ }
+
+ if (zip->entry == NULL)
+ return ARCHIVE_EOF;
+
+ if (zip->entry->rsrcname.s)
+ rsrc = (struct zip_entry *)__archive_rb_tree_find_node(
+ &zip->tree_rsrc, zip->entry->rsrcname.s);
+ else
+ rsrc = NULL;
+
+ /* File entries are sorted by the header offset, we should mostly
+ * use __archive_read_consume to advance a read point to avoid redundant
+ * data reading. */
+ offset = archive_filter_bytes(&a->archive, 0);
+ if (offset < zip->entry->local_header_offset)
+ __archive_read_consume(a,
+ zip->entry->local_header_offset - offset);
+ else if (offset != zip->entry->local_header_offset) {
+ __archive_read_seek(a, zip->entry->local_header_offset, SEEK_SET);
}
+ zip->unconsumed = 0;
+ r = zip_read_local_file_header(a, entry, zip);
+ if (r != ARCHIVE_OK)
+ return r;
+ if (rsrc) {
+ int ret2 = zip_read_mac_metadata(a, entry, rsrc);
+ if (ret2 < ret)
+ ret = ret2;
+ }
+ return (ret);
+}
+
+/*
+ * We're going to seek for the next header anyway, so we don't
+ * need to bother doing anything here.
+ */
+static int
+archive_read_format_zip_read_data_skip_seekable(struct archive_read *a)
+{
+ struct zip *zip;
+ zip = (struct zip *)(a->format->data);
+
+ zip->unconsumed = 0;
+ return (ARCHIVE_OK);
+}
+
+int
+archive_read_support_format_zip_seekable(struct archive *_a)
+{
+ struct archive_read *a = (struct archive_read *)_a;
+ struct zip *zip;
+ int r;
+
+ archive_check_magic(_a, ARCHIVE_READ_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_read_support_format_zip_seekable");
+
+ zip = (struct zip *)malloc(sizeof(*zip));
+ if (zip == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate zip data");
+ return (ARCHIVE_FATAL);
+ }
+ memset(zip, 0, sizeof(*zip));
+
+#ifdef HAVE_COPYFILE_H
+ /* Set this by default on Mac OS. */
+ zip->process_mac_extensions = 1;
#endif
+
+ /*
+ * Until enough data has been read, we cannot tell about
+ * any encrypted entries yet.
+ */
+ zip->has_encrypted_entries = ARCHIVE_READ_FORMAT_ENCRYPTION_DONT_KNOW;
+ zip->crc32func = real_crc32;
+
+ r = __archive_read_register_format(a,
+ zip,
+ "zip",
+ archive_read_format_zip_seekable_bid,
+ archive_read_format_zip_options,
+ archive_read_format_zip_seekable_read_header,
+ archive_read_format_zip_read_data,
+ archive_read_format_zip_read_data_skip_seekable,
+ NULL,
+ archive_read_format_zip_cleanup,
+ archive_read_support_format_zip_capabilities_seekable,
+ archive_read_format_zip_has_encrypted_entries);
+
+ if (r != ARCHIVE_OK)
+ free(zip);
+ return (ARCHIVE_OK);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_util.c b/Utilities/cmlibarchive/libarchive/archive_util.c
index 34d8081..b53beca 100644
--- a/Utilities/cmlibarchive/libarchive/archive_util.c
+++ b/Utilities/cmlibarchive/libarchive/archive_util.c
@@ -45,6 +45,15 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1
#if defined(HAVE_WINCRYPT_H) && !defined(__CYGWIN__)
#include <wincrypt.h>
#endif
+#ifdef HAVE_ZLIB_H
+#include <cm_zlib.h>
+#endif
+#ifdef HAVE_LZMA_H
+#include <lzma.h>
+#endif
+#ifdef HAVE_BZLIB_H
+#include <cm_bzlib.h>
+#endif
#include "archive.h"
#include "archive_private.h"
@@ -54,6 +63,8 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_util.c 201098 2009-12-28 02:58:1
#define O_CLOEXEC 0
#endif
+static int archive_utility_string_sort_helper(char **, unsigned int);
+
/* Generic initialization of 'struct archive' objects. */
int
__archive_clean(struct archive *a)
@@ -74,6 +85,38 @@ archive_version_string(void)
return (ARCHIVE_VERSION_STRING);
}
+const char *
+archive_version_details(void)
+{
+ static struct archive_string str;
+ static int init = 0;
+
+ if (!init) {
+ archive_string_init(&str);
+
+ archive_strcat(&str, ARCHIVE_VERSION_STRING);
+#ifdef HAVE_ZLIB_H
+ archive_strcat(&str, " zlib/");
+ archive_strcat(&str, ZLIB_VERSION);
+#endif
+#ifdef HAVE_LZMA_H
+ archive_strcat(&str, " liblzma/");
+ archive_strcat(&str, LZMA_VERSION_STRING);
+#endif
+#ifdef HAVE_BZLIB_H
+ {
+ const char *p = BZ2_bzlibVersion();
+ const char *sep = strchr(p, ',');
+ if (sep == NULL)
+ sep = p + strlen(p);
+ archive_strcat(&str, " bz2lib/");
+ archive_strncat(&str, p, sep - p);
+ }
+#endif
+ }
+ return str.s;
+}
+
int
archive_errno(struct archive *a)
{
@@ -499,3 +542,69 @@ __archive_ensure_cloexec_flag(int fd)
}
#endif
}
+
+/*
+ * Utility function to sort a group of strings using quicksort.
+ */
+static int
+archive_utility_string_sort_helper(char **strings, unsigned int n)
+{
+ unsigned int i, lesser_count, greater_count;
+ char **lesser, **greater, **tmp, *pivot;
+ int retval1, retval2;
+
+ /* A list of 0 or 1 elements is already sorted */
+ if (n <= 1)
+ return (ARCHIVE_OK);
+
+ lesser_count = greater_count = 0;
+ lesser = greater = NULL;
+ pivot = strings[0];
+ for (i = 1; i < n; i++)
+ {
+ if (strcmp(strings[i], pivot) < 0)
+ {
+ lesser_count++;
+ tmp = (char **)realloc(lesser, lesser_count * sizeof(char *));
+ if (!tmp)
+ return (ARCHIVE_FATAL);
+ lesser = tmp;
+ lesser[lesser_count - 1] = strings[i];
+ }
+ else
+ {
+ greater_count++;
+ tmp = (char **)realloc(greater, greater_count * sizeof(char *));
+ if (!tmp)
+ return (ARCHIVE_FATAL);
+ greater = tmp;
+ greater[greater_count - 1] = strings[i];
+ }
+ }
+
+ /* quicksort(lesser) */
+ retval1 = archive_utility_string_sort_helper(lesser, lesser_count);
+ for (i = 0; i < lesser_count; i++)
+ strings[i] = lesser[i];
+ free(lesser);
+
+ /* pivot */
+ strings[lesser_count] = pivot;
+
+ /* quicksort(greater) */
+ retval2 = archive_utility_string_sort_helper(greater, greater_count);
+ for (i = 0; i < greater_count; i++)
+ strings[lesser_count + 1 + i] = greater[i];
+ free(greater);
+
+ return (retval1 < retval2) ? retval1 : retval2;
+}
+
+int
+archive_utility_string_sort(char **strings)
+{
+ unsigned int size = 0;
+ while (strings[size] != NULL)
+ size++;
+ return archive_utility_string_sort_helper(strings, size);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_virtual.c b/Utilities/cmlibarchive/libarchive/archive_virtual.c
index 0c4155f..de2595a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_virtual.c
+++ b/Utilities/cmlibarchive/libarchive/archive_virtual.c
@@ -55,6 +55,14 @@ archive_filter_bytes(struct archive *a, int n)
}
int
+archive_free(struct archive *a)
+{
+ if (a == NULL)
+ return (ARCHIVE_OK);
+ return ((a->vtable->archive_free)(a));
+}
+
+int
archive_write_close(struct archive *a)
{
return ((a->vtable->archive_close)(a));
@@ -76,9 +84,7 @@ archive_write_fail(struct archive *a)
int
archive_write_free(struct archive *a)
{
- if (a == NULL)
- return (ARCHIVE_OK);
- return ((a->vtable->archive_free)(a));
+ return archive_free(a);
}
#if ARCHIVE_VERSION_NUMBER < 4000000
@@ -93,9 +99,7 @@ archive_write_finish(struct archive *a)
int
archive_read_free(struct archive *a)
{
- if (a == NULL)
- return (ARCHIVE_OK);
- return ((a->vtable->archive_free)(a));
+ return archive_free(a);
}
#if ARCHIVE_VERSION_NUMBER < 4000000
diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.c b/Utilities/cmlibarchive/libarchive/archive_windows.c
index d3bf758..d4e93fe 100644
--- a/Utilities/cmlibarchive/libarchive/archive_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_windows.c
@@ -301,7 +301,7 @@ __la_open(const char *path, int flags, ...)
ws = NULL;
if ((flags & ~O_BINARY) == O_RDONLY) {
/*
- * When we open a directory, _open function returns
+ * When we open a directory, _open function returns
* "Permission denied" error.
*/
attr = GetFileAttributesA(path);
@@ -515,9 +515,9 @@ __hstat(HANDLE handle, struct ustat *st)
else
mode |= S_IFREG;
st->st_mode = mode;
-
+
fileTimeToUTC(&info.ftLastAccessTime, &t, &ns);
- st->st_atime = t;
+ st->st_atime = t;
st->st_atime_nsec = ns;
fileTimeToUTC(&info.ftLastWriteTime, &t, &ns);
st->st_mtime = t;
@@ -525,7 +525,7 @@ __hstat(HANDLE handle, struct ustat *st)
fileTimeToUTC(&info.ftCreationTime, &t, &ns);
st->st_ctime = t;
st->st_ctime_nsec = ns;
- st->st_size =
+ st->st_size =
((int64_t)(info.nFileSizeHigh) * ((int64_t)MAXDWORD + 1))
+ (int64_t)(info.nFileSizeLow);
#ifdef SIMULATE_WIN_STAT
@@ -599,7 +599,7 @@ __la_stat(const char *path, struct stat *st)
struct ustat u;
int ret;
- handle = la_CreateFile(path, 0, 0, NULL, OPEN_EXISTING,
+ handle = la_CreateFile(path, 0, FILE_SHARE_READ, NULL, OPEN_EXISTING,
FILE_FLAG_BACKUP_SEMANTICS,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
diff --git a/Utilities/cmlibarchive/libarchive/archive_windows.h b/Utilities/cmlibarchive/libarchive/archive_windows.h
index 620810c..9a19cdf 100644
--- a/Utilities/cmlibarchive/libarchive/archive_windows.h
+++ b/Utilities/cmlibarchive/libarchive/archive_windows.h
@@ -93,7 +93,7 @@
/* Alias the Windows _function to the POSIX equivalent. */
#define close _close
-#define fcntl(fd, cmd, flg) /* No operation. */
+#define fcntl(fd, cmd, flg) /* No operation. */
#ifndef fileno
#define fileno _fileno
#endif
@@ -113,13 +113,14 @@
#define lstat __la_stat
#define open __la_open
#define read __la_read
-#if !defined(__BORLANDC__)
+#if !defined(__BORLANDC__) && !defined(__WATCOMC__)
#define setmode _setmode
#endif
#ifdef stat
#undef stat
#endif
#define stat(path,stref) __la_stat(path,stref)
+#if !defined(__WATCOMC__)
#if !defined(__BORLANDC__)
#define strdup _strdup
#endif
@@ -127,9 +128,12 @@
#if !defined(__BORLANDC__)
#define umask _umask
#endif
+#endif
#define waitpid __la_waitpid
#define write __la_write
+#if !defined(__WATCOMC__)
+
#ifndef O_RDONLY
#define O_RDONLY _O_RDONLY
#define O_WRONLY _O_WRONLY
@@ -188,6 +192,7 @@
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) /* directory */
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) /* regular file */
#endif
+
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) /* Symbolic link */
#define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) /* Socket */
@@ -207,7 +212,7 @@
#define _S_IXGRP (_S_IXUSR >> 3) /* read permission, group */
#define _S_IWGRP (_S_IWUSR >> 3) /* write permission, group */
#define _S_IRGRP (_S_IRUSR >> 3) /* execute/search permission, group */
-#define _S_IRWXO (_S_IRWXG >> 3)
+#define _S_IRWXO (_S_IRWXG >> 3)
#define _S_IXOTH (_S_IXGRP >> 3) /* read permission, other */
#define _S_IWOTH (_S_IWGRP >> 3) /* write permission, other */
#define _S_IROTH (_S_IRGRP >> 3) /* execute/search permission, other */
@@ -227,6 +232,8 @@
#define S_IWOTH _S_IWOTH
#define S_IROTH _S_IROTH
+#endif
+
#define F_DUPFD 0 /* Duplicate file descriptor. */
#define F_GETFD 1 /* Get file descriptor flags. */
#define F_SETFD 2 /* Set file descriptor flags. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write.c b/Utilities/cmlibarchive/libarchive/archive_write.c
index b296069..8997193 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write.c
@@ -503,8 +503,9 @@ _archive_write_close(struct archive *_a)
archive_clear_error(&a->archive);
- /* Finish the last entry. */
- if (a->archive.state == ARCHIVE_STATE_DATA)
+ /* Finish the last entry if a finish callback is specified */
+ if (a->archive.state == ARCHIVE_STATE_DATA
+ && a->format_finish_entry != NULL)
r = ((a->format_finish_entry)(a));
/* Finish off the archive. */
@@ -638,6 +639,9 @@ _archive_write_header(struct archive *_a, struct archive_entry *entry)
/* Format and write header. */
r2 = ((a->format_write_header)(a, entry));
+ if (r2 == ARCHIVE_FAILED) {
+ return (ARCHIVE_FAILED);
+ }
if (r2 == ARCHIVE_FATAL) {
a->archive.state = ARCHIVE_STATE_FATAL;
return (ARCHIVE_FATAL);
@@ -658,7 +662,8 @@ _archive_write_finish_entry(struct archive *_a)
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_write_finish_entry");
- if (a->archive.state & ARCHIVE_STATE_DATA)
+ if (a->archive.state & ARCHIVE_STATE_DATA
+ && a->format_finish_entry != NULL)
ret = (a->format_finish_entry)(a);
a->archive.state = ARCHIVE_STATE_HEADER;
return (ret);
@@ -671,8 +676,13 @@ static ssize_t
_archive_write_data(struct archive *_a, const void *buff, size_t s)
{
struct archive_write *a = (struct archive_write *)_a;
+ const size_t max_write = INT_MAX;
+
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
ARCHIVE_STATE_DATA, "archive_write_data");
+ /* In particular, this catches attempts to pass negative values. */
+ if (s > max_write)
+ s = max_write;
archive_clear_error(&a->archive);
return ((a->format_write_data)(a, buff, s));
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
index 85fdf6a..da1cf5e 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_lrzip.c
@@ -44,7 +44,7 @@ __FBSDID("$FreeBSD$");
struct write_lrzip {
struct archive_write_program_data *pdata;
int compression_level;
- enum { lzma = 0, bzip2, gzip, lzo, zpaq } compression;
+ enum { lzma = 0, bzip2, gzip, lzo, none, zpaq } compression;
};
static int archive_write_lrzip_open(struct archive_write_filter *);
@@ -107,6 +107,8 @@ archive_write_lrzip_options(struct archive_write_filter *f, const char *key,
data->compression = gzip;
else if (strcmp(value, "lzo") == 0)
data->compression = lzo;
+ else if (strcmp(value, "none") == 0)
+ data->compression = none;
else if (strcmp(value, "zpaq") == 0)
data->compression = zpaq;
else
@@ -148,6 +150,9 @@ archive_write_lrzip_open(struct archive_write_filter *f)
case lzo:
archive_strcat(&as, " -l");
break;
+ case none:
+ archive_strcat(&as, " -n");
+ break;
case zpaq:
archive_strcat(&as, " -z");
break;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
index 9797203..5cbba54 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_acl.c
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_disk.c 201159 2009-12-29 0
#include "archive_acl_private.h"
#include "archive_write_disk_private.h"
-#if !defined(HAVE_POSIX_ACL) || !defined(ACL_TYPE_NFS4)
+#ifndef HAVE_POSIX_ACL
/* Default empty function body to satisfy mainline code. */
int
archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
@@ -79,10 +79,12 @@ archive_write_disk_set_acls(struct archive *a, int fd, const char *name,
ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_DEFAULT,
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
return (ret);
+#ifdef ACL_TYPE_NFS4
} else if (archive_acl_count(abstract_acl, ARCHIVE_ENTRY_ACL_TYPE_NFS4) > 0) {
ret = set_acl(a, fd, name, abstract_acl, ACL_TYPE_NFS4,
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
return (ret);
+#endif
} else
return ARCHIVE_OK;
}
@@ -94,6 +96,7 @@ static struct {
{ARCHIVE_ENTRY_ACL_EXECUTE, ACL_EXECUTE},
{ARCHIVE_ENTRY_ACL_WRITE, ACL_WRITE},
{ARCHIVE_ENTRY_ACL_READ, ACL_READ},
+#ifdef ACL_TYPE_NFS4
{ARCHIVE_ENTRY_ACL_READ_DATA, ACL_READ_DATA},
{ARCHIVE_ENTRY_ACL_LIST_DIRECTORY, ACL_LIST_DIRECTORY},
{ARCHIVE_ENTRY_ACL_WRITE_DATA, ACL_WRITE_DATA},
@@ -110,8 +113,10 @@ static struct {
{ARCHIVE_ENTRY_ACL_WRITE_ACL, ACL_WRITE_ACL},
{ARCHIVE_ENTRY_ACL_WRITE_OWNER, ACL_WRITE_OWNER},
{ARCHIVE_ENTRY_ACL_SYNCHRONIZE, ACL_SYNCHRONIZE}
+#endif
};
+#ifdef ACL_TYPE_NFS4
static struct {
int archive_inherit;
int platform_inherit;
@@ -121,6 +126,7 @@ static struct {
{ARCHIVE_ENTRY_ACL_ENTRY_NO_PROPAGATE_INHERIT, ACL_ENTRY_NO_PROPAGATE_INHERIT},
{ARCHIVE_ENTRY_ACL_ENTRY_INHERIT_ONLY, ACL_ENTRY_INHERIT_ONLY}
};
+#endif
static int
set_acl(struct archive *a, int fd, const char *name,
@@ -130,7 +136,9 @@ set_acl(struct archive *a, int fd, const char *name,
acl_t acl;
acl_entry_t acl_entry;
acl_permset_t acl_permset;
+#ifdef ACL_TYPE_NFS4
acl_flagset_t acl_flagset;
+#endif
int ret;
int ae_type, ae_permset, ae_tag, ae_id;
uid_t ae_uid;
@@ -171,14 +179,17 @@ set_acl(struct archive *a, int fd, const char *name,
case ARCHIVE_ENTRY_ACL_OTHER:
acl_set_tag_type(acl_entry, ACL_OTHER);
break;
+#ifdef ACL_TYPE_NFS4
case ARCHIVE_ENTRY_ACL_EVERYONE:
acl_set_tag_type(acl_entry, ACL_EVERYONE);
break;
+#endif
default:
/* XXX */
break;
}
+#ifdef ACL_TYPE_NFS4
switch (ae_type) {
case ARCHIVE_ENTRY_ACL_TYPE_ALLOW:
acl_set_entry_type_np(acl_entry, ACL_ENTRY_TYPE_ALLOW);
@@ -200,6 +211,7 @@ set_acl(struct archive *a, int fd, const char *name,
// XXX error handling here.
break;
}
+#endif
acl_get_permset(acl_entry, &acl_permset);
acl_clear_perms(acl_permset);
@@ -210,6 +222,7 @@ set_acl(struct archive *a, int fd, const char *name,
acl_perm_map[i].platform_perm);
}
+#ifdef ACL_TYPE_NFS4
acl_get_flagset_np(acl_entry, &acl_flagset);
acl_clear_flags_np(acl_flagset);
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
@@ -217,6 +230,7 @@ set_acl(struct archive *a, int fd, const char *name,
acl_add_flag_np(acl_flagset,
acl_inherit_map[i].platform_inherit);
}
+#endif
}
/* Try restoring the ACL through 'fd' if we can. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
index b69c873..80389ee 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
@@ -2215,7 +2215,8 @@ _archive_write_disk_free(struct archive *_a)
free(a->resource_fork);
free(a->compressed_buffer);
free(a->uncompressed_buffer);
-#ifdef HAVE_ZLIB_H
+#if defined(__APPLE__) && defined(UF_COMPRESSED) && defined(HAVE_SYS_XATTR_H)\
+ && defined(HAVE_ZLIB_H)
if (a->stream_valid) {
switch (deflateEnd(&a->stream)) {
case Z_OK:
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
index 0f0780a..ed62009 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
@@ -525,7 +525,7 @@ la_GetFunctionKernel32(const char *name)
static int set;
if (!set) {
set = 1;
- lib = LoadLibrary("kernel32.dll");
+ lib = LoadLibrary(TEXT("kernel32.dll"));
}
if (lib == NULL) {
fprintf(stderr, "Can't load kernel32.dll?!\n");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_format.3 b/Utilities/cmlibarchive/libarchive/archive_write_format.3
index dad2f7d..39d3006 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_format.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_format.3
@@ -24,13 +24,14 @@
.\"
.\" $FreeBSD$
.\"
-.Dd February 2, 2012
+.Dd February 14, 2013
.Dt ARCHIVE_WRITE_FORMAT 3
.Os
.Sh NAME
.Nm archive_write_set_format_cpio ,
.Nm archive_write_set_format_pax ,
.Nm archive_write_set_format_pax_restricted ,
+.Nm archive_write_set_format_raw ,
.Nm archive_write_set_format_shar ,
.Nm archive_write_set_format_shar_dump ,
.Nm archive_write_set_format_ustar
@@ -46,6 +47,8 @@ Streaming Archive Library (libarchive, -larchive)
.Ft int
.Fn archive_write_set_format_pax_restricted "struct archive *"
.Ft int
+.Fn archive_write_set_format_raw "struct archive *"
+.Ft int
.Fn archive_write_set_format_shar "struct archive *"
.Ft int
.Fn archive_write_set_format_shar_dump "struct archive *"
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
index 641d56f..9055753 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
@@ -47,6 +47,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] =
{ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC, archive_write_set_format_cpio_newc },
{ ARCHIVE_FORMAT_ISO9660, archive_write_set_format_iso9660 },
{ ARCHIVE_FORMAT_MTREE, archive_write_set_format_mtree },
+ { ARCHIVE_FORMAT_RAW, archive_write_set_format_raw },
{ ARCHIVE_FORMAT_SHAR, archive_write_set_format_shar },
{ ARCHIVE_FORMAT_SHAR_BASE, archive_write_set_format_shar },
{ ARCHIVE_FORMAT_SHAR_DUMP, archive_write_set_format_shar_dump },
@@ -57,7 +58,7 @@ struct { int code; int (*setter)(struct archive *); } codes[] =
archive_write_set_format_pax_restricted },
{ ARCHIVE_FORMAT_TAR_USTAR, archive_write_set_format_ustar },
{ ARCHIVE_FORMAT_XAR, archive_write_set_format_xar },
- { ARCHIVE_FORMAT_ZIP, archive_write_set_format_zip },
+ { ARCHIVE_FORMAT_ZIP, archive_write_set_format_zip },
{ 0, NULL }
};
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
index af3105e..4f3ce7d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
@@ -63,6 +63,7 @@ struct { const char *name; int (*setter)(struct archive *); } names[] =
{ "pax", archive_write_set_format_pax },
{ "paxr", archive_write_set_format_pax_restricted },
{ "posix", archive_write_set_format_pax },
+ { "raw", archive_write_set_format_raw },
{ "rpax", archive_write_set_format_pax_restricted },
{ "shar", archive_write_set_format_shar },
{ "shardump", archive_write_set_format_shar_dump },
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c
index 9c0613c..4d343ea 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_mtree.c
@@ -128,6 +128,9 @@ struct mtree_entry {
unsigned long fflags_clear;
dev_t rdevmajor;
dev_t rdevminor;
+ dev_t devmajor;
+ dev_t devminor;
+ int64_t ino;
};
struct mtree_writer {
@@ -210,6 +213,9 @@ struct mtree_writer {
#define F_SHA256 0x00800000 /* SHA-256 digest */
#define F_SHA384 0x01000000 /* SHA-384 digest */
#define F_SHA512 0x02000000 /* SHA-512 digest */
+#define F_INO 0x04000000 /* inode number */
+#define F_RESDEV 0x08000000 /* device ID on which the
+ * entry resides */
/* Options */
int dironly; /* If it is set, ignore all files except
@@ -823,8 +829,11 @@ mtree_entry_new(struct archive_write *a, struct archive_entry *entry,
archive_entry_fflags(entry, &me->fflags_set, &me->fflags_clear);
me->mtime = archive_entry_mtime(entry);
me->mtime_nsec = archive_entry_mtime_nsec(entry);
- me->rdevmajor = archive_entry_rdevmajor(entry);
+ me->rdevmajor = archive_entry_rdevmajor(entry);
me->rdevminor = archive_entry_rdevminor(entry);
+ me->devmajor = archive_entry_devmajor(entry);
+ me->devminor = archive_entry_devminor(entry);
+ me->ino = archive_entry_ino(entry);
me->size = archive_entry_size(entry);
if (me->filetype == AE_IFDIR) {
me->dir_info = calloc(1, sizeof(*me->dir_info));
@@ -882,7 +891,7 @@ archive_write_mtree_header(struct archive_write *a,
mtree->first = 0;
archive_strcat(&mtree->buf, "#mtree\n");
if ((mtree->keys & SET_KEYS) == 0)
- mtree->output_global_set = 0;/* Disalbed. */
+ mtree->output_global_set = 0;/* Disabled. */
}
mtree->entry_bytes_remaining = archive_entry_size(entry);
@@ -983,6 +992,15 @@ write_mtree_entry(struct archive_write *a, struct mtree_entry *me)
if ((keys & F_UID) != 0)
archive_string_sprintf(str, " uid=%jd", (intmax_t)me->uid);
+ if ((keys & F_INO) != 0)
+ archive_string_sprintf(str, " inode=%jd", (intmax_t)me->ino);
+ if ((keys & F_RESDEV) != 0) {
+ archive_string_sprintf(str,
+ " resdevice=native,%ju,%ju",
+ (uintmax_t)me->devmajor,
+ (uintmax_t)me->devminor);
+ }
+
switch (me->filetype) {
case AE_IFLNK:
if ((keys & F_TYPE) != 0)
@@ -1117,7 +1135,7 @@ write_mtree_entry_tree(struct archive_write *a)
} else {
/* Whenever output_global_set is enabled
* output global value(/set keywords)
- * even if the directory entry is not allowd
+ * even if the directory entry is not allowed
* to be written because the global values
* can be used for the children. */
if (mtree->output_global_set)
@@ -1296,6 +1314,8 @@ archive_write_mtree_options(struct archive_write *a, const char *key,
if (strcmp(key, "indent") == 0) {
mtree->indent = (value != NULL)? 1: 0;
return (ARCHIVE_OK);
+ } else if (strcmp(key, "inode") == 0) {
+ keybit = F_INO;
}
break;
case 'l':
@@ -1314,7 +1334,9 @@ archive_write_mtree_options(struct archive_write *a, const char *key,
keybit = F_NLINK;
break;
case 'r':
- if (strcmp(key, "ripemd160digest") == 0 ||
+ if (strcmp(key, "resdevice") == 0) {
+ keybit = F_RESDEV;
+ } else if (strcmp(key, "ripemd160digest") == 0 ||
strcmp(key, "rmd160") == 0 ||
strcmp(key, "rmd160digest") == 0)
keybit = F_RMD160;
@@ -1855,9 +1877,9 @@ mtree_entry_setup_filenames(struct archive_write *a, struct mtree_entry *file,
return (ret);
}
- /* Make a basename from dirname and slash */
+ /* Make a basename from file->parentdir.s and slash */
*slash = '\0';
- file->parentdir.length = slash - dirname;
+ file->parentdir.length = slash - file->parentdir.s;
archive_strcpy(&(file->basename), slash + 1);
return (ret);
}
@@ -2198,6 +2220,9 @@ mtree_entry_exchange_same_entry(struct archive_write *a, struct mtree_entry *np,
np->mtime_nsec = file->mtime_nsec;
np->rdevmajor = file->rdevmajor;
np->rdevminor = file->rdevminor;
+ np->devmajor = file->devmajor;
+ np->devminor = file->devminor;
+ np->ino = file->ino;
return (ARCHIVE_WARN);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c
new file mode 100644
index 0000000..feff936
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_raw.c
@@ -0,0 +1,125 @@
+/*-
+ * Copyright (c) 2013 Marek Kubica
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#include "archive_entry.h"
+#include "archive_write_private.h"
+
+static ssize_t archive_write_raw_data(struct archive_write *,
+ const void *buff, size_t s);
+static int archive_write_raw_free(struct archive_write *);
+static int archive_write_raw_header(struct archive_write *,
+ struct archive_entry *);
+
+struct raw {
+ int entries_written;
+};
+
+/*
+ * Set output format to 'raw' format.
+ */
+int
+archive_write_set_format_raw(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ struct raw *raw;
+
+ archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_format_raw");
+
+ /* If someone else was already registered, unregister them. */
+ if (a->format_free != NULL)
+ (a->format_free)(a);
+
+ raw = (struct raw *)calloc(1, sizeof(*raw));
+ if (raw == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate raw data");
+ return (ARCHIVE_FATAL);
+ }
+ raw->entries_written = 0;
+ a->format_data = raw;
+ a->format_name = "raw";
+ /* no options exist for this format */
+ a->format_options = NULL;
+ a->format_write_header = archive_write_raw_header;
+ a->format_write_data = archive_write_raw_data;
+ a->format_finish_entry = NULL;
+ /* nothing needs to be done on closing */
+ a->format_close = NULL;
+ a->format_free = archive_write_raw_free;
+ a->archive.archive_format = ARCHIVE_FORMAT_RAW;
+ a->archive.archive_format_name = "RAW";
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_raw_header(struct archive_write *a, struct archive_entry *entry)
+{
+ struct raw *raw = (struct raw *)a->format_data;
+
+ if (archive_entry_filetype(entry) != AE_IFREG) {
+ archive_set_error(&a->archive, ERANGE,
+ "Raw format only supports filetype AE_IFREG");
+ return (ARCHIVE_FATAL);
+ }
+
+
+ if (raw->entries_written > 0) {
+ archive_set_error(&a->archive, ERANGE,
+ "Raw format only supports one entry per archive");
+ return (ARCHIVE_FATAL);
+ }
+ raw->entries_written++;
+
+ return (ARCHIVE_OK);
+}
+
+static ssize_t
+archive_write_raw_data(struct archive_write *a, const void *buff, size_t s)
+{
+ int ret;
+
+ ret = __archive_write_output(a, buff, s);
+ if (ret >= 0)
+ return (s);
+ else
+ return (ret);
+}
+
+static int
+archive_write_raw_free(struct archive_write *a)
+{
+ struct raw *raw;
+
+ raw = (struct raw *)a->format_data;
+ free(raw);
+ a->format_data = NULL;
+ return (ARCHIVE_OK);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c
index 9ec15f9..c033fb3 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_shar.c
@@ -548,6 +548,7 @@ archive_write_shar_finish_entry(struct archive_write *a)
archive_strcat(&shar->work, ":");
shar_quote(&shar->work, g, 1);
}
+ archive_strcat(&shar->work, " ");
shar_quote(&shar->work,
archive_entry_pathname(shar->entry), 1);
archive_strcat(&shar->work, "\n");
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
index 5a9f114..3b07e35 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
@@ -29,24 +29,6 @@
* Development supported by Google Summer of Code 2008.
*/
-/*
- * The current implementation is very limited:
- *
- * - No encryption support.
- * - No ZIP64 support.
- * - No support for splitting and spanning.
- * - Only supports regular file and folder entries.
- *
- * Note that generally data in ZIP files is little-endian encoded,
- * with some exceptions.
- *
- * TODO: Since Libarchive is generally 64bit oriented, but this implementation
- * does not yet support sizes exceeding 32bit, it is highly fragile for
- * big archives. This should change when ZIP64 is finally implemented, otherwise
- * some serious checking has to be done.
- *
- */
-
#include "archive_platform.h"
__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 2009-12-29 06:15:32Z kientzle $");
@@ -77,25 +59,80 @@ __FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_zip.c 201168 20
#include "archive_crc32.h"
#endif
-#define ZIP_SIGNATURE_LOCAL_FILE_HEADER 0x04034b50
-#define ZIP_SIGNATURE_DATA_DESCRIPTOR 0x08074b50
-#define ZIP_SIGNATURE_FILE_HEADER 0x02014b50
-#define ZIP_SIGNATURE_CENTRAL_DIRECTORY_END 0x06054b50
-#define ZIP_SIGNATURE_EXTRA_TIMESTAMP 0x5455
-#define ZIP_SIGNATURE_EXTRA_NEW_UNIX 0x7875
-#define ZIP_VERSION_EXTRACT 0x0014 /* ZIP version 2.0 is needed. */
-#define ZIP_VERSION_BY 0x0314 /* Made by UNIX, using ZIP version 2.0. */
-#define ZIP_FLAGS 0x08 /* Flagging bit 3 (count from 0) for using data descriptor. */
-#define ZIP_FLAGS_UTF8_NAME (1 << 11)
+#define ZIP_ENTRY_FLAG_LENGTH_AT_END (1<<3)
+#define ZIP_ENTRY_FLAG_UTF8_NAME (1 << 11)
+
enum compression {
- COMPRESSION_STORE = 0
-#ifdef HAVE_ZLIB_H
- ,
+ COMPRESSION_UNSPECIFIED = -1,
+ COMPRESSION_STORE = 0,
COMPRESSION_DEFLATE = 8
+};
+
+#ifdef HAVE_ZLIB_H
+#define COMPRESSION_DEFAULT COMPRESSION_DEFLATE
+#else
+#define COMPRESSION_DEFAULT COMPRESSION_STORE
+#endif
+
+struct cd_segment {
+ struct cd_segment *next;
+ size_t buff_size;
+ unsigned char *buff;
+ unsigned char *p;
+};
+
+/* Bits used to enable/disable certain experimental features. */
+#define EXPERIMENT_LA 1
+#define EXPERIMENTS_ALL 0xffff
+
+struct zip {
+
+ int64_t entry_offset;
+ int64_t entry_compressed_size;
+ int64_t entry_uncompressed_size;
+ int64_t entry_compressed_written;
+ int64_t entry_uncompressed_written;
+ int64_t entry_uncompressed_limit;
+ struct archive_entry *entry;
+ uint32_t entry_crc32;
+ enum compression entry_compression;
+ int entry_flags;
+ int entry_uses_zip64;
+ int experiments;
+
+ unsigned char *file_header;
+ size_t file_header_extra_offset;
+ unsigned long (*crc32func)(unsigned long crc, const void *buff, size_t len);
+
+ struct cd_segment *central_directory;
+ struct cd_segment *central_directory_last;
+ size_t central_directory_bytes;
+ size_t central_directory_entries;
+
+ int64_t written_bytes; /* Overall position in file. */
+
+ struct archive_string_conv *opt_sconv;
+ struct archive_string_conv *sconv_default;
+ enum compression requested_compression;
+ int init_default_conversion;
+
+#define ZIP_FLAG_AVOID_ZIP64 1
+#define ZIP_FLAG_FORCE_ZIP64 2
+#define ZIP_FLAG_EXPERIMENT_EL 4
+ int flags;
+
+#ifdef HAVE_ZLIB_H
+ z_stream stream;
+ size_t len_buf;
+ unsigned char *buf;
#endif
};
+/* Don't call this min or MIN, since those are already defined
+ on lots of platforms (but not all). */
+#define zipmin(a, b) ((a) > (b) ? (b) : (a))
+
static ssize_t archive_write_zip_data(struct archive_write *,
const void *buff, size_t s);
static int archive_write_zip_close(struct archive_write *);
@@ -108,106 +145,58 @@ static int archive_write_zip_options(struct archive_write *,
static unsigned int dos_time(const time_t);
static size_t path_length(struct archive_entry *);
static int write_path(struct archive_entry *, struct archive_write *);
+static void copy_path(struct archive_entry *, unsigned char *);
+static struct archive_string_conv *get_sconv(struct archive_write *, struct zip *);
-#define LOCAL_FILE_HEADER_SIGNATURE 0
-#define LOCAL_FILE_HEADER_VERSION 4
-#define LOCAL_FILE_HEADER_FLAGS 6
-#define LOCAL_FILE_HEADER_COMPRESSION 8
-#define LOCAL_FILE_HEADER_TIMEDATE 10
-#define LOCAL_FILE_HEADER_CRC32 14
-#define LOCAL_FILE_HEADER_COMPRESSED_SIZE 18
-#define LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE 22
-#define LOCAL_FILE_HEADER_FILENAME_LENGTH 26
-#define LOCAL_FILE_HEADER_EXTRA_LENGTH 28
-#define SIZE_LOCAL_FILE_HEADER 30
-
-#define FILE_HEADER_SIGNATURE 0
-#define FILE_HEADER_VERSION_BY 4
-#define FILE_HEADER_VERSION_EXTRACT 6
-#define FILE_HEADER_FLAGS 8
-#define FILE_HEADER_COMPRESSION 10
-#define FILE_HEADER_TIMEDATE 12
-#define FILE_HEADER_CRC32 16
-#define FILE_HEADER_COMPRESSED_SIZE 20
-#define FILE_HEADER_UNCOMPRESSED_SIZE 24
-#define FILE_HEADER_FILENAME_LENGTH 28
-#define FILE_HEADER_EXTRA_LENGTH 30
-#define FILE_HEADER_COMMENT_LENGTH 32
-#define FILE_HEADER_DISK_NUMBER 34
-#define FILE_HEADER_ATTRIBUTES_INTERNAL 36
-#define FILE_HEADER_ATTRIBUTES_EXTERNAL 38
-#define FILE_HEADER_OFFSET 42
-#define SIZE_FILE_HEADER 46
-
- /* Not mandatory, but recommended by specification. */
-#define DATA_DESCRIPTOR_SIGNATURE 0
-#define DATA_DESCRIPTOR_CRC32 4
-#define DATA_DESCRIPTOR_COMPRESSED_SIZE 8
-#define DATA_DESCRIPTOR_UNCOMPRESSED_SIZE 12
-#define SIZE_DATA_DESCRIPTOR 16
-
-#define EXTRA_DATA_LOCAL_TIME_ID 0
-#define EXTRA_DATA_LOCAL_TIME_SIZE 2
-#define EXTRA_DATA_LOCAL_TIME_FLAG 4
-#define EXTRA_DATA_LOCAL_MTIME 5
-#define EXTRA_DATA_LOCAL_ATIME 9
-#define EXTRA_DATA_LOCAL_CTIME 13
-#define EXTRA_DATA_LOCAL_UNIX_ID 17
-#define EXTRA_DATA_LOCAL_UNIX_SIZE 19
-#define EXTRA_DATA_LOCAL_UNIX_VERSION 21
-#define EXTRA_DATA_LOCAL_UNIX_UID_SIZE 22
-#define EXTRA_DATA_LOCAL_UNIX_UID 23
-#define EXTRA_DATA_LOCAL_UNIX_GID_SIZE 27
-#define EXTRA_DATA_LOCAL_UNIX_GID 28
-#define SIZE_EXTRA_DATA_LOCAL 32
-
-#define EXTRA_DATA_CENTRAL_TIME_ID 0
-#define EXTRA_DATA_CENTRAL_TIME_SIZE 2
-#define EXTRA_DATA_CENTRAL_TIME_FLAG 4
-#define EXTRA_DATA_CENTRAL_MTIME 5
-#define EXTRA_DATA_CENTRAL_UNIX_ID 9
-#define EXTRA_DATA_CENTRAL_UNIX_SIZE 11
-#define SIZE_EXTRA_DATA_CENTRAL 13
-
-#define CENTRAL_DIRECTORY_END_SIGNATURE 0
-#define CENTRAL_DIRECTORY_END_DISK 4
-#define CENTRAL_DIRECTORY_END_START_DISK 6
-#define CENTRAL_DIRECTORY_END_ENTRIES_DISK 8
-#define CENTRAL_DIRECTORY_END_ENTRIES 10
-#define CENTRAL_DIRECTORY_END_SIZE 12
-#define CENTRAL_DIRECTORY_END_OFFSET 16
-#define CENTRAL_DIRECTORY_END_COMMENT_LENGTH 20
-#define SIZE_CENTRAL_DIRECTORY_END 22
-
-struct zip_file_header_link {
- struct zip_file_header_link *next;
- struct archive_entry *entry;
- int64_t offset;
- unsigned long crc32;
- int64_t compressed_size;
- enum compression compression;
- int flags;
-};
+static unsigned char *
+cd_alloc(struct zip *zip, size_t length)
+{
+ unsigned char *p;
+
+ if (zip->central_directory == NULL
+ || (zip->central_directory_last->p + length
+ > zip->central_directory_last->buff + zip->central_directory_last->buff_size)) {
+ struct cd_segment *segment = calloc(1, sizeof(*segment));
+ if (segment == NULL)
+ return NULL;
+ segment->buff_size = 64 * 1024;
+ segment->buff = malloc(segment->buff_size);
+ if (segment->buff == NULL) {
+ free(segment);
+ return NULL;
+ }
+ segment->p = segment->buff;
-struct zip {
- uint8_t data_descriptor[SIZE_DATA_DESCRIPTOR];
- struct zip_file_header_link *central_directory;
- struct zip_file_header_link *central_directory_end;
- int64_t offset;
- int64_t written_bytes;
- int64_t remaining_data_bytes;
- enum compression compression;
- int flags;
- struct archive_string_conv *opt_sconv;
- struct archive_string_conv *sconv_default;
- int init_default_conversion;
+ if (zip->central_directory == NULL) {
+ zip->central_directory
+ = zip->central_directory_last
+ = segment;
+ } else {
+ zip->central_directory_last->next = segment;
+ zip->central_directory_last = segment;
+ }
+ }
-#ifdef HAVE_ZLIB_H
- z_stream stream;
- size_t len_buf;
- unsigned char *buf;
-#endif
-};
+ p = zip->central_directory_last->p;
+ zip->central_directory_last->p += length;
+ zip->central_directory_bytes += length;
+ return (p);
+}
+
+static unsigned long
+real_crc32(unsigned long crc, const void *buff, size_t len)
+{
+ return crc32(crc, buff, len);
+}
+
+static unsigned long
+fake_crc32(unsigned long crc, const void *buff, size_t len)
+{
+ (void)crc; /* UNUSED */
+ (void)buff; /* UNUSED */
+ (void)len; /* UNUSED */
+ return 0;
+}
static int
archive_write_zip_options(struct archive_write *a, const char *key,
@@ -217,24 +206,49 @@ archive_write_zip_options(struct archive_write *a, const char *key,
int ret = ARCHIVE_FAILED;
if (strcmp(key, "compression") == 0) {
+ /*
+ * Set compression to use on all future entries.
+ * This only affects regular files.
+ */
if (val == NULL || val[0] == 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"%s: compression option needs a compression name",
a->format_name);
} else if (strcmp(val, "deflate") == 0) {
#ifdef HAVE_ZLIB_H
- zip->compression = COMPRESSION_DEFLATE;
+ zip->requested_compression = COMPRESSION_DEFLATE;
ret = ARCHIVE_OK;
#else
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"deflate compression not supported");
#endif
} else if (strcmp(val, "store") == 0) {
- zip->compression = COMPRESSION_STORE;
+ zip->requested_compression = COMPRESSION_STORE;
ret = ARCHIVE_OK;
}
return (ret);
+ } else if (strcmp(key, "experimental") == 0) {
+ if (val == NULL || val[0] == 0) {
+ zip->flags &= ~ ZIP_FLAG_EXPERIMENT_EL;
+ } else {
+ zip->flags |= ZIP_FLAG_EXPERIMENT_EL;
+ }
+ return (ARCHIVE_OK);
+ } else if (strcmp(key, "fakecrc32") == 0) {
+ /*
+ * FOR TESTING ONLY: disable CRC calculation to speed up
+ * certain complex tests.
+ */
+ if (val == NULL || val[0] == 0) {
+ zip->crc32func = real_crc32;
+ } else {
+ zip->crc32func = fake_crc32;
+ }
+ return (ARCHIVE_OK);
} else if (strcmp(key, "hdrcharset") == 0) {
+ /*
+ * Set the character set used in translating filenames.
+ */
if (val == NULL || val[0] == 0) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"%s: hdrcharset option needs a character-set name",
@@ -248,6 +262,21 @@ archive_write_zip_options(struct archive_write *a, const char *key,
ret = ARCHIVE_FATAL;
}
return (ret);
+ } else if (strcmp(key, "zip64") == 0) {
+ /*
+ * Bias decisions about Zip64: force them to be
+ * generated in certain cases where they are not
+ * forbidden or avoid them in certain cases where they
+ * are not strictly required.
+ */
+ if (val != NULL && *val != '\0') {
+ zip->flags |= ZIP_FLAG_FORCE_ZIP64;
+ zip->flags &= ~ZIP_FLAG_AVOID_ZIP64;
+ } else {
+ zip->flags &= ~ZIP_FLAG_FORCE_ZIP64;
+ zip->flags |= ZIP_FLAG_AVOID_ZIP64;
+ }
+ return (ARCHIVE_OK);
}
/* Note: The "warn" return is just to inform the options
@@ -261,9 +290,9 @@ archive_write_zip_set_compression_deflate(struct archive *_a)
{
struct archive_write *a = (struct archive_write *)_a;
int ret = ARCHIVE_FAILED;
-
+
archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
- ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER,
+ ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_write_zip_set_compression_deflate");
if (a->archive.archive_format != ARCHIVE_FORMAT_ZIP) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -273,11 +302,12 @@ archive_write_zip_set_compression_deflate(struct archive *_a)
} else {
#ifdef HAVE_ZLIB_H
struct zip *zip = a->format_data;
- zip->compression = COMPRESSION_DEFLATE;
+ zip->requested_compression = COMPRESSION_DEFLATE;
ret = ARCHIVE_OK;
#else
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"deflate compression not supported");
+ ret = ARCHIVE_FAILED;
#endif
}
return (ret);
@@ -289,9 +319,9 @@ archive_write_zip_set_compression_store(struct archive *_a)
struct archive_write *a = (struct archive_write *)_a;
struct zip *zip = a->format_data;
int ret = ARCHIVE_FAILED;
-
+
archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
- ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER,
+ ARCHIVE_STATE_NEW | ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_write_zip_set_compression_deflate");
if (a->archive.archive_format != ARCHIVE_FORMAT_ZIP) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -299,7 +329,7 @@ archive_write_zip_set_compression_store(struct archive *_a)
" with zip format");
ret = ARCHIVE_FATAL;
} else {
- zip->compression = COMPRESSION_STORE;
+ zip->requested_compression = COMPRESSION_STORE;
ret = ARCHIVE_OK;
}
return (ret);
@@ -324,14 +354,12 @@ archive_write_set_format_zip(struct archive *_a)
"Can't allocate zip data");
return (ARCHIVE_FATAL);
}
- zip->central_directory = NULL;
- zip->central_directory_end = NULL;
- zip->offset = 0;
- zip->written_bytes = 0;
- zip->remaining_data_bytes = 0;
+
+ /* "Unspecified" lets us choose the appropriate compression. */
+ zip->requested_compression = COMPRESSION_UNSPECIFIED;
+ zip->crc32func = real_crc32;
#ifdef HAVE_ZLIB_H
- zip->compression = COMPRESSION_DEFLATE;
zip->len_buf = 65536;
zip->buf = malloc(zip->len_buf);
if (zip->buf == NULL) {
@@ -340,8 +368,6 @@ archive_write_set_format_zip(struct archive *_a)
"Can't allocate compression buffer");
return (ARCHIVE_FATAL);
}
-#else
- zip->compression = COMPRESSION_STORE;
#endif
a->format_data = zip;
@@ -355,9 +381,6 @@ archive_write_set_format_zip(struct archive *_a)
a->archive.archive_format = ARCHIVE_FORMAT_ZIP;
a->archive.archive_format_name = "ZIP";
- archive_le32enc(&zip->data_descriptor[DATA_DESCRIPTOR_SIGNATURE],
- ZIP_SIGNATURE_DATA_DESCRIPTOR);
-
return (ARCHIVE_OK);
}
@@ -376,17 +399,21 @@ is_all_ascii(const char *p)
static int
archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
{
- struct zip *zip;
- uint8_t h[SIZE_LOCAL_FILE_HEADER];
- uint8_t e[SIZE_EXTRA_DATA_LOCAL];
- uint8_t *d;
- struct zip_file_header_link *l;
- struct archive_string_conv *sconv;
+ unsigned char local_header[32];
+ unsigned char local_extra[128];
+ struct zip *zip = a->format_data;
+ unsigned char *e;
+ unsigned char *cd_extra;
+ size_t filename_length;
+ const char *slink = NULL;
+ size_t slink_size = 0;
+ struct archive_string_conv *sconv = get_sconv(a, zip);
int ret, ret2 = ARCHIVE_OK;
int64_t size;
mode_t type;
+ int version_needed = 10;
- /* Entries other than a regular file or a folder are skipped. */
+ /* Ignore types of entries that we don't support. */
type = archive_entry_filetype(entry);
if (type != AE_IFREG && type != AE_IFDIR && type != AE_IFLNK) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
@@ -394,70 +421,64 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
return ARCHIVE_FAILED;
};
- /* Directory entries should have a size of 0. */
- if (type == AE_IFDIR)
+ /* If we're not using Zip64, reject large files. */
+ if (zip->flags & ZIP_FLAG_AVOID_ZIP64) {
+ /* Reject entries over 4GB. */
+ if (archive_entry_size_is_set(entry)
+ && (archive_entry_size(entry) > 0xffffffff)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Files > 4GB require Zip64 extensions");
+ return ARCHIVE_FAILED;
+ }
+ /* Reject entries if archive is > 4GB. */
+ if (zip->written_bytes > 0xffffffff) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Archives > 4GB require Zip64 extensions");
+ return ARCHIVE_FAILED;
+ }
+ }
+
+ /* Only regular files can have size > 0. */
+ if (type != AE_IFREG)
archive_entry_set_size(entry, 0);
- zip = a->format_data;
- /* Setup default conversion. */
- if (zip->opt_sconv == NULL && !zip->init_default_conversion) {
- zip->sconv_default =
- archive_string_default_conversion_for_write(&(a->archive));
- zip->init_default_conversion = 1;
- }
- if (zip->flags == 0) {
- /* Initialize the general purpose flags. */
- zip->flags = ZIP_FLAGS;
- if (zip->opt_sconv != NULL) {
- if (strcmp(archive_string_conversion_charset_name(
- zip->opt_sconv), "UTF-8") == 0)
- zip->flags |= ZIP_FLAGS_UTF8_NAME;
-#if HAVE_NL_LANGINFO
- } else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
- zip->flags |= ZIP_FLAGS_UTF8_NAME;
-#endif
- }
+ /* Reset information from last entry. */
+ zip->entry_offset = zip->written_bytes;
+ zip->entry_uncompressed_limit = INT64_MAX;
+ zip->entry_compressed_size = 0;
+ zip->entry_uncompressed_size = 0;
+ zip->entry_compressed_written = 0;
+ zip->entry_uncompressed_written = 0;
+ zip->entry_flags = 0;
+ zip->entry_uses_zip64 = 0;
+ zip->entry_crc32 = zip->crc32func(0, NULL, 0);
+ if (zip->entry != NULL) {
+ archive_entry_free(zip->entry);
+ zip->entry = NULL;
}
- d = zip->data_descriptor;
- size = archive_entry_size(entry);
- zip->remaining_data_bytes = size;
- /* Append archive entry to the central directory data. */
- l = (struct zip_file_header_link *) malloc(sizeof(*l));
- if (l == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate zip header data");
- return (ARCHIVE_FATAL);
- }
#if defined(_WIN32) && !defined(__CYGWIN__)
/* Make sure the path separators in pahtname, hardlink and symlink
* are all slash '/', not the Windows path separator '\'. */
- l->entry = __la_win_entry_in_posix_pathseparator(entry);
- if (l->entry == entry)
- l->entry = archive_entry_clone(entry);
+ zip->entry = __la_win_entry_in_posix_pathseparator(entry);
+ if (zip->entry == entry)
+ zip->entry = archive_entry_clone(entry);
#else
- l->entry = archive_entry_clone(entry);
+ zip->entry = archive_entry_clone(entry);
#endif
- if (l->entry == NULL) {
+ if (zip->entry == NULL) {
archive_set_error(&a->archive, ENOMEM,
"Can't allocate zip header data");
- free(l);
return (ARCHIVE_FATAL);
}
- l->flags = zip->flags;
- if (zip->opt_sconv != NULL)
- sconv = zip->opt_sconv;
- else
- sconv = zip->sconv_default;
+
if (sconv != NULL) {
const char *p;
size_t len;
if (archive_entry_pathname_l(entry, &p, &len, sconv) != 0) {
if (errno == ENOMEM) {
- archive_entry_free(l->entry);
- free(l);
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory for Pathname");
return (ARCHIVE_FATAL);
@@ -470,163 +491,283 @@ archive_write_zip_header(struct archive_write *a, struct archive_entry *entry)
ret2 = ARCHIVE_WARN;
}
if (len > 0)
- archive_entry_set_pathname(l->entry, p);
+ archive_entry_set_pathname(zip->entry, p);
/*
- * Although there is no character-set regulation for Symlink,
- * it is suitable to convert a character-set of Symlinke to
- * what those of the Pathname has been converted to.
+ * There is no standard for symlink handling; we convert
+ * it using the same character-set translation that we use
+ * for filename.
*/
if (type == AE_IFLNK) {
if (archive_entry_symlink_l(entry, &p, &len, sconv)) {
if (errno == ENOMEM) {
- archive_entry_free(l->entry);
- free(l);
archive_set_error(&a->archive, ENOMEM,
"Can't allocate memory "
" for Symlink");
return (ARCHIVE_FATAL);
}
- /*
- * Even if the strng conversion failed,
- * we should not report the error since
- * thre is no regulation for.
- */
+ /* No error if we can't convert. */
} else if (len > 0)
- archive_entry_set_symlink(l->entry, p);
+ archive_entry_set_symlink(zip->entry, p);
+ }
+ }
+
+ /* If filename isn't ASCII and we can use UTF-8, set the UTF-8 flag. */
+ if (!is_all_ascii(archive_entry_pathname(zip->entry))) {
+ if (zip->opt_sconv != NULL) {
+ if (strcmp(archive_string_conversion_charset_name(
+ zip->opt_sconv), "UTF-8") == 0)
+ zip->entry_flags |= ZIP_ENTRY_FLAG_UTF8_NAME;
+#if HAVE_NL_LANGINFO
+ } else if (strcmp(nl_langinfo(CODESET), "UTF-8") == 0) {
+ zip->entry_flags |= ZIP_ENTRY_FLAG_UTF8_NAME;
+#endif
}
}
- /* If all characters in a filename are ASCII, Reset UTF-8 Name flag. */
- if ((l->flags & ZIP_FLAGS_UTF8_NAME) != 0 &&
- is_all_ascii(archive_entry_pathname(l->entry)))
- l->flags &= ~ZIP_FLAGS_UTF8_NAME;
+ filename_length = path_length(zip->entry);
- /* Initialize the CRC variable and potentially the local crc32(). */
- l->crc32 = crc32(0, NULL, 0);
+ /* Determine appropriate compression and size for this entry. */
if (type == AE_IFLNK) {
- const char *p = archive_entry_symlink(l->entry);
- if (p != NULL)
- size = strlen(p);
+ slink = archive_entry_symlink(zip->entry);
+ if (slink != NULL)
+ slink_size = strlen(slink);
else
- size = 0;
- zip->remaining_data_bytes = 0;
- archive_entry_set_size(l->entry, size);
- l->compression = COMPRESSION_STORE;
- l->compressed_size = size;
+ slink_size = 0;
+ zip->entry_uncompressed_limit = slink_size;
+ zip->entry_compressed_size = slink_size;
+ zip->entry_uncompressed_size = slink_size;
+ zip->entry_crc32 = zip->crc32func(zip->entry_crc32,
+ (const unsigned char *)slink, slink_size);
+ zip->entry_compression = COMPRESSION_STORE;
+ version_needed = 20;
+ } else if (type != AE_IFREG) {
+ zip->entry_compression = COMPRESSION_STORE;
+ zip->entry_uncompressed_limit = 0;
+ size = 0;
+ version_needed = 20;
+ } else if (archive_entry_size_is_set(zip->entry)) {
+ size = archive_entry_size(zip->entry);
+ zip->entry_uncompressed_limit = size;
+ zip->entry_compression = zip->requested_compression;
+ if (zip->entry_compression == COMPRESSION_UNSPECIFIED) {
+ zip->entry_compression = COMPRESSION_DEFAULT;
+ }
+ if (zip->entry_compression == COMPRESSION_STORE) {
+ zip->entry_compressed_size = size;
+ zip->entry_uncompressed_size = size;
+ version_needed = 10;
+ } else {
+ zip->entry_uncompressed_size = size;
+ version_needed = 20;
+ }
+ if ((zip->flags & ZIP_FLAG_FORCE_ZIP64) /* User asked. */
+ || (zip->entry_uncompressed_size > ARCHIVE_LITERAL_LL(0xffffffff))) { /* Large entry. */
+ zip->entry_uses_zip64 = 1;
+ version_needed = 45;
+ }
+
+ /* We may know the size, but never the CRC. */
+ zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END;
} else {
- l->compression = zip->compression;
- l->compressed_size = 0;
+ /* Prefer deflate if it's available, because deflate
+ * has a clear end-of-data marker that makes
+ * length-at-end more reliable. */
+ zip->entry_compression = COMPRESSION_DEFAULT;
+ zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END;
+ if ((zip->flags & ZIP_FLAG_AVOID_ZIP64) == 0) {
+ zip->entry_uses_zip64 = 1;
+ version_needed = 45;
+ } else if (zip->entry_compression == COMPRESSION_STORE) {
+ version_needed = 10;
+ } else {
+ version_needed = 20;
+ }
}
- l->next = NULL;
- if (zip->central_directory == NULL) {
- zip->central_directory = l;
+
+ /* Format the local header. */
+ memset(local_header, 0, sizeof(local_header));
+ memcpy(local_header, "PK\003\004", 4);
+ archive_le16enc(local_header + 4, version_needed);
+ archive_le16enc(local_header + 6, zip->entry_flags);
+ archive_le16enc(local_header + 8, zip->entry_compression);
+ archive_le32enc(local_header + 10, dos_time(archive_entry_mtime(zip->entry)));
+ archive_le32enc(local_header + 14, zip->entry_crc32);
+ if (zip->entry_uses_zip64) {
+ /* Zip64 data in the local header "must" include both
+ * compressed and uncompressed sizes AND those fields
+ * are included only if these are 0xffffffff;
+ * THEREFORE these must be set this way, even if we
+ * know one of them is smaller. */
+ archive_le32enc(local_header + 18, ARCHIVE_LITERAL_LL(0xffffffff));
+ archive_le32enc(local_header + 22, ARCHIVE_LITERAL_LL(0xffffffff));
} else {
- zip->central_directory_end->next = l;
- }
- zip->central_directory_end = l;
-
- /* Store the offset of this header for later use in central
- * directory. */
- l->offset = zip->written_bytes;
-
- memset(h, 0, sizeof(h));
- archive_le32enc(&h[LOCAL_FILE_HEADER_SIGNATURE],
- ZIP_SIGNATURE_LOCAL_FILE_HEADER);
- archive_le16enc(&h[LOCAL_FILE_HEADER_VERSION], ZIP_VERSION_EXTRACT);
- archive_le16enc(&h[LOCAL_FILE_HEADER_FLAGS], l->flags);
- archive_le16enc(&h[LOCAL_FILE_HEADER_COMPRESSION], l->compression);
- archive_le32enc(&h[LOCAL_FILE_HEADER_TIMEDATE],
- dos_time(archive_entry_mtime(entry)));
- archive_le16enc(&h[LOCAL_FILE_HEADER_FILENAME_LENGTH],
- (uint16_t)path_length(l->entry));
-
- switch (l->compression) {
- case COMPRESSION_STORE:
- /* Setting compressed and uncompressed sizes even when
- * specification says to set to zero when using data
- * descriptors. Otherwise the end of the data for an
- * entry is rather difficult to find. */
- archive_le32enc(&h[LOCAL_FILE_HEADER_COMPRESSED_SIZE],
- (uint32_t)size);
- archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE],
- (uint32_t)size);
- break;
-#ifdef HAVE_ZLIB_H
- case COMPRESSION_DEFLATE:
- archive_le32enc(&h[LOCAL_FILE_HEADER_UNCOMPRESSED_SIZE],
- (uint32_t)size);
+ archive_le32enc(local_header + 18, zip->entry_compressed_size);
+ archive_le32enc(local_header + 22, zip->entry_uncompressed_size);
+ }
+ archive_le16enc(local_header + 26, filename_length);
+
+ /* Format as much of central directory file header as we can: */
+ zip->file_header = cd_alloc(zip, 46);
+ /* If (zip->file_header == NULL) XXXX */
+ ++zip->central_directory_entries;
+ memset(zip->file_header, 0, 46);
+ memcpy(zip->file_header, "PK\001\002", 4);
+ /* "Made by PKZip 2.0 on Unix." */
+ archive_le16enc(zip->file_header + 4, 3 * 256 + version_needed);
+ archive_le16enc(zip->file_header + 6, version_needed);
+ archive_le16enc(zip->file_header + 8, zip->entry_flags);
+ archive_le16enc(zip->file_header + 10, zip->entry_compression);
+ archive_le32enc(zip->file_header + 12, dos_time(archive_entry_mtime(zip->entry)));
+ archive_le16enc(zip->file_header + 28, filename_length);
+ /* Following Info-Zip, store mode in the "external attributes" field. */
+ archive_le32enc(zip->file_header + 38,
+ ((uint32_t)archive_entry_mode(zip->entry)) << 16);
+ e = cd_alloc(zip, filename_length);
+ /* If (e == NULL) XXXX */
+ copy_path(zip->entry, e);
+
+ /* Format extra data. */
+ memset(local_extra, 0, sizeof(local_extra));
+ e = local_extra;
+
+ /* First, extra blocks that are the same between
+ * the local file header and the central directory.
+ * We format them once and then duplicate them. */
+
+ /* UT timestamp, length depends on what timestamps are set. */
+ memcpy(e, "UT", 2);
+ archive_le16enc(e + 2,
+ 1
+ + (archive_entry_mtime_is_set(entry) ? 4 : 0)
+ + (archive_entry_atime_is_set(entry) ? 4 : 0)
+ + (archive_entry_ctime_is_set(entry) ? 4 : 0));
+ e += 4;
+ *e++ =
+ (archive_entry_mtime_is_set(entry) ? 1 : 0)
+ | (archive_entry_atime_is_set(entry) ? 2 : 0)
+ | (archive_entry_ctime_is_set(entry) ? 4 : 0);
+ if (archive_entry_mtime_is_set(entry)) {
+ archive_le32enc(e, (uint32_t)archive_entry_mtime(entry));
+ e += 4;
+ }
+ if (archive_entry_atime_is_set(entry)) {
+ archive_le32enc(e, (uint32_t)archive_entry_atime(entry));
+ e += 4;
+ }
+ if (archive_entry_ctime_is_set(entry)) {
+ archive_le32enc(e, (uint32_t)archive_entry_ctime(entry));
+ e += 4;
+ }
- zip->stream.zalloc = Z_NULL;
- zip->stream.zfree = Z_NULL;
- zip->stream.opaque = Z_NULL;
- zip->stream.next_out = zip->buf;
- zip->stream.avail_out = (uInt)zip->len_buf;
- if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION,
- Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't init deflate compressor");
- return (ARCHIVE_FATAL);
+ /* ux Unix extra data, length 11, version 1 */
+ /* TODO: If uid < 64k, use 2 bytes, ditto for gid. */
+ memcpy(e, "ux\013\000\001", 5);
+ e += 5;
+ *e++ = 4; /* Length of following UID */
+ archive_le32enc(e, (uint32_t)archive_entry_uid(entry));
+ e += 4;
+ *e++ = 4; /* Length of following GID */
+ archive_le32enc(e, (uint32_t)archive_entry_gid(entry));
+ e += 4;
+
+ /* Copy UT and ux into central directory as well. */
+ zip->file_header_extra_offset = zip->central_directory_bytes;
+ cd_extra = cd_alloc(zip, e - local_extra);
+ memcpy(cd_extra, local_extra, e - local_extra);
+
+ /*
+ * Following extra blocks vary between local header and
+ * central directory. These are the local header versions.
+ * Central directory versions get formatted in
+ * archive_write_zip_finish_entry() below.
+ */
+
+ /* "[Zip64 entry] in the local header MUST include BOTH
+ * original [uncompressed] and compressed size fields." */
+ if (zip->entry_uses_zip64) {
+ unsigned char *zip64_start = e;
+ memcpy(e, "\001\000\020\000", 4);
+ e += 4;
+ archive_le64enc(e, zip->entry_uncompressed_size);
+ e += 8;
+ archive_le64enc(e, zip->entry_compressed_size);
+ e += 8;
+ archive_le16enc(zip64_start + 2, e - (zip64_start + 4));
+ }
+
+ if (zip->flags & ZIP_FLAG_EXPERIMENT_EL) {
+ /* Experimental 'el' extension to improve streaming. */
+ unsigned char *external_info = e;
+ int included = 7;
+ memcpy(e, "el\000\000", 4); // 0x6c65 + 2-byte length
+ e += 4;
+ e[0] = included; /* bitmap of included fields */
+ e += 1;
+ if (included & 1) {
+ archive_le16enc(e, /* "Version created by" */
+ 3 * 256 + version_needed);
+ e += 2;
}
- break;
-#endif
+ if (included & 2) {
+ archive_le16enc(e, 0); /* internal file attributes */
+ e += 2;
+ }
+ if (included & 4) {
+ archive_le32enc(e, /* external file attributes */
+ ((uint32_t)archive_entry_mode(zip->entry)) << 16);
+ e += 4;
+ }
+ if (included & 8) {
+ // Libarchive does not currently support file comments.
+ }
+ archive_le16enc(external_info + 2, e - (external_info + 4));
}
- /* Formatting extra data. */
- archive_le16enc(&h[LOCAL_FILE_HEADER_EXTRA_LENGTH], sizeof(e));
- archive_le16enc(&e[EXTRA_DATA_LOCAL_TIME_ID],
- ZIP_SIGNATURE_EXTRA_TIMESTAMP);
- archive_le16enc(&e[EXTRA_DATA_LOCAL_TIME_SIZE], 1 + 4 * 3);
- e[EXTRA_DATA_LOCAL_TIME_FLAG] = 0x07;
- archive_le32enc(&e[EXTRA_DATA_LOCAL_MTIME],
- (uint32_t)archive_entry_mtime(entry));
- archive_le32enc(&e[EXTRA_DATA_LOCAL_ATIME],
- (uint32_t)archive_entry_atime(entry));
- archive_le32enc(&e[EXTRA_DATA_LOCAL_CTIME],
- (uint32_t)archive_entry_ctime(entry));
-
- archive_le16enc(&e[EXTRA_DATA_LOCAL_UNIX_ID],
- ZIP_SIGNATURE_EXTRA_NEW_UNIX);
- archive_le16enc(&e[EXTRA_DATA_LOCAL_UNIX_SIZE], 1 + (1 + 4) * 2);
- e[EXTRA_DATA_LOCAL_UNIX_VERSION] = 1;
- e[EXTRA_DATA_LOCAL_UNIX_UID_SIZE] = 4;
- archive_le32enc(&e[EXTRA_DATA_LOCAL_UNIX_UID],
- (uint32_t)archive_entry_uid(entry));
- e[EXTRA_DATA_LOCAL_UNIX_GID_SIZE] = 4;
- archive_le32enc(&e[EXTRA_DATA_LOCAL_UNIX_GID],
- (uint32_t)archive_entry_gid(entry));
-
- archive_le32enc(&d[DATA_DESCRIPTOR_UNCOMPRESSED_SIZE],
- (uint32_t)size);
-
- ret = __archive_write_output(a, h, sizeof(h));
+ /* Update local header with size of extra data and write it all out: */
+ archive_le16enc(local_header + 28, e - local_extra);
+
+ ret = __archive_write_output(a, local_header, 30);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- zip->written_bytes += sizeof(h);
+ zip->written_bytes += 30;
- ret = write_path(l->entry, a);
+ ret = write_path(zip->entry, a);
if (ret <= ARCHIVE_OK)
return (ARCHIVE_FATAL);
zip->written_bytes += ret;
- ret = __archive_write_output(a, e, sizeof(e));
+ ret = __archive_write_output(a, local_extra, e - local_extra);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- zip->written_bytes += sizeof(e);
-
- if (type == AE_IFLNK) {
- const unsigned char *p;
+ zip->written_bytes += e - local_extra;
- p = (const unsigned char *)archive_entry_symlink(l->entry);
- ret = __archive_write_output(a, p, (size_t)size);
+ /* For symlinks, write the body now. */
+ if (slink != NULL) {
+ ret = __archive_write_output(a, slink, slink_size);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- zip->written_bytes += size;
- l->crc32 = crc32(l->crc32, p, (unsigned)size);
+ zip->entry_compressed_written += slink_size;
+ zip->entry_uncompressed_written += slink_size;
+ zip->written_bytes += slink_size;
}
- if (ret2 != ARCHIVE_OK)
- return (ret2);
- return (ARCHIVE_OK);
+#ifdef HAVE_ZLIB_H
+ if (zip->entry_compression == COMPRESSION_DEFLATE) {
+ zip->stream.zalloc = Z_NULL;
+ zip->stream.zfree = Z_NULL;
+ zip->stream.opaque = Z_NULL;
+ zip->stream.next_out = zip->buf;
+ zip->stream.avail_out = (uInt)zip->len_buf;
+ if (deflateInit2(&zip->stream, Z_DEFAULT_COMPRESSION,
+ Z_DEFLATED, -15, 8, Z_DEFAULT_STRATEGY) != Z_OK) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't init deflate compressor");
+ return (ARCHIVE_FATAL);
+ }
+ }
+#endif
+
+ return (ret2);
}
static ssize_t
@@ -634,22 +775,21 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
{
int ret;
struct zip *zip = a->format_data;
- struct zip_file_header_link *l = zip->central_directory_end;
- if ((int64_t)s > zip->remaining_data_bytes)
- s = (size_t)zip->remaining_data_bytes;
+ if ((int64_t)s > zip->entry_uncompressed_limit)
+ s = (size_t)zip->entry_uncompressed_limit;
+ zip->entry_uncompressed_written += s;
if (s == 0) return 0;
- switch (l->compression) {
+ switch (zip->entry_compression) {
case COMPRESSION_STORE:
ret = __archive_write_output(a, buff, s);
- if (ret != ARCHIVE_OK) return (ret);
+ if (ret != ARCHIVE_OK)
+ return (ret);
zip->written_bytes += s;
- zip->remaining_data_bytes -= s;
- l->compressed_size += s;
- l->crc32 = crc32(l->crc32, buff, (unsigned)s);
- return (s);
+ zip->entry_compressed_written += s;
+ break;
#if HAVE_ZLIB_H
case COMPRESSION_DEFLATE:
zip->stream.next_in = (unsigned char*)(uintptr_t)buff;
@@ -663,16 +803,13 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
zip->len_buf);
if (ret != ARCHIVE_OK)
return (ret);
- l->compressed_size += zip->len_buf;
+ zip->entry_compressed_written += zip->len_buf;
zip->written_bytes += zip->len_buf;
zip->stream.next_out = zip->buf;
zip->stream.avail_out = (uInt)zip->len_buf;
}
} while (zip->stream.avail_in != 0);
- zip->remaining_data_bytes -= s;
- /* If we have it, use zlib's fast crc32() */
- l->crc32 = crc32(l->crc32, buff, (uInt)s);
- return (s);
+ break;
#endif
default:
@@ -680,153 +817,174 @@ archive_write_zip_data(struct archive_write *a, const void *buff, size_t s)
"Invalid ZIP compression type");
return ARCHIVE_FATAL;
}
+
+ zip->entry_uncompressed_limit -= s;
+ zip->entry_crc32 = zip->crc32func(zip->entry_crc32, buff, (unsigned)s);
+ return (s);
+
}
static int
archive_write_zip_finish_entry(struct archive_write *a)
{
- /* Write the data descripter after file data has been written. */
- int ret;
struct zip *zip = a->format_data;
- uint8_t *d = zip->data_descriptor;
- struct zip_file_header_link *l = zip->central_directory_end;
-#if HAVE_ZLIB_H
- size_t reminder;
-#endif
+ int ret;
- switch(l->compression) {
- case COMPRESSION_STORE:
- break;
#if HAVE_ZLIB_H
- case COMPRESSION_DEFLATE:
+ if (zip->entry_compression == COMPRESSION_DEFLATE) {
for (;;) {
+ size_t remainder;
ret = deflate(&zip->stream, Z_FINISH);
if (ret == Z_STREAM_ERROR)
return (ARCHIVE_FATAL);
- reminder = zip->len_buf - zip->stream.avail_out;
- ret = __archive_write_output(a, zip->buf, reminder);
+ remainder = zip->len_buf - zip->stream.avail_out;
+ ret = __archive_write_output(a, zip->buf, remainder);
if (ret != ARCHIVE_OK)
return (ret);
- l->compressed_size += reminder;
- zip->written_bytes += reminder;
+ zip->entry_compressed_written += remainder;
+ zip->written_bytes += remainder;
zip->stream.next_out = zip->buf;
if (zip->stream.avail_out != 0)
break;
zip->stream.avail_out = (uInt)zip->len_buf;
}
deflateEnd(&zip->stream);
- break;
+ }
#endif
+
+ /* Write trailing data descriptor. */
+ if ((zip->entry_flags & ZIP_ENTRY_FLAG_LENGTH_AT_END) != 0) {
+ char d[24];
+ memcpy(d, "PK\007\010", 4);
+ archive_le32enc(d + 4, zip->entry_crc32);
+ if (zip->entry_uses_zip64) {
+ archive_le64enc(d + 8, (uint64_t)zip->entry_compressed_written);
+ archive_le64enc(d + 16, (uint64_t)zip->entry_uncompressed_written);
+ ret = __archive_write_output(a, d, 24);
+ zip->written_bytes += 24;
+ } else {
+ archive_le32enc(d + 8, (uint32_t)zip->entry_compressed_written);
+ archive_le32enc(d + 12, (uint32_t)zip->entry_uncompressed_written);
+ ret = __archive_write_output(a, d, 16);
+ zip->written_bytes += 16;
+ }
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
}
- archive_le32enc(&d[DATA_DESCRIPTOR_CRC32], l->crc32);
- archive_le32enc(&d[DATA_DESCRIPTOR_COMPRESSED_SIZE],
- (uint32_t)l->compressed_size);
- ret = __archive_write_output(a, d, SIZE_DATA_DESCRIPTOR);
- if (ret != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
- zip->written_bytes += SIZE_DATA_DESCRIPTOR;
+ /* Append Zip64 extra data to central directory information. */
+ if (zip->entry_compressed_written > ARCHIVE_LITERAL_LL(0xffffffff)
+ || zip->entry_uncompressed_written > ARCHIVE_LITERAL_LL(0xffffffff)
+ || zip->entry_offset > ARCHIVE_LITERAL_LL(0xffffffff)) {
+ unsigned char zip64[32];
+ unsigned char *z = zip64, *zd;
+ memcpy(z, "\001\000\000\000", 4);
+ z += 4;
+ if (zip->entry_uncompressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+ archive_le64enc(z, zip->entry_uncompressed_written);
+ z += 8;
+ }
+ if (zip->entry_compressed_written >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+ archive_le64enc(z, zip->entry_compressed_written);
+ z += 8;
+ }
+ if (zip->entry_offset >= ARCHIVE_LITERAL_LL(0xffffffff)) {
+ archive_le64enc(z, zip->entry_offset);
+ z += 8;
+ }
+ archive_le16enc(zip64 + 2, z - (zip64 + 4));
+ zd = cd_alloc(zip, z - zip64);
+ if (zd == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate zip data");
+ return (ARCHIVE_FATAL);
+ }
+ memcpy(zd, zip64, z - zip64);
+ /* Zip64 means version needs to be set to at least 4.5 */
+ if (archive_le16dec(zip->file_header + 6) < 45)
+ archive_le16enc(zip->file_header + 6, 45);
+ }
+
+ /* Fix up central directory file header. */
+ archive_le32enc(zip->file_header + 16, zip->entry_crc32);
+ archive_le32enc(zip->file_header + 20,
+ zipmin(zip->entry_compressed_written, ARCHIVE_LITERAL_LL(0xffffffff)));
+ archive_le32enc(zip->file_header + 24,
+ zipmin(zip->entry_uncompressed_written, ARCHIVE_LITERAL_LL(0xffffffff)));
+ archive_le16enc(zip->file_header + 30,
+ zip->central_directory_bytes - zip->file_header_extra_offset);
+ archive_le32enc(zip->file_header + 42,
+ zipmin(zip->entry_offset, ARCHIVE_LITERAL_LL(0xffffffff)));
+
return (ARCHIVE_OK);
}
static int
archive_write_zip_close(struct archive_write *a)
{
- struct zip *zip;
- struct zip_file_header_link *l;
- uint8_t h[SIZE_FILE_HEADER];
- uint8_t end[SIZE_CENTRAL_DIRECTORY_END];
- uint8_t e[SIZE_EXTRA_DATA_CENTRAL];
+ uint8_t buff[64];
int64_t offset_start, offset_end;
- int entries;
+ struct zip *zip = a->format_data;
+ struct cd_segment *segment;
int ret;
- zip = a->format_data;
- l = zip->central_directory;
-
- /*
- * Formatting central directory file header fields that are
- * fixed for all entries.
- * Fields not used (and therefor 0) are:
- *
- * - comment_length
- * - disk_number
- * - attributes_internal
- */
- memset(h, 0, sizeof(h));
- archive_le32enc(&h[FILE_HEADER_SIGNATURE], ZIP_SIGNATURE_FILE_HEADER);
- archive_le16enc(&h[FILE_HEADER_VERSION_BY], ZIP_VERSION_BY);
- archive_le16enc(&h[FILE_HEADER_VERSION_EXTRACT], ZIP_VERSION_EXTRACT);
-
- entries = 0;
offset_start = zip->written_bytes;
-
- /* Formatting individual header fields per entry and
- * writing each entry. */
- while (l != NULL) {
- archive_le16enc(&h[FILE_HEADER_FLAGS], l->flags);
- archive_le16enc(&h[FILE_HEADER_COMPRESSION], l->compression);
- archive_le32enc(&h[FILE_HEADER_TIMEDATE],
- dos_time(archive_entry_mtime(l->entry)));
- archive_le32enc(&h[FILE_HEADER_CRC32], l->crc32);
- archive_le32enc(&h[FILE_HEADER_COMPRESSED_SIZE],
- (uint32_t)l->compressed_size);
- archive_le32enc(&h[FILE_HEADER_UNCOMPRESSED_SIZE],
- (uint32_t)archive_entry_size(l->entry));
- archive_le16enc(&h[FILE_HEADER_FILENAME_LENGTH],
- (uint16_t)path_length(l->entry));
- archive_le16enc(&h[FILE_HEADER_EXTRA_LENGTH], sizeof(e));
- archive_le16enc(&h[FILE_HEADER_ATTRIBUTES_EXTERNAL+2],
- archive_entry_mode(l->entry));
- archive_le32enc(&h[FILE_HEADER_OFFSET], (uint32_t)l->offset);
-
- /* Formatting extra data. */
- archive_le16enc(&e[EXTRA_DATA_CENTRAL_TIME_ID],
- ZIP_SIGNATURE_EXTRA_TIMESTAMP);
- archive_le16enc(&e[EXTRA_DATA_CENTRAL_TIME_SIZE], 1 + 4);
- e[EXTRA_DATA_CENTRAL_TIME_FLAG] = 0x07;
- archive_le32enc(&e[EXTRA_DATA_CENTRAL_MTIME],
- (uint32_t)archive_entry_mtime(l->entry));
- archive_le16enc(&e[EXTRA_DATA_CENTRAL_UNIX_ID],
- ZIP_SIGNATURE_EXTRA_NEW_UNIX);
- archive_le16enc(&e[EXTRA_DATA_CENTRAL_UNIX_SIZE], 0x0000);
-
- ret = __archive_write_output(a, h, sizeof(h));
+ segment = zip->central_directory;
+ while (segment != NULL) {
+ ret = __archive_write_output(a,
+ segment->buff, segment->p - segment->buff);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- zip->written_bytes += sizeof(h);
-
- ret = write_path(l->entry, a);
- if (ret <= ARCHIVE_OK)
- return (ARCHIVE_FATAL);
- zip->written_bytes += ret;
+ zip->written_bytes += segment->p - segment->buff;
+ segment = segment->next;
+ }
+ offset_end = zip->written_bytes;
- ret = __archive_write_output(a, e, sizeof(e));
- if (ret != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
- zip->written_bytes += sizeof(e);
+ /* If central dir info is too large, write Zip64 end-of-cd */
+ if (offset_end - offset_start > ARCHIVE_LITERAL_LL(0xffffffff)
+ || offset_start > ARCHIVE_LITERAL_LL(0xffffffff)
+ || zip->central_directory_entries > 0xffffUL
+ || (zip->flags & ZIP_FLAG_FORCE_ZIP64)) {
+ /* Zip64 end-of-cd record */
+ memset(buff, 0, 56);
+ memcpy(buff, "PK\006\006", 4);
+ archive_le64enc(buff + 4, 44);
+ archive_le16enc(buff + 12, 45);
+ archive_le16enc(buff + 14, 45);
+ /* This is disk 0 of 0. */
+ archive_le64enc(buff + 24, zip->central_directory_entries);
+ archive_le64enc(buff + 32, zip->central_directory_entries);
+ archive_le64enc(buff + 40, offset_end - offset_start);
+ archive_le64enc(buff + 48, offset_start);
+ ret = __archive_write_output(a, buff, 56);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += 56;
+
+ /* Zip64 end-of-cd locator record. */
+ memset(buff, 0, 20);
+ memcpy(buff, "PK\006\007", 4);
+ archive_le32enc(buff + 4, 0);
+ archive_le64enc(buff + 8, offset_end);
+ archive_le32enc(buff + 16, 1);
+ ret = __archive_write_output(a, buff, 20);
+ if (ret != ARCHIVE_OK)
+ return (ARCHIVE_FATAL);
+ zip->written_bytes += 20;
- l = l->next;
- entries++;
}
- offset_end = zip->written_bytes;
- /* Formatting end of central directory. */
- memset(end, 0, sizeof(end));
- archive_le32enc(&end[CENTRAL_DIRECTORY_END_SIGNATURE],
- ZIP_SIGNATURE_CENTRAL_DIRECTORY_END);
- archive_le16enc(&end[CENTRAL_DIRECTORY_END_ENTRIES_DISK], entries);
- archive_le16enc(&end[CENTRAL_DIRECTORY_END_ENTRIES], entries);
- archive_le32enc(&end[CENTRAL_DIRECTORY_END_SIZE],
- (uint32_t)(offset_end - offset_start));
- archive_le32enc(&end[CENTRAL_DIRECTORY_END_OFFSET],
- (uint32_t)offset_start);
-
- /* Writing end of central directory. */
- ret = __archive_write_output(a, end, sizeof(end));
+ /* Format and write end of central directory. */
+ memset(buff, 0, sizeof(buff));
+ memcpy(buff, "PK\005\006", 4);
+ archive_le16enc(buff + 8, zipmin(0xffffU, zip->central_directory_entries));
+ archive_le16enc(buff + 10, zipmin(0xffffU, zip->central_directory_entries));
+ archive_le32enc(buff + 12, (uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff), (offset_end - offset_start)));
+ archive_le32enc(buff + 16, (uint32_t)zipmin(ARCHIVE_LITERAL_LL(0xffffffff), offset_start));
+ ret = __archive_write_output(a, buff, 22);
if (ret != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- zip->written_bytes += sizeof(end);
+ zip->written_bytes += 22;
return (ARCHIVE_OK);
}
@@ -834,18 +992,21 @@ static int
archive_write_zip_free(struct archive_write *a)
{
struct zip *zip;
- struct zip_file_header_link *l;
+ struct cd_segment *segment;
zip = a->format_data;
while (zip->central_directory != NULL) {
- l = zip->central_directory;
- zip->central_directory = l->next;
- archive_entry_free(l->entry);
- free(l);
+ segment = zip->central_directory;
+ zip->central_directory = segment->next;
+ free(segment->buff);
+ free(segment);
}
#ifdef HAVE_ZLIB_H
free(zip->buf);
#endif
+ archive_entry_free(zip->entry);
+ /* TODO: Free opt_sconv, sconv_default */
+
free(zip);
a->format_data = NULL;
return (ARCHIVE_OK);
@@ -918,7 +1079,7 @@ write_path(struct archive_entry *entry, struct archive_write *archive)
return (ARCHIVE_FATAL);
written_bytes += strlen(path);
- /* Folders are recognized by a traling slash. */
+ /* Folders are recognized by a trailing slash. */
if ((type == AE_IFDIR) & (path[strlen(path) - 1] != '/')) {
ret = __archive_write_output(archive, "/", 1);
if (ret != ARCHIVE_OK)
@@ -928,3 +1089,38 @@ write_path(struct archive_entry *entry, struct archive_write *archive)
return ((int)written_bytes);
}
+
+static void
+copy_path(struct archive_entry *entry, unsigned char *p)
+{
+ const char *path;
+ size_t pathlen;
+ mode_t type;
+
+ path = archive_entry_pathname(entry);
+ pathlen = strlen(path);
+ type = archive_entry_filetype(entry);
+
+ memcpy(p, path, pathlen);
+
+ /* Folders are recognized by a trailing slash. */
+ if ((type == AE_IFDIR) & (path[pathlen - 1] != '/')) {
+ p[pathlen] = '/';
+ p[pathlen + 1] = '\0';
+ }
+}
+
+
+static struct archive_string_conv *
+get_sconv(struct archive_write *a, struct zip *zip)
+{
+ if (zip->opt_sconv != NULL)
+ return (zip->opt_sconv);
+
+ if (!zip->init_default_conversion) {
+ zip->sconv_default =
+ archive_string_default_conversion_for_write(&(a->archive));
+ zip->init_default_conversion = 1;
+ }
+ return (zip->sconv_default);
+}
diff --git a/Utilities/cmlibarchive/libarchive/filter_fork_windows.c b/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
index fa59cc9..ad271fe 100644
--- a/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
+++ b/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
@@ -36,7 +36,7 @@ __archive_create_child(const char *cmd, int *child_stdin, int *child_stdout)
{
HANDLE childStdout[2], childStdin[2],childStderr;
SECURITY_ATTRIBUTES secAtts;
- STARTUPINFO staInfo;
+ STARTUPINFOA staInfo;
PROCESS_INFORMATION childInfo;
struct archive_string cmdline;
struct archive_string fullpath;
diff --git a/Utilities/cmlibarchive/libarchive/mtree.5 b/Utilities/cmlibarchive/libarchive/mtree.5
index 983fff7..8c45a7d 100644
--- a/Utilities/cmlibarchive/libarchive/mtree.5
+++ b/Utilities/cmlibarchive/libarchive/mtree.5
@@ -28,7 +28,7 @@
.\" From: @(#)mtree.8 8.2 (Berkeley) 12/11/93
.\" $FreeBSD$
.\"
-.Dd May 6, 2008
+.Dd September 4, 2013
.Dt MTREE 5
.Os
.Sh NAME
@@ -134,6 +134,52 @@ The checksum of the file using the default algorithm specified by
the
.Xr cksum 1
utility.
+.It Cm device
+The device number for
+.Sy block
+or
+.Sy char
+file types.
+The value must be one of the following forms:
+.Pp
+.Bl -tag -width 4n
+.It Ar format , Ns Ar major , Ns Ar minor Ns Bo , Ns Ar subunit Bc
+A device with
+.Ar major , minor
+and optional
+.Ar subunit
+fields.
+Their meaning is specified by the operating's system
+.Ar format .
+See below for valid formats.
+.It Ar number
+Opaque number (as stored on the file system).
+.El
+.Pp
+The following values for
+.Ar format
+are recognized:
+.Sy native ,
+.Sy 386bsd ,
+.Sy 4bsd ,
+.Sy bsdos ,
+.Sy freebsd ,
+.Sy hpux ,
+.Sy isc ,
+.Sy linux ,
+.Sy netbsd ,
+.Sy osf1 ,
+.Sy sco ,
+.Sy solaris ,
+.Sy sunos ,
+.Sy svr3 ,
+.Sy svr4 ,
+and
+.Sy ultrix .
+.Pp
+See
+.Xr mknod 8
+for more details.
.It Cm contents
The full pathname of a file that holds the contents of this file.
.It Cm flags
@@ -150,6 +196,8 @@ The file group as a numeric value.
The file group as a symbolic name.
.It Cm ignore
Ignore any file hierarchy below this file.
+.It Cm inode
+The inode number.
.It Cm link
The target of the symbolic link when type=link.
.It Cm md5
@@ -164,6 +212,16 @@ value.
The number of hard links the file is expected to have.
.It Cm nochange
Make sure this file or directory exists but otherwise ignore all attributes.
+.It Cm optional
+The file is optional; do not complain about the file if it is not in
+the file hierarchy.
+.It Cm resdevice
+The
+.Dq resident
+device number of the file, e.g. the ID of the device that
+contains the file.
+Its format is the same as the one for
+.Cm device .
.It Cm ripemd160digest
The
.Tn RIPEMD160
@@ -192,6 +250,24 @@ message digest of the file.
.It Cm sha256digest
A synonym for
.Cm sha256 .
+.It Cm sha384
+The
+.Tn FIPS
+180-2
+.Pq Dq Tn SHA-384
+message digest of the file.
+.It Cm sha384digest
+A synonym for
+.Cm sha384 .
+.It Cm sha512
+The
+.Tn FIPS
+180-2
+.Pq Dq Tn SHA-512
+message digest of the file.
+.It Cm sha512digest
+A synonym for
+.Cm sha512 .
.It Cm size
The size, in bytes, of the file.
.It Cm time
diff --git a/bootstrap b/bootstrap
index 69dcbce..233806c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -329,6 +329,7 @@ fi
KWSYS_CXX_SOURCES="\
Directory \
EncodingCXX \
+ FStream \
Glob \
RegularExpression \
SystemTools"
@@ -1085,8 +1086,8 @@ if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
cmake_test_flags=
# If we are on HP-UX, check for -Ae for the C compiler.
- cmake_test_flags="-Ae"
if [ "x${cmake_system}" = "xHP-UX" ]; then
+ cmake_test_flags="-Ae"
TMPFILE=`cmake_tmp_file`
echo '
int main(int argc, char** argv) { (void)argc; (void)argv; return 0; }
@@ -1107,6 +1108,29 @@ if [ "x${cmake_cxx_compiler_is_gnu}" != "x1" ]; then
echo "${cmake_c_compiler} does not need ${cmake_test_flags}"
fi
rm -f "${TMPFILE}.c"
+ echo '
+ #include <iostream>
+ int main(int argc, char** argv) {
+ for(int i=0; i < 1; ++i);
+ for(int i=0; i < 1; ++i);
+ (void)argc; (void)argv; return 0; }
+' > ${TMPFILE}.cxx
+ cmake_need_AAstd98=0
+ cmake_test_flags="-AA +hpxstd98"
+ if cmake_try_run "${cmake_cxx_compiler}" "${cmake_cxx_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
+ :
+ else
+ if cmake_try_run "${cmake_cxx_compiler}" \
+ "${cmake_cxx_flags} ${cmake_test_flags}" "${TMPFILE}.cxx" >> cmake_bootstrap.log 2>&1; then
+ cmake_need_AAstd98=1
+ fi
+ fi
+ if [ "x${cmake_need_AAstd98}" = "x1" ]; then
+ cmake_cxx_flags="${cmake_cxx_flags} ${cmake_test_flags}"
+ echo "${cmake_cxx_compiler} needs ${cmake_test_flags}"
+ else
+ echo "${cmake_cxx_compiler} does not need ${cmake_test_flags}"
+ fi
fi
cmake_test_flags=
fi
diff --git a/cmake_uninstall.cmake.in b/cmake_uninstall.cmake.in
index 7cd7fc1..d81f62a 100644
--- a/cmake_uninstall.cmake.in
+++ b/cmake_uninstall.cmake.in
@@ -3,7 +3,7 @@ if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif()
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
-string(REGEX REPLACE "\n" ";" files "${files}")
+string(REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"")
if(EXISTS "$ENV{DESTDIR}${file}")