Toolchain-mingw32.cmake 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # the name of the target operating system
  2. set(CMAKE_SYSTEM_NAME Windows)
  3. #remove the runtime dependency for libgcc_s_sjlj-1.dll
  4. set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc")
  5. # Which compilers to use for C and C++, and location of target
  6. # environment.
  7. if(EXISTS /usr/i686-w64-mingw32)
  8. # First look in standard location as used by Debian/Ubuntu/etc.
  9. set(CMAKE_STRIP i686-w64-mingw32-strip)
  10. set(CMAKE_C_COMPILER i686-w64-mingw32-gcc)
  11. set(CMAKE_CXX_COMPILER i686-w64-mingw32-g++)
  12. set(CMAKE_RC_COMPILER i686-w64-mingw32-windres)
  13. set(CMAKE_AR:FILEPATH /usr/bin/i686-w64-mingw32-ar)
  14. set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32)
  15. elseif(EXISTS /usr/i586-mingw32msvc)
  16. # First look in standard location as used by Debian/Ubuntu/etc.
  17. set(CMAKE_STRIP i586-mingw32msvc-strip)
  18. set(CMAKE_C_COMPILER i586-mingw32msvc-gcc)
  19. set(CMAKE_CXX_COMPILER i586-mingw32msvc-g++)
  20. set(CMAKE_RC_COMPILER i586-mingw32msvc-windres)
  21. set(CMAKE_FIND_ROOT_PATH /usr/i586-mingw32msvc)
  22. elseif(EXISTS /opt/mingw)
  23. # You can get a MinGW environment using the script at <http://mxe.cc>.
  24. # It downloads and builds MinGW and most of the dependencies for you.
  25. # You can use the toolchain file generated by MXE called `mxe-conf.cmake'
  26. # or you can use this file by adjusting the above and following paths.
  27. set(CMAKE_STRIP /opt/mingw/usr/bin/i686-pc-mingw32-strip)
  28. set(CMAKE_C_COMPILER /opt/mingw/usr/bin/i686-pc-mingw32-gcc)
  29. set(CMAKE_CXX_COMPILER /opt/mingw/usr/bin/i686-pc-mingw32-g++)
  30. set(CMAKE_RC_COMPILER /opt/mingw/usr/bin/i686-pc-mingw32-windres)
  31. set(CMAKE_FIND_ROOT_PATH /opt/mingw/usr/i686-pc-mingw32)
  32. else()
  33. # Else fill in local path which the user will likely adjust.
  34. # This is the location assumed by <http://www.libsdl.org/extras/win32/cross/>
  35. set(CMAKE_STRIP /usr/local/cross-tools/bin/i386-mingw32-strip)
  36. set(CMAKE_C_COMPILER /usr/local/cross-tools/bin/i386-mingw32-gcc)
  37. set(CMAKE_CXX_COMPILER /usr/local/cross-tools/bin/i386-mingw32-g++)
  38. set(CMAKE_RC_COMPILER /usr/local/cross-tools/bin/i386-mingw32-windres)
  39. set(CMAKE_FIND_ROOT_PATH /usr/local/cross-tools)
  40. endif()
  41. # Adjust the default behaviour of the FIND_XXX() commands:
  42. # search headers and libraries in the target environment, search
  43. # programs in the host environment
  44. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  45. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  46. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  47. # Tell pkg-config not to look at the target environment's .pc files.
  48. # Setting PKG_CONFIG_LIBDIR sets the default search directory, but we have to
  49. # set PKG_CONFIG_PATH as well to prevent pkg-config falling back to the host's
  50. # path.
  51. set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig)
  52. set(ENV{PKG_CONFIG_PATH} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig)
  53. set(ENV{MINGDIR} ${CMAKE_FIND_ROOT_PATH})