diff --git a/frontend/CMakeLists.txt b/frontend/CMakeLists.txt index aac8a4c9..b8cf0d4b 100644 --- a/frontend/CMakeLists.txt +++ b/frontend/CMakeLists.txt @@ -21,3 +21,7 @@ set_target_properties(zint_frontend PROPERTIES OUTPUT_NAME "zint") target_link_libraries(zint_frontend zint) install(TARGETS zint_frontend DESTINATION "${BIN_INSTALL_DIR}" RUNTIME) + +if(ZINT_TEST) + add_subdirectory(tests) +endif(ZINT_TEST) diff --git a/frontend/tests/CMakeLists.txt b/frontend/tests/CMakeLists.txt index 218f5879..7d06f8a7 100644 --- a/frontend/tests/CMakeLists.txt +++ b/frontend/tests/CMakeLists.txt @@ -8,51 +8,16 @@ project(zint_frontend_tests) enable_testing() -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") - -set(ZINT_DEBUG FALSE CACHE BOOL "Set debug compile flag") -set(ZINT_SANITIZE FALSE CACHE BOOL "Set sanitize compile/link flags") - -find_package(LibZint REQUIRED) -find_package(PNG REQUIRED) - -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() - -include_directories(../../backend/tests) -add_library(testcommon STATIC IMPORTED GLOBAL) -set_target_properties(testcommon PROPERTIES IMPORTED_LOCATION "../../../backend/tests/build/libtestcommon.a") - macro(zint_add_test test_name test_command) set(ADDITIONAL_LIBS "${ARGN}" ${LIBRARY_FLAGS}) add_executable(${test_command} ${test_command}.c) - target_link_libraries(${test_command} testcommon ZINT::ZINT ${PNG_LIBRARIES} ${ADDITIONAL_LIBS}) + target_link_libraries(${test_command} testcommon ${ADDITIONAL_LIBS}) add_test(${test_name} ${test_command}) + if(ZINT_STATIC) + add_executable(${test_command}-static ${test_command}.c) + target_link_libraries(${test_command}-static testcommon-static ${ADDITIONAL_LIBS}) + add_test(${test_name}-static ${test_command}-static) + endif() endmacro() -zint_add_test(args, test_args) +zint_add_test(args test_args) diff --git a/frontend/tests/README b/frontend/tests/README index 11293c47..85931514 100644 --- a/frontend/tests/README +++ b/frontend/tests/README @@ -1,26 +1,7 @@ Zint frontend test suite ------------------------ -See /backend/tests/README first to build the backend test suite, as -its library /backend/tests/build/libtestcommon.a is used here. Then - - cd - cd frontend/tests - mkdir build - cd build - cmake .. - make - -If the backend test suite was made with -DZINT_SANITIZE:BOOL=1 then instead - - cd - cd frontend/tests - mkdir build - cd build - cmake -DZINT_SANITIZE:BOOL=1 .. - make - --DZINT_DEBUG:BOOL=1 can also be used. +See /backend/tests/README to see how to build the test suite. ------------------------------------------------------------------------------