aboutsummaryrefslogtreecommitdiffstats
path: root/sources/shiboken6/libshiboken/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'sources/shiboken6/libshiboken/CMakeLists.txt')
-rw-r--r--sources/shiboken6/libshiboken/CMakeLists.txt141
1 files changed, 93 insertions, 48 deletions
diff --git a/sources/shiboken6/libshiboken/CMakeLists.txt b/sources/shiboken6/libshiboken/CMakeLists.txt
index 444fd8ce2..b5bbb498a 100644
--- a/sources/shiboken6/libshiboken/CMakeLists.txt
+++ b/sources/shiboken6/libshiboken/CMakeLists.txt
@@ -1,21 +1,7 @@
-project(libshiboken)
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
-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(STATUS "PYTHON_NUMPY_LOCATION: " ${PYTHON_NUMPY_LOCATION})
-endmacro()
+project(libshiboken)
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)
@@ -29,13 +15,41 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/sbkversion.h.in"
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/embed/signature_bootstrap.py"
"${CMAKE_CURRENT_BINARY_DIR}/embed/signature_bootstrap.py" @ONLY)
+# Variable from enclosing scope.
+list(TRANSFORM shiboken_python_files
+ PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/../shibokenmodule/files.dir/shibokensupport/"
+ OUTPUT_VARIABLE embedded_shiboken_files)
+
+if (QUIET_BUILD)
+ set(embedding_option "--quiet")
+else()
+ set(embedding_option "")
+endif()
+
+if(SHIBOKEN_IS_CROSS_BUILD)
+ set(host_python_path "${QFP_PYTHON_HOST_PATH}")
+ set(use_pyc_in_embedding FALSE)
+else()
+ set(host_python_path "${Python_EXECUTABLE}")
+ if(PYTHON_LIMITED_API)
+ set(use_pyc_in_embedding FALSE)
+ else()
+ set(use_pyc_in_embedding TRUE)
+ endif()
+endif()
+
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/embed/signature_bootstrap_inc.h"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/embed/signature_inc.h"
- COMMAND ${PYTHON_EXECUTABLE} -E
+ COMMAND ${host_python_path} -E
"${CMAKE_CURRENT_SOURCE_DIR}/embed/embedding_generator.py"
--cmake-dir "${CMAKE_CURRENT_BINARY_DIR}/embed"
- --limited-api ${PYTHON_LIMITED_API})
+ --use-pyc ${use_pyc_in_embedding}
+ ${embedding_option}
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/embed/embedding_generator.py"
+ "${CMAKE_CURRENT_SOURCE_DIR}/embed/signature_bootstrap.py"
+ ${embedded_shiboken_files}
+ )
set(libshiboken_MAJOR_VERSION ${shiboken_MAJOR_VERSION})
set(libshiboken_MINOR_VERSION ${shiboken_MINOR_VERSION})
@@ -44,39 +58,49 @@ set(libshiboken_VERSION "${libshiboken_MAJOR_VERSION}.${libshiboken_MINOR_VERSIO
set(libshiboken_SOVERSION "${shiboken6_library_so_version}")
set(libshiboken_SRC
-basewrapper.cpp
-debugfreehook.cpp
-gilstate.cpp
-helper.cpp
-sbkarrayconverter.cpp
-sbkconverter.cpp
-sbkenum.cpp
-sbkmodule.cpp
-sbkstring.cpp
-sbkstaticstrings.cpp
-bindingmanager.cpp
-threadstatesaver.cpp
-shibokenbuffer.cpp
-pep384impl.cpp
-voidptr.cpp
-bufferprocs_py37.cpp
+autodecref.h
+basewrapper.cpp basewrapper.h basewrapper_p.h
+bindingmanager.cpp bindingmanager.h
+bufferprocs_py37.cpp bufferprocs_py37.h
+debugfreehook.cpp debugfreehook.h
+gilstate.cpp gilstate.h
+helper.cpp helper.h
+pep384impl.cpp pep384impl.h
+pyobjectholder.h
+sbkarrayconverter.cpp sbkarrayconverter.h sbkarrayconverter_p.h
+sbkcontainer.cpp sbkcontainer.h
+sbkconverter.cpp sbkconverter.h sbkconverter_p.h
+sbkcppstring.cpp sbkcppstring.h sbkcpptonumpy.h
+sbkenum.cpp sbkenum.h
+sbkerrors.cpp sbkerrors.h
+sbkfeature_base.cpp sbkfeature_base.h
+sbkmodule.cpp sbkmodule.h
+sbknumpy.cpp sbknumpycheck.h
+sbknumpyview.h
+sbkpython.h
+sbksmartpointer.cpp sbksmartpointer.h
+sbkstaticstrings.cpp sbkstaticstrings.h sbkstaticstrings_p.h
+sbkstring.cpp sbkstring.h
+sbktypefactory.cpp sbktypefactory.h
+sbkwindows.h
+shiboken.h
+shibokenbuffer.cpp shibokenbuffer.h
+shibokenmacros.h
+threadstatesaver.cpp threadstatesaver.h
+voidptr.cpp voidptr.h
embed/signature_bootstrap_inc.h
embed/signature_inc.h
-signature/signature.cpp
+signature/signature.cpp signature.h signature_p.h
signature/signature_globals.cpp
signature/signature_extend.cpp
signature/signature_helper.cpp
)
-get_numpy_location()
-
-if (NOT "${PYTHON_NUMPY_LOCATION}" STREQUAL "")
- list(APPEND libshiboken_SRC sbknumpyarrayconverter.cpp)
-endif()
-
-set(APIEXTRACTOR_EXTRA_INCLUDES ${APIEXTRACTOR_EXTRA_INCLUDES} ${LIBXSLT_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR})
+# This is needed to let the header obey a variable in "pep384impl.h".
+# Note: This must be set on the cpp file!
+set_property(SOURCE "pep384impl.cpp" PROPERTY SKIP_UNITY_BUILD_INCLUSION ON)
add_library(libshiboken SHARED ${libshiboken_SRC})
add_library(Shiboken6::libshiboken ALIAS libshiboken)
@@ -87,11 +111,17 @@ target_include_directories(libshiboken PUBLIC
$<INSTALL_INTERFACE:include/shiboken6>
)
-if (NOT "${PYTHON_NUMPY_LOCATION}" STREQUAL "")
- target_include_directories(libshiboken PRIVATE ${PYTHON_NUMPY_LOCATION}/core/include)
+if (NOT "${NUMPY_INCLUDE_DIR}" STREQUAL "")
+ message(STATUS "NUMPY_INCLUDE_DIR: " ${NUMPY_INCLUDE_DIR})
+ target_include_directories(libshiboken PRIVATE ${NUMPY_INCLUDE_DIR})
target_compile_definitions(libshiboken PRIVATE -DHAVE_NUMPY
PRIVATE -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
+else()
+ message(STATUS "NUMPY not found")
+endif()
+if(SHIBOKEN_IS_CROSS_BUILD)
+ target_compile_definitions(libshiboken PRIVATE -DSHIBOKEN_NO_EMBEDDING_PYC=1)
endif()
shiboken_compute_python_includes()
@@ -101,7 +131,7 @@ shiboken_compute_python_includes()
shiboken_compute_python_libraries()
if(PYTHON_LIMITED_API)
- target_compile_definitions(libshiboken PUBLIC "-DPy_LIMITED_API=0x03050000")
+ target_compile_definitions(libshiboken PUBLIC "-DPy_LIMITED_API=0x03060000")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
@@ -120,30 +150,45 @@ set_target_properties(libshiboken PROPERTIES OUTPUT_NAME "shiboken6${shiboken6_S
SOVERSION ${libshiboken_SOVERSION}
DEFINE_SYMBOL BUILD_LIBSHIBOKEN)
+qfp_strip_library("libshiboken")
+
install(FILES
autodecref.h
basewrapper.h
+ basewrapper_p.h
bindingmanager.h
gilstate.h
helper.h
+ pyobjectholder.h
sbkarrayconverter.h
+ sbkcontainer.h
sbkconverter.h
+ sbkcpptonumpy.h
sbkenum.h
+ sbkerrors.h
+ sbkfeature_base.h
sbkmodule.h
+ sbknumpycheck.h
+ sbknumpyview.h
sbkstring.h
+ sbkcppstring.h
+ sbksmartpointer.h
sbkstaticstrings.h
+ sbktypefactory.h
shiboken.h
shibokenmacros.h
threadstatesaver.h
shibokenbuffer.h
sbkpython.h
+ sbkwindows.h
pep384impl.h
+ pep384ext.h
voidptr.h
bufferprocs_py37.h
"${CMAKE_CURRENT_BINARY_DIR}/sbkversion.h"
signature.h
- signature/signature_p.h
+ signature_p.h
DESTINATION include/shiboken6${shiboken6_SUFFIX})
install(TARGETS libshiboken EXPORT Shiboken6Targets
@@ -151,4 +196,4 @@ install(TARGETS libshiboken EXPORT Shiboken6Targets
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}"
RUNTIME DESTINATION bin)
install(EXPORT Shiboken6Targets NAMESPACE Shiboken6::
- DESTINATION ${LIB_INSTALL_DIR}/cmake/Shiboken6-${shiboken6_VERSION})
+ DESTINATION ${LIB_INSTALL_DIR}/cmake/Shiboken6)