[CMake] Building arguments to target_comple_definitions()
Rob Boehne
robb at datalogics.com
Mon Oct 15 10:12:34 EDT 2018
How would one set a variable containing multiple definitions to be passed to target_compile_definitions() ?
From: Chuck Atkins <chuck.atkins at kitware.com>
Date: Friday, October 12, 2018 at 1:45 PM
To: Rob Boehne <robb at datalogics.com>
Cc: CMake Mail List <cmake at cmake.org>
Subject: Re: [CMake] Building arguments to target_comple_definitions()
So in CMake parlance, what type is the last argument to target_compile_definitions? Is it a list, string or something else?
It's a series of VISIBILITY_SPECIFIER DEF1 DEF2 ... DEFN, so the visibility specifier followed by a list of definitions, optionally followed by another visibility specifier and list of definitions, etc.
add_library(Foo OBJECT Foo.cxx)
target_compile_definitions(Foo
PUBLIC
COMMON_DEF_1 COMMON_DEF_2
PRIVATE
FOO_SPECIFIC_DEF=42
)
will translate to something like:
c++ -DCOMMON_DEF_1 -DCOMMON_DEF_2 -DFOO_SPECIFIC_DEF=4 -o Foo.cxx.o -c Foo.cxx
- Chuck
From: Chuck Atkins <chuck.atkins at kitware.com<mailto:chuck.atkins at kitware.com>>
Date: Thursday, October 11, 2018 at 2:55 PM
To: Rob Boehne <robb at datalogics.com<mailto:robb at datalogics.com>>
Cc: CMake Mail List <cmake at cmake.org<mailto:cmake at cmake.org>>
Subject: Re: [CMake] Building arguments to target_comple_definitions()
So, are you suggesting that I make a “dummy” target and fill it with the common options in compile_definitions() and include_directories() (et. al.)
Then make my OBJECT libraries (and the shared library) depend on the “dummy” target?
If that’s not the suggestion, I’m afraid I don’t see how I can use this to set the common flags
That's certainly one way you can solve the problem, i.e. making an interface library with the common defs, and a good idea at that, but that's not what I was referring to. I was simply tying to explain that the error your getting trying to pass arguments to target_compile_options is because you're missing the visibility argument.
- Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181015/b30dba8a/attachment.html>
More information about the CMake
mailing list