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, toolset=None)[source]¶ Bases:
object
Represents a CMake generator.
-
__init__
(name, env=None, toolset=None)[source]¶ Instantiate a generator object with the given
name
.By default,
os.environ
is associated with the generator. Dictionary passed asenv
parameter will be merged withos.environ
. If an environment variable is set in bothos.environ
andenv
, the variable inenv
is used.Some CMake generators support a
toolset
specification to tell the native build system how to choose a compiler.
-
property
description
¶ Name of CMake generator with properties describing the environment (e.g toolset)
-
property
name
¶ Name of CMake generator.
-
property
toolset
¶ Toolset specification associated with the 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, toolset=None)[source]¶ Bases:
object
Represents a CMake generator.
-
__init__
(name, env=None, toolset=None)[source]¶ Instantiate a generator object with the given
name
.By default,
os.environ
is associated with the generator. Dictionary passed asenv
parameter will be merged withos.environ
. If an environment variable is set in bothos.environ
andenv
, the variable inenv
is used.Some CMake generators support a
toolset
specification to tell the native build system how to choose a compiler.
-
property
description
¶ Name of CMake generator with properties describing the environment (e.g toolset)
-
property
name
¶ Name of CMake generator.
-
property
toolset
¶ Toolset specification associated with the 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
compile_test_cmakelist
(*args, **kwds)[source]¶ Attempt to configure the test project with each
CMakeGenerator
fromcandidate_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
.
-
property
default_generators
¶ List of generators considered by
get_best_generator()
.
-
property
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
-
static
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.
-
property
generator_installation_help
¶ Return message guiding the user for installing a valid toolchain.
-
static
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
.-
property
generator_installation_help
¶ Return message guiding the user for installing a valid toolchain.
-
property
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, toolset=None)[source]¶ Bases:
skbuild.platform_specifics.abstract.CMakeGenerator
Represents a command-line CMake generator initialized with a specific Visual Studio environment.
-
__init__
(name, year, toolset=None)[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. SeeVS_YEAR_TO_VERSION
.If set, the
toolset
defines the Visual Studio Toolset to select.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, toolset=None)[source]¶ Bases:
skbuild.platform_specifics.abstract.CMakeGenerator
Represents a Visual Studio CMake generator.
-
__init__
(year, toolset=None)[source]¶ Instantiate a generator object with its name set to the Visual Studio generator associated with the given
year
(seeVS_YEAR_TO_VERSION
), the current platform (32-bit or 64-bit) and the selectedtoolset
(if applicable).
-
-
skbuild.platform_specifics.windows.
VS_YEAR_TO_VERSION
= {'2008': 9, '2010': 10, '2012': 11, '2013': 12, '2015': 14, '2017': 15}¶ Describes the version of Visual Studio supported by
CMakeVisualStudioIDEGenerator
andCMakeVisualStudioCommandLineGenerator
.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
.-
property
generator_installation_help
¶ Return message guiding the user for installing a valid toolchain.
-
property
-
skbuild.platform_specifics.windows.
find_visual_studio
(vs_version)[source]¶ Return Visual Studio installation path associated with
vs_version
or an empty string if any.The
vs_version
corresponds to the Visual Studio version to lookup. SeeVS_YEAR_TO_VERSION
.Note
For VS 2017 and newer, returns path based on the result of invoking
vswhere.exe
.For VS 2010 to VS 2015, returns path by looking up all key/value pairs associated with the
Software\Microsoft\VisualStudio\SxS\VC7
registry key. Each key/value pair is the visual studio version (e.g 14.0) and the installation path (e.g C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/).