How to use the cmake.CMAKE_BIN_DIR function in cmake

To help you get started, we’ve selected a few cmake examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github slurps-mad-rips / brujeria / src / brujeria / importlib / loader.py View on Github external
def create_module (self, spec: ModuleSpec):
        # TODO: run build/generate CMakeLists.txt steps here
        # This is the file that gets included
        name = spec.name.split('.')[-1]
        init = spec.loader_state
        extension = Extension(name, init)
        cmake_prg = os.path.join(CMAKE_BIN_DIR, 'cmake')
        extension.configure()
        extension.build()
        shim = ModuleSpec(spec.name, loader=self, origin=extension.output)
        return super().create_module(shim)
github slurps-mad-rips / brujeria / src / brujeria / tool.py View on Github external
from subprocess import run
from distutils import sysconfig
from functools import partial
from pathlib import Path
import os

from cmake import CMAKE_BIN_DIR
import importlib_resources

from .app import CACHE_HOME

CMAKE_PRG = os.path.join(CMAKE_BIN_DIR, "cmake")
SUFFIX = sysconfig.get_config_var("EXT_SUFFIX")


def argument(options, var, value):
    if value is None or not value:
        return
    options.append("-D{}={}".format(var, value))


# TODO: This needs to eventually wrap the curandera library
# Right now we just hope the user hasn't changed the output name of the module
# With the curandera library we can just get the metadata back from the
# configure command.
class CMake:
    def __init__(self, spec, state):
        name = spec.name.split(".")
github openai / retro / setup.py View on Github external
pylib_dir = ''
        if not self.inplace:
            pylib_dir = '-DPYLIB_DIRECTORY:PATH=%s' % self.build_lib
        if self.debug:
            build_type = '-DCMAKE_BUILD_TYPE=Debug'
        else:
            build_type = ''
        python_executable = '-DPYTHON_EXECUTABLE:STRING=%s' % sys.executable
        cmake_exe = find_executable('cmake')
        if not cmake_exe:
            try:
                import cmake
            except ImportError:
                subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'cmake'])
                import cmake
            cmake_exe = os.path.join(cmake.CMAKE_BIN_DIR, 'cmake')
        subprocess.check_call([cmake_exe, '.', '-G', 'Unix Makefiles', build_type, pyext_suffix, pylib_dir, python_executable])
        if self.parallel:
            jobs = '-j%d' % self.parallel
        else:
            import multiprocessing
            jobs = '-j%d' % multiprocessing.cpu_count()
        make_exe = find_executable('make')
        if not make_exe:
            raise RuntimeError('Could not find Make executable. Is it installed?')
        subprocess.check_call([make_exe, jobs, 'retro'])
github scikit-build / scikit-build / skbuild / setuptools_wrap.py View on Github external
)

    # Install cmake if listed in `setup_requires`
    for package in kw.get('setup_requires', []):
        if Requirement(package).name == 'cmake':
            setup_requires = [package]
            dist = upstream_Distribution({'setup_requires': setup_requires})
            dist.fetch_build_eggs(setup_requires)

            # Considering packages associated with "setup_requires" keyword are
            # installed in .eggs subdirectory without honoring setuptools "console_scripts"
            # entry_points and without settings the expected executable permissions, we are
            # taking care of it below.
            import cmake
            for executable in ['cmake', 'cpack', 'ctest']:
                executable = os.path.join(cmake.CMAKE_BIN_DIR, executable)
                if platform.system().lower() == 'windows':
                    executable += '.exe'
                st = os.stat(executable)
                permissions = (
                        st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
                )
                os.chmod(executable, permissions)
            cmake_executable = os.path.join(cmake.CMAKE_BIN_DIR, 'cmake')
            break

    # Languages are used to determine a working generator
    cmake_languages = skbuild_kw['cmake_languages']

    try:
        if cmake_executable is None:
            cmake_executable = CMAKE_DEFAULT_EXECUTABLE
github slurps-mad-rips / brujeria / src / brujeria / cmake / extension.py View on Github external
# cache(<var>  ) -- set cache variable
# info -- message(STATUS)
# warn -- message(WARNING)
# error -- message(FATAL_ERROR)
#
# Additional functions may be added at a later time.
import os
from ..core.config import config
from ..core.xdg import CACHE_HOME
from functools import partial
from pkg_resources import resource_filename
from distutils import sysconfig
from subprocess import run
from cmake import CMAKE_BIN_DIR

CMAKE_PRG = os.path.join(CMAKE_BIN_DIR, 'cmake')

def argument (opts, var, value):
    if var is None: return
    opts.append(f'-D{var}={value}')

class Extension:
    def __init__ (self, name, init):
        self.name = name
        self.path = init.parent
        self.languages = ['C', 'CXX']
        self.prelude = None
        self.version = None
        self.description = None
        self.dst = CACHE_HOME / 'brujeria' / self.name
        cmake_src = '-H{}'.format(resource_filename('brujeria', 'data'))
        cmake_dst = '-B{}'.format(self.dst)</var>
github scikit-build / scikit-build / skbuild / setuptools_wrap.py View on Github external
# Considering packages associated with "setup_requires" keyword are
            # installed in .eggs subdirectory without honoring setuptools "console_scripts"
            # entry_points and without settings the expected executable permissions, we are
            # taking care of it below.
            import cmake
            for executable in ['cmake', 'cpack', 'ctest']:
                executable = os.path.join(cmake.CMAKE_BIN_DIR, executable)
                if platform.system().lower() == 'windows':
                    executable += '.exe'
                st = os.stat(executable)
                permissions = (
                        st.st_mode | stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
                )
                os.chmod(executable, permissions)
            cmake_executable = os.path.join(cmake.CMAKE_BIN_DIR, 'cmake')
            break

    # Languages are used to determine a working generator
    cmake_languages = skbuild_kw['cmake_languages']

    try:
        if cmake_executable is None:
            cmake_executable = CMAKE_DEFAULT_EXECUTABLE
        cmkr = cmaker.CMaker(cmake_executable)
        if not skip_cmake:
            cmake_minimum_required_version = skbuild_kw['cmake_minimum_required_version']
            if cmake_minimum_required_version is not None:
                if parse_version(cmkr.cmake_version) &lt; parse_version(cmake_minimum_required_version):
                    raise SKBuildError(
                        "CMake version %s or higher is required. CMake version %s is being used" % (
                            cmake_minimum_required_version, cmkr.cmake_version))