1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-24 05:03:26 +08:00

1425 Commits

Author SHA1 Message Date
Bruno Manganelli
cc2a5261f8 Factor out enum MessageType into dedicated header
Reduce the number of files relying on `cmake.h`.
2019-01-16 08:16:31 -05:00
Brad King
6845e2559d Add deprecation warnings for policies CMP0065 and below
The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for some policies
to encourage projects to port away from setting policies to OLD.
2019-01-11 14:47:20 -05:00
Artur Ryt
cbf0c0fce4 cmake: Enable --warn-uninitialized inside string(CONFIGURE) and configure_file
Fixes: #18489
2018-12-30 08:31:09 +11:00
Artur Ryt
67ac4ed1dc cmMakefile: Move uninitialized vars logic into MaybeWarnUninitialized() 2018-12-28 15:16:37 +01:00
Artur Ryt
5257af3634 cmMakefile: move common logic to IsProjectFile function 2018-12-28 15:16:37 +01:00
Regina Pfeifer
b2aa3aedea clang-tidy: Use default member initialization 2018-12-15 10:52:37 +01:00
Artur Ryt
fe9a16c80f cmMakefile: Fix @CMAKE_CURRENT_LIST_LINE@ for ExpandVariablesInStringNew
Added check for variable name in @@ evaluation and test for
configuring @CMAKE_CURRENT_LIST_LINE@ with new CMP0053

Fixes: #18646
2018-12-12 08:29:14 -05:00
Artur Ryt
dda4755b46 cmMakefile: Fix ConfigureString not passing filename and line
It enables to use CMAKE_CURRENT_LIST_LINE in string(CONFIGURE)
Added tests for it for ${} and @@ notattion for old CMP0053
and ${} for new
2018-12-12 08:29:01 -05:00
Regina Pfeifer
5731ec30f0 clang-tidy: fix warnings from version 7
Fix some warnings that are new since clang-tidy version 4, and update
`.clang-tidy` to suppress the rest.
2018-11-20 10:36:08 -05:00
Kyle Edwards
0f5c1b404b find_package(): Add policy to remove the FindQt module
Removing FindQt.cmake gives Qt upstream a path forward to export its
own QtConfig.cmake files which can be found by find_package()
without having to explicitly specify CONFIG. Projects that still
want to use Qt3/4 can call find_package(Qt[34]), include(FindQt),
or add FindQt.cmake to their CMAKE_MODULE_PATH.
2018-11-14 15:05:06 -05:00
R2RT
53a5aec899 CMP0053: Fix double warning on uninitialized variables in -P mode
When `CMP0053` is not set to OLD or NEW then we compute both variants
in case we need to warn about a behavior change.  Do not allow both
code paths to produce an uninitialized variable warning.

Fixes: #18552
2018-11-05 08:31:09 -05:00
R2RT
f92f93467e cmMakefile: Rename SuppressWatches to SuppressSideEffects 2018-11-05 08:29:10 -05:00
Kyle Edwards
fc8955e889 add_subdirectory: Run subdirectory install rules in correct order
Before this change, install rules created by add_subdirectory()
would be executed after all of the top-level install rules, even
if they were declared before the top-level rules. This change
adds a new policy, CMP0082, which interleaves the add_subdirectory()
install rules with the other install rules so they are run in the
correct order.
2018-10-10 10:26:39 -04:00
Marc Chevrier
f9717725f9 link_directories(): enhance capabilities 2018-09-25 23:59:59 +10:00
Marc Chevrier
a71caab46b LINK_DIRECTORIES: Add new properties and commands
These new capabilities enable to manage link directories

Two new properties:
* target properties: LINK_DIRECTORIES and INTERFACE_LINK_DIRECTORIES

One new command
* target_link_directories(): to populate target properties

Fixes: #17215
2018-09-25 23:59:58 +10:00
Craig Scott
fe751ad1fb Merge topic 'deprecate-policy-old'
0c709cb2a2 Add deprecation warnings for policies CMP0063 and below

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2397
2018-09-20 11:30:24 -04:00
Brad King
a8f628c0a4 Merge topic 'getsafedef-stdstring'
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const&

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2350
2018-09-18 11:18:00 -04:00
Vitaly Stakhovsky
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& 2018-09-18 11:16:46 -04:00
Brad King
0c709cb2a2 Add deprecation warnings for policies CMP0063 and below
The OLD behaviors of all policies are deprecated, but only by
documentation.  Add an explicit deprecation diagnostic for some policies
to encourage projects to port away from setting policies to OLD.
2018-09-17 14:16:48 -04:00
Brad King
333804fa0e Merge topic 'out-of-dir-linking'
a1ad0a699b target_link_libraries: Allow use with targets in other directories
9bbae5ae28 cmTarget: Future-proof AddLinkLibrary target lookup scope
f9cb6f618a cmExportFileGenerator: Use cmGeneratorTarget::ResolveTargetReference
18441a6269 cmGeneratorTarget: Factor target name resolution out of link item resolution
2f708f5d65 Make internal TARGET_PROPERTY generator expressions more robust
94a75801c8 Android.mk: De-duplicate link libraries logic during export
8a63b23d16 cmGlobalGenerator: Remove unused FindLocalGenerator method

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Patrick Stotko <stotko@cs.uni-bonn.de>
Merge-request: !2370
2018-09-14 13:25:07 -04:00
Brad King
a1ad0a699b target_link_libraries: Allow use with targets in other directories
Previously the command did not allow naming targets on the LHS that
were not created in the calling directory.  Lift this restriction to
enable more flexible use by projects.

Targets named on the RHS will need to be looked up during generation in
the scope of the call site rather than the scope of the LHS target.
Introduce an internal syntax in `[INTERFACE_]LINK_LIBRARIES` properties
to specify target names that need to be looked up in a directory other
than that containing the target on which the property is set.  Add
minimal documentation of the syntax to help users that encounter it.

Unfortunately CMake previously did allow such calls in the case that
only `INTERFACE` libraries are specified, but those libraries would be
looked up in the target's directory rather than the caller's.  Add
policy `CMP0079` to enable the new behavior with new lookup scope in a
compatible way.

Fixes: #17943
2018-09-12 13:06:36 -04:00
Vitaly Stakhovsky
13d10ee616 cmState::GetInitializedCacheValue: Return as const std::string* 2018-09-10 09:31:48 -04:00
Brad King
917d98699e Merge topic 'definitions-get'
437d0c16c7 cmStateSnapshot::GetDefinition(): Return std::string const*

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2356
2018-09-07 16:08:02 -04:00
Brad King
e1ebec55d4 Merge topic 'grd-stdstring'
4d89830d71 cmMakefile: Make GetRequiredDefinition return std::string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2347
2018-09-06 09:54:56 -04:00
Vitaly Stakhovsky
437d0c16c7 cmStateSnapshot::GetDefinition(): Return std::string const*
Expose std::string type used internally in cmDefinitions instead of const char*
2018-09-05 20:08:17 -04:00
Vitaly Stakhovsky
4d89830d71 cmMakefile: Make GetRequiredDefinition return std::string
In all cases the return value is converted to std::string anyway.

Also remove unnecessary `c_str()` calls in arguments to
`GetRequiredDefinition`.
2018-09-05 15:15:55 -04:00
Vitaly Stakhovsky
6f16be6a62 Remove unnecessary c_str() calls
Use the new IsOn(),IsOff() overloads.
2018-09-05 15:12:57 -04:00
Vitaly Stakhovsky
c8fd23ec6f cmMakefile: return directories as const std::string& 2018-08-27 14:07:43 -04:00
Vitaly Stakhovsky
ada121e573 cmStateDirectory: use const std::string& for return values 2018-08-12 18:59:21 +10:00
Craig Scott
ae2b12a95c Merge topic 'project-injected-no-cmp0048'
6646771b0f project: Do not issue CMP0048 warnings on injected call
08eb157c03 Tests: Add case showing CMP0048 warning on injected project command

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2235
2018-07-25 08:15:02 -04:00
Brad King
6646771b0f project: Do not issue CMP0048 warnings on injected call
Fixes: #18202
2018-07-24 13:14:10 -04:00
Marc Chevrier
c1f5a44b28 LINK_OPTIONS: Add new family of properties
This family enable to manage link flags

Three new properties:
* directory property: LINK_OPTIONS
* target properties: LINK_OPTIONS and INTERFACE_LINK_OPTIONS

Two new commands
* add_link_options(): to populate directory property
* target_link_options(): to populate target properties

Fixes: #16543
2018-06-06 17:22:39 +02:00
Kitware Robot
d7204e649e Revise C++ coding style using clang-format-6.0
Run the `clang-format.bash` script to update all our C and C++ code to a
new style defined by `.clang-format`.  Use `clang-format` version 6.0.

* If you reached this commit for a line in `git blame`, re-run the blame
  operation starting at the parent of this commit to see older history
  for the content.

* See the parent commit for instructions to rebase a change across this
  style transition commit.
2018-06-01 09:53:42 -04:00
Brad King
f248f8ad78 Merge topic 'parallel_build_option'
1ab3881ec9 cmake: Add options for parallel builds to --build mode

Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Henry Schreiner <henryschreineriii@gmail.com>
Merge-request: !1962
2018-05-29 10:05:09 -04:00
Florian Maushart
1ab3881ec9 cmake: Add options for parallel builds to --build mode
While we already support `cmake --build . -- -j`, the options after `--`
are specific to the native build tool.  Add new options `--parallel
[<N>]` and `-j [<N>]` to abstract this and map to the proper option
for the native build tool.
2018-05-25 09:42:20 -04:00
Florian Jacomme
b1a05d6c76 Revise implementation of case-insensitive command names
Store both the as-written and lower-case command names and use
the latter to avoid case-insensitive string comparisons.

