set(CMAKE_SYSTEM_NAME Windows) set(TOOLCHAIN_PREFIX x86_64-w64-mingw32) set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}-gcc) set(CMAKE_CXX_COMPILER ${TOOLCHAIN_PREFIX}-g++) set(CMAKE_AR ${TOOLCHAIN_PREFIX}-gcc-ar) set(CMAKE_RANLIB ${TOOLCHAIN_PREFIX}-gcc-ranlib) set(CMAKE_RC_COMPILER ${TOOLCHAIN_PREFIX}-windres) set(CMAKE_RC_FLAGS -DGCC_WINDRES) set(CMAKE_FIND_ROOT_PATH "/usr/${TOOLCHAIN_PREFIX};/usr/lib/gcc/${TOOLCHAIN_PREFIX}/;${CMAKE_CURRENT_BINARY_DIR}/deps") # modify default behavior of FIND_XXX() commands to # search for headers/libs in the target environment and # search for programs in the build host environment set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Set Wine as the emulator if we're not running under Windows if (NOT "${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") find_program (WINE wine REQUIRED) set (CMAKE_CROSSCOMPILING_EMULATOR "${WINE}") endif () # Export the chosen compiler via CXX and CC, because it's entirely possible # one of child build scripts will call out to something that relies on these # to discover the compiler (or will otherwise choose the wrong one). set ($ENV{CXX} "${CMAKE_CXX_COMPILER}") set ($ENV{CC} "${CMAKE_C_COMPILER}")