View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014850CMakeCMakepublic2014-03-30 11:422016-06-10 14:31
Reportertoeb 
Assigned ToKitware Robot 
PrioritynormalSeverityfeatureReproducibilityhave not tried
StatusclosedResolutionmoved 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0014850: Overriding function with a macro should either be turned off or usefull.
Descriptionconsider 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



TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0042522)
Kitware Robot (administrator)
2016-06-10 14:29

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2014-03-30 11:42 toeb New Issue
2016-06-10 14:29 Kitware Robot Note Added: 0042522
2016-06-10 14:29 Kitware Robot Status new => resolved
2016-06-10 14:29 Kitware Robot Resolution open => moved
2016-06-10 14:29 Kitware Robot Assigned To => Kitware Robot
2016-06-10 14:31 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team