Skip to content

Instantly share code, notes, and snippets.

@mbilyanov
Created September 22, 2020 09:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbilyanov/0c8f25653a6015bdc8f904bcaea3bff5 to your computer and use it in GitHub Desktop.
Save mbilyanov/0c8f25653a6015bdc8f904bcaea3bff5 to your computer and use it in GitHub Desktop.
toolchain-mingw32.cmake
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Windows)
# Choose an appropriate compiler prefix
# /include and /lib folders required by the 64bit mingw.
set(COMPILER_PREFIX "x86_64-w64-mingw32")
# which compilers to use for C and C++
find_program(CMAKE_C_COMPILER NAMES /usr/bin/${COMPILER_PREFIX}-gcc)
find_program(CMAKE_CXX_COMPILER NAMES /usr/bin/${COMPILER_PREFIX}-g++)
# here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX})
# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search
# programs in the 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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment