Turn zint tests into a subproject of backend

All dependency handling is implied via linking to the zint target. Options
are inherited from the backend build
This commit is contained in:
Schaich 2021-03-22 19:44:05 +09:00
parent 83bac8c8a5
commit 3e89058051
2 changed files with 5 additions and 50 deletions

View File

@ -47,3 +47,7 @@ endif()
install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS}) install(TARGETS zint ${INSTALL_TARGETS_DEFAULT_ARGS})
install(FILES zint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel) install(FILES zint.h DESTINATION ${INCLUDE_INSTALL_DIR} COMPONENT Devel)
if(ZINT_TEST)
add_subdirectory(tests)
endif(ZINT_TEST)

View File

@ -8,19 +8,6 @@ project(zint_backend_tests)
enable_testing() enable_testing()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
option(ZINT_DEBUG "Set debug compile flag" OFF)
option(ZINT_SANITIZE "Set sanitize compile/link flags" OFF)
option(ZINT_TEST "Set test compile flag" OFF)
find_package(LibZint REQUIRED)
find_package(PNG)
if(NOT PNG_FOUND)
add_definitions(-DNO_PNG)
endif()
set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz) set(BWIPP_TAR ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps.tar.xz)
set(BWIPP_PS ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps) set(BWIPP_PS ${CMAKE_CURRENT_SOURCE_DIR}/tools/bwipp_dump.ps)
@ -29,44 +16,8 @@ if(NOT EXISTS ${BWIPP_PS})
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/tools)
endif() endif()
include(CheckCCompilerFlag)
check_c_compiler_flag(-Wall C_COMPILER_FLAG_WALL)
if(C_COMPILER_FLAG_WALL)
add_compile_options("-Wall")
endif()
check_c_compiler_flag(-Wextra C_COMPILER_FLAG_WEXTRA)
if(C_COMPILER_FLAG_WEXTRA)
add_compile_options("-Wextra")
endif()
if(ZINT_DEBUG)
check_c_compiler_flag(-g C_COMPILER_FLAG_G)
if(C_COMPILER_FLAG_G)
add_compile_options("-g")
endif()
endif()
if(ZINT_SANITIZE)
# check_c_compiler_flag fails for -fsanitize
if(${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
add_compile_options("-fsanitize=undefined")
add_compile_options("-fsanitize=address")
link_libraries("-fsanitize=undefined -fsanitize=address")
endif()
endif()
if(ZINT_TEST)
add_definitions("-DZINT_TEST")
endif()
add_library(testcommon testcommon.c testcommon.h) add_library(testcommon testcommon.c testcommon.h)
if(PNG_FOUND) target_link_libraries(testcommon zint)
target_link_libraries(testcommon ZINT::ZINT PNG::PNG)
else()
target_link_libraries(testcommon ZINT::ZINT)
endif()
macro(zint_add_test test_name test_command) macro(zint_add_test test_name test_command)
set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS}) set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS})