xmake is a lightweight cross-platform build tool based on Lua. It uses xmake.lua to maintain project builds. Compared with makefile/CMakeLists.txt, the configuration syntax is more concise and intuitive. It is very friendly to novices. You can get started quickly in a short time. Let users focus more on actual project development.
In this new version, we focused on improving the dependency package management of xmake, adding support for the pacman package manager under Archlinux and MSYS2/Mingw, and we further enriched xmake’s official package repository xmake-repo , adding 50 Several commonly used C/C++ packages.
In addition, we have added a new independent subcommand based on xmake: xrepo , a complete and independent cross-platform C/C++ package manager, which makes it easier for users to manage the installation and integrated use of daily C/C++ packages.
At the same time, we have also launched the xrepo related site xrepo.xmake.io , where we can quickly check the usage of xrepo, as well as the support and usage of each package in the official xmake-repo repository.
New feature introduction
Xrepo package manager
xrepo is a cross-platform C/C++ package manager based on Xmake .
It is based on the runtime provided by xmake, but it is a complete and independent package management program. Compared with package managers such as vcpkg/homebrew, xrepo can provide C/C++ packages for more platforms and architectures at the same time.
It also supports multi-version semantic selection. In addition, it is a decentralized distributed warehouse. It not only provides the official xmake-repo warehouse, but also supports users to build multiple private warehouses.
At the same time, xrepo also supports installing packages from third-party package managers such as vcpkg/homebrew/conan, and provides unified and consistent library link information to facilitate integration and docking with third-party projects.
If you want to know more, please refer to: online documentation , Github and Gitee
installation
We only need to install xmake to use the xrepo command. For the installation of xmake, we can see: xmake installation document .
Support platform
- Windows (x86, x64)
- macOS (i386, x86_64, arm64)
- Linux (i386, x86_64, cross-toolchains ..)
- * BSD (i386, x86_64)
- Android (x86, x86_64, armeabi, armeabi-v7a, arm64-v8a)
- iOS (armv7, armv7s, arm64, i386, x86_64)
- MSYS (i386, x86_64)
- MinGW (i386, x86_64, arm, arm64)
- Cross Toolchains
Supported package management warehouse
- Official self-built warehouse xmake-repo ( tbox >1.6.1)
- User-built warehouse
- Conan (conan::openssl/1.1.1g)
- Vcpkg (vcpkg:ffmpeg)
- Homebrew/Linuxbrew (brew::pcre2/libpcre2-8)
- Pacman on archlinux/msys2 (pacman::libcurl)
- Tag (clib :: clibs/[email protected])
- Dub (dub::log 0.4.3)
Distributed warehouse support
In addition to directly retrieving the installation package from the official repository: xmake-repo , we can also add any number of self-built repositories, and even completely isolate the external network, and only maintain the installation and integration of private packages on the company's internal network.
Just use the following command to add your own warehouse address:
$ xrepo add-repo myrepo https://github.com/mygroup/myrepo
Install the C/C++ package independently
Various installation methods are available, supporting semantic version, debugging package, dynamic library, configurable parameters, and C/C++ package installation in various third-party package management.
$ xrepo install zlib tbox
$ xrepo install "zlib 1.2.x"
$ xrepo install "zlib >=1.2.0"
$ xrepo install -p iphoneos -a arm64 zlib
$ xrepo install -p android [--ndk=/xxx] zlib
$ xrepo install -p mingw [--mingw=/xxx] zlib
$ xrepo install -p cross --sdk=/xxx/arm-linux-musleabi-cross zlib
$ xrepo install -m debug zlib
$ xrepo install -k shared zlib
$ xrepo install -f "vs_runtime=MD" zlib
$ xrepo install -f "regex=true,thread=true" boost
$ xrepo install brew::zlib
$ xrepo install vcpkg::zlib
$ xrepo install conan::zlib/1.2.11
$ xrepo install pacman:libpng
$ xrepo install dub:log
Seamless integration with xmake engineering
add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8")
add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true})
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl")
The following is the overall architecture and compilation process integrated with xmake.
For more information about how to use xrepo, please refer to the document: Xrepo Quick Start .
Support the installation of cross-compiled dependency packages
In the new version, we have improved the dependency package installation mechanism inside xmake, and added C/C++ dependency package installation support for the cross-compilation tool chain, for example:
add_requires("zlib", "openssl")
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("zlib", "openssl")
We have configured two dependency packages above: zlib, openssl, and then we switch to the cross-compilation environment and use the compilation tool chain on musl.cc to compile.
$ xmake f -p cross --sdk=/tmp/arm-linux-musleabi-cross
in xmake-repo:
-> openssl 1.1.1h
please input: y (y/n)
=> http://zlib.net/zlib-1.2.11.tar.gz .. ok
=> download https://github.com/openssl/openssl/archive/OpenSSL_1_1_1h.zip .. ok
=> installing zlib .. ok
=> installing openssl .. ok
$ xmake
[ 50%]: ccache compiling.release src/main.cpp
[ 75%]: linking.release test
[100%]: build ok!
xmake will automatically pull the zlib/openssl source code package, and then use the arm-linux-musleabi-cross
cross tool chain to compile and install zlib and openssl. After the installation is complete, it will be automatically integrated into the test project to participate in the link until it is fully compiled.
Of course, to make C/C++ support cross-compilation, you first need to maintain the official xmake-repo repository and add support for cross-compilation. At present, there are not many C/C++ packages that support crossover in the warehouse, but many have already been included, and will continue to be expanded in the future.
If you want to see which packages support cross compilation, you can go directly to the package warehouse site to view: C/C++ package list that supports cross compilation
We can also use the xrepo command provided in the new version to directly retrieve the packages supported by the specified platform (support fuzzy query):
$ xrepo search -p cross zli*
We also welcome everyone to help contribute more packages to the official xmake-repo repository, and work together to improve the construction of the C/C++ package management ecosystem, so that users can use various dependent packages more conveniently, and no longer need to be involved in various tedious porting tasks. Troubled.
Dependent package license detection mechanism
Considering that the respective licenses of the packages in the warehouse are different, some packages may conflict with the license of the user project after use, so xmake adds a package dependency license compatibility detection mechanism in the new version.
And a new set_license
interface has been added , allowing users to set the license of each target.
For example, we integrated a LGPL-2.0 package libplist library, but our project does not have any license settings.
add_requires("libplist") -- LGPL-2.0
target("test")
set_kind("binary")
add_files("src/*.cpp")
add_packages("libplist")
When compiling, the following prompt will appear to warn users that there may be a risk of code license conflicts when using libplist.
$ xmake
warning: target(test) maybe is not compatible with license(LGPL-2.1) of package(libplist),
we can use shared libraries with LGPL-2.1 or use set_license()/set_policy() to modify/disable license!
And if we explicitly pass the project to set_license("LGPL-2.0")
ensure full compatibility, there will be no warning messages, and for GPL
related licenses, xmake will also have corresponding detections.
The relatively loose license packages such as MIT and BSD are directly integrated and used without any warning.
In addition, if we explicitly set set_license()
the license conflict with the package, we will also prompt a warning.
Pacman package source support
In the previous version, xmake already supports the automatic integration of third-party warehouse package sources such as vcpkg, conan, clib, homebrew, etc. In the new version, we have added support for integration of packages managed by pacman.
We support both the installation and integration of pacman package on archlinux, and the mingw x86_64
/ i386
package installation and integration of pacman on msys2 .
add_requires("pacman::zlib", {alias = "zlib"})
add_requires("pacman::libpng", {alias = "libpng"})
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("zlib", "libpng")
On archlinux, only:
xmake
To install the mingw package on msys2, you need to specify the mingw platform:
xmake f -p mingw -a [x86_64|i386]
xmake
Mandatory installation of any version of the package
Because the packages in the xmake-repo warehouse have a strict version list and the corresponding sha256 value for the integrity check of the download, this will ensure the reliability and integrity of the package download.
However, it also leads to the inability to fully include all versions of a package. If there is a required version that has not been included, one way is for the user to add the pr to the xmake-repo repository to increase the support for the corresponding version.
Another way is to configure the {verify = false}
mandatory skip verification mechanism in xmake.lua so that you can choose to download any version of the package.
add_requires("libcurl 7.73.0", {verify = false})
vcpkg package integration improvements
Regarding the dependency integration of the vcpkg package, a lot of improvements have been made in the new version. Not only has the switch support for the windows-static-md package been added, but we have also improved the automatic detection mechanism of the vcpkg command, making it possible in more scenarios It can be detected automatically instead of requiring manual configuration.
Custom cross toolchain improvements
In the new version, we continue to make improvements to the custom tool chain to make the automatic detection more intelligent. Usually only need to specify sdkdir, xmake can automatically detect other configurations, such as cross and other information, for example:
toolchain("my_toolchain")
set_kind("standalone")
set_sdkdir("/tmp/arm-linux-musleabi-cross")
toolchain_end()
target("hello")
set_kind("binary")
add_files("apps/hello/*.c")
This is one of the most streamlined cross-toolchain configuration, just set the corresponding sdk path, and then set_kind("standalone")
mark it as a complete independent toolchain.
At this time, we can --toolchain=my_toolchain
manually switch to this toolchain through the command line to use.
xmake f --toolchain=my_toolchain
xmake
In addition, we can also directly set_toolchains
bind it to the corresponding target in xmake.lua , then only when this target is compiled, will we switch to our custom toolchain.
toolchain("my_toolchain")
set_kind("standalone")
set_sdkdir("/tmp/arm-linux-musleabi-cross")
toolchain_end()
target("hello")
set_kind("binary")
add_files("apps/hello/*.c")
set_toolchains("my_toolchain")
In this way, we no longer need to switch the toolchain manually, just execute xmake and it will automatically switch to the my_toolchain toolchain by default.
This is especially useful for embedded development, because there are many cross-compilation tool chains for embedded platforms, and we often need various switches to complete the compilation of different platforms.
Therefore, we can place all toolchain definitions in a separate lua file to define, for example:
projectdir
- xmake.lua
- toolchains
- my_toolchain1.lua
- my_toolchain2.lua
- ...
Then, we only need to introduce them in xmake.lua through includes, and bind different tool chains according to different custom platforms:
includes("toolchains/*.lua")
target("hello")
set_kind("binary")
add_files("apps/hello/*.c")
if is_plat("myplat1") then
set_toolchains("my_toolchain1")
elseif is_plat("myplat2") then
set_toolchains("my_toolchain2")
end
In this way, we can quickly switch the designated platform directly when compiling to automatically switch the corresponding tool chain.
xmake f -p myplat1
xmake
If some cross-compilation tool chains are complex in structure and automatic detection is not enough, you can use set_toolset
, set_cross
and set_bindir
other interfaces according to the actual situation , and configure other settings in a targeted manner.
For example, in the following example, we also added some cxflags/ldflags and built-in system library links.
toolchain("my_toolchain")
set_kind("standalone")
set_sdkdir("/tmp/arm-linux-musleabi-cross")
on_load(function (toolchain)
-- add flags for arch
if toolchain:is_arch("arm") then
toolchain:add("cxflags", "-march=armv7-a", "-msoft-float", {force = true})
toolchain:add("ldflags", "-march=armv7-a", "-msoft-float", {force = true})
end
toolchain:add("ldflags", "--static", {force = true})
toolchain:add("syslinks", "gcc", "c")
end)
For more examples of custom toolchains, you can refer to the built-in toolchain definition in the source directory of xmake: internal toolchain list
Menu configuration supports mouse operation
Remember that xmake also provides graphical terminal menu configuration? It is the classic menu config graphical configuration interface similar to linux kernel.
xmake f --menu
In the new version, we have also made further improvements to it, adding cross-platform mouse operations. We can use the mouse to click and select various configuration items, which is more convenient.
update content
New features
- Add a new xrepo command to manage and install C/C++ packages
- Support the installation of cross-compiled dependency packages
- Added toolchain support on musl.cc
- #1009 : Support ignoring verification to install any version of the package,
add_requires("libcurl 7.73.0", {verify = false})
- #1016 : Add license compatibility check for dependent packages
- #1017 : Support external/system header file support
add_sysincludedirs
, dependent packages are used by default-isystem
- #1020 : Support finding and installing pacman package on archlinux and msys2
- Improve
xmake f --menu
menu configuration, support mouse operation
Improve
- #997 :
xmake project -k cmake
Addset_languages
support for plugins - #998 : Support installing windows-static-md type vcpkg package
- #996 : Improve vcpkg directory search
- #1008 : Improve cross-compilation tool chain
- #1030 : Improve the rules of xcode.framework and xcode.application
- #1051 : Add
edit
andembed
debug information format type to msvc compilerset_symbols()
- #1062 : Improve the
xmake project -k vs
plugin