Skip to content

Commit 2e91988

Browse files
committed
scripts: Enable passing extra CMake options to the Windows build
1 parent a92f77a commit 2e91988

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

scripts/windows_build_wheels.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ def build_wrapped_itk(
106106

107107

108108
def build_wheel(python_version, single_wheel=False,
109-
cleanup=False, wheel_names=None):
109+
cleanup=False, wheel_names=None,
110+
cmake_options=[]):
110111

111112
python_executable, \
112113
python_include_dir, \
@@ -152,7 +153,7 @@ def build_wheel(python_version, single_wheel=False,
152153
"-DPYTHON_INCLUDE_DIR:PATH=%s" % python_include_dir,
153154
"-DPYTHON_LIBRARY:FILEPATH=%s" % python_library,
154155
"-DDOXYGEN_EXECUTABLE:FILEPATH=C:/P/doxygen/doxygen.exe",
155-
])
156+
] + cmake_options)
156157
# Cleanup
157158
check_call([python_executable, "setup.py", "clean"])
158159

@@ -192,7 +193,7 @@ def build_wheel(python_version, single_wheel=False,
192193
"-DPYTHON_EXECUTABLE:FILEPATH=%s" % python_executable,
193194
"-DPYTHON_INCLUDE_DIR:PATH=%s" % python_include_dir,
194195
"-DPYTHON_LIBRARY:FILEPATH=%s" % python_library
195-
])
196+
] + cmake_options)
196197

197198
# Cleanup
198199
if cleanup:
@@ -226,7 +227,7 @@ def test_wheels(single_wheel=False):
226227

227228

228229
def build_wheels(py_envs=DEFAULT_PY_ENVS, single_wheel=False,
229-
cleanup=False, wheel_names=None):
230+
cleanup=False, wheel_names=None, cmake_options=[]):
230231

231232
for py_env in py_envs:
232233
prepare_build_env(py_env)
@@ -252,7 +253,8 @@ def build_wheels(py_envs=DEFAULT_PY_ENVS, single_wheel=False,
252253
# Compile wheels re-using standalone project and archive cache
253254
for py_env in py_envs:
254255
build_wheel(py_env, single_wheel=single_wheel,
255-
cleanup=cleanup, wheel_names=wheel_names)
256+
cleanup=cleanup, wheel_names=wheel_names,
257+
cmake_options=cmake_options)
256258

257259

258260
def main(wheel_names=None):
@@ -261,10 +263,12 @@ def main(wheel_names=None):
261263
parser.add_argument('--py-envs', nargs='+', default=DEFAULT_PY_ENVS,
262264
help='Target Python environment versions, e.g. "37-x64".')
263265
parser.add_argument('--no-cleanup', dest='cleanup', action='store_false', help='Do not clean up temporary build files.')
266+
parser.add_argument('cmake_options', nargs='*', help='Extra options to pass to CMake, e.g. -DBUILD_SHARED_LIBS:BOOL=OFF')
264267
args = parser.parse_args()
265268

266269
build_wheels(single_wheel=args.single_wheel, cleanup=args.cleanup,
267-
py_envs=args.py_envs, wheel_names=wheel_names)
270+
py_envs=args.py_envs, wheel_names=wheel_names,
271+
cmake_options=args.cmake_options)
268272
fixup_wheels()
269273
test_wheels(single_wheel=args.single_wheel)
270274

0 commit comments

Comments
 (0)