Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building w/o Ninja for cross-compile targets #52

Open
ericgur opened this issue Jun 18, 2024 · 0 comments
Open

Support building w/o Ninja for cross-compile targets #52

ericgur opened this issue Jun 18, 2024 · 0 comments

Comments

@ericgur
Copy link

ericgur commented Jun 18, 2024

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')}",
        ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant