856 Commits

Author SHA1 Message Date
Brad King
fa5bf870df Merge topic 'implicit-includes'
5990ecb741 Compute implicit include directories from compiler output
d751d2d2ed CMakeDetermineCompilerABI: set locale to C for try_compile()
c765ae495a CMakeDetermineCompilerABI: pass verbose flag during compilation
8c5221fb1f try_compile: Preserve special characters in COMPILE_DEFINITIONS
15ad830062 Refactor exclusion of -I/usr/include to avoid per-language values

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2716
2019-01-22 11:37:49 -05:00
Brad King
15ad830062 Refactor exclusion of -I/usr/include to avoid per-language values
Add a `CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES` to contain the
hard-coded list of paths to be excluded from `-I` arguments so that the
values remain excluded even if the per-language
`CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` variants change.

This is needed to preserve our historical exclusion of `-I/usr/include`
even when it is not a real implicit include directory.  A policy may be
needed to remove it later.
2019-01-21 11:14:07 -05:00
Regina Pfeifer
ef61997b1b clang-tidy: Use emplace 2019-01-17 13:12:02 -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
f255280fd9 PIE link options: Update strategy to fix performance regression
Fixes: #18700
2018-12-19 19:41:27 +11:00
Marc Chevrier
c4b4d8b3a6 POSITION_INDEPENDENT_CODE: Manage link flags for executables
Fixes: #14983, #16561
2018-11-11 17:34:09 +01:00
Cengizhan Pasaoglu
c67ab22cdc Using front() and back() instead of calculations 2018-11-06 21:43:33 +03:00
Brad King
a052479a5c Merge topic 'msvc-custom-rc-mt'
bd9bfc6449 MSVC: Respect CMAKE_RC_COMPILER and CMAKE_MT in vs_link_{dll,exe}
0033676796 CUDA: Enable RC language on Windows
02f566a559 MSVC: Factor out enable_language(RC) call into helper macro
b601bb6f1c CUDA: Find CMAKE_LINKER on Windows
3eebe28ef4 cmLocalNinjaGenerator: Simplify CreateRulePlaceholderExpander

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2424
2018-11-02 07:57:06 -04:00
Mateusz Zych
bd9bfc6449 MSVC: Respect CMAKE_RC_COMPILER and CMAKE_MT in vs_link_{dll,exe}
CMake commands vs_link_dll and vs_link_exe, performing linking on MSVC,
are responsible for calling resource compiler and manifest tool.

Before this commit, both of these tools were called directly, with the
expectation that they are available in the `PATH`. This has been fixed
by respecting CMake variables `CMAKE_RC_COMPILER` and `CMAKE_MT`
defining paths to these tools.

Fixes: #17804
2018-10-29 13:40:47 -04: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
Vitaly Stakhovsky
b8bb6ba653 cmGeneratorTarget::GetExportMacro: return const std::string* 2018-10-16 11:12:19 -04:00
Brad King
e2dd6ac977 Merge topic 'remove-AddCompileDefinitions'
8f076acdb0 cmLocalGenerator: Remove AddCompileDefinitions method

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2470
2018-10-11 07:44:03 -04: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
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
Brad King
d686f81e58 Restore possibly regressed CMP0018 logic
Refactoring in commit f4ff60a803 (cmMakefile: Make GetSafeDefinition
return std::string const&, 2018-09-05) changed the treatment of the
empty string in CMP0018 diagnostic logic.  Restore the behavior.
2018-09-19 07:42:08 -04:00
Vitaly Stakhovsky
f4ff60a803 cmMakefile: Make GetSafeDefinition return std::string const& 2018-09-18 11:16:46 -04:00
Brad King
f13d4b1077 Merge topic 'replace-os-x-name-with-macos'
ab2e35d614 Replace occurrences of "Mac OS X" with "macOS" in comments
fc1602456a Help: Replace occurrences of "Mac OS X" with "macOS"

Acked-by: Kitware Robot <kwrobot@kitware.com>
Reviewed-by: Gregor Jasny <gjasny@googlemail.com>
Reviewed-by: Clinton Stimpson <clinton@elemtech.com>
Merge-request: !2351
2018-09-11 08:28:05 -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
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
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
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
Vitaly Stakhovsky
ada121e573 cmStateDirectory: use const std::string& for return values 2018-08-12 18:59:21 +10:00
Brad King
75844dd609 Merge topic 'cleanup-find-cstr'
69ca85cc7f Remove unnecessary c_str() in RegularExpression::find calls

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2271
2018-08-09 08:00:03 -04:00
Vitaly Stakhovsky
69ca85cc7f Remove unnecessary c_str() in RegularExpression::find calls 2018-08-07 15:28:24 -04:00
Sebastian Holtermann
b6802cd506 cmGeneratedFileStream: clang-tidy applied to remove redundant `c_str` calls
After changing the ``cmGeneratedFileStream`` methods to accept
``std::string const&`` instead of ``const char*`` we don't
need to call ``std::string::c_str`` anymore when passing
a ``std::string`` to a ``cmGeneratedFileStream`` method.

