summaryrefslogtreecommitdiff
path: root/Modules/CMakeCCompiler.cmake.in
Commit message (Collapse)AuthorAgeFilesLines
* Link step: use linker dependency linker fileMarc Chevrier2023-05-031-0/+1
| | | | | | Based on work done by @ben.boeckel (!8051) Fixes: #22217
* Apple: Handle generation and comsuption of text-based stubs (.tbd files)Marc Chevrier2023-03-011-0/+1
| | | | Fixes: #24123
* CompilerID: Compiler extensions default detectionRaul Tambre2021-09-281-0/+1
|
* MINGW: Define variable only when targeting Windows platformsBrad King2021-09-171-4/+0
| | | | | | | | | | | | | | | The `MINGW` variable indicates that the compiler targets MinGW, a GNU ABI on Windows. Since commit aff3147917 (Modernize GNU compiler info on Windows, 2009-12-02, v2.8.2~636), we load the `Platform/Windows-GNU` module for compilers targetin MinGW, so set the variable there instead. This is equivalent to `Platform/Windows-MSVC` setting the `MSVC` variable. Also remove `if(MINGW)` checks from the module, which have not been necessary since the enclosed logic was moved to that module. The undocumented `CMAKE_COMPILER_IS_MINGW` internal variable is now unused, so remove it too. Fixes: #22647
* Cygwin: Remove redundant definitions of CYGWIN and UNIX variablesBrad King2021-09-161-5/+0
| | | | | | | | These are set by modules loaded for `CMAKE_SYSTEM_NAME`. We do not need to set them again if the compiler defines `__CYGWIN__`. Also remove the now-unused undocumented `CMAKE_COMPILER_IS_CYGWIN` internal variable.
* C23 supportRaul Tambre2021-02-251-0/+1
|
* C17 supportRaul Tambre2021-02-251-0/+1
| | | | Implements #17755.
* CMakeDetermineCompilerABI: Detect byte order as part of checkBrad King2020-11-041-0/+1
| | | | | | | We already detect `sizeof(void*)`. Detect the byte order as part of the same check. Issue: #21392
* Compilers: Add paths from -print-sysroot to system prefix pathRobert Maynard2020-04-141-0/+1
|
* clang: introduce CMAKE_<lang>_COMPILER_FRONTEND_VARIANTZsolt Parragi2019-05-171-0/+1
| | | | | | | | This variable is set to GNU on Windows when clang.exe ar clang++.exe is used, and set to MSVC for clang-cl.exe. CMAKE_<lang>_SIMULATE_ID is set to MSVC in both cases, as clang defaults to -fms-compatibility for all command lines on windows.
* Compute implicit include directories from compiler outputChuck Cranor2019-01-211-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - CMakeParseImplicitIncludeInfo.cmake: new parser that extracts the compiler's include path from verbose output. If the parser cannot parse the output, we fall back to the old behavior. On osx we skip over framework directories (handled elsewhere). - CMakeDetermineCompilerABI.cmake: - use verbose flag in try_compile for ${src} - use new cmake_parse_implicit_include_info() to attempt extract implicit include directory path and if successful set CMAKE_${LANG}_IMPLICIT_INCLUDE_DIRECTORIES - CMakeCCompiler.cmake.in and CMakeCXXCompiler.cmake.in - preserve CMAKE_${LANG}_IMPLICIT_INCLUDE_DIRECTORIES value between runs in the same way CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES is preserved - Tests/RunCMake/ParseImplicitIncludeInfo: tests for parse based on the older Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in. The test runs a set of verbose compiler outputs collected from various machines through the parser and checks the results. New compiler files can be added by dropping input/output files in the ParseImplicitIncludeInfo/data subdirectory and then adding the new set of files to the ${targets} list in ParseImplicitIncludeInfo.cmake. There is a helper CMakeLists.txt in ParseImplicitIncludeInfo/data that can help with the generation of test input files. NOTE: the standard cmake pre-commit hook rejects verbose compiler output with trailing spaces... you have to manually edit them out. This shouldn't impact the test. Note that both the parser and the test code can use CMAKE_${LANG}_COMPILER_* variables such as ${CMAKE_CXX_COMPILER_ID} to decide how to parse verbose compiler output. For the test code, this requires us to save the variables values in the test input files. Fixes: #16291
* MSVC: Respect CMAKE_RC_COMPILER and CMAKE_MT in vs_link_{dll,exe}Mateusz Zych2018-10-291-0/+1
| | | | | | | | | | | | 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
* Xcode: Detect architecture(s) using ARCHS instead of CURRENT_ARCHBrad King2018-06-181-1/+1
| | | | | | | | | Xcode 10 no longer populates `CURRENT_ARCH` with the current architecture in shell scripts and instead uses `undefined_arch`. Instead we must use `ARCHS`. It lists all architectures separated by spaces. Fixes: #18085
* Add infrastructure to detect secondary compiler version informationBrad King2017-10-031-0/+1
| | | | | | | | | | | Create a `CMAKE_<LANG>_COMPILER_VERSION_INTERNAL` variable to hold a secondary/internal compiler version number detected at the same time as the primary compiler version. This will be useful for some compilers where we need such a number to determine correct usage. Inspired-by: Stefan Andersson <tfosm@hotmail.com> Suggested-by: Norbert Lange <norbert.lange@andritz.com> Issue: #17264
* Add a CMAKE_<LANG>_COMPILER_ARCHITECTURE_ID variableNorbert Lange2017-06-291-0/+1
| | | | | | | | | | Compilers such as MSVC and IAR may have variants that target different architectures. We have been using a `MSVC_<LANG>_ARCHITECTURE_ID` variable to hold this information for MSVC. Add an alternative with a more general name (later we can port MSVC to it too). This additional information may be needed to generate proper invocations of the compiler based on its architecture variant.
* Merge topic 'lang-specific-binutils'Brad King2017-04-051-2/+2
|\ | | | | | | | | | | | | 73934188 Rename CMAKE_GCC_{AR,RANLIB} to CMAKE_LANG_COMPILER_{AR,RANLIB} Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !656
| * Rename CMAKE_GCC_{AR,RANLIB} to CMAKE_LANG_COMPILER_{AR,RANLIB}Ruslan Baratov2017-04-031-2/+2
| | | | | | | | | | | | 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.
* | Xcode: Detect CURRENT_ARCH for use by generatorBrad King2017-03-311-0/+1
|/ | | | | | | During compiler identification, extract the Xcode `CURRENT_ARCH` value and save it for later use by the Xcode generator in an internal compiler information variable. This will be useful to know the locations of object files when only one architecture is built.
* Add 'CMAKE_GCC_AR' and 'CMAKE_GCC_RANLIB' variablesRuslan Baratov2017-03-091-0/+2
|
* CMakeDetermine*Compiler: Add hook to save custom compiler informationBrad King2016-08-121-0/+1
| | | | | | Provide a way for Platform/<os>-Determine-<lang>.cmake modules to save platform-specific information about the compiler in the configured CMake<lang>Compiler.cmake modules.
* Compiler: Add infrastructure for detecting compiler wrappersChuck Atkins2015-12-071-0/+1
|
* Revert "Disable shared library support when compiler links statically" (#15855)Brad King2015-11-231-1/+0
| | | | | | | | In commit v3.4.0-rc1~18^2 (Disable shared library support when compiler links statically, 2015-09-30) we tried to detect when the compiler is not capable of linking shared libraries (possibly due to flags in use). However, the approach is not robust against flags like `-nostdlib`. Revert it for now pending another solution to the original problem.
* Disable shared library support when compiler links staticallyBrad King2015-09-301-0/+1
| | | | | | | | | When a user or a compiler wrapper adds '-static' to the compiler flags then it will always link static binaries. Detect this from the compiler id binary and disable TARGET_SUPPORTS_SHARED_LIBS. This will prevent projects from accidentally adding shared libraries when the toolchain does not support them. It also helps CMake avoid linking with flags that require shared libraries to be supported.
* Ninja: Detect MSVC /showIncludes prefix with compiler flags (#15596)Brad King2015-09-181-2/+5
| | | | | | | | Move detection over to the compiler id logic where we have already constructed the list of compiler flags from ARG1 and CMAKE_<LANG>_FLAGS. Pass the flags when we execute "cl" with "/showIncludes". Also pass "/c" because we only need to compile, not link. Check the compiler process exit code before trusting its output.
* Ninja: Refactor lookup of cmcldeps locationBrad King2015-09-181-1/+0
| | | | | This executable comes with CMake so just compute its location in cmSystemTools instead of storing it in compiler information modules.
* Project: Determine default language dialect for the compiler.Stephen Kelly2015-09-181-0/+1
| | | | | | Use the __cplusplus and __STDC_VERSION__ macros to automatically determine the default dialect for the compiler while determining its id and version.
* Features: Extend concept to C language.Stephen Kelly2014-05-151-0/+5
| | | | | | | | | | | Add properties and variables corresponding to CXX equivalents. Add features for c_function_prototypes (C90), c_restrict (C99), c_variadic_macros (C99) and c_static_assert (C11). This feature set can be extended later. Add a <PREFIX>_RESTRICT symbol define to WriteCompilerDetectionHeader to conditionally represent the c_restrict feature.
* Treat .m files consistently as C across all generatorsTim Blechmann2014-03-201-1/+1
| | | | | | | | | | | | | | | | | Objective C sources should be compiled with the C compiler, not C++. The Xcode generator correctly classifies ".m" sources already. The cmSystemTools::GetFileFormat method was fixed by commit v2.8.0~1782 (fix for 7045, use gcc for .m, 2008-08-19) but it is not used by any of the generator since commit v2.4.0~2819 (major changes to support addition of languages, 2004-09-22). Fix the CMAKE_<LANG>_SOURCE_FILE_EXTENSIONS table entries so that cmGlobalGenerator::GetLanguageFromExtension tells the Makefile, Ninja, and VS IDE generators to compile ".m" sources as C. This makes behavior consistent on all generators. Signed-off-by: Tim Blechmann <tim@klingt.org>
* Ninja: use deps = gcc/msvc featurePeter Kümmel2013-10-241-1/+1
| | | | cmcldeps is now only used for .rc file processing
* CMakeDetermineCompilerId: Add notion of "simulated" id/versionBrad King2013-10-041-0/+2
| | | | | | | | | Some compilers try to simulate other compilers as a drop-in replacement supporting all the same command-line options and predefined preprocessor macros. In such cases it will be useful to have CMake load the compiler information files for the simulated compiler instead of duplicating the information. Teach CMakeDetermineCompilerId to extract the simulated compiler id and version when the compiler id detection provides it.
* OS X: Detect implicit linker framework search pathsBrad King2012-12-111-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | Previously we hard-coded a list of implicit framework directories but did not account for CMAKE_OSX_SYSROOT or for changes to the list across OS X versions. Instead we should automatically detect the framework directories for the active toolchain. The parent commit added the "-Wl,-v" option to ask "ld" to print its implicit directories. It displays a block such as: Framework search paths: /... Parse this block to extract the list of framework directories. Detection may fail on toolchains that do not list their framework directories, such as older OS X linkers. Always treat the paths <sdk>/Library/Frameworks <sdk>/System/Library/Frameworks <sdk>/Network/Library/Frameworks # Older OS X only /System/Library/Frameworks as implicit. Note that /System/Library/Frameworks should always be considered implicit so that frameworks CMake finds there will not override the SDK copies.
* OS X: Always generate -isysroot if any SDK is in useBrad King2012-09-211-1/+1
| | | | | | | | Drop the last use of CMAKE_OSX_SYSROOT_DEFAULT. Replace internal platform variable CMAKE_${lang}_HAS_ISYSROOT with a more general CMAKE_${lang}_SYSROOT_FLAG variable. If the -isysroot flag exists and CMAKE_OSX_SYSROOT points to an SDK (not "/") then always add it to compiler command lines. This is already done in the Xcode IDE.
* Store ABI detection results in compiler information filesBrad King2012-08-241-0/+1
| | | | | | | | | | Drop use of cache entry CMAKE_DETERMINE_<LANG>_ABI_COMPILED and replace it with variable CMAKE_<LANG>_ABI_COMPILED. Since the grandparent commit this test result is specific to the version of CMake. Store it in the version-specific compiler information files instead of CMakeCache.txt so testing can be re-done to meet the requirements of the current version of CMake even if another version of CMake was already used to configure the build tree.
* Move CMAKE_<LANG>_COMPILER_WORKS to compiler information filesBrad King2012-08-241-0/+1
| | | | | | | | Since the parent commit this test result is specific to the version of CMake. Store it in the version-specific compiler information files instead of CMakeCache.txt so testing can be re-done to meet the requirements of the current version of CMake even if another version of CMake was already used to configure the build tree.
* Remove CMake-language block-end command argumentsKitware Robot2012-08-131-4/+4
| | | | | | | | | | | | | | | | | 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-41/+41
| | | | | | | | | | | | | | | | | 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
* Ninja: don't set cmcldeps vars to empty string when they are not definedPeter Kuemmel2012-06-091-4/+2
|
* Ninja: allow spaces in source pathPeter Kuemmel2012-06-081-0/+5
| | | | And make /showIncude prefix visible for all build rules
* Add framework to detect compiler version with its id (#12408)Brad King2011-12-071-0/+1
| | | | | | | | | | | | | | | | | | | | Teach CMakePlatformId.h to construct an "INFO:compiler_version[]" string literal from macros COMPILER_VERSION_(MAJOR|MINOR|PATCH|TWEAK) to be defined in CMake(C|CXX)CompilerId.(c|cpp) for each compiler. Provide conversion macros DEC() and HEX() to decode decimal or hex digits from integer values. Parse the version out of the compiler id binary along with the other INFO values already present. Store the result in variable CMAKE_<LANG>_COMPILER_VERSION in the format "major[.minor[.patch[.tweak]]]". Save the value persistently in CMake(C|CXX)Compiler.cmake in the build tree. Document the variable for internal use since we do not set it everywhere yet. Report the compiler version on the compiler id result line e.g. The C compiler identification is GNU 4.5.2 Report CMAKE_(C|CXX)_COMPILER_(ID|VERSION) in SystemInformation test.
* Teach find_(library|package) about Linux multiarch (#12037)Brad King2011-06-081-0/+5
| | | | | | | | | | | | | Implement support for multiarch as specified here: http://wiki.debian.org/Multiarch https://wiki.ubuntu.com/MultiarchSpec Detect the <arch> part of <prefix>/lib/<arch> from the implicit library search path from each compiler to set CMAKE_<lang>_LIBRARY_ARCHITECTURE. Define CMAKE_LIBRARY_ARCHITECTURE using one of these values (they should all be the same). Teach the find_library and find_package commands to search <prefix>/lib/<arch> whenever they would search <prefix>/lib.
* Fix issue #10155 - default value of CMAKE_OSX_DEPLOYMENT_TARGET should ↵David Cole2010-01-291-0/+1
| | | | always be the empty string. When the value of CMAKE_OSX_DEPLOYMENT_TARGET is the empty string, the -mmacosx-version-min flag should not show up on the compiler command line. The logic for selecting default value of CMAKE_OSX_SYSROOT is orthogonal to and independent of the value of the deployment target. The default value for CMAKE_OSX_SYSROOT is the SDK that corresponds to the current version of Mac OSX on which cmake is running.
* -also put CMAKE_LINKER in the C and CXX compiler information filesAlexander Neundorf2010-01-221-0/+1
| | | | | | This is already done for assembler and is necessary for e.g. Symbian. Alex
* Change the way 32/64 bit compiles are detected with MSVC and intel makefile ↵Bill Hoffman2009-11-191-0/+1
| | | | builds. Use the platform ID preprocessor approach.
* Fix check for -isysroot on OS XBrad King2009-09-191-0/+2
| | | | | | | | | | | Previously we checked for this flag by parsing the version number of GCC out of 'gcc --version', but this is not reliable because the format can vary greatly. Now we run 'gcc -v --help' and look for '-isysroot' in the list of options. We also now store the result on a per-language basis in the per-compiler info file "CMake<LANG>Compiler.cmake". This is necessary to make it accessible from try-compile projects so that they generate correctly.
* ENH: Implicit link info for C, CXX, and FortranBrad King2009-07-231-0/+3
| | | | | | | | | | | | | This teaches CMake to detect implicit link information for C, C++, and Fortran compilers. We detect the implicit linker search directories and implicit linker options for UNIX-like environments using verbose output from compiler front-ends. We store results in new variables called CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES The implicit libraries can contain linker flags as well as library names.
* ENH: Generalize the check for sizeof void* to detect more ABI information.Brad King2008-01-211-3/+11
|
* ENH: second try for handling the linker language with integer priority ↵Alexander Neundorf2007-07-121-1/+1
| | | | | | values (returning a pointer to a string on the stack is no good idea) Alex
* COMP: revert last commit for now, broke Visual StudioAlexander Neundorf2007-07-111-1/+1
| | | | Alex
* ENH: CMAKE_<LANG>_LINKER_PREFERENCE is now an integer priority, not aAlexander Neundorf2007-07-111-1/+1
| | | | | | | | | | | | | | | | | | | two-step priority (None or Prefered) Current order: ASM 0, C 10, Fortran 20, CXX 30, Java 40 This is the same order as automake choses: http://www.gnu.org/software/automake/manual/html_node/How-the-Linker-is-Chosen.html This change should be backward compatible: if there is a project using fortran and CXX, they had to set the LINKER_LANGUAGE explicitely, otherwise cmake complained (but still generated the project files). Explicitely setting the linker language still overrides automatic detection. If somebody has a custom language for cmake and the PREFERENCE starts with "P", its changed to 100, which gives it preference over all other languages (except the other custom languages which have also "Prefered"). "None" is converted to 0. Alex
* ENH: split cmGlobalGenerator::SetLanguageEnabled() in two parts, where theAlexander Neundorf2007-06-111-1/+0
| | | | | | | | second part copies the values from the cmake variables into internal maps. So this can now be done after the compiler-specific information has been loaded, which can now overwrite more settings. Alex