6/2/2023 0 Comments Compile cmake linuxSo before building libpng I first compile zlib with a particular incantation: make -f win32/Makefile. However zlib does distribute a Makefile intended for targeting GNU tools on Windows. While libpng (used as an example above) provides a nice CMake configuration that cross-compiles cleanly, it depends on zlib which does not. DCMAKE_PREFIX_PATH=$HOME/windows_binaries \ So if we want to build against the libpng that was just built and generate a “release” binary: cmake -DCMAKE_SYSTEM_NAME=Windows \ DCMAKE_INSTALL_PREFIX=$HOME/windows_binaries \Īs I’ve observed previously, you can then link against these libraries by setting CMAKE_PREFIX_PATH. (which itself provides options to enable a shared library and tests which we turn off): cmake -DCMAKE_SYSTEM_NAME=Windows \ For instance building a libpng static library Libraries that you might depend on can be built in the same way, and installed to a chosen directory by setting CMAKE_INSTALL_PREFIX then building the install target. When building binaries to share it’s probably helpful to do a non-debug build by also setting CMAKE_BUILD_TYPE, perhaps to MinSizeRel or RelWithDebInfo. If no support for 32-bit Windows is required, the x86_64-prefixed tools will build 64-bit binaries instead (eg, x86_64-w64-mingw32-gcc). The i686- prefixed compiler builds 32-bit binaries, which I usually prefer to build because they’ll work both on 32- and 64-bit Windows. Targeting mingw-64 then, the cmake invocation looks like this: cmake -DCMAKE_SYSTEM_NAME=Windows \ CMAKE_CXX_COMPILER is the name of the compiler to use for C sources.CMAKE_C_COMPILER is the name of the compiler to use. CMAKE_SYSTEM_NAME being set implies that you’re cross-compiling, which will prevent cmake from trying to do things like run the binaries it builds (unless they’re tool binaries being built for the host, rather than the target). armlinuxsetup.cmake,arm set (CMAKESYSTEMNAME Linux) set (CMAKESYSTEMPROCESSOR arm) 32bit set (tools /home/share/work/hk/ad-speaker/codes/prebuilts/gcc/linux-x86/arm/gcc-arm-10.3-2021.For simple needs, only three variables must be set: Many Linux distributions provide packages for it: mingw-w64 on Debian (including Ubuntu and variants), mingw-w64-gcc on Arch and similar for other distributions.ĬMake documents how to specify cross-compilation options, but it’s not terribly clear which settings are mandatory. This isn’t hard, but finding the right options is a little bit of a challenge every time, so now I’m recording the procedure here both as a reminder to myself, and to provide a quick recipe that future searchers can use.Ĭross-compiling for Windows will of course need an appropriate toolchain, which these days tends to be mingw-w64. exe that can be given to mostly non-technical Windows users to run. I sometimes find myself wanting to cross-compile programs with CMake on a Linux machine such that I get a standalone. All other trademarks are property of their respective owners.Cross-compiling CMake projects for Windows 20 January, 2021 Qt and respective logos are trademarks of The Qt Company Ltd. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. The book Professional CMake: A Practical Guide provides a great introduction to the most relevant CMake features.īuild with CMake Building projects on the command lineĭocumentation contributions included herein are the copyrights of The official CMake Tutorial covers common build system tasks. The official CMake Documentation is an invaluable source for working with CMake. qm files are handled, use the underlying commands qt_add_lupdate and qt_add_lrelease. The qt_add_translations command is a convenience wrapper. ts files and the embedding into a resource, see the qt_add_translations documentation. target release_translationsįor more information about how to influence the handling of.
0 Comments
Leave a Reply. |