Commit Graph

47480 Commits

Author SHA1 Message Date
Matt Davies 2ce42f281f VS: Add VS_SETTINGS source file property
VS_SETTINGS is a list of key value pairs that get written as item
metadata for the associated non-built file. The entire value of
VS_SETTINGS is evaluated as a generator expression.
2020-03-20 16:16:58 +00:00
Matt Davies 53116d3942 VS: Use unordered_map to write HLSL settings. 2020-03-20 16:16:44 +00:00
Ryan Thornton 75e82a13db GoogleTest: Add new DISCOVERY_MODE option to gtest_discover_tests
Introducing a new DISCOVERY_MODE mode option, which provides greater control
over when gtest_discover_tests perforsm test discovery.

It has two supported modes:
* POST_BUILD
* PRE_TEST

POST_BUILD is the default behavior, which adds a POST_BUILD command
to perform test discovery after the test has been built.

PRE_TEST is a new mode, which delays test discovery until test execution.

DISCOVERY_MODE can be controlled in two ways:
1. Setting the DISCOVERY_MODE when calling gtest_discover_tests
2. Setting the global CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE
   prior to calling gtest_discover_tests

By delaying test discovery until ctest runtime,
we can provide better cross compile support,
because we're more likely to be in an environment that can run the test executable.

This was achieved by moving the command for test discovery
into the generated ctest include file.

In PRE_TEST mode, the generated include file now has the form:

if(EXISTS "path/to/test.exe")
  if("path/to/test.exe" IS_NEWER_THAN "path/to/ctest_file")
    // command to discover tests
    // and generate ctest_file
  endif()
  include("path/to/ctest_file")
endif()
elseif()
  // test not built
endif()

Which generates the appropriate CTest files at runtime
and regenerates the CTest files when the executable is updated.

In the old approach, test discovery was always added as POST_BUILD step
and the executable was ran in order to scan for tests.

If the test executable failed to run for any reason,
this resulted in a link failure.

This failure could more commonly occur when cross compiling,
because your build environment might not have
the appropriate runtime environment dlls required to run the test executable.

I also ran into the issue when compiling a Qt application using Qt Creator.
Qt Creator manages its build and runtime environments separately
and only adds the Qt dlls to the environment during runtime -- not during build.

So when gtest_discover_tests ran my test executable,
it promptly crashed because the environment wasn't correct,
which resulted in a build failure.

Setting the DISCOVERY_MODE to PRE_TEST fixed my build failure
by delaying test discovery until runtime,
because this allowed the test exe to run in the proper environment.

A few non-trivial implementation details worth noting:

1. bracket_arguments

In the PRE_TEST side, parameters whose contents might contain special characters,
need to be handled with great care.

To aid in escaping these list arguments, backslashes, and other special characters,
and ensuring that they are preserved in the generated file,
bracket arguments (i.e. [== <...> ==]) are used.

For example:

    gtest_discover_tests(
      ...
      EXTRA_ARGS how now "\"brown\" cow"
    )

Generates a file with the following call:

    gtest_discover_tests_impl(
      ...
      TEST_EXTRA_ARGS [==[how;now;"brown" cow]==]
    )

This way the arguments are forwarded correctly.

2. multi-config generators

Multi-Config generators (e.g. MSBuild) now work more correctly in
PRE_TEST than POST_BUILD.

PRE_TEST is more correct because it will generate a unique CTest file for each configuration.

It generates a per config file responsible for test discovery:
    foo[1]_include-Debug.cmake
    foo[1]_include-MinSizeRel.cmake
    foo[1]_include-Release.cmake
    foo[1]_include-RelWithDebInfo.cmake

A per config file for containing the google tests:
    foo[1]_tests-Debug.cmake

And an outer ctest file:
    foo[1]_include-Debug.cmake

That is generically written to include the correct configuration file
by looking at the value of ${CTEST_CONFIGURATION_TYPE} when CTest runs.

POST_BUILD, in contrast, preserves the existing functionality.

Tests are disocvered based on the last configuration that was chosen
and only a single file is produced:
    foo[1]_include.cmake
    foo[1]_tests.cmake

