mingw.toolchain.cmake 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #
  2. # Copyright (c) 2008-2014 the Urho3D project.
  3. #
  4. # Permission is hereby granted, free of charge, to any person obtaining a copy
  5. # of this software and associated documentation files (the "Software"), to deal
  6. # in the Software without restriction, including without limitation the rights
  7. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. # copies of the Software, and to permit persons to whom the Software is
  9. # furnished to do so, subject to the following conditions:
  10. #
  11. # The above copyright notice and this permission notice shall be included in
  12. # all copies or substantial portions of the Software.
  13. #
  14. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. # THE SOFTWARE.
  21. #
  22. cmake_minimum_required (VERSION 2.6.3)
  23. if (CMAKE_TOOLCHAIN_FILE)
  24. # Reference toolchain variable to suppress "unused variable" warning
  25. endif ()
  26. # Target operating system and architecture
  27. set (CMAKE_SYSTEM_NAME Windows)
  28. set (CMAKE_SYSTEM_PROCESSOR x86)
  29. # Sanitate the path
  30. file (TO_CMAKE_PATH "$ENV{MINGW_PREFIX}" MINGW_PREFIX)
  31. # C/C++ compilers
  32. set (CMAKE_C_COMPILER ${MINGW_PREFIX}-gcc CACHE PATH "C compiler")
  33. set (CMAKE_CXX_COMPILER ${MINGW_PREFIX}-g++ CACHE PATH "C++ compiler")
  34. set (CMAKE_RC_COMPILER ${MINGW_PREFIX}-windres CACHE PATH "RC compiler")
  35. # specify the system root
  36. file (TO_CMAKE_PATH "$ENV{MINGW_ROOT}" MINGW_ROOT)
  37. if (NOT MINGW_ROOT)
  38. get_filename_component (MINGW_PREFIX ${MINGW_PREFIX} NAME)
  39. set (MINGW_ROOT /usr/${MINGW_PREFIX}/sys-root)
  40. endif ()
  41. set (MINGW_SYSROOT ${MINGW_ROOT} CACHE PATH "Path to MinGW SYSROOT")
  42. set (CMAKE_FIND_ROOT_PATH ${MINGW_SYSROOT})
  43. # only search libraries and headers in the target directories
  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. # setup install destination prefix path only when cross-compiling
  48. if (CMAKE_CROSSCOMPILING)
  49. set (CMAKE_INSTALL_PREFIX "${MINGW_SYSROOT}/usr/local" CACHE PATH "Install path prefix, prepended onto install directories.")
  50. endif ()