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 and DVCPKG_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 builds
x86-mingw-dynamic, x86-mingw-static - for Windows builds (32-Bit) (optional?)
arm64-linux, arm-linux or arm64-windows, arm-windows - for ARM builds
wasm32-emscripten - for WebASM/Emscripten (optional)
- more (optional)
- setup cmake-toolchain
- cmake toolchain files included (batteries included)
- use pre-defined cmake toolchain files
- 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")
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), ...
Add function to setup
-DCMAKE_TOOLCHAIN_FILE/-DVCPKG_TOOLCHAIN_FILEandinclude()toolchain via-DOPT_TARGET_TRIPLET:STRING=x64-mingw-dynamicoption.Example:
or with cmake arguments:
VCPKG_HOST_TRIPLET,VCPKG_TRIPLETandDVCPKG_CHAINLOAD_TOOLCHAIN_FILE- https://github.com/microsoft/vcpkg/blob/master/docs/users/triplets.md-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-linuxorarm64-windows,arm-windows- for ARM buildswasm32-emscripten- for WebASM/Emscripten (optional)-DANDROID_NDKand-DANDROID_ABIemscript,set_target_properties(${target} PROPERTIES LINK_FLAGS "-s ASSERTIONS=1 -s WASM=1 -s ASYNCIFY -s USE_PTHREADS=1 --bind")Notes