Skip to content

Commit

Permalink
Build test package (#4) (#5)
Browse files Browse the repository at this point in the history
*  use common cmake and workflows

* build documentation and release

* use cmake components

* set the export to the qrCode

* add ctest to have the test target

* added alias target to use namespaces also
  • Loading branch information
EddyTheCo authored Jun 1, 2023
1 parent fb85736 commit 78ed7b8
Show file tree
Hide file tree
Showing 11 changed files with 147 additions and 122 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: build-docs
run-name: ${{ github.actor }} ${{ github.event_name }} to ${{ github.base_ref }}
on:
pull_request_target:
types: [closed]
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')) }}
permissions:
pages: write
id-token: write
23 changes: 23 additions & 0 deletions .github/workflows/build-test-install.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: push-build-release
run-name: ${{ github.actor }} ${{ github.event_name }} to ${{ github.base_ref }}
on:

push:
tags:
- 'v*'
pull_request:
types: [opened,reopened]
branches: [develop]
jobs:
build_test_package:
strategy:
matrix:
os: [ubuntu-latest,macos-latest,windows-latest]
sharedLib: [true,false]

uses: EddyTheCo/Common/.github/workflows/build-test-install.yml@main
permissions:
contents: write
with:
os: ${{ matrix.os }}
sharedLib: ${{ matrix.sharedLib }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.git/
doc/html/
doc/*.tag
*.swp
66 changes: 54 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

project(qrCode VERSION 0.1 DESCRIPTION "library for qr codes" LANGUAGES CXX)

include(local_conf.cmake OPTIONAL)

include(FetchContent)
FetchContent_Declare(
ccommon
GIT_REPOSITORY https://github.com/EddyTheCo/Common.git
GIT_TAG main
)
FetchContent_MakeAvailable(ccommon)
version_from_git(
LOG OFF
TIMESTAMP "%Y%m%d%H%M%S"
)
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.")
Expand All @@ -14,17 +26,47 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
endif()

set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
option(USE_QT " build or not the qt interface of the library " ON)
option(BUILD_Dec "build or not the decoding part of the library" OFF)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
include(GNUInstallDirs)
add_subdirectory(QrGen)
if(BUILD_Dec)
add_subdirectory(QrDec)
endif(BUILD_Dec)
if(USE_QT)
add_subdirectory(QtQrGen)
if(BUILD_Dec)
add_subdirectory(QtQrDec)
endif(BUILD_Dec)
endif(USE_QT)

#add_subdirectory(QtQrDec)
#add_subdirectory(QrDec)


install(EXPORT ${PROJECT_NAME}-config
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT qrCode
)
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
)
export(EXPORT ${PROJECT_NAME}-config
FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
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)
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}-static")
endif(NOT BUILD_SHARED_LIBS)
include(CPack)
endif()
3 changes: 3 additions & 0 deletions Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@PACKAGE_INIT@

include ( "${CMAKE_CURRENT_LIST_DIR}/qrCodeTargets.cmake" )
63 changes: 15 additions & 48 deletions QrGen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,26 @@
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)

project(QrCodeGenLib VERSION 0.1 DESCRIPTION "library for qr codes generation" 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_EXTENSIONS OFF)

project(QrGeneration LANGUAGES CXX)

add_library(QrGen src/qrcodegen.cpp src/utils.cpp include/qrcodegen.hpp)

add_library(qrCode::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:include>")

install(TARGETS QrGen EXPORT QrGenTargets DESTINATION lib)
install(DIRECTORY include/ DESTINATION include/)
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")

install(EXPORT QrGenTargets
FILE QrGenTargets.cmake
NAMESPACE qr::
DESTINATION lib/cmake/QrGen
)
include(CMakePackageConfigHelpers)
# generate the config file that is includes the exports
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/QrGenConfig.cmake"
INSTALL_DESTINATION "lib/cmake/QrGen"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/QrGenConfigVersion.cmake"
VERSION "0.1.1.0"
COMPATIBILITY AnyNewerVersion
install(TARGETS QrGen
EXPORT qrCode-config
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT Qr
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/QrGenConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/QrGenConfigVersion.cmake
DESTINATION lib/cmake/QrGen
)
export(EXPORT QrGenTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/QrGenTargets.cmake"
install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode
COMPONENT Qr
)

if(BUILD_DOCS)
get_target_property(build_docs cmake_build_docs SOURCES)
include(${build_docs})
endif()
3 changes: 0 additions & 3 deletions QrGen/Config.cmake.in

This file was deleted.

85 changes: 32 additions & 53 deletions QtQrGen/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,58 +1,37 @@
cmake_minimum_required(VERSION 3.16)
project(qmlqr LANGUAGES CXX)
project(QrGeneration LANGUAGES CXX)

set(CMAKE_AUTOMOC ON)
include(local_conf.cmake OPTIONAL)
find_package(Qt6 COMPONENTS Core Gui Qml Quick Svg)
if (Qt6_FOUND)
qt_add_library(QtQrGen Qrimageprovider.cpp include/Qrimageprovider.hpp)

find_package(Qt6 REQUIRED COMPONENTS Core Gui Qml Quick Core5Compat Svg)
add_library(qrCode::QtQrGen ALIAS QtQrGen)
target_include_directories(QtQrGen PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/qrCode>")

qt_add_library(QtQrGen Qrimageprovider.cpp include/Qrimageprovider.hpp)

set_target_properties(QtQrGen PROPERTIES
WIN32_EXECUTABLE TRUE
MACOSX_BUNDLE TRUE
)
target_include_directories(QtQrGen PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"$<INSTALL_INTERFACE:include>")
target_link_libraries(QtQrGen PUBLIC
Qt6::Quick
)
target_link_libraries(QtQrGen PRIVATE
QrGen
Qt6::Core
Qt6::Gui
Qt6::Qml
Qt6::Quick
Qt6::Core5Compat
Qt6::Svg
)
target_link_libraries(QtQrGen PUBLIC
Qt6::Quick
)
target_link_libraries(QtQrGen PRIVATE
QrGen
Qt6::Core
Qt6::Gui
Qt6::Qml
Qt6::Quick
Qt6::Svg
)

install(TARGETS QtQrGen EXPORT QtQrGenTargets LIBRARY DESTINATION lib)
install(DIRECTORY include/ DESTINATION include/)

install(EXPORT QtQrGenTargets
FILE QtQrGenTargets.cmake
NAMESPACE qr::
DESTINATION lib/cmake/QtQrGen
)
include(CMakePackageConfigHelpers)
# generate the config file that is includes the exports
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/QtQrGenConfig.cmake"
INSTALL_DESTINATION "lib/cmake/QtQrGen"
NO_SET_AND_CHECK_MACRO
NO_CHECK_REQUIRED_COMPONENTS_MACRO
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/QtQrGenConfigVersion.cmake"
VERSION "0.1.1.0"
COMPATIBILITY AnyNewerVersion
)
install(FILES
${CMAKE_CURRENT_BINARY_DIR}/QtQrGenConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/QtQrGenConfigVersion.cmake
DESTINATION lib/cmake/QtQrGen
)
export(EXPORT QtQrGenTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/QtQrGenTargets.cmake"
)
install(TARGETS QtQrGen
EXPORT qrCode-config
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT QtQr
)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/qrCode
COMPONENT QtQr
)
endif(Qt6_FOUND)
if(BUILD_DOCS)
get_target_property(build_docs cmake_build_docs SOURCES)
include(${build_docs})
endif()
3 changes: 0 additions & 3 deletions QtQrGen/Config.cmake.in

This file was deleted.

1 change: 0 additions & 1 deletion QtQrGen/Qrimageprovider.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include <QPainter>
#include <QStringRef>
#include <QSvgRenderer>
#include "qrcodegen.hpp"
#include "Qrimageprovider.hpp"
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ include(FetchContent)
qrCode
GIT_REPOSITORY git@github.com:EddyTheCo/qrCode.git
GIT_TAG main
)
FIND_PACKAGE_ARGS COMPONENTS qrCode CONFIG
)
FetchContent_MakeAvailable(qrCode)
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> QrGen QtQrGen)
target_link_libraries(<target> <PRIVATE|PUBLIC|INTERFACE> qrCode::QrGen qrCode::QtQrGen)
```


Expand Down

0 comments on commit 78ed7b8

Please sign in to comment.