[CMake] XXX_DIR

Fernando Cacciola fernando.cacciola at gmail.com
Tue Feb 19 09:23:18 EST 2008


Hi people,

According to my experiments in 2.4.7, XXX_DIR seems rather special.

Consider a CMakeLists.txt containing just "find_package(XYZ)"

Run "cmake ."

You'll see the error:

CMake Error: XYZ_DIR is not set.  It must be set to the directory containing
XYZConfig.cmake in order to use XYZ.

Define the enviroment variable to the folder containing the CMakeLists.txt 
file,
for intance:

export XYZ_DIR=.

Run "cmake ." again.

You'll see the same error.

You could think that this is because XYZ_DIR is
defined as a enviroment variable instead of a cmake variable.
Let's see.

Add an empty file named "XYZConfig.cmake" in the folder pointed to by 
XYZ_DIR.
Run "cmake. " again

Now you'll see that it works! Which means that cmake used the enviroment
variable XYZ_DIR.

Change XYZ_DIR to point somwehre else.
Delete CMakeCache.txt
Run "cmake ." again.

Now you'll see the same "XYZ_DIR is not set" error as before, which suggests
that the enviroment variable is recognized only if it points to 
XYZConfig.cmake

Delete CMakeCache.txt again
Run "cmake -DZYZ_DIR=wrong_folder ."

You'll see the error:

CMake Error: XYZ_DIR is set to "wrong_folder", which is not a directory
containing XYZConfig.cmake

Which shows that if XYZ_DIR is passed as a cmake is it consistently used 
(unlike
the case of an enviroment variable which seems to be used only if it points 
to
the right folder)

Furthermore, if you look at the cache at each step above, you'll see that 
when
XYZ_DIR is passed as a cmake variable is not stored in the cache, while when 
it
is passed as an enviroment variable it is (either with a XYZ_DIR-NOITFOUND 
value
or the correct folder value)


Can you clarify the details of this variable?
Is it true that it can be a enviroment variable but it must point to the 
right folder?
Is it true that if it is a an enviroment variable it is stored in the cache, 
but not if set in the command line?
Can it be stored in the cache if passed in the command line?

TIA


-- 
Fernando Cacciola
SciSoft
http://fcacciola.50webs.com
http://groups.google.com/group/cppba





More information about the CMake mailing list