[CMake] User defined variable not propagating into subdirs
Stephen Collyer
scollyer at netspinner.co.uk
Fri Nov 16 06:49:40 EST 2007
I have a top-level cmake list file with this in it:
OPTION (MDP_BUILD_SHARED_LIBS "Build Shared Libraries" ON)
SET (LIB_TYPE STATIC)
IF (MDP_BUILD_SHARED_LIBS)
SET (LIB_TYPE SHARED)
IF (WIN32)
ADD_DEFINITIONS("-DMDP_BUILD_SHARED_LIBS")
ENDIF (WIN32)
ENDIF (MDP_BUILD_SHARED_LIBS)
In a lower subdirectory, I have this to build a library:
ADD_LIBRARY(Test ${LIB_TYPE} Test.cpp)
the idea being that I can drive the generation of shared/static
libraries via the setting of the MDP_BUILD_SHARED_LIBS setting
which defaults to ON. However if I run cmake in an out-of-source
build from scratch and run a "make all", it seems that LIB_TYPE
is'nt being seen inside the lower subdirs - I've tested this by
adding "SET (LIB_TYPE SHARED)" explicitly to the library cmake
list file, then it build a shared library.
Can someone explain what's going on here. I'm beginning to
tear my hair out.
And for added bonus: is there a cmake log file generated anywhere
so I can see what it thinks it doing ? I can't find one anywhere.
--
Regards
Steve Collyer
Netspinner Ltd
More information about the CMake
mailing list