summaryrefslogtreecommitdiffstats
path: root/Source/cmCoreTryCompile.cxx
Commit message (Collapse)AuthorAgeFilesLines
* CheckSourceCompiles: Avoid linker warning with -fembed-bitcodeCraig Scott2022-04-091-0/+6
| | | | | | | | | | | | | | | When the Apple linker sees -headerpad_max_install_names and bitcode is enabled with a flag like -fembed-bitcode, it issues a warning and ignores the -headerpad_max_install_names flag. This causes unrelated compiler and linker flag checks to fail for valid flags. In f745e0497e (CheckCompilerFlags: Catch linker warning about ignored flags, 2022-01-03), we started detecting linker warnings, which caused a regression for projects that were setting -fembed-bitcode in their CMAKE_CXX_FLAGS or similar. Prevent that regression by removing the -headerpad_max_install_names linker flag when we know it will warn and be ignored anyway. Fixes: #23390 Issue: #23408
* Source: Replace most calls to sprintf with snprintfSean McBride2021-10-251-1/+2
|
* Source: Fix clang -Wimplicit-fallthrough warningsSean McBride2021-09-281-0/+3
|
* Rename cmProp in cmValueMarc Chevrier2021-09-211-15/+15
|
* cmProp: cm::string_view cast operator must be explicitMarc Chevrier2021-09-141-3/+3
| | | | | | | To avoid ambiguity on std::string assigment between the following two cmProp cast operators: * operator const std::string&() const noexcept * operator cm::string_view() const noexcept
* cmProp: refactoring: transform alias in classMarc Chevrier2021-08-081-6/+4
| | | | | | To handle safely the values used by CMake variables and properties, introduce the class cmProp as a replacement from the simple pointer to std::string instance.
* try_compile: Propagate CMP0126 to the generated test projectBrad King2021-07-201-0/+7
| | | | | Set policy CMP0126 to the value used in the calling project. It may affect toolchain file behavior.
* HIP: Add language to CMakeRobert Maynard2021-06-071-1/+20
|
* ARMClang: Do not automatically add cpu/arch compile or link optionsLingkai Dong2021-04-271-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | The compile options `--march=<arch>` and `--mcpu=<cpu>` and the link option `--cpu=<cpu>` are automatically added by CMake based on `CMAKE_SYSTEM_PROCESSOR` or `CMAKE_SYSTEM_ARCH`. But this is not sufficient, because armclang also supports enabling or disabling features using `+<feature>`: -mcpu=<name>[+[no]<feature>+...] For example: -mcpu=cortex-a57+nocrypto+nofp+nosimd+crc (Reference: https://developer.arm.com/documentation/dui0774/k/Compiler-Command-line-Options/-mcpu?lang=en) The problem is, even if a project adds a flag with features it needs, CMake still adds flags, resulting in code that is compiled with wrong CPU features and unable to run. Add policy `CMP0123` to not automatically add compile or link options, and let projects set them instead. Co-Author: Brad King <brad.king@kitware.com> Fixes: #21173
* try_compile: Improve error message when a file cannot be removedBrad King2021-04-151-5/+9
|
* ISPC: Generated Headers suffix configurable with a better defaultRobert Maynard2020-12-141-0/+2
| | | | | | | | | The target property `ISPC_HEADER_SUFFIX` and associated global variable now can control the suffix used when generating the C/C++ interoperability ISPC headers. In addition the default suffix is now "_ispc.h" which matches the common convention that the ISPC compiler team uses and recommends.
* ISPC: Support generation for multiple instruction setsRobert Maynard2020-09-041-0/+2
|
* cmMakefile::GetDefinition: return cmPropVitaly Stakhovsky2020-09-021-31/+30
|
* Add ISPC compiler support to CMakeRobert Maynard2020-08-281-0/+12
|
* Source: use cmNonempty()Vitaly Stakhovsky2020-07-281-2/+2
|
* cmNonempty: Convenience inlines to check for non-empty stringVitaly Stakhovsky2020-07-141-3/+3
|
* Merge topic 'refactor_language_mapping_logic'Brad King2020-06-231-52/+79
|\ | | | | | | | | | | | | | | c4e890946a try_compile: consistently add language properties 0e16da8233 cmCoreTryCompile use anonymous namespace instead of static Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4895
| * try_compile: consistently add language propertiesRobert Maynard2020-06-221-25/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | | It was very easy to forgot to add all the possible language properties that try_compile might need. Refactored the code to make it harder to skip flags. This changes adds the missing language properties for the CUDA, Fortran, OBJC, OBJCXX, and Swift languages: - CMAKE_<LANG>_COMPILER_EXTERNAL_TOOLCHAIN - CMAKE_<LANG>_COMPILER_TARGET - CMAKE_<LANG>_LINK_NO_PIE_SUPPORTED - CMAKE_<LANG>_PIE_SUPPORTED
| * cmCoreTryCompile use anonymous namespace instead of staticRobert Maynard2020-06-181-37/+29
| |
* | Merge topic 'try_compile-nfs'Brad King2020-06-191-1/+3
|\ \ | |/ |/| | | | | | | | | | | | | a9a258c302 try_compile: Do not try to remove '.nfs*' files Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Robert Maynard <robert.maynard@kitware.com> Acked-by: Axel Huebl <axel.huebl@plasma.ninja> Merge-request: !4913
| * try_compile: Do not try to remove '.nfs*' filesBrad King2020-06-171-1/+3
| | | | | | | | | | | | | | These files are part of the NFS implementation and should not be removed. They will automatically disappear when NFS is done with them. Fixes: #20844
* | try_compile: Refactor language standard level parsingRobert Maynard2020-06-171-288/+194
|/ | | | | | | cmCoreTryCompile had significant code duplication around handling languages that offer standard levels. This refactoring reduces the complexity and makes it easier to add new languages in the future.
* CUDA: Fix CUDA_ARCHITECTURES policy CMP0104 check in try_compileBrad King2020-06-051-0/+8
| | | | | | | | | | | | | | | | Since commit e98588aaba (CUDA: Add CUDA_ARCHITECTURES target property, 2020-03-12), `CMAKE_CUDA_ARCHITECTURES` is both initialized and required by policy CMP0104's `NEW` behavior. Inside a `try_compile` project we use `cmake_minimum_required(VERSION ...)` with the current running version of CMake. Now that our version number is 3.18, `CMP0104` gets set to `NEW` in the `try_compile`. If the outer projects does not set the policy then `CMAKE_CUDA_ARCHITECTURES` is not available and the `try_compile` fails to generate. Teach `try_compile` to check the outer project's policy status and set policy CMP0104 to `OLD` if needed to match. Fixes: #20794
* Merge branch 'backport-cuda-default-runtime' into cuda-default-runtimeBrad King2020-05-221-0/+3
|\
| * CUDA: Propagate CMAKE_CUDA_RUNTIME_LIBRARY state to try_compileRobert Maynard2020-05-201-0/+3
| |
* | Refactoring: rename "cm_static_string_view.hxx" as <cmext/string_view>Marc Chevrier2020-04-301-2/+2
| |
* | CUDA: Add CUDA_ARCHITECTURES target propertyRaul Tambre2020-04-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | Simplifies CUDA target architecture handling. Required for Clang support as Clang doesn't automatically select a supported architecture. We detect a supported architecture during compiler identification and set CMAKE_CUDA_ARCHITECTURES to it. Introduces CMP0104 for backwards compatibility with manually setting code generation flags with NVCC. Implements #17963.
* | CUDA: Forward CMAKE_CUDA_COMPILER_TARGET in try_compile()Raul Tambre2020-04-071-0/+3
| | | | | | | | Required for crosscompile support with Clang.
* | cmState::GetTargetTypeName: return type is *cmPropVitaly Stakhovsky2020-03-191-24/+16
|/
* cmCoreTryCompile::CleanupFiles now removes symlinks instead of their contents.Johnny Jazeix2019-12-261-1/+3
| | | | Fixes: #17522
* Handle multi-arch sysroots on Apple platformsTor Arne Vestbø2019-12-131-0/+3
|
* ObjC: Add try_compile supportCristian Adam2019-11-091-80/+128
| | | | Fixes: #19920
* try_compile: support Swift for cross-compilationSaleem Abdulrasool2019-10-151-0/+3
| | | | | Ensure that we preserve the `CMAKE_Swift_COMPILER_TARGET` variable to use cross-compilation for testing the Swift compiler if appropriate.
* 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.