Minimales Mujoco CMake-Build-Beispiel
Minimales Mujoco CMake-Build-Beispiel mit GLFW3
Dies ist ein minimales Beispiel, wie man eine Mujoco-Anwendung mit CMake und GLFW3 baut, d.h. mit grafischer Oberfläche.
CMakeLists.txt
cmake_minimum_required(VERSION 3.10)
project(mujocotest)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(PkgConfig REQUIRED)
pkg_search_module(MUJOCO mujoco)
pkg_search_module(GLFW REQUIRED glfw3)
if(NOT MUJOCO_FOUND)
set(MUJOCO_INCLUDE_DIRS /opt/mujoco/include)
set(MUJOCO_LIBRARIES /opt/mujoco/lib/libmujoco.so)
endif()
add_executable(mujocotest main.cpp)
target_include_directories(mujocotest PRIVATE ${MUJOCO_INCLUDE_DIRS} ${GLFW_INCLUDE_DIRS})
target_link_libraries(mujocotest PRIVATE ${MUJOCO_LIBRARIES} ${GLFW_LIBRARIES})Minimales Mujoco CMake-Build-Beispiel ohne GLFW3
Dies ist nützlich, wenn Sie eine Mujoco-Anwendung ohne grafische Oberfläche bauen möchten, z.B. für die Ausführung auf einem Server.
CMakeLists_no_glfw.txt
cmake_minimum_required(VERSION 3.10)
project(mujocotest)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(PkgConfig REQUIRED)
pkg_search_module(MUJOCO mujoco)
if(NOT MUJOCO_FOUND)
set(MUJOCO_INCLUDE_DIRS /opt/mujoco/include)
set(MUJOCO_LIBRARIES /opt/mujoco/lib/libmujoco.so)
endif()
add_executable(mujocotest main.cpp)
target_include_directories(mujocotest PRIVATE ${MUJOCO_INCLUDE_DIRS})
target_link_libraries(mujocotest PRIVATE ${MUJOCO_LIBRARIES})If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow