[CMake] target_compile_flags and PUBLIC

Biddiscombe, John A. biddisco at cscs.ch
Tue Oct 9 04:41:25 EDT 2018


Marc

Thank you. That fixes it.

JB
________________________________
From: Marc CHEVRIER [marc.chevrier at gmail.com]
Sent: 09 October 2018 09:52
To: Biddiscombe, John A.
Cc: cmake at cmake.org
Subject: Re: [CMake] target_compile_flags and PUBLIC

Have a look at '$<BUILD_INTERFACE:...>' and '$<INSTALL_INTERFACE:...>' generator expressions.

Le mar. 9 oct. 2018 à 09:48, Biddiscombe, John A. <biddisco at cscs.ch<mailto:biddisco at cscs.ch>> a écrit :
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
--

Powered by www.kitware.com<http://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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20181009/4cbdb186/attachment.html>


More information about the CMake mailing list