Commit Graph

924 Commits

Author SHA1 Message Date
Robert Maynard
7a969fe21d cmMakefile: Refactor API to better handle empty config values 2020-07-03 07:43:18 -04:00
Kyle Edwards
d5b5c19278 cmGlobalGenerator: FindMakeProgram() before CMakeDetermineSystem
Prior to 147d36c, the build tool was found before the toolset was
selected, but was changed to be found after in order to support a
64-bit MSBuild (introduced in da402a0.) However, a bug was found in
64-bit MSBuild, which resulted in da402a0 being reverted in
f3cedf3 (but 147d36c was not reverted.) Move FindMakeProgram() even
earlier than it was before 147d36c, before CMakeDetermineSystem is
called, so that the Visual Studio Android support can report its
sysroot, giving Android-Determine the information it needs to
inspect the NDK.

When the bug in 64-bit MSBuild is fixed, we will have a chicken-and-
egg problem, but we don't need to worry about it for now.
2020-06-18 15:35:26 -04:00
Justin Goshi
742ff97f80 Refactor language standard computation
Instead of mutating the configure-time cmTarget's properties at generate
time, compute and store it in a cmGeneratorTarget field.
2020-06-16 16:32:34 -07:00
lumberyard-employee-dm
87c860ebad cmake --build: Fix exit code when building multiple targets
Updated the cmGlobalGenerator::Build method to check the return `retVal`
parameter supplied to the `cmSystemTools::RunSingleCommand` to validate
that each invocation of the build command returned an exit code of zero.

Fixes: #20790
2020-06-12 11:40:23 -04:00
Brad King
a432b1075c Merge topic 'getdef-expand'
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4819
2020-06-02 08:02:24 -04:00
Brad King
fff14290d2 Merge topic 'cmprop'
b36d1bdd9d Single location for cmProp typedef

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4829
2020-06-02 08:00:55 -04:00
Vitaly Stakhovsky
b36d1bdd9d Single location for cmProp typedef 2020-06-01 08:54:20 -04:00
Brad King
3020decbff Merge topic 'pch-fix-bad-ClearSourcesCache'
902858367f Merge branch 'backport-3.16-pch-fix-bad-ClearSourcesCache'
fa7b041eca PCH: Fix logic error that incorrectly clears sources during VS generation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4815
2020-06-01 07:44:35 -04:00
Vitaly Stakhovsky
7ed8c9ebe3 cmMakefile: add GetDefExpandList() that splits value into std::vector
Combines cmMakefile:GetDefinition() and cmExpandList()
2020-05-30 08:59:20 -04:00
Brad King
902858367f Merge branch 'backport-3.16-pch-fix-bad-ClearSourcesCache' 2020-05-29 06:14:59 -04:00
Brad King
fa7b041eca PCH: Fix logic error that incorrectly clears sources during VS generation
Since commit 729d997f10 (Precompile Headers: Add REUSE_FROM signature,
2019-08-30, v3.16.0-rc1~101^2), `GetPchFileObject` handles the case that
it is called first for another target's `REUSE_FROM` by calling
`AddSource` to make sure `GetObjectName` can produce the correct object
name.  However, `AddSource` causes `ClearSourcesCache` to be called,
which since commit a9f4f58f0c (cmGeneratorTarget: Clear AllConfigSources
in ClearSourcesCache, 2020-05-15, v3.16.7~2^2) now correctly erases the
`AllConfigSources` structure.  This is okay during `AddPchDependencies`,
but there is another code path in which it is problematic.

When the Visual Studio generator's `WriteAllSources` method is looping
over the sources, the `cmake_pch.cxx` source is encountered first.  This
causes `OutputSourceSpecificFlags` to call `GetPchCreateCompileOptions`,
which calls `GetPchFile`, which under MSVC with `CMAKE_LINK_PCH` calls
`GetPchFileObject`.  That leads to `ClearSourcesCache` erasing the
structure over which `WriteAllSources` is iterating!

This bug is caught by our `RunCMake.PrecompileHeaders` test when run
with the VS generator as of the commit that exposed it by fixing
`ClearSourcesCache`.  However, that change was backported to the CMake
3.16 series after testing only with later versions versions that contain
commit a55df20499 (Multi-Ninja: Add precompile headers support,
2020-01-10, v3.17.0-rc1~136^2).  By adding proper multi-config support
for PCH, that commit taught `cmLocalGenerator::AddPchDependencies` to
call `GetPchFile` with the real set of configurations instead of just
the empty string.  This allows the `GetPchFile` cache of PCH sources to
be populated up front so that the later calls to it in the
`WriteAllSources` loop as described above do not actually call
`GetPchFileObject` or `ClearSourcesCache`.  That hid the problem.

