zint/backend/CMakeLists.txt

130 lines
4.0 KiB
CMake
Raw Normal View History

# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
# Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
# vim: set ts=4 sw=4 et :
2008-09-19 02:44:52 +12:00
project(zint)
EAN/UPC: add quiet zone indicators option (API `output_options` `EANUPC_GUARD_WHITESPACE`, CLI `--guardwhitespace`) (ticket #287) EAN-2/EAN-5: HRT now at top instead of at bottom for standalones, following BWIPP CLI: batch mode: don't close input if stdin EAN/UPC: fix excess 1X to right of add-ons Composites: fix excess whitespace; fix quiet zone calcs to allow for linear shifting CLI: use own (Wine) version of `CommandLineToArgvW()` to avoid loading "shell32.dll" Move "font.h" -> "raster_font.h" EPS/SVG: use new `out_putsf()` func to output floats, avoiding trailing zeroes & locale dependency EPS: simplify "TR" formula SVG: change font from "Helvetica, sans serif" to "OCR-B, monospace"; use single "<path>" instead of multiple "<rect>"s to draw boxes (reduces file size) Add `EMBED_VECTOR_FONT` to `output_options` (CLI `--embedfont`) to enable embedding of font in vector output - currently only for SVG output of EAN/UPC GUI: use "OCR-B" font for EAN/UPC and "Arimo" for all others (was "Helvetica" for both); paint background of screen preview light grey so as contrasts with whitespace and quiet zones EMF: prefix funcs with `emf_`; simplify string `halign` handling large: rename `large_int` -> `large_uint` CODE128/common: move `c128_hrt_cpy_iso8859_1()` to `hrt_cpy_iso8859_1()` and add `ZINT_WARN_HRT_TRUNCATED` warning (for future use) Various symbologies: replace `printf()` with `fputs()` (symbol->debug) QRCODE: better assert(), removing a NOLINT (2 left) CLI: add some more barcode synonyms for DBAR common: various fiddlings CMake: don't include png.c unless ZINT_USE_PNG (avoids clang warning)
2023-06-12 12:25:55 +12:00
if(ZINT_USE_PNG)
find_package(PNG)
endif()
set(zint_COMMON_SRCS common.c library.c large.c reedsol.c gs1.c eci.c filemem.c general_field.c)
2022-07-04 02:47:56 +12:00
set(zint_ONEDIM_SRCS bc412.c code.c code128.c 2of5.c upcean.c telepen.c medical.c plessey.c rss.c)
2018-02-07 09:57:01 +13:00
set(zint_POSTAL_SRCS postal.c auspost.c imail.c mailmark.c)
2019-03-21 22:14:24 +13:00
set(zint_TWODIM_SRCS code16k.c codablock.c dmatrix.c pdf417.c qr.c maxicode.c composite.c aztec.c code49.c code1.c gridmtx.c hanxin.c dotcode.c ultra.c)
EAN/UPC: add quiet zone indicators option (API `output_options` `EANUPC_GUARD_WHITESPACE`, CLI `--guardwhitespace`) (ticket #287) EAN-2/EAN-5: HRT now at top instead of at bottom for standalones, following BWIPP CLI: batch mode: don't close input if stdin EAN/UPC: fix excess 1X to right of add-ons Composites: fix excess whitespace; fix quiet zone calcs to allow for linear shifting CLI: use own (Wine) version of `CommandLineToArgvW()` to avoid loading "shell32.dll" Move "font.h" -> "raster_font.h" EPS/SVG: use new `out_putsf()` func to output floats, avoiding trailing zeroes & locale dependency EPS: simplify "TR" formula SVG: change font from "Helvetica, sans serif" to "OCR-B, monospace"; use single "<path>" instead of multiple "<rect>"s to draw boxes (reduces file size) Add `EMBED_VECTOR_FONT` to `output_options` (CLI `--embedfont`) to enable embedding of font in vector output - currently only for SVG output of EAN/UPC GUI: use "OCR-B" font for EAN/UPC and "Arimo" for all others (was "Helvetica" for both); paint background of screen preview light grey so as contrasts with whitespace and quiet zones EMF: prefix funcs with `emf_`; simplify string `halign` handling large: rename `large_int` -> `large_uint` CODE128/common: move `c128_hrt_cpy_iso8859_1()` to `hrt_cpy_iso8859_1()` and add `ZINT_WARN_HRT_TRUNCATED` warning (for future use) Various symbologies: replace `printf()` with `fputs()` (symbol->debug) QRCODE: better assert(), removing a NOLINT (2 left) CLI: add some more barcode synonyms for DBAR common: various fiddlings CMake: don't include png.c unless ZINT_USE_PNG (avoids clang warning)
2023-06-12 12:25:55 +12:00
if(ZINT_USE_PNG AND PNG_FOUND)
set(zint_OUTPUT_SRCS vector.c ps.c svg.c emf.c bmp.c pcx.c gif.c png.c tif.c raster.c output.c)
else()
set(zint_OUTPUT_SRCS vector.c ps.c svg.c emf.c bmp.c pcx.c gif.c tif.c raster.c output.c)
endif()
set(zint_SRCS ${zint_OUTPUT_SRCS} ${zint_COMMON_SRCS} ${zint_ONEDIM_SRCS} ${zint_POSTAL_SRCS} ${zint_TWODIM_SRCS})
2008-09-19 02:44:52 +12:00
if(ZINT_SHARED)
add_library(zint SHARED ${zint_SRCS})
if(WIN32)
target_sources(${PROJECT_NAME} PRIVATE libzint.rc)
endif()
2021-10-22 03:53:22 +13:00
endif()
2020-03-30 22:54:21 +13:00
if(ZINT_STATIC)
add_library(zint-static STATIC ${zint_SRCS})
if(WIN32)
set_target_properties(zint-static PROPERTIES OUTPUT_NAME zint-static)
else()
set_target_properties(zint-static PROPERTIES OUTPUT_NAME zint)
endif()
endif()
2008-09-19 02:44:52 +12:00
function(zint_target_link_libraries library)
if(ZINT_SHARED)
target_link_libraries(zint ${library})
endif()
if(ZINT_STATIC)
target_link_libraries(zint-static ${library})
endif()
endfunction()
function(zint_target_compile_definitions scope definition)
if(ZINT_SHARED)
target_compile_definitions(zint ${scope} ${definition})
endif()
if(ZINT_STATIC)
target_compile_definitions(zint-static ${scope} ${definition})
endif()
endfunction()
function(zint_target_compile_options scope option)
if(ZINT_SHARED)
target_compile_options(zint ${scope} ${option})
endif()
if(ZINT_STATIC)
target_compile_options(zint-static ${scope} ${option})
endif()
endfunction()
function(zint_target_include_directories)
2022-11-22 03:56:52 +13:00
if(ZINT_SHARED)
target_include_directories(zint ${ARGN})
2022-11-22 03:56:52 +13:00
endif()
if(ZINT_STATIC)
target_include_directories(zint-static ${ARGN})
2022-11-22 03:56:52 +13:00
endif()
endfunction()
if(ZINT_SHARED)
set_target_properties(zint PROPERTIES SOVERSION "${ZINT_VERSION_MAJOR}.${ZINT_VERSION_MINOR}"
VERSION ${ZINT_VERSION})
endif()
2008-09-19 02:44:52 +12:00
if(ZINT_USE_PNG AND PNG_FOUND)
zint_target_link_libraries(PNG::PNG)
message(STATUS "Using PNG")
else()
zint_target_compile_definitions(PRIVATE ZINT_NO_PNG)
message(STATUS "Not using PNG")
endif()
if(ZINT_TEST)
zint_target_compile_definitions(PUBLIC ZINT_TEST)
endif()
check_c_compiler_flag("-Wc90-c99-compat" C_COMPILER_FLAG_WC90_C99_COMPAT)
if(C_COMPILER_FLAG_WC90_C99_COMPAT)
zint_target_compile_options(PRIVATE "-Wc90-c99-compat")
endif()
if(NOT MSVC)
# Link with standard C math library.
zint_target_link_libraries(m)
endif()
if(MSVC)
2022-12-20 05:34:43 +13:00
if(ZINT_SHARED)
target_compile_definitions(zint PRIVATE DLL_EXPORT)
endif()
endif()
2008-09-19 02:44:52 +12:00
2022-11-22 03:56:52 +13:00
zint_target_include_directories(PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
2022-11-22 03:56:52 +13:00
)
# Adapted from old (2008) KDE "SetPaths.cmake" to use GNUInstallDirs
set(INSTALL_TARGETS_DEFAULT_ARGS RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT Devel)
if(ZINT_SHARED)
2022-11-22 03:56:52 +13:00
install(TARGETS zint EXPORT zint-targets ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()
if(ZINT_STATIC)
2022-11-22 03:56:52 +13:00
install(TARGETS zint-static EXPORT zint-targets ${INSTALL_TARGETS_DEFAULT_ARGS})
endif()
install(EXPORT zint-targets NAMESPACE zint:: DESTINATION "${CMAKE_INSTALL_DATADIR}/zint")
install(FILES zint.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT Devel)
if(ZINT_TEST)
add_subdirectory(tests)
endif()