Add -x32/-x64 suffix to boost libraries when building for Windows.
authorCarl Hetherington <cth@carlh.net>
Tue, 22 Feb 2022 22:06:29 +0000 (23:06 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 24 Feb 2022 20:13:14 +0000 (21:13 +0100)
cscript
src/wscript
wscript

diff --git a/cscript b/cscript
index d97e1d9927a6db00640db50c54eb222932e9d206..22be13a97abad201d73d2cb25f3d87fbf39ae7f7 100644 (file)
--- a/cscript
+++ b/cscript
@@ -4,7 +4,7 @@ def build(target, options):
     if target.platform == 'linux':
         cmd += ' --static'
     elif target.platform == 'windows':
-        cmd += ' --target-windows'
+        cmd += f' --target-windows-{target.bits}'
 
     target.append_with_space('LIBS', '-lboost_system')
     target.append_with_space('LIBS', '-lboost_filesystem')
index 2d09b3182c0fb101cbaf9916099fc139fee5e3d2..e7dbbcbd4256233dbdb78a4f6f25a967e2c31aa0 100644 (file)
@@ -6,7 +6,7 @@ def configure(conf):
     s = conf.env.VERSION.split('.')
     major_minor = '%s.%s.0' % (s[0], s[1])
     conf.env.append_value('CXXFLAGS', ['-DPACKAGE_VERSION="%s"' % major_minor])
-    if conf.options.target_windows:
+    if conf.options.target_windows_64 or conf.options.target_windows_32:
         conf.env.append_value('CXXFLAGS', ['-DASDCP_PLATFORM="win32"', '-DKM_WIN32', '-DWIN32_LEAN_AND_MEAN'])
     else:
         conf.env.append_value('CXXFLAGS', '-DASDCP_PLATFORM="linux"')
diff --git a/wscript b/wscript
index 5c9277f0a72f05a3a156948c46a93cd7d769dae6..9a2cd5f674b934f27f00b2729a350fccd397750b 100644 (file)
--- a/wscript
+++ b/wscript
@@ -21,7 +21,8 @@ else:
 
 def options(opt):
     opt.load('compiler_cxx')
-    opt.add_option('--target-windows', action='store_true', default=False, help='set up to do a cross-compile to Windows')
+    opt.add_option('--target-windows-64', action='store_true', default=False, help='set up to do a cross-compile to Windows 64-bit')
+    opt.add_option('--target-windows-32', action='store_true', default=False, help='set up to do a cross-compile to Windows 32-bit')
     opt.add_option('--enable-debug', action='store_true', default=False, help='build with debugging information and without optimisation')
     opt.add_option('--static', action='store_true', default=False, help='build statically')
 
@@ -29,9 +30,10 @@ def configure(conf):
     conf.load('compiler_cxx')
     conf.env.append_value('CXXFLAGS', ['-Wall', '-Wextra', '-D_FILE_OFFSET_BITS=64', '-D__STDC_FORMAT_MACROS'])
 
-    conf.env.TARGET_WINDOWS = conf.options.target_windows
+    conf.env.TARGET_WINDOWS_64 = conf.options.target_windows_64
+    conf.env.TARGET_WINDOWS_32 = conf.options.target_windows_32
     conf.env.TARGET_OSX = sys.platform == 'darwin'
-    conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS and not conf.env.TARGET_OSX
+    conf.env.TARGET_LINUX = not conf.env.TARGET_WINDOWS_64 and not conf.env.TARGET_WINDOWS_32 and not conf.env.TARGET_OSX
     conf.env.STATIC = conf.options.static
     conf.env.VERSION = VERSION
 
@@ -44,8 +46,10 @@ def configure(conf):
 
     conf.check_cfg(package='openssl', args='--cflags --libs', uselib_store='OPENSSL', mandatory=True)
 
-    if conf.options.target_windows:
-        boost_lib_suffix = '-mt'
+    if conf.options.target_windows_64:
+        boost_lib_suffix = '-mt-x64'
+    elif conf.options.target_windows_32:
+        boost_lib_suffix = '-mt-x32'
     else:
         boost_lib_suffix = ''
 
@@ -80,8 +84,11 @@ def configure(conf):
     conf.recurse('src')
 
 def build(bld):
-    if bld.env.TARGET_WINDOWS:
-        boost_lib_suffix = '-mt'
+    if bld.env.TARGET_WINDOWS_64:
+        boost_lib_suffix = '-mt-x64'
+        flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN'
+    elif bld.env.TARGET_WINDOWS_32:
+        boost_lib_suffix = '-mt-x32'
         flags = '-DKM_WIN32 -DWIN32_LEAN_AND_MEAN'
     else:
         boost_lib_suffix = ''