skbuild.platform_specifics package

This package provides get_platform() allowing to get an instance of abstract.CMakePlatform matching the current platform.

class skbuild.platform_specifics.CMakeGenerator(name, env=None)[source]

Bases: object

Represents a CMake generator.

__init__(name, env=None)[source]

Instantiate a generator object with the given name.

By default, os.environ is associated with the generator. Dictionary passed as env parameter will be merged with os.environ. If an environment variable is set in both os.environ and env, the variable in env is used.

name

Name of CMake generator.

skbuild.platform_specifics.get_platform()[source]

Return an instance of abstract.CMakePlatform corresponding to the current platform.

Submodules

skbuild.platform_specifics.abstract module

This module defines objects useful to discover which CMake generator is supported on the current platform.

class skbuild.platform_specifics.abstract.CMakeGenerator(name, env=None)[source]

Bases: object

Represents a CMake generator.

__init__(name, env=None)[source]

Instantiate a generator object with the given name.

By default, os.environ is associated with the generator. Dictionary passed as env parameter will be merged with os.environ. If an environment variable is set in both os.environ and env, the variable in env is used.

name

Name of CMake generator.

class skbuild.platform_specifics.abstract.CMakePlatform[source]

Bases: object

This class encapsulates the logic allowing to get the identifier of a working CMake generator.

Derived class should at least set default_generators.

static cleanup_test()[source]

Delete test project directory.

static compile_test_cmakelist(*args, **kwds)[source]

Attempt to configure the test project with each CMakeGenerator from candidate_generators.

Only cmake arguments starting with -DCMAKE_ are used to configure the test project.

The function returns the first generator allowing to successfully configure the test project using cmake_exe_path.

default_generators

List of generators considered by get_best_generator().

generator_installation_help

Return message guiding the user for installing a valid toolchain.

get_best_generator(generator_name=None, skip_generator_test=False, languages=('CXX', 'C'), cleanup=True, cmake_executable='cmake', cmake_args=())[source]

Loop over generators to find one that works by configuring and compiling a test project.

Parameters:
  • generator_name (string or None) – If provided, uses only provided generator, instead of trying default_generators.
  • skip_generator_test (bool) – If set to True and if a generator name is specified, the generator test is skipped. If no generator_name is specified and the option is set to True, the first available generator is used.
  • languages (tuple) – The languages you’ll need for your project, in terms that CMake recognizes.
  • cleanup (bool) – If True, cleans up temporary folder used to test generators. Set to False for debugging to see CMake’s output files.
  • cmake_executable (string) – Path to CMake executable used to configure and build the test project used to evaluate if a generator is working.
  • cmake_args (tuple) – List of CMake arguments to use when configuring the test project. Only arguments starting with -DCMAKE_ are used.
Returns:

CMake Generator object

Return type:

CMakeGenerator or None

Raises:

skbuild.exceptions.SKBuildGeneratorNotFoundError

get_generator(generator_name)[source]

Loop over generators and return the first that matches the given name.

static write_test_cmakelist(languages)[source]

Write a minimal CMakeLists.txt useful to check if the requested languages are supported.

skbuild.platform_specifics.bsd module

This module defines object specific to BSD platform.

class skbuild.platform_specifics.bsd.BSDPlatform[source]

Bases: skbuild.platform_specifics.unix.UnixPlatform

BSD implementation of abstract.CMakePlatform.

skbuild.platform_specifics.linux module

This module defines object specific to Linux platform.

class skbuild.platform_specifics.linux.LinuxPlatform[source]

Bases: skbuild.platform_specifics.unix.UnixPlatform

Linux implementation of abstract.CMakePlatform

static build_essential_install_cmd()[source]

Return a tuple of the form (distribution_name, cmd).

cmd is the command allowing to install the build tools in the current Linux distribution. It set to an empty string if the command is not known.

distribution_name is the name of the current distribution. It is set to an empty string if the distribution could not be determined.

generator_installation_help

Return message guiding the user for installing a valid toolchain.

skbuild.platform_specifics.osx module

This module defines object specific to OSX platform.

class skbuild.platform_specifics.osx.OSXPlatform[source]

Bases: skbuild.platform_specifics.unix.UnixPlatform

OSX implementation of abstract.CMakePlatform.

generator_installation_help

Return message guiding the user for installing a valid toolchain.

skbuild.platform_specifics.platform_factory module

This modules implements the logic allowing to instantiate the expected abstract.CMakePlatform.

skbuild.platform_specifics.platform_factory.get_platform()[source]

Return an instance of abstract.CMakePlatform corresponding to the current platform.

skbuild.platform_specifics.unix module

This module defines object specific to Unix platform.

class skbuild.platform_specifics.unix.UnixPlatform[source]

Bases: skbuild.platform_specifics.abstract.CMakePlatform

Unix implementation of abstract.CMakePlatform.

skbuild.platform_specifics.windows module

This module defines object specific to Windows platform.

class skbuild.platform_specifics.windows.CMakeVisualStudioCommandLineGenerator(name, year)[source]

Bases: skbuild.platform_specifics.abstract.CMakeGenerator

Represents a command-line CMake generator initialized with a specific Visual Studio environment.

__init__(name, year)[source]

Instantiate CMake command-line generator.

The generator name can be values like Ninja, NMake Makefiles or NMake Makefiles JOM.

The year defines the Visual Studio environment associated with the generator. See VS_YEAR_TO_VERSION.

The platform (32-bit or 64-bit) is automatically selected based on the value of platform.architecture()[0].

class skbuild.platform_specifics.windows.CMakeVisualStudioIDEGenerator(year)[source]

Bases: skbuild.platform_specifics.abstract.CMakeGenerator

Represents a Visual Studio CMake generator.

__init__(year)[source]

Instantiate a generator object with its name set to the Visual Studio generator associated with the given year (see VS_YEAR_TO_VERSION) and the current platform (32-bit or 64-bit).

skbuild.platform_specifics.windows.VS_YEAR_TO_VERSION = {'2008': 9, '2010': 10, '2015': 14}

Describes the version of Visual Studio supported by CMakeVisualStudioIDEGenerator and CMakeVisualStudioCommandLineGenerator.

The different version are identified by their year.

class skbuild.platform_specifics.windows.WindowsPlatform[source]

Bases: skbuild.platform_specifics.abstract.CMakePlatform

Windows implementation of abstract.CMakePlatform.

generator_installation_help

Return message guiding the user for installing a valid toolchain.