Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix same bug, add cmake to ci, refactor cmake #177

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
32 changes: 19 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#Author: KangLin(kl222@126.com)

#sudo: required
dist: xenial
dist: bionic

services:
- xvfb

language: cpp

cache:
- apt: true
- apt
- directories:
- Tools
- Package

compiler:
- g++
Expand All @@ -24,17 +24,15 @@ addons:

env:
jobs:
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.13 QT_VERSION=5.13.0
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.12 QT_VERSION=5.12.4
- BUILD_TARGERT="linux" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
# - BUILD_TARGERT="android_armv7" QT_VERSION_DIR=5.9 QT_VERSION=5.9.8
- BUILD_TARGERT="unix" DOWNLOAD_QT=APT
- BUILD_TARGERT="unix" QT_VERSION_DIR=512 QT_VERSION=5.12.6 DOWNLOAD_QT=FALSE
- BUILD_TARGERT="unix" QT_VERSION_DIR=511 QT_VERSION=5.11.3 DOWNLOAD_QT=FALSE

before_install:
- echo "TRAVIS_OS_NAME=${TRAVIS_OS_NAME}"
- export DISPLAY=:99.0
- sudo apt-get install -y libgl1-mesa-glx libgl1-mesa-dev
- cmake --version

install:
- bash ${TRAVIS_BUILD_DIR}/ci/build-install-tools.sh #> /dev/null
Expand All @@ -43,7 +41,15 @@ before_script:
- source ${TRAVIS_BUILD_DIR}/ci/build_env.sh

script:
- mkdir ${TRAVIS_BUILD_DIR}/build
- cd ${TRAVIS_BUILD_DIR}/build
- ${QT_ROOT}/bin/qmake -o Makefile CONFIG+=Release ${TRAVIS_BUILD_DIR}/src/QZXing.pro
- make -f Makefile
# Test qmake
- mkdir ${TRAVIS_BUILD_DIR}/build_qamke
- cd ${TRAVIS_BUILD_DIR}/build_qamke
- ${QT_ROOT}/bin/qmake CONFIG+=Release PRFIEX=`pwd`/install ${TRAVIS_BUILD_DIR}/src
- make install

# Test cmake
- mkdir ${TRAVIS_BUILD_DIR}/build_camke
- cd ${TRAVIS_BUILD_DIR}/build_camke
- cmake -DQt5_DIR=${QT_ROOT}/lib/cmake/Qt5 -DCMAKE_INSTALL_PREFIX=`pwd`/install ${TRAVIS_BUILD_DIR}/src
- cmake --build . --config Release
- cmake --build . --config Release --target install
70 changes: 70 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Author: Kang Lin (kl222@126.com)

cmake_minimum_required(VERSION 2.8.12)

if(POLICY CMP0100)
cmake_policy(SET CMP0100 NEW)
endif()

if(POLICY CMP0077)
cmake_policy(SET CMP0077 NEW)
endif()

project(QZXing)

# TODO: Modify the version to the correct version
SET(BUILD_VERSION "2.3")
# Find Git Version Patch
IF(EXISTS "${CMAKE_SOURCE_DIR}/.git")
if(NOT GIT)
SET(GIT $ENV{GIT})
endif()
if(NOT GIT)
FIND_PROGRAM(GIT NAMES git git.exe git.cmd)
endif()
IF(GIT)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} describe --tags
OUTPUT_VARIABLE GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_VERSION)
EXECUTE_PROCESS(
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${GIT} rev-parse --short HEAD
OUTPUT_VARIABLE GIT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
SET(BUILD_VERSION ${GIT_VERSION})
ENDIF()
ENDIF()
message("BUILD_VERSION:${BUILD_VERSION}")
set(VERSION ${BUILD_VERSION})

# Open qt compile tools
SET(CMAKE_AUTOUIC ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTORCC ON)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)

include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
include(GenerateExportHeader)

# Record the files that will need to be deleted
CONFIGURE_FILE(
"${CMAKE_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
# Create delete target
ADD_CUSTOM_TARGET(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake")

SET(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libs")

if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
endif()

add_subdirectory(src)
74 changes: 71 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,71 @@ Supports barcode decoding for the following types:
The project can be used in two ways:
<a name="embedInSourceCode"></a>
## Embed the source code.
- qmake project

Copy source code folder of QZXing to the root of your project. Add the following line to your .pro file. For more information see [here](https://github.com/ftylitak/qzxing/wiki/Using-the-QZXing-through-the-source-code).

```qmake
include(QZXing/QZXing.pri)
```

- cmake project

Download source code of QZXing to QZXing_DIR. Add the following line to your CMakeLists.txt file.

```cmake
add_subdirectory(${QZXing_DIR}/src ${CMAKE_BINARY_DIR}/QZXing)

target_link_libraries(${PROJECT_NAME} PUBLIC QZXing)
```

<a name="externalLibrary"></a>
## Compile the project as an external library
Open QZXing project (QZXing.pro) and compile. If it is needed to compile as static library, uncomment the following line in the .pro file.
- Qtcreator
+ qmake project

Open QZXing project (QZXing.pro) and compile. If it is needed to compile as static library, uncomment the following line in the .pro file.

```qmake
CONFIG += staticlib
```

+ cmake project

Open CMakeLists and compile. If it is needed to compile as static library, add the folloing parameter.

```bash
-DBUILD_SHARED_LIBS=OFF
```

- Comand line
+ qmake

```bash
cd ${QZXing_DIR}
mkdir build
cd build
qmake ../src # Configure
make # Compile
make install # Install
```

+ cmake

```bash
cd ${QZXing_DIR}
mkdir build
cd build
# Configure
cmake ..
# Compile
cmake --build .
# Install
cmake --build . --target install # Install develop library
# or
cmake --build . --target install-runtime # Install runtime library
```

<a name="controlDependencies"></a>
## Control dependencies
Project file config tags are now introduced to be able to control the dependencies of the library accoring to the needs.
Expand All @@ -72,20 +125,35 @@ Warning! The initial default configuration till 20/03/2017 was including qzxing_

<a name="controlDependenciesCoreQML"></a>
### QZXing (core + QML)
If an application is going to use QML functionality, it is now possible to add the dependency to it. This can be done by adding the folloing line to the .pro file of its project:
If an application is going to use QML functionality, it is now possible to add the dependency to it.
- qmake. This can be done by adding the folloing line to the .pro file of its project:

```qmake
CONFIG += qzxing_qml
```

- cmake. It can be used by adding the folloing line to parameter of cmake:

```cmake
-DQZXING_QML=ON
```

<a name="controlDependenciesCoreQMLQZXingFilter"></a>
### QZXing + QZXingFilter
QZXing includes QZXingFilter, a QAbstractVideoFilter implementation to provide a mean of providing live feed to the decoding library. It automatically includes QML implementation as well.
This option requires "multimedia" Qt module this is why it is considered as a separate configuration. It can be used by adding the folloing line to the .pro file of a project:
This option requires "multimedia" Qt module this is why it is considered as a separate configuration.
- qmake. It can be used by adding the folloing line to the .pro file of a project:

```qmake
CONFIG += qzxing_multimedia
```

- cmake. It can be used by adding the folloing line to parameter of cmake:

```cmake
-DQZXING_MULTIMEDIA=ON
```

<a name="howTo"></a>
# How to use

Expand Down
50 changes: 26 additions & 24 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
#original author: KangLin(kl222@126.com)
#original author: Kang Lin(kl222@126.com)

version: '3.0.a.5.{build}'

configuration:
- release
- debug
- Release
- Debug

environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATORS: "Visual Studio 14 2015"
QT_ROOT: C:/Qt/5.6/msvc2015

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
GENERATORS: "Visual Studio 14 2015 Win64"
QT_ROOT: C:/Qt/5.9/msvc2015_64

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
GENERATORS: "Visual Studio 15 2017 Win64"
QT_ROOT: C:/Qt/5.12/msvc2017_64
# - QT_ROOT: C:/Qt/5.12/msvc2015
# - QT_ROOT: C:/Qt/5.12/mingw53_32

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
QT_ROOT: C:/Qt/5.9/msvc2017_64
# - QT_ROOT: C:/Qt/5.9/msvc2015_64
# - QT_ROOT: C:/Qt/5.9/msvc2015
# - QT_ROOT: C:/Qt/5.9/msvc2013_64
# - QT_ROOT: C:/Qt/5.9/mingw53_32

- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
QT_ROOT: C:/Qt/5.6/msvc2015_64
# - QT_ROOT: C:/Qt/5.6/msvc2015
# - QT_ROOT: C:/Qt/5.6/msvc2013_64
# - QT_ROOT: C:/Qt/5.6/msvc2013

init:

Expand Down Expand Up @@ -75,17 +69,25 @@ install:
- cl

build_script:
- mkdir "%APPVEYOR_BUILD_FOLDER%/build"
- cd "%APPVEYOR_BUILD_FOLDER%/build"
- call "%QT_ROOT%/bin/qmake.exe" CONFIG+=%Configuration% PREFIX="%APPVEYOR_BUILD_FOLDER%/install" "%APPVEYOR_BUILD_FOLDER%/src/QZXing.pro"
# Test qmake
- mkdir "%APPVEYOR_BUILD_FOLDER%/build_qmake"
- cd "%APPVEYOR_BUILD_FOLDER%/build_qmake"
- call "%QT_ROOT%/bin/qmake.exe" CONFIG+=%Configuration% PREFIX="%APPVEYOR_BUILD_FOLDER%/install_qmake" "%APPVEYOR_BUILD_FOLDER%/src"
- call %MAKE%
- call %MAKE% install
- call %MAKE% install

# Test cmake
- mkdir "%APPVEYOR_BUILD_FOLDER%/build_cmake"
- cd "%APPVEYOR_BUILD_FOLDER%/build_cmake"
- cmake.exe -G"%GENERATORS%" -DCMAKE_INSTALL_PREFIX="%APPVEYOR_BUILD_FOLDER%/install_cmake" -DQt5_DIR="%QT_ROOT%/lib/cmake/Qt5" "%APPVEYOR_BUILD_FOLDER%/src"
- cmake --build . --config %Configuration%
- cmake --build . --config %Configuration% --target install

test_script:

artifacts:
- path: install
name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_$(BUILD_VERSION)
- path: install_qmake
name: QZXing_$(QMAKE_XSPEC)$(TOOLCHAIN_VERSION)_$(CONFIGURATION)_Qt$(QT_VERSION)_$(BUILD_VERSION)
type: zip

# whitelist branches to avoid testing feature branches twice (as branch and as pull request)
Expand Down
Loading