If you only want to compile the platform of the current host environment, such as compiling the Windows version on Windows and the Macosx version on Macosx, you just need to click the following command:
xmake
Because xmake detects the current environment by default, compiles the platform version of the current host by default, without additional configuration, and compiles the release version by default.
If there are multiple targets in the project, the above command will compile all targets. If you only want to compile and specify one target, such as test, you only need to execute:
xmake test
If you want to compile the debug version, you need to do some simple configurations:
xmake config --mode=debug xmake
Xmake provides a shortened version of each command and parameter:
xmake f -m debug xmake
Note: In order to improve flexibility, the compilation option settings of the release version and the debug version need to be described in the project description file. If they are not set, the programs generated by the release version and the debug version are the same.
If you want to forcibly rebuild all, you can execute:
xmake -r xmake --rebuild
If you want to specify a specific architecture to compile, you can compile it as follows:
xmake f -a armv7 xmake
Generally, if no architecture is specified, the default architecture of the specified platform will be used by default. For example, x86_64 is the default architecture for Macosx, and armv7 is the default architecture for iPhone OS Corporal
If you want to specify other platforms to compile, such as the version of iphone os on mac os x, then:
xmake f -p iphoneos xmake
Compile Android version:
xmake f -p android --ndk=xxxx xmake
Although it is not necessary to reconfigure each compilation after configuration, if you switch the compilation target platform to IOS and Linux, the previous settings of ndk will be cleared, and you will have to reconfigure next time.
If you want to make it easier to switch compilation back and forth between different platforms, you can set the ndk to the global configuration, for example:
--Set the ndk to the global configuration xmake g --ndk=xxx --Switch to the Android compilation platform, and you don't need to set the ndk every time xmake f -p android xmake -r --Switch to ios compilation platform xmake f -p iphoneos xmake -r
Compiling the Windows version is very simple. As long as you have installed VS on your machine, xmake will automatically detect it. No additional configuration is required. Just open the cmd, enter your project directory, and then execute xmake.
Compile with other cross toolchains:
xmake f -p android -a armv7-a --cross=arm-linux-androideabi- --toolchains=/xxxx/bin xmake
By default, when compiling the configuration, the previous configuration will be cached, so that only some parameters need to be modified each time, and it is not necessary to reconfigure all the parameters each time
If you want to reconfigure all and clear the original cache, you can add the -- clean parameter:
xmake f -c xmake f --clean xmake
When configuring, xmake will check some interfaces and link libraries that the project depends on. If you want to see specific configuration detection information, you can add the -- verbose parameter to echo the configuration information
xmake f -c -v xmake f --clean --verbose xmake
Xmake also supports manually setting some compilation options and tools when compiling. The specific parameter list is as follows:
--cc=CC The C Compiler --cxx=CXX The C++ Compiler --cflags=CFLAGS The C Compiler Flags --cxflags=CXFLAGS The C/C++ compiler Flags --cxxflags=CXXFLAGS The C++ Compiler Flags --as=AS The Assembler --asflags=ASFLAGS The Assembler Flags --ld=LD The Linker --ldflags=LDFLAGS The Binary Linker Flags --ar=AR The Static Library Linker --arflags=ARFLAGS The Static Library Linker Flags --sh=SH The Shared Library Linker --shflags=SHFLAGS The Shared Library Linker Flags --mm=MM The Objc Compiler --mxx=MXX The Objc++ Compiler --mflags=MFLAGS The Objc Compiler Flags --mxflags=MXFLAGS The Objc/c++ Compiler Flags --mxxflags=MXXFLAGS The Objc++ Compiler Flags