diff --git a/modules/freetype/SCsub b/modules/freetype/SCsub index 3e2068b8dbb..f6d7cdfc116 100644 --- a/modules/freetype/SCsub +++ b/modules/freetype/SCsub @@ -62,13 +62,6 @@ if env['builtin_freetype']: # Globally too, as freetype is used in scene (see bottom) env.Append(CCFLAGS=['/FI', '"modules/freetype/uwpdef.h"']) - sfnt = thirdparty_dir + 'src/sfnt/sfnt.c' - if env['platform'] == 'javascript': - # Forcibly undefine this macro so SIMD is not used in this file, - # since currently unsupported in WASM - sfnt = env_freetype.Object(sfnt, CPPFLAGS=['-U__OPTIMIZE__']) - thirdparty_sources += [sfnt] - env_freetype.Append(CPPPATH=[thirdparty_dir + "/include"]) # Also needed in main env for scene/ env.Append(CPPPATH=[thirdparty_dir + "/include"]) @@ -81,6 +74,16 @@ if env['builtin_freetype']: if env['builtin_libpng']: env_freetype.Append(CPPPATH=["#thirdparty/libpng"]) + sfnt = thirdparty_dir + 'src/sfnt/sfnt.c' + # Must be done after all CPPFLAGS are being set so we can copy them. + if env['platform'] == 'javascript': + # Forcibly undefine this macro so SIMD is not used in this file, + # since currently unsupported in WASM + tmp_env = env_freetype.Clone() + tmp_env.Append(CPPFLAGS=['-U__OPTIMIZE__']) + sfnt = tmp_env.Object(sfnt) + thirdparty_sources += [sfnt] + env_thirdparty = env_freetype.Clone() env_thirdparty.disable_warnings() lib = env_thirdparty.add_library("freetype_builtin", thirdparty_sources)