Fix this by re-ordering calls to `AddPchDependencies` to handle
`REUSE_FROM` targets only after the targets whose PCH they re-use.
Remove the now-unnecessary call to `AddSource` from `GetPchFileObject`
so that `ClearSourcesCache` is never called during `WriteAllSources`.
Update the PchReuseFrom test case to cover an ordering of targets that
causes generators to encounter a `REUSE_FROM` target before the target
whose PCH it re-uses.

Fixes: #20770
2020-05-29 05:52:03 -04:00
Cristian Adam
8f2702005a AutoMoc: Configure AutoMoc after generated sources (PCH, Unity)
Fixes: #20119
2020-05-26 13:14:27 +02:00
Brad King
d6a88d2158 cmTarget: Replace "perConfig" constructor boolean with enum 2020-05-18 12:56:55 -04:00
Brad King
25995b2b30 cmGlobalGenerator: Fix CheckTargetsForMissingSources after refactoring
Refactoring in commit 01b2d6ab74 (Modernize: Use ranged for-loops when
possible, 2019-02-07, v3.15.0-rc1~575^2) accidentally changed a loop
condition in this method from "keep iterating if srcs.empty()" to
"stop iterating if srcs.empty()".  Switch it back.

The bug could only manifest in very subtle conditions in a multi-config
generator.  Add one such case to the test suite.

Fixes: #20706
2020-05-15 05:39:25 -04:00
Marc Chevrier
2faa3f6c55 Refactoring: Third-parties public headers are under cm3p prefix
Fixes: #20666
2020-05-07 12:06:08 +02:00
Brad King
0b08c1279c Merge topic 'cmprop-state'
e267c3fddf cmState::GetInitializedCacheValue: return cmProp

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4696
2020-05-01 08:31:32 -04:00
Vitaly Stakhovsky
e267c3fddf cmState::GetInitializedCacheValue: return cmProp
cmProp alias is used; no actual change in type
2020-04-30 10:45:45 -04:00
Vitaly Stakhovsky
53675adbcf GetSafeProperty: return std::string const& 2020-04-30 10:27:16 -04:00
Vitaly Stakhovsky
36aba01223 cmGeneratorTarget::GetProperty: return cmProp 2020-04-29 10:59:39 -04:00
Marc Chevrier
aacd4e4a90 Refactoring: add cm::contains to <cmext/algorithm> 2020-04-17 10:00:03 +02:00
Brad King
156196938c Merge topic 'cmprop-source'
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp
fc223f9860 cmGlobalXCodeGenerator: Fix genex interpreter overloads

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4603
2020-04-15 09:49:46 -04:00
Brad King
a67565751f Merge topic 'msbuildUtf8Support'
bc877a7e94 Add support to indicate UTF-8 custom command pipe output encoding

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4587
2020-04-15 09:44:48 -04:00
Vitaly Stakhovsky
e64fa5f1b6 cmSourceFile::GetProperty: return cmProp 2020-04-14 10:57:17 -04:00
Justin Goshi
bc877a7e94 Add support to indicate UTF-8 custom command pipe output encoding
Adds a flag to indicate that pipe output from a custom command should be
interpreted as UTF-8 encoded. This change does not introduce a public
way to set the flag, but generators that create internally-generated
commands know if they are calling cmake, which uses UTF-8 pipes.

MSBuild added support for interpreting output of PreBuildEvent,
PreLinkEvent, PostBuildEvent, and CustomBuildStep as UTF-8. This change
will appear in Visual Studio 16.6 Preview 3. It is opt-in, and you need
to add the StdOutEncoding tag. MSBuild treats these as property bags so
if we emit the tag for earlier versions of Visual Studio it would be
safely ignored. This change emits the StdOutEncoding tag and sets it to
UTF-8 whenever the custom command UTF-8 pipe flag is set. This fixes
globalization issues when the output from cmake contained characters
that required MSBuild to interpret as UTF-8 before displaying them.
2020-04-13 12:54:47 -07:00
Ben Boeckel
f413727d27 clang-tidy: address bugprone-sizeof-expression lint 2020-04-13 11:26:03 -04:00
Vitaly Stakhovsky
aba23c747b cmMakefile::GetProperty: return cmProp 2020-04-01 10:56:34 -04:00
Vitaly Stakhovsky
3eec21a01c cmTarget::GetProperty: return cmProp 2020-03-30 15:00:14 -04:00
Vitaly Stakhovsky
c84cf42897 cmState::GetGlobalProperty: return cmProp 2020-03-25 09:10:46 -04:00
Brad King
94139ac58e Merge topic 'export-repeat'
8affe9aa33 export: Fix use-after-free on multiple calls overwriting same FILE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4494
2020-03-20 06:17:00 -04:00
Brad King
8affe9aa33 export: Fix use-after-free on multiple calls overwriting same FILE
CMake 3.16 and below allow multiple `export()` calls with the same output
file even without using `APPEND`.  The implementation worked by accident
by leaking memory.  Refactoring in commit 5444a8095d (cmGlobalGenerator:
modernize memrory managemenbt, 2019-12-29, v3.17.0-rc1~239^2) cleaned up
that memory leak and converted it to a use-after-free instead.

