summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/command/target_precompile_headers.rst14
-rw-r--r--Help/manual/cmake-properties.7.rst2
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/manual/cmake.1.rst18
-rw-r--r--Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst32
-rw-r--r--Help/prop_tgt/PRECOMPILE_HEADERS_REUSE_FROM.rst7
-rw-r--r--Help/release/dev/FindGnuTLS-target.rst4
-rw-r--r--Help/release/dev/automoc_path_prefix.rst13
-rw-r--r--Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst11
-rw-r--r--Help/variable/MSVC_TOOLSET_VERSION.rst1
-rw-r--r--Modules/CMakeFindBinUtils.cmake2
-rw-r--r--Modules/CMakeGenericSystem.cmake1
-rw-r--r--Modules/FindGnuTLS.cmake40
-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/cmCPackGeneratorFactory.cxx25
-rw-r--r--Source/CPack/cmCPackGeneratorFactory.h12
-rw-r--r--Source/CPack/cpack.cxx5
-rw-r--r--Source/cmAddCustomCommandCommand.cxx13
-rw-r--r--Source/cmAddCustomTargetCommand.cxx16
-rw-r--r--Source/cmAddDependenciesCommand.cxx30
-rw-r--r--Source/cmAddExecutableCommand.cxx38
-rw-r--r--Source/cmAddLibraryCommand.cxx62
-rw-r--r--Source/cmAddSubDirectoryCommand.cxx15
-rw-r--r--Source/cmAddTestCommand.cxx19
-rw-r--r--Source/cmCMakePolicyCommand.cxx47
-rw-r--r--Source/cmCommonTargetGenerator.cxx1
-rw-r--r--Source/cmComputeLinkInformation.cxx35
-rw-r--r--Source/cmComputeLinkInformation.h6
-rw-r--r--Source/cmConfigureFileCommand.cxx12
-rw-r--r--Source/cmCustomCommandGenerator.cxx41
-rw-r--r--Source/cmCustomCommandGenerator.h1
-rw-r--r--Source/cmCustomCommandLines.cxx22
-rw-r--r--Source/cmCustomCommandLines.h19
-rw-r--r--Source/cmFLTKWrapUICommand.cxx19
-rw-r--r--Source/cmFileAPICodemodel.cxx20
-rw-r--r--Source/cmFileCommand.cxx261
-rw-r--r--Source/cmFindPackageCommand.cxx45
-rw-r--r--Source/cmForEachCommand.cxx15
-rw-r--r--Source/cmGeneratorTarget.cxx133
-rw-r--r--Source/cmGeneratorTarget.h3
-rw-r--r--Source/cmGetPropertyCommand.cxx36
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx22
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx11
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx35
-rw-r--r--Source/cmInstallCommand.cxx314
-rw-r--r--Source/cmLinkLineComputer.cxx99
-rw-r--r--Source/cmLinkLineComputer.h18
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx41
-rw-r--r--Source/cmLinkLineDeviceComputer.h8
-rw-r--r--Source/cmListCommand.cxx111
-rw-r--r--Source/cmLoadCommandCommand.cxx7
-rw-r--r--Source/cmLocalGenerator.cxx149
-rw-r--r--Source/cmLocalGenerator.h16
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx8
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx25
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx9
-rw-r--r--Source/cmMakefile.cxx29
-rw-r--r--Source/cmMakefile.h8
-rw-r--r--Source/cmMakefileTargetGenerator.cxx31
-rw-r--r--Source/cmNinjaTargetGenerator.cxx13
-rw-r--r--Source/cmOptionCommand.cxx16
-rw-r--r--Source/cmOrderDirectories.cxx14
-rw-r--r--Source/cmProjectCommand.cxx9
-rw-r--r--Source/cmQTWrapCPPCommand.cxx12
-rw-r--r--Source/cmQTWrapUICommand.cxx33
-rw-r--r--Source/cmQtAutoGen.cxx9
-rw-r--r--Source/cmQtAutoGen.h3
-rw-r--r--Source/cmQtAutoGenInitializer.cxx399
-rw-r--r--Source/cmQtAutoGenInitializer.h18
-rw-r--r--Source/cmQtAutoGenerator.cxx31
-rw-r--r--Source/cmQtAutoGenerator.h24
-rw-r--r--Source/cmQtAutoMocUic.cxx1129
-rw-r--r--Source/cmQtAutoMocUic.h231
-rw-r--r--Source/cmQtAutoRcc.cxx118
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx6
-rw-r--r--Source/cmSetPropertyCommand.cxx56
-rw-r--r--Source/cmStringCommand.cxx32
-rw-r--r--Source/cmTarget.cxx45
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx11
-rw-r--r--Source/cmTargetCompileFeaturesCommand.cxx11
-rw-r--r--Source/cmTargetCompileOptionsCommand.cxx10
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx9
-rw-r--r--Source/cmTargetLinkDirectoriesCommand.cxx10
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx74
-rw-r--r--Source/cmTargetLinkOptionsCommand.cxx10
-rw-r--r--Source/cmTargetPrecompileHeadersCommand.cxx2
-rw-r--r--Source/cmTargetPropCommandBase.cxx13
-rw-r--r--Source/cmTargetPropCommandBase.h7
-rw-r--r--Source/cmTargetSourcesCommand.cxx9
-rw-r--r--Source/cmVariableWatchCommand.cxx24
-rw-r--r--Source/kwsys/CommandLineArguments.cxx22
-rw-r--r--Source/kwsys/Configure.hxx.in1
-rw-r--r--Source/kwsys/ConsoleBuf.hxx.in18
-rw-r--r--Source/kwsys/Directory.cxx2
-rw-r--r--Source/kwsys/DynamicLoader.cxx20
-rw-r--r--Source/kwsys/EncodingCXX.cxx25
-rw-r--r--Source/kwsys/Glob.cxx2
-rw-r--r--Source/kwsys/Glob.hxx.in2
-rw-r--r--Source/kwsys/RegularExpression.cxx122
-rw-r--r--Source/kwsys/RegularExpression.hxx.in37
-rw-r--r--Source/kwsys/SystemInformation.cxx208
-rw-r--r--Source/kwsys/SystemInformation.hxx.in10
-rw-r--r--Source/kwsys/SystemTools.cxx76
-rw-r--r--Source/kwsys/SystemTools.hxx.in24
-rw-r--r--Source/kwsys/hashtable.hxx.in21
-rw-r--r--Source/kwsys/testCommandLineArguments.cxx4
-rw-r--r--Source/kwsys/testCommandLineArguments1.cxx6
-rw-r--r--Source/kwsys/testConsoleBuf.cxx60
-rw-r--r--Source/kwsys/testDynamicLoader.cxx2
-rw-r--r--Source/kwsys/testEncoding.cxx4
-rw-r--r--Source/kwsys/testProcess.c2
-rw-r--r--Source/kwsys/testSystemTools.cxx10
-rw-r--r--Templates/TestDriver.cxx.in20
-rw-r--r--Tests/CMakeLists.txt1
-rw-r--r--Tests/FindGnuTLS/CMakeLists.txt10
-rw-r--r--Tests/FindGnuTLS/Test/CMakeLists.txt17
-rw-r--r--Tests/FindGnuTLS/Test/main.c22
-rw-r--r--Tests/Plugin/CMakeLists.txt12
-rw-r--r--Tests/Plugin/include/DynamicLoader.hxx49
-rw-r--r--Tests/Plugin/src/DynamicLoader.cxx263
-rw-r--r--Tests/Plugin/src/example_exe.cxx17
-rw-r--r--Tests/Plugin/src/example_exe.h.in2
-rw-r--r--Tests/QtAutogen/MocInclude/CMakeLists.txt112
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp11
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp9
-rw-r--r--Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp15
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDot.cpp11
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDot.hpp (renamed from Tests/QtAutogen/MocInclude/SObjA.hpp)10
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in11
-rw-r--r--Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in15
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp43
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp17
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp4
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp32
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp20
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp39
-rw-r--r--Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp17
-rw-r--r--Tests/QtAutogen/MocInclude/Common/None.cpp20
-rw-r--r--Tests/QtAutogen/MocInclude/Common/None.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/None_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp44
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp20
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp45
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp20
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDot.cpp39
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDot.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp40
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnDot_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp22
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Common/common.cpp.in32
-rw-r--r--Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in5
-rw-r--r--Tests/QtAutogen/MocInclude/EObjA.cpp44
-rw-r--r--Tests/QtAutogen/MocInclude/EObjA.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/EObjAExtra.cpp20
-rw-r--r--Tests/QtAutogen/MocInclude/EObjAExtra.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/EObjA_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/EObjB.cpp45
-rw-r--r--Tests/QtAutogen/MocInclude/EObjB.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/EObjB_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/LObjA.cpp39
-rw-r--r--Tests/QtAutogen/MocInclude/LObjA.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/LObjA_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/LObjB.cpp40
-rw-r--r--Tests/QtAutogen/MocInclude/LObjB.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/LObjB_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/ObjA.cpp20
-rw-r--r--Tests/QtAutogen/MocInclude/ObjA.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/ObjA_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/ObjB.cpp22
-rw-r--r--Tests/QtAutogen/MocInclude/ObjB.hpp19
-rw-r--r--Tests/QtAutogen/MocInclude/ObjB_p.h14
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt17
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjA.cpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjA.hpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjB.cpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjB.hpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjBExtra.hpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjC.cpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp (renamed from Tests/QtAutogen/MocIncludeRelaxed/RObjC.hpp)0
-rw-r--r--Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp21
-rw-r--r--Tests/QtAutogen/MocInclude/SObjA.cpp11
-rw-r--r--Tests/QtAutogen/MocInclude/SObjB.cpp.in11
-rw-r--r--Tests/QtAutogen/MocInclude/SObjB.hpp.in15
-rw-r--r--Tests/QtAutogen/MocInclude/SObjC.cpp35
-rw-r--r--Tests/QtAutogen/MocInclude/SObjC.hpp15
-rw-r--r--Tests/QtAutogen/MocInclude/SObjCExtra.cpp31
-rw-r--r--Tests/QtAutogen/MocInclude/SObjCExtra.hpp15
-rw-r--r--Tests/QtAutogen/MocInclude/SObjCExtra.moc.in4
-rw-r--r--Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt14
-rw-r--r--Tests/QtAutogen/MocInclude/Strict/strict.cpp7
-rw-r--r--Tests/QtAutogen/MocInclude/main.cpp9
-rw-r--r--Tests/QtAutogen/MocInclude/shared.cmake71
-rw-r--r--Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp20
-rw-r--r--Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp18
-rw-r--r--Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp14
-rw-r--r--Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp41
-rw-r--r--Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp17
-rw-r--r--Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp17
-rw-r--r--Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt20
-rw-r--r--Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp12
-rw-r--r--Tests/QtAutogen/MocIncludeRelaxed/main.cpp26
-rw-r--r--Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt10
-rw-r--r--Tests/QtAutogen/MocIncludeStrict/main.cpp26
-rw-r--r--Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt80
-rw-r--r--Tests/QtAutogen/Tests.cmake4
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-check.py40
-rw-r--r--Tests/RunCMake/FileAPI/cxx/CMakeLists.txt1
-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
231 files changed, 4263 insertions, 3350 deletions
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/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 19afb7d..8f8cb33 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -134,6 +134,7 @@ Properties on Targets
/prop_tgt/AUTOMOC_EXECUTABLE
/prop_tgt/AUTOMOC_MACRO_NAMES
/prop_tgt/AUTOMOC_MOC_OPTIONS
+ /prop_tgt/AUTOMOC_PATH_PREFIX
/prop_tgt/AUTOMOC
/prop_tgt/AUTOUIC
/prop_tgt/AUTOUIC_EXECUTABLE
@@ -298,6 +299,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/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 2d473d8..def63e4 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -342,6 +342,7 @@ Variables that Control the Build
/variable/CMAKE_AUTOMOC_DEPEND_FILTERS
/variable/CMAKE_AUTOMOC_MACRO_NAMES
/variable/CMAKE_AUTOMOC_MOC_OPTIONS
+ /variable/CMAKE_AUTOMOC_PATH_PREFIX
/variable/CMAKE_AUTORCC
/variable/CMAKE_AUTORCC_OPTIONS
/variable/CMAKE_AUTOUIC
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 2576cde..754f14b 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -473,6 +473,12 @@ Available commands are:
directory and it must exist.
``copy_if_different`` does follow symlinks.
+``create_symlink <old> <new>``
+ Create a symbolic link ``<new>`` naming ``<old>``.
+
+ .. note::
+ Path to where ``<new>`` symbolic link will be created has to exist beforehand.
+
``echo [<string>...]``
Displays arguments as text.
@@ -485,6 +491,9 @@ Available commands are:
``environment``
Display the current environment variables.
+``false``
+ Do nothing, with an exit code of 1.
+
``make_directory <dir>...``
Create ``<dir>`` directories. If necessary, create parent
directories too. If a directory already exists it will be
@@ -602,18 +611,9 @@ Available commands are:
Touch a file if it exists but do not create it. If a file does
not exist it will be silently ignored.
-``create_symlink <old> <new>``
- Create a symbolic link ``<new>`` naming ``<old>``.
-
-.. note::
- Path to where ``<new>`` symbolic link will be created has to exist beforehand.
-
``true``
Do nothing, with an exit code of 0.
-``false``
- Do nothing, with an exit code of 1.
-
Windows-specific Command-Line Tools
-----------------------------------
diff --git a/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst
new file mode 100644
index 0000000..e2ebb3f
--- /dev/null
+++ b/Help/prop_tgt/AUTOMOC_PATH_PREFIX.rst
@@ -0,0 +1,32 @@
+AUTOMOC_PATH_PREFIX
+-------------------
+
+When this property is ``ON``, CMake will generate the ``-p`` path prefix
+option for ``moc`` on :prop_tgt:`AUTOMOC` enabled Qt targets.
+
+To generate the path prefix, CMake tests if the header compiled by ``moc``
+is in any of the target
+:command:`include directories <target_include_directories>`. If so, CMake will
+compute the relative path accordingly. If the header is not in the
+:command:`include directories <target_include_directories>`, CMake will omit
+the ``-p`` path prefix option. ``moc`` usually generates a
+relative include path in that case.
+
+:prop_tgt:`AUTOMOC_PATH_PREFIX` is initialized from the variable
+:variable:`CMAKE_AUTOMOC_PATH_PREFIX`, which is ``ON`` by default.
+
+See the :manual:`cmake-qt(7)` manual for more information on using CMake
+with Qt.
+
+Reproducible builds
+^^^^^^^^^^^^^^^^^^^
+
+For reproducible builds is is recommended to keep headers that are ``moc``
+compiled in one of the target
+:command:`include directories <target_include_directories>` and set
+:prop_tgt:`AUTOMOC_PATH_PREFIX` to ``ON`` (which is the default). This ensures
+that
+
+- ``moc`` output files are identical on different build setups,
+- ``moc`` output files will compile correctly when the source and/or
+ build directory is a symbolic link.
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/Help/release/dev/FindGnuTLS-target.rst b/Help/release/dev/FindGnuTLS-target.rst
new file mode 100644
index 0000000..671a7b7
--- /dev/null
+++ b/Help/release/dev/FindGnuTLS-target.rst
@@ -0,0 +1,4 @@
+FindGnuTLS-target
+-----------------
+
+* The :module:`FindGnuTLS` module now provides an imported target.
diff --git a/Help/release/dev/automoc_path_prefix.rst b/Help/release/dev/automoc_path_prefix.rst
new file mode 100644
index 0000000..bee1b32
--- /dev/null
+++ b/Help/release/dev/automoc_path_prefix.rst
@@ -0,0 +1,13 @@
+automoc_path_prefix
+-------------------
+
+* When using :prop_tgt:`AUTOMOC`, CMake now generates the ``-p`` path prefix
+ option for ``moc``. This ensures that ``moc`` output files are identical
+ on different build setups (given, that the headers compiled by ``moc`` are
+ in an :command:`include directory <target_include_directories>`).
+ Also it ensures that ``moc`` output files will compile correctly when the
+ source and/or build directory is a symbolic link.
+
+ The ``moc`` path prefix generation behavior can be configured by setting
+ the new :variable:`CMAKE_AUTOMOC_PATH_PREFIX` variable and/or
+ :prop_tgt:`AUTOMOC_PATH_PREFIX` target property.
diff --git a/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst
new file mode 100644
index 0000000..dca0b06
--- /dev/null
+++ b/Help/variable/CMAKE_AUTOMOC_PATH_PREFIX.rst
@@ -0,0 +1,11 @@
+CMAKE_AUTOMOC_PATH_PREFIX
+-------------------------
+
+Whether to generate the ``-p`` path prefix option for ``moc`` on
+:prop_tgt:`AUTOMOC` enabled Qt targets.
+
+This variable is used to initialize the :prop_tgt:`AUTOMOC_PATH_PREFIX`
+property on all the targets. See that target property for additional
+information.
+
+The default value is ``ON``.
diff --git a/Help/variable/MSVC_TOOLSET_VERSION.rst b/Help/variable/MSVC_TOOLSET_VERSION.rst
index 77e1ea9..f4a33e2 100644
--- a/Help/variable/MSVC_TOOLSET_VERSION.rst
+++ b/Help/variable/MSVC_TOOLSET_VERSION.rst
@@ -14,6 +14,7 @@ Known toolset version numbers are::
120 = VS 2013 (12.0)
140 = VS 2015 (14.0)
141 = VS 2017 (15.0)
+ 142 = VS 2019 (16.0)
Compiler versions newer than those known to CMake will be reported
as the latest known toolset version.
diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake
index 01f9dae..781b48c 100644
--- a/Modules/CMakeFindBinUtils.cmake
+++ b/Modules/CMakeFindBinUtils.cmake
@@ -134,7 +134,7 @@ else()
endif()
if(CMAKE_PLATFORM_HAS_INSTALLNAME)
- find_program(CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
+ find_program(CMAKE_INSTALL_NAME_TOOL NAMES ${_CMAKE_TOOLCHAIN_PREFIX}install_name_tool HINTS ${_CMAKE_TOOLCHAIN_LOCATION})
if(NOT CMAKE_INSTALL_NAME_TOOL)
message(FATAL_ERROR "Could not find install_name_tool, please check your installation.")
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index ddfc7bd..77d8cfd 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -26,6 +26,7 @@ set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON)
set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
+set(CMAKE_AUTOMOC_PATH_PREFIX ON)
set(CMAKE_AUTOMOC_MACRO_NAMES "Q_OBJECT" "Q_GADGET" "Q_NAMESPACE")
# basically all general purpose OSs support shared libs
diff --git a/Modules/FindGnuTLS.cmake b/Modules/FindGnuTLS.cmake
index 123a0f5..819f000 100644
--- a/Modules/FindGnuTLS.cmake
+++ b/Modules/FindGnuTLS.cmake
@@ -7,16 +7,25 @@ FindGnuTLS
Find the GNU Transport Layer Security library (gnutls)
-
-
-Once done this will define
-
-::
-
- GNUTLS_FOUND - System has gnutls
- GNUTLS_INCLUDE_DIR - The gnutls include directory
- GNUTLS_LIBRARIES - The libraries needed to use gnutls
- GNUTLS_DEFINITIONS - Compiler switches required for using gnutls
+IMPORTED Targets
+^^^^^^^^^^^^^^^^
+
+This module defines :prop_tgt:`IMPORTED` target ``GnuTLS::GnuTLS``, if
+gnutls has been found.
+
+Result Variables
+^^^^^^^^^^^^^^^^
+
+``GNUTLS_FOUND``
+ System has gnutls
+``GNUTLS_INCLUDE_DIR``
+ The gnutls include directory
+``GNUTLS_LIBRARIES``
+ The libraries needed to use gnutls
+``GNUTLS_DEFINITIONS``
+ Compiler switches required for using gnutls
+``GNUTLS_VERSION``
+ version of gnutls.
#]=======================================================================]
# Note that this doesn't try to find the gnutls-extra package.
@@ -34,6 +43,8 @@ if (NOT WIN32)
find_package(PkgConfig QUIET)
PKG_CHECK_MODULES(PC_GNUTLS QUIET gnutls)
set(GNUTLS_DEFINITIONS ${PC_GNUTLS_CFLAGS_OTHER})
+ set(GNUTLS_VERSION ${PC_GNUTLS_VERSION})
+ # keep for backward compatibility
set(GNUTLS_VERSION_STRING ${PC_GNUTLS_VERSION})
endif ()
@@ -59,4 +70,13 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuTLS
if(GNUTLS_FOUND)
set(GNUTLS_LIBRARIES ${GNUTLS_LIBRARY})
set(GNUTLS_INCLUDE_DIRS ${GNUTLS_INCLUDE_DIR})
+
+ if(NOT TARGET GnuTLS::GnuTLS)
+ add_library(GnuTLS::GnuTLS UNKNOWN IMPORTED)
+ set_target_properties(GnuTLS::GnuTLS PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${GNUTLS_INCLUDE_DIRS}"
+ INTERFACE_COMPILE_DEFINITIONS "${GNUTLS_DEFINITIONS}"
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${GNUTLS_LIBRARIES}")
+ endif()
endif()
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 887d970..9a4f63e 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 20190917)
+set(CMake_VERSION_PATCH 20190920)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
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/cpack.cxx b/Source/CPack/cpack.cxx
index ab44a42..ce41d40 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -25,6 +25,7 @@
#include <cstddef>
#include <iostream>
#include <map>
+#include <memory>
#include <sstream>
#include <string>
#include <utility>
@@ -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/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx
index c91198c..35db6a4 100644
--- a/Source/cmAddCustomCommandCommand.cxx
+++ b/Source/cmAddCustomCommandCommand.cxx
@@ -321,10 +321,9 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args,
}
// No command for this output exists.
- std::ostringstream e;
- e << "given APPEND option with output\n\"" << output[0]
- << "\"\nwhich is not already a custom command output.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given APPEND option with output\n\"", output[0],
+ "\"\nwhich is not already a custom command output."));
return false;
}
@@ -407,10 +406,8 @@ bool cmAddCustomCommandCommandCheckOutputs(
// Make sure the output file name has no invalid characters.
std::string::size_type pos = o.find_first_of("#<>");
if (pos != std::string::npos) {
- std::ostringstream msg;
- msg << "called with OUTPUT containing a \"" << o[pos]
- << "\". This character is not allowed.";
- status.SetError(msg.str());
+ status.SetError(cmStrCat("called with OUTPUT containing a \"", o[pos],
+ "\". This character is not allowed."));
return false;
}
}
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index ec5c1a7..9fd1234 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddCustomTargetCommand.h"
-#include <sstream>
#include <utility>
#include "cmCustomCommandLines.h"
@@ -29,11 +28,9 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
// Check the target name.
if (targetName.find_first_of("/\\") != std::string::npos) {
- std::ostringstream e;
- e << "called with invalid target name \"" << targetName
- << "\". Target names may not contain a slash. "
- << "Use ADD_CUSTOM_COMMAND to generate files.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("called with invalid target name \"", targetName,
+ "\". Target names may not contain a slash. "
+ "Use ADD_CUSTOM_COMMAND to generate files."));
return false;
}
@@ -153,10 +150,9 @@ bool cmAddCustomTargetCommand(std::vector<std::string> const& args,
std::string::size_type pos = targetName.find_first_of("#<>");
if (pos != std::string::npos) {
- std::ostringstream msg;
- msg << "called with target name containing a \"" << targetName[pos]
- << "\". This character is not allowed.";
- status.SetError(msg.str());
+ status.SetError(cmStrCat("called with target name containing a \"",
+ targetName[pos],
+ "\". This character is not allowed."));
return false;
}
diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx
index 0ddbda8..b1fc893 100644
--- a/Source/cmAddDependenciesCommand.cxx
+++ b/Source/cmAddDependenciesCommand.cxx
@@ -2,12 +2,11 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddDependenciesCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmRange.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
bool cmAddDependenciesCommand(std::vector<std::string> const& args,
@@ -21,10 +20,10 @@ bool cmAddDependenciesCommand(std::vector<std::string> const& args,
cmMakefile& mf = status.GetMakefile();
std::string const& target_name = args[0];
if (mf.IsAlias(target_name)) {
- std::ostringstream e;
- e << "Cannot add target-level dependencies to alias target \""
- << target_name << "\".\n";
- mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot add target-level dependencies to alias target \"",
+ target_name, "\".\n"));
}
if (cmTarget* target = mf.FindTargetToUse(target_name)) {
@@ -33,14 +32,17 @@ bool cmAddDependenciesCommand(std::vector<std::string> const& args,
target->AddUtility(arg, &mf);
}
} else {
- std::ostringstream e;
- e << "Cannot add target-level dependencies to non-existent target \""
- << target_name << "\".\n"
- << "The add_dependencies works for top-level logical targets created "
- << "by the add_executable, add_library, or add_custom_target commands. "
- << "If you want to add file-level dependencies see the DEPENDS option "
- << "of the add_custom_target and add_custom_command commands.";
- mf.IssueMessage(MessageType::FATAL_ERROR, e.str());
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Cannot add target-level dependencies to non-existent "
+ "target \"",
+ target_name,
+ "\".\nThe add_dependencies works for "
+ "top-level logical targets created by the add_executable, "
+ "add_library, or add_custom_target commands. If you want to add "
+ "file-level dependencies see the DEPENDS option of the "
+ "add_custom_target and add_custom_command commands."));
}
return true;
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 1a87028..e738bc4 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -2,13 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddExecutableCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
#include "cmMakefile.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
#include "cmTarget.h"
bool cmAddExecutableCommand(std::vector<std::string> const& args,
@@ -99,34 +98,30 @@ bool cmAddExecutableCommand(std::vector<std::string> const& args,
std::string const& aliasedName = *s;
if (mf.IsAlias(aliasedName)) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is itself an ALIAS.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is itself an ALIAS."));
return false;
}
cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true);
if (!aliasedTarget) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" does not already exist.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" does not already exist."));
return false;
}
cmStateEnums::TargetType type = aliasedTarget->GetType();
if (type != cmStateEnums::EXECUTABLE) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is not an executable.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is not an executable."));
return false;
}
if (aliasedTarget->IsImported() &&
!aliasedTarget->IsImportedGloballyVisible()) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << exename << "\" because target \""
- << aliasedName << "\" is imported but not globally visible.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", exename,
+ "\" because target \"", aliasedName,
+ "\" is imported but not globally visible."));
return false;
}
mf.AddAlias(exename, aliasedName);
@@ -137,10 +132,9 @@ bool cmAddExecutableCommand(std::vector<std::string> const& args,
if (importTarget) {
// Make sure the target does not already exist.
if (mf.FindTargetToUse(exename)) {
- std::ostringstream e;
- e << "cannot create imported target \"" << exename
- << "\" because another target with the same name already exists.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "cannot create imported target \"", exename,
+ "\" because another target with the same name already exists."));
return false;
}
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index dc8937a..0439c51 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddLibraryCommand.h"
-#include <sstream>
-
#include "cmAlgorithms.h"
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
@@ -184,20 +182,16 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
std::string const& aliasedName = *s;
if (mf.IsAlias(aliasedName)) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is itself an ALIAS.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is itself an ALIAS."));
return false;
}
cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true);
if (!aliasedTarget) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName
- << "\" does not already "
- "exist.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" does not already exist."));
return false;
}
cmStateEnums::TargetType aliasedType = aliasedTarget->GetType();
@@ -208,18 +202,16 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
aliasedType != cmStateEnums::INTERFACE_LIBRARY &&
!(aliasedType == cmStateEnums::UNKNOWN_LIBRARY &&
aliasedTarget->IsImported())) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is not a library.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is not a library."));
return false;
}
if (aliasedTarget->IsImported() &&
!aliasedTarget->IsImportedGloballyVisible()) {
- std::ostringstream e;
- e << "cannot create ALIAS target \"" << libName << "\" because target \""
- << aliasedName << "\" is imported but not globally visible.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("cannot create ALIAS target \"", libName,
+ "\" because target \"", aliasedName,
+ "\" is imported but not globally visible."));
return false;
}
mf.AddAlias(libName, aliasedName);
@@ -238,12 +230,13 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
if ((type == cmStateEnums::SHARED_LIBRARY ||
type == cmStateEnums::MODULE_LIBRARY) &&
!mf.GetState()->GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) {
- std::ostringstream w;
- w << "ADD_LIBRARY called with "
- << (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE")
- << " option but the target platform does not support dynamic linking. "
- "Building a STATIC library instead. This may lead to problems.";
- mf.IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ mf.IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ "ADD_LIBRARY called with ",
+ (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE"),
+ " option but the target platform does not support dynamic linking. ",
+ "Building a STATIC library instead. This may lead to problems."));
type = cmStateEnums::STATIC_LIBRARY;
}
@@ -266,19 +259,17 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
}
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (!cmGeneratorExpression::IsValidTargetName(libName)) {
- std::ostringstream e;
- e << "Invalid name for IMPORTED INTERFACE library target: " << libName;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "Invalid name for IMPORTED INTERFACE library target: ", libName));
return false;
}
}
// Make sure the target does not already exist.
if (mf.FindTargetToUse(libName)) {
- std::ostringstream e;
- e << "cannot create imported target \"" << libName
- << "\" because another target with the same name already exists.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "cannot create imported target \"", libName,
+ "\" because another target with the same name already exists."));
return false;
}
@@ -309,9 +300,8 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args,
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (!cmGeneratorExpression::IsValidTargetName(libName) ||
libName.find("::") != std::string::npos) {
- std::ostringstream e;
- e << "Invalid name for INTERFACE library target: " << libName;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("Invalid name for INTERFACE library target: ", libName));
return false;
}
diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx
index c0be308..6a1a514 100644
--- a/Source/cmAddSubDirectoryCommand.cxx
+++ b/Source/cmAddSubDirectoryCommand.cxx
@@ -3,7 +3,6 @@
#include "cmAddSubDirectoryCommand.h"
#include <cstring>
-#include <sstream>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
@@ -64,13 +63,13 @@ bool cmAddSubDirectoryCommand(std::vector<std::string> const& args,
// error.
if (!cmSystemTools::IsSubDirectory(srcPath,
mf.GetCurrentSourceDirectory())) {
- std::ostringstream e;
- e << "not given a binary directory but the given source directory "
- << "\"" << srcPath << "\" is not a subdirectory of \""
- << mf.GetCurrentSourceDirectory() << "\". "
- << "When specifying an out-of-tree source a binary directory "
- << "must be explicitly specified.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("not given a binary directory but the given source ",
+ "directory \"", srcPath, "\" is not a subdirectory of \"",
+ mf.GetCurrentSourceDirectory(),
+ "\". When specifying an "
+ "out-of-tree source a binary directory must be explicitly "
+ "specified."));
return false;
}
diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx
index 7904bf5..8942113 100644
--- a/Source/cmAddTestCommand.cxx
+++ b/Source/cmAddTestCommand.cxx
@@ -2,10 +2,9 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmAddTestCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmTest.h"
#include "cmTestGenerator.h"
@@ -38,10 +37,8 @@ bool cmAddTestCommand(std::vector<std::string> const& args,
// If the test was already added by a new-style signature do not
// allow it to be duplicated.
if (!test->GetOldStyle()) {
- std::ostringstream e;
- e << " given test name \"" << args[0]
- << "\" which already exists in this directory.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(" given test name \"", args[0],
+ "\" which already exists in this directory."));
return false;
}
} else {
@@ -110,9 +107,7 @@ bool cmAddTestCommandHandleNameMode(std::vector<std::string> const& args,
working_directory = args[i];
doing = DoingNone;
} else {
- std::ostringstream e;
- e << " given unknown argument:\n " << args[i] << "\n";
- status.SetError(e.str());
+ status.SetError(cmStrCat(" given unknown argument:\n ", args[i], "\n"));
return false;
}
}
@@ -133,10 +128,8 @@ bool cmAddTestCommandHandleNameMode(std::vector<std::string> const& args,
// Require a unique test name within the directory.
if (mf.GetTest(name)) {
- std::ostringstream e;
- e << " given test NAME \"" << name
- << "\" which already exists in this directory.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(" given test NAME \"", name,
+ "\" which already exists in this directory."));
return false;
}
diff --git a/Source/cmCMakePolicyCommand.cxx b/Source/cmCMakePolicyCommand.cxx
index 9b1aea9..b7f08d2 100644
--- a/Source/cmCMakePolicyCommand.cxx
+++ b/Source/cmCMakePolicyCommand.cxx
@@ -2,14 +2,13 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCMakePolicyCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
+#include "cmStringAlgorithms.h"
namespace {
bool HandleSetMode(std::vector<std::string> const& args,
@@ -60,9 +59,7 @@ bool cmCMakePolicyCommand(std::vector<std::string> const& args,
return HandleGetWarningMode(args, status);
}
- std::ostringstream e;
- e << "given unknown first argument \"" << args[0] << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given unknown first argument \"", args[0], "\""));
return false;
}
@@ -82,9 +79,8 @@ bool HandleSetMode(std::vector<std::string> const& args,
} else if (args[2] == "NEW") {
policyStatus = cmPolicies::NEW;
} else {
- std::ostringstream e;
- e << "SET given unrecognized policy status \"" << args[2] << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("SET given unrecognized policy status \"", args[2], "\""));
return false;
}
@@ -128,10 +124,9 @@ bool HandleGetMode(std::vector<std::string> const& args,
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET given policy \"" << id << "\" which is not known to this "
- << "version of CMake.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}
@@ -155,12 +150,14 @@ bool HandleGetMode(std::vector<std::string> const& args,
case cmPolicies::REQUIRED_ALWAYS:
// The policy is required to be set before anything needs it.
{
- std::ostringstream e;
- e << cmPolicies::GetRequiredPolicyError(pid) << "\n"
- << "The call to cmake_policy(GET " << id << " ...) at which this "
- << "error appears requests the policy, and this version of CMake "
- << "requires that the policy be set to NEW before it is checked.";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ cmPolicies::GetRequiredPolicyError(pid), "\n",
+ "The call to cmake_policy(GET ", id,
+ " ...) at which this "
+ "error appears requests the policy, and this version of CMake ",
+ "requires that the policy be set to NEW before it is checked."));
}
}
@@ -188,10 +185,9 @@ bool HandleVersionMode(std::vector<std::string> const& args,
: std::string();
if (dd != std::string::npos &&
(version_min.empty() || version_max.empty())) {
- std::ostringstream e;
- e << "VERSION \"" << version_string
- << R"(" does not have a version on both sides of "...".)";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("VERSION \"", version_string,
+ R"(" does not have a version on both sides of "...".)"));
return false;
}
@@ -215,10 +211,9 @@ bool HandleGetWarningMode(std::vector<std::string> const& args,
// Lookup the policy number.
cmPolicies::PolicyID pid;
if (!cmPolicies::GetPolicyID(id.c_str(), pid)) {
- std::ostringstream e;
- e << "GET_WARNING given policy \"" << id
- << "\" which is not known to this version of CMake.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET_WARNING given policy \"", id,
+ "\" which is not known to this version of CMake."));
return false;
}
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/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 09dbbb1..832f38e 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -6,6 +6,7 @@
#include "cmComputeLinkDepends.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -406,6 +407,18 @@ cmComputeLinkInformation::~cmComputeLinkInformation()
delete this->OrderDependentRPath;
}
+void cmComputeLinkInformation::AppendValues(
+ std::string& result, std::vector<BT<std::string>>& values)
+{
+ for (BT<std::string>& p : values) {
+ if (result.empty()) {
+ result.append(" ");
+ }
+
+ result.append(p.Value);
+ }
+}
+
cmComputeLinkInformation::ItemVector const&
cmComputeLinkInformation::GetItems() const
{
@@ -418,6 +431,28 @@ std::vector<std::string> const& cmComputeLinkInformation::GetDirectories()
return this->OrderLinkerSearchPath->GetOrderedDirectories();
}
+std::vector<BT<std::string>>
+cmComputeLinkInformation::GetDirectoriesWithBacktraces()
+{
+ std::vector<BT<std::string>> directoriesWithBacktraces;
+
+ std::vector<BT<std::string>> targetLinkDirectores =
+ this->Target->GetLinkDirectories(this->Config, this->LinkLanguage);
+
+ const std::vector<std::string>& orderedDirectories = this->GetDirectories();
+ for (const std::string& dir : orderedDirectories) {
+ auto result =
+ std::find(targetLinkDirectores.begin(), targetLinkDirectores.end(), dir);
+ if (result != targetLinkDirectores.end()) {
+ directoriesWithBacktraces.emplace_back(std::move(*result));
+ } else {
+ directoriesWithBacktraces.emplace_back(dir);
+ }
+ }
+
+ return directoriesWithBacktraces;
+}
+
std::string cmComputeLinkInformation::GetRPathLinkString() const
{
// If there is no separate linker runtime search flag (-rpath-link)
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 0f71381..d3345d9 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -17,6 +17,8 @@ class cmGlobalGenerator;
class cmMakefile;
class cmOrderDirectories;
class cmake;
+template <typename T>
+class BT;
/** \class cmComputeLinkInformation
* \brief Compute link information for a target in one configuration.
@@ -43,8 +45,10 @@ public:
cmGeneratorTarget const* Target = nullptr;
};
using ItemVector = std::vector<Item>;
+ void AppendValues(std::string& result, std::vector<BT<std::string>>& values);
ItemVector const& GetItems() const;
std::vector<std::string> const& GetDirectories() const;
+ std::vector<BT<std::string>> GetDirectoriesWithBacktraces();
std::vector<std::string> const& GetDepends() const;
std::vector<std::string> const& GetFrameworkPaths() const;
std::string GetLinkLanguage() const { return this->LinkLanguage; }
@@ -66,6 +70,8 @@ public:
std::string GetConfig() const { return this->Config; }
+ const cmGeneratorTarget* GetTarget() { return this->Target; }
+
private:
void AddItem(std::string const& item, const cmGeneratorTarget* tgt);
void AddSharedDepItem(std::string const& item, cmGeneratorTarget const* tgt);
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 7e37f32..8767386 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmConfigureFileCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -26,13 +24,9 @@ bool cmConfigureFileCommand(std::vector<std::string> const& args,
// If the input location is a directory, error out.
if (cmSystemTools::FileIsDirectory(inputFile)) {
- std::ostringstream e;
- /* clang-format off */
- e << "input location\n"
- << " " << inputFile << "\n"
- << "is a directory but a file was expected.";
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(cmStrCat("input location\n ", inputFile,
+ "\n"
+ "is a directory but a file was expected."));
return false;
}
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 2c0cbfd..ddb855b 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -17,6 +17,26 @@
#include <memory>
#include <utility>
+namespace {
+void AppendPaths(const std::vector<std::string>& inputs,
+ cmGeneratorExpression& ge, cmLocalGenerator* lg,
+ std::string const& config, std::vector<std::string>& output)
+{
+ for (std::string const& in : inputs) {
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(in);
+ std::vector<std::string> result =
+ cmExpandedList(cge->Evaluate(lg, config));
+ for (std::string& it : result) {
+ cmSystemTools::ConvertToUnixSlashes(it);
+ if (cmSystemTools::FileIsFullPath(it)) {
+ it = cmSystemTools::CollapseFullPath(it);
+ }
+ }
+ cmAppend(output, result);
+ }
+}
+}
+
cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
std::string config,
cmLocalGenerator* lg)
@@ -46,25 +66,16 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc,
// lists on an empty command may have left this empty.
// FIXME: Should we define behavior for removing empty commands?
if (argv.empty()) {
- argv.push_back(std::string());
+ argv.emplace_back();
}
this->CommandLines.push_back(std::move(argv));
}
- std::vector<std::string> depends = this->CC.GetDepends();
- for (std::string const& d : depends) {
- std::unique_ptr<cmCompiledGeneratorExpression> cge = this->GE->Parse(d);
- 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);
- }
- }
- cmAppend(this->Depends, result);
- }
+ AppendPaths(cc.GetByproducts(), *this->GE, this->LG, this->Config,
+ this->Byproducts);
+ AppendPaths(cc.GetDepends(), *this->GE, this->LG, this->Config,
+ this->Depends);
const std::string& workingdirectory = this->CC.GetWorkingDirectory();
if (!workingdirectory.empty()) {
@@ -239,7 +250,7 @@ std::vector<std::string> const& cmCustomCommandGenerator::GetOutputs() const
std::vector<std::string> const& cmCustomCommandGenerator::GetByproducts() const
{
- return this->CC.GetByproducts();
+ return this->Byproducts;
}
std::vector<std::string> const& cmCustomCommandGenerator::GetDepends() const
diff --git a/Source/cmCustomCommandGenerator.h b/Source/cmCustomCommandGenerator.h
index 766f4b8..d614302 100644
--- a/Source/cmCustomCommandGenerator.h
+++ b/Source/cmCustomCommandGenerator.h
@@ -23,6 +23,7 @@ class cmCustomCommandGenerator
cmGeneratorExpression* GE;
cmCustomCommandLines CommandLines;
std::vector<std::vector<std::string>> EmulatorsWithArguments;
+ std::vector<std::string> Byproducts;
std::vector<std::string> Depends;
std::string WorkingDirectory;
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/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx
index 654714e..11844e4 100644
--- a/Source/cmFLTKWrapUICommand.cxx
+++ b/Source/cmFLTKWrapUICommand.cxx
@@ -77,16 +77,15 @@ bool cmFLTKWrapUICommand(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;
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index e33ba2d..96ea071 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1269,8 +1269,8 @@ Json::Value Target::DumpLinkCommandFragments()
std::string linkLanguageFlags;
std::vector<BT<std::string>> linkFlags;
std::string frameworkPath;
- std::string linkPath;
- std::string linkLibs;
+ std::vector<BT<std::string>> linkPath;
+ std::vector<BT<std::string>> linkLibs;
cmLocalGenerator* lg = this->GT->GetLocalGenerator();
cmLinkLineComputer linkLineComputer(lg,
lg->GetStateSnapshot().GetDirectory());
@@ -1279,8 +1279,6 @@ Json::Value Target::DumpLinkCommandFragments()
this->GT);
linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags);
frameworkPath = cmTrimWhitespace(frameworkPath);
- linkPath = cmTrimWhitespace(linkPath);
- linkLibs = cmTrimWhitespace(linkLibs);
if (!linkLanguageFlags.empty()) {
linkFragments.append(
@@ -1301,13 +1299,19 @@ Json::Value Target::DumpLinkCommandFragments()
}
if (!linkPath.empty()) {
- linkFragments.append(
- this->DumpCommandFragment(std::move(linkPath), "libraryPath"));
+ for (BT<std::string> frag : linkPath) {
+ frag.Value = cmTrimWhitespace(frag.Value);
+ linkFragments.append(
+ this->DumpCommandFragment(this->ToJBT(frag), "libraryPath"));
+ }
}
if (!linkLibs.empty()) {
- linkFragments.append(
- this->DumpCommandFragment(std::move(linkLibs), "libraries"));
+ for (BT<std::string> frag : linkLibs) {
+ frag.Value = cmTrimWhitespace(frag.Value);
+ linkFragments.append(
+ this->DumpCommandFragment(this->ToJBT(frag), "libraries"));
+ }
}
return linkFragments;
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index 33acd05..4701d29 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -274,9 +274,8 @@ bool HandleHashCommand(std::vector<std::string> const& args,
{
#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
@@ -287,16 +286,12 @@ bool HandleHashCommand(std::vector<std::string> const& args,
status.GetMakefile().AddDefinition(args[2], out);
return true;
}
- std::ostringstream e;
- e << args[0] << " failed to read file \"" << args[1]
- << "\": " << cmSystemTools::GetLastSystemError();
- status.SetError(e.str());
+ status.SetError(cmStrCat(args[0], " failed to read file \"", args[1],
+ "\": ", cmSystemTools::GetLastSystemError()));
}
return false;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- status.SetError(e.str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
@@ -376,30 +371,24 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (arg_mode == arg_limit_input) {
if (sscanf(args[i].c_str(), "%d", &limit_input) != 1 ||
limit_input < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_INPUT value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_INPUT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
arg_mode = arg_none;
} else if (arg_mode == arg_limit_output) {
if (sscanf(args[i].c_str(), "%d", &limit_output) != 1 ||
limit_output < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_OUTPUT value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_OUTPUT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
arg_mode = arg_none;
} else if (arg_mode == arg_limit_count) {
int count;
if (sscanf(args[i].c_str(), "%d", &count) != 1 || count < 0) {
- std::ostringstream e;
- e << "STRINGS option LIMIT_COUNT value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LIMIT_COUNT value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
limit_count = count;
@@ -407,10 +396,8 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (arg_mode == arg_length_minimum) {
int len;
if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
- std::ostringstream e;
- e << "STRINGS option LENGTH_MINIMUM value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LENGTH_MINIMUM value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
minlen = len;
@@ -418,20 +405,16 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (arg_mode == arg_length_maximum) {
int len;
if (sscanf(args[i].c_str(), "%d", &len) != 1 || len < 0) {
- std::ostringstream e;
- e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i]
- << "\" is not an unsigned integer.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option LENGTH_MAXIMUM value \"",
+ args[i], "\" is not an unsigned integer."));
return false;
}
maxlen = len;
arg_mode = arg_none;
} else if (arg_mode == arg_regex) {
if (!regex.compile(args[i])) {
- std::ostringstream e;
- e << "STRINGS option REGEX value \"" << args[i]
- << "\" could not be compiled.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option REGEX value \"", args[i],
+ "\" could not be compiled."));
return false;
}
have_regex = true;
@@ -448,16 +431,14 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
} else if (args[i] == "UTF-32BE") {
encoding = encoding_utf32be;
} else {
- std::ostringstream e;
- e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("STRINGS option ENCODING \"", args[i],
+ "\" not recognized."));
return false;
}
arg_mode = arg_none;
} else {
- std::ostringstream e;
- e << "STRINGS given unknown argument \"" << args[i] << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("STRINGS given unknown argument \"", args[i], "\""));
return false;
}
}
@@ -479,9 +460,8 @@ bool HandleStringsCommand(std::vector<std::string> const& args,
cmsys::ifstream fin(fileName.c_str());
#endif
if (!fin) {
- std::ostringstream e;
- e << "STRINGS file \"" << fileName << "\" cannot be read.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("STRINGS file \"", fileName, "\" cannot be read."));
return false;
}
@@ -963,9 +943,7 @@ bool HandleDifferentCommand(std::vector<std::string> const& args,
file_rhs = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "DIFFERENT given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(cmStrCat("DIFFERENT given unknown argument ", args[i]));
return false;
}
}
@@ -1027,9 +1005,8 @@ bool HandleRPathChangeCommand(std::vector<std::string> const& args,
newRPath = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_CHANGE given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHANGE given unknown argument ", args[i]));
return false;
}
}
@@ -1046,9 +1023,8 @@ bool HandleRPathChangeCommand(std::vector<std::string> const& args,
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
- std::ostringstream e;
- e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHANGE given FILE \"", file, "\" that does not exist."));
return false;
}
bool success = true;
@@ -1058,15 +1034,9 @@ bool HandleRPathChangeCommand(std::vector<std::string> const& args,
if (!cmSystemTools::ChangeRPath(file, oldRPath, newRPath,
removeEnvironmentRPath, &emsg, &changed)) {
- std::ostringstream e;
- /* clang-format off */
- e << "RPATH_CHANGE could not write new RPATH:\n"
- << " " << newRPath << "\n"
- << "to the file:\n"
- << " " << file << "\n"
- << emsg;
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(cmStrCat("RPATH_CHANGE could not write new RPATH:\n ",
+ newRPath, "\nto the file:\n ", file, "\n",
+ emsg));
success = false;
}
if (success) {
@@ -1098,9 +1068,8 @@ bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
file = args[i];
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_REMOVE given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE given unknown argument ", args[i]));
return false;
}
}
@@ -1109,9 +1078,8 @@ bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
return false;
}
if (!cmSystemTools::FileExists(file, true)) {
- std::ostringstream e;
- e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE given FILE \"", file, "\" that does not exist."));
return false;
}
bool success = true;
@@ -1119,13 +1087,9 @@ bool HandleRPathRemoveCommand(std::vector<std::string> const& args,
std::string emsg;
bool removed;
if (!cmSystemTools::RemoveRPath(file, &emsg, &removed)) {
- std::ostringstream e;
- /* clang-format off */
- e << "RPATH_REMOVE could not remove RPATH from file:\n"
- << " " << file << "\n"
- << emsg;
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_REMOVE could not remove RPATH from file: \n ", file,
+ "\n", emsg));
success = false;
}
if (success) {
@@ -1164,9 +1128,8 @@ bool HandleRPathCheckCommand(std::vector<std::string> const& args,
rpath = args[i].c_str();
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "RPATH_CHECK given unknown argument " << args[i];
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("RPATH_CHECK given unknown argument ", args[i]));
return false;
}
}
@@ -1215,9 +1178,8 @@ bool HandleReadElfCommand(std::vector<std::string> const& args,
Arguments const arguments = parser.Parse(cmMakeRange(args).advance(2));
if (!cmSystemTools::FileExists(fileNameArg, true)) {
- std::ostringstream e;
- e << "READ_ELF given FILE \"" << fileNameArg << "\" that does not exist.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("READ_ELF given FILE \"", fileNameArg,
+ "\" that does not exist."));
return false;
}
@@ -1311,15 +1273,8 @@ bool HandleRename(std::vector<std::string> const& args,
if (!cmSystemTools::RenameFile(oldname, newname)) {
std::string err = cmSystemTools::GetLastSystemError();
- std::ostringstream e;
- /* clang-format off */
- e << "RENAME failed to rename\n"
- << " " << oldname << "\n"
- << "to\n"
- << " " << newname << "\n"
- << "because: " << err << "\n";
- /* clang-format on */
- status.SetError(e.str());
+ status.SetError(cmStrCat("RENAME failed to rename\n ", oldname,
+ "\nto\n ", newname, "\nbecause: ", err, "\n"));
return false;
}
return true;
@@ -1494,10 +1449,8 @@ public:
bool updated = (OldPercentage != this->CurrentPercentage);
if (updated) {
- std::ostringstream oss;
- oss << "[" << this->Text << " " << this->CurrentPercentage
- << "% complete]";
- status = oss.str();
+ status =
+ cmStrCat("[", this->Text, " ", this->CurrentPercentage, "% complete]");
}
return updated;
@@ -1743,9 +1696,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
msg = cmStrCat("returning early; file already exists with expected ",
hashMatchMSG, '"');
if (!statusVar.empty()) {
- std::ostringstream result;
- result << 0 << ";\"" << msg;
- status.GetMakefile().AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(statusVar, cmStrCat(0, ";\"", msg));
}
return true;
}
@@ -1891,10 +1842,9 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
::curl_easy_cleanup(curl);
if (!statusVar.empty()) {
- std::ostringstream result;
- result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
- << "\"";
- status.GetMakefile().AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(
+ statusVar,
+ cmStrCat(static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\""));
}
::curl_global_cleanup();
@@ -1914,14 +1864,6 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
}
if (expectedHash != actualHash) {
- std::ostringstream oss;
- oss << "DOWNLOAD HASH mismatch" << std::endl
- << " for file: [" << file << "]" << std::endl
- << " expected hash: [" << expectedHash << "]" << std::endl
- << " actual hash: [" << actualHash << "]" << std::endl
- << " status: [" << static_cast<int>(res) << ";\""
- << ::curl_easy_strerror(res) << "\"]" << std::endl;
-
if (!statusVar.empty() && res == 0) {
status.GetMakefile().AddDefinition(statusVar,
"1;HASH mismatch: "
@@ -1930,7 +1872,19 @@ bool HandleDownloadCommand(std::vector<std::string> const& args,
" actual: " + actualHash);
}
- status.SetError(oss.str());
+ status.SetError(cmStrCat("DOWNLOAD HASH mismatch\n"
+ " for file: [",
+ file,
+ "]\n"
+ " expected hash: [",
+ expectedHash,
+ "]\n"
+ " actual hash: [",
+ actualHash,
+ "]\n"
+ " status: [",
+ static_cast<int>(res), ";\"",
+ ::curl_easy_strerror(res), "\"]\n"));
return false;
}
}
@@ -2180,10 +2134,9 @@ bool HandleUploadCommand(std::vector<std::string> const& args,
::curl_easy_cleanup(curl);
if (!statusVar.empty()) {
- std::ostringstream result;
- result << static_cast<int>(res) << ";\"" << ::curl_easy_strerror(res)
- << "\"";
- status.GetMakefile().AddDefinition(statusVar, result.str());
+ status.GetMakefile().AddDefinition(
+ statusVar,
+ cmStrCat(static_cast<int>(res), ";\"", ::curl_easy_strerror(res), "\""));
}
::curl_global_cleanup();
@@ -2322,9 +2275,9 @@ bool HandleLockCommand(std::vector<std::string> const& args,
} else if (args[i] == "PROCESS") {
guard = GUARD_PROCESS;
} else {
- std::ostringstream e;
- e << merr << ", but got:\n \"" << args[i] << "\".";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(merr, ", but got:\n \"", args[i], "\"."));
return false;
}
@@ -2346,17 +2299,18 @@ bool HandleLockCommand(std::vector<std::string> const& args,
}
long scanned;
if (!cmStrToLong(args[i], &scanned) || scanned < 0) {
- std::ostringstream e;
- e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer.";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("TIMEOUT value \"", args[i],
+ "\" is not an unsigned integer."));
return false;
}
timeout = static_cast<unsigned long>(scanned);
} else {
- std::ostringstream e;
- e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n";
- e << "but got: \"" << args[i] << "\".";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or ",
+ "TIMEOUT\nbut got: \"", args[i], "\"."));
return false;
}
}
@@ -2375,18 +2329,19 @@ bool HandleLockCommand(std::vector<std::string> const& args,
// Create file and directories if needed
std::string parentDir = cmSystemTools::GetParentDirectory(path);
if (!cmSystemTools::MakeDirectory(parentDir)) {
- std::ostringstream e;
- e << "directory\n \"" << parentDir << "\"\ncreation failed ";
- e << "(check permissions).";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("directory\n \"", parentDir,
+ "\"\ncreation failed (check permissions)."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
FILE* file = cmsys::SystemTools::Fopen(path, "w");
if (!file) {
- std::ostringstream e;
- e << "file\n \"" << path << "\"\ncreation failed (check permissions).";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("file\n \"", path,
+ "\"\ncreation failed (check permissions)."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2419,9 +2374,9 @@ bool HandleLockCommand(std::vector<std::string> const& args,
const std::string result = fileLockResult.GetOutputMessage();
if (resultVariable.empty() && !fileLockResult.IsOk()) {
- std::ostringstream e;
- e << "error locking file\n \"" << path << "\"\n" << result << ".";
- status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("error locking file\n \"", path, "\"\n", result, "."));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2485,9 +2440,8 @@ bool HandleSizeCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
@@ -2498,9 +2452,8 @@ bool HandleSizeCommand(std::vector<std::string> const& args,
const std::string& outputVariable = args[argsIndex++];
if (!cmSystemTools::FileExists(filename, true)) {
- std::ostringstream e;
- e << "SIZE requested of path that is not readable:\n " << filename;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("SIZE requested of path that is not readable:\n ", filename));
return false;
}
@@ -2514,9 +2467,8 @@ bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires a file name and output variable";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires a file name and output variable"));
return false;
}
@@ -2525,10 +2477,8 @@ bool HandleReadSymlinkCommand(std::vector<std::string> const& args,
std::string result;
if (!cmSystemTools::ReadSymlink(filename, result)) {
- std::ostringstream e;
- e << "READ_SYMLINK requested of path that is not a symlink:\n "
- << filename;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "READ_SYMLINK requested of path that is not a symlink:\n ", filename));
return false;
}
@@ -2655,10 +2605,9 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
std::string platform =
status.GetMakefile().GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME");
if (!supportedPlatforms.count(platform)) {
- std::ostringstream e;
- e << "GET_RUNTIME_DEPENDENCIES is not supported on system \"" << platform
- << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("GET_RUNTIME_DEPENDENCIES is not supported on system \"",
+ platform, "\""));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2718,17 +2667,13 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
&keywordsMissingValues);
auto argIt = unrecognizedArguments.begin();
if (argIt != unrecognizedArguments.end()) {
- std::ostringstream e;
- e << "Unrecognized argument: \"" << *argIt << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("Unrecognized argument: \"", *argIt, "\""));
cmSystemTools::SetFatalErrorOccured();
return false;
}
argIt = keywordsMissingValues.begin();
if (argIt != keywordsMissingValues.end()) {
- std::ostringstream e;
- e << "Keyword missing value: " << *argIt;
- status.SetError(e.str());
+ status.SetError(cmStrCat("Keyword missing value: ", *argIt));
cmSystemTools::SetFatalErrorOccured();
return false;
}
@@ -2792,9 +2737,7 @@ bool HandleGetRuntimeDependenciesCommand(std::vector<std::string> const& args,
} else {
auto it = archive.GetUnresolvedPaths().begin();
assert(it != archive.GetUnresolvedPaths().end());
- std::ostringstream e;
- e << "Could not resolve file " << *it;
- status.SetError(e.str());
+ status.SetError(cmStrCat("Could not resolve file ", *it));
cmSystemTools::SetFatalErrorOccured();
return false;
}
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 8c8cf13..fea7e08 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -348,11 +348,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
} else if (doing == DoingConfigs) {
if (args[i].find_first_of(":/\\") != std::string::npos ||
cmSystemTools::GetFilenameLastExtension(args[i]) != ".cmake") {
- std::ostringstream e;
- e << "given CONFIGS option followed by invalid file name \"" << args[i]
- << "\". The names given must be file names without "
- << "a path and with a \".cmake\" extension.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ "given CONFIGS option followed by invalid file name \"", args[i],
+ "\". The names given must be file names without "
+ "a path and with a \".cmake\" extension."));
return false;
}
this->Configs.push_back(args[i]);
@@ -360,9 +359,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
haveVersion = true;
this->Version = args[i];
} else {
- std::ostringstream e;
- e << "called with invalid argument \"" << args[i] << "\"";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("called with invalid argument \"", args[i], "\""));
return false;
}
}
@@ -372,10 +370,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
optionalComponents.begin(), optionalComponents.end(),
std::back_inserter(doubledComponents));
if (!doubledComponents.empty()) {
- std::ostringstream e;
- e << "called with components that are both required and optional:\n";
- e << cmWrap(" ", doubledComponents, "", "\n") << "\n";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("called with components that are both required and "
+ "optional:\n",
+ cmWrap(" ", doubledComponents, "", "\n"), "\n"));
return false;
}
@@ -459,11 +457,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
cmStrCat("CMAKE_DISABLE_FIND_PACKAGE_", this->Name);
if (this->Makefile->IsOn(disableFindPackageVar)) {
if (this->Required) {
- std::ostringstream e;
- e << "for module " << this->Name << " called with REQUIRED, but "
- << disableFindPackageVar
- << " is enabled. A REQUIRED package cannot be disabled.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("for module ", this->Name, " called with REQUIRED, but ",
+ disableFindPackageVar,
+ " is enabled. A REQUIRED package cannot be disabled."));
return false;
}
@@ -701,9 +698,9 @@ bool cmFindPackageCommand::FindModule(bool& found)
this->Makefile->GetPolicyStatus(it->second);
switch (status) {
case cmPolicies::WARN: {
- std::ostringstream e;
- e << cmPolicies::GetPolicyWarning(it->second) << "\n";
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(it->second), "\n"));
CM_FALLTHROUGH;
}
case cmPolicies::OLD:
@@ -934,10 +931,10 @@ bool cmFindPackageCommand::HandlePackageMode(
}
// output result if in config mode but not in quiet mode
else if (!this->Quiet) {
- std::ostringstream aw;
- aw << "Could NOT find " << this->Name << " (missing: " << this->Name
- << "_DIR)";
- this->Makefile->DisplayStatus(aw.str(), -1);
+ this->Makefile->DisplayStatus(cmStrCat("Could NOT find ", this->Name,
+ " (missing: ", this->Name,
+ "_DIR)"),
+ -1);
}
}
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 3c39c46..d563a1d 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -4,7 +4,6 @@
#include <cstdio>
#include <cstdlib>
-#include <sstream>
#include <utility>
#include "cm_memory.hxx"
@@ -146,10 +145,9 @@ bool cmForEachCommand(std::vector<std::string> const& args,
}
if ((start > stop && step > 0) || (start < stop && step < 0) ||
step == 0) {
- std::ostringstream str;
- str << "called with incorrect range specification: start ";
- str << start << ", stop " << stop << ", step " << step;
- status.SetError(str.str());
+ status.SetError(
+ cmStrCat("called with incorrect range specification: start ", start,
+ ", stop ", stop, ", step ", step));
return false;
}
std::vector<std::string> range;
@@ -204,10 +202,9 @@ bool HandleInMode(std::vector<std::string> const& args, cmMakefile& makefile)
cmExpandList(value, fb->Args, true);
}
} else {
- std::ostringstream e;
- e << "Unknown argument:\n"
- << " " << args[i] << "\n";
- makefile.IssueMessage(MessageType::FATAL_ERROR, e.str());
+ makefile.IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Unknown argument:\n", " ", args[i], "\n"));
return true;
}
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 2ca5706..ce9699b 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -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"
@@ -3371,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;
}
@@ -3440,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")) {
@@ -3449,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);
}
- 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();
+ }
+ 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;
}
@@ -3696,7 +3745,7 @@ void processLinkDirectories(cmGeneratorTarget const* tgt,
// in case projects set the LINK_DIRECTORIES property directly.
cmSystemTools::ConvertToUnixSlashes(entryDirectory);
if (uniqueDirectories.insert(entryDirectory).second) {
- directories.emplace_back(entryDirectory);
+ directories.emplace_back(entryDirectory, entry.Backtrace);
if (debugDirectories) {
usedDirectories += " * " + entryDirectory + "\n";
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 4207d65..6c36c4b 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -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/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx
index e8e87e7..947d893 100644
--- a/Source/cmGetPropertyCommand.cxx
+++ b/Source/cmGetPropertyCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGetPropertyCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmInstalledFile.h"
@@ -99,11 +97,11 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
} else if (args[1] == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
- std::ostringstream e;
- e << "given invalid scope " << args[1] << ". "
- << "Valid scopes are "
- << "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL.";
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "given invalid scope ", args[1],
+ ". "
+ "Valid scopes are "
+ "GLOBAL, DIRECTORY, TARGET, SOURCE, TEST, VARIABLE, CACHE, INSTALL."));
return false;
}
@@ -138,9 +136,7 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args,
doing = DoingNone;
propertyName = args[i];
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << args[i] << "\".";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", args[i], "\"."));
return false;
}
}
@@ -331,10 +327,8 @@ bool HandleTargetMode(cmExecutionStatus& status, const std::string& name,
}
return StoreResult(infoType, status.GetMakefile(), variable, prop_cstr);
}
- std::ostringstream e;
- e << "could not find TARGET " << name
- << ". Perhaps it has not yet been created.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("could not find TARGET ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
@@ -352,9 +346,8 @@ bool HandleSourceMode(cmExecutionStatus& status, const std::string& name,
return StoreResult(infoType, status.GetMakefile(), variable,
sf->GetPropertyForUser(propertyName));
}
- std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given SOURCE name that could not be found or created: ", name));
return false;
}
@@ -374,9 +367,7 @@ bool HandleTestMode(cmExecutionStatus& status, const std::string& name,
}
// If not found it is an error.
- std::ostringstream e;
- e << "given TEST name that does not exist: " << name;
- status.SetError(e.str());
+ status.SetError(cmStrCat("given TEST name that does not exist: ", name));
return false;
}
@@ -431,9 +422,8 @@ bool HandleInstallMode(cmExecutionStatus& status, const std::string& name,
return StoreResult(infoType, status.GetMakefile(), variable,
isSet ? value.c_str() : nullptr);
}
- std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given INSTALL name that could not be found or created: ", name));
return false;
}
}
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 18ff9ac..255739d 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -3,6 +3,7 @@
#include "cmGlobalVisualStudio8Generator.h"
#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorExpression.h"
@@ -146,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());
@@ -173,20 +170,13 @@ 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
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 de04e84..4d41fd7 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -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/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 9b931f7..e7bb1ac 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -293,9 +293,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << "TARGETS given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -391,9 +390,8 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
for (std::string const& tgt : targetList) {
if (this->Makefile->IsAlias(tgt)) {
- std::ostringstream e;
- e << "TARGETS given target \"" << tgt << "\" which is an alias.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given target \"", tgt, "\" which is an alias."));
return false;
}
// Lookup this target in the current directory.
@@ -414,19 +412,17 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
target->GetType() != cmStateEnums::MODULE_LIBRARY &&
target->GetType() != cmStateEnums::OBJECT_LIBRARY &&
target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- std::ostringstream e;
- e << "TARGETS given target \"" << tgt
- << "\" which is not an executable, library, or module.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given target \"", tgt,
+ "\" which is not an executable, library, or module."));
return false;
}
// Store the target in the list to be installed.
targets.push_back(target);
} else {
// Did not find the target.
- std::ostringstream e;
- e << "TARGETS given target \"" << tgt << "\" which does not exist.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given target \"", tgt, "\" which does not exist."));
return false;
}
}
@@ -507,11 +503,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
frameworkGenerator = CreateInstallTargetGenerator(
target, frameworkArgs, false, this->Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no FRAMEWORK DESTINATION for shared library "
- "FRAMEWORK target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given no FRAMEWORK DESTINATION for shared "
+ "library FRAMEWORK target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
@@ -549,11 +544,11 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
frameworkGenerator = CreateInstallTargetGenerator(
target, frameworkArgs, false, this->Makefile->GetBacktrace());
} else {
- std::ostringstream e;
- e << "TARGETS given no FRAMEWORK DESTINATION for static library "
- "FRAMEWORK target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given no FRAMEWORK DESTINATION for static "
+ "library FRAMEWORK target \"",
+ target.GetName(), "\"."));
+
return false;
}
} else {
@@ -572,10 +567,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
namelinkOnly =
(namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
} else {
- std::ostringstream e;
- e << "TARGETS given no LIBRARY DESTINATION for module target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given no LIBRARY DESTINATION for module "
+ "target \"",
+ target.GetName(), "\"."));
return false;
}
} break;
@@ -586,10 +581,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
std::string reason;
if (!this->Makefile->GetGlobalGenerator()
->HasKnownObjectFileLocation(&reason)) {
- std::ostringstream e;
- e << "TARGETS given OBJECT library \"" << target.GetName()
- << "\" whose objects may not be installed" << reason << ".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat("TARGETS given OBJECT library \"", target.GetName(),
+ "\" whose objects may not be installed", reason, "."));
return false;
}
@@ -619,11 +613,9 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
}
}
if (!bundleGenerator) {
- std::ostringstream e;
- e << "TARGETS given no BUNDLE DESTINATION for MACOSX_BUNDLE "
- "executable target \""
- << target.GetName() << "\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat("TARGETS given no BUNDLE DESTINATION for "
+ "MACOSX_BUNDLE executable target \"",
+ target.GetName(), "\"."));
return false;
}
} else {
@@ -708,10 +700,10 @@ bool cmInstallCommand::HandleTargetsMode(std::vector<std::string> const& args)
resourceGenerator = CreateInstallFilesGenerator(
this->Makefile, absFiles, resourceArgs, false);
} else {
- std::ostringstream e;
- e << "INSTALL TARGETS - target " << target.GetName() << " has "
- << "RESOURCE files but no RESOURCE DESTINATION.";
- cmSystemTools::Message(e.str(), "Warning");
+ cmSystemTools::Message(
+ cmStrCat("INSTALL TARGETS - target ", target.GetName(),
+ " has RESOURCE files but no RESOURCE DESTINATION."),
+ "Warning");
}
}
}
@@ -820,17 +812,15 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
std::string type = ica.GetType();
if (!type.empty() && allowedTypes.count(type) == 0) {
- std::ostringstream e;
- e << args[0] << " given non-type \"" << type << "\" with TYPE argument.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given non-type \"", type, "\" with TYPE argument."));
return false;
}
@@ -843,9 +833,8 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
if (!ica.GetRename().empty() && filesVector.size() > 1) {
// The rename option works only with one file.
- std::ostringstream e;
- e << args[0] << " given RENAME option with more than one file.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given RENAME option with more than one file."));
return false;
}
@@ -897,20 +886,16 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args)
}
if (!type.empty() && !ica.GetDestination().empty()) {
- std::ostringstream e;
- e << args[0]
- << " given both TYPE and DESTINATION arguments. You may only specify "
- "one.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0],
+ " given both TYPE and DESTINATION arguments. "
+ "You may only specify one."));
return false;
}
std::string destination = this->GetDestinationForType(&ica, type);
if (destination.empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
@@ -959,10 +944,8 @@ bool cmInstallCommand::HandleDirectoryMode(
for (unsigned int i = 1; i < args.size(); ++i) {
if (args[i] == "DESTINATION") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -970,10 +953,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingDestination;
} else if (args[i] == "TYPE") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -981,10 +962,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingType;
} else if (args[i] == "OPTIONAL") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -993,10 +972,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "MESSAGE_NEVER") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1014,20 +991,16 @@ bool cmInstallCommand::HandleDirectoryMode(
} else if (args[i] == "EXCLUDE") {
// Add this property to the current match rule.
if (!in_match_mode || doing == DoingPattern || doing == DoingRegex) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" before a PATTERN or REGEX is given."));
return false;
}
literal_args += " EXCLUDE";
doing = DoingNone;
} else if (args[i] == "PERMISSIONS") {
if (!in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" before a PATTERN or REGEX is given.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" before a PATTERN or REGEX is given."));
return false;
}
@@ -1036,10 +1009,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsMatch;
} else if (args[i] == "FILE_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1047,10 +1018,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsFile;
} else if (args[i] == "DIRECTORY_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1058,10 +1027,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingPermsDir;
} else if (args[i] == "USE_SOURCE_PERMISSIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1070,10 +1037,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "FILES_MATCHING") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1082,10 +1047,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (args[i] == "CONFIGURATIONS") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1093,10 +1056,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingConfigurations;
} else if (args[i] == "COMPONENT") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
@@ -1104,10 +1065,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingComponent;
} else if (args[i] == "EXCLUDE_FROM_ALL") {
if (in_match_mode) {
- std::ostringstream e;
- e << args[0] << " does not allow \"" << args[i]
- << "\" after PATTERN or REGEX.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " does not allow \"", args[i],
+ "\" after PATTERN or REGEX."));
return false;
}
exclude_from_all = true;
@@ -1124,10 +1083,8 @@ bool cmInstallCommand::HandleDirectoryMode(
// Make sure the name is a directory.
if (cmSystemTools::FileExists(dir) &&
!cmSystemTools::FileIsDirectory(dir)) {
- std::ostringstream e;
- e << args[0] << " given non-directory \"" << args[i]
- << "\" to install.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given non-directory \"", args[i],
+ "\" to install."));
return false;
}
@@ -1140,10 +1097,8 @@ bool cmInstallCommand::HandleDirectoryMode(
doing = DoingNone;
} else if (doing == DoingType) {
if (allowedTypes.count(args[i]) == 0) {
- std::ostringstream e;
- e << args[0] << " given non-type \"" << args[i]
- << "\" with TYPE argument.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given non-type \"", args[i],
+ "\" with TYPE argument."));
return false;
}
@@ -1179,36 +1134,30 @@ bool cmInstallCommand::HandleDirectoryMode(
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
permissions_file)) {
- std::ostringstream e;
- e << args[0] << " given invalid file permission \"" << args[i]
- << "\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given invalid file permission \"",
+ args[i], "\"."));
return false;
}
} else if (doing == DoingPermsDir) {
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
permissions_dir)) {
- std::ostringstream e;
- e << args[0] << " given invalid directory permission \"" << args[i]
- << "\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ args[0], " given invalid directory permission \"", args[i], "\"."));
return false;
}
} else if (doing == DoingPermsMatch) {
// Check the requested permission.
if (!cmInstallCommandArguments::CheckPermissions(args[i],
literal_args)) {
- std::ostringstream e;
- e << args[0] << " given invalid permission \"" << args[i] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given invalid permission \"", args[i], "\"."));
return false;
}
} else {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << args[i] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", args[i], "\"."));
return false;
}
}
@@ -1226,19 +1175,15 @@ bool cmInstallCommand::HandleDirectoryMode(
if (!destination) {
if (type.empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
destinationStr = this->GetDestinationForType(nullptr, type);
destination = destinationStr.c_str();
} else if (!type.empty()) {
- std::ostringstream e;
- e << args[0]
- << " given both TYPE and DESTINATION arguments. You may only specify "
- "one.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0],
+ " given both TYPE and DESTINATION "
+ "arguments. You may only specify one."));
return false;
}
@@ -1280,9 +1225,8 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -1293,39 +1237,35 @@ bool cmInstallCommand::HandleExportAndroidMKMode(
// Make sure there is a destination.
if (ica.GetDestination().empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Check the file name.
std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument may not contain a path. "
- << "Specify the path in the DESTINATION argument.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given invalid export file name \"",
+ fname,
+ "\". The FILE argument may not contain a path. "
+ "Specify the path in the DESTINATION argument."));
return false;
}
// Check the file extension.
if (!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".mk") {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument must specify a name ending in \".mk\".";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ args[0], " given invalid export file name \"", fname,
+ R"(". The FILE argument must specify a name ending in ".mk".)"));
return false;
}
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given export name \"" << exp << "\". "
- << "This name cannot be safely converted to a file name. "
- << "Specify a different export name or use the FILE option to set "
- << "a file name explicitly.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given export name \"", exp,
+ "\". "
+ "This name cannot be safely converted to a file name. "
+ "Specify a different export name or use the FILE option to set "
+ "a file name explicitly."));
return false;
}
// Use the default name
@@ -1375,9 +1315,8 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
if (!unknownArgs.empty()) {
// Unknown argument.
- std::ostringstream e;
- e << args[0] << " given unknown argument \"" << unknownArgs[0] << "\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given unknown argument \"", unknownArgs[0], "\"."));
return false;
}
@@ -1388,30 +1327,28 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
// Make sure there is a destination.
if (ica.GetDestination().empty()) {
// A destination is required.
- std::ostringstream e;
- e << args[0] << " given no DESTINATION!";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given no DESTINATION!"));
return false;
}
// Check the file name.
std::string fname = filename;
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument may not contain a path. "
- << "Specify the path in the DESTINATION argument.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(args[0], " given invalid export file name \"",
+ fname,
+ "\". "
+ "The FILE argument may not contain a path. "
+ "Specify the path in the DESTINATION argument."));
return false;
}
// Check the file extension.
if (!fname.empty() &&
cmSystemTools::GetFilenameLastExtension(fname) != ".cmake") {
- std::ostringstream e;
- e << args[0] << " given invalid export file name \"" << fname << "\". "
- << "The FILE argument must specify a name ending in \".cmake\".";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(args[0], " given invalid export file name \"", fname,
+ "\". "
+ "The FILE argument must specify a name ending in \".cmake\"."));
return false;
}
@@ -1420,12 +1357,12 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
fname = cmStrCat(exp, ".cmake");
if (fname.find_first_of(":/\\") != std::string::npos) {
- std::ostringstream e;
- e << args[0] << " given export name \"" << exp << "\". "
- << "This name cannot be safely converted to a file name. "
- << "Specify a different export name or use the FILE option to set "
- << "a file name explicitly.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ args[0], " given export name \"", exp,
+ "\". "
+ "This name cannot be safely converted to a file name. "
+ "Specify a different export name or use the FILE option to set "
+ "a file name explicitly."));
return false;
}
}
@@ -1441,12 +1378,10 @@ bool cmInstallCommand::HandleExportMode(std::vector<std::string> const& args)
tgt->GetPolicyStatusCMP0022() != cmPolicies::OLD);
if (!newCMP0022Behavior) {
- std::ostringstream e;
- e << "INSTALL(EXPORT) given keyword \""
- << "EXPORT_LINK_INTERFACE_LIBRARIES"
- << "\", but target \"" << te->TargetName
- << "\" does not have policy CMP0022 set to NEW.";
- this->SetError(e.str());
+ this->SetError(cmStrCat(
+ "INSTALL(EXPORT) given keyword \""
+ "EXPORT_LINK_INTERFACE_LIBRARIES\", but target \"",
+ te->TargetName, "\" does not have policy CMP0022 set to NEW."));
return false;
}
}
@@ -1480,9 +1415,8 @@ bool cmInstallCommand::MakeFilesFullPath(
// Make sure the file is not a directory.
if (gpos == std::string::npos && cmSystemTools::FileIsDirectory(file)) {
- std::ostringstream e;
- e << modeName << " given directory \"" << relFile << "\" to install.";
- this->SetError(e.str());
+ this->SetError(
+ cmStrCat(modeName, " given directory \"", relFile, "\" to install."));
return false;
}
// Store the file for installation.
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index 91c551f..0dc6236 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -4,10 +4,13 @@
#include "cmLinkLineComputer.h"
#include <sstream>
+#include <utility>
#include <vector>
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
+#include "cmLinkItem.h"
+#include "cmListFileCache.h"
#include "cmOutputConverter.h"
#include "cmStateDirectory.h"
#include "cmStateTypes.h"
@@ -56,6 +59,15 @@ std::string cmLinkLineComputer::ConvertToLinkReference(
std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli)
{
std::string linkLibs;
+ std::vector<BT<std::string>> linkLibsList;
+ this->ComputeLinkLibs(cli, linkLibsList);
+ cli.AppendValues(linkLibs, linkLibsList);
+ return linkLibs;
+}
+
+void cmLinkLineComputer::ComputeLinkLibs(
+ cmComputeLinkInformation& cli, std::vector<BT<std::string>>& linkLibraries)
+{
using ItemVector = cmComputeLinkInformation::ItemVector;
ItemVector const& items = cli.GetItems();
for (auto const& item : items) {
@@ -63,16 +75,33 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli)
item.Target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
+
+ BT<std::string> linkLib;
if (item.IsPath) {
- linkLibs += cli.GetLibLinkFileFlag();
- linkLibs +=
+ linkLib.Value += cli.GetLibLinkFileFlag();
+ linkLib.Value +=
this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value));
} else {
- linkLibs += item.Value;
+ linkLib.Value += item.Value;
}
- linkLibs += " ";
+ linkLib.Value += " ";
+
+ const cmLinkImplementation* linkImpl =
+ cli.GetTarget()->GetLinkImplementation(cli.GetConfig());
+
+ for (const cmLinkImplItem& iter : linkImpl->Libraries) {
+ if (iter.Target != nullptr &&
+ iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ std::string libPath = iter.Target->GetLocation(cli.GetConfig());
+ if (item.Value == libPath) {
+ linkLib.Backtrace = iter.Backtrace;
+ break;
+ }
+ }
+ }
+
+ linkLibraries.emplace_back(linkLib);
}
- return linkLibs;
}
std::string cmLinkLineComputer::ConvertToOutputFormat(std::string const& input)
@@ -101,8 +130,19 @@ std::string cmLinkLineComputer::ComputeLinkPath(
std::string const& libPathTerminator)
{
std::string linkPath;
+ std::vector<BT<std::string>> linkPathList;
+ this->ComputeLinkPath(cli, libPathFlag, libPathTerminator, linkPathList);
+ cli.AppendValues(linkPath, linkPathList);
+ return linkPath;
+}
+void cmLinkLineComputer::ComputeLinkPath(
+ cmComputeLinkInformation& cli, std::string const& libPathFlag,
+ std::string const& libPathTerminator, std::vector<BT<std::string>>& linkPath)
+{
if (cli.GetLinkLanguage() == "Swift") {
+ std::string linkPathNoBT;
+
for (const cmComputeLinkInformation::Item& item : cli.GetItems()) {
const cmGeneratorTarget* target = item.Target;
if (!target) {
@@ -116,20 +156,23 @@ std::string cmLinkLineComputer::ComputeLinkPath(
type = cmStateEnums::ImportLibraryArtifact;
}
- linkPath += cmStrCat(" ", libPathFlag,
- item.Target->GetDirectory(cli.GetConfig(), type),
- libPathTerminator, " ");
+ linkPathNoBT += cmStrCat(
+ " ", libPathFlag, item.Target->GetDirectory(cli.GetConfig(), type),
+ libPathTerminator, " ");
}
}
- }
- for (std::string const& libDir : cli.GetDirectories()) {
- linkPath +=
- cmStrCat(" ", libPathFlag, this->ConvertToOutputForExisting(libDir),
- libPathTerminator, " ");
+ if (!linkPathNoBT.empty()) {
+ linkPath.emplace_back(std::move(linkPathNoBT));
+ }
}
- return linkPath;
+ for (BT<std::string> libDir : cli.GetDirectoriesWithBacktraces()) {
+ libDir.Value = cmStrCat(" ", libPathFlag,
+ this->ConvertToOutputForExisting(libDir.Value),
+ libPathTerminator, " ");
+ linkPath.emplace_back(libDir);
+ }
}
std::string cmLinkLineComputer::ComputeRPath(cmComputeLinkInformation& cli)
@@ -179,13 +222,30 @@ std::string cmLinkLineComputer::ComputeFrameworkPath(
std::string cmLinkLineComputer::ComputeLinkLibraries(
cmComputeLinkInformation& cli, std::string const& stdLibString)
{
- std::ostringstream fout;
- fout << this->ComputeRPath(cli);
+ std::string linkLibraries;
+ std::vector<BT<std::string>> linkLibrariesList;
+ this->ComputeLinkLibraries(cli, stdLibString, linkLibrariesList);
+ cli.AppendValues(linkLibraries, linkLibrariesList);
+ return linkLibraries;
+}
+
+void cmLinkLineComputer::ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries)
+{
+ std::ostringstream rpathOut;
+ rpathOut << this->ComputeRPath(cli);
+
+ std::string rpath = rpathOut.str();
+ if (!rpath.empty()) {
+ linkLibraries.emplace_back(std::move(rpath));
+ }
// Write the library flags to the build rule.
- fout << this->ComputeLinkLibs(cli);
+ this->ComputeLinkLibs(cli, linkLibraries);
// Add the linker runtime search path if any.
+ std::ostringstream fout;
std::string rpath_link = cli.GetRPathLinkString();
if (!cli.GetRPathLinkFlag().empty() && !rpath_link.empty()) {
fout << cli.GetRPathLinkFlag();
@@ -198,7 +258,10 @@ std::string cmLinkLineComputer::ComputeLinkLibraries(
fout << stdLibString << " ";
}
- return fout.str();
+ std::string remainingLibs = fout.str();
+ if (!remainingLibs.empty()) {
+ linkLibraries.emplace_back(remainingLibs);
+ }
}
std::string cmLinkLineComputer::GetLinkerLanguage(cmGeneratorTarget* target,
diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h
index 2355c32..f426976 100644
--- a/Source/cmLinkLineComputer.h
+++ b/Source/cmLinkLineComputer.h
@@ -7,12 +7,15 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <vector>
#include "cmStateDirectory.h"
class cmComputeLinkInformation;
class cmGeneratorTarget;
class cmOutputConverter;
+template <typename T>
+class BT;
class cmLinkLineComputer
{
@@ -34,17 +37,28 @@ public:
std::string const& libPathFlag,
std::string const& libPathTerminator);
+ void ComputeLinkPath(cmComputeLinkInformation& cli,
+ std::string const& libPathFlag,
+ std::string const& libPathTerminator,
+ std::vector<BT<std::string>>& linkPath);
+
std::string ComputeFrameworkPath(cmComputeLinkInformation& cli,
std::string const& fwSearchFlag);
- virtual std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
- std::string const& stdLibString);
+ std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
+ std::string const& stdLibString);
+
+ virtual void ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries);
virtual std::string GetLinkerLanguage(cmGeneratorTarget* target,
std::string const& config);
protected:
std::string ComputeLinkLibs(cmComputeLinkInformation& cli);
+ void ComputeLinkLibs(cmComputeLinkInformation& cli,
+ std::vector<BT<std::string>>& linkLibraries);
std::string ComputeRPath(cmComputeLinkInformation& cli);
std::string ConvertToOutputFormat(std::string const& input);
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 1a602ca..d845652 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -4,13 +4,14 @@
#include "cmLinkLineDeviceComputer.h"
#include <set>
-#include <sstream>
#include <utility>
#include "cmAlgorithms.h"
#include "cmComputeLinkInformation.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
+#include "cmLinkItem.h"
+#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
#include "cmStateDirectory.h"
@@ -67,12 +68,10 @@ bool cmLinkLineDeviceComputer::ComputeRequiresDeviceLinking(
return false;
}
-std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
- cmComputeLinkInformation& cli, std::string const& stdLibString)
+void cmLinkLineDeviceComputer::ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries)
{
- // Write the library flags to the build rule.
- std::ostringstream fout;
-
// Generate the unique set of link items when device linking.
// The nvcc device linker is designed so that each static library
// with device symbols only needs to be listed once as it doesn't
@@ -110,7 +109,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
}
}
- std::string out;
+ BT<std::string> linkLib;
if (item.IsPath) {
// nvcc understands absolute paths to libraries ending in '.a' or '.lib'.
// These should be passed to nvlink. Other extensions need to be left
@@ -118,7 +117,7 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
// can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
if (cmHasLiteralSuffix(item.Value, ".a") ||
cmHasLiteralSuffix(item.Value, ".lib")) {
- out += this->ConvertToOutputFormat(
+ linkLib.Value += this->ConvertToOutputFormat(
this->ConvertToLinkReference(item.Value));
}
} else if (item.Value == "-framework") {
@@ -127,19 +126,33 @@ std::string cmLinkLineDeviceComputer::ComputeLinkLibraries(
skipItemAfterFramework = true;
continue;
} else if (cmLinkItemValidForDevice(item.Value)) {
- out += item.Value;
+ linkLib.Value += item.Value;
}
- if (emitted.insert(out).second) {
- fout << out << " ";
+ if (emitted.insert(linkLib.Value).second) {
+ linkLib.Value += " ";
+
+ const cmLinkImplementation* linkImpl =
+ cli.GetTarget()->GetLinkImplementation(cli.GetConfig());
+
+ for (const cmLinkImplItem& iter : linkImpl->Libraries) {
+ if (iter.Target != nullptr &&
+ iter.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ std::string libPath = iter.Target->GetLocation(cli.GetConfig());
+ if (item.Value == libPath) {
+ linkLib.Backtrace = iter.Backtrace;
+ break;
+ }
+ }
+ }
+
+ linkLibraries.emplace_back(linkLib);
}
}
if (!stdLibString.empty()) {
- fout << stdLibString << " ";
+ linkLibraries.emplace_back(cmStrCat(stdLibString, ' '));
}
-
- return fout.str();
}
std::string cmLinkLineDeviceComputer::GetLinkerLanguage(cmGeneratorTarget*,
diff --git a/Source/cmLinkLineDeviceComputer.h b/Source/cmLinkLineDeviceComputer.h
index 0ea5f69..a9b01cd 100644
--- a/Source/cmLinkLineDeviceComputer.h
+++ b/Source/cmLinkLineDeviceComputer.h
@@ -7,6 +7,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
+#include <vector>
#include "cmLinkLineComputer.h"
@@ -15,6 +16,8 @@ class cmGeneratorTarget;
class cmLocalGenerator;
class cmOutputConverter;
class cmStateDirectory;
+template <typename T>
+class BT;
class cmLinkLineDeviceComputer : public cmLinkLineComputer
{
@@ -29,8 +32,9 @@ public:
bool ComputeRequiresDeviceLinking(cmComputeLinkInformation& cli);
- std::string ComputeLinkLibraries(cmComputeLinkInformation& cli,
- std::string const& stdLibString) override;
+ void ComputeLinkLibraries(
+ cmComputeLinkInformation& cli, std::string const& stdLibString,
+ std::vector<BT<std::string>>& linkLibraries) override;
std::string GetLinkerLanguage(cmGeneratorTarget* target,
std::string const& config) override;
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 9487e3b..826abf5 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -158,10 +158,8 @@ bool HandleGetCommand(std::vector<std::string> const& args,
item = static_cast<int>(nitem) + item;
}
if (item < 0 || nitem <= static_cast<size_t>(item)) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << nitem << ", "
- << nitem - 1 << ")";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (-", nitem,
+ ", ", nitem - 1, ")"));
return false;
}
value += varArgsExpanded[item];
@@ -366,9 +364,7 @@ bool HandleInsertCommand(std::vector<std::string> const& args,
if ((!GetList(varArgsExpanded, listName, status.GetMakefile()) ||
varArgsExpanded.empty()) &&
item != 0) {
- std::ostringstream str;
- str << "index: " << item << " out of range (0, 0)";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (0, 0)"));
return false;
}
@@ -378,10 +374,9 @@ bool HandleInsertCommand(std::vector<std::string> const& args,
item = static_cast<int>(nitem) + item;
}
if (item < 0 || nitem < static_cast<size_t>(item)) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << varArgsExpanded.size()
- << ", " << varArgsExpanded.size() << ")";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (-",
+ varArgsExpanded.size(), ", ",
+ varArgsExpanded.size(), ")"));
return false;
}
}
@@ -398,10 +393,8 @@ bool HandleJoinCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 4) {
- std::ostringstream error;
- error << "sub-command JOIN requires three arguments (" << args.size() - 1
- << " found).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command JOIN requires three arguments (",
+ args.size() - 1, " found)."));
return false;
}
@@ -596,11 +589,9 @@ protected:
index = static_cast<int>(count) + index;
}
if (index < 0 || count <= static_cast<std::size_t>(index)) {
- std::ostringstream str;
- str << "sub-command TRANSFORM, selector " << this->Tag
- << ", index: " << index << " out of range (-" << count << ", "
- << count - 1 << ").";
- throw transform_error(str.str());
+ throw transform_error(cmStrCat(
+ "sub-command TRANSFORM, selector ", this->Tag, ", index: ", index,
+ " out of range (-", count, ", ", count - 1, ")."));
}
return index;
}
@@ -681,17 +672,14 @@ public:
makefile->ClearMatches();
if (!this->ReplaceHelper.IsRegularExpressionValid()) {
- std::ostringstream error;
- error
- << "sub-command TRANSFORM, action REPLACE: Failed to compile regex \""
- << arguments[0] << "\".";
- throw transform_error(error.str());
+ throw transform_error(
+ cmStrCat("sub-command TRANSFORM, action REPLACE: Failed to compile "
+ "regex \"",
+ arguments[0], "\"."));
}
if (!this->ReplaceHelper.IsReplaceExpressionValid()) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, action REPLACE: "
- << this->ReplaceHelper.GetError() << ".";
- throw transform_error(error.str());
+ throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ",
+ this->ReplaceHelper.GetError(), "."));
}
}
@@ -701,10 +689,8 @@ public:
std::string output;
if (!this->ReplaceHelper.Replace(input, output)) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, action REPLACE: "
- << this->ReplaceHelper.GetError() << ".";
- throw transform_error(error.str());
+ throw transform_error(cmStrCat("sub-command TRANSFORM, action REPLACE: ",
+ this->ReplaceHelper.GetError(), "."));
}
return output;
@@ -839,19 +825,17 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
auto descriptor = descriptors.find(args[index]);
if (descriptor == descriptors.end()) {
- std::ostringstream error;
- error << " sub-command TRANSFORM, " << args[index] << " invalid action.";
- status.SetError(error.str());
+ status.SetError(
+ cmStrCat(" sub-command TRANSFORM, ", args[index], " invalid action."));
return false;
}
// Action arguments
index += 1;
if (args.size() < index + descriptor->Arity) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, action " << descriptor->Name
- << " expects " << descriptor->Arity << " argument(s).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command TRANSFORM, action ",
+ descriptor->Name, " expects ", descriptor->Arity,
+ " argument(s)."));
return false;
}
@@ -881,10 +865,10 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
while (args.size() > index) {
if ((args[index] == REGEX || args[index] == AT || args[index] == FOR) &&
command.Selector) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, selector already specified ("
- << command.Selector->Tag << ").";
- status.SetError(error.str());
+ status.SetError(
+ cmStrCat("sub-command TRANSFORM, selector already specified (",
+ command.Selector->Tag, ")."));
+
return false;
}
@@ -898,11 +882,10 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
command.Selector = cm::make_unique<TransformSelectorRegex>(args[index]);
if (!command.Selector->Validate()) {
- std::ostringstream error;
- error << "sub-command TRANSFORM, selector REGEX failed to compile "
- "regex \"";
- error << args[index] << "\".";
- status.SetError(error.str());
+ status.SetError(
+ cmStrCat("sub-command TRANSFORM, selector REGEX failed to compile "
+ "regex \"",
+ args[index], "\"."));
return false;
}
@@ -1020,11 +1003,9 @@ bool HandleTransformCommand(std::vector<std::string> const& args,
continue;
}
- std::ostringstream error;
- error << "sub-command TRANSFORM, '"
- << cmJoin(cmMakeRange(args).advance(index), " ")
- << "': unexpected argument(s).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command TRANSFORM, '",
+ cmJoin(cmMakeRange(args).advance(index), " "),
+ "': unexpected argument(s)."));
return false;
}
@@ -1261,10 +1242,8 @@ bool HandleSublistCommand(std::vector<std::string> const& args,
cmExecutionStatus& status)
{
if (args.size() != 5) {
- std::ostringstream error;
- error << "sub-command SUBLIST requires four arguments (" << args.size() - 1
- << " found).";
- status.SetError(error.str());
+ status.SetError(cmStrCat("sub-command SUBLIST requires four arguments (",
+ args.size() - 1, " found)."));
return false;
}
@@ -1285,16 +1264,12 @@ bool HandleSublistCommand(std::vector<std::string> const& args,
using size_type = decltype(varArgsExpanded)::size_type;
if (start < 0 || size_type(start) >= varArgsExpanded.size()) {
- std::ostringstream error;
- error << "begin index: " << start << " is out of range 0 - "
- << varArgsExpanded.size() - 1;
- status.SetError(error.str());
+ status.SetError(cmStrCat("begin index: ", start, " is out of range 0 - ",
+ varArgsExpanded.size() - 1));
return false;
}
if (length < -1) {
- std::ostringstream error;
- error << "length: " << length << " should be -1 or greater";
- status.SetError(error.str());
+ status.SetError(cmStrCat("length: ", length, " should be -1 or greater"));
return false;
}
@@ -1344,10 +1319,8 @@ bool HandleRemoveAtCommand(std::vector<std::string> const& args,
item = static_cast<int>(nitem) + item;
}
if (item < 0 || nitem <= static_cast<size_t>(item)) {
- std::ostringstream str;
- str << "index: " << item << " out of range (-" << nitem << ", "
- << nitem - 1 << ")";
- status.SetError(str.str());
+ status.SetError(cmStrCat("index: ", item, " out of range (-", nitem,
+ ", ", nitem - 1, ")"));
return false;
}
removed.push_back(static_cast<size_t>(item));
diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx
index 66fdada..6f5df46 100644
--- a/Source/cmLoadCommandCommand.cxx
+++ b/Source/cmLoadCommandCommand.cxx
@@ -7,7 +7,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <sstream>
+
#include <utility>
#include "cm_memory.hxx"
@@ -207,9 +207,8 @@ bool cmLoadCommandCommand(std::vector<std::string> const& args,
// Try to find the program.
std::string fullPath = cmSystemTools::FindFile(moduleName, path);
if (fullPath.empty()) {
- std::ostringstream e;
- e << "Attempt to load command failed from file \"" << moduleName << "\"";
- status.SetError(e.str());
+ status.SetError(cmStrCat("Attempt to load command failed from file \"",
+ moduleName, "\""));
return false;
}
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 5bbb83c..d7c0611 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"
@@ -1197,17 +1199,21 @@ void cmLocalGenerator::GetTargetFlags(
std::string& linkLibs, std::string& flags, std::string& linkFlags,
std::string& frameworkPath, std::string& linkPath, cmGeneratorTarget* target)
{
- std::vector<BT<std::string>> tmpLinkFlags;
- this->GetTargetFlags(linkLineComputer, config, linkLibs, flags, tmpLinkFlags,
- frameworkPath, linkPath, target);
- this->AppendFlags(linkFlags, tmpLinkFlags);
+ std::vector<BT<std::string>> linkFlagsList;
+ std::vector<BT<std::string>> linkPathList;
+ std::vector<BT<std::string>> linkLibsList;
+ this->GetTargetFlags(linkLineComputer, config, linkLibsList, flags,
+ linkFlagsList, frameworkPath, linkPathList, target);
+ this->AppendFlags(linkFlags, linkFlagsList);
+ this->AppendFlags(linkPath, linkPathList);
+ this->AppendFlags(linkLibs, linkLibsList);
}
void cmLocalGenerator::GetTargetFlags(
cmLinkLineComputer* linkLineComputer, const std::string& config,
- std::string& linkLibs, std::string& flags,
+ std::vector<BT<std::string>>& linkLibs, std::string& flags,
std::vector<BT<std::string>>& linkFlags, std::string& frameworkPath,
- std::string& linkPath, cmGeneratorTarget* target)
+ std::vector<BT<std::string>>& linkPath, cmGeneratorTarget* target)
{
const std::string buildType = cmSystemTools::UpperCase(config);
cmComputeLinkInformation* pcli = target->GetLinkInformation(config);
@@ -1525,6 +1531,19 @@ void cmLocalGenerator::OutputLinkLibraries(
std::string& linkLibraries, std::string& frameworkPath,
std::string& linkPath)
{
+ std::vector<BT<std::string>> linkLibrariesList;
+ std::vector<BT<std::string>> linkPathList;
+ this->OutputLinkLibraries(pcli, linkLineComputer, linkLibrariesList,
+ frameworkPath, linkPathList);
+ pcli->AppendValues(linkLibraries, linkLibrariesList);
+ pcli->AppendValues(linkPath, linkPathList);
+}
+
+void cmLocalGenerator::OutputLinkLibraries(
+ cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer,
+ std::vector<BT<std::string>>& linkLibraries, std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath)
+{
cmComputeLinkInformation& cli = *pcli;
std::string linkLanguage = cli.GetLinkLanguage();
@@ -1556,10 +1575,9 @@ void cmLocalGenerator::OutputLinkLibraries(
cmStrCat("CMAKE_", linkLanguage, "_FRAMEWORK_SEARCH_FLAG"));
frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag);
- linkPath =
- linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator);
-
- linkLibraries = linkLineComputer->ComputeLinkLibraries(cli, stdLibString);
+ linkLineComputer->ComputeLinkPath(cli, libPathFlag, libPathTerminator,
+ linkPath);
+ linkLineComputer->ComputeLinkLibraries(cli, stdLibString, linkLibraries);
}
std::string cmLocalGenerator::GetLinkLibsCMP0065(
@@ -2255,23 +2273,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/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 34f58bd..512df26 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -382,12 +382,11 @@ public:
std::string& flags, std::string& linkFlags,
std::string& frameworkPath, std::string& linkPath,
cmGeneratorTarget* target);
- void GetTargetFlags(cmLinkLineComputer* linkLineComputer,
- const std::string& config, std::string& linkLibs,
- std::string& flags,
- std::vector<BT<std::string>>& linkFlags,
- std::string& frameworkPath, std::string& linkPath,
- cmGeneratorTarget* target);
+ void GetTargetFlags(
+ cmLinkLineComputer* linkLineComputer, const std::string& config,
+ std::vector<BT<std::string>>& linkLibs, std::string& flags,
+ std::vector<BT<std::string>>& linkFlags, std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath, cmGeneratorTarget* target);
void GetTargetDefines(cmGeneratorTarget const* target,
std::string const& config, std::string const& lang,
std::set<std::string>& defines) const;
@@ -430,6 +429,11 @@ protected:
cmLinkLineComputer* linkLineComputer,
std::string& linkLibraries,
std::string& frameworkPath, std::string& linkPath);
+ void OutputLinkLibraries(cmComputeLinkInformation* pcli,
+ cmLinkLineComputer* linkLineComputer,
+ std::vector<BT<std::string>>& linkLibraries,
+ std::string& frameworkPath,
+ std::vector<BT<std::string>>& linkPath);
// Handle old-style install rules stored in the targets.
void GenerateTargetInstallRules(
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index f80695d..0be1de5 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -161,8 +161,7 @@ void cmLocalUnixMakefileGenerator3::GetLocalObjectFiles(
continue;
}
std::vector<cmSourceFile const*> objectSources;
- gt->GetObjectSources(
- objectSources, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
+ gt->GetObjectSources(objectSources, this->ConfigName);
// Compute full path to object file directory for this target.
std::string dir = cmStrCat(gt->LocalGenerator->GetCurrentBinaryDirectory(),
'/', this->GetTargetDirectory(gt), '/');
@@ -1864,9 +1863,8 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
<< "_TARGET_INCLUDE_PATH\n";
std::vector<std::string> includes;
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
- this->GetIncludeDirectories(includes, target, implicitLang.first, config);
+ this->GetIncludeDirectories(includes, target, implicitLang.first,
+ this->ConfigName);
std::string binaryDir = this->GetState()->GetBinaryDirectory();
if (this->Makefile->IsOn("CMAKE_DEPENDS_IN_PROJECT_ONLY")) {
std::string const& sourceDir = this->GetState()->GetSourceDirectory();
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/cmMakefile.cxx b/Source/cmMakefile.cxx
index b3a0678..1938c23 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1249,35 +1249,6 @@ void cmMakefile::CommitAppendCustomCommandToOutput(
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);
- }
- cmCustomCommandLines commandLines;
- commandLines.push_back(std::move(commandLine));
-
- // Call the real signature of this method.
- return this->AddUtilityCommand(utilityName, origin, excludeFromAll,
- workingDirectory, depends, commandLines);
-}
-
-cmTarget* cmMakefile::AddUtilityCommand(
- const std::string& utilityName, TargetOrigin origin, bool excludeFromAll,
const char* workingDirectory, const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 19a71ad..42a769a 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -243,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,
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 477badd..482af22 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -150,16 +150,13 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
{
// -- Write the custom commands for this target
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
-
// Evaluates generator expressions and expands prop_value
auto evaluatedFiles =
- [this, &config](const char* prop_value) -> std::vector<std::string> {
+ [this](const char* prop_value) -> std::vector<std::string> {
std::vector<std::string> files;
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop_value);
- cmExpandList(cge->Evaluate(this->LocalGenerator, config, false,
+ cmExpandList(cge->Evaluate(this->LocalGenerator, this->ConfigName, false,
this->GeneratorTarget, nullptr, nullptr),
files);
return files;
@@ -191,7 +188,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
// First generate the object rule files. Save a list of all object
// files for this target.
std::vector<cmSourceFile const*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName);
std::string currentBinDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
for (cmSourceFile const* sf : customCommands) {
@@ -224,7 +221,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
this->GeneratorTarget->GetPostBuildCommands());
for (const auto& be : buildEventCommands) {
- const std::vector<std::string>& byproducts = be.GetByproducts();
+ cmCustomCommandGenerator beg(be, this->ConfigName, this->LocalGenerator);
+ const std::vector<std::string>& byproducts = beg.GetByproducts();
for (std::string const& byproduct : byproducts) {
this->CleanFiles.insert(
this->LocalGenerator->MaybeConvertToRelativePath(currentBinDir,
@@ -233,17 +231,17 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
}
}
std::vector<cmSourceFile const*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources, config);
+ this->GeneratorTarget->GetHeaderSources(headerSources, this->ConfigName);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources, this->MacOSXContentGenerator);
std::vector<cmSourceFile const*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources, config);
+ this->GeneratorTarget->GetExtraSources(extraSources, this->ConfigName);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources, this->MacOSXContentGenerator);
const char* pchExtension =
this->Makefile->GetDefinition("CMAKE_PCH_EXTENSION");
std::vector<cmSourceFile const*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+ this->GeneratorTarget->GetExternalObjects(externalObjects, this->ConfigName);
for (cmSourceFile const* sf : externalObjects) {
auto const& objectFileName = sf->GetFullPath();
if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) {
@@ -251,7 +249,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
}
}
std::vector<cmSourceFile const*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources, config);
+ this->GeneratorTarget->GetObjectSources(objectSources, this->ConfigName);
for (cmSourceFile const* sf : objectSources) {
// Generate this object file's rule file.
this->WriteObjectRuleFiles(*sf);
@@ -1610,10 +1608,8 @@ void cmMakefileTargetGenerator::CreateLinkLibs(
{
std::string frameworkPath;
std::string linkPath;
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
cmComputeLinkInformation* pcli =
- this->GeneratorTarget->GetLinkInformation(config);
+ this->GeneratorTarget->GetLinkInformation(this->ConfigName);
this->LocalGenerator->OutputLinkLibraries(pcli, linkLineComputer, linkLibs,
frameworkPath, linkPath);
linkLibs = frameworkPath + linkPath + linkLibs;
@@ -1706,13 +1702,12 @@ void cmMakefileTargetGenerator::AddIncludeFlags(std::string& flags,
bool useResponseFile = this->Makefile->IsOn(responseVar);
std::vector<std::string> includes;
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
this->LocalGenerator->GetIncludeDirectories(includes, this->GeneratorTarget,
- lang, config);
+ lang, this->ConfigName);
std::string includeFlags = this->LocalGenerator->GetIncludeFlags(
- includes, this->GeneratorTarget, lang, false, useResponseFile, config);
+ includes, this->GeneratorTarget, lang, false, useResponseFile,
+ this->ConfigName);
if (includeFlags.empty()) {
return;
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 37e9e0e..84a98fd 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -777,11 +777,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
<< cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType())
<< " target " << this->GetTargetName() << "\n\n";
- const std::string& config =
- this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE");
{
std::vector<cmSourceFile const*> customCommands;
- this->GeneratorTarget->GetCustomCommands(customCommands, config);
+ this->GeneratorTarget->GetCustomCommands(customCommands, this->ConfigName);
for (cmSourceFile const* sf : customCommands) {
cmCustomCommand const* cc = sf->GetCustomCommand();
this->GetLocalGenerator()->AddCustomCommandTarget(
@@ -793,13 +791,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
}
{
std::vector<cmSourceFile const*> headerSources;
- this->GeneratorTarget->GetHeaderSources(headerSources, config);
+ this->GeneratorTarget->GetHeaderSources(headerSources, this->ConfigName);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
headerSources, this->MacOSXContentGenerator.get());
}
{
std::vector<cmSourceFile const*> extraSources;
- this->GeneratorTarget->GetExtraSources(extraSources, config);
+ this->GeneratorTarget->GetExtraSources(extraSources, this->ConfigName);
this->OSXBundleGenerator->GenerateMacOSXContentStatements(
extraSources, this->MacOSXContentGenerator.get());
}
@@ -808,7 +806,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
GetMakefile()->GetDefinition("CMAKE_PCH_EXTENSION");
std::vector<cmSourceFile const*> externalObjects;
- this->GeneratorTarget->GetExternalObjects(externalObjects, config);
+ this->GeneratorTarget->GetExternalObjects(externalObjects,
+ this->ConfigName);
for (cmSourceFile const* sf : externalObjects) {
const auto objectFileName = this->GetSourceFilePath(sf);
if (!cmSystemTools::StringEndsWith(objectFileName, pchExtension)) {
@@ -863,7 +862,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements()
{
std::vector<cmSourceFile const*> objectSources;
- this->GeneratorTarget->GetObjectSources(objectSources, config);
+ this->GeneratorTarget->GetObjectSources(objectSources, this->ConfigName);
for (cmSourceFile const* sf : objectSources) {
this->WriteObjectBuildStatement(sf);
}
diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx
index a0a0989..22e59ac 100644
--- a/Source/cmOptionCommand.cxx
+++ b/Source/cmOptionCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmOptionCommand.h"
-#include <sstream>
-
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -74,13 +72,13 @@ bool cmOptionCommand(std::vector<std::string> const& args,
const auto* existsAfterSet =
status.GetMakefile().GetStateSnapshot().GetDefinition(args[0]);
if (!existsAfterSet) {
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0077)
- << "\n"
- "For compatibility with older versions of CMake, option "
- "is clearing the normal variable '"
- << args[0] << "'.";
- status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ status.GetMakefile().IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0077),
+ "\n"
+ "For compatibility with older versions of CMake, option "
+ "is clearing the normal variable '",
+ args[0], "'."));
}
}
return true;
diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx
index e1267ec..916a9f7 100644
--- a/Source/cmOrderDirectories.cxx
+++ b/Source/cmOrderDirectories.cxx
@@ -465,14 +465,14 @@ void cmOrderDirectories::FindImplicitConflicts()
}
// Warn about the conflicts.
- std::ostringstream w;
- w << "Cannot generate a safe " << this->Purpose << " for target "
- << this->Target->GetName()
- << " because files in some directories may conflict with "
- << " libraries in implicit directories:\n"
- << text << "Some of these libraries may not be found correctly.";
this->GlobalGenerator->GetCMakeInstance()->IssueMessage(
- MessageType::WARNING, w.str(), this->Target->GetBacktrace());
+ MessageType::WARNING,
+ cmStrCat("Cannot generate a safe ", this->Purpose, " for target ",
+ this->Target->GetName(),
+ " because files in some directories may "
+ "conflict with libraries in implicit directories:\n",
+ text, "Some of these libraries may not be found correctly."),
+ this->Target->GetBacktrace());
}
void cmOrderDirectories::OrderDirectories()
diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx
index e74fff6..5fa6a21 100644
--- a/Source/cmProjectCommand.cxx
+++ b/Source/cmProjectCommand.cxx
@@ -8,7 +8,6 @@
#include <cstdio>
#include <functional>
#include <limits>
-#include <sstream>
#include <utility>
#include "cmMakefile.h"
@@ -320,10 +319,10 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args,
}
}
if (!vw.empty()) {
- std::ostringstream w;
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0048)
- << "\nThe following variable(s) would be set to empty:" << vw;
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0048),
+ "\nThe following variable(s) would be set to empty:", vw));
}
}
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index 1a5602b..cc4df8f 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQTWrapCPPCommand.h"
-#include <utility>
-
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
@@ -65,14 +63,8 @@ bool cmQTWrapCPPCommand(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);
diff --git a/Source/cmQTWrapUICommand.cxx b/Source/cmQTWrapUICommand.cxx
index b7b5efa..66c0228 100644
--- a/Source/cmQTWrapUICommand.cxx
+++ b/Source/cmQTWrapUICommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQTWrapUICommand.h"
-#include <utility>
-
#include "cmCustomCommandLines.h"
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
@@ -76,31 +74,12 @@ bool cmQTWrapUICommand(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);
diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx
index f3c78d3..57c8825 100644
--- a/Source/cmQtAutoGen.cxx
+++ b/Source/cmQtAutoGen.cxx
@@ -162,6 +162,15 @@ std::string cmQtAutoGen::QuotedCommand(std::vector<std::string> const& command)
return res;
}
+std::string cmQtAutoGen::ParentDir(cm::string_view filename)
+{
+ auto slashPos = filename.rfind('/');
+ if (slashPos == cm::string_view::npos) {
+ return std::string();
+ }
+ return std::string(filename.substr(0, slashPos));
+}
+
std::string cmQtAutoGen::SubDirPrefix(cm::string_view filename)
{
auto slashPos = filename.rfind('/');
diff --git a/Source/cmQtAutoGen.h b/Source/cmQtAutoGen.h
index fb15586..71969ee 100644
--- a/Source/cmQtAutoGen.h
+++ b/Source/cmQtAutoGen.h
@@ -80,6 +80,9 @@ public:
static std::string QuotedCommand(std::vector<std::string> const& command);
+ /// @brief Returns the parent directory of the file (thread safe)
+ static std::string ParentDir(cm::string_view filename);
+
/// @brief Returns the parent directory of the file with a "/" suffix
static std::string SubDirPrefix(cm::string_view filename);
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 54304c3..ad4e4d5 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1,9 +1,11 @@
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQtAutoGenInitializer.h"
+
#include "cmQtAutoGen.h"
#include "cmQtAutoGenGlobalInitializer.h"
+#include "cmAlgorithms.h"
#include "cmCustomCommand.h"
#include "cmCustomCommandLines.h"
#include "cmFilePathChecksum.h"
@@ -41,7 +43,9 @@
#include "cm_memory.hxx"
-static std::size_t GetParallelCPUCount()
+namespace {
+
+std::size_t GetParallelCPUCount()
{
static std::size_t count = 0;
// Detect only on the first call
@@ -55,8 +59,8 @@ static std::size_t GetParallelCPUCount()
return count;
}
-static std::string FileProjectRelativePath(cmMakefile* makefile,
- std::string const& fileName)
+std::string FileProjectRelativePath(cmMakefile* makefile,
+ std::string const& fileName)
{
std::string res;
{
@@ -80,9 +84,9 @@ static std::string FileProjectRelativePath(cmMakefile* makefile,
* recursive STATIC_LIBRARY dependencies depends on targetOrigin
* (STATIC_LIBRARY cycle).
*/
-static bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
- cmGeneratorTarget const* targetDepend,
- std::string const& config)
+bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
+ cmGeneratorTarget const* targetDepend,
+ std::string const& config)
{
bool cycle = false;
if ((targetOrigin->GetType() == cmStateEnums::STATIC_LIBRARY) &&
@@ -120,6 +124,42 @@ static bool StaticLibraryCycle(cmGeneratorTarget const* targetOrigin,
return cycle;
}
+/** Sanitizes file search paths */
+class SearchPathSanitizer
+{
+public:
+ SearchPathSanitizer(cmMakefile* makefile)
+ : SourcePath_(makefile->GetCurrentSourceDirectory())
+ {
+ }
+ std::vector<std::string> operator()(
+ std::vector<std::string> const& paths) const;
+
+private:
+ std::string SourcePath_;
+};
+
+std::vector<std::string> SearchPathSanitizer::operator()(
+ std::vector<std::string> const& paths) const
+{
+ std::vector<std::string> res;
+ res.reserve(paths.size());
+ for (std::string const& srcPath : paths) {
+ // Collapse relative paths
+ std::string path = cmSystemTools::CollapseFullPath(srcPath, SourcePath_);
+ // Remove suffix slashes
+ while (cmHasSuffix(path, '/')) {
+ path.pop_back();
+ }
+ // Accept only non empty paths
+ if (!path.empty()) {
+ res.emplace_back(std::move(path));
+ }
+ }
+ return res;
+}
+} // End of unnamed namespace
+
cmQtAutoGenInitializer::InfoWriter::InfoWriter(std::string const& filename)
{
Ofs_.SetCopyIfDifferent(true);
@@ -213,11 +253,15 @@ void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists(
};
cmQtAutoGenInitializer::cmQtAutoGenInitializer(
- cmQtAutoGenGlobalInitializer* globalInitializer, cmGeneratorTarget* target,
- IntegerVersion const& qtVersion, bool mocEnabled, bool uicEnabled,
- bool rccEnabled, bool globalAutogenTarget, bool globalAutoRccTarget)
+ cmQtAutoGenGlobalInitializer* globalInitializer,
+ cmGeneratorTarget* genTarget, IntegerVersion const& qtVersion,
+ bool mocEnabled, bool uicEnabled, bool rccEnabled, bool globalAutogenTarget,
+ bool globalAutoRccTarget)
: GlobalInitializer(globalInitializer)
- , Target(target)
+ , GenTarget(genTarget)
+ , GlobalGen(genTarget->GetGlobalGenerator())
+ , LocalGen(genTarget->GetLocalGenerator())
+ , Makefile(genTarget->Makefile)
, QtVersion(qtVersion)
{
AutogenTarget.GlobalTarget = globalAutogenTarget;
@@ -229,19 +273,15 @@ cmQtAutoGenInitializer::cmQtAutoGenInitializer(
bool cmQtAutoGenInitializer::InitCustomTargets()
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
- cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator();
-
// Configurations
- this->MultiConfig = globalGen->IsMultiConfig();
- this->ConfigDefault = makefile->GetConfigurations(this->ConfigsList);
+ this->MultiConfig = this->GlobalGen->IsMultiConfig();
+ this->ConfigDefault = this->Makefile->GetConfigurations(this->ConfigsList);
if (this->ConfigsList.empty()) {
this->ConfigsList.push_back(this->ConfigDefault);
}
// Verbosity
- this->Verbosity = makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE");
+ this->Verbosity = this->Makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE");
if (!this->Verbosity.empty()) {
unsigned long iVerb = 0;
if (!cmStrToULong(this->Verbosity, &iVerb)) {
@@ -253,14 +293,14 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Targets FOLDER
{
const char* folder =
- makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
+ this->Makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
if (folder == nullptr) {
- folder =
- makefile->GetState()->GetGlobalProperty("AUTOGEN_TARGETS_FOLDER");
+ folder = this->Makefile->GetState()->GetGlobalProperty(
+ "AUTOGEN_TARGETS_FOLDER");
}
// Inherit FOLDER property from target (#13688)
if (folder == nullptr) {
- folder = this->Target->GetProperty("FOLDER");
+ folder = this->GenTarget->GetProperty("FOLDER");
}
if (folder != nullptr) {
this->TargetsFolder = folder;
@@ -270,7 +310,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Check status of policy CMP0071
{
cmPolicies::PolicyStatus const CMP0071_status =
- makefile->GetPolicyStatus(cmPolicies::CMP0071);
+ this->Makefile->GetPolicyStatus(cmPolicies::CMP0071);
switch (CMP0071_status) {
case cmPolicies::WARN:
this->CMP0071Warn = true;
@@ -291,18 +331,18 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
{
// Collapsed current binary directory
std::string const cbd = cmSystemTools::CollapseFullPath(
- std::string(), makefile->GetCurrentBinaryDirectory());
+ std::string(), this->Makefile->GetCurrentBinaryDirectory());
// Info directory
- this->Dir.Info =
- cmStrCat(cbd, "/CMakeFiles/", this->Target->GetName(), "_autogen.dir");
+ this->Dir.Info = cmStrCat(cbd, "/CMakeFiles/", this->GenTarget->GetName(),
+ "_autogen.dir");
cmSystemTools::ConvertToUnixSlashes(this->Dir.Info);
// Build directory
- this->Dir.Build = this->Target->GetSafeProperty("AUTOGEN_BUILD_DIR");
+ this->Dir.Build = this->GenTarget->GetSafeProperty("AUTOGEN_BUILD_DIR");
if (this->Dir.Build.empty()) {
this->Dir.Build =
- cmStrCat(cbd, '/', this->Target->GetName(), "_autogen");
+ cmStrCat(cbd, '/', this->GenTarget->GetName(), "_autogen");
}
cmSystemTools::ConvertToUnixSlashes(this->Dir.Build);
// Cleanup build directory
@@ -339,11 +379,12 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
}
// Autogen target name
- this->AutogenTarget.Name = cmStrCat(this->Target->GetName(), "_autogen");
+ this->AutogenTarget.Name =
+ cmStrCat(this->GenTarget->GetName(), "_autogen");
// Autogen target parallel processing
this->AutogenTarget.Parallel =
- this->Target->GetSafeProperty("AUTOGEN_PARALLEL");
+ this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL");
if (this->AutogenTarget.Parallel.empty() ||
(this->AutogenTarget.Parallel == "AUTO")) {
// Autodetect number of CPUs
@@ -377,15 +418,14 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Autogen target: Compute user defined dependencies
{
this->AutogenTarget.DependOrigin =
- this->Target->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS");
+ this->GenTarget->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS");
std::string const deps =
- this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
+ this->GenTarget->GetSafeProperty("AUTOGEN_TARGET_DEPENDS");
if (!deps.empty()) {
- std::vector<std::string> extraDeps = cmExpandedList(deps);
- for (std::string const& depName : extraDeps) {
+ for (std::string const& depName : cmExpandedList(deps)) {
// Allow target and file dependencies
- auto* depTarget = makefile->FindTargetToUse(depName);
+ auto* depTarget = this->Makefile->FindTargetToUse(depName);
if (depTarget != nullptr) {
this->AutogenTarget.DependTargets.insert(depTarget);
} else {
@@ -397,13 +437,13 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// CMAKE_AUTOMOC_RELAXED_MODE deprecation warning
if (this->Moc.Enabled) {
- if (makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) {
- makefile->IssueMessage(
+ if (this->Makefile->IsOn("CMAKE_AUTOMOC_RELAXED_MODE")) {
+ this->Makefile->IssueMessage(
MessageType::AUTHOR_WARNING,
cmStrCat("AUTOMOC: CMAKE_AUTOMOC_RELAXED_MODE is "
"deprecated an will be removed in the future. Consider "
"disabling it and converting the target ",
- this->Target->GetName(), " to regular mode."));
+ this->GenTarget->GetName(), " to regular mode."));
}
}
}
@@ -415,7 +455,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Add autogen include directory to the origin target INCLUDE_DIRECTORIES
if (this->MocOrUicEnabled() || (this->Rcc.Enabled && this->MultiConfig)) {
- this->Target->AddIncludeDirectory(this->Dir.Include, true);
+ this->GenTarget->AddIncludeDirectory(this->Dir.Include, true);
}
// Scan files
@@ -438,33 +478,29 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
bool cmQtAutoGenInitializer::InitMoc()
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
-
// Mocs compilation file
this->Moc.MocsCompilation =
cmStrCat(this->Dir.Build, "/mocs_compilation.cpp");
// Moc predefs command
- if (this->Target->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") &&
+ if (this->GenTarget->GetPropertyAsBool("AUTOMOC_COMPILER_PREDEFINES") &&
(this->QtVersion >= IntegerVersion(5, 8))) {
- this->Moc.PredefsCmd =
- makefile->GetSafeDefinition("CMAKE_CXX_COMPILER_PREDEFINES_COMMAND");
+ this->Moc.PredefsCmd = this->Makefile->GetSafeDefinition(
+ "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND");
}
// Moc includes
{
- bool const appendImplicit = (this->QtVersion.Major >= 5);
+ SearchPathSanitizer sanitizer(this->Makefile);
auto GetIncludeDirs =
- [this, localGen,
- appendImplicit](std::string const& cfg) -> std::vector<std::string> {
+ [this, &sanitizer](std::string const& cfg) -> std::vector<std::string> {
// Get the include dirs for this target, without stripping the implicit
- // include dirs off, see
- // https://gitlab.kitware.com/cmake/cmake/issues/13667
+ // include dirs off, see issue #13667.
std::vector<std::string> dirs;
- localGen->GetIncludeDirectoriesImplicit(dirs, this->Target, "CXX", cfg,
- false, appendImplicit);
- return dirs;
+ bool const appendImplicit = (this->QtVersion.Major >= 5);
+ this->LocalGen->GetIncludeDirectoriesImplicit(
+ dirs, this->GenTarget, "CXX", cfg, false, appendImplicit);
+ return sanitizer(dirs);
};
// Default configuration include directories
@@ -483,9 +519,9 @@ bool cmQtAutoGenInitializer::InitMoc()
// Moc compile definitions
{
auto GetCompileDefinitions =
- [this, localGen](std::string const& cfg) -> std::set<std::string> {
+ [this](std::string const& cfg) -> std::set<std::string> {
std::set<std::string> defines;
- localGen->GetTargetDefines(this->Target, cfg, "CXX", defines);
+ this->LocalGen->GetTargetDefines(this->GenTarget, cfg, "CXX", defines);
#ifdef _WIN32
if (this->Moc.PredefsCmd.empty()) {
// Add WIN32 definition if we don't have a moc_predefs.h
@@ -525,18 +561,13 @@ bool cmQtAutoGenInitializer::InitMoc()
bool cmQtAutoGenInitializer::InitUic()
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
-
// Uic search paths
{
std::string const usp =
- this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
+ this->GenTarget->GetSafeProperty("AUTOUIC_SEARCH_PATHS");
if (!usp.empty()) {
- cmExpandList(usp, this->Uic.SearchPaths);
- std::string const& srcDir = makefile->GetCurrentSourceDirectory();
- for (std::string& path : this->Uic.SearchPaths) {
- path = cmSystemTools::CollapseFullPath(path, srcDir);
- }
+ this->Uic.SearchPaths =
+ SearchPathSanitizer(this->Makefile)(cmExpandedList(usp));
}
}
// Uic target options
@@ -544,7 +575,7 @@ bool cmQtAutoGenInitializer::InitUic()
auto UicGetOpts =
[this](std::string const& cfg) -> std::vector<std::string> {
std::vector<std::string> opts;
- this->Target->GetAutoUicOptions(opts, cfg);
+ this->GenTarget->GetAutoUicOptions(opts, cfg);
return opts;
};
@@ -605,14 +636,13 @@ bool cmQtAutoGenInitializer::InitRcc()
bool cmQtAutoGenInitializer::InitScanFiles()
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- cmake const* cm = makefile->GetCMakeInstance();
+ cmake const* cm = this->Makefile->GetCMakeInstance();
auto const& kw = this->GlobalInitializer->kw();
auto makeMUFile = [this, &kw](cmSourceFile* sf, std::string const& fullPath,
bool muIt) -> MUFileHandle {
MUFileHandle muf = cm::make_unique<MUFile>();
- muf->RealPath = cmSystemTools::GetRealPath(fullPath);
+ muf->FullPath = fullPath;
muf->SF = sf;
muf->Generated = sf->GetIsGenerated();
bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
@@ -642,9 +672,9 @@ bool cmQtAutoGenInitializer::InitScanFiles()
{
// Scan through target files
std::vector<cmSourceFile*> srcFiles;
- this->Target->GetConfigCommonSourceFiles(srcFiles);
+ this->GenTarget->GetConfigCommonSourceFiles(srcFiles);
for (cmSourceFile* sf : srcFiles) {
- // sf->GetExtension() is only valid after sf->GetFullPath() ...
+ // sf->GetExtension() is only valid after sf->ResolveFullPath() ...
// Since we're iterating over source files that might be not in the
// target we need to check for path errors (not existing files).
std::string pathError;
@@ -670,7 +700,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
!sf->GetPropertyAsBool(kw.SKIP_AUTORCC)) {
// Register qrc file
Qrc qrc;
- qrc.QrcFile = cmSystemTools::GetRealPath(fullPath);
+ qrc.QrcFile = fullPath;
qrc.QrcName =
cmSystemTools::GetFilenameWithoutLastExtension(qrc.QrcFile);
qrc.Generated = sf->GetIsGenerated();
@@ -690,7 +720,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// sources meta data cache. Clear it so that OBJECT library targets that
// are AUTOGEN initialized after this target get their added
// mocs_compilation.cpp source acknowledged by this target.
- this->Target->ClearSourcesCache();
+ this->GenTarget->ClearSourcesCache();
// For source files find additional headers and private headers
if (this->MocOrUicEnabled()) {
@@ -704,21 +734,21 @@ bool cmQtAutoGenInitializer::InitScanFiles()
MUFile const& muf = *pair.second;
if (muf.MocIt || muf.UicIt) {
// Search for the default header file and a private header
- std::string const& srcPath = muf.SF->ResolveFullPath();
- std::string basePath =
- cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath),
- cmSystemTools::GetFilenameWithoutLastExtension(srcPath));
+ std::string const& srcFullPath = muf.SF->ResolveFullPath();
+ std::string basePath = cmStrCat(
+ cmQtAutoGen::SubDirPrefix(srcFullPath),
+ cmSystemTools::GetFilenameWithoutLastExtension(srcFullPath));
for (auto const& suffix : suffixes) {
std::string const suffixedPath = cmStrCat(basePath, suffix);
for (auto const& ext : exts) {
std::string fullPath = cmStrCat(suffixedPath, '.', ext);
auto constexpr locationKind = cmSourceFileLocationKind::Known;
- cmSourceFile* sf = makefile->GetSource(fullPath, locationKind);
+ cmSourceFile* sf =
+ this->Makefile->GetSource(fullPath, locationKind);
if (sf != nullptr) {
// Check if we know about this header already
- if (this->AutogenTarget.Headers.find(sf) !=
- this->AutogenTarget.Headers.end()) {
+ if (cmContains(this->AutogenTarget.Headers, sf)) {
continue;
}
// We only accept not-GENERATED files that do exist.
@@ -728,7 +758,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
}
} else if (cmSystemTools::FileExists(fullPath)) {
// Create a new source file for the existing file
- sf = makefile->CreateSource(fullPath, false, locationKind);
+ sf = this->Makefile->CreateSource(fullPath, false, locationKind);
}
if (sf != nullptr) {
@@ -757,8 +787,8 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// The reason is that their file names might be discovered from source files
// at generation time.
if (this->MocOrUicEnabled()) {
- for (cmSourceFile* sf : makefile->GetSourceFiles()) {
- // sf->GetExtension() is only valid after sf->GetFullPath() ...
+ for (cmSourceFile* sf : this->Makefile->GetSourceFiles()) {
+ // sf->GetExtension() is only valid after sf->ResolveFullPath() ...
// Since we're iterating over source files that might be not in the
// target we need to check for path errors (not existing files).
std::string pathError;
@@ -770,16 +800,14 @@ bool cmQtAutoGenInitializer::InitScanFiles()
cmSystemTools::LowerCase(sf->GetExtension());
if (cm->IsHeaderExtension(extLower)) {
- if (this->AutogenTarget.Headers.find(sf) ==
- this->AutogenTarget.Headers.end()) {
+ if (!cmContains(this->AutogenTarget.Headers, sf)) {
auto muf = makeMUFile(sf, fullPath, false);
if (muf->SkipMoc || muf->SkipUic) {
this->AutogenTarget.Headers.emplace(sf, std::move(muf));
}
}
} else if (cm->IsSourceExtension(extLower)) {
- if (this->AutogenTarget.Sources.find(sf) ==
- this->AutogenTarget.Sources.end()) {
+ if (!cmContains(this->AutogenTarget.Headers, sf)) {
auto muf = makeMUFile(sf, fullPath, false);
if (muf->SkipMoc || muf->SkipUic) {
this->AutogenTarget.Sources.emplace(sf, std::move(muf));
@@ -787,7 +815,6 @@ bool cmQtAutoGenInitializer::InitScanFiles()
}
} else if (this->Uic.Enabled && (extLower == kw.ui)) {
// .ui file
- std::string realPath = cmSystemTools::GetRealPath(fullPath);
bool const skipAutogen = sf->GetPropertyAsBool(kw.SKIP_AUTOGEN);
bool const skipUic =
(skipAutogen || sf->GetPropertyAsBool(kw.SKIP_AUTOUIC));
@@ -795,13 +822,12 @@ bool cmQtAutoGenInitializer::InitScanFiles()
// Check if the .ui file has uic options
std::string const uicOpts = sf->GetSafeProperty(kw.AUTOUIC_OPTIONS);
if (!uicOpts.empty()) {
- this->Uic.FileFiles.push_back(std::move(realPath));
- std::vector<std::string> optsVec = cmExpandedList(uicOpts);
- this->Uic.FileOptions.push_back(std::move(optsVec));
+ this->Uic.FileFiles.push_back(fullPath);
+ this->Uic.FileOptions.push_back(cmExpandedList(uicOpts));
}
} else {
// Register skipped .ui file
- this->Uic.SkipUi.insert(std::move(realPath));
+ this->Uic.SkipUi.insert(fullPath);
}
}
}
@@ -812,7 +838,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
if (this->CMP0071Accept) {
// Let the autogen target depend on the GENERATED files
for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
- this->AutogenTarget.DependFiles.insert(muf->RealPath);
+ this->AutogenTarget.DependFiles.insert(muf->FullPath);
}
} else if (this->CMP0071Warn) {
cm::string_view property;
@@ -825,9 +851,9 @@ bool cmQtAutoGenInitializer::InitScanFiles()
}
std::string files;
for (MUFile* muf : this->AutogenTarget.FilesGenerated) {
- files += cmStrCat(" ", Quoted(muf->RealPath), '\n');
+ files += cmStrCat(" ", Quoted(muf->FullPath), '\n');
}
- makefile->IssueMessage(
+ this->Makefile->IssueMessage(
MessageType::AUTHOR_WARNING,
cmStrCat(
cmPolicies::GetPolicyWarning(cmPolicies::CMP0071), '\n',
@@ -848,7 +874,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
const bool modernQt = (this->QtVersion.Major >= 5);
// Target rcc options
std::vector<std::string> optionsTarget =
- cmExpandedList(this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS));
+ cmExpandedList(this->GenTarget->GetSafeProperty(kw.AUTORCC_OPTIONS));
// Check if file name is unique
for (Qrc& qrc : this->Rcc.Qrcs) {
@@ -862,7 +888,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
}
// Path checksum and file names
{
- cmFilePathChecksum const fpathCheckSum(makefile);
+ cmFilePathChecksum const fpathCheckSum(this->Makefile);
for (Qrc& qrc : this->Rcc.Qrcs) {
qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile);
// RCC output file name
@@ -925,12 +951,8 @@ bool cmQtAutoGenInitializer::InitScanFiles()
bool cmQtAutoGenInitializer::InitAutogenTarget()
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
- cmGlobalGenerator* globalGen = localGen->GetGlobalGenerator();
-
// Register info file as generated by CMake
- makefile->AddCMakeOutputFile(this->AutogenTarget.InfoFile);
+ this->Makefile->AddCMakeOutputFile(this->AutogenTarget.InfoFile);
// Files provided by the autogen target
std::vector<std::string> autogenProvides;
@@ -952,25 +974,18 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
}
tools += "UIC";
}
- autogenComment =
- cmStrCat("Automatic ", tools, " for target ", this->Target->GetName());
+ autogenComment = cmStrCat("Automatic ", tools, " for target ",
+ this->GenTarget->GetName());
}
// 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;
- if (globalGen->GetName().find("Visual Studio") != std::string::npos) {
+ if (this->GlobalGen->GetName().find("Visual Studio") != std::string::npos) {
// Under VS use a PRE_BUILD event instead of a separate target to
// reduce the number of targets loaded into the IDE.
// This also works around a VS 11 bug that may skip updating the target:
@@ -992,7 +1007,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
if (usePRE_BUILD) {
// Add additional autogen target dependencies to origin target
for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
- this->Target->Target->AddUtility(depTarget->GetName(), makefile);
+ this->GenTarget->Target->AddUtility(depTarget->GetName(),
+ this->Makefile);
}
// Add the pre-build command directly to bypass the OBJECT_LIBRARY
@@ -1002,12 +1018,12 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// PRE_BUILD does not support file dependencies!
const std::vector<std::string> no_output;
const std::vector<std::string> no_deps;
- cmCustomCommand cc(makefile, no_output, autogenProvides, no_deps,
+ cmCustomCommand cc(this->Makefile, no_output, autogenProvides, no_deps,
commandLines, autogenComment.c_str(),
this->Dir.Work.c_str());
cc.SetEscapeOldStyle(false);
cc.SetEscapeAllowMakeVars(true);
- this->Target->Target->AddPreBuildCommand(cc);
+ this->GenTarget->Target->AddPreBuildCommand(cc);
} else {
// Add link library target dependencies to the autogen target
@@ -1018,12 +1034,12 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
std::map<cmGeneratorTarget const*, std::size_t> commonTargets;
for (std::string const& config : this->ConfigsList) {
cmLinkImplementationLibraries const* libs =
- this->Target->GetLinkImplementationLibraries(config);
+ this->GenTarget->GetLinkImplementationLibraries(config);
if (libs != nullptr) {
for (cmLinkItem const& item : libs->Libraries) {
cmGeneratorTarget const* libTarget = item.Target;
if ((libTarget != nullptr) &&
- !StaticLibraryCycle(this->Target, libTarget, config)) {
+ !StaticLibraryCycle(this->GenTarget, libTarget, config)) {
// Increment target config count
commonTargets[libTarget]++;
}
@@ -1038,25 +1054,25 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
}
// Create autogen target
- cmTarget* autogenTarget = makefile->AddUtilityCommand(
+ cmTarget* autogenTarget = this->Makefile->AddUtilityCommand(
this->AutogenTarget.Name, cmMakefile::TargetOrigin::Generator, true,
this->Dir.Work.c_str(), /*byproducts=*/autogenProvides,
std::vector<std::string>(this->AutogenTarget.DependFiles.begin(),
this->AutogenTarget.DependFiles.end()),
commandLines, false, autogenComment.c_str());
// Create autogen generator target
- localGen->AddGeneratorTarget(
- new cmGeneratorTarget(autogenTarget, localGen));
+ this->LocalGen->AddGeneratorTarget(
+ new cmGeneratorTarget(autogenTarget, this->LocalGen));
// Forward origin utilities to autogen target
if (this->AutogenTarget.DependOrigin) {
- for (BT<std::string> const& depName : this->Target->GetUtilities()) {
- autogenTarget->AddUtility(depName.Value, makefile);
+ for (BT<std::string> const& depName : this->GenTarget->GetUtilities()) {
+ autogenTarget->AddUtility(depName.Value, this->Makefile);
}
}
// Add additional autogen target dependencies to autogen target
for (cmTarget* depTarget : this->AutogenTarget.DependTargets) {
- autogenTarget->AddUtility(depTarget->GetName(), makefile);
+ autogenTarget->AddUtility(depTarget->GetName(), this->Makefile);
}
// Set FOLDER property in autogen target
@@ -1065,11 +1081,12 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
}
// Add autogen target to the origin target dependencies
- this->Target->Target->AddUtility(this->AutogenTarget.Name, makefile);
+ this->GenTarget->Target->AddUtility(this->AutogenTarget.Name,
+ this->Makefile);
// Add autogen target to the global autogen target dependencies
if (this->AutogenTarget.GlobalTarget) {
- this->GlobalInitializer->AddToGlobalAutoGen(localGen,
+ this->GlobalInitializer->AddToGlobalAutoGen(this->LocalGen,
this->AutogenTarget.Name);
}
}
@@ -1079,12 +1096,9 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
bool cmQtAutoGenInitializer::InitRccTargets()
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
-
for (Qrc const& qrc : this->Rcc.Qrcs) {
// Register info file as generated by CMake
- makefile->AddCMakeOutputFile(qrc.InfoFile);
+ this->Makefile->AddCMakeOutputFile(qrc.InfoFile);
// Register file at target
this->AddGeneratedSource(qrc.RccFile, this->Rcc);
@@ -1100,58 +1114,52 @@ 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));
+ std::string ccComment =
+ cmStrCat("Automatic RCC for ",
+ FileProjectRelativePath(this->Makefile, qrc.QrcFile));
if (qrc.Generated || this->Rcc.GlobalTarget) {
// Create custom rcc target
std::string ccName;
{
- ccName = cmStrCat(this->Target->GetName(), "_arcc_", qrc.QrcName);
+ ccName = cmStrCat(this->GenTarget->GetName(), "_arcc_", qrc.QrcName);
if (!qrc.Unique) {
ccName += cmStrCat('_', qrc.PathChecksum);
}
- cmTarget* autoRccTarget = makefile->AddUtilityCommand(
+ cmTarget* autoRccTarget = this->Makefile->AddUtilityCommand(
ccName, cmMakefile::TargetOrigin::Generator, true,
this->Dir.Work.c_str(), ccOutput, ccDepends, commandLines, false,
ccComment.c_str());
// Create autogen generator target
- localGen->AddGeneratorTarget(
- new cmGeneratorTarget(autoRccTarget, localGen));
+ this->LocalGen->AddGeneratorTarget(
+ new cmGeneratorTarget(autoRccTarget, this->LocalGen));
// Set FOLDER property in autogen target
if (!this->TargetsFolder.empty()) {
autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
}
if (!this->Rcc.ExecutableTargetName.empty()) {
- autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName, makefile);
+ autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName,
+ this->Makefile);
}
}
// Add autogen target to the origin target dependencies
- this->Target->Target->AddUtility(ccName, makefile);
+ this->GenTarget->Target->AddUtility(ccName, this->Makefile);
// Add autogen target to the global autogen target dependencies
if (this->Rcc.GlobalTarget) {
- this->GlobalInitializer->AddToGlobalAutoRcc(localGen, ccName);
+ this->GlobalInitializer->AddToGlobalAutoRcc(this->LocalGen, ccName);
}
} else {
// Create custom rcc command
@@ -1168,13 +1176,13 @@ bool cmQtAutoGenInitializer::InitRccTargets()
}
std::string no_main_dependency;
cmImplicitDependsList no_implicit_depends;
- makefile->AddCustomCommandToOutput(
+ this->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);
+ this->Makefile->AddCMakeDependFile(qrc.QrcFile);
}
}
@@ -1207,9 +1215,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
InfoWriter ofs(this->AutogenTarget.InfoFile);
if (ofs) {
// Utility lambdas
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- auto MfDef = [makefile](const char* key) {
- return makefile->GetSafeDefinition(key);
+ auto MfDef = [this](const char* key) {
+ return this->Makefile->GetSafeDefinition(key);
};
// Write common settings
@@ -1225,8 +1232,6 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
MfDef("CMAKE_CURRENT_SOURCE_DIR"));
ofs.Write("AM_CMAKE_CURRENT_BINARY_DIR",
MfDef("CMAKE_CURRENT_BINARY_DIR"));
- ofs.Write("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE",
- MfDef("CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE"));
ofs.Write("AM_BUILD_DIR", this->Dir.Build);
ofs.Write("AM_INCLUDE_DIR", this->Dir.Include);
ofs.WriteConfig("AM_INCLUDE_DIR", this->Dir.ConfigInclude);
@@ -1253,7 +1258,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
std::sort(sortedHeaders.begin(), sortedHeaders.end(),
[](MUFile const* a, MUFile const* b) {
- return (a->RealPath < b->RealPath);
+ return (a->FullPath < b->FullPath);
});
}
@@ -1262,13 +1267,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
continue;
}
if (muf->SkipMoc) {
- moc_skip.insert(muf->RealPath);
+ moc_skip.insert(muf->FullPath);
}
if (muf->SkipUic) {
- uic_skip.insert(muf->RealPath);
+ uic_skip.insert(muf->FullPath);
}
if (muf->MocIt || muf->UicIt) {
- headers.emplace_back(muf->RealPath);
+ headers.emplace_back(muf->FullPath);
headersFlags.emplace_back(
cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u'));
}
@@ -1276,7 +1281,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
// Header build paths
{
- cmFilePathChecksum const fpathCheckSum(makefile);
+ cmFilePathChecksum const fpathCheckSum(this->Makefile);
std::unordered_set<std::string> emitted;
for (std::string const& hdr : headers) {
std::string const basePath =
@@ -1307,7 +1312,7 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
}
std::sort(sorted.begin(), sorted.end(),
[](MUFile const* a, MUFile const* b) {
- return (a->RealPath < b->RealPath);
+ return (a->FullPath < b->FullPath);
});
for (MUFile const* const muf : sorted) {
@@ -1315,13 +1320,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
continue;
}
if (muf->SkipMoc) {
- moc_skip.insert(muf->RealPath);
+ moc_skip.insert(muf->FullPath);
}
if (muf->SkipUic) {
- uic_skip.insert(muf->RealPath);
+ uic_skip.insert(muf->FullPath);
}
if (muf->MocIt || muf->UicIt) {
- sources.emplace_back(muf->RealPath);
+ sources.emplace_back(muf->FullPath);
sourcesFlags.emplace_back(
cmStrCat(muf->MocIt ? 'M' : 'm', muf->UicIt ? 'U' : 'u'));
}
@@ -1354,12 +1359,14 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
ofs.WriteStrings("AM_MOC_INCLUDES", this->Moc.Includes);
ofs.WriteConfigStrings("AM_MOC_INCLUDES", this->Moc.ConfigIncludes);
ofs.Write("AM_MOC_OPTIONS",
- this->Target->GetSafeProperty("AUTOMOC_MOC_OPTIONS"));
+ this->GenTarget->GetSafeProperty("AUTOMOC_MOC_OPTIONS"));
ofs.Write("AM_MOC_RELAXED_MODE", MfDef("CMAKE_AUTOMOC_RELAXED_MODE"));
+ ofs.Write("AM_MOC_PATH_PREFIX",
+ this->GenTarget->GetSafeProperty("AUTOMOC_PATH_PREFIX"));
ofs.Write("AM_MOC_MACRO_NAMES",
- this->Target->GetSafeProperty("AUTOMOC_MACRO_NAMES"));
+ this->GenTarget->GetSafeProperty("AUTOMOC_MACRO_NAMES"));
ofs.Write("AM_MOC_DEPEND_FILTERS",
- this->Target->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
+ this->GenTarget->GetSafeProperty("AUTOMOC_DEPEND_FILTERS"));
ofs.Write("AM_MOC_PREDEFS_CMD", this->Moc.PredefsCmd);
}
@@ -1390,6 +1397,11 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
for (Qrc const& qrc : this->Rcc.Qrcs) {
InfoWriter ofs(qrc.InfoFile);
if (ofs) {
+ // Utility lambdas
+ auto MfDef = [this](const char* key) {
+ return this->Makefile->GetSafeDefinition(key);
+ };
+
// Write
ofs.Write("# Configurations\n");
ofs.Write("ARCC_MULTI_CONFIG", this->MultiConfig ? "TRUE" : "FALSE");
@@ -1399,6 +1411,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
ofs.WriteConfig("ARCC_SETTINGS_FILE", qrc.ConfigSettingsFile);
ofs.Write("# Directories\n");
+ ofs.Write("ARCC_CMAKE_SOURCE_DIR", MfDef("CMAKE_SOURCE_DIR"));
+ ofs.Write("ARCC_CMAKE_BINARY_DIR", MfDef("CMAKE_BINARY_DIR"));
ofs.Write("ARCC_BUILD_DIR", this->Dir.Build);
ofs.Write("ARCC_INCLUDE_DIR", this->Dir.Include);
ofs.WriteConfig("ARCC_INCLUDE_DIR", this->Dir.ConfigInclude);
@@ -1429,8 +1443,7 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
void cmQtAutoGenInitializer::RegisterGeneratedSource(
std::string const& filename)
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
- cmSourceFile* gFile = makefile->GetOrCreateSource(filename, true);
+ cmSourceFile* gFile = this->Makefile->GetOrCreateSource(filename, true);
gFile->SetProperty("GENERATED", "1");
gFile->SetProperty("SKIP_AUTOGEN", "1");
}
@@ -1442,7 +1455,7 @@ bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
// Register source at makefile
this->RegisterGeneratedSource(filename);
// Add source file to target
- this->Target->AddSource(filename, prepend);
+ this->GenTarget->AddSource(filename, prepend);
// Add source file to source group
return this->AddToSourceGroup(filename, genVars.GenNameUpper);
}
@@ -1450,7 +1463,6 @@ bool cmQtAutoGenInitializer::AddGeneratedSource(std::string const& filename,
bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
cm::string_view genNameUpper)
{
- cmMakefile* makefile = this->Target->Target->GetMakefile();
cmSourceGroup* sourceGroup = nullptr;
// Acquire source group
{
@@ -1462,7 +1474,8 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
cmStrCat(genNameUpper, "_SOURCE_GROUP"), "AUTOGEN_SOURCE_GROUP"
};
for (std::string const& prop : props) {
- const char* propName = makefile->GetState()->GetGlobalProperty(prop);
+ const char* propName =
+ this->Makefile->GetState()->GetGlobalProperty(prop);
if ((propName != nullptr) && (*propName != '\0')) {
groupName = propName;
property = prop;
@@ -1472,7 +1485,7 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
}
// Generate a source group on demand
if (!groupName.empty()) {
- sourceGroup = makefile->GetOrCreateSourceGroup(groupName);
+ sourceGroup = this->Makefile->GetOrCreateSourceGroup(groupName);
if (sourceGroup == nullptr) {
cmSystemTools::Error(
cmStrCat(genNameUpper, " error in ", property,
@@ -1490,8 +1503,8 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)
{
- Target->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", fileName.c_str(),
- false);
+ this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES",
+ fileName.c_str(), false);
}
static unsigned int CharPtrToUInt(const char* const input)
@@ -1504,7 +1517,7 @@ static unsigned int CharPtrToUInt(const char* const input)
}
static std::vector<cmQtAutoGen::IntegerVersion> GetKnownQtVersions(
- cmGeneratorTarget const* target)
+ cmGeneratorTarget const* genTarget)
{
// Qt version variable prefixes
static std::initializer_list<
@@ -1526,7 +1539,7 @@ static std::vector<cmQtAutoGen::IntegerVersion> GetKnownQtVersions(
}
};
- cmMakefile* makefile = target->Target->GetMakefile();
+ cmMakefile* makefile = genTarget->Makefile;
// Read versions from variables
for (auto const& keyPair : keys) {
@@ -1576,22 +1589,20 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
{
auto print_err = [this, &genVars](std::string const& err) {
cmSystemTools::Error(cmStrCat(genVars.GenNameUpper, " for target ",
- this->Target->GetName(), ": ", err));
+ this->GenTarget->GetName(), ": ", err));
};
// Custom executable
{
std::string const prop = cmStrCat(genVars.GenNameUpper, "_EXECUTABLE");
- std::string const val = this->Target->Target->GetSafeProperty(prop);
+ std::string const val = this->GenTarget->Target->GetSafeProperty(prop);
if (!val.empty()) {
// Evaluate generator expression
{
- cmListFileBacktrace lfbt =
- this->Target->Target->GetMakefile()->GetBacktrace();
+ cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(val);
- genVars.Executable =
- cge->Evaluate(this->Target->GetLocalGenerator(), "");
+ genVars.Executable = cge->Evaluate(this->LocalGen, "");
}
if (genVars.Executable.empty() && !ignoreMissingTarget) {
print_err(prop + " evaluates to an empty value");
@@ -1619,15 +1630,15 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
std::string const targetName = cmStrCat(prefix, executable);
// Find target
- cmLocalGenerator* localGen = this->Target->GetLocalGenerator();
- cmGeneratorTarget* target = localGen->FindGeneratorTargetToUse(targetName);
- if (target != nullptr) {
+ cmGeneratorTarget* genTarget =
+ this->LocalGen->FindGeneratorTargetToUse(targetName);
+ if (genTarget != nullptr) {
genVars.ExecutableTargetName = targetName;
- genVars.ExecutableTarget = target;
- if (target->IsImported()) {
- genVars.Executable = target->ImportedGetLocation("");
+ genVars.ExecutableTarget = genTarget;
+ if (genTarget->IsImported()) {
+ genVars.Executable = genTarget->ImportedGetLocation("");
} else {
- genVars.Executable = target->GetLocation("");
+ genVars.Executable = genTarget->GetLocation("");
}
} else {
if (ignoreMissingTarget) {
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index 84a27e4..bedda30 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -18,9 +18,12 @@
#include <vector>
class cmGeneratorTarget;
-class cmTarget;
+class cmGlobalGenerator;
+class cmLocalGenerator;
+class cmMakefile;
class cmQtAutoGenGlobalInitializer;
class cmSourceFile;
+class cmTarget;
/// @brief Initializes the QtAutoGen generators
class cmQtAutoGenInitializer : public cmQtAutoGen
@@ -47,7 +50,7 @@ public:
/// @brief Moc/Uic file
struct MUFile
{
- std::string RealPath;
+ std::string FullPath;
cmSourceFile* SF = nullptr;
bool Generated = false;
bool SkipMoc = false;
@@ -112,10 +115,10 @@ public:
public:
/// @return The detected Qt version and the required Qt major version
static std::pair<IntegerVersion, unsigned int> GetQtVersion(
- cmGeneratorTarget const* target);
+ cmGeneratorTarget const* genTarget);
cmQtAutoGenInitializer(cmQtAutoGenGlobalInitializer* globalInitializer,
- cmGeneratorTarget* target,
+ cmGeneratorTarget* genTarget,
IntegerVersion const& qtVersion, bool mocEnabled,
bool uicEnabled, bool rccEnabled,
bool globalAutogenTarget, bool globalAutoRccTarget);
@@ -152,8 +155,11 @@ private:
bool ignoreMissingTarget) const;
private:
- cmQtAutoGenGlobalInitializer* GlobalInitializer;
- cmGeneratorTarget* Target;
+ cmQtAutoGenGlobalInitializer* GlobalInitializer = nullptr;
+ cmGeneratorTarget* GenTarget = nullptr;
+ cmGlobalGenerator* GlobalGen = nullptr;
+ cmLocalGenerator* LocalGen = nullptr;
+ cmMakefile* Makefile = nullptr;
// Configuration
IntegerVersion QtVersion;
diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx
index 80b8741..086b68c 100644
--- a/Source/cmQtAutoGenerator.cxx
+++ b/Source/cmQtAutoGenerator.cxx
@@ -93,32 +93,18 @@ void cmQtAutoGenerator::Logger::Warning(GenT genType,
}
}
-void cmQtAutoGenerator::Logger::WarningFile(GenT genType,
- cm::string_view filename,
- cm::string_view message) const
-{
- Warning(genType, cmStrCat(" ", Quoted(filename), '\n', message));
-}
-
void cmQtAutoGenerator::Logger::Error(GenT genType,
cm::string_view message) const
{
std::string msg =
- cmStrCat(HeadLine(cmStrCat(GeneratorName(genType), " error")), message,
- cmHasSuffix(message, '\n') ? "\n" : "\n\n");
+ cmStrCat('\n', HeadLine(cmStrCat(GeneratorName(genType), " error")),
+ message, cmHasSuffix(message, '\n') ? "\n" : "\n\n");
{
std::lock_guard<std::mutex> lock(Mutex_);
cmSystemTools::Stderr(msg);
}
}
-void cmQtAutoGenerator::Logger::ErrorFile(GenT genType,
- cm::string_view filename,
- cm::string_view message) const
-{
- Error(genType, cmStrCat(" ", Quoted(filename), '\n', message));
-}
-
void cmQtAutoGenerator::Logger::ErrorCommand(
GenT genType, cm::string_view message,
std::vector<std::string> const& command, std::string const& output) const
@@ -286,3 +272,16 @@ std::string cmQtAutoGenerator::SettingsFind(std::string const& content,
}
return std::string();
}
+
+std::string cmQtAutoGenerator::MessagePath(cm::string_view path) const
+{
+ std::string res;
+ if (cmHasPrefix(path, ProjectDirs().Source)) {
+ res = cmStrCat("SRC:", path.substr(ProjectDirs().Source.size()));
+ } else if (cmHasPrefix(path, ProjectDirs().Binary)) {
+ res = cmStrCat("BIN:", path.substr(ProjectDirs().Binary.size()));
+ } else {
+ res = std::string(path);
+ }
+ return cmQtAutoGen::Quoted(res);
+}
diff --git a/Source/cmQtAutoGenerator.h b/Source/cmQtAutoGenerator.h
index 4b8b0b7..371b25c 100644
--- a/Source/cmQtAutoGenerator.h
+++ b/Source/cmQtAutoGenerator.h
@@ -23,9 +23,7 @@ class cmQtAutoGenerator : public cmQtAutoGen
public:
// -- Types
- /**
- * Thread safe logger
- */
+ /** Thread safe logger. */
class Logger
{
public:
@@ -45,12 +43,8 @@ public:
void Info(GenT genType, cm::string_view message) const;
// -- Log warning
void Warning(GenT genType, cm::string_view message) const;
- void WarningFile(GenT genType, cm::string_view filename,
- cm::string_view message) const;
// -- Log error
void Error(GenT genType, cm::string_view message) const;
- void ErrorFile(GenT genType, cm::string_view filename,
- cm::string_view message) const;
void ErrorCommand(GenT genType, cm::string_view message,
std::vector<std::string> const& command,
std::string const& output) const;
@@ -64,6 +58,15 @@ public:
bool ColorOutput_ = false;
};
+ /** Project directories. */
+ struct ProjectDirsT
+ {
+ std::string Source;
+ std::string Binary;
+ std::string CurrentSource;
+ std::string CurrentBinary;
+ };
+
// -- File system methods
static bool MakeParentDirectory(std::string const& filename);
static bool FileRead(std::string& content, std::string const& filename,
@@ -91,13 +94,18 @@ public:
std::string const& InfoDir() const { return InfoDir_; }
std::string const& InfoConfig() const { return InfoConfig_; }
+ // -- Directories
+ ProjectDirsT const& ProjectDirs() const { return ProjectDirs_; }
+
// -- Utility
static std::string SettingsFind(std::string const& content, const char* key);
+ std::string MessagePath(cm::string_view path) const;
protected:
// -- Abstract processing interface
virtual bool Init(cmMakefile* makefile) = 0;
virtual bool Process() = 0;
+ ProjectDirsT& ProjectDirsRef() { return ProjectDirs_; }
private:
// -- Info settings
@@ -105,6 +113,8 @@ private:
cmFileTime InfoFileTime_;
std::string InfoDir_;
std::string InfoConfig_;
+ // -- Directories
+ ProjectDirsT ProjectDirs_;
};
#endif
diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx
index 40ebdde..4e4875e 100644
--- a/Source/cmQtAutoMocUic.cxx
+++ b/Source/cmQtAutoMocUic.cxx
@@ -2,14 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmQtAutoMocUic.h"
-#include <algorithm>
-#include <initializer_list>
-#include <list>
-#include <set>
-#include <utility>
-
-#include "cm_memory.hxx"
-
#include "cmAlgorithms.h"
#include "cmCryptoHash.h"
#include "cmGeneratedFileStream.h"
@@ -17,9 +9,13 @@
#include "cmQtAutoGen.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cm_memory.hxx"
#include "cmake.h"
#include "cmsys/FStream.hxx"
+#include <algorithm>
+#include <set>
+#include <utility>
#if defined(__APPLE__)
# include <unistd.h>
#endif
@@ -238,13 +234,6 @@ void cmQtAutoMocUic::JobT::LogError(GenT genType,
Gen()->Log().Error(genType, message);
}
-void cmQtAutoMocUic::JobT::LogFileError(GenT genType, cm::string_view filename,
- cm::string_view message) const
-{
- Gen()->AbortError();
- Gen()->Log().ErrorFile(genType, filename, message);
-}
-
void cmQtAutoMocUic::JobT::LogCommandError(
GenT genType, cm::string_view message,
std::vector<std::string> const& command, std::string const& output) const
@@ -269,6 +258,7 @@ bool cmQtAutoMocUic::JobT::RunProcess(GenT genType,
info.empty() || cmHasSuffix(info, '\n') ? "" : "\n",
QuotedCommand(command), '\n'));
}
+ // Run command
return cmWorkerPool::JobT::RunProcess(result, command,
BaseConst().AutogenBuildDir);
}
@@ -283,24 +273,21 @@ void cmQtAutoMocUic::JobMocPredefsT::Process()
if (!Update(reason.get())) {
return;
}
- std::string const& predefsFileRel = MocConst().PredefsFileRel;
std::string const& predefsFileAbs = MocConst().PredefsFileAbs;
{
cmWorkerPool::ProcessResultT result;
{
// Compose command
std::vector<std::string> cmd = MocConst().PredefsCmd;
- // Add includes
- cmAppend(cmd, MocConst().Includes);
// Add definitions
- for (std::string const& def : MocConst().Definitions) {
- cmd.emplace_back("-D" + def);
- }
+ cmAppend(cmd, MocConst().OptionsDefinitions);
+ // Add includes
+ cmAppend(cmd, MocConst().OptionsIncludes);
// Execute command
if (!RunProcess(GenT::MOC, result, cmd, reason.get())) {
LogCommandError(GenT::MOC,
cmStrCat("The content generation command for ",
- Quoted(predefsFileRel), " failed.\n",
+ MessagePath(predefsFileAbs), " failed.\n",
result.ErrorMessage),
cmd, result.StdOut);
return;
@@ -310,19 +297,20 @@ void cmQtAutoMocUic::JobMocPredefsT::Process()
// (Re)write predefs file only on demand
if (cmQtAutoGenerator::FileDiffers(predefsFileAbs, result.StdOut)) {
if (!cmQtAutoGenerator::FileWrite(predefsFileAbs, result.StdOut)) {
- LogFileError(GenT::MOC, predefsFileAbs,
- cmStrCat("Writing ", Quoted(predefsFileRel), " failed."));
+ LogError(
+ GenT::MOC,
+ cmStrCat("Writing ", MessagePath(predefsFileAbs), " failed."));
return;
}
} else {
// Touch to update the time stamp
if (Log().Verbose()) {
- Log().Info(GenT::MOC, "Touching " + Quoted(predefsFileRel));
+ Log().Info(GenT::MOC, "Touching " + MessagePath(predefsFileAbs));
}
if (!cmSystemTools::Touch(predefsFileAbs, false)) {
- LogFileError(
- GenT::MOC, predefsFileAbs,
- cmStrCat("Touching ", Quoted(predefsFileAbs), " failed."));
+ LogError(
+ GenT::MOC,
+ cmStrCat("Touching ", MessagePath(predefsFileAbs), " failed."));
return;
}
}
@@ -330,7 +318,9 @@ void cmQtAutoMocUic::JobMocPredefsT::Process()
// Read file time afterwards
if (!MocEval().PredefsTime.Load(predefsFileAbs)) {
- LogFileError(GenT::MOC, predefsFileAbs, "File time reading failed.");
+ LogError(GenT::MOC,
+ cmStrCat("Reading the file time of ", MessagePath(predefsFileAbs),
+ " failed."));
return;
}
}
@@ -340,7 +330,7 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const
// Test if the file exists
if (!MocEval().PredefsTime.Load(MocConst().PredefsFileAbs)) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(MocConst().PredefsFileRel),
+ *reason = cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs),
", because it doesn't exist.");
}
return true;
@@ -349,7 +339,7 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const
// Test if the settings changed
if (MocConst().SettingsChanged) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(MocConst().PredefsFileRel),
+ *reason = cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs),
", because the moc settings changed.");
}
return true;
@@ -362,8 +352,9 @@ bool cmQtAutoMocUic::JobMocPredefsT::Update(std::string* reason) const
if (execTime.Load(exec)) {
if (MocEval().PredefsTime.Older(execTime)) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(MocConst().PredefsFileRel),
- " because it is older than ", Quoted(exec), '.');
+ *reason =
+ cmStrCat("Generating ", MessagePath(MocConst().PredefsFileAbs),
+ " because it is older than ", MessagePath(exec), '.');
}
return true;
}
@@ -380,19 +371,21 @@ bool cmQtAutoMocUic::JobParseT::ReadFile()
std::string const& fileName = FileHandle->FileName;
// Write info
if (Log().Verbose()) {
- Log().Info(GenT::GEN, "Parsing " + Quoted(fileName));
+ Log().Info(GenT::GEN, cmStrCat("Parsing ", MessagePath(fileName)));
}
// Read file content
{
std::string error;
if (!cmQtAutoGenerator::FileRead(Content, fileName, &error)) {
- LogFileError(GenT::GEN, fileName, "Could not read the file: " + error);
+ LogError(
+ GenT::GEN,
+ cmStrCat("Could not read ", MessagePath(fileName), ".\n", error));
return false;
}
}
// Warn if empty
if (Content.empty()) {
- Log().WarningFile(GenT::GEN, fileName, "The file is empty.");
+ Log().Warning(GenT::GEN, cmStrCat(MessagePath(fileName), " is empty."));
return false;
}
return true;
@@ -555,37 +548,35 @@ void cmQtAutoMocUic::JobParseSourceT::Process()
}
}
-void cmQtAutoMocUic::JobEvaluateT::Process()
+std::string cmQtAutoMocUic::JobEvalCacheT::MessageSearchLocations() const
{
- // Evaluate for moc
- if (MocConst().Enabled) {
- // Evaluate headers
- for (auto const& pair : BaseEval().Headers) {
- if (!MocEvalHeader(pair.second)) {
- return;
- }
- }
- // Evaluate sources
- for (auto const& pair : BaseEval().Sources) {
- if (!MocEvalSource(pair.second)) {
- return;
- }
+ std::string res;
+ res.reserve(512);
+ for (std::string const& path : SearchLocations) {
+ res += " ";
+ res += MessagePath(path);
+ res += '\n';
+ }
+ return res;
+}
+
+void cmQtAutoMocUic::JobEvalCacheMocT::Process()
+{
+ // Evaluate headers
+ for (auto const& pair : BaseEval().Headers) {
+ if (!EvalHeader(pair.second)) {
+ return;
}
}
- // Evaluate for uic
- if (UicConst().Enabled) {
- if (!UicEval(BaseEval().Headers) || !UicEval(BaseEval().Sources)) {
+ // Evaluate sources
+ for (auto const& pair : BaseEval().Sources) {
+ if (!EvalSource(pair.second)) {
return;
}
}
-
- // Add discovered header parse jobs
- Gen()->CreateParseJobs<JobParseHeaderT>(MocEval().HeadersDiscovered);
- // Add generate job after
- Gen()->WorkerPool().EmplaceJob<JobGenerateT>();
}
-bool cmQtAutoMocUic::JobEvaluateT::MocEvalHeader(SourceFileHandleT source)
+bool cmQtAutoMocUic::JobEvalCacheMocT::EvalHeader(SourceFileHandleT source)
{
SourceFileT const& sourceFile = *source;
auto const& parseData = sourceFile.ParseData->Moc;
@@ -606,13 +597,13 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalHeader(SourceFileHandleT source)
}
// Register mapping in headers map
- MocRegisterMapping(handle, true);
+ RegisterMapping(handle);
}
return true;
}
-bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
+bool cmQtAutoMocUic::JobEvalCacheMocT::EvalSource(
SourceFileHandleT const& source)
{
SourceFileT const& sourceFile = *source;
@@ -623,7 +614,7 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
return true;
}
- std::string const sourceDir = SubDirPrefix(sourceFile.FileName);
+ std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName);
std::string const sourceBase =
cmSystemTools::GetFilenameWithoutLastExtension(sourceFile.FileName);
@@ -650,27 +641,30 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
// Check if this source needs to be moc processed but doesn't.
if (!sourceIncludesDotMoc && !parseData.Macro.empty() &&
!(relaxedMode && sourceIncludesMocUnderscore)) {
- LogFileError(GenT::MOC, sourceFile.FileName,
- cmStrCat("The file contains a ", Quoted(parseData.Macro),
- " macro, but does not include ",
- Quoted(sourceBase + ".moc"),
- "!\nConsider to\n - add #include \"", sourceBase,
- ".moc\"\n - enable SKIP_AUTOMOC for this file"));
+ LogError(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName), "\ncontains a ",
+ Quoted(parseData.Macro), " macro, but does not include ",
+ MessagePath(sourceBase + ".moc"),
+ "!\nConsider to\n - add #include \"", sourceBase,
+ ".moc\"\n - enable SKIP_AUTOMOC for this file"));
return false;
}
// Evaluate "moc_" includes
for (IncludeKeyT const& incKey : parseData.Include.Underscore) {
- std::string const headerBase = incKey.Dir + incKey.Base;
- SourceFileHandleT header = MocFindIncludedHeader(sourceDir, headerBase);
- if (!header) {
- LogFileError(GenT::MOC, sourceFile.FileName,
- cmStrCat("The file includes the moc file ",
- Quoted(incKey.Key),
- ",\nbut the header could not be found "
- "in the following locations\n",
- MocMessageTestHeaders(headerBase)));
- return false;
+ SourceFileHandleT headerHandle;
+ {
+ std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base);
+ if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) {
+ LogError(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ ",\nbut a header ", MessageHeader(headerBase),
+ "\ncould not be found "
+ "in the following directories\n",
+ MessageSearchLocations()));
+ return false;
+ }
}
// The include might be handled differently in relaxed mode
if (relaxedMode && !sourceIncludesDotMoc && !parseData.Macro.empty() &&
@@ -682,30 +676,30 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
// used. This is for KDE4 compatibility.
// Issue a warning
- Log().WarningFile(
- GenT::MOC, sourceFile.FileName,
- cmStrCat("The file contains a ", Quoted(parseData.Macro),
- " macro, but does not include ", Quoted(sourceBase + ".moc"),
- ".\nInstead it includes ", Quoted(incKey.Key),
- ".\nRunning moc on the source\n ",
- Quoted(sourceFile.FileName), "!\nBetter include ",
- Quoted(sourceBase + ".moc"),
+ Log().Warning(
+ GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName), "\ncontains a ",
+ Quoted(parseData.Macro), " macro, but does not include ",
+ MessagePath(sourceBase + ".moc"), ".\nInstead it includes ",
+ MessagePath(incKey.Key), ".\nRunning moc on the source\n ",
+ MessagePath(sourceFile.FileName), "!\nBetter include ",
+ MessagePath(sourceBase + ".moc"),
" for compatibility with regular mode.\n",
"This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
// Create mapping
- if (!MocRegisterIncluded(incKey.Key, source, source, false)) {
+ if (!RegisterIncluded(incKey.Key, source, source)) {
return false;
}
continue;
}
// Check if header is skipped
- if (MocConst().skipped(header->FileName)) {
+ if (MocConst().skipped(headerHandle->FileName)) {
continue;
}
// Create mapping
- if (!MocRegisterIncluded(incKey.Key, source, std::move(header), true)) {
+ if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle))) {
return false;
}
}
@@ -718,53 +712,60 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
bool const ownMoc = (incKey.Base == sourceBase);
if (ownMoc && !parseData.Macro.empty()) {
// Create mapping for the regular use case
- if (!MocRegisterIncluded(incKey.Key, source, source, false)) {
+ if (!RegisterIncluded(incKey.Key, source, source)) {
return false;
}
continue;
}
// Try to find a header instead but issue a warning.
// This is for KDE4 compatibility.
- std::string const headerBase = incKey.Dir + incKey.Base;
- SourceFileHandleT header = MocFindIncludedHeader(sourceDir, headerBase);
- if (!header) {
- LogFileError(
- GenT::MOC, sourceFile.FileName,
- cmStrCat("The file includes the moc file ", Quoted(incKey.Key),
- ",\nwhich seems to be the moc file from a different source "
- "file.\nCMAKE_AUTOMOC_RELAXED_MODE: Also a matching header"
- "could not be found in the following locations\n",
- MocMessageTestHeaders(headerBase)));
- return false;
+ SourceFileHandleT headerHandle;
+ {
+ std::string const headerBase = cmStrCat(incKey.Dir, incKey.Base);
+ if (!FindIncludedHeader(headerHandle, sourceDirPrefix, headerBase)) {
+ LogError(
+ GenT::MOC,
+ cmStrCat(
+ MessagePath(sourceFile.FileName), "\nincludes the moc file ",
+ MessagePath(incKey.Key),
+ ",\nwhich seems to be the moc file from a different source "
+ "file.\nCMAKE_AUTOMOC_RELAXED_MODE:\nAlso a matching header ",
+ MessageHeader(headerBase),
+ "\ncould not be found in the following directories\n",
+ MessageSearchLocations()));
+ return false;
+ }
}
// Check if header is skipped
- if (MocConst().skipped(header->FileName)) {
+ if (MocConst().skipped(headerHandle->FileName)) {
continue;
}
// Issue a warning
if (ownMoc && parseData.Macro.empty()) {
- Log().WarningFile(
- GenT::MOC, sourceFile.FileName,
- cmStrCat("The file includes the moc file ", Quoted(incKey.Key),
+ Log().Warning(
+ GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
", but does not contain a\n", MocConst().MacrosString(),
" macro.\nRunning moc on the header\n ",
- Quoted(header->FileName), "!\nBetter include ",
- Quoted("moc_" + incKey.Base + ".cpp"),
+ MessagePath(headerHandle->FileName), "!\nBetter include ",
+ MessagePath("moc_" + incKey.Base + ".cpp"),
" for a compatibility with regular mode.\n",
"This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
} else {
- Log().WarningFile(
- GenT::MOC, sourceFile.FileName,
- cmStrCat("The file includes the moc file ", Quoted(incKey.Key),
- " instead of ", Quoted("moc_" + incKey.Base + ".cpp"),
+ Log().Warning(
+ GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ " instead of ", MessagePath("moc_" + incKey.Base + ".cpp"),
".\nRunning moc on the header\n ",
- Quoted(header->FileName), "!\nBetter include ",
- Quoted("moc_" + incKey.Base + ".cpp"),
+ MessagePath(headerHandle->FileName), "!\nBetter include ",
+ MessagePath("moc_" + incKey.Base + ".cpp"),
" for compatibility with regular mode.\n",
"This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"));
}
// Create mapping
- if (!MocRegisterIncluded(incKey.Key, source, std::move(header), true)) {
+ if (!RegisterIncluded(incKey.Key, source, std::move(headerHandle))) {
return false;
}
}
@@ -775,25 +776,26 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
bool const ownMoc = (incKey.Base == sourceBase);
if (!ownMoc) {
// Don't allow <BASE>.moc include other than own in regular mode
- LogFileError(
- GenT::MOC, sourceFile.FileName,
- cmStrCat("The file includes the moc file ", Quoted(incKey.Key),
- ",\nwhich seems to be the moc file from a different "
- "source file.\nThis is not supported. Include ",
- Quoted(sourceBase + ".moc"),
- " to run moc on this source file."));
+ LogError(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ", MessagePath(incKey.Key),
+ ",\nwhich seems to be the moc file from a different "
+ "source file.\nThis is not supported. Include ",
+ MessagePath(sourceBase + ".moc"),
+ " to run moc on this source file."));
return false;
}
// Accept but issue a warning if moc isn't required
if (parseData.Macro.empty()) {
- Log().WarningFile(GenT::MOC, sourceFile.FileName,
- cmStrCat("The file includes the moc file ",
- Quoted(incKey.Key),
- ", but does not contain a ",
- MocConst().MacrosString(), " macro."));
+ Log().Warning(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the moc file ",
+ MessagePath(incKey.Key),
+ ", but does not contain a ",
+ MocConst().MacrosString(), " macro."));
}
// Create mapping
- if (!MocRegisterIncluded(incKey.Key, source, source, false)) {
+ if (!RegisterIncluded(incKey.Key, source, source)) {
return false;
}
}
@@ -802,80 +804,74 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource(
return true;
}
-cmQtAutoMocUic::SourceFileHandleT
-cmQtAutoMocUic::JobEvaluateT::MocFindIncludedHeader(
- std::string const& includerDir, std::string const& includeBase) const
+bool cmQtAutoMocUic::JobEvalCacheMocT::FindIncludedHeader(
+ SourceFileHandleT& headerHandle, cm::string_view includerDir,
+ cm::string_view includeBase)
{
- // Search in vicinity of the source
- {
- SourceFileHandleT res = MocFindHeader(includerDir + includeBase);
- if (res) {
- return res;
- }
- }
- // Search in include directories
- for (std::string const& path : MocConst().IncludePaths) {
- std::string testPath = cmStrCat(path, '/', includeBase);
- SourceFileHandleT res = MocFindHeader(testPath);
- if (res) {
- return res;
- }
- }
- // Return without success
- return SourceFileHandleT();
-}
+ // Clear search locations
+ SearchLocations.clear();
+
+ auto findHeader = [this,
+ &headerHandle](std::string const& basePath) -> bool {
+ bool found = false;
+ std::string const baseCollapsed =
+ this->Gen()->CollapseFullPathTS(cmStrCat(basePath, '.'));
+ for (std::string const& ext : this->BaseConst().HeaderExtensions) {
+ std::string const testPath = cmStrCat(baseCollapsed, ext);
+ cmFileTime fileTime;
+ if (!fileTime.Load(testPath)) {
+ // File not found
+ continue;
+ }
-cmQtAutoMocUic::SourceFileHandleT cmQtAutoMocUic::JobEvaluateT::MocFindHeader(
- std::string const& basePath) const
-{
- std::string testPath;
- testPath.reserve(basePath.size() + 8);
- for (std::string const& ext : BaseConst().HeaderExtensions) {
- testPath.clear();
- testPath += basePath;
- testPath += '.';
- testPath += ext;
- cmFileTime fileTime;
- if (fileTime.Load(testPath)) {
- // Compute real path of the file
- testPath = cmSystemTools::GetRealPath(testPath);
// Return a known file if it exists already
{
auto it = BaseEval().Headers.find(testPath);
if (it != BaseEval().Headers.end()) {
- return it->second;
+ headerHandle = it->second;
+ found = true;
+ break;
}
}
+
// Created and return discovered file entry
- SourceFileHandleT& res = MocEval().HeadersDiscovered[testPath];
- if (!res) {
- res = std::make_shared<SourceFileT>(testPath);
- res->FileTime = fileTime;
- res->Moc = true;
+ {
+ SourceFileHandleT& handle = MocEval().HeadersDiscovered[testPath];
+ if (!handle) {
+ handle = std::make_shared<SourceFileT>(testPath);
+ handle->FileTime = fileTime;
+ handle->IsHeader = true;
+ handle->Moc = true;
+ }
+ headerHandle = handle;
+ found = true;
+ break;
}
- return res;
}
- }
- // Return without success
- return SourceFileHandleT();
-}
+ if (!found) {
+ this->SearchLocations.emplace_back(
+ cmQtAutoGen::ParentDir(baseCollapsed));
+ }
+ return found;
+ };
-std::string cmQtAutoMocUic::JobEvaluateT::MocMessageTestHeaders(
- cm::string_view fileBase) const
-{
- std::string const exts =
- cmStrCat(".{", cmJoin(BaseConst().HeaderExtensions, ","), '}');
- // Compose result string
- std::string res = cmStrCat(" ", fileBase, exts, '\n');
+ // Search in vicinity of the source
+ if (findHeader(cmStrCat(includerDir, includeBase))) {
+ return true;
+ }
+ // Search in include directories
for (std::string const& path : MocConst().IncludePaths) {
- res += cmStrCat(" ", path, '/', fileBase, exts, '\n');
+ if (findHeader(cmStrCat(path, '/', includeBase))) {
+ return true;
+ }
}
- return res;
+ // Return without success
+ return false;
}
-bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded(
+bool cmQtAutoMocUic::JobEvalCacheMocT::RegisterIncluded(
std::string const& includeString, SourceFileHandleT includerFileHandle,
- SourceFileHandleT sourceFileHandle, bool sourceIsHeader) const
+ SourceFileHandleT sourceFileHandle) const
{
// Check if this file is already included
MappingHandleT& handle = MocEval().Includes[includeString];
@@ -883,18 +879,19 @@ bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded(
// Check if the output file would be generated from different source files
if (handle->SourceFile != sourceFileHandle) {
std::string files =
- cmStrCat(" ", Quoted(includerFileHandle->FileName), '\n');
+ cmStrCat(" ", MessagePath(includerFileHandle->FileName), '\n');
for (auto const& item : handle->IncluderFiles) {
- files += cmStrCat(" ", Quoted(item->FileName), '\n');
+ files += cmStrCat(" ", MessagePath(item->FileName), '\n');
}
LogError(
GenT::MOC,
cmStrCat("The source files\n", files,
- "contain the same include string ", Quoted(includeString),
+ "contain the same include string ",
+ MessagePath(includeString),
", but\nthe moc file would be generated from different "
"source files\n ",
- Quoted(sourceFileHandle->FileName), " and\n ",
- Quoted(handle->SourceFile->FileName),
+ MessagePath(sourceFileHandle->FileName), " and\n ",
+ MessagePath(handle->SourceFile->FileName),
".\nConsider to\n"
" - not include the \"moc_<NAME>.cpp\" file\n"
" - add a directory prefix to a \"<NAME>.moc\" include "
@@ -916,15 +913,16 @@ bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded(
handle->OutputFile = Gen()->AbsoluteIncludePath(includeString);
// Register mapping in sources/headers map
- MocRegisterMapping(handle, sourceIsHeader);
+ RegisterMapping(handle);
return true;
}
-void cmQtAutoMocUic::JobEvaluateT::MocRegisterMapping(
- MappingHandleT mappingHandle, bool sourceIsHeader) const
+void cmQtAutoMocUic::JobEvalCacheMocT::RegisterMapping(
+ MappingHandleT mappingHandle) const
{
- auto& regMap =
- sourceIsHeader ? MocEval().HeaderMappings : MocEval().SourceMappings;
+ auto& regMap = mappingHandle->SourceFile->IsHeader
+ ? MocEval().HeaderMappings
+ : MocEval().SourceMappings;
// Check if source file already gets mapped
auto& regHandle = regMap[mappingHandle->SourceFile->FileName];
if (!regHandle) {
@@ -938,17 +936,33 @@ void cmQtAutoMocUic::JobEvaluateT::MocRegisterMapping(
}
}
-bool cmQtAutoMocUic::JobEvaluateT::UicEval(SourceFileMapT const& fileMap)
+std::string cmQtAutoMocUic::JobEvalCacheMocT::MessageHeader(
+ cm::string_view headerBase) const
{
- for (auto const& pair : fileMap) {
- if (!UicEvalFile(pair.second)) {
- return false;
+ return MessagePath(cmStrCat(
+ headerBase, ".{", cmJoin(this->BaseConst().HeaderExtensions, ","), '}'));
+}
+
+void cmQtAutoMocUic::JobEvalCacheUicT::Process()
+{
+ // Prepare buffers
+ SearchLocations.reserve((UicConst().SearchPaths.size() + 1) * 2);
+
+ // Evaluate headers
+ for (auto const& pair : BaseEval().Headers) {
+ if (!EvalFile(pair.second)) {
+ return;
+ }
+ }
+ // Evaluate sources
+ for (auto const& pair : BaseEval().Sources) {
+ if (!EvalFile(pair.second)) {
+ return;
}
}
- return true;
}
-bool cmQtAutoMocUic::JobEvaluateT::UicEvalFile(
+bool cmQtAutoMocUic::JobEvalCacheUicT::EvalFile(
SourceFileHandleT const& sourceFileHandle)
{
SourceFileT const& sourceFile = *sourceFileHandle;
@@ -957,17 +971,25 @@ bool cmQtAutoMocUic::JobEvaluateT::UicEvalFile(
return true;
}
- std::string const sourceDir = SubDirPrefix(sourceFile.FileName);
+ std::string const sourceDirPrefix = SubDirPrefix(sourceFile.FileName);
for (IncludeKeyT const& incKey : Include) {
- // Find .ui file name
- SourceFileHandleT uiFileHandle =
- UicFindIncludedUi(sourceFile.FileName, sourceDir, incKey);
- if (!uiFileHandle || UicConst().skipped(uiFileHandle->FileName)) {
+ // Find .ui file
+ UiName = cmStrCat(incKey.Base, ".ui");
+ if (!FindIncludedUi(sourceDirPrefix, incKey.Dir)) {
+ LogError(GenT::UIC,
+ cmStrCat(MessagePath(sourceFile.FileName),
+ "\nincludes the uic file ", MessagePath(incKey.Key),
+ ",\nbut the user interface file ", MessagePath(UiName),
+ "\ncould not be found in the following directories\n",
+ MessageSearchLocations()));
+ return false;
+ }
+ // Check if the file is skipped
+ if (UicConst().skipped(UiFileHandle->FileName)) {
continue;
}
// Register mapping
- if (!UicRegisterMapping(incKey.Key, std::move(uiFileHandle),
- sourceFileHandle)) {
+ if (!RegisterMapping(incKey.Key, sourceFileHandle)) {
return false;
}
}
@@ -975,20 +997,73 @@ bool cmQtAutoMocUic::JobEvaluateT::UicEvalFile(
return true;
}
-bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping(
- std::string const& includeString, SourceFileHandleT uiFileHandle,
- SourceFileHandleT includerFileHandle)
+bool cmQtAutoMocUic::JobEvalCacheUicT::FindIncludedUi(
+ cm::string_view sourceDirPrefix, cm::string_view includePrefix)
+{
+ // Clear locations buffer
+ SearchLocations.clear();
+
+ auto findUi = [this](std::string const& testPath) -> bool {
+ std::string const fullPath = this->Gen()->CollapseFullPathTS(testPath);
+ cmFileTime fileTime;
+ if (!fileTime.Load(fullPath)) {
+ this->SearchLocations.emplace_back(cmQtAutoGen::ParentDir(fullPath));
+ return false;
+ }
+ // .ui file found in files system!
+ // Get or create .ui file handle
+ SourceFileHandleT& handle = this->UicEval().UiFiles[fullPath];
+ if (!handle) {
+ // The file wasn't registered, yet
+ handle = std::make_shared<SourceFileT>(fullPath);
+ handle->FileTime = fileTime;
+ }
+ this->UiFileHandle = handle;
+ return true;
+ };
+
+ // Vicinity of the source
+ if (findUi(cmStrCat(sourceDirPrefix, UiName))) {
+ return true;
+ }
+ if (!includePrefix.empty()) {
+ if (findUi(cmStrCat(sourceDirPrefix, includePrefix, UiName))) {
+ return true;
+ }
+ }
+ // Additional AUTOUIC search paths
+ auto const& searchPaths = UicConst().SearchPaths;
+ if (!searchPaths.empty()) {
+ for (std::string const& sPath : searchPaths) {
+ if (findUi(cmStrCat(sPath, '/', UiName))) {
+ return true;
+ }
+ }
+ if (!includePrefix.empty()) {
+ for (std::string const& sPath : searchPaths) {
+ if (findUi(cmStrCat(sPath, '/', includePrefix, UiName))) {
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+bool cmQtAutoMocUic::JobEvalCacheUicT::RegisterMapping(
+ std::string const& includeString, SourceFileHandleT includerFileHandle)
{
auto& Includes = Gen()->UicEval().Includes;
auto it = Includes.find(includeString);
if (it != Includes.end()) {
MappingHandleT const& handle = it->second;
- if (handle->SourceFile != uiFileHandle) {
+ if (handle->SourceFile != UiFileHandle) {
// The output file already gets generated - from a different .ui file!
std::string files =
- cmStrCat(" ", Quoted(includerFileHandle->FileName), '\n');
+ cmStrCat(" ", MessagePath(includerFileHandle->FileName), '\n');
for (auto const& item : handle->IncluderFiles) {
- files += cmStrCat(" ", Quoted(item->FileName), '\n');
+ files += cmStrCat(" ", MessagePath(item->FileName), '\n');
}
LogError(
GenT::UIC,
@@ -997,8 +1072,8 @@ bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping(
Quoted(includeString),
", but\nthe uic file would be generated from different "
"user interface files\n ",
- Quoted(uiFileHandle->FileName), " and\n ",
- Quoted(handle->SourceFile->FileName),
+ MessagePath(UiFileHandle->FileName), " and\n ",
+ MessagePath(handle->SourceFile->FileName),
".\nConsider to\n"
" - add a directory prefix to a \"ui_<NAME>.h\" include "
"(e.g \"sub/ui_<NAME>.h\")\n"
@@ -1013,7 +1088,7 @@ bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping(
MappingHandleT handle = std::make_shared<MappingT>();
handle->IncludeString = includeString;
handle->IncluderFiles.emplace_back(std::move(includerFileHandle));
- handle->SourceFile = std::move(uiFileHandle);
+ handle->SourceFile = UiFileHandle;
handle->OutputFile = Gen()->AbsoluteIncludePath(includeString);
// Register mapping
Includes.emplace(includeString, std::move(handle));
@@ -1021,123 +1096,60 @@ bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping(
return true;
}
-cmQtAutoMocUic::SourceFileHandleT
-cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi(
- std::string const& sourceFile, std::string const& sourceDir,
- IncludeKeyT const& incKey) const
+void cmQtAutoMocUic::JobEvalCacheFinishT::Process()
{
- std::string searchFileName = cmStrCat(incKey.Base, ".ui");
- // Collect search paths list
- std::vector<std::string> testFiles;
- {
- auto& searchPaths = UicConst().SearchPaths;
- testFiles.reserve((searchPaths.size() + 1) * 2);
-
- // Vicinity of the source
- testFiles.emplace_back(sourceDir + searchFileName);
- if (!incKey.Dir.empty()) {
- testFiles.emplace_back(cmStrCat(sourceDir, incKey.Dir, searchFileName));
- }
- // AUTOUIC search paths
- if (!searchPaths.empty()) {
- for (std::string const& sPath : searchPaths) {
- testFiles.emplace_back(cmStrCat(sPath, '/', searchFileName));
- }
- if (!incKey.Dir.empty()) {
- for (std::string const& sPath : searchPaths) {
- testFiles.emplace_back(
- cmStrCat(sPath, '/', incKey.Dir, searchFileName));
- }
- }
- }
- }
-
- // Search for the .ui file!
- for (std::string const& testFile : testFiles) {
- cmFileTime fileTime;
- if (fileTime.Load(testFile)) {
- // .ui file found in files system!
- std::string realPath = cmSystemTools::GetRealPath(testFile);
- // Get or create .ui file handle
- SourceFileHandleT& handle = Gen()->UicEval().UiFiles[realPath];
- if (!handle) {
- // The file wasn't registered, yet
- handle = std::make_shared<SourceFileT>(realPath);
- handle->FileTime = fileTime;
- }
- return handle;
- }
- }
+ // Add discovered header parse jobs
+ Gen()->CreateParseJobs<JobParseHeaderT>(MocEval().HeadersDiscovered);
- // Log error
+ // Add dependency probing jobs
{
- std::string files;
- for (std::string const& testFile : testFiles) {
- files += cmStrCat(" ", Quoted(testFile), '\n');
+ // Add fence job to ensure all parsing has finished
+ Gen()->WorkerPool().EmplaceJob<JobFenceT>();
+ if (MocConst().Enabled) {
+ Gen()->WorkerPool().EmplaceJob<JobProbeDepsMocT>();
}
- LogFileError(
- GenT::UIC, sourceFile,
- cmStrCat("The file includes the uic file ", Quoted(incKey.Key),
- ",\nbut the user interface file ", Quoted(searchFileName),
- "\ncould not be found in the following locations\n", files));
+ if (UicConst().Enabled) {
+ Gen()->WorkerPool().EmplaceJob<JobProbeDepsUicT>();
+ }
+ // Add probe finish job
+ Gen()->WorkerPool().EmplaceJob<JobProbeDepsFinishT>();
}
-
- return SourceFileHandleT();
}
-void cmQtAutoMocUic::JobGenerateT::Process()
+void cmQtAutoMocUic::JobProbeDepsMocT::Process()
{
- // Add moc compile jobs
- if (MocConst().Enabled) {
- for (auto const& pair : MocEval().HeaderMappings) {
- // Register if this mapping is a candidate for mocs_compilation.cpp
- bool const compFile = pair.second->IncludeString.empty();
- if (compFile) {
- MocEval().CompFiles.emplace_back(pair.second->SourceFile->BuildPath);
- }
- if (!MocGenerate(pair.second, compFile)) {
- return;
- }
+ // Create moc header jobs
+ for (auto const& pair : MocEval().HeaderMappings) {
+ // Register if this mapping is a candidate for mocs_compilation.cpp
+ bool const compFile = pair.second->IncludeString.empty();
+ if (compFile) {
+ MocEval().CompFiles.emplace_back(pair.second->SourceFile->BuildPath);
}
- for (auto const& pair : MocEval().SourceMappings) {
- if (!MocGenerate(pair.second, false)) {
- return;
- }
+ if (!Generate(pair.second, compFile)) {
+ return;
}
-
- // Add mocs compilations job on demand
- Gen()->WorkerPool().EmplaceJob<JobMocsCompilationT>();
}
- // Add uic compile jobs
- if (UicConst().Enabled) {
- for (auto const& pair : Gen()->UicEval().Includes) {
- if (!UicGenerate(pair.second)) {
- return;
- }
+ // Create moc source jobs
+ for (auto const& pair : MocEval().SourceMappings) {
+ if (!Generate(pair.second, false)) {
+ return;
}
}
-
- // Add finish job
- Gen()->WorkerPool().EmplaceJob<JobFinishT>();
}
-bool cmQtAutoMocUic::JobGenerateT::MocGenerate(MappingHandleT const& mapping,
- bool compFile) const
+bool cmQtAutoMocUic::JobProbeDepsMocT::Generate(MappingHandleT const& mapping,
+ bool compFile) const
{
std::unique_ptr<std::string> reason;
if (Log().Verbose()) {
reason = cm::make_unique<std::string>();
}
- if (MocUpdate(*mapping, reason.get())) {
- // Create the parent directory
- if (!MakeParentDirectory(mapping->OutputFile)) {
- LogFileError(GenT::MOC, mapping->OutputFile,
- "Could not create parent directory.");
- return false;
- }
+ if (Probe(*mapping, reason.get())) {
+ // Register the parent directory for creation
+ MocEval().OutputDirs.emplace(cmQtAutoGen::ParentDir(mapping->OutputFile));
// Add moc job
- Gen()->WorkerPool().EmplaceJob<JobMocT>(mapping, std::move(reason));
+ Gen()->WorkerPool().EmplaceJob<JobCompileMocT>(mapping, std::move(reason));
// Check if a moc job for a mocs_compilation.cpp entry was generated
if (compFile) {
MocEval().CompUpdated = true;
@@ -1146,7 +1158,7 @@ bool cmQtAutoMocUic::JobGenerateT::MocGenerate(MappingHandleT const& mapping,
return true;
}
-bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
+bool cmQtAutoMocUic::JobProbeDepsMocT::Probe(MappingT const& mapping,
std::string* reason) const
{
std::string const& sourceFile = mapping.SourceFile->FileName;
@@ -1157,8 +1169,8 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
if (!outputFileTime.Load(outputFile)) {
if (reason != nullptr) {
*reason =
- cmStrCat("Generating ", Quoted(outputFile),
- ", because it doesn't exist, from ", Quoted(sourceFile));
+ cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it doesn't exist, from ", MessagePath(sourceFile));
}
return true;
}
@@ -1166,9 +1178,9 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
// Test if any setting changed
if (MocConst().SettingsChanged) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(outputFile),
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
", because the uic settings changed, from ",
- Quoted(sourceFile));
+ MessagePath(sourceFile));
}
return true;
}
@@ -1176,9 +1188,9 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
// Test if the source file is newer
if (outputFileTime.Older(mapping.SourceFile->FileTime)) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(outputFile),
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
", because it's older than its source file, from ",
- Quoted(sourceFile));
+ MessagePath(sourceFile));
}
return true;
}
@@ -1187,9 +1199,10 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
if (!MocConst().PredefsFileAbs.empty()) {
if (outputFileTime.Older(MocEval().PredefsTime)) {
if (reason != nullptr) {
- *reason = cmStrCat(
- "Generating ", Quoted(outputFile), ", because it's older than ",
- Quoted(MocConst().PredefsFileAbs), ", from ", Quoted(sourceFile));
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than ",
+ MessagePath(MocConst().PredefsFileAbs), ", from ",
+ MessagePath(sourceFile));
}
return true;
}
@@ -1198,9 +1211,9 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
// Test if the moc executable is newer
if (outputFileTime.Older(MocConst().ExecutableTime)) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(outputFile),
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
", because it's older than the moc executable, from ",
- Quoted(sourceFile));
+ MessagePath(sourceFile));
}
return true;
}
@@ -1211,19 +1224,21 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
std::string const sourceDir = SubDirPrefix(sourceFile);
for (std::string const& dep : mapping.SourceFile->ParseData->Moc.Depends) {
// Find dependency file
- auto const depMatch = MocFindDependency(sourceDir, dep);
+ auto const depMatch = FindDependency(sourceDir, dep);
if (depMatch.first.empty()) {
- Log().WarningFile(GenT::MOC, sourceFile,
- "Could not find dependency file " + Quoted(dep));
+ Log().Warning(GenT::MOC,
+ cmStrCat(MessagePath(sourceFile), " depends on ",
+ MessagePath(dep),
+ " but the file does not exist."));
continue;
}
// Test if dependency file is older
if (outputFileTime.Older(depMatch.second)) {
if (reason != nullptr) {
- *reason =
- cmStrCat("Generating ", Quoted(outputFile),
- ", because it's older than its dependency file ",
- Quoted(depMatch.first), ", from ", Quoted(sourceFile));
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it's older than its dependency file ",
+ MessagePath(depMatch.first), ", from ",
+ MessagePath(sourceFile));
}
return true;
}
@@ -1234,7 +1249,7 @@ bool cmQtAutoMocUic::JobGenerateT::MocUpdate(MappingT const& mapping,
}
std::pair<std::string, cmFileTime>
-cmQtAutoMocUic::JobGenerateT::MocFindDependency(
+cmQtAutoMocUic::JobProbeDepsMocT::FindDependency(
std::string const& sourceDir, std::string const& includeString) const
{
using ResPair = std::pair<std::string, cmFileTime>;
@@ -1256,27 +1271,26 @@ cmQtAutoMocUic::JobGenerateT::MocFindDependency(
return ResPair();
}
-bool cmQtAutoMocUic::JobGenerateT::UicGenerate(
- MappingHandleT const& mapping) const
+void cmQtAutoMocUic::JobProbeDepsUicT::Process()
{
- std::unique_ptr<std::string> reason;
- if (Log().Verbose()) {
- reason = cm::make_unique<std::string>();
- }
- if (UicUpdate(*mapping, reason.get())) {
- // Create the parent directory
- if (!MakeParentDirectory(mapping->OutputFile)) {
- LogFileError(GenT::UIC, mapping->OutputFile,
- "Could not create parent directory.");
- return false;
+ for (auto const& pair : Gen()->UicEval().Includes) {
+ MappingHandleT const& mapping = pair.second;
+ std::unique_ptr<std::string> reason;
+ if (Log().Verbose()) {
+ reason = cm::make_unique<std::string>();
}
+ if (!Probe(*mapping, reason.get())) {
+ continue;
+ }
+
+ // Register the parent directory for creation
+ UicEval().OutputDirs.emplace(cmQtAutoGen::ParentDir(mapping->OutputFile));
// Add uic job
- Gen()->WorkerPool().EmplaceJob<JobUicT>(mapping, std::move(reason));
+ Gen()->WorkerPool().EmplaceJob<JobCompileUicT>(mapping, std::move(reason));
}
- return true;
}
-bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping,
+bool cmQtAutoMocUic::JobProbeDepsUicT::Probe(MappingT const& mapping,
std::string* reason) const
{
std::string const& sourceFile = mapping.SourceFile->FileName;
@@ -1287,8 +1301,8 @@ bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping,
if (!outputFileTime.Load(outputFile)) {
if (reason != nullptr) {
*reason =
- cmStrCat("Generating ", Quoted(outputFile),
- ", because it doesn't exist, from ", Quoted(sourceFile));
+ cmStrCat("Generating ", MessagePath(outputFile),
+ ", because it doesn't exist, from ", MessagePath(sourceFile));
}
return true;
}
@@ -1296,9 +1310,9 @@ bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping,
// Test if the uic settings changed
if (UicConst().SettingsChanged) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(outputFile),
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
", because the uic settings changed, from ",
- Quoted(sourceFile));
+ MessagePath(sourceFile));
}
return true;
}
@@ -1306,9 +1320,9 @@ bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping,
// Test if the source file is newer
if (outputFileTime.Older(mapping.SourceFile->FileTime)) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(outputFile),
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
" because it's older than the source file ",
- Quoted(sourceFile));
+ MessagePath(sourceFile));
}
return true;
}
@@ -1316,9 +1330,9 @@ bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping,
// Test if the uic executable is newer
if (outputFileTime.Older(UicConst().ExecutableTime)) {
if (reason != nullptr) {
- *reason = cmStrCat("Generating ", Quoted(outputFile),
+ *reason = cmStrCat("Generating ", MessagePath(outputFile),
", because it's older than the uic executable, from ",
- Quoted(sourceFile));
+ MessagePath(sourceFile));
}
return true;
}
@@ -1326,24 +1340,93 @@ bool cmQtAutoMocUic::JobGenerateT::UicUpdate(MappingT const& mapping,
return false;
}
-void cmQtAutoMocUic::JobMocT::Process()
+void cmQtAutoMocUic::JobProbeDepsFinishT::Process()
+{
+ // Create output directories
+ {
+ using StringSet = std::unordered_set<std::string>;
+ auto createDirs = [this](GenT genType, StringSet const& dirSet) {
+ for (std::string const& dirName : dirSet) {
+ if (!cmSystemTools::MakeDirectory(dirName)) {
+ this->LogError(
+ genType,
+ cmStrCat("Creating directory ", MessagePath(dirName), " failed."));
+ return;
+ }
+ }
+ };
+ if (MocConst().Enabled && UicConst().Enabled) {
+ StringSet outputDirs = MocEval().OutputDirs;
+ outputDirs.insert(UicEval().OutputDirs.begin(),
+ UicEval().OutputDirs.end());
+ createDirs(GenT::GEN, outputDirs);
+ } else if (MocConst().Enabled) {
+ createDirs(GenT::MOC, MocEval().OutputDirs);
+ } else if (UicConst().Enabled) {
+ createDirs(GenT::UIC, UicEval().OutputDirs);
+ }
+ }
+
+ if (MocConst().Enabled) {
+ // Add mocs compilations job
+ Gen()->WorkerPool().EmplaceJob<JobMocsCompilationT>();
+ }
+
+ // Add finish job
+ Gen()->WorkerPool().EmplaceJob<JobFinishT>();
+}
+
+void cmQtAutoMocUic::JobCompileMocT::Process()
{
std::string const& sourceFile = Mapping->SourceFile->FileName;
std::string const& outputFile = Mapping->OutputFile;
// Compose moc command
std::vector<std::string> cmd;
- cmd.push_back(MocConst().Executable);
- // Add options
- cmAppend(cmd, MocConst().AllOptions);
- // Add predefs include
- if (!MocConst().PredefsFileAbs.empty()) {
- cmd.emplace_back("--include");
- cmd.push_back(MocConst().PredefsFileAbs);
+ {
+ // Reserve large enough
+ cmd.reserve(MocConst().OptionsDefinitions.size() +
+ MocConst().OptionsIncludes.size() +
+ MocConst().OptionsExtra.size() + 16);
+ cmd.push_back(MocConst().Executable);
+ // Add definitions
+ cmAppend(cmd, MocConst().OptionsDefinitions);
+ // Add includes
+ cmAppend(cmd, MocConst().OptionsIncludes);
+ // Add predefs include
+ if (!MocConst().PredefsFileAbs.empty()) {
+ cmd.emplace_back("--include");
+ cmd.push_back(MocConst().PredefsFileAbs);
+ }
+ // Add path prefix on demand
+ if (MocConst().PathPrefix && Mapping->SourceFile->IsHeader) {
+ for (std::string const& dir : MocConst().IncludePaths) {
+ cm::string_view prefix = sourceFile;
+ if (cmHasPrefix(prefix, dir)) {
+ prefix.remove_prefix(dir.size());
+ if (cmHasPrefix(prefix, '/')) {
+ prefix.remove_prefix(1);
+ auto slashPos = prefix.rfind('/');
+ if (slashPos != cm::string_view::npos) {
+ cmd.emplace_back("-p");
+ cmd.emplace_back(prefix.substr(0, slashPos));
+ } else {
+ cmd.emplace_back("-p");
+ cmd.emplace_back("./");
+ }
+ break;
+ }
+ }
+ }
+ }
+ // Add extra options
+ cmAppend(cmd, MocConst().OptionsExtra);
+ // Add output file
+ cmd.emplace_back("-o");
+ cmd.push_back(outputFile);
+ // Add source file
+ cmd.push_back(sourceFile);
}
- cmd.emplace_back("-o");
- cmd.push_back(outputFile);
- cmd.push_back(sourceFile);
// Execute moc command
cmWorkerPool::ProcessResultT result;
@@ -1358,19 +1441,19 @@ void cmQtAutoMocUic::JobMocT::Process()
if (!Mapping->IncluderFiles.empty()) {
includers = "included by\n";
for (auto const& item : Mapping->IncluderFiles) {
- includers += cmStrCat(" ", Quoted(item->FileName), '\n');
+ includers += cmStrCat(" ", MessagePath(item->FileName), '\n');
}
}
LogCommandError(GenT::MOC,
cmStrCat("The moc process failed to compile\n ",
- Quoted(sourceFile), "\ninto\n ",
- Quoted(outputFile), '\n', includers,
+ MessagePath(sourceFile), "\ninto\n ",
+ MessagePath(outputFile), '\n', includers,
result.ErrorMessage),
cmd, result.StdOut);
}
}
-void cmQtAutoMocUic::JobUicT::Process()
+void cmQtAutoMocUic::JobCompileUicT::Process()
{
std::string const& sourceFile = Mapping->SourceFile->FileName;
std::string const& outputFile = Mapping->OutputFile;
@@ -1402,13 +1485,13 @@ void cmQtAutoMocUic::JobUicT::Process()
// Uic command failed
std::string includers;
for (auto const& item : Mapping->IncluderFiles) {
- includers += cmStrCat(" ", Quoted(item->FileName), '\n');
+ includers += cmStrCat(" ", MessagePath(item->FileName), '\n');
}
LogCommandError(GenT::UIC,
cmStrCat("The uic process failed to compile\n ",
- Quoted(sourceFile), "\ninto\n ",
- Quoted(outputFile), "\nincluded by\n", includers,
- result.ErrorMessage),
+ MessagePath(sourceFile), "\ninto\n ",
+ MessagePath(outputFile), "\nincluded by\n",
+ includers, result.ErrorMessage),
cmd, result.StdOut);
}
}
@@ -1436,20 +1519,24 @@ void cmQtAutoMocUic::JobMocsCompilationT::Process()
if (cmQtAutoGenerator::FileDiffers(compAbs, content)) {
// Actually write mocs compilation file
if (Log().Verbose()) {
- Log().Info(GenT::MOC, "Generating MOC compilation " + compAbs);
+ Log().Info(GenT::MOC,
+ "Generating MOC compilation " + MessagePath(compAbs));
}
if (!FileWrite(compAbs, content)) {
- LogFileError(GenT::MOC, compAbs,
- "mocs compilation file writing failed.");
+ LogError(GenT::MOC,
+ cmStrCat("Writing MOC compilation ", MessagePath(compAbs),
+ " failed."));
}
} else if (MocEval().CompUpdated) {
// Only touch mocs compilation file
if (Log().Verbose()) {
- Log().Info(GenT::MOC, "Touching mocs compilation " + compAbs);
+ Log().Info(GenT::MOC,
+ "Touching MOC compilation " + MessagePath(compAbs));
}
if (!cmSystemTools::Touch(compAbs, false)) {
- LogFileError(GenT::MOC, compAbs,
- "mocs compilation file touching failed.");
+ LogError(GenT::MOC,
+ cmStrCat("Touching MOC compilation ", MessagePath(compAbs),
+ " failed."));
}
}
}
@@ -1543,12 +1630,10 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
makefile->GetCMakeInstance()->GetHeaderExtensions();
// - Files and directories
- BaseConst_.IncludeProjectDirsBefore =
- InfoGetBool("AM_CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE");
- BaseConst_.ProjectSourceDir = InfoGet("AM_CMAKE_SOURCE_DIR");
- BaseConst_.ProjectBinaryDir = InfoGet("AM_CMAKE_BINARY_DIR");
- BaseConst_.CurrentSourceDir = InfoGet("AM_CMAKE_CURRENT_SOURCE_DIR");
- BaseConst_.CurrentBinaryDir = InfoGet("AM_CMAKE_CURRENT_BINARY_DIR");
+ ProjectDirsRef().Source = InfoGet("AM_CMAKE_SOURCE_DIR");
+ ProjectDirsRef().Binary = InfoGet("AM_CMAKE_BINARY_DIR");
+ ProjectDirsRef().CurrentSource = InfoGet("AM_CMAKE_CURRENT_SOURCE_DIR");
+ ProjectDirsRef().CurrentBinary = InfoGet("AM_CMAKE_CURRENT_BINARY_DIR");
BaseConst_.AutogenBuildDir = InfoGet("AM_BUILD_DIR");
if (BaseConst_.AutogenBuildDir.empty()) {
return LogInfoError("Autogen build directory missing.");
@@ -1563,7 +1648,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
}
if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) {
return LogInfoError(cmStrCat("The CMake executable ",
- Quoted(BaseConst_.CMakeExecutable),
+ MessagePath(BaseConst_.CMakeExecutable),
" does not exist."));
}
BaseConst_.ParseCacheFile = InfoGetConfig("AM_PARSE_CACHE_FILE");
@@ -1592,7 +1677,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
// Load the executable file time
if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) {
return LogInfoError(cmStrCat("The moc executable ",
- Quoted(MocConst_.Executable),
+ MessagePath(MocConst_.Executable),
" does not exist."));
}
for (std::string& sfl : InfoGetList("AM_MOC_SKIP")) {
@@ -1600,8 +1685,11 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
}
MocConst_.Definitions = InfoGetConfigList("AM_MOC_DEFINITIONS");
MocConst_.IncludePaths = InfoGetConfigList("AM_MOC_INCLUDES");
- MocConst_.Options = InfoGetList("AM_MOC_OPTIONS");
+ MocConst_.OptionsExtra = InfoGetList("AM_MOC_OPTIONS");
+
MocConst_.RelaxedMode = InfoGetBool("AM_MOC_RELAXED_MODE");
+ MocConst_.PathPrefix = InfoGetBool("AM_MOC_PATH_PREFIX");
+
for (std::string const& item : InfoGetList("AM_MOC_MACRO_NAMES")) {
MocConst_.MacroFilters.emplace_back(
item, ("[\n][ \t]*{?[ \t]*" + item).append("[^a-zA-Z0-9_]"));
@@ -1658,7 +1746,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
// Load the executable file time
if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) {
return LogInfoError(cmStrCat("The uic executable ",
- Quoted(UicConst_.Executable),
+ MessagePath(UicConst_.Executable),
" does not exist."));
}
for (std::string& sfl : InfoGetList("AM_UIC_SKIP")) {
@@ -1685,83 +1773,89 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
}
}
- // - Headers and sources
+ // Headers
{
- auto makeSource =
- [&LogInfoError](std::string const& fileName,
- std::string const& fileFlags) -> SourceFileHandleT {
+ // Get file lists
+ cm::string_view const keyFiles = "AM_HEADERS";
+ cm::string_view const keyFlags = "AM_HEADERS_FLAGS";
+ std::vector<std::string> files = InfoGetList(keyFiles);
+ std::vector<std::string> flags = InfoGetList(keyFlags);
+ std::vector<std::string> builds;
+ if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) {
+ return false;
+ }
+ if (MocConst().Enabled) {
+ cm::string_view const keyPaths = "AM_HEADERS_BUILD_PATHS";
+ builds = InfoGetList(keyPaths);
+ if (!MatchSizes(keyFiles, keyPaths, files.size(), builds.size())) {
+ return false;
+ }
+ }
+
+ // Process file lists
+ for (std::size_t ii = 0; ii != files.size(); ++ii) {
+ std::string& fileName(files[ii]);
+ std::string const& fileFlags(flags[ii]);
if (fileFlags.size() != 2) {
- LogInfoError("Invalid file flags string size");
- return SourceFileHandleT();
+ LogInfoError(cmStrCat("Invalid flags string size ", fileFlags.size(),
+ "in ", keyFlags));
+ return false;
}
cmFileTime fileTime;
if (!fileTime.Load(fileName)) {
- LogInfoError("The source file " + cmQtAutoGen::Quoted(fileName) +
- " does not exist.");
- return SourceFileHandleT();
- }
- SourceFileHandleT sfh = std::make_shared<SourceFileT>(fileName);
- sfh->FileTime = fileTime;
- sfh->Moc = (fileFlags[0] == 'M');
- sfh->Uic = (fileFlags[1] == 'U');
- return sfh;
- };
-
- // Headers
- {
- // Get file lists
- cm::string_view const keyFiles = "AM_HEADERS";
- cm::string_view const keyFlags = "AM_HEADERS_FLAGS";
- std::vector<std::string> files = InfoGetList(keyFiles);
- std::vector<std::string> flags = InfoGetList(keyFlags);
- std::vector<std::string> builds;
- if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) {
+ LogInfoError(cmStrCat("The header file ", this->MessagePath(fileName),
+ " does not exist."));
return false;
}
- if (MocConst().Enabled) {
- cm::string_view const keyPaths = "AM_HEADERS_BUILD_PATHS";
- builds = InfoGetList(keyPaths);
- if (!MatchSizes(keyFiles, keyPaths, files.size(), builds.size())) {
- return false;
- }
- }
- // Process file lists
- for (std::size_t ii = 0; ii != files.size(); ++ii) {
- std::string& fileName(files[ii]);
- SourceFileHandleT sfh = makeSource(fileName, flags[ii]);
- if (!sfh) {
- return false;
- }
- if (MocConst().Enabled) {
- sfh->BuildPath = std::move(builds[ii]);
- if (sfh->BuildPath.empty()) {
- Log().ErrorFile(GenT::GEN, this->InfoFile(),
- "Header file build path is empty");
- return false;
- }
+
+ SourceFileHandleT sourceHandle = std::make_shared<SourceFileT>(fileName);
+ sourceHandle->FileTime = fileTime;
+ sourceHandle->IsHeader = true;
+ sourceHandle->Moc = (fileFlags[0] == 'M');
+ sourceHandle->Uic = (fileFlags[1] == 'U');
+
+ if (sourceHandle->Moc && MocConst().Enabled) {
+ sourceHandle->BuildPath = std::move(builds[ii]);
+ if (sourceHandle->BuildPath.empty()) {
+ return LogInfoError("Header file build path is empty");
}
- BaseEval().Headers.emplace(std::move(fileName), std::move(sfh));
}
+ BaseEval().Headers.emplace(std::move(fileName), std::move(sourceHandle));
}
+ }
- // Sources
- {
- cm::string_view const keyFiles = "AM_SOURCES";
- cm::string_view const keyFlags = "AM_SOURCES_FLAGS";
- std::vector<std::string> files = InfoGetList(keyFiles);
- std::vector<std::string> flags = InfoGetList(keyFlags);
- if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) {
+ // Sources
+ {
+ cm::string_view const keyFiles = "AM_SOURCES";
+ cm::string_view const keyFlags = "AM_SOURCES_FLAGS";
+ std::vector<std::string> files = InfoGetList(keyFiles);
+ std::vector<std::string> flags = InfoGetList(keyFlags);
+ if (!MatchSizes(keyFiles, keyFlags, files.size(), flags.size())) {
+ return false;
+ }
+
+ // Process file lists
+ for (std::size_t ii = 0; ii != files.size(); ++ii) {
+ std::string& fileName(files[ii]);
+ std::string const& fileFlags(flags[ii]);
+ if (fileFlags.size() != 2) {
+ LogInfoError(cmStrCat("Invalid flags string size ", fileFlags.size(),
+ "in ", keyFlags));
return false;
}
- // Process file lists
- for (std::size_t ii = 0; ii != files.size(); ++ii) {
- std::string& fileName(files[ii]);
- SourceFileHandleT sfh = makeSource(fileName, flags[ii]);
- if (!sfh) {
- return false;
- }
- BaseEval().Sources.emplace(std::move(fileName), std::move(sfh));
+ cmFileTime fileTime;
+ if (!fileTime.Load(fileName)) {
+ LogInfoError(cmStrCat("The source file ", this->MessagePath(fileName),
+ " does not exist."));
+ return false;
}
+
+ SourceFileHandleT sourceHandle = std::make_shared<SourceFileT>(fileName);
+ sourceHandle->FileTime = fileTime;
+ sourceHandle->IsHeader = false;
+ sourceHandle->Moc = (fileFlags[0] == 'M');
+ sourceHandle->Uic = (fileFlags[1] == 'U');
+ BaseEval().Sources.emplace(std::move(fileName), std::move(sourceHandle));
}
}
@@ -1775,49 +1869,20 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
// Moc predefs file
if (!MocConst_.PredefsCmd.empty()) {
+ std::string pathRel;
if (BaseConst_.MultiConfig) {
- MocConst_.PredefsFileRel =
- cmStrCat("moc_predefs_", InfoConfig(), ".h");
+ pathRel = cmStrCat("moc_predefs_", InfoConfig(), ".h");
} else {
- MocConst_.PredefsFileRel = "moc_predefs.h";
+ pathRel = "moc_predefs.h";
}
- MocConst_.PredefsFileAbs = AbsoluteBuildPath(MocConst().PredefsFileRel);
+ MocConst_.PredefsFileAbs = AbsoluteBuildPath(pathRel);
}
- // Sort include directories on demand
- if (BaseConst().IncludeProjectDirsBefore) {
- // Move strings to temporary list
- std::list<std::string> includes(MocConst().IncludePaths.begin(),
- MocConst().IncludePaths.end());
- MocConst_.IncludePaths.clear();
- MocConst_.IncludePaths.reserve(includes.size());
- // Append project directories only
- {
- std::initializer_list<cm::string_view> const movePaths = {
- BaseConst().ProjectBinaryDir, BaseConst().ProjectSourceDir
- };
- for (cm::string_view const& ppath : movePaths) {
- auto it = includes.begin();
- while (it != includes.end()) {
- std::string const& path = *it;
- if (cmHasPrefix(path, ppath)) {
- MocConst_.IncludePaths.push_back(path);
- it = includes.erase(it);
- } else {
- ++it;
- }
- }
- }
- }
- // Append remaining directories
- MocConst_.IncludePaths.insert(MocConst_.IncludePaths.end(),
- includes.begin(), includes.end());
- }
// Compose moc includes list
{
+ // Compute framework paths
std::set<std::string> frameworkPaths;
for (std::string const& path : MocConst().IncludePaths) {
- MocConst_.Includes.push_back("-I" + path);
// Extract framework path
if (cmHasLiteralSuffix(path, ".framework/Headers")) {
// Go up twice to get to the framework root
@@ -1827,26 +1892,26 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile)
pathComponents.begin(), pathComponents.end() - 2));
}
}
+ // Reserve options
+ MocConst_.OptionsIncludes.reserve(MocConst().IncludePaths.size() +
+ frameworkPaths.size() * 2);
+ // Append includes
+ for (std::string const& path : MocConst().IncludePaths) {
+ MocConst_.OptionsIncludes.emplace_back("-I" + path);
+ }
// Append framework includes
for (std::string const& path : frameworkPaths) {
- MocConst_.Includes.emplace_back("-F");
- MocConst_.Includes.push_back(path);
+ MocConst_.OptionsIncludes.emplace_back("-F");
+ MocConst_.OptionsIncludes.push_back(path);
}
}
- // Setup single list with all options
+
+ // Compose moc definitions list
{
- // Add includes
- MocConst_.AllOptions.insert(MocConst_.AllOptions.end(),
- MocConst().Includes.begin(),
- MocConst().Includes.end());
- // Add definitions
+ MocConst_.OptionsDefinitions.reserve(MocConst().Definitions.size());
for (std::string const& def : MocConst().Definitions) {
- MocConst_.AllOptions.push_back("-D" + def);
+ MocConst_.OptionsDefinitions.emplace_back("-D" + def);
}
- // Add options
- MocConst_.AllOptions.insert(MocConst_.AllOptions.end(),
- MocConst().Options.begin(),
- MocConst().Options.end());
}
}
@@ -1870,18 +1935,38 @@ void cmQtAutoMocUic::CreateParseJobs(SourceFileMapT const& sourceMap)
}
}
+/** Concurrently callable implementation of cmSystemTools::CollapseFullPath */
+std::string cmQtAutoMocUic::CollapseFullPathTS(std::string const& path) const
+{
+ std::lock_guard<std::mutex> guard(CMakeLibMutex_);
+ return cmSystemTools::CollapseFullPath(path, ProjectDirs().CurrentSource);
+}
+
void cmQtAutoMocUic::InitJobs()
{
// Add moc_predefs.h job
if (MocConst().Enabled && !MocConst().PredefsCmd.empty()) {
WorkerPool().EmplaceJob<JobMocPredefsT>();
}
+
// Add header parse jobs
CreateParseJobs<JobParseHeaderT>(BaseEval().Headers);
// Add source parse jobs
CreateParseJobs<JobParseSourceT>(BaseEval().Sources);
- // Add evaluate job
- WorkerPool().EmplaceJob<JobEvaluateT>();
+
+ // Add parse cache evaluations jobs
+ {
+ // Add a fence job to ensure all parsing has finished
+ WorkerPool().EmplaceJob<JobFenceT>();
+ if (MocConst().Enabled) {
+ WorkerPool().EmplaceJob<JobEvalCacheMocT>();
+ }
+ if (UicConst().Enabled) {
+ WorkerPool().EmplaceJob<JobEvalCacheUicT>();
+ }
+ // Add evaluate job
+ WorkerPool().EmplaceJob<JobEvalCacheFinishT>();
+ }
}
bool cmQtAutoMocUic::Process()
@@ -1920,11 +2005,18 @@ void cmQtAutoMocUic::SettingsFileRead()
if (MocConst_.Enabled) {
cryptoHash.Initialize();
cha(MocConst().Executable);
- std::for_each(MocConst().AllOptions.begin(), MocConst().AllOptions.end(),
- cha);
- cha(BaseConst().IncludeProjectDirsBefore ? "TRUE" : "FALSE");
- std::for_each(MocConst().PredefsCmd.begin(), MocConst().PredefsCmd.end(),
- cha);
+ for (auto const& item : MocConst().OptionsDefinitions) {
+ cha(item);
+ }
+ for (auto const& item : MocConst().OptionsIncludes) {
+ cha(item);
+ }
+ for (auto const& item : MocConst().OptionsExtra) {
+ cha(item);
+ }
+ for (auto const& item : MocConst().PredefsCmd) {
+ cha(item);
+ }
for (auto const& filter : MocConst().DependFilters) {
cha(filter.Key);
}
@@ -1984,7 +2076,9 @@ bool cmQtAutoMocUic::SettingsFileWrite()
// Only write if any setting changed
if (MocConst().SettingsChanged || UicConst().SettingsChanged) {
if (Log().Verbose()) {
- Log().Info(GenT::GEN, "Writing settings file " + Quoted(SettingsFile_));
+ Log().Info(
+ GenT::GEN,
+ cmStrCat("Writing settings file ", MessagePath(SettingsFile_)));
}
// Compose settings file content
std::string content;
@@ -2001,8 +2095,9 @@ bool cmQtAutoMocUic::SettingsFileWrite()
// Write settings file
std::string error;
if (!cmQtAutoGenerator::FileWrite(SettingsFile_, content, &error)) {
- Log().ErrorFile(GenT::GEN, SettingsFile_,
- "Settings file writing failed. " + error);
+ Log().Error(GenT::GEN,
+ cmStrCat("Writing the settings file ",
+ MessagePath(SettingsFile_), " failed.\n", error));
// Remove old settings file to trigger a full rebuild on the next run
cmSystemTools::RemoveFile(SettingsFile_);
return false;
@@ -2042,12 +2137,14 @@ bool cmQtAutoMocUic::ParseCacheWrite()
if (BaseEval().ParseCacheChanged) {
if (Log().Verbose()) {
Log().Info(GenT::GEN,
- "Writing parse cache file " +
- Quoted(BaseConst().ParseCacheFile));
+ cmStrCat("Writing the parse cache file ",
+ MessagePath(BaseConst().ParseCacheFile)));
}
if (!BaseEval().ParseCache.WriteToFile(BaseConst().ParseCacheFile)) {
- Log().ErrorFile(GenT::GEN, BaseConst().ParseCacheFile,
- "Parse cache file writing failed.");
+ Log().Error(GenT::GEN,
+ cmStrCat("Writing the parse cache file ",
+ MessagePath(BaseConst().ParseCacheFile),
+ " failed."));
return false;
}
}
@@ -2058,8 +2155,10 @@ bool cmQtAutoMocUic::CreateDirectories()
{
// Create AUTOGEN include directory
if (!cmSystemTools::MakeDirectory(BaseConst().AutogenIncludeDir)) {
- Log().ErrorFile(GenT::GEN, BaseConst().AutogenIncludeDir,
- "Could not create directory.");
+ Log().Error(GenT::GEN,
+ cmStrCat("Creating the AUTOGEN include directory ",
+ MessagePath(BaseConst().AutogenIncludeDir),
+ " failed."));
return false;
}
return true;
diff --git a/Source/cmQtAutoMocUic.h b/Source/cmQtAutoMocUic.h
index 549b088..43123f2 100644
--- a/Source/cmQtAutoMocUic.h
+++ b/Source/cmQtAutoMocUic.h
@@ -16,6 +16,7 @@
#include <cstddef>
#include <map>
#include <memory>
+#include <mutex>
#include <set>
#include <string>
#include <unordered_map>
@@ -40,9 +41,7 @@ public:
public:
// -- Types
- /**
- * Search key plus regular expression pair
- */
+ /** Search key plus regular expression pair. */
struct KeyExpT
{
KeyExpT() = default;
@@ -63,9 +62,7 @@ public:
cmsys::RegularExpression Exp;
};
- /**
- * Include string with sub parts
- */
+ /** Include string with sub parts. */
struct IncludeKeyT
{
IncludeKeyT(std::string const& key, std::size_t basePrefixLength);
@@ -75,9 +72,7 @@ public:
std::string Base; // Base part of the include file name
};
- /**
- * Source file parsing cache
- */
+ /** Source file parsing cache. */
class ParseCacheT
{
public:
@@ -127,9 +122,7 @@ public:
std::unordered_map<std::string, FileHandleT> Map_;
};
- /**
- * Source file data
- */
+ /** Source file data. */
class SourceFileT
{
public:
@@ -143,15 +136,14 @@ public:
cmFileTime FileTime;
ParseCacheT::FileHandleT ParseData;
std::string BuildPath;
+ bool IsHeader = false;
bool Moc = false;
bool Uic = false;
};
using SourceFileHandleT = std::shared_ptr<SourceFileT>;
using SourceFileMapT = std::map<std::string, SourceFileHandleT>;
- /**
- * Meta compiler file mapping information
- */
+ /** Meta compiler file mapping information. */
struct MappingT
{
SourceFileHandleT SourceFile;
@@ -162,9 +154,7 @@ public:
using MappingHandleT = std::shared_ptr<MappingT>;
using MappingMapT = std::map<std::string, MappingHandleT>;
- /**
- * Common settings
- */
+ /** Common settings. */
class BaseSettingsT
{
public:
@@ -178,13 +168,8 @@ public:
// -- Attributes
// - Config
bool MultiConfig = false;
- bool IncludeProjectDirsBefore = false;
unsigned int QtVersionMajor = 4;
// - Directories
- std::string ProjectSourceDir;
- std::string ProjectBinaryDir;
- std::string CurrentSourceDir;
- std::string CurrentBinaryDir;
std::string AutogenBuildDir;
std::string AutogenIncludeDir;
// - Files
@@ -194,9 +179,7 @@ public:
std::vector<std::string> HeaderExtensions;
};
- /**
- * Shared common variables
- */
+ /** Shared common variables. */
class BaseEvalT
{
public:
@@ -210,9 +193,7 @@ public:
SourceFileMapT Sources;
};
- /**
- * Moc settings
- */
+ /** Moc settings. */
class MocSettingsT
{
public:
@@ -231,26 +212,24 @@ public:
bool Enabled = false;
bool SettingsChanged = false;
bool RelaxedMode = false;
+ bool PathPrefix = false;
cmFileTime ExecutableTime;
std::string Executable;
std::string CompFileAbs;
- std::string PredefsFileRel;
std::string PredefsFileAbs;
std::unordered_set<std::string> SkipList;
std::vector<std::string> IncludePaths;
- std::vector<std::string> Includes;
std::vector<std::string> Definitions;
- std::vector<std::string> Options;
- std::vector<std::string> AllOptions;
+ std::vector<std::string> OptionsIncludes;
+ std::vector<std::string> OptionsDefinitions;
+ std::vector<std::string> OptionsExtra;
std::vector<std::string> PredefsCmd;
std::vector<KeyExpT> DependFilters;
std::vector<KeyExpT> MacroFilters;
cmsys::RegularExpression RegExpInclude;
};
- /**
- * Moc shared variables
- */
+ /** Moc shared variables. */
class MocEvalT
{
public:
@@ -262,14 +241,14 @@ public:
MappingMapT Includes;
// -- Discovered files
SourceFileMapT HeadersDiscovered;
+ // -- Output directories
+ std::unordered_set<std::string> OutputDirs;
// -- Mocs compilation
bool CompUpdated = false;
std::vector<std::string> CompFiles;
};
- /**
- * Uic settings
- */
+ /** Uic settings. */
class UicSettingsT
{
public:
@@ -294,25 +273,23 @@ public:
cmsys::RegularExpression RegExpInclude;
};
- /**
- * Uic shared variables
- */
+ /** Uic shared variables. */
class UicEvalT
{
public:
+ // -- Discovered files
SourceFileMapT UiFiles;
+ // -- Mappings
MappingMapT Includes;
+ // -- Output directories
+ std::unordered_set<std::string> OutputDirs;
};
- /**
- * Abstract job class for concurrent job processing
- */
+ /** Abstract job class for concurrent job processing. */
class JobT : public cmWorkerPool::JobT
{
protected:
- /**
- * @brief Protected default constructor
- */
+ /** Protected default constructor. */
JobT(bool fence = false)
: cmWorkerPool::JobT(fence)
{
@@ -333,25 +310,24 @@ public:
UicSettingsT const& UicConst() const { return Gen()->UicConst(); }
UicEvalT& UicEval() const { return Gen()->UicEval(); }
- // -- Error logging with automatic abort
+ // -- Logging
+ std::string MessagePath(cm::string_view path) const
+ {
+ return Gen()->MessagePath(path);
+ }
+ // - Error logging with automatic abort
void LogError(GenT genType, cm::string_view message) const;
- void LogFileError(GenT genType, cm::string_view filename,
- cm::string_view message) const;
void LogCommandError(GenT genType, cm::string_view message,
std::vector<std::string> const& command,
std::string const& output) const;
- /**
- * @brief Run an external process. Use only during Process() call!
- */
+ /** @brief Run an external process. Use only during Process() call! */
bool RunProcess(GenT genType, cmWorkerPool::ProcessResultT& result,
std::vector<std::string> const& command,
std::string* infoMessage = nullptr);
};
- /**
- * Fence job utility class
- */
+ /** Fence job utility class. */
class JobFenceT : public JobT
{
public:
@@ -362,18 +338,14 @@ public:
void Process() override{};
};
- /**
- * Generate moc_predefs.h
- */
+ /** Generate moc_predefs.h. */
class JobMocPredefsT : public JobFenceT
{
void Process() override;
bool Update(std::string* reason) const;
};
- /**
- * File parse job base class
- */
+ /** File parse job base class. */
class JobParseT : public JobT
{
public:
@@ -397,9 +369,7 @@ public:
std::string Content;
};
- /**
- * Header file parse job
- */
+ /** Header file parse job. */
class JobParseHeaderT : public JobParseT
{
public:
@@ -407,9 +377,7 @@ public:
void Process() override;
};
- /**
- * Source file parse job
- */
+ /** Source file parse job. */
class JobParseSourceT : public JobParseT
{
public:
@@ -417,57 +385,79 @@ public:
void Process() override;
};
- /**
- * Evaluate parsed files
- */
- class JobEvaluateT : public JobFenceT
+ /** Evaluate cached file parse data - moc. */
+ class JobEvalCacheT : public JobT
+ {
+ protected:
+ std::string MessageSearchLocations() const;
+ std::vector<std::string> SearchLocations;
+ };
+
+ /** Evaluate cached file parse data - moc. */
+ class JobEvalCacheMocT : public JobEvalCacheT
+ {
+ void Process() override;
+ bool EvalHeader(SourceFileHandleT source);
+ bool EvalSource(SourceFileHandleT const& source);
+ bool FindIncludedHeader(SourceFileHandleT& headerHandle,
+ cm::string_view includerDir,
+ cm::string_view includeBase);
+ bool RegisterIncluded(std::string const& includeString,
+ SourceFileHandleT includerFileHandle,
+ SourceFileHandleT sourceFileHandle) const;
+ void RegisterMapping(MappingHandleT mappingHandle) const;
+ std::string MessageHeader(cm::string_view headerBase) const;
+ };
+
+ /** Evaluate cached file parse data - uic. */
+ class JobEvalCacheUicT : public JobEvalCacheT
+ {
+ void Process() override;
+ bool EvalFile(SourceFileHandleT const& sourceFileHandle);
+ bool FindIncludedUi(cm::string_view sourceDirPrefix,
+ cm::string_view includePrefix);
+ bool RegisterMapping(std::string const& includeString,
+ SourceFileHandleT includerFileHandle);
+
+ std::string UiName;
+ SourceFileHandleT UiFileHandle;
+ };
+
+ /** Evaluate cached file parse data - finish */
+ class JobEvalCacheFinishT : public JobFenceT
{
void Process() override;
+ };
- // -- Moc
- bool MocEvalHeader(SourceFileHandleT source);
- bool MocEvalSource(SourceFileHandleT const& source);
- SourceFileHandleT MocFindIncludedHeader(
- std::string const& includerDir, std::string const& includeBase) const;
- SourceFileHandleT MocFindHeader(std::string const& basePath) const;
- std::string MocMessageTestHeaders(cm::string_view fileBase) const;
- bool MocRegisterIncluded(std::string const& includeString,
- SourceFileHandleT includerFileHandle,
- SourceFileHandleT sourceFileHandle,
- bool sourceIsHeader) const;
- void MocRegisterMapping(MappingHandleT mappingHandle,
- bool sourceIsHeader) const;
-
- // -- Uic
- bool UicEval(SourceFileMapT const& fileMap);
- bool UicEvalFile(SourceFileHandleT const& sourceFileHandle);
- SourceFileHandleT UicFindIncludedUi(std::string const& sourceFile,
- std::string const& sourceDir,
- IncludeKeyT const& incKey) const;
- bool UicRegisterMapping(std::string const& includeString,
- SourceFileHandleT uiFileHandle,
- SourceFileHandleT includerFileHandle);
+ /** Dependency probing base job. */
+ class JobProbeDepsT : public JobT
+ {
};
- /**
- * Generates moc/uic jobs
- */
- class JobGenerateT : public JobFenceT
+ /** Probes file dependencies and generates moc compile jobs. */
+ class JobProbeDepsMocT : public JobProbeDepsT
{
void Process() override;
- // -- Moc
- bool MocGenerate(MappingHandleT const& mapping, bool compFile) const;
- bool MocUpdate(MappingT const& mapping, std::string* reason) const;
- std::pair<std::string, cmFileTime> MocFindDependency(
+ bool Generate(MappingHandleT const& mapping, bool compFile) const;
+ bool Probe(MappingT const& mapping, std::string* reason) const;
+ std::pair<std::string, cmFileTime> FindDependency(
std::string const& sourceDir, std::string const& includeString) const;
- // -- Uic
- bool UicGenerate(MappingHandleT const& mapping) const;
- bool UicUpdate(MappingT const& mapping, std::string* reason) const;
};
- /**
- * File compiling base job
- */
+ /** Probes file dependencies and generates uic compile jobs. */
+ class JobProbeDepsUicT : public JobProbeDepsT
+ {
+ void Process() override;
+ bool Probe(MappingT const& mapping, std::string* reason) const;
+ };
+
+ /** Dependency probing finish job. */
+ class JobProbeDepsFinishT : public JobFenceT
+ {
+ void Process() override;
+ };
+
+ /** Meta compiler base job. */
class JobCompileT : public JobT
{
public:
@@ -482,36 +472,30 @@ public:
std::unique_ptr<std::string> Reason;
};
- /**
- * moc compiles a file
- */
- class JobMocT : public JobCompileT
+ /** moc compiles a file. */
+ class JobCompileMocT : public JobCompileT
{
public:
using JobCompileT::JobCompileT;
void Process() override;
};
- /**
- * uic compiles a file
- */
- class JobUicT : public JobCompileT
+ /** uic compiles a file. */
+ class JobCompileUicT : public JobCompileT
{
public:
using JobCompileT::JobCompileT;
void Process() override;
};
- /// @brief Generate mocs_compilation.cpp
- ///
+ /** Generate mocs_compilation.cpp. */
class JobMocsCompilationT : public JobFenceT
{
private:
void Process() override;
};
- /// @brief The last job
- ///
+ /** @brief The last job. */
class JobFinishT : public JobFenceT
{
private:
@@ -536,6 +520,7 @@ public:
std::string AbsoluteIncludePath(cm::string_view relativePath) const;
template <class JOBTYPE>
void CreateParseJobs(SourceFileMapT const& sourceMap);
+ std::string CollapseFullPathTS(std::string const& path) const;
private:
// -- Utility accessors
@@ -572,6 +557,8 @@ private:
// -- Worker thread pool
std::atomic<bool> JobError_ = ATOMIC_VAR_INIT(false);
cmWorkerPool WorkerPool_;
+ // -- Concurrent processing
+ mutable std::mutex CMakeLibMutex_;
};
#endif
diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx
index e931346..cd3e034 100644
--- a/Source/cmQtAutoRcc.cxx
+++ b/Source/cmQtAutoRcc.cxx
@@ -16,7 +16,6 @@
#include <algorithm>
cmQtAutoRcc::cmQtAutoRcc() = default;
-
cmQtAutoRcc::~cmQtAutoRcc() = default;
bool cmQtAutoRcc::Init(cmMakefile* makefile)
@@ -41,8 +40,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile)
return cmExpandedList(InfoGetConfig(key));
};
auto LogInfoError = [this](cm::string_view msg) -> bool {
- this->Log().Error(GenT::RCC,
- cmStrCat("In ", Quoted(this->InfoFile()), ":\n", msg));
+ this->Log().Error(
+ GenT::RCC, cmStrCat("In ", MessagePath(this->InfoFile()), ":\n", msg));
return false;
};
@@ -56,6 +55,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile)
MultiConfig_ = makefile->IsOn("ARCC_MULTI_CONFIG");
// - Directories
+ ProjectDirsRef().Source = InfoGet("ARCC_CMAKE_SOURCE_DIR");
+ ProjectDirsRef().Binary = InfoGet("ARCC_CMAKE_BINARY_DIR");
AutogenBuildDir_ = InfoGet("ARCC_BUILD_DIR");
if (AutogenBuildDir_.empty()) {
return LogInfoError("Build directory empty.");
@@ -69,8 +70,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile)
// - Rcc executable
RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE");
if (!RccExecutableTime_.Load(RccExecutable_)) {
- return LogInfoError(cmStrCat("The rcc executable ", Quoted(RccExecutable_),
- " does not exist."));
+ return LogInfoError(cmStrCat(
+ "The rcc executable ", MessagePath(RccExecutable_), " does not exist."));
}
RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS");
@@ -185,8 +186,9 @@ bool cmQtAutoRcc::SettingsFileRead()
if (!cmSystemTools::FileExists(SettingsFile_, true)) {
// Touch the settings file to make sure it exists
if (!cmSystemTools::Touch(SettingsFile_, true)) {
- Log().ErrorFile(GenT::RCC, SettingsFile_,
- "Settings file creation failed.");
+ Log().Error(GenT::RCC,
+ cmStrCat("Touching the settings file ",
+ MessagePath(SettingsFile_), " failed."));
return false;
}
}
@@ -196,7 +198,9 @@ bool cmQtAutoRcc::SettingsFileRead()
// Make sure the lock file exists
if (!cmSystemTools::FileExists(LockFile_, true)) {
if (!cmSystemTools::Touch(LockFile_, true)) {
- Log().ErrorFile(GenT::RCC, LockFile_, "Lock file creation failed.");
+ Log().Error(GenT::RCC,
+ cmStrCat("Touching the lock file ", MessagePath(LockFile_),
+ " failed."));
return false;
}
}
@@ -204,8 +208,9 @@ bool cmQtAutoRcc::SettingsFileRead()
cmFileLockResult lockResult =
LockFileLock_.Lock(LockFile_, static_cast<unsigned long>(-1));
if (!lockResult.IsOk()) {
- Log().ErrorFile(GenT::RCC, LockFile_,
- "File lock failed: " + lockResult.GetOutputMessage());
+ Log().Error(GenT::RCC,
+ cmStrCat("Locking of the lock file ", MessagePath(LockFile_),
+ " failed.\n", lockResult.GetOutputMessage()));
return false;
}
}
@@ -221,8 +226,10 @@ bool cmQtAutoRcc::SettingsFileRead()
if (SettingsChanged_) {
std::string error;
if (!FileWrite(SettingsFile_, "", &error)) {
- Log().ErrorFile(GenT::RCC, SettingsFile_,
- "Settings file clearing failed. " + error);
+ Log().Error(GenT::RCC,
+ cmStrCat("Clearing of the settings file ",
+ MessagePath(SettingsFile_), " failed.\n",
+ error));
return false;
}
}
@@ -239,14 +246,16 @@ bool cmQtAutoRcc::SettingsFileWrite()
// Only write if any setting changed
if (SettingsChanged_) {
if (Log().Verbose()) {
- Log().Info(GenT::RCC, "Writing settings file " + Quoted(SettingsFile_));
+ Log().Info(GenT::RCC,
+ "Writing settings file " + MessagePath(SettingsFile_));
}
// Write settings file
std::string content = cmStrCat("rcc:", SettingsString_, '\n');
std::string error;
if (!FileWrite(SettingsFile_, content, &error)) {
- Log().ErrorFile(GenT::RCC, SettingsFile_,
- "Settings file writing failed. " + error);
+ Log().Error(GenT::RCC,
+ cmStrCat("Writing of the settings file ",
+ MessagePath(SettingsFile_), " failed.\n", error));
// Remove old settings file to trigger a full rebuild on the next run
cmSystemTools::RemoveFile(SettingsFile_);
return false;
@@ -263,17 +272,18 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
{
// Test if the rcc input file exists
if (!QrcFileTime_.Load(QrcFile_)) {
- Log().ErrorFile(
- GenT::RCC, QrcFile_,
- cmStrCat("The resources file ", Quoted(QrcFile_), " does not exist"));
+ Log().Error(GenT::RCC,
+ cmStrCat("The resources file ", MessagePath(QrcFile_),
+ " does not exist"));
return false;
}
// Test if the rcc output file exists
if (!RccFileTime_.Load(RccFileOutput_)) {
if (Log().Verbose()) {
- Reason = cmStrCat("Generating ", Quoted(RccFileOutput_),
- ", because it doesn't exist, from ", Quoted(QrcFile_));
+ Reason =
+ cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it doesn't exist, from ", MessagePath(QrcFile_));
}
generate = true;
return true;
@@ -282,9 +292,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
// Test if the settings changed
if (SettingsChanged_) {
if (Log().Verbose()) {
- Reason = cmStrCat("Generating ", Quoted(RccFileOutput_),
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
", because the rcc settings changed, from ",
- Quoted(QrcFile_));
+ MessagePath(QrcFile_));
}
generate = true;
return true;
@@ -293,9 +303,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
// Test if the rcc output file is older than the .qrc file
if (RccFileTime_.Older(QrcFileTime_)) {
if (Log().Verbose()) {
- Reason = cmStrCat("Generating ", Quoted(RccFileOutput_),
- ", because it is older than ", Quoted(QrcFile_),
- ", from ", Quoted(QrcFile_));
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it is older than ", MessagePath(QrcFile_),
+ ", from ", MessagePath(QrcFile_));
}
generate = true;
return true;
@@ -304,9 +314,9 @@ bool cmQtAutoRcc::TestQrcRccFiles(bool& generate)
// Test if the rcc output file is older than the rcc executable
if (RccFileTime_.Older(RccExecutableTime_)) {
if (Log().Verbose()) {
- Reason = cmStrCat("Generating ", Quoted(RccFileOutput_),
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
", because it is older than the rcc executable, from ",
- Quoted(QrcFile_));
+ MessagePath(QrcFile_));
}
generate = true;
return true;
@@ -322,7 +332,9 @@ bool cmQtAutoRcc::TestResources(bool& generate)
std::string error;
RccLister const lister(RccExecutable_, RccListOptions_);
if (!lister.list(QrcFile_, Inputs_, error, Log().Verbose())) {
- Log().ErrorFile(GenT::RCC, QrcFile_, error);
+ Log().Error(
+ GenT::RCC,
+ cmStrCat("Listing of ", MessagePath(QrcFile_), " failed.\n", error));
return false;
}
}
@@ -332,17 +344,18 @@ bool cmQtAutoRcc::TestResources(bool& generate)
// Check if the resource file exists
cmFileTime fileTime;
if (!fileTime.Load(resFile)) {
- Log().ErrorFile(GenT::RCC, QrcFile_,
- cmStrCat("Could not find the resource file\n ",
- Quoted(resFile), '\n'));
+ Log().Error(GenT::RCC,
+ cmStrCat("The resource file ", MessagePath(resFile),
+ " listed in ", MessagePath(QrcFile_),
+ " does not exist."));
return false;
}
// Check if the resource file is newer than the rcc output file
if (RccFileTime_.Older(fileTime)) {
if (Log().Verbose()) {
- Reason = cmStrCat("Generating ", Quoted(RccFileOutput_),
- ", because it is older than ", Quoted(resFile),
- ", from ", Quoted(QrcFile_));
+ Reason = cmStrCat("Generating ", MessagePath(RccFileOutput_),
+ ", because it is older than ", MessagePath(resFile),
+ ", from ", MessagePath(QrcFile_));
}
generate = true;
break;
@@ -357,12 +370,15 @@ bool cmQtAutoRcc::TestInfoFile()
if (RccFileTime_.Older(InfoFileTime())) {
if (Log().Verbose()) {
Log().Info(GenT::RCC,
- cmStrCat("Touching ", Quoted(RccFileOutput_),
- " because it is older than ", Quoted(InfoFile())));
+ cmStrCat("Touching ", MessagePath(RccFileOutput_),
+ " because it is older than ",
+ MessagePath(InfoFile())));
}
// Touch build file
if (!cmSystemTools::Touch(RccFileOutput_, false)) {
- Log().ErrorFile(GenT::RCC, RccFileOutput_, "Build file touch failed");
+ Log().Error(
+ GenT::RCC,
+ cmStrCat("Touching ", MessagePath(RccFileOutput_), " failed."));
return false;
}
BuildFileChanged_ = true;
@@ -375,8 +391,9 @@ bool cmQtAutoRcc::GenerateRcc()
{
// Make parent directory
if (!MakeParentDirectory(RccFileOutput_)) {
- Log().ErrorFile(GenT::RCC, RccFileOutput_,
- "Could not create parent directory");
+ Log().Error(GenT::RCC,
+ cmStrCat("Could not create parent directory of ",
+ MessagePath(RccFileOutput_)));
return false;
}
@@ -405,8 +422,8 @@ bool cmQtAutoRcc::GenerateRcc()
// rcc process failed
Log().ErrorCommand(GenT::RCC,
cmStrCat("The rcc process failed to compile\n ",
- Quoted(QrcFile_), "\ninto\n ",
- Quoted(RccFileOutput_)),
+ MessagePath(QrcFile_), "\ninto\n ",
+ MessagePath(RccFileOutput_)),
cmd, rccStdOut + rccStdErr);
cmSystemTools::RemoveFile(RccFileOutput_);
return false;
@@ -443,22 +460,29 @@ bool cmQtAutoRcc::GenerateWrapper()
if (fileDiffers) {
// Write new wrapper file
if (Log().Verbose()) {
- Log().Info(GenT::RCC, "Generating RCC wrapper file " + RccFilePublic_);
+ Log().Info(GenT::RCC,
+ cmStrCat("Generating RCC wrapper file ",
+ MessagePath(RccFilePublic_)));
}
std::string error;
if (!FileWrite(RccFilePublic_, content, &error)) {
- Log().ErrorFile(GenT::RCC, RccFilePublic_,
- "RCC wrapper file writing failed. " + error);
+ Log().Error(GenT::RCC,
+ cmStrCat("Generating RCC wrapper file ",
+ MessagePath(RccFilePublic_), " failed.\n",
+ error));
return false;
}
} else if (BuildFileChanged_) {
// Just touch the wrapper file
if (Log().Verbose()) {
- Log().Info(GenT::RCC, "Touching RCC wrapper file " + RccFilePublic_);
+ Log().Info(
+ GenT::RCC,
+ cmStrCat("Touching RCC wrapper file ", MessagePath(RccFilePublic_)));
}
if (!cmSystemTools::Touch(RccFilePublic_, false)) {
- Log().ErrorFile(GenT::RCC, RccFilePublic_,
- "RCC wrapper file touch failed.");
+ Log().Error(GenT::RCC,
+ cmStrCat("Touching RCC wrapper file ",
+ MessagePath(RccFilePublic_), " failed."));
return false;
}
}
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 27f45a8..52bde7c 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -3,10 +3,10 @@
#include "cmSeparateArgumentsCommand.h"
#include <algorithm>
-#include <sstream>
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
// cmSeparateArgumentsCommand
@@ -56,9 +56,7 @@ bool cmSeparateArgumentsCommand(std::vector<std::string> const& args,
command = arg;
doing = DoingNone;
} else {
- std::ostringstream e;
- e << "given unknown argument " << arg;
- status.SetError(e.str());
+ status.SetError(cmStrCat("given unknown argument ", arg));
return false;
}
}
diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx
index 387c3fc..112d832 100644
--- a/Source/cmSetPropertyCommand.cxx
+++ b/Source/cmSetPropertyCommand.cxx
@@ -100,11 +100,10 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args,
} else if (scopeName == "INSTALL") {
scope = cmProperty::INSTALL;
} else {
- std::ostringstream e;
- e << "given invalid scope " << scopeName << ". "
- << "Valid scopes are GLOBAL, DIRECTORY, "
- "TARGET, SOURCE, TEST, CACHE, INSTALL.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given invalid scope ", scopeName,
+ ". "
+ "Valid scopes are GLOBAL, DIRECTORY, "
+ "TARGET, SOURCE, TEST, CACHE, INSTALL."));
return false;
}
@@ -149,9 +148,7 @@ bool cmSetPropertyCommand(std::vector<std::string> const& args,
propertyValue += arg;
remove = false;
} else {
- std::ostringstream e;
- e << "given invalid argument \"" << arg << "\".";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given invalid argument \"", arg, "\"."));
return false;
}
}
@@ -293,10 +290,8 @@ bool HandleTargetMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "could not find TARGET " << name
- << ". Perhaps it has not yet been created.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("could not find TARGET ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
}
@@ -340,9 +335,8 @@ bool HandleSourceMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "given SOURCE name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "given SOURCE name that could not be found or created: ", name));
return false;
}
}
@@ -428,26 +422,23 @@ bool HandleCacheMode(cmExecutionStatus& status,
{
if (propertyName == "ADVANCED") {
if (!remove && !cmIsOn(propertyValue) && !cmIsOff(propertyValue)) {
- std::ostringstream e;
- e << "given non-boolean value \"" << propertyValue
- << R"(" for CACHE property "ADVANCED". )";
- status.SetError(e.str());
+ status.SetError(cmStrCat("given non-boolean value \"", propertyValue,
+ R"(" for CACHE property "ADVANCED". )"));
return false;
}
} else if (propertyName == "TYPE") {
if (!cmState::IsCacheEntryType(propertyValue)) {
- std::ostringstream e;
- e << "given invalid CACHE entry TYPE \"" << propertyValue << "\"";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given invalid CACHE entry TYPE \"", propertyValue, "\""));
return false;
}
} else if (propertyName != "HELPSTRING" && propertyName != "STRINGS" &&
propertyName != "VALUE") {
- std::ostringstream e;
- e << "given invalid CACHE property " << propertyName << ". "
- << "Settable CACHE properties are: "
- << "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE.";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat("given invalid CACHE property ", propertyName,
+ ". "
+ "Settable CACHE properties are: "
+ "ADVANCED, HELPSTRING, STRINGS, TYPE, and VALUE."));
return false;
}
@@ -462,10 +453,8 @@ bool HandleCacheMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "could not find CACHE variable " << name
- << ". Perhaps it has not yet been created.";
- status.SetError(e.str());
+ status.SetError(cmStrCat("could not find CACHE variable ", name,
+ ". Perhaps it has not yet been created."));
return false;
}
}
@@ -511,9 +500,8 @@ bool HandleInstallMode(cmExecutionStatus& status,
return false;
}
} else {
- std::ostringstream e;
- e << "given INSTALL name that could not be found or created: " << name;
- status.SetError(e.str());
+ status.SetError(cmStrCat(
+ "given INSTALL name that could not be found or created: ", name));
return false;
}
}
diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx
index ab670ca..809d05e 100644
--- a/Source/cmStringCommand.cxx
+++ b/Source/cmStringCommand.cxx
@@ -11,7 +11,6 @@
#include <cstdlib>
#include <iterator>
#include <memory>
-#include <sstream>
#include "cm_static_string_view.hxx"
@@ -46,9 +45,8 @@ bool HandleHashCommand(std::vector<std::string> const& args,
{
#if !defined(CMAKE_BOOTSTRAP)
if (args.size() != 3) {
- std::ostringstream e;
- e << args[0] << " requires an output variable and an input string";
- status.SetError(e.str());
+ status.SetError(
+ cmStrCat(args[0], " requires an output variable and an input string"));
return false;
}
@@ -60,9 +58,7 @@ bool HandleHashCommand(std::vector<std::string> const& args,
}
return false;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- status.SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
@@ -148,9 +144,7 @@ bool HandleConfigureCommand(std::vector<std::string> const& args,
} else if (args[i] == "ESCAPE_QUOTES") {
escapeQuotes = true;
} else {
- std::ostringstream err;
- err << "Unrecognized argument \"" << args[i] << "\"";
- status.SetError(err.str());
+ status.SetError(cmStrCat("Unrecognized argument \"", args[i], "\""));
return false;
}
}
@@ -377,9 +371,7 @@ bool HandleFindCommand(std::vector<std::string> const& args,
pos = sstring.rfind(schar);
}
if (std::string::npos != pos) {
- std::ostringstream s;
- s << pos;
- status.GetMakefile().AddDefinition(outvar, s.str());
+ status.GetMakefile().AddDefinition(outvar, std::to_string(pos));
return true;
}
@@ -474,16 +466,12 @@ bool HandleSubstringCommand(std::vector<std::string> const& args,
size_t stringLength = stringValue.size();
int intStringLength = static_cast<int>(stringLength);
if (begin < 0 || begin > intStringLength) {
- std::ostringstream ostr;
- ostr << "begin index: " << begin << " is out of range 0 - "
- << stringLength;
- status.SetError(ostr.str());
+ status.SetError(
+ cmStrCat("begin index: ", begin, " is out of range 0 - ", stringLength));
return false;
}
if (end < -1) {
- std::ostringstream ostr;
- ostr << "end index: " << end << " should be -1 or greater";
- status.SetError(ostr.str());
+ status.SetError(cmStrCat("end index: ", end, " should be -1 or greater"));
return false;
}
@@ -915,9 +903,7 @@ bool HandleUuidCommand(std::vector<std::string> const& args,
status.GetMakefile().AddDefinition(outputVariable, uuid);
return true;
#else
- std::ostringstream e;
- e << args[0] << " not available during bootstrap";
- status.SetError(e.str().c_str());
+ status.SetError(cmStrCat(args[0], " not available during bootstrap"));
return false;
#endif
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 83d69a4..c56aa9d 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -312,6 +312,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp("AUTOMOC_MACRO_NAMES");
initProp("AUTOMOC_MOC_OPTIONS");
initProp("AUTOUIC_OPTIONS");
+ initProp("AUTOMOC_PATH_PREFIX");
initProp("AUTOUIC_SEARCH_PATHS");
initProp("AUTORCC_OPTIONS");
initProp("LINK_DEPENDS_NO_SHARED");
@@ -1081,6 +1082,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);
@@ -1227,6 +1229,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);
}
@@ -1304,6 +1341,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/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index b64646a..94e249f 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileDefinitionsCommand.h"
-#include <sstream>
-
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
@@ -20,11 +18,10 @@ bool cmTargetCompileDefinitionsCommand::InitialPass(
void cmTargetCompileDefinitionsCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify compile definitions for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile definitions for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetCompileDefinitionsCommand::Join(
diff --git a/Source/cmTargetCompileFeaturesCommand.cxx b/Source/cmTargetCompileFeaturesCommand.cxx
index 976c8cb..a22b94b 100644
--- a/Source/cmTargetCompileFeaturesCommand.cxx
+++ b/Source/cmTargetCompileFeaturesCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileFeaturesCommand.h"
-#include <sstream>
-
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
@@ -20,11 +18,10 @@ bool cmTargetCompileFeaturesCommand::InitialPass(
void cmTargetCompileFeaturesCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify compile features for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile features for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetCompileFeaturesCommand::Join(
diff --git a/Source/cmTargetCompileOptionsCommand.cxx b/Source/cmTargetCompileOptionsCommand.cxx
index 7dadb82..ccc215a 100644
--- a/Source/cmTargetCompileOptionsCommand.cxx
+++ b/Source/cmTargetCompileOptionsCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetCompileOptionsCommand.h"
-#include <sstream>
-
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -21,10 +19,10 @@ bool cmTargetCompileOptionsCommand::InitialPass(
void cmTargetCompileOptionsCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify compile options for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify compile options for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetCompileOptionsCommand::Join(
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index d099349..7801ee8 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -3,7 +3,6 @@
#include "cmTargetIncludeDirectoriesCommand.h"
#include <set>
-#include <sstream>
#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
@@ -25,10 +24,10 @@ bool cmTargetIncludeDirectoriesCommand::InitialPass(
void cmTargetIncludeDirectoriesCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify include directories for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify include directories for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetIncludeDirectoriesCommand::Join(
diff --git a/Source/cmTargetLinkDirectoriesCommand.cxx b/Source/cmTargetLinkDirectoriesCommand.cxx
index 435c392..c2ef6c1 100644
--- a/Source/cmTargetLinkDirectoriesCommand.cxx
+++ b/Source/cmTargetLinkDirectoriesCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkDirectoriesCommand.h"
-#include <sstream>
-
#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
@@ -23,10 +21,10 @@ bool cmTargetLinkDirectoriesCommand::InitialPass(
void cmTargetLinkDirectoriesCommand::HandleMissingTarget(
const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify link directories for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify link directories for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetLinkDirectoriesCommand::Join(
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 237d90c..b432599 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -256,10 +256,11 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
// Make sure the last argument was not a library type specifier.
if (haveLLT) {
- std::ostringstream e;
- e << "The \"" << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt]
- << "\" argument must be followed by a library.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("The \"",
+ cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[llt],
+ "\" argument must be followed by a library."));
cmSystemTools::SetFatalErrorOccured();
}
@@ -284,14 +285,14 @@ bool cmTargetLinkLibrariesCommand::InitialPass(
void cmTargetLinkLibrariesCommand::LinkLibraryTypeSpecifierWarning(int left,
int right)
{
- std::ostringstream w;
- w << "Link library type specifier \""
- << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left]
- << "\" is followed by specifier \""
- << cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right]
- << "\" instead of a library name. "
- << "The first specifier will be ignored.";
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ "Link library type specifier \"",
+ cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[left],
+ "\" is followed by specifier \"",
+ cmTargetLinkLibrariesCommand::LinkLibraryTypeNames[right],
+ "\" instead of a library name. The first specifier will be ignored."));
}
bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
@@ -404,12 +405,13 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
this->CurrentProcessingState != ProcessingPlainLinkInterface) {
if (rejectRemoteLinking) {
- std::ostringstream e;
- e << "Attempt to add link library \"" << lib << "\" to target \""
- << this->Target->GetName()
- << "\" which is not built in this directory.\n"
- << "This is allowed only when policy CMP0079 is set to NEW.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Attempt to add link library \"", lib, "\" to target \"",
+ this->Target->GetName(),
+ "\" which is not built in this "
+ "directory.\nThis is allowed only when policy CMP0079 "
+ "is set to NEW."));
return false;
}
@@ -421,29 +423,31 @@ bool cmTargetLinkLibrariesCommand::HandleLibrary(const std::string& lib,
(tgt->GetType() != cmStateEnums::OBJECT_LIBRARY) &&
(tgt->GetType() != cmStateEnums::INTERFACE_LIBRARY) &&
!tgt->IsExecutableWithExports()) {
- std::ostringstream e;
- e << "Target \"" << lib << "\" of type "
- << cmState::GetTargetTypeName(tgt->GetType())
- << " may not be linked into another target. One may link only to "
- "INTERFACE, OBJECT, STATIC or SHARED libraries, or to executables "
- "with the ENABLE_EXPORTS property set.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Target \"", lib, "\" of type ",
+ cmState::GetTargetTypeName(tgt->GetType()),
+ " may not be linked into another target. One may link only to "
+ "INTERFACE, OBJECT, STATIC or SHARED libraries, or to ",
+ "executables with the ENABLE_EXPORTS property set."));
}
this->Target->AddLinkLibrary(*this->Makefile, lib, libRef, llt);
}
if (warnRemoteInterface) {
- std::ostringstream w;
- /* clang-format off */
- w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0079) << "\n"
- "Target\n " << this->Target->GetName() << "\nis not created in this "
- "directory. For compatibility with older versions of CMake, link "
- "library\n " << lib << "\nwill be looked up in the directory in "
- "which the target was created rather than in this calling "
- "directory.";
- /* clang-format on */
- this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0079), "\nTarget\n ",
+ this->Target->GetName(),
+ "\nis not created in this "
+ "directory. For compatibility with older versions of CMake, link "
+ "library\n ",
+ lib,
+ "\nwill be looked up in the directory in which "
+ "the target was created rather than in this calling directory."));
}
// Handle (additional) case where the command was called with PRIVATE /
diff --git a/Source/cmTargetLinkOptionsCommand.cxx b/Source/cmTargetLinkOptionsCommand.cxx
index 2866cf1..dbd7bfe 100644
--- a/Source/cmTargetLinkOptionsCommand.cxx
+++ b/Source/cmTargetLinkOptionsCommand.cxx
@@ -2,8 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkOptionsCommand.h"
-#include <sstream>
-
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -20,10 +18,10 @@ bool cmTargetLinkOptionsCommand::InitialPass(
void cmTargetLinkOptionsCommand::HandleMissingTarget(const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify link options for target \"" << name
- << "\" which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify link options for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetLinkOptionsCommand::Join(
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/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index 2251a65..7c9d03c 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -30,11 +30,10 @@ void cmTargetSourcesCommand::HandleInterfaceContent(
void cmTargetSourcesCommand::HandleMissingTarget(const std::string& name)
{
- std::ostringstream e;
- e << "Cannot specify sources for target \"" << name
- << "\" "
- "which is not built by this project.";
- this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Cannot specify sources for target \"", name,
+ "\" which is not built by this project."));
}
std::string cmTargetSourcesCommand::Join(
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index f9f7d66..f2c8f3c 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -3,13 +3,13 @@
#include "cmVariableWatchCommand.h"
#include <memory>
-#include <sstream>
#include <utility>
#include "cmExecutionStatus.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmVariableWatch.h"
#include "cmake.h"
@@ -58,22 +58,20 @@ static void cmVariableWatchCommandVariableAccessed(const std::string& variable,
newLFF.Line = 9999;
cmExecutionStatus status(*makefile);
if (!makefile->ExecuteCommand(newLFF, status)) {
- std::ostringstream error;
- error << "Error in cmake code at\nUnknown:0:\n"
- << "A command failed during the invocation of callback \""
- << data->Command << "\".";
- cmSystemTools::Error(error.str());
+ cmSystemTools::Error(
+ cmStrCat("Error in cmake code at\nUnknown:0:\nA command failed "
+ "during the invocation of callback \"",
+ data->Command, "\"."));
data->InCallback = false;
return;
}
processed = true;
}
if (!processed) {
- std::ostringstream msg;
- msg << "Variable \"" << variable << "\" was accessed using "
- << accessString << " with value \"" << (newValue ? newValue : "")
- << "\".";
- makefile->IssueMessage(MessageType::LOG, msg.str());
+ makefile->IssueMessage(
+ MessageType::LOG,
+ cmStrCat("Variable \"", variable, "\" was accessed using ", accessString,
+ " with value \"", (newValue ? newValue : ""), "\"."));
}
data->InCallback = false;
@@ -134,9 +132,7 @@ bool cmVariableWatchCommand(std::vector<std::string> const& args,
command = args[1];
}
if (variable == "CMAKE_CURRENT_LIST_FILE") {
- std::ostringstream ostr;
- ostr << "cannot be set on the variable: " << variable;
- status.SetError(ostr.str());
+ status.SetError(cmStrCat("cannot be set on the variable: ", variable));
return false;
}
diff --git a/Source/kwsys/CommandLineArguments.cxx b/Source/kwsys/CommandLineArguments.cxx
index dc9f01d..3fd1955 100644
--- a/Source/kwsys/CommandLineArguments.cxx
+++ b/Source/kwsys/CommandLineArguments.cxx
@@ -67,8 +67,8 @@ class CommandLineArgumentsInternal
{
public:
CommandLineArgumentsInternal()
- : UnknownArgumentCallback{ KWSYS_NULLPTR }
- , ClientData{ KWSYS_NULLPTR }
+ : UnknownArgumentCallback{ nullptr }
+ , ClientData{ nullptr }
, LastArgument{ 0 }
{
}
@@ -187,7 +187,7 @@ int CommandLineArguments::Parse()
switch (cs->ArgumentType) {
case NO_ARGUMENT:
// No value
- if (!this->PopulateVariable(cs, KWSYS_NULLPTR)) {
+ if (!this->PopulateVariable(cs, nullptr)) {
return 0;
}
break;
@@ -340,7 +340,7 @@ void CommandLineArguments::AddCallback(const char* argument,
s.Callback = callback;
s.CallData = call_data;
s.VariableType = CommandLineArguments::NO_VARIABLE_TYPE;
- s.Variable = KWSYS_NULLPTR;
+ s.Variable = nullptr;
s.Help = help;
this->Internals->Callbacks[argument] = s;
@@ -355,8 +355,8 @@ void CommandLineArguments::AddArgument(const char* argument,
CommandLineArgumentsCallbackStructure s;
s.Argument = argument;
s.ArgumentType = type;
- s.Callback = KWSYS_NULLPTR;
- s.CallData = KWSYS_NULLPTR;
+ s.Callback = nullptr;
+ s.CallData = nullptr;
s.VariableType = vtype;
s.Variable = variable;
s.Help = help;
@@ -427,7 +427,7 @@ const char* CommandLineArguments::GetHelp(const char* arg)
CommandLineArguments::Internal::CallbacksMap::iterator it =
this->Internals->Callbacks.find(arg);
if (it == this->Internals->Callbacks.end()) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
// Since several arguments may point to the same argument, find the one this
@@ -621,7 +621,7 @@ void CommandLineArguments::PopulateVariable(bool* variable,
void CommandLineArguments::PopulateVariable(int* variable,
const std::string& value)
{
- char* res = KWSYS_NULLPTR;
+ char* res = nullptr;
*variable = static_cast<int>(strtol(value.c_str(), &res, 10));
// if ( res && *res )
// {
@@ -632,7 +632,7 @@ void CommandLineArguments::PopulateVariable(int* variable,
void CommandLineArguments::PopulateVariable(double* variable,
const std::string& value)
{
- char* res = KWSYS_NULLPTR;
+ char* res = nullptr;
*variable = strtod(value.c_str(), &res);
// if ( res && *res )
// {
@@ -669,7 +669,7 @@ void CommandLineArguments::PopulateVariable(std::vector<bool>* variable,
void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
const std::string& value)
{
- char* res = KWSYS_NULLPTR;
+ char* res = nullptr;
variable->push_back(static_cast<int>(strtol(value.c_str(), &res, 10)));
// if ( res && *res )
// {
@@ -680,7 +680,7 @@ void CommandLineArguments::PopulateVariable(std::vector<int>* variable,
void CommandLineArguments::PopulateVariable(std::vector<double>* variable,
const std::string& value)
{
- char* res = KWSYS_NULLPTR;
+ char* res = nullptr;
variable->push_back(strtod(value.c_str(), &res));
// if ( res && *res )
// {
diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in
index 92ffea3..29a2dd1 100644
--- a/Source/kwsys/Configure.hxx.in
+++ b/Source/kwsys/Configure.hxx.in
@@ -58,7 +58,6 @@
# define KWSYS_CXX_HAS_EXT_STDIO_FILEBUF_H \
@KWSYS_NAMESPACE@_CXX_HAS_EXT_STDIO_FILEBUF_H
# define KWSYS_FALLTHROUGH @KWSYS_NAMESPACE@_FALLTHROUGH
-# define KWSYS_NULLPTR @KWSYS_NAMESPACE@_NULLPTR
# define KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP \
@KWSYS_NAMESPACE@_SYSTEMTOOLS_USE_TRANSLATION_MAP
#endif
diff --git a/Source/kwsys/ConsoleBuf.hxx.in b/Source/kwsys/ConsoleBuf.hxx.in
index 73a1efb..49dbdf7 100644
--- a/Source/kwsys/ConsoleBuf.hxx.in
+++ b/Source/kwsys/ConsoleBuf.hxx.in
@@ -116,7 +116,7 @@ protected:
DWORD charsWritten;
success =
::WriteConsoleW(m_hOutput, wbuffer.c_str(), (DWORD)wbuffer.size(),
- &charsWritten, NULL) == 0
+ &charsWritten, nullptr) == 0
? false
: true;
} else {
@@ -124,8 +124,9 @@ protected:
std::string buffer;
success = encodeOutputBuffer(wbuffer, buffer);
if (success) {
- success = ::WriteFile(m_hOutput, buffer.c_str(),
- (DWORD)buffer.size(), &bytesWritten, NULL) == 0
+ success =
+ ::WriteFile(m_hOutput, buffer.c_str(), (DWORD)buffer.size(),
+ &bytesWritten, nullptr) == 0
? false
: true;
}
@@ -152,7 +153,7 @@ protected:
DWORD charsRead;
if (ReadConsoleW(m_hInput, wbuffer,
(sizeof(wbuffer) / sizeof(wbuffer[0])), &charsRead,
- NULL) == 0 ||
+ nullptr) == 0 ||
charsRead == 0) {
_setg(true);
return Traits::eof();
@@ -168,7 +169,7 @@ protected:
return Traits::eof();
}
char* buffer = new char[size.LowPart];
- while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, NULL) ==
+ while (ReadFile(m_hInput, buffer, size.LowPart, &bytesRead, nullptr) ==
0) {
if (GetLastError() == ERROR_MORE_DATA) {
strbuffer += std::string(buffer, bytesRead);
@@ -327,11 +328,12 @@ private:
}
const int length =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
- (int)wbuffer.size(), NULL, 0, NULL, NULL);
+ (int)wbuffer.size(), nullptr, 0, nullptr, nullptr);
char* buf = new char[length];
const bool success =
WideCharToMultiByte(m_activeOutputCodepage, 0, wbuffer.c_str(),
- (int)wbuffer.size(), buf, length, NULL, NULL) > 0
+ (int)wbuffer.size(), buf, length, nullptr,
+ nullptr) > 0
? true
: false;
buffer = std::string(buf, length);
@@ -356,7 +358,7 @@ private:
length -= BOMsize;
}
const size_t wlength = static_cast<size_t>(MultiByteToWideChar(
- actualCodepage, 0, data, static_cast<int>(length), NULL, 0));
+ actualCodepage, 0, data, static_cast<int>(length), nullptr, 0));
wchar_t* wbuf = new wchar_t[wlength];
const bool success =
MultiByteToWideChar(actualCodepage, 0, data, static_cast<int>(length),
diff --git a/Source/kwsys/Directory.cxx b/Source/kwsys/Directory.cxx
index 59530a4..e379182 100644
--- a/Source/kwsys/Directory.cxx
+++ b/Source/kwsys/Directory.cxx
@@ -48,7 +48,7 @@ unsigned long Directory::GetNumberOfFiles() const
const char* Directory::GetFile(unsigned long dindex) const
{
if (dindex >= this->Internal->Files.size()) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
return this->Internal->Files[dindex].c_str();
}
diff --git a/Source/kwsys/DynamicLoader.cxx b/Source/kwsys/DynamicLoader.cxx
index b93a215..a4b8641 100644
--- a/Source/kwsys/DynamicLoader.cxx
+++ b/Source/kwsys/DynamicLoader.cxx
@@ -223,15 +223,15 @@ namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
const std::string& libname, int flags)
{
- CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, NULL);
+ CHECK_OPEN_FLAGS(flags, SearchBesideLibrary, nullptr);
DWORD llFlags = 0;
if (flags & SearchBesideLibrary) {
llFlags |= LOAD_WITH_ALTERED_SEARCH_PATH;
}
- return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(), NULL,
- llFlags);
+ return LoadLibraryExW(Encoding::ToWindowsExtendedPath(libname).c_str(),
+ nullptr, llFlags);
}
int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
@@ -289,9 +289,9 @@ const char* DynamicLoader::LastError()
DWORD error = GetLastError();
DWORD length = FormatMessageW(
- FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, error,
+ FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, nullptr, error,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, NULL);
+ lpMsgBuf, DYNLOAD_ERROR_BUFFER_SIZE, nullptr);
static char str[DYNLOAD_ERROR_BUFFER_SIZE + 1];
@@ -305,7 +305,7 @@ const char* DynamicLoader::LastError()
}
if (!WideCharToMultiByte(CP_UTF8, 0, lpMsgBuf, -1, str,
- DYNLOAD_ERROR_BUFFER_SIZE, NULL, NULL)) {
+ DYNLOAD_ERROR_BUFFER_SIZE, nullptr, nullptr)) {
/* WideCharToMultiByte failed. Use a default message. */
_snprintf(str, DYNLOAD_ERROR_BUFFER_SIZE,
"DynamicLoader encountered error 0x%X. "
@@ -372,7 +372,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
DynamicLoader::SymbolPointer psym;
} result;
- result.psym = NULL;
+ result.psym = nullptr;
if (!lib) {
last_dynamic_err = B_BAD_VALUE;
@@ -384,7 +384,7 @@ DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid);
if (rc != B_OK) {
last_dynamic_err = rc;
- result.psym = NULL;
+ result.psym = nullptr;
}
}
return result.psym;
@@ -412,7 +412,7 @@ namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
const std::string& libname, int flags)
{
- CHECK_OPEN_FLAGS(flags, 0, NULL);
+ CHECK_OPEN_FLAGS(flags, 0, nullptr);
char* name = (char*)calloc(1, libname.size() + 1);
dld_init(program_invocation_name);
@@ -458,7 +458,7 @@ namespace KWSYS_NAMESPACE {
DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
const std::string& libname, int flags)
{
- CHECK_OPEN_FLAGS(flags, 0, NULL);
+ CHECK_OPEN_FLAGS(flags, 0, nullptr);
return dlopen(libname.c_str(), RTLD_LAZY);
}
diff --git a/Source/kwsys/EncodingCXX.cxx b/Source/kwsys/EncodingCXX.cxx
index 251deef..4593c92 100644
--- a/Source/kwsys/EncodingCXX.cxx
+++ b/Source/kwsys/EncodingCXX.cxx
@@ -65,7 +65,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac,
for (int i = 0; i < ac; i++) {
this->argv_[i] = strdup(av[i]);
}
- this->argv_[ac] = KWSYS_NULLPTR;
+ this->argv_[ac] = nullptr;
}
Encoding::CommandLineArguments::CommandLineArguments(int ac,
@@ -75,7 +75,7 @@ Encoding::CommandLineArguments::CommandLineArguments(int ac,
for (int i = 0; i < ac; i++) {
this->argv_[i] = kwsysEncoding_DupToNarrow(av[i]);
}
- this->argv_[ac] = KWSYS_NULLPTR;
+ this->argv_[ac] = nullptr;
}
Encoding::CommandLineArguments::~CommandLineArguments()
@@ -90,7 +90,7 @@ Encoding::CommandLineArguments::CommandLineArguments(
{
this->argv_.resize(other.argv_.size());
for (size_t i = 0; i < this->argv_.size(); i++) {
- this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR;
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr;
}
}
@@ -105,7 +105,7 @@ Encoding::CommandLineArguments& Encoding::CommandLineArguments::operator=(
this->argv_.resize(other.argv_.size());
for (i = 0; i < this->argv_.size(); i++) {
- this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : KWSYS_NULLPTR;
+ this->argv_[i] = other.argv_[i] ? strdup(other.argv_[i]) : nullptr;
}
}
@@ -128,8 +128,9 @@ std::wstring Encoding::ToWide(const std::string& str)
{
std::wstring wstr;
# if defined(_WIN32)
- const int wlength = MultiByteToWideChar(
- KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(), int(str.size()), NULL, 0);
+ const int wlength =
+ MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
+ int(str.size()), nullptr, 0);
if (wlength > 0) {
wchar_t* wdata = new wchar_t[wlength];
int r = MultiByteToWideChar(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.data(),
@@ -162,12 +163,12 @@ std::string Encoding::ToNarrow(const std::wstring& str)
# if defined(_WIN32)
int length =
WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
- int(str.size()), NULL, 0, NULL, NULL);
+ int(str.size()), nullptr, 0, nullptr, nullptr);
if (length > 0) {
char* data = new char[length];
int r =
WideCharToMultiByte(KWSYS_ENCODING_DEFAULT_CODEPAGE, 0, str.c_str(),
- int(str.size()), data, length, NULL, NULL);
+ int(str.size()), data, length, nullptr, nullptr);
if (r > 0) {
nstr = std::string(data, length);
}
@@ -193,7 +194,7 @@ std::string Encoding::ToNarrow(const std::wstring& str)
std::wstring Encoding::ToWide(const char* cstr)
{
std::wstring wstr;
- size_t length = kwsysEncoding_mbstowcs(KWSYS_NULLPTR, cstr, 0) + 1;
+ size_t length = kwsysEncoding_mbstowcs(nullptr, cstr, 0) + 1;
if (length > 0) {
std::vector<wchar_t> wchars(length);
if (kwsysEncoding_mbstowcs(&wchars[0], cstr, length) > 0) {
@@ -206,7 +207,7 @@ std::wstring Encoding::ToWide(const char* cstr)
std::string Encoding::ToNarrow(const wchar_t* wcstr)
{
std::string str;
- size_t length = kwsysEncoding_wcstombs(KWSYS_NULLPTR, wcstr, 0) + 1;
+ size_t length = kwsysEncoding_wcstombs(nullptr, wcstr, 0) + 1;
if (length > 0) {
std::vector<char> chars(length);
if (kwsysEncoding_wcstombs(&chars[0], wcstr, length) > 0) {
@@ -227,9 +228,9 @@ std::wstring Encoding::ToWindowsExtendedPath(std::string const& source)
/* The +3 is a workaround for a bug in some versions of GetFullPathNameW that
* won't return a large enough buffer size if the input is too small */
- wfull_len = GetFullPathNameW(wsource.c_str(), 0, NULL, NULL) + 3;
+ wfull_len = GetFullPathNameW(wsource.c_str(), 0, nullptr, nullptr) + 3;
std::vector<wchar_t> wfull(wfull_len);
- GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], NULL);
+ GetFullPathNameW(wsource.c_str(), wfull_len, &wfull[0], nullptr);
/* This should get the correct size without any extra padding from the
* previous size workaround. */
diff --git a/Source/kwsys/Glob.cxx b/Source/kwsys/Glob.cxx
index 829c138..34bb0d0 100644
--- a/Source/kwsys/Glob.cxx
+++ b/Source/kwsys/Glob.cxx
@@ -431,7 +431,7 @@ void Glob::SetRelative(const char* dir)
const char* Glob::GetRelative()
{
if (this->Relative.empty()) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
return this->Relative.c_str();
}
diff --git a/Source/kwsys/Glob.hxx.in b/Source/kwsys/Glob.hxx.in
index 4c3bde1..170766f 100644
--- a/Source/kwsys/Glob.hxx.in
+++ b/Source/kwsys/Glob.hxx.in
@@ -54,7 +54,7 @@ public:
~Glob();
//! Find all files that match the pattern.
- bool FindFiles(const std::string& inexpr, GlobMessages* messages = 0);
+ bool FindFiles(const std::string& inexpr, GlobMessages* messages = nullptr);
//! Return the list of files that matched.
std::vector<std::string>& GetFiles();
diff --git a/Source/kwsys/RegularExpression.cxx b/Source/kwsys/RegularExpression.cxx
index 3e10765..5e6f8da 100644
--- a/Source/kwsys/RegularExpression.cxx
+++ b/Source/kwsys/RegularExpression.cxx
@@ -37,7 +37,7 @@ namespace KWSYS_NAMESPACE {
RegularExpression::RegularExpression(const RegularExpression& rxp)
{
if (!rxp.program) {
- this->program = KWSYS_NULLPTR;
+ this->program = nullptr;
return;
}
int ind;
@@ -48,7 +48,7 @@ RegularExpression::RegularExpression(const RegularExpression& rxp)
// Copy pointers into last successful "find" operation
this->regmatch = rxp.regmatch;
this->regmust = rxp.regmust; // Copy field
- if (rxp.regmust != KWSYS_NULLPTR) {
+ if (rxp.regmust != nullptr) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
@@ -69,7 +69,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
return *this;
}
if (!rxp.program) {
- this->program = KWSYS_NULLPTR;
+ this->program = nullptr;
return *this;
}
int ind;
@@ -81,7 +81,7 @@ RegularExpression& RegularExpression::operator=(const RegularExpression& rxp)
// Copy pointers into last successful "find" operation
this->regmatch = rxp.regmatch;
this->regmust = rxp.regmust; // Copy field
- if (rxp.regmust != KWSYS_NULLPTR) {
+ if (rxp.regmust != nullptr) {
char* dum = rxp.program;
ind = 0;
while (dum != rxp.regmust) {
@@ -164,8 +164,8 @@ bool RegularExpression::deep_equal(const RegularExpression& rxp) const
*
* regstart char that must begin a match; '\0' if none obvious
* reganch is the match anchored (at beginning-of-line only)?
- * regmust string (pointer into program) that match must include, or NULL
- * regmlen length of regmust string
+ * regmust string (pointer into program) that match must include, or
+ * nullptr regmlen length of regmust string
*
* Regstart and reganch permit very fast decisions on suitable starting points
* for a match, cutting down the work a lot. Regmust permits fast rejection
@@ -339,7 +339,7 @@ bool RegularExpression::compile(const char* exp)
const char* longest;
int flags;
- if (exp == KWSYS_NULLPTR) {
+ if (exp == nullptr) {
// RAISE Error, SYM(RegularExpression), SYM(No_Expr),
printf("RegularExpression::compile(): No expression supplied.\n");
return false;
@@ -367,13 +367,13 @@ bool RegularExpression::compile(const char* exp)
// Allocate space.
//#ifndef _WIN32
- if (this->program != KWSYS_NULLPTR)
+ if (this->program != nullptr)
delete[] this->program;
//#endif
this->program = new char[comp.regsize];
this->progsize = static_cast<int>(comp.regsize);
- if (this->program == KWSYS_NULLPTR) {
+ if (this->program == nullptr) {
// RAISE Error, SYM(RegularExpression), SYM(Out_Of_Memory),
printf("RegularExpression::compile(): Out of memory.\n");
return false;
@@ -389,7 +389,7 @@ bool RegularExpression::compile(const char* exp)
// Dig out information for optimizations.
this->regstart = '\0'; // Worst-case defaults.
this->reganch = 0;
- this->regmust = KWSYS_NULLPTR;
+ this->regmust = nullptr;
this->regmlen = 0;
scan = this->program + 1; // First BRANCH.
if (OP(regnext(scan)) == END) { // Only one top-level choice.
@@ -410,9 +410,9 @@ bool RegularExpression::compile(const char* exp)
// absence of others.
//
if (flags & SPSTART) {
- longest = KWSYS_NULLPTR;
+ longest = nullptr;
size_t len = 0;
- for (; scan != KWSYS_NULLPTR; scan = regnext(scan))
+ for (; scan != nullptr; scan = regnext(scan))
if (OP(scan) == EXACTLY && strlen(OPERAND(scan)) >= len) {
longest = OPERAND(scan);
len = strlen(OPERAND(scan));
@@ -448,19 +448,19 @@ char* RegExpCompile::reg(int paren, int* flagp)
if (regnpar >= RegularExpressionMatch::NSUBEXP) {
// RAISE Error, SYM(RegularExpression), SYM(Too_Many_Parens),
printf("RegularExpression::compile(): Too many parentheses.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
parno = regnpar;
regnpar++;
ret = regnode(static_cast<char>(OPEN + parno));
} else
- ret = KWSYS_NULLPTR;
+ ret = nullptr;
// Pick up the branches, linking them together.
br = regbranch(&flags);
- if (br == KWSYS_NULLPTR)
- return (KWSYS_NULLPTR);
- if (ret != KWSYS_NULLPTR)
+ if (br == nullptr)
+ return (nullptr);
+ if (ret != nullptr)
regtail(ret, br); // OPEN -> first.
else
ret = br;
@@ -470,8 +470,8 @@ char* RegExpCompile::reg(int paren, int* flagp)
while (*regparse == '|') {
regparse++;
br = regbranch(&flags);
- if (br == KWSYS_NULLPTR)
- return (KWSYS_NULLPTR);
+ if (br == nullptr)
+ return (nullptr);
regtail(ret, br); // BRANCH -> BRANCH.
if (!(flags & HASWIDTH))
*flagp &= ~HASWIDTH;
@@ -483,23 +483,23 @@ char* RegExpCompile::reg(int paren, int* flagp)
regtail(ret, ender);
// Hook the tails of the branches to the closing node.
- for (br = ret; br != KWSYS_NULLPTR; br = regnext(br))
+ for (br = ret; br != nullptr; br = regnext(br))
regoptail(br, ender);
// Check for proper termination.
if (paren && *regparse++ != ')') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
printf("RegularExpression::compile(): Unmatched parentheses.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
} else if (!paren && *regparse != '\0') {
if (*regparse == ')') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Parens),
printf("RegularExpression::compile(): Unmatched parentheses.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
} else {
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
// NOTREACHED
}
@@ -521,19 +521,19 @@ char* RegExpCompile::regbranch(int* flagp)
*flagp = WORST; // Tentatively.
ret = regnode(BRANCH);
- chain = KWSYS_NULLPTR;
+ chain = nullptr;
while (*regparse != '\0' && *regparse != '|' && *regparse != ')') {
latest = regpiece(&flags);
- if (latest == KWSYS_NULLPTR)
- return (KWSYS_NULLPTR);
+ if (latest == nullptr)
+ return (nullptr);
*flagp |= flags & HASWIDTH;
- if (chain == KWSYS_NULLPTR) // First piece.
+ if (chain == nullptr) // First piece.
*flagp |= flags & SPSTART;
else
regtail(chain, latest);
chain = latest;
}
- if (chain == KWSYS_NULLPTR) // Loop ran zero times.
+ if (chain == nullptr) // Loop ran zero times.
regnode(NOTHING);
return (ret);
@@ -556,8 +556,8 @@ char* RegExpCompile::regpiece(int* flagp)
int flags;
ret = regatom(&flags);
- if (ret == KWSYS_NULLPTR)
- return (KWSYS_NULLPTR);
+ if (ret == nullptr)
+ return (nullptr);
op = *regparse;
if (!ISMULT(op)) {
@@ -568,7 +568,7 @@ char* RegExpCompile::regpiece(int* flagp)
if (!(flags & HASWIDTH) && op != '?') {
// RAISE Error, SYM(RegularExpression), SYM(Empty_Operand),
printf("RegularExpression::compile() : *+ operand could be empty.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
*flagp = (op != '+') ? (WORST | SPSTART) : (WORST | HASWIDTH);
@@ -602,7 +602,7 @@ char* RegExpCompile::regpiece(int* flagp)
if (ISMULT(*regparse)) {
// RAISE Error, SYM(RegularExpression), SYM(Nested_Operand),
printf("RegularExpression::compile(): Nested *?+.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
return (ret);
}
@@ -655,7 +655,7 @@ char* RegExpCompile::regatom(int* flagp)
if (rxpclass > rxpclassend + 1) {
// RAISE Error, SYM(RegularExpression), SYM(Invalid_Range),
printf("RegularExpression::compile(): Invalid range in [].\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
for (; rxpclass <= rxpclassend; rxpclass++)
regc(static_cast<char>(rxpclass));
@@ -668,15 +668,15 @@ char* RegExpCompile::regatom(int* flagp)
if (*regparse != ']') {
// RAISE Error, SYM(RegularExpression), SYM(Unmatched_Bracket),
printf("RegularExpression::compile(): Unmatched [].\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
regparse++;
*flagp |= HASWIDTH | SIMPLE;
} break;
case '(':
ret = reg(1, &flags);
- if (ret == KWSYS_NULLPTR)
- return (KWSYS_NULLPTR);
+ if (ret == nullptr)
+ return (nullptr);
*flagp |= flags & (HASWIDTH | SPSTART);
break;
case '\0':
@@ -684,18 +684,18 @@ char* RegExpCompile::regatom(int* flagp)
case ')':
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n"); // Never here
- return KWSYS_NULLPTR;
+ return nullptr;
case '?':
case '+':
case '*':
// RAISE Error, SYM(RegularExpression), SYM(No_Operand),
printf("RegularExpression::compile(): ?+* follows nothing.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
case '\\':
if (*regparse == '\0') {
// RAISE Error, SYM(RegularExpression), SYM(Trailing_Backslash),
printf("RegularExpression::compile(): Trailing backslash.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
ret = regnode(EXACTLY);
regc(*regparse++);
@@ -711,7 +711,7 @@ char* RegExpCompile::regatom(int* flagp)
if (len <= 0) {
// RAISE Error, SYM(RegularExpression), SYM(Internal_Error),
printf("RegularExpression::compile(): Internal error.\n");
- return KWSYS_NULLPTR;
+ return nullptr;
}
ender = *(regparse + len);
if (len > 1 && ISMULT(ender))
@@ -809,7 +809,7 @@ void RegExpCompile::regtail(char* p, const char* val)
scan = p;
for (;;) {
temp = regnext(scan);
- if (temp == KWSYS_NULLPTR)
+ if (temp == nullptr)
break;
scan = temp;
}
@@ -828,7 +828,7 @@ void RegExpCompile::regtail(char* p, const char* val)
void RegExpCompile::regoptail(char* p, const char* val)
{
// "Operandless" and "op != BRANCH" are synonymous in practice.
- if (p == KWSYS_NULLPTR || p == regdummyptr || OP(p) != BRANCH)
+ if (p == nullptr || p == regdummyptr || OP(p) != BRANCH)
return;
regtail(OPERAND(p), val);
}
@@ -878,14 +878,14 @@ bool RegularExpression::find(char const* string,
}
// If there is a "must appear" string, look for it.
- if (this->regmust != KWSYS_NULLPTR) {
+ if (this->regmust != nullptr) {
s = string;
- while ((s = strchr(s, this->regmust[0])) != KWSYS_NULLPTR) {
+ while ((s = strchr(s, this->regmust[0])) != nullptr) {
if (strncmp(s, this->regmust, this->regmlen) == 0)
break; // Found it.
s++;
}
- if (s == KWSYS_NULLPTR) // Not present.
+ if (s == nullptr) // Not present.
return false;
}
@@ -903,7 +903,7 @@ bool RegularExpression::find(char const* string,
s = string;
if (this->regstart != '\0')
// We know what char it must start with.
- while ((s = strchr(s, this->regstart)) != KWSYS_NULLPTR) {
+ while ((s = strchr(s, this->regstart)) != nullptr) {
if (regFind.regtry(s, rmatch.startp, rmatch.endp, this->program))
return true;
s++;
@@ -937,8 +937,8 @@ int RegExpFind::regtry(const char* string, const char** start,
sp1 = start;
ep = end;
for (i = RegularExpressionMatch::NSUBEXP; i > 0; i--) {
- *sp1++ = KWSYS_NULLPTR;
- *ep++ = KWSYS_NULLPTR;
+ *sp1++ = nullptr;
+ *ep++ = nullptr;
}
if (regmatch(prog + 1)) {
start[0] = string;
@@ -966,7 +966,7 @@ int RegExpFind::regmatch(const char* prog)
scan = prog;
- while (scan != KWSYS_NULLPTR) {
+ while (scan != nullptr) {
next = regnext(scan);
@@ -998,14 +998,12 @@ int RegExpFind::regmatch(const char* prog)
reginput += len;
} break;
case ANYOF:
- if (*reginput == '\0' ||
- strchr(OPERAND(scan), *reginput) == KWSYS_NULLPTR)
+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) == nullptr)
return (0);
reginput++;
break;
case ANYBUT:
- if (*reginput == '\0' ||
- strchr(OPERAND(scan), *reginput) != KWSYS_NULLPTR)
+ if (*reginput == '\0' || strchr(OPERAND(scan), *reginput) != nullptr)
return (0);
reginput++;
break;
@@ -1034,7 +1032,7 @@ int RegExpFind::regmatch(const char* prog)
// Don't set startp if some later invocation of the
// same parentheses already has.
//
- if (regstartp[no] == KWSYS_NULLPTR)
+ if (regstartp[no] == nullptr)
regstartp[no] = save;
return (1);
} else
@@ -1062,7 +1060,7 @@ int RegExpFind::regmatch(const char* prog)
// Don't set endp if some later invocation of the
// same parentheses already has.
//
- if (regendp[no] == KWSYS_NULLPTR)
+ if (regendp[no] == nullptr)
regendp[no] = save;
return (1);
} else
@@ -1082,7 +1080,7 @@ int RegExpFind::regmatch(const char* prog)
return (1);
reginput = save;
scan = regnext(scan);
- } while (scan != KWSYS_NULLPTR && OP(scan) == BRANCH);
+ } while (scan != nullptr && OP(scan) == BRANCH);
return (0);
// NOTREACHED
}
@@ -1160,13 +1158,13 @@ int RegExpFind::regrepeat(const char* p)
}
break;
case ANYOF:
- while (*scan != '\0' && strchr(opnd, *scan) != KWSYS_NULLPTR) {
+ while (*scan != '\0' && strchr(opnd, *scan) != nullptr) {
count++;
scan++;
}
break;
case ANYBUT:
- while (*scan != '\0' && strchr(opnd, *scan) == KWSYS_NULLPTR) {
+ while (*scan != '\0' && strchr(opnd, *scan) == nullptr) {
count++;
scan++;
}
@@ -1188,11 +1186,11 @@ static const char* regnext(const char* p)
int offset;
if (p == regdummyptr)
- return (KWSYS_NULLPTR);
+ return (nullptr);
offset = NEXT(p);
if (offset == 0)
- return (KWSYS_NULLPTR);
+ return (nullptr);
if (OP(p) == BACK)
return (p - offset);
@@ -1205,11 +1203,11 @@ static char* regnext(char* p)
int offset;
if (p == regdummyptr)
- return (KWSYS_NULLPTR);
+ return (nullptr);
offset = NEXT(p);
if (offset == 0)
- return (KWSYS_NULLPTR);
+ return (nullptr);
if (OP(p) == BACK)
return (p - offset);
diff --git a/Source/kwsys/RegularExpression.hxx.in b/Source/kwsys/RegularExpression.hxx.in
index ed86418..df7eb45 100644
--- a/Source/kwsys/RegularExpression.hxx.in
+++ b/Source/kwsys/RegularExpression.hxx.in
@@ -71,9 +71,9 @@ private:
*/
inline RegularExpressionMatch::RegularExpressionMatch()
{
- startp[0] = 0;
- endp[0] = 0;
- searchstring = 0;
+ startp[0] = nullptr;
+ endp[0] = nullptr;
+ searchstring = nullptr;
}
/**
@@ -81,7 +81,7 @@ inline RegularExpressionMatch::RegularExpressionMatch()
*/
inline bool RegularExpressionMatch::isValid() const
{
- return (this->startp[0] != 0);
+ return (this->startp[0] != nullptr);
}
/**
@@ -89,9 +89,9 @@ inline bool RegularExpressionMatch::isValid() const
*/
inline void RegularExpressionMatch::clear()
{
- startp[0] = 0;
- endp[0] = 0;
- searchstring = 0;
+ startp[0] = nullptr;
+ endp[0] = nullptr;
+ searchstring = nullptr;
}
/**
@@ -135,7 +135,7 @@ inline std::string::size_type RegularExpressionMatch::end(int n) const
*/
inline std::string RegularExpressionMatch::match(int n) const
{
- if (this->startp[n] == 0) {
+ if (this->startp[n] == nullptr) {
return std::string();
} else {
return std::string(
@@ -230,10 +230,11 @@ inline std::string RegularExpressionMatch::match(int n) const
* into the object's private data fields. The == and != operators only check
* the to see if the compiled regular expression is the same, and the
* deep_equal functions also checks to see if the start and end pointers are
- * the same. The is_valid function returns false if program is set to NULL,
- * (i.e. there is no valid compiled expression). The set_invalid function
- * sets the program to NULL (Warning: this deletes the compiled expression).
- * The following examples may help clarify regular expression usage:
+ * the same. The is_valid function returns false if program is set to
+ * nullptr, (i.e. there is no valid compiled expression). The set_invalid
+ * function sets the program to nullptr (Warning: this deletes the compiled
+ * expression). The following examples may help clarify regular expression
+ * usage:
*
* * The regular expression "^hello" matches a "hello" only at the
* beginning of a line. It would match "hello there" but not "hi,
@@ -288,7 +289,7 @@ class @KWSYS_NAMESPACE@_EXPORT RegularExpression
{
public:
/**
- * Instantiate RegularExpression with program=NULL.
+ * Instantiate RegularExpression with program=nullptr.
*/
inline RegularExpression();
@@ -410,7 +411,7 @@ inline RegularExpression::RegularExpression()
: regstart{}
, reganch{}
, regmust{}
- , program{ 0 }
+ , program{ nullptr }
, progsize{}
{
}
@@ -423,7 +424,7 @@ inline RegularExpression::RegularExpression(const char* s)
: regstart{}
, reganch{}
, regmust{}
- , program{ 0 }
+ , program{ nullptr }
, progsize{}
{
if (s) {
@@ -439,7 +440,7 @@ inline RegularExpression::RegularExpression(const std::string& s)
: regstart{}
, reganch{}
, regmust{}
- , program{ 0 }
+ , program{ nullptr }
, progsize{}
{
this->compile(s);
@@ -545,7 +546,7 @@ inline bool RegularExpression::operator!=(const RegularExpression& r) const
*/
inline bool RegularExpression::is_valid() const
{
- return (this->program != 0);
+ return (this->program != nullptr);
}
inline void RegularExpression::set_invalid()
@@ -553,7 +554,7 @@ inline void RegularExpression::set_invalid()
//#ifndef _WIN32
delete[] this->program;
//#endif
- this->program = 0;
+ this->program = nullptr;
}
} // namespace @KWSYS_NAMESPACE@
diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx
index 7dc6cf4..6ec6e48 100644
--- a/Source/kwsys/SystemInformation.cxx
+++ b/Source/kwsys/SystemInformation.cxx
@@ -847,31 +847,16 @@ void SystemInformation::RunMemoryCheck()
// SystemInformationImplementation starts here
-#define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
-#define TLBCACHE_INFO_UNITS (15)
-#define CLASSICAL_CPU_FREQ_LOOP 10000000
-#define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
-
-// Status Flag
-#define HT_NOT_CAPABLE 0
-#define HT_ENABLED 1
-#define HT_DISABLED 2
-#define HT_SUPPORTED_NOT_ENABLED 3
-#define HT_CANNOT_DETECT 4
-
-// EDX[28] Bit 28 is set if HT is supported
-#define HT_BIT 0x10000000
-
-// EAX[11:8] Bit 8-11 contains family processor ID.
-#define FAMILY_ID 0x0F00
-#define PENTIUM4_ID 0x0F00
-// EAX[23:20] Bit 20-23 contains extended family processor ID
-#define EXT_FAMILY_ID 0x0F00000
-// EBX[23:16] Bit 16-23 in ebx contains the number of logical
-#define NUM_LOGICAL_BITS 0x00FF0000
-// processors per physical processor when execute cpuid with
-// eax set to 1
-// EBX[31:24] Bits 24-31 (8 bits) return the 8-bit unique
+#if USE_CPUID
+# define STORE_TLBCACHE_INFO(x, y) x = (x < (y)) ? (y) : x
+# define TLBCACHE_INFO_UNITS (15)
+#endif
+
+#if USE_ASM_INSTRUCTIONS
+# define CLASSICAL_CPU_FREQ_LOOP 10000000
+# define RDTSC_INSTRUCTION _asm _emit 0x0f _asm _emit 0x31
+#endif
+
#define INITIAL_APIC_ID_BITS 0xFF000000
// initial APIC ID for the processor this code is running on.
// Default value = 0xff if HT is not supported
@@ -888,7 +873,7 @@ int LoadLines(FILE* file, std::vector<std::string>& lines)
char buf[bufSize] = { '\0' };
while (!feof(file) && !ferror(file)) {
errno = 0;
- if (fgets(buf, bufSize, file) == KWSYS_NULLPTR) {
+ if (fgets(buf, bufSize, file) == nullptr) {
if (ferror(file) && (errno == EINTR)) {
clearerr(file);
}
@@ -952,7 +937,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
return -1;
}
int i = 0;
- while (fieldNames[i] != NULL) {
+ while (fieldNames[i] != nullptr) {
int ierr = NameValue(fields, fieldNames[i], values[i]);
if (ierr) {
return -(i + 2);
@@ -966,7 +951,7 @@ int GetFieldsFromFile(const char* fileName, const char** fieldNames, T* values)
template <typename T>
int GetFieldFromFile(const char* fileName, const char* fieldName, T& value)
{
- const char* fieldNames[2] = { fieldName, NULL };
+ const char* fieldNames[2] = { fieldName, nullptr };
T values[1] = { T(0) };
int ierr = GetFieldsFromFile(fileName, fieldNames, values);
if (ierr) {
@@ -984,7 +969,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
T* values)
{
FILE* file = popen(command, "r");
- if (file == KWSYS_NULLPTR) {
+ if (file == nullptr) {
return -1;
}
std::vector<std::string> fields;
@@ -994,7 +979,7 @@ int GetFieldsFromCommand(const char* command, const char** fieldNames,
return -1;
}
int i = 0;
- while (fieldNames[i] != KWSYS_NULLPTR) {
+ while (fieldNames[i] != nullptr) {
int ierr = NameValue(fields, fieldNames[i], values[i]);
if (ierr) {
return -(i + 2);
@@ -1030,8 +1015,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGFPE:
- oss << "Caught SIGFPE at "
- << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
+ oss << "Caught SIGFPE at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
# if defined(FPE_INTDIV)
@@ -1079,8 +1063,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGSEGV:
- oss << "Caught SIGSEGV at "
- << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
+ oss << "Caught SIGSEGV at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case SEGV_MAPERR:
@@ -1098,8 +1081,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGBUS:
- oss << "Caught SIGBUS at "
- << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
+ oss << "Caught SIGBUS at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case BUS_ADRALN:
@@ -1139,8 +1121,7 @@ void StacktraceSignalHandler(int sigNo, siginfo_t* sigInfo,
break;
case SIGILL:
- oss << "Caught SIGILL at "
- << (sigInfo->si_addr == KWSYS_NULLPTR ? "0x" : "")
+ oss << "Caught SIGILL at " << (sigInfo->si_addr == nullptr ? "0x" : "")
<< sigInfo->si_addr << " ";
switch (sigInfo->si_code) {
case ILL_ILLOPC:
@@ -1324,8 +1305,8 @@ SymbolProperties::SymbolProperties()
// not using an initializer list
// to avoid some PGI compiler warnings
this->SetBinary("???");
- this->SetBinaryBaseAddress(KWSYS_NULLPTR);
- this->Address = KWSYS_NULLPTR;
+ this->SetBinaryBaseAddress(nullptr);
+ this->Address = nullptr;
this->SetSourceFile("???");
this->SetFunction("???");
this->SetLineNumber(-1);
@@ -1682,7 +1663,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
return -2;
}
- for (ifa = ifas; ifa != KWSYS_NULLPTR; ifa = ifa->ifa_next) {
+ for (ifa = ifas; ifa != nullptr; ifa = ifa->ifa_next) {
int fam = ifa->ifa_addr ? ifa->ifa_addr->sa_family : -1;
// Skip Loopback interfaces
if (((fam == AF_INET) || (fam == AF_INET6)) &&
@@ -1693,7 +1674,7 @@ int SystemInformationImplementation::GetFullyQualifiedDomainName(
: sizeof(struct sockaddr_in6));
ierr = getnameinfo(ifa->ifa_addr, static_cast<socklen_t>(addrlen), host,
- NI_MAXHOST, KWSYS_NULLPTR, 0, NI_NAMEREQD);
+ NI_MAXHOST, nullptr, 0, NI_NAMEREQD);
if (ierr) {
// don't report the failure now since we may succeed on another
// interface. If all attempts fail then return the failure code.
@@ -2577,7 +2558,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed()
// If RDTSC is not supported, we fallback to trying to read this value
// from the registry:
if (!retrieved) {
- HKEY hKey = NULL;
+ HKEY hKey = nullptr;
LONG err =
RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", 0,
@@ -2597,7 +2578,7 @@ bool SystemInformationImplementation::RetrieveCPUClockSpeed()
}
RegCloseKey(hKey);
- hKey = NULL;
+ hKey = nullptr;
}
}
#endif
@@ -3628,7 +3609,7 @@ SystemInformationImplementation::GetHostMemoryTotal()
#elif defined(__APPLE__)
uint64_t mem;
size_t len = sizeof(mem);
- int ierr = sysctlbyname("hw.memsize", &mem, &len, KWSYS_NULLPTR, 0);
+ int ierr = sysctlbyname("hw.memsize", &mem, &len, nullptr, 0);
if (ierr) {
return -1;
}
@@ -3745,12 +3726,12 @@ SystemInformationImplementation::GetHostMemoryUsed()
# endif
#elif defined(__linux)
// First try to use MemAvailable, but it only works on newer kernels
- const char* names2[3] = { "MemTotal:", "MemAvailable:", NULL };
+ const char* names2[3] = { "MemTotal:", "MemAvailable:", nullptr };
SystemInformation::LongLong values2[2] = { SystemInformation::LongLong(0) };
int ierr = GetFieldsFromFile("/proc/meminfo", names2, values2);
if (ierr) {
const char* names4[5] = { "MemTotal:", "MemFree:", "Buffers:", "Cached:",
- NULL };
+ nullptr };
SystemInformation::LongLong values4[4] = { SystemInformation::LongLong(
0) };
ierr = GetFieldsFromFile("/proc/meminfo", names4, values4);
@@ -3771,8 +3752,7 @@ SystemInformationImplementation::GetHostMemoryUsed()
if (psz < 1) {
return -1;
}
- const char* names[3] = { "Pages wired down:", "Pages active:",
- KWSYS_NULLPTR };
+ const char* names[3] = { "Pages wired down:", "Pages active:", nullptr };
SystemInformation::LongLong values[2] = { SystemInformation::LongLong(0) };
int ierr = GetFieldsFromCommand("vm_stat", names, values);
if (ierr) {
@@ -3820,7 +3800,7 @@ SystemInformationImplementation::GetProcMemoryUsed()
std::ostringstream oss;
oss << "ps -o rss= -p " << pid;
FILE* file = popen(oss.str().c_str(), "r");
- if (file == KWSYS_NULLPTR) {
+ if (file == nullptr) {
return -1;
}
oss.str("");
@@ -3920,9 +3900,9 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
void* stack[TRACE_MAX_STACK_FRAMES];
HANDLE process = GetCurrentProcess();
- SymInitialize(process, NULL, TRUE);
+ SymInitialize(process, nullptr, TRUE);
WORD numberOfFrames =
- CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, NULL);
+ CaptureStackBackTrace(firstFrame, TRACE_MAX_STACK_FRAMES, stack, nullptr);
SYMBOL_INFO* symbol = static_cast<SYMBOL_INFO*>(
malloc(sizeof(SYMBOL_INFO) +
(TRACE_MAX_FUNCTION_NAME_LENGTH - 1) * sizeof(TCHAR)));
@@ -3933,7 +3913,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
line.SizeOfStruct = sizeof(IMAGEHLP_LINE64);
for (int i = 0; i < numberOfFrames; i++) {
DWORD64 address = reinterpret_cast<DWORD64>(stack[i]);
- SymFromAddr(process, address, NULL, symbol);
+ SymFromAddr(process, address, nullptr, symbol);
if (SymGetLineFromAddr64(process, address, &displacement, &line)) {
oss << " at " << symbol->Name << " in " << line.FileName << " line "
<< line.LineNumber << std::endl;
@@ -4000,13 +3980,13 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
if (enable && !saOrigValid) {
// save the current actions
- sigaction(SIGABRT, KWSYS_NULLPTR, &saABRTOrig);
- sigaction(SIGSEGV, KWSYS_NULLPTR, &saSEGVOrig);
- sigaction(SIGTERM, KWSYS_NULLPTR, &saTERMOrig);
- sigaction(SIGINT, KWSYS_NULLPTR, &saINTOrig);
- sigaction(SIGILL, KWSYS_NULLPTR, &saILLOrig);
- sigaction(SIGBUS, KWSYS_NULLPTR, &saBUSOrig);
- sigaction(SIGFPE, KWSYS_NULLPTR, &saFPEOrig);
+ sigaction(SIGABRT, nullptr, &saABRTOrig);
+ sigaction(SIGSEGV, nullptr, &saSEGVOrig);
+ sigaction(SIGTERM, nullptr, &saTERMOrig);
+ sigaction(SIGINT, nullptr, &saINTOrig);
+ sigaction(SIGILL, nullptr, &saILLOrig);
+ sigaction(SIGBUS, nullptr, &saBUSOrig);
+ sigaction(SIGFPE, nullptr, &saFPEOrig);
// enable read, disable write
saOrigValid = 1;
@@ -4020,22 +4000,22 @@ void SystemInformationImplementation::SetStackTraceOnError(int enable)
# endif
sigemptyset(&sa.sa_mask);
- sigaction(SIGABRT, &sa, KWSYS_NULLPTR);
- sigaction(SIGSEGV, &sa, KWSYS_NULLPTR);
- sigaction(SIGTERM, &sa, KWSYS_NULLPTR);
- sigaction(SIGINT, &sa, KWSYS_NULLPTR);
- sigaction(SIGILL, &sa, KWSYS_NULLPTR);
- sigaction(SIGBUS, &sa, KWSYS_NULLPTR);
- sigaction(SIGFPE, &sa, KWSYS_NULLPTR);
+ sigaction(SIGABRT, &sa, nullptr);
+ sigaction(SIGSEGV, &sa, nullptr);
+ sigaction(SIGTERM, &sa, nullptr);
+ sigaction(SIGINT, &sa, nullptr);
+ sigaction(SIGILL, &sa, nullptr);
+ sigaction(SIGBUS, &sa, nullptr);
+ sigaction(SIGFPE, &sa, nullptr);
} else if (!enable && saOrigValid) {
// restore previous actions
- sigaction(SIGABRT, &saABRTOrig, KWSYS_NULLPTR);
- sigaction(SIGSEGV, &saSEGVOrig, KWSYS_NULLPTR);
- sigaction(SIGTERM, &saTERMOrig, KWSYS_NULLPTR);
- sigaction(SIGINT, &saINTOrig, KWSYS_NULLPTR);
- sigaction(SIGILL, &saILLOrig, KWSYS_NULLPTR);
- sigaction(SIGBUS, &saBUSOrig, KWSYS_NULLPTR);
- sigaction(SIGFPE, &saFPEOrig, KWSYS_NULLPTR);
+ sigaction(SIGABRT, &saABRTOrig, nullptr);
+ sigaction(SIGSEGV, &saSEGVOrig, nullptr);
+ sigaction(SIGTERM, &saTERMOrig, nullptr);
+ sigaction(SIGINT, &saINTOrig, nullptr);
+ sigaction(SIGILL, &saILLOrig, nullptr);
+ sigaction(SIGBUS, &saBUSOrig, nullptr);
+ sigaction(SIGFPE, &saFPEOrig, nullptr);
// enable write, disable read
saOrigValid = 0;
@@ -4417,7 +4397,7 @@ void SystemInformationImplementation::CPUCountWindows()
std::vector<SYSTEM_LOGICAL_PROCESSOR_INFORMATION> ProcInfo;
{
DWORD Length = 0;
- DWORD rc = pGetLogicalProcessorInformation(NULL, &Length);
+ DWORD rc = pGetLogicalProcessorInformation(nullptr, &Length);
assert(FALSE == rc);
(void)rc; // Silence unused variable warning in Borland C++ 5.81
assert(GetLastError() == ERROR_INSUFFICIENT_BUFFER);
@@ -4471,7 +4451,7 @@ bool SystemInformationImplementation::ParseSysCtl()
int err = 0;
uint64_t value = 0;
size_t len = sizeof(value);
- sysctlbyname("hw.memsize", &value, &len, KWSYS_NULLPTR, 0);
+ sysctlbyname("hw.memsize", &value, &len, nullptr, 0);
this->TotalPhysicalMemory = static_cast<size_t>(value / 1048576);
// Parse values for Mac
@@ -4481,7 +4461,7 @@ bool SystemInformationImplementation::ParseSysCtl()
if (host_statistics(mach_host_self(), HOST_VM_INFO, (host_info_t)&vmstat,
&count) == KERN_SUCCESS) {
len = sizeof(value);
- err = sysctlbyname("hw.pagesize", &value, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("hw.pagesize", &value, &len, nullptr, 0);
int64_t available_memory =
(vmstat.free_count + vmstat.inactive_count) * value;
this->AvailablePhysicalMemory =
@@ -4491,10 +4471,11 @@ bool SystemInformationImplementation::ParseSysCtl()
# ifdef VM_SWAPUSAGE
// Virtual memory.
int mib[2] = { CTL_VM, VM_SWAPUSAGE };
- size_t miblen = sizeof(mib) / sizeof(mib[0]);
+ unsigned int miblen =
+ static_cast<unsigned int>(sizeof(mib) / sizeof(mib[0]));
struct xsw_usage swap;
len = sizeof(swap);
- err = sysctl(mib, miblen, &swap, &len, KWSYS_NULLPTR, 0);
+ err = sysctl(mib, miblen, &swap, &len, nullptr, 0);
if (err == 0) {
this->AvailableVirtualMemory =
static_cast<size_t>(swap.xsu_avail / 1048576);
@@ -4507,75 +4488,72 @@ bool SystemInformationImplementation::ParseSysCtl()
// CPU Info
len = sizeof(this->NumberOfPhysicalCPU);
- sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len,
- KWSYS_NULLPTR, 0);
+ sysctlbyname("hw.physicalcpu", &this->NumberOfPhysicalCPU, &len, nullptr, 0);
len = sizeof(this->NumberOfLogicalCPU);
- sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, KWSYS_NULLPTR,
- 0);
+ sysctlbyname("hw.logicalcpu", &this->NumberOfLogicalCPU, &len, nullptr, 0);
int cores_per_package = 0;
len = sizeof(cores_per_package);
err = sysctlbyname("machdep.cpu.cores_per_package", &cores_per_package, &len,
- KWSYS_NULLPTR, 0);
+ nullptr, 0);
// That name was not found, default to 1
this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical =
err != 0 ? 1 : static_cast<unsigned char>(cores_per_package);
len = sizeof(value);
- sysctlbyname("hw.cpufrequency", &value, &len, KWSYS_NULLPTR, 0);
+ sysctlbyname("hw.cpufrequency", &value, &len, nullptr, 0);
this->CPUSpeedInMHz = static_cast<float>(value) / 1000000;
// Chip family
len = sizeof(this->ChipID.Family);
// Seems only the intel chips will have this name so if this fails it is
// probably a PPC machine
- err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
- KWSYS_NULLPTR, 0);
+ err =
+ sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len, nullptr, 0);
if (err != 0) // Go back to names we know but are less descriptive
{
this->ChipID.Family = 0;
::memset(retBuf, 0, 128);
len = 32;
- err = sysctlbyname("hw.machine", &retBuf, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("hw.machine", &retBuf, &len, nullptr, 0);
std::string machineBuf(retBuf);
if (machineBuf.find_first_of("Power") != std::string::npos) {
this->ChipID.Vendor = "IBM";
len = sizeof(this->ChipID.Family);
- err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len,
- KWSYS_NULLPTR, 0);
+ err = sysctlbyname("hw.cputype", &this->ChipID.Family, &len, nullptr, 0);
len = sizeof(this->ChipID.Model);
- err = sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len,
- KWSYS_NULLPTR, 0);
+ err =
+ sysctlbyname("hw.cpusubtype", &this->ChipID.Model, &len, nullptr, 0);
this->FindManufacturer();
}
} else // Should be an Intel Chip.
{
len = sizeof(this->ChipID.Family);
err = sysctlbyname("machdep.cpu.family", &this->ChipID.Family, &len,
- KWSYS_NULLPTR, 0);
+ nullptr, 0);
::memset(retBuf, 0, 128);
len = 128;
- err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("machdep.cpu.vendor", retBuf, &len, nullptr, 0);
// Chip Vendor
this->ChipID.Vendor = retBuf;
this->FindManufacturer();
// Chip Model
len = sizeof(value);
- err = sysctlbyname("machdep.cpu.model", &value, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("machdep.cpu.model", &value, &len, nullptr, 0);
this->ChipID.Model = static_cast<int>(value);
// Chip Stepping
len = sizeof(value);
value = 0;
- err = sysctlbyname("machdep.cpu.stepping", &value, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("machdep.cpu.stepping", &value, &len, nullptr, 0);
if (!err) {
this->ChipID.Revision = static_cast<int>(value);
}
// feature string
- char* buf = KWSYS_NULLPTR;
+ char* buf = nullptr;
size_t allocSize = 128;
err = 0;
@@ -4592,8 +4570,7 @@ bool SystemInformationImplementation::ParseSysCtl()
}
buf[0] = ' ';
len = allocSize - 2; // keep space for leading and trailing space
- err =
- sysctlbyname("machdep.cpu.features", buf + 1, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("machdep.cpu.features", buf + 1, &len, nullptr, 0);
}
if (!err && buf && len) {
// now we can match every flags as space + flag + space
@@ -4634,8 +4611,7 @@ bool SystemInformationImplementation::ParseSysCtl()
// brand string
::memset(retBuf, 0, sizeof(retBuf));
len = sizeof(retBuf);
- err =
- sysctlbyname("machdep.cpu.brand_string", retBuf, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("machdep.cpu.brand_string", retBuf, &len, nullptr, 0);
if (!err) {
this->ChipID.ProcessorName = retBuf;
this->ChipID.ModelName = retBuf;
@@ -4643,10 +4619,10 @@ bool SystemInformationImplementation::ParseSysCtl()
// Cache size
len = sizeof(value);
- err = sysctlbyname("hw.l1icachesize", &value, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("hw.l1icachesize", &value, &len, nullptr, 0);
this->Features.L1CacheSize = static_cast<int>(value);
len = sizeof(value);
- err = sysctlbyname("hw.l2cachesize", &value, &len, KWSYS_NULLPTR, 0);
+ err = sysctlbyname("hw.l2cachesize", &value, &len, nullptr, 0);
this->Features.L2CacheSize = static_cast<int>(value);
return true;
@@ -4683,7 +4659,7 @@ std::string SystemInformationImplementation::RunProcess(
kwsysProcess_Execute(gp);
- char* data = KWSYS_NULLPTR;
+ char* data = nullptr;
int length;
double timeout = 255;
int pipe; // pipe id as returned by kwsysProcess_WaitForData()
@@ -4695,7 +4671,7 @@ std::string SystemInformationImplementation::RunProcess(
{
buffer.append(data, length);
}
- kwsysProcess_WaitForExit(gp, KWSYS_NULLPTR);
+ kwsysProcess_WaitForExit(gp, nullptr);
int result = 0;
switch (kwsysProcess_GetState(gp)) {
@@ -4766,7 +4742,7 @@ std::string SystemInformationImplementation::ParseValueFromKStat(
for (size_t i = 0; i < args_string.size(); ++i) {
args.push_back(args_string[i].c_str());
}
- args.push_back(KWSYS_NULLPTR);
+ args.push_back(nullptr);
std::string buffer = this->RunProcess(args);
@@ -4965,7 +4941,7 @@ bool SystemInformationImplementation::QueryBSDMemory()
# endif
size_t sz = sizeof(k);
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@@ -5036,7 +5012,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
size_t sz = sizeof(k);
int ctrl[2] = { CTL_HW, HW_NCPU };
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@@ -5046,7 +5022,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
# if defined(HW_CPUSPEED)
ctrl[1] = HW_CPUSPEED;
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@@ -5057,7 +5033,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE;
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@@ -5068,7 +5044,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
ctrl[0] = CTL_MACHDEP;
ctrl[1] = CPU_SSE2;
- if (sysctl(ctrl, 2, &k, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, &k, &sz, nullptr, 0) != 0) {
return false;
}
@@ -5081,7 +5057,7 @@ bool SystemInformationImplementation::QueryBSDProcessor()
char vbuf[25];
::memset(vbuf, 0, sizeof(vbuf));
sz = sizeof(vbuf) - 1;
- if (sysctl(ctrl, 2, vbuf, &sz, NULL, 0) != 0) {
+ if (sysctl(ctrl, 2, vbuf, &sz, nullptr, 0) != 0) {
return false;
}
@@ -5293,7 +5269,7 @@ bool SystemInformationImplementation::QueryOSInformation()
RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SYSTEM\\CurrentControlSet\\Control\\ProductOptions", 0,
KEY_QUERY_VALUE, &hKey);
- RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
+ RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr,
(LPBYTE)szProductType, &dwBufLen);
RegCloseKey(hKey);
@@ -5335,13 +5311,13 @@ bool SystemInformationImplementation::QueryOSInformation()
// Load the Kernel32 DLL.
hKernelDLL = LoadLibraryW(L"kernel32");
- if (hKernelDLL != NULL) {
+ if (hKernelDLL != nullptr) {
// Only XP and .NET Server support IsWOW64Process so... Load
// dynamically!
DLLProc = (LPFNPROC)GetProcAddress(hKernelDLL, "IsWow64Process");
// If the function address is valid, call the function.
- if (DLLProc != NULL)
+ if (DLLProc != nullptr)
(DLLProc)(GetCurrentProcess(), &bIsWindows64Bit);
else
bIsWindows64Bit = false;
@@ -5456,7 +5432,7 @@ int SystemInformationImplementation::CallSwVers(const char* arg,
std::vector<const char*> args;
args.push_back("sw_vers");
args.push_back(arg);
- args.push_back(KWSYS_NULLPTR);
+ args.push_back(nullptr);
ver = this->RunProcess(args);
this->TrimNewline(ver);
#else
diff --git a/Source/kwsys/SystemInformation.hxx.in b/Source/kwsys/SystemInformation.hxx.in
index 5e93878..fc42e9d 100644
--- a/Source/kwsys/SystemInformation.hxx.in
+++ b/Source/kwsys/SystemInformation.hxx.in
@@ -115,8 +115,8 @@ public:
// returns an informative general description if the installed and
// available ram on this system. See the GetHostMemoryTotal, and
// Get{Host,Proc}MemoryAvailable methods for more information.
- std::string GetMemoryDescription(const char* hostLimitEnvVarName = NULL,
- const char* procLimitEnvVarName = NULL);
+ std::string GetMemoryDescription(const char* hostLimitEnvVarName = nullptr,
+ const char* procLimitEnvVarName = nullptr);
// Retrieve amount of physical memory installed on the system in KiB
// units.
@@ -128,7 +128,7 @@ public:
// parallel. The amount of memory reported may differ from the host
// total if a host wide resource limit is applied. Such reource limits
// are reported to us via an application specified environment variable.
- LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = NULL);
+ LongLong GetHostMemoryAvailable(const char* hostLimitEnvVarName = nullptr);
// Get total system RAM in units of KiB available to this process.
// This may differ from the host available if a per-process resource
@@ -136,8 +136,8 @@ public:
// system via rlimit API. Resource limits that are not imposed via
// rlimit API may be reported to us via an application specified
// environment variable.
- LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = NULL,
- const char* procLimitEnvVarName = NULL);
+ LongLong GetProcMemoryAvailable(const char* hostLimitEnvVarName = nullptr,
+ const char* procLimitEnvVarName = nullptr);
// Get the system RAM used by all processes on the host, in units of KiB.
LongLong GetHostMemoryUsed();
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 8571477..ce4d6ef 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -192,15 +192,15 @@ static inline char* realpath(const char* path, char* resolved_path)
{
const size_t maxlen = KWSYS_SYSTEMTOOLS_MAXPATH;
snprintf(resolved_path, maxlen, "%s", path);
- BPath normalized(resolved_path, NULL, true);
+ BPath normalized(resolved_path, nullptr, true);
const char* resolved = normalized.Path();
- if (resolved != NULL) // NULL == No such file.
+ if (resolved != nullptr) // nullptr == No such file.
{
if (snprintf(resolved_path, maxlen, "%s", resolved) < maxlen) {
return resolved_path;
}
}
- return NULL; // something went wrong.
+ return nullptr; // something went wrong.
}
#endif
@@ -273,12 +273,12 @@ inline void Realpath(const std::string& path, std::string& resolved_path,
if (bufferLen) {
*errorMessage = "Destination path buffer size too small.";
} else if (unsigned int errorId = GetLastError()) {
- LPSTR message = NULL;
+ LPSTR message = nullptr;
DWORD size = FormatMessageA(
FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPSTR)&message, 0, NULL);
+ nullptr, errorId, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ (LPSTR)&message, 0, nullptr);
*errorMessage = std::string(message, size);
LocalFree(message);
} else {
@@ -313,7 +313,7 @@ inline int Chdir(const std::string& dir)
return chdir(dir.c_str());
}
inline void Realpath(const std::string& path, std::string& resolved_path,
- std::string* errorMessage = KWSYS_NULLPTR)
+ std::string* errorMessage = nullptr)
{
char resolved_name[KWSYS_SYSTEMTOOLS_MAXPATH];
@@ -359,7 +359,7 @@ double SystemTools::GetTime(void)
11644473600.0);
#else
struct timeval t;
- gettimeofday(&t, KWSYS_NULLPTR);
+ gettimeofday(&t, nullptr);
return 1.0 * double(t.tv_sec) + 0.000001 * double(t.tv_usec);
#endif
}
@@ -389,8 +389,8 @@ struct kwsysEnvCompare
#else
const char* leq = strchr(l, '=');
const char* req = strchr(r, '=');
- size_t llen = leq ? (leq - l) : strlen(l);
- size_t rlen = req ? (req - r) : strlen(r);
+ size_t llen = leq ? static_cast<size_t>(leq - l) : strlen(l);
+ size_t rlen = req ? static_cast<size_t>(req - r) : strlen(r);
if (llen == rlen) {
return strncmp(l, r, llen) < 0;
} else {
@@ -420,7 +420,7 @@ public:
const envchar* Release(const envchar* env)
{
- const envchar* old = KWSYS_NULLPTR;
+ const envchar* old = nullptr;
iterator i = this->find(env);
if (i != this->end()) {
old = *i;
@@ -630,7 +630,7 @@ const char* SystemToolsStatic::GetEnvBuffered(const char* key)
}
return menv.c_str();
}
- return KWSYS_NULLPTR;
+ return nullptr;
}
#endif
@@ -684,7 +684,7 @@ bool SystemTools::HasEnv(const char* key)
#else
const char* v = getenv(key);
#endif
- return v != KWSYS_NULLPTR;
+ return v != nullptr;
}
bool SystemTools::HasEnv(const std::string& key)
@@ -915,7 +915,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
while ((pos = dir.find('/', pos)) != std::string::npos) {
topdir = dir.substr(0, pos);
- if (Mkdir(topdir) == 0 && mode != KWSYS_NULLPTR) {
+ if (Mkdir(topdir) == 0 && mode != nullptr) {
SystemTools::SetPermissions(topdir, *mode);
}
@@ -934,7 +934,7 @@ bool SystemTools::MakeDirectory(const std::string& path, const mode_t* mode)
) {
return false;
}
- } else if (mode != KWSYS_NULLPTR) {
+ } else if (mode != nullptr) {
SystemTools::SetPermissions(topdir, *mode);
}
@@ -1055,7 +1055,7 @@ static DWORD SystemToolsMakeRegistryMode(DWORD mode,
// only add the modes when on a system that supports Wow64.
static FARPROC wow64p =
GetProcAddress(GetModuleHandleW(L"kernel32"), "IsWow64Process");
- if (wow64p == NULL) {
+ if (wow64p == nullptr) {
return mode;
}
@@ -1136,7 +1136,7 @@ bool SystemTools::ReadRegistryValue(const std::string& key, std::string& value,
DWORD dwType, dwSize;
dwSize = 1023;
wchar_t data[1024];
- if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), NULL,
+ if (RegQueryValueExW(hKey, Encoding::ToWide(valuename).c_str(), nullptr,
&dwType, (BYTE*)data, &dwSize) == ERROR_SUCCESS) {
if (dwType == REG_SZ) {
value = Encoding::ToNarrow(data);
@@ -1186,7 +1186,7 @@ bool SystemTools::WriteRegistryValue(const std::string& key,
wchar_t lpClass[] = L"";
if (RegCreateKeyExW(primaryKey, Encoding::ToWide(second).c_str(), 0, lpClass,
REG_OPTION_NON_VOLATILE,
- SystemToolsMakeRegistryMode(KEY_WRITE, view), NULL,
+ SystemToolsMakeRegistryMode(KEY_WRITE, view), nullptr,
&hKey, &dwDummy) != ERROR_SUCCESS) {
return false;
}
@@ -1252,10 +1252,10 @@ bool SystemTools::SameFile(const std::string& file1, const std::string& file2)
hFile1 =
CreateFileW(Encoding::ToWide(file1).c_str(), GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
hFile2 =
CreateFileW(Encoding::ToWide(file2).c_str(), GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile1 == INVALID_HANDLE_VALUE || hFile2 == INVALID_HANDLE_VALUE) {
if (hFile1 != INVALID_HANDLE_VALUE) {
CloseHandle(hFile1);
@@ -1347,7 +1347,7 @@ bool SystemTools::FileExists(const std::string& filename)
// even if we do not have permission to read the file itself
HANDLE handle =
CreateFileW(Encoding::ToWindowsExtendedPath(filename).c_str(), 0, 0,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (handle == INVALID_HANDLE_VALUE) {
return false;
@@ -1493,12 +1493,12 @@ bool SystemTools::Touch(const std::string& filename, bool create)
CloseHandle(h);
#elif KWSYS_CXX_HAS_UTIMENSAT
// utimensat is only available on newer Unixes and macOS 10.13+
- if (utimensat(AT_FDCWD, filename.c_str(), NULL, 0) < 0) {
+ if (utimensat(AT_FDCWD, filename.c_str(), nullptr, 0) < 0) {
return false;
}
#else
// fall back to utimes
- if (utimes(filename.c_str(), NULL) < 0) {
+ if (utimes(filename.c_str(), nullptr) < 0) {
return false;
}
#endif
@@ -1653,7 +1653,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2)
size_t len1 = strlen(str1);
char* newstr = new char[len1 + strlen(str2) + 1];
if (!newstr) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
strcpy(newstr, str1);
strcat(newstr + len1, str2);
@@ -1676,7 +1676,7 @@ char* SystemTools::AppendStrings(const char* str1, const char* str2,
size_t len1 = strlen(str1), len2 = strlen(str2);
char* newstr = new char[len1 + len2 + strlen(str3) + 1];
if (!newstr) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
strcpy(newstr, str1);
strcat(newstr + len1, str2);
@@ -1726,7 +1726,7 @@ size_t SystemTools::CountChar(const char* str, char c)
char* SystemTools::RemoveChars(const char* str, const char* toremove)
{
if (!str) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
char* clean_str = new char[strlen(str) + 1];
char* ptr = clean_str;
@@ -1748,7 +1748,7 @@ char* SystemTools::RemoveChars(const char* str, const char* toremove)
char* SystemTools::RemoveCharsButUpperHex(const char* str)
{
if (!str) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
char* clean_str = new char[strlen(str) + 1];
char* ptr = clean_str;
@@ -1829,7 +1829,7 @@ bool SystemTools::StringEndsWith(const std::string& str1, const char* str2)
const char* SystemTools::FindLastString(const char* str1, const char* str2)
{
if (!str1 || !str2) {
- return KWSYS_NULLPTR;
+ return nullptr;
}
size_t len1 = strlen(str1), len2 = strlen(str2);
@@ -1842,7 +1842,7 @@ const char* SystemTools::FindLastString(const char* str1, const char* str2)
} while (ptr-- != str1);
}
- return KWSYS_NULLPTR;
+ return nullptr;
}
// Duplicate string
@@ -1852,7 +1852,7 @@ char* SystemTools::DuplicateString(const char* str)
char* newstr = new char[strlen(str) + 1];
return strcpy(newstr, str);
}
- return KWSYS_NULLPTR;
+ return nullptr;
}
// Return a cropped string
@@ -3018,16 +3018,16 @@ bool SystemTools::FileIsSymlink(const std::string& name)
// * a file or directory that has an associated reparse point, or
// * a file that is a symbolic link.
HANDLE hFile = CreateFileW(
- path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
- FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ path.c_str(), GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING,
+ FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
byte buffer[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
DWORD bytesReturned = 0;
- if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, NULL, 0, buffer,
+ if (!DeviceIoControl(hFile, FSCTL_GET_REPARSE_POINT, nullptr, 0, buffer,
MAXIMUM_REPARSE_DATA_BUFFER_SIZE, &bytesReturned,
- NULL)) {
+ nullptr)) {
CloseHandle(hFile);
// Since FILE_ATTRIBUTE_REPARSE_POINT is set this file must be
// a symbolic link if it is not a reparse point.
@@ -3058,7 +3058,7 @@ bool SystemTools::FileIsFIFO(const std::string& name)
#if defined(_WIN32)
HANDLE hFile =
CreateFileW(Encoding::ToWide(name).c_str(), GENERIC_READ, FILE_SHARE_READ,
- NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
+ nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, nullptr);
if (hFile == INVALID_HANDLE_VALUE) {
return false;
}
@@ -3219,7 +3219,7 @@ bool SystemTools::FindProgramPath(const char* argv0, std::string& pathOut,
std::string SystemTools::CollapseFullPath(const std::string& in_relative)
{
- return SystemTools::CollapseFullPath(in_relative, KWSYS_NULLPTR);
+ return SystemTools::CollapseFullPath(in_relative, nullptr);
}
#if KWSYS_SYSTEMTOOLS_USE_TRANSLATION_MAP
@@ -4013,7 +4013,7 @@ bool SystemTools::GetShortPath(const std::string& path, std::string& shortPath)
}
std::wstring wtempPath = Encoding::ToWide(tempPath);
- DWORD ret = GetShortPathNameW(wtempPath.c_str(), NULL, 0);
+ DWORD ret = GetShortPathNameW(wtempPath.c_str(), nullptr, 0);
std::vector<wchar_t> buffer(ret);
if (ret != 0) {
ret = GetShortPathNameW(wtempPath.c_str(), &buffer[0],
@@ -4421,7 +4421,7 @@ std::string SystemTools::GetOperatingSystemNameAndVersion()
return 0;
}
- lRet = RegQueryValueExW(hKey, L"ProductType", NULL, NULL,
+ lRet = RegQueryValueExW(hKey, L"ProductType", nullptr, nullptr,
(LPBYTE)szProductType, &dwBufLen);
if ((lRet != ERROR_SUCCESS) || (dwBufLen > BUFSIZE)) {
diff --git a/Source/kwsys/SystemTools.hxx.in b/Source/kwsys/SystemTools.hxx.in
index dd1266b..c4ab9d4 100644
--- a/Source/kwsys/SystemTools.hxx.in
+++ b/Source/kwsys/SystemTools.hxx.in
@@ -400,9 +400,10 @@ public:
* installPrefix is a possibly null pointer to the install directory.
*/
static bool FindProgramPath(const char* argv0, std::string& pathOut,
- std::string& errorMsg, const char* exeName = 0,
- const char* buildDir = 0,
- const char* installPrefix = 0);
+ std::string& errorMsg,
+ const char* exeName = nullptr,
+ const char* buildDir = nullptr,
+ const char* installPrefix = nullptr);
/**
* Given a path to a file or directory, convert it to a full path.
@@ -420,11 +421,11 @@ public:
* Get the real path for a given path, removing all symlinks. In
* the event of an error (non-existent path, permissions issue,
* etc.) the original path is returned if errorMessage pointer is
- * NULL. Otherwise empty string is returned and errorMessage
+ * nullptr. Otherwise empty string is returned and errorMessage
* contains error description.
*/
static std::string GetRealPath(const std::string& path,
- std::string* errorMessage = 0);
+ std::string* errorMessage = nullptr);
/**
* Split a path name into its root component and the rest of the
@@ -442,7 +443,7 @@ public:
* given.
*/
static const char* SplitPathRootComponent(const std::string& p,
- std::string* root = 0);
+ std::string* root = nullptr);
/**
* Split a path name into its basic components. The first component
@@ -528,7 +529,8 @@ public:
* be true when the line read had a newline character.
*/
static bool GetLineFromStream(std::istream& istr, std::string& line,
- bool* has_newline = 0, long sizeLimit = -1);
+ bool* has_newline = nullptr,
+ long sizeLimit = -1);
/**
* Get the parent directory of the directory or file
@@ -563,8 +565,9 @@ public:
* can make a full path even if none of the directories existed
* prior to calling this function.
*/
- static bool MakeDirectory(const char* path, const mode_t* mode = 0);
- static bool MakeDirectory(const std::string& path, const mode_t* mode = 0);
+ static bool MakeDirectory(const char* path, const mode_t* mode = nullptr);
+ static bool MakeDirectory(const std::string& path,
+ const mode_t* mode = nullptr);
/**
* Copy the source file to the destination file only
@@ -842,7 +845,8 @@ public:
* string vector passed in. If env is set then the value
* of env will be used instead of PATH.
*/
- static void GetPath(std::vector<std::string>& path, const char* env = 0);
+ static void GetPath(std::vector<std::string>& path,
+ const char* env = nullptr);
/**
* Read an environment variable
diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in
index 0981c66..8c4b002 100644
--- a/Source/kwsys/hashtable.hxx.in
+++ b/Source/kwsys/hashtable.hxx.in
@@ -354,7 +354,7 @@ public:
return end();
}
- iterator end() { return iterator(0, this); }
+ iterator end() { return iterator(nullptr, this); }
const_iterator begin() const
{
@@ -364,7 +364,7 @@ public:
return end();
}
- const_iterator end() const { return const_iterator(0, this); }
+ const_iterator end() const { return const_iterator(nullptr, this); }
friend bool operator==<>(const hashtable&, const hashtable&);
@@ -510,7 +510,7 @@ private:
{
const size_type __n_buckets = _M_next_size(__n);
_M_buckets.reserve(__n_buckets);
- _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)0);
+ _M_buckets.insert(_M_buckets.end(), __n_buckets, (_Node*)nullptr);
_M_num_elements = 0;
}
@@ -544,7 +544,7 @@ private:
_Node* _M_new_node(const value_type& __obj)
{
_Node* __n = _M_get_node();
- __n->_M_next = 0;
+ __n->_M_next = nullptr;
try {
construct(&__n->_M_val, __obj);
return __n;
@@ -839,9 +839,9 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::erase(iterator __first,
else if (__f_bucket == __l_bucket)
_M_erase_bucket(__f_bucket, __first._M_cur, __last._M_cur);
else {
- _M_erase_bucket(__f_bucket, __first._M_cur, 0);
+ _M_erase_bucket(__f_bucket, __first._M_cur, nullptr);
for (size_type __n = __f_bucket + 1; __n < __l_bucket; ++__n)
- _M_erase_bucket(__n, 0);
+ _M_erase_bucket(__n, nullptr);
if (__l_bucket != _M_buckets.size())
_M_erase_bucket(__l_bucket, __last._M_cur);
}
@@ -873,7 +873,8 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::resize(
if (__num_elements_hint > __old_n) {
const size_type __n = _M_next_size(__num_elements_hint);
if (__n > __old_n) {
- _M_buckets_type __tmp(__n, (_Node*)(0), _M_buckets.get_allocator());
+ _M_buckets_type __tmp(__n, (_Node*)(nullptr),
+ _M_buckets.get_allocator());
try {
for (size_type __bucket = 0; __bucket < __old_n; ++__bucket) {
_Node* __first = _M_buckets[__bucket];
@@ -940,12 +941,12 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::clear()
{
for (size_type __i = 0; __i < _M_buckets.size(); ++__i) {
_Node* __cur = _M_buckets[__i];
- while (__cur != 0) {
+ while (__cur != nullptr) {
_Node* __next = __cur->_M_next;
_M_delete_node(__cur);
__cur = __next;
}
- _M_buckets[__i] = 0;
+ _M_buckets[__i] = nullptr;
}
_M_num_elements = 0;
}
@@ -956,7 +957,7 @@ void hashtable<_Val, _Key, _HF, _Ex, _Eq, _All>::_M_copy_from(
{
_M_buckets.clear();
_M_buckets.reserve(__ht._M_buckets.size());
- _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)0);
+ _M_buckets.insert(_M_buckets.end(), __ht._M_buckets.size(), (_Node*)nullptr);
try {
for (size_type __i = 0; __i < __ht._M_buckets.size(); ++__i) {
const _Node* __cur = __ht._M_buckets[__i];
diff --git a/Source/kwsys/testCommandLineArguments.cxx b/Source/kwsys/testCommandLineArguments.cxx
index 15f9c02..1778a9b 100644
--- a/Source/kwsys/testCommandLineArguments.cxx
+++ b/Source/kwsys/testCommandLineArguments.cxx
@@ -76,7 +76,7 @@ int testCommandLineArguments(int argc, char* argv[])
int some_int_variable = 10;
double some_double_variable = 10.10;
- char* some_string_variable = KWSYS_NULLPTR;
+ char* some_string_variable = nullptr;
std::string some_stl_string_variable;
bool some_bool_variable = false;
bool some_bool_variable1 = false;
@@ -203,7 +203,7 @@ int testCommandLineArguments(int argc, char* argv[])
for (cc = 0; cc < strings_argument.size(); ++cc) {
delete[] strings_argument[cc];
- strings_argument[cc] = KWSYS_NULLPTR;
+ strings_argument[cc] = nullptr;
}
return res;
}
diff --git a/Source/kwsys/testCommandLineArguments1.cxx b/Source/kwsys/testCommandLineArguments1.cxx
index 9895008..64561b1 100644
--- a/Source/kwsys/testCommandLineArguments1.cxx
+++ b/Source/kwsys/testCommandLineArguments1.cxx
@@ -21,7 +21,7 @@ int testCommandLineArguments1(int argc, char* argv[])
arg.Initialize(argc, argv);
int n = 0;
- char* m = KWSYS_NULLPTR;
+ char* m = nullptr;
std::string p;
int res = 0;
@@ -55,11 +55,11 @@ int testCommandLineArguments1(int argc, char* argv[])
delete[] m;
}
- char** newArgv = KWSYS_NULLPTR;
+ char** newArgv = nullptr;
int newArgc = 0;
arg.GetUnusedArguments(&newArgc, &newArgv);
int cc;
- const char* valid_unused_args[9] = { KWSYS_NULLPTR,
+ const char* valid_unused_args[9] = { nullptr,
"--ignored",
"--second-ignored",
"third-ignored",
diff --git a/Source/kwsys/testConsoleBuf.cxx b/Source/kwsys/testConsoleBuf.cxx
index b6ad118..4b7ddf0 100644
--- a/Source/kwsys/testConsoleBuf.cxx
+++ b/Source/kwsys/testConsoleBuf.cxx
@@ -51,7 +51,7 @@ static void displayError(DWORD errorCode)
LPWSTR message;
if (FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
- NULL, errorCode, 0, (LPWSTR)&message, 0, NULL)) {
+ nullptr, errorCode, 0, (LPWSTR)&message, 0, nullptr)) {
std::cerr << "Error message: " << kwsys::Encoding::ToNarrow(message)
<< std::endl;
HeapFree(GetProcessHeap(), 0, message);
@@ -124,7 +124,7 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
}
WCHAR cmd[MAX_PATH];
- if (GetModuleFileNameW(NULL, cmd, MAX_PATH) == 0) {
+ if (GetModuleFileNameW(nullptr, cmd, MAX_PATH) == 0) {
std::cerr << "GetModuleFileName failed!" << std::endl;
return false;
}
@@ -136,14 +136,14 @@ static bool createProcess(HANDLE hIn, HANDLE hOut, HANDLE hErr)
wcscat(cmd, L".exe");
bool success =
- CreateProcessW(NULL, // No module name (use command line)
+ CreateProcessW(nullptr, // No module name (use command line)
cmd, // Command line
- NULL, // Process handle not inheritable
- NULL, // Thread handle not inheritable
+ nullptr, // Process handle not inheritable
+ nullptr, // Thread handle not inheritable
bInheritHandles, // Set handle inheritance
dwCreationFlags,
- NULL, // Use parent's environment block
- NULL, // Use parent's starting directory
+ nullptr, // Use parent's environment block
+ nullptr, // Use parent's starting directory
&startupInfo, // Pointer to STARTUPINFO structure
&processInfo) !=
0; // Pointer to PROCESS_INFORMATION structure
@@ -174,7 +174,7 @@ static bool createPipe(PHANDLE readPipe, PHANDLE writePipe)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
return CreatePipe(readPipe, writePipe, &securityAttributes, 0) == 0 ? false
: true;
}
@@ -194,7 +194,7 @@ static HANDLE createFile(LPCWSTR fileName)
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
HANDLE file =
CreateFileW(fileName, GENERIC_READ | GENERIC_WRITE,
@@ -202,7 +202,7 @@ static HANDLE createFile(LPCWSTR fileName)
&securityAttributes,
CREATE_ALWAYS, // overwrite existing
FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_DELETE_ON_CLOSE,
- NULL); // no template
+ nullptr); // no template
if (file == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(" << kwsys::Encoding::ToNarrow(fileName) << ")"
@@ -288,7 +288,7 @@ static int testPipe()
DWORD bytesWritten = 0;
if (!WriteFile(inPipeWrite, encodedInputTestString.c_str(),
(DWORD)encodedInputTestString.size(), &bytesWritten,
- NULL) ||
+ nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@@ -305,7 +305,8 @@ static int testPipe()
throw std::runtime_error("WaitForSingleObject failed!");
}
DWORD bytesRead = 0;
- if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead, NULL) ||
+ if (!ReadFile(outPipeRead, buffer, sizeof(buffer), &bytesRead,
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@@ -313,7 +314,7 @@ static int testPipe()
if ((bytesRead <
encodedTestString.size() + 1 + encodedInputTestString.size() &&
!ReadFile(outPipeRead, buffer + bytesRead,
- sizeof(buffer) - bytesRead, &bytesRead, NULL)) ||
+ sizeof(buffer) - bytesRead, &bytesRead, nullptr)) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@@ -324,7 +325,7 @@ static int testPipe()
encodedInputTestString.size()) == 0) {
bytesRead = 0;
if (!ReadFile(errPipeRead, buffer2, sizeof(buffer2), &bytesRead,
- NULL) ||
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#3 failed!");
}
@@ -383,13 +384,13 @@ static int testFile()
char buffer2[200];
int length;
- if ((length =
- WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString, -1,
- buffer, sizeof(buffer), NULL, NULL)) == 0) {
+ if ((length = WideCharToMultiByte(TestCodepage, 0, UnicodeInputTestString,
+ -1, buffer, sizeof(buffer), nullptr,
+ nullptr)) == 0) {
throw std::runtime_error("WideCharToMultiByte failed!");
}
buffer[length - 1] = '\n';
- if (!WriteFile(inFile, buffer, length, &bytesWritten, NULL) ||
+ if (!WriteFile(inFile, buffer, length, &bytesWritten, nullptr) ||
bytesWritten == 0) {
throw std::runtime_error("WriteFile failed!");
}
@@ -413,7 +414,7 @@ static int testFile()
INVALID_SET_FILE_POINTER) {
throw std::runtime_error("SetFilePointer#1 failed!");
}
- if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, NULL) ||
+ if (!ReadFile(outFile, buffer, sizeof(buffer), &bytesRead, nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#1 failed!");
}
@@ -429,7 +430,8 @@ static int testFile()
throw std::runtime_error("SetFilePointer#2 failed!");
}
- if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead, NULL) ||
+ if (!ReadFile(errFile, buffer2, sizeof(buffer2), &bytesRead,
+ nullptr) ||
bytesRead == 0) {
throw std::runtime_error("ReadFile#2 failed!");
}
@@ -519,12 +521,12 @@ static int testConsole()
if (RegOpenKeyExW(HKEY_CURRENT_USER, L"Console", 0, KEY_READ | KEY_WRITE,
&hConsoleKey) == ERROR_SUCCESS) {
DWORD dwordSize = sizeof(DWORD);
- if (RegQueryValueExW(hConsoleKey, L"FontFamily", NULL, NULL,
+ if (RegQueryValueExW(hConsoleKey, L"FontFamily", nullptr, nullptr,
(LPBYTE)&FontFamily, &dwordSize) == ERROR_SUCCESS) {
if (FontFamily != TestFontFamily) {
- RegQueryValueExW(hConsoleKey, L"FaceName", NULL, NULL,
+ RegQueryValueExW(hConsoleKey, L"FaceName", nullptr, nullptr,
(LPBYTE)FaceName, &FaceNameSize);
- RegQueryValueExW(hConsoleKey, L"FontSize", NULL, NULL,
+ RegQueryValueExW(hConsoleKey, L"FontSize", nullptr, nullptr,
(LPBYTE)&FontSize, &dwordSize);
RegSetValueExW(hConsoleKey, L"FontFamily", 0, REG_DWORD,
@@ -557,10 +559,10 @@ static int testConsole()
SECURITY_ATTRIBUTES securityAttributes;
securityAttributes.nLength = sizeof(SECURITY_ATTRIBUTES);
securityAttributes.bInheritHandle = TRUE;
- securityAttributes.lpSecurityDescriptor = NULL;
+ securityAttributes.lpSecurityDescriptor = nullptr;
hIn = CreateFileW(L"CONIN$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- OPEN_EXISTING, 0, NULL);
+ OPEN_EXISTING, 0, nullptr);
if (hIn == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONIN$)" << std::endl;
@@ -568,7 +570,7 @@ static int testConsole()
}
hOut = CreateFileW(L"CONOUT$", GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, &securityAttributes,
- OPEN_EXISTING, 0, NULL);
+ OPEN_EXISTING, 0, nullptr);
if (hOut == INVALID_HANDLE_VALUE) {
DWORD lastError = GetLastError();
std::cerr << "CreateFile(CONOUT$)" << std::endl;
@@ -630,7 +632,7 @@ static int testConsole()
}
# endif
- if (createProcess(NULL, NULL, NULL)) {
+ if (createProcess(nullptr, nullptr, nullptr)) {
try {
DWORD status;
if ((status = WaitForSingleObject(beforeInputEvent, waitTimeout)) !=
@@ -746,7 +748,7 @@ int testConsoleBuf(int, char* [])
int ret = 0;
#if defined(_WIN32)
- beforeInputEvent = CreateEventW(NULL,
+ beforeInputEvent = CreateEventW(nullptr,
FALSE, // auto-reset event
FALSE, // initial state is nonsignaled
BeforeInputEventName); // object name
@@ -755,7 +757,7 @@ int testConsoleBuf(int, char* [])
return 1;
}
- afterOutputEvent = CreateEventW(NULL, FALSE, FALSE, AfterOutputEventName);
+ afterOutputEvent = CreateEventW(nullptr, FALSE, FALSE, AfterOutputEventName);
if (!afterOutputEvent) {
std::cerr << "CreateEvent#2 failed " << GetLastError() << std::endl;
return 1;
diff --git a/Source/kwsys/testDynamicLoader.cxx b/Source/kwsys/testDynamicLoader.cxx
index eff2ed7..2421ac0 100644
--- a/Source/kwsys/testDynamicLoader.cxx
+++ b/Source/kwsys/testDynamicLoader.cxx
@@ -21,7 +21,7 @@
// left on disk.
#include <testSystemTools.h>
-static std::string GetLibName(const char* lname, const char* subdir = NULL)
+static std::string GetLibName(const char* lname, const char* subdir = nullptr)
{
// Construct proper name of lib
std::string slname;
diff --git a/Source/kwsys/testEncoding.cxx b/Source/kwsys/testEncoding.cxx
index fdad1cd..988697b 100644
--- a/Source/kwsys/testEncoding.cxx
+++ b/Source/kwsys/testEncoding.cxx
@@ -84,7 +84,7 @@ static int testRobustEncoding()
// this conversion could fail
std::wstring wstr = kwsys::Encoding::ToWide(cstr);
- wstr = kwsys::Encoding::ToWide(KWSYS_NULLPTR);
+ wstr = kwsys::Encoding::ToWide(nullptr);
if (wstr != L"") {
const wchar_t* wcstr = wstr.c_str();
std::cout << "ToWide(NULL) returned";
@@ -112,7 +112,7 @@ static int testRobustEncoding()
std::string win_str = kwsys::Encoding::ToNarrow(cwstr);
#endif
- std::string str = kwsys::Encoding::ToNarrow(KWSYS_NULLPTR);
+ std::string str = kwsys::Encoding::ToNarrow(nullptr);
if (str != "") {
std::cout << "ToNarrow(NULL) returned " << str << std::endl;
ret++;
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index f139f58..39aaa23 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -477,7 +477,7 @@ static int runChild2(kwsysProcess* kp, const char* cmd[], int state,
printf("Error in administrating child process: [%s]\n",
kwsysProcess_GetErrorString(kp));
break;
- };
+ }
if (result) {
if (exception != kwsysProcess_GetExitException(kp)) {
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index 88277de..1f3a15b 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -52,7 +52,7 @@ static const char* toUnixPaths[][2] = {
{ "\\\\usr\\local\\bin\\passwd", "//usr/local/bin/passwd" },
{ "\\\\usr\\lo cal\\bin\\pa sswd", "//usr/lo cal/bin/pa sswd" },
{ "\\\\usr\\lo\\ cal\\bin\\pa\\ sswd", "//usr/lo/ cal/bin/pa/ sswd" },
- { KWSYS_NULLPTR, KWSYS_NULLPTR }
+ { nullptr, nullptr }
};
static bool CheckConvertToUnixSlashes(std::string const& input,
@@ -71,7 +71,7 @@ static bool CheckConvertToUnixSlashes(std::string const& input,
static const char* checkEscapeChars[][4] = {
{ "1 foo 2 bar 2", "12", "\\", "\\1 foo \\2 bar \\2" },
{ " {} ", "{}", "#", " #{#} " },
- { KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR, KWSYS_NULLPTR }
+ { nullptr, nullptr, nullptr, nullptr }
};
static bool CheckEscapeChars(std::string const& input,
@@ -160,7 +160,7 @@ static bool CheckFileOperations()
res = false;
}
// calling with 0 pointer should return false
- if (kwsys::SystemTools::MakeDirectory(KWSYS_NULLPTR)) {
+ if (kwsys::SystemTools::MakeDirectory(nullptr)) {
std::cerr << "Problem with MakeDirectory(0)" << std::endl;
res = false;
}
@@ -218,11 +218,11 @@ static bool CheckFileOperations()
}
// calling with 0 pointer should return false
- if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR)) {
+ if (kwsys::SystemTools::FileExists(nullptr)) {
std::cerr << "Problem with FileExists(0)" << std::endl;
res = false;
}
- if (kwsys::SystemTools::FileExists(KWSYS_NULLPTR, true)) {
+ if (kwsys::SystemTools::FileExists(nullptr, true)) {
std::cerr << "Problem with FileExists(0) as file" << std::endl;
res = false;
}
diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in
index c58ef71..ad8bfb0 100644
--- a/Templates/TestDriver.cxx.in
+++ b/Templates/TestDriver.cxx.in
@@ -13,9 +13,15 @@
@CMAKE_FORWARD_DECLARE_TESTS@
#ifdef __cplusplus
-#define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+# define CM_CAST(TYPE, EXPR) static_cast<TYPE>(EXPR)
+# if __cplusplus >= 201103L
+# define CM_NULL nullptr
+# else
+# define CM_NULL NULL
+# endif
#else
-#define CM_CAST(TYPE, EXPR) (TYPE)(EXPR)
+# define CM_CAST(TYPE, EXPR) (TYPE)(EXPR)
+# define CM_NULL NULL
#endif
/* Create map. */
@@ -29,7 +35,7 @@ typedef struct /* NOLINT */
static functionMapEntry cmakeGeneratedFunctionMapEntries[] = {
@CMAKE_FUNCTION_TABLE_ENTIRES@
- { NULL, NULL } /* NOLINT */
+ { CM_NULL, CM_NULL } /* NOLINT */
};
static const int NumTests = CM_CAST(int,
@@ -45,8 +51,8 @@ static char* lowercase(const char* string)
stringSize = CM_CAST(size_t, strlen(string) + 1);
new_string = CM_CAST(char*, malloc(sizeof(char) * stringSize));
- if (new_string == NULL) { /* NOLINT */
- return NULL; /* NOLINT */
+ if (new_string == CM_NULL) { /* NOLINT */
+ return CM_NULL; /* NOLINT */
}
strcpy(new_string, string);
for (p = new_string; *p != 0; ++p) {
@@ -86,7 +92,7 @@ int main(int ac, char* av[])
av++;
}
partial_match = 0;
- arg = NULL; /* NOLINT */
+ arg = CM_NULL; /* NOLINT */
/* If partial match is requested. */
if (testToRun == -1 && ac > 1) {
partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0;
@@ -100,7 +106,7 @@ int main(int ac, char* av[])
}
for (i = 0; i < NumTests && testToRun == -1; ++i) {
char *test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name);
- if (partial_match != 0 && strstr(test_name, arg) != NULL) { /* NOLINT */
+ if (partial_match != 0 && strstr(test_name, arg) != CM_NULL) { /* NOLINT */
testToRun = i;
ac -= 2;
av += 2;
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index c14107a..78ae7aa 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -1394,6 +1394,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
GIF
Git
GLEW
+ GnuTLS
GSL
GTK2
Iconv
diff --git a/Tests/FindGnuTLS/CMakeLists.txt b/Tests/FindGnuTLS/CMakeLists.txt
new file mode 100644
index 0000000..059ac7b
--- /dev/null
+++ b/Tests/FindGnuTLS/CMakeLists.txt
@@ -0,0 +1,10 @@
+add_test(NAME FindGnuTLS.Test COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindGnuTLS/Test"
+ "${CMake_BINARY_DIR}/Tests/FindGnuTLS/Test"
+ ${build_generator_args}
+ --build-project TestFindGnuTLS
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
diff --git a/Tests/FindGnuTLS/Test/CMakeLists.txt b/Tests/FindGnuTLS/Test/CMakeLists.txt
new file mode 100644
index 0000000..c5a9819
--- /dev/null
+++ b/Tests/FindGnuTLS/Test/CMakeLists.txt
@@ -0,0 +1,17 @@
+cmake_minimum_required(VERSION 3.4)
+project(TestFindGnuTLS C)
+include(CTest)
+
+find_package(GnuTLS REQUIRED)
+
+add_definitions(-DCMAKE_EXPECTED_GNUTLS_VERSION="${GNUTLS_VERSION}")
+
+add_executable(test_tgt main.c)
+target_link_libraries(test_tgt GnuTLS::GnuTLS)
+add_test(NAME test_tgt COMMAND test_tgt)
+
+add_executable(test_var main.c)
+target_include_directories(test_var PRIVATE ${GNUTLS_INCLUDE_DIRS})
+target_link_libraries(test_var PRIVATE ${GNUTLS_LIBRARIES})
+target_compile_definitions(test_var PRIVATE ${GNUTLS_DEFINITIONS})
+add_test(NAME test_var COMMAND test_var)
diff --git a/Tests/FindGnuTLS/Test/main.c b/Tests/FindGnuTLS/Test/main.c
new file mode 100644
index 0000000..122fb2d
--- /dev/null
+++ b/Tests/FindGnuTLS/Test/main.c
@@ -0,0 +1,22 @@
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <gnutls/gnutls.h>
+
+int main()
+{
+ // test the linker
+ gnutls_session_t session;
+ if (gnutls_init(&session, GNUTLS_CLIENT)) {
+ gnutls_deinit(session);
+ }
+
+ // check the version
+ char gnutls_version_string[16];
+ snprintf(gnutls_version_string, 16, "%i.%i.%i", GNUTLS_VERSION_MAJOR,
+ GNUTLS_VERSION_MINOR, GNUTLS_VERSION_PATCH);
+ assert(strcmp(gnutls_version_string, CMAKE_EXPECTED_GNUTLS_VERSION) == 0);
+
+ return 0;
+}
diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt
index 8e8fa07..729bba3 100644
--- a/Tests/Plugin/CMakeLists.txt
+++ b/Tests/Plugin/CMakeLists.txt
@@ -10,14 +10,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/plugin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${Plugin_BINARY_DIR}/lib/static)
-# We need the dynamic loader support from KWSys to load the plugin in
-# the executable.
-set(KWSYS_NAMESPACE kwsys)
-set(KWSYS_HEADER_ROOT ${Plugin_BINARY_DIR}/include)
-set(KWSYS_USE_DynamicLoader 1)
-set(KWSYS_ENCODING_DEFAULT_CODEPAGE CP_UTF8)
-add_subdirectory(${Plugin_SOURCE_DIR}/../../Source/kwsys src/kwsys)
-
# Configure the location of plugins.
configure_file(${Plugin_SOURCE_DIR}/src/example_exe.h.in
${Plugin_BINARY_DIR}/include/example_exe.h @ONLY)
@@ -36,14 +28,14 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
endif()
# Create an executable that exports an API for use by plugins.
-add_executable(example_exe src/example_exe.cxx)
+add_executable(example_exe src/example_exe.cxx src/DynamicLoader.cxx)
set_target_properties(example_exe PROPERTIES
ENABLE_EXPORTS 1
OUTPUT_NAME example
# Test placing exe import library in unique directory.
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/exe
)
-target_link_libraries(example_exe kwsys)
+target_link_libraries(example_exe ${CMAKE_DL_LIBS})
# Create a plugin that uses the API provided by the executable.
# This module "links" to the executable to use the symbols.
diff --git a/Tests/Plugin/include/DynamicLoader.hxx b/Tests/Plugin/include/DynamicLoader.hxx
new file mode 100644
index 0000000..20b37de
--- /dev/null
+++ b/Tests/Plugin/include/DynamicLoader.hxx
@@ -0,0 +1,49 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.
+ See https://cmake.org/licensing#kwsys for details. */
+#ifndef DynamicLoader_hxx
+#define DynamicLoader_hxx
+
+#include <string>
+
+#if defined(__hpux)
+# include <dl.h>
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
+#elif defined(__APPLE__)
+# include <AvailabilityMacros.h>
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+# include <mach-o/dyld.h>
+# endif
+#elif defined(__BEOS__)
+# include <be/kernel/image.h>
+#endif
+
+class DynamicLoader
+{
+public:
+#if defined(__hpux)
+ typedef shl_t LibraryHandle;
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+ typedef HMODULE LibraryHandle;
+#elif defined(__APPLE__)
+# if MAC_OS_X_VERSION_MAX_ALLOWED < 1030
+ typedef NSModule LibraryHandle;
+# else
+ typedef void* LibraryHandle;
+# endif
+#elif defined(__BEOS__)
+ typedef image_id LibraryHandle;
+#else // POSIX
+ typedef void* LibraryHandle;
+#endif
+
+ typedef void (*SymbolPointer)();
+
+ static LibraryHandle OpenLibrary(const std::string&);
+
+ static int CloseLibrary(LibraryHandle);
+
+ static SymbolPointer GetSymbolAddress(LibraryHandle, const std::string&);
+};
+
+#endif
diff --git a/Tests/Plugin/src/DynamicLoader.cxx b/Tests/Plugin/src/DynamicLoader.cxx
new file mode 100644
index 0000000..d4a2637
--- /dev/null
+++ b/Tests/Plugin/src/DynamicLoader.cxx
@@ -0,0 +1,263 @@
+/* Distributed under the OSI-approved BSD 3-Clause License.
+ See https://cmake.org/licensing#kwsys for details. */
+#if defined(_WIN32)
+# define NOMINMAX // hide min,max to not conflict with <limits>
+#endif
+
+#include <DynamicLoader.hxx>
+
+#if defined(__hpux)
+# include <dl.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ return shl_load(libname.c_str(), BIND_DEFERRED | DYNAMIC_PATH, 0L);
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (!lib) {
+ return 0;
+ }
+ return !shl_unload(lib);
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ void* addr;
+ int status;
+
+ /* TYPE_PROCEDURE Look for a function or procedure. (This used to be default)
+ * TYPE_DATA Look for a symbol in the data segment (for example,
+ * variables).
+ * TYPE_UNDEFINED Look for any symbol.
+ */
+ status = shl_findsym(&lib, sym.c_str(), TYPE_UNDEFINED, &addr);
+ void* result = (status < 0) ? (void*)0 : addr;
+
+ // Hack to cast pointer-to-data to pointer-to-function.
+ return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+}
+
+#elif defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED < 1030)
+# include <mach-o/dyld.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ NSObjectFileImageReturnCode rc;
+ NSObjectFileImage image = 0;
+
+ rc = NSCreateObjectFileImageFromFile(libname.c_str(), &image);
+ // rc == NSObjectFileImageInappropriateFile when trying to load a dylib file
+ if (rc != NSObjectFileImageSuccess) {
+ return 0;
+ }
+ NSModule handle = NSLinkModule(image, libname.c_str(),
+ NSLINKMODULE_OPTION_BINDNOW |
+ NSLINKMODULE_OPTION_RETURN_ON_ERROR);
+ NSDestroyObjectFileImage(image);
+ return handle;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ bool success = NSUnLinkModule(lib, NSUNLINKMODULE_OPTION_NONE);
+ return success;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ void* result = 0;
+ // Need to prepend symbols with '_' on Apple-gcc compilers
+ std::string rsym = '_' + sym;
+
+ NSSymbol symbol = NSLookupSymbolInModule(lib, rsym.c_str());
+ if (symbol) {
+ result = NSAddressOfSymbol(symbol);
+ }
+
+ // Hack to cast pointer-to-data to pointer-to-function.
+ return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+}
+
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+# include <windows.h>
+
+# include <stdio.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ DynamicLoader::LibraryHandle lh;
+ int length = MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, NULL, 0);
+ wchar_t* wchars = new wchar_t[length + 1];
+ wchars[0] = '\0';
+ MultiByteToWideChar(CP_UTF8, 0, libname.c_str(), -1, wchars, length);
+ lh = LoadLibraryW(wchars);
+ delete[] wchars;
+ return lh;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ return (int)FreeLibrary(lib);
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ void* result;
+# if defined(__BORLANDC__) || defined(__WATCOMC__)
+ // Need to prepend symbols with '_'
+ std::string ssym = '_' + sym;
+ const char* rsym = ssym.c_str();
+# else
+ const char* rsym = sym.c_str();
+# endif
+ result = (void*)GetProcAddress(lib, rsym);
+// Hack to cast pointer-to-data to pointer-to-function.
+# ifdef __WATCOMC__
+ return *(DynamicLoader::SymbolPointer*)(&result);
+# else
+ return *reinterpret_cast<DynamicLoader::SymbolPointer*>(&result);
+# endif
+}
+
+#elif defined(__BEOS__)
+# include <be/kernel/image.h>
+# include <be/support/Errors.h>
+
+static image_id last_dynamic_err = B_OK;
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ // image_id's are integers, errors are negative. Add one just in case we
+ // get a valid image_id of zero (is that even possible?).
+ image_id rc = load_add_on(libname.c_str());
+ if (rc < 0) {
+ last_dynamic_err = rc;
+ return 0;
+ }
+
+ return rc + 1;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (!lib) {
+ last_dynamic_err = B_BAD_VALUE;
+ return 0;
+ } else {
+ // The function dlclose() returns 0 on success, and non-zero on error.
+ status_t rc = unload_add_on(lib - 1);
+ if (rc != B_OK) {
+ last_dynamic_err = rc;
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+
+ result.psym = NULL;
+
+ if (!lib) {
+ last_dynamic_err = B_BAD_VALUE;
+ } else {
+ // !!! FIXME: BeOS can do function-only lookups...does this ever
+ // !!! FIXME: actually _want_ a data symbol lookup, or was this union
+ // !!! FIXME: a leftover of dlsym()? (s/ANY/TEXT for functions only).
+ status_t rc =
+ get_image_symbol(lib - 1, sym.c_str(), B_SYMBOL_TYPE_ANY, &result.pvoid);
+ if (rc != B_OK) {
+ last_dynamic_err = rc;
+ result.psym = NULL;
+ }
+ }
+ return result.psym;
+}
+
+#elif defined(__MINT__)
+# define _GNU_SOURCE /* for program_invocation_name */
+# include <dld.h>
+# include <errno.h>
+# include <malloc.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ char* name = (char*)calloc(1, libname.size() + 1);
+ dld_init(program_invocation_name);
+ strncpy(name, libname.c_str(), libname.size());
+ dld_link(libname.c_str());
+ return (void*)name;
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ dld_unlink_by_file((char*)lib, 0);
+ free(lib);
+ return 0;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+ result.pvoid = dld_get_symbol(sym.c_str());
+ return result.psym;
+}
+
+#else
+# include <dlfcn.h>
+
+DynamicLoader::LibraryHandle DynamicLoader::OpenLibrary(
+ const std::string& libname)
+{
+ return dlopen(libname.c_str(), RTLD_LAZY);
+}
+
+int DynamicLoader::CloseLibrary(DynamicLoader::LibraryHandle lib)
+{
+ if (lib) {
+ // The function dlclose() returns 0 on success, and non-zero on error.
+ return !dlclose(lib);
+ }
+ // else
+ return 0;
+}
+
+DynamicLoader::SymbolPointer DynamicLoader::GetSymbolAddress(
+ DynamicLoader::LibraryHandle lib, const std::string& sym)
+{
+ // Hack to cast pointer-to-data to pointer-to-function.
+ union
+ {
+ void* pvoid;
+ DynamicLoader::SymbolPointer psym;
+ } result;
+ result.pvoid = dlsym(lib, sym.c_str());
+ return result.psym;
+}
+
+#endif
diff --git a/Tests/Plugin/src/example_exe.cxx b/Tests/Plugin/src/example_exe.cxx
index 257a35c..fd810a9 100644
--- a/Tests/Plugin/src/example_exe.cxx
+++ b/Tests/Plugin/src/example_exe.cxx
@@ -1,4 +1,4 @@
-#include <kwsys/DynamicLoader.hxx>
+#include "DynamicLoader.hxx"
#include <example.h>
@@ -24,20 +24,17 @@ extern "C" int example_exe_function()
int main()
{
- std::string libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR "/";
- libName += kwsys::DynamicLoader::LibPrefix();
- libName += "example_mod_1";
- libName += kwsys::DynamicLoader::LibExtension();
- kwsys::DynamicLoader::LibraryHandle handle =
- kwsys::DynamicLoader::OpenLibrary(libName.c_str());
+ std::string const libName = EXAMPLE_EXE_PLUGIN_DIR CONFIG_DIR
+ "/" EXAMPLE_EXE_MOD_PREFIX "example_mod_1" EXAMPLE_EXE_MOD_SUFFIX;
+ DynamicLoader::LibraryHandle handle = DynamicLoader::OpenLibrary(libName);
if (!handle) {
// Leave the .c_str() on this one. It is needed on OpenWatcom.
std::cerr << "Could not open plugin \"" << libName.c_str() << "\"!"
<< std::endl;
return 1;
}
- kwsys::DynamicLoader::SymbolPointer sym =
- kwsys::DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function");
+ DynamicLoader::SymbolPointer sym =
+ DynamicLoader::GetSymbolAddress(handle, "example_mod_1_function");
if (!sym) {
std::cerr << "Could not get plugin symbol \"example_mod_1_function\"!"
<< std::endl;
@@ -52,6 +49,6 @@ int main()
std::cerr << "Incorrect return value from plugin!" << std::endl;
return 1;
}
- kwsys::DynamicLoader::CloseLibrary(handle);
+ DynamicLoader::CloseLibrary(handle);
return 0;
}
diff --git a/Tests/Plugin/src/example_exe.h.in b/Tests/Plugin/src/example_exe.h.in
index 62f0d9f..af71021 100644
--- a/Tests/Plugin/src/example_exe.h.in
+++ b/Tests/Plugin/src/example_exe.h.in
@@ -2,5 +2,7 @@
#define example_exe_h
#define EXAMPLE_EXE_PLUGIN_DIR "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@"
+#define EXAMPLE_EXE_MOD_PREFIX "@CMAKE_SHARED_MODULE_PREFIX@"
+#define EXAMPLE_EXE_MOD_SUFFIX "@CMAKE_SHARED_MODULE_SUFFIX@"
#endif
diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt
new file mode 100644
index 0000000..04c8baf
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt
@@ -0,0 +1,112 @@
+cmake_minimum_required(VERSION 3.15)
+project(MocInclude)
+get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
+include("${CS_REAL}/../AutogenCoreTest.cmake")
+
+# Test moc include patterns
+
+set(COM_DIR "${CMAKE_CURRENT_SOURCE_DIR}/Common")
+
+macro(addCopyCommand from to)
+ add_custom_command(
+ OUTPUT ${to}
+ COMMAND ${CMAKE_COMMAND} -E copy ${from} ${to}
+ DEPENDS ${from})
+endmacro()
+
+# Create an executable
+function(makeExecutable TARGET_NAME)
+ # Utility variables
+ set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+
+ # Copy directory
+ file(REMOVE_RECURSE "${CB_DIR}/InIncludes")
+ file(COPY "${COM_DIR}/InIncludes.in" DESTINATION "${CB_DIR}")
+ file(RENAME "${CB_DIR}/InIncludes.in" "${CB_DIR}/InIncludes")
+
+ # Generate .moc file from the header externally and
+ # enabled SKIP_AUTOMOC on the source file
+ qtx_wrap_cpp(ExternDotMOC ${COM_DIR}/ExternDot.hpp OPTIONS "-p" "./")
+ addCopyCommand(${ExternDotMOC}
+ ${CB_DIR}/ExternDot.moc)
+ set_property(
+ SOURCE ${COM_DIR}/ExternDot.cpp
+ PROPERTY SKIP_AUTOMOC ON)
+
+ # Generate .moc file from the GENERATED header externally
+ # and enabled SKIP_AUTOMOC on the source file
+ addCopyCommand(${COM_DIR}/ExternDotGenerated.hpp.in
+ ${CB_DIR}/ExternDotGenerated.hpp)
+ addCopyCommand(${COM_DIR}/ExternDotGenerated.cpp.in
+ ${CB_DIR}/ExternDotGenerated.cpp)
+ qtx_wrap_cpp(ExternDotGeneratedMOC
+ ${CB_DIR}/ExternDotGenerated.hpp
+ OPTIONS "-p" "./")
+ addCopyCommand(${ExternDotGeneratedMOC}
+ ${CB_DIR}/ExternDotGenerated.moc)
+ set_property(
+ SOURCE ${CB_DIR}/ExternDotGenerated.cpp
+ PROPERTY SKIP_AUTOMOC ON)
+
+ # Generate header moc file externally with a custom name
+ # and enabled SKIP_AUTOMOC on the header
+ qtx_wrap_cpp(MixedCustomMOC
+ ${COM_DIR}/MixedCustom.hpp
+ OPTIONS "-p" "./")
+ addCopyCommand(${MixedCustomMOC}
+ ${CB_DIR}/MixedCustom_extMoc.cpp)
+ set_property(
+ SOURCE ${COM_DIR}/MixedCustom.hpp
+ PROPERTY SKIP_AUTOMOC ON)
+ # Custom target to depend on
+ add_custom_target("${TARGET_NAME}_MixedCustom"
+ DEPENDS ${CB_DIR}/MixedCustom_extMoc.cpp
+ BYPRODUCTS ${CB_DIR}/moc_MixedCustom.cpp
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${COM_DIR}/moc_MixedCustom.cpp.in
+ ${CB_DIR}/moc_MixedCustom.cpp)
+
+ add_executable(${TARGET_NAME}
+ # Test own "*.moc" and "moc_*.cpp" includes
+ ${COM_DIR}/None.cpp
+ ${COM_DIR}/OwnDot.cpp
+ ${COM_DIR}/OwnUnderscore.cpp
+ ${COM_DIR}/OwnDotUnderscore.cpp
+
+ # Test "moc_*.cpp" includes of other files
+ ${COM_DIR}/OtherUnderscore.cpp
+ ${COM_DIR}/OtherUnderscoreExtra.cpp
+ ${COM_DIR}/OtherUnderscoreSub.cpp
+ ${COM_DIR}/OtherUnderscoreSubDir/SubExtra.cpp
+
+ # Test relative ../../ path for moc includes
+ ${COM_DIR}/DualSub/Second/Second.cpp
+ ${COM_DIR}/DualSubMocked.cpp
+
+ # Test externally generated moc files
+ ${COM_DIR}/ExternDot.cpp
+ ${CB_DIR}/ExternDot.moc
+
+ # Test externally generated moc files for GENERATED source
+ ${CB_DIR}/ExternDotGenerated.cpp
+ ${CB_DIR}/ExternDotGenerated.moc
+
+ # Test externally generated moc files and SKIP_AUTOMOC enabled header
+ ${COM_DIR}/MixedSkipped.cpp
+ ${COM_DIR}/MixedCustom.hpp
+ ${COM_DIR}/MixedCustom.cpp
+
+ # Test sources in a subdirectory
+ ${CB_DIR}/InIncludes/SubOwnDot.cpp
+ ${COM_DIR}/InIncludesMoc.cpp
+ )
+ add_dependencies(${TARGET_NAME} "${TARGET_NAME}_MixedCustom")
+ target_include_directories(${TARGET_NAME} PRIVATE "${COM_DIR}")
+ target_include_directories(${TARGET_NAME} PRIVATE "${CB_DIR}")
+ target_include_directories(${TARGET_NAME} PRIVATE "${CMAKE_SOURCE_DIR}")
+ target_link_libraries(${TARGET_NAME} ${QT_LIBRARIES})
+ set_target_properties(${TARGET_NAME} PROPERTIES AUTOMOC ON)
+endfunction()
+
+add_subdirectory(Strict)
+add_subdirectory(Relaxed)
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp
new file mode 100644
index 0000000..453add1
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.cpp
@@ -0,0 +1,11 @@
+#include "Second.hpp"
+
+Second::Second()
+{
+}
+
+Second::~Second()
+{
+}
+
+#include "../../moc_DualSubMocked.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp
new file mode 100644
index 0000000..e1f3eac
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSub/Second/Second.hpp
@@ -0,0 +1,14 @@
+#ifndef Second_HPP
+#define Second_HPP
+
+#include <QObject>
+
+class Second : public QObject
+{
+ Q_OBJECT
+public:
+ Second();
+ ~Second();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp
new file mode 100644
index 0000000..1d4658d
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.cpp
@@ -0,0 +1,9 @@
+#include "DualSubMocked.hpp"
+
+DualSubMocked::DualSubMocked()
+{
+}
+
+DualSubMocked::~DualSubMocked()
+{
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp
new file mode 100644
index 0000000..58cb571
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/DualSubMocked.hpp
@@ -0,0 +1,15 @@
+#ifndef DualSubMocked_HPP
+#define DualSubMocked_HPP
+
+#include <QObject>
+
+// Header moc file is included by DualSub/Second/Second.cpp
+class DualSubMocked : public QObject
+{
+ Q_OBJECT
+public:
+ DualSubMocked();
+ ~DualSubMocked();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp
new file mode 100644
index 0000000..2495aa7
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.cpp
@@ -0,0 +1,11 @@
+#include "ExternDot.hpp"
+
+ExternDot::ExternDot()
+{
+}
+
+ExternDot::~ExternDot()
+{
+}
+
+#include "ExternDot.moc"
diff --git a/Tests/QtAutogen/MocInclude/SObjA.hpp b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp
index 1436abc..7eaab2a 100644
--- a/Tests/QtAutogen/MocInclude/SObjA.hpp
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDot.hpp
@@ -1,15 +1,15 @@
-#ifndef SOBJA_HPP
-#define SOBJA_HPP
+#ifndef ExternDot_HPP
+#define ExternDot_HPP
#include <QObject>
// Object source includes externally generated .moc file
-class SObjA : public QObject
+class ExternDot : public QObject
{
Q_OBJECT
public:
- SObjA();
- ~SObjA();
+ ExternDot();
+ ~ExternDot();
};
#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in
new file mode 100644
index 0000000..09ce5cd
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.cpp.in
@@ -0,0 +1,11 @@
+#include "ExternDotGenerated.hpp"
+
+ExternDotGenerated::ExternDotGenerated()
+{
+}
+
+ExternDotGenerated::~ExternDotGenerated()
+{
+}
+
+#include "ExternDotGenerated.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in
new file mode 100644
index 0000000..21c69be
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/ExternDotGenerated.hpp.in
@@ -0,0 +1,15 @@
+#ifndef ExternDotGenerated_HPP
+#define ExternDotGenerated_HPP
+
+#include <QObject>
+
+// GENERATED Object source includes externally generated .moc file
+class ExternDotGenerated : public QObject
+{
+ Q_OBJECT
+public:
+ ExternDotGenerated();
+ ~ExternDotGenerated();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp
new file mode 100644
index 0000000..af35711
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.cpp
@@ -0,0 +1,43 @@
+#include "SubOwnDot.hpp"
+#include "SubOwnDot_p.hpp"
+
+namespace InIncludes {
+
+class SubOwnDotLocal : public QObject
+{
+ Q_OBJECT
+public:
+ SubOwnDotLocal();
+ ~SubOwnDotLocal();
+};
+
+SubOwnDotLocal::SubOwnDotLocal()
+{
+}
+
+SubOwnDotLocal::~SubOwnDotLocal()
+{
+}
+
+SubOwnDotPrivate::SubOwnDotPrivate()
+{
+}
+
+SubOwnDotPrivate::~SubOwnDotPrivate()
+{
+}
+
+SubOwnDot::SubOwnDot()
+{
+ SubOwnDotPrivate privateObj;
+ SubOwnDotLocal localObj;
+}
+
+SubOwnDot::~SubOwnDot()
+{
+}
+
+} // End of namespace
+
+// For the local QObject
+#include "SubOwnDot.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp
new file mode 100644
index 0000000..038ddfa
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot.hpp
@@ -0,0 +1,17 @@
+#ifndef InIncludes_SubOwnDot_HPP
+#define InIncludes_SubOwnDot_HPP
+
+#include <QObject>
+
+namespace InIncludes {
+
+class SubOwnDot : public QObject
+{
+ Q_OBJECT
+public:
+ SubOwnDot();
+ ~SubOwnDot();
+};
+}
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp
new file mode 100644
index 0000000..626a9a8
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludes.in/SubOwnDot_p.hpp
@@ -0,0 +1,18 @@
+#ifndef InIncludes_SubOwnDot_P_HPP
+#define InIncludes_SubOwnDot_P_HPP
+
+#include <QObject>
+
+namespace InIncludes {
+
+class SubOwnDotPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ SubOwnDotPrivate();
+ ~SubOwnDotPrivate();
+};
+
+} // End of namespace
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp
new file mode 100644
index 0000000..88f53a4
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/InIncludesMoc.cpp
@@ -0,0 +1,4 @@
+
+// Moc a header that is not in the sources but in a directory that
+// is in the list of include directories.
+#include "InIncludes/moc_SubOwnDot.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp
new file mode 100644
index 0000000..557cc62
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.cpp
@@ -0,0 +1,32 @@
+#include "MixedCustom.hpp"
+
+class MixedCustomLocal : public QObject
+{
+ Q_OBJECT
+
+public:
+ MixedCustomLocal();
+ ~MixedCustomLocal();
+};
+
+MixedCustomLocal::MixedCustomLocal()
+{
+}
+
+MixedCustomLocal::~MixedCustomLocal()
+{
+}
+
+MixedCustom::MixedCustom()
+{
+ MixedCustomLocal local;
+}
+
+MixedCustom::~MixedCustom()
+{
+}
+
+// AUTOMOC generated source moc
+#include "MixedCustom.moc"
+// Externally generated header moc
+#include "MixedCustom_extMoc.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp
new file mode 100644
index 0000000..6e8ff88
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedCustom.hpp
@@ -0,0 +1,20 @@
+#ifndef MixedCustom_HPP
+#define MixedCustom_HPP
+
+#include <QObject>
+
+// Object source includes
+// - externally generated header moc file
+// - AUTOMOC generated source .moc file
+class MixedCustom : public QObject
+{
+ Q_OBJECT
+public:
+ MixedCustom();
+ ~MixedCustom();
+};
+
+// Function forward declaration
+void moc_MixedCustom(MixedCustom const& arg);
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp
new file mode 100644
index 0000000..df08ff1
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.cpp
@@ -0,0 +1,39 @@
+#include "MixedSkipped.hpp"
+#include "MixedCustom.hpp"
+
+class MixedSkippedLocal : public QObject
+{
+ Q_OBJECT
+
+public:
+ MixedSkippedLocal();
+ ~MixedSkippedLocal();
+};
+
+MixedSkippedLocal::MixedSkippedLocal()
+{
+}
+
+MixedSkippedLocal::~MixedSkippedLocal()
+{
+}
+
+MixedSkipped::MixedSkipped()
+{
+ MixedSkippedLocal local;
+ MixedCustom externCutom;
+ // Call moc named function
+ moc_MixedCustom(externCutom);
+}
+
+MixedSkipped::~MixedSkipped()
+{
+}
+
+// Include AUTOMOC generated moc files
+#include "MixedSkipped.moc"
+#include "moc_MixedSkipped.cpp"
+
+// Include externally generated moc_ named file that is not a moc file
+// and for which the relevant header is SKIP_AUTOMOC enabled
+#include "moc_MixedCustom.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp
new file mode 100644
index 0000000..5f6c664
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/MixedSkipped.hpp
@@ -0,0 +1,17 @@
+#ifndef MixedSkipped_HPP
+#define MixedSkipped_HPP
+
+#include <QObject>
+
+// Object source includes
+// - Own moc_ and .moc files.
+// - externally generated moc_ file from a SKIP_AUTOMOC enabled header
+class MixedSkipped : public QObject
+{
+ Q_OBJECT
+public:
+ MixedSkipped();
+ ~MixedSkipped();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/None.cpp b/Tests/QtAutogen/MocInclude/Common/None.cpp
new file mode 100644
index 0000000..d01d5ec
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/None.cpp
@@ -0,0 +1,20 @@
+#include "None.hpp"
+#include "None_p.h"
+
+NonePrivate::NonePrivate()
+{
+}
+
+NonePrivate::~NonePrivate()
+{
+}
+
+None::None()
+ : d(new NonePrivate)
+{
+}
+
+None::~None()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/None.hpp b/Tests/QtAutogen/MocInclude/Common/None.hpp
new file mode 100644
index 0000000..ca0713e
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/None.hpp
@@ -0,0 +1,19 @@
+#ifndef None_HPP
+#define None_HPP
+
+#include <QObject>
+
+// Object source comes without any _moc/.moc includes
+class NonePrivate;
+class None : public QObject
+{
+ Q_OBJECT
+public:
+ None();
+ ~None();
+
+private:
+ NonePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/None_p.h b/Tests/QtAutogen/MocInclude/Common/None_p.h
new file mode 100644
index 0000000..e209aeb
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/None_p.h
@@ -0,0 +1,14 @@
+#ifndef None_P_HPP
+#define None_P_HPP
+
+#include <QObject>
+
+class NonePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ NonePrivate();
+ ~NonePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp
new file mode 100644
index 0000000..219619f
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.cpp
@@ -0,0 +1,44 @@
+#include "OtherUnderscore.hpp"
+#include "OtherUnderscoreExtra.hpp"
+#include "OtherUnderscore_p.hpp"
+
+class OtherUnderscoreLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreLocal();
+ ~OtherUnderscoreLocal();
+};
+
+OtherUnderscoreLocal::OtherUnderscoreLocal()
+{
+}
+
+OtherUnderscoreLocal::~OtherUnderscoreLocal()
+{
+}
+
+OtherUnderscorePrivate::OtherUnderscorePrivate()
+{
+ OtherUnderscoreLocal localObj;
+ OtherUnderscoreExtra extraObj;
+}
+
+OtherUnderscorePrivate::~OtherUnderscorePrivate()
+{
+}
+
+OtherUnderscore::OtherUnderscore()
+ : d(new OtherUnderscorePrivate)
+{
+}
+
+OtherUnderscore::~OtherUnderscore()
+{
+ delete d;
+}
+
+// For OtherUnderscoreLocal
+#include "OtherUnderscore.moc"
+// - Not the own header
+#include "moc_OtherUnderscoreExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp
new file mode 100644
index 0000000..a4ff603
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore.hpp
@@ -0,0 +1,19 @@
+#ifndef OtherUnderscore_HPP
+#define OtherUnderscore_HPP
+
+#include <QObject>
+
+// Sources includes a moc_ includes of an extra object
+class OtherUnderscorePrivate;
+class OtherUnderscore : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscore();
+ ~OtherUnderscore();
+
+private:
+ OtherUnderscorePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp
new file mode 100644
index 0000000..4ccf080
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.cpp
@@ -0,0 +1,20 @@
+#include "OtherUnderscoreExtra.hpp"
+#include "OtherUnderscoreExtra_p.hpp"
+
+OtherUnderscoreExtraPrivate::OtherUnderscoreExtraPrivate()
+{
+}
+
+OtherUnderscoreExtraPrivate::~OtherUnderscoreExtraPrivate()
+{
+}
+
+OtherUnderscoreExtra::OtherUnderscoreExtra()
+ : d(new OtherUnderscoreExtraPrivate)
+{
+}
+
+OtherUnderscoreExtra::~OtherUnderscoreExtra()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp
new file mode 100644
index 0000000..5afe48c
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra.hpp
@@ -0,0 +1,18 @@
+#ifndef OtherUnderscoreEXTRA_HPP
+#define OtherUnderscoreEXTRA_HPP
+
+#include <QObject>
+
+class OtherUnderscoreExtraPrivate;
+class OtherUnderscoreExtra : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreExtra();
+ ~OtherUnderscoreExtra();
+
+private:
+ OtherUnderscoreExtraPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp
new file mode 100644
index 0000000..2066ac3
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreExtra_p.hpp
@@ -0,0 +1,14 @@
+#ifndef OtherUnderscoreEXTRA_P_HPP
+#define OtherUnderscoreEXTRA_P_HPP
+
+#include <QObject>
+
+class OtherUnderscoreExtraPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreExtraPrivate();
+ ~OtherUnderscoreExtraPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp
new file mode 100644
index 0000000..28850aa
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.cpp
@@ -0,0 +1,45 @@
+#include "OtherUnderscoreSub.hpp"
+#include "OtherUnderscoreSubDir/SubExtra.hpp"
+#include "OtherUnderscoreSub_p.hpp"
+
+class OtherUnderscoreSubLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreSubLocal();
+ ~OtherUnderscoreSubLocal();
+};
+
+OtherUnderscoreSubLocal::OtherUnderscoreSubLocal()
+{
+}
+
+OtherUnderscoreSubLocal::~OtherUnderscoreSubLocal()
+{
+}
+
+OtherUnderscoreSubPrivate::OtherUnderscoreSubPrivate()
+{
+ OtherUnderscoreSubLocal localObj;
+ SubExtra extraObj;
+}
+
+OtherUnderscoreSubPrivate::~OtherUnderscoreSubPrivate()
+{
+}
+
+OtherUnderscoreSub::OtherUnderscoreSub()
+ : d(new OtherUnderscoreSubPrivate)
+{
+}
+
+OtherUnderscoreSub::~OtherUnderscoreSub()
+{
+ delete d;
+}
+
+// For OtherUnderscoreSubLocal
+#include "OtherUnderscoreSub.moc"
+// - Not the own header
+// - in a subdirectory
+#include "OtherUnderscoreSubDir/moc_SubExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp
new file mode 100644
index 0000000..7feaa46
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub.hpp
@@ -0,0 +1,19 @@
+#ifndef OtherUnderscoreSub_HPP
+#define OtherUnderscoreSub_HPP
+
+#include <QObject>
+
+// Sources includes a moc_ includes of an extra object in a subdirectory
+class OtherUnderscoreSubPrivate;
+class OtherUnderscoreSub : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreSub();
+ ~OtherUnderscoreSub();
+
+private:
+ OtherUnderscoreSubPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp
new file mode 100644
index 0000000..e323ed8
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.cpp
@@ -0,0 +1,20 @@
+#include "SubExtra.hpp"
+#include "SubExtra_p.hpp"
+
+SubExtraPrivate::SubExtraPrivate()
+{
+}
+
+SubExtraPrivate::~SubExtraPrivate()
+{
+}
+
+SubExtra::SubExtra()
+ : d(new SubExtraPrivate)
+{
+}
+
+SubExtra::~SubExtra()
+{
+ delete d;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp
new file mode 100644
index 0000000..5700634
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra.hpp
@@ -0,0 +1,18 @@
+#ifndef SubExtra_HPP
+#define SubExtra_HPP
+
+#include <QObject>
+
+class SubExtraPrivate;
+class SubExtra : public QObject
+{
+ Q_OBJECT
+public:
+ SubExtra();
+ ~SubExtra();
+
+private:
+ SubExtraPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp
new file mode 100644
index 0000000..5a14a2d
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSubDir/SubExtra_p.hpp
@@ -0,0 +1,14 @@
+#ifndef SubExtra_P_HPP
+#define SubExtra_P_HPP
+
+#include <QObject>
+
+class SubExtraPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ SubExtraPrivate();
+ ~SubExtraPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp
new file mode 100644
index 0000000..7d5999c
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscoreSub_p.hpp
@@ -0,0 +1,14 @@
+#ifndef OtherUnderscoreSub_P_HPP
+#define OtherUnderscoreSub_P_HPP
+
+#include <QObject>
+
+class OtherUnderscoreSubPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscoreSubPrivate();
+ ~OtherUnderscoreSubPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp
new file mode 100644
index 0000000..96906cf
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OtherUnderscore_p.hpp
@@ -0,0 +1,14 @@
+#ifndef OtherUnderscore_P_HPP
+#define OtherUnderscore_P_HPP
+
+#include <QObject>
+
+class OtherUnderscorePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OtherUnderscorePrivate();
+ ~OtherUnderscorePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp
new file mode 100644
index 0000000..1cce272
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.cpp
@@ -0,0 +1,39 @@
+#include "OwnDot.hpp"
+#include "OwnDot_p.h"
+
+class OwnDotLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotLocal();
+ ~OwnDotLocal();
+};
+
+OwnDotLocal::OwnDotLocal()
+{
+}
+
+OwnDotLocal::~OwnDotLocal()
+{
+}
+
+OwnDotPrivate::OwnDotPrivate()
+{
+ OwnDotLocal localObj;
+}
+
+OwnDotPrivate::~OwnDotPrivate()
+{
+}
+
+OwnDot::OwnDot()
+ : d(new OwnDotPrivate)
+{
+}
+
+OwnDot::~OwnDot()
+{
+ delete d;
+}
+
+#include "OwnDot.moc"
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp
new file mode 100644
index 0000000..6f49f12
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDot.hpp
@@ -0,0 +1,19 @@
+#ifndef OwnDot_HPP
+#define OwnDot_HPP
+
+#include <QObject>
+
+// Object source comes with a .moc include
+class OwnDotPrivate;
+class OwnDot : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDot();
+ ~OwnDot();
+
+private:
+ OwnDotPrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp
new file mode 100644
index 0000000..2a0b8ad
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.cpp
@@ -0,0 +1,40 @@
+#include "OwnDotUnderscore.hpp"
+#include "OwnDotUnderscore_p.h"
+
+class OwnDotUnderscoreLocal : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotUnderscoreLocal();
+ ~OwnDotUnderscoreLocal();
+};
+
+OwnDotUnderscoreLocal::OwnDotUnderscoreLocal()
+{
+}
+
+OwnDotUnderscoreLocal::~OwnDotUnderscoreLocal()
+{
+}
+
+OwnDotUnderscorePrivate::OwnDotUnderscorePrivate()
+{
+ OwnDotUnderscoreLocal localObj;
+}
+
+OwnDotUnderscorePrivate::~OwnDotUnderscorePrivate()
+{
+}
+
+OwnDotUnderscore::OwnDotUnderscore()
+ : d(new OwnDotUnderscorePrivate)
+{
+}
+
+OwnDotUnderscore::~OwnDotUnderscore()
+{
+ delete d;
+}
+
+#include "OwnDotUnderscore.moc"
+#include "moc_OwnDotUnderscore.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp
new file mode 100644
index 0000000..478955c
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore.hpp
@@ -0,0 +1,19 @@
+#ifndef LOwnDotUnderscore_HPP
+#define LOwnDotUnderscore_HPP
+
+#include <QObject>
+
+// Object source comes with a .moc and a _moc include
+class OwnDotUnderscorePrivate;
+class OwnDotUnderscore : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotUnderscore();
+ ~OwnDotUnderscore();
+
+private:
+ OwnDotUnderscorePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h
new file mode 100644
index 0000000..6950b7f
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDotUnderscore_p.h
@@ -0,0 +1,14 @@
+#ifndef OwnDotUnderscore_P_HPP
+#define OwnDotUnderscore_P_HPP
+
+#include <QObject>
+
+class OwnDotUnderscorePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotUnderscorePrivate();
+ ~OwnDotUnderscorePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h
new file mode 100644
index 0000000..f3aff32
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnDot_p.h
@@ -0,0 +1,14 @@
+#ifndef OwnDot_P_HPP
+#define OwnDot_P_HPP
+
+#include <QObject>
+
+class OwnDotPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OwnDotPrivate();
+ ~OwnDotPrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp
new file mode 100644
index 0000000..ebbcf45
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.cpp
@@ -0,0 +1,22 @@
+#include "OwnUnderscore.hpp"
+#include "OwnUnderscore_p.h"
+
+OwnUnderscorePrivate::OwnUnderscorePrivate()
+{
+}
+
+OwnUnderscorePrivate::~OwnUnderscorePrivate()
+{
+}
+
+OwnUnderscore::OwnUnderscore()
+ : d(new OwnUnderscorePrivate)
+{
+}
+
+OwnUnderscore::~OwnUnderscore()
+{
+ delete d;
+}
+
+#include "moc_OwnUnderscore.cpp"
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp
new file mode 100644
index 0000000..e6a6a6e
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore.hpp
@@ -0,0 +1,19 @@
+#ifndef OwnUnderscore_HPP
+#define OwnUnderscore_HPP
+
+#include <QObject>
+
+// Object source comes with a _moc include
+class OwnUnderscorePrivate;
+class OwnUnderscore : public QObject
+{
+ Q_OBJECT
+public:
+ OwnUnderscore();
+ ~OwnUnderscore();
+
+private:
+ OwnUnderscorePrivate* const d;
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h
new file mode 100644
index 0000000..a3a6b00
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/OwnUnderscore_p.h
@@ -0,0 +1,14 @@
+#ifndef OwnUnderscore_P_HPP
+#define OwnUnderscore_P_HPP
+
+#include <QObject>
+
+class OwnUnderscorePrivate : public QObject
+{
+ Q_OBJECT
+public:
+ OwnUnderscorePrivate();
+ ~OwnUnderscorePrivate();
+};
+
+#endif
diff --git a/Tests/QtAutogen/MocInclude/Common/common.cpp.in b/Tests/QtAutogen/MocInclude/Common/common.cpp.in
new file mode 100644
index 0000000..b53e93d
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/common.cpp.in
@@ -0,0 +1,32 @@
+#include "DualSub/Second/Second.hpp"
+#include "DualSubMocked.hpp"
+#include "ExternDot.hpp"
+#include "ExternDotGenerated.hpp"
+#include "None.hpp"
+#include "OtherUnderscore.hpp"
+#include "OtherUnderscoreSub.hpp"
+#include "OwnDot.hpp"
+#include "OwnDotUnderscore.hpp"
+#include "OwnUnderscore.hpp"
+#include "InIncludes/SubOwnDot.hpp"
+
+bool @COMMON_FUNCTION_NAME@()
+{
+ None objNone;
+ OwnUnderscore objOwnUnderscore;
+ OwnDot objOwnDot;
+ OwnDotUnderscore objOwnDotUnderscore;
+
+ OtherUnderscore objOtherUnderscore;
+ OtherUnderscoreSub objOtherUnderscoreSub;
+
+ Second second;
+ DualSubMocked dualSubMocked;
+
+ ExternDot objExternDot;
+ ExternDotGenerated objGeneratedExternDot;
+
+ InIncludes::SubOwnDot subOwnDot;
+
+ return true;
+}
diff --git a/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in
new file mode 100644
index 0000000..6c44793
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Common/moc_MixedCustom.cpp.in
@@ -0,0 +1,5 @@
+
+void moc_MixedCustom(MixedCustom const & arg)
+{
+ (void)arg;
+}
diff --git a/Tests/QtAutogen/MocInclude/EObjA.cpp b/Tests/QtAutogen/MocInclude/EObjA.cpp
deleted file mode 100644
index 7681c29..0000000
--- a/Tests/QtAutogen/MocInclude/EObjA.cpp
+++ /dev/null
@@ -1,44 +0,0 @@
-#include "EObjA.hpp"
-#include "EObjAExtra.hpp"
-#include "EObjA_p.hpp"
-
-class EObjALocal : public QObject
-{
- Q_OBJECT
-public:
- EObjALocal();
- ~EObjALocal();
-};
-
-EObjALocal::EObjALocal()
-{
-}
-
-EObjALocal::~EObjALocal()
-{
-}
-
-EObjAPrivate::EObjAPrivate()
-{
- EObjALocal localObj;
- EObjAExtra extraObj;
-}
-
-EObjAPrivate::~EObjAPrivate()
-{
-}
-
-EObjA::EObjA()
- : d(new EObjAPrivate)
-{
-}
-
-EObjA::~EObjA()
-{
- delete d;
-}
-
-// For EObjALocal
-#include "EObjA.moc"
-// - Not the own header
-#include "moc_EObjAExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/EObjA.hpp b/Tests/QtAutogen/MocInclude/EObjA.hpp
deleted file mode 100644
index 0939ab6..0000000
--- a/Tests/QtAutogen/MocInclude/EObjA.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef EOBJA_HPP
-#define EOBJA_HPP
-
-#include <QObject>
-
-// Sources includes a moc_ includes of an extra object
-class EObjAPrivate;
-class EObjA : public QObject
-{
- Q_OBJECT
-public:
- EObjA();
- ~EObjA();
-
-private:
- EObjAPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/EObjAExtra.cpp b/Tests/QtAutogen/MocInclude/EObjAExtra.cpp
deleted file mode 100644
index 369ca8f..0000000
--- a/Tests/QtAutogen/MocInclude/EObjAExtra.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "EObjAExtra.hpp"
-#include "EObjAExtra_p.hpp"
-
-EObjAExtraPrivate::EObjAExtraPrivate()
-{
-}
-
-EObjAExtraPrivate::~EObjAExtraPrivate()
-{
-}
-
-EObjAExtra::EObjAExtra()
- : d(new EObjAExtraPrivate)
-{
-}
-
-EObjAExtra::~EObjAExtra()
-{
- delete d;
-}
diff --git a/Tests/QtAutogen/MocInclude/EObjAExtra.hpp b/Tests/QtAutogen/MocInclude/EObjAExtra.hpp
deleted file mode 100644
index b10681d..0000000
--- a/Tests/QtAutogen/MocInclude/EObjAExtra.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef EOBJAEXTRA_HPP
-#define EOBJAEXTRA_HPP
-
-#include <QObject>
-
-class EObjAExtraPrivate;
-class EObjAExtra : public QObject
-{
- Q_OBJECT
-public:
- EObjAExtra();
- ~EObjAExtra();
-
-private:
- EObjAExtraPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp b/Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp
deleted file mode 100644
index d8bf284..0000000
--- a/Tests/QtAutogen/MocInclude/EObjAExtra_p.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef EOBJAEXTRA_P_HPP
-#define EOBJAEXTRA_P_HPP
-
-#include <QObject>
-
-class EObjAExtraPrivate : public QObject
-{
- Q_OBJECT
-public:
- EObjAExtraPrivate();
- ~EObjAExtraPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/EObjA_p.hpp b/Tests/QtAutogen/MocInclude/EObjA_p.hpp
deleted file mode 100644
index 9ef5624..0000000
--- a/Tests/QtAutogen/MocInclude/EObjA_p.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef EOBJA_P_HPP
-#define EOBJA_P_HPP
-
-#include <QObject>
-
-class EObjAPrivate : public QObject
-{
- Q_OBJECT
-public:
- EObjAPrivate();
- ~EObjAPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/EObjB.cpp b/Tests/QtAutogen/MocInclude/EObjB.cpp
deleted file mode 100644
index 3068c68..0000000
--- a/Tests/QtAutogen/MocInclude/EObjB.cpp
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "EObjB.hpp"
-#include "EObjB_p.hpp"
-#include "subExtra/EObjBExtra.hpp"
-
-class EObjBLocal : public QObject
-{
- Q_OBJECT
-public:
- EObjBLocal();
- ~EObjBLocal();
-};
-
-EObjBLocal::EObjBLocal()
-{
-}
-
-EObjBLocal::~EObjBLocal()
-{
-}
-
-EObjBPrivate::EObjBPrivate()
-{
- EObjBLocal localObj;
- EObjBExtra extraObj;
-}
-
-EObjBPrivate::~EObjBPrivate()
-{
-}
-
-EObjB::EObjB()
- : d(new EObjBPrivate)
-{
-}
-
-EObjB::~EObjB()
-{
- delete d;
-}
-
-// For EObjBLocal
-#include "EObjB.moc"
-// - Not the own header
-// - in a subdirectory
-#include "subExtra/moc_EObjBExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/EObjB.hpp b/Tests/QtAutogen/MocInclude/EObjB.hpp
deleted file mode 100644
index 6632bdb..0000000
--- a/Tests/QtAutogen/MocInclude/EObjB.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef EOBJB_HPP
-#define EOBJB_HPP
-
-#include <QObject>
-
-// Sources includes a moc_ includes of an extra object in a subdirectory
-class EObjBPrivate;
-class EObjB : public QObject
-{
- Q_OBJECT
-public:
- EObjB();
- ~EObjB();
-
-private:
- EObjBPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/EObjB_p.hpp b/Tests/QtAutogen/MocInclude/EObjB_p.hpp
deleted file mode 100644
index 84b1ea2..0000000
--- a/Tests/QtAutogen/MocInclude/EObjB_p.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef EOBJB_P_HPP
-#define EOBJB_P_HPP
-
-#include <QObject>
-
-class EObjBPrivate : public QObject
-{
- Q_OBJECT
-public:
- EObjBPrivate();
- ~EObjBPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/LObjA.cpp b/Tests/QtAutogen/MocInclude/LObjA.cpp
deleted file mode 100644
index 9aae991..0000000
--- a/Tests/QtAutogen/MocInclude/LObjA.cpp
+++ /dev/null
@@ -1,39 +0,0 @@
-#include "LObjA.hpp"
-#include "LObjA_p.h"
-
-class LObjALocal : public QObject
-{
- Q_OBJECT
-public:
- LObjALocal();
- ~LObjALocal();
-};
-
-LObjALocal::LObjALocal()
-{
-}
-
-LObjALocal::~LObjALocal()
-{
-}
-
-LObjAPrivate::LObjAPrivate()
-{
- LObjALocal localObj;
-}
-
-LObjAPrivate::~LObjAPrivate()
-{
-}
-
-LObjA::LObjA()
- : d(new LObjAPrivate)
-{
-}
-
-LObjA::~LObjA()
-{
- delete d;
-}
-
-#include "LObjA.moc"
diff --git a/Tests/QtAutogen/MocInclude/LObjA.hpp b/Tests/QtAutogen/MocInclude/LObjA.hpp
deleted file mode 100644
index aac670c..0000000
--- a/Tests/QtAutogen/MocInclude/LObjA.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef LOBJA_HPP
-#define LOBJA_HPP
-
-#include <QObject>
-
-// Object source comes with a .moc include
-class LObjAPrivate;
-class LObjA : public QObject
-{
- Q_OBJECT
-public:
- LObjA();
- ~LObjA();
-
-private:
- LObjAPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/LObjA_p.h b/Tests/QtAutogen/MocInclude/LObjA_p.h
deleted file mode 100644
index 97113d6..0000000
--- a/Tests/QtAutogen/MocInclude/LObjA_p.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LOBJA_P_HPP
-#define LOBJA_P_HPP
-
-#include <QObject>
-
-class LObjAPrivate : public QObject
-{
- Q_OBJECT
-public:
- LObjAPrivate();
- ~LObjAPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/LObjB.cpp b/Tests/QtAutogen/MocInclude/LObjB.cpp
deleted file mode 100644
index 7485d8f..0000000
--- a/Tests/QtAutogen/MocInclude/LObjB.cpp
+++ /dev/null
@@ -1,40 +0,0 @@
-#include "LObjB.hpp"
-#include "LObjB_p.h"
-
-class LObjBLocal : public QObject
-{
- Q_OBJECT
-public:
- LObjBLocal();
- ~LObjBLocal();
-};
-
-LObjBLocal::LObjBLocal()
-{
-}
-
-LObjBLocal::~LObjBLocal()
-{
-}
-
-LObjBPrivate::LObjBPrivate()
-{
- LObjBLocal localObj;
-}
-
-LObjBPrivate::~LObjBPrivate()
-{
-}
-
-LObjB::LObjB()
- : d(new LObjBPrivate)
-{
-}
-
-LObjB::~LObjB()
-{
- delete d;
-}
-
-#include "LObjB.moc"
-#include "moc_LObjB.cpp"
diff --git a/Tests/QtAutogen/MocInclude/LObjB.hpp b/Tests/QtAutogen/MocInclude/LObjB.hpp
deleted file mode 100644
index eb4e58d..0000000
--- a/Tests/QtAutogen/MocInclude/LObjB.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef LLObjB_HPP
-#define LLObjB_HPP
-
-#include <QObject>
-
-// Object source comes with a .moc and a _moc include
-class LObjBPrivate;
-class LObjB : public QObject
-{
- Q_OBJECT
-public:
- LObjB();
- ~LObjB();
-
-private:
- LObjBPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/LObjB_p.h b/Tests/QtAutogen/MocInclude/LObjB_p.h
deleted file mode 100644
index b88f40e..0000000
--- a/Tests/QtAutogen/MocInclude/LObjB_p.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef LOBJB_P_HPP
-#define LOBJB_P_HPP
-
-#include <QObject>
-
-class LObjBPrivate : public QObject
-{
- Q_OBJECT
-public:
- LObjBPrivate();
- ~LObjBPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/ObjA.cpp b/Tests/QtAutogen/MocInclude/ObjA.cpp
deleted file mode 100644
index 6f6b90e..0000000
--- a/Tests/QtAutogen/MocInclude/ObjA.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "ObjA.hpp"
-#include "ObjA_p.h"
-
-ObjAPrivate::ObjAPrivate()
-{
-}
-
-ObjAPrivate::~ObjAPrivate()
-{
-}
-
-ObjA::ObjA()
- : d(new ObjAPrivate)
-{
-}
-
-ObjA::~ObjA()
-{
- delete d;
-}
diff --git a/Tests/QtAutogen/MocInclude/ObjA.hpp b/Tests/QtAutogen/MocInclude/ObjA.hpp
deleted file mode 100644
index f16c924..0000000
--- a/Tests/QtAutogen/MocInclude/ObjA.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef OBJA_HPP
-#define OBJA_HPP
-
-#include <QObject>
-
-// Object source comes without any _moc/.moc includes
-class ObjAPrivate;
-class ObjA : public QObject
-{
- Q_OBJECT
-public:
- ObjA();
- ~ObjA();
-
-private:
- ObjAPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/ObjA_p.h b/Tests/QtAutogen/MocInclude/ObjA_p.h
deleted file mode 100644
index d944bc6..0000000
--- a/Tests/QtAutogen/MocInclude/ObjA_p.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef OBJA_P_HPP
-#define OBJA_P_HPP
-
-#include <QObject>
-
-class ObjAPrivate : public QObject
-{
- Q_OBJECT
-public:
- ObjAPrivate();
- ~ObjAPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/ObjB.cpp b/Tests/QtAutogen/MocInclude/ObjB.cpp
deleted file mode 100644
index a6f2509..0000000
--- a/Tests/QtAutogen/MocInclude/ObjB.cpp
+++ /dev/null
@@ -1,22 +0,0 @@
-#include "ObjB.hpp"
-#include "ObjB_p.h"
-
-ObjBPrivate::ObjBPrivate()
-{
-}
-
-ObjBPrivate::~ObjBPrivate()
-{
-}
-
-ObjB::ObjB()
- : d(new ObjBPrivate)
-{
-}
-
-ObjB::~ObjB()
-{
- delete d;
-}
-
-#include "moc_ObjB.cpp"
diff --git a/Tests/QtAutogen/MocInclude/ObjB.hpp b/Tests/QtAutogen/MocInclude/ObjB.hpp
deleted file mode 100644
index 2ac8d17..0000000
--- a/Tests/QtAutogen/MocInclude/ObjB.hpp
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef ObjB_HPP
-#define ObjB_HPP
-
-#include <QObject>
-
-// Object source comes with a _moc include
-class ObjBPrivate;
-class ObjB : public QObject
-{
- Q_OBJECT
-public:
- ObjB();
- ~ObjB();
-
-private:
- ObjBPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/ObjB_p.h b/Tests/QtAutogen/MocInclude/ObjB_p.h
deleted file mode 100644
index 61ba604..0000000
--- a/Tests/QtAutogen/MocInclude/ObjB_p.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef OBJB_P_HPP
-#define OBJB_P_HPP
-
-#include <QObject>
-
-class ObjBPrivate : public QObject
-{
- Q_OBJECT
-public:
- ObjBPrivate();
- ~ObjBPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt
new file mode 100644
index 0000000..048b79c
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/CMakeLists.txt
@@ -0,0 +1,17 @@
+# Enable relaxed mode
+set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
+
+# Common test
+set(COMMON_FUNCTION_NAME commonRelaxed)
+configure_file(
+ "${COM_DIR}/common.cpp.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp")
+
+makeExecutable(libRelaxed)
+target_sources(libRelaxed PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}/commonRelaxed.cpp"
+ RObjA.cpp
+ RObjB.cpp
+ RObjC.cpp
+ relaxed.cpp
+ )
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjA.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp
index 2e2cf6a..2e2cf6a 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjA.cpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.cpp
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjA.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp
index 5974187..5974187 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjA.hpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjA.hpp
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjB.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp
index c56d10f..c56d10f 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjB.cpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.cpp
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjB.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp
index d6d0474..d6d0474 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjB.hpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjB.hpp
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjBExtra.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp
index 5d6be75..5d6be75 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjBExtra.hpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjBExtra.hpp
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjC.cpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp
index 4ba32f5..4ba32f5 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjC.cpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.cpp
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RObjC.hpp b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp
index 5552ede..5552ede 100644
--- a/Tests/QtAutogen/MocIncludeRelaxed/RObjC.hpp
+++ b/Tests/QtAutogen/MocInclude/Relaxed/RObjC.hpp
diff --git a/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp
new file mode 100644
index 0000000..5a511b6
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Relaxed/relaxed.cpp
@@ -0,0 +1,21 @@
+// AUTOMOC relaxed mode objects
+#include "RObjA.hpp"
+#include "RObjB.hpp"
+#include "RObjC.hpp"
+
+// Forward declaration
+bool commonRelaxed();
+
+int main(int argv, char** args)
+{
+ // Common tests
+ if (!commonRelaxed()) {
+ return -1;
+ }
+
+ // Relaxed tests
+ RObjA rObjA;
+ RObjB rObjB;
+ RObjC rObjC;
+ return 0;
+}
diff --git a/Tests/QtAutogen/MocInclude/SObjA.cpp b/Tests/QtAutogen/MocInclude/SObjA.cpp
deleted file mode 100644
index 7e75bf9..0000000
--- a/Tests/QtAutogen/MocInclude/SObjA.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "SObjA.hpp"
-
-SObjA::SObjA()
-{
-}
-
-SObjA::~SObjA()
-{
-}
-
-#include "SObjA.moc"
diff --git a/Tests/QtAutogen/MocInclude/SObjB.cpp.in b/Tests/QtAutogen/MocInclude/SObjB.cpp.in
deleted file mode 100644
index b1cc12a..0000000
--- a/Tests/QtAutogen/MocInclude/SObjB.cpp.in
+++ /dev/null
@@ -1,11 +0,0 @@
-#include "SObjB.hpp"
-
-SObjB::SObjB()
-{
-}
-
-SObjB::~SObjB()
-{
-}
-
-#include "SObjB.moc"
diff --git a/Tests/QtAutogen/MocInclude/SObjB.hpp.in b/Tests/QtAutogen/MocInclude/SObjB.hpp.in
deleted file mode 100644
index 5e396ae..0000000
--- a/Tests/QtAutogen/MocInclude/SObjB.hpp.in
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef SOBJB_HPP
-#define SOBJB_HPP
-
-#include <QObject>
-
-// Object source includes externally generated .moc file
-class SObjB : public QObject
-{
- Q_OBJECT
-public:
- SObjB();
- ~SObjB();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/SObjC.cpp b/Tests/QtAutogen/MocInclude/SObjC.cpp
deleted file mode 100644
index 1e8d397..0000000
--- a/Tests/QtAutogen/MocInclude/SObjC.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-#include "SObjC.hpp"
-
-void SObjCLocalFunction();
-
-class SObjCLocal : public QObject
-{
- Q_OBJECT
-
-public:
- SObjCLocal();
- ~SObjCLocal();
-};
-
-SObjCLocal::SObjCLocal()
-{
-}
-
-SObjCLocal::~SObjCLocal()
-{
-}
-
-SObjC::SObjC()
-{
- SObjCLocal localObject;
- SObjCLocalFunction();
-}
-
-SObjC::~SObjC()
-{
-}
-
-#include "SObjC.moc"
-#include "moc_SObjC.cpp"
-// Include moc_ file for which the header is SKIP_AUTOMOC enabled
-#include "moc_SObjCExtra.cpp"
diff --git a/Tests/QtAutogen/MocInclude/SObjC.hpp b/Tests/QtAutogen/MocInclude/SObjC.hpp
deleted file mode 100644
index def0f9d..0000000
--- a/Tests/QtAutogen/MocInclude/SObjC.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef SOBJC_HPP
-#define SOBJC_HPP
-
-#include <QObject>
-
-// Object source includes externally generated .moc file
-class SObjC : public QObject
-{
- Q_OBJECT
-public:
- SObjC();
- ~SObjC();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/SObjCExtra.cpp b/Tests/QtAutogen/MocInclude/SObjCExtra.cpp
deleted file mode 100644
index 55dd1c3..0000000
--- a/Tests/QtAutogen/MocInclude/SObjCExtra.cpp
+++ /dev/null
@@ -1,31 +0,0 @@
-#include "SObjCExtra.hpp"
-
-class SObjCLocalExtra : public QObject
-{
- Q_OBJECT
-
-public:
- SObjCLocalExtra();
- ~SObjCLocalExtra();
-};
-
-SObjCLocalExtra::SObjCLocalExtra()
-{
-}
-
-SObjCLocalExtra::~SObjCLocalExtra()
-{
-}
-
-SObjCExtra::SObjCExtra()
-{
-}
-
-SObjCExtra::~SObjCExtra()
-{
-}
-
-// Externally generated header moc
-#include "SObjCExtra_extMoc.cpp"
-// AUTOMOC generated source moc
-#include "SObjCExtra.moc"
diff --git a/Tests/QtAutogen/MocInclude/SObjCExtra.hpp b/Tests/QtAutogen/MocInclude/SObjCExtra.hpp
deleted file mode 100644
index 08545ac..0000000
--- a/Tests/QtAutogen/MocInclude/SObjCExtra.hpp
+++ /dev/null
@@ -1,15 +0,0 @@
-#ifndef SOBJCEXTRA_HPP
-#define SOBJCEXTRA_HPP
-
-#include <QObject>
-
-// Object source includes externally generated .moc file
-class SObjCExtra : public QObject
-{
- Q_OBJECT
-public:
- SObjCExtra();
- ~SObjCExtra();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/SObjCExtra.moc.in b/Tests/QtAutogen/MocInclude/SObjCExtra.moc.in
deleted file mode 100644
index 00fc4aa..0000000
--- a/Tests/QtAutogen/MocInclude/SObjCExtra.moc.in
+++ /dev/null
@@ -1,4 +0,0 @@
-
-void SObjCLocalFunction()
-{
-}
diff --git a/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt
new file mode 100644
index 0000000..12c503f
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Strict/CMakeLists.txt
@@ -0,0 +1,14 @@
+# Disable relaxed mode
+set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
+
+# Common test
+set(COMMON_FUNCTION_NAME commonStrict)
+configure_file(
+ "${COM_DIR}/common.cpp.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp")
+
+makeExecutable(libStrict)
+target_sources(libStrict PRIVATE
+ "${CMAKE_CURRENT_BINARY_DIR}/commonStrict.cpp"
+ strict.cpp
+ )
diff --git a/Tests/QtAutogen/MocInclude/Strict/strict.cpp b/Tests/QtAutogen/MocInclude/Strict/strict.cpp
new file mode 100644
index 0000000..dd24bb0
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/Strict/strict.cpp
@@ -0,0 +1,7 @@
+// Forward declaration
+bool commonStrict();
+
+int main(int argv, char** args)
+{
+ return commonStrict() ? 0 : -1;
+}
diff --git a/Tests/QtAutogen/MocInclude/main.cpp b/Tests/QtAutogen/MocInclude/main.cpp
new file mode 100644
index 0000000..371c5fd
--- /dev/null
+++ b/Tests/QtAutogen/MocInclude/main.cpp
@@ -0,0 +1,9 @@
+
+// Forward declaration
+bool libStrict();
+bool libRelaxed();
+
+int main(int argv, char** args)
+{
+ return (libStrict() && libRelaxed()) ? 0 : -1;
+}
diff --git a/Tests/QtAutogen/MocInclude/shared.cmake b/Tests/QtAutogen/MocInclude/shared.cmake
deleted file mode 100644
index 2ca2841..0000000
--- a/Tests/QtAutogen/MocInclude/shared.cmake
+++ /dev/null
@@ -1,71 +0,0 @@
-# Test moc include patterns
-include_directories("../MocInclude")
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# Generate .moc file externally and enabled SKIP_AUTOMOC on the file
-qtx_generate_moc(
- ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.hpp
- ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc)
-set_property(SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjA.cpp PROPERTY SKIP_AUTOMOC ON)
-
-# Generate .moc file externally from generated source file
-# and enabled SKIP_AUTOMOC on the source file
-add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp
- COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.hpp.in
- ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp)
-add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp
- COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjB.cpp.in
- ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp)
-qtx_generate_moc(
- ${CMAKE_CURRENT_BINARY_DIR}/SObjB.hpp
- ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc)
-set_property(SOURCE ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp PROPERTY SKIP_AUTOMOC ON)
-
-# Generate moc file externally and enabled SKIP_AUTOMOC on the header
-qtx_generate_moc(
- ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp
- ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp)
-set_property(
- SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.hpp
- PROPERTY SKIP_AUTOMOC ON)
-# Custom target to depend on
-set(SOBJC_MOC ${CMAKE_CURRENT_BINARY_DIR}/moc_SObjCExtra.cpp)
-add_custom_target("${MOC_INCLUDE_NAME}_SOBJC"
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/SObjCExtra_extMoc.cpp
- BYPRODUCTS ${SOBJC_MOC}
- COMMAND ${CMAKE_COMMAND} -E copy
- ${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/SObjCExtra.moc.in
- ${SOBJC_MOC})
-
-# MOC_INCLUDE_NAME must be defined by the includer
-add_executable(${MOC_INCLUDE_NAME}
- # Common sources
- ../MocInclude/ObjA.cpp
- ../MocInclude/ObjB.cpp
-
- ../MocInclude/LObjA.cpp
- ../MocInclude/LObjB.cpp
-
- ../MocInclude/EObjA.cpp
- ../MocInclude/EObjAExtra.cpp
- ../MocInclude/EObjB.cpp
- ../MocInclude/subExtra/EObjBExtra.cpp
-
- ../MocInclude/SObjA.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/SObjA.moc
- ${CMAKE_CURRENT_BINARY_DIR}/SObjB.cpp
- ${CMAKE_CURRENT_BINARY_DIR}/SObjB.moc
- ../MocInclude/SObjC.cpp
- ../MocInclude/SObjCExtra.hpp
- ../MocInclude/SObjCExtra.cpp
-
- ../MocInclude/subGlobal/GObj.cpp
- main.cpp
-)
-add_dependencies(${MOC_INCLUDE_NAME} "${MOC_INCLUDE_NAME}_SOBJC")
-target_link_libraries(${MOC_INCLUDE_NAME} ${QT_LIBRARIES})
-set_target_properties(${MOC_INCLUDE_NAME} PROPERTIES AUTOMOC ON)
diff --git a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp b/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp
deleted file mode 100644
index c697866..0000000
--- a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-#include "EObjBExtra.hpp"
-#include "EObjBExtra_p.hpp"
-
-EObjBExtraPrivate::EObjBExtraPrivate()
-{
-}
-
-EObjBExtraPrivate::~EObjBExtraPrivate()
-{
-}
-
-EObjBExtra::EObjBExtra()
- : d(new EObjBExtraPrivate)
-{
-}
-
-EObjBExtra::~EObjBExtra()
-{
- delete d;
-}
diff --git a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp b/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp
deleted file mode 100644
index 3798d7f..0000000
--- a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra.hpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#ifndef EOBJBEXTRA_HPP
-#define EOBJBEXTRA_HPP
-
-#include <QObject>
-
-class EObjBExtraPrivate;
-class EObjBExtra : public QObject
-{
- Q_OBJECT
-public:
- EObjBExtra();
- ~EObjBExtra();
-
-private:
- EObjBExtraPrivate* const d;
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp b/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp
deleted file mode 100644
index 3231fac..0000000
--- a/Tests/QtAutogen/MocInclude/subExtra/EObjBExtra_p.hpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef EOBJBEXTRA_P_HPP
-#define EOBJBEXTRA_P_HPP
-
-#include <QObject>
-
-class EObjBExtraPrivate : public QObject
-{
- Q_OBJECT
-public:
- EObjBExtraPrivate();
- ~EObjBExtraPrivate();
-};
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp b/Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp
deleted file mode 100644
index 6b92f21..0000000
--- a/Tests/QtAutogen/MocInclude/subGlobal/GObj.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-#include "GObj.hpp"
-#include "GObj_p.hpp"
-
-namespace subGlobal {
-
-class GObjLocal : public QObject
-{
- Q_OBJECT
-public:
- GObjLocal();
- ~GObjLocal();
-};
-
-GObjLocal::GObjLocal()
-{
-}
-
-GObjLocal::~GObjLocal()
-{
-}
-
-GObjPrivate::GObjPrivate()
-{
-}
-
-GObjPrivate::~GObjPrivate()
-{
-}
-
-GObj::GObj()
-{
- GObjLocal localObj;
-}
-
-GObj::~GObj()
-{
-}
-}
-
-// For the local QObject
-#include "GObj.moc"
diff --git a/Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp b/Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp
deleted file mode 100644
index 2f9ee82..0000000
--- a/Tests/QtAutogen/MocInclude/subGlobal/GObj.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef GOBJ_HPP
-#define GOBJ_HPP
-
-#include <QObject>
-
-namespace subGlobal {
-
-class GObj : public QObject
-{
- Q_OBJECT
-public:
- GObj();
- ~GObj();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp b/Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp
deleted file mode 100644
index 4a43755..0000000
--- a/Tests/QtAutogen/MocInclude/subGlobal/GObj_p.hpp
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef GOBJ_P_HPP
-#define GOBJ_P_HPP
-
-#include <QObject>
-
-namespace subGlobal {
-
-class GObjPrivate : public QObject
-{
- Q_OBJECT
-public:
- GObjPrivate();
- ~GObjPrivate();
-};
-}
-
-#endif
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt b/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt
deleted file mode 100644
index 8b4da34..0000000
--- a/Tests/QtAutogen/MocIncludeRelaxed/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project(MocIncludeRelaxed)
-include("../AutogenCoreTest.cmake")
-
-# Test moc include patterns
-set(CMAKE_AUTOMOC_RELAXED_MODE TRUE)
-
-# Shared executable
-set(MOC_INCLUDE_NAME "mocIncludeRelaxed")
-include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake)
-
-# Relaxed only executable
-add_executable(mocIncludeRelaxedOnly
- RObjA.cpp
- RObjB.cpp
- RObjC.cpp
- RMain.cpp
-)
-target_link_libraries(mocIncludeRelaxedOnly ${QT_LIBRARIES})
-set_target_properties(mocIncludeRelaxedOnly PROPERTIES AUTOMOC ON)
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp b/Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp
deleted file mode 100644
index 5b2c070..0000000
--- a/Tests/QtAutogen/MocIncludeRelaxed/RMain.cpp
+++ /dev/null
@@ -1,12 +0,0 @@
-// Relaxed AUTOMOC objects
-#include "RObjA.hpp"
-#include "RObjB.hpp"
-#include "RObjC.hpp"
-
-int main(int argv, char** args)
-{
- RObjA rObjA;
- RObjB rObjB;
- RObjC rObjC;
- return 0;
-}
diff --git a/Tests/QtAutogen/MocIncludeRelaxed/main.cpp b/Tests/QtAutogen/MocIncludeRelaxed/main.cpp
deleted file mode 100644
index 5a3148d..0000000
--- a/Tests/QtAutogen/MocIncludeRelaxed/main.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "EObjA.hpp"
-#include "EObjB.hpp"
-#include "LObjA.hpp"
-#include "LObjB.hpp"
-#include "ObjA.hpp"
-#include "ObjB.hpp"
-#include "SObjA.hpp"
-#include "SObjB.hpp"
-#include "subGlobal/GObj.hpp"
-
-int main(int argv, char** args)
-{
- subGlobal::GObj gObj;
- ObjA objA;
- ObjB objB;
- LObjA lObjA;
- LObjB lObjB;
- EObjA eObjA;
- EObjB eObjB;
- SObjA sObjA;
- SObjB sObjB;
- return 0;
-}
-
-// Header in global subdirectory
-#include "subGlobal/moc_GObj.cpp"
diff --git a/Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt b/Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt
deleted file mode 100644
index d0aaebf..0000000
--- a/Tests/QtAutogen/MocIncludeStrict/CMakeLists.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-cmake_minimum_required(VERSION 3.10)
-project(MocIncludeStrict)
-include("../AutogenCoreTest.cmake")
-
-# Test moc include patterns
-set(CMAKE_AUTOMOC_RELAXED_MODE FALSE)
-
-# Shared executable
-set(MOC_INCLUDE_NAME "mocIncludeStrict")
-include(${CMAKE_CURRENT_SOURCE_DIR}/../MocInclude/shared.cmake)
diff --git a/Tests/QtAutogen/MocIncludeStrict/main.cpp b/Tests/QtAutogen/MocIncludeStrict/main.cpp
deleted file mode 100644
index 5a3148d..0000000
--- a/Tests/QtAutogen/MocIncludeStrict/main.cpp
+++ /dev/null
@@ -1,26 +0,0 @@
-#include "EObjA.hpp"
-#include "EObjB.hpp"
-#include "LObjA.hpp"
-#include "LObjB.hpp"
-#include "ObjA.hpp"
-#include "ObjB.hpp"
-#include "SObjA.hpp"
-#include "SObjB.hpp"
-#include "subGlobal/GObj.hpp"
-
-int main(int argv, char** args)
-{
- subGlobal::GObj gObj;
- ObjA objA;
- ObjB objB;
- LObjA lObjA;
- LObjB lObjB;
- EObjA eObjA;
- EObjB eObjB;
- SObjA sObjA;
- SObjB sObjB;
- return 0;
-}
-
-// Header in global subdirectory
-#include "subGlobal/moc_GObj.cpp"
diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
new file mode 100644
index 0000000..1627b39
--- /dev/null
+++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
@@ -0,0 +1,80 @@
+cmake_minimum_required(VERSION 3.15)
+project(MocIncludeSymlink)
+include("../AutogenCoreTest.cmake")
+
+#
+# Tests if MocInclude can be build when
+# - The source directory is a symbolic link
+# - The build directory is a symbolic link
+#
+
+# -- Utility variables
+set(CS_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
+set(CB_DIR "${CMAKE_CURRENT_BINARY_DIR}")
+
+# Absolute MocInclude path
+get_filename_component(MocIncludePath "../MocInclude" ABSOLUTE)
+message("MocIncludePath: ${MocIncludePath}")
+
+# Use nested subdirectories to ensure relatives paths are correct as well
+set(BUILD_DIR_NORMAL "${CB_DIR}/Build/Normal")
+set(BUILD_DIR_LINKED "${CB_DIR}/Build/Linked")
+
+set(SL_SOURCE_DIR "${CB_DIR}/SL_Source")
+set(SL_BUILD_DIR "${CB_DIR}/SL_Build")
+
+# -- Utility macros
+function(makeSymLink origin link)
+ message("Creating symbolic link\n Link: ${link}\n To: ${origin}")
+ file(CREATE_LINK ${origin} ${link} RESULT res SYMBOLIC)
+ if(NOT (${res} STREQUAL "0"))
+ message("Symlink creation failed.\n Link: ${link}\n To: ${origin}\n Result: ${res}")
+ endif()
+endfunction()
+
+# -- Make source directory symlink
+makeSymLink(${MocIncludePath} ${SL_SOURCE_DIR} linkResult)
+if(NOT EXISTS ${SL_SOURCE_DIR})
+ message("Directory symlink can't be created. Skipping test.")
+ return()
+endif()
+
+# -- Make normal build directory
+file(REMOVE_RECURSE ${BUILD_DIR_NORMAL})
+file(MAKE_DIRECTORY ${BUILD_DIR_NORMAL})
+
+# -- Make linked build directory and symlink
+file(REMOVE_RECURSE ${BUILD_DIR_LINKED})
+file(MAKE_DIRECTORY ${BUILD_DIR_LINKED})
+makeSymLink(${BUILD_DIR_LINKED} ${SL_BUILD_DIR} linkResult)
+if(NOT EXISTS ${SL_BUILD_DIR})
+ message("Directory symlink can't be created. Skipping test.")
+ return()
+endif()
+
+
+# -- Building
+macro(buildMocInclude sourceDir binaryDir)
+ message("Building MocInclude\n - source dir: ${sourceDir}\n - binary dir: ${binaryDir}\n")
+ try_compile(result
+ "${binaryDir}"
+ "${sourceDir}"
+ MocInclude
+ CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}"
+ "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
+ "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ OUTPUT_VARIABLE output
+ )
+ if (result)
+ message(STATUS "--- Build success. ---")
+ else()
+ message(STATUS "\n### Building MocInclude failed. ###\n\n--- Output ---\n${output}")
+ message(FATAL_ERROR "--- Building MocInclude failed. End of output. ---")
+ endif()
+endmacro()
+
+message("\nTry building with\n - symbolic link source dir\n - non symbolic build dir\n")
+buildMocInclude(${SL_SOURCE_DIR} ${BUILD_DIR_NORMAL})
+
+message("\nTry building with\n - symbolic link source dir\n - symbolic link build dir\n")
+buildMocInclude(${SL_SOURCE_DIR} ${SL_BUILD_DIR})
diff --git a/Tests/QtAutogen/Tests.cmake b/Tests/QtAutogen/Tests.cmake
index 6771828..2b001d4 100644
--- a/Tests/QtAutogen/Tests.cmake
+++ b/Tests/QtAutogen/Tests.cmake
@@ -32,8 +32,8 @@ ADD_AUTOGEN_TEST(UicSkipSource)
if(QT_TEST_ALLOW_QT_MACROS)
ADD_AUTOGEN_TEST(MocCMP0071)
- ADD_AUTOGEN_TEST(MocIncludeRelaxed mocIncludeRelaxed)
- ADD_AUTOGEN_TEST(MocIncludeStrict mocIncludeStrict)
+ ADD_AUTOGEN_TEST(MocInclude)
+ ADD_AUTOGEN_TEST(MocIncludeSymlink)
ADD_AUTOGEN_TEST(MocSkipSource)
endif()
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
index 2a24421..52934f2 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -249,13 +249,13 @@ def check_target(c):
if expected["backtrace"] is not None:
expected_keys.append("backtrace")
- assert actual["fragment"] == expected["fragment"]
+ assert matches(actual["fragment"], expected["fragment"])
assert actual["role"] == expected["role"]
check_backtrace(obj, actual["backtrace"], expected["backtrace"])
assert sorted(actual.keys()) == sorted(expected_keys)
- check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]),
+ check_list_match(lambda a, e: matches(a["fragment"], e["fragment"]),
obj["link"]["commandFragments"], expected["link"]["commandFragments"],
check=check_link_command_fragments,
check_exception=lambda a, e: "Link fragment: %s" % a["fragment"],
@@ -2218,6 +2218,42 @@ def gen_check_targets(c, g, inSource):
},
],
},
+ {
+ "fragment" : ".*TargetLinkDir\\\"?$",
+ "role" : "libraryPath",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 19,
+ "command": "target_link_directories",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ {
+ "fragment" : ".*cxx_lib.*",
+ "role" : "libraries",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 6,
+ "command": "target_link_libraries",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
],
},
"archive": None,
diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
index 17ff455..b0564f5 100644
--- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
+++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
@@ -16,3 +16,4 @@ target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib)
target_compile_options(cxx_exe PUBLIC TargetCompileOptions)
target_link_options(cxx_exe PUBLIC TargetLinkOptions)
+target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir")
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)