Portable way to find out INCLUDE,LIBS,CXXFLAGS,LDFLAGS - how to compile my program on foreign systems?

(By dev package I mean the OpenCV source code, compiled locally).

Ceres et al are present (at /usr/lib64), it was installed manually by me. Eigen3 was installed by Fedora’s dnf. LD_LIBRARY_PATH includes these paths. OpenCV was installed by downloading sources (v4.5.5 from official location). It discovered all these libraries during compilation. Eigen3Config.cmake resides in /usr/share/cmake CeresConfig.cmake in /usr/lib64/cmake/Ceres/.

cmake was installed using the package manager (dnf). Does OpenCV tries and install its own version of cmake ? (sometimes fedora packages are a version behind the most recent one). If yes, then this is a problem.

But let’s assume for a minute that this is a misconfiguration of my system.

I need to find OpenCV’s include dir (above cmake script provides that) and also library path (it does not seem there is a variable to contain that info in OpenCVConfig.cmake) and libraries to be linked. The reason for this is that I am writing a Perl module which will use OpenCV library calls. Perl has its own Makefile and all I need are the -I... -L... -l ... flags to link to OpenCV libs via this Makefile.