Hi John, you could put those flags as PUBLIC into a separate INTERFACE target (let's call it hpxFlags) and then do
target_libraries(hpx PRIVATE hpxFlags) Then create another interface target hpxForTests to combine those two targets: target_link_libraries(hpxForTests PUBLIC hpx hpxFlags) And then link all the tests to hpxForTests instead of to hpx. Petr On Tue, 9 Oct 2018 at 09:48, Biddiscombe, John A. <biddi...@cscs.ch> wrote: > 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 > > 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 >
-- Powered by 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