MujocoMacOS.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. # Copyright 2022 DeepMind Technologies Limited
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # https://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. if(APPLE)
  15. # Target the oldest version of macOS that is still supported by Apple.
  16. # We follow https://endoflife.date/macos, which considers a version to become
  17. # unsupported the first time it is excluded from a macOS security update
  18. # (e.g. https://github.com/endoflife-date/endoflife.date/issues/1602).
  19. set(MUJOCO_MACOSX_VERSION_MIN 11)
  20. # We are setting the -mmacosx-version-min compiler flag directly rather than using the
  21. # CMAKE_OSX_DEPLOYMENT_TARGET variable since we do not want to affect choice of SDK,
  22. # and also we only want to apply the version restriction locally.
  23. set(MUJOCO_MACOS_COMPILE_OPTIONS -mmacosx-version-min=${MUJOCO_MACOSX_VERSION_MIN}
  24. -Werror=partial-availability -Werror=unguarded-availability
  25. )
  26. set(MUJOCO_MACOS_LINK_OPTIONS -mmacosx-version-min=${MUJOCO_MACOSX_VERSION_MIN}
  27. -Wl,-no_weak_imports
  28. )
  29. else()
  30. set(MUJOCO_MACOS_COMPILE_OPTIONS "")
  31. set(MUJOCO_MACOS_LINK_OPTIONS "")
  32. endif()
  33. function(enforce_mujoco_macosx_min_version)
  34. if(APPLE)
  35. add_compile_options(${MUJOCO_MACOS_COMPILE_OPTIONS})
  36. add_link_options(${MUJOCO_MACOS_LINK_OPTIONS})
  37. endif()
  38. endfunction()