Pavlyk, Oleksandr
2016-09-27 21:09:59 UTC
Suppose I would like to take advantage of some functions from MKL in numpy C source code, which would require to use
#include "mkl.h"
Ideally this include line must not break the build of numpy when MKL is not present, so my initial approach was to use
#if defined(SCIPY_MKL_H)
#include "mkl.h"
#endif
Unfortunately, this did not work when building with gcc on a machine where MKL is present on default LD_LIBRARY_PATH, because then the distutils code was setting SCIPY_MKL_H preprocessor variable, even though mkl headers are not on the C_INCLUDE_PATH.
What is the preferred solution to include an external library header to ensure that code-base continues to build in most common cases?
One approach I can think of is to set a preprocessor variable, say HAVE_MKL_HEADERS in numpy/core/includes/numpy/config.h depending on an outcome of building of a simple _configtest.c using config.try_compile(), like it is done in numpy/core/setup.py
Is there a simpler, or a better way?
Thank you,
Oleksandr
#include "mkl.h"
Ideally this include line must not break the build of numpy when MKL is not present, so my initial approach was to use
#if defined(SCIPY_MKL_H)
#include "mkl.h"
#endif
Unfortunately, this did not work when building with gcc on a machine where MKL is present on default LD_LIBRARY_PATH, because then the distutils code was setting SCIPY_MKL_H preprocessor variable, even though mkl headers are not on the C_INCLUDE_PATH.
What is the preferred solution to include an external library header to ensure that code-base continues to build in most common cases?
One approach I can think of is to set a preprocessor variable, say HAVE_MKL_HEADERS in numpy/core/includes/numpy/config.h depending on an outcome of building of a simple _configtest.c using config.try_compile(), like it is done in numpy/core/setup.py
Is there a simpler, or a better way?
Thank you,
Oleksandr