That is the internal target name in ZXing and it works because ZXing is built as part of the same build tree via add_subdirectory(zxing-cpp/core).
However ZXing also provides an alias target name "ZXing::Core" (see), the same as their exported target name to use after find_package(ZXing).
Using such an alias is often done to allow users to decide if they want to build a component (here: ZXing) as part of the same CMake call or separately:
A primary use-case for ALIAS targets is for example or unit test executables accompanying a library, which may be part of the same buildsystem or built separately based on user configuration. […]
[After providing] add_library(Upstream::lib1 ALIAS lib1) in another directory, we can link unconditionally to the Upstream::lib1 target, which may be an IMPORTED target from a package, or an ALIAS target if built as part of the same buildsystem.
In this repository, making it possible to build ZXing separately and importing its targets with find_package(…) would need some more changes. But this would be a preparation. The code quoted above would then be:
Background: I integrated QZXingNu into an application because it's the most up-to-date barcode reader component for Qt. It works great! :+1: :+1: I then switched to building ZXing separately. Doing so it took me some hours to figure out that I had to change the library target from ZXingCore to ZXing::Core (see) :smile:
A suggestion from upstream: please use ZXing::ZXing as I consider that to be the default name now. ZXing::Core is provided for backward compatibility, at the moment.
Currently, linker configuration in this project is done like this, from here in
CMakeLists.txt
:That is the internal target name in ZXing and it works because ZXing is built as part of the same build tree via
add_subdirectory(zxing-cpp/core)
.However ZXing also provides an alias target name "ZXing::Core" (see), the same as their exported target name to use after
find_package(ZXing)
.Using such an alias is often done to allow users to decide if they want to build a component (here: ZXing) as part of the same CMake call or separately:
In this repository, making it possible to build ZXing separately and importing its targets with
find_package(…)
would need some more changes. But this would be a preparation. The code quoted above would then be:Background: I integrated QZXingNu into an application because it's the most up-to-date barcode reader component for Qt. It works great! :+1: :+1: I then switched to building ZXing separately. Doing so it took me some hours to figure out that I had to change the library target from
ZXingCore
toZXing::Core
(see) :smile: