From c8c25c4863aded63812bf75280311f5c419b1eed Mon Sep 17 00:00:00 2001 From: Markus Mittendrein Date: Sat, 12 Mar 2022 16:31:37 +0100 Subject: [PATCH] Add CMake option to disable the use of WinToast(Lib), needed for mingw build --- CMakeLists.txt | 10 +++++++++- cmake/filelists/EngineWin32.txt | 5 ----- config.h.cmake | 1 + src/C4Toast.cpp | 6 +++--- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fa16da629..460baa31a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,8 @@ CMAKE_DEPENDENT_OPTION(WITH_DEVELOPER_MODE "Use GTK for the developer mode" OFF "NOT USE_CONSOLE" OFF) # USE_LIBNOTIFY CMAKE_DEPENDENT_OPTION(USE_LIBNOTIFY "Use libnotify for desktop notifications" ON "WITH_DEVELOPER_MODE AND NOT USE_CONSOLE AND NOT WIN32" OFF) +# USE_WINTOAST +CMAKE_DEPENDENT_OPTION(USE_WINTOAST "Use WinToast for desktop notifications" ON "NOT USE_CONSOLE AND WIN32" OFF) # Use Microsoft CryptoAPI instead of OpenSSL when compiling for Windows if (WIN32) @@ -191,6 +193,13 @@ if (USE_LIBNOTIFY) src/C4ToastLibNotify.cpp src/C4ToastLibNotify.h) endif () +if (USE_WINTOAST) + target_include_directories(clonk PRIVATE src/WinToast/src) + list(APPEND CLONK_SOURCES + src/C4ToastWinToastLib.cpp src/C4ToastWinToastLib.h + src/WinToast/src/wintoastlib.cpp src/WinToast/src/wintoastlib.h) +endif () + if (USE_CONSOLE) add_executable(clonk ${CLONK_SOURCES}) else () @@ -319,7 +328,6 @@ endif () # Link Windows libraries if (WIN32) - target_include_directories(clonk PRIVATE src/WinToast/src) target_link_libraries(clonk dbghelp iphlpapi winmm ws2_32) if (USE_SDL_MIXER) diff --git a/cmake/filelists/EngineWin32.txt b/cmake/filelists/EngineWin32.txt index 9889c15da..ef872c65c 100644 --- a/cmake/filelists/EngineWin32.txt +++ b/cmake/filelists/EngineWin32.txt @@ -1,7 +1,5 @@ src/C4CrashHandlerWin32.cpp src/C4FileClasses.cpp -src/C4ToastWinToastLib.cpp -src/C4ToastWinToastLib.h src/C4Windows.h src/res/engine.rc src/res/engine_resource.h @@ -11,6 +9,3 @@ src/StdJoystick.h src/StdStringEncodingConverter.cpp src/StdStringEncodingConverter.h src/StdWindow.cpp - -src/WinToast/src/wintoastlib.cpp -src/WinToast/src/wintoastlib.h diff --git a/config.h.cmake b/config.h.cmake index 3b27b4f00..eecffa46d 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -8,6 +8,7 @@ #cmakedefine USE_SDL_FOR_GAMEPAD 1 #cmakedefine USE_STAT 1 #cmakedefine USE_X11 1 +#cmakedefine USE_WINTOAST 1 #cmakedefine WITH_DEVELOPER_MODE 1 #cmakedefine WITH_GLIB 1 diff --git a/src/C4Toast.cpp b/src/C4Toast.cpp index 811beb953..b468a4e7b 100644 --- a/src/C4Toast.cpp +++ b/src/C4Toast.cpp @@ -18,7 +18,7 @@ #ifdef USE_LIBNOTIFY #include "C4ToastLibNotify.h" -#elif defined(_WIN32) +#elif defined(USE_WINTOAST) #include "C4ToastWinToastLib.h" #endif @@ -28,7 +28,7 @@ C4ToastSystem *C4ToastSystem::NewInstance() { #ifdef USE_LIBNOTIFY return new C4ToastSystemLibNotify{}; -#elif defined(_WIN32) +#elif defined(USE_WINTOAST) return new C4ToastSystemWinToastLib{}; #else return nullptr; @@ -50,7 +50,7 @@ void C4ToastImpl::SetEventHandler(C4ToastEventHandler *const eventHandler) C4Toast::C4Toast() : impl{ #ifdef USE_LIBNOTIFY new C4ToastImplLibNotify{} -#elif defined(_WIN32) +#elif defined(USE_WINTOAST) new C4ToastImplWinToastLib{} #else new C4ToastImpl{}