# sam — the plan9 sam structural-regexp command language engine.
#
# sam_lib is pure (QString in, edits out) and fully unit tested. It needs
# Qt Core for QString/QRegularExpression and Qt Core's QProcess for the shell
# filter commands (< > | !); no GUI dependency.
find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS Core REQUIRED)

add_library(sam_lib STATIC
    samengine.cpp
    samengine.h
    samregex.cpp
    samregex.h
)
target_link_libraries(sam_lib PUBLIC Qt6::Core)
target_include_directories(sam_lib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

find_package(Qt6 ${QT_MIN_VERSION} COMPONENTS Test)
if(Qt6Test_FOUND)
    add_executable(test_samengine test_samengine.cpp)
    target_link_libraries(test_samengine PRIVATE sam_lib Qt6::Test)
    add_test(NAME samengine COMMAND test_samengine)

    add_executable(test_samregex test_samregex.cpp)
    target_link_libraries(test_samregex PRIVATE sam_lib Qt6::Test)
    add_test(NAME samregex COMMAND test_samregex)
endif()