The problem is caused by using the `cmGlobalGenerator::BuildExportSets`
map to own `cmExportBuildFileGenerator` instances.  It can own only
one instance per output FILE name at a time, so repeating use of the
same file now frees the old `cmExportBuildFileGenerator` instance
and leaves the pointer in the `cmMakefile::ExportBuildFileGenerators`
vector dangling.  Move ownership of the instances into `cmMakefile`'s
vector since its entries are not replaced on a repeat output FILE.

In future work we should introduce a policy to error out on this case.
For now simply fix the use-after-free to restore CMake <= 3.16 behavior.

Fixes: #20469
2020-03-19 06:41:39 -04:00
Vitaly Stakhovsky
36a5b3d1d1 cmMakefile::AddCacheDefinition: Add overload that accepts std::string value 2020-03-11 09:40:43 -04:00
Kyle Edwards
9590c3a400 Generator: Don't allow Ninja Multi-Config variables on other generators
We may want to enable these variables later on with specific
semantics. To avoid breaking backwards compatibility, make it an
error to use them for now.
2020-02-27 09:23:08 -05:00
Kyle Edwards
7abc3d61ac Ninja Multi-Config: Fix issue with framework dependencies and Autogen
Fixes: #20345
2020-02-17 08:24:57 -05:00
Kyle Edwards
2ac835b9f9 Refactor: Allow generators to decide default configuration for build
And allow them to read any cache values they need.
2020-02-04 14:13:07 -05:00
Brad King
a4d7a79beb Merge topic 'ninja-1.10'
ccaa0bccc4 Ninja: Do not clean metadata when re-generating inside a running build
657820a00b Ninja: Track when running to re-generate during a build
b12b013028 Ninja: Factor metadata cleanup into dedicated method
5d92e60d81 Ninja: Skip cleandead and recompact if build.ninja is missing
dd0a4718fd Ninja: Fix CMAKE_NINJA_OUTPUT_PATH_PREFIX with Ninja 1.10
0944caaebb Tests: Fix RunCMake.CMP0037 test with Ninja 1.10
9d4883cce5 Tests: Fix RunCMake.Ninja test for Ninja 1.10

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4290
2020-01-28 11:35:24 -05:00
Brad King
657820a00b Ninja: Track when running to re-generate during a build
Tell CMake explicitly when it is re-running inside a `ninja` invocation
to re-generate the build system.
2020-01-27 15:39:04 -05:00
Vitaly Stakhovsky
1398517f31 AppendProperty: convert value param to std::string 2020-01-25 10:37:00 -05:00
Brad King
56a3e84a67 Merge topic 'realpath-cache'
9d5a554cc9 cmGlobalGenerator: Add cache for realpath() results

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4220
2020-01-20 11:55:04 -05:00
Brad King
cd6f6b2a9f Merge topic 'cmake-ctest-arguments'
4153d8445b Add CMAKE_CTEST_ARGUMENTS variable to pass command-line arguments to ctest

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4168
2020-01-17 09:40:23 -05:00
Tim Blechmann
9d5a554cc9 cmGlobalGenerator: Add cache for realpath() results
Cache the results of `realpath()` system calls in `cmGlobalGenerator`
to avoid repeating such calls for the same paths over and over.
2020-01-16 11:29:25 +08:00
Robert Goulet
4153d8445b Add CMAKE_CTEST_ARGUMENTS variable to pass command-line arguments to ctest
Fixes: #20172
2020-01-15 15:02:56 -05:00
Marc Chevrier
f466cea3c9 cmMakefile: modernize memory management 2020-01-14 11:03:07 +01:00
Marc Chevrier
a00960288b GlobalGenerator family: modernize memory management 2020-01-07 11:03:11 +01:00
Marc Chevrier
5444a8095d cmGlobalGenerator: modernize memrory managemenbt 2019-12-30 16:55:39 +01:00
Brad King
64e2891cbd Merge topic 'stdstring-target'
c34b4497f8 cmTarget: add std::string overloads

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4137
2019-12-17 11:09:20 -05:00
Vitaly Stakhovsky
c34b4497f8 cmTarget: add std::string overloads 2019-12-14 09:30:28 -05:00
Kyle Edwards
5a8a9f7229 Ninja: Add multi-config variant
Co-Authored-by: vector-of-bool <vectorofbool@gmail.com>
2019-12-13 10:51:46 -05:00
Marc Chevrier
36c8cae2e8 cmLocalGenerator: modernize memory management 2019-12-10 00:24:06 +01:00
Brad King
fc99130752 Merge branch 'backport-unity-object-libraries' into unity-object-libraries 2019-12-08 11:21:38 -05:00
Cristian Adam
fa93b4a59b Unity: Proper handling of object libraries
Fixes: #20051
2019-12-07 15:44:38 +01:00