@@ -2,28 +2,40 @@ if (NOT MuJoCo_FOUND)
22 if (NOT Python3_FOUND)
33 set (MuJoCo_FOUND FALSE )
44 if (MuJoCo_FIND_REQUIRED)
5- message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip." )
5+ message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip 1 ." )
66 endif ()
77 return ()
88 endif ()
99
10- # Check if the include directory exists
11- cmake_path (APPEND Python3_SITELIB mujoco include OUTPUT_VARIABLE MuJoCo_INCLUDE_DIRS )
10+ # Get MuJoCo path from python
11+ execute_process (
12+ COMMAND ${Python3_EXECUTABLE} -c "import mujoco; print(mujoco.__path__[0])"
13+ OUTPUT_VARIABLE MUJOCO_PATH
14+ OUTPUT_STRIP_TRAILING_WHITESPACE
15+ )
16+
17+ if (NOT MUJOCO_PATH)
18+ set (MuJoCo_FOUND FALSE )
19+ if (MuJoCo_FIND_REQUIRED)
20+ message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip 2." )
21+ endif ()
22+ return ()
23+ endif ()
24+
25+ set (MuJoCo_INCLUDE_DIRS "${MUJOCO_PATH} /include" )
1226 if (NOT EXISTS ${MuJoCo_INCLUDE_DIRS} )
1327 set (MuJoCo_FOUND FALSE )
1428 if (MuJoCo_FIND_REQUIRED)
15- message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip." )
29+ message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip 3 ." )
1630 endif ()
1731 return ()
1832 endif ()
1933
20- # Check if the library file exists
21- cmake_path (APPEND Python3_SITELIB mujoco OUTPUT_VARIABLE mujoco_library_path )
22- file (GLOB mujoco_library_path "${mujoco_library_path} /libmujoco.so.*" )
34+ file (GLOB mujoco_library_path "${MUJOCO_PATH} /libmujoco.so.*" )
2335 if (NOT mujoco_library_path)
2436 set (MuJoCo_FOUND FALSE )
2537 if (MuJoCo_FIND_REQUIRED)
26- message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip." )
38+ message (FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip 4 ." )
2739 endif ()
2840 return ()
2941 endif ()
0 commit comments