I haven't done anything similar with groovy, but I think it should work more-or-less the same, since it's all CMake based. When I wanted to install OpenCV with CUDA, I did the process below. Note: I am a novice at building with CMake, so there are probably better ways of doing this.
Install OpenCV to a specific directory following the instructions on their website.
Create a CMakeModule folder within your working program directory, find a version of FindOpenCV.cmake to copy into that folder, then specify the path to OpenCV by adding the line:
set(OpenCV_DIR "/directory/to/opencv2")
In your program's CMake file, add:
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${PROJECT_SOURCE_DIR}/CMakeModules/")
find_package(OpenCV REQUIRED)
include_directories(${OpenCV_INCLUDE_DIRS})
add_definitions(${OpenCV_DEFINITIONS})
MESSAGE(STATUS "OpenCV at: ${OpenCV_INCLUDE_DIRS}")
more code
target_link_libraries(executable_name ${OpenCV_LIBRARIES})
There might be some specifics that are incorrect, but I think the general idea should work.