With this I obtain 2-6% speed increase (on Windows) for the configure
step with no significant changes in memory usage.  A case-insensitive
comparison is a lot slower than just calling `==` because the operator
will use things like memcmp, so prefer the latter.

The `cmSystemTools::LowerCase` function allocates a new string each time
it is called, so before this change we were allocating in:

* cmMakefile::Configure two times for each function
  (to look for `cmake_minimum_required` and `project`)
* cmMakefile::ExecuteCommand twice by function by calling
  cmState::GetCommand and copying the name

Now we are only allocating once by function instead of four.
2018-05-22 10:56:24 -04:00
Vitaly Stakhovsky
0c47ed6430 cmMakefile: Convert private helpers to file static functions
The two-argument forms of `AddDefineFlag` and `RemoveDefineFlag`
need no access to `cmMakefile` class members.  They are used only
within the implementation file.
2018-05-01 10:25:49 -04:00
Vitaly Stakhovsky
e13fa223fc cmMakefile: Improve ExpandVariablesInString return type
Return `std::string const&` instead of a `const char*` that points
into a string anyway.  Update call sites accordingly.
2018-05-01 10:24:31 -04:00
Brad King
22e4837442 Merge topic 'fix-CMAKE_DISABLE_SOURCE_CHANGES-top-dir'
60cb75e4a1 Fix CMAKE_DISABLE_SOURCE_CHANGES recognition of top of build tree

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2001
2018-04-25 08:57:08 -04:00
Marc Chevrier
60cb75e4a1 Fix CMAKE_DISABLE_SOURCE_CHANGES recognition of top of build tree
The change in commit v3.11.0-rc1~480^2 (UseJava: add_jar OUTPUT_DIR
option used only for jar generation, 2017-10-12) added code of the form
`file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR})`.  This exposed an existing
bug in `CMAKE_DISABLE_SOURCE_CHANGES` in which it does not recognize
that the top of the build tree itself is in the build tree.  Fix that
now.

Fixes: #17933
2018-04-24 10:42:00 -04:00
Marc Chevrier
cb83314e65 add_compile_definitions: add new command
This command manages preprocessor definitions at directory level and
supports generator expressions.

Fixes: #15374
2018-04-20 09:28:13 -04:00
Brad King
391a5837ee cmake_policy: Add undocumented PARENT_SCOPE option to GET
Policies affecting the behavior of CMake-provided macros and functions
need to be able to get the policy setting as of the call site rather
than the definition site.  Add an undocumented option to do this.
2018-04-18 08:09:56 -04:00
Brad King
2cdefcbe62 Merge topic 'variable_watch-on-PARENT_SCOPE'
65198cfd0f variable_watch: trigger on variables set via PARENT_SCOPE

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1948
2018-04-12 11:32:37 -04:00
Matteo Settenvini
65198cfd0f variable_watch: trigger on variables set via PARENT_SCOPE
Make sure that we also trigger variable watches when a variable
is set in the parent scope.

Fixes: #17827
2018-04-11 15:02:07 -04:00
Brad King
5c10e8f608 Merge topic 'fix-crash-trace-exp-uninit-vars'
aad360eb3d Fix crash with --trace-expand --warn-uninitialized together

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1944
2018-04-10 11:32:56 -04:00
R2RT
aad360eb3d Fix crash with --trace-expand --warn-uninitialized together
Some code paths in `ExpandVariablesInString{New,Old}` were not checking
the `filename` parameter for a null pointer, but this can happen when
using the above flags together.  Add the checks and a test case.

Fixes: #17896
2018-04-09 11:59:07 -04:00
jrp2014
0ad329f7c0 Sanitize paths from LINK_DIRECTORIES directory property
Normally they are sanitized by the `link_directories` command before
populating the property, but projects may set the property directly.
2018-04-04 14:42:20 -04:00
Brad King
7fe580a362 Features: Add infrastructure for C++ 20 language standard
Issue: #17849
2018-03-27 07:40:54 -04:00
Craig Scott
82df2fe17e Merge topic 'policy-version-range'
45408b5ea1 cmake_minimum_required: Optionally set policies with version range
6a41aa2abd cmPolicies: Split parsing and impl of ApplyPolicyVersion
1d00ed7cf7 cmPolicies: Drop unnecessary check from ApplyPolicyVersion
0df559832b cmPolicies: Pass policy version as std::string

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1864
2018-03-22 15:24:49 -04:00
Brad King
45408b5ea1 cmake_minimum_required: Optionally set policies with version range
Teach `cmake_minimum_required` and `cmake_policy(VERSION)` to support a
version range of the form `<min>[...<max>]`.  Define this to mean that
version `<min>` is required, but known policies up to those introduced
by `<max>` will be set to `NEW`.  This will allow projects to easily
specify a range of versions for which they have been updated.
2018-03-21 08:00:28 -04:00