SampleDependencies.cmake 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. # Copyright 2021 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. include(FindOrFetch)
  15. if(SAMPLE_STANDALONE)
  16. # If standalone, by default look for MuJoCo binary version.
  17. set(DEFAULT_USE_SYSTEM_MUJOCO ON)
  18. else()
  19. set(DEFAULT_USE_SYSTEM_MUJOCO OFF)
  20. endif()
  21. option(MUJOCO_SAMPLES_USE_SYSTEM_MUJOCO "Use installed MuJoCo version."
  22. ${DEFAULT_USE_SYSTEM_MUJOCO}
  23. )
  24. unset(DEFAULT_USE_SYSTEM_MUJOCO)
  25. option(MUJOCO_SAMPLES_USE_SYSTEM_MUJOCO "Use installed MuJoCo version." OFF)
  26. option(MUJOCO_SAMPLES_USE_SYSTEM_GLFW "Use installed GLFW version." OFF)
  27. set(MUJOCO_DEP_VERSION_glfw3
  28. 7482de6071d21db77a7236155da44c172a7f6c9e # 3.3.8
  29. CACHE STRING "Version of `glfw` to be fetched."
  30. )
  31. mark_as_advanced(MUJOCO_DEP_VERSION_glfw3)
  32. find_package(Threads REQUIRED)
  33. set(MUJOCO_BUILD_EXAMPLES OFF)
  34. set(MUJOCO_BUILD_TESTS OFF)
  35. set(MUJOCO_BUILD_PYTHON OFF)
  36. set(MUJOCO_TEST_PYTHON_UTIL OFF)
  37. findorfetch(
  38. USE_SYSTEM_PACKAGE
  39. MUJOCO_SAMPLES_USE_SYSTEM_MUJOCO
  40. PACKAGE_NAME
  41. mujoco
  42. LIBRARY_NAME
  43. mujoco
  44. GIT_REPO
  45. https://github.com/google-deepmind/mujoco.git
  46. GIT_TAG
  47. main
  48. TARGETS
  49. mujoco
  50. EXCLUDE_FROM_ALL
  51. )
  52. option(MUJOCO_EXTRAS_STATIC_GLFW
  53. "Link MuJoCo sample apps and simulate libraries against GLFW statically." ON
  54. )
  55. if(MUJOCO_EXTRAS_STATIC_GLFW)
  56. set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
  57. set(BUILD_SHARED_LIBS
  58. OFF
  59. CACHE INTERNAL "Build SHARED libraries"
  60. )
  61. endif()
  62. set(GLFW_BUILD_EXAMPLES OFF)
  63. set(GLFW_BUILD_TESTS OFF)
  64. set(GLFW_BUILD_DOCS OFF)
  65. set(GLFW_INSTALL OFF)
  66. findorfetch(
  67. USE_SYSTEM_PACKAGE
  68. MUJOCO_SAMPLES_USE_SYSTEM_GLFW
  69. PACKAGE_NAME
  70. glfw3
  71. LIBRARY_NAME
  72. glfw3
  73. GIT_REPO
  74. https://github.com/glfw/glfw.git
  75. GIT_TAG
  76. ${MUJOCO_DEP_VERSION_glfw3}
  77. TARGETS
  78. glfw
  79. EXCLUDE_FROM_ALL
  80. )
  81. if(MUJOCO_EXTRAS_STATIC_GLFW)
  82. set(BUILD_SHARED_LIBS
  83. ${BUILD_SHARED_LIBS_OLD}
  84. CACHE BOOL "Build SHARED libraries" FORCE
  85. )
  86. unset(BUILD_SHARED_LIBS_OLD)
  87. endif()
  88. if(NOT SAMPLE_STANDALONE)
  89. target_compile_options(glfw PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
  90. target_link_options(glfw PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
  91. endif()