Toolchain-mingw32.cmake 2.5 KB

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