Skip to content

Commit f2c320a

Browse files
committed
Allow setting OpenMP flags using env var
1 parent 6dabb04 commit f2c320a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@
2929
BUILD_DOCS = os.getenv('BUILD_DOCS', '0') == '1'
3030

3131

32+
def get_openmp_flag():
33+
default_flag = '-fopenmp' if sys.platform != 'win32' else '/openmp'
34+
return os.getenv("OPENMP_FLAG", default_flag)
35+
36+
3237
def get_extensions():
3338
extensions = []
3439

@@ -52,11 +57,8 @@ def get_extensions():
5257
info = parallel_info()
5358
if ('backend: OpenMP' in info and 'OpenMP not found' not in info
5459
and sys.platform != 'darwin'):
55-
extra_compile_args['cxx'] += ['-DAT_PARALLEL_OPENMP']
56-
if sys.platform == 'win32':
57-
extra_compile_args['cxx'] += ['/openmp']
58-
else:
59-
extra_compile_args['cxx'] += ['-fopenmp']
60+
extra_compile_args['cxx'] += ['-DAT_PARALLEL_OPENMP',
61+
get_openmp_flag()]
6062
else:
6163
print('Compiling without OpenMP...')
6264

0 commit comments

Comments
 (0)