Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Using CMake in MSYS2

Installing

When building projects for Windows with CMake (as opposed tobuilding projects that are going to run in MSYS2 posix emulation runtime)make sure to install the MinGW version of CMake, i.e. installinge.g.mingw-w64-x86_64-cmake.

You also want to install a tool for actually doing the build. Thecurrent recommended default is Ninja, which you can install from themingw-w64-x86_64-ninja package.

(Other alternatives aremake ormingw-w64-x86_64-make, for buildingwith GNU Make running either as a MSYS2 or MinGW process.)

Building

When running the CMake configuration command, it's recommended to explicitlyspecify the desired build file generator with the-G option. MSYS2provided CMake defaults to Ninja (but this is not the default in upstreamCMake, so it's safest to explicitly specify it).

Thus, to configure and build a CMake based project, you can run thefollowing commands:

$cmake-GNinja<path-to-source>-DCMAKE_BUILD_TYPE=Release$cmake--build.

The relevant generator alternatives are:

  • -G Ninja
  • -G "MSYS Makefiles"
  • -G "MinGW Makefiles"

If building by invokingcmake --build, the same command works for allgenerator choices. Alternatively, to build by directly invoking thebuild tool, you can callninja,make ormingw32-make respectivelyfor those three alternatives.

Examples

For building projects with CMake in MSYS2 in Github Actions, see theCMake Example.


[8]ページ先頭

©2009-2025 Movatter.jp