summaryrefslogtreecommitdiffstats
path: root/Modules/Compiler/GNU.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Linker configuration: introduce a new architectureMarc Chevrier2024-07-201-54/+0
| | | | | | | | A new set of files are dedicated to linker configuration. This set of files enable a fine-tuned configuration based of the linker type as identified during compiler detection. Fixes: #25360
* Add CMAKE_<LANG>_STANDARD_LATEST variablesTyler2024-04-301-0/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a variable to indicate the latest standard known to be supported for each language: * `CMAKE_C_STANDARD_LATEST` * `CMAKE_CXX_STANDARD_LATEST` * `CMAKE_CUDA_STANDARD_LATEST` * `CMAKE_HIP_STANDARD_LATEST` * `CMAKE_OBJC_STANDARD_LATEST` * `CMAKE_OBJCXX_STANDARD_LATEST` These variables, more generally referred to as `CMAKE_<LANG>_STANDARD_LATEST`, are assigned an integer value which represents the minimum between the latest version of the associated language standard supported by the current compiler and the latest version supported by CMake. Add documentation for these variables in a new page called `CMAKE_<LANG>_STANDARD_LATEST` was added under the "Variables for Languages" section of the `cmake-variables(7)` page. Update each compiler-specific CMake script under `${CMAKE_ROOT}\Modules\Compiler` to manually define the relevant `CMAKE_<LANG>_STANDARD_LATEST` variable as necessary. This will require updating and maintaining as newer compiler versions become recognized by CMake. Closes: #25717
* GNU: Do not use "fat-lto-objects" flags for IPO on Apple platformsRené Bertin2024-04-241-1/+1
| | | | | | | | | | | Fat LTO objects contain both traditional object code and the LTO bitcode IR, but the GNU compiler does not support them on Apple platforms. A compile error is raised when `-f[no-]fat-lto-objects` flags are used, so avoid them. This also implies that static Fortran libraries cannot be built with IPO. Fixes: #25931
* GNU: Add flags for C++26 modesRaul Tambre2024-04-161-0/+5
| | | | | Flags added in GCC commit `5388a43f6a3` (c++: Add support for -std={c,gnu}++2{c,6}, 2023-06-22).
* Modules: Factor out helpers for GNU language standard flagsTyler2024-03-291-0/+87
| | | | | | | | | | | | | | Add the following macros to `${CMAKE_ROOT}\Modules\Compiler\GNU.cmake`: * `__compiler_gnu_c_standards()` * `__compiler_gnu_cxx_standards()` These macros are used to define the `CMAKE_<LANG><STANDARD>_STANDARD_COMPILE_OPTION` and `CMAKE_<LANG><STANDARD>_EXTENSION_COMPILE_OPTION` variables for C- and C++-based languages for GCC. The macros are similar to the existing `__compiler_clang_cxx_standards()` macro found in `${CMAKE_ROOT}\Modules\Compiler\Clang.cmake`.
* IPO: Support duplicate object names in large archivesRuslan Baratov2024-02-151-2/+2
| | | | | | | | | Apply the fix from commit 1ec6485c6a (Support duplicate object names in large archives, 2014-04-16, v3.1.0-rc1~629^2) to the IPO-specific archiving rules. Use "quick append" instead of "replace". Fixes: #25675 Issue: #14874
* GNU: Remove duplicate and unnecessary optimization flags for gfortranBrad King2023-11-211-3/+8
| | | | | | | | Since commit a66004bee0 (Honor CMAKE_<LANG>_FLAGS[_<CONFIG>]_INIT set in toolchain files, 2016-07-05, v3.7.0-rc1~392^2) we've accidentally been adding extra optimization flags instead of replacing unwanted flags. Fixes: #25434
* Link Step: linker depfile configuration: bug fixMarc Chevrier2023-10-251-5/+6
| | | | | Follow up commit 538ff514b5 (Link Step: use the correct linker for depfile handling, 2023-10-16)
* Link Step: use the correct linker for depfile handlingMarc Chevrier2023-10-241-11/+18
| | | | | Follow up commit 375e6fdbbe (Link step: use linker dependency linker file, 2023-04-19, v3.27.0-rc1~126^2).
* link dependencies: deactivate the featureMarc Chevrier2023-06-231-3/+10
| | | | | | | Unfortunately it breaks in combination with LTO due to a bug in the GNU linker. Fixes: #25014
* Link Step: ensure the correct linker is used for depfile configurationMarc Chevrier2023-05-281-2/+3
| | | | This is related to MR !8443.
* Link step: use linker dependency linker fileMarc Chevrier2023-05-031-0/+38
| | | | | | Based on work done by @ben.boeckel (!8051) Fixes: #22217
* Only initialize CMAKE_CXX_COMPILER_PREDEFINES_COMMANDJoerg Bornemann2022-11-161-6/+8
| | | | | | | | | | | Don't initialize the other CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND variables. The only language variant that is used is CMAKE_CXX_COMPILER_PREDEFINES_COMMAND, and the other language variants contained invalid, namely C++-specific commands. Fixes: #23968
* IPO: Do not use -flto=auto with GCC 10.x on WindowsBrad King2022-08-101-1/+8
| | | | | | | | | Revise the change from commit fe57410b33 (IPO: Use -flto=auto if compiler is GCC >= 10.1, 2022-06-22, v3.24.0-rc2~2^2) to require at least GCC 11 on Windows. Fixes: #23836 Issue: #23640
* IPO: Use -flto=auto if compiler is GCC >= 10.1Linus Dierheimer2022-06-221-1/+12
| | | | | | | Since GCC 12.1, the `-flto` option warns unless given an explicit LTRANS job count. Issue: #23640
* COMPILE_WARNING_AS_ERROR: Add options to treat warnings as errorsMartin Duffy2022-05-061-0/+1
| | | | | | | | | | | | Add `COMPILE_WARNING_AS_ERROR` target property and supporting `CMAKE_COMPILE_WARNING_AS_ERROR` variable. `COMPILE_WARNING_AS_ERROR` is initialized by `CMAKE_COMPILE_WARNING_AS_ERROR`. It is a boolean variable. If it is true, it expands to a different flag depending on the compiler such that any warnings at compile will be treated as errors. Supports compiler ids that I could find a relevant flag for.
* color: Introduce CMAKE_COLOR_DIAGNOSTICS variableSemyon Kolton2022-03-081-0/+7
| | | | | | | Add a variable to control both makefile color messages and compiler color diagnostics. Fixes: #15502
* Merge topic 'makefiles-compiler-deps-optims'Brad King2020-11-301-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | 2c71d051fa Makefiles Generators: use compiler for dependencies generation afd0f6785d Refactoring: Abstract Makefile line continuation format b6068ce407 Refactoring: enhance include file filtering 3401403f69 Refactoring: Introduce place-holder for dependency target. a97c41bf8b Refactoring: Makefiles Generators: Add support for various depends scanners Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Brad King <brad.king@kitware.com> Merge-request: !5528
| * Refactoring: Introduce place-holder for dependency target.Marc Chevrier2020-11-281-1/+1
| | | | | | | | | | | | | | | | These changes are in preparation of compiler generated dependencies support for Makefiles generators * compiler output and dependency target can be different for Makefiles generators * resolve inconsistency naming for dependency file place-holder
* | Modules: Rename Internal/CMake{CheckCompiler => TryCompilerOrLinker}FlagRobert Maynard2020-11-251-1/+0
|/ | | | | | | | Rename the `CheckPIESupported` helper functions so that they don't clobber other internal functions. Also rename them to document they can't be unified with `CheckCompilerFlag`. Fixes: #21497
* Merge branch 'backport-3.17-pch-no-Fortran' into pch-no-FortranBrad King2020-06-021-6/+8
|\
| * PCH: Do not enable GNU or Intel PCH settings for FortranBrad King2020-06-021-5/+7
| | | | | | | | | | | | | | | | | | The PCH settings are shared by C and CXX languages but do not make sense for Fortran. In particular, `CMAKE_PCH_EXTENSION` should not be set because it can overwrite the value set for C/C++ languages, which may have a different compiler vendor than the Fortran compiler. Fixes: #20752
* | GNU: Disable depfiles in try-compile mode only for GCCRaul Tambre2020-04-071-1/+2
| | | | | | | | | | Disabling them causes issues for Clang's CUDA frontend. Since this is a GCC bug, simply check for GCC.
* | PCH: add an option to disable `-Winvalid-pch`Cristian Adam2020-03-261-2/+3
|/ | | | Fixes: #20295
* PCH: Do not add #pragma system_header for Xcode generatorCristian Adam2019-12-041-1/+3
| | | | Fixes: #20039
* PCH: Add support for OBJC/OBJCXX languagesCristian Adam2019-11-031-0/+2
|
* Precompile headers: Add methods to generate PCH sourcesCristian Adam2019-08-281-0/+8
| | | | Co-Author: Daniel Pfeifer <daniel@pfeifer-mail.de>
* PIE link options: Update strategy to fix performance regressionMarc Chevrier2018-12-191-14/+5
| | | | Fixes: #18700
* POSITION_INDEPENDENT_CODE: Manage link flags for executablesMarc Chevrier2018-11-111-0/+16
| | | | Fixes: #14983, #16561
* Respect CMAKE_<LANG>_COMPILER_ARG1 in CMAKE_<LANG>_COMPILER_PREDEFINES_COMMANDSebastian Holtermann2018-08-281-1/+7
| | | | | | | | | | | AUTOMOC used to fail to generate ``moc_predefs.h`` when ``ccache`` was used as a compiler starter by e.g. configuring a project with the environment variable CXX="ccache g++". The reason was that ``CMAKE_<LANG>_COMPILER_ARG1`` wasn't respected in the definition of ``CMAKE_<LANG>_COMPILER_PREDEFINES_COMMAND`` for various compilers. This is fixed by this patch. Fixes #17275.
* LINK_OPTIONS: Add support of "LINKER:" prefixMarc Chevrier2018-06-061-0/+3
|
* Move GNU COMPILER_PREDEFINES_COMMAND from Platform to CompilerSebastian Holtermann2018-06-011-0/+2
| | | | | | | | Moves `CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND` from linux specific [Modules/Platform/Linux-GNU.cmake](Modules/Platform/Linux-GNU.cmake) to [Modules/Compiler/GNU.cmake](Modules/Compiler/GNU.cmake). This enables compiler predefines generation (in AUTOMOC) on all platforms that run gcc (and clang).
* IPO: Fix support for spaces in path to archive toolsThomas Stenersen2017-10-061-3/+3
| | | | | | | | In the normal archiving rules the ``<CMAKE_AR>`` placeholder is replaced by the generators with a properly-quoted path to the tool. In the IPO rules we specify the tools directly, so we need to quote them. Fixes: #17326
* IPO: Consider support for each language separatelyBrad King2017-06-141-3/+3
| | | | | | | | | We only define `INTERPROCEDURAL_OPTIMIZATION` behavior for C, CXX, and Fortran languages. Do not try to enable support for other languages. Furthermore, each language builds with a different compiler, so check for support by CMake and the compiler for each language independently. Fixes: #16944
* GNU: Use common compiler macros for language standard defaultChuck Atkins2017-05-021-0/+2
|
* Rename CMAKE_GCC_{AR,RANLIB} to CMAKE_LANG_COMPILER_{AR,RANLIB}Ruslan Baratov2017-04-031-3/+3
| | | | | | The variables recently added by commit b9d36826 (Add 'CMAKE_GCC_AR' and 'CMAKE_GCC_RANLIB' variables, 2017-03-08) are more appropriately managed with language-specific names rather than toolchain-specific names.
* Implement interprocedural optimization for GNU compilersRuslan Baratov2017-03-301-0/+39
| | | | | Honor the `INTERPROCEDURAL_OPTIMIZATION` target property for GNU compilers by activating their link-time-optimization (LTO) flags.
* Simplify CMake per-source license noticesBrad King2016-09-271-12/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Per-source copyright/license notice headers that spell out copyright holder names and years are hard to maintain and often out-of-date or plain wrong. Precise contributor information is already maintained automatically by the version control tool. Ultimately it is the receiver of a file who is responsible for determining its licensing status, and per-source notices are merely a convenience. Therefore it is simpler and more accurate for each source to have a generic notice of the license name and references to more detailed information on copyright holders and full license terms. Our `Copyright.txt` file now contains a list of Contributors whose names appeared source-level copyright notices. It also references version control history for more precise information. Therefore we no longer need to spell out the list of Contributors in each source file notice. Replace CMake per-source copyright/license notice headers with a short description of the license and links to `Copyright.txt` and online information available from "https://cmake.org/licensing". The online URL also handles cases of modules being copied out of our source into other projects, so we can drop our notices about replacing links with full license text. Run the `Utilities/Scripts/filter-notices.bash` script to perform the majority of the replacements mechanically. Manually fix up shebang lines and trailing newlines in a few files. Manually update the notices in a few files that the script does not handle.
* GNU: Use -fvisibility on GCC 4.0 and 4.1 tooBrad King2016-08-021-1/+1
| | | | | | | This flag is needed for the `<LANG>_VISIBILITY_PRESET` target property. It has been supported since GCC 4.0, not 4.2 as we previously recorded. Fixes #16222.
* Honor CMAKE_<LANG>_FLAGS[_<CONFIG>]_INIT set in toolchain filesBrad King2016-07-061-5/+5
| | | | | | | | | | | | | | | | | | | | | | | Document these variables. Change our convention for setting these variables from: set(CMAKE_C_FLAGS_INIT "...") to string(APPEND CMAKE_C_FLAGS_INIT " ...") so that any value previously set by a toolchain file will be used. Automate the conversion with: sed -i 's/set *(\(CMAKE_\(C\|CXX\|Fortran\|RC\|ASM\|${[^}]\+}\)_FLAGS\(_[^_]\+\)\?_INIT \+"\)/string(APPEND \1 /' \ Modules/Compiler/*.cmake Modules/Platform/*.cmake and follow up with some manual fixes (e.g. to cases that already meant to append). Also revert the automated changes to contexts that are not protected from running multiple times.
* Ninja: Add dependencies on system-provided header files (#14914)Brad King2016-03-151-1/+1
| | | | | | | | When system-provided packages are upgraded we must re-compile sources depending on their headers. Use `-MD` instead of `-MMD` so that the generated depfiles do not exclude system headers. Suggested-by: Jussi Judin
* Apple: Enable -isystem for GNU Compiler >= 4 (#15953)Gregor Jasny2016-02-071-1/+1
| | | | | | | | Due to #4662 -isystem support was disabled for all GNU Compilers on Apple platforms. But the change was probably a just work around for a broken compiler on Tiger (see 10837#c27206). So we tighten the condition to only kick in for GCC versions earlier than 4. That should ensure sane behavior for Xcode 3.2 and later.
* Factor an <INCLUDES> placeholder out of <FLAGS> in rule variablesBrad King2015-07-131-2/+2
| | | | | | | | | | | Teach the Makefile and Ninja generators to substitute for an <INCLUDES> placeholder instead of putting -I in <FLAGS>. Update our values for CMAKE_<LANG>_COMPILE_OBJECT, CMAKE_<LANG>_CREATE_ASSEMBLY_SOURCE, and CMAKE_<LANG>_CREATE_PREPROCESSED_SOURCE to place <INCLUDES> just before <FLAGS>.
* Add CMAKE_SYSROOT variable to set --sysroot when cross compiling.Stephen Kelly2013-11-191-0/+1
| | | | | | | | | | As CMAKE_ROOT_FIND_PATH can be a list, a new CMAKE_SYSROOT is introduced, which is never a list. The contents of this variable is passed to supporting compilers as --sysroot. It is also accounted for when processing implicit link directories reported by the compiler, and when generating RPATH information.
* Revert "Use --sysroot when cross compiling."Stephen Kelly2013-07-121-1/+0
| | | | | | | This reverts commit de4da665d3205afa239749c41513a315c3831f51. This feature is not yet ready for release. It needs to be merged with the CMAKE_OSX_SYSROOT feature.
* Use --sysroot when cross compiling.Stephen Kelly2013-06-071-0/+1
| | | | | | | | | | As CMAKE_ROOT_FIND_PATH can be a list, a new CMAKE_SYSROOT is introduced, which is never a list. The contents of this variable is passed to supporting compilers as --sysroot. It is also accounted for when processing implicit link directories reported by the compiler, and when generating RPATH information.
* Introduce target property <LANG>_VISIBILITY_PRESETStephen Kelly2013-06-021-0/+3
| | | | | | This is initialized by CMAKE_<LANG>_VISIBILITY_PRESET. The target property is used as the operand to the -fvisibility= compile option with GNU compilers and clang.
* Add -DNDEBUG to RelWithDebInfo flags where where Release flags had it.Clinton Stimpson2012-08-161-1/+1
| | | | | | Previously, it was inconsistent in that some platforms/compilers had this flag for the RelWithDebInfo configuration and some didn't. This fixes issue #11366.
* Remove CMake-language block-end command argumentsKitware Robot2012-08-131-1/+1
| | | | | | | | | | | | | | | | | Ancient versions of CMake required else(), endif(), and similar block termination commands to have arguments matching the command starting the block. This is no longer the preferred style. Run the following shell code: for c in else endif endforeach endfunction endmacro endwhile; do echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | egrep -z -v 'Tests/CMakeTests/While-Endwhile-' | xargs -0 sed -i -f convert.sed && rm convert.sed
* Convert CMake-language commands to lower caseKitware Robot2012-08-131-1/+1
| | | | | | | | | | | | | | | | | Ancient CMake versions required upper-case commands. Later command names became case-insensitive. Now the preferred style is lower-case. Run the following shell code: cmake --help-command-list | grep -v "cmake version" | while read c; do echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | xargs -0 sed -i -f convert.sed && rm convert.sed