mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Make tests use main chatterino project objects (#2840)
This commit is contained in:
parent
5512437f1b
commit
91b0170241
|
@ -58,7 +58,6 @@ find_package(Threads REQUIRED)
|
|||
|
||||
find_library(LIBRT rt)
|
||||
|
||||
if (BUILD_APP)
|
||||
if (USE_SYSTEM_LIBCOMMUNI)
|
||||
find_package(LibCommuni REQUIRED)
|
||||
else()
|
||||
|
@ -90,7 +89,6 @@ if (BUILD_APP)
|
|||
find_package(RapidJSON REQUIRED)
|
||||
|
||||
find_package(Websocketpp REQUIRED)
|
||||
endif ()
|
||||
|
||||
if (BUILD_TESTS)
|
||||
find_package(GTest REQUIRED)
|
||||
|
@ -113,9 +111,12 @@ endif()
|
|||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if (BUILD_APP)
|
||||
add_subdirectory(src)
|
||||
if (BUILD_TESTS)
|
||||
add_definitions(-DCHATTERINO_TEST)
|
||||
endif ()
|
||||
|
||||
add_subdirectory(src)
|
||||
|
||||
if (BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6a71d6c395af2134ff56c50a5d056866ac4f3134
|
||||
Subproject commit 7cf8431d644332107a51a46c1e3de70e64692f0c
|
|
@ -1,4 +1,7 @@
|
|||
set(SOURCE_FILES main.cpp
|
||||
set(LIBRARY_PROJECT "${PROJECT_NAME}-lib")
|
||||
set(EXECUTABLE_PROJECT "${PROJECT_NAME}")
|
||||
|
||||
set(SOURCE_FILES
|
||||
Application.cpp
|
||||
Application.hpp
|
||||
BaseSettings.cpp
|
||||
|
@ -471,68 +474,10 @@ endif ()
|
|||
# Generate source groups for use in IDEs
|
||||
source_group(TREE ${CMAKE_SOURCE_DIR} FILES ${SOURCE_FILES})
|
||||
|
||||
add_executable(${PROJECT_NAME} ${SOURCE_FILES})
|
||||
add_sanitizers(${PROJECT_NAME})
|
||||
add_library(${LIBRARY_PROJECT} OBJECT ${SOURCE_FILES})
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
target_precompile_headers(${PROJECT_NAME} PRIVATE PrecompiledHeader.hpp)
|
||||
endif ()
|
||||
|
||||
# Enable autogeneration of Qts MOC/RCC/UIC
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
AUTOUIC ON
|
||||
)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
CHATTERINO
|
||||
UNICODE
|
||||
AB_CUSTOM_THEME
|
||||
AB_CUSTOM_SETTINGS
|
||||
IRC_STATIC
|
||||
IRC_NAMESPACE=Communi
|
||||
)
|
||||
if (USE_SYSTEM_QT5KEYCHAIN)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
CMAKE_BUILD
|
||||
)
|
||||
endif ()
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
CHATTERINO_GIT_HASH=\"${GIT_HASH}\"
|
||||
CHATTERINO_GIT_RELEASE=\"${GIT_RELEASE}\"
|
||||
CHATTERINO_GIT_COMMIT=\"${GIT_COMMIT}\"
|
||||
)
|
||||
if (WIN32)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
USEWINSDK
|
||||
)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${PROJECT_NAME} PRIVATE /EHsc)
|
||||
endif ()
|
||||
|
||||
if (APPLE)
|
||||
set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE TRUE)
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "Chatterino"
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "com.chatterino"
|
||||
MACOSX_BUNDLE_INFO_STRING "Chat client for Twitch"
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_ICON_FILE chatterino.icns
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
Qt5::Gui
|
||||
|
@ -540,42 +485,7 @@ target_link_libraries(${PROJECT_NAME}
|
|||
Qt5::Multimedia
|
||||
Qt5::Svg
|
||||
Qt5::Concurrent
|
||||
)
|
||||
|
||||
if (WinToast_FOUND)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
WinToast)
|
||||
endif ()
|
||||
|
||||
if (USE_CONAN AND TARGET CONAN_PKG::boost)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
CONAN_PKG::boost
|
||||
)
|
||||
else ()
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
Boost::boost
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (USE_CONAN AND TARGET CONAN_PKG::openssl)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
CONAN_PKG::openssl
|
||||
)
|
||||
else ()
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE ${RapidJSON_INCLUDE_DIRS})
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
LibCommuni::LibCommuni
|
||||
qt5keychain
|
||||
Pajlada::Serialize
|
||||
|
@ -586,14 +496,16 @@ target_link_libraries(${PROJECT_NAME}
|
|||
RapidJSON::RapidJSON
|
||||
LRUCache
|
||||
)
|
||||
if (LIBRT)
|
||||
target_link_libraries(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
${LIBRT}
|
||||
)
|
||||
endif ()
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
if (BUILD_APP)
|
||||
add_executable(${EXECUTABLE_PROJECT} main.cpp)
|
||||
add_sanitizers(${EXECUTABLE_PROJECT})
|
||||
|
||||
target_include_directories(${EXECUTABLE_PROJECT} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
target_link_libraries(${EXECUTABLE_PROJECT} PUBLIC ${LIBRARY_PROJECT})
|
||||
|
||||
set_target_properties(${EXECUTABLE_PROJECT}
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
|
@ -606,22 +518,22 @@ set_target_properties(${PROJECT_NAME}
|
|||
if (MSVC)
|
||||
get_target_property(Qt5_Core_Location Qt5::Core LOCATION)
|
||||
get_filename_component(QT_BIN_DIR ${Qt5_Core_Location} DIRECTORY)
|
||||
set(WINDEPLOYQT_COMMAND "${QT_BIN_DIR}/windeployqt.exe" $<TARGET_FILE:${PROJECT_NAME}> --release --no-compiler-runtime --no-translations --no-opengl-sw)
|
||||
set(WINDEPLOYQT_COMMAND "${QT_BIN_DIR}/windeployqt.exe" $<TARGET_FILE:${EXECUTABLE_PROJECT}> --release --no-compiler-runtime --no-translations --no-opengl-sw)
|
||||
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
install(TARGETS ${EXECUTABLE_PROJECT}
|
||||
RUNTIME DESTINATION .
|
||||
)
|
||||
|
||||
install(CODE "execute_process(COMMAND ${WINDEPLOYQT_COMMAND} --dir \${CMAKE_INSTALL_PREFIX})")
|
||||
elseif (APPLE)
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
install(TARGETS ${EXECUTABLE_PROJECT}
|
||||
RUNTIME DESTINATION bin
|
||||
BUNDLE DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib/static
|
||||
)
|
||||
else ()
|
||||
install(TARGETS ${PROJECT_NAME}
|
||||
install(TARGETS ${EXECUTABLE_PROJECT}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib/static
|
||||
|
@ -636,3 +548,103 @@ else ()
|
|||
DESTINATION share/icons/hicolor/256x256/apps
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (USE_PRECOMPILED_HEADERS)
|
||||
target_precompile_headers(${LIBRARY_PROJECT} PRIVATE PrecompiledHeader.hpp)
|
||||
endif ()
|
||||
|
||||
# Enable autogeneration of Qts MOC/RCC/UIC
|
||||
set_target_properties(${LIBRARY_PROJECT}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
AUTOUIC ON
|
||||
)
|
||||
|
||||
target_compile_definitions(${LIBRARY_PROJECT} PUBLIC
|
||||
CHATTERINO
|
||||
UNICODE
|
||||
AB_CUSTOM_THEME
|
||||
AB_CUSTOM_SETTINGS
|
||||
IRC_STATIC
|
||||
IRC_NAMESPACE=Communi
|
||||
|
||||
CHATTERINO_GIT_HASH=\"${GIT_HASH}\"
|
||||
CHATTERINO_GIT_RELEASE=\"${GIT_RELEASE}\"
|
||||
CHATTERINO_GIT_COMMIT=\"${GIT_COMMIT}\"
|
||||
)
|
||||
if (USE_SYSTEM_QT5KEYCHAIN)
|
||||
target_compile_definitions(${LIBRARY_PROJECT} PUBLIC
|
||||
CMAKE_BUILD
|
||||
)
|
||||
endif ()
|
||||
if (WIN32)
|
||||
target_compile_definitions(${LIBRARY_PROJECT} PUBLIC
|
||||
USEWINSDK
|
||||
)
|
||||
if (BUILD_APP)
|
||||
set_target_properties(${EXECUTABLE_PROJECT} PROPERTIES WIN32_EXECUTABLE TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(${LIBRARY_PROJECT} PUBLIC /EHsc)
|
||||
endif ()
|
||||
|
||||
if (APPLE AND BUILD_APP)
|
||||
set_target_properties(${EXECUTABLE_PROJECT} PROPERTIES MACOSX_BUNDLE TRUE)
|
||||
set_target_properties(${EXECUTABLE_PROJECT}
|
||||
PROPERTIES
|
||||
MACOSX_BUNDLE_BUNDLE_NAME "Chatterino"
|
||||
MACOSX_BUNDLE_GUI_IDENTIFIER "com.chatterino"
|
||||
MACOSX_BUNDLE_INFO_STRING "Chat client for Twitch"
|
||||
MACOSX_BUNDLE_LONG_VERSION_STRING "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_SHORT_VERSION_STRING "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_BUNDLE_VERSION "${PROJECT_VERSION}"
|
||||
MACOSX_BUNDLE_ICON_FILE chatterino.icns
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_include_directories(${LIBRARY_PROJECT} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if (WinToast_FOUND)
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
WinToast)
|
||||
endif ()
|
||||
|
||||
if (USE_CONAN AND TARGET CONAN_PKG::boost)
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
CONAN_PKG::boost
|
||||
)
|
||||
else ()
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
Boost::boost
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (USE_CONAN AND TARGET CONAN_PKG::openssl)
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
CONAN_PKG::openssl
|
||||
)
|
||||
else ()
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
OpenSSL::SSL
|
||||
OpenSSL::Crypto
|
||||
)
|
||||
endif ()
|
||||
|
||||
target_include_directories(${LIBRARY_PROJECT} PUBLIC ${RapidJSON_INCLUDE_DIRS})
|
||||
|
||||
if (LIBRT)
|
||||
target_link_libraries(${LIBRARY_PROJECT}
|
||||
PUBLIC
|
||||
${LIBRT}
|
||||
)
|
||||
endif ()
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include "singletons/Resources.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "util/FormatTime.hpp"
|
||||
#include "util/IrcHelpers.hpp"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QImageReader>
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <rapidjson/document.h>
|
||||
#include <QColor>
|
||||
#include <QElapsedTimer>
|
||||
#include <QString>
|
||||
|
||||
#include <functional>
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include "providers/twitch/TwitchEmotes.hpp"
|
||||
#include "providers/twitch/api/Helix.hpp"
|
||||
|
||||
#include <IrcConnection>
|
||||
#include <QColor>
|
||||
#include <QElapsedTimer>
|
||||
#include <QRegularExpression>
|
||||
|
|
|
@ -1,41 +1,5 @@
|
|||
project(chatterino-test)
|
||||
|
||||
set(main_dir ${CMAKE_SOURCE_DIR}/src)
|
||||
|
||||
include_directories(${main_dir})
|
||||
|
||||
set(chatterino_SOURCES
|
||||
${CMAKE_SOURCE_DIR}/src/BaseSettings.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/common/ChatterinoSetting.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/Modes.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/NetworkCommon.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/NetworkManager.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/NetworkPrivate.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/NetworkRequest.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/NetworkResult.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/QLogging.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/common/ChatterSet.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/debug/Benchmark.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/controllers/highlights/HighlightPhrase.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/messages/Emote.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/messages/Image.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/messages/ImageSet.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/providers/emoji/Emojis.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/singletons/Paths.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/src/util/DebugCount.cpp
|
||||
${CMAKE_SOURCE_DIR}/src/util/RapidjsonHelpers.cpp
|
||||
|
||||
${CMAKE_SOURCE_DIR}/resources/resources.qrc
|
||||
${CMAKE_SOURCE_DIR}/resources/resources_autogenerated.qrc
|
||||
)
|
||||
|
||||
set(test_SOURCES
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/main.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/src/AccessGuard.cpp
|
||||
|
@ -46,52 +10,17 @@ set(test_SOURCES
|
|||
${CMAKE_CURRENT_LIST_DIR}/src/Emojis.cpp
|
||||
)
|
||||
|
||||
add_executable(${PROJECT_NAME}
|
||||
${chatterino_SOURCES}
|
||||
${test_SOURCES}
|
||||
)
|
||||
add_executable(${PROJECT_NAME} ${test_SOURCES})
|
||||
add_sanitizers(${PROJECT_NAME})
|
||||
|
||||
# Enable autogeneration of Qts MOC/RCC/UIC
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
AUTOMOC ON
|
||||
AUTORCC ON
|
||||
AUTOUIC ON
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE chatterino-lib)
|
||||
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE
|
||||
Qt5::Core
|
||||
Qt5::Widgets
|
||||
Qt5::Network
|
||||
Qt5::Concurrent
|
||||
gtest gtest_main
|
||||
Pajlada::Serialize
|
||||
Pajlada::Settings
|
||||
Pajlada::Signals
|
||||
Threads::Threads
|
||||
LRUCache
|
||||
)
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE gtest)
|
||||
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
CHATTERINO
|
||||
CHATTERINO_TEST
|
||||
UNICODE
|
||||
AB_CUSTOM_THEME
|
||||
AB_CUSTOM_SETTINGS
|
||||
IRC_STATIC
|
||||
IRC_NAMESPACE=Communi
|
||||
CHATTERINO_GIT_HASH=\"${GIT_HASH}\"
|
||||
CHATTERINO_GIT_RELEASE=\"${GIT_RELEASE}\"
|
||||
CHATTERINO_GIT_COMMIT=\"${GIT_COMMIT}\"
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
||||
USEWINSDK
|
||||
)
|
||||
endif ()
|
||||
|
||||
set_target_properties(${PROJECT_NAME}
|
||||
PROPERTIES
|
||||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
|
||||
|
|
Loading…
Reference in a new issue