<div dir="ltr">I've tried this. But then it fails to compile due to `INTERFACE API=${API_EXPORT_MACRO}` target compile definition.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">пт, 30 авг. 2019 г. в 17:49, Kyle Edwards <<a href="mailto:kyle.edwards@kitware.com">kyle.edwards@kitware.com</a>>:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, 2019-08-30 at 17:36 +0300, Eugene Karpov wrote:<br>
> Hello all,<br>
> <br>
> I'm working on a cross platform project. On Ubuntu I would like to<br>
> save all the compiler options, definitions and other complier related<br>
> stuff to a generated file to use it later for precompiled header<br>
> generation.<br>
> My issue is that I have to specify a macro that contain double quotes<br>
> for g++ compiler visibility attribute. When I generate a file with<br>
> double quotes they are not escaped. I also tried to use<br>
> `string(replace "\"" "\\\""...)` without effect.<br>
> I've made simple two files project of a shared library to show the<br>
> issue. It has only target compile definitions for simplicity.<br>
> <br>
> ------------- CMakeLists.txt ------------------<br>
> cmake_minimum_required(VERSION 3.14)<br>
> set(target test)<br>
> project(${target})<br>
> if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")<br>
>     set(API_IMPORT_MACRO "__attribute__((visibility(\"default\")))")<br>
>     set(API_EXPORT_MACRO "__attribute__((visibility(\"default\")))")<br>
<br>
The quotes here need to be double-escaped, like so:<br>
<br>
set(API_IMPORT_MACRO "__attribute__((visibility(\\\"default\\\")))")<br>
set(API_EXPORT_MACRO "__attribute__((visibility(\\\"default\\\")))")<br>
<br>
Kyle<br>
</blockquote></div>