Language build rules should be changeable target properties instead of global platform dependent variables.
It would probably make sense to move the build rules (i.e. CMAKE_${lang}_LINK_EXECUTABLE
, CMAKE_${lang}_CREATE_(SHARED|STATIC|MODULE)_LIBRARY
, CMAKE_${lang}_COMPILE_OBJECT
etc) into the targets themselves instead of having purely global rules.
From what those variables do it should already be clear that they only make sense if they are directly associated with certain targets instead of being globally defined. The global definition however could easily be the default like many other CMAKE_
variables for target properties.
Use case:
I had at least one target in a MSVC toolchain where I wanted needed to invoke the compiler instead of linker for linking.