Skip to content

Commit cd6d589

Browse files
committed
fix: mujoco not found in make commands
1 parent d85f584 commit cd6d589

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

cmake/FindMuJoCo.cmake

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,47 @@ 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+
ERROR_VARIABLE MUJOCO_PYTHON_ERROR
15+
RESULT_VARIABLE MUJOCO_PYTHON_RESULT
16+
OUTPUT_STRIP_TRAILING_WHITESPACE
17+
)
18+
19+
if (MUJOCO_PYTHON_RESULT)
20+
message(STATUS "Python command failed with result: ${MUJOCO_PYTHON_RESULT}")
21+
message(STATUS "Python command stderr: ${MUJOCO_PYTHON_ERROR}")
22+
endif()
23+
24+
if (NOT MUJOCO_PATH)
25+
set(MuJoCo_FOUND FALSE)
26+
if (MuJoCo_FIND_REQUIRED)
27+
message(FATAL_ERROR "Could not find MuJoCo. MUJOCO_PATH is empty. Python command output: '${MUJOCO_PATH}'. Python command error: '${MUJOCO_PYTHON_ERROR}'. Please install MuJoCo using pip 2.")
28+
endif()
29+
return()
30+
endif()
31+
32+
set(MuJoCo_INCLUDE_DIRS "${MUJOCO_PATH}/include")
1233
if (NOT EXISTS ${MuJoCo_INCLUDE_DIRS})
1334
set(MuJoCo_FOUND FALSE)
1435
if (MuJoCo_FIND_REQUIRED)
15-
message(FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip.")
36+
message(FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip 3.")
1637
endif()
1738
return()
1839
endif()
1940

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.*")
41+
file(GLOB mujoco_library_path "${MUJOCO_PATH}/libmujoco.so.*")
2342
if (NOT mujoco_library_path)
2443
set(MuJoCo_FOUND FALSE)
2544
if (MuJoCo_FIND_REQUIRED)
26-
message(FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip.")
45+
message(FATAL_ERROR "Could not find MuJoCo. Please install MuJoCo using pip 4.")
2746
endif()
2847
return()
2948
endif()

0 commit comments

Comments
 (0)