cmake_host_system_information¶
Queries system information of the host system on which cmake runs. One or more can be provided to select the information to be queried. The list of queried values is stored in .
can be one of the following values:
Fully qualified domain name
Total virtual memory in MiB [ 1 ]
Available virtual memory in MiB [ 1 ]
Total physical memory in MiB [ 1 ]
Available physical memory in MiB [ 1 ]
One if processor is 64Bit
One if processor has floating point unit
One if processor supports MMX instructions
One if processor supports Ext. MMX instructions
One if processor supports SSE instructions
One if processor supports SSE2 instructions
One if processor supports SSE FP instructions
One if processor supports SSE MMX instructions
One if processor supports 3DNow instructions
One if processor supports 3DNow+ instructions
One if IA64 processor emulating x86
One if processor has serial number
Human readable processor name
Human readable full processor description
The OS sub-type e.g. on Windows Professional
Read /etc/os-release file and define the given into a list of read variables
Get the variable (see man 5 os-release) if it exists in the /etc/os-release file
cmake_host_system_information(RESULT PRETTY_NAME QUERY DISTRIB_PRETTY_NAME) message(STATUS "$") cmake_host_system_information(RESULT DISTRO QUERY DISTRIB_INFO) foreach(VAR IN LISTS DISTRO) message(STATUS "$=`$<$>`") endforeach()
-- Ubuntu 20.04.2 LTS -- DISTRO_BUG_REPORT_URL=`https://bugs.launchpad.net/ubuntu/` -- DISTRO_HOME_URL=`https://www.ubuntu.com/` -- DISTRO_ID=`ubuntu` -- DISTRO_ID_LIKE=`debian` -- DISTRO_NAME=`Ubuntu` -- DISTRO_PRETTY_NAME=`Ubuntu 20.04.2 LTS` -- DISTRO_PRIVACY_POLICY_URL=`https://www.ubuntu.com/legal/terms-and-policies/privacy-policy` -- DISTRO_SUPPORT_URL=`https://help.ubuntu.com/` -- DISTRO_UBUNTU_CODENAME=`focal` -- DISTRO_VERSION=`20.04.2 LTS (Focal Fossa)` -- DISTRO_VERSION_CODENAME=`focal` -- DISTRO_VERSION_ID=`20.04`
If /etc/os-release file is not found, the command tries to gather OS identification via fallback scripts. The fallback script can use various distribution-specific files to collect OS identification data and map it into man 5 os-release variables.
Fallback Interface Variables¶
In addition to the scripts shipped with CMake, a user may append full paths to his script(s) to the this list. The script filename has the following format: NNN-.cmake , where NNN is three digits used to apply collected scripts in a specific order.
Variables collected by the user provided fallback script ought to be assigned to CMake variables using this naming convention. Example, the ID variable from the manual becomes CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID .
The fallback script ought to store names of all assigned CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ variables in this list.
# Try to detect some old distribution # See also # - http://linuxmafia.com/faq/Admin/release-files.html # if(NOT EXISTS "$/etc/foobar-release") return() endif() # Get the first string only file( STRINGS "$/etc/foobar-release" CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT LIMIT_COUNT 1 ) # # Example: # # Foobar distribution release 1.2.3 (server) # if(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT MATCHES "Foobar distribution release ([0-9\.]+) .*") set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME Foobar) set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME "$") set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID foobar) set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION $CMAKE_MATCH_1>) set(CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID $CMAKE_MATCH_1>) list( APPEND CMAKE_GET_OS_RELEASE_FALLBACK_RESULT CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_NAME CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_PRETTY_NAME CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_ID CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION CMAKE_GET_OS_RELEASE_FALLBACK_RESULT_VERSION_ID ) endif() unset(CMAKE_GET_OS_RELEASE_FALLBACK_CONTENT)
One MiB (mebibyte) is equal to 1024×1024 bytes.
Query Windows registry¶
cmake_host_system_information(RESULT QUERY WINDOWS_REGISTRY [VALUE_NAMES|SUBKEYS|VALUE ] [VIEW (64|32|64_32|32_64|HOST|TARGET|BOTH)] [SEPARATOR ] [ERROR_VARIABLE ])
Performs query operations on local computer registry subkey. Returns a list of subkeys or value names that are located under the specified subkey in the registry or the data of the specified value name. The result of the queried entity is stored in .
Querying registry for any other platforms than Windows , including CYGWIN , will always returns an empty string and sets an error message in the variable specified with sub-option ERROR_VARIABLE .
specify the full path of a subkey on the local computer. The must include a valid root key. Valid root keys for the local computer are:
- HKLM or HKEY_LOCAL_MACHINE
- HKCU or HKEY_CURRENT_USER
- HKCR or HKEY_CLASSES_ROOT
- HKU or HKEY_USERS
- HKCC or HKEY_CURRENT_CONFIG
And, optionally, the path to a subkey under the specified root key. The path separator can be the slash or the backslash. is not case sensitive. For example:
cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKLM") cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Kitware") cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKCU\\SOFTWARE\\Kitware")
Request the list of value names defined under . If a default value is defined, it will be identified with the special name (default) .
Request the list of subkeys defined under .
Request the data stored in value named . If VALUE is not specified or argument is the special name (default) , the content of the default value, if any, will be returned.
# query default value for HKLM/SOFTWARE/Kitware key cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Kitware") # query default value for HKLM/SOFTWARE/Kitware key using special value name cmake_host_system_information(RESULT result QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/Kitware" VALUE "(default)")
- REG_SZ .
- REG_EXPAND_SZ . The returned data is expanded.
- REG_MULTI_SZ . The returned is expressed as a CMake list. See also SEPARATOR sub-option.
- REG_DWORD .
- REG_QWORD .
For all other types, an empty string is returned.
Specify which registry views must be queried. When not specified, BOTH view is used.
Query the 64bit registry. On 32bit Windows , returns always an empty string.
For VALUE sub-option or default value, query the registry using view 64 , and if the request failed, query the registry using view 32 . For VALUE_NAMES and SUBKEYS sub-options, query both views ( 64 and 32 ) and merge the results (sorted and duplicates removed).
For VALUE sub-option or default value, query the registry using view 32 , and if the request failed, query the registry using view 64 . For VALUE_NAMES and SUBKEYS sub-options, query both views ( 32 and 64 ) and merge the results (sorted and duplicates removed).
Query the registry matching the architecture of the host: 64 on 64bit Windows and 32 on 32bit Windows .
Query the registry matching the architecture specified by CMAKE_SIZEOF_VOID_P variable. If not defined, fallback to HOST view.
Query both views ( 32 and 64 ). The order depends of the following rules: If CMAKE_SIZEOF_VOID_P variable is defined. Use the following view depending of the content of this variable:
If CMAKE_SIZEOF_VOID_P variable is not defined, rely on architecture of the host:
Specify the separator character for REG_MULTI_SZ type. When not specified, the character \0 is used.
Returns any error raised during query operation. In case of success, the variable holds an empty string.
CMAKE_VERSION¶
The CMake version string as three non-negative integer components separated by . and possibly followed by — and other information. The first two components represent the feature level and the third component represents either a bug-fix level or development date.
Release versions and release candidate versions of CMake use the format:
where the component is less than 20000000 . Development versions of CMake use the format:
where the component is of format CCYYMMDD and may contain arbitrary text. This represents development as of a particular date following the . feature release.
Individual component values are also available in variables:
Use the if() command VERSION_LESS , VERSION_GREATER , VERSION_EQUAL , VERSION_LESS_EQUAL , or VERSION_GREATER_EQUAL operators to compare version string values against CMAKE_VERSION using a component-wise test. Version component values may be 10 or larger so do not attempt to compare version strings as floating-point numbers.
CMake versions 2.8.2 through 2.8.12 used three components for the feature level. Release versions represented the bug-fix level in a fourth component, i.e. ..[.][-rc] . Development versions represented the development date in the fourth component, i.e. …[-] .
CMake versions prior to 2.8.2 used three components for the feature level and had no bug-fix component. Release versions used an even-valued second component, i.e. ..[-rc] . Development versions used an odd-valued second component with the development date as the third component, i.e. .. .
The CMAKE_VERSION variable is defined by CMake 2.6.3 and higher. Earlier versions defined only the individual component variables.
VERSION
Для разделяемых библиотек VERSION и SOVERSION могут использоваться для указания версии сборки и версии API соответственно. При сборке или установке создаются соответствующие символические ссылки, если платформа поддерживает символические ссылки, а компоновщик поддерживает так называемые имена. Если указан только один из обоих, предполагается, что отсутствующие имеют одинаковый номер версии. Для исполняемых файлов VERSION может использоваться для указания версии сборки. При сборке или установке соответствующие символические ссылки создаются, если платформа поддерживает символические ссылки.
Windows Versions
Для разделяемых библиотек и исполняемых файлов в Windows атрибут VERSION анализируется для извлечения номера версии . . Эти числа используются в качестве версии изображения двоичного файла.
Mach-O Versions
Для общих библиотек и исполняемых файлов в системах Mach-O (например, macOS, iOS) свойство SOVERSION соответствует версии совместимости, а VERSION соответствует текущей версии (если не предусмотрены специальные переопределения для Mach-O, как обсуждается ниже). См FRAMEWORK целевого свойства для примера.
Для совместно используемых библиотек свойства MACHO_COMPATIBILITY_VERSION и MACHO_CURRENT_VERSION могут использоваться для переопределения версии совместимости и текущей версии соответственно. Обратите внимание, что SOVERSION по- прежнему будет использоваться для формирования install_name , и SOVERSION и VERSION также могут влиять на имена файлов и символических ссылок .
Версии двоичных файлов Mach-O можно проверить с помощью команды otool -L .
CMake 3.25
Добавлять ли флаг компиляции для скрытия символов встроенных функций Свойство VISIBILITY_INLINES_HIDDEN определяет,будет ли установлен флаг для скрытия символов функций,