You can install ROS melodic using a portage overlay. However, I was having a hard time compiling against the Eigen libraries. I fixed it by setting two variables
CMAKE_PREFIX_PATH=/usr:/opt/ros/melodic
CATKIN_PREFIX_PATH=/usr:/opt/ros/melodic
Since Eigen and OpenCV aren't installed alongside ROS on gentoo, you have to point to the system versions of these first. So putting /usr
first prefers the system versions over the ones installed with ROS.