Commit Graph

1560 Commits

Author SHA1 Message Date
Brad King
12e6c14e69 PellesC: Add default -Ze flag to support compilation against Windows APIs
The Pelles C compiler requires MS extensions to support `__declspec`
and other constructs needed to use Windows APIs.  Unfortunately the
flag also disables standard definitions, so restore them.

Issue: #21536
Co-authored-by: Serguei E. Leontiev <leo@sai.msu.ru>
2026-05-04 10:47:08 -04:00
Serguei E. Leontiev
9db2cf5429 PellesC: Add default compilation and link flags
Specify debug symbols and optimization flags for each configuration.

Issue: #21536
2026-05-01 11:28:49 -04:00
Brad King
811bf8fb89 Merge topic 'LINKER_TYPE-wild'
e96c5ba13d Add the support of the wild linker

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11966
2026-04-24 09:16:32 -04:00
Marc Chevrier
e96c5ba13d Add the support of the wild linker
Fixes: #27755
2026-04-23 16:21:30 +02:00
Brad King
1be31e5b61 PellesC: Add support for Windows DLL module definition files
Issue: #21536
Co-authored-by: Serguei E. Leontiev <leo@sai.msu.ru>
2026-04-23 09:33:32 -04:00
Brad King
a95fae2d36 PellesC: Add support for ASM_POASM language assembler
The Pelles C compiler does not support ASM, and the `poasm` assembler
uses a distinct syntax.  Add a dedicated language as we do for similar
cases from other vendors.  Leave documentation commented out for now
because the PellesC toolchain support in general is not yet documented.

Fixes: #27758
Issue: #21536
Co-authored-by: Serguei E. Leontiev <leo@sai.msu.ru>
2026-04-22 14:42:00 -04:00
Brad King
efc3e90d0d PellesC: Move C-specific compile command to C-specific code path 2026-04-22 14:35:09 -04:00
Brad King
fec53c68cd PellesC: Add support for Windows Resources
The PellesC toolchain provides a `porc` tool to compile them.

Note that `polib` fails to archive resource files (`.res`):

    POLIB: fatal error: An internal error occurred

Turn off the static library part of the VSResource test.

Issue: #21536
Inspired-by: Serguei E. Leontiev <leo@sai.msu.ru>
2026-04-20 11:58:39 -04:00
Brad King
9fc0edced9 Merge topic 'treat-arm64-as-matching-arm64e-for-sysroots'
d68bed8397 Apple: Treat arm64 as matching arm64e when resolving arch sysroots

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11903
2026-04-13 10:53:03 -04:00
Brad King
41534f1571 Merge topic 'haiku-rescan'
9a342eb39b Haiku: Add support for RESCAN

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11919
2026-04-13 10:50:00 -04:00
Brad King
3bed3edd45 Merge topic 'Modules-use-NO_CACHE'
80abf737cc Modules: use `find_*(NO_CACHE)`
2c75267803 Modules/CMakeTest*Compiler: use `try_compile(NO_CACHE)`

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11914
2026-04-13 10:48:10 -04:00
Ben Boeckel
80abf737cc Modules: use find_*(NO_CACHE)
Avoid manual cache management logic.
2026-04-12 08:02:28 -04:00
Trung Nguyen
9a342eb39b Haiku: Add support for RESCAN
Haiku also uses the GNU toolchain and therefore should support this
feature.
2026-04-11 06:04:50 +10:00
Tor Arne Vestbø
d68bed8397 Apple: Treat arm64 as matching arm64e when resolving arch sysroots
Xcode 26.4's iPhoneOS SDK advertises arm64e (not arm64) in
libSystem.tbd. After stripping the platform suffix, the arch list
contains arm64e, which doesn't match when CMAKE_OSX_ARCHITECTURES
includes arm64. As a result, arm64 falls through to the simulator
SDK, silently breaking iOS device builds.

Since arm64e is a superset of arm64 (all arm64e devices run arm64
binaries), we now fall back to checking for arm64e when arm64 is
not found in an SDK's architecture list.
2026-04-10 14:45:48 -04:00
Brad King
b7a5f2732d PellesC: Add minimal support for this C compiler
Add bare minimum functionality to compile C code and link on Windows.
Explicitly label tests that are expected to work with `CFLAGS=-Ze`.

