Makefile Generator indepent definition of compiler / linker options containing shell meta characters

Hello, we are facing problems to define compiler or linker options inside cmake files that contain characters having some special meaning for make target commands interpreter in a CMakeGenerator independent way. Eg. When using the binutils ld option ‘-( archive_list -)’ we have to define it dependent on the selected CMakeGenerator:
if("${CMAKE_GENERATOR}" STREQUAL “Unix Makefiles”)
target_link_libraries(pt “-Wl,-\\(” b a “-Wl,-\\)”)
target_link_libraries(pt “-Wl,-(” b a “-Wl,-)”)

For ‘Unix Makefiles’ generator the brackets have to be masked because of their special meaning for sh command lines.

For ‘MinGW Makefiles’ generator brackets must not be masked else ‘-\(‘ and ‘-\)’ would be passed as invalid arguments to the linker.

Is there any way to define these kind of options in a CMakeGenerator independent way, i.e. without querying it.

That’s probably the reason why almost everyone uses the long form of those options…

For reference, CMake Issue 20078 has discussion of grouping link libraries. That’s orthogonal to escaping ( characters though.