Apple-GNU.cmake 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # This module is shared by multiple languages; use include blocker.
  4. include_guard()
  5. macro(__apple_compiler_gnu lang)
  6. set(CMAKE_${lang}_VERBOSE_FLAG "-v -Wl,-v") # also tell linker to print verbose output
  7. # GNU does not have -shared on OS X
  8. set(CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS "-dynamiclib -Wl,-headerpad_max_install_names")
  9. set(CMAKE_SHARED_MODULE_CREATE_${lang}_FLAGS "-bundle -Wl,-headerpad_max_install_names")
  10. if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.3)
  11. set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
  12. endif()
  13. endmacro()
  14. macro(cmake_gnu_set_sysroot_flag lang)
  15. if(NOT DEFINED CMAKE_${lang}_SYSROOT_FLAG)
  16. set(_doc "${lang} compiler has -isysroot")
  17. message(STATUS "Checking whether ${_doc}")
  18. execute_process(
  19. COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
  20. OUTPUT_VARIABLE _gcc_help
  21. ERROR_VARIABLE _gcc_help
  22. )
  23. if("${_gcc_help}" MATCHES "isysroot")
  24. message(STATUS "Checking whether ${_doc} - yes")
  25. set(CMAKE_${lang}_SYSROOT_FLAG "-isysroot")
  26. else()
  27. message(STATUS "Checking whether ${_doc} - no")
  28. set(CMAKE_${lang}_SYSROOT_FLAG "")
  29. endif()
  30. set(CMAKE_${lang}_SYSROOT_FLAG_CODE "set(CMAKE_${lang}_SYSROOT_FLAG \"${CMAKE_${lang}_SYSROOT_FLAG}\")")
  31. endif()
  32. endmacro()
  33. macro(cmake_gnu_set_osx_deployment_target_flag lang)
  34. if(NOT DEFINED CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG)
  35. set(_doc "${lang} compiler supports OSX deployment target flag")
  36. message(STATUS "Checking whether ${_doc}")
  37. execute_process(
  38. COMMAND ${CMAKE_${lang}_COMPILER} "-v" "--help"
  39. OUTPUT_VARIABLE _gcc_help
  40. ERROR_VARIABLE _gcc_help
  41. )
  42. if("${_gcc_help}" MATCHES "macosx-version-min")
  43. message(STATUS "Checking whether ${_doc} - yes")
  44. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=")
  45. else()
  46. message(STATUS "Checking whether ${_doc} - no")
  47. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "")
  48. endif()
  49. set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG_CODE "set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG \"${CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG}\")")
  50. endif()
  51. endmacro()