{"id":17359119,"url":"https://github.com/nathanjhood/msys2-toolchain","last_synced_at":"2025-07-22T01:02:27.980Z","repository":{"id":177162907,"uuid":"658201164","full_name":"nathanjhood/MSYS2-toolchain","owner":"nathanjhood","description":"CMake with vcpkg for all MSYS2 sub-systems.","archived":false,"fork":false,"pushed_at":"2023-08-27T23:33:38.000Z","size":1020,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-14T02:25:59.648Z","etag":null,"topics":["clang","cmake","cygwin","gnu","mingw-w64","mingw32","mingw64","msys2","msys2-mingw","msys2-mingw64","vcpkg"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nathanjhood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-06-25T04:44:00.000Z","updated_at":"2025-04-09T14:39:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"f0ed2ac1-0384-49c7-99f3-75108432fe68","html_url":"https://github.com/nathanjhood/MSYS2-toolchain","commit_stats":null,"previous_names":["stoneydsp/msys2-toolchain","nathanjhood/msys2-toolchain"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nathanjhood/MSYS2-toolchain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanjhood%2FMSYS2-toolchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanjhood%2FMSYS2-toolchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanjhood%2FMSYS2-toolchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanjhood%2FMSYS2-toolchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nathanjhood","download_url":"https://codeload.github.com/nathanjhood/MSYS2-toolchain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nathanjhood%2FMSYS2-toolchain/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266405362,"owners_count":23923535,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["clang","cmake","cygwin","gnu","mingw-w64","mingw32","mingw64","msys2","msys2-mingw","msys2-mingw64","vcpkg"],"created_at":"2024-10-15T19:08:14.084Z","updated_at":"2025-07-22T01:02:27.891Z","avatar_url":"https://github.com/nathanjhood.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MSYS2 toolchain\n\nFull CMake build support for all \u003ca href=\"msys2.org\"\u003eMsys64\u003c/a\u003e sub-systems, with optonal \u003ca href=\"\"\u003evcpkg\u003c/a\u003e integration.\n\nCurrently being developed in tandem with my specialized fork of \u003ca href=\"https://github.com/StoneyDSP/msys2-pacman.git\"\u003eMSYS2-Pacman\u003c/a\u003e, with the aim of bringing the building of package binaries from hosted source repositories to msys2 environments for Windows.\n\nAs a means of thoroughly testing the toolchains, I have simultaneously developed several small projects that require a more extensive usage of the libraries and headers available in each subsystem; A \u003ca href=\"https://github.com/StoneyDSP/CMakeProject1.git\"\u003esimple CMake application\u003c/a\u003e suitable for templating new projects, a specialized fork of \u003ca href=\"https://github.com/StoneyDSP/msys2-pacman.git\"\u003eMSYS2-Pacman\u003c/a\u003e for package management, and a \u003ca href=\"https://github.com/StoneyDSP/CxxWin.git\"\u003enative windowed application using the Win32 API and Direct2D graphics\u003c/a\u003e.\n\n# \u003cb\u003eUsage\u003c/b\u003e\n\nSimply pass the \u003ca href=\"\"\u003escripts/buildsystems/MSYS2.cmake\u003c/a\u003e file as your \"\u003cb\u003eCMAKE_TOOLCHAIN_FILE\u003c/b\u003e\", along with a desired \"\u003cb\u003eMSYSTEM\u003c/b\u003e\".\n\n```\n$ cmake -S \"\u003cpath/to/project\u003e\" -B \"\u003cpath/to/project\u003e/build\" \"-DMSYSTEM=MINGW64\" \"-DCMAKE_TOOLCHAIN_FILE=\u003cpath/to/this/repo\u003e/scripts/buildsystems/MSYS2.cmake\" \"-DCMAKE_MODULE_PATH=\u003cpath/to/this/repo\u003e/scripts/cmake/Modules\" -G \"Ninja Multi-Config\"\n```\n\nChoose an \"\u003cb\u003eMSYSTEM\u003c/b\u003e\" from one of the following  options:\n\n* UCRT64\n* MINGW64\n* MINGW32\n* CLANG64\n* CLANG32\n* CLANGARM64\n* MSYS2\n\n\u003cu\u003e\u003ci\u003eIMPORTANT\u003c/i\u003e\u003c/u\u003e - Make sure you include this part of the above command, to enable the '\u003cb\u003eMSYSTEM\u003c/b\u003e' platform for CMake:\n\n-D\u003cb\u003eCMAKE_MODULE_PATH\u003c/b\u003e=\u003ci\u003e\\\u003cpath/to/this/repo\\\u003e\u003c/i\u003e/scripts/cmake/Modules\"\n\n# \u003cb\u003eRequirements\u003c/b\u003e\n\n* Windows Host machine\n* MSYS2 installation (please try to use the default install location)\n* CMake\n\nNote that will need to have run the standard init commands for Msys development;\n\n```pacman -Syuu```\n\n```pacman -S --needed base-devel```\n\n```pacman -S cmake```\n\n```pacman -S autotools```\n\n```pacman -S ming-w64-{msystem}-{arch}-toolchain```\n\n```pacman -S ming-w64-{msystem}-{arch}-cmake```\n\n```pacman -S ming-w64-{msystem}-{arch}-toolchain```\n\n```pacman -S ming-w64-{msystem}-{arch}-autotools```\n\nCorresponding to the chosen MSYSTEM in order to have the toolchain installed and available to for use by this project. See the MSYS2 (and Packages page) docs for more.\n\n\n# \u003cb\u003eDescription\u003c/b\u003e\n\nThis independent project is an ongoing investigation into the potential of cross-pollinating \u003ca href=\"\"\u003eMSYS2\u003c/a\u003e's multi-verse of build envinronments and toolchains, with the source code package registry access and management of \u003ca href=\"\"\u003eMicrosoft's vcpkg\u003c/a\u003e, thanks to the power and flexibility of \u003ca href=\"\"\u003eCMake\u003c/a\u003e.\n\nFortunately, for this project to achieve it's targets, much of the required configurations are already available within a standard CMake, Msys64, and optionally vcpkg, installation; we have simply defined an additional set of standard processes for directing the flow of file-hopping that CMake does under the hood when configuring/building/etc to pick up combinations of native CMake files that otherwise wouldn't be specified together, using the provided configs alone.\n\nDoing this involves porting the contents of several configuration as found in Windows MSYS2 installations:\n\n* \u003ca href=\"\"\u003eetc/makepkg.conf\u003c/a\u003e*\n* \u003ca href=\"\"\u003eetc/makepkg_mingw.conf\u003c/a\u003e**\n\n(*for \"\u003cb\u003eMSYS2\u003c/b\u003e\")\n\n(**for \"\u003cb\u003eMINGW32\u003c/b\u003e/\u003cb\u003e64\u003c/b\u003e\", \"\u003cb\u003eCLANG32\u003c/b\u003e/\u003cb\u003e64\u003c/b\u003e/\u003cb\u003eARM64\u003c/b\u003e\", and \"\u003cb\u003eURCRT64\u003c/b\u003e\")\n\nThese files are typically used to drive configurations for \"\u003cb\u003ePKGBUILD\u003c/b\u003e\", which is the integrated package-building/bundling mechanism used by '\u003cb\u003epacman\u003c/b\u003e' in typical development scenarios when using MSYS2.\n\nThis project aims to port as much of the above as possible to a natively-CMake-driven process, including the integration of a port Microsoft's 'vcpkg' package manager and its' useful \"triplet/toolchain/buildsystem\" paradigm:\n\n* Known configuration of system to build software on, i.e., the '\u003cb\u003ehost\u003c/b\u003e'\u003cb\u003e*\u003c/b\u003e.\n* Desired configuration of system to run software on, i.e., the '\u003cb\u003etarget\u003c/b\u003e'\u003cb\u003e*\u003c/b\u003e.\n* Chain of tools to build with, i.e., a '\u003cb\u003etoolchain\u003c/b\u003e'.\n* A building process invoking all of the above, i.e., a '\u003cb\u003ebuild system\u003c/b\u003e'.\n\n\u003ci\u003e\u003cb\u003e*\u003c/b\u003eeach of these configurations are referred to as '\u003cb\u003etriplets\u003c/b\u003e'\u003c/i\u003e\n\nIn a CMake-driven build environment, these settings can all be pre-defined with configuration scripts ('\u003cb\u003etoolchain files\u003c/b\u003e') which configure CMake with a full set of environment variables, binary/library paths, and compiler flags for each of the available invoking MSYS sub-systems (often known as \"MSYSTEM\"'s), appropriately setting each of the underlying build tool behaviours for each sub-system, enabling CMake to correctly find and use them.\n\nThis project does precisely the above with as minimal user requirements as possible. With the desired toolchain(s) on your pacman-driven Msys installation in place, it should be as simple as passing the 'MSYS2.cmake' buildsystem file (as the CMake toolchain) and an 'MSYSTEM' to your CMake invocation, making the entire sub-system readily available to your CMake/Msys64 projects.\n\nHere's what building with each of the sub-systems offers, as per the \u003ca href=\"\"\u003eMSYS2 documentation\u003c/a\u003e:\n\n## MINGW64\n\n* MinGW-based x64-bit environment\n* GNU compilers and binary utlilities\n* 'MSVCRT' C Standard Library\n* 'libstdc++' C++ Standard Library\n\n## MINGW32\n\n* MinGW-based x32-bit environment\n* GNU compilers and binary utlilities\n* 'MSVCRT' C Standard Library\n* 'libstdc++' C++ Standard Library\n\n## CLANG64\n\n* MinGW-based x64-bit environment\n* Clang compilers and LLVM binary utlilities\n* 'UCRT' C Standard Library\n* 'libc++' C++ Standard Library\n\n## CLANG32\n\n* MinGW-based x32-bit environment\n* Clang compilers and LLVM binary utlilities\n* 'UCRT' C Standard Library\n* 'libc++' C++ Standard Library\n\n## UCRT64\n\n* MinGW-based x64-bit environment\n* Support for both GNU *and* Clang compiler toolchains\n* 'UCRT' C Standard Library\n* 'libstdc++' C++ Standard Library\n\n## MSYS2\n\n* Cygwin-based native environment\n* Support for both GNU *and* Clang compiler toolchains\n* 'Cygwin' C Standard Library with 'MSYS2' Runtimes\n* 'libstdc++' C++ Standard Library\n\n\u003c/br\u003e\n\u003ci\u003e\u003cb\u003e*\u003c/b\u003e Microsoft Visual C++ Runtime (\u003cb\u003eMSVCRT\u003c/b\u003e)\u003c/i\u003e\n\n\u003ci\u003e\u003cb\u003e**\u003c/b\u003e Universal C Runtime (\u003cb\u003eUCRT\u003c/b\u003e)\u003c/i\u003e\n\n\u003c/br\u003e\n\u003c/br\u003e\nTo use the toolchain and buildsystem, first install your MSYSTEM toolchain using pacman as usual, then pass these vars to your CMake invocation when building;\n\n* \"-D\u003cb\u003eCMAKE_TOOLCHAIN_FILE\u003c/b\u003e=\u003ci\u003e\\\u003cpath/to/this/repo\\\u003e\u003c/i\u003e/scripts/buildsystem/MSYS2.cmake\"\n\n* \"-D\u003cb\u003eMSYSTEM\u003c/b\u003e=\u003cb\u003eMINGW64\u003c/b\u003e\"\n\n* \"-D\u003cb\u003eCMAKE_MODULE_PATH\u003c/b\u003e=\u003ci\u003e\\\u003cpath/to/this/repo\\\u003e\u003c/i\u003e/scripts/cmake/Modules\"\n\nor, to use a sub-system without the encasing buildsystem, just pass it in as the toolchain file directly (this omits usage as a package manager, but still provides a full configured toolchain and utilities);\n\n* -D\u003cb\u003eCMAKE_TOOLCHAIN_FILE\u003c/b\u003e=\u003ci\u003e\"\\\u003cpath/to/this/repo\\\u003e\u003c/i\u003e/scripts/toolchains/MINGW64.cmake\"\n\n\u003ci\u003e* you may of course swap 'MINGW64' for any of the other available MSYSTEM's - just don't forget to include files indicated in the module path as above. \u003cb\u003e\u003cu\u003eCMake will fail without this\u003c/b\u003e!\u003c/u\u003e\u003c/i\u003e\n\nThe 'chainload' toolchain files ('scripts/toolchains') are named identically to the chosen \"\u003cb\u003eMSYSTEM\u003c/b\u003e\" and *may* provide more thorough default behaviours for invoked \"\u003cb\u003eMSYSTEM\u003c/b\u003e\" settings. Use in tandem for best results. However, there is *some* experimental support for passing just the 'buildsystem' file without any '\\\u003cMSYSTEM\\\u003e':\n\n* \u003cb\u003e-DCMAKE_TOOLCHAIN_FILE\u003c/b\u003e:FILEPATH=\u003ci\u003e\"\\\u003cpath/to/this/repo\\\u003e/scripts/buildsystem/MSYS2.cmake\"\u003c/i\u003e\n\n\"\u003cb\u003eCMAKE_TOOLCHAIN_FILE\u003c/b\u003e\" and \"\u003cb\u003eMSYSTEM\u003c/b\u003e\" can often also be set in your IDE's CMake integration extension's settings, and/or a \u003ci\u003e'CMakePresets.json'\u003c/i\u003e in the project root folder.\n\nFor best results, it is recommended to use either '\u003cb\u003eNinja\u003c/b\u003e' or '\u003cb\u003eNinja Multi-Config\u003c/b\u003e' as a generator, with the 'preferred' generator set to one of the Makefile generators - '\u003cb\u003eUnix\u003c/b\u003e/\u003cb\u003eMinGW\u003c/b\u003e/\u003cb\u003eMSYS Makefiles\u003c/b\u003e' etc.\n\n# \u003cb\u003eOptions\u003c/b\u003e\n\n## \"\u003cb\u003eMSYS2_PATH_TYPE\u003c/b\u003e\"\n\nWe have a working implementation of Msys64's 'path type' switching option under the custom CMake variable \"\u003cb\u003eMSYS2_PATH_TYPE\u003c/b\u003e\", as follows:\n\n* \"-D\u003cb\u003eMSYS2_PATH_TYPE\u003c/b\u003e=\u003cb\u003einherit\u003c/b\u003e\"\n\nInherit the Windows environment's \"PATH\" variable. Note that this will make all of the Windows path available in current shell, with possible interference in project builds.\n\n* \"-D\u003cb\u003eMSYS2_PATH_TYPE\u003c/b\u003e=\u003cb\u003eminimal\u003c/b\u003e\"\n\nProvides a minimal set of paths from the Windows environment's system folder; notably, this *excludes* all of your Windows 'Program Files' directories.\n\n* \"-D\u003cb\u003eMSYS2_PATH_TYPE\u003c/b\u003e=\u003cb\u003estrict\u003c/b\u003e\"\n\nDo not inherit any paths from the Windows environment, and allow for full customization of external paths. This is supposed to be used in special cases such as debugging without need to change this file, but not daily usage.\n\n## \u003cb\u003eOPTION_MSYS_PREFER_MSYSTEM_PATHS\u003c/b\u003e\n\nIf set to 'ON', the paths under the current 'MSYSTEM' directory will be scanned before the '\\\u003cmsysRoot\\\u003e/usr' directory during CMake's file/program/lib lookup routines.\n\nAccepts a Boolean value. Defaults to \"\u003cb\u003eON\u003c/b\u003e\".\n\n## \u003cb\u003eOPTION_MSYS_PREFER_WIN32_PATHS\u003c/b\u003e\n\nIf set to 'ON', the paths under the calling environment's 'PATH' variable will be scanned before any other paths, during CMake's file/program/lib lookup routines.\n\nAccepts a Boolean value. Defaults to \"\u003cb\u003eOFF\u003c/b\u003e\".\n\n## \u003cb\u003eOPTION_ENABLE_X11\u003c/b\u003e\n\nAdds '\\\u003cmsystemRoot\\\u003e/include/X11' to 'CMAKE_SYSTEM_INCLUDE_PATH', and '\\\u003cmsystemRoot\\\u003e/lib/X11' 'to CMAKE_SYSTEM_LIBRARY_PATH' for lookup.\n\nAccepts a Boolean value. Defaults to \"\u003cb\u003eOFF\u003c/b\u003e\".\n\n## \u003cb\u003eOPTION_USE_DSX_BINUTILS\u003c/b\u003e (coming soon!)\n\nAlso very much worth noting is that several sub-systems offer \"DSX-compatibility\" GNU Bin Utils, located various differently-named directories here and there. It seems at least a fun idea to leverage a ```cmake_option(OPTION_USE_DSX_BINUTILS)``` or similar, which likewise would favour these directories during file lookups for the tools in question. Again, this is actually all *pretty much* made possible, in fact quite easy, in CMake's design. Currently there are so very many features, permutations, varieties across the entire project that this concept hasn't yet been explored further, but stay tuned.\n\n# Stay tuned for further development!\n\n# Thanks for reading!\n\n# Legal\n\nThis Git repo, named \"MSYS2-toolchain\", is an independant project, created and maintained by \u003ca href=\"https://github.com/StoneyDSP\"\u003eStoneyDSP\u003c/a\u003e as a project of interest. By \"independant\", the author specifies that they have no relation to any of the parties further outlined below in this section of the page.\n\n## MSYS2\n\n\u003ci\u003eThe below is quoted from \u003ca href=\"https://www.msys2.org/license/\"\u003ehttps://www.msys2.org/license/\u003c/a\u003e\u003c/i\u003e\n\n\"MSYS2 is a software distribution consisting of several independent parts, each with their own licenses, comparable to a Linux distribution.\n\nThe installer, for example, is based on the qt-installer-framework and pre-packs the direct and indirect dependencies of the base meta package. Each package has its own licenses.\n\nThe \"pacman\" package manager in MSYS2 allows users to install other packages available in our repository, each with their own licenses.\n\nThe license information for each package as visible on \u003ca href=\"https://www.msys2.org/license/\"\u003ehttps://packages.msys2.org\u003c/a\u003e is maintained on a best effort basis and \"we\" (quote) make no guarantee that it is accurate or complete.\"\n\n## vcpkg\n\nvcpkg - C++ Library Manager for Windows, Linux, and MacOS\n\nCopyright (c) Microsoft Corporation\n\nvcpkg is distributed under the MIT License\n\nAll rights reserved.\n\n## CMake\n\nCMake - Cross Platform Makefile Generator\n\nCopyright 2000-2023 Kitware, Inc. and Contributors\n\nCMake is distributed under the OSI-approved BSD 3-clause License\n\nAll rights reserved.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanjhood%2Fmsys2-toolchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanjhood%2Fmsys2-toolchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanjhood%2Fmsys2-toolchain/lists"}