[CMake] Removing duplicate entries from CXXFLAGS

Roman Bolshakov roolebo at gmail.com
Tue Oct 6 06:58:02 EDT 2015


CMake performs deduplication of per-target flags for sure.




However I'm not sure if CMAKE_CXX_FLAGS is deduplicated. But I consider this variable as global flags for the whole project which is defined at topmost CMakeLists.txt. If you need to specify some flags specifically for a target use target_compile_options.



—
Sent from Mailbox

On Mon, Oct 5, 2015 at 4:23 PM, Attila Krasznahorkay
<attila.krasznahorkay at gmail.com> wrote:

> Dear All,
> Let me try a simpler question this time. (I'm a bit disappointed that nobody had any comments on my question about sub-projects.)
> I'm trying to clean up my project's build a bit. As it collects compilation flags from a few separate places, by the time it finishes collecting everything, the compilation commands are usually very long. As they have many duplications. Like:
> -m64 -pipe -W
>  -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -Wno-deprecated-declaration
> s -stdlib=libc++ -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++
> 11 -Wno-deprecated-declarations -stdlib=libc++ -Wno-unused-local-typedefs -Wno-tautological-undefined-compare -Wno-incon
> sistent-missing-override -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread
> -std=c++11 -Wno-deprecated-declarations -stdlib=libc++ -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-commo
> n -Qunused-arguments -pthread -std=c++11 -Wno-deprecated-declarations -stdlib=libc++ -m64 -pipe -W -Wall -Woverloaded-vi
> rtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -Wno-deprecated-declarations -stdlib=libc++ -m64
> -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -Wno-deprecated-dec
> larations -stdlib=libc++ -m64 -pipe -fsigned-char -fno-common -Qunused-arguments -pthread -std=c++11 -stdlib=libc++
> Naturally it would help the build log reading tremendously if I could remove the duplications from these lines. But I can't find a good way of doing it. How could I weed out all the duplications in the CXXFLAGS associated to a given target?
> Cheers,
>             Attila
> -- 
> 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:
> http://public.kitware.com/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20151006/1a754215/attachment.html>


More information about the CMake mailing list