On 07/20/2015 12:52 AM, Eric Wing wrote:
> I would like to dynamically construct a macro or function name to
> invoke. I basically have a core CMake system I want users to be able
> to extend/plug stuff into without knowing about a lot of the core
> CMake implementation. Callback functions would be an easy way for me
> to accomplish this.
>
> As an example,
>
> # In my core code, I have a macro designed to callback other macros
> macro(DO_PACKAGE _TARGET_NAME)
> foreach(callback ${DO_PACKAGE_CALLBACK_LIST})
> DO_PACKAGE_FOR_${callback}(${_TARGET_NAME})
> endforeach()
> endmacro(BLURRR_PACKAGE_EXTRAS)
>
>
> ### Also in my core code, I pick an appropriate time to trigger my
> macro to call user callbacks
> DERIVE_SOME_NAME()
> ADD_EXECUTABLE(${SOME_NAME} ...)
> DO_PACKAGE(${SOME_NAME})
>
>
>
> # So in user modules provided by others, they follow a convention where
> # they define a macro DO_PACKAGE_ appended by their module name.
> macro(DO_PACKAGE_FOR_MYMODULE _TARGET_NAME)
> MESSAGE("in mymod callback")
> # do stuff
> endmacro()
>
> # And I make them add their module name to a global list so I can call
> it back at the right time
> list(APPEND DO_PACKAGE_CALLBACK_LIST "MYMODULE")
>
>
> So in my attempts to do this, I'm getting errors like:
> Parse error. Expected a command name, got unquoted argument with text
>
> Is there way to do this (or something similar)?
>
> Thanks,
> Eric
I don't think this functionality is supported (although I haven't
checked if it is possible to redefine a function in cmake). Perhaps you
could create a system where you import a cmake module supplied by the
external developers if it exists? If you can define an interface you
could check if the functions exist in the module?Regards, Micha
signature.asc
Description: OpenPGP digital signature
-- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://public.kitware.com/mailman/listinfo/cmake
