# use with cmake -DCMAKE_TOOLCHAIN_FILE=source_dir/w64.cmake [-DGNU_HOST=i686-w64-mingw32] source_dir # the name of the target operating system SET(CMAKE_SYSTEM_NAME Windows) # Choose an appropriate compiler prefix # for classical mingw32 # see http://www.mingw.org/ #set(GNU_HOST "i586-mingw32msvc") # for 32 or 64 bits mingw-w64 # see http://mingw-w64.sourceforge.net/ #set(GNU_HOST "i686-w64-mingw32") IF("${GNU_HOST}" STREQUAL "") SET(GNU_HOST x86_64-w64-mingw32) ENDIF() SET(CMAKE_C_COMPILER ${GNU_HOST}-gcc) SET(CMAKE_CXX_COMPILER ${GNU_HOST}-g++) SET(CMAKE_RC_COMPILER ${GNU_HOST}-windres) SET(CMAKE_FIND_ROOT_PATH /usr/${GNU_HOST} ${USER_ROOT_PATH}) # prevent CMAKE to look for libs,includes and packages outside the mingw path SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) # however, use executables from the current system SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)