Add cscript
[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.mingw_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.mingw_path, target.get('CC')), file=f)
12         print("SET(CMAKE_RC_COMPILER %s/%s)" % (target.mingw_path, target.get('WINRC')), file=f)
13         all = ""
14         for p in target.mingw_prefixes:
15             all += "%s " % p
16         print("SET(CMAKE_ROOT_FIND_PATH %s %s)" % (all, target.mingw_path), file=f)
17         print("SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)", file=f)
18         print("SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)", file=f)
19         print("SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)", file=f)
20         cmd += ' -DCMAKE_TOOLCHAIN_FILE=mingw.cmake'
21         f.close()
22     if target.platform == 'linux':
23         cmd += ' -DBUILD_SHARED_LIBS=OFF'
24     if target.platform == 'osx':
25         cmd += ' -DCMAKE_OSX_SYSROOT=%s/MacOSX%s.sdk' % (target.sdk_prefix, target.sdk)
26
27     target.command(cmd)
28     target.command('make -j%d VERBOSE=1' % target.parallel)
29     target.command('make install')