[CMake] Puzzle about CMAKE_MODULE_PATH

Brad King brad.king at kitware.com
Wed Sep 14 13:57:36 EDT 2005


Mark Foskey wrote:
> I'm trying to build SNAP, which is a part of the InsightApplications 
> suite, outside of InsightApplications.  I'm working under Linux.
> 
> To make it easier for ITK and VTK to be found, I set the following 
> environment varibles:
> 
>   ITK_DIR=/afs/radonc/libraries/itk/build
>   VTK_DIR=/afs/radonc/libraries/vtk/build
 >
> I also set a variable so that the SNAP CMakeLists.txt file calls 
> FIND_PACKAGE(ITK) and FIND_PACKAGE(VTK).  Unfortunately, the environment 
> variables are ignored by the package-finding modules -- I get:
> 
>   Cannot build InsightApplications without ITK.  Please set ITK_DIR.

Environment variables are not CMake cache variables.  Setting them is 
useless.  This message is asking you to set ITK_DIR in the cache.  If 
you are running a CMake GUI such as ccmake then the ITK_DIR variable 
should be present but not set after this message appears.

> However, if I put
> 
>    SET( CMAKE_MODULE_PATH "/afs/radonc/pkg/cmake/share/CMake/Modules/" )
> 
> in the SNAP CMakeLists.txt file, both ITK and VTK are found just fine.
> 
> This is mysterious to me.  I think ccmake is finding the Modules 
> directory even without the CMAKE_MODULE_PATH, since it otherwise runs 
> OK, and since the modules directory is findable (via a softlink) as 
> ${CMAKE_ROOT}/Modules.  So why does it behave differently, apparently 
> not using Modules/FindITK.cmake, when CMAKE_MODULE_PATH is not set?

What do you mean by "via a softlink"?  The whole CMake install tree 
should be extracted together in one tree with no symlinks.  Did you 
customize your installation?

FYI, CMAKE_MODULE_PATH is meant as a way for user projects to ADD to the 
set of directories searched for modules by FIND_PACKAGE and INCLUDE. 
The main ${CMAKE_ROOT}/Modules should always be automatically located 
unless CMake is not installed correctly.

-Brad


More information about the CMake mailing list