1
0
mirror of https://git.code.sf.net/p/zint/code synced 2025-12-28 15:27:07 +00:00
Files
zint/cmake/zint_add_test.cmake
gitlost a3f6c75bc0 CLI: add ZINT_TEST-only "--test" option (currently just ensures
the barcode name table is sorted so binary chop works), adding
  `ZINT_HAVE_GS1SE` define to "zint_add_test.cmake" - allows
  `test_barcode_symbology()` in "test_args.c" to be a lot less
  verbose; `const`-up various variables;
manual: use better MAILMAKE_4S example data and mention special
  fixed string international destination
2025-12-26 18:22:48 +00:00

48 lines
2.5 KiB
CMake

# Copyright (C) 2021-2025 Robin Stuart <rstuart114@gmail.com>
# Adapted from qrencode/tests/CMakeLists.txt
# Copyright (C) 2006-2017 Kentaro Fukuchi <kentaro@fukuchi.org>
# vim: set ts=4 sw=4 et :
macro(zint_add_test test_name test_command)
set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS})
if(ZINT_SHARED)
add_executable(${test_command} ${test_command}.c)
target_link_libraries(${test_command} testcommon ${ADDITIONAL_LIBS})
if(NOT (ZINT_USE_PNG AND PNG_FOUND))
target_compile_definitions(${test_command} PRIVATE ZINT_NO_PNG)
endif()
if(ZINT_USE_GS1SE AND GS1SE)
target_compile_definitions(${test_command} PRIVATE ZINT_HAVE_GS1SE)
endif()
add_test(${test_name} ${test_command})
if(MSVC)
string(REPLACE ";" "\\;" env_path "$ENV{PATH}")
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};PATH=${CMAKE_BINARY_DIR}/backend/${CMAKE_BUILD_TYPE}\;${CMAKE_BINARY_DIR}/frontend/${CMAKE_BUILD_TYPE}\;${env_path}")
else()
set_tests_properties(${test_name} PROPERTIES ENVIRONMENT
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/backend;PATH=${CMAKE_BINARY_DIR}/frontend:$ENV{PATH}")
endif()
endif()
if(ZINT_STATIC)
add_executable(${test_command}-static ${test_command}.c)
target_link_libraries(${test_command}-static testcommon-static ${ADDITIONAL_LIBS})
if(NOT (ZINT_USE_PNG AND PNG_FOUND))
target_compile_definitions(${test_command}-static PRIVATE ZINT_NO_PNG)
endif()
if(ZINT_USE_GS1SE AND GS1SE)
target_compile_definitions(${test_command}-static PRIVATE ZINT_HAVE_GS1SE)
endif()
add_test(${test_name}-static ${test_command}-static)
if(MSVC)
string(REPLACE ";" "\\;" env_path "$ENV{PATH}")
set_tests_properties(${test_name}-static PROPERTIES ENVIRONMENT
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};PATH=${CMAKE_BINARY_DIR}/backend/${CMAKE_BUILD_TYPE}\;${CMAKE_BINARY_DIR}/frontend/${CMAKE_BUILD_TYPE}\;${env_path}")
else()
set_tests_properties(${test_name}-static PROPERTIES ENVIRONMENT
"CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR};LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/backend;PATH=${CMAKE_BINARY_DIR}/frontend:$ENV{PATH}")
endif()
endif()
endmacro()