summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
Commit message (Collapse)AuthorAgeFilesLines
* Revise include order using clang-format-6.0Kitware Robot2019-10-011-2/+4
| | | | | 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.
* clang-tidy: modernize-deprecated-headersRegina Pfeifer2019-09-161-2/+2
|
* Source sweep: Replace cmExpandList with the shorter cmExpandedListSebastian Holtermann2019-08-231-2/+1
| | | | | | | | | | | | This replaces the code pattern ``` std::vector<std::string> args; cmExpandList(valueStr, args, ...) ``` with ``` std::vector<std::string> args = cmExpandedList(valueStr, ...) ```
* Source sweep: Use cmStrCat for string concatenationSebastian Holtermann2019-08-221-7/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch is generated by a python script that uses regular expressions to search for string concatenation patterns of the kind ``` std::string str = <ARG0>; str += <ARG1>; str += <ARG2>; ... ``` and replaces them with a single `cmStrCat` call ``` std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...); ``` If any `<ARGX>` is itself a concatenated string of the kind ``` a + b + c + ...; ``` then `<ARGX>` is split into multiple arguments for the `cmStrCat` call. If there's a sequence of literals in the `<ARGX>`, then all literals in the sequence are concatenated and merged into a single literal argument for the `cmStrCat` call. Single character strings are converted to single char arguments for the `cmStrCat` call. `std::to_string(...)` wrappings are removed from `cmStrCat` arguments, because it supports numeric types as well as string types. `arg.substr(x)` arguments to `cmStrCat` are replaced with `cm::string_view(arg).substr(x)`
* avoid adding multiple consecutive string literals to std::stringRolf Eike Beer2019-08-181-2/+1
| | | | While at it change some single character additions to be of type char.
* Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgumentSebastian Holtermann2019-08-141-2/+2
|
* Merge topic 'tidy_inefficient_string'Brad King2019-08-071-2/+3
|\ | | | | | | | | | | | | 18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3648
| * clang-tidy: Enable performance-inefficient-string-concatenationSebastian Holtermann2019-08-051-2/+3
| | | | | | | | | | | | | | Enables the clang-tidy test performance-inefficient-string-concatenation and replaces all inefficient string concatenations with `cmStrCat`. Closes: #19555
* | cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenizeSebastian Holtermann2019-08-051-1/+1
|/ | | | | | | | | | This adds the following functions to `cmStringAlgorithms`: - `cmIsSpace` - `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`) - `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`) - `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to accept `cm::string_view`)
* cmStringAlgorithms: Move string functions to the new cmStringAlgorithms.hSebastian Holtermann2019-07-291-1/+1
| | | | | This adds the `cmStringAlgorithms.h` header and moves all string functions from `cmAlgorithms.h` to `cmStringAlgorithms.h`.
* cmMakefile: Let AddDefinition accept a value as cm::string_viewSebastian Holtermann2019-07-241-3/+2
| | | | | | | | | | | | | | | | This changes `cmMakefile::AddDefinition` to take a `cm::string_view` as value argument instead of a `const char *`. Benefits are: - `std::string` can be passed to `cmMakefile::AddDefinition` directly without the `c_str()` plus string length recomputation fallback. - Lengths of literals passed to `cmMakefile::AddDefinition` can be computed at compile time. In various sources uses of `cmMakefile::AddDefinition` are adapted to avoid `std::string::c_str` calls and the `std::string` is passed directly. Uses of `cmMakefile::AddDefinition`, where a `nullptr` `const char*` might be passed to `cmMakefile::AddDefinition` are extended with `nullptr` checks.
* Source: std::string related cleanupVitaly Stakhovsky2019-05-151-5/+5
|
* Merge topic 'fix_ios_try_compile'Brad King2019-05-061-1/+8
|\ | | | | | | | | | | | | 275b6b3194 iOS: Fix try_compile FILE_COPY not to fail Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3272
| * iOS: Fix try_compile FILE_COPY not to failAlexandru Croitor2019-05-061-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | When building for iOS, the compiled target is placed into a bundle. If a single-configuration generator is used, like Makefiles or Ninja, the try_compile FILE_COPY behavior fails to find the bundle, because it only looks for the bundle inside a Debug subfolder (presumably to support a multi-configuration generator like Xcode). Consider looking for the bundle in the root try_compile folder, as well as in the location specified by CMAKE_TRY_COMPILE_CONFIGURATION. Closes: #19211
* | MSVC: Add abstraction for runtime library selectionBrad King2019-04-171-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace our hard-coded defaults for `/MD` and `/MDd` with a first-class abstraction to select the runtime library from an enumeration of logical names. We've long hesitated to do this because the idea of "runtime library selection" touches on related concepts on several platforms. Avoid that scope creep by simply defining an abstraction that applies only when targeting the MSVC ABI on Windows. Removing the old default flags requires a policy because existing projects may rely on string processing to edit them and choose a runtime library under the old behavior. Add policy CMP0091 to provide compatibility. Fixes: #19108
* | Merge topic 'ghs_os_dir'Brad King2019-04-081-2/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | a1e6b414b9 GHS: Update GHS_BSP_NAME processing 266dadf868 GHS: Print status message regarding GHS_OS_DIR Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3123
| * | GHS: Print status message regarding GHS_OS_DIRFred Baksik2019-03-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | -- Rename platform script so it runs before initial try_compile() in project() command. -- Fix incorrect variable name GHS_OS_DIR_OPTION -- Remove unnecessary ".*" from REGEX expression for GHS_CANDIDATE_OS_DIRS -- Forward GHS_OS_DIR_OPTION to try_compile() and preserve trailing whitespace of the variable.
* | | Merge topic 'toolchain-include_directories'Brad King2019-03-261-1/+16
|\ \ \ | |/ / |/| / | |/ | | | | | | 588fa1bb9e Restore support for include_directories() in toolchain files Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3140
| * Restore support for include_directories() in toolchain filesBrad King2019-03-251-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Any `include_directories()` calls in toolchain files are used during our ABI detection step even though it does not include any system headers. Since commit 5990ecb741 (Compute implicit include directories from compiler output, 2018-12-07, v3.14.0-rc1~108^2), that check is also used to detect implicit include directories. Any `include_directories()` in a toolchain file are detected as implicit and later excluded from explicit specification on compiler command lines, thus breaking the purpose of the calls in the first place. Fix the implicit include directory detection step to avoid using paths from `include_directories()` calls in the toolchain file. Fixes: #19079
* | cmSystemTools::Error: consolidate parameters into single std::stringVitaly Stakhovsky2019-02-201-2/+2
|/
* try_compile: Restore expansion of ;-list in COMPILE_DEFINITIONSBrad King2019-02-151-1/+1
| | | | | | | | | | | | | | | | | | | | | The quoting added by commit 8c5221fb1f (try_compile: Preserve special characters in COMPILE_DEFINITIONS, 2019-01-21, v3.14.0-rc1~108^2~3) broke the case that the `COMPILE_DEFINITIONS` value contains a `;`. Without the quoting the `;` would be generated literally in an unquoted argument in the test `CMakeLists.txt` file and would then be expanded. With quoting the `;` is preserved, which is not the old behavior. Fix this by expanding the `;`-list ahead of time. Add test cases for behavior with both `#` and `;`. This was noticed with the PGI compiler where we set `CMAKE_CXX*_STANDARD_COMPILE_OPTION` to values like `--c++17;-A`. The symptom had also been observed while preparing commit ef8f237686 (ParseImplicitIncludeInfo: add SunPro Fortran and PGI compiler, Cray fix, 2019-01-29, v3.14.0-rc1~26^2~2) but was not recognized at the time as a regression. Revert the workaround added by that commit. Fixes: #18919
* Merge topic 'cmake-files-directory'Brad King2019-01-251-1/+1
|\ | | | | | | | | | | | | | | 3e867ed400 cmake: inlined files dir constant and removed it from cmake.h Acked-by: Kitware Robot <kwrobot@kitware.com> Rejected-by: vvs31415 <vstakhovsky@fastmail.com> Merge-request: !2655
| * cmake: inlined files dir constant and removed it from cmake.hBruno Manganelli2019-01-211-1/+1
| |
* | Merge topic 'implicit-includes'Brad King2019-01-221-1/+3
|\ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
| * | try_compile: Preserve special characters in COMPILE_DEFINITIONSBrad King2019-01-211-1/+3
| | | | | | | | | | | | | | | | | | | | | When generating the `CMakeLists.txt` file, we pass the values given to our `COMPILE_DEFINITIONS` option in an `add_definitions` call. Pass them as bracket arguments to preserve special characters like `#`.
* | | Merge topic 'use-emplace'Brad King2019-01-211-2/+2
|\ \ \ | |/ / |/| | | | | | | | | | | | | | | | | ef61997b1b clang-tidy: Use emplace 2e5307a2a4 CTestSVN: Accept std::string in SVNInfo constructor Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2811
| * | clang-tidy: Use emplaceRegina Pfeifer2019-01-171-2/+2
| |/
* | GHS: try_compile() now uses GHS platform variablesFred Baksik2019-01-161-0/+16
|/ | | | | | | -- Forward GHS platform variables to try_compile() CMAKE_TRY_COMPILE_PLATFORM_VARIABLES only worked for source signature try_compile() -- Update tests to no longer add GHS platform variables to try_compile() -- Avoid linker error in GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt by building library
* Factor out enum MessageType into dedicated headerBruno Manganelli2019-01-161-30/+33
| | | | Reduce the number of files relying on `cmake.h`.
* PIE link options: Update strategy to fix performance regressionMarc Chevrier2018-12-191-0/+18
| | | | Fixes: #18700
* try_compile/try_run: Add support for LINK_OPTIONS option.Marc Chevrier2018-12-011-0/+23
|
* CMP0083: fix warning message on try_compileMarc Chevrier2018-11-191-0/+7
| | | | Fixes: #18593
* Revise C++ coding style using clang-format-6.0Kitware Robot2018-06-011-11/+17
| | | | | | | | | | | | 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.
* cmake: Add options for parallel builds to --build modeFlorian Maushart2018-05-251-1/+2
| | | | | | | 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.
* Genex: Fix COMPILE_LANGUAGE propagation through try_compileBrad King2018-03-121-1/+2
| | | | | | | | When evaluating include directories during export to a `try_compile` test project, thread the compile language through to the generator expression evaluator so it can support `$<COMPILE_LANGUAGE:...>`. Issue: #17811
* Reduce raw string pointers usage.Pavel Solodovnikov2018-01-311-11/+9
| | | | | | | | | | * 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.
* Reduce allocation of temporary values on heap.Pavel Solodovnikov2018-01-261-5/+5
| | | | | - Use `std::move` while inserting temporary results into vectors. - Change `push_back` to `emplace_back` where appropriate.
* Meta: replace empty-string assignments with `clear()`.Pavel Solodovnikov2017-09-151-3/+3
|
* Meta: modernize old-fashioned loops to range-based `for`.Pavel Solodovnikov2017-09-121-30/+21
| | | | | | Changes done via `clang-tidy` with some manual fine-tuning for the variable naming and `auto` type deduction where appropriate.
* IWYU: Mark cmConfigure.h with pragma: keepDaniel Pfeifer2017-08-261-1/+0
| | | | Also remove `#include "cmConfigure.h"` from most source files.
* Use C++11 nullptrDaniel Pfeifer2017-08-241-1/+1
|
* Provide and use CM_FALLTHROUGHDaniel Pfeifer2017-06-031-0/+4
|
* Access string npos without instancePavel Solodovnikov2017-06-011-1/+1
|
* Add options for separate compile and link sysrootsBrad King2017-05-091-0/+4
| | | | | | | | | 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>
* Use quotes for non-system includesDaniel Pfeifer2017-04-111-2/+2
| | | | | | | | | | | | | Automate with: git grep -l '#include <cm_' -- Source \ | xargs sed -i 's/#include <\(cm_.*\)>/#include "\1"/g' git grep -l '#include <cmsys/' -- Source \ | xargs sed -i 's/#include <\(cmsys\/.*\)>/#include "\1"/g' git grep -l '#include <cm[A-Z]' -- Source \ | xargs sed -i 's/#include <\(cm[A-Z].*\)>/#include "\1"/g'
* fix some include-what-you-use diagnosticsDaniel Pfeifer2017-02-171-0/+1
|
* try_compile: extend CMP0067 to honor language standards for CUDA.Robert Maynard2016-12-121-2/+77
|
* clang-tidy: apply misc-suspicious-string-compare fixesDaniel Pfeifer2016-12-121-11/+6
|
* clang-tidy: apply readability-redundant-control-flow fixesDaniel Pfeifer2016-12-121-1/+0
|
* try_compile: Add policy CMP0067 to honor language standardsBrad King2016-12-061-0/+79
| | | | | | | | | | | | | | Projects use `try_compile` to check if they will be able to compile some particular source code. When a language standard variable like `CMAKE_CXX_STANDARD` is set, then the project intends to compile source code using a compiler mode for that standard. Therefore it makes sense for `try_compile` to use that standard in the test project too. Unfortunately this was not done when support for the `CMAKE_CXX_STANDARD` variable was first implemented. Add a policy to introduce the improved behavior in a compatible way. Closes: #16456