Relative header paths in the CMake config
When using MuJoCo by including it as a git submodule and including it into the build configuration via add_subdirectory I ran into the issue that cmake --install . would stop to function because a MuJoCo header could not be found:
CMake Error at cmake_install.cmake:61 (file):
file INSTALL cannot find
"/Users/jonas/my_project_dir/include/mujoco/mjdata.h": No such
file or directory.
The actual path should be /Users/jonas/my_project_dir/external/mujoco/include/mujoco/mjdata.h.
I fixed this by making the MUJOCO_HEADERS relative to the CMakeLists.txt by using CMAKE_CURRENT_SOURCE_DIR. I'm not sure if it would be a better practice to use CMAKE_CURRENT_PROJECT_DIR in this case but I think it shouldn't make a difference in the end because the current project (mujoco) is defined in the same CMakeLists.txt. A priori this change should not have any side effects when not building mujoco as a subdirectory but standalone and a posteriori it still built and installed fine when used standalone.
PS: For the same use case (using MuJoCo as a subdirectory) it would also be great if the cmake --install behavior could be completely disabled through e.g. a flag. I tried to turn it off using EXCLUDE_FROM_ALL but that didn't have an effect.