2021-06-10 22:15:39 +12:00
|
|
|
# Copyright (C) 2008 by BogDan Vatra < bogdan@licentia.eu >
|
2024-06-22 02:18:00 +12:00
|
|
|
# Copyright (C) 2009-2024 Robin Stuart <rstuart114@gmail.com>
|
2020-12-01 04:51:14 +13:00
|
|
|
# vim: set ts=4 sw=4 et :
|
2008-09-19 02:44:52 +12:00
|
|
|
|
|
|
|
project(zint)
|
|
|
|
|
2023-06-12 12:25:55 +12:00
|
|
|
if(ZINT_USE_PNG)
|
|
|
|
find_package(PNG)
|
|
|
|
endif()
|
|
|
|
|
2023-12-28 08:20:19 +13:00
|
|
|
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)
|
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()
|
2016-07-20 10:02:39 +12:00
|
|
|
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
|
|
|
|
2022-11-22 00:41:29 +13:00
|
|
|
if(ZINT_SHARED)
|
|
|
|
add_library(zint SHARED ${zint_SRCS})
|
2020-12-01 04:51:14 +13:00
|
|
|
|
2022-11-22 00:41:29 +13:00
|
|
|
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)
|
2020-12-01 04:51:14 +13:00
|
|
|
add_library(zint-static STATIC ${zint_SRCS})
|
2022-11-22 00:41:29 +13:00
|
|
|
if(WIN32)
|
|
|
|
set_target_properties(zint-static PROPERTIES OUTPUT_NAME zint-static)
|
|
|
|
else()
|
|
|
|
set_target_properties(zint-static PROPERTIES OUTPUT_NAME zint)
|
|
|
|
endif()
|
2020-12-01 04:51:14 +13:00
|
|
|
endif()
|
2008-09-19 02:44:52 +12:00
|
|
|
|
2021-03-23 00:20:44 +13:00
|
|
|
function(zint_target_link_libraries library)
|
2022-11-22 00:41:29 +13:00
|
|
|
if(ZINT_SHARED)
|
|
|
|
target_link_libraries(zint ${library})
|
|
|
|
endif()
|
2021-03-23 00:20:44 +13:00
|
|
|
if(ZINT_STATIC)
|
|
|
|
target_link_libraries(zint-static ${library})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
function(zint_target_compile_definitions scope definition)
|
2022-11-22 00:41:29 +13:00
|
|
|
if(ZINT_SHARED)
|
|
|
|
target_compile_definitions(zint ${scope} ${definition})
|
|
|
|
endif()
|
2021-03-23 00:20:44 +13:00
|
|
|
if(ZINT_STATIC)
|
|
|
|
target_compile_definitions(zint-static ${scope} ${definition})
|
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2022-12-20 05:35:16 +13:00
|
|
|
function(zint_target_include_directories)
|
2022-11-22 03:56:52 +13:00
|
|
|
if(ZINT_SHARED)
|
2022-12-20 05:35:16 +13:00
|
|
|
target_include_directories(zint ${ARGN})
|
2022-11-22 03:56:52 +13:00
|
|
|
endif()
|
|
|
|
if(ZINT_STATIC)
|
2022-12-20 05:35:16 +13:00
|
|
|
target_include_directories(zint-static ${ARGN})
|
2022-11-22 03:56:52 +13:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
2022-11-22 00:41:29 +13:00
|
|
|
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
|
|
|
|
2021-03-30 03:35:57 +13:00
|
|
|
if(ZINT_USE_PNG AND PNG_FOUND)
|
2021-03-23 00:20:44 +13:00
|
|
|
zint_target_link_libraries(PNG::PNG)
|
2023-11-20 08:39:54 +13:00
|
|
|
message(STATUS "Using PNG")
|
2021-03-22 23:33:05 +13:00
|
|
|
else()
|
2022-11-25 03:18:31 +13:00
|
|
|
zint_target_compile_definitions(PRIVATE ZINT_NO_PNG)
|
2023-11-20 08:39:54 +13:00
|
|
|
message(STATUS "Not using PNG")
|
2021-03-22 23:33:05 +13:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(ZINT_TEST)
|
2021-03-23 00:20:44 +13:00
|
|
|
zint_target_compile_definitions(PUBLIC ZINT_TEST)
|
2020-12-01 04:51:14 +13:00
|
|
|
endif()
|
|
|
|
|
2018-12-12 21:37:56 +13:00
|
|
|
if(NOT MSVC)
|
2020-12-01 04:51:14 +13:00
|
|
|
# Link with standard C math library.
|
2021-03-23 00:20:44 +13:00
|
|
|
zint_target_link_libraries(m)
|
2020-12-01 04:51:14 +13:00
|
|
|
endif()
|
2018-12-12 21:37:56 +13:00
|
|
|
|
|
|
|
if(MSVC)
|
2022-12-20 05:34:43 +13:00
|
|
|
if(ZINT_SHARED)
|
|
|
|
target_compile_definitions(zint PRIVATE DLL_EXPORT)
|
|
|
|
endif()
|
2020-12-01 04:51:14 +13:00
|
|
|
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}>
|
2024-06-22 02:18:00 +12:00
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
2022-11-22 03:56:52 +13:00
|
|
|
)
|
|
|
|
|
2024-06-22 02:18:00 +12: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)
|
|
|
|
|
2022-11-22 00:41:29 +13:00
|
|
|
if(ZINT_SHARED)
|
2022-11-22 03:56:52 +13:00
|
|
|
install(TARGETS zint EXPORT zint-targets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
2022-11-22 00:41:29 +13:00
|
|
|
endif()
|
2021-07-07 06:53:31 +12:00
|
|
|
if(ZINT_STATIC)
|
2022-11-22 03:56:52 +13:00
|
|
|
install(TARGETS zint-static EXPORT zint-targets ${INSTALL_TARGETS_DEFAULT_ARGS})
|
2021-07-07 06:53:31 +12:00
|
|
|
endif()
|
2024-06-22 02:18:00 +12:00
|
|
|
install(EXPORT zint-targets NAMESPACE zint:: DESTINATION "${CMAKE_INSTALL_DATADIR}/zint")
|
|
|
|
install(FILES zint.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT Devel)
|
2021-03-22 23:44:05 +13:00
|
|
|
|
|
|
|
if(ZINT_TEST)
|
|
|
|
add_subdirectory(tests)
|
2021-06-10 22:15:39 +12:00
|
|
|
endif()
|