Toolchain-mingw32.cmake 2.5 KB

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