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

**URL:** https://discourse.cmake.org/t/makefile-generator-indepent-definition-of-compiler-linker-options-containing-shell-meta-characters/1534
**Category:** Code
**Tags:** gen:makefiles
**Created:** [July 10, 2020, 1:09pm UTC](https://discourse.cmake.org/t/makefile-generator-indepent-definition-of-compiler-linker-options-containing-shell-meta-characters/1534 "2020-07-10T13:09:06Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![raik](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/82dd89/32.png) [@raik](https://discourse.cmake.org/u/raik)
#### Post date: [July 10, 2020, 1:09pm UTC](https://discourse.cmake.org/t/makefile-generator-indepent-definition-of-compiler-linker-options-containing-shell-meta-characters/1534/1 "2020-07-10T13:09:06Z")

</div>

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,-\\)”)  
else()  
target\_link\_libraries(pt “-Wl,-(” b a “-Wl,-)”)  
endif()

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.

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [July 10, 2020, 2:07pm UTC](https://discourse.cmake.org/t/makefile-generator-indepent-definition-of-compiler-linker-options-containing-shell-meta-characters/1534/2 "2020-07-10T14:07:30Z")

</div>

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

---

<div class="post-metadata">

### Author: ![brad.king](https://discourse.cmake.org/user_avatar/discourse.cmake.org/brad.king/32/11_2.png) [@brad.king](https://discourse.cmake.org/u/brad.king)
#### Post date: [July 28, 2020, 1:45pm UTC](https://discourse.cmake.org/t/makefile-generator-indepent-definition-of-compiler-linker-options-containing-shell-meta-characters/1534/3 "2020-07-28T13:45:32Z")

</div>

For reference, [CMake Issue 20078](https://gitlab.kitware.com/cmake/cmake/-/issues/20078) has discussion of grouping link libraries. That’s orthogonal to escaping `(` characters though.