But it runs with whatever executable requested by ctest --config,
which means it's possible to run the wrong tests
if some tests were enabled in one configuration but not another.
2020-03-20 10:14:39 -05:00
Francisco Facioni ecc0086bfc cmake-gui: Fix use-after-free in Open-possible check
Fix `QCMake::checkOpenPossible` to copy `toLocal8Bit().data()` before
its lifetime expires.
2020-03-20 08:38:31 -04:00
Brad King 9c3dddb4f5 Merge branch 'release-3.17' 2020-03-20 07:35:44 -04:00
Brad King e3185e3d1b CMake 3.17.0 v3.17.0 2020-03-20 06:26:14 -04:00
Brad King 6bea0b2290 Merge branch 'release-3.17' 2020-03-20 06:22:48 -04:00
Brad King dfca1887b0 Merge topic 'FindMatlab-r2020' into release-3.17
75331a4578 FindMatlab: Add R2020a=9.8

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4507
2020-03-20 06:22:48 -04:00
Brad King a2bbc34ace Merge topic 'FindMatlab-r2020'
75331a4578 FindMatlab: Add R2020a=9.8

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4507
2020-03-20 06:22:48 -04:00
Brad King bb22f4588f Merge branch 'release-3.16' 2020-03-20 06:21:11 -04:00
Brad King 3ab89b5475 Merge topic 'GetPrerequisites-vcruntime-is-system' into release-3.17
417b765f5a GetPrerequisites: Classify vcruntime libraries as system

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4506
2020-03-20 06:17:49 -04:00
Brad King 1294cb3485 Merge branch 'release-3.17' 2020-03-20 06:17:49 -04:00
Brad King 7c0346e90a Merge topic 'GetPrerequisites-vcruntime-is-system'
417b765f5a GetPrerequisites: Classify vcruntime libraries as system

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4506
2020-03-20 06:17:49 -04:00
Brad King 6786d7c92e Merge branch 'release-3.17' 2020-03-20 06:17:01 -04:00
Brad King 119d1dadce Merge topic 'export-repeat' into release-3.17
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 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
Kitware Robot 9bbea2344b CMake Nightly Date Stamp 2020-03-20 00:01:11 -04:00
Ryan Thornton 889a7146ff GoogleTestAddTests: Refactor into callable method
Move test discovery logic into new gtest_discover_tests_impl method
and make GoogleTestAddTests aware of whether it is being launched in
CMake's script mode.

When launched in script mode, gtest_discover_tests_impl is called
passing arguments obtained from the definitions passed into the call to cmake.
(i.e. cmake -P GoogleTestAddTests -D <arg1> -D <arg2> ...)

This preserves the existing behavior assumed by GoogleTest.cmake.
Unit tests are unchanged and still pass.

Looking ahead, it also allows GoogleTestAddTests to be included in generated files
and call gtest_discover_tests_impl to perform test discovery at test runtime
with the new PRE_TEST discovery mode introduced later in this branch.

My original approach attempted to call execute_process(cmake -P ...) in
the generated file, the same way POST_BUILD is doing, but I ran into
difficulties serializing the command arguments correctly.

