[CMake] User defined variable not propagating into subdirs

Bill Hoffman bill.hoffman at kitware.com
Fri Nov 16 11:31:51 EST 2007

Stephen Collyer wrote:
> Alan W. Irwin wrote:
>> On 2007-11-16 11:49-0000 Stephen Collyer wrote:
>>> I have a top-level cmake list file with this in it:
>>> OPTION (MDP_BUILD_SHARED_LIBS "Build Shared Libraries" ON)
>>>  IF (WIN32)
>>>  ENDIF (WIN32)
>>> In a lower subdirectory, I have this to build a library:
>>> ADD_LIBRARY(Test ${LIB_TYPE} Test.cpp)
>> Bill has already given you a global way to set static or shared libraries,
>> but what caught my eye here is that your LIB_TYPE was not propagating to
>> lower directories as it should.
> Right. I'd actually forgotten that that was my original problem.
>> I successfully use such propagation of variables all the time with
>> ADD_SUBDIRECTORY. Are you using SUBDIRS instead? 
> No, I'm using ADD_SUBDIRECTORY. However, I'm now using an
> preprocessor code lower down the tree, and that is working,
> so my original problem has disappeared. But, yes, I'm concerned
> that something odd is happening with the LIB_TYPE variable as
> I expected it to be available lower down the tree. As I know
> next to nothing about cmake, I can't really offer an explanation
> though.
I think there is some issue with giving cache values without types from 
the command line cmake, this maybe the problem you are seeing.  I think 
this is fixed in CVS CMake.


More information about the CMake mailing list