Toolchain-mingw64.cmake 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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/x86_64-w64-mingw32)
  8. # First look in standard location as used by Debian/Ubuntu/etc.
  9. set(CMAKE_STRIP x86_64-w64-mingw32-strip)
  10. set(CMAKE_C_COMPILER x86_64-w64-mingw32-gcc)
  11. set(CMAKE_CXX_COMPILER x86_64-w64-mingw32-g++)
  12. set(CMAKE_RC_COMPILER x86_64-w64-mingw32-windres)
  13. set(CMAKE_AR:FILEPATH /usr/bin/x86_64-w64-mingw32-ar)
  14. set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32)
  15. elseif(EXISTS /usr/i586-mingw32msvc)
  16. # Else fill in local path which the user will likely adjust.
  17. set(CMAKE_STRIP /usr/local/cross-tools/bin/i386-mingw32-strip)
  18. set(CMAKE_C_COMPILER /usr/local/cross-tools/bin/i386-mingw32-gcc)
  19. set(CMAKE_CXX_COMPILER /usr/local/cross-tools/bin/i386-mingw32-g++)
  20. set(CMAKE_RC_COMPILER /usr/local/cross-tools/bin/i386-mingw32-windres)
  21. set(CMAKE_FIND_ROOT_PATH /usr/local/cross-tools)
  22. endif()
  23. # Adjust the default behaviour of the FIND_XXX() commands:
  24. # search headers and libraries in the target environment, search
  25. # programs in the host environment
  26. set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  27. set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  28. set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  29. # Tell pkg-config not to look at the target environment's .pc files.
  30. # Setting PKG_CONFIG_LIBDIR sets the default search directory, but we have to
  31. # set PKG_CONFIG_PATH as well to prevent pkg-config falling back to the host's
  32. # path.
  33. set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig)
  34. set(ENV{PKG_CONFIG_PATH} ${CMAKE_FIND_ROOT_PATH}/lib/pkgconfig)
  35. set(ENV{MINGDIR} ${CMAKE_FIND_ROOT_PATH})