Skip to content

Commit 02d4a0f

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

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

setup.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@
2828

2929
BUILD_DOCS = os.getenv('BUILD_DOCS', '0') == '1'
3030

31+
def get_openmp_flag():
32+
if os.getenv("OPENMP_FLAG") is not None:
33+
return os.getenv("OPENMP_FLAG")
34+
if sys.platform == 'win32':
35+
return ['/openmp']
36+
else:
37+
return ['-fopenmp']
38+
3139

3240
def get_extensions():
3341
extensions = []
@@ -52,11 +60,7 @@ def get_extensions():
5260
info = parallel_info()
5361
if ('backend: OpenMP' in info and 'OpenMP not found' not in info
5462
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']
63+
extra_compile_args['cxx'] += ['-DAT_PARALLEL_OPENMP', get_openmp_flag()]
6064
else:
6165
print('Compiling without OpenMP...')
6266

0 commit comments

Comments
 (0)