# How to remove default argument from linker command line

**URL:** https://discourse.cmake.org/t/how-to-remove-default-argument-from-linker-command-line/14376
**Category:** Usage
**Tags:** os:windows
**Created:** [July 15, 2025, 10:07pm UTC](https://discourse.cmake.org/t/how-to-remove-default-argument-from-linker-command-line/14376 "2025-07-15T22:07:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![phx-veronica](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@phx-veronica](https://discourse.cmake.org/u/phx-veronica)
#### Post date: [July 15, 2025, 10:07pm UTC](https://discourse.cmake.org/t/how-to-remove-default-argument-from-linker-command-line/14376/1 "2025-07-15T22:07:57Z")

</div>

I am using CMake to compile an EFI application for ARM64 with MSVC. EFI applications are not compatible with the /DYNAMICBASE linker command line switch, which CMake adds by default. For x86-64, it’s enough to add /DYNAMICBASE:NO to the linker command with `add_link_options (/DYNAMICBASE:NO)`, but this isn’t enough for ARM64, the original /DYNAMICBASE must be removed.

So I need to remove the default /DYNAMICBASE from the linker command line. How do I do this?

I know the command line being generated by CMake includes /DYNAMICBASE from running cmake --build . --verbose, and I know that I am not adding the /DYNAMICBASE myself anywhere. It is coming from CMake itself.

---

<div class="post-metadata">

### Author: ![phx-veronica](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/p/ce7236/32.png) [@phx-veronica](https://discourse.cmake.org/u/phx-veronica)
#### Post date: [July 15, 2025, 10:10pm UTC](https://discourse.cmake.org/t/how-to-remove-default-argument-from-linker-command-line/14376/2 "2025-07-15T22:10:52Z")

</div>

I tried modifying LINK\_OPTIONS, and that doesn’t remove it:

get\_target\_property (project\_linkopts project LINK\_OPTIONS)

list (REMOVE\_ITEM project\_linkopts “/DYNAMICBASE”)

set\_target\_properties(project PROPERTIES LINK\_OPTIONS “${project\_linkopts}”)

Using prints, I found that /DYNAMICBASE isn’t present in LINK\_OPTIONS to begin with, it’s coming from somewhere else.

---

<div class="post-metadata">

### Author: ![vito.gamberini](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vito.gamberini/32/4376_2.png) [@vito.gamberini](https://discourse.cmake.org/u/vito.gamberini)
#### Post date: [July 17, 2025, 3:56pm UTC](https://discourse.cmake.org/t/how-to-remove-default-argument-from-linker-command-line/14376/3 "2025-07-17T15:56:57Z")

</div>

It’s built-in to the MSBuild templates that the MSBuild-based generators use. These were generated directly from the templates that MS ships with Visual Studio with the `Source/cmConvertMSBuildXMLToJSON.py` script.

The simple answer is to use a generator other than MSBuild that doesn’t have such built-in flag assumptions. Ninja is the usual recommendation.
