Skip to content

Commit

Permalink
Fix CMake build on Windows with setuptools. (#5280)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivialfis authored Feb 5, 2020
1 parent 595a004 commit 84e395d
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python-package/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,22 +95,23 @@ class BuildExt(build_ext.build_ext):
def build(self, src_dir, build_dir, generator, build_tool=None, use_omp=1):
'''Build the core library with CMake.'''
cmake_cmd = ['cmake', src_dir, generator]

for k, v in USER_OPTIONS.items():
arg = k.replace('-', '_').upper()
value = str(v[2])
cmake_cmd.append('-D' + arg + '=' + value)
if k == 'USE_OPENMP' and use_omp == 0:
continue

if system() == 'Windows':
cmake_cmd.append('--build')

subprocess.check_call(cmake_cmd, cwd=build_dir)

if system() != 'Windows':
nproc = os.cpu_count()
subprocess.check_call([build_tool, '-j' + str(nproc)],
cwd=build_dir)
else:
subprocess.check_call(['cmake', '--build', '.',
'--config', 'Release'], cwd=build_dir)

def build_cmake_extension(self):
'''Configure and build using CMake'''
Expand Down

0 comments on commit 84e395d

Please sign in to comment.