<div dir="ltr"><div dir="ltr">Hi All,<br><div><br></div><div>I have been cleaning up our legacy CMake to use newer features (available in 3.12+) including trying to use target_...() functions nearly exclusively. As part of this, I was toying with cleaning up our use cases for adding compiler flags and similar definitions using real targets and target_link_libraries.</div><div><br></div><div>For instance, as a simple example, let's say I wanted to add/provide a definition MY_FLAG, I could do something like...</div><div><br></div><div>```</div><div>add_library(my_flag INTERFACE)<br></div><div>target_compile_definitions(my_flag INTERFACE MY_FLAG=1)</div><div><br></div><div>add_library(other_library SHARED ...)</div><div>target_link_libraries(other_library ... <b>PRIVATE </b>my_flag)</div><div><br></div><div>export/install rules</div><div>```</div><div><br></div><div>I want this library to be private to my component, and it's only used under the PRIVATE banner. However, the issue I'm running into is with the install/export rules. I get an error similar to ...</div><div><br></div><div>```</div><div><div>CMake Error: install(EXPORT "MY_PROJECT" ...) includes target "other_library" which requires target "my_flag" that is not in the export set. </div><div>```</div><div><br></div><div>If my_flag is defined in my component, I can add it to the export set perhaps to workaround the issue, but in many cases, it would be coming from a helper script in another sub-project I'm fetching using FetchContent and don't want to expose the functionality via my export scripts.</div></div><div><br></div><div>(1) Is it recommended to use interface libraries to clean up compile defintions, etc.</div><div>(2) Should it be possible to link privately such libraries and not have the export functionality complain?</div><div><br></div><div>Thanks!</div><div><br></div><div><br></div></div></div>