Leave out documentation for now because this is not usable in general.

Issue: #21536
Inspired-by: Serguei E. Leontiev <leo@sai.msu.ru>
2026-04-07 09:43:24 -04:00
Colin Cross
39b998edee Android: Add future linux-arm64 CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG
Future NDK versions may support linux `aarch64` hosts.  Teach CMake to
set `CMAKE_ANDROID_NDK_TOOLCHAIN_HOST_TAG` to `linux-arm64` on them.
2026-03-30 17:02:12 -04:00
Serguei E. Leontiev
402d72b6c0 OrangeC: Add support for compiling Windows Resources
OrangeC 7.0 and above come with a resource compiler, ORC.
2026-03-25 17:01:34 -04:00
Willem Deconinck
2b2cea3037 NAG-Fortran: Add support for WHOLE_ARCHIVE on Linux 2026-03-23 17:15:35 -04:00
Brad King
c6c2e8efc1 Merge topic 'fbuild_fix_clang_cl_manifest'
30ce1cfdcb FASTBuild: fix clang-cl build with manifests

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11823
2026-03-17 09:05:05 -04:00
Eduard Voronkin
30ce1cfdcb FASTBuild: fix clang-cl build with manifests
Fixes: #27691
2026-03-16 11:52:50 -04:00
Aditya Vidyadhar Kamath
3e99e8efb2 AIX: Teach ExportImportList to use toolchain-specific nm
This is needed to handle LTO objects.

Fixes: #27655
2026-03-09 14:35:19 -04:00
Nilsen84
ed0f48e79b clang-cl: use gcc depfiles over /showIncludes
This enables `#embed` dependencies when using `clang-cl`.

Fixes: #27594
2026-02-13 10:44:50 -05:00
Gavin Zhao
73051ad572 fix: build HIP on Windows with MSVC-style clang-cl.exe 2026-02-05 18:55:24 -05:00
Tyler Yankee
98f9874703 cmake: Add per-language link flags for all target types
Previously, `CMAKE_<LANG>_LINK_FLAGS` was an undocumented variable used
for linking executables only. Re-spell that variable mirroring the
existing spellings for shared and module libraries, and add policy
CMP0210 to preserve compatibility.

Then, repurpose `CMAKE_<LANG>_LINK_FLAGS` to provide a variable to be
used for per-language link flags for all target types, along with a
per-configuration variant. These are added to the `<LINK_FLAGS>` rule
placeholder in the generators.

Fixes: #21934
Relates: #25620

Co-authored-by: Brad King <brad.king@kitware.com>
2026-01-31 19:37:09 -05:00
Brad King
1e4f9c2394 macOS: Remove outdated condition for -search_paths_first link flag
We no longer support versions of macOS older than 10.4.
2026-01-26 12:19:08 -05:00
Eisuke Kawashima
0837fb552f IntelLLVM: Remove unused code
In commit a90d2a9eed (IntelLLVM: Add support for Intel LLVM-based
compilers, 2020-11-02, v3.20.0-rc1~89^2~20) we added a `set()` that is
immediately followed by another `set()` of the same variable.  Remove
the former.

Fixes: #27019
2025-12-01 16:26:58 -05:00
Brad King
86574083a8 Emscripten: Drop hard-coded -fPIC flag
In commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16,
v4.2.0-rc1~607^2~3) this flag was added as part of an attempt to support
shared libraries without requiring projects to set much themselves. That
attempt was reverted by commit d361bf365e (Emscripten: Drop hard-coded
-sMAIN_MODULE and -sSIDE_MODULE flags, 2025-09-18, v4.2.0-rc1~146^2).
Also avoid hard-coding `-fPIC`.  `POSITION_INDEPENDENT_CODE` is already
enabled for shared library targets.  Projects can enable it themselves
where `-fPIC` is needed outside of shared libraries.

Fixes: #27424
Issue: #27240
2025-11-25 10:32:04 -05:00
Brad King
75e98477e3 Emscripten: Restore placement of source files on compile command-lines
Since commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16,
v4.2.0-rc1~607^2~3), compilation command-lines for Emscripten place
`-c <SOURCE>` before all the flags.  Restore the original order.

