Skip to end of banner
Go to start of banner

CMake

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 25 Current »

CMake is a widely used open-source, cross-platform family of tools designed to build, test, and package software.

Project homepage: https://cmake.org/

Source code: https://gitlab.kitware.com/cmake/cmake

Status

  • Native CMake support for windows on arm has been completed and official installers are available now from official CMake download pages https://cmake.org/download/

  • Emulated CMake can be used successfully but is no longer required as native CMake support is available.

Getting CMake on win-arm64

Build from source

OpenSSL: https://linaro.atlassian.net/wiki/spaces/WOAR/pages/28654632982/A+tale+of+a+dependency+chain+Pillow+and+the+crew#OpenSSL

cmake . -DCMAKE_INSTALL_PREFIX=<install dir path> -DCMAKE_BUILD_TYPE=Release -A ARM64
cmake --build .
cmake --install .

I needed to create release build, because of the debug DLL issue: Debug run-time DLL issue

Note: Please check out a commit with https://gitlab.kitware.com/cmake/cmake/-/commit/3eb9f69ffe3bf9a8a69195a54d147abfc6146cf5

Python distribution

CMake (and Ninja) is distributed via Python wheels also. These distributions are replacement installation of the host projects, using Python’s distribution system.

In other words, if you are able to install them with pip, you’ll be fine and shouldn’t worry about downloading binaries and setting environment variables.

This project provides a setup.py script that build CMake Python wheels.

PyPi release: https://pypi.org/project/cmake/

Github source:https://github.com/scikit-build/cmake-python-distributions

It relies on scikit-build and not setuptools.

sci-kit build win-arm64 support was released in 0.13.0: https://github.com/scikit-build/scikit-build/pull/612

The Python distribution tries to download the corresponding release binary of CMake for the given platform, but for win-arm64 there aren’t any. The fallback could be to build CMake from source, but it requires OpenSSL, what is also not yet released for win-arm64. Moreover building native CMake with ported local OpenSSL doesn’t pass all the tests of CMake.

So the current solution is to wrap the x86 emulated CMake as it works on every WoA machine as expected.
https://github.com/scikit-build/cmake-python-distributions/pull/231

As soon as this patch will be included by a following release, this should get x86 emulated CMake:

pip install cmake

As soon as official native win-arm64 CMake is released, this should be updated to deploy that binary.

Build native win-arm64 CMake via Python distribution

If you still would like to build CMake from source this are the steps:

OpenSSL: https://linaro.atlassian.net/wiki/spaces/WOAR/pages/28654632982/A+tale+of+a+dependency+chain+Pillow+and+the+crew#OpenSSL

Tutorial: https://cmake-python-distributions.readthedocs.io/en/latest/building.html

python setup.py bdist_wheel -DBUILD_CMAKE_FROM_SOURCE:BOOL=ON -DOPENSSL_ROOT_DIR="c:\Program Files\OpenSSL" 

Using CMake on win-arm64

Generator: Ninja

Compiler: MSVC

cmd /k '"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsx86_arm64.bat" & powershell'
cmake -G "Ninja" ..

Compiler: LLVM

Using inline attributes

cmake -G "Ninja" -DCMAKE_C_COMPILER="clang-cl.exe" -DCMAKE_CXX_COMPILER="clang-cl.exe" 

Using environment variables

$env:CC="c:\kg\tools\LLVM-13.0.0-woa64\bin\clang-cl.exe"
$env:CXX="c:\kg\tools\LLVM-13.0.0-woa64\bin\clang-cl.exe"
cmake .. -G Ninja

Compiler: MSVC, Linker: LLVM

cmake -G "Ninja" -DCMAKE_C_COMPILER="cl.exe" -DCMAKE_CXX_COMPILER="cl.exe" -DCMAKE_LINKER="lld-link.exe" ..

Example:

cmake . -G "Ninja" -DCMAKE_C_COMPILER="c:\\kg\\tools\\LLVM-13.0.0-woa64\\bin\\clang-cl.exe" -DCMAKE_CXX_COMPILER="c:\\kg\\tools\\LLVM-13.0.0-woa64\\bin\\clang-cl.exe" -DCMAKE_LINKER="lld-link.exe"="c:\\kg\\tools\\LLVM-13.0.0-woa64\\bin\\lld-link.exe"

Environment variable for linker is ignored.

Generator: Visual Studio

Compiler: MSVC

cmake .. -G"Visual Studio 16 2019" -A ARM64

Compiler: LLVM

In general "-T llvm" would be the switch to use LLVM as a different toolset for a generator, but this option is not yet enabled for win-arm64.

Identify win-arm64 in CMake

The following CMake variable can help: {CMAKE_SYSTEM_PROCESSOR}

message(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
CMAKE_SYSTEM_PROCESSOR: ARM64

This works only on a native CMake instance and would give incorrect value with an emulated CMake

* Known issue

Can’t find installed Visual Studio, so only Ninja is working as a generator.

  Generator

    Visual Studio 16 2019

  could not find any instance of Visual Studio.

This has been fixed with https://gitlab.kitware.com/cmake/cmake/-/merge_requests/7159

  • No labels