mingw32-w64-cross-travis.toolchain.cmake 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #
  2. # Mingw-w64 cross compiler toolchain
  3. #
  4. # - The usual CMAKE variables will point to the cross compiler
  5. # - HOST_EXE_LINKER, HOST_C_COMPILER, HOST_EXE_LINKER_FLAGS,
  6. # HOST_C_FLAGS point to a host compiler
  7. #
  8. set(MINGW_TRIPLET i686-w64-mingw32)
  9. # For x86_64 use
  10. #set(MINGW_TRIPLET x86_64-w64-mingw32)
  11. # The location of your toolchain sys-root
  12. set(MINGW_PREFIX_PATH /opt/mingw32/${MINGW_TRIPLET}/)
  13. # or sometimes like this
  14. #set(MINGW_PREFIX_PATH /usr/${MINGW_TRIPLET}/sys-root)
  15. # the name of the target operating system
  16. set(CMAKE_SYSTEM_NAME Windows)
  17. # which compilers to use for C and C++
  18. set(CMAKE_C_COMPILER ${MINGW_TRIPLET}-gcc)
  19. set(CMAKE_CXX_COMPILER ${MINGW_TRIPLET}-g++)
  20. set(CMAKE_RC_COMPILER ${MINGW_TRIPLET}-windres)
  21. set(CMAKE_C_COMPILER ${MINGW_TRIPLET}-gcc)
  22. set(CMAKE_CXX_COMPILER ${MINGW_TRIPLET}-g++)
  23. set(CMAKE_RC_COMPILER ${MINGW_TRIPLET}-windres)
  24. # Where is the target environment located
  25. set(CMAKE_FIND_ROOT_PATH "${MINGW_PREFIX_PATH}/mingw")
  26. # adjust the default behaviour of the FIND_XXX() commands:
  27. # search headers and libraries in the target environment, search
  28. # programs in the host environment
  29. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  30. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  31. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  32. set(CROSS_TARGET ${MINGW_TRIPLET})
  33. # We need a host compiler too - assuming mildly sane Unix
  34. # defaults here
  35. set(HOST_C_COMPILER cc)
  36. set(HOST_EXE_LINKER ld)
  37. if (MINGW_TRIPLET MATCHES "^x86_64")
  38. set(HOST_C_FLAGS)
  39. set(HOST_EXE_LINKER_FLAGS)
  40. else()
  41. # In 32 bits systems have the HOST compiler generate 32 bits binaries
  42. set(HOST_C_FLAGS -m32)
  43. set(HOST_EXE_LINKER_FLAGS -m32)
  44. endif()