Fixes: #27404
2025-11-24 14:49:19 -05:00
Brad King
863dc3a7ac VS/Android: Use ApplicationTypeRevision 3.0 in VS2026
Extend commit e78abf94e3 (VS/Android: Use ApplicationTypeRevision 3.0 in
VS2022, 2023-04-21, v3.27.0-rc1~165^2~4) to cover VS 2026 too.  This was
missed in commit 3392b371e2 (VS: Add Visual Studio 18 2026 generator,
2025-08-20, v4.2.0-rc1~165^2~1).
2025-11-20 14:06:11 -05:00
Brad King
1925477cb7 macOS: Do not incorrectly search for per-arch SDKs
Extend commit a9b41195d2 (Handle multi-arch sysroots on Apple platforms,
2019-07-26, v3.17.0-rc1~287^2) to recognize versioned macOS SDK names.

Fixes: #27340
2025-10-29 14:50:51 -04:00
Brad King
b39e361175 Merge topic 'xcode-macos-deployment-target' into release-4.2
de53a46a91 Help: Add 4.1 release note for restored Xcode default deployment target
85ba6f5d1b Merge branch 'backport-4.0-xcode-macos-deployment-target'
884260ced6 Help: Add 4.0 release note for restored Xcode default deployment target
1a37c83c7e Xcode: Restore default CMAKE_OSX_DEPLOYMENT_TARGET to run on host
e927408047 Apple: Initialize deployment target after SDK

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11361
2025-10-27 09:26:15 -04:00
Brad King
85ba6f5d1b Merge branch 'backport-4.0-xcode-macos-deployment-target' 2025-10-26 11:19:58 -04:00
Brad King
1a37c83c7e Xcode: Restore default CMAKE_OSX_DEPLOYMENT_TARGET to run on host
Xcode by default targets the SDK's macOS version rather than the host's
macOS version.  In commit 7b19531291 (macOS: Do not pass any
SDK/-isysroot to compilers by default, 2024-11-06, v4.0.0-rc1~511^2) we
reverted commit 24aafbde11 (Xcode: Adjust deployment target SDK version
to host version, 2015-10-11, v3.4.0-rc2~6^2), but it is still needed for
Xcode.  Restore the behavior so binaries run on the host by default.

Fixes: #27309
2025-10-26 11:19:19 -04:00
Brad King
e927408047 Apple: Initialize deployment target after SDK 2025-10-26 11:16:45 -04:00
Eduard Voronkin
4135175337 FASTBuild: support CUDA language
Fixes: #27318
2025-10-25 08:58:38 -04:00
Brad King
61d0bdf6b7 macOS: Avoid relying on sw_vers when cross-compiling from another OS
We have a few code paths needed only to support builds hosted on
macOS 10.4.  Update the conditions to work when cross-compiling
to macOS from another platform.

This backports commit eb8facd396 (macOS: Avoid relying on sw_vers
when cross-compiling from another OS, 2025-04-28, v4.1.0-rc1~260^2)
to CMake 4.0.

Fixes: #26814
2025-10-22 17:26:36 -04:00
Brad King
d9d65ab54f macOS: Remove outdated condition for CMAKE_OSX_DEPLOYMENT_TARGET
Revert commit 2853326e7a (BUG: Only set CMAKE_OSX_DEPLOYMENT_TARGET on
Mac OSX 10.4 or later, 2009-01-27, v2.8.0~1169).  AFAIK no one is using
macOS versions older than 10.4 anymore.

This backports commit 476b2a386f (macOS: Remove outdated condition
for CMAKE_OSX_DEPLOYMENT_TARGET, 2025-04-28, v4.1.0-rc1~260^2~1)
to CMake 4.0.
2025-10-22 17:26:31 -04:00
Tristan Daifuku
69e2f3f8ea Linker: Tolerate CMAKE_EXECUTE_PROCESS_COMMAND_ERROR_IS_FATAL set to ANY
Tolerate expected failures of linkers invoked via `execute_process`.
2025-10-20 11:58:46 -04:00
AJIOB
83bbde5449 MSVC: Define _WINDLL consistently for shared libraries
Visual Studio defines this automatically for `.dll` targets.
For consistency, define it when compiling for the MSVC ABI
with other generators.  Add policy CMP0203 for compatibility.

