-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup
executable file
·82 lines (61 loc) · 2.83 KB
/
setup
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env python
# This file is autogenerated by Autocmake http://autocmake.org
# Copyright (c) 2015 by Radovan Bast and Jonas Juselius
import os
import sys
sys.path.insert(0, 'cmake')
sys.path.insert(0, 'cmake/lib')
sys.path.insert(0, 'cmake/lib/docopt')
import config
import docopt
options = """
Usage:
./setup [options] [<builddir>]
./setup (-h | --help)
Options:
--fc=<FC> Fortran compiler [default: gfortran].
--extra-fc-flags=<EXTRA_FCFLAGS> Extra Fortran compiler flags [default: ''].
--fc-support=<FC_SUPPORT> Toggle Fortran language support (ON/OFF) [default: ON].
--int64 Enable 64bit integers [default: False].
--coverage Enable code coverage [default: False].
--type=<TYPE> Set the CMake build type (debug, release, or relwithdeb) [default: release].
--generator=<STRING> Set the CMake build system generator [default: Unix Makefiles].
--show Show CMake command and exit.
--cmake-executable=<CMAKE_EXECUTABLE> Set the CMake executable [default: cmake].
--cmake-options=<STRING> Define options to CMake [default: ''].
<builddir> Build directory.
-h --help Show this screen.
"""
def gen_cmake_command(options, arguments):
"""
Generate CMake command based on options and arguments.
"""
command = []
command.append('FC={0}'.format(arguments['--fc']))
command.append('%s' % arguments['--cmake-executable'])
command.append('-DEXTRA_FCFLAGS="{0}"'.format(arguments['--extra-fc-flags']))
command.append('-DENABLE_FC_SUPPORT="{0}"'.format(arguments['--fc-support']))
command.append('-DENABLE_64BIT_INTEGERS=%s' % arguments['--int64'])
command.append('-DENABLE_CODE_COVERAGE=%s' % arguments['--coverage'])
command.append('-DCMAKE_BUILD_TYPE=%s' % arguments['--type'])
command.append('-G "%s"' % arguments['--generator'])
if arguments['--cmake-options'] != "''":
command.append('%s' % arguments['--cmake-options'])
return ' '.join(command)
# parse command line args
try:
arguments = docopt.docopt(options, argv=None)
except docopt.DocoptExit:
sys.stderr.write('ERROR: bad input to %s\n' % sys.argv[0])
sys.stderr.write(options)
sys.exit(-1)
# use extensions to validate/post-process args
if config.module_exists('extensions'):
import extensions
arguments = extensions.postprocess_args(sys.argv, arguments)
root_directory = os.path.dirname(os.path.realpath(__file__))
build_path = arguments['<builddir>']
# create cmake command
cmake_command = '%s %s' % (gen_cmake_command(options, arguments), root_directory)
# run cmake
config.configure(root_directory, build_path, cmake_command, arguments['--show'])