By exposing a way to call gtest_discover_tests_impl directly from our generated file,
we remove a layer of shell quoting / parsing that our arguments have to survive,
which simplifies the act of producing a generated file that behaves the
same as its POST_BUILD counterpart.
2020-03-19 11:59:20 -05:00
Michael Hirsch, Ph.D 75331a4578 FindMatlab: Add R2020a=9.8
This allows Matlab R2020a to be recognized as a valid Matlab version.
2020-03-19 12:47:10 -04:00
Brad King 2a085de535 Merge branch 'GetPrerequisites-vcruntime-is-system' into release-3.16
Merge-request: !4506
2020-03-19 10:19:43 -04:00
Err0rC0deX 417b765f5a GetPrerequisites: Classify vcruntime libraries as system
Previously GetPrerequisites classified `vcruntime*.dll` as type "other".
They should be classified as type "system".
2020-03-19 10:17:40 -04:00
Vitaly Stakhovsky ef408dd232 cmState::GetTargetTypeName: return type is *cmProp 2020-03-19 08:55:03 -04:00
Vitaly Stakhovsky 0bf0e35e59 cmCacheManager::GetProperty: return cmProp 2020-03-19 08:18:42 -04:00
Brad King 60db3af147 Merge topic 'cmprop-state'
bd89133543 cmState::GetCacheEntryValue: return cmProp

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4493
2020-03-19 07:18:27 -04:00
Brad King 7bdf84d2d5 Merge topic 'target-improve'
b915fec56e cmTarget: minor code improvements

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4483
2020-03-19 07:17:39 -04:00
Brad King e37f67c7f7 Merge topic 'CheckLanguage-private-vars'
36baf1f13c CheckLanguage: hide commonly used variable names

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4497
2020-03-19 07:17:00 -04:00
Brad King 2154d0239f Merge branch 'release-3.17' 2020-03-19 06:57:52 -04:00
Brad King 0586123ede Merge topic 'trace-format-json-doc'
1994f950ff cmake: List valid values for --trace-format on the command line
e39766d84a Help: Fix documentation of --trace-format parameter

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4500
2020-03-19 06:57:52 -04:00
Brad King 8fad32f5b9 Merge topic 'trace-format-json-doc' into release-3.17
1994f950ff cmake: List valid values for --trace-format on the command line
e39766d84a Help: Fix documentation of --trace-format parameter

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4500
2020-03-19 06:57:51 -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
Kitware Robot d995be9ead CMake Nightly Date Stamp 2020-03-19 00:01:09 -04:00
Kyle Edwards 1994f950ff cmake: List valid values for --trace-format on the command line 2020-03-18 16:16:46 -04:00
Kyle Edwards e39766d84a Help: Fix documentation of --trace-format parameter 2020-03-18 16:02:04 -04:00
Hannes Vogt 36baf1f13c CheckLanguage: hide commonly used variable names
The check_language sets internal variables with a common name in the
caller's scope: `result`, `output` and `content`.
They are now prefixed with `_cl_`,
inspired by the CheckLibraryExists module.
2020-03-18 17:47:06 +01:00
Brad King 863b0fa2ac Merge topic 'FindRuby-updates'
46064c8193 FindRuby: Add support for versions up to 2.7
675eaf3bd0 FindRuby: Update MSVC runtime library selection
b970e25d98 FindRuby: Remove extra whitespace
ecdace4d61 FindRuby: Include FPHSA closer to where it is used
f52f496138 FindRuby: Provide Ruby_LIBRARIES result variable
b00d736a0b FindRuby: Add dedicated tests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4481
2020-03-18 09:09:18 -04:00
Brad King d9ad00119d Merge topic 'FindPkgConfig-broken-pkg-config'
1c99f5df28 FindPkgConfig: Add test for specified pkg-config tool missing
b59f36aad8 FindPkgConfig: Unset results when pkg-config is broken

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4451
2020-03-18 09:08:12 -04:00
Brad King 2d3eeffc5d Merge topic 'bootstrap-version-crlf'
2ec6fbcb9b bootstrap: Tolerate trailing content in CMakeVersion.cmake components

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4491
2020-03-18 09:07:24 -04:00
Brad King 9abc99e905 Merge topic 'FindPython-version-validation-fix' into release-3.17
cc7f116cb4 FindPython: fix regression on version validation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4492
2020-03-18 07:54:23 -04:00
Brad King 0d8e2f7ba9 Merge branch 'release-3.17' 2020-03-18 07:54:23 -04:00
Brad King 3c7774e207 Merge topic 'FindPython-version-validation-fix'
cc7f116cb4 FindPython: fix regression on version validation

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4492
2020-03-18 07:54:23 -04:00
Kitware Robot 5a8eec41fc CMake Nightly Date Stamp 2020-03-18 00:01:11 -04:00
Vitaly Stakhovsky bd89133543 cmState::GetCacheEntryValue: return cmProp 2020-03-17 12:09:20 -04:00
Marc Chevrier cc7f116cb4 FindPython: fix regression on version validation
In commit 3dab4682f6 (FindPython: reduces consumption of resources,
2020-02-10, v3.17.0-rc1~11^2) we accidentally broke the python
executable version validation when the "LOCATION" strategy is used
with the plain `FindPython` module.  Fix the logic and add test
cases covering those combinations.

Fixes: #20465
2020-03-17 10:08:34 -04:00
Julien Marrec 46064c8193 FindRuby: Add support for versions up to 2.7
Fixes: #20370
2020-03-17 08:43:10 -04:00
Brad King 675eaf3bd0 FindRuby: Update MSVC runtime library selection
Use the `MSVC_TOOLSET_VERSION` variable computed by CMake to get the
matching Ruby library name component.

Inspired-by: Julien Marrec <julien.marrec@gmail.com>
2020-03-17 08:39:06 -04:00
Vitaly Stakhovsky b915fec56e cmTarget: minor code improvements 2020-03-17 08:33:57 -04:00
Brad King bee0100396 Merge topic 'file-archive'
c7e1198a23 file: Add ARCHIVE_{CREATE|EXTRACT} subcommands

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4475
2020-03-17 08:06:57 -04:00
Brad King 97562a2023 Merge topic 'property-computer'
fad0ee5404 cmTargetPropertyComputer::GetProperty: return cmProp

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4482
2020-03-17 08:06:18 -04:00
Brad King d2e0b8bcfd Merge topic 'prop_t'
60f57d0dcc cmPropertyMap: Introduce cmProp as return type for GetProperty() functions

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4471
2020-03-17 08:05:29 -04:00
Brad King 2b720f6ab6 Merge topic 'mf_profiling_json'
897af4c266 cmMakefileProfilingData: Fix ambiguous conversion to Json::Value

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4479
2020-03-17 08:04:46 -04:00