comparison mupdf-source/thirdparty/zxing-cpp/wrappers/python/CMakeLists.txt @ 2:b50eed0cc0ef upstream

ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4. The directory name has changed: no version number in the expanded directory now.
author Franz Glasner <fzglas.hg@dom66.de>
date Mon, 15 Sep 2025 11:43:07 +0200
parents
children
comparison
equal deleted inserted replaced
1:1d09e1dec1d9 2:b50eed0cc0ef
1 cmake_minimum_required(VERSION 3.18)
2 project(ZXingPython)
3
4 # check if we are called from the top-level ZXing project
5 get_directory_property(hasParent PARENT_DIRECTORY)
6 if (NOT hasParent)
7 # Build with C++20 by default (which enables position independent DataMatrix detection).
8 set(CMAKE_CXX_STANDARD 20)
9 set(CMAKE_CXX_EXTENSIONS OFF)
10 # Allow the fallback to earlier versions if the compiler does not support it.
11 set(CMAKE_CXX_STANDARD_REQUIRED OFF)
12
13 option (BUILD_SHARED_LIBS "Link python module to shared lib" OFF)
14 option (ZXING_READERS "Build with reader support (decoders)" ON)
15 set (ZXING_WRITERS "NEW" CACHE STRING "Build with old and/or new writer (encoder) backend (OFF/ON/OLD/NEW)")
16 set (ZXING_DEPENDENCIES "AUTO" CACHE STRING "Fetch from github or use locally installed (AUTO/GITHUB/LOCAL)")
17 option (ZXING_EXPERIMENTAL_API "Build with experimental API" ON)
18 option (ZXING_USE_BUNDLED_ZINT "Use the bundled libzint for barcode creation/generation" ON)
19
20 set(CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/core)
21 if(IS_SYMLINK ${CORE_PATH})
22 # This is needed because otherwise GCC resolves the symlink which causes paths to randomly
23 # be prefixed by /core or by /wrappers/python/core depending on include order.
24 set(CORE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../core)
25 endif()
26
27 if(EXISTS ${CORE_PATH})
28 add_subdirectory(${CORE_PATH} ZXing EXCLUDE_FROM_ALL)
29 include(${CMAKE_CURRENT_SOURCE_DIR}/zxing.cmake)
30 else()
31 message(FATAL_ERROR "Unable to locate zxing source code")
32 endif()
33 endif()
34
35 find_package(Python3 COMPONENTS Interpreter Development.Module REQUIRED) # see https://github.com/pybind/pybind11/issues/4785
36 set(PYBIND11_FINDPYTHON ON) # see https://github.com/pybind/pybind11/issues/4785
37 zxing_add_package(pybind11 pybind11 https://github.com/pybind/pybind11.git v2.13.6)
38
39 # build the python module
40 pybind11_add_module(zxingcpp zxing.cpp)
41 target_link_libraries(zxingcpp PRIVATE ZXing::ZXing)
42
43 if (ZXING_READERS AND ZXING_WRITERS)
44 add_test(NAME PythonTest COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/test.py -v)
45 set_property(TEST PythonTest PROPERTY ENVIRONMENT PYTHONPATH=$<TARGET_FILE_DIR:zxingcpp>)
46 endif()
47
48 if (NOT DEFINED ZXING_PYTHON_INSTALL_BINDIR)
49 set(ZXING_PYTHON_INSTALL_BINDIR "${CMAKE_INSTALL_BINDIR}")
50 endif()
51
52 if (NOT DEFINED ZXING_PYTHON_INSTALL_LIBDIR)
53 set(ZXING_PYTHON_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}")
54 endif()
55
56 install(TARGETS zxingcpp
57 COMPONENT python
58 RUNTIME DESTINATION "${ZXING_PYTHON_INSTALL_BINDIR}"
59 LIBRARY DESTINATION "${ZXING_PYTHON_INSTALL_LIBDIR}"
60 ARCHIVE DESTINATION "${ZXING_PYTHON_INSTALL_LIBDIR}")
61