[CMake] Double redefinition of commands...

Alexander Neundorf a.neundorf-work at gmx.net
Thu May 19 16:14:49 EDT 2011


On Thursday 19 May 2011, Theodore Papadopoulo wrote:
> 	Hello,
> 
> I'm facing with the following problem, I'm using the _XXX trick to
> access the previous version of a command. Unfortunately, this is not
> quite what I need because of a double redefinition of the command.
> 
> Here is a small example of the problem I have:
> 
> PROJECT(Test)
> 
> FUNCTION(FIND_LIBRARY VAR)
>     MESSAGE("HERE 1")
>     _FIND_LIBRARY(${VAR} ${ARGN})
> ENDFUNCTION()
> 
> FIND_LIBRARY(ZLIB z)
> 
> FUNCTION(FIND_LIBRARY VAR)
>     MESSAGE("HERE 2")
>     _FIND_LIBRARY(${VAR} ${ARGN})
> ENDFUNCTION()
> 
> FIND_LIBRARY(GTKLIB gtk)
> 
> In the second call "FIND_LIBRARY(GTKLIB gtk)", _FIND_LIBRARY refers to
> the first definition and the call to that function just loops forever.
> Browsing cmake sources reveals that basically cmake just renames the old
> function XXX into _XXX. If _XXX already exists, it is suppressed (if I
> understood well).

This feature is not very, let's say polished, so yes, it is not perfect as it 
is.
Why do you want do do this ?
How about adding a "my_find_library()", so you don't have to rename it ?
In KDE4 we have KDE4_ADD_EXECUTABLE(), KDE4_ADD_LIBRARY() which add some 
features, and developers who want to make use of this have to use these 
functions.
It works well for us.

Alex


More information about the CMake mailing list