Wrapper tool preprocessor symbols for cross-compilation
VTK relies on KWIML to elucidate platform details from pre-defined preprocessor symbols. In order for the wrapper tools (vtkWrapPython, vtkWrapHierarchy, etc) to function accurately,
- they must predefine all the preprocessor symbols that KWIML needs for the current platform
- KWIML's headers must be in the include path when the wrapper tools execute
Currently, the AddStandardMacros()
function in vtkParsePreprocess.c
defines the preprocessor symbols that were defined when vtkParsePreprocess.c itself was compiled. This works well for native compilation, but some symbols are expected to be incorrect for cross-compilation. So far there haven't been any noted cross-compilation failures, but as VTK becomes more and more reliant on KWIML, failures seem inevitable.
For cross-compilation (and perhaps native compilation), it would be nice if we could generate a header that defines the needed symbols, and then tell the wrapper tools to process that header before processing any other code.
Such a header can be generated easily with either clang or gcc and an empty source file:
clang++ -o predefines.h [options] -dM -E empty.cxx
g++ -o predefines.h [options] -dD -E empty.cxx
We can add an option to the wrapper tools to accept this header:
vtkWrapPython -include predefines.h [other options]
As an example, the output for Apple clang starts as follows:
#define OBJC_NEW_PROPERTIES 1
#define _LP64 1
#define __APPLE_CC__ 6000
#define __APPLE__ 1
If people doing cross-compiles are willing to manually generate "predefines.h", we can simply add an optional cmake setting that will accept the path to that header.
VTK_WRAP_PREDEFINES=/path/to/predefines.h
Addendum: the wrapper tools should also predefine the following, even if only dummy values are used:
__DATE__
__TIME__
__FILE__
__LINE__