fixup! Try to build with AVX2.
[openjpeg.git] / cscript
1 import os
2
3 def build(target, options):
4     cmd = 'cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%s -DBUILD_PKGCONFIG_FILES=ON' % target.directory
5     if target.platform == 'windows':
6         # Hack: the build fails if PATH includes /opt/windows/64/bin; I don't know why:
7         # remove it
8         target.set('PATH', '%s:%s' % (target.tool_path, os.environ['PATH']))
9         f = open('mingw.cmake', 'w')
10         print("SET(CMAKE_SYSTEM_NAME Windows)", file=f)
11         print("SET(CMAKE_C_COMPILER %s/%s)" % (target.tool_path, target.get('CC')), file=f)
12         print("SET(CMAKE_RC_COMPILER %s/%s)" % (target.tool_path, target.get('WINRC')), file=f)
13         all = "%s " % target.library_prefix
14         print("SET(CMAKE_ROOT_FIND_PATH %s %s)" % (all, target.tool_path), file=f)
15         print("SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)", file=f)
16         print("SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)", file=f)
17         print("SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)", file=f)
18         cmd += ' -DCMAKE_TOOLCHAIN_FILE=mingw.cmake'
19         f.close()
20     if target.platform == 'linux':
21         cmd += ' -DBUILD_SHARED_LIBS=OFF -DCMAKE_C_FLAGS_RELEASE="-O3 -DNDEBUG -mavx2"'
22     if target.platform == 'osx':
23         cmd += ' -DCMAKE_OSX_SYSROOT=%s/MacOSX%s.sdk' % (target.sdk_prefix, target.sdk)
24
25     target.command(cmd)
26     target.command('make -j%d VERBOSE=1' % target.parallel)
27     target.command('make install')