1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-06-18 09:48:41 +08:00

362 Commits

Author SHA1 Message Date
Brad King
83c1657ff7 Unity build: Generate sources during Compute step
The unity build sources need to be added for all generators.  Create
them during `cmGlobalGenerator::Compute` to avoid duplicating the calls
in every generator.  We already handle Qt autogen there too.

Issue: #19789
2019-10-03 14:55:22 -04:00
Kitware Robot
ed98209ddc Revise include order using clang-format-6.0
Run the `clang-format.bash` script to update our C and C++ code to a new
include order `.clang-format`.  Use `clang-format` version 6.0.
2019-10-01 12:26:36 -04:00
Justin Goshi
4d6334824d fileapi: add backtraces for LINK_PATH and LINK_DIRECTORIES 2019-09-18 14:00:39 -04:00
Justin Goshi
5bd65dff7a cmLocalGenerator: Add OutputLinkLibraries overload with backtraces 2019-09-18 14:00:39 -04:00
Justin Goshi
291c83f063 cmLocalGenerator: Add GetTargetCompileFlags overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
8e973b8e8d cmLocalGenerator: Add GetTargetFlags overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
4d5bbb7704 cmLocalGenerator: Add GetStaticLibraryFlags overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
1f6a436bf4 cmLocalGenerator: Add AddCompileOptions overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
5355a60fd0 cmLocalGenerator: Add AppendCompileOptions overload with backtraces 2019-09-10 10:45:41 -04:00
Justin Goshi
a20d2c85d0 cmLocalGenerator: Add AppendFlags overload with backtraces 2019-09-09 09:43:34 -04:00
Brad King
ca8c3d64c8 Merge topic 'use-using'
1d3f5ebb0d clang-tidy: Enable check modernize-use-using
a1ddf2d0ba clang-tidy: Replace typedef with using

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3782
2019-09-06 12:38:04 -04:00
Brad King
5acf0de1fe cmLocalGenerator: Remove AppendFlags 'const char*' overload
Update call sites to ensure the `std::string` argument can be
constructed safely.
2019-09-05 10:31:56 -04:00
Regina Pfeifer
a1ddf2d0ba clang-tidy: Replace typedef with using
Automate the conversion with

  perl -i -0pe 's/typedef ([^;]*) ([^ ]+);/using $2 = $1;/g'

then manually fix a few places.
2019-09-04 18:03:01 +02:00
Cristian Adam
7114c141e2 Unity build: Add support for Ninja and Makefile generators 2019-08-29 16:44:09 +02:00
Cristian Adam
b8626261e9 Precompile headers: Add methods to generate PCH sources
Co-Author: Daniel Pfeifer <daniel@pfeifer-mail.de>
2019-08-28 11:47:40 -04:00
Kitware Robot
54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP 2019-08-09 10:41:44 -04:00
Brad King
0d025f75c1 Merge topic 'implicit-includes-CPATH'
2d0b0e2b9d Do not exclude include directories made implicit by CPATH

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3395
2019-05-31 09:03:28 -04:00
Brad King
2d0b0e2b9d Do not exclude include directories made implicit by CPATH
Entries of the `CPATH` environment variable are implicitly searched as
include directories by some C/C++ compilers.  Since commit 5990ecb741
(Compute implicit include directories from compiler output, 2018-12-07,
v3.14.0-rc1~108^2) these entries are detected by CMake and included in
the `CMAKE_{C,CXX}_IMPLICIT_INCLUDE_DIRECTORIES` variables.

However, we should not exclude them from explicit specification via `-I`
or particularly `-isystem` because they are meant as user-specified
include directories that can be re-ordered without breaking compiler
builtin headers.  In particular, we need explicit requests via
`include_directories` with the `SYSTEM` option to result in `-isystem`
so that third-party headers do not produce warnings.

Co-Author: Ben Boeckel <ben.boeckel@kitware.com>
Fixes: #19291
2019-05-30 09:24:59 -04:00
Sebastian Holtermann
735c6f39d9 Fix invalid ///! doxygen comment line starts
In various places `///!` was used to start a comment line.  This is not valid
Doygen syntax.  This patch replaces `///!` comment starts with `//!`.
2019-03-31 11:27:12 +02:00
Vitaly Stakhovsky
0281f9a4ca cmMakefile::ConfigureFile: Accept std::string parameters 2019-02-18 20:48:19 -05:00
Brad King
60c06620a6 Merge topic 'cmoutputconverter-simplify'
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory.

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2831
2019-01-29 09:18:42 -05:00
Sebastian Holtermann
f16dfdf71f cmLocalGenerator: Simplify GetIncludeDirectories
This patch strips the `stripImplicitDirs` and `appendAllImplicitDirs`
parameters from the `cmLocalGenerator::GetIncludeDirectories` method and makes
it a wrapper into the new `cmLocalGenerator::GetIncludeDirectoriesImplicit`
method.  `cmLocalGenerator::GetIncludeDirectoriesImplicit` is the renamed old
implementation of `cmLocalGenerator::GetIncludeDirectories` and still
accepts `stripImplicitDirs` and `appendAllImplicitDirs`.

