Unverified Commit a93a9eb2 authored by Carl Schwan's avatar Carl Schwan 🚴
Browse files

Use static lib for unit tests



Create a static link and use that for the unit tests and the qml plugin

Signed-off-by: Carl Schwan's avatarCarl Schwan <carl@carlschwan.eu>
parent d41e6fda
Pipeline #227087 passed with stage
in 3 minutes and 22 seconds
# SPDX-FileCopyrightText: 2022 Carl Schwan <carl@carlschwan.eu>
# SPDX-License-Identifier: BSD-2-Clause
ecm_add_qml_module(kalendar_mail_plugin URI "org.kde.kalendar.mail" VERSION 1.0)
if (BUILD_TESTING)
add_subdirectory(tests)
add_subdirectory(mime/tests)
add_subdirectory(mimetreeparser/autotests)
add_subdirectory(mimetreeparser/tests)
endif()
target_sources(kalendar_mail_plugin PUBLIC
mailplugin.cpp
mailplugin.h
set(kalendar_mail_SRCS
mailmanager.cpp
mailmanager.h
mailmodel.cpp
......@@ -35,6 +38,31 @@ target_sources(kalendar_mail_plugin PUBLIC
mime/partmodel.cpp
)
ecm_qt_declare_logging_category(kalendar_mail_SRCS
HEADER kalendar_mail_debug.h
IDENTIFIER "KALENDAR_MAIL_LOG"
CATEGORY_NAME org.kde.kalendar.mail
DESCRIPTION "kalendar mail"
EXPORT KALENDAR
)
ecm_qt_export_logging_category(
IDENTIFIER "KALENDAR_MAIL_LOG"
CATEGORY_NAME "org.kde.kalendar.mail"
DESCRIPTION "Kalendar - mail"
EXPORT KALENDAR
)
add_library(kalendar_mail_static STATIC ${kalendar_mail_SRCS})
target_link_libraries(kalendar_mail_static PUBLIC kalendar_lib KF5::MailCommon KF5::AkonadiMime)
ecm_add_qml_module(kalendar_mail_plugin URI "org.kde.kalendar.mail" VERSION 1.0)
target_sources(kalendar_mail_plugin PRIVATE
mailplugin.cpp
mailplugin.h
)
ecm_target_qml_sources(kalendar_mail_plugin SOURCES
qml/MailSidebar.qml
qml/FolderView.qml
......@@ -47,6 +75,12 @@ ecm_target_qml_sources(kalendar_mail_plugin
qml/private/MailDelegate.qml
)
ecm_target_qml_sources(kalendar_mail_plugin
PRIVATE PATH mailboxselector SOURCES
qml/mailboxselector/MailBoxList.qml
qml/mailboxselector/MailBoxListPage.qml
)
ecm_target_qml_sources(kalendar_mail_plugin
PRIVATE PATH mailpartview SOURCES
qml/mailpartview/HtmlPart.qml
......@@ -57,35 +91,7 @@ ecm_target_qml_sources(kalendar_mail_plugin
qml/mailpartview/TextPart.qml
)
ecm_target_qml_sources(kalendar_mail_plugin
PRIVATE PATH mailboxselector SOURCES
qml/mailboxselector/MailBoxList.qml
qml/mailboxselector/MailBoxListPage.qml
)
ecm_qt_declare_logging_category(kalendar_contact_plugin
HEADER kalendar_mail_debug.h
IDENTIFIER KALENDAR_MAIL_LOG
CATEGORY_NAME org.kde.kalendar.mail
DESCRIPTION "kalendar mail"
EXPORT KALENDAR
)
target_link_libraries(kalendar_mail_plugin PRIVATE kalendar_lib KF5::MailCommon KF5::AkonadiMime)
ecm_qt_install_logging_categories(
EXPORT KALENDAR
FILE kalendar.contact.categories
DESTINATION ${KDE_INSTALL_LOGGINGCATEGORIESDIR}
)
if (BUILD_TESTING)
add_subdirectory(tests)
add_subdirectory(mime/tests)
add_subdirectory(mimetreeparser/autotests)
add_subdirectory(mimetreeparser/tests)
endif()
target_link_libraries(kalendar_mail_plugin PUBLIC kalendar_mail_static)
ecm_finalize_qml_module(kalendar_mail_plugin
DESTINATION ${KDE_INSTALL_QMLDIR}
......
......@@ -3,25 +3,14 @@
add_definitions( -DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../testdata" )
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Test)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
include( ${CMAKE_SOURCE_DIR}/cmake/modules/add_gpg_crypto_test.cmake )
include(${CMAKE_SOURCE_DIR}/cmake/modules/add_gpg_crypto_test.cmake)
add_executable(mailtemplatetest
mailtemplatetest.cpp
)
add_executable(mailtemplatetest mailtemplatetest.cpp)
add_gpg_crypto_test(mailtemplatetest mailtemplatetest)
target_link_libraries(mailtemplatetest
Qt5::Core
Qt5::Test
kalendar_lib
KF5::MailCommon
KF5::AkonadiMime
kalendar_mail_plugin
kalendar_mail_static
)
# SPDX-FileCopyrightText: 2017 Christian Mollekopf <mollekopf@kolabsys.com>
# SPDX-License-Identifier: BSD-3-Clause
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
${GPGME_INCLUDE_DIRS}
)
set(AUTOMOC ON)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../testdata" )
......@@ -14,37 +8,30 @@ add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/../testdata" )
include(ECMAddTests)
include(${CMAKE_SOURCE_DIR}/cmake/modules/add_gpg_crypto_test.cmake)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Test)
function(add_mimetreeparser_class_unittest _name _additionalSource)
add_executable(${_name} ${_name}.cpp setupenv.cpp ${_additionalSource})
target_link_libraries(${_name}
Qt5::Core
target_link_libraries(${_name} PRIVATE
Qt5::Test
KF5::Mime
kalendar_lib
KF5::MailCommon
KF5::AkonadiMime
kalendar_mail_plugin
kalendar_mail_static
)
target_include_directories(${_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/..)
add_test(NAME ${_name} COMMAND $<TARGET_FILE:${_name}>)
endfunction()
function(add_mimetreeparser_crypto_unittest _name)
add_executable(${_name} ${_name}.cpp setupenv.cpp)
if (QT_MAJOR_VERSION STREQUAL "6")
target_link_libraries(${_name} QGpgmeQt6 Qt6::Core5Compat)
target_link_libraries(${_name} PRIVATE QGpgmeQt6 Qt6::Core5Compat)
else()
target_link_libraries(${_name} Gpgme::Gpgme)
target_link_libraries(${_name} PRIVATE Gpgme::Gpgme)
endif()
target_link_libraries(${_name}
Qt5::Core
target_include_directories(${_name} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/..
${GPGME_INCLUDE_DIRS}
)
target_link_libraries(${_name} PRIVATE
Qt5::Test
KF5::Mime
kalendar_lib
KF5::MailCommon
KF5::AkonadiMime
kalendar_mail_plugin
kalendar_mail_static
)
add_gpg_crypto_test(${_name} mimetreeparser-${_name})
endfunction()
......
......@@ -14,24 +14,14 @@ include(ECMAddTests)
add_executable(mimetreeparsertest mimetreeparsertest.cpp)
add_gpg_crypto_test(mimetreeparsertest mimetreeparsertest)
target_link_libraries(mimetreeparsertest
Qt5::Core
target_link_libraries(mimetreeparsertest PUBLIC
Qt5::Test
KF5::Mime
kalendar_lib
KF5::MailCommon
KF5::AkonadiMime
kalendar_mail_plugin
kalendar_mail_static
)
add_executable(gpgerrortest gpgerrortest.cpp)
target_link_libraries(gpgerrortest
Qt5::Core
target_link_libraries(gpgerrortest PUBLIC
Qt5::Test
KF5::Mime
kalendar_lib
KF5::MailCommon
KF5::AkonadiMime
kalendar_mail_plugin
kalendar_mail_static
)
add_test(NAME gpgerrortest COMMAND $<TARGET_FILE:gpgerrortest>)
......@@ -2,23 +2,15 @@
# SPDX-License-Identifier: BSD-3-Clause
include(${CMAKE_SOURCE_DIR}/cmake/modules/add_gpg_crypto_test.cmake)
include_directories(
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/..
)
include_directories(${GPGME_INCLUDE_DIRS})
include(ECMAddTests)
find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Test)
add_executable(cryptotest cryptotest.cpp)
target_include_directories(cryptotest PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
${CMAKE_CURRENT_BINARY_DIR}
${GPGME_INCLUDE_DIRS}
)
add_gpg_crypto_test(cryptotest cryptotest)
target_link_libraries(cryptotest
kalendar_lib
kalendar_mail_plugin
Qt5::Core
Qt5::Test
KF5::MailCommon
KF5::AkonadiMime
kalendar_mail_static
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment