Skip to content

Commit

Permalink
Improvements (#56)
Browse files Browse the repository at this point in the history
* Align the URI of the modules

* Create alias targets

* Set private the singleton constructor

* Added the examples

* Improve readmes
  • Loading branch information
EddyTheCo authored Dec 9, 2023
1 parent 7414aa2 commit b099b7c
Show file tree
Hide file tree
Showing 45 changed files with 1,325 additions and 746 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ on:
branches: [main]
jobs:
build_doxygen:
uses: EddyTheCo/Common/.github/workflows/build-docs.yml@main
if: ${{ (github.event.pull_request.merged == true) && (startsWith(github.base_ref, 'main')) }}
uses: EddyTheCo/Common/.github/workflows/build-docs.yml@v0.1.1
if: ${{ (github.event.pull_request.merged == true) && (startsWith(github.base_ref, 'main')) }}
permissions:
pages: write
id-token: write
5 changes: 3 additions & 2 deletions .github/workflows/build-test-install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ jobs:
matrix:
os: [ubuntu-latest,macos-latest,windows-latest]

uses: EddyTheCo/Common/.github/workflows/build-test-install.yml@main
uses: EddyTheCo/Common/.github/workflows/build-test-install.yml@v0.1.1
permissions:
contents: write
with:
os: ${{ matrix.os }}
sharedLib: true
qtVersion: '6.6.0'
qtModules: 'qtshadertools qtmultimedia'
qtModules: 'qtshadertools qtmultimedia'
test: false
release:
if: startsWith(github.ref, 'refs/tags/v')
needs: build_test_package
Expand Down
43 changes: 17 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,56 +15,47 @@ version_from_git(
)
project(qrCode VERSION ${VERSION} DESCRIPTION "library for qr code manipulation" LANGUAGES CXX)

set(default_build_type "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE
STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(GNUInstallDirs)

add_subdirectory(QrDec)
add_subdirectory(QrGen)
add_subdirectory(QtQrDec)
add_subdirectory(QtQrGen)


add_subdirectory(QrDec)
add_subdirectory(QtQrDec)

install(EXPORT qrCodeTargets
FILE qrCodeTargets.cmake
NAMESPACE qrCode::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qrCode
COMPONENT qrCode
install(EXPORT ${PROJECT_NAME}-config
FILE ${PROJECT_NAME}-config.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Esterv
NAMESPACE ${PROJECT_NAME}::
COMPONENT ${PROJECT_NAME}
)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/qrCodeConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qrCode
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Esterv
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/qrCodeConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/qrCodeConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/qrCodeConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/qrCode
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Esterv
)
export(EXPORT qrCodeTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/qrCodeTargets.cmake"
export(EXPORT ${PROJECT_NAME}-config
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
)

if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
set(CPACK_PACKAGE_CONTACT "estervtech")
set(CPACK_PACKAGE_CONTACT "estervtech")
include(CTest)
set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-v${SEMVER}-${CMAKE_SYSTEM_NAME}_${CMAKE_SYSTEM_VERSION}-${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_CXX_COMPILER_ID}")
if(NOT BUILD_SHARED_LIBS)
Expand Down
2 changes: 1 addition & 1 deletion Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
include(CMakeFindDependencyMacro)
find_dependency(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Svg OPTIONAL_COMPONENTS Multimedia )
find_dependency(OpenCV REQUIRED COMPONENTS core objdetect )
find_dependency(MyDesigns 0.4 REQUIRED CONFIG)
find_dependency(EstervDesigns 1.0 COMPONENTS SimpleStyle CustomControls CONFIG)
include ( "${CMAKE_CURRENT_LIST_DIR}/qrCodeTargets.cmake" )
13 changes: 7 additions & 6 deletions QrDec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,21 @@ endif()
if(OpenCV_FOUND)
add_library(QrDec qrcodedec.cpp)

add_library(${PROJECT_NAME}::QrDec ALIAS QrDec)
target_include_directories(QrDec PUBLIC $<BUILD_INTERFACE:${OpenCV_INCLUDE_DIRS}>)
target_link_libraries(QrDec PUBLIC ${OpenCV_LIBS})

target_include_directories(QrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Esterv/${PROJECT_NAME}>")
install(TARGETS QrDec
EXPORT qrCodeTargets
EXPORT ${PROJECT_NAME}-config
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Qr
COMPONENT QrDec
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode
COMPONENT Qr
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Esterv/${PROJECT_NAME}
COMPONENT QrDec
)
else()
message(STATUS "OpenCV was not found")
message(STATUS "The QRCODE decoding library will not be built")
endif(OpenCV_FOUND)
3 changes: 0 additions & 3 deletions QrDec/Config.cmake.in

This file was deleted.

20 changes: 15 additions & 5 deletions QrDec/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# QrGen
# QrDec

This repo detect and decode a Qr code in a image.
The compiled library depend on [opencv](https://opencv.org/)

CMake produce the target 'QrDec' so one can link to this library like
The detection and decoding is performed by [OpenCV](https://opencv.org/) libraries.
In case OpenCV is not found on your system CMake will download pre compiled libraries from [my action releases](https://github.com/EddyTheCo/install-OpenCV-action).

## Adding the libraries to your CMake project
```
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> QrDec)
include(FetchContent)
FetchContent_Declare(
qrCode
GIT_REPOSITORY https://github.com/EddyTheCo/qrCode.git
GIT_TAG v1.0.0
FIND_PACKAGE_ARGS 1.0 COMPONENTS QrDec CONFIG
)
FetchContent_MakeAvailable(qrCode)
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> qrCode::QrDec)
```


Expand Down
15 changes: 0 additions & 15 deletions QrDec/tests/CMakeLists.txt

This file was deleted.

21 changes: 0 additions & 21 deletions QrDec/tests/load_from_file.cpp

This file was deleted.

Binary file removed QrDec/tests/qrcode-feature.jpg
Binary file not shown.
18 changes: 7 additions & 11 deletions QrGen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
add_library(QrGen src/qrcodegen.cpp src/utils.cpp)
add_library(${PROJECT_NAME}::QrGen ALIAS QrGen)

set_target_properties(QrGen PROPERTIES POSITION_INDEPENDENT_CODE ON)

target_compile_features(QrGen PUBLIC cxx_std_11)

target_include_directories(QrGen PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Esterv/${PROJECT_NAME}>")

install(TARGETS QrGen
EXPORT qrCodeTargets
install(TARGETS QrGen
EXPORT ${PROJECT_NAME}-config
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Qr
COMPONENT QrGen
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode
COMPONENT Qr
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Esterv/${PROJECT_NAME}
COMPONENT QrGen
)

if(BUILD_DOCS)
get_target_property(build_docs cmake_build_docs SOURCES)
include(${build_docs})
endif()
14 changes: 12 additions & 2 deletions QrGen/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
# QrGen

The code is based on [QR Code generator library](https://github.com/nayuki/QR-Code-generator) and produce a library for the generation of a QR code of certain data.
CMake produce the target 'QrGen' so one can link to this library like

## Adding the libraries to your CMake project
```
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> QrGen)
include(FetchContent)
FetchContent_Declare(
qrCode
GIT_REPOSITORY https://github.com/EddyTheCo/qrCode.git
GIT_TAG v1.0.0
FIND_PACKAGE_ARGS 1.0 COMPONENTS QrGen CONFIG
)
FetchContent_MakeAvailable(qrCode)
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> qrCode::QrGen)
```


Expand Down
132 changes: 85 additions & 47 deletions QtQrDec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,51 +1,89 @@

find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick OPTIONAL_COMPONENTS Multimedia)
if(EMSCRIPTEN)
find_package(Qt6 COMPONENTS Core Gui Qml Quick ShaderTools)
else()
find_package(Qt6 COMPONENTS Core Gui Qml Quick ShaderTools Multimedia)
endif(EMSCRIPTEN)

FetchContent_Declare(
MyDesigns
GIT_REPOSITORY https://github.com/EddyTheCo/MyDesigns.git
GIT_TAG v0.4.1
FIND_PACKAGE_ARGS 0.4 CONFIG
)
FetchContent_MakeAvailable(MyDesigns)
EstervDesigns
GIT_REPOSITORY https://github.com/EddyTheCo/MyDesigns.git
GIT_TAG v1.0.0
FIND_PACKAGE_ARGS 1.0 COMPONENTS SimpleStyle CustomControls CONFIG
)
FetchContent_MakeAvailable(EstervDesigns)


if (Qt6_FOUND AND TARGET QrDec)
qt_standard_project_setup()
qt6_add_qml_module(QtQrDec
URI QtQrDec
VERSION 1.0
SOURCES Qrimagedecoder.cpp include/Qrimagedecoder.hpp
QML_FILES
qml/QrQmlCamera.qml
qml/QrCam.qml
qml/QrTextCamPop.qml
RESOURCE_PREFIX
"/esterVtech.com/imports"
OUTPUT_TARGETS out_targets_var
OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/QtQrDec
IMPORT_PATH ${CMAKE_BINARY_DIR}
)

target_include_directories(QtQrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")

target_link_libraries(QtQrDec PUBLIC Qt6::Gui Qt6::Quick QrDec $<TARGET_NAME_IF_EXISTS:Qt6::Multimedia> MyDesigns
$<$<STREQUAL:$<TARGET_PROPERTY:MyDesigns,TYPE>,STATIC_LIBRARY>:MyDesignsplugin>)

install(TARGETS QtQrDec QtQrDecplugin ${out_targets_var}
EXPORT qrCodeTargets
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT QtQr
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode
COMPONENT QtQr
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/QtQrDec/
DESTINATION ${CMAKE_INSTALL_LIBDIR}/QMLPlugins/QtQrDec
COMPONENT QtQr
)

if(EMSCRIPTEN)
target_compile_definitions(QtQrDec PRIVATE USE_EMSCRIPTEN)
endif(EMSCRIPTEN)
qt_standard_project_setup()
qt6_add_qml_module(QtQrDec
URI Esterv.CustomControls.QrDec
VERSION 1.0
SOURCES Qrimagedecoder.cpp include/Qrimagedecoder.hpp
QML_FILES
"qml/QrCam.qml"
"qml/QrDecPop.qml"
"qml/QrTextField.qml"
RESOURCE_PREFIX
"/esterVtech.com/imports"
OUTPUT_TARGETS out_targets_var
OUTPUT_DIRECTORY
${CMAKE_BINARY_DIR}/Esterv/CustomControls/QrDec
IMPORT_PATH ${CMAKE_BINARY_DIR} ${CMAKE_INSTALL_LIBDIR}
)

add_library(${PROJECT_NAME}::QtQrDec ALIAS QtQrDec)
add_library(${PROJECT_NAME}::QtQrDecplugin ALIAS QtQrDecplugin)


qt6_add_shaders(QtQrDec "esterVtech.com.imports.QtQrDec.shaders"
BATCHABLE
PRECOMPILE
OPTIMIZED
OUTPUT_TARGETS out_targets_var2
PREFIX
"/esterVtech.com/imports/Designs"
FILES
"frag/qrscanner.frag"
)
target_include_directories(QtQrDec PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/Esterv/${PROJECT_NAME}>")
if(EMSCRIPTEN)
target_compile_definitions(QtQrDec PRIVATE USE_EMSCRIPTEN)
else()
target_link_libraries(QtQrDec PUBLIC Qt6::Multimedia)
endif(EMSCRIPTEN)
target_link_libraries(QtQrDec PUBLIC Qt6::Gui Qt6::Quick QrDec Qt6::Multimedia
EstervDesigns::SimpleStyle EstervDesigns::customControls
$<$<STREQUAL:$<TARGET_PROPERTY:EstervDesigns::SimpleStyle,TYPE>,STATIC_LIBRARY>:EstervDesigns::SimpleStyleplugin>
$<$<STREQUAL:$<TARGET_PROPERTY:EstervDesigns::customControls,TYPE>,STATIC_LIBRARY>:EstervDesigns::customControlsplugin>)

install(TARGETS QtQrDec ${out_targets_var} ${out_targets_var2}
EXPORT ${PROJECT_NAME}-config
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT QtQrDec
)
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/Esterv/${PROJECT_NAME}
COMPONENT QtQrDec
)
install(DIRECTORY ${CMAKE_BINARY_DIR}/Esterv/CustomControls/QrDec
DESTINATION ${CMAKE_INSTALL_LIBDIR}/Esterv/CustomControls
COMPONENT QtQrDec
)

install(TARGETS QtQrDecplugin
EXPORT ${PROJECT_NAME}-config
DESTINATION ${CMAKE_INSTALL_LIBDIR}/Esterv/CustomControls/QrDec
COMPONENT QtQrDec
)

if(EMSCRIPTEN)
target_compile_definitions(QtQrDec PRIVATE USE_EMSCRIPTEN)
endif(EMSCRIPTEN)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
add_subdirectory(examples)
endif(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
else(Qt6_FOUND AND TARGET QrDec)
message(STATUS "The QML Module for QRCODE decoding will not be built")
endif(Qt6_FOUND AND TARGET QrDec)
Loading

0 comments on commit b099b7c

Please sign in to comment.