On Thu, 4 Apr 2019 at 14:47, Benjamin Orgogozo <[email protected]> wrote: > > If I'm right (I'm far from being a cmake expert) there are two ways to > define "global" compilation flags: > 1- set the CXX_COMPILE_FLAGS variable; > 2- use add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-WMyFavouriteWarning).
The list should rather be, in preference/priority order 1. https://cmake.org/cmake/help/latest/command/target_compile_options.html 2. add_compile_options And, if you really, really need 3. append to CMAKE_CXX_FLAGS > Since I don't want to *add* a compilation flags but remove one, I would > like to retrieve the properties of the target > (get_target_property(my_compilation_flags TARGET COMPILE_FLAGS)), and > then modify those and use it to set the properties of the target. > > Two questions for me remain: > 1- How do I get *all* the compilation flags used for a target? > get_target_property doesn't return flags is CXX_COMPILE_FLAGS nor those > added by add_compile_options. Are you certain you've got the variable name right? https://cmake.org/cmake/help/latest/search.html?q=CXX_COMPILE_FLAGS > 2- How do I *replace* compilation flags and don't *add* compilation > flags? Both target_compile_options and set_target_properties seems to > *add* flags and don't replace. See https://cmake.org/pipermail/cmake/2018-December/068716.html Best regards, -- Mateusz Loskot, http://mateusz.loskot.net -- 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
