[CMake] Is there a default value for CMAKE_MODULE_PATH?

Matthew Woehlke mwoehlke.floss at gmail.com
Wed Nov 16 13:37:16 EST 2016


On 2016-11-09 10:05, Jayesh Badwaik wrote:
> Over past few days, Boost has updated from version 1.61 to version 1.62. The 
> latest version of CMake that I have (3.6.3) does not yet have the appropriate 
> FindBoost.cmake and hence, issues warnings as shown in the postscript. 
> 
> As I see this is temporary, and there is a correct FindBoost.cmake in the git 
> repository which works fine. So, I want to use this new module file till the 
> time when the new version of CMake comes out and I won't have to use this 
> special file anymore.
> 
> All the solutions that I have found on internet require me to put a line 
> setting the CMAKE_MODULE_PATH in my project source code. I don't want to do it 
> since the change is supposed to be temporary anyway. So, I was wondering if 
> there is a location inside the PROJECT_SOURCE_DIR which is scanned by default 
> by cmake?
> 
> If there is no such location, I can live with the warnings for a little while, 
> but I was just curious.

I don't think you can avoid setting CMAKE_MODULE_PATH. Also, it's only
"temporary" until you bump your cmake_minimum_required.

What I've done in some projects is include the module in a directory
named after the version of CMake that will include the updated version.
You can then iterate over such directories and compare the name to the
CMake version to decide whether or not to add that directory. This way
someone with new enough CMake to not need the module will use the
built-in version, while someone with older CMake will get your copy.

-- 
Matthew



More information about the CMake mailing list