The motivation is that there's only *one* case where
`cmLocalGenerator::GetIncludeDirectories` is called with the
`stripImplicitDirs` parameter being `false` (QtAutoGen), but many other places
where it is called using the `true` default value.

QtAutoGen is modified to use `cmLocalGenerator::GetIncludeDirectoriesImplicit`
directly.  In two use cases of `cmLocalGenerator::GetIncludeDirectories`
the manually set `true` value for `stripImplicitDirs` is removed.
2019-01-28 08:41:28 -05:00
Bruno Manganelli
b6a957c969 cmOutputConverter: move ConvertToRelativePath to cmStateDirectory. 2019-01-27 15:48:57 +00:00
Vitaly Stakhovsky
614876c638 cmLocalUnixMakefileGenerator3: more methods accept std::string 2019-01-22 11:11:13 -05:00
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
Marc Chevrier
c4b4d8b3a6 POSITION_INDEPENDENT_CODE: Manage link flags for executables
Fixes: #14983, #16561
2018-11-11 17:34:09 +01:00
Vitaly Stakhovsky
b2c85cb698 cmLocalGenerator::AppendDefines: Remove const char* overloads
Accept const std::string& arguments only
2018-10-26 06:54:32 -04:00
Brad King
753ab3c978 Add generator APIs to get build settings with backtraces
In cmGeneratorTarget and cmLocalGenerator we offer several APIs to get
build settings like include directories, compile definitions, source
files, etc.  Add corresponding APIs that include backtrace information.
2018-10-18 08:26:27 -04:00
Brad King
52311484dd cmLocalGenerator: Make MoveSystemIncludesToEnd file-local 2018-10-18 08:26:27 -04:00
Brad King
8f076acdb0 cmLocalGenerator: Remove AddCompileDefinitions method
This method offers the same definitions as `GetTargetDefines` except
that it excludes the "export" macro on shared libraries.  Update call
sites to use `GetTargetDefines` instead.  Some of them were incorrectly
excluding the export macro.
2018-10-10 09:34:12 -04:00
Bartosz Kosiorek
ab2e35d614 Replace occurrences of "Mac OS X" with "macOS" in comments
Apple's main Operating system changed their name from OS X to macOS:

    https://www.engadget.com/2016/06/13/os-x-is-now-macos/

Revise source comments accordingly.
2018-09-10 13:34:09 +02:00
Brad King
9da844d8cb Merge topic 'lg-directory'
50fbfee3a0 cmLocalGenerator: return directories as const std::string&

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2309
2018-08-28 13:43:48 -04:00
Vitaly Stakhovsky
50fbfee3a0 cmLocalGenerator: return directories as const std::string& 2018-08-27 15:48:57 -04:00
Marc Chevrier
974de0e199 static library: add property STATIC_LIBRARY_OPTIONS
issue: #18251
2018-08-15 15:20:18 +02:00
Sebastian Holtermann
b0b820ea39 cmLocalGenerator: Extend the functionality of `GetIncludeDirectories()`
What ``cmLocalGenerator::GetIncludeDirectories`` does
-----------------------------------------------------

In general it concatenates the

1. ``target->GetIncludeDirectories(LANG)`` and the
2. ``CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES``.

Additionally it performs some sorting and special treatment of the

- ``CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES``.

By default all ``CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES`` are stripped from
the result list.

When explicitly requested (by setting ``stripImplicitInclDirs=false``) *some*
implicit directories are appended to the result list.  The implicit directories
that *are* appended are those that were requested to be included by

1. ``target->GetIncludeDirectories(LANG)`` or
2. ``CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES``.

All other implicit directories are still stripped from the result list.

