[CMake] Variable availability from the FindXXX modules

Hendrik Sattler post at hendrik-sattler.de
Fri Jun 12 15:46:45 EDT 2009


Am Freitag 12 Juni 2009 21:29:00 schrieb Tyler Roscoe:
> On Fri, Jun 12, 2009 at 02:42:28PM -0400, Michael Jackson wrote:
> > think is a kludge to get it to work. In my top level CMakeLists.txt
> > file I "include" another CMake file which calls another project via
> > add_subdirectory(). With in that last call is a call to "FindBoost"
> > which goes just fine. Now work our way all the way back to the top of
> > the CMake file hierarchy and when I do "message(STATUS
> > "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}") I get an empty statement.
>
> When you do add_subdirectory(), you create a new scope. The Boost
> variables are only defined in that scope, which is why you can't see
> them from your top-level CMakeLists.
>
> >     I had to put in another call to:
> > FIND_PACKAGE(Boost 1.36 COMPONENTS )
> > INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
> > message (STATUS "Boost_INCLUDE_DIRS: ${Boost_INCLUDE_DIRS}")
> >
> > and now I get the proper print out. So effectively I have called
> > FindBoost at least twice. Would something like this be normal?

No. The most work like finding the files are globally cached values. The other 
variables are supposed to be uncached and are derived from the cached values. 
Thus, only a small part of the actual work is repeated.

HS



More information about the CMake mailing list