Very new to CMake, and so far I'm finding it to be extremely helpful. I have a set of custom libraries that I would like to build for multiple platforms using cross-compilation. The toolchains are installed, and I can hand-create the Makefile
s that I need to do so, but I would like to be able to make use of CMake.
Is there a way to tell cmake
which toolchain to use, either at the command line or in the CMakeLists.txt
file?
With the MSVC toolchain you can also use set(CMAKE_EXE_LINKER_FLAGS "/machine:x86") (sub in your architecture) in your cmake files. On Windows/MSVC, 64 and 32 bit are actually different compilers, unlike e.g gcc where architectue is a flag you'll pass to a compiler.
It is the path to a file which is read early in the CMake run and which specifies locations for compilers and toolchain utilities, and other target platform and compiler related information.
The CMAKE_SYSROOT content is passed to the compiler in the --sysroot flag, if supported. The path is also stripped from the RPATH / RUNPATH if necessary on installation. The CMAKE_SYSROOT is also used to prefix paths searched by the find_* commands.
Have a look here: basically, you define a "toolchain file" that sets things like the system name, paths to compilers and so on. You then call cmake
like so:
cmake /path/to/src -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/foo-bar-baz.cmake
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With