[cmake-developers] [CMake 0014850]: Overriding function with a macro should either be turned off or usefull.

Mantis Bug Tracker mantis at public.kitware.com
Sun Mar 30 11:42:06 EDT 2014


The following issue has been SUBMITTED. 
====================================================================== 
http://www.cmake.org/Bug/view.php?id=14850 
====================================================================== 
Reported By:                toeb
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   14850
Category:                   CMake
Reproducibility:            have not tried
Severity:                   feature
Priority:                   normal
Status:                     new
====================================================================== 
Date Submitted:             2014-03-30 11:42 EDT
Last Modified:              2014-03-30 11:42 EDT
====================================================================== 
Summary:                    Overriding function with a macro should either be
turned off or usefull.
Description: 
consider the following code valid cmake code which currently fails at execution:
macro(function)
 _function(${ARGN}
 message("function called: ${ARGN})
endmacro()

function(test_func)

endfunction()
test_func()

this fails because _function does not have a corresponding end_function()

It would be very cool however if the behaviour could be changed for this special
case (also redefining end_function or all commands that are of begin() end()
form) or more generally allowing begin/end constructs to span through macros
(maybe with a policy? or an extra function?) 

it would allow for very cool tricks and would almost certainly not break any
existing cmake projects

with this single feature cmake could be extended by clean object oriented
programming paradigms, it would allow hierarchical logging, and aspect oriented
programming paradigms as well. 

In my case I want to do the following (return value):
macro(return)
 set(__result ${ARGN} PARENT_SCOPE)
 _return()
endmacro()
function(tmp_fu)
  return(hello)
endfunction()
function(tmp_fu2)

endfunction()
tmp_fu()
message(${__result})
tmp_fu2()
# result is still the same as before because it is not cleared when function is
called. 
# what would help is this redefinition for function (which does not work):
# because it would execute set(__result PARENT_SCOPE) before every function
execution
macro(function)
 _function($ARGN)
 set(__result PARENT_SCOPE)
endmacro()




I have already implemented Object oriented cmake
(https://github.com/toeb/oo-cmake) - the documentation is currently a bit off
(it is much more powerfull already) but this one limitation is missing to make
oo-cmake a almost lean oo-programming language.

tell me if this makes sense to you




====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2014-03-30 11:42 toeb           New Issue                                    
======================================================================



More information about the cmake-developers mailing list