cmake_minimum_required(VERSION 3.19) project(mingw-cmake-toolchains NONE) set(MINGW_TOOLCHAINS i686-w64-mingw32 x86_64-w64-mingw32) include(GNUInstallDirs) foreach(MINGW_TOOLCHAIN IN ITEMS ${MINGW_TOOLCHAINS}) configure_file(toolchain.cmake.in "${MINGW_TOOLCHAIN}.cmake" @ONLY) install( FILES "${CMAKE_CURRENT_BINARY_DIR}/${MINGW_TOOLCHAIN}.cmake" DESTINATION "${CMAKE_INSTALL_DATADIR}/cmake/toolchains") endforeach()