The reason to not simply append all implicit directories is that Qt4's moc has
problems to parse some headers that might be found in the implicit system
include directories (See commit d2536579d51e77827b8e55f39123316324314781
and
[QTBUG-28045](https://bugreports.qt.io/browse/QTBUG-28045)
).
That has been solved in Qt5's moc though.

Extension request to ``cmLocalGenerator::GetIncludeDirectories``
----------------------------------------------------------------

For Qt5's moc we like to have an option that allows to append *all* implict
include directories to the result list, not just those that were user requested.

Changes to ``cmLocalGenerator::GetIncludeDirectories``
------------------------------------------------------

- Shorten the function parameter name ``stripImplicitInclDirs`` to
  ``stripImplicitDirs``.

- Add new boolean function parameter ``appendAllImplicitDirs``
  with a default value ``false``.

The old default behavior of the function stays the same, but a specialized
behavior can be requested by AUTOMOC for Qt4/Qt5 respectively.
2018-07-25 12:45:10 +02:00
Ephi Sinowitz
76ad2ecb50 Order SYSTEM include directories after non-system directories
An effect of the `-isystem` flag is to search the directory after those
specified via `-I` flags.  Make behavior more consistent on compilers
that do not have any `-isystem` flag by explicitly moving system include
directories to the end.
2018-04-23 11:47:52 -04:00
Pavel Solodovnikov
653b894683 Reduce raw string pointers usage.
* Change some functions to take `std::string` instead of
  `const char*` in the following classes: `cmMakeFile`, `cmake`,
  `cmCoreTryCompile`, `cmSystemTools`,  `cmState`, `cmLocalGenerator`
  and a few others.
* Greatly reduce using of `const char*` overloads for
  `cmSystemTools::MakeDirectory` and `cmSystemTools::RelativePath`.
* Remove many redundant `c_str()` conversions throughout the code.
2018-01-31 18:23:03 +03:00
Frank Winklmeier
aed227fd5a cmLocalGenerator: change ImportedGeneratorTargets from vector to map
For large number of targets significant amount of time is spent in
cmLocalGenerator::FindGeneratorTargetToUse, which uses find_if on a
vector to locate the given target. Using a map instead of vector for
ImportedGeneratorTargets (as done for cmMakefile::ImportedTargets)
provides a significant speedup (up to factor of 2).
2018-01-30 14:04:37 -05:00
Frank Winklmeier
4443adc1c0 cmLocalGenerator: remove public GetImportedGeneratorTargets
GetImportedGeneratorTargets is not used anywhere hence remove it
to avoid exposing the type of ImportedGeneratorTargets.
2018-01-30 17:51:14 +01:00
Marc Chevrier
0448311179 sourceFile properties: add property INCLUDE_DIRECTORIES 2018-01-24 15:10:10 +01:00
Marc Chevrier
3f935e690a LocalGenerator: refactoring
Introduce method AppendCompileOptions to support
future source file property COMPILE_OPTIONS.
2018-01-23 10:24:47 +01:00
Daniel Pfeifer
ca2233e31f IWYU: Mark cmConfigure.h with pragma: keep
Also remove `#include "cmConfigure.h"` from most source files.
2017-08-26 07:41:04 +02:00
Daniel Pfeifer
5962db4389 Use C++11 nullptr 2017-08-24 23:39:47 +02:00
Daniel Pfeifer
cbcfb79f9c Use C++11 unordered containers 2017-08-22 23:05:27 +02:00
Aaron Orenstein
af3fd6f22f Performance: Add an index to Change cmLocalGenerator::GeneratorTargets.
Add an index to Change cmLocalGenerator::GeneratorTargets for faster lookup by
name.

Also changed a bunch of uses of cmLocalGenerator::GetGeneratorTargets() to take
const references instead of copying the vector.

Represent generator targets as a map (name -> target) to make name lookups more
efficient instead of looping through the entire vector to find the desired one.
2017-08-16 15:35:38 -07:00
Brad King
53e89b6ab0 Add options for separate compile and link sysroots
Add `CMAKE_SYSROOT_COMPILE` and `CMAKE_SYSROOT_LINK` variables to as
operation-specific alternatives to `CMAKE_SYSROOT`.  This will be useful
for Android NDKs that compile and link with different sysroot values
(e.g. `r14` with unified headers).

Co-Author: Florent Castelli <florent.castelli@gmail.com>
2017-05-09 14:21:54 -04:00
Brad King
d037be122e cmLocalGenerator: Add a hook for compiler flags used at link time
When using a compiler to drive linking we add compiler flags from
`CMAKE_<LANG>_FLAGS` in case they affect the way the compiler invokes
the linker, but we don't add flags from other places that are meant only
for compiling sources.  Rather than calling the `AddLanguageFlags`
method (which is used to add flags for compiling sources) directly, add
an intermediate method that is used when adding the flags for linking.
This will give us a way to add language-specific compiler flags needed
when driving the linker in the same place on the command line as other
compiler flags go.
2017-05-01 10:33:05 -04:00
Brad King
b115bc49ff Features: Refactor <LANG>_STANDARD update
In order to support generator expressions in target COMPILE_FEATURES
we apply them at generate time.  Move this step to the beginning of
generation instead of doing it on demand while collecting flags.
This avoids repeating the process unnecessarily, and will then allow
`cmLocalGenerator::AddCompilerRequirementFlag` to be used any time
during generation.
2017-05-01 10:33:05 -04:00
Ruslan Baratov
7d057b2738 Clang IPO (LTO) support 2017-04-28 17:13:56 +03:00
Brad King
a8667467ea Add IPO compiler flags more consistently in generators
Move addition of IPO flags into `cmLocalGenerator::AddLanguageFlags`
because all call sites of that need the IPO flags, but not all were
following the call with `AppendFeatureOptions`.
2017-04-27 16:15:07 -04:00