From 662d7a9ef59a4f17ee84eb356129edc78f89f8db Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 24 May 2017 19:33:39 -0400 Subject: [PATCH] Added FindGnuBarcode cmake module. --- CMakeLists.txt | 7 +++++++ cmake/Modules/FindGnuBarcode.cmake | 27 +++++++++++++++++++++++++++ cmake/Modules/FindLibQrencode.cmake | 1 - glabels/CMakeLists.txt | 7 +++++++ 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 cmake/Modules/FindGnuBarcode.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 1cefe15..4e4399c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ find_package(ZLIB 1.2 REQUIRED) # # Optional dependencies # +find_package (GnuBarcode QUIET) find_package (LibQrencode QUIET) @@ -77,6 +78,12 @@ message (STATUS "C++ Compiler ............ " ${CMAKE_CXX_COMPILER_ID} " " ${CMAK message (STATUS "Qt version .............. " ${Qt5Core_VERSION}) message (STATUS "zlib version ............ " ${ZLIB_VERSION_STRING}) +if (GNUBARCODE_FOUND) + message (STATUS "GNU Barcode (optional)... " ${GNUBARCODE_VERSION_STRING}) +else (GNUBARCODE_FOUND) + message (STATUS "GNU Barcode (optional)... No.") +endif (GNUBARCODE_FOUND) + if (LIBQRENCODE_FOUND) message (STATUS "qrencode (optional)...... " ${LIBQRENCODE_VERSION_STRING}) else (LIBQRENCODE_FOUND) diff --git a/cmake/Modules/FindGnuBarcode.cmake b/cmake/Modules/FindGnuBarcode.cmake new file mode 100644 index 0000000..45997b9 --- /dev/null +++ b/cmake/Modules/FindGnuBarcode.cmake @@ -0,0 +1,27 @@ +# - Try to find the GNU Barcode library +# Once done this will define +# +# GNUBARCODE_FOUND - System has GNU Barcode +# GNUBARCODE_INCLUDE_DIR - The GNU Barcode include directory +# GNUBARCODE_LIBRARIES - The libraries needed to use GNU Barcode +# GNUBARCODE_VERSION_STRING - the version of GNU Barcode found + +set (GNUBARCODE_DEFINITIONS "") + +find_path (GNUBARCODE_INCLUDE_DIR NAMES barcode.h PATH_SUFFIXES barcode) + +find_library (GNUBARCODE_LIBRARIES NAMES barcode ) + +if (GNUBARCODE_INCLUDE_DIR AND EXISTS "${GNUBARCODE_INCLUDE_DIR}/barcode.h") + file (STRINGS "${GNUBARCODE_INCLUDE_DIR}/barcode.h" BARCODE_H REGEX "^#define BARCODE_VERSION *\"[^\"]*\"") + string (REGEX REPLACE "^.*VERSION *\"([^\"]*)\"" "\\1" GNUBARCODE_VERSION_STRING ${BARCODE_H}) +endif() + +# handle the QUIETLY and REQUIRED arguments and set GNUBARCODE_FOUND to TRUE if +# all listed variables are TRUE +include(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(GnuBarcode + REQUIRED_VARS GNUBARCODE_LIBRARIES GNUBARCODE_INCLUDE_DIR + VERSION_VAR GNUBARCODE_VERSION_STRING) + +mark_as_advanced(GNUBARCODE_INCLUDE_DIR GNUBARCODE_LIBRARIES) diff --git a/cmake/Modules/FindLibQrencode.cmake b/cmake/Modules/FindLibQrencode.cmake index ec2724a..e5390ee 100644 --- a/cmake/Modules/FindLibQrencode.cmake +++ b/cmake/Modules/FindLibQrencode.cmake @@ -5,7 +5,6 @@ # LIBQRENCODE_INCLUDE_DIR - The LibQrencode include directory # LIBQRENCODE_LIBRARIES - The libraries needed to use LibQrencode # LIBQRENCODE_DEFINITIONS - Compiler switches required for using LibQrencode -# LIBQRENCODE_XMLLINT_EXECUTABLE - The XML checking tool xmllint coming with LibQrencode # LIBQRENCODE_VERSION_STRING - the version of LibQrencode found # use pkg-config to get the directories and then use these values with find_path() and find_library() diff --git a/glabels/CMakeLists.txt b/glabels/CMakeLists.txt index 9ebd762..bc237bf 100644 --- a/glabels/CMakeLists.txt +++ b/glabels/CMakeLists.txt @@ -11,6 +11,13 @@ endif () # Uncomment to build with pedantic flags #add_compile_options (-Werror -Wall -Wpedantic) +if (${GNUBARCODE_FOUND}) + add_definitions (-DHAVE_GNU_BARCODE=1) +else (${GNUBARCODE_FOUND}) + set (GNUBARCODE_INCLUDE_DIR "") + set (GNUBARCODE_LIBRARIES "") +endif (${GNUBARCODE_FOUND}) + if (${LIBQRENCODE_FOUND}) add_definitions (-DHAVE_QRENCODE=1) else (${LIBQRENCODE_FOUND})