blob: bdc40657b7a373eb1f7e117ec1a8da168445cb4a [file] [log] [blame]
Alexander Afanasyev3fd14f02014-03-26 14:34:39 -07001# -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*-
2
3from waflib import Logs, Configure
4
5def configure(conf):
6 areCustomCxxflagsPresent = (len(conf.env.CXXFLAGS) > 0)
7 if conf.options.debug:
8 conf.define('_DEBUG', 1)
9 defaultFlags = ['-O0', '-g3',
10 '-Werror',
11 '-Wall',
12 '-fcolor-diagnostics', # only clang supports
13
14 # to disable known warnings
15 '-Wno-unused-variable', # cryptopp
16 '-Wno-unused-function',
17 '-Wno-deprecated-declarations',
18 ]
19
20 if areCustomCxxflagsPresent:
21 missingFlags = [x for x in defaultFlags if x not in conf.env.CXXFLAGS]
22 if len(missingFlags) > 0:
23 Logs.warn("Selected debug mode, but CXXFLAGS is set to a custom value '%s'"
24 % " ".join(conf.env.CXXFLAGS))
25 Logs.warn("Default flags '%s' are not activated" % " ".join(missingFlags))
26 else:
27 conf.add_supported_cxxflags(cxxflags = defaultFlags)
28 else:
29 defaultFlags = ['-O2', '-g', '-Wall',
30
31 # to disable known warnings
32 '-Wno-unused-variable', # cryptopp
33 '-Wno-unused-function',
34 '-Wno-deprecated-declarations',
35 ]
36 if not areCustomCxxflagsPresent:
37 conf.add_supported_cxxflags(cxxflags = defaultFlags)
38
39@Configure.conf
40def add_supported_cxxflags(self, cxxflags):
41 """
42 Check which cxxflags are supported by compiler and add them to env.CXXFLAGS variable
43 """
44 self.start_msg('Checking allowed flags for c++ compiler')
45
46 supportedFlags = []
47 for flag in cxxflags:
48 if self.check_cxx (cxxflags=[flag], mandatory=False):
49 supportedFlags += [flag]
50
51 self.end_msg (' '.join (supportedFlags))
52 self.env.CXXFLAGS += supportedFlags