summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy1
-rw-r--r--Help/command/add_custom_command.rst6
-rw-r--r--Help/command/add_custom_target.rst6
-rw-r--r--Help/command/target_precompile_headers.rst14
-rw-r--r--Help/cpack_gen/wix.rst4
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst7
-rw-r--r--Modules/CMakePlatformId.h.in3
-rw-r--r--Modules/Compiler/IAR-C.cmake5
-rw-r--r--Modules/Compiler/IAR-CXX.cmake4
-rw-r--r--Modules/Compiler/IAR-DetermineCompiler.cmake2
-rw-r--r--Modules/Compiler/IAR-FindBinUtils.cmake3
-rw-r--r--Modules/FindPkgConfig.cmake6
-rw-r--r--Modules/Platform/Windows-MSVC.cmake13
-rw-r--r--Source/CMakeLists.txt2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWInstaller.cxx2
-rw-r--r--Source/CPack/IFW/cmCPackIFWPackage.cxx2
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx2
-rw-r--r--Source/CPack/OSXScriptLauncher.cxx3
-rw-r--r--Source/CPack/WiX/cmCPackWIXGenerator.cxx35
-rw-r--r--Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx10
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx2
-rw-r--r--Source/CPack/cmCPackDragNDropGenerator.cxx2
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.cxx25
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.h12
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx4
-rw-r--r--Source/CPack/cmCPackPackageMakerGenerator.cxx6
-rw-r--r--Source/CPack/cmCPackProductBuildGenerator.cxx2
-rw-r--r--Source/CPack/cmCPackRPMGenerator.cxx2
-rw-r--r--Source/CPack/cmCPackSTGZGenerator.cxx2
-rw-r--r--Source/CPack/cpack.cxx7
-rw-r--r--Source/CTest/cmCTestBZR.cxx2
-rw-r--r--Source/CTest/cmCTestBuildAndTestHandler.cxx2
-rw-r--r--Source/CTest/cmCTestBuildCommand.cxx2
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx4
-rw-r--r--Source/CTest/cmCTestConfigureCommand.cxx2
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx4
-rw-r--r--Source/CTest/cmCTestCurl.cxx2
-rw-r--r--Source/CTest/cmCTestGIT.cxx8
-rw-r--r--Source/CTest/cmCTestHandlerCommand.cxx2
-rw-r--r--Source/CTest/cmCTestLaunch.cxx4
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx2
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx4
-rw-r--r--Source/CTest/cmCTestP4.cxx2
-rw-r--r--Source/CTest/cmCTestRunTest.cxx2
-rw-r--r--Source/CTest/cmCTestSVN.cxx4
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx6
-rw-r--r--Source/CTest/cmCTestSleepCommand.cxx2
-rw-r--r--Source/CTest/cmCTestStartCommand.cxx2
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx4
-rw-r--r--Source/CTest/cmCTestTestCommand.cxx2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx6
-rw-r--r--Source/CTest/cmCTestVC.cxx4
-rw-r--r--Source/CTest/cmParseBlanketJSCoverage.cxx4
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx4
-rw-r--r--Source/CTest/cmParseCoberturaCoverage.cxx4
-rw-r--r--Source/CTest/cmParseDelphiCoverage.cxx4
-rw-r--r--Source/CTest/cmParseGTMCoverage.cxx4
-rw-r--r--Source/CTest/cmParseJacocoCoverage.cxx4
-rw-r--r--Source/CTest/cmParsePHPCoverage.cxx4
-rw-r--r--Source/CTest/cmProcess.cxx2
-rw-r--r--Source/CursesDialog/ccmake.cxx4
-rw-r--r--Source/CursesDialog/cmCursesCacheEntryComposite.cxx2
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx4
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx4
-rw-r--r--Source/CursesDialog/cmCursesMainForm.h2
-rw-r--r--Source/CursesDialog/cmCursesStringWidget.cxx4
-rw-r--r--Source/QtDialog/CMakeSetup.cxx4
-rw-r--r--Source/cmAddCustomCommandCommand.cxx47
-rw-r--r--Source/cmAddCustomTargetCommand.cxx2
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx2
-rw-r--r--Source/cmAffinity.cxx2
-rw-r--r--Source/cmArchiveWrite.cxx4
-rw-r--r--Source/cmArchiveWrite.h2
-rw-r--r--Source/cmAuxSourceDirectoryCommand.cxx2
-rw-r--r--Source/cmBase32.h2
-rw-r--r--Source/cmBuildCommand.cxx75
-rw-r--r--Source/cmBuildCommand.h42
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx2
-rw-r--r--Source/cmCMakeMinimumRequired.cxx2
-rw-r--r--Source/cmCPluginAPI.cxx2
-rw-r--r--Source/cmCTest.cxx10
-rw-r--r--Source/cmCTest.h2
-rw-r--r--Source/cmCacheManager.cxx4
-rw-r--r--Source/cmCommandArgumentParserHelper.cxx2
-rw-r--r--Source/cmCommands.cxx61
-rw-r--r--Source/cmCommonTargetGenerator.cxx1
-rw-r--r--Source/cmComputeComponentGraph.cxx2
-rw-r--r--Source/cmComputeLinkDepends.cxx6
-rw-r--r--Source/cmComputeLinkInformation.cxx4
-rw-r--r--Source/cmComputeTargetDepends.cxx4
-rw-r--r--Source/cmConditionEvaluator.cxx6
-rw-r--r--Source/cmCoreTryCompile.cxx4
-rw-r--r--Source/cmCreateTestSourceList.cxx39
-rw-r--r--Source/cmCreateTestSourceList.h29
-rw-r--r--Source/cmCryptoHash.h2
-rw-r--r--Source/cmCustomCommand.cxx7
-rw-r--r--Source/cmCustomCommand.h17
-rw-r--r--Source/cmCustomCommandGenerator.cxx3
-rw-r--r--Source/cmCustomCommandLines.cxx22
-rw-r--r--Source/cmCustomCommandLines.h19
-rw-r--r--Source/cmDefinePropertyCommand.cxx51
-rw-r--r--Source/cmDefinePropertyCommand.h26
-rw-r--r--Source/cmDefinitions.cxx2
-rw-r--r--Source/cmDependsFortran.cxx4
-rw-r--r--Source/cmDependsJavaParserHelper.cxx6
-rw-r--r--Source/cmDocumentation.cxx4
-rw-r--r--Source/cmDocumentationFormatter.cxx2
-rw-r--r--Source/cmELF.cxx2
-rw-r--r--Source/cmEnableLanguageCommand.cxx17
-rw-r--r--Source/cmEnableLanguageCommand.h32
-rw-r--r--Source/cmExecProgramCommand.cxx2
-rw-r--r--Source/cmExecuteProcessCommand.cxx4
-rw-r--r--Source/cmExportFileGenerator.cxx4
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx2
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx2
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx4
-rw-r--r--Source/cmExtraKateGenerator.cxx2
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx2
-rw-r--r--Source/cmFLTKWrapUICommand.cxx60
-rw-r--r--Source/cmFLTKWrapUICommand.h30
-rw-r--r--Source/cmFileCommand.cxx8
-rw-r--r--Source/cmFileCopier.cxx2
-rw-r--r--Source/cmFileLock.cxx2
-rw-r--r--Source/cmFileLockPool.cxx2
-rw-r--r--Source/cmFileLockResult.cxx4
-rw-r--r--Source/cmFileLockUnix.cxx4
-rw-r--r--Source/cmFileMonitor.cxx2
-rw-r--r--Source/cmFilePathChecksum.h2
-rw-r--r--Source/cmFileTime.cxx2
-rw-r--r--Source/cmFindBase.cxx2
-rw-r--r--Source/cmFindCommon.cxx2
-rw-r--r--Source/cmFindLibraryCommand.cxx4
-rw-r--r--Source/cmFindPackageCommand.cxx6
-rw-r--r--Source/cmForEachCommand.cxx4
-rw-r--r--Source/cmFortranParser.h2
-rw-r--r--Source/cmFortranParserImpl.cxx4
-rw-r--r--Source/cmGeneratedFileStream.cxx2
-rw-r--r--Source/cmGeneratorExpression.cxx2
-rw-r--r--Source/cmGeneratorExpressionDAGChecker.cxx2
-rw-r--r--Source/cmGeneratorExpressionEvaluator.h2
-rw-r--r--Source/cmGeneratorExpressionLexer.h2
-rw-r--r--Source/cmGeneratorExpressionNode.cxx8
-rw-r--r--Source/cmGeneratorExpressionParser.cxx4
-rw-r--r--Source/cmGeneratorTarget.cxx176
-rw-r--r--Source/cmGeneratorTarget.h5
-rw-r--r--Source/cmGetPipes.cxx2
-rw-r--r--Source/cmGetSourceFilePropertyCommand.cxx19
-rw-r--r--Source/cmGetSourceFilePropertyCommand.h21
-rw-r--r--Source/cmGetTargetPropertyCommand.cxx26
-rw-r--r--Source/cmGetTargetPropertyCommand.h21
-rw-r--r--Source/cmGetTestPropertyCommand.cxx17
-rw-r--r--Source/cmGetTestPropertyCommand.h21
-rw-r--r--Source/cmGlobalGenerator.cxx6
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx4
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h2
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx31
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx11
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx41
-rw-r--r--Source/cmHexFileConverter.cxx6
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx32
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.h31
-rw-r--r--Source/cmIncludeRegularExpressionCommand.cxx18
-rw-r--r--Source/cmIncludeRegularExpressionCommand.h30
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmInstallExportAndroidMKGenerator.cxx134
-rw-r--r--Source/cmInstallExportAndroidMKGenerator.h37
-rw-r--r--Source/cmInstallExportGenerator.h2
-rw-r--r--Source/cmInstallFilesCommand.cxx23
-rw-r--r--Source/cmInstallFilesCommand.h30
-rw-r--r--Source/cmInstallProgramsCommand.cxx20
-rw-r--r--Source/cmInstallProgramsCommand.h30
-rw-r--r--Source/cmInstallTargetGenerator.cxx2
-rw-r--r--Source/cmInstallTargetsCommand.cxx26
-rw-r--r--Source/cmInstallTargetsCommand.h31
-rw-r--r--Source/cmLinkLibrariesCommand.cxx23
-rw-r--r--Source/cmLinkLibrariesCommand.h31
-rw-r--r--Source/cmLinkedTree.h2
-rw-r--r--Source/cmListCommand.cxx6
-rw-r--r--Source/cmListFileCache.cxx2
-rw-r--r--Source/cmListFileCache.h2
-rw-r--r--Source/cmLoadCommandCommand.cxx8
-rw-r--r--Source/cmLocalGenerator.cxx119
-rw-r--r--Source/cmLocalNinjaGenerator.cxx4
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx2
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx25
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx9
-rw-r--r--Source/cmLocale.h2
-rw-r--r--Source/cmMacroCommand.cxx2
-rw-r--r--Source/cmMakefile.cxx263
-rw-r--r--Source/cmMakefile.h86
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx2
-rw-r--r--Source/cmMakefileTargetGenerator.cxx2
-rw-r--r--Source/cmMathCommand.cxx2
-rw-r--r--Source/cmNewLineStyle.cxx2
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx2
-rw-r--r--Source/cmNinjaTargetGenerator.cxx2
-rw-r--r--Source/cmOrderDirectories.cxx2
-rw-r--r--Source/cmOutputConverter.cxx4
-rw-r--r--Source/cmOutputRequiredFilesCommand.cxx2
-rw-r--r--Source/cmPolicies.cxx8
-rw-r--r--Source/cmProcessOutput.h2
-rw-r--r--Source/cmProcessTools.h2
-rw-r--r--Source/cmQTWrapCPPCommand.cxx49
-rw-r--r--Source/cmQTWrapCPPCommand.h30
-rw-r--r--Source/cmQTWrapUICommand.cxx92
-rw-r--r--Source/cmQTWrapUICommand.h29
-rw-r--r--Source/cmQtAutoGenInitializer.cxx43
-rw-r--r--Source/cmRST.cxx4
-rw-r--r--Source/cmRemoveDefinitionsCommand.cxx16
-rw-r--r--Source/cmRemoveDefinitionsCommand.h31
-rw-r--r--Source/cmRulePlaceholderExpander.cxx4
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.cxx35
-rw-r--r--Source/cmSetSourceFilesPropertiesCommand.h29
-rw-r--r--Source/cmSetTestsPropertiesCommand.cxx31
-rw-r--r--Source/cmSetTestsPropertiesCommand.h26
-rw-r--r--Source/cmSourceFile.cxx21
-rw-r--r--Source/cmSourceFile.h17
-rw-r--r--Source/cmSourceFileLocation.cxx2
-rw-r--r--Source/cmSourceGroupCommand.cxx2
-rw-r--r--Source/cmState.cxx6
-rw-r--r--Source/cmStateDirectory.cxx2
-rw-r--r--Source/cmStateSnapshot.cxx2
-rw-r--r--Source/cmStringAlgorithms.cxx4
-rw-r--r--Source/cmStringAlgorithms.h2
-rw-r--r--Source/cmStringCommand.cxx6
-rw-r--r--Source/cmSubdirCommand.cxx28
-rw-r--r--Source/cmSubdirCommand.h31
-rw-r--r--Source/cmSystemTools.cxx14
-rw-r--r--Source/cmSystemTools.h2
-rw-r--r--Source/cmTarget.cxx48
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx2
-rw-r--r--Source/cmTargetPrecompileHeadersCommand.cxx2
-rw-r--r--Source/cmTargetPropCommandBase.cxx13
-rw-r--r--Source/cmTargetPropCommandBase.h7
-rw-r--r--Source/cmTimestamp.cxx2
-rw-r--r--Source/cmTimestamp.h2
-rw-r--r--Source/cmTryRunCommand.cxx2
-rw-r--r--Source/cmUVHandlePtr.cxx4
-rw-r--r--Source/cmUVProcessChain.cxx2
-rw-r--r--Source/cmUVProcessChain.h3
-rw-r--r--Source/cmUtilitySourceCommand.cxx2
-rw-r--r--Source/cmUuid.cxx2
-rw-r--r--Source/cmWorkerPool.cxx2
-rw-r--r--Source/cmWorkerPool.h2
-rw-r--r--Source/cmXMLParser.cxx4
-rw-r--r--Source/cmXMLSafe.cxx4
-rw-r--r--Source/cm_codecvt.hxx2
-rw-r--r--Source/cm_get_date.h2
-rw-r--r--Source/cmake.cxx4
-rw-r--r--Source/cmakemain.cxx4
-rw-r--r--Source/cmcmd.cxx8
-rw-r--r--Source/ctest.cxx2
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx2
-rw-r--r--Tests/CustomCommandByproducts/CMakeLists.txt49
-rw-r--r--Tests/CustomCommandByproducts/CustomCommandByproducts.c3
-rw-r--r--Tests/CustomCommandByproducts/byproduct9.c.in1
-rw-r--r--Tests/FindEnvModules/EnvModules.cmake16
-rw-r--r--Tests/GeneratorExpression/CMakeLists.txt28
-rw-r--r--Tests/GeneratorExpression/check-part5.cmake1
-rw-r--r--Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake49
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake20
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake18
-rw-r--r--Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/empty.c3
-rw-r--r--Tests/RunCMake/PrecompileHeaders/include/foo.h2
-rw-r--r--Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/add_custom_command/GeneratedProperty.cmake10
-rw-r--r--Tests/RunCMake/add_custom_command/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/add_custom_target/GeneratedProperty.cmake14
-rw-r--r--Tests/RunCMake/add_custom_target/RunCMakeTest.cmake1
274 files changed, 1604 insertions, 1866 deletions
diff --git a/.clang-tidy b/.clang-tidy
index a240e9c..a520679 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -11,7 +11,6 @@ misc-*,\
-misc-static-assert,\
modernize-*,\
-modernize-avoid-c-arrays,\
--modernize-deprecated-headers,\
-modernize-use-nodiscard,\
-modernize-use-noexcept,\
-modernize-use-transparent-functors,\
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index ed321fc..ab2a023 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -68,9 +68,6 @@ The options are:
order-only dependencies to ensure the byproducts will be
available before their dependents build.
- The ``BYPRODUCTS`` option is ignored on non-Ninja generators
- except to mark byproducts ``GENERATED``.
-
``COMMAND``
Specify the command-line(s) to execute at build time.
If more than one ``COMMAND`` is specified they will be executed in order,
@@ -111,6 +108,9 @@ The options are:
an ``OUTPUT`` of another custom command in the same directory
(``CMakeLists.txt`` file) CMake automatically brings the other
custom command into the target in which this command is built.
+ A target-level dependency is added if any dependency is listed as
+ ``BYPRODUCTS`` of a target or any of its build events in the same
+ directory to ensure the byproducts will be available.
If ``DEPENDS`` is not specified the command will run whenever
the ``OUTPUT`` is missing; if the command does not actually
create the ``OUTPUT`` then the rule will always run.
diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst
index 08b9516..e74960c 100644
--- a/Help/command/add_custom_target.rst
+++ b/Help/command/add_custom_target.rst
@@ -49,9 +49,6 @@ The options are:
order-only dependencies to ensure the byproducts will be
available before their dependents build.
- The ``BYPRODUCTS`` option is ignored on non-Ninja generators
- except to mark byproducts ``GENERATED``.
-
``COMMAND``
Specify the command-line(s) to execute at build time.
If more than one ``COMMAND`` is specified they will be executed in order,
@@ -86,6 +83,9 @@ The options are:
:command:`add_custom_command` command calls in the same directory
(``CMakeLists.txt`` file). They will be brought up to date when
the target is built.
+ A target-level dependency is added if any dependency is a byproduct
+ of a target or any of its build events in the same directory to ensure
+ the byproducts will be available before this target is built.
Use the :command:`add_dependencies` command to add dependencies
on other targets.
diff --git a/Help/command/target_precompile_headers.rst b/Help/command/target_precompile_headers.rst
index 3e28265..7d36b11 100644
--- a/Help/command/target_precompile_headers.rst
+++ b/Help/command/target_precompile_headers.rst
@@ -9,9 +9,23 @@ Add a list of header files to precompile.
<INTERFACE|PUBLIC|PRIVATE> [header1...]
[<INTERFACE|PUBLIC|PRIVATE> [header2...] ...])
+ target_precompile_headers(<target> REUSE_FROM <other_target>)
+
Adds header files to :prop_tgt:`PRECOMPILE_HEADERS` or
:prop_tgt:`INTERFACE_PRECOMPILE_HEADERS` target properties.
+The second signature will reuse an already precompiled header file artefact
+from another target. This is done by setting the
+:prop_tgt:`PRECOMPILE_HEADERS_REUSE_FROM` to ``<other_target>`` value.
+The ``<other_target>`` will become a dependency of ``<target>``.
+
+.. note::
+
+ The second signature will require the same set of compiler options,
+ compiler flags, compiler definitions for both ``<target>``, and
+ ``<other_target>``. Compilers (e.g. GCC) will issue a warning if the
+ precompiled header file cannot be used (``-Winvalid-pch``).
+
Precompiling header files can speed up compilation by creating a partially
processed version of some header files, and then using that version during
compilations rather than repeatedly parsing the original headers.
diff --git a/Help/cpack_gen/wix.rst b/Help/cpack_gen/wix.rst
index dde4943..7fb5a12 100644
--- a/Help/cpack_gen/wix.rst
+++ b/Help/cpack_gen/wix.rst
@@ -95,6 +95,10 @@ Windows using WiX.
If this variable is not set, it will be initialized with CPACK_PACKAGE_NAME
+ If this variable is set to ``.``, then application shortcuts will be
+ created directly in the start menu and the uninstaller shortcut will be
+ omitted.
+
.. variable:: CPACK_WIX_CULTURES
Language(s) of the installer
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 19afb7d..0928abe 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -298,6 +298,7 @@ Properties on Targets
/prop_tgt/PDB_OUTPUT_DIRECTORY
/prop_tgt/POSITION_INDEPENDENT_CODE
/prop_tgt/PRECOMPILE_HEADERS
+ /prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM
/prop_tgt/PREFIX
/prop_tgt/PRIVATE_HEADER
/prop_tgt/PROJECT_LABEL
diff --git a/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst b/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst
new file mode 100644
index 0000000..d740303
--- /dev/null
+++ b/Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst
@@ -0,0 +1,7 @@
+PRECOMPILE_HEADERS_REUSE_FROM
+-----------------------------
+
+Target from which to reuse the precomipled headers build artifact.
+
+See the second signature of :command:`target_precompile_headers` command
+for more detailed information.
diff --git a/Modules/CMakePlatformId.h.in b/Modules/CMakePlatformId.h.in
index 542a6fe..95465ce 100644
--- a/Modules/CMakePlatformId.h.in
+++ b/Modules/CMakePlatformId.h.in
@@ -174,6 +174,9 @@
# elif defined(__ICC430__)
# define ARCHITECTURE_ID "MSP430"
+# elif defined(__ICCV850__)
+# define ARCHITECTURE_ID "V850"
+
# else /* unknown architecture */
# define ARCHITECTURE_ID ""
# endif
diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake
index e03ce3f..9ad1ba0 100644
--- a/Modules/Compiler/IAR-C.cmake
+++ b/Modules/Compiler/IAR-C.cmake
@@ -60,6 +60,11 @@ elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430")
__compiler_check_default_language_standard(C 1.10 90 5.10 99)
set(CMAKE_C_OUTPUT_EXTENSION ".r43")
+elseif("${CMAKE_C_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850")
+ __compiler_iar_xlink(C)
+ __compiler_check_default_language_standard(C 1.10 90 4.10 99)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r85")
+
else()
message(FATAL_ERROR "CMAKE_C_COMPILER_ARCHITECTURE_ID not detected. This should be automatic.")
endif()
diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake
index e8f1142..549d242 100644
--- a/Modules/Compiler/IAR-CXX.cmake
+++ b/Modules/Compiler/IAR-CXX.cmake
@@ -68,6 +68,10 @@ elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430")
__compiler_check_default_language_standard(CXX 5.10 98)
set(CMAKE_CXX_OUTPUT_EXTENSION ".r43")
+elseif("${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850")
+ __compiler_iar_xlink(CXX)
+ __compiler_check_default_language_standard(CXX 1.10 98)
+ set(CMAKE_C_OUTPUT_EXTENSION ".r85")
else()
message(FATAL_ERROR "CMAKE_CXX_COMPILER_ARCHITECTURE_ID not detected. This should be automatic." )
endif()
diff --git a/Modules/Compiler/IAR-DetermineCompiler.cmake b/Modules/Compiler/IAR-DetermineCompiler.cmake
index 57ca1c9..7e17778 100644
--- a/Modules/Compiler/IAR-DetermineCompiler.cmake
+++ b/Modules/Compiler/IAR-DetermineCompiler.cmake
@@ -31,7 +31,7 @@ set(_compiler_id_version_compute "
# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@(((__VER__) / 1000) % 1000)
# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@((__VER__) % 1000)
# define @PREFIX@COMPILER_VERSION_INTERNAL @MACRO_DEC@(__IAR_SYSTEMS_ICC__)
-# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__))
+# elif defined(__VER__) && (defined(__ICCAVR__) || defined(__ICCRX__) || defined(__ICCRH850__) || defined(__ICCRL78__) || defined(__ICC430__) || defined(__ICCRISCV__) || defined(__ICCV850__))
# define @PREFIX@COMPILER_VERSION_MAJOR @MACRO_DEC@((__VER__) / 100)
# define @PREFIX@COMPILER_VERSION_MINOR @MACRO_DEC@((__VER__) - (((__VER__) / 100)*100))
# define @PREFIX@COMPILER_VERSION_PATCH @MACRO_DEC@(__SUBVERSION__)
diff --git a/Modules/Compiler/IAR-FindBinUtils.cmake b/Modules/Compiler/IAR-FindBinUtils.cmake
index b7d4664..6258cf3 100644
--- a/Modules/Compiler/IAR-FindBinUtils.cmake
+++ b/Modules/Compiler/IAR-FindBinUtils.cmake
@@ -45,7 +45,8 @@ set(CMAKE_IAR_LINKER \"${CMAKE_IAR_LINKER}\")
")
elseif("${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "AVR" OR
- "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430")
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "MSP430" OR
+ "${CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_ARCHITECTURE_ID}" STREQUAL "V850")
# Find the "xlink" linker and "xar" archiver:
find_program(CMAKE_IAR_LINKER xlink HINTS ${__iar_hints}
diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake
index 4c9af91..5162a44 100644
--- a/Modules/FindPkgConfig.cmake
+++ b/Modules/FindPkgConfig.cmake
@@ -214,7 +214,11 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path)
NAMES ${_pkg_search}
${_find_opts})
mark_as_advanced(pkgcfg_lib_${_prefix}_${_pkg_search})
- list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
+ if(pkgcfg_lib_${_prefix}_${_pkg_search})
+ list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}")
+ else()
+ list(APPEND _libs ${_pkg_search})
+ endif()
endforeach()
set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE)
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index 6ddcaa3..34f5d03 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -333,10 +333,17 @@ macro(__windows_compiler_msvc lang)
set(CMAKE_LINK_PCH ON)
if(MSVC_VERSION GREATER_EQUAL 1910)
# VS 2017 or greater
- set(CMAKE_PCH_PROLOGUE "#pragma system_header")
+ if (NOT ${CMAKE_${lang}_COMPILER_ID} STREQUAL "Clang")
+ set(CMAKE_PCH_PROLOGUE "#pragma system_header")
+ else()
+ set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
+ endif()
+ endif()
+ if (NOT ${CMAKE_${lang}_COMPILER_ID} STREQUAL "Clang")
+ set(CMAKE_PCH_COPY_COMPILE_PDB ON)
endif()
- set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu<PCH_HEADER> /FI<PCH_HEADER>)
- set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc<PCH_HEADER> /FI<PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH /Yu<PCH_HEADER> /Fp<PCH_FILE> /FI<PCH_HEADER>)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH /Yc<PCH_HEADER> /Fp<PCH_FILE> /FI<PCH_HEADER>)
if("x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
set(_CMAKE_${lang}_IPO_SUPPORTED_BY_CMAKE YES)
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index decb39a..65cd6c9 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -191,6 +191,8 @@ set(SRCS
cmCustomCommand.h
cmCustomCommandGenerator.cxx
cmCustomCommandGenerator.h
+ cmCustomCommandLines.cxx
+ cmCustomCommandLines.h
cmDefinitions.cxx
cmDefinitions.h
cmDepends.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index e9cca30..c09c1ce 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 15)
-set(CMake_VERSION_PATCH 20190913)
+set(CMake_VERSION_PATCH 20190919)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
index b4bfea7..2393279 100644
--- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx
+++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx
@@ -13,8 +13,8 @@
#include "cmXMLParser.h"
#include "cmXMLWriter.h"
+#include <cstddef>
#include <sstream>
-#include <stddef.h>
#include <utility>
cmCPackIFWInstaller::cmCPackIFWInstaller() = default;
diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx
index 5fa8cce..9f2a443 100644
--- a/Source/CPack/IFW/cmCPackIFWPackage.cxx
+++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx
@@ -13,9 +13,9 @@
#include "cmTimestamp.h"
#include "cmXMLWriter.h"
+#include <cstddef>
#include <map>
#include <sstream>
-#include <stddef.h>
#include <utility>
//---------------------------------------------------------- CompareStruct ---
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index 8042167..82ddbdb 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -8,7 +8,7 @@
#include "cmXMLParser.h"
#include "cmXMLWriter.h"
-#include <stddef.h>
+#include <cstddef>
cmCPackIFWRepository::cmCPackIFWRepository()
: Update(cmCPackIFWRepository::None)
diff --git a/Source/CPack/OSXScriptLauncher.cxx b/Source/CPack/OSXScriptLauncher.cxx
index 00d272c..b8f12fd 100644
--- a/Source/CPack/OSXScriptLauncher.cxx
+++ b/Source/CPack/OSXScriptLauncher.cxx
@@ -3,8 +3,9 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
#include "cmsys/SystemTools.hxx"
+
+#include <cstddef>
#include <iostream>
-#include <stddef.h>
#include <string>
#include <vector>
diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
index b0b2df2..f784832 100644
--- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx
+++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx
@@ -537,9 +537,16 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles()
}
}
- bool emitUninstallShortcut =
- emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) !=
- emittedShortcutTypes.end();
+ bool emitUninstallShortcut = true;
+ const char* cpackWixProgramMenuFolder =
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
+ if (cpackWixProgramMenuFolder &&
+ cm::string_view(cpackWixProgramMenuFolder) == ".") {
+ emitUninstallShortcut = false;
+ } else if (emittedShortcutTypes.find(cmWIXShortcuts::START_MENU) ==
+ emittedShortcutTypes.end()) {
+ emitUninstallShortcut = false;
+ }
if (!CreateShortcuts(std::string(), "ProductFeature", globalShortcuts,
emitUninstallShortcut, fileDefinitions,
@@ -733,9 +740,16 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
{
std::string directoryId;
switch (type) {
- case cmWIXShortcuts::START_MENU:
- directoryId = "PROGRAM_MENU_FOLDER";
- break;
+ case cmWIXShortcuts::START_MENU: {
+ const char* cpackWixProgramMenuFolder =
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
+ if (cpackWixProgramMenuFolder &&
+ cm::string_view(cpackWixProgramMenuFolder) == ".") {
+ directoryId = "ProgramMenuFolder";
+ } else {
+ directoryId = "PROGRAM_MENU_FOLDER";
+ }
+ } break;
case cmWIXShortcuts::DESKTOP:
directoryId = "DesktopFolder";
break;
@@ -789,8 +803,13 @@ bool cmCPackWIXGenerator::CreateShortcutsOfSpecificType(
fileDefinitions);
if (type == cmWIXShortcuts::START_MENU) {
- fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
- idSuffix);
+ const char* cpackWixProgramMenuFolder =
+ GetOption("CPACK_WIX_PROGRAM_MENU_FOLDER");
+ if (cpackWixProgramMenuFolder &&
+ cm::string_view(cpackWixProgramMenuFolder) != ".") {
+ fileDefinitions.EmitRemoveFolder("CM_REMOVE_PROGRAM_MENU_FOLDER" +
+ idSuffix);
+ }
}
if (emitUninstallShortcut) {
diff --git a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
index 975dffb..0a83ca2 100644
--- a/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
+++ b/Source/CPack/WiX/cmWIXDirectoriesSourceWriter.cxx
@@ -14,10 +14,12 @@ void cmWIXDirectoriesSourceWriter::EmitStartMenuFolder(
BeginElement("Directory");
AddAttribute("Id", "ProgramMenuFolder");
- BeginElement("Directory");
- AddAttribute("Id", "PROGRAM_MENU_FOLDER");
- AddAttribute("Name", startMenuFolder);
- EndElement("Directory");
+ if (startMenuFolder != ".") {
+ BeginElement("Directory");
+ AddAttribute("Id", "PROGRAM_MENU_FOLDER");
+ AddAttribute("Name", startMenuFolder);
+ EndElement("Directory");
+ }
EndElement("Directory");
}
diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx
index cefbc90..0e64b5a 100644
--- a/Source/CPack/cmCPackDebGenerator.cxx
+++ b/Source/CPack/cmCPackDebGenerator.cxx
@@ -13,10 +13,10 @@
#include "cm_sys_stat.h"
#include "cmsys/Glob.hxx"
+#include <cstring>
#include <map>
#include <ostream>
#include <set>
-#include <string.h>
#include <utility>
namespace {
diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx
index ca06b81..bedbfa8 100644
--- a/Source/CPack/cmCPackDragNDropGenerator.cxx
+++ b/Source/CPack/cmCPackDragNDropGenerator.cxx
@@ -12,9 +12,9 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdlib>
#include <iomanip>
#include <map>
-#include <stdlib.h>
#include <CoreFoundation/CoreFoundation.h>
diff --git a/Source/CPack/cmCPackGeneratorFactory.cxx b/Source/CPack/cmCPackGeneratorFactory.cxx
index a564eb1..79e344b 100644
--- a/Source/CPack/cmCPackGeneratorFactory.cxx
+++ b/Source/CPack/cmCPackGeneratorFactory.cxx
@@ -6,7 +6,6 @@
#include <utility>
#include "IFW/cmCPackIFWGenerator.h"
-#include "cmAlgorithms.h"
#ifdef HAVE_FREEBSD_PKG
# include "cmCPackFreeBSDGenerator.h"
#endif
@@ -138,33 +137,21 @@ cmCPackGeneratorFactory::cmCPackGeneratorFactory()
#endif
}
-cmCPackGeneratorFactory::~cmCPackGeneratorFactory()
-{
- cmDeleteAll(this->Generators);
-}
-
-cmCPackGenerator* cmCPackGeneratorFactory::NewGenerator(
+std::unique_ptr<cmCPackGenerator> cmCPackGeneratorFactory::NewGenerator(
const std::string& name)
{
- cmCPackGenerator* gen = this->NewGeneratorInternal(name);
+ auto it = this->GeneratorCreators.find(name);
+ if (it == this->GeneratorCreators.end()) {
+ return nullptr;
+ }
+ std::unique_ptr<cmCPackGenerator> gen(it->second());
if (!gen) {
return nullptr;
}
- this->Generators.push_back(gen);
gen->SetLogger(this->Logger);
return gen;
}
-cmCPackGenerator* cmCPackGeneratorFactory::NewGeneratorInternal(
- const std::string& name)
-{
- auto it = this->GeneratorCreators.find(name);
- if (it == this->GeneratorCreators.end()) {
- return nullptr;
- }
- return (it->second)();
-}
-
void cmCPackGeneratorFactory::RegisterGenerator(
const std::string& name, const char* generatorDescription,
CreateGeneratorCall* createGenerator)
diff --git a/Source/CPack/cmCPackGeneratorFactory.h b/Source/CPack/cmCPackGeneratorFactory.h
index da2eb8d..62b7484 100644
--- a/Source/CPack/cmCPackGeneratorFactory.h
+++ b/Source/CPack/cmCPackGeneratorFactory.h
@@ -6,8 +6,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <map>
+#include <memory>
#include <string>
-#include <vector>
class cmCPackGenerator;
class cmCPackLog;
@@ -20,14 +20,9 @@ class cmCPackGeneratorFactory
{
public:
cmCPackGeneratorFactory();
- ~cmCPackGeneratorFactory();
-
- cmCPackGeneratorFactory(const cmCPackGeneratorFactory&) = delete;
- cmCPackGeneratorFactory& operator=(const cmCPackGeneratorFactory&) = delete;
//! Get the generator
- cmCPackGenerator* NewGenerator(const std::string& name);
- void DeleteGenerator(cmCPackGenerator* gen);
+ std::unique_ptr<cmCPackGenerator> NewGenerator(const std::string& name);
using CreateGeneratorCall = cmCPackGenerator*();
@@ -44,9 +39,6 @@ public:
}
private:
- cmCPackGenerator* NewGeneratorInternal(const std::string& name);
- std::vector<cmCPackGenerator*> Generators;
-
using t_GeneratorCreatorsMap = std::map<std::string, CreateGeneratorCall*>;
t_GeneratorCreatorsMap GeneratorCreators;
DescriptionsMap GeneratorDescriptions;
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 8098edf..3f53186 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -14,10 +14,10 @@
#include "cmsys/Directory.hxx"
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdlib>
+#include <cstring>
#include <map>
#include <sstream>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
/* NSIS uses different command line syntax on Windows and others */
diff --git a/Source/CPack/cmCPackPackageMakerGenerator.cxx b/Source/CPack/cmCPackPackageMakerGenerator.cxx
index 5dc36ab..7be6a7d 100644
--- a/Source/CPack/cmCPackPackageMakerGenerator.cxx
+++ b/Source/CPack/cmCPackPackageMakerGenerator.cxx
@@ -4,11 +4,11 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
#include <map>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <string>
#include "cmCPackComponentGroup.h"
diff --git a/Source/CPack/cmCPackProductBuildGenerator.cxx b/Source/CPack/cmCPackProductBuildGenerator.cxx
index 800af28..dae268c 100644
--- a/Source/CPack/cmCPackProductBuildGenerator.cxx
+++ b/Source/CPack/cmCPackProductBuildGenerator.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackProductBuildGenerator.h"
+#include <cstddef>
#include <map>
#include <sstream>
-#include <stddef.h>
#include "cmCPackComponentGroup.h"
#include "cmCPackLog.h"
diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx
index e8728a3..0c1cecf 100644
--- a/Source/CPack/cmCPackRPMGenerator.cxx
+++ b/Source/CPack/cmCPackRPMGenerator.cxx
@@ -3,7 +3,7 @@
#include "cmCPackRPMGenerator.h"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
#include <map>
#include <ostream>
#include <utility>
diff --git a/Source/CPack/cmCPackSTGZGenerator.cxx b/Source/CPack/cmCPackSTGZGenerator.cxx
index 3092508..eb48c37 100644
--- a/Source/CPack/cmCPackSTGZGenerator.cxx
+++ b/Source/CPack/cmCPackSTGZGenerator.cxx
@@ -3,8 +3,8 @@
#include "cmCPackSTGZGenerator.h"
#include "cmsys/FStream.hxx"
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
#include <string>
#include <vector>
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 08681ec..ce41d40 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -22,10 +22,11 @@
# include "cmsys/ConsoleBuf.hxx"
#endif
+#include <cstddef>
#include <iostream>
#include <map>
+#include <memory>
#include <sstream>
-#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
@@ -237,7 +238,6 @@ int main(int argc, char const* const* argv)
cmCPackGeneratorFactory generators;
generators.SetLogger(&log);
- cmCPackGenerator* cpackGenerator = nullptr;
cmDocumentation doc;
doc.addCPackStandardDocSections();
@@ -360,7 +360,8 @@ int main(int argc, char const* const* argv)
parsed = 0;
}
if (parsed) {
- cpackGenerator = generators.NewGenerator(gen);
+ std::unique_ptr<cmCPackGenerator> cpackGenerator =
+ generators.NewGenerator(gen);
if (cpackGenerator) {
cpackGenerator->SetTrace(trace);
cpackGenerator->SetTraceExpand(traceExpand);
diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx
index 52dc0ac..4ea0c88 100644
--- a/Source/CTest/cmCTestBZR.cxx
+++ b/Source/CTest/cmCTestBZR.cxx
@@ -11,10 +11,10 @@
#include "cm_expat.h"
#include "cmsys/RegularExpression.hxx"
+#include <cstdlib>
#include <list>
#include <map>
#include <ostream>
-#include <stdlib.h>
#include <vector>
extern "C" int cmBZRXMLParserUnknownEncodingHandler(void* /*unused*/,
diff --git a/Source/CTest/cmCTestBuildAndTestHandler.cxx b/Source/CTest/cmCTestBuildAndTestHandler.cxx
index e7fb4c7..0f79670 100644
--- a/Source/CTest/cmCTestBuildAndTestHandler.cxx
+++ b/Source/CTest/cmCTestBuildAndTestHandler.cxx
@@ -14,9 +14,9 @@
#include "cmsys/Process.h"
#include <chrono>
+#include <cstdlib>
#include <cstring>
#include <ratio>
-#include <stdlib.h>
cmCTestBuildAndTestHandler::cmCTestBuildAndTestHandler()
{
diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx
index cb22fa6..02b00e3 100644
--- a/Source/CTest/cmCTestBuildCommand.cxx
+++ b/Source/CTest/cmCTestBuildCommand.cxx
@@ -11,8 +11,8 @@
#include "cmSystemTools.h"
#include "cmake.h"
+#include <cstring>
#include <sstream>
-#include <string.h>
class cmExecutionStatus;
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index e07d7aa..86abb12 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -17,9 +17,9 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
+#include <cstdlib>
+#include <cstring>
#include <set>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
static const char* cmCTestErrorMatches[] = {
diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx
index 320c184..8a56f3d 100644
--- a/Source/CTest/cmCTestConfigureCommand.cxx
+++ b/Source/CTest/cmCTestConfigureCommand.cxx
@@ -10,8 +10,8 @@
#include "cmSystemTools.h"
#include "cmake.h"
+#include <cstring>
#include <sstream>
-#include <string.h>
#include <vector>
cmCTestConfigureCommand::cmCTestConfigureCommand()
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx
index d9dd931..4d76387 100644
--- a/Source/CTest/cmCTestCoverageHandler.cxx
+++ b/Source/CTest/cmCTestCoverageHandler.cxx
@@ -24,12 +24,12 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
#include <chrono>
+#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <utility>
class cmMakefile;
diff --git a/Source/CTest/cmCTestCurl.cxx b/Source/CTest/cmCTestCurl.cxx
index 40f5918..8793260 100644
--- a/Source/CTest/cmCTestCurl.cxx
+++ b/Source/CTest/cmCTestCurl.cxx
@@ -8,8 +8,8 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include <cstdio>
#include <ostream>
-#include <stdio.h>
cmCTestCurl::cmCTestCurl(cmCTest* ctest)
{
diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx
index 3ae464d..9fd3a62 100644
--- a/Source/CTest/cmCTestGIT.cxx
+++ b/Source/CTest/cmCTestGIT.cxx
@@ -4,10 +4,10 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
+#include <ctime>
#include <vector>
#include "cmCTest.h"
diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx
index 6add717..9c5425d 100644
--- a/Source/CTest/cmCTestHandlerCommand.cxx
+++ b/Source/CTest/cmCTestHandlerCommand.cxx
@@ -10,9 +10,9 @@
#include "cmSystemTools.h"
#include "cmWorkingDirectory.h"
+#include <cstdlib>
#include <cstring>
#include <sstream>
-#include <stdlib.h>
cmCTestHandlerCommand::cmCTestHandlerCommand()
{
diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx
index ac52581..ba49c29 100644
--- a/Source/CTest/cmCTestLaunch.cxx
+++ b/Source/CTest/cmCTestLaunch.cxx
@@ -5,9 +5,9 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Process.h"
#include "cmsys/RegularExpression.hxx"
+#include <cstdlib>
+#include <cstring>
#include <iostream>
-#include <stdlib.h>
-#include <string.h>
#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 259240f..ba196f0 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -12,9 +12,9 @@
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
#include <chrono>
+#include <cstring>
#include <iostream>
#include <sstream>
-#include <string.h>
#include <utility>
struct CatToErrorType
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index af1980a..f79ba2e 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -25,15 +25,15 @@
#include <algorithm>
#include <chrono>
+#include <cmath>
+#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
-#include <math.h>
#include <memory>
#include <sstream>
#include <stack>
-#include <stdlib.h>
#include <unordered_map>
#include <utility>
#include <vector>
diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx
index 08c850d..a6aea85 100644
--- a/Source/CTest/cmCTestP4.cxx
+++ b/Source/CTest/cmCTestP4.cxx
@@ -12,8 +12,8 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <ctime>
#include <ostream>
-#include <time.h>
#include <utility>
cmCTestP4::cmCTestP4(cmCTest* ct, std::ostream& log)
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index c5bb826..3629a50 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -13,11 +13,11 @@
#include "cmsys/RegularExpression.hxx"
#include <chrono>
#include <cstdint>
+#include <cstdio>
#include <cstring>
#include <iomanip>
#include <ratio>
#include <sstream>
-#include <stdio.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx
index a945111..6e5b5e7 100644
--- a/Source/CTest/cmCTestSVN.cxx
+++ b/Source/CTest/cmCTestSVN.cxx
@@ -12,10 +12,10 @@
#include "cmXMLWriter.h"
#include "cmsys/RegularExpression.hxx"
+#include <cstdlib>
+#include <cstring>
#include <map>
#include <ostream>
-#include <stdlib.h>
-#include <string.h>
struct cmCTestSVN::Revision : public cmCTestVC::Revision
{
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 81966dd..354e3c4 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -34,13 +34,13 @@
#include "cmSystemTools.h"
#include "cmake.h"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <map>
#include <memory>
#include <ratio>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
#ifdef _WIN32
diff --git a/Source/CTest/cmCTestSleepCommand.cxx b/Source/CTest/cmCTestSleepCommand.cxx
index 2752cd3..bc4470c 100644
--- a/Source/CTest/cmCTestSleepCommand.cxx
+++ b/Source/CTest/cmCTestSleepCommand.cxx
@@ -4,7 +4,7 @@
#include "cmCTestScriptHandler.h"
-#include <stdlib.h>
+#include <cstdlib>
class cmExecutionStatus;
diff --git a/Source/CTest/cmCTestStartCommand.cxx b/Source/CTest/cmCTestStartCommand.cxx
index e4a1844..844f2ca 100644
--- a/Source/CTest/cmCTestStartCommand.cxx
+++ b/Source/CTest/cmCTestStartCommand.cxx
@@ -8,8 +8,8 @@
#include "cmMakefile.h"
#include "cmSystemTools.h"
+#include <cstddef>
#include <sstream>
-#include <stddef.h>
class cmExecutionStatus;
diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx
index f215911..ca7fd2c 100644
--- a/Source/CTest/cmCTestSubmitHandler.cxx
+++ b/Source/CTest/cmCTestSubmitHandler.cxx
@@ -6,9 +6,9 @@
#include "cm_jsoncpp_reader.h"
#include "cm_jsoncpp_value.h"
#include <chrono>
+#include <cstdio>
+#include <cstdlib>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include "cmAlgorithms.h"
#include "cmCTest.h"
diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx
index 24de5b4..3a29ad3 100644
--- a/Source/CTest/cmCTestTestCommand.cxx
+++ b/Source/CTest/cmCTestTestCommand.cxx
@@ -10,8 +10,8 @@
#include "cmStringAlgorithms.h"
#include <chrono>
+#include <cstdlib>
#include <sstream>
-#include <stdlib.h>
#include <vector>
cmCTestTestCommand::cmCTestTestCommand()
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f0c5939..10f9f9b 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -29,15 +29,15 @@
#include <cmsys/Directory.hxx>
#include <cmsys/RegularExpression.hxx>
#include <cstddef>
+#include <cstdio>
+#include <cstdlib>
#include <cstring>
+#include <ctime>
#include <functional>
#include <iomanip>
#include <iterator>
#include <set>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
#include <utility>
namespace {
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 773886d..00919e5 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -8,9 +8,9 @@
#include "cmXMLWriter.h"
#include "cmsys/Process.h"
+#include <cstdio>
+#include <ctime>
#include <sstream>
-#include <stdio.h>
-#include <time.h>
#include <vector>
cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log)
diff --git a/Source/CTest/cmParseBlanketJSCoverage.cxx b/Source/CTest/cmParseBlanketJSCoverage.cxx
index 191100c..8c87700 100644
--- a/Source/CTest/cmParseBlanketJSCoverage.cxx
+++ b/Source/CTest/cmParseBlanketJSCoverage.cxx
@@ -7,8 +7,8 @@
#include "cmSystemTools.h"
#include "cmsys/FStream.hxx"
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
class cmParseBlanketJSCoverage::JSONParser
{
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index b3ef7d3..da48610 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -7,9 +7,9 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
+#include <cstdio>
+#include <cstdlib>
#include <map>
-#include <stdio.h>
-#include <stdlib.h>
#include <utility>
cmParseCacheCoverage::cmParseCacheCoverage(
diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx
index e4f353b..7c00d00 100644
--- a/Source/CTest/cmParseCoberturaCoverage.cxx
+++ b/Source/CTest/cmParseCoberturaCoverage.cxx
@@ -7,8 +7,8 @@
#include "cmXMLParser.h"
#include "cmsys/FStream.hxx"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
class cmParseCoberturaCoverage::XMLParser : public cmXMLParser
{
diff --git a/Source/CTest/cmParseDelphiCoverage.cxx b/Source/CTest/cmParseDelphiCoverage.cxx
index e8a184a..22c756c 100644
--- a/Source/CTest/cmParseDelphiCoverage.cxx
+++ b/Source/CTest/cmParseDelphiCoverage.cxx
@@ -6,8 +6,8 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
-#include <stdio.h>
-#include <stdlib.h>
+#include <cstdio>
+#include <cstdlib>
class cmParseDelphiCoverage::HTMLParser
{
diff --git a/Source/CTest/cmParseGTMCoverage.cxx b/Source/CTest/cmParseGTMCoverage.cxx
index 621ca79..1f2181b 100644
--- a/Source/CTest/cmParseGTMCoverage.cxx
+++ b/Source/CTest/cmParseGTMCoverage.cxx
@@ -7,9 +7,9 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
+#include <cstdio>
+#include <cstdlib>
#include <map>
-#include <stdio.h>
-#include <stdlib.h>
#include <vector>
cmParseGTMCoverage::cmParseGTMCoverage(cmCTestCoverageHandlerContainer& cont,
diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx
index 6a2d0cc..be6348a 100644
--- a/Source/CTest/cmParseJacocoCoverage.cxx
+++ b/Source/CTest/cmParseJacocoCoverage.cxx
@@ -9,8 +9,8 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
class cmParseJacocoCoverage::XMLParser : public cmXMLParser
{
diff --git a/Source/CTest/cmParsePHPCoverage.cxx b/Source/CTest/cmParsePHPCoverage.cxx
index 870e222..8f0404d 100644
--- a/Source/CTest/cmParsePHPCoverage.cxx
+++ b/Source/CTest/cmParsePHPCoverage.cxx
@@ -7,8 +7,8 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
-#include <stdlib.h>
-#include <string.h>
+#include <cstdlib>
+#include <cstring>
/*
To setup coverage for php.
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 61d2ed3..9c63a59 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -10,8 +10,8 @@
#include "cmStringAlgorithms.h"
#include "cmsys/Process.h"
+#include <csignal>
#include <iostream>
-#include <signal.h>
#include <string>
#if defined(_WIN32)
# include "cm_kwiml.h"
diff --git a/Source/CursesDialog/ccmake.cxx b/Source/CursesDialog/ccmake.cxx
index ce32898..567b4f4 100644
--- a/Source/CursesDialog/ccmake.cxx
+++ b/Source/CursesDialog/ccmake.cxx
@@ -11,9 +11,9 @@
#include "cmake.h"
#include "cmsys/Encoding.hxx"
+#include <csignal>
+#include <cstring>
#include <iostream>
-#include <signal.h>
-#include <string.h>
#include <string>
#include <vector>
diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
index f450a1c..47fe84c 100644
--- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
+++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx
@@ -15,7 +15,7 @@
#include "cmSystemTools.h"
#include "cmake.h"
-#include <assert.h>
+#include <cassert>
#include <vector>
cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index 95026d5..028cc26 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -7,8 +7,8 @@
#include "cmCursesStandardIncludes.h"
#include "cmVersion.h"
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
inline int ctrl(int z)
{
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 1b25716..5f8a19e 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -19,8 +19,8 @@
#include "cmake.h"
#include <algorithm>
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
#include <utility>
inline int ctrl(int z)
diff --git a/Source/CursesDialog/cmCursesMainForm.h b/Source/CursesDialog/cmCursesMainForm.h
index d379975..f3194ab 100644
--- a/Source/CursesDialog/cmCursesMainForm.h
+++ b/Source/CursesDialog/cmCursesMainForm.h
@@ -9,7 +9,7 @@
#include "cmCursesStandardIncludes.h"
#include "cmStateTypes.h"
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <vector>
diff --git a/Source/CursesDialog/cmCursesStringWidget.cxx b/Source/CursesDialog/cmCursesStringWidget.cxx
index 26724e7..3fc1858 100644
--- a/Source/CursesDialog/cmCursesStringWidget.cxx
+++ b/Source/CursesDialog/cmCursesStringWidget.cxx
@@ -8,8 +8,8 @@
#include "cmCursesWidget.h"
#include "cmStateTypes.h"
-#include <stdio.h>
-#include <string.h>
+#include <cstdio>
+#include <cstring>
inline int ctrl(int z)
{
diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx
index 287a482..ad18cfe 100644
--- a/Source/QtDialog/CMakeSetup.cxx
+++ b/Source/QtDialog/CMakeSetup.cxx
@@ -229,8 +229,8 @@ int main(int argc, char** argv)
#if defined(Q_OS_MAC)
# include "cm_sys_stat.h"
-# include <errno.h>
-# include <string.h>
+# include <cerrno>
+# include <cstring>
# include <unistd.h>
static bool cmOSXInstall(std::string const& dir, std::string const& tool)
{
diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index d2330e1..c91198c 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -4,7 +4,6 @@
#include <sstream>
#include <unordered_set>
-#include <utility>
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
@@ -13,7 +12,6 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
-#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmTarget.h"
@@ -51,7 +49,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
bool uses_terminal = false;
bool command_expand_lists = false;
std::string implicit_depends_lang;
- cmCustomCommand::ImplicitDependsList implicit_depends;
+ cmImplicitDependsList implicit_depends;
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;
@@ -248,6 +246,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
// An implicit dependency starting point is also an
// explicit dependency.
std::string dep = copy;
+ // Upfront path conversion is correct because Genex
+ // are not supported.
cmSystemTools::ConvertToUnixSlashes(dep);
depends.push_back(dep);
@@ -264,9 +264,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
target = copy;
break;
case doing_depends: {
- std::string dep = copy;
- cmSystemTools::ConvertToUnixSlashes(dep);
- depends.push_back(std::move(dep));
+ depends.push_back(copy);
} break;
case doing_outputs:
outputs.push_back(filename);
@@ -317,14 +315,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
// Check for an append request.
if (append) {
- // Lookup an existing command.
- if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) {
- if (cmCustomCommand* cc = sf->GetCustomCommand()) {
- cc->AppendCommands(commandLines);
- cc->AppendDepends(depends);
- cc->AppendImplicitDepends(implicit_depends);
- return true;
- }
+ if (mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends,
+ commandLines)) {
+ return true;
}
// No command for this output exists.
@@ -351,28 +344,10 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
job_pool, command_expand_lists);
} else if (target.empty()) {
// Target is empty, use the output.
- mf.AddCustomCommandToOutput(output, byproducts, depends, main_dependency,
- commandLines, comment, working.c_str(), false,
- escapeOldStyle, uses_terminal,
- command_expand_lists, depfile, job_pool);
-
- // Add implicit dependency scanning requests if any were given.
- if (!implicit_depends.empty()) {
- bool okay = false;
- if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) {
- if (cmCustomCommand* cc = sf->GetCustomCommand()) {
- okay = true;
- cc->SetImplicitDepends(implicit_depends);
- }
- }
- if (!okay) {
- std::ostringstream e;
- e << "could not locate source file with a custom command producing \""
- << output[0] << "\" even though this command tried to create it!";
- status.SetError(e.str());
- return false;
- }
- }
+ mf.AddCustomCommandToOutput(
+ output, byproducts, depends, main_dependency, implicit_depends,
+ commandLines, comment, working.c_str(), false, escapeOldStyle,
+ uses_terminal, command_expand_lists, depfile, job_pool);
} else if (!byproducts.empty()) {
status.SetError("BYPRODUCTS may not be specified with SOURCE signatures");
return false;
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index caea510..ec5c1a7 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -127,7 +127,7 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
}
filename += copy;
cmSystemTools::ConvertToUnixSlashes(filename);
- byproducts.push_back(filename);
+ byproducts.push_back(cmSystemTools::CollapseFullPath(filename));
} break;
case doing_depends: {
std::string dep = copy;
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index 17bdc4a..c0be308 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddSubDirectoryCommand.h"
+#include <cstring>
#include <sstream>
-#include <string.h>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
diff --git a/Source/cmAffinity.cxx b/Source/cmAffinity.cxx
index a6d89aa..33768a9 100644
--- a/Source/cmAffinity.cxx
+++ b/Source/cmAffinity.cxx
@@ -13,7 +13,7 @@
# include <pthread.h>
# include <sched.h>
// On some platforms CPU_ZERO needs memset but sched.h forgets string.h
-# include <string.h> // IWYU pragma: keep
+# include <cstring> // IWYU pragma: keep
# if defined(__FreeBSD__)
# include <pthread_np.h>
# include <sys/cpuset.h>
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index a6c25e1..c45edaf 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -11,10 +11,10 @@
#include "cmsys/Encoding.hxx"
#include "cmsys/FStream.hxx"
+#include <cstring>
+#include <ctime>
#include <iostream>
#include <sstream>
-#include <string.h>
-#include <time.h>
#ifndef __LA_SSIZE_T
# define __LA_SSIZE_T la_ssize_t
diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h
index e90a603..e791761 100644
--- a/Source/cmArchiveWrite.h
+++ b/Source/cmArchiveWrite.h
@@ -5,8 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
-#include <stddef.h>
#include <string>
#if defined(CMAKE_BOOTSTRAP)
diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx
index 7bf19d0..111bc41 100644
--- a/Source/cmAuxSourceDirectoryCommand.cxx
+++ b/Source/cmAuxSourceDirectoryCommand.cxx
@@ -4,7 +4,7 @@
#include "cmsys/Directory.hxx"
#include <algorithm>
-#include <stddef.h>
+#include <cstddef>
#include <utility>
#include "cmExecutionStatus.h"
diff --git a/Source/cmBase32.h b/Source/cmBase32.h
index c6758d4..d85198d 100644
--- a/Source/cmBase32.h
+++ b/Source/cmBase32.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
/** \class cmBase32Encoder
diff --git a/Source/cmBuildCommand.cxx b/Source/cmBuildCommand.cxx
index e9e1d49..49c9439 100644
--- a/Source/cmBuildCommand.cxx
+++ b/Source/cmBuildCommand.cxx
@@ -2,32 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmBuildCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-bool cmBuildCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
-{
- // Support the legacy signature of the command:
- //
- if (2 == args.size()) {
- return this->TwoArgsSignature(args);
- }
-
- return this->MainSignature(args);
-}
+namespace {
-bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
+bool MainSignature(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("requires at least one argument naming a CMake variable");
+ status.SetError("requires at least one argument naming a CMake variable");
return false;
}
@@ -63,9 +52,7 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
doing = DoingNone;
target = args[i];
} else {
- std::ostringstream e;
- e << "unknown argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ status.SetError(cmStrCat("unknown argument \"", args[i], "\""));
return false;
}
}
@@ -82,30 +69,32 @@ bool cmBuildCommand::MainSignature(std::vector<std::string> const& args)
configuration = "Release";
}
+ cmMakefile& mf = status.GetMakefile();
if (!project_name.empty()) {
- this->Makefile->IssueMessage(
- MessageType::AUTHOR_WARNING,
- "Ignoring PROJECT_NAME option because it has no effect.");
+ mf.IssueMessage(MessageType::AUTHOR_WARNING,
+ "Ignoring PROJECT_NAME option because it has no effect.");
}
- std::string makecommand =
- this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
- target, configuration, "", this->Makefile->IgnoreErrorsCMP0061());
+ std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand(
+ target, configuration, "", mf.IgnoreErrorsCMP0061());
- this->Makefile->AddDefinition(variable, makecommand);
+ mf.AddDefinition(variable, makecommand);
return true;
}
-bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
+bool TwoArgsSignature(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with less than two arguments");
+ status.SetError("called with less than two arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
std::string const& define = args[0];
- const char* cacheValue = this->Makefile->GetDefinition(define);
+ const char* cacheValue = mf.GetDefinition(define);
std::string configType;
if (!cmSystemTools::GetEnv("CMAKE_CONFIG_TYPE", configType) ||
@@ -113,16 +102,28 @@ bool cmBuildCommand::TwoArgsSignature(std::vector<std::string> const& args)
configType = "Release";
}
- std::string makecommand =
- this->Makefile->GetGlobalGenerator()->GenerateCMakeBuildCommand(
- "", configType, "", this->Makefile->IgnoreErrorsCMP0061());
+ std::string makecommand = mf.GetGlobalGenerator()->GenerateCMakeBuildCommand(
+ "", configType, "", mf.IgnoreErrorsCMP0061());
if (cacheValue) {
return true;
}
- this->Makefile->AddCacheDefinition(define, makecommand.c_str(),
- "Command used to build entire project "
- "from the command line.",
- cmStateEnums::STRING);
+ mf.AddCacheDefinition(define, makecommand.c_str(),
+ "Command used to build entire project "
+ "from the command line.",
+ cmStateEnums::STRING);
return true;
}
+
+} // namespace
+
+bool cmBuildCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
+{
+ // Support the legacy signature of the command:
+ if (args.size() == 2) {
+ return TwoArgsSignature(args, status);
+ }
+
+ return MainSignature(args, status);
+}
diff --git a/Source/cmBuildCommand.h b/Source/cmBuildCommand.h
index d373103..45aa71d 100644
--- a/Source/cmBuildCommand.h
+++ b/Source/cmBuildCommand.h
@@ -8,47 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmBuildCommand
- * \brief build_command command
- *
- * cmBuildCommand implements the build_command CMake command
- */
-class cmBuildCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmBuildCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-
- /**
- * The primary command signature with optional, KEYWORD-based args.
- */
- virtual bool MainSignature(std::vector<std::string> const& args);
-
- /**
- * Legacy "exactly 2 args required" signature.
- */
- virtual bool TwoArgsSignature(std::vector<std::string> const& args);
-
-private:
- bool IgnoreErrors() const;
-};
+bool cmBuildCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 974b984..c3f6f40 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakeHostSystemInformationCommand.h"
-#include <stddef.h>
+#include <cstddef>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
diff --git a/Source/cmCMakeMinimumRequired.cxx b/Source/cmCMakeMinimumRequired.cxx
index f93c266..1b03873 100644
--- a/Source/cmCMakeMinimumRequired.cxx
+++ b/Source/cmCMakeMinimumRequired.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakeMinimumRequired.h"
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index f19d99b..9c7beca 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -14,7 +14,7 @@
#include "cmState.h"
#include "cmVersion.h"
-#include <stdlib.h>
+#include <cstdlib>
#ifdef __QNX__
# include <malloc.h> /* for malloc/free on QNX */
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index cd54770..5e17ce8 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -11,16 +11,16 @@
#include "cmsys/Process.h"
#include "cmsys/SystemInformation.hxx"
#include <algorithm>
+#include <cctype>
#include <chrono>
-#include <ctype.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <iostream>
#include <map>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <string>
-#include <time.h>
#include <utility>
#include <vector>
#if defined(_WIN32)
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 41dac85..9b11653 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -9,11 +9,11 @@
#include "cmProcessOutput.h"
#include <chrono>
+#include <ctime>
#include <map>
#include <memory>
#include <sstream>
#include <string>
-#include <time.h>
#include <vector>
class cmCTestBuildHandler;
diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx
index e28107f..0888a5e 100644
--- a/Source/cmCacheManager.cxx
+++ b/Source/cmCacheManager.cxx
@@ -5,9 +5,9 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
#include <algorithm>
+#include <cstdio>
+#include <cstring>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <string>
#include "cmGeneratedFileStream.h"
diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx
index b368b3a..e35fba5 100644
--- a/Source/cmCommandArgumentParserHelper.cxx
+++ b/Source/cmCommandArgumentParserHelper.cxx
@@ -8,9 +8,9 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include <cstring>
#include <iostream>
#include <sstream>
-#include <string.h>
int cmCommandArgument_yyparse(yyscan_t yyscanner);
//
diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx
index dfe130e..38fcf5b 100644
--- a/Source/cmCommands.cxx
+++ b/Source/cmCommands.cxx
@@ -222,41 +222,32 @@ void GetProjectCommands(cmState* state)
state->AddBuiltinCommand("add_library", cmAddLibraryCommand);
state->AddBuiltinCommand("add_subdirectory", cmAddSubDirectoryCommand);
state->AddBuiltinCommand("add_test", cmAddTestCommand);
- state->AddBuiltinCommand("build_command", cm::make_unique<cmBuildCommand>());
- state->AddBuiltinCommand("create_test_sourcelist",
- cm::make_unique<cmCreateTestSourceList>());
- state->AddBuiltinCommand("define_property",
- cm::make_unique<cmDefinePropertyCommand>());
- state->AddBuiltinCommand("enable_language",
- cm::make_unique<cmEnableLanguageCommand>());
+ state->AddBuiltinCommand("build_command", cmBuildCommand);
+ state->AddBuiltinCommand("create_test_sourcelist", cmCreateTestSourceList);
+ state->AddBuiltinCommand("define_property", cmDefinePropertyCommand);
+ state->AddBuiltinCommand("enable_language", cmEnableLanguageCommand);
state->AddBuiltinCommand("enable_testing", cmEnableTestingCommand);
state->AddBuiltinCommand("get_source_file_property",
- cm::make_unique<cmGetSourceFilePropertyCommand>());
- state->AddBuiltinCommand("get_target_property",
- cm::make_unique<cmGetTargetPropertyCommand>());
- state->AddBuiltinCommand("get_test_property",
- cm::make_unique<cmGetTestPropertyCommand>());
+ cmGetSourceFilePropertyCommand);
+ state->AddBuiltinCommand("get_target_property", cmGetTargetPropertyCommand);
+ state->AddBuiltinCommand("get_test_property", cmGetTestPropertyCommand);
state->AddBuiltinCommand("include_directories",
cm::make_unique<cmIncludeDirectoryCommand>());
- state->AddBuiltinCommand(
- "include_regular_expression",
- cm::make_unique<cmIncludeRegularExpressionCommand>());
+ state->AddBuiltinCommand("include_regular_expression",
+ cmIncludeRegularExpressionCommand);
state->AddBuiltinCommand("install", cm::make_unique<cmInstallCommand>());
- state->AddBuiltinCommand("install_files",
- cm::make_unique<cmInstallFilesCommand>());
- state->AddBuiltinCommand("install_targets",
- cm::make_unique<cmInstallTargetsCommand>());
+ state->AddBuiltinCommand("install_files", cmInstallFilesCommand);
+ state->AddBuiltinCommand("install_targets", cmInstallTargetsCommand);
state->AddBuiltinCommand("link_directories",
cm::make_unique<cmLinkDirectoriesCommand>());
state->AddBuiltinCommand("project", cm::make_unique<cmProjectCommand>());
- state->AddBuiltinCommand(
- "set_source_files_properties",
- cm::make_unique<cmSetSourceFilesPropertiesCommand>());
+ state->AddBuiltinCommand("set_source_files_properties",
+ cmSetSourceFilesPropertiesCommand);
state->AddBuiltinCommand("set_target_properties",
cm::make_unique<cmSetTargetPropertiesCommand>());
state->AddBuiltinCommand("set_tests_properties",
- cm::make_unique<cmSetTestsPropertiesCommand>());
- state->AddBuiltinCommand("subdirs", cm::make_unique<cmSubdirCommand>());
+ cmSetTestsPropertiesCommand);
+ state->AddBuiltinCommand("subdirs", cmSubdirCommand);
state->AddBuiltinCommand(
"target_compile_definitions",
cm::make_unique<cmTargetCompileDefinitionsCommand>());
@@ -285,27 +276,21 @@ void GetProjectCommands(cmState* state)
state->AddBuiltinCommand("aux_source_directory",
cmAuxSourceDirectoryCommand);
state->AddBuiltinCommand("export", cm::make_unique<cmExportCommand>());
- state->AddBuiltinCommand("fltk_wrap_ui",
- cm::make_unique<cmFLTKWrapUICommand>());
- state->AddBuiltinCommand(
- "include_external_msproject",
- cm::make_unique<cmIncludeExternalMSProjectCommand>());
- state->AddBuiltinCommand("install_programs",
- cm::make_unique<cmInstallProgramsCommand>());
+ state->AddBuiltinCommand("fltk_wrap_ui", cmFLTKWrapUICommand);
+ state->AddBuiltinCommand("include_external_msproject",
+ cmIncludeExternalMSProjectCommand);
+ state->AddBuiltinCommand("install_programs", cmInstallProgramsCommand);
state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand);
- state->AddBuiltinCommand("link_libraries",
- cm::make_unique<cmLinkLibrariesCommand>());
+ state->AddBuiltinCommand("link_libraries", cmLinkLibrariesCommand);
state->AddBuiltinCommand("target_link_options",
cm::make_unique<cmTargetLinkOptionsCommand>());
state->AddBuiltinCommand("target_link_directories",
cm::make_unique<cmTargetLinkDirectoriesCommand>());
state->AddBuiltinCommand("load_cache",
cm::make_unique<cmLoadCacheCommand>());
- state->AddBuiltinCommand("qt_wrap_cpp",
- cm::make_unique<cmQTWrapCPPCommand>());
- state->AddBuiltinCommand("qt_wrap_ui", cm::make_unique<cmQTWrapUICommand>());
- state->AddBuiltinCommand("remove_definitions",
- cm::make_unique<cmRemoveDefinitionsCommand>());
+ state->AddBuiltinCommand("qt_wrap_cpp", cmQTWrapCPPCommand);
+ state->AddBuiltinCommand("qt_wrap_ui", cmQTWrapUICommand);
+ state->AddBuiltinCommand("remove_definitions", cmRemoveDefinitionsCommand);
state->AddBuiltinCommand("source_group",
cm::make_unique<cmSourceGroupCommand>());
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 33286ad..19a096b 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -171,6 +171,7 @@ std::string cmCommonTargetGenerator::ComputeTargetCompilePDB() const
if (this->GeneratorTarget->GetType() > cmStateEnums::OBJECT_LIBRARY) {
return compilePdbPath;
}
+
compilePdbPath =
this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName());
if (compilePdbPath.empty()) {
diff --git a/Source/cmComputeComponentGraph.cxx b/Source/cmComputeComponentGraph.cxx
index 113463f..655e4ac 100644
--- a/Source/cmComputeComponentGraph.cxx
+++ b/Source/cmComputeComponentGraph.cxx
@@ -4,7 +4,7 @@
#include <algorithm>
-#include <assert.h>
+#include <cassert>
cmComputeComponentGraph::cmComputeComponentGraph(Graph const& input)
: InputGraph(input)
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 15b0087..2ee4ca2 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -16,11 +16,11 @@
#include "cmake.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index ade0f87..09dbbb1 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -20,9 +20,9 @@
#include "cmake.h"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
+#include <cstring>
#include <sstream>
-#include <string.h>
#include <utility>
//#define CM_COMPUTE_LINK_INFO_DEBUG
diff --git a/Source/cmComputeTargetDepends.cxx b/Source/cmComputeTargetDepends.cxx
index de82782..239fcdf 100644
--- a/Source/cmComputeTargetDepends.cxx
+++ b/Source/cmComputeTargetDepends.cxx
@@ -20,9 +20,9 @@
#include "cmTargetDepend.h"
#include "cmake.h"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
#include <utility>
/*
diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx
index 97469be..3ddd8ca 100644
--- a/Source/cmConditionEvaluator.cxx
+++ b/Source/cmConditionEvaluator.cxx
@@ -3,11 +3,11 @@
#include "cmConditionEvaluator.h"
#include "cmsys/RegularExpression.hxx"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <functional>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
#include "cmAlgorithms.h"
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 3687056..12050b3 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -3,10 +3,10 @@
#include "cmCoreTryCompile.h"
#include "cmsys/Directory.hxx"
+#include <cstdio>
+#include <cstring>
#include <set>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <utility>
#include "cmExportTryCompileFileGenerator.h"
diff --git a/Source/cmCreateTestSourceList.cxx b/Source/cmCreateTestSourceList.cxx
index da23519..9d492ba 100644
--- a/Source/cmCreateTestSourceList.cxx
+++ b/Source/cmCreateTestSourceList.cxx
@@ -4,19 +4,17 @@
#include <algorithm>
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmCreateTestSourceList
-bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmCreateTestSourceList(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with wrong number of arguments.");
+ status.SetError("called with wrong number of arguments.");
return false;
}
@@ -29,14 +27,14 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
if (*i == "EXTRA_INCLUDE") {
++i;
if (i == args.end()) {
- this->SetError("incorrect arguments to EXTRA_INCLUDE");
+ status.SetError("incorrect arguments to EXTRA_INCLUDE");
return false;
}
extraInclude = cmStrCat("#include \"", *i, "\"\n");
} else if (*i == "FUNCTION") {
++i;
if (i == args.end()) {
- this->SetError("incorrect arguments to FUNCTION");
+ status.SetError("incorrect arguments to FUNCTION");
return false;
}
function = cmStrCat(*i, "(&ac, &av);\n");
@@ -54,12 +52,12 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
// Name of the test driver
// make sure they specified an extension
if (cmSystemTools::GetFilenameExtension(*i).size() < 2) {
- this->SetError(
+ status.SetError(
"You must specify a file extension for the test driver file.");
return false;
}
- std::string driver =
- cmStrCat(this->Makefile->GetCurrentBinaryDirectory(), '/', *i);
+ cmMakefile& mf = status.GetMakefile();
+ std::string driver = cmStrCat(mf.GetCurrentBinaryDirectory(), '/', *i);
++i;
std::string configFile = cmSystemTools::GetCMakeRoot();
@@ -121,35 +119,32 @@ bool cmCreateTestSourceList::InitialPass(std::vector<std::string> const& args,
numTests++;
}
if (!extraInclude.empty()) {
- this->Makefile->AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES",
- extraInclude);
+ mf.AddDefinition("CMAKE_TESTDRIVER_EXTRA_INCLUDES", extraInclude);
}
if (!function.empty()) {
- this->Makefile->AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function);
+ mf.AddDefinition("CMAKE_TESTDRIVER_ARGVC_FUNCTION", function);
}
- this->Makefile->AddDefinition("CMAKE_FORWARD_DECLARE_TESTS",
- forwardDeclareCode);
- this->Makefile->AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES",
- functionMapCode);
+ mf.AddDefinition("CMAKE_FORWARD_DECLARE_TESTS", forwardDeclareCode);
+ mf.AddDefinition("CMAKE_FUNCTION_TABLE_ENTIRES", functionMapCode);
bool res = true;
- if (!this->Makefile->ConfigureFile(configFile, driver, false, true, false)) {
+ if (!mf.ConfigureFile(configFile, driver, false, true, false)) {
res = false;
}
// Construct the source list.
std::string sourceListValue;
{
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(driver);
+ cmSourceFile* sf = mf.GetOrCreateSource(driver);
sf->SetProperty("ABSTRACT", "0");
sourceListValue = args[1];
}
for (i = testsBegin; i != tests.end(); ++i) {
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(*i);
+ cmSourceFile* sf = mf.GetOrCreateSource(*i);
sf->SetProperty("ABSTRACT", "0");
sourceListValue += ";";
sourceListValue += *i;
}
- this->Makefile->AddDefinition(sourceList, sourceListValue);
+ mf.AddDefinition(sourceList, sourceListValue);
return res;
}
diff --git a/Source/cmCreateTestSourceList.h b/Source/cmCreateTestSourceList.h
index 5aa6af4..19503f4 100644
--- a/Source/cmCreateTestSourceList.h
+++ b/Source/cmCreateTestSourceList.h
@@ -8,34 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmCreateTestSourceList
- * \brief Test driver generation command
- *
- */
-
-class cmCreateTestSourceList : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmCreateTestSourceList>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmCreateTestSourceList(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h
index 681f5cc..145ff91 100644
--- a/Source/cmCryptoHash.h
+++ b/Source/cmCryptoHash.h
@@ -7,8 +7,8 @@
#include "cm_string_view.hxx"
+#include <cstddef>
#include <memory>
-#include <stddef.h>
#include <string>
#include <vector>
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index 7402eeb..fc6718d 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -88,18 +88,17 @@ cmListFileBacktrace const& cmCustomCommand::GetBacktrace() const
return this->Backtrace;
}
-cmCustomCommand::ImplicitDependsList const&
-cmCustomCommand::GetImplicitDepends() const
+cmImplicitDependsList const& cmCustomCommand::GetImplicitDepends() const
{
return this->ImplicitDepends;
}
-void cmCustomCommand::SetImplicitDepends(ImplicitDependsList const& l)
+void cmCustomCommand::SetImplicitDepends(cmImplicitDependsList const& l)
{
this->ImplicitDepends = l;
}
-void cmCustomCommand::AppendImplicitDepends(ImplicitDependsList const& l)
+void cmCustomCommand::AppendImplicitDepends(cmImplicitDependsList const& l)
{
cmAppend(this->ImplicitDepends, l);
}
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index 102b178..bb5a0ed 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -14,6 +14,11 @@
class cmMakefile;
+class cmImplicitDependsList
+ : public std::vector<std::pair<std::string, std::string>>
+{
+};
+
/** \class cmCustomCommand
* \brief A class to encapsulate a custom command
*
@@ -68,13 +73,9 @@ public:
/** Backtrace of the command that created this custom command. */
cmListFileBacktrace const& GetBacktrace() const;
- using ImplicitDependsPair = std::pair<std::string, std::string>;
- class ImplicitDependsList : public std::vector<ImplicitDependsPair>
- {
- };
- void SetImplicitDepends(ImplicitDependsList const&);
- void AppendImplicitDepends(ImplicitDependsList const&);
- ImplicitDependsList const& GetImplicitDepends() const;
+ void SetImplicitDepends(cmImplicitDependsList const&);
+ void AppendImplicitDepends(cmImplicitDependsList const&);
+ cmImplicitDependsList const& GetImplicitDepends() const;
/** Set/Get whether this custom command should be given access to the
real console (if possible). */
@@ -99,7 +100,7 @@ private:
std::vector<std::string> Depends;
cmCustomCommandLines CommandLines;
cmListFileBacktrace Backtrace;
- ImplicitDependsList ImplicitDepends;
+ cmImplicitDependsList ImplicitDepends;
std::string Comment;
std::string WorkingDirectory;
std::string Depfile;
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 82cc037..2c0cbfd 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -13,8 +13,8 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include <cstddef>
#include <memory>
-#include <stddef.h>
#include <utility>
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
@@ -58,6 +58,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
std::vector<std::string> result =
cmExpandedList(cge->Evaluate(this->LG, this->Config));
for (std::string& it : result) {
+ cmSystemTools::ConvertToUnixSlashes(it);
if (cmSystemTools::FileIsFullPath(it)) {
it = cmSystemTools::CollapseFullPath(it);
}
diff --git a/Source/cmCustomCommandLines.cxx b/Source/cmCustomCommandLines.cxx
new file mode 100644
index 0000000..37ad75b
--- /dev/null
+++ b/Source/cmCustomCommandLines.cxx
@@ -0,0 +1,22 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmCustomCommandLines.h"
+
+cmCustomCommandLine cmMakeCommandLine(
+ std::initializer_list<cm::string_view> ilist)
+{
+ cmCustomCommandLine commandLine;
+ commandLine.reserve(ilist.size());
+ for (cm::string_view cmd : ilist) {
+ commandLine.emplace_back(cmd);
+ }
+ return commandLine;
+}
+
+cmCustomCommandLines cmMakeSingleCommandLine(
+ std::initializer_list<cm::string_view> ilist)
+{
+ cmCustomCommandLines commandLines;
+ commandLines.push_back(cmMakeCommandLine(ilist));
+ return commandLines;
+}
diff --git a/Source/cmCustomCommandLines.h b/Source/cmCustomCommandLines.h
index 35a15ba..213aeb1 100644
--- a/Source/cmCustomCommandLines.h
+++ b/Source/cmCustomCommandLines.h
@@ -5,25 +5,28 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <initializer_list>
#include <string>
#include <vector>
+#include "cm_string_view.hxx" // IWYU pragma: keep
+
/** Data structure to represent a single command line. */
class cmCustomCommandLine : public std::vector<std::string>
{
-public:
- using Superclass = std::vector<std::string>;
- using iterator = Superclass::iterator;
- using const_iterator = Superclass::const_iterator;
};
/** Data structure to represent a list of command lines. */
class cmCustomCommandLines : public std::vector<cmCustomCommandLine>
{
-public:
- using Superclass = std::vector<cmCustomCommandLine>;
- using iterator = Superclass::iterator;
- using const_iterator = Superclass::const_iterator;
};
+/** Return a command line from a list of command line parts. */
+cmCustomCommandLine cmMakeCommandLine(
+ std::initializer_list<cm::string_view> ilist);
+
+/** Return a command line vector with a single command line. */
+cmCustomCommandLines cmMakeSingleCommandLine(
+ std::initializer_list<cm::string_view> ilist);
+
#endif
diff --git a/Source/cmDefinePropertyCommand.cxx b/Source/cmDefinePropertyCommand.cxx
index 86a83da..f4e4fda 100644
--- a/Source/cmDefinePropertyCommand.cxx
+++ b/Source/cmDefinePropertyCommand.cxx
@@ -2,19 +2,17 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmDefinePropertyCommand.h"
-#include <sstream>
-
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmProperty.h"
#include "cmState.h"
+#include "cmStringAlgorithms.h"
-class cmExecutionStatus;
-
-bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmDefinePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -37,17 +35,17 @@ bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
} else if (scope_arg == "CACHED_VARIABLE") {
scope = cmProperty::CACHED_VARIABLE;
} else {
- std::ostringstream e;
- e << "given invalid scope " << scope_arg << ". "
- << "Valid scopes are "
- << "GLOBAL, DIRECTORY, TARGET, SOURCE, "
- << "TEST, VARIABLE, CACHED_VARIABLE.";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid scope ", scope_arg,
+ ". Valid scopes are GLOBAL, DIRECTORY, TARGET, "
+ "SOURCE, TEST, VARIABLE, CACHED_VARIABLE."));
return false;
}
// Parse remaining arguments.
bool inherited = false;
+ std::string PropertyName;
+ std::string BriefDocs;
+ std::string FullDocs;
enum Doing
{
DoingNone,
@@ -68,39 +66,36 @@ bool cmDefinePropertyCommand::InitialPass(std::vector<std::string> const& args,
inherited = true;
} else if (doing == DoingProperty) {
doing = DoingNone;
- this->PropertyName = args[i];
+ PropertyName = args[i];
} else if (doing == DoingBrief) {
- this->BriefDocs += args[i];
+ BriefDocs += args[i];
} else if (doing == DoingFull) {
- this->FullDocs += args[i];
+ FullDocs += args[i];
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << args[i] << "\".";
- this->SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", args[i], "\"."));
return false;
}
}
// Make sure a property name was found.
- if (this->PropertyName.empty()) {
- this->SetError("not given a PROPERTY <name> argument.");
+ if (PropertyName.empty()) {
+ status.SetError("not given a PROPERTY <name> argument.");
return false;
}
// Make sure documentation was given.
- if (this->BriefDocs.empty()) {
- this->SetError("not given a BRIEF_DOCS <brief-doc> argument.");
+ if (BriefDocs.empty()) {
+ status.SetError("not given a BRIEF_DOCS <brief-doc> argument.");
return false;
}
- if (this->FullDocs.empty()) {
- this->SetError("not given a FULL_DOCS <full-doc> argument.");
+ if (FullDocs.empty()) {
+ status.SetError("not given a FULL_DOCS <full-doc> argument.");
return false;
}
// Actually define the property.
- this->Makefile->GetState()->DefineProperty(
- this->PropertyName, scope, this->BriefDocs.c_str(), this->FullDocs.c_str(),
- inherited);
+ status.GetMakefile().GetState()->DefineProperty(
+ PropertyName, scope, BriefDocs.c_str(), FullDocs.c_str(), inherited);
return true;
}
diff --git a/Source/cmDefinePropertyCommand.h b/Source/cmDefinePropertyCommand.h
index 36f97df..60dd76a 100644
--- a/Source/cmDefinePropertyCommand.h
+++ b/Source/cmDefinePropertyCommand.h
@@ -8,31 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmDefinePropertyCommand : public cmCommand
-{
-public:
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmDefinePropertyCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-
-private:
- std::string PropertyName;
- std::string BriefDocs;
- std::string FullDocs;
-};
+bool cmDefinePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx
index e688890..2a117c1 100644
--- a/Source/cmDefinitions.cxx
+++ b/Source/cmDefinitions.cxx
@@ -4,7 +4,7 @@
#include "cm_string_view.hxx"
-#include <assert.h>
+#include <cassert>
#include <functional>
#include <unordered_set>
#include <utility>
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index b657ff7..de919f1 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -3,10 +3,10 @@
#include "cmDependsFortran.h"
#include "cmsys/FStream.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstdlib>
#include <iostream>
#include <map>
-#include <stdlib.h>
#include <utility>
#include "cmFortranParser.h" /* Interface to parser object. */
diff --git a/Source/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx
index 12d875d..63a96d0 100644
--- a/Source/cmDependsJavaParserHelper.cxx
+++ b/Source/cmDependsJavaParserHelper.cxx
@@ -7,10 +7,10 @@
#include "cm_string_view.hxx"
#include "cmsys/FStream.hxx"
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <iostream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
int cmDependsJava_yyparse(yyscan_t yyscanner);
diff --git a/Source/cmDocumentation.cxx b/Source/cmDocumentation.cxx
index d4628fa..d1f3a83 100644
--- a/Source/cmDocumentation.cxx
+++ b/Source/cmDocumentation.cxx
@@ -11,8 +11,8 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Glob.hxx"
#include <algorithm>
-#include <ctype.h>
-#include <string.h>
+#include <cctype>
+#include <cstring>
#include <utility>
static const char* cmDocumentationStandardOptions[][2] = {
diff --git a/Source/cmDocumentationFormatter.cxx b/Source/cmDocumentationFormatter.cxx
index 3e7f989..be6756a 100644
--- a/Source/cmDocumentationFormatter.cxx
+++ b/Source/cmDocumentationFormatter.cxx
@@ -5,9 +5,9 @@
#include "cmDocumentationEntry.h"
#include "cmDocumentationSection.h"
+#include <cstring>
#include <iomanip>
#include <ostream>
-#include <string.h>
#include <string>
#include <vector>
diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx
index 90250b6..12f996d 100644
--- a/Source/cmELF.cxx
+++ b/Source/cmELF.cxx
@@ -6,10 +6,10 @@
#include "cm_kwiml.h"
#include "cm_memory.hxx"
#include "cmsys/FStream.hxx"
+#include <cstddef>
#include <map>
#include <memory>
#include <sstream>
-#include <stddef.h>
#include <utility>
#include <vector>
diff --git a/Source/cmEnableLanguageCommand.cxx b/Source/cmEnableLanguageCommand.cxx
index ddd26de..59522c0 100644
--- a/Source/cmEnableLanguageCommand.cxx
+++ b/Source/cmEnableLanguageCommand.cxx
@@ -2,20 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmEnableLanguageCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmEnableLanguageCommand
-bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmEnableLanguageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- bool optional = false;
- std::vector<std::string> languages;
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+
+ bool optional = false;
+ std::vector<std::string> languages;
for (std::string const& it : args) {
if (it == "OPTIONAL") {
optional = true;
@@ -24,6 +23,6 @@ bool cmEnableLanguageCommand::InitialPass(std::vector<std::string> const& args,
}
}
- this->Makefile->EnableLanguage(languages, optional);
+ status.GetMakefile().EnableLanguage(languages, optional);
return true;
}
diff --git a/Source/cmEnableLanguageCommand.h b/Source/cmEnableLanguageCommand.h
index dc43e34..1f8c4ce 100644
--- a/Source/cmEnableLanguageCommand.h
+++ b/Source/cmEnableLanguageCommand.h
@@ -8,37 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmEnableLanguageCommand
- * \brief Specify the name for this build project.
- *
- * cmEnableLanguageCommand is used to specify a name for this build project.
- * It is defined once per set of CMakeList.txt files (including
- * all subdirectories). Currently it just sets the name of the workspace
- * file for Microsoft Visual C++
- */
-class cmEnableLanguageCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmEnableLanguageCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmEnableLanguageCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmExecProgramCommand.cxx b/Source/cmExecProgramCommand.cxx
index 74e9c55..207b6fd 100644
--- a/Source/cmExecProgramCommand.cxx
+++ b/Source/cmExecProgramCommand.cxx
@@ -3,7 +3,7 @@
#include "cmExecProgramCommand.h"
#include "cmsys/Process.h"
-#include <stdio.h>
+#include <cstdio>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx
index acf2a83..12364c8 100644
--- a/Source/cmExecuteProcessCommand.cxx
+++ b/Source/cmExecuteProcessCommand.cxx
@@ -6,10 +6,10 @@
#include "cmsys/Process.h"
#include <algorithm>
-#include <ctype.h> /* isspace */
+#include <cctype> /* isspace */
+#include <cstdio>
#include <iostream>
#include <memory>
-#include <stdio.h>
#include <vector>
#include "cmAlgorithms.h"
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 9545814..e588f7b 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -19,9 +19,9 @@
#include "cmTargetExport.h"
#include "cmsys/FStream.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstring>
#include <sstream>
-#include <string.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index 1b536c9..207ea41 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmExportInstallAndroidMKGenerator.h"
+#include <cstddef>
#include <ostream>
-#include <stddef.h>
#include "cmExportBuildAndroidMKGenerator.h"
#include "cmExportSet.h"
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index 5a01eb2..e74ad0c 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -15,10 +15,10 @@
#include "cmake.h"
#include "cmsys/SystemInformation.hxx"
+#include <cstring>
#include <map>
#include <set>
#include <sstream>
-#include <string.h>
#include <utility>
cmExtraCodeLiteGenerator::cmExtraCodeLiteGenerator()
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index d398018..ca612b5 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -4,10 +4,10 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <map>
#include <sstream>
-#include <stdio.h>
#include <utility>
#include "cmGeneratedFileStream.h"
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index 7ac73cf..b3d869e 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -12,9 +12,9 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include <cstring>
#include <ostream>
#include <set>
-#include <string.h>
#include <vector>
cmExtraKateGenerator::cmExtraKateGenerator() = default;
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 6ad8609..f041821 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -3,9 +3,9 @@
#include "cmExtraSublimeTextGenerator.h"
#include "cmsys/RegularExpression.hxx"
+#include <cstring>
#include <set>
#include <sstream>
-#include <string.h>
#include <utility>
#include "cmGeneratedFileStream.h"
diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index ea9e672..11844e4 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -2,16 +2,16 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFLTKWrapUICommand.h"
-#include <stddef.h>
+#include <cstddef>
#include "cmCustomCommandLines.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
class cmTarget;
static void FinalAction(cmMakefile& makefile, std::string const& name)
@@ -30,39 +30,40 @@ static void FinalAction(cmMakefile& makefile, std::string const& name)
}
}
-// cmFLTKWrapUICommand
-bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmFLTKWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// what is the current source dir
- std::string cdir = this->Makefile->GetCurrentSourceDirectory();
+ std::string cdir = mf.GetCurrentSourceDirectory();
std::string const& fluid_exe =
- this->Makefile->GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
+ mf.GetRequiredDefinition("FLTK_FLUID_EXECUTABLE");
// Target that will use the generated files
std::string const& target = args[0];
// get the list of GUI files from which .cxx and .h will be generated
- std::string outputDirectory = this->Makefile->GetCurrentBinaryDirectory();
+ std::string outputDirectory = mf.GetCurrentBinaryDirectory();
{
// Some of the generated files are *.h so the directory "GUI"
// where they are created have to be added to the include path
std::vector<std::string> outputDirectories;
outputDirectories.push_back(outputDirectory);
- this->Makefile->AddIncludeDirectories(outputDirectories);
+ mf.AddIncludeDirectories(outputDirectories);
}
// List of produced files.
std::vector<cmSourceFile*> generatedSourcesClasses;
for (std::string const& arg : cmMakeRange(args).advance(1)) {
- cmSourceFile* curr = this->Makefile->GetSource(arg);
+ cmSourceFile* curr = mf.GetSource(arg);
// if we should use the source GUI
// to generate .cxx and .h files
if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) {
@@ -76,29 +77,26 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
depends.push_back(fluid_exe);
std::string cxxres = cmStrCat(outName, ".cxx");
- cmCustomCommandLine commandLine;
- commandLine.push_back(fluid_exe);
- commandLine.push_back("-c"); // instructs Fluid to run in command line
- commandLine.push_back("-h"); // optionally rename .h files
- commandLine.push_back(hname);
- commandLine.push_back("-o"); // optionally rename .cxx files
- commandLine.push_back(cxxres);
- commandLine.push_back(origname); // name of the GUI fluid file
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine({
+ fluid_exe,
+ "-c", // instructs Fluid to run in command line
+ "-h", // optionally rename .h files
+ hname,
+ "-o", // optionally rename .cxx files
+ cxxres,
+ origname // name of the GUI fluid file
+ });
// Add command for generating the .h and .cxx files
std::string no_main_dependency;
const char* no_comment = nullptr;
const char* no_working_dir = nullptr;
- this->Makefile->AddCustomCommandToOutput(
- cxxres, depends, no_main_dependency, commandLines, no_comment,
- no_working_dir);
- this->Makefile->AddCustomCommandToOutput(
- hname, depends, no_main_dependency, commandLines, no_comment,
- no_working_dir);
-
- cmSourceFile* sf = this->Makefile->GetSource(cxxres);
+ mf.AddCustomCommandToOutput(cxxres, depends, no_main_dependency,
+ commandLines, no_comment, no_working_dir);
+ mf.AddCustomCommandToOutput(hname, depends, no_main_dependency,
+ commandLines, no_comment, no_working_dir);
+
+ cmSourceFile* sf = mf.GetSource(cxxres);
sf->AddDepend(hname);
sf->AddDepend(origname);
generatedSourcesClasses.push_back(sf);
@@ -116,9 +114,9 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector<std::string> const& args,
}
std::string const varName = target + "_FLTK_UI_SRCS";
- this->Makefile->AddDefinition(varName, sourceListValue);
+ mf.AddDefinition(varName, sourceListValue);
- this->Makefile->AddFinalAction(
+ mf.AddFinalAction(
[target](cmMakefile& makefile) { FinalAction(makefile, target); });
return true;
}
diff --git a/Source/cmFLTKWrapUICommand.h b/Source/cmFLTKWrapUICommand.h
index ea8d401..bb56dbd 100644
--- a/Source/cmFLTKWrapUICommand.h
+++ b/Source/cmFLTKWrapUICommand.h
@@ -8,35 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmFLTKWrapUICommand
- * \brief Create .h and .cxx files rules for FLTK user interfaces files
- *
- * cmFLTKWrapUICommand is used to create wrappers for FLTK classes into
- * normal C++
- */
-class cmFLTKWrapUICommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmFLTKWrapUICommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmFLTKWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index e8a7810..33acd05 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -9,14 +9,14 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cctype>
#include <cmath>
-#include <ctype.h>
+#include <cstdio>
+#include <cstdlib>
#include <map>
#include <set>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <utility>
#include <vector>
diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx
index e00e726..5b9c85a 100644
--- a/Source/cmFileCopier.cxx
+++ b/Source/cmFileCopier.cxx
@@ -16,8 +16,8 @@
# include "cmsys/FStream.hxx"
#endif
+#include <cstring>
#include <sstream>
-#include <string.h>
using namespace cmFSPermissions;
diff --git a/Source/cmFileLock.cxx b/Source/cmFileLock.cxx
index 1e472da..d380798 100644
--- a/Source/cmFileLock.cxx
+++ b/Source/cmFileLock.cxx
@@ -3,7 +3,7 @@
#include "cmFileLock.h"
#include "cmFileLockResult.h"
-#include <assert.h>
+#include <cassert>
// Common implementation
diff --git a/Source/cmFileLockPool.cxx b/Source/cmFileLockPool.cxx
index d700a79..8db2db2 100644
--- a/Source/cmFileLockPool.cxx
+++ b/Source/cmFileLockPool.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileLockPool.h"
-#include <assert.h>
+#include <cassert>
#include "cmAlgorithms.h"
#include "cmFileLock.h"
diff --git a/Source/cmFileLockResult.cxx b/Source/cmFileLockResult.cxx
index c4779f0..9d5a6c6 100644
--- a/Source/cmFileLockResult.cxx
+++ b/Source/cmFileLockResult.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileLockResult.h"
-#include <errno.h>
-#include <string.h>
+#include <cerrno>
+#include <cstring>
#define WINMSG_BUF_LEN (1024)
cmFileLockResult cmFileLockResult::MakeOk()
diff --git a/Source/cmFileLockUnix.cxx b/Source/cmFileLockUnix.cxx
index 1bf5013..7393823 100644
--- a/Source/cmFileLockUnix.cxx
+++ b/Source/cmFileLockUnix.cxx
@@ -3,9 +3,9 @@
#include "cmFileLock.h"
#include "cmSystemTools.h"
-#include <errno.h> // errno
+#include <cerrno> // errno
+#include <cstdio> // SEEK_SET
#include <fcntl.h>
-#include <stdio.h> // SEEK_SET
#include <unistd.h>
cmFileLock::cmFileLock() = default;
diff --git a/Source/cmFileMonitor.cxx b/Source/cmFileMonitor.cxx
index 56ee739..7fcced2 100644
--- a/Source/cmFileMonitor.cxx
+++ b/Source/cmFileMonitor.cxx
@@ -6,7 +6,7 @@
#include "cmsys/SystemTools.hxx"
#include <cassert>
-#include <stddef.h>
+#include <cstddef>
#include <unordered_map>
#include <utility>
diff --git a/Source/cmFilePathChecksum.h b/Source/cmFilePathChecksum.h
index 30881ce..b7d5cd2 100644
--- a/Source/cmFilePathChecksum.h
+++ b/Source/cmFilePathChecksum.h
@@ -6,7 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <array>
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <utility>
diff --git a/Source/cmFileTime.cxx b/Source/cmFileTime.cxx
index 253457f..f92c0ff 100644
--- a/Source/cmFileTime.cxx
+++ b/Source/cmFileTime.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFileTime.h"
+#include <ctime>
#include <string>
-#include <time.h>
// Use a platform-specific API to get file times efficiently.
#if !defined(_WIN32) || defined(__CYGWIN__)
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index e0daa4f..7d74118 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -2,10 +2,10 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmFindBase.h"
+#include <cstddef>
#include <deque>
#include <iostream>
#include <map>
-#include <stddef.h>
#include "cmAlgorithms.h"
#include "cmMakefile.h"
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 5606838..badec55 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -4,7 +4,7 @@
#include <algorithm>
#include <array>
-#include <string.h>
+#include <cstring>
#include <utility>
#include "cmAlgorithms.h"
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index 529e5c8..011e8aa 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -4,9 +4,9 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdio>
+#include <cstring>
#include <set>
-#include <stdio.h>
-#include <string.h>
#include <utility>
#include "cmGlobalGenerator.h"
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 8f76030..8c8cf13 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -9,13 +9,13 @@
#include "cmsys/RegularExpression.hxx"
#include "cmsys/String.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
#include <deque>
#include <functional>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index f0633aa..3c39c46 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmForEachCommand.h"
+#include <cstdio>
+#include <cstdlib>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h
index 825876c..6f97b42 100644
--- a/Source/cmFortranParser.h
+++ b/Source/cmFortranParser.h
@@ -12,7 +12,7 @@
# include <vector>
#endif
-#include <stddef.h> /* size_t */
+#include <cstddef> /* size_t */
/* Forward declare parser object type. */
using cmFortranParser = struct cmFortranParser_s;
diff --git a/Source/cmFortranParserImpl.cxx b/Source/cmFortranParserImpl.cxx
index ad377de..b983b4d 100644
--- a/Source/cmFortranParserImpl.cxx
+++ b/Source/cmFortranParserImpl.cxx
@@ -5,10 +5,10 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <set>
#include <stack>
-#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx
index 491d96f..2af04b6 100644
--- a/Source/cmGeneratedFileStream.cxx
+++ b/Source/cmGeneratedFileStream.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGeneratedFileStream.h"
-#include <stdio.h>
+#include <cstdio>
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx
index 7bb6a63..f49ed2c 100644
--- a/Source/cmGeneratorExpression.cxx
+++ b/Source/cmGeneratorExpression.cxx
@@ -6,7 +6,6 @@
#include <memory>
#include <utility>
-#include "assert.h"
#include "cmAlgorithms.h"
#include "cmGeneratorExpressionContext.h"
#include "cmGeneratorExpressionDAGChecker.h"
@@ -15,6 +14,7 @@
#include "cmGeneratorExpressionParser.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include <cassert>
cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace)
: Backtrace(std::move(backtrace))
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index dda0abc..76f2905 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -10,8 +10,8 @@
#include "cmStringAlgorithms.h"
#include "cmake.h"
+#include <cstring>
#include <sstream>
-#include <string.h>
#include <utility>
cmGeneratorExpressionDAGChecker::cmGeneratorExpressionDAGChecker(
diff --git a/Source/cmGeneratorExpressionEvaluator.h b/Source/cmGeneratorExpressionEvaluator.h
index 4530152..b10bb5b 100644
--- a/Source/cmGeneratorExpressionEvaluator.h
+++ b/Source/cmGeneratorExpressionEvaluator.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <utility>
#include <vector>
diff --git a/Source/cmGeneratorExpressionLexer.h b/Source/cmGeneratorExpressionLexer.h
index bf24308..9e01948 100644
--- a/Source/cmGeneratorExpressionLexer.h
+++ b/Source/cmGeneratorExpressionLexer.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <vector>
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 89b6c1c..6cb7a96 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -30,15 +30,15 @@
#include "cmsys/String.h"
#include <algorithm>
-#include <assert.h>
-#include <errno.h>
+#include <cassert>
+#include <cerrno>
+#include <cstdlib>
+#include <cstring>
#include <iterator>
#include <map>
#include <memory>
#include <set>
#include <sstream>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx
index ba00b94..a0b685e 100644
--- a/Source/cmGeneratorExpressionParser.cxx
+++ b/Source/cmGeneratorExpressionParser.cxx
@@ -5,8 +5,8 @@
#include "cmAlgorithms.h"
#include "cmGeneratorExpressionEvaluator.h"
-#include <assert.h>
-#include <stddef.h>
+#include <cassert>
+#include <cstddef>
#include <utility>
cmGeneratorExpressionParser::cmGeneratorExpressionParser(
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index fa04fbb..3a321c5 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -4,16 +4,16 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cerrno>
#include <cstddef>
-#include <errno.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <iterator>
#include <memory>
#include <queue>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <unordered_set>
#include <utility>
@@ -35,6 +35,7 @@
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmSourceFileLocation.h"
+#include "cmSourceFileLocationKind.h"
#include "cmState.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -2599,7 +2600,7 @@ private:
SourceEntry* CurrentEntry;
std::queue<cmSourceFile*> SourceQueue;
std::set<cmSourceFile*> SourcesQueued;
- using NameMapType = std::map<std::string, cmSourceFile*>;
+ using NameMapType = std::map<std::string, cmSourcesWithOutput>;
NameMapType NameMap;
std::vector<std::string> NewSources;
@@ -2705,19 +2706,30 @@ void cmTargetTraceDependencies::QueueSource(cmSourceFile* sf)
void cmTargetTraceDependencies::FollowName(std::string const& name)
{
- auto i = this->NameMap.find(name);
- if (i == this->NameMap.end()) {
+ // Use lower bound with key comparison to not repeat the search for the
+ // insert position if the name could not be found (which is the common case).
+ auto i = this->NameMap.lower_bound(name);
+ if (i == this->NameMap.end() || i->first != name) {
// Check if we know how to generate this file.
- cmSourceFile* sf = this->Makefile->GetSourceFileWithOutput(name);
- NameMapType::value_type entry(name, sf);
- i = this->NameMap.insert(entry).first;
- }
- if (cmSourceFile* sf = i->second) {
- // Record the dependency we just followed.
- if (this->CurrentEntry) {
- this->CurrentEntry->Depends.push_back(sf);
+ cmSourcesWithOutput sources = this->Makefile->GetSourcesWithOutput(name);
+ i = this->NameMap.emplace_hint(i, name, sources);
+ }
+ if (cmTarget* t = i->second.Target) {
+ // The name is a byproduct of a utility target or a PRE_BUILD, PRE_LINK, or
+ // POST_BUILD command.
+ this->GeneratorTarget->Target->AddUtility(t->GetName());
+ }
+ if (cmSourceFile* sf = i->second.Source) {
+ // For now only follow the dependency if the source file is not a
+ // byproduct. Semantics of byproducts in a non-Ninja context will have to
+ // be defined first.
+ if (!i->second.SourceIsByproduct) {
+ // Record the dependency we just followed.
+ if (this->CurrentEntry) {
+ this->CurrentEntry->Depends.push_back(sf);
+ }
+ this->QueueSource(sf);
}
- this->QueueSource(sf);
}
}
@@ -3360,57 +3372,67 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
}
std::string& filename = inserted.first->second;
+ const cmGeneratorTarget* generatorTarget = this;
+ const char* pchReuseFrom =
+ generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+ if (pchReuseFrom) {
+ generatorTarget =
+ this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ }
+
if (this->GetGlobalGenerator()->IsMultiConfig()) {
- filename =
- cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), "/");
+ filename = cmStrCat(
+ generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(), "/");
} else {
// For GCC we need to have the header file .h[xx]
// next to the .h[xx].gch file
- filename = this->ObjectDirectory;
+ filename = generatorTarget->ObjectDirectory;
}
- filename = cmStrCat(filename, "CMakeFiles/", this->GetName(),
+ filename = cmStrCat(filename, "CMakeFiles/", generatorTarget->GetName(),
".dir/cmake_pch", ((language == "C") ? ".h" : ".hxx"));
const std::string filename_tmp = cmStrCat(filename, ".tmp");
- {
+ if (!pchReuseFrom) {
auto pchPrologue = this->Makefile->GetDefinition("CMAKE_PCH_PROLOGUE");
auto pchEpilogue = this->Makefile->GetDefinition("CMAKE_PCH_EPILOGUE");
- cmGeneratedFileStream file(
- filename_tmp, false,
- this->GetGlobalGenerator()->GetMakefileEncoding());
- file << "/* generated by CMake */\n\n";
- if (pchPrologue) {
- file << pchPrologue << "\n";
- }
- if (this->GetGlobalGenerator()->IsXcode()) {
- file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n";
- }
- if (language == "CXX") {
- file << "#ifdef __cplusplus\n";
- }
- for (auto const& header_bt : headers) {
- if (header_bt.Value.empty()) {
- continue;
+ {
+ cmGeneratedFileStream file(
+ filename_tmp, false,
+ this->GetGlobalGenerator()->GetMakefileEncoding());
+ file << "/* generated by CMake */\n\n";
+ if (pchPrologue) {
+ file << pchPrologue << "\n";
}
- if (header_bt.Value[0] == '<' || header_bt.Value[0] == '"') {
- file << "#include " << header_bt.Value << "\n";
- } else {
- file << "#include \"" << header_bt.Value << "\"\n";
+ if (this->GetGlobalGenerator()->IsXcode()) {
+ file << "#ifndef CMAKE_SKIP_PRECOMPILE_HEADERS\n";
+ }
+ if (language == "CXX") {
+ file << "#ifdef __cplusplus\n";
+ }
+ for (auto const& header_bt : headers) {
+ if (header_bt.Value.empty()) {
+ continue;
+ }
+ if (header_bt.Value[0] == '<' || header_bt.Value[0] == '\"') {
+ file << "#include " << header_bt.Value << "\n";
+ } else {
+ file << "#include \"" << header_bt.Value << "\"\n";
+ }
+ }
+ if (language == "CXX") {
+ file << "#endif // __cplusplus\n";
+ }
+ if (this->GetGlobalGenerator()->IsXcode()) {
+ file << "#endif // CMAKE_SKIP_PRECOMPILE_HEADERS\n";
+ }
+ if (pchEpilogue) {
+ file << pchEpilogue << "\n";
}
}
- if (language == "CXX") {
- file << "#endif // __cplusplus\n";
- }
- if (this->GetGlobalGenerator()->IsXcode()) {
- file << "#endif // CMAKE_SKIP_PRECOMPILE_HEADERS\n";
- }
- if (pchEpilogue) {
- file << pchEpilogue << "\n";
- }
+ cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
}
- cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
}
return inserted.first->second;
}
@@ -3429,8 +3451,18 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config,
return std::string();
}
std::string& filename = inserted.first->second;
- filename = cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(),
- "/CMakeFiles/", this->GetName(), ".dir/cmake_pch");
+
+ const cmGeneratorTarget* generatorTarget = this;
+ const char* pchReuseFrom =
+ generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+ if (pchReuseFrom) {
+ generatorTarget =
+ this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ }
+
+ filename =
+ cmStrCat(generatorTarget->LocalGenerator->GetCurrentBinaryDirectory(),
+ "/CMakeFiles/", generatorTarget->GetName(), ".dir/cmake_pch");
// For GCC the source extension will be tranformed into .h[xx].gch
if (!this->Makefile->IsOn("CMAKE_LINK_PCH")) {
@@ -3438,12 +3470,40 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config,
} else {
filename += ((language == "C") ? ".c" : ".cxx");
}
+
const std::string filename_tmp = cmStrCat(filename, ".tmp");
- {
- cmGeneratedFileStream file(filename_tmp);
- file << "/* generated by CMake */\n";
+ if (!pchReuseFrom) {
+ {
+ cmGeneratedFileStream file(filename_tmp);
+ file << "/* generated by CMake */\n";
+ }
+ cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
+ }
+ }
+ return inserted.first->second;
+}
+
+std::string cmGeneratorTarget::GetPchFileObject(const std::string& config,
+ const std::string& language)
+{
+ if (language != "C" && language != "CXX") {
+ return std::string();
+ }
+ const auto inserted =
+ this->PchObjectFiles.insert(std::make_pair(language + config, ""));
+ if (inserted.second) {
+ const std::string pchSource = this->GetPchSource(config, language);
+ if (pchSource.empty()) {
+ return std::string();
}
- cmSystemTools::MoveFileIfDifferent(filename_tmp, filename);
+ std::string& filename = inserted.first->second;
+
+ this->AddSource(pchSource, true);
+
+ auto pchSf = this->Makefile->GetOrCreateSource(
+ pchSource, false, cmSourceFileLocationKind::Known);
+
+ filename = cmStrCat(this->ObjectDirectory, this->GetObjectName(pchSf));
}
return inserted.first->second;
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 9eb2ecf..6c36c4b 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -10,9 +10,9 @@
#include "cmPolicies.h"
#include "cmStateTypes.h"
+#include <cstddef>
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
#include <unordered_map>
#include <utility>
@@ -462,6 +462,8 @@ public:
const std::string& language) const;
std::string GetPchSource(const std::string& config,
const std::string& language) const;
+ std::string GetPchFileObject(const std::string& config,
+ const std::string& language);
bool IsSystemIncludeDirectory(const std::string& dir,
const std::string& config,
@@ -880,6 +882,7 @@ private:
mutable std::set<std::string> LinkImplicitNullProperties;
mutable std::map<std::string, std::string> PchHeaders;
mutable std::map<std::string, std::string> PchSources;
+ mutable std::map<std::string, std::string> PchObjectFiles;
void ExpandLinkItems(std::string const& prop, std::string const& value,
std::string const& config,
diff --git a/Source/cmGetPipes.cxx b/Source/cmGetPipes.cxx
index ad323f7..79f90fd 100644
--- a/Source/cmGetPipes.cxx
+++ b/Source/cmGetPipes.cxx
@@ -28,7 +28,7 @@ int cmGetPipes(int* fds)
return 0;
}
#else
-# include <errno.h>
+# include <cerrno>
# include <unistd.h>
int cmGetPipes(int* fds)
diff --git a/Source/cmGetSourceFilePropertyCommand.cxx b/Source/cmGetSourceFilePropertyCommand.cxx
index 5c1c8a5..eefdc6c 100644
--- a/Source/cmGetSourceFilePropertyCommand.cxx
+++ b/Source/cmGetSourceFilePropertyCommand.cxx
@@ -2,26 +2,25 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetSourceFilePropertyCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
-class cmExecutionStatus;
-
-// cmSetSourceFilePropertyCommand
-bool cmGetSourceFilePropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetSourceFilePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& var = args[0];
std::string const& file = args[1];
- cmSourceFile* sf = this->Makefile->GetSource(file);
+ cmMakefile& mf = status.GetMakefile();
+ cmSourceFile* sf = mf.GetSource(file);
// for the location we must create a source file first
if (!sf && args[2] == "LOCATION") {
- sf = this->Makefile->CreateSource(file);
+ sf = mf.CreateSource(file);
}
if (sf) {
const char* prop = nullptr;
@@ -29,11 +28,11 @@ bool cmGetSourceFilePropertyCommand::InitialPass(
prop = sf->GetPropertyForUser(args[2]);
}
if (prop) {
- this->Makefile->AddDefinition(var, prop);
+ mf.AddDefinition(var, prop);
return true;
}
}
- this->Makefile->AddDefinition(var, "NOTFOUND");
+ mf.AddDefinition(var, "NOTFOUND");
return true;
}
diff --git a/Source/cmGetSourceFilePropertyCommand.h b/Source/cmGetSourceFilePropertyCommand.h
index 387a7f4..f0c319b 100644
--- a/Source/cmGetSourceFilePropertyCommand.h
+++ b/Source/cmGetSourceFilePropertyCommand.h
@@ -8,26 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetSourceFilePropertyCommand : public cmCommand
-{
-public:
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmGetSourceFilePropertyCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmGetSourceFilePropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetTargetPropertyCommand.cxx b/Source/cmGetTargetPropertyCommand.cxx
index 07aaf02..7f5df9c 100644
--- a/Source/cmGetTargetPropertyCommand.cxx
+++ b/Source/cmGetTargetPropertyCommand.cxx
@@ -4,6 +4,7 @@
#include <sstream>
+#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -11,32 +12,31 @@
#include "cmTarget.h"
#include "cmTargetPropertyComputer.h"
-class cmExecutionStatus;
class cmMessenger;
-// cmSetTargetPropertyCommand
-bool cmGetTargetPropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() != 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& var = args[0];
std::string const& targetName = args[1];
std::string prop;
bool prop_exists = false;
+ cmMakefile& mf = status.GetMakefile();
- if (cmTarget* tgt = this->Makefile->FindTargetToUse(targetName)) {
+ if (cmTarget* tgt = mf.FindTargetToUse(targetName)) {
if (args[2] == "ALIASED_TARGET") {
- if (this->Makefile->IsAlias(targetName)) {
+ if (mf.IsAlias(targetName)) {
prop = tgt->GetName();
prop_exists = true;
}
} else if (!args[2].empty()) {
const char* prop_cstr = nullptr;
- cmListFileBacktrace bt = this->Makefile->GetBacktrace();
- cmMessenger* messenger = this->Makefile->GetMessenger();
+ cmListFileBacktrace bt = mf.GetBacktrace();
+ cmMessenger* messenger = mf.GetMessenger();
if (cmTargetPropertyComputer::PassesWhitelist(tgt->GetType(), args[2],
messenger, bt)) {
prop_cstr = tgt->GetComputedProperty(args[2], messenger, bt);
@@ -53,7 +53,7 @@ bool cmGetTargetPropertyCommand::InitialPass(
bool issueMessage = false;
std::ostringstream e;
MessageType messageType = MessageType::AUTHOR_WARNING;
- switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0045)) {
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0045)) {
case cmPolicies::WARN:
issueMessage = true;
e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0045) << "\n";
@@ -68,16 +68,16 @@ bool cmGetTargetPropertyCommand::InitialPass(
if (issueMessage) {
e << "get_target_property() called with non-existent target \""
<< targetName << "\".";
- this->Makefile->IssueMessage(messageType, e.str());
+ mf.IssueMessage(messageType, e.str());
if (messageType == MessageType::FATAL_ERROR) {
return false;
}
}
}
if (prop_exists) {
- this->Makefile->AddDefinition(var, prop);
+ mf.AddDefinition(var, prop);
return true;
}
- this->Makefile->AddDefinition(var, var + "-NOTFOUND");
+ mf.AddDefinition(var, var + "-NOTFOUND");
return true;
}
diff --git a/Source/cmGetTargetPropertyCommand.h b/Source/cmGetTargetPropertyCommand.h
index 1a53195..c13078f 100644
--- a/Source/cmGetTargetPropertyCommand.h
+++ b/Source/cmGetTargetPropertyCommand.h
@@ -8,26 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetTargetPropertyCommand : public cmCommand
-{
-public:
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmGetTargetPropertyCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmGetTargetPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGetTestPropertyCommand.cxx b/Source/cmGetTestPropertyCommand.cxx
index 0b0d6eb..cf8c1d5 100644
--- a/Source/cmGetTestPropertyCommand.cxx
+++ b/Source/cmGetTestPropertyCommand.cxx
@@ -2,33 +2,32 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetTestPropertyCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmTest.h"
-class cmExecutionStatus;
-
-// cmGetTestPropertyCommand
-bool cmGetTestPropertyCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
std::string const& testName = args[0];
std::string const& var = args[2];
- cmTest* test = this->Makefile->GetTest(testName);
+ cmMakefile& mf = status.GetMakefile();
+ cmTest* test = mf.GetTest(testName);
if (test) {
const char* prop = nullptr;
if (!args[1].empty()) {
prop = test->GetProperty(args[1]);
}
if (prop) {
- this->Makefile->AddDefinition(var, prop);
+ mf.AddDefinition(var, prop);
return true;
}
}
- this->Makefile->AddDefinition(var, "NOTFOUND");
+ mf.AddDefinition(var, "NOTFOUND");
return true;
}
diff --git a/Source/cmGetTestPropertyCommand.h b/Source/cmGetTestPropertyCommand.h
index a53a7f7..30beb8f 100644
--- a/Source/cmGetTestPropertyCommand.h
+++ b/Source/cmGetTestPropertyCommand.h
@@ -8,26 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmGetTestPropertyCommand : public cmCommand
-{
-public:
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmGetTestPropertyCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmGetTestPropertyCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 9479424..2273c50 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -5,13 +5,13 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <initializer_list>
#include <iterator>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <windows.h>
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 0b45f4b..236554f 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -18,9 +18,9 @@
#include "cmake.h"
#include <algorithm>
+#include <cstring>
#include <map>
#include <ostream>
-#include <string.h>
#include <utility>
const char* cmGlobalGhsMultiGenerator::FILE_EXTENSION = ".gpj";
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 062eccb..9ce6324 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -7,10 +7,10 @@
#include "cm_jsoncpp_writer.h"
#include "cmsys/FStream.hxx"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
+#include <cstdio>
#include <iterator>
#include <sstream>
-#include <stdio.h>
#include "cm_memory.hxx"
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 264de54..6a39509 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -5,10 +5,10 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
#include <map>
#include <set>
-#include <stddef.h>
#include <string>
#include <vector>
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 5e60108..255739d 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalVisualStudio8Generator.h"
+#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
@@ -145,12 +147,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Add a custom prebuild target to run the VerifyGlobs script.
cmake* cm = this->GetCMakeInstance();
if (cm->DoWriteGlobVerifyTarget()) {
- cmCustomCommandLine verifyCommandLine;
- verifyCommandLine.push_back(cmSystemTools::GetCMakeCommand());
- verifyCommandLine.push_back("-P");
- verifyCommandLine.push_back(cm->GetGlobVerifyScript());
- cmCustomCommandLines verifyCommandLines;
- verifyCommandLines.push_back(verifyCommandLine);
+ cmCustomCommandLines verifyCommandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-P", cm->GetGlobVerifyScript() });
std::vector<std::string> byproducts;
byproducts.push_back(cm->GetGlobVerifyStamp());
@@ -172,30 +170,25 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
listFiles.erase(new_end, listFiles.end());
// Create a rule to re-run CMake.
- cmCustomCommandLine commandLine;
- commandLine.push_back(cmSystemTools::GetCMakeCommand());
std::string argS = cmStrCat("-S", lg->GetSourceDirectory());
- commandLine.push_back(argS);
std::string argB = cmStrCat("-B", lg->GetBinaryDirectory());
- commandLine.push_back(argB);
- commandLine.push_back("--check-stamp-list");
- commandLine.push_back(stampList.c_str());
- commandLine.push_back("--vs-solution-file");
std::string const sln =
lg->GetBinaryDirectory() + "/" + lg->GetProjectName() + ".sln";
- commandLine.push_back(sln);
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), argS, argB, "--check-stamp-list",
+ stampList, "--vs-solution-file", sln });
// Add the rule. Note that we cannot use the CMakeLists.txt
// file as the main dependency because it would get
// overwritten by the CreateVCProjBuildRule.
// (this could be avoided with per-target source files)
- std::string no_main_dependency;
std::vector<std::string> no_byproducts;
+ std::string no_main_dependency;
+ cmImplicitDependsList no_implicit_depends;
if (cmSourceFile* file = mf->AddCustomCommandToOutput(
- stamps, no_byproducts, listFiles, no_main_dependency, commandLines,
- "Checking Build System", no_working_directory, true, false)) {
+ stamps, no_byproducts, listFiles, no_main_dependency,
+ no_implicit_depends, commandLines, "Checking Build System",
+ no_working_directory, true, false)) {
gt->AddSource(file->ResolveFullPath());
} else {
cmSystemTools::Error("Error adding rule for " + stamps[0]);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 6e0b804..a0ce740 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -13,6 +13,7 @@
#include "cmAlgorithms.h"
#include "cmCallVisualStudioMacro.h"
#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmLocalVisualStudioGenerator.h"
@@ -900,17 +901,11 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
std::string obj_dir = gt->ObjectDirectory;
std::string cmakeCommand = cmSystemTools::GetCMakeCommand();
cmSystemTools::ConvertToWindowsExtendedPath(cmakeCommand);
- cmCustomCommandLine cmdl;
- cmdl.push_back(cmakeCommand);
- cmdl.push_back("-E");
- cmdl.push_back("__create_def");
- cmdl.push_back(mdi->DefFile);
std::string obj_dir_expanded = obj_dir;
cmSystemTools::ReplaceString(obj_dir_expanded, this->GetCMakeCFGIntDir(),
configName.c_str());
cmSystemTools::MakeDirectory(obj_dir_expanded);
std::string const objs_file = obj_dir_expanded + "/objects.txt";
- cmdl.push_back(objs_file);
cmGeneratedFileStream fout(objs_file.c_str());
if (!fout) {
cmSystemTools::Error("could not open " + objs_file);
@@ -948,8 +943,8 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
fout << i->GetFullPath() << "\n";
}
- cmCustomCommandLines commandLines;
- commandLines.push_back(cmdl);
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file });
cmCustomCommand command(gt->Target->GetMakefile(), outputs, empty, empty,
commandLines, "Auto build dll exports", ".");
commands.push_back(command);
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index af5d279..4d41fd7 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -3,11 +3,11 @@
#include "cmGlobalXCodeGenerator.h"
#include "cmsys/RegularExpression.hxx"
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
+#include <cstring>
#include <iomanip>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include "cm_memory.hxx"
@@ -15,6 +15,7 @@
#include "cmComputeLinkInformation.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
+#include "cmCustomCommandLines.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
@@ -500,22 +501,18 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
const char* no_working_directory = nullptr;
std::vector<std::string> no_depends;
cmTarget* allbuild = mf->AddUtilityCommand(
- "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true, no_depends,
- no_working_directory, "echo", "Build all projects");
+ "ALL_BUILD", cmMakefile::TargetOrigin::Generator, true,
+ no_working_directory, no_depends,
+ cmMakeSingleCommandLine({ "echo", "Build all projects" }));
cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root);
root->AddGeneratorTarget(allBuildGt);
// Add XCODE depend helper
std::string dir = root->GetCurrentBinaryDirectory();
- cmCustomCommandLine makeHelper;
- makeHelper.push_back("make");
- makeHelper.push_back("-C");
- makeHelper.push_back(dir);
- makeHelper.push_back("-f");
- makeHelper.push_back(this->CurrentXCodeHackMakefile);
- makeHelper.push_back("OBJDIR=$(OBJDIR)");
- makeHelper.push_back(""); // placeholder, see below
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { "make", "-C", dir, "-f", this->CurrentXCodeHackMakefile,
+ "OBJDIR=$(OBJDIR)", /* placeholder, see below */ "" });
// Add ZERO_CHECK
bool regenerate = !this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION");
@@ -530,7 +527,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
cmSystemTools::ReplaceString(file, "\\ ", " ");
cmTarget* check = mf->AddUtilityCommand(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, cmMakefile::TargetOrigin::Generator,
- true, no_depends, no_working_directory, "make", "-f", file.c_str());
+ true, no_working_directory, no_depends,
+ cmMakeSingleCommandLine({ "make", "-f", file }));
cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root);
root->AddGeneratorTarget(checkGt);
@@ -555,10 +553,8 @@ void cmGlobalXCodeGenerator::AddExtraTargets(
// this will make sure that when the next target is built
// things are up-to-date
if (target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
- makeHelper.back() = // fill placeholder
+ commandLines.front().back() = // fill placeholder
this->PostBuildMakeTarget(target->GetName(), "$(CONFIGURATION)");
- cmCustomCommandLines commandLines;
- commandLines.push_back(makeHelper);
std::vector<std::string> no_byproducts;
gen->GetMakefile()->AddCustomCommandToTarget(
target->GetName(), no_byproducts, no_depends, commandLines,
@@ -1440,19 +1436,14 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
if (gtgt->GetType() == cmStateEnums::SHARED_LIBRARY &&
!gtgt->IsFrameworkOnApple()) {
- cmCustomCommandLines cmd;
- cmd.resize(1);
- cmd[0].push_back(cmSystemTools::GetCMakeCommand());
- cmd[0].push_back("-E");
- cmd[0].push_back("cmake_symlink_library");
std::string str_file = cmStrCat("$<TARGET_FILE:", gtgt->GetName(), '>');
std::string str_so_file =
cmStrCat("$<TARGET_SONAME_FILE:", gtgt->GetName(), '>');
std::string str_link_file =
cmStrCat("$<TARGET_LINKER_FILE:", gtgt->GetName(), '>');
- cmd[0].push_back(str_file);
- cmd[0].push_back(str_so_file);
- cmd[0].push_back(str_link_file);
+ cmCustomCommandLines cmd = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library",
+ str_file, str_so_file, str_link_file });
cmCustomCommand command(this->CurrentMakefile, std::vector<std::string>(),
std::vector<std::string>(),
diff --git a/Source/cmHexFileConverter.cxx b/Source/cmHexFileConverter.cxx
index 190f2e3..2fa4b55 100644
--- a/Source/cmHexFileConverter.cxx
+++ b/Source/cmHexFileConverter.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmHexFileConverter.h"
-#include <ctype.h>
-#include <stdio.h>
-#include <string.h>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
#include "cmSystemTools.h"
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index 93134ad..fa1e8bc 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -2,6 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmIncludeExternalMSProjectCommand.h"
+#include "cmExecutionStatus.h"
+
#ifdef _WIN32
# include "cmGlobalGenerator.h"
# include "cmMakefile.h"
@@ -11,22 +13,20 @@
# include "cmake.h"
#endif
-class cmExecutionStatus;
-
-// cmIncludeExternalMSProjectCommand
-bool cmIncludeExternalMSProjectCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
- "number of arguments");
+ status.SetError("INCLUDE_EXTERNAL_MSPROJECT called with incorrect "
+ "number of arguments");
return false;
}
+
// only compile this for win32 to avoid coverage errors
#ifdef _WIN32
- if (this->Makefile->GetDefinition("WIN32") ||
- this->Makefile->GetGlobalGenerator()
- ->IsIncludeExternalMSProjectSupported()) {
+ cmMakefile& mf = status.GetMakefile();
+ if (mf.GetDefinition("WIN32") ||
+ mf.GetGlobalGenerator()->IsIncludeExternalMSProjectSupported()) {
enum Doing
{
DoingNone,
@@ -77,15 +77,15 @@ bool cmIncludeExternalMSProjectCommand::InitialPass(
if (!customGuid.empty()) {
std::string guidVariable = utility_name + "_GUID_CMAKE";
- this->Makefile->GetCMakeInstance()->AddCacheEntry(
- guidVariable.c_str(), customGuid.c_str(), "Stored GUID",
- cmStateEnums::INTERNAL);
+ mf.GetCMakeInstance()->AddCacheEntry(guidVariable.c_str(),
+ customGuid.c_str(), "Stored GUID",
+ cmStateEnums::INTERNAL);
}
// Create a target instance for this utility.
- cmTarget* target = this->Makefile->AddNewTarget(cmStateEnums::UTILITY,
- utility_name.c_str());
- if (this->Makefile->GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
+ cmTarget* target =
+ mf.AddNewTarget(cmStateEnums::UTILITY, utility_name.c_str());
+ if (mf.GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
diff --git a/Source/cmIncludeExternalMSProjectCommand.h b/Source/cmIncludeExternalMSProjectCommand.h
index 9f76576..1013c44 100644
--- a/Source/cmIncludeExternalMSProjectCommand.h
+++ b/Source/cmIncludeExternalMSProjectCommand.h
@@ -8,36 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmIncludeExternalMSProjectCommand
- * \brief Specify an external MS project file for inclusion in the workspace.
- *
- * cmIncludeExternalMSProjectCommand is used to specify an externally
- * generated Microsoft project file for inclusion in the default workspace
- * generated by CMake.
- */
-class cmIncludeExternalMSProjectCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmIncludeExternalMSProjectCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmIncludeRegularExpressionCommand.cxx b/Source/cmIncludeRegularExpressionCommand.cxx
index 073c95f..655ebd6 100644
--- a/Source/cmIncludeRegularExpressionCommand.cxx
+++ b/Source/cmIncludeRegularExpressionCommand.cxx
@@ -2,22 +2,22 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmIncludeRegularExpressionCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmIncludeRegularExpressionCommand
-bool cmIncludeRegularExpressionCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmIncludeRegularExpressionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- if ((args.empty()) || (args.size() > 2)) {
- this->SetError("called with incorrect number of arguments");
+ if (args.empty() || args.size() > 2) {
+ status.SetError("called with incorrect number of arguments");
return false;
}
- this->Makefile->SetIncludeRegularExpression(args[0].c_str());
+
+ cmMakefile& mf = status.GetMakefile();
+ mf.SetIncludeRegularExpression(args[0].c_str());
if (args.size() > 1) {
- this->Makefile->SetComplainRegularExpression(args[1]);
+ mf.SetComplainRegularExpression(args[1]);
}
return true;
diff --git a/Source/cmIncludeRegularExpressionCommand.h b/Source/cmIncludeRegularExpressionCommand.h
index 1723c8b..ca152b0 100644
--- a/Source/cmIncludeRegularExpressionCommand.h
+++ b/Source/cmIncludeRegularExpressionCommand.h
@@ -8,35 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmIncludeRegularExpressionCommand
- * \brief Set the regular expression for following #includes.
- *
- * cmIncludeRegularExpressionCommand is used to specify the regular expression
- * that determines whether to follow a #include file in dependency checking.
- */
-class cmIncludeRegularExpressionCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmIncludeRegularExpressionCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmIncludeRegularExpressionCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 9a78c49..9b931f7 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -4,9 +4,9 @@
#include "cm_static_string_view.hxx"
#include "cmsys/Glob.hxx"
+#include <cstddef>
#include <set>
#include <sstream>
-#include <stddef.h>
#include <utility>
#include "cmArgumentParser.h"
diff --git a/Source/cmInstallExportAndroidMKGenerator.cxx b/Source/cmInstallExportAndroidMKGenerator.cxx
deleted file mode 100644
index e8de029..0000000
--- a/Source/cmInstallExportAndroidMKGenerator.cxx
+++ /dev/null
@@ -1,134 +0,0 @@
-
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#include "cmInstallExportAndroidMKGenerator.h"
-
-#include <stdio.h>
-
-#include "cmExportInstallFileGenerator.h"
-#include "cmExportSet.h"
-#include "cmGeneratedFileStream.h"
-#include "cmGlobalGenerator.h"
-#include "cmInstallFilesGenerator.h"
-#include "cmInstallTargetGenerator.h"
-#include "cmLocalGenerator.h"
-#include "cmMakefile.h"
-#include "cmMessageType.h"
-
-cmInstallExportAndroidMKGenerator::cmInstallExportAndroidMKGenerator(
- cmExportSet* exportSet, const char* destination,
- const char* file_permissions, std::vector<std::string> const& configurations,
- const char* component, MessageLevel message, bool exclude_from_all,
- const char* filename, const char* name_space, bool exportOld)
- : cmInstallExportGenerator(exportSet, destination, file_permissions,
- configurations, component, message,
- exclude_from_all, filename, name_space, exportOld)
-{
-}
-
-cmInstallExportAndroidMKGenerator::~cmInstallExportAndroidMKGenerator()
-{
-}
-
-bool cmInstallExportAndroidMKGenerator::Compute(cmLocalGenerator* lg)
-{
- this->LocalGenerator = lg;
- this->ExportSet->Compute(lg);
- return true;
-}
-
-void cmInstallExportAndroidMKGenerator::GenerateScript(std::ostream& os)
-{
- // Skip empty sets.
- if (ExportSet->GetTargetExports()->empty()) {
- std::ostringstream e;
- e << "INSTALL(EXPORT) given unknown export \"" << ExportSet->GetName()
- << "\"";
- cmSystemTools::Error(e.str());
- return;
- }
-
- // Create the temporary directory in which to store the files.
- this->ComputeTempDir();
- cmSystemTools::MakeDirectory(this->TempDir.c_str());
-
- // Construct a temporary location for the file.
- this->MainImportFile = cmStrCat(this->TempDir, '/', this->FileName);
-
- // Generate the import file for this export set.
- this->EFGen->SetExportFile(this->MainImportFile.c_str());
- this->EFGen->SetNamespace(this->Namespace);
- this->EFGen->SetExportOld(this->ExportOld);
- if (this->ConfigurationTypes->empty()) {
- if (!this->ConfigurationName.empty()) {
- this->EFGen->AddConfiguration(this->ConfigurationName);
- } else {
- this->EFGen->AddConfiguration("");
- }
- } else {
- for (std::string const& config : this->ConfigurationTypes) {
- this->EFGen->AddConfiguration(config);
- }
- }
- this->EFGen->GenerateImportFile();
-
- // Perform the main install script generation.
- this->cmInstallGenerator::GenerateScript(os);
-}
-
-void cmInstallExportAndroidMKGenerator::GenerateScriptConfigs(
- std::ostream& os, Indent const& indent)
-{
- // Create the main install rules first.
- this->cmInstallGenerator::GenerateScriptConfigs(os, indent);
-
- // Now create a configuration-specific install rule for the import
- // file of each configuration.
- std::vector<std::string> files;
- for (auto const& pair : this->EFGen->GetConfigImportFiles()) {
- files.push_back(pair.second);
- std::string config_test = this->CreateConfigTest(pair.first);
- os << indent << "if(" << config_test << ")\n";
- this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
- false, this->FilePermissions.c_str(), nullptr,
- nullptr, nullptr, indent.Next());
- os << indent << "endif()\n";
- files.clear();
- }
-}
-
-void cmInstallExportAndroidMKGenerator::GenerateScriptActions(
- std::ostream& os, Indent const& indent)
-{
- // Remove old per-configuration export files if the main changes.
- std::string installedDir =
- cmStrCat("$ENV{DESTDIR}",
- this->ConvertToAbsoluteDestination(this->Destination), '/');
- std::string installedFile = cmStrCat(installedDir, this->FileName);
- os << indent << "if(EXISTS \"" << installedFile << "\")\n";
- Indent indentN = indent.Next();
- Indent indentNN = indentN.Next();
- Indent indentNNN = indentNN.Next();
- /* clang-format off */
- os << indentN << "file(DIFFERENT EXPORT_FILE_CHANGED FILES\n"
- << indentN << " \"" << installedFile << "\"\n"
- << indentN << " \"" << this->MainImportFile << "\")\n";
- os << indentN << "if(EXPORT_FILE_CHANGED)\n";
- os << indentNN << "file(GLOB OLD_CONFIG_FILES \"" << installedDir
- << this->EFGen->GetConfigImportFileGlob() << "\")\n";
- os << indentNN << "if(OLD_CONFIG_FILES)\n";
- os << indentNNN << "message(STATUS \"Old export file \\\"" << installedFile
- << "\\\" will be replaced. Removing files [${OLD_CONFIG_FILES}].\")\n";
- os << indentNNN << "file(REMOVE ${OLD_CONFIG_FILES})\n";
- os << indentNN << "endif()\n";
- os << indentN << "endif()\n";
- os << indent << "endif()\n";
- /* clang-format on */
-
- // Install the main export file.
- std::vector<std::string> files;
- files.push_back(this->MainImportFile);
- this->AddInstallRule(os, this->Destination, cmInstallType_FILES, files,
- false, this->FilePermissions.c_str(), nullptr, nullptr,
- nullptr, indent);
-}
diff --git a/Source/cmInstallExportAndroidMKGenerator.h b/Source/cmInstallExportAndroidMKGenerator.h
deleted file mode 100644
index a92ff27..0000000
--- a/Source/cmInstallExportAndroidMKGenerator.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
- file Copyright.txt or https://cmake.org/licensing for details. */
-#ifndef cmInstallExportAndroidMKGenerator_h
-#define cmInstallExportAndroidMKGenerator_h
-
-#include "cmInstallExportGenerator.h"
-
-class cmExportInstallFileGenerator;
-class cmInstallFilesGenerator;
-class cmInstallTargetGenerator;
-class cmExportSet;
-class cmMakefile;
-
-/** \class cmInstallExportAndroidMKGenerator
- * \brief Generate rules for creating an export files.
- */
-class cmInstallExportAndroidMKGenerator : public cmInstallExportGenerator
-{
-public:
- cmInstallExportAndroidMKGenerator(
- cmExportSet* exportSet, const char* dest, const char* file_permissions,
- const std::vector<std::string>& configurations, const char* component,
- MessageLevel message, bool exclude_from_all, const char* filename,
- const char* name_space, bool exportOld);
- ~cmInstallExportAndroidMKGenerator();
-
- bool Compute(cmLocalGenerator* lg) override;
-
-protected:
- virtual void GenerateScript(std::ostream& os);
- virtual void GenerateScriptConfigs(std::ostream& os, Indent const& indent);
- virtual void GenerateScriptActions(std::ostream& os, Indent const& indent);
- void GenerateImportFile(cmExportSet const* exportSet);
- void GenerateImportFile(const char* config, cmExportSet const* exportSet);
-};
-
-#endif
diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h
index e680066..3b9268a 100644
--- a/Source/cmInstallExportGenerator.h
+++ b/Source/cmInstallExportGenerator.h
@@ -8,8 +8,8 @@
#include "cmInstallGenerator.h"
#include "cmScriptGenerator.h"
+#include <cstddef>
#include <iosfwd>
-#include <stddef.h>
#include <string>
#include <vector>
diff --git a/Source/cmInstallFilesCommand.cxx b/Source/cmInstallFilesCommand.cxx
index 4eb5f24..d623943 100644
--- a/Source/cmInstallFilesCommand.cxx
+++ b/Source/cmInstallFilesCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallFilesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
@@ -11,8 +12,6 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
static std::string FindInstallSource(cmMakefile& makefile, const char* name);
static void CreateInstallGenerator(cmMakefile& makefile,
std::string const& dest,
@@ -20,16 +19,18 @@ static void CreateInstallGenerator(cmMakefile& makefile,
static void FinalAction(cmMakefile& makefile, std::string const& dest,
std::vector<std::string> const& args);
-bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmInstallFilesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
+ mf.GetGlobalGenerator()->EnableInstallTarget();
std::string const& dest = args[0];
@@ -37,18 +38,18 @@ bool cmInstallFilesCommand::InitialPass(std::vector<std::string> const& args,
std::vector<std::string> files;
for (std::string const& arg : cmMakeRange(args).advance(2)) {
// Find the source location for each file listed.
- files.push_back(FindInstallSource(*this->Makefile, arg.c_str()));
+ files.push_back(FindInstallSource(mf, arg.c_str()));
}
- CreateInstallGenerator(*this->Makefile, dest, files);
+ CreateInstallGenerator(mf, dest, files);
} else {
std::vector<std::string> finalArgs(args.begin() + 1, args.end());
- this->Makefile->AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
+ mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
FinalAction(makefile, dest, finalArgs);
});
}
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ mf.GetGlobalGenerator()->AddInstallComponent(
+ mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
return true;
}
diff --git a/Source/cmInstallFilesCommand.h b/Source/cmInstallFilesCommand.h
index f9b84fd..f4ebbde 100644
--- a/Source/cmInstallFilesCommand.h
+++ b/Source/cmInstallFilesCommand.h
@@ -8,35 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallFilesCommand
- * \brief Specifies where to install some files
- *
- * cmInstallFilesCommand specifies the relative path where a list of
- * files should be installed.
- */
-class cmInstallFilesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmInstallFilesCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmInstallFilesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallProgramsCommand.cxx b/Source/cmInstallProgramsCommand.cxx
index 31a18b5..6bb4409 100644
--- a/Source/cmInstallProgramsCommand.cxx
+++ b/Source/cmInstallProgramsCommand.cxx
@@ -2,6 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallProgramsCommand.h"
+#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmInstallFilesGenerator.h"
@@ -10,30 +11,29 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
static void FinalAction(cmMakefile& makefile, std::string const& dest,
std::vector<std::string> const& args);
static std::string FindInstallSource(cmMakefile& makefile, const char* name);
-// cmExecutableCommand
-bool cmInstallProgramsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmInstallProgramsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
+ mf.GetGlobalGenerator()->EnableInstallTarget();
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ mf.GetGlobalGenerator()->AddInstallComponent(
+ mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
std::string const& dest = args[0];
std::vector<std::string> const finalArgs(args.begin() + 1, args.end());
- this->Makefile->AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
+ mf.AddFinalAction([dest, finalArgs](cmMakefile& makefile) {
FinalAction(makefile, dest, finalArgs);
});
return true;
diff --git a/Source/cmInstallProgramsCommand.h b/Source/cmInstallProgramsCommand.h
index ccd621d..c567f3b 100644
--- a/Source/cmInstallProgramsCommand.h
+++ b/Source/cmInstallProgramsCommand.h
@@ -8,35 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallProgramsCommand
- * \brief Specifies where to install some programs
- *
- * cmInstallProgramsCommand specifies the relative path where a list of
- * programs should be installed.
- */
-class cmInstallProgramsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmInstallProgramsCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmInstallProgramsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index 7bbef35..90b0e1d 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmInstallTargetGenerator.h"
-#include <assert.h>
+#include <cassert>
#include <map>
#include <memory>
#include <set>
diff --git a/Source/cmInstallTargetsCommand.cxx b/Source/cmInstallTargetsCommand.cxx
index 30fd03d..44f23a5 100644
--- a/Source/cmInstallTargetsCommand.cxx
+++ b/Source/cmInstallTargetsCommand.cxx
@@ -5,25 +5,25 @@
#include <unordered_map>
#include <utility>
+#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmTarget.h"
-class cmExecutionStatus;
-
-// cmExecutableCommand
-bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmInstallTargetsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Enable the install target.
- this->Makefile->GetGlobalGenerator()->EnableInstallTarget();
+ mf.GetGlobalGenerator()->EnableInstallTarget();
- cmMakefile::cmTargetMap& tgts = this->Makefile->GetTargets();
+ cmMakefile::cmTargetMap& tgts = mf.GetTargets();
auto s = args.begin();
++s;
std::string runtime_dir = "/bin";
@@ -31,8 +31,8 @@ bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args,
if (*s == "RUNTIME_DIRECTORY") {
++s;
if (s == args.end()) {
- this->SetError("called with RUNTIME_DIRECTORY but no actual "
- "directory");
+ status.SetError("called with RUNTIME_DIRECTORY but no actual "
+ "directory");
return false;
}
@@ -45,14 +45,14 @@ bool cmInstallTargetsCommand::InitialPass(std::vector<std::string> const& args,
ti->second.SetHaveInstallRule(true);
} else {
std::string str = "Cannot find target: \"" + *s + "\" to install.";
- this->SetError(str);
+ status.SetError(str);
return false;
}
}
}
- this->Makefile->GetGlobalGenerator()->AddInstallComponent(
- this->Makefile->GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
+ mf.GetGlobalGenerator()->AddInstallComponent(
+ mf.GetSafeDefinition("CMAKE_INSTALL_DEFAULT_COMPONENT_NAME"));
return true;
}
diff --git a/Source/cmInstallTargetsCommand.h b/Source/cmInstallTargetsCommand.h
index 55e69ba..0c5850c 100644
--- a/Source/cmInstallTargetsCommand.h
+++ b/Source/cmInstallTargetsCommand.h
@@ -8,36 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmInstallTargetsCommand
- * \brief Specifies where to install some targets
- *
- * cmInstallTargetsCommand specifies the relative path where a list of
- * targets should be installed. The targets can be executables or
- * libraries.
- */
-class cmInstallTargetsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmInstallTargetsCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmInstallTargetsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index bf05310..cb63ceb 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -2,38 +2,37 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLinkLibrariesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmLinkLibrariesCommand
-bool cmLinkLibrariesCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmLinkLibrariesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
return true;
}
+ cmMakefile& mf = status.GetMakefile();
// add libraries, note that there is an optional prefix
// of debug and optimized than can be used
for (auto i = args.begin(); i != args.end(); ++i) {
if (*i == "debug") {
++i;
if (i == args.end()) {
- this->SetError("The \"debug\" argument must be followed by "
- "a library");
+ status.SetError("The \"debug\" argument must be followed by "
+ "a library");
return false;
}
- this->Makefile->AppendProperty("LINK_LIBRARIES", "debug");
+ mf.AppendProperty("LINK_LIBRARIES", "debug");
} else if (*i == "optimized") {
++i;
if (i == args.end()) {
- this->SetError("The \"optimized\" argument must be followed by "
- "a library");
+ status.SetError("The \"optimized\" argument must be followed by "
+ "a library");
return false;
}
- this->Makefile->AppendProperty("LINK_LIBRARIES", "optimized");
+ mf.AppendProperty("LINK_LIBRARIES", "optimized");
}
- this->Makefile->AppendProperty("LINK_LIBRARIES", i->c_str());
+ mf.AppendProperty("LINK_LIBRARIES", i->c_str());
}
return true;
diff --git a/Source/cmLinkLibrariesCommand.h b/Source/cmLinkLibrariesCommand.h
index 484ab0a..3412251 100644
--- a/Source/cmLinkLibrariesCommand.h
+++ b/Source/cmLinkLibrariesCommand.h
@@ -8,36 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmLinkLibrariesCommand
- * \brief Specify a list of libraries to link into executables.
- *
- * cmLinkLibrariesCommand is used to specify a list of libraries to link
- * into executable(s) or shared objects. The names of the libraries
- * should be those defined by the LIBRARY(library) command(s).
- */
-class cmLinkLibrariesCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmLinkLibrariesCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmLinkLibrariesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmLinkedTree.h b/Source/cmLinkedTree.h
index 8b91162..c7453ea 100644
--- a/Source/cmLinkedTree.h
+++ b/Source/cmLinkedTree.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <assert.h>
+#include <cassert>
#include <vector>
/**
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index b35dc6f..9487e3b 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -4,15 +4,15 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <cstddef>
+#include <cstdio>
+#include <cstdlib> // required for atoi
#include <functional>
#include <iterator>
#include <set>
#include <sstream>
#include <stdexcept>
-#include <stdio.h>
-#include <stdlib.h> // required for atoi
#include <utility>
#include <vector>
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 349d5e9..ab53df6 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -10,7 +10,7 @@
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <assert.h>
+#include <cassert>
#include <memory>
#include <sstream>
#include <utility>
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 5de1a74..9cae827 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -5,9 +5,9 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cstddef>
#include <iosfwd>
#include <memory>
-#include <stddef.h>
#include <string>
#include <utility>
#include <vector>
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index f650eb1..66fdada 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -2,12 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmLoadCommandCommand.h"
-#include <signal.h>
+#include <csignal>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 51eb78c..afcd69f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -4,7 +4,9 @@
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
+#include "cmCustomCommand.h"
#include "cmCustomCommandGenerator.h"
+#include "cmCustomCommandLines.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
#include "cmGeneratorExpressionEvaluationFile.h"
@@ -38,15 +40,15 @@
#endif
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <cstdlib>
+#include <cstring>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <memory>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <unordered_set>
#include <utility>
#include <vector>
@@ -2255,23 +2257,124 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target,
return;
}
+ const char* pchReuseFrom =
+ target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
+
auto pch_sf = this->Makefile->GetOrCreateSource(
pchSource, false, cmSourceFileLocationKind::Known);
std::string pchFile = pchHeader;
if (!this->GetGlobalGenerator()->IsXcode()) {
+ if (!pchReuseFrom) {
+ target->AddSource(pchSource, true);
+ }
+
// Exclude the pch files from linking
if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
- cmSystemTools::ReplaceString(pchFile, (lang == "C" ? ".h" : ".hxx"),
- pchExtension);
- pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str());
+
+ auto replaceExtension = [](const std::string& str,
+ const std::string& ext) -> std::string {
+ auto dot_pos = str.rfind('.');
+ std::string result;
+ if (dot_pos != std::string::npos) {
+ result = str.substr(0, dot_pos);
+ }
+ result += ext;
+ return result;
+ };
+
+ if (!pchReuseFrom) {
+ std::string pchSourceObj = target->GetPchFileObject(config, lang);
+
+ pchFile = replaceExtension(pchSourceObj, pchExtension);
+ pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str());
+ } else {
+ auto reuseTarget =
+ this->GlobalGenerator->FindGeneratorTarget(pchReuseFrom);
+
+ if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
+
+ const std::string pdb_prefix =
+ this->GetGlobalGenerator()->IsMultiConfig()
+ ? cmStrCat(this->GlobalGenerator->GetCMakeCFGIntDir(), "/")
+ : "";
+
+ const std::string target_compile_pdb_dir =
+ cmStrCat(target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
+ "/", target->GetName(), ".dir/");
+
+ const std::string copy_script =
+ cmStrCat(target_compile_pdb_dir, "copy_idb_pdb.cmake");
+ cmGeneratedFileStream file(copy_script);
+
+ file << "# CMake generated file\n";
+ for (auto extension : { ".pdb", ".idb" }) {
+ const std::string from_file = cmStrCat(
+ reuseTarget->GetLocalGenerator()->GetCurrentBinaryDirectory(),
+ "/", pchReuseFrom, ".dir/${PDB_PREFIX}", pchReuseFrom,
+ extension);
+
+ const std::string to_dir = cmStrCat(
+ target->GetLocalGenerator()->GetCurrentBinaryDirectory(), "/",
+ target->GetName(), ".dir/${PDB_PREFIX}");
+
+ file << "if (EXISTS \"" << from_file << "\")\n";
+ file << " file(COPY \"" << from_file << "\""
+ << " DESTINATION \"" << to_dir << "\")\n";
+ file << "endif()\n";
+ }
+
+ cmCustomCommandLines commandLines;
+ cmCustomCommandLine currentLine;
+ currentLine.push_back(cmSystemTools::GetCMakeCommand());
+ currentLine.push_back(cmStrCat("-DPDB_PREFIX=", pdb_prefix));
+ currentLine.push_back("-P");
+ currentLine.push_back(copy_script);
+ commandLines.push_back(std::move(currentLine));
+
+ const std::string no_main_dependency;
+ const std::vector<std::string> no_deps;
+ const char* no_message = "";
+ const char* no_current_dir = nullptr;
+ std::vector<std::string> no_byproducts;
+
+ std::vector<std::string> outputs;
+ outputs.push_back(cmStrCat(target_compile_pdb_dir, pdb_prefix,
+ pchReuseFrom, ".pdb"));
+
+ if (this->GetGlobalGenerator()->IsMultiConfig()) {
+ this->Makefile->AddCustomCommandToTarget(
+ target->GetName(), outputs, no_deps, commandLines,
+ cmTarget::PRE_BUILD, no_message, no_current_dir);
+ } else {
+ cmImplicitDependsList no_implicit_depends;
+ cmSourceFile* copy_rule = this->Makefile->AddCustomCommandToOutput(
+ outputs, no_byproducts, no_deps, no_main_dependency,
+ no_implicit_depends, commandLines, no_message, no_current_dir);
+
+ if (copy_rule) {
+ target->AddSource(copy_rule->ResolveFullPath());
+ }
+ }
+
+ target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
+ target_compile_pdb_dir.c_str());
+ }
+
+ std::string pchSourceObj = reuseTarget->GetPchFileObject(config, lang);
+
+ // Link to the pch object file
+ target->Target->SetProperty(
+ "LINK_FLAGS",
+ this->ConvertToOutputFormat(pchSourceObj, SHELL).c_str());
+
+ pchFile = replaceExtension(pchSourceObj, pchExtension);
+ }
} else {
pchFile += pchExtension;
pch_sf->SetProperty("PCH_EXTENSION", pchExtension.c_str());
}
- target->AddSource(pchSource, true);
-
for (auto& str : { std::ref(useOptionList), std::ref(createOptionList) }) {
cmSystemTools::ReplaceString(str, "<PCH_HEADER>", pchHeader);
cmSystemTools::ReplaceString(str, "<PCH_FILE>", pchFile);
diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx
index 1284d4d..0fe385f 100644
--- a/Source/cmLocalNinjaGenerator.cxx
+++ b/Source/cmLocalNinjaGenerator.cxx
@@ -3,11 +3,11 @@
#include "cmLocalNinjaGenerator.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstdio>
#include <iterator>
#include <memory>
#include <sstream>
-#include <stdio.h>
#include <utility>
#include "cmCryptoHash.h"
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 8248608..f80695d 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -5,8 +5,8 @@
#include "cmsys/FStream.hxx"
#include "cmsys/Terminal.h"
#include <algorithm>
+#include <cstdio>
#include <sstream>
-#include <stdio.h>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 6c7fb2b..026f494 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -92,11 +92,8 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets()
for (cmGeneratorTarget* l : tgts) {
if (l->GetType() == cmStateEnums::GLOBAL_TARGET) {
std::vector<std::string> no_depends;
- cmCustomCommandLine force_command;
- force_command.push_back("cd");
- force_command.push_back(".");
- cmCustomCommandLines force_commands;
- force_commands.push_back(force_command);
+ cmCustomCommandLines force_commands =
+ cmMakeSingleCommandLine({ "cd", "." });
std::string no_main_dependency;
std::string force = cmStrCat(this->GetCurrentBinaryDirectory(),
"/CMakeFiles/", l->GetName(), "_force");
@@ -246,21 +243,15 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
std::unique(listFiles.begin(), listFiles.end());
listFiles.erase(new_end, listFiles.end());
+ std::string argS = cmStrCat("-S", this->GetSourceDirectory());
+ std::string argB = cmStrCat("-B", this->GetBinaryDirectory());
std::string stampName =
cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp");
- cmCustomCommandLine commandLine;
- commandLine.push_back(cmSystemTools::GetCMakeCommand());
+ cmCustomCommandLines commandLines =
+ cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB,
+ "--check-stamp-file", stampName });
std::string comment = cmStrCat("Building Custom Rule ", makefileIn);
- std::string args;
- args = cmStrCat("-S", this->GetSourceDirectory());
- commandLine.push_back(args);
- args = cmStrCat("-B", this->GetBinaryDirectory());
- commandLine.push_back(args);
- commandLine.push_back("--check-stamp-file");
- commandLine.push_back(stampName);
- cmCustomCommandLines commandLines;
- commandLines.push_back(commandLine);
- const char* no_working_directory = 0;
+ const char* no_working_directory = nullptr;
std::string fullpathStampName =
cmSystemTools::CollapseFullPath(stampName.c_str());
this->Makefile->AddCustomCommandToOutput(
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index f3f2042..cec9c02 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -98,16 +98,11 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
}
// Add a pre-build event to create the directory.
- cmCustomCommandLine command;
- command.push_back(cmSystemTools::GetCMakeCommand());
- command.push_back("-E");
- command.push_back("make_directory");
- command.push_back(impDir);
std::vector<std::string> no_output;
std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
- cmCustomCommandLines commands;
- commands.push_back(command);
+ cmCustomCommandLines commands = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir });
pcc.reset(new cmCustomCommand(0, no_output, no_byproducts, no_depends,
commands, 0, 0));
pcc->SetEscapeOldStyle(false);
diff --git a/Source/cmLocale.h b/Source/cmLocale.h
index 3580ec8..c44a42d 100644
--- a/Source/cmLocale.h
+++ b/Source/cmLocale.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <locale.h>
+#include <clocale>
#include <string>
class cmLocaleRAII
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index ef6a705..af97761 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMacroCommand.h"
-#include <stdio.h>
+#include <cstdio>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 16cc453..c593939 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -5,16 +5,18 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
#include <cstring>
-#include <ctype.h>
#include <iterator>
#include <memory>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <utility>
+#include "cm_memory.hxx"
+
#include "cmAlgorithms.h"
#include "cmCommandArgumentParserHelper.h"
#include "cmCustomCommand.h"
@@ -908,12 +910,44 @@ void cmMakefile::AddCustomCommandToTarget(
t.AddPostBuildCommand(cc);
break;
}
+ this->UpdateOutputToSourceMap(byproducts, &t);
+}
+
+void cmMakefile::UpdateOutputToSourceMap(
+ std::vector<std::string> const& byproducts, cmTarget* target)
+{
+ for (std::string const& o : byproducts) {
+ this->UpdateOutputToSourceMap(o, target);
+ }
+}
+
+void cmMakefile::UpdateOutputToSourceMap(std::string const& byproduct,
+ cmTarget* target)
+{
+ SourceEntry entry;
+ entry.Sources.Target = target;
+
+ auto pr = this->OutputToSource.emplace(byproduct, entry);
+ if (!pr.second) {
+ SourceEntry& current = pr.first->second;
+ // Has the target already been set?
+ if (!current.Sources.Target) {
+ current.Sources.Target = target;
+ } else {
+ // Multiple custom commands/targets produce the same output (source file
+ // or target). See also comment in other UpdateOutputToSourceMap
+ // overload.
+ //
+ // TODO: Warn the user about this case.
+ }
+ }
}
cmSourceFile* cmMakefile::AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends, const std::string& main_dependency,
+ const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
@@ -994,44 +1028,57 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
depends2.push_back(main_dependency);
}
- cmCustomCommand* cc = new cmCustomCommand(
+ std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>(
this, outputs, byproducts, depends2, commandLines, comment, workingDir);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true);
+ cc->SetImplicitDepends(implicit_depends);
cc->SetUsesTerminal(uses_terminal);
cc->SetCommandExpandLists(command_expand_lists);
cc->SetDepfile(depfile);
cc->SetJobPool(job_pool);
- file->SetCustomCommand(cc);
- this->UpdateOutputToSourceMap(outputs, file);
+ file->SetCustomCommand(std::move(cc));
+ this->UpdateOutputToSourceMap(outputs, file, false);
+ this->UpdateOutputToSourceMap(byproducts, file, true);
}
return file;
}
void cmMakefile::UpdateOutputToSourceMap(
- std::vector<std::string> const& outputs, cmSourceFile* source)
+ std::vector<std::string> const& outputs, cmSourceFile* source,
+ bool byproduct)
{
for (std::string const& o : outputs) {
- this->UpdateOutputToSourceMap(o, source);
+ this->UpdateOutputToSourceMap(o, source, byproduct);
}
}
void cmMakefile::UpdateOutputToSourceMap(std::string const& output,
- cmSourceFile* source)
-{
- auto i = this->OutputToSource.find(output);
- if (i != this->OutputToSource.end()) {
- // Multiple custom commands produce the same output but may
- // be attached to a different source file (MAIN_DEPENDENCY).
- // LinearGetSourceFileWithOutput would return the first one,
- // so keep the mapping for the first one.
- //
- // TODO: Warn the user about this case. However, the VS 8 generator
- // triggers it for separate generate.stamp rules in ZERO_CHECK and
- // individual targets.
- return;
+ cmSourceFile* source, bool byproduct)
+{
+ SourceEntry entry;
+ entry.Sources.Source = source;
+ entry.Sources.SourceIsByproduct = byproduct;
+
+ auto pr = this->OutputToSource.emplace(output, entry);
+ if (!pr.second) {
+ SourceEntry& current = pr.first->second;
+ // Outputs take precedence over byproducts
+ if (!current.Sources.Source ||
+ (current.Sources.SourceIsByproduct && !byproduct)) {
+ current.Sources.Source = source;
+ current.Sources.SourceIsByproduct = false;
+ } else {
+ // Multiple custom commands produce the same output but may
+ // be attached to a different source file (MAIN_DEPENDENCY).
+ // LinearGetSourceFileWithOutput would return the first one,
+ // so keep the mapping for the first one.
+ //
+ // TODO: Warn the user about this case. However, the VS 8 generator
+ // triggers it for separate generate.stamp rules in ZERO_CHECK and
+ // individual targets.
+ }
}
- this->OutputToSource[output] = source;
}
cmSourceFile* cmMakefile::AddCustomCommandToOutput(
@@ -1044,10 +1091,11 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
std::vector<std::string> outputs;
outputs.push_back(output);
std::vector<std::string> no_byproducts;
+ cmImplicitDependsList no_implicit_depends;
return this->AddCustomCommandToOutput(
- outputs, no_byproducts, depends, main_dependency, commandLines, comment,
- workingDir, replace, escapeOldStyle, uses_terminal, command_expand_lists,
- depfile, job_pool);
+ outputs, no_byproducts, depends, main_dependency, no_implicit_depends,
+ commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal,
+ command_expand_lists, depfile, job_pool);
}
void cmMakefile::AddCustomCommandOldStyle(
@@ -1108,33 +1156,21 @@ void cmMakefile::AddCustomCommandOldStyle(
}
}
-cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
- const std::vector<std::string>& depends, const char* workingDirectory,
- const char* command, const char* arg1, const char* arg2, const char* arg3,
- const char* arg4)
-{
- // Construct the command line for the custom command.
- cmCustomCommandLine commandLine;
- commandLine.push_back(command);
- if (arg1) {
- commandLine.push_back(arg1);
- }
- if (arg2) {
- commandLine.push_back(arg2);
- }
- if (arg3) {
- commandLine.push_back(arg3);
- }
- if (arg4) {
- commandLine.push_back(arg4);
+bool cmMakefile::AppendCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines)
+{
+ // Lookup an existing command.
+ if (cmSourceFile* sf = this->GetSourceFileWithOutput(output)) {
+ if (cmCustomCommand* cc = sf->GetCustomCommand()) {
+ cc->AppendCommands(commandLines);
+ cc->AppendDepends(depends);
+ cc->AppendImplicitDepends(implicit_depends);
+ return true;
+ }
}
- cmCustomCommandLines commandLines;
- commandLines.push_back(std::move(commandLine));
-
- // Call the real signature of this method.
- return this->AddUtilityCommand(utilityName, origin, excludeFromAll,
- workingDirectory, depends, commandLines);
+ return false;
}
cmTarget* cmMakefile::AddUtilityCommand(
@@ -1181,11 +1217,12 @@ cmTarget* cmMakefile::AddUtilityCommand(
std::vector<std::string> forced;
forced.push_back(force);
std::string no_main_dependency;
+ cmImplicitDependsList no_implicit_depends;
bool no_replace = false;
this->AddCustomCommandToOutput(
- forced, byproducts, depends, no_main_dependency, commandLines, comment,
- workingDirectory, no_replace, escapeOldStyle, uses_terminal,
- command_expand_lists, /*depfile=*/"", job_pool);
+ forced, byproducts, depends, no_main_dependency, no_implicit_depends,
+ commandLines, comment, workingDirectory, no_replace, escapeOldStyle,
+ uses_terminal, command_expand_lists, /*depfile=*/"", job_pool);
cmSourceFile* sf = target->AddSourceCMP0049(force);
// The output is not actually created so mark it symbolic.
@@ -1194,6 +1231,8 @@ cmTarget* cmMakefile::AddUtilityCommand(
} else {
cmSystemTools::Error("Could not get source file entry for " + force);
}
+
+ this->UpdateOutputToSourceMap(byproducts, target);
}
return target;
}
@@ -2007,52 +2046,126 @@ cmTarget* cmMakefile::AddNewTarget(cmStateEnums::TargetType type,
this->Targets
.emplace(name, cmTarget(name, type, cmTarget::VisibilityNormal, this))
.first;
+ this->OrderedTargets.push_back(&it->second);
this->GetGlobalGenerator()->IndexTarget(&it->second);
this->GetStateSnapshot().GetDirectory().AddNormalTargetName(name);
return &it->second;
}
+namespace {
+bool AnyOutputMatches(const std::string& name,
+ const std::vector<std::string>& outputs)
+{
+ for (std::string const& output : outputs) {
+ std::string::size_type pos = output.rfind(name);
+ // If the output matches exactly
+ if (pos != std::string::npos && pos == output.size() - name.size() &&
+ (pos == 0 || output[pos - 1] == '/')) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool AnyTargetCommandOutputMatches(
+ const std::string& name, const std::vector<cmCustomCommand>& commands)
+{
+ for (cmCustomCommand const& command : commands) {
+ if (AnyOutputMatches(name, command.GetByproducts())) {
+ return true;
+ }
+ }
+ return false;
+}
+}
+
+cmTarget* cmMakefile::LinearGetTargetWithOutput(const std::string& name) const
+{
+ // We go through the ordered vector of targets to get reproducible results
+ // should multiple names match.
+ for (cmTarget* t : this->OrderedTargets) {
+ // Does the output of any command match the source file name?
+ if (AnyTargetCommandOutputMatches(name, t->GetPreBuildCommands())) {
+ return t;
+ }
+ if (AnyTargetCommandOutputMatches(name, t->GetPreLinkCommands())) {
+ return t;
+ }
+ if (AnyTargetCommandOutputMatches(name, t->GetPostBuildCommands())) {
+ return t;
+ }
+ }
+ return nullptr;
+}
+
cmSourceFile* cmMakefile::LinearGetSourceFileWithOutput(
- const std::string& name) const
+ const std::string& name, cmSourceOutputKind kind, bool& byproduct) const
{
- std::string out;
+ // Outputs take precedence over byproducts.
+ byproduct = false;
+ cmSourceFile* fallback = nullptr;
- // look through all the source files that have custom commands
- // and see if the custom command has the passed source file as an output
+ // Look through all the source files that have custom commands and see if the
+ // custom command has the passed source file as an output.
for (cmSourceFile* src : this->SourceFiles) {
- // does this source file have a custom command?
+ // Does this source file have a custom command?
if (src->GetCustomCommand()) {
// Does the output of the custom command match the source file name?
- const std::vector<std::string>& outputs =
- src->GetCustomCommand()->GetOutputs();
- for (std::string const& output : outputs) {
- out = output;
- std::string::size_type pos = out.rfind(name);
- // If the output matches exactly
- if (pos != std::string::npos && pos == out.size() - name.size() &&
- (pos == 0 || out[pos - 1] == '/')) {
- return src;
+ if (AnyOutputMatches(name, src->GetCustomCommand()->GetOutputs())) {
+ // Return the first matching output.
+ return src;
+ }
+ if (kind == cmSourceOutputKind::OutputOrByproduct) {
+ if (AnyOutputMatches(name, src->GetCustomCommand()->GetByproducts())) {
+ // Do not return the source yet as there might be a matching output.
+ fallback = src;
}
}
}
}
- // otherwise return NULL
- return nullptr;
+ // Did we find a byproduct?
+ byproduct = fallback != nullptr;
+ return fallback;
}
-cmSourceFile* cmMakefile::GetSourceFileWithOutput(
+cmSourcesWithOutput cmMakefile::GetSourcesWithOutput(
const std::string& name) const
{
+ // Linear search? Also see GetSourceFileWithOutput for detail.
+ if (!cmSystemTools::FileIsFullPath(name)) {
+ cmSourcesWithOutput sources;
+ sources.Target = this->LinearGetTargetWithOutput(name);
+ sources.Source = this->LinearGetSourceFileWithOutput(
+ name, cmSourceOutputKind::OutputOrByproduct, sources.SourceIsByproduct);
+ return sources;
+ }
+ // Otherwise we use an efficient lookup map.
+ auto o = this->OutputToSource.find(name);
+ if (o != this->OutputToSource.end()) {
+ return o->second.Sources;
+ }
+ return {};
+}
+
+cmSourceFile* cmMakefile::GetSourceFileWithOutput(
+ const std::string& name, cmSourceOutputKind kind) const
+{
// 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(name)) {
- return this->LinearGetSourceFileWithOutput(name);
+ bool byproduct = false;
+ return this->LinearGetSourceFileWithOutput(name, kind, byproduct);
}
// Otherwise we use an efficient lookup map.
auto o = this->OutputToSource.find(name);
- if (o != this->OutputToSource.end()) {
- return (*o).second;
+ if (o != this->OutputToSource.end() &&
+ (!o->second.Sources.SourceIsByproduct ||
+ kind == cmSourceOutputKind::OutputOrByproduct)) {
+ // Source file could also be null pointer for example if we found the
+ // byproduct of a utility target or a PRE_BUILD, PRE_LINK, or POST_BUILD
+ // command of a target.
+ return o->second.Sources.Source;
}
return nullptr;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 52464d6..6d695a7 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -6,13 +6,13 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmsys/RegularExpression.hxx"
+#include <cstddef>
#include <deque>
#include <functional>
#include <map>
#include <memory>
#include <set>
#include <stack>
-#include <stddef.h>
#include <string>
#include <unordered_map>
#include <vector>
@@ -42,6 +42,7 @@ class cmExportBuildFileGenerator;
class cmFunctionBlocker;
class cmGeneratorExpressionEvaluationFile;
class cmGlobalGenerator;
+class cmImplicitDependsList;
class cmInstallGenerator;
class cmMessenger;
class cmSourceFile;
@@ -51,6 +52,24 @@ class cmTestGenerator;
class cmVariableWatch;
class cmake;
+/** Flag if byproducts shall also be considered. */
+enum class cmSourceOutputKind
+{
+ OutputOnly,
+ OutputOrByproduct
+};
+
+/** Target and source file which have a specific output. */
+struct cmSourcesWithOutput
+{
+ /** Target with byproduct. */
+ cmTarget* Target = nullptr;
+
+ /** Source file with output or byproduct. */
+ cmSourceFile* Source = nullptr;
+ bool SourceIsByproduct = false;
+};
+
/** A type-safe wrapper for a string representing a directory id. */
class cmDirectoryId
{
@@ -166,6 +185,7 @@ public:
const std::vector<std::string>& byproducts,
const std::vector<std::string>& depends,
const std::string& main_dependency,
+ const cmImplicitDependsList& implicit_depends,
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
@@ -183,6 +203,10 @@ public:
const std::string& source,
const cmCustomCommandLines& commandLines,
const char* comment);
+ bool AppendCustomCommandToOutput(
+ const std::string& output, const std::vector<std::string>& depends,
+ const cmImplicitDependsList& implicit_depends,
+ const cmCustomCommandLines& commandLines);
/**
* Add a define flag to the build.
@@ -219,14 +243,6 @@ public:
* Add a utility to the build. A utility target is a command that
* is run every time the target is built.
*/
- cmTarget* AddUtilityCommand(const std::string& utilityName,
- TargetOrigin origin, bool excludeFromAll,
- const std::vector<std::string>& depends,
- const char* workingDirectory,
- const char* command, const char* arg1 = nullptr,
- const char* arg2 = nullptr,
- const char* arg3 = nullptr,
- const char* arg4 = nullptr);
cmTarget* AddUtilityCommand(
const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& depends,
@@ -687,10 +703,19 @@ public:
}
/**
- * Is there a source file that has the provided source file as an output?
- * if so then return it
+ * Return the target if the provided source name is a byproduct of a utility
+ * target or a PRE_BUILD, PRE_LINK, or POST_BUILD command.
+ * Return the source file which has the provided source name as output.
*/
- cmSourceFile* GetSourceFileWithOutput(const std::string& outName) const;
+ cmSourcesWithOutput GetSourcesWithOutput(const std::string& name) const;
+
+ /**
+ * Is there a source file that has the provided source name as an output?
+ * If so then return it.
+ */
+ cmSourceFile* GetSourceFileWithOutput(
+ const std::string& name,
+ cmSourceOutputKind kind = cmSourceOutputKind::OutputOnly) const;
//! Add a new cmTest to the list of tests for this makefile.
cmTest* CreateTest(const std::string& testName);
@@ -914,6 +939,9 @@ protected:
mutable cmTargetMap Targets;
std::map<std::string, std::string> AliasTargets;
+ using TargetsVec = std::vector<cmTarget*>;
+ TargetsVec OrderedTargets;
+
using SourceFileVec = std::vector<cmSourceFile*>;
SourceFileVec SourceFiles;
@@ -1036,21 +1064,37 @@ private:
cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
/**
- * 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 std::string&).
+ * See LinearGetSourceFileWithOutput for background information
+ */
+ cmTarget* LinearGetTargetWithOutput(const std::string& name) const;
+
+ /**
+ * Generalized old version of GetSourceFileWithOutput kept for
+ * backward-compatibility. It implements a linear search and supports
+ * relative file paths. It is used as a fall back by GetSourceFileWithOutput
+ * and GetSourcesWithOutput.
*/
- cmSourceFile* LinearGetSourceFileWithOutput(const std::string& cname) const;
+ cmSourceFile* LinearGetSourceFileWithOutput(const std::string& name,
+ cmSourceOutputKind kind,
+ bool& byproduct) const;
+
+ struct SourceEntry
+ {
+ cmSourcesWithOutput Sources;
+ };
// A map for fast output to input look up.
- using OutputToSourceMap = std::unordered_map<std::string, cmSourceFile*>;
+ using OutputToSourceMap = std::unordered_map<std::string, SourceEntry>;
OutputToSourceMap OutputToSource;
+ void UpdateOutputToSourceMap(std::vector<std::string> const& byproducts,
+ cmTarget* target);
+ void UpdateOutputToSourceMap(std::string const& byproduct, cmTarget* target);
+
void UpdateOutputToSourceMap(std::vector<std::string> const& outputs,
- cmSourceFile* source);
- void UpdateOutputToSourceMap(std::string const& output,
- cmSourceFile* source);
+ cmSourceFile* source, bool byproduct);
+ void UpdateOutputToSourceMap(std::string const& output, cmSourceFile* source,
+ bool byproduct);
bool AddRequiredTargetCFeature(cmTarget* target, const std::string& feature,
std::string* error = nullptr) const;
diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx
index 6d71a6d..b37a933 100644
--- a/Source/cmMakefileLibraryTargetGenerator.cxx
+++ b/Source/cmMakefileLibraryTargetGenerator.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileLibraryTargetGenerator.h"
+#include <cstddef>
#include <set>
#include <sstream>
-#include <stddef.h>
#include <utility>
#include <vector>
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 1f6986b..477badd 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmMakefileTargetGenerator.h"
+#include <cstdio>
#include <memory>
#include <sstream>
-#include <stdio.h>
#include <utility>
#include "cmAlgorithms.h"
diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx
index 83c22aa..4ea3638 100644
--- a/Source/cmMathCommand.cxx
+++ b/Source/cmMathCommand.cxx
@@ -8,7 +8,7 @@
#include "cmMessageType.h"
#include "cm_kwiml.h"
-#include <stdio.h>
+#include <cstdio>
namespace {
bool HandleExprCommand(std::vector<std::string> const& args,
diff --git a/Source/cmNewLineStyle.cxx b/Source/cmNewLineStyle.cxx
index 1ff741e..a121332 100644
--- a/Source/cmNewLineStyle.cxx
+++ b/Source/cmNewLineStyle.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmNewLineStyle.h"
-#include <stddef.h>
+#include <cstddef>
cmNewLineStyle::cmNewLineStyle() = default;
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index bc2506e..97742c1 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -3,7 +3,7 @@
#include "cmNinjaNormalTargetGenerator.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <iterator>
#include <map>
#include <set>
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 90b59e7..37e9e0e 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -5,7 +5,7 @@
#include "cm_jsoncpp_value.h"
#include "cm_jsoncpp_writer.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <iterator>
#include <map>
#include <ostream>
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index c8cac3b..e1267ec 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -11,7 +11,7 @@
#include "cmake.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <functional>
#include <sstream>
#include <vector>
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index bf516e3..e602a6d 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -3,8 +3,8 @@
#include "cmOutputConverter.h"
#include <algorithm>
-#include <assert.h>
-#include <ctype.h>
+#include <cassert>
+#include <cctype>
#include <set>
#include <vector>
diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx
index 2f4e003..d9a433d 100644
--- a/Source/cmOutputRequiredFilesCommand.cxx
+++ b/Source/cmOutputRequiredFilesCommand.cxx
@@ -4,9 +4,9 @@
#include "cmsys/FStream.hxx"
#include "cmsys/RegularExpression.hxx"
+#include <cstdio>
#include <map>
#include <set>
-#include <stdio.h>
#include <utility>
#include "cmAlgorithms.h"
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index d33cd32..c8bc56d 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -8,11 +8,11 @@
#include "cmSystemTools.h"
#include "cmVersion.h"
-#include <assert.h>
-#include <ctype.h>
+#include <cassert>
+#include <cctype>
+#include <cstdio>
+#include <cstring>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
#include <vector>
static bool stringToId(const char* input, cmPolicies::PolicyID& pid)
diff --git a/Source/cmProcessOutput.h b/Source/cmProcessOutput.h
index 400354c..3db47a4 100644
--- a/Source/cmProcessOutput.h
+++ b/Source/cmProcessOutput.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stddef.h>
+#include <cstddef>
#include <string>
#include <vector>
diff --git a/Source/cmProcessTools.h b/Source/cmProcessTools.h
index c205a8f..7d97e36 100644
--- a/Source/cmProcessTools.h
+++ b/Source/cmProcessTools.h
@@ -6,8 +6,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmProcessOutput.h"
+#include <cstring>
#include <iosfwd>
-#include <string.h>
#include <string>
/** \class cmProcessTools
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index ba82813..cc4df8f 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -3,44 +3,41 @@
#include "cmQTWrapCPPCommand.h"
#include "cmCustomCommandLines.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <utility>
-
-class cmExecutionStatus;
-
-// cmQTWrapCPPCommand
-bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 3) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Get the moc executable to run in the custom command.
- std::string const& moc_exe =
- this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
+ std::string const& moc_exe = mf.GetRequiredDefinition("QT_MOC_EXECUTABLE");
// Get the variable holding the list of sources.
std::string const& sourceList = args[1];
- std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
+ std::string sourceListValue = mf.GetSafeDefinition(sourceList);
// Create a rule for all sources listed.
for (std::string const& arg : cmMakeRange(args).advance(2)) {
- cmSourceFile* curr = this->Makefile->GetSource(arg);
+ cmSourceFile* curr = mf.GetSource(arg);
// if we should wrap the class
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
// Compute the name of the file to generate.
std::string srcName =
cmSystemTools::GetFilenameWithoutLastExtension(arg);
- std::string newName = cmStrCat(
- this->Makefile->GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
- cmSourceFile* sf = this->Makefile->GetOrCreateSource(newName, true);
+ std::string newName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
+ cmSourceFile* sf = mf.GetOrCreateSource(newName, true);
if (curr) {
sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
}
@@ -51,9 +48,9 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
hname = arg;
} else {
if (curr && curr->GetIsGenerated()) {
- hname = this->Makefile->GetCurrentBinaryDirectory();
+ hname = mf.GetCurrentBinaryDirectory();
} else {
- hname = this->Makefile->GetCurrentSourceDirectory();
+ hname = mf.GetCurrentSourceDirectory();
}
hname += "/";
hname += arg;
@@ -66,14 +63,8 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
sourceListValue += newName;
// Create the custom command to generate the file.
- cmCustomCommandLine commandLine;
- commandLine.push_back(moc_exe);
- commandLine.push_back("-o");
- commandLine.push_back(newName);
- commandLine.push_back(hname);
-
- cmCustomCommandLines commandLines;
- commandLines.push_back(std::move(commandLine));
+ cmCustomCommandLines commandLines =
+ cmMakeSingleCommandLine({ moc_exe, "-o", newName, hname });
std::vector<std::string> depends;
depends.push_back(moc_exe);
@@ -81,13 +72,13 @@ bool cmQTWrapCPPCommand::InitialPass(std::vector<std::string> const& args,
std::string no_main_dependency;
const char* no_working_dir = nullptr;
- this->Makefile->AddCustomCommandToOutput(
- newName, depends, no_main_dependency, commandLines, "Qt Wrapped File",
- no_working_dir);
+ mf.AddCustomCommandToOutput(newName, depends, no_main_dependency,
+ commandLines, "Qt Wrapped File",
+ no_working_dir);
}
}
// Store the final list of source files.
- this->Makefile->AddDefinition(sourceList, sourceListValue);
+ mf.AddDefinition(sourceList, sourceListValue);
return true;
}
diff --git a/Source/cmQTWrapCPPCommand.h b/Source/cmQTWrapCPPCommand.h
index 88a2210..75fa180 100644
--- a/Source/cmQTWrapCPPCommand.h
+++ b/Source/cmQTWrapCPPCommand.h
@@ -8,35 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmQTWrapCPPCommand
- * \brief Create moc file rules for Qt classes
- *
- * cmQTWrapCPPCommand is used to create wrappers for Qt classes into
- * normal C++
- */
-class cmQTWrapCPPCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmQTWrapCPPCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index 8bc914f..66c0228 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -3,51 +3,47 @@
#include "cmQTWrapUICommand.h"
#include "cmCustomCommandLines.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmRange.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-#include <utility>
-
-class cmExecutionStatus;
-
-// cmQTWrapUICommand
-bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmQTWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 4) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// Get the uic and moc executables to run in the custom commands.
- std::string const& uic_exe =
- this->Makefile->GetRequiredDefinition("QT_UIC_EXECUTABLE");
- std::string const& moc_exe =
- this->Makefile->GetRequiredDefinition("QT_MOC_EXECUTABLE");
+ std::string const& uic_exe = mf.GetRequiredDefinition("QT_UIC_EXECUTABLE");
+ std::string const& moc_exe = mf.GetRequiredDefinition("QT_MOC_EXECUTABLE");
// Get the variable holding the list of sources.
std::string const& headerList = args[1];
std::string const& sourceList = args[2];
- std::string headerListValue = this->Makefile->GetSafeDefinition(headerList);
- std::string sourceListValue = this->Makefile->GetSafeDefinition(sourceList);
+ std::string headerListValue = mf.GetSafeDefinition(headerList);
+ std::string sourceListValue = mf.GetSafeDefinition(sourceList);
// Create rules for all sources listed.
for (std::string const& arg : cmMakeRange(args).advance(3)) {
- cmSourceFile* curr = this->Makefile->GetSource(arg);
+ cmSourceFile* curr = mf.GetSource(arg);
// if we should wrap the class
if (!(curr && curr->GetPropertyAsBool("WRAP_EXCLUDE"))) {
// Compute the name of the files to generate.
std::string srcName =
cmSystemTools::GetFilenameWithoutLastExtension(arg);
- std::string hName = cmStrCat(this->Makefile->GetCurrentBinaryDirectory(),
- '/', srcName, ".h");
- std::string cxxName = cmStrCat(
- this->Makefile->GetCurrentBinaryDirectory(), '/', srcName, ".cxx");
- std::string mocName = cmStrCat(
- this->Makefile->GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
+ std::string hName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), '/', srcName, ".h");
+ std::string cxxName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), '/', srcName, ".cxx");
+ std::string mocName =
+ cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
// Compute the name of the ui file from which to generate others.
std::string uiName;
@@ -55,9 +51,9 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
uiName = arg;
} else {
if (curr && curr->GetIsGenerated()) {
- uiName = this->Makefile->GetCurrentBinaryDirectory();
+ uiName = mf.GetCurrentBinaryDirectory();
} else {
- uiName = this->Makefile->GetCurrentSourceDirectory();
+ uiName = mf.GetCurrentSourceDirectory();
}
uiName += "/";
uiName += arg;
@@ -78,56 +74,34 @@ bool cmQTWrapUICommand::InitialPass(std::vector<std::string> const& args,
sourceListValue += mocName;
// set up .ui to .h and .cxx command
- cmCustomCommandLine hCommand;
- hCommand.push_back(uic_exe);
- hCommand.push_back("-o");
- hCommand.push_back(hName);
- hCommand.push_back(uiName);
- cmCustomCommandLines hCommandLines;
- hCommandLines.push_back(std::move(hCommand));
-
- cmCustomCommandLine cxxCommand;
- cxxCommand.push_back(uic_exe);
- cxxCommand.push_back("-impl");
- cxxCommand.push_back(hName);
- cxxCommand.push_back("-o");
- cxxCommand.push_back(cxxName);
- cxxCommand.push_back(uiName);
- cmCustomCommandLines cxxCommandLines;
- cxxCommandLines.push_back(std::move(cxxCommand));
-
- cmCustomCommandLine mocCommand;
- mocCommand.push_back(moc_exe);
- mocCommand.push_back("-o");
- mocCommand.push_back(mocName);
- mocCommand.push_back(hName);
- cmCustomCommandLines mocCommandLines;
- mocCommandLines.push_back(std::move(mocCommand));
+ cmCustomCommandLines hCommandLines =
+ cmMakeSingleCommandLine({ uic_exe, "-o", hName, uiName });
+ cmCustomCommandLines cxxCommandLines = cmMakeSingleCommandLine(
+ { uic_exe, "-impl", hName, "-o", cxxName, uiName });
+ cmCustomCommandLines mocCommandLines =
+ cmMakeSingleCommandLine({ moc_exe, "-o", mocName, hName });
std::vector<std::string> depends;
depends.push_back(uiName);
std::string no_main_dependency;
const char* no_comment = nullptr;
const char* no_working_dir = nullptr;
- this->Makefile->AddCustomCommandToOutput(
- hName, depends, no_main_dependency, hCommandLines, no_comment,
- no_working_dir);
+ mf.AddCustomCommandToOutput(hName, depends, no_main_dependency,
+ hCommandLines, no_comment, no_working_dir);
depends.push_back(hName);
- this->Makefile->AddCustomCommandToOutput(
- cxxName, depends, no_main_dependency, cxxCommandLines, no_comment,
- no_working_dir);
+ mf.AddCustomCommandToOutput(cxxName, depends, no_main_dependency,
+ cxxCommandLines, no_comment, no_working_dir);
depends.clear();
depends.push_back(hName);
- this->Makefile->AddCustomCommandToOutput(
- mocName, depends, no_main_dependency, mocCommandLines, no_comment,
- no_working_dir);
+ mf.AddCustomCommandToOutput(mocName, depends, no_main_dependency,
+ mocCommandLines, no_comment, no_working_dir);
}
}
// Store the final list of source files and headers.
- this->Makefile->AddDefinition(sourceList, sourceListValue);
- this->Makefile->AddDefinition(headerList, headerListValue);
+ mf.AddDefinition(sourceList, sourceListValue);
+ mf.AddDefinition(headerList, headerListValue);
return true;
}
diff --git a/Source/cmQTWrapUICommand.h b/Source/cmQTWrapUICommand.h
index 6a346d4..a17ef54 100644
--- a/Source/cmQTWrapUICommand.h
+++ b/Source/cmQTWrapUICommand.h
@@ -8,34 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmQTWrapUICommand
- * \brief Create .h and .cxx files rules for Qt user interfaces files
- *
- * cmQTWrapUICommand is used to create wrappers for Qt classes into normal C++
- */
-class cmQTWrapUICommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmQTWrapUICommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmQTWrapUICommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index d6916b0..355141e 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -957,16 +957,9 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
}
// Compose command lines
- cmCustomCommandLines commandLines;
- {
- cmCustomCommandLine currentLine;
- currentLine.push_back(cmSystemTools::GetCMakeCommand());
- currentLine.push_back("-E");
- currentLine.push_back("cmake_autogen");
- currentLine.push_back(this->AutogenTarget.InfoFile);
- currentLine.push_back("$<CONFIGURATION>");
- commandLines.push_back(std::move(currentLine));
- }
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), "-E", "cmake_autogen",
+ this->AutogenTarget.InfoFile, "$<CONFIGURATION>" });
// Use PRE_BUILD on demand
bool usePRE_BUILD = false;
@@ -1100,22 +1093,14 @@ bool cmQtAutoGenInitializer::InitRccTargets()
if (this->MultiConfig) {
// Build for all configurations
for (std::string const& config : this->ConfigsList) {
- cmCustomCommandLine currentLine;
- currentLine.push_back(cmSystemTools::GetCMakeCommand());
- currentLine.push_back("-E");
- currentLine.push_back("cmake_autorcc");
- currentLine.push_back(qrc.InfoFile);
- currentLine.push_back(config);
- commandLines.push_back(std::move(currentLine));
+ commandLines.push_back(
+ cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E",
+ "cmake_autorcc", qrc.InfoFile, config }));
}
} else {
- cmCustomCommandLine currentLine;
- currentLine.push_back(cmSystemTools::GetCMakeCommand());
- currentLine.push_back("-E");
- currentLine.push_back("cmake_autorcc");
- currentLine.push_back(qrc.InfoFile);
- currentLine.push_back("$<CONFIG>");
- commandLines.push_back(std::move(currentLine));
+ commandLines.push_back(
+ cmMakeCommandLine({ cmSystemTools::GetCMakeCommand(), "-E",
+ "cmake_autorcc", qrc.InfoFile, "$<CONFIG>" }));
}
std::string ccComment = cmStrCat(
"Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile));
@@ -1166,10 +1151,12 @@ bool cmQtAutoGenInitializer::InitRccTargets()
if (!this->Rcc.ExecutableTargetName.empty()) {
ccDepends.push_back(this->Rcc.ExecutableTargetName);
}
- makefile->AddCustomCommandToOutput(ccOutput, ccByproducts, ccDepends,
- /*main_dependency*/ std::string(),
- commandLines, ccComment.c_str(),
- this->Dir.Work.c_str());
+ std::string no_main_dependency;
+ cmImplicitDependsList no_implicit_depends;
+ makefile->AddCustomCommandToOutput(
+ ccOutput, ccByproducts, ccDepends, no_main_dependency,
+ no_implicit_depends, commandLines, ccComment.c_str(),
+ this->Dir.Work.c_str());
}
// Reconfigure when .qrc file changes
makefile->AddCMakeDependFile(qrc.QrcFile);
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index aa394e5..edbb3de 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -10,9 +10,9 @@
#include "cmsys/FStream.hxx"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
+#include <cstddef>
#include <iterator>
-#include <stddef.h>
#include <utility>
cmRST::cmRST(std::ostream& os, std::string docroot)
diff --git a/Source/cmRemoveDefinitionsCommand.cxx b/Source/cmRemoveDefinitionsCommand.cxx
index 8d3f688..339ff9d 100644
--- a/Source/cmRemoveDefinitionsCommand.cxx
+++ b/Source/cmRemoveDefinitionsCommand.cxx
@@ -2,21 +2,15 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRemoveDefinitionsCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
-class cmExecutionStatus;
-
-// cmRemoveDefinitionsCommand
-bool cmRemoveDefinitionsCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmRemoveDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
- // it is OK to have no arguments
- if (args.empty()) {
- return true;
- }
-
+ cmMakefile& mf = status.GetMakefile();
for (std::string const& i : args) {
- this->Makefile->RemoveDefineFlag(i);
+ mf.RemoveDefineFlag(i);
}
return true;
}
diff --git a/Source/cmRemoveDefinitionsCommand.h b/Source/cmRemoveDefinitionsCommand.h
index 85d01d4..868416b 100644
--- a/Source/cmRemoveDefinitionsCommand.h
+++ b/Source/cmRemoveDefinitionsCommand.h
@@ -8,36 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmRemoveDefinitionsCommand
- * \brief Specify a list of compiler defines
- *
- * cmRemoveDefinitionsCommand specifies a list of compiler defines.
- * These defines will
- * be removed from the compile command.
- */
-class cmRemoveDefinitionsCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmRemoveDefinitionsCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmRemoveDefinitionsCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index 6c954a6..0a1d109 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRulePlaceholderExpander.h"
-#include <ctype.h>
-#include <string.h>
+#include <cctype>
+#include <cstring>
#include <utility>
#include "cmOutputConverter.h"
diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx
index 8e3217f..7ff604b 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.cxx
+++ b/Source/cmSetSourceFilesPropertiesCommand.cxx
@@ -2,18 +2,23 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSetSourceFilesPropertiesCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmSourceFile.h"
#include "cmStringAlgorithms.h"
-class cmExecutionStatus;
+static bool RunCommand(cmMakefile* mf,
+ std::vector<std::string>::const_iterator filebeg,
+ std::vector<std::string>::const_iterator fileend,
+ std::vector<std::string>::const_iterator propbeg,
+ std::vector<std::string>::const_iterator propend,
+ std::string& errors);
-// cmSetSourceFilesPropertiesCommand
-bool cmSetSourceFilesPropertiesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.size() < 2) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
@@ -29,22 +34,24 @@ bool cmSetSourceFilesPropertiesCommand::InitialPass(
++j;
}
+ cmMakefile& mf = status.GetMakefile();
+
// now call the worker function
std::string errors;
- bool ret = cmSetSourceFilesPropertiesCommand::RunCommand(
- this->Makefile, args.begin(), args.begin() + numFiles,
- args.begin() + numFiles, args.end(), errors);
+ bool ret = RunCommand(&mf, args.begin(), args.begin() + numFiles,
+ args.begin() + numFiles, args.end(), errors);
if (!ret) {
- this->SetError(errors);
+ status.SetError(errors);
}
return ret;
}
-bool cmSetSourceFilesPropertiesCommand::RunCommand(
- cmMakefile* mf, std::vector<std::string>::const_iterator filebeg,
- std::vector<std::string>::const_iterator fileend,
- std::vector<std::string>::const_iterator propbeg,
- std::vector<std::string>::const_iterator propend, std::string& errors)
+static bool RunCommand(cmMakefile* mf,
+ std::vector<std::string>::const_iterator filebeg,
+ std::vector<std::string>::const_iterator fileend,
+ std::vector<std::string>::const_iterator propbeg,
+ std::vector<std::string>::const_iterator propend,
+ std::string& errors)
{
std::vector<std::string> propertyPairs;
bool generated = false;
diff --git a/Source/cmSetSourceFilesPropertiesCommand.h b/Source/cmSetSourceFilesPropertiesCommand.h
index 6fd6c41..5eef785 100644
--- a/Source/cmSetSourceFilesPropertiesCommand.h
+++ b/Source/cmSetSourceFilesPropertiesCommand.h
@@ -8,34 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetSourceFilesPropertiesCommand : public cmCommand
-{
-public:
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmSetSourceFilesPropertiesCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
- static bool RunCommand(cmMakefile* mf,
- std::vector<std::string>::const_iterator filebeg,
- std::vector<std::string>::const_iterator fileend,
- std::vector<std::string>::const_iterator propbeg,
- std::vector<std::string>::const_iterator propend,
- std::string& errors);
-};
+bool cmSetSourceFilesPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSetTestsPropertiesCommand.cxx b/Source/cmSetTestsPropertiesCommand.cxx
index ed909c6..de61eda 100644
--- a/Source/cmSetTestsPropertiesCommand.cxx
+++ b/Source/cmSetTestsPropertiesCommand.cxx
@@ -5,21 +5,25 @@
#include <iterator>
#include "cmAlgorithms.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmTest.h"
-class cmExecutionStatus;
+static bool SetOneTest(const std::string& tname,
+ std::vector<std::string>& propertyPairs, cmMakefile* mf,
+ std::string& errors);
-// cmSetTestsPropertiesCommand
-bool cmSetTestsPropertiesCommand::InitialPass(
- std::vector<std::string> const& args, cmExecutionStatus&)
+bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
+ cmMakefile& mf = status.GetMakefile();
+
// first collect up the list of files
std::vector<std::string> propertyPairs;
int numFiles = 0;
@@ -29,7 +33,7 @@ bool cmSetTestsPropertiesCommand::InitialPass(
// now loop through the rest of the arguments, new style
++j;
if (std::distance(j, args.end()) % 2 != 0) {
- this->SetError("called with incorrect number of arguments.");
+ status.SetError("called with incorrect number of arguments.");
return false;
}
cmAppend(propertyPairs, j, args.end());
@@ -38,8 +42,8 @@ bool cmSetTestsPropertiesCommand::InitialPass(
numFiles++;
}
if (propertyPairs.empty()) {
- this->SetError("called with illegal arguments, maybe "
- "missing a PROPERTIES specifier?");
+ status.SetError("called with illegal arguments, maybe "
+ "missing a PROPERTIES specifier?");
return false;
}
@@ -47,10 +51,9 @@ bool cmSetTestsPropertiesCommand::InitialPass(
int i;
for (i = 0; i < numFiles; ++i) {
std::string errors;
- bool ret = cmSetTestsPropertiesCommand::SetOneTest(args[i], propertyPairs,
- this->Makefile, errors);
+ bool ret = SetOneTest(args[i], propertyPairs, &mf, errors);
if (!ret) {
- this->SetError(errors);
+ status.SetError(errors);
return ret;
}
}
@@ -58,9 +61,9 @@ bool cmSetTestsPropertiesCommand::InitialPass(
return true;
}
-bool cmSetTestsPropertiesCommand::SetOneTest(
- const std::string& tname, std::vector<std::string>& propertyPairs,
- cmMakefile* mf, std::string& errors)
+static bool SetOneTest(const std::string& tname,
+ std::vector<std::string>& propertyPairs, cmMakefile* mf,
+ std::string& errors)
{
if (cmTest* test = mf->GetTest(tname)) {
// now loop through all the props and set them
diff --git a/Source/cmSetTestsPropertiesCommand.h b/Source/cmSetTestsPropertiesCommand.h
index d73e95a..4b75464 100644
--- a/Source/cmSetTestsPropertiesCommand.h
+++ b/Source/cmSetTestsPropertiesCommand.h
@@ -8,31 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-class cmMakefile;
-
-class cmSetTestsPropertiesCommand : public cmCommand
-{
-public:
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmSetTestsPropertiesCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the input file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
- static bool SetOneTest(const std::string& tname,
- std::vector<std::string>& propertyPairs,
- cmMakefile* mf, std::string& errors);
-};
+bool cmSetTestsPropertiesCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index 4deb94a..3344217 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -5,7 +5,6 @@
#include <array>
#include <utility>
-#include "cmCustomCommand.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -21,11 +20,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name,
{
}
-cmSourceFile::~cmSourceFile()
-{
- this->SetCustomCommand(nullptr);
-}
-
std::string const& cmSourceFile::GetExtension() const
{
return this->Extension;
@@ -320,19 +314,12 @@ bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
return cmIsOn(this->GetProperty(prop));
}
-cmCustomCommand* cmSourceFile::GetCustomCommand()
-{
- return this->CustomCommand;
-}
-
-cmCustomCommand const* cmSourceFile::GetCustomCommand() const
+cmCustomCommand* cmSourceFile::GetCustomCommand() const
{
- return this->CustomCommand;
+ return this->CustomCommand.get();
}
-void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
+void cmSourceFile::SetCustomCommand(std::unique_ptr<cmCustomCommand> cc)
{
- cmCustomCommand* old = this->CustomCommand;
- this->CustomCommand = cc;
- delete old;
+ this->CustomCommand = std::move(cc);
}
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index 774cb28..dd36d45 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -5,14 +5,15 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include "cmCustomCommand.h"
#include "cmPropertyMap.h"
#include "cmSourceFileLocation.h"
#include "cmSourceFileLocationKind.h"
+#include <memory>
#include <string>
#include <vector>
-class cmCustomCommand;
class cmMakefile;
/** \class cmSourceFile
@@ -32,17 +33,11 @@ public:
cmMakefile* mf, const std::string& name,
cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
- ~cmSourceFile();
-
- cmSourceFile(const cmSourceFile&) = delete;
- cmSourceFile& operator=(const cmSourceFile&) = delete;
-
/**
- * Get the list of the custom commands for this source file
+ * Get the custom command for this source file
*/
- cmCustomCommand* GetCustomCommand();
- cmCustomCommand const* GetCustomCommand() const;
- void SetCustomCommand(cmCustomCommand* cc);
+ cmCustomCommand* GetCustomCommand() const;
+ void SetCustomCommand(std::unique_ptr<cmCustomCommand> cc);
//! Set/Get a property of this source file
void SetProperty(const std::string& prop, const char* value);
@@ -114,7 +109,7 @@ public:
private:
cmSourceFileLocation Location;
cmPropertyMap Properties;
- cmCustomCommand* CustomCommand = nullptr;
+ std::unique_ptr<cmCustomCommand> CustomCommand;
std::string Extension;
std::string Language;
std::string FullPath;
diff --git a/Source/cmSourceFileLocation.cxx b/Source/cmSourceFileLocation.cxx
index 0e8d09d..bd75c14 100644
--- a/Source/cmSourceFileLocation.cxx
+++ b/Source/cmSourceFileLocation.cxx
@@ -9,7 +9,7 @@
#include "cmSystemTools.h"
#include "cmake.h"
-#include <assert.h>
+#include <cassert>
cmSourceFileLocation::cmSourceFileLocation() = default;
diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx
index c239a1f..3be7fec 100644
--- a/Source/cmSourceGroupCommand.cxx
+++ b/Source/cmSourceGroupCommand.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSourceGroupCommand.h"
+#include <cstddef>
#include <set>
-#include <stddef.h>
#include <utility>
#include "cmAlgorithms.h"
diff --git a/Source/cmState.cxx b/Source/cmState.cxx
index 751eb77..7463bf8 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -4,9 +4,9 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
+#include <cassert>
+#include <cstdlib>
+#include <cstring>
#include <utility>
#include "cm_memory.hxx"
diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx
index c14bf4a..ede00a0 100644
--- a/Source/cmStateDirectory.cxx
+++ b/Source/cmStateDirectory.cxx
@@ -4,7 +4,7 @@
#include "cmStateDirectory.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <iterator>
#include <vector>
diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx
index b3e33ea..28d5170 100644
--- a/Source/cmStateSnapshot.cxx
+++ b/Source/cmStateSnapshot.cxx
@@ -4,7 +4,7 @@
#include "cmStateSnapshot.h"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
#include <iterator>
#include <string>
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index 131a01e..bb6dcd7 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -3,10 +3,10 @@
#include "cmStringAlgorithms.h"
#include <algorithm>
+#include <cerrno>
#include <cstddef>
#include <cstdio>
-#include <errno.h>
-#include <stdlib.h>
+#include <cstdlib>
std::string cmTrimWhitespace(cm::string_view str)
{
diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h
index 7f442d8..cb6b8ba 100644
--- a/Source/cmStringAlgorithms.h
+++ b/Source/cmStringAlgorithms.h
@@ -8,9 +8,9 @@
#include "cmRange.h"
#include "cm_string_view.hxx"
#include <cctype>
+#include <cstring>
#include <initializer_list>
#include <sstream>
-#include <string.h>
#include <string>
#include <utility>
#include <vector>
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index 9a2de9d..ab670ca 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -6,12 +6,12 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <ctype.h>
+#include <cctype>
+#include <cstdio>
+#include <cstdlib>
#include <iterator>
#include <memory>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include "cm_static_string_view.hxx"
diff --git a/Source/cmSubdirCommand.cxx b/Source/cmSubdirCommand.cxx
index 07f8efe..2477d7a 100644
--- a/Source/cmSubdirCommand.cxx
+++ b/Source/cmSubdirCommand.cxx
@@ -2,22 +2,21 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmSubdirCommand.h"
+#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-class cmExecutionStatus;
-
-// cmSubdirCommand
-bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus&)
+bool cmSubdirCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status)
{
if (args.empty()) {
- this->SetError("called with incorrect number of arguments");
+ status.SetError("called with incorrect number of arguments");
return false;
}
bool res = true;
bool excludeFromAll = false;
+ cmMakefile& mf = status.GetMakefile();
for (std::string const& i : args) {
if (i == "EXCLUDE_FROM_ALL") {
@@ -30,24 +29,21 @@ bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
}
// if they specified a relative path then compute the full
- std::string srcPath =
- this->Makefile->GetCurrentSourceDirectory() + "/" + i;
+ std::string srcPath = mf.GetCurrentSourceDirectory() + "/" + i;
if (cmSystemTools::FileIsDirectory(srcPath)) {
- std::string binPath =
- this->Makefile->GetCurrentBinaryDirectory() + "/" + i;
- this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
+ std::string binPath = mf.GetCurrentBinaryDirectory() + "/" + i;
+ mf.AddSubDirectory(srcPath, binPath, excludeFromAll, false);
}
// otherwise it is a full path
else if (cmSystemTools::FileIsDirectory(i)) {
// we must compute the binPath from the srcPath, we just take the last
// element from the source path and use that
- std::string binPath = this->Makefile->GetCurrentBinaryDirectory() + "/" +
+ std::string binPath = mf.GetCurrentBinaryDirectory() + "/" +
cmSystemTools::GetFilenameName(i);
- this->Makefile->AddSubDirectory(i, binPath, excludeFromAll, false);
+ mf.AddSubDirectory(i, binPath, excludeFromAll, false);
} else {
- std::string error = cmStrCat("Incorrect SUBDIRS command. Directory: ", i,
- " does not exist.");
- this->SetError(error);
+ status.SetError(cmStrCat("Incorrect SUBDIRS command. Directory: ", i,
+ " does not exist."));
res = false;
}
}
diff --git a/Source/cmSubdirCommand.h b/Source/cmSubdirCommand.h
index 3499c46..3254e84 100644
--- a/Source/cmSubdirCommand.h
+++ b/Source/cmSubdirCommand.h
@@ -8,36 +8,9 @@
#include <string>
#include <vector>
-#include "cm_memory.hxx"
-
-#include "cmCommand.h"
-
class cmExecutionStatus;
-/** \class cmSubdirCommand
- * \brief Specify a list of subdirectories to build.
- *
- * cmSubdirCommand specifies a list of subdirectories to process
- * by CMake. For each subdirectory listed, CMake will descend
- * into that subdirectory and process any CMakeLists.txt found.
- */
-class cmSubdirCommand : public cmCommand
-{
-public:
- /**
- * This is a virtual constructor for the command.
- */
- std::unique_ptr<cmCommand> Clone() override
- {
- return cm::make_unique<cmSubdirCommand>();
- }
-
- /**
- * This is called when the command is first encountered in
- * the CMakeLists.txt file.
- */
- bool InitialPass(std::vector<std::string> const& args,
- cmExecutionStatus& status) override;
-};
+bool cmSubdirCommand(std::vector<std::string> const& args,
+ cmExecutionStatus& status);
#endif
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 86af683..62a8d8f 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -40,16 +40,16 @@
#include "cmsys/System.h"
#include "cmsys/Terminal.h"
#include <algorithm>
-#include <assert.h>
-#include <ctype.h>
-#include <errno.h>
+#include <cassert>
+#include <cctype>
+#include <cerrno>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <fcntl.h>
#include <iostream>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
#include <utility>
#include <vector>
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index 8ca4939..e7eef33 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -11,8 +11,8 @@
#include "cm_string_view.hxx"
#include "cmsys/Process.h"
#include "cmsys/SystemTools.hxx" // IWYU pragma: export
+#include <cstddef>
#include <functional>
-#include <stddef.h>
#include <string>
#include <vector>
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 2420810..e65fb25 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -4,12 +4,12 @@
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
-#include <assert.h>
+#include <cassert>
+#include <cstring>
#include <initializer_list>
#include <iterator>
#include <set>
#include <sstream>
-#include <string.h>
#include <unordered_set>
#include "cm_memory.hxx"
@@ -1085,6 +1085,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
MAKE_STATIC_PROP(COMPILE_FEATURES);
MAKE_STATIC_PROP(COMPILE_OPTIONS);
MAKE_STATIC_PROP(PRECOMPILE_HEADERS);
+ MAKE_STATIC_PROP(PRECOMPILE_HEADERS_REUSE_FROM);
MAKE_STATIC_PROP(CUDA_PTX_COMPILATION);
MAKE_STATIC_PROP(EXPORT_NAME);
MAKE_STATIC_PROP(IMPORTED_GLOBAL);
@@ -1231,6 +1232,41 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
<< impl->Name << "\")\n";
impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
return;
+ } else if (prop == propPRECOMPILE_HEADERS_REUSE_FROM) {
+ if (this->GetProperty("PRECOMPILE_HEADERS")) {
+ std::ostringstream e;
+ e << "PRECOMPILE_HEADERS property is already set on target (\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
+ auto reusedTarget =
+ impl->Makefile->GetCMakeInstance()->GetGlobalGenerator()->FindTarget(
+ value);
+ if (!reusedTarget) {
+ const std::string e(
+ "PRECOMPILE_HEADERS_REUSE_FROM set with non existing target");
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e);
+ return;
+ }
+
+ std::string reusedFrom = reusedTarget->GetSafeProperty(prop);
+ if (reusedFrom.empty()) {
+ reusedFrom = value;
+ }
+
+ impl->Properties.SetProperty(prop, reusedFrom.c_str());
+
+ reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom.c_str());
+ reusedTarget->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
+ cmStrCat(reusedFrom, ".dir/").c_str());
+
+ for (auto p : { "COMPILE_PDB_NAME", "PRECOMPILE_HEADERS",
+ "INTERFACE_PRECOMPILE_HEADERS" }) {
+ this->SetProperty(p, reusedTarget->GetProperty(p));
+ }
+
+ this->AddUtility(reusedFrom, impl->Makefile);
} else {
impl->Properties.SetProperty(prop, value);
}
@@ -1308,6 +1344,14 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
impl->LinkDirectoriesBacktraces.push_back(lfbt);
}
} else if (prop == "PRECOMPILE_HEADERS") {
+ if (this->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM")) {
+ std::ostringstream e;
+ e << "PRECOMPILE_HEADERS_REUSE_FROM property is already set on target "
+ "(\""
+ << impl->Name << "\")\n";
+ impl->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return;
+ }
if (value && *value) {
impl->PrecompileHeadersEntries.emplace_back(value);
cmListFileBacktrace lfbt = impl->Makefile->GetBacktrace();
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 4fbec90..237d90c 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -2,8 +2,8 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkLibrariesCommand.h"
+#include <cstring>
#include <sstream>
-#include <string.h>
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx
index 30cf1be..97f1bea 100644
--- a/Source/cmTargetPrecompileHeadersCommand.cxx
+++ b/Source/cmTargetPrecompileHeadersCommand.cxx
@@ -10,7 +10,7 @@
bool cmTargetPrecompileHeadersCommand::InitialPass(
std::vector<std::string> const& args, cmExecutionStatus&)
{
- return this->HandleArguments(args, "PRECOMPILE_HEADERS");
+ return this->HandleArguments(args, "PRECOMPILE_HEADERS", PROCESS_REUSE_FROM);
}
void cmTargetPrecompileHeadersCommand::HandleMissingTarget(
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index 3aa845c..4bc3125 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -65,6 +65,19 @@ bool cmTargetPropCommandBase::HandleArguments(
++argIndex;
}
+ if ((flags & PROCESS_REUSE_FROM) && args[argIndex] == "REUSE_FROM") {
+ if (args.size() != 3) {
+ this->SetError("called with incorrect number of arguments");
+ return false;
+ }
+ ++argIndex;
+
+ this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM",
+ args[argIndex].c_str());
+
+ ++argIndex;
+ }
+
this->Property = prop;
while (argIndex < args.size()) {
diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h
index 943285d..b244417 100644
--- a/Source/cmTargetPropCommandBase.h
+++ b/Source/cmTargetPropCommandBase.h
@@ -17,9 +17,10 @@ class cmTargetPropCommandBase : public cmCommand
public:
enum ArgumentFlags
{
- NO_FLAGS = 0,
- PROCESS_BEFORE = 1,
- PROCESS_SYSTEM = 2
+ NO_FLAGS = 0x0,
+ PROCESS_BEFORE = 0x1,
+ PROCESS_SYSTEM = 0x2,
+ PROCESS_REUSE_FROM = 0x3
};
bool HandleArguments(std::vector<std::string> const& args,
diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx
index a9be729..390fd16 100644
--- a/Source/cmTimestamp.cxx
+++ b/Source/cmTimestamp.cxx
@@ -2,9 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTimestamp.h"
+#include <cstdlib>
#include <cstring>
#include <sstream>
-#include <stdlib.h>
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
diff --git a/Source/cmTimestamp.h b/Source/cmTimestamp.h
index d5fbdfd..40338f8 100644
--- a/Source/cmTimestamp.h
+++ b/Source/cmTimestamp.h
@@ -5,8 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <ctime>
#include <string>
-#include <time.h>
/** \class cmTimestamp
* \brief Utility class to generate string representation of a timestamp
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx
index 24d0f0f..73354ec 100644
--- a/Source/cmTryRunCommand.cxx
+++ b/Source/cmTryRunCommand.cxx
@@ -3,7 +3,7 @@
#include "cmTryRunCommand.h"
#include "cmsys/FStream.hxx"
-#include <stdio.h>
+#include <cstdio>
#include "cmDuration.h"
#include "cmMakefile.h"
diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx
index 97c27cb..23dabb7 100644
--- a/Source/cmUVHandlePtr.cxx
+++ b/Source/cmUVHandlePtr.cxx
@@ -3,9 +3,9 @@
#define cmUVHandlePtr_cxx
#include "cmUVHandlePtr.h"
-#include <assert.h>
+#include <cassert>
+#include <cstdlib>
#include <mutex>
-#include <stdlib.h>
#include "cm_uv.h"
diff --git a/Source/cmUVProcessChain.cxx b/Source/cmUVProcessChain.cxx
index 56d6c09..2c37a64 100644
--- a/Source/cmUVProcessChain.cxx
+++ b/Source/cmUVProcessChain.cxx
@@ -7,7 +7,7 @@
#include "cmUVStreambuf.h"
#include "cm_uv.h"
-#include <assert.h>
+#include <cassert>
#include <istream> // IWYU pragma: keep
#include <iterator>
diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h
index 76a9c40..8a19bc3 100644
--- a/Source/cmUVProcessChain.h
+++ b/Source/cmUVProcessChain.h
@@ -7,13 +7,12 @@
#include <array>
#include <cstddef>
+#include <cstdint>
#include <iosfwd>
#include <memory>
#include <string>
#include <vector>
-#include <stdint.h>
-
class cmUVProcessChain;
class cmUVProcessChainBuilder
diff --git a/Source/cmUtilitySourceCommand.cxx b/Source/cmUtilitySourceCommand.cxx
index 6b3590f..a43165c 100644
--- a/Source/cmUtilitySourceCommand.cxx
+++ b/Source/cmUtilitySourceCommand.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmUtilitySourceCommand.h"
-#include <string.h>
+#include <cstring>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx
index 91c8af3..f0f2c51 100644
--- a/Source/cmUuid.cxx
+++ b/Source/cmUuid.cxx
@@ -5,7 +5,7 @@
#include "cmCryptoHash.h"
#include <array>
-#include <string.h>
+#include <cstring>
static const std::array<int, 5> kUuidGroups = { { 4, 2, 2, 2, 6 } };
diff --git a/Source/cmWorkerPool.cxx b/Source/cmWorkerPool.cxx
index 2e4d00b..5ac81df 100644
--- a/Source/cmWorkerPool.cxx
+++ b/Source/cmWorkerPool.cxx
@@ -11,10 +11,10 @@
#include <algorithm>
#include <array>
#include <condition_variable>
+#include <cstddef>
#include <deque>
#include <functional>
#include <mutex>
-#include <stddef.h>
#include <thread>
#include "cm_memory.hxx"
diff --git a/Source/cmWorkerPool.h b/Source/cmWorkerPool.h
index b541ce3..bf07299 100644
--- a/Source/cmWorkerPool.h
+++ b/Source/cmWorkerPool.h
@@ -5,7 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
-#include <stdint.h>
+#include <cstdint>
#include <string>
#include <utility>
#include <vector>
diff --git a/Source/cmXMLParser.cxx b/Source/cmXMLParser.cxx
index 4c6c35a..1f69032 100644
--- a/Source/cmXMLParser.cxx
+++ b/Source/cmXMLParser.cxx
@@ -4,10 +4,10 @@
#include "cm_expat.h"
#include "cmsys/FStream.hxx"
-#include <ctype.h>
+#include <cctype>
+#include <cstring>
#include <iostream>
#include <sstream>
-#include <string.h>
cmXMLParser::cmXMLParser()
{
diff --git a/Source/cmXMLSafe.cxx b/Source/cmXMLSafe.cxx
index d9bdc02..7c3b306 100644
--- a/Source/cmXMLSafe.cxx
+++ b/Source/cmXMLSafe.cxx
@@ -4,9 +4,9 @@
#include "cm_utf8.h"
+#include <cstdio>
+#include <cstring>
#include <sstream>
-#include <stdio.h>
-#include <string.h>
cmXMLSafe::cmXMLSafe(const char* s)
: Data(s)
diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx
index 2060584..b2cb9e6 100644
--- a/Source/cm_codecvt.hxx
+++ b/Source/cm_codecvt.hxx
@@ -5,8 +5,8 @@
#include "cmConfigure.h" // IWYU pragma: keep
+#include <cwchar>
#include <locale>
-#include <wchar.h>
class codecvt : public std::codecvt<char, char, mbstate_t>
{
diff --git a/Source/cm_get_date.h b/Source/cm_get_date.h
index 6acf8de..38a690e 100644
--- a/Source/cm_get_date.h
+++ b/Source/cm_get_date.h
@@ -3,7 +3,7 @@
#ifndef cm_get_date_h
#define cm_get_date_h
-#include <time.h>
+#include <time.h> /* NOLINT(modernize-deprecated-headers) */
#ifdef __cplusplus
extern "C" {
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 170e09b..9a66805 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -105,12 +105,12 @@
#include "cmsys/Glob.hxx"
#include "cmsys/RegularExpression.hxx"
#include <algorithm>
+#include <cstdio>
+#include <cstdlib>
#include <cstring>
#include <initializer_list>
#include <iostream>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
#include <utility>
namespace {
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 2b51a2a..252c6d6 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -25,10 +25,10 @@
#endif
#include <cassert>
+#include <cctype>
#include <climits>
-#include <ctype.h>
+#include <cstring>
#include <iostream>
-#include <string.h>
#include <string>
#include <vector>
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index ba2ba33..211fd4c 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -39,13 +39,13 @@
#include "cmsys/Process.h"
#include "cmsys/Terminal.h"
#include <array>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
+#include <ctime>
#include <iostream>
#include <memory>
#include <sstream>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <time.h>
#include <utility>
class cmConnection;
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index a69ba15..7be6746 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -11,8 +11,8 @@
#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP)
# include "cmsys/ConsoleBuf.hxx"
#endif
+#include <cstring>
#include <iostream>
-#include <string.h>
#include <string>
#include <vector>
diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx
index 010e17a..4a79c80 100644
--- a/Tests/CMakeLib/run_compile_commands.cxx
+++ b/Tests/CMakeLib/run_compile_commands.cxx
@@ -1,9 +1,9 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include "cmsys/FStream.hxx"
+#include <cstdlib>
#include <iostream>
#include <map>
-#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
diff --git a/Tests/CustomCommandByproducts/CMakeLists.txt b/Tests/CustomCommandByproducts/CMakeLists.txt
index d0bf648..08c897c 100644
--- a/Tests/CustomCommandByproducts/CMakeLists.txt
+++ b/Tests/CustomCommandByproducts/CMakeLists.txt
@@ -14,20 +14,21 @@ add_custom_command(
# Generate a byproduct in a rule that runs in a dependency of the consumer.
add_custom_command(
- OUTPUT timestamp2.txt
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/timestamp2.txt
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in byproduct2.c
- BYPRODUCTS byproduct2.c
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct2.c
COMMAND ${CMAKE_COMMAND} -E touch timestamp2.txt
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct2.c.in
)
-add_custom_target(Producer2 DEPENDS timestamp2.txt)
+add_custom_target(Producer2 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/timestamp2.txt)
# Generate a byproduct in a custom target.
add_custom_target(Producer3_4
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in byproduct3.c
- BYPRODUCTS byproduct3.c
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct3.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct3.c.in
)
# Generate a byproduct in a custom target POST_BUILD command.
@@ -35,33 +36,37 @@ add_custom_command(
TARGET Producer3_4 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in byproduct4.c
- BYPRODUCTS byproduct4.c
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/../CustomCommandByproducts/byproduct4.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct4.c.in
)
-add_executable(ProducerExe ProducerExe.c)
+add_executable(ProducerExe5_6_7 ProducerExe.c)
# Generate a byproduct in an executable POST_BUILD command.
add_custom_command(
- TARGET ProducerExe POST_BUILD
+ TARGET ProducerExe5_6_7 POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in byproduct5.c
BYPRODUCTS byproduct5.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct5.c.in
)
# Generate a byproduct in an executable PRE_LINK command.
add_custom_command(
- TARGET ProducerExe PRE_LINK
+ TARGET ProducerExe5_6_7 PRE_LINK
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in byproduct6.c
BYPRODUCTS byproduct6.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct6.c.in
)
# Generate a byproduct in an executable PRE_BUILD command.
add_custom_command(
- TARGET ProducerExe PRE_BUILD
+ TARGET ProducerExe5_6_7 PRE_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in byproduct7.c
BYPRODUCTS byproduct7.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct7.c.in
)
# Generate a byproduct in a custom command that consumes other byproducts.
@@ -80,6 +85,25 @@ add_custom_command(OUTPUT timestamp8.txt
${CMAKE_CURRENT_SOURCE_DIR}/byproduct8.c.in
)
+add_executable(ProducerExe9 ProducerExe.c)
+
+# Generate a byproduct in a custom target which depends on a byproduct of a
+# POST_BUILD command (test if dependency of custom target Producer9 to
+# ProducerExe9 is added).
+add_custom_command(
+ TARGET ProducerExe9 POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in byproduct9a.c
+ BYPRODUCTS byproduct9a.c
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/byproduct9.c.in
+ )
+add_custom_target(Producer9
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ byproduct9a.c byproduct9.c
+ BYPRODUCTS byproduct9.c
+ DEPENDS byproduct9a.c
+ )
+
# Generate the library file of an imported target as a byproduct
# of an external project.
get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
@@ -136,10 +160,13 @@ add_executable(CustomCommandByproducts
byproduct6.c
byproduct7.c
byproduct8.c timestamp8.txt
+ byproduct9.c
)
+
+# Dependencies to byproducts of custom commands other than build events are not
+# yet traced (see issue #19005).
add_dependencies(CustomCommandByproducts Producer2)
-add_dependencies(CustomCommandByproducts Producer3_4)
-add_dependencies(CustomCommandByproducts ProducerExe)
+
target_link_libraries(CustomCommandByproducts ExternalLibrary)
if(CMAKE_GENERATOR STREQUAL "Ninja")
diff --git a/Tests/CustomCommandByproducts/CustomCommandByproducts.c b/Tests/CustomCommandByproducts/CustomCommandByproducts.c
index 02ad7ea..0658d05 100644
--- a/Tests/CustomCommandByproducts/CustomCommandByproducts.c
+++ b/Tests/CustomCommandByproducts/CustomCommandByproducts.c
@@ -6,10 +6,11 @@ extern int byproduct5(void);
extern int byproduct6(void);
extern int byproduct7(void);
extern int byproduct8(void);
+extern int byproduct9(void);
extern int ExternalLibrary(void);
int main(void)
{
return (byproduct1() + byproduct2() + byproduct3() + byproduct4() +
byproduct5() + byproduct6() + byproduct7() + byproduct8() +
- ExternalLibrary() + 0);
+ byproduct9() + ExternalLibrary() + 0);
}
diff --git a/Tests/CustomCommandByproducts/byproduct9.c.in b/Tests/CustomCommandByproducts/byproduct9.c.in
new file mode 100644
index 0000000..11eed2c
--- /dev/null
+++ b/Tests/CustomCommandByproducts/byproduct9.c.in
@@ -0,0 +1 @@
+int byproduct9(void) { return 0; }
diff --git a/Tests/FindEnvModules/EnvModules.cmake b/Tests/FindEnvModules/EnvModules.cmake
index 0c81bf2..21b0042 100644
--- a/Tests/FindEnvModules/EnvModules.cmake
+++ b/Tests/FindEnvModules/EnvModules.cmake
@@ -18,18 +18,16 @@ if(avail_mods)
message("module list")
env_module_list(loaded_mods)
+ set(mod0_found FALSE)
foreach(mod IN LISTS loaded_mods)
message(" ${mod}")
+ if(NOT mod0_found AND mod MATCHES "^${mod0}")
+ set(mod0_found ${mod})
+ endif()
endforeach()
- list(LENGTH loaded_mods num_loaded_mods)
- message("Number of modules loaded: ${num_loaded_mods}")
- if(NOT num_loaded_mods EQUAL 1)
- message(FATAL_ERROR "Exactly 1 module should be loaded. Found ${num_loaded_mods}")
- endif()
-
- list(GET loaded_mods 0 mod0_actual)
- if(NOT (mod0_actual MATCHES "^${mod0}"))
- message(FATAL_ERROR "Loaded module does not match ${mod0}. Actual: ${mod0_actual}")
+ if(NOT mod0_found)
+ message(FATAL_ERROR "Requested module ${mod0} not found in loaded modules")
endif()
+ message("module ${mod0} found loaded as ${mod0_found}")
endif()
diff --git a/Tests/GeneratorExpression/CMakeLists.txt b/Tests/GeneratorExpression/CMakeLists.txt
index 3ff2b85..9d51342 100644
--- a/Tests/GeneratorExpression/CMakeLists.txt
+++ b/Tests/GeneratorExpression/CMakeLists.txt
@@ -86,7 +86,7 @@ add_custom_target(check-part1 ALL
-Dtest_colons_4=$<1:C:\\CMake>
-Dtest_colons_5=$<1:C:/CMake>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part1.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 1 of 5)"
VERBATIM
)
@@ -157,7 +157,7 @@ add_custom_target(check-part2 ALL
-Dtest_arbitrary_content_comma_9=$<1:a,,b,,>
-Dtest_arbitrary_content_comma_10=$<1:,,a,,b,,>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part2.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 2 of 5)"
VERBATIM
)
@@ -251,7 +251,7 @@ add_custom_target(check-part3 ALL
-Dequal22=$<EQUAL:10,-012>
-Dequal23=$<EQUAL:-10,-012>
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part3.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 3 of 5)"
VERBATIM
)
@@ -277,7 +277,27 @@ add_custom_target(check-part4 ALL
-DWIN32=${WIN32}
-DCMAKE_GENERATOR=${CMAKE_GENERATOR}
-P ${CMAKE_CURRENT_SOURCE_DIR}/check-part4.cmake
- COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 4)"
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 4 of 5)"
+ VERBATIM
+ )
+
+add_custom_target(check-part5 ALL
+ COMMAND ${CMAKE_COMMAND} -E echo "check done (part 5 of 5)"
+ DEPENDS check-part5.stamp
+ VERBATIM
+ )
+
+add_custom_command(
+ OUTPUT check-part5.stamp
+ DEPENDS $<FILTER:file.foo.bar,EXCLUDE,\\.foo\\.bar$>
+ COMMAND ${CMAKE_COMMAND} -E sleep 0
+ VERBATIM
+ )
+set_property(SOURCE check-part5.stamp PROPERTY SYMBOLIC 1)
+
+add_custom_command(
+ OUTPUT file.foo.bar
+ COMMAND ${CMAKE_COMMAND} -P check-part5.cmake
VERBATIM
)
diff --git a/Tests/GeneratorExpression/check-part5.cmake b/Tests/GeneratorExpression/check-part5.cmake
new file mode 100644
index 0000000..77d1387
--- /dev/null
+++ b/Tests/GeneratorExpression/check-part5.cmake
@@ -0,0 +1 @@
+message(SEND_ERROR "$<FILTER:file.foo.bar,EXCLUDE,\\.foo\\.bar$> genex in DEPENDS argument of 'add_custom_command()' is not empty")
diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
index e82b05f..62bb5de 100644
--- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
+++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake
@@ -39,7 +39,7 @@ foreach(i 1 2)
"Name: CMakeInternalFakePackage${i}
Description: Dummy package (${i}) for FindPkgConfig IMPORTED_TARGET test
Version: 1.2.3
-Libs: -l${pname}
+Libs: -l${pname} -l${pname}-doesnotexist
")
endforeach()
@@ -47,27 +47,6 @@ endforeach()
# the import target find_library() calls handle the NO...PATH options correctly
set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig)
-# Confirm correct behavior of NO_CMAKE_PATH, ensuring we only find the library
-# for the imported target if we have both set CMAKE_PREFIX_PATH and have not
-# given the NO_CMAKE_PATH option
-unset(CMAKE_PREFIX_PATH)
-unset(ENV{CMAKE_PREFIX_PATH})
-pkg_check_modules(FakePackage1 QUIET IMPORTED_TARGET cmakeinternalfakepackage1)
-if (TARGET PkgConfig::FakePackage1)
- message(FATAL_ERROR "Have import target for fake package 1 with no path prefix")
-endif()
-
-set(CMAKE_PREFIX_PATH ${fakePkgDir})
-pkg_check_modules(FakePackage1 QUIET IMPORTED_TARGET NO_CMAKE_PATH cmakeinternalfakepackage1)
-if (TARGET PkgConfig::FakePackage1)
- message(FATAL_ERROR "Have import target for fake package 1 with ignored cmake path")
-endif()
-
-pkg_check_modules(FakePackage1 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage1)
-if (NOT TARGET PkgConfig::FakePackage1)
- message(FATAL_ERROR "No import target for fake package 1 with prefix path")
-endif()
-
# find targets in subdir and check their visibility
add_subdirectory(target_subdir)
if (TARGET PkgConfig::FakePackage1_dir)
@@ -82,31 +61,35 @@ endif()
# combination
unset(CMAKE_PREFIX_PATH)
unset(ENV{CMAKE_PREFIX_PATH})
-pkg_check_modules(FakePackage2 QUIET IMPORTED_TARGET cmakeinternalfakepackage2)
-if (TARGET PkgConfig::FakePackage2)
- message(FATAL_ERROR "Have import target for fake package 2 with no path prefix")
-endif()
-
set(ENV{CMAKE_PREFIX_PATH} ${fakePkgDir})
-pkg_check_modules(FakePackage2 QUIET IMPORTED_TARGET NO_CMAKE_ENVIRONMENT_PATH cmakeinternalfakepackage2)
-if (TARGET PkgConfig::FakePackage2)
- message(FATAL_ERROR "Have import target for fake package 2 with ignored cmake path")
-endif()
pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2)
if (NOT TARGET PkgConfig::FakePackage2)
message(FATAL_ERROR "No import target for fake package 2 with prefix path")
endif()
+# check that 2 library entries exist
+list(LENGTH FakePackage2_LINK_LIBRARIES fp2_nlibs)
+if (NOT fp2_nlibs EQUAL 2)
+ message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has ${fp2_nlibs} entries but should have exactly 2")
+endif()
+
# check that the full library path is also returned
-if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a")
+list(GET FakePackage2_LINK_LIBRARIES 0 fp2_lib0)
+if (NOT fp2_lib0 STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a")
+ message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}")
+endif()
+
+# check that the library that couldn't be found still shows up
+list(GET FakePackage2_LINK_LIBRARIES 1 fp2_lib1)
+if (NOT fp2_lib1 STREQUAL "cmakeinternalfakepackage2-doesnotexist")
message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}")
endif()
# the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run
unset(FakePackage2_LINK_LIBRARIES)
pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2)
-if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a")
+if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a;cmakeinternalfakepackage2-doesnotexist")
message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}")
endif()
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
new file mode 100644
index 0000000..4502456
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFrom.cmake
@@ -0,0 +1,20 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchReuseFrom C)
+
+add_library(empty empty.c)
+target_precompile_headers(empty PUBLIC
+ <stdio.h>
+ <string.h>
+)
+target_include_directories(empty PUBLIC include)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo REUSE_FROM empty)
+
+add_executable(foobar foobar.c)
+target_link_libraries(foobar foo )
+set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt
new file mode 100644
index 0000000..8cdcfd9
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir-build-stderr.txt
@@ -0,0 +1,2 @@
+^(|Warning #670: precompiled header file [^
+]* was not generated in this directory)$
diff --git a/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake
new file mode 100644
index 0000000..fff74dc
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/PchReuseFromSubdir.cmake
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.15)
+project(PchReuseFromSubdir C)
+
+add_library(empty empty.c)
+target_precompile_headers(empty PUBLIC
+ <stdio.h>
+ <string.h>
+)
+target_include_directories(empty PUBLIC include)
+
+add_library(foo foo.c)
+target_include_directories(foo PUBLIC include)
+target_precompile_headers(foo REUSE_FROM empty)
+
+subdirs(subdir)
+
+enable_testing()
+add_test(NAME foobar COMMAND foobar)
diff --git a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
index fffcc47..bd3b1b8 100644
--- a/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
+++ b/Tests/RunCMake/PrecompileHeaders/RunCMakeTest.cmake
@@ -16,3 +16,5 @@ run_cmake(DisabledPch)
run_test(PchInterface)
run_cmake(PchPrologueEpilogue)
run_test(SkipPrecompileHeaders)
+run_test(PchReuseFrom)
+run_test(PchReuseFromSubdir)
diff --git a/Tests/RunCMake/PrecompileHeaders/empty.c b/Tests/RunCMake/PrecompileHeaders/empty.c
new file mode 100644
index 0000000..30ae1c4
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/empty.c
@@ -0,0 +1,3 @@
+void nothing()
+{
+}
diff --git a/Tests/RunCMake/PrecompileHeaders/include/foo.h b/Tests/RunCMake/PrecompileHeaders/include/foo.h
index 4a49474..fc0ae14 100644
--- a/Tests/RunCMake/PrecompileHeaders/include/foo.h
+++ b/Tests/RunCMake/PrecompileHeaders/include/foo.h
@@ -1,6 +1,6 @@
#ifndef foo_h
#define foo_h
-extern int foo();
+int foo(void);
#endif
diff --git a/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt
new file mode 100644
index 0000000..fa926c4
--- /dev/null
+++ b/Tests/RunCMake/PrecompileHeaders/subdir/CMakeLists.txt
@@ -0,0 +1,3 @@
+add_executable(foobar ../foobar.c)
+target_link_libraries(foobar foo )
+set_target_properties(foobar PROPERTIES PRECOMPILE_HEADERS_REUSE_FROM foo)
diff --git a/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake
new file mode 100644
index 0000000..628134b
--- /dev/null
+++ b/Tests/RunCMake/add_custom_command/GeneratedProperty.cmake
@@ -0,0 +1,10 @@
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a"
+ BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/b"
+ COMMAND c
+ )
+get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED)
+get_source_file_property(GENERATED_B "${CMAKE_CURRENT_BINARY_DIR}/b" GENERATED)
+if(NOT GENERATED_A OR NOT GENERATED_B)
+ message(FATAL_ERROR "failed")
+endif()
diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
index 0387dbb..20097b7 100644
--- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake
@@ -3,6 +3,7 @@ include(RunCMake)
run_cmake(AppendNoOutput)
run_cmake(AppendNotOutput)
run_cmake(BadArgument)
+run_cmake(GeneratedProperty)
run_cmake(NoArguments)
run_cmake(NoOutputOrTarget)
run_cmake(OutputAndTarget)
diff --git a/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake
new file mode 100644
index 0000000..d034534
--- /dev/null
+++ b/Tests/RunCMake/add_custom_target/GeneratedProperty.cmake
@@ -0,0 +1,14 @@
+add_custom_command(
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/a"
+ COMMAND b
+ )
+add_custom_target(CollapseFullPath
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/a"
+ BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/../GeneratedProperty-build/c"
+ COMMAND d
+ )
+get_source_file_property(GENERATED_A "${CMAKE_CURRENT_BINARY_DIR}/a" GENERATED)
+get_source_file_property(GENERATED_C "${CMAKE_CURRENT_BINARY_DIR}/c" GENERATED)
+if(NOT GENERATED_A OR NOT GENERATED_C)
+ message(FATAL_ERROR "failed")
+endif()
diff --git a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
index 2caed03..d80ca19 100644
--- a/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
+++ b/Tests/RunCMake/add_custom_target/RunCMakeTest.cmake
@@ -1,6 +1,7 @@
include(RunCMake)
run_cmake(CommandExpandsEmpty)
+run_cmake(GeneratedProperty)
run_cmake(NoArguments)
run_cmake(BadTargetName)
run_cmake(ByproductsNoCommand)