[CMake] if( defined xxx ) does not work as (I) expected
Michael Hufer
Michael.Hufer at swissrisk.com
Wed Oct 25 09:20:06 EDT 2006
Hi all,
I am new to CMake and am currently switching the make system for our X-Gen
product to CMake.
Since the project contains a lot of shared libraries I wrote a macro to ease
the writing of CMakeLists.txt for them. The macro receives a list of
"external" libraries this library depends on. Some of these externals require
extra defines or link flags and I collect them in the macro like this:
---
foreach( EXT ${EXTERNAL_LIBS} )
[...]
if( DEFINED ${EXT}_DEFINES )
set( EXT_DEFINES "${EXT_DEFINES} ${${EXT}_DEFINES}" )
endif( DEFINED ${EXT}_DEFINES )
[...]
endforeach( EXT ${EXTERNAL_LIBS} )
[...]
if( DEFINED EXT_DEFINES )
set_source_files_properties( $MODULE_SOURCES} PROPERTIES COMPILE_FLAGS
${EXT_DEFINES} )
endif( DEFINED EXT_DEFINES )
---
(the macro is defined in cmake/XGen-Macros.cmake in the attached zip-file).
while the first 'if(defined ${EXT}_DEFINES)' works as expected the second
'if( DEFINED EXT_DEFINES )' where I check if actually any of the 'externals'
for this library needs extra defines is always false even if the message()
inserted before reports that this variable is in fact defined and shows its
value.
The handling of extra link flags is identical and there also the first
'if-defined' works as expected but the second does not...
I checked and double checked the macrocode, inserted debug messages etc. and
don't see any obvious errors.
So what am I doing wrong or did I actually find a bug in cmake?
Cheers,
Micha.
--
Michael Hufer | EMail: mailto:Michael.Hufer at swissrisk.com
Software Developer | WWW: http://www.swissrisk.com
SWISSRISK AG | Phone: ++49 69 50952 - 0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cmake-bug.zip
Type: application/x-zip
Size: 12874 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20061025/7855c7ca/cmake-bug.bin
More information about the CMake
mailing list