Skip to content
Snippets Groups Projects
Commit 10ece11c authored by Dominic Kempf's avatar Dominic Kempf Committed by Dominic Kempf
Browse files

[CMake] Allow adding compile flags upon running make

Autotools users kept complaining, that it is conceptionally
disappointing that targets cannot be build with flags set upon
entering make (e.g. make CXXFLAGS+="-myflag" mytarget). This
patch introduces a small hack, that allows for such feature
in cmake. It is, however, (at least) questionable whether we
want to include it. Still, for your information and convenience:

To use the feature you must:
- be using a CMake generator that is based on Makefiles (defaults to true)
- set the define ALLOW_EXTRA_CXXFLAGS to true, e.g. by including
  CMAKE_FLAGS="-DALLOW_EXTRA_CXXFLAGS=1" in your optsfile.
- reconfigure your project

cmake will then wrap a small shell script around your compiler
and allow you to append the content of an environment variable
to yout compiler flags. Run for above example:
EXTRA_CXXFLAGS="-myflag" make mytarget

The additional flags will be visually confirmed if and only if
you set the verbosity (as always):
EXTRA_CXXFLAGS="-myflag" make VERBOSE=1 mytarget
parent 4adcfde1
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment