summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Windows-GNU.cmake
Commit message (Collapse)AuthorAgeFilesLines
* Link Step: compute effective linker used by the compilerMarc Chevrier2023-10-241-0/+2
| | | | | | | | | | | | | | | Extract the effective linker during the computation of implicit artifacts delivered by the compiler to the linker. Define various variables describing the linker: * CMAKE_<LANG>_COMPILER_LINKER * CMAKE_<LANG>_COMPILER_LINKER_VERSION * CMAKE_<LANG>_COMPILER_LINKER_ID * CMAKE_<LANG>_COMPILER_LINKER_FRONTEND_VARIANT This is complementary to feature introduced by commit 96a953b1ed (Add options to specify linker tool, 2023-09-27). Fixes: #17596, #18209, #25344
* Add options to specify linker toolMarc Chevrier2023-10-131-0/+5
| | | | | | | | | | | | | | | | | | Offer the capability, through variable `CMAKE_LINKER_TYPE`, as well as the target property `LINKER_TYPE` to specify which linker must be used. The implementation of this capability is specified by variables specific to the language and linker type: `CMAKE_<LANG>_USING_LINKER_<TYPE>`. Some definitions are provided as part of `CMake`. For example, to select the `LLVM` linker rather than the standard one, the type `LLD` should be specified through the variable `CMAKE_LINKER_TYPE`. And, on `Apple`, `Linux` and some environments on `Windows`, the variable `CMAKE_<LANG>_USING_LINKER_LLD` has value `-fuse-ld=lld`. And for `Windows` environments based on `MSVC`, where the linker is used directly, the tool `lld-link.exe` will be used rather than `link.exe`. Fixes: #19174, #24254, #24990
* MinGW: Search for packages in standard MSYSTEM environment prefixesBrad King2023-09-131-0/+19
| | | | | | | | | | | | | | | | MSYS2 and similar MinGW/MSYS distributions define development environments with a `MSYSTEM` environment variable. Each such environment has a documented installation prefix for its packages, often provided by a `MSYSTEM_PREFIX` environment variable. Since commit 84a25fc263 (cmake_host_system_information: Add MSYSTEM_PREFIX query, 2023-09-08) we can look up this prefix. Add `$MSYSTEM_PREFIX/local` and `$MSYSTEM_PREFIX` to our system search prefixes when targeting MinGW under `MSYSTEM` environments. This is their equivalent to `/usr/local` and `/usr`, which we search by default on UNIX systems. Issue: #24216
* MinGW: Fix regression when windres is not foundBrad King2022-11-291-1/+2
| | | | | | | | | | | | The fix in commit e9755bc7c1 (MinGW: Restore using windres when toolchain-prefixed name is not available, 2022-08-15, v3.24.1~4^2) incorrectly listed two entries in `CMAKE_RC_COMPILER_INIT`, which is only meant to have one value. Revise the logic to support multiple platform-specific names for the Windows Resource Compiler while still only using one name as the fallback when it is not found. Fixes: #24190 Issue: #23841
* MinGW: Restore using windres when toolchain-prefixed name is not availableBrad King2022-08-151-1/+1
| | | | | | | | | | | | | | | | | Since commit 55ba10dcfd (MSYS/MinGW Makefiles: Simplify selection of windres as Resource Compiler, 2022-05-26, v3.24.0-rc1~82^2) the `MinGW Makefiles` and `MSYS Makefiles` generators no longer specify the plain `windres` name for the MinGW resource compiler. Instead, the name is specified in our MinGW platform information module. After the change in commit af4adf6aa9 (MinGW: Fix default windres selection when cross-compiling, 2020-03-25, v3.18.0-rc1~492^2), when cross-compiling, we only specify the toolchain-prefixed name of the tool, which may not be available in all environments. If the toolchain-prefixed name is not available, fall back to the plain `windres` name. We already use this approach for other binutils. Fixes: #23841
* genex-LINK_LIBRARY: Add feature WHOLE_ARCHIVEMarc Chevrier2022-03-171-0/+25
|
* Genex-LINK_GROUP: Add feature RESCANMarc Chevrier2022-03-051-0/+8
| | | | | Feature RESCAN can be used to manage circular references between static libraries.
* Merge topic 'GNUtoMS-vs2022'Brad King2021-11-041-1/+1
|\ | | | | | | | | | | | | 571a795d2f GNUtoMS: Add search path for VS 2022 environment scripts Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6695
| * GNUtoMS: Add search path for VS 2022 environment scriptsBrad King2021-11-031-1/+1
| | | | | | | | | | | | | | | | Extend the logic from commit 08c5b3eff0 (GNUtoMS: Add search path for VS 2019 environment scripts, 2020-01-09, v3.16.3~15^2) to consider VS 2022 paths too. Fixes: #22847
* | MINGW: Define variable only when targeting Windows platformsBrad King2021-09-171-24/+20
|/ | | | | | | | | | | | | | | 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
* Windows-GNU: Support duplicate object names when linking shared librariesBrad King2021-05-031-1/+1
| | | | | | | | | Extend the change from commit 39d0ade07e (Windows-GNU: Support duplicate object names in large archives (#14874), 2014-04-14, v3.1.0-rc1~629^2~1) to apply to the temporary archive we create for linking shared libraries with MinGW tools. Issue: #21988
* Per-language Win32/Console flagsRaul Tambre2021-03-171-1/+1
| | | | | | | | Allows using different compilers with different flags for different languages. For example Clang with GNU-like commandline for CXX and MSVC as host compiler for CUDA. Should help with #21914.
* Merge topic 'compile-commands-collapse-whitespace'Brad King2020-03-261-2/+2
|\ | | | | | | | | | | | | | | | | e565053bce Ninja: Remove unnecessary newlines in compile commands 5d4bab500e Avoid consecutive whitespace in rules d8622fbd0f Modules: Collapse consecutive whitespace in strings Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4512
| * Modules: Collapse consecutive whitespace in stringsDaan De Meyer2020-03-231-2/+2
| |
* | MinGW: Fix default windres selection when cross-compilingBrad King2020-03-251-1/+1
| | | | | | | | | | | | | | When cross-compiling to MinGW, select the `windres` tool named with the toolchain's prefix. Fixes: #20500
* | MinGW: Drop unnecessary windres selection code with Unix MakefilesBrad King2020-03-251-4/+0
|/ | | | | | | | Since commit 957c2aac7f (RC: Simplify selection of resource compiler based on C/C++ toolchain, 2015-05-07, v3.3.0-rc1~93^2~5) we select windres as the RC compiler on MinGW via `CMAKE_RC_COMPILER_INIT`. Drop the special case from commit be9afbf453 (Find mingw's windres also when Unix Makefiles are used, 2012-08-27, v2.8.10~152^2).
* MinGW: Update find_library to not find plain .dll filesBrad King2020-01-201-1/+1
| | | | | | | | Modern distributions of packages built with MinGW tools provide `.dll.a` import libraries. Prefer those instead of finding plain `.dll` files. This avoids accidentally finding unrelated Windows `.dll` files. Fixes: #20019
* Merge topic 'GNUtoMS-vs2019'Brad King2020-01-101-1/+1
|\ | | | | | | | | | | | | 08c5b3eff0 GNUtoMS: Add search path for VS 2019 environment scripts Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4197
| * GNUtoMS: Add search path for VS 2019 environment scriptsBrad King2020-01-091-1/+1
| | | | | | | | | | | | | | | | Extend the logic from commit abe8a623d9 (GNUtoMS: Add search path for VS 2017 environment scripts, 2017-05-19, v3.8.2~1^2) to consider VS 2019 paths too. Fixes: #20162
* | replace remove and remove_directory with rm in testsJohnny Jazeix2019-11-131-1/+1
|/
* PIE link options: Update strategy to fix performance regressionMarc Chevrier2018-12-191-0/+1
| | | | Fixes: #18700
* POSITION_INDEPENDENT_CODE: Manage link flags for executablesMarc Chevrier2018-11-111-0/+2
| | | | Fixes: #14983, #16561
* GNUtoMS: Add search path for VS 2017 environment scriptsAlex Ghosh2017-05-221-0/+15
| | | | | | Use `cmake_host_system_information` to query the VS Installer tool for the locations of VS versions since VS 2017 does not provide registry entries anymore. Add a loop to simplify addition of future versions.
* GNUtoMS: Add search path for VS 2015 environment scriptsAlex Ghosh2017-05-171-0/+2
|
* 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.
* Re-order 'ar' options 'cq' => 'qc'Brad King2015-09-091-1/+1
| | | | | | | | | | | The documetnation of binutils: https://sourceware.org/binutils/docs/binutils/ar-cmdline.html suggests to use the parameters "q" and "c" in this order ("q" is operation, and "c" is the modifier). Suggested-by: Дилян Палаузов <dilyan.palauzov@aegee.org>
* Windows-GNU: Restore find_library treatment of '.dll' as linkable (#15409)Brad King2015-06-081-1/+1
| | | | | | | Revert commit v3.3.0-rc1~435^2 (Windows-GNU: Do not tell find_library to treat '.dll' as linkable, 2015-02-18). MinGW tools support linking to '.dll' files directly and many non-CMake build systems still do not provide a separate '.dll.a' file.
* RC: Do not override MinGW Makefiles generator preferenceBrad King2015-05-111-1/+1
| | | | | | | | Update logic added in commit 957c2aac (RC: Simplify selection of resource compiler based on C/C++ toolchain, 2015-05-07) to avoid overriding CMAKE_GENERATOR_RC. The MinGW and MSYS Makefiles generators use it to select a windres next to the compiler even if it is not in the PATH.
* RC: Simplify selection of resource compiler based on C/C++ toolchainBrad King2015-05-071-0/+4
| | | | | | | | | | Revert the refactoring by commit v2.8.11~105^2~1 (Ninja: use MinGW generator code in EnableLanguage, 2013-03-09) and move the MinGW- specific logic back to the "MinGW Makefiles" generator. Instead teach the platform information modules for GNU and MSVC on Windows to set the preferred RC compiler just before enabling the RC language. This way we choose the RC compiler based on the C/C++ toolchain that is actually enabled.
* RC: Enable language after C, CXX, or Fortran is enabled (#15404)Brad King2015-02-251-2/+2
| | | | | | | | The RC language is special in that it is automatically enabled on Windows-based platforms when another primary language is enabled. Move enablement of RC from early in the enablement of the other language to late. This will allow it to use information detected as part of enabling C, CXX, or Fortran.
* Windows-GNU: Do not tell find_library to treat '.dll' as linkableBrad King2015-02-181-1/+1
| | | | | Modern software distributions always use a separate ".dll.a" or ".lib" import library for linking.
* Merge topic 'GNUtoMS-vs-12'Brad King2014-05-281-1/+3
|\ | | | | | | | | 668e571d GNUtoMS: Add support for VS 2013 (#14936)
| * GNUtoMS: Add support for VS 2013 (#14936)Brad King2014-05-271-1/+3
| | | | | | | | | | | | Add to the Platform/Windows-GNU module list of VS registry entries those for VS 2013. Also add the name "vcvars64.bat" used by VS 10 and above for 64-bit tools.
* | Merge topic 'mingw-archive-no-replace'Brad King2014-04-151-2/+2
|\ \ | | | | | | | | | | | | 39d0ade0 Windows-GNU: Support duplicate object names in large archives (#14874)
| * | Windows-GNU: Support duplicate object names in large archives (#14874)Brad King2014-04-141-2/+2
| |/ | | | | | | | | | | | | | | | | | | | | | | | | Since commit v2.6.0~388 (Added build rule variables CMAKE_<LANG>_ARCHIVE_..., 2008-01-29) we use separate "ar cr ..." and "ar r ..." steps to incrementally add a large list of object files to an archive. Since the "r" command replaces existing objects of the same name in an archive, if multiple objects have the same file name and appear in separate append steps then one overwrites the other. Instead, use "ar cq ..." and "ar q ..." to always append to the archive. We already remove the archive before creating it so this will not cause objects to be appended to existing archives on incremental rebuilds.
* | MinGW: link like on Unix and use compile flags when linkingPeter Kümmel2014-04-151-2/+2
| |
* | Windows: Use response files to specify link libraries for GNU toolsBrad King2014-03-051-1/+4
|/ | | | | | | | | Work around the command-line-length limit by using an @linklibs.rsp response file to pass the flags for link libraries. This allows very long lists of libraries to be used in addition to the existing support for passing object files via response file. Suggested-by: Peter Keuschnigg <peter.keuschnigg@pmu.ac.at>
* Find mingw's windres also when Unix Makefiles are usedPeter Kümmel2012-08-271-0/+4
|
* 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
* Ninja: disable work around when linking with mingwPeter Kümmel2012-07-111-1/+3
| | | | | | | The work around is only needed by older GCCs (only testet 4.4/4.7) Ninja is very new so chances are high that there is also a new mingw. Use slashes in link rsp file, because ar.exe can't handle \.
* Add platform variables for position independent code flagsStephen Kelly2012-06-121-1/+5
| | | | | | | | | | | | | | | | | | | | Store in new platform variables CMAKE_${lang}_COMPILE_OPTIONS_PIC CMAKE_${lang}_COMPILE_OPTIONS_PIE flags for position independent code generation. In almost all cases, this means duplication of the CMAKE_SHARED_LIBRARY_${lang}_FLAGS for the _PIC case and using the assumed pie equivalent for the _PIE case. Note that the GNU compiler has supported -fPIE since 3.4 and that there is no -fPIC on GNU for Windows or Cygwin. There is a possibility that the _PIE variables are not correct. However, as there is no backwards compatibility to be concerned about (as the POSITION_INDEPENDENT_CODE property is not used anywhere yet), the current state suffices.
* Windows-GNU: Remove extra quotes in GNUtoMS rule variableBrad King2011-12-081-1/+1
| | | | | CMake replaces the <TARGET...> tokens with properly quoted values so we do not need an extra set of quotes around them.
* Add CMAKE_GNUtoMS option to convert GNU .dll.a to MS .libBrad King2011-12-051-0/+54
| | | | | | | | | | | | | | | | Teach the Windows-GNU.cmake platform file to look for Visual Studio tools matching the target ABI. Add an extra step to the link command for shared libraries and executables that export symbols and on which a new GNUtoMS property is set (initialized by the CMAKE_GNUtoMS option). Tell the GNU linker to output a module definition (.def) file listing exported symbols in addition to the GNU-format import library (.dll.a). Pass the .def file to the MS "lib" tool to construct a MS-format DLL import library (.lib). Teach the install(TARGETS) command to install the MS import library next to the GNU one. Teach the install(EXPORT) and export() command to set the IMPORTED_IMPLIB property pointing at the import library to use the import library matching the tools in the importing project.
* Merge topic 'include-flags-response-file'Brad King2011-03-221-0/+3
|\ | | | | | | | | | | | | | | 86cb17b Pass include directories with response files to GNU on Windows 9a0b9bc Optionally pass include directories with response files 6e8a67f Generate target-wide flags before individual build rules d099546 Factor old-style -D flags out from -I flag generation
| * Pass include directories with response files to GNU on WindowsBrad King2011-03-171-0/+3
| | | | | | | | | | | | | | The GNU 4.x toolchain on MinGW (and therefore MSYS) allows compiler options to be passed via response files. Use this to pass include directory -I options. This allows the include file search path to be very long despite shell and mingw32-make command line length limits.
* | Pass .def files directly to MinGW tools (#9997)Brad King2011-02-231-1/+1
| | | | | | | | | | | | | | | | | | Commit 6a61a8a5 (Honor module .def files with MinGW tools, 2011-02-21) set CMAKE_LINK_DEF_FILE_FLAG to "-Wl," to enable passing .def files to the linker on MinGW. However, older GNU tools in the MSYS shell do not know how to translate "-Wl,/c/..." to "c:/..." and complain that the file does not exist. Instead set the flag to just "" which tells CMake it can pass the file through the front-end with no special flag.
* | Honor module .def files with MinGW tools (#9997)Brad King2011-02-211-0/+1
|/ | | | | | | | | Since commit 024d05ad (Fix use of module .def files for MS tools, 2009-09-29) module .def files work for any platform that sets CMAKE_LINK_DEF_FILE_FLAG correctly. Set it in the Windows-GNU platform information file to enable support with MinGW tools. Also enable the test added by commit 0db2c850 (Test use of module .def files for MS tools, 2009-09-29) for MinGW and MSYS generators.
* Add support for windows resources with mingw/msys.Bill Hoffman2010-12-231-0/+2
|
* MinGW: Support long object file listsBrad King2010-09-171-1/+34
| | | | | | | Use a combination of response files and the archiver to support long object file lists that do not fit in the Windows command-line length limit. This can work only with GCC >= 4 because the MinGW GCC 3.x front-ends do not support response-file syntax.
* Merge topic 'module-header-spelling'Brad King2010-08-101-1/+1
|\ | | | | | | | | 2cde67a Modules: Fix spelling 'To distributed' -> 'To distribute'