Darwin-GNU.cmake 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 -Wl,-headerpad_max_install_names")
  21. set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
  22. endmacro()
  23. macro(cmake_gnu_set_sysroot_flag lang)
  24. if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG)
  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}_SYSROOT_FLAG "-isysroot")
  35. else()
  36. message(STATUS "Checking whether ${_doc} - no")
  37. set(CMAKE_${lang}_SYSROOT_FLAG "")
  38. endif()
  39. set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")")
  40. endif()
  41. endmacro()
  42. macro(cmake_gnu_set_osx_deployment_target_flag lang)
  43. if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
  44. set(_doc "${lang} compiler supports OSX deployment target flag")
  45. message(STATUS "Checking whether ${_doc}")
  46. execute_process(
  47. COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
  48. OUTPUT_VARIABLE _gcc_help
  49. ERROR_VARIABLE _gcc_help
  50. )
  51. if("${_gcc_help}" MATCHES "macosx-version-min")
  52. message(STATUS "Checking whether ${_doc} - yes")
  53. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
  54. else()
  55. message(STATUS "Checking whether ${_doc} - no")
  56. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
  57. endif()
  58. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
  59. endif()
  60. endmacro()