Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CMake bracket escape character for custom target command

I am in need of the bracket escape character used to avoid quoting special characters in CMake when parsing make commands to add_custom_target. This is more of a syntax problem that from my understanding, is not covered in CMake documentation.

An example case is:

add_custom_target ( defined_path ALL .exe <args1> | ( ! grep ... )

In this example, the extension to <args1> is resolved as | "(" grep ... ")". Unfortunately appending backslash before the brackets only works for string cases, i.e. assigning to a variable with set: set ( something "\(" ). Even then the variable itself is resolved in the build.make surrounded by quotations. Likewise parsing a pre-formatted list using separate_arguments also resolves with quotations.

The full command without the make formatting is executed successfully.

like image 939
lukemtesta Avatar asked Apr 07 '26 12:04

lukemtesta


1 Answers

Cmake requires an explicit call to shell in the target command

like image 59
lukemtesta Avatar answered Apr 09 '26 09:04

lukemtesta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!