Fixes: #27253
2025-09-29 18:26:44 -04:00
Brad King
d361bf365e Emscripten: Drop hard-coded -sMAIN_MODULE and -sSIDE_MODULE flags
These flags are only needed for builds involving shared libraries,
and can cause undesirable behavior when they are not needed.
They also have variants with values like `=2`.  For now, just require
projects to add the flags when needed so they have full control.
In the future we may be able to add an abstraction to control them,
and automatically enable them when linking to shared libraries
or creating them.

Fixes: #27232
Issue: #27240
2025-09-19 09:54:02 -04:00
Brad King
707f14d434 Emscripten: Restore support for indirect use of emsdk toolchain file
Extend commit 644ad91e6a (Emscripten: Restore support for emsdk
toolchain file and platform module, 2025-09-17) to support using a
third-party `CMAKE_TOOLCHAIN_FILE` that includes the emsdk-provided
toolchain file.

Issue: #27232
2025-09-19 09:21:33 -04:00
Brad King
792f6989e9 Merge topic 'android-ndk-custom-toolchain'
9266d4817d Android: Allow custom compilers with NDK

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !11199
2025-09-18 08:49:55 -04:00
Brad King
f2b2bac85d Emscripten: Detect and identify linker invoked by the compiler driver 2025-09-17 20:03:48 -04:00
Brad King
7f3f6d1ec6 Emscripten: Allow overriding -sMAIN_MODULE and -sSIDE_MODULE linker flags
Place the flag early on executable link lines so that projects can
override it, e.g., with `-sMAIN_MODULE=2` or `-sMAIN_MODULE=0` via
`target_link_options`.

The `-sSIDE_MODULE` flag already appears early enough on shared library
link lines.

Issue: #27232
2025-09-17 19:54:40 -04:00
Brad King
526c6ff6d2 Emscripten: Drop -sMAIN_MODULE and -sSIDE_MODULE with emsdk toolchain file
Emscripten provides a combined toolchain file and platform module that
predates CMake upstream support.  It disables support for shared libs.
Fix commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16) to
avoid linking with `-sMAIN_MODULE` or `-sSIDE_MODULE` flags, meant to
support shared libraries, when using the emsdk toolchain file.

Fixes: #27232
2025-09-17 19:53:22 -04:00
Brad King
644ad91e6a Emscripten: Restore support for emsdk toolchain file and platform module
Emscripten provides a combined toolchain file and platform module that
predates CMake upstream support.  Since commit 96d9b94a98 (Emscripten:
Add platform modules, 2025-05-16), our `Platform/Emscripten` module is
included instead, suppressing existing behavior for users that set
`CMAKE_TOOLCHAIN_FILE` to the emsdk-provided toolchain file.  Restore
the previous behavior by teaching our module to defer to the original
module in that case.

Issue: #27232
2025-09-17 19:45:44 -04:00
Brad King
9cbeb922dd Emscripten: Enable de-duplication of libraries for CMP0156 with LLD
LLD automatically resolves newly encountered symbols using object files
previously encountered.  Also, the Emscripten compiler driver invokes
the LLD linker with `--whole-archive ... --no-whole-archive` around all
the libraries.  Therefore we should not repeat any.

Issue: #27232
Suggested-by: Marc Chevrier <marc.chevrier@gmail.com>
2025-09-17 19:44:13 -04:00
Brad King
f22d2904e2 Emscripten: Drop unused placeholder from link rule variables
Update commit 96d9b94a98 (Emscripten: Add platform modules, 2025-05-16)
to account for commit 67639002ad (Ninja,Makefile: Drop now-unused
placeholders from link rule variables, 2025-06-09, v4.1.0-rc1~37^2~1).
2025-09-17 19:44:13 -04:00
Brad King
f4da11a5da Emscripten: Select emcc and em++ compilers by default
This was missed by commit 96d9b94a98 (Emscripten: Add platform modules,
2025-05-16).
2025-09-17 19:44:13 -04:00
Brad King
9266d4817d Android: Allow custom compilers with NDK
If the user or toolchain file has already set `CMAKE_{C,CXX}_COMPILER`,
do not override it with the NDK-provided toolchain.

Fixes: #27162
2025-09-17 10:44:47 -04:00