Triplet variables
This article describes the kmpkg variables that are available to triplet files. A triplet file can also include user defined variables.
See the triplets concept documentation for a high-level view of triplet capabilities.
Variables
KMPKG_TARGET_ARCHITECTURE
Specifies the target machine architecture.
Valid options include x86, x64, arm, arm64, arm64ec, s390x, ppc64le, riscv32, riscv64, loongarch32, loongarch64, mips64, and wasm32.
KMPKG_CRT_LINKAGE
Specifies the desired CRT linkage (for MSVC).
Valid options are dynamic and static.
KMPKG_LIBRARY_LINKAGE
Specifies the preferred library linkage.
Valid options are dynamic and static. Libraries can ignore this setting if
they do not support the preferred linkage type.
KMPKG_BUILD_TYPE
You can set this value to release to build release-only versions of the ports.
By default this value is empty. When this value is empty kmpkg builds release
and debug configurations of ports.
KMPKG_CMAKE_SYSTEM_NAME
Specifies the target platform.
Valid options include any CMake system name, such as:
- Empty (Windows Desktop for legacy reasons)
WindowsStore(Universal Windows Platform)MinGW(Minimalist GNU for Windows)Darwin(Mac OSX)iOS(iOS)Linux(Linux)Emscripten(WebAssembly)
KMPKG_CMAKE_SYSTEM_VERSION
Specifies the target platform system version.
This field is optional and, if present, will be passed into the build as
CMAKE_SYSTEM_VERSION.
See also the CMake documentation for
CMAKE_SYSTEM_VERSION
KMPKG_CHAINLOAD_TOOLCHAIN_FILE
Specifies an alternate CMake toolchain file to use.
This (if set) will override all other compiler detection logic. By default, a
toolchain file is selected from scripts/toolchains/ appropriate to the
platform.
To create a custom toolchain file, it's best to start by including an existing toolchain from
${KMPKG_ROOT}/scripts/toolchainsand extend it. This ensures that essential variables set by the kmpkg executable, such asKMPKG_TARGET_ARCHITECTURE,KMPKG_CXX_FLAGS,KMPKG_LINKER_FLAGS, and other variables are forwarded to CMake.
See also the CMake documentation for toolchain files.
KMPKG_CXX_FLAGS
Sets additional compiler flags to be used when not using
KMPKG_CHAINLOAD_TOOLCHAIN_FILE.
This option also has forms for configuration-specific flags and C language flags:
KMPKG_CXX_FLAGSKMPKG_CXX_FLAGS_DEBUGKMPKG_CXX_FLAGS_RELEASEKMPKG_C_FLAGSKMPKG_C_FLAGS_DEBUGKMPKG_C_FLAGS_RELEASE
If you set KMPKG_CXX_FLAGS, you also have to set KMPKG_C_FLAGS, and vice-versa.
The same is true for the configuration-specific flags. These variables accept a
space-delimited string of compiler flags:
set(KMPKG_CXX_FLAGS "/wd4996 -D_CRT_SECURE_NO_WARNINGS")
set(KMPKG_C_FLAGS "/wd4996 -D_CRT_SECURE_NO_WARNINGS")
KMPKG_LINKER_FLAGS
Sets additional linker flags to be used while building dynamic libraries and
executables in the absence of KMPKG_CHAINLOAD_TOOLCHAIN_FILE.
This option also has forms for configuration-specific flags:
KMPKG_LINKER_FLAGSKMPKG_LINKER_FLAGS_DEBUGKMPKG_LINKER_FLAGS_RELEASE
KMPKG_MESON_CONFIGURE_OPTIONS
Set additional Meson configure options that are appended to the configure
command (in
kmpkg_configure_meson).
This field is optional.
Also available as build-type specific KMPKG_MESON_CONFIGURE_OPTIONS_DEBUG and
KMPKG_MESON_CONFIGURE_OPTIONS_RELEASE variables.
KMPKG_MESON_NATIVE_FILE_RELEASE
Provide an additional configuration dependent file as a meson cross/native file. Can be used to override settings provided by kmpkg since it will be passed after kmpkg's generated cross/native files are passed.
Especially useful to provide your own build_machine and host_machine entries.
KMPKG_MESON_NATIVE_FILE_DEBUG
See KMPKG_MESON_NATIVE_FILE_RELEASE.
KMPKG_MESON_CROSS_FILE_RELEASE
See KMPKG_MESON_NATIVE_FILE_RELEASE.
KMPKG_MESON_CROSS_FILE_DEBUG
See KMPKG_MESON_NATIVE_FILE_RELEASE.
KMPKG_CMAKE_CONFIGURE_OPTIONS
Sets additional CMake configure options that are appended to the configure
command (in
kmpkg_cmake_configure).
This field is optional.
Also available as build-type specific KMPKG_CMAKE_CONFIGURE_OPTIONS_DEBUG and
KMPKG_CMAKE_CONFIGURE_OPTIONS_RELEASE variables.
KMPKG_CONFIGURE_MAKE_OPTIONS
Set additional automake/autoconf configure options that are appended to the
configure command (in
kmpkg_configure_make).
This field is optional.
For example, to skip certain libtool checks that may errantly fail:
set(KMPKG_CONFIGURE_MAKE_OPTIONS "lt_cv_deplibs_check_method=pass_all")
Also available as build-type specific KMPKG_CONFIGURE_MAKE_OPTIONS_DEBUG and
KMPKG_CONFIGURE_MAKE_OPTIONS_RELEASE variables.
KMPKG_HASH_ADDITIONAL_FILES
A list of files to include in the calculation of package ABI hashes.
This field is optional.
Declare any files that affect the contents of a package and should be factored into the calculation of the ABI hash. For example:
- Files that are included (via
include(filepath)) in custom triplets and toolchains. - Files that are defined in
KMPKG_MESON_(NATIVE|CROSS)_FILE_<CONFIG>
Only the contents and order of the files are considered, the paths of the files do not affect the ABI hash.
set(KMPKG_HASH_ADDITIONAL_FILES
"${CMAKE_CURRENT_LIST_DIR}/file1.cmake"
"${CMAKE_CURRENT_LIST_DIR}/meson-cross.txt"
)
KMPKG_POST_PORTFILE_INCLUDES
A list of CMake files to include after the execution of portfile.cmake.
This field is optional.
The contents and order of the files are used for the ABI hash, the paths of the files do not affect the ABI hash.
set(KMPKG_POST_PORTFILE_INCLUDES
"${CMAKE_CURRENT_LIST_DIR}/file1.cmake"
"${CMAKE_CURRENT_LIST_DIR}/file2.cmake"
)
KMPKG_DEP_INFO_OVERRIDE_VARS
This section covers an experimental feature of kmpkg which may change or be removed at any time.
Replaces the default computed list of triplet "Supports" terms.
This option (if set) will override the default set of terms used for Platform Expression evaluation.
See the "supports" manifest file field
documentation for more details.
This list is extracted via the
kmpkg_get_dep_infohelper function.
KMPKG_DISABLE_COMPILER_TRACKING
Enabling this option is not recommended since it can lead to ABI incompatibility in restored binary packages. See the binary caching documentation to learn more
When this option is set to TRUE, ON, or 1, the compiler will not be
tracked as part of the package abis.
This will cause binary caching to reuse builds from older or newer compilers.
Windows-specific Variables
KMPKG_ENV_PASSTHROUGH
Instructs kmpkg to allow additional environment variables into the build process.
On Windows, kmpkg builds packages in a special clean environment that is
isolated from the current command prompt to ensure build reliability and
consistency. This triplet option can be set to a list of additional environment
variables that will be added to the clean environment. The values of these
environment variables will be hashed into the package abi -- to pass through
environment variables without abi tracking, see
KMPKG_ENV_PASSTHROUGH_UNTRACKED.
See also the kmpkg env command for how you can inspect
the precise environment that will be used.
This list is extracted via the
kmpkg_get_tagshelper function.
KMPKG_ENV_PASSTHROUGH_UNTRACKED
Instructs kmpkg to allow additional environment variables into the build process without abi tracking.
KMPKG_VISUAL_STUDIO_PATH
Specifies the Visual Studio installation to use.
To select the precise combination of Visual Studio instance and toolset version, we walk through the following algorithm:
- Determine the setting for
KMPKG_VISUAL_STUDIO_PATHfrom the triplet, or the environment variableKMPKG_VISUAL_STUDIO_PATH, or consider it unset - Determine the setting for
KMPKG_PLATFORM_TOOLSETfrom the triplet or consider it unset - Gather a list of all pairs of Visual Studio instances with all toolsets
available in those instances
- This is ordered first by instance type (Stable, Prerelease, Legacy) and then by toolset version (v143, v142, v141, v140)
- Filter the list based on the settings for
KMPKG_VISUAL_STUDIO_PATHandKMPKG_PLATFORM_TOOLSET. - Select the best remaining option
The path should be absolute, formatted with backslashes, and have no trailing slash:
set(KMPKG_VISUAL_STUDIO_PATH "C:\\Program Files\\Microsoft Visual Studio\\2022\\Preview")
KMPKG_PLATFORM_TOOLSET
Specifies the Visual Studio-based C/C++ compiler toolchain to use.
See KMPKG_VISUAL_STUDIO_PATH for the full
selection algorithm.
Valid settings:
- The Visual Studio 2022 platform toolset is
v143. - The Visual Studio 2019 platform toolset is
v142. - The Visual Studio 2017 platform toolset is
v141. - The Visual Studio 2015 platform toolset is
v140.
KMPKG_PLATFORM_TOOLSET_VERSION
Specifies the detailed MSVC C/C++ compiler toolchain to use.
By default, KMPKG_PLATFORM_TOOLSET always chooses the latest installed minor
version of the selected toolset. If you need more granularity, you can use this
variable. You can specify either a partial or a full version number. Valid values are,
for example, 14.25 or 14.27.29110.
KMPKG_LOAD_VCVARS_ENV
Determines whether kmpkg will search for and use an instance of Visual Studio as part of the triplet environment.
By default, this is ON for Windows triplets that do not specify
KMPKG_CHAINLOAD_TOOLCHAIN_FILE. For
non-Windows triplets and triplets specifying KMPKG_CHAINLOAD_TOOLCHAIN_FILE,
this defaults to OFF.
Linux Variables
KMPKG_FIXUP_ELF_RPATH
When this option is set to (true|1|on), kmpkg will add $ORIGIN and
$ORIGIN/<path_relative_to_lib> to the RUNPATH header of executables and
shared libraries. This allows packages to be relocated on Linux.
MacOS Variables
KMPKG_INSTALL_NAME_DIR
Sets the install name used when building macOS dynamic libraries. Default value
is @rpath. See the CMake documentation for
CMAKE_INSTALL_NAME_DIR
for more information.
KMPKG_FIXUP_MACHO_RPATH
Ensures Mach-O binaries built by kmpkg are relocatable by using relative install names and run-paths.
When set to ON:
- Modifies absolute
LC_LC_ID_DYLIBfield to@rpath/<library>for shared library binaries; - Modifies absolute
LC_RPATHfields to relative@loader_path/<relative/path/to/library>for executable and shared library binaries.
This functionality is enabled by default when
KMPKG_TARGET_IS_OSXisTRUE. To disable, explicitly setKMPKG_FIXUP_MACHO_RPATHtoOFFin a triplet file.
For more information about dynamic libraries on macOS, refer to the following links:
- Dynamic Library Identification
- Dynamic Library Standard Setup for Apps
- Dynamic Library Full Path Alternative
- Embedding nonstandard code structures in a bundle
KMPKG_OSX_DEPLOYMENT_TARGET
Sets the minimum macOS version for compiled binaries. This also changes what versions of the macOS platform SDK CMake will search for. See the CMake documentation for CMAKE_OSX_DEPLOYMENT_TARGET for more information.
KMPKG_OSX_SYSROOT
Set the name or path of the macOS platform SDK that will be used by CMake. See the CMake documentation for CMAKE_OSX_SYSROOT for more information.
KMPKG_OSX_ARCHITECTURES
Set the macOS / iOS target architecture which will be used by CMake. See the CMake documentation for CMAKE_OSX_ARCHITECTURES for more information.
Per-port customization
The CMake variable PORT will be set when interpreting the triplet file. It can be
used to change settings (such as KMPKG_LIBRARY_LINKAGE) on a per-port basis.
Example:
set(KMPKG_LIBRARY_LINKAGE static)
if(PORT MATCHES "qt5-")
set(KMPKG_LIBRARY_LINKAGE dynamic)
endif()
This will build all the qt5-* ports as dynamic libraries, but every other port as a
static library.
For an example in a real project, see https://github.com/Intelight/kmpkg/blob/master/triplets/x86-windows-mixed.cmake.