summarylogtreecommitdiffstats
path: root/mujoco.patch
blob: 0fa34eabe44925647ee66faf91b71ebc49571afa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
diff --git a/cmake/MujocoDependencies.cmake b/cmake/MujocoDependencies.cmake
index 4c15a91..b5e5925 100644
--- a/cmake/MujocoDependencies.cmake
+++ b/cmake/MujocoDependencies.cmake
@@ -79,6 +79,7 @@ set(BUILD_SHARED_LIBS
     CACHE INTERNAL "Build SHARED libraries"
 )
 
+find_package(lodepng REQUIRED)
 if(NOT TARGET lodepng)
   FetchContent_Declare(
     lodepng
@@ -103,9 +104,9 @@ set(QHULL_ENABLE_TESTING OFF)
 
 findorfetch(
   USE_SYSTEM_PACKAGE
-  OFF
+  ON
   PACKAGE_NAME
-  qhull
+  Qhull
   LIBRARY_NAME
   qhull
   GIT_REPO
@@ -116,18 +117,22 @@ findorfetch(
   qhull
   EXCLUDE_FROM_ALL
 )
-# MuJoCo includes a file from libqhull_r which is not exported by the qhull include directories.
-# Add it to the target.
-target_include_directories(
-  qhullstatic_r INTERFACE $<BUILD_INTERFACE:${qhull_SOURCE_DIR}/src/libqhull_r>
-)
-target_compile_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(qhullstatic_r PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
+if(NOT TARGET qhullstatic_r)
+  add_library(qhullstatic_r INTERFACE)
+  target_link_libraries(qhullstatic_r INTERFACE Qhull::qhull_r)
+  # Workaround as headers are installed in <prefix>/include/libqhull_r/something.h
+  # but mujoco include them as #include <something.h>
+  get_property(qhull_include_dirs TARGET Qhull::qhull_r PROPERTY INTERFACE_INCLUDE_DIRECTORIES)
+  foreach(qhull_include_dir IN LISTS qhull_include_dirs)
+    target_include_directories(qhullstatic_r INTERFACE ${qhull_include_dirs}/libqhull_r)
+  endforeach()
+  target_include_directories(qhullstatic_r INTERFACE )
+endif()
 
 set(tinyxml2_BUILD_TESTING OFF)
 findorfetch(
   USE_SYSTEM_PACKAGE
-  OFF
+  ON
   PACKAGE_NAME
   tinyxml2
   LIBRARY_NAME
@@ -140,12 +145,10 @@ findorfetch(
   tinyxml2
   EXCLUDE_FROM_ALL
 )
-target_compile_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(tinyxml2 PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
 
 findorfetch(
   USE_SYSTEM_PACKAGE
-  OFF
+  ON
   PACKAGE_NAME
   tinyobjloader
   LIBRARY_NAME
@@ -163,7 +166,7 @@ set(ENABLE_DOUBLE_PRECISION ON)
 set(CCD_HIDE_ALL_SYMBOLS ON)
 findorfetch(
   USE_SYSTEM_PACKAGE
-  OFF
+  ON
   PACKAGE_NAME
   ccd
   LIBRARY_NAME
@@ -176,19 +179,6 @@ findorfetch(
   ccd
   EXCLUDE_FROM_ALL
 )
-target_compile_options(ccd PRIVATE ${MUJOCO_MACOS_COMPILE_OPTIONS})
-target_link_options(ccd PRIVATE ${MUJOCO_MACOS_LINK_OPTIONS})
-
-# libCCD has an unconditional `#define _CRT_SECURE_NO_WARNINGS` on Windows.
-# TODO(stunya): Remove this after https://github.com/danfis/libccd/pull/77 is merged.
-if(WIN32)
-  if(MSVC)
-    # C4005 is the MSVC equivalent of -Wmacro-redefined.
-    target_compile_options(ccd PRIVATE /wd4005)
-  else()
-    target_compile_options(ccd PRIVATE -Wno-macro-redefined)
-  endif()
-endif()
 
 if(MUJOCO_BUILD_TESTS)
   set(ABSL_PROPAGATE_CXX_STD ON)
@@ -203,7 +193,7 @@ if(MUJOCO_BUILD_TESTS)
   set(ABSL_BUILD_TESTING OFF)
   findorfetch(
     USE_SYSTEM_PACKAGE
-    OFF
+    ON
     PACKAGE_NAME
     absl
     LIBRARY_NAME
@@ -230,7 +220,7 @@ if(MUJOCO_BUILD_TESTS)
 
   findorfetch(
     USE_SYSTEM_PACKAGE
-    OFF
+    ON
     PACKAGE_NAME
     GTest
     LIBRARY_NAME
@@ -264,7 +254,7 @@ if(MUJOCO_BUILD_TESTS)
 
   findorfetch(
     USE_SYSTEM_PACKAGE
-    OFF
+    ON
     PACKAGE_NAME
     benchmark
     LIBRARY_NAME
@@ -283,6 +273,9 @@ endif()
 
 if(MUJOCO_TEST_PYTHON_UTIL)
   add_compile_definitions(EIGEN_MPL2_ONLY)
+  find_package(Eigen3 REQUIRED)
+  # Doing that so the next if is not triggered
+  add_library(eigen ALIAS Eigen3::Eigen)
   if(NOT TARGET eigen)
     # Support new IN_LIST if() operator.
     set(CMAKE_POLICY_DEFAULT_CMP0057 NEW)
diff --git a/cmake/MujocoOptions.cmake b/cmake/MujocoOptions.cmake
index 998b966..213f422 100644
--- a/cmake/MujocoOptions.cmake
+++ b/cmake/MujocoOptions.cmake
@@ -86,7 +86,6 @@ get_mujoco_extra_link_options(EXTRA_LINK_OPTIONS)
 
 if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT MSVC))
   set(EXTRA_COMPILE_OPTIONS
-      -Werror
       -Wall
       -Wimplicit-fallthrough
       -Wunused
diff --git a/sample/cmake/SampleDependencies.cmake b/sample/cmake/SampleDependencies.cmake
index 5e98243..88a7838 100644
--- a/sample/cmake/SampleDependencies.cmake
+++ b/sample/cmake/SampleDependencies.cmake
@@ -26,8 +26,8 @@ option(MUJOCO_SAMPLES_USE_SYSTEM_MUJOCO "Use installed MuJoCo version."
 )
 unset(DEFAULT_USE_SYSTEM_MUJOCO)
 
-option(MUJOCO_SAMPLES_USE_SYSTEM_MUJOCO "Use installed MuJoCo version." OFF)
-option(MUJOCO_SAMPLES_USE_SYSTEM_GLFW "Use installed GLFW version." OFF)
+option(MUJOCO_SAMPLES_USE_SYSTEM_MUJOCO "Use installed MuJoCo version." ON)
+option(MUJOCO_SAMPLES_USE_SYSTEM_GLFW "Use installed GLFW version." ON)
 
 set(MUJOCO_DEP_VERSION_glfw3
     7482de6071d21db77a7236155da44c172a7f6c9e # 3.3.8
@@ -59,7 +59,7 @@ findorfetch(
 )
 
 option(MUJOCO_EXTRAS_STATIC_GLFW
-       "Link MuJoCo sample apps and simulate libraries against GLFW statically." ON
+       "Link MuJoCo sample apps and simulate libraries against GLFW statically." OFF
 )
 if(MUJOCO_EXTRAS_STATIC_GLFW)
   set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})
diff --git a/simulate/CMakeLists.txt b/simulate/CMakeLists.txt
index 2358ef7..25e50e3 100644
--- a/simulate/CMakeLists.txt
+++ b/simulate/CMakeLists.txt
@@ -80,6 +80,7 @@ if(MUJOCO_HARDEN)
 endif()
 
 # Fetch lodepng dependency.
+find_package(lodepng REQUIRED)
 if(NOT TARGET lodepng)
   FetchContent_Declare(
     lodepng
diff --git a/simulate/cmake/SimulateDependencies.cmake b/simulate/cmake/SimulateDependencies.cmake
index fa539c2..eb0b95a 100644
--- a/simulate/cmake/SimulateDependencies.cmake
+++ b/simulate/cmake/SimulateDependencies.cmake
@@ -22,12 +22,12 @@ else()
 endif()
 
 option(MUJOCO_SIMULATE_USE_SYSTEM_MUJOCO "Use installed MuJoCo version."
-       ${DEFAULT_USE_SYSTEM_MUJOCO}
+       ON
 )
 unset(DEFAULT_USE_SYSTEM_MUJOCO)
 
-option(MUJOCO_SIMULATE_USE_SYSTEM_MUJOCO "Use installed MuJoCo version." OFF)
-option(MUJOCO_SIMULATE_USE_SYSTEM_GLFW "Use installed GLFW version." OFF)
+option(MUJOCO_SIMULATE_USE_SYSTEM_MUJOCO "Use installed MuJoCo version." ON)
+option(MUJOCO_SIMULATE_USE_SYSTEM_GLFW "Use installed GLFW version." ON)
 
 set(MUJOCO_DEP_VERSION_glfw3
     7482de6071d21db77a7236155da44c172a7f6c9e # 3.3.8
@@ -59,7 +59,7 @@ findorfetch(
 )
 
 option(MUJOCO_EXTRAS_STATIC_GLFW
-       "Link MuJoCo sample apps and simulate libraries against GLFW statically." ON
+       "Link MuJoCo sample apps and simulate libraries against GLFW statically." OFF
 )
 if(MUJOCO_EXTRAS_STATIC_GLFW)
   set(BUILD_SHARED_LIBS_OLD ${BUILD_SHARED_LIBS})