diff --git a/build/SConscript.configure b/build/SConscript.configure index 01d86d58..6b5eab89 100644 --- a/build/SConscript.configure +++ b/build/SConscript.configure @@ -267,9 +267,29 @@ def osxlibinst_as_build_function(self, target, source, pkgname = None, use_own = self.AddPostAction(inst, 'install_name_tool -id @loader_path/../Frameworks/' + name + ' $TARGET') return inst +def remove_flag(env, value): + try: + env['CXXFLAGS'].remove(value) + except: + pass + +def append_flag(env, value): + env['CXXFLAGS'].append(value) + +env.__class__.RemoveFlag = remove_flag +env.__class__.AppendFlag = append_flag env.__class__.OSXLibInst = osxlibinst_build_function env.__class__.OSXLibInstAs = osxlibinst_as_build_function +def prepare_for_objective_cpp(env): + # Objective C++ does not permit the following optimization flags + env.RemoveFlag('-fstrict-aliasing') + env.RemoveFlag('-ftree-vectorize') + env.RemoveFlag('-std=c++0x') + env.AppendFlag('-fno-strict-aliasing') + +env.__class__.ConfigureForObjectiveCPP = prepare_for_objective_cpp + if hasCollada: env.Append(CPPDEFINES = [['MTS_HAS_COLLADA', 1]] ) diff --git a/src/libcore/SConscript b/src/libcore/SConscript index 8d35666d..5416e864 100644 --- a/src/libcore/SConscript +++ b/src/libcore/SConscript @@ -39,13 +39,7 @@ libcore_objects = [ # Add some platform-specific components if sys.platform == 'darwin': coreEnv_osx = coreEnv.Clone() - try: - # Objective C++ does not permit the following optimization flags - coreEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing') - coreEnv_osx['CXXFLAGS'].remove('-ftree-vectorize') - coreEnv_osx['CXXFLAGS'].append('-fno-strict-aliasing') - except: - pass + coreEnv_osx.ConfigureForObjectiveCPP() libcore_objects += coreEnv_osx.SharedObject('platform_darwin.mm') elif sys.platform == 'win32': libcore_objects += coreEnv.SharedObject('getopt.c') diff --git a/src/libhw/SConscript b/src/libhw/SConscript index e263a573..0d9ab15a 100644 --- a/src/libhw/SConscript +++ b/src/libhw/SConscript @@ -30,13 +30,7 @@ if glEnv.has_key('GLINCLUDE'): if sys.platform == 'darwin': glEnv_osx = glEnv.Clone() - try: - # Objective C++ does not permit the following optimization flags - glEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing') - glEnv_osx['CXXFLAGS'].remove('-ftree-vectorize') - glEnv_osx['CXXFLAGS'].append('-fno-strict-aliasing') - except: - pass + glEnv_osx.ConfigureForObjectiveCPP() libhw_objects += glEnv_osx.SharedObject(['nsglsession.mm', 'nsgldevice.mm', 'nsglrenderer.mm']) diff --git a/src/mitsuba/SConscript b/src/mitsuba/SConscript index 9e687c5b..4ac8f392 100644 --- a/src/mitsuba/SConscript +++ b/src/mitsuba/SConscript @@ -20,13 +20,7 @@ if mainEnv.has_key('GLINCLUDE'): if sys.platform == 'darwin': # On OSX, we need this stub to access OpenGL from the command line mainEnv_osx = mainEnv.Clone() - try: - # Objective C++ does not permit the following optimization flags - mainEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing') - mainEnv_osx['CXXFLAGS'].remove('-ftree-vectorize') - mainEnv_osx['CXXFLAGS'].append('-fno-strict-aliasing') - except: - pass + mainEnv_osx.ConfigureForObjectiveCPP() stubs += [mainEnv_osx.StaticObject('darwin_stub.mm')] mainEnv.Program('mtsutil', resources + stubs + ['mtsutil.cpp']) diff --git a/src/mtsgui/SConscript b/src/mtsgui/SConscript index fb73096c..3d04e5ec 100644 --- a/src/mtsgui/SConscript +++ b/src/mtsgui/SConscript @@ -49,13 +49,7 @@ if hasQt: if sys.platform == 'darwin': qtEnv_osx = qtEnv.Clone() - try: - # Objective C++ does not permit the following optimization flags - qtEnv_osx['CXXFLAGS'].remove('-fstrict-aliasing') - qtEnv_osx['CXXFLAGS'].remove('-ftree-vectorize') - qtEnv_osx['CXXFLAGS'].append('-fno-strict-aliasing') - except: - pass + qtEnv_osx.ConfigureForObjectiveCPP() qtEnv_osx['CXXFLAGS'].append(['-Fdependencies/darwin', '-framework', 'BWToolkitFramework']) qtSources += qtEnv_osx.StaticObject('previewsettingsdlg_cocoa_impl.mm') else: