Closed
Description
According to https://github.com/nu-book/zxing-cpp/blob/bee813aebf01d42476b1b5c463f9e07ed0067443/example/CMakeLists.txt , executables are built when BUILD_READERS
and BUILD_WRITERS
are defined. However, no install()
target is provided. As a result, the built binaries will not be installed into /usr/bin/
on POSIX-like OS, even if BUILD_EXAMPLES
is enabled.
As a result, I propose the following prototype patch as a possible fix:
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index c9f2ab4..17c3ea9 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -3,12 +3,16 @@ set (CMAKE_CXX_STANDARD 11)
zxing_add_package_stb()
+include (GNUInstallDirs)
+
if (BUILD_READERS)
add_executable (ZXingReader ZXingReader.cpp)
target_link_libraries (ZXingReader ZXing::ZXing stb::stb)
add_test(NAME ZXingReaderTest COMMAND ZXingReader -fast -format qrcode "${CMAKE_SOURCE_DIR}/test/samples/qrcode-1/1.png")
+
+ install(TARGETS ZXingReader DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (BUILD_WRITERS)
@@ -17,6 +21,8 @@ if (BUILD_WRITERS)
target_link_libraries (ZXingWriter ZXing::ZXing stb::stb)
add_test(NAME ZXingWriterTest COMMAND ZXingWriter qrcode "I have the best words." test.png)
+
+ install(TARGETS ZXingWriter DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
@@ -28,11 +34,13 @@ if (BUILD_READERS)
if (TARGET Qt5::Gui)
add_executable (ZXingQtReader ZXingQtReader.cpp ZXingQtReader.h)
target_link_libraries(ZXingQtReader ZXing::ZXing Qt5::Gui)
+ install(TARGETS ZXingQtReader DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if (TARGET Qt5::Multimedia)
add_executable(ZXingQtCamReader ZXingQtCamReader.cpp ZXingQtCamReader.qrc ZXingQtReader.h)
target_link_libraries(ZXingQtCamReader ZXing::ZXing Qt5::Gui Qt5::Multimedia Qt5::Quick)
+ install(TARGETS ZXingQtCamReader DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
find_package(OpenCV)
@@ -40,5 +48,6 @@ if (BUILD_READERS)
add_executable (ZXingOpenCV ZXingOpenCV.cpp)
target_include_directories (ZXingOpenCV PRIVATE ${OpenCV_INCLUDE_DIRS})
target_link_libraries (ZXingOpenCV ZXing::ZXing ${OpenCV_LIBS})
+ install(TARGETS ZXingOpenCV DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
Just FYI, I hereby release this patch into the Public Domain.
I am making the assumption that the built example bin files should always be installed. If not, we can always add another option in topdir CMakeLists.txt.
Metadata
Metadata
Assignees
Labels
No labels