[CMake] target_compile_flags and PUBLIC

Biddiscombe, John A. biddisco at cscs.ch
Tue Oct 9 03:40:51 EDT 2018


I have a problem with exported flags from a project.

If I use `target_compile_options(hpx PUBLIC ${flags})` hpx is compiled with the flags, and all 500+ tests within the project that depend on hpx inherit the flags too, so they get built correctly. However, the `HPXTargets.cmake` file that is generated with the exported targets, also inherits these flags and lists them in INTERFACE_COMPILE_OPTIONS, so now users are complaining that flags used to compile hpx are being passed onto their project and some of the stuff we use like `-Werror=sign-compare` causes a build fail in their project. If I use `target_compile_options(hpx PRIVATE ${flags})` then the flags are not passed on to the user projects, but also not passed on to the tests either. Is there an easy way of saying, pass these flags to all my projects within this 'PROJECT' but don't export them via the PUBLIC/INTERFACE to 3rd party users?

Thanks

JB
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181009/660fc8f1/attachment.html>


More information about the CMake mailing list