diff --git a/examples/qt-lib/CMakeLists.txt b/examples/qt-lib/CMakeLists.txt index 8efd4dd..5db4599 100644 --- a/examples/qt-lib/CMakeLists.txt +++ b/examples/qt-lib/CMakeLists.txt @@ -1,19 +1,19 @@ cmake_minimum_required(VERSION 3.0.0) project(SnoreToastQtExample VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Core REQUIRED) find_package(Qt5Gui REQUIRED) find_package(Qt5Network REQUIRED) if (NOT TARGET SnoreToast::LibSnoreToast) find_package(LibSnoreToast REQUIRED) endif() add_executable(${PROJECT_NAME} "main.cpp") -target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui SnoreToast::LibSnoreToast SnoreToast::LibSnoreToastActions) +target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui SnoreToast::LibSnoreToast) diff --git a/examples/qt/CMakeLists.txt b/examples/qt/CMakeLists.txt index fb83017..49732c3 100644 --- a/examples/qt/CMakeLists.txt +++ b/examples/qt/CMakeLists.txt @@ -1,18 +1,19 @@ cmake_minimum_required(VERSION 3.0.0) project(SnoreToastCliQtExample VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_AUTOMOC ON) find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) -if (NOT TARGET SnoreToast::SnoreToast) +# if build as part of snoretoast project we don't look it up +if (NOT TARGET SnoreToast::SnoreToastActions) find_package(LibSnoreToast REQUIRED) endif() add_executable(${PROJECT_NAME} "main.cpp") -target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network) +target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Network SnoreToast::SnoreToastActions) diff --git a/examples/qt/main.cpp b/examples/qt/main.cpp index c5b7072..6499908 100644 --- a/examples/qt/main.cpp +++ b/examples/qt/main.cpp @@ -1,85 +1,85 @@ /* SnoreToast is capable to invoke Windows 8 toast notifications. Copyright (C) 2019 Hannah von Reth SnoreToast is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. SnoreToast is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with SnoreToast. If not, see . */ #include #include #include #include #include #include #include -#include "../../src/snoretoastactions.h" +#include int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); QLocalServer *server = new QLocalServer(); QObject::connect(server, &QLocalServer::newConnection, server, [server]() { auto sock = server->nextPendingConnection(); sock->waitForReadyRead(); const QByteArray rawData = sock->readAll(); const QString data = QString::fromWCharArray(reinterpret_cast(rawData.constData()), rawData.size() / sizeof(wchar_t)); QMap map; for (const auto &str : data.split(";")) { const auto index = str.indexOf("="); map[str.mid(0, index)] = str.mid(index + 1); } const auto action = map["action"]; std::wstring waction(action.size(), 0); action.toWCharArray(waction.data()); std::wcout << qPrintable(data) << std::endl; std::wcout << "Action: " << waction << " " << static_cast(SnoreToastActions::getAction(waction)) << std::endl; // TODO: parse data }); server->listen("foo"); std::wcout << qPrintable(server->fullServerName()) << std::endl; const QString appId = "SnoreToast.Qt.Example"; QProcess proc(&a); proc.start("SnoreToast.exe", { "-install", "SnoreToastTestQt", a.applicationFilePath(), appId }); proc.waitForFinished(); std::wcout << proc.exitCode() << std::endl; std::wcout << qPrintable(proc.readAll()) << std::endl; QTimer *timer = new QTimer(&a); a.connect(timer, &QTimer::timeout, timer, [&] { static int id = 0; if (id >= 10) { timer->stop(); } auto proc = new QProcess(&a); proc->start("SnoreToast.exe", { "-t", "test", "-m", "message", "-pipename", server->fullServerName(), "-w", "-id", QString::number(id++), "-appId", appId, "-application", a.applicationFilePath() }); proc->connect(proc, QOverload::of(&QProcess::finished), proc, [proc] { std::wcout << qPrintable(proc->readAll()) << std::endl; std::wcout << proc->exitCode() << std::endl; }); }); timer->start(1000); return a.exec(); } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ac3b962..7259098 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,37 +1,37 @@ +add_library(SnoreToastActions INTERFACE) +target_include_directories(SnoreToastActions INTERFACE + $ + $ +) +add_library(SnoreToast::SnoreToastActions ALIAS SnoreToastActions) + + add_library(libsnoretoast STATIC snoretoasts.cpp toasteventhandler.cpp linkhelper.cpp utils.cpp) -target_link_libraries(libsnoretoast PUBLIC runtimeobject shlwapi) +target_link_libraries(libsnoretoast PUBLIC runtimeobject shlwapi SnoreToast::SnoreToastActions) target_compile_definitions(libsnoretoast PRIVATE UNICODE _UNICODE __WRL_CLASSIC_COM_STRICT__ WIN32_LEAN_AND_MEAN NOMINMAX) target_compile_definitions(libsnoretoast PRIVATE SNORETOAST_VERSION_MAJOR=${PROJECT_VERSION_MAJOR} SNORETOAST_VERSION_MINOR=${PROJECT_VERSION_MINOR} SNORETOAST_VERSION_PATCH=${PROJECT_VERSION_PATCH} ) target_compile_definitions(libsnoretoast PUBLIC __WRL_CLASSIC_COM_STRICT__) target_include_directories(libsnoretoast PUBLIC $) set_target_properties(libsnoretoast PROPERTIES EXPORT_NAME LibSnoreToast) add_library(SnoreToast::LibSnoreToast ALIAS libsnoretoast) -add_library(libsnoretoast_actions INTERFACE) -target_include_directories(libsnoretoast_actions INTERFACE - $ - $ -) -add_library(SnoreToast::LibSnoreToastActions ALIAS libsnoretoast_actions) generate_export_header(libsnoretoast) add_executable(SnoreToast WIN32 main.cpp ${SNORE_TOAST_DEPS}) -target_link_libraries(SnoreToast libsnoretoast) +target_link_libraries(SnoreToast SnoreToast::LibSnoreToast) target_compile_definitions(SnoreToast PRIVATE UNICODE _UNICODE WIN32_LEAN_AND_MEAN NOMINMAX) -add_executable(SnoreToast::SnoreToast ALIAS SnoreToast) - - # if there are changes to the callback mechanism we need to change the uuid for the activator SNORETOAST_CALLBACK_UUID target_compile_definitions(SnoreToast PRIVATE SNORETOAST_CALLBACK_UUID="{383803B6-AFDA-4220-BFC3-0DBF810106BF}" ) +add_executable(SnoreToast::SnoreToast ALIAS SnoreToast) -install(TARGETS libsnoretoast SnoreToast libsnoretoast_actions EXPORT LibSnoreToastConfig RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) +install(TARGETS libsnoretoast SnoreToast SnoreToastActions EXPORT LibSnoreToastConfig RUNTIME DESTINATION bin LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) install(FILES snoretoastactions.h DESTINATION includes/snoretoast) install(EXPORT LibSnoreToastConfig DESTINATION lib/cmake/libsnoretoast NAMESPACE SnoreToast::)