Set per-file build flags?

Sysprogs forums Forums VisualGDB Set per-file build flags?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #7704
    angus_fx
    Participant

    Hello,

    Loving VisualGDB so far – but wondered if there’s a way to set CFLAGS and CXXFLAGS per cpp file (same as you can in VC++ or Xcode, selecting individual files and adjusting their build settings).

    In particular, I need to switch AVX and AVX2 on and off per file.

    Also – does it have any support for building multiple projects inheriting from a common settings file – analogous to the *.vsprops heritable properties in VC++ and the *.xcconfig in Xcode)?

    Thanks much,

    Angus.

    #7708
    support
    Keymaster

    You can modify your makefile as follows to support per-file flags

    1. Modify the file rule templates to include file-specific variables:

    $(CXX) $(CXXFLAGS) $($(basename $(notdir $<))_FLAGS) -c $< -o $@ -MD -MF $(@:.o=.dep)

    1. Add file-specific flags defines above the FileSpecificTemplates line:

    LEDBlink_FLAGS := -O0

    You can modify the $(basename $(notdir …)) expression to use the directory name instead of the file name. See the GNU Make function reference for more details.

    You can similarly add the “include” lines to the Makefile to include your own files containing lines like “CFLAGS += some_flag”.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.