Open
Description
Add function to setup -DCMAKE_TOOLCHAIN_FILE
/-DVCPKG_TOOLCHAIN_FILE
and include()
toolchain via -DOPT_TARGET_TRIPLET:STRING=x64-mingw-dynamic
option.
Example:
project_options(
TARGET_TRIPLET "x64-mingw-dynamic"
)
or with cmake arguments:
# for custom toolchains
cmake ... -DOPT_TOOLCHAIN_FILE:STRING="..." -DOPT_TARGET_TRIPLET:STRING="..."
## setup vcpkg and more
# use project_options toolchains
cmake ... -DOPT_TARGET_TRIPLET:STRING="..."
## setup vcpkg and more
# use vcpkg arguments
cmake ... -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE="..." -DVCPKG_TARGET_TRIPLET="..."
## read vcpkg triplet and set OPT_TARGET_TRIPLET etc.
- setup variables for cmake/vcpkg:
VCPKG_HOST_TRIPLET
,VCPKG_TRIPLET
andDVCPKG_CHAINLOAD_TOOLCHAIN_FILE
- https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md - Possible Triplets for
-DOPT_TARGET_TRIPLET
:x64-mingw-dynamic
,x64-mingw-static
- for Windows buildsx86-mingw-dynamic
,x86-mingw-static
- for Windows builds (32-Bit) (optional?)arm64-linux
,arm-linux
orarm64-windows
,arm-windows
- for ARM buildswasm32-emscripten
- for WebASM/Emscripten (optional)- more (optional)
- setup cmake-toolchain
- cmake toolchain files included (batteries included)
- use pre-defined cmake toolchain files
- examples from - https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html
- https://github.com/staticlibs/cmake/tree/master/toolchains
- write own toolchains - https://github.com/aminya/Toolchain, https://github.com/abeimler/simple-cppbuilder/tree/main/cmake
- https://github.com/ruslo/polly (outdated)
- https://github.com/onqtam/awesome-cmake#toolchains=
- https://github.com/dockcross/dockcross
- checks for ENV variables and paths, print some helpful messages if something is missing (optional)
- For example, when building for Android you need to set
-DANDROID_NDK
and-DANDROID_ABI
- Maybe add some (default) extra properties: like for example
emscript
,set_target_properties(${target} PROPERTIES LINK_FLAGS "-s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s USE_PTHREADS=1 --bind")
- For example, when building for Android you need to set
Notes
- Cross compiler must setup by user
- Maybe addition arguments must be pass for cross-compiler root path or other paths like Android NDK, emscripten SDK (emsdk), ...