I've tried this. But then it fails to compile due to `INTERFACE
API=${API_EXPORT_MACRO}` target compile definition.

пт, 30 авг. 2019 г. в 17:49, Kyle Edwards <kyle.edwa...@kitware.com>:

> On Fri, 2019-08-30 at 17:36 +0300, Eugene Karpov wrote:
> > Hello all,
> >
> > I'm working on a cross platform project. On Ubuntu I would like to
> > save all the compiler options, definitions and other complier related
> > stuff to a generated file to use it later for precompiled header
> > generation.
> > My issue is that I have to specify a macro that contain double quotes
> > for g++ compiler visibility attribute. When I generate a file with
> > double quotes they are not escaped. I also tried to use
> > `string(replace "\"" "\\\""...)` without effect.
> > I've made simple two files project of a shared library to show the
> > issue. It has only target compile definitions for simplicity.
> >
> > ------------- CMakeLists.txt ------------------
> > cmake_minimum_required(VERSION 3.14)
> > set(target test)
> > project(${target})
> > if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
> >     set(API_IMPORT_MACRO "__attribute__((visibility(\"default\")))")
> >     set(API_EXPORT_MACRO "__attribute__((visibility(\"default\")))")
>
> The quotes here need to be double-escaped, like so:
>
> set(API_IMPORT_MACRO "__attribute__((visibility(\\\"default\\\")))")
> set(API_EXPORT_MACRO "__attribute__((visibility(\\\"default\\\")))")
>
> Kyle
>
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
https://cmake.org/mailman/listinfo/cmake-developers

Reply via email to