[CMake] Building arguments to target_comple_definitions()

Rob Boehne robb at datalogics.com
Thu Oct 11 15:34:37 EDT 2018


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


From: Chuck Atkins <chuck.atkins at kitware.com>
Date: Thursday, October 11, 2018 at 2:12 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()

Hi Rob,

target_compile_definitions( CHUNK1 ${COMMON_DEFINITIONS}  CHUNK1_STUFF CHUNK_NAME=\”One\” )
target_compile_definitions( CHUNK2 ${COMMON_DEFINITIONS}  CHUNK2_STUFF CHUNK_NAME=\”Two\”)
target_compile_definitions( FooBar ${COMMON_DEFINITIONS}  )

This is what I was referring to.  Adding visibility to target_compile_definitions:

target_compile_definitions(CHUNK1 PRIVATE ${COMMON_DEFINITIONS} CHUNK1_STUFF CHUNK_NAME=\"One\")
target_compile_definitions(CHUNK2 PRIVATE ${COMMON_DEFINITIONS} CHUNK2_STUFF CHUNK_NAME=\"Two\")
target_compile_definitions(FooBar PRIVATE ${COMMON_DEFINITIONS})

All of the target_<foo> commands take the format target_foo(target_name USAGE_VISIBILY bar1 bar2 bar3 ...).  target_link_libraries is the exception with everythign being PUBLIC by default but only because it pre-dates all the other target commands.

- Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181011/3d75e185/attachment.html>


More information about the CMake mailing list