Darwin-GNU.cmake 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #=============================================================================
  2. # Copyright 2002-2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # This module is shared by multiple languages; use include blocker.
  14. if(__DARWIN_COMPILER_GNU)
  15. return()
  16. endif()
  17. set(__DARWIN_COMPILER_GNU 1)
  18. macro(__darwin_compiler_gnu lang)
  19. # GNU does not have -shared on OS X
  20. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -headerpad_max_install_names")
  21. set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -headerpad_max_install_names")
  22. endmacro()
  23. macro(cmake_gnu_has_isysroot lang)
  24. if("x${CMAKE_${lang}_HAS_ISYSROOT}" STREQUAL "x")
  25. set(_doc "${lang} compiler has -isysroot")
  26. message(STATUS "Checking whether ${_doc}")
  27. execute_process(
  28. COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
  29. OUTPUT_VARIABLE _gcc_help
  30. ERROR_VARIABLE _gcc_help
  31. )
  32. if("${_gcc_help}" MATCHES "isysroot")
  33. message(STATUS "Checking whether ${_doc} - yes")
  34. set(CMAKE_${lang}_HAS_ISYSROOT 1)
  35. else()
  36. message(STATUS "Checking whether ${_doc} - no")
  37. set(CMAKE_${lang}_HAS_ISYSROOT 0)
  38. endif()
  39. endif()
  40. endmacro()
  41. macro(cmake_gnu_set_osx_deployment_target_flag lang)
  42. if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
  43. set(_doc "${lang} compiler supports OSX deployment target flag")
  44. message(STATUS "Checking whether ${_doc}")
  45. execute_process(
  46. COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
  47. OUTPUT_VARIABLE _gcc_help
  48. ERROR_VARIABLE _gcc_help
  49. )
  50. if("${_gcc_help}" MATCHES "macosx-version-min")
  51. message(STATUS "Checking whether ${_doc} - yes")
  52. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
  53. else()
  54. message(STATUS "Checking whether ${_doc} - no")
  55. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
  56. endif()
  57. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "SET(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
  58. endif()
  59. endmacro()