I have a CMake project that generates a library. I have written a CMake script, FindXXX.cmake, to help users of my library. This way they can use find_package(XXX) and get the variables needed. So far so good.
The problem now is that users have copied this FindXXX.cmake into their own projects. If I modify it, they will just stick with the former one.
Is there a common way to distribute such a script? Should my installer put it in some special location so that CMake finds it without having users copying it in their project?
Try to copy to
${CMAKE_ROOT}/Modules. You may need system administrator rights.Another solution could be add some registry entry on Windows:
HKEY_CURRENT_USER\Software\Kitware\CMakeSetup\Settings\StartPath. You should add the nextWhereBuild{i}value to your project CMake files. The trick here is that the CMake search for known libraries from the previously-used libraries.Based on the suggested documentation:
You should create the following library and copy FindProjectName.cmake:
C:\Program Files\ProjectName\CMake on Windows, /usr/local/ProjectName/share/cmake on Linux.