[CMake] cache variable prevents FIND_LIBRARY to be called again :/

Tristan Carel tristan.carel at gmail.com
Wed Nov 1 16:32:16 EST 2006


On 11/1/06, Brad King <brad.king at kitware.com> wrote:
> Tristan Carel wrote:
> > Hi,
> >
> > The documentation of `FIND_LIBRARY' specify:
> > "Once one of these calls succeeds the result variable will be set and
> > stored in the cache so that neither call will search again."
> >
> > Is there a way to avoid this behavior? I've got a FIND_LIBRARY whose
> > search locations depends of the result of a EXECUTE_PROCESS so this
> > FIND_LIBRARY needs to be performed each time I run `configure'.
> >
> > Is there a way to remove an entry from the cache?
>
> It doesn't have to be removed from the cache.  The command should just
> not see the value loaded from it:
>
> SET(MYLIB)
> FIND_LIBRARY(MYLIB ...)

It doesn't seem to work, the cache value is not updated.

Here is more details about my problem.
--------------------------------------------------
FIND_EXECUTABLE(PYTHON_EXECUTABLE python)

# store version of PYTHON_EXECUTABLE in `PythonLibs_version'
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c ...
  OUTPUT_VARIABLE PythonLibs_version)
# ask PYTHON_EXECUTABLE where is the library dir and store it in
`PythonLibs_libdir'
EXECUTE_PROCESS(COMMAND ${PYTHON_EXECUTABLE} -c ...
  OUTPUT_VARIABLE PythonLibs_libdir)
MESSAGE(STATUS "
PythonLibs_libdir: ${PythonLibs_libdir}
PythonLibs_version: ${PythonLibs_library_suffix}")

SET(PYTHON_LIBRARIES)
FIND_LIBRARY(PYTHON_LIBRARIES python${PythonLibs_version}
  PATHS ${PythonLibs_libdir} NO_DEFAULT_PATH)
MESSAGE(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
--------------------------------------------------

Now the use case, made on Windows with CMake 2.4.3

$ cmake --version
cmake version 2.4-patch 3
$ cmake ../../
[...] // checking compiler ...
--
PythonLibs_libdir: C:\Python24/Libs
PythonLibs_version: 24
--
PYTHON_LIBRARIES: C:/Python24/libs/python24.lib
-- Configuring done
-- Generating done
-- Build files have been written to:
P:/)(*#(*&%/trunk/config/cmake/test-python/build/vc6

$ echo "everything is fine. now let's try with python 2.5"
$ cmake -DPYTHON_EXECUTABLE="c:/python25/python.exe" ../..
--
PythonLibs_libdir: c:\Python25/Libs
PythonLibs_version: 25
--
PYTHON_LIBRARIES: C:/Python24/libs/python24.lib
-- Configuring done
-- Generating done
-- Build files have been written to:
P:/)(*#(*&%/trunk/config/cmake/test-python/_build/vc6
$ echo Arf :/

The behavior is the same on the cvs.
-- 
Tristan Carel
Music with dinner is an insult both to the cook and the violinist.


More information about the CMake mailing list