title: Controlling flags passed to the generator
body: <p>My project is bare metal, so I need to have a full control of the compiler/linker flags passed by cmake to the generator (ninja in this case). after setting seemingly everything, I still am getting <code>/SUBSYSTEM:console</code> passed to the linker which I haven't set (I do set another /subsystem value) in the ninja.build file. I checked CMakeCache.txt file so as to see, that all *_INIT variables were cleared/set appropriately by my &quot;override&quot; file, and they really are. I checked the target link options, the directory ones, there is no this option set over there, yet it's getting stubbornly passed. Where else I need to look to find what yet variable (they seem to be endless) is adding to the final linker options list? Thanks.</p>
  <p>Edited. As asked, below is the minimal example for redproducing it:</p>
  <pre><code>cmake_minimum_required(VERSION 3.10)
  set(CMAKE_POSITION_INDEPENDENT_CODE OFF)
  
  set(CMAKE_USER_MAKE_RULES_OVERRIDE &quot;./overrides.cmake&quot;)
  
  set(CMAKE_BUILD_TYPE &quot;Release&quot;)
  
  project(MyProject)
  
  if(ARCH STREQUAL &quot;arm&quot;)
      set(CMAKE_C_FLAGS &quot;/arch:ARMv7VE ${CMAKE_C_FLAGS}&quot;)
  endif()
  
  list(APPEND MyProjectSources
      source1.c source2.c source3.c
  )
  
  add_executable(MyProject ${MyProjectSources})
  set_target_properties(MyProject PROPERTIES SUFFIX &quot;.efi&quot;)
  
  target_compile_options(MyProject PRIVATE    /kernel /X /Zl /GR- /EHs-c- /Gs65536 /GS- /TC /nologo)
  target_link_options(MyProject PRIVATE   /NODEFAULTLIB /SAFESEH:NO /RELEASE /SUBSYSTEM:EFI_APPLICATION
                  /ENTRY:LoaderEntry /FIXED:NO /GUARD:NO /MACHINE:${ARCH} /NOLOGO)
  </code></pre>
  <p>and here is the <code>overrides.cmake</code> file, mentioned in the above, main (and only) <code>CMakeLists.txt</code> file:</p>
  <pre><code>set(CMAKE_CXX_FLAGS_DEBUG_INIT &quot;&quot;)
  set(CMAKE_CXX_FLAGS_INIT &quot;&quot;)
  set(CMAKE_CXX_FLAGS_RELEASE_INIT &quot;&quot;)
  set(CMAKE_CXX_STANDARD_LIBRARIES_INIT &quot;&quot;)
  
  set(CMAKE_C_FLAGS_DEBUG_INIT &quot;&quot;)
  set(CMAKE_C_FLAGS_INIT &quot;&quot;)
  set(CMAKE_C_FLAGS_RELEASE_INIT &quot;&quot;)
  set(CMAKE_C_STANDARD_LIBRARIES_INIT &quot;&quot;)
  
  set(CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT &quot;/debug&quot;)
  set(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT &quot;/debug&quot;)
  set(CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT &quot;/debug&quot;)
  set(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO_INIT &quot;/debug&quot;)
  set(CMAKE_MODULE_LINKER_FLAGS_DEBUG_INIT &quot;/debug&quot;)
  set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO_INIT &quot;/debug&quot;
  </code></pre>
  <p>The resulting <code>ninja.build</code> file's linker options, have these 3 flags (prepended), in addition to what I've set:</p>
  <pre><code>/machine:ARM64 /INCREMENTAL:NO /subsystem:console
  </code></pre>
  <p>the 1st comes from <code>CMAKE_EXE_LINKER_FLAGS</code>, the 2nd - from <code>CMAKE_EXE_LINKER_FLAGS_RELEASE</code>, and the 3rd comes from nowhere.</p>