How to use cmake - 10 common examples

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 scikit-build / scikit-build / tests / test_setup.py View on Github external
project(test NONE)
        install(CODE "execute_process(
          COMMAND \\${CMAKE_COMMAND} -E sleep 0)")
        """
    ))

    with execute_setup_py(tmp_dir, ['build'], disable_languages_test=True):
        assert mock_setup.call_count == 1
        setup_kw = mock_setup.call_args[1]
        assert setup_kw['setup_requires'] == setup_requires

        import cmake

        out, _ = capsys.readouterr()
        if "Searching for cmake>=3.10" in out:
            assert cmake.__file__.lower().startswith(str(tmp_dir).lower())
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 nnrg / opennero / cmake / bundle.py View on Github external
def bundle(self, target = None):
        """ make sure that everything target links to is in the bundle """
        if target == None:
            self.bundle(self.exepath)
            return
        lib_file = os.popen('otool -LX ' + target)
        assert(lib_file)
        for l in lib_file:
            id = l.strip().split()[0] # get the link id of the library
            for prefix in Bundler.LOCALS:
                if id.startswith(prefix):
                    self.addlib(id, target)
        lib_file.close()
github gromacs / gromacs / python_packaging / src / setup.py View on Github external
if gmxapi_DIR != os.path.commonpath([gmxapi_DIR, gmx_toolchain]):
    raise GmxapiInstallError('GROMACS toolchain file {} is not in gmxapi_DIR {}'.format(
        gmx_toolchain,
        gmxapi_DIR
    ))

cmake_platform_hints = ['-DCMAKE_TOOLCHAIN_FILE={}'.format(gmx_toolchain)]

# TODO: Use package-specific hinting variable.
# We want to be sure that we find a -config.cmake associated with the
# toolchains file, but we want to preempt most of the normal CMake
# [search procedure](https://cmake.org/cmake/help/latest/command/find_package.html#id5),
# which could lead to hard-to-diagnose build problems.
# Note that _ROOT is not standard until CMake 3.12
# Reference https://cmake.org/cmake/help/latest/policy/CMP0074.html#policy:CMP0074
_cmake_major, _cmake_minor = cmake.__version__.split('.')[0:2]
if int(_cmake_major) >= 3 and int(_cmake_minor) >= 12:
    cmake_gmxapi_hint = '-Dgmxapi_ROOT={}'
else:
    cmake_gmxapi_hint = '-DCMAKE_PREFIX_PATH={}'
cmake_gmxapi_hint = cmake_gmxapi_hint.format(gmxapi_DIR)

cmake_args = list(cmake_platform_hints)
cmake_args.append(cmake_gmxapi_hint)

setup(
    name='gmxapi',

    # TODO: (pending infrastructure and further discussion) Replace with CMake variables from GMXAPI version.
    version='0.1.0b2',
    python_requires='>=3.5, <3.9',
    setup_requires=['cmake>=3.9.6',
github freeorion / freeorion / cmake / make_versioncpp.py View on Github external
print "ERROR: invalid parameters."
    print "make_versioncpp.py  "
    quit()

os.chdir(sys.argv[1])
build_sys = sys.argv[2]

# A list of tuples containing generators
generators = [
    Generator('util/Version.cpp.in', 'util/Version.cpp')
]
if system() == 'Windows':
    generators.append(NsisInstScriptGenerator('Installer/FreeOrion_Install_Script.nsi.in',
                                              'Installer/FreeOrion_Install_Script.nsi'))
if system() == 'Darwin':
    generators.append(Generator('Xcode/Info.plist.in', 'Xcode/Info.plist'))

version = "0.4.9+"
branch = ""
build_no = INVALID_BUILD_NO

try:
    branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
    if (branch == "master") or (branch[:7] == "release"):
        branch = ""
    else:
        branch += " "
    commit = check_output(["git", "show", "-s", "--format=%h", "--abbrev=7", "HEAD"]).strip()
    timestamp = float(check_output(["git", "show", "-s", "--format=%ct", "HEAD"]).strip())
    build_no = ".".join([datetime.utcfromtimestamp(timestamp).strftime("%Y-%m-%d"), commit])
except:
    print "WARNING: git not installed or not setup correctly"
github freeorion / freeorion / cmake / make_versioncpp.py View on Github external
FreeOrion_BUILDSYS=build_sys,
                FreeOrion_DLL_LIST_INSTALL="",
                FreeOrion_DLL_LIST_UNINSTALL="")


if 3 != len(sys.argv):
    print "ERROR: invalid parameters."
    print "make_versioncpp.py  "
    quit()

os.chdir(sys.argv[1])
build_sys = sys.argv[2]

# A list of tuples containing generators
generators = [
    Generator('util/Version.cpp.in', 'util/Version.cpp')
]
if system() == 'Windows':
    generators.append(NsisInstScriptGenerator('Installer/FreeOrion_Install_Script.nsi.in',
                                              'Installer/FreeOrion_Install_Script.nsi'))
if system() == 'Darwin':
    generators.append(Generator('Xcode/Info.plist.in', 'Xcode/Info.plist'))

version = "0.4.9+"
branch = ""
build_no = INVALID_BUILD_NO

try:
    branch = check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']).strip()
    if (branch == "master") or (branch[:7] == "release"):
        branch = ""
    else:
github tpaviot / pythonocc-core / cmake / __init__.py View on Github external
major, minor, patch_dev = spl
        if '-' in patch_dev:
            patch = patch_dev.split('-')[0]
        else:
            patch = patch_dev
    elif len(spl) == 2:
        major, minor = spl
        patch = 0

    if ((int(major) > PYTHONOCC_VERSION_MAJOR) or
       (int(major) == PYTHONOCC_VERSION_MAJOR and int(minor) > PYTHONOCC_VERSION_MINOR) or
       (int(major) == PYTHONOCC_VERSION_MAJOR and int(minor) == PYTHONOCC_VERSION_MINOR and
        int(patch) >= PYTHONOCC_VERSION_PATCH)):
        return True
    else:
        raise pythonoccVersionNumberError("Require pythonocc-%s but current is pythonocc-%s" % (required_version, VERSION))
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
class PrettyElementTree(ElementTree.ElementTree):
    def __str__(self):
        x = deepcopy(self)
        indent(x.getroot())
        out = StringIO()
        x.write(out, encoding='utf-8', xml_declaration=True)
        return out.getvalue()

def xml_document(t):
    e = t.element if isinstance(t,tag) else t
    return PrettyElementTree(e)

if __name__ == '__main__':
    
    _ = tag
    print _.CarrierCode

    print _.RequestHeader[
                _.AccountNumber[ 33 ]
              , (_.MeterNumber[ 44 ]
              , _.CarrierCode[ 'FDXG' ])
            ]
    
    print xml_document(
            _.RequestHeader[
                _.AccountNumber[ 33 ]
              , _.MeterNumber[ 44 ]
              , _.CarrierCode[ 'FDXG' ]
            ])

    print xml_document(_('checkout-shopping-cart', xmlns="http://checkout.google.com/schema/2"))
github ryppl / ryppl / cmake / scripts / dom.py View on Github external
def xml_document(t):
    e = t.element if isinstance(t,tag) else t
    return PrettyElementTree(e)