cmakeopenvdb

Is it possible to tell CMake to use `CONFIG` search procedure in `MODULE` mode to be able to find OpenVDB?


OpenVDB provides a FindOpenVDB.cmake file, but unfortunately no OpenVDBConfig.cmake. The FindOpenVDB.cmake file can only be found in the MODULE mode of find_package. However, that mode only considers the directories in CMAKE_MODULE_PATH, which does not contain the path to the OpenVDB CMake files.

Would MODULE mode use the same search procedure as CONFIG mode, it would be able to find FindOpenVDB.cmake, since when running in CONFIG mode the debug logs show that the directory where FindOpenVDB.cmake is located is considered.

Is it possible to tell find_package to use the CONFIG search procedure in MODULE mode as well?


Solution

  • Is it possible to tell find_package to use the CONFIG search procedure in MODULE mode as well?

    I don't think that such way exists. It would contradict to the purposes of Config and Find scripts described in CMake documentation.

    A 'Find' script should be among the sources of the consumer project, which wants to use find_package. (Some of these scripts are shipped with CMake itself). The purpose of this script is to locate required package on the build machine, and fill some variables/IMPORTED targets with the package artifacts.

    A 'Config' script is provided by the package's installation. The script should provide information about the particular package installation to which the script belongs to. CMake (via find_package) allows a consumer project to locate such scripts on the build machine and execute them.

    That is, if you want to use FindOpenVDB.cmake in your project, you should copy that file to your project's sources and adjust variable CMAKE_MODULE_PATH in your CMakeLists.txt.

    Installing of FindOpenVDB.cmake by OpenVDB project is deficiency of that project. You may fill a bugreport to their tracker. If they want to install a script, then it should be a 'Config' script, with appropriate name and content.