This patch removes all redundant ``std::string::c_str``
calls when passing a string to a ``cmGeneratedFileStream`` method.

It was generated by building CMake with clang-tidy enabled using
the following options:

-DCMAKE_CXX_CLANG_TIDY=/usr/bin/clang-tidy-4.0;-checks=-*,readability-redundant-string-cstr;-fix;-fix-errors
2018-08-07 17:02:39 +02:00
Sebastian Holtermann
2e9199b291 cmLocalGenerator: Respect user requested implicit include directories order
In ``cmLocalGenerator::GetIncludeDirectories`` append the user requested
implicit include directories first, then append the remaining implicit
include directories.  By By doing so we keep the user requested order of
implicit include directories.
2018-07-30 09:22:46 +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
Sebastian Holtermann
1f36652ef4 cmLocalGenerator: Style changes: Private local variable renames
Code style change in ``cmLocalGenerator::GetIncludeDirectories``.

Rename a variable to reflect its purpose a little bit better.
2018-07-25 12:26:25 +02:00
Sebastian Holtermann
db866d05de cmLocalGenerator: Style change: Wrap temporary strings and code in braces
Code style change in ``cmLocalGenerator::GetIncludeDirectories``.

Embrace ``{}`` temporary strings and code that uses them to minimize their
lifetime.
2018-07-25 12:24:16 +02:00
Sebastian Holtermann
3713dc9b8e cmLocalGenerator: Style change: Wrap temporary strings and code in braces
Code style change in ``cmLocalGenerator::GetIncludeDirectories``.

Embrace ``{}`` temporary strings and code that uses them to minimize their
lifetime.
2018-07-25 12:20:56 +02:00
Sebastian Holtermann
d1077c1ce6 cmLocalGenerator: Style change: Use return value of std::set::insert
Code style change in ``cmLocalGenerator::GetIncludeDirectories()``.

Use the return value of ``std::set::insert`` instead of testing
if the entry already exists in the set using ``std::find``.
2018-07-25 12:08:19 +02: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
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
Brad King
1b6ec4b9e3 Merge topic 'features-c++20'
8570dc7f64 Help: Update compiler versions in cmake-compile-features.7.rst
874d3d2948 Help: Add release note for C++ 20 support
7f295b1bd3 Features: Activate C++ 20 support for Clang 5.0+
71cb8ce3a1 Features: Activate C++ 20 support for GNU 8.0+
8f146c4508 Features: Activate C++ 20 support for MSVC 19.12.25835+
7fe580a362 Features: Add infrastructure for C++ 20 language standard
1b328e09a3 Features: Use -std=c++17 for C++ 17 on Clang 5.0+
0bc3e5788a Features: Use -std=c++17 for C++ 17 on GNU 8.0+

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1892
2018-04-02 10:01:23 -04:00
Brad King
7fe580a362 Features: Add infrastructure for C++ 20 language standard
Issue: #17849
2018-03-27 07:40:54 -04:00
Brad King
70c50aa23c Revert "Remove CTestTestfile.cmake when BUILD_TESTING is OFF"
Revert commit v3.8.0-rc1~305^2 (Remove CTestTestfile.cmake when BUILD_TESTING
is OFF, 2016-11-14) again.  We reverted it once in commit v3.8.0-rc3~22^2
(Revert "Remove CTestTestfile.cmake when BUILD_TESTING is OFF", 2017-03-06) but
it was accidentally restored by commit v3.11.0-rc1~387^2 (server: add
"ctestInfo" request to get test info, 2017-10-25), perhaps due to conflict
resolution during rebase.

We cannot remove `CTestTestfile.cmake` when testing is off because it breaks
projects that never enable testing but create their own `CTestTestfile.cmake`
manually instead.  Revert the change again and add a test case.
2018-03-26 07:44:22 -04:00
Brad King
2deb9b7f34 Genex: Fix COMPILE_LANGUAGE in SYSTEM include directories
When evaluating `INTERFACE_SYSTEM_INCLUDE_DIRECTORIES`, or evaluating
`INTERFACE_INCLUDE_DIRECTORIES` on an imported target, thread the
compile language through to the generator expression evaluator so
that it can support `$<COMPILE_LANGUAGE:...>`.

Fixes: #17811
2018-03-12 11:45:01 -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
Pavel Solodovnikov
c85bb007df Reduce allocation of temporary values on heap.
- Use `std::move` while inserting temporary results into vectors.
- Change `push_back` to `emplace_back` where appropriate.
2018-01-26 13:24:45 +03: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
Domen Vrankar
deeba85f81 CMake: enable setting default dir creation permissions
Introduces CMAKE_DEFAULT_DIRECTORY_INSTALL_PERMISSIONS
variable which enables the user to specify the default
permissions for directory creation. This setting is then
used to auto set the permissions on directories which
are implicitly created by install() and file(INSTALL)
commands such as CMAKE_INSTALL_PREFIX directories.
2017-11-08 20:27:03 +01:00
Brad King
1348f97784 Merge topic 'server-test-info'
35a52bd1 server: add "ctestInfo" request to get test info

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !1414
2017-11-07 08:18:59 -05:00