diff options
author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-07-07 10:54:28 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2017-08-03 06:21:19 +0000 |
commit | 58a93d240c5bdd3bc60ccddbc31676bd0fa2eae3 (patch) | |
tree | 18ad59ef9241a444a2605a73d4300cc65d55158c /sources/shiboken2/libshiboken/CMakeLists.txt | |
parent | 1578d14d1693122d4bcacede0d77527d8e898629 (diff) |
Add numpy support
Add simple array converters giving access to NumPy arrays.
Task-number: PYSIDE-354
Task-number: PYSIDE-516
Change-Id: I2446b0f1ef98eaf12df95e4bd0e03d73e0cd7126
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'sources/shiboken2/libshiboken/CMakeLists.txt')
-rw-r--r-- | sources/shiboken2/libshiboken/CMakeLists.txt | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/sources/shiboken2/libshiboken/CMakeLists.txt b/sources/shiboken2/libshiboken/CMakeLists.txt index 3d27e643d..06d6330f5 100644 --- a/sources/shiboken2/libshiboken/CMakeLists.txt +++ b/sources/shiboken2/libshiboken/CMakeLists.txt @@ -1,5 +1,22 @@ project(libshiboken) +macro(get_numpy_location) + execute_process( + COMMAND ${PYTHON_EXECUTABLE} -c "if True: + import sys + import os + numpy = '' + for p in sys.path: + if 'site-' in p: + numpy = os.path.join(p, 'numpy') + if os.path.exists(numpy): + print(os.path.realpath(numpy)) + break" + OUTPUT_VARIABLE PYTHON_NUMPY_LOCATION + OUTPUT_STRIP_TRAILING_WHITESPACE) + message("PYTHON_NUMPY_LOCATION: " ${PYTHON_NUMPY_LOCATION}) +endmacro() + option(ENABLE_VERSION_SUFFIX "Used to use current version in suffix to generated files. This is used to allow multiples versions installed simultaneous." FALSE) if(ENABLE_VERSION_SUFFIX) set(shiboken2_SUFFIX "-${shiboken_MAJOR_VERSION}.${shiboken_MINOR_VERSION}") @@ -32,9 +49,19 @@ typeresolver.cpp shibokenbuffer.cpp ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${SBK_PYTHON_INCLUDE_DIR}) +get_numpy_location() + +set(libshiboken_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${SBK_PYTHON_INCLUDE_DIR}) + +if (NOT "${PYTHON_NUMPY_LOCATION}" STREQUAL "") + set(libshiboken_INCLUDES ${libshiboken_INCLUDES} ${PYTHON_NUMPY_LOCATION}/core/include) + set(libshiboken_SRC ${libshiboken_SRC} sbknumpyarrayconverter.cpp) + add_definitions(-DHAVE_NUMPY -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION) +endif() + +set(APIEXTRACTOR_EXTRA_INCLUDES ${APIEXTRACTOR_EXTRA_INCLUDES} ${LIBXSLT_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR}) + +include_directories(${libshiboken_INCLUDES}) add_library(libshiboken SHARED ${libshiboken_SRC}) target_link_libraries(libshiboken ${SBK_PYTHON_LIBRARIES}) set_target_properties(libshiboken PROPERTIES OUTPUT_NAME "shiboken2${shiboken2_SUFFIX}${PYTHON_SHARED_LIBRARY_SUFFIX}" |