[cmake-developers] Function overrides

Wojciech Knapik wmknapik at gmail.com
Thu May 30 11:14:37 EDT 2013


Hi

I want to write several self-contained modules that would each hijack a
standard CMake function in order to execute some CMake code when
necessary, without requiring the user to alter their existing
CMakeLists.

The idea is that including the module will provide functionality with no
other actions required.

The problem is, that you can't redefine, say, add_executable more than
once, as discussed here:
http://www.cmake.org/pipermail/cmake/2011-March/043320.html

Is there a way to achieve this, one way, or another ?

I actually have two use cases here - one is where I want to redefine
add_executable/add_library specifically and the other is where I don't
really want to redefine anything, but I need to execute a piece of code
in every CMakeList in the project.

thanks,
WK

PS. I know you can achieve this by providing a wrapper for the user to
use instead of the standard function, but that's not nearly as nice, is
it ?



More information about the cmake-developers mailing list