I need to build a Python Extension for an OS that requires compilation with Xcode (cross compile, build on MacOS).
cmake-build-extension hard-codes the use of Ninja.
No issue having Ninja installed but it can't be used to build the project.
w/o the patch, cmake is called with 2 -G flags, one for Ninja and one for XCode.
I suggest the patch below. Check if the user (in setup.py) has asked for build system.
File modified is build_extension.py, line 149.
Maybe it can be improved because it behaves differently if Ninja is explicitly requested.
ext_dir = Path(self.get_ext_fullpath(ext.name)).parent.absolute()
cmake_install_prefix = ext_dir / ext.install_prefix
##### patch start here
# CMake configure arguments
configure_args = [
f"-DCMAKE_BUILD_TYPE={ext.cmake_build_type}",
f"-DCMAKE_INSTALL_PREFIX:PATH={cmake_install_prefix}",
]
# check the user has opted-in for a build system
build_system_specified = bool([option for option in ext.cmake_configure_options if option.startswith('**-DCMAKE_GENERATOR=**')])
# Default to Ninja if the user didn't explicitly request a build system
if not build_system_specified:
configure_args += [
"-GNinja",
# Fix #26: https://github.com/diegoferigo/cmake-build-extension/issues/26
f"-DCMAKE_MAKE_PROGRAM={shutil.which('ninja')}",
]
I need to build a Python Extension for an OS that requires compilation with Xcode (cross compile, build on MacOS).
cmake-build-extension hard-codes the use of Ninja.
No issue having Ninja installed but it can't be used to build the project.
w/o the patch, cmake is called with 2 -G flags, one for Ninja and one for XCode.
I suggest the patch below. Check if the user (in setup.py) has asked for build system.
File modified is build_extension.py, line 149.
Maybe it can be improved because it behaves differently if Ninja is explicitly requested.