Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@wizard97
Copy link
Contributor

Add CMake options for:

  • ZXING_ENABLE_1D
  • ZXING_ENABLE_AZTEC
  • ZXING_ENABLE_DATAMATRIX
  • ZXING_ENABLE_MAXICODE
  • ZXING_ENABLE_PDF417
  • ZXING_ENABLE_QRCODE

This allows people to compile and link in only backends of interest, saving substantial .text/.rodata space for resource constrained embedded systems.

@axxel
Copy link
Collaborator

axxel commented Oct 13, 2025

As you can see, this breaks a bunch of stuff (which was to be expected on second thought). I need to spend more time thinking about how I'd like this to look in the end (positive vs. negative defaults and naming conventions). I'll come back to this later.

Allow importing core/ via add_subdirectory without defining
ZXING_ENABLE_*, default to ON in this case.
@wizard97
Copy link
Contributor Author

wizard97 commented Oct 13, 2025

As you can see, this breaks a bunch of stuff (which was to be expected on second thought). I need to spend more time thinking about how I'd like this to look in the end (positive vs. negative defaults and naming conventions). I'll come back to this later.

I see the problem. There care cases where core/CMakeLists.txt is being imported without the top-level CMakeLists.txt, which causes all the ENABLE_* vars to be undefined (no formats/codes enabled). I added the following to core/CMakeLists.txt to default to ON if not defined. This should make this change a NOP to existing users that do not set these variables:

# If parent CMakeLists.txt does not define ZXING_ENABLE_... options, set them to ON.
foreach(format 1D AZTEC DATAMATRIX MAXICODE PDF417 QRCODE)
    set(_var "ZXING_ENABLE_${format}")
    if (NOT DEFINED ${_var})
        set(${_var} ON CACHE BOOL "Enable support for ${format} barcodes" FORCE)
    endif()
endforeach()

Can you retry the workflow?

@axxel axxel merged commit ed6c869 into zxing-cpp:master Oct 14, 2025
20 checks passed
@axxel
Copy link
Collaborator

axxel commented Oct 14, 2025

Thanks a lot. I had some additional cleanup that I wanted to add but did not have access to your PR repo/branch. So I merged it as is and added my changes in master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants