CheckHost.cmake 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #
  2. # Copyright (c) 2008-2016 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. # Check the capability of the host system
  23. #
  24. # NULL_DEVICE
  25. #
  26. # WIN32 only:
  27. # HAS_MKLINK (capable to create mklink which is analogous to symlink)
  28. #
  29. # non-WIN32:
  30. # HAS_LIB64 (multilib capable)
  31. #
  32. if (CMAKE_HOST_WIN32)
  33. set (NULL_DEVICE nul)
  34. if (NOT DEFINED HAS_MKLINK)
  35. # Test whether the host system is capable of setting up symbolic link
  36. execute_process (COMMAND cmd /C mklink test-link CMakeCache.txt RESULT_VARIABLE MKLINK_EXIT_CODE OUTPUT_QUIET ERROR_QUIET)
  37. if (MKLINK_EXIT_CODE EQUAL 0)
  38. set (HAS_MKLINK TRUE)
  39. file (REMOVE ${CMAKE_BINARY_DIR}/test-link)
  40. else ()
  41. set (HAS_MKLINK FALSE)
  42. message (WARNING "Could not use MKLINK to setup symbolic links as this Windows user account does not have the privilege to do so. "
  43. "When MKLINK is not available then the build system will fallback to use file/directory copy of the library headers from source tree to build tree. "
  44. "In order to prevent stale headers being used in the build, this file/directory copy will be redone also as a post-build step for each library targets. "
  45. "This may slow down the build unnecessarily or even cause other unforseen issues due to incomplete or stale headers in the build tree. "
  46. "Request your Windows Administrator to grant your user account to have privilege to create symlink via MKLINK command. "
  47. "You are NOT advised to use the Administrator account directly to generate build tree in all cases.")
  48. endif ()
  49. set (HAS_MKLINK ${HAS_MKLINK} CACHE INTERNAL "MKLINK capability")
  50. endif ()
  51. else ()
  52. set (NULL_DEVICE /dev/null)
  53. if (NOT DEFINED HAS_LIB64)
  54. if (EXISTS /usr/lib64)
  55. set (HAS_LIB64 TRUE)
  56. else ()
  57. set (HAS_LIB64 FALSE)
  58. endif ()
  59. set (HAS_LIB64 ${HAS_LIB64} CACHE INTERNAL "Multilib capability")
  60. endif ()
  61. endif ()