[CMake] Puzzle about CMAKE_MODULE_PATH
Mark Foskey
mark_foskey at unc.edu
Wed Sep 14 16:00:32 EDT 2005
Brad King wrote:
> 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.
Not in this case, because FindITK.cmake has the lines:
FIND_PATH(ITK_DIR ITKConfig.cmake
# Look for an environment variable ITK_DIR.
$ENV{ITK_DIR}
[...]
so it reads the environment variable when it tries to set the cache
variable of the same name. Sorry I didn't make it clear that I was
trying to make use of that behavior. FindVTK.cmake also does this, and
I really like it, since we have our libraries installed in atypical
places, and it's nice to be able to set a variable once and not have to
find the library in ccmake every time I start a new project. (The issue
is that the standard locations aren't on a central server, and we don't
want to have to install separately on each machine.)
>> 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?
Yes. A 'bin' directory in AFS space has a softlink to the correct
ccmake executable for the given hardware platform, and softlinks to
'Modules' and two other associated directories. Apparently it doesn't
follow the softlink to find the FindFOO.cmake files in Modules. I will
try fixing our setup.
--
Mark Foskey (919) 966-1101 x245 Radiation Oncology, CB 7512
mark_foskey at unc.edu University of North Carolina
http://www.cs.unc.edu/~foskey Chapel Hill, NC 27599-7512
More information about the CMake
mailing list