From 1e8cbf6590198e788cdc046c4beb00af327b0d84 Mon Sep 17 00:00:00 2001 From: lins05 Date: Fri, 27 Sep 2013 17:17:12 +0800 Subject: [PATCH] make it compile on windows --- Application.manifest | 16 ++++++++++++++++ CMakeLists.txt | 18 ++++++++++++++---- seafile-applet.rc | 1 + src/configurator.cpp | 6 ++++++ src/ui/init-seafile-dialog.cpp | 10 +++++++--- src/utils/process-win.cpp | 16 ++++++++++++---- src/utils/utils.cpp | 1 - 7 files changed, 56 insertions(+), 12 deletions(-) create mode 100644 Application.manifest create mode 100644 seafile-applet.rc diff --git a/Application.manifest b/Application.manifest new file mode 100644 index 00000000..f0f460c2 --- /dev/null +++ b/Application.manifest @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index bf97397a..41c99e31 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,18 @@ INCLUDE(FindPkgConfig) SET(CMAKE_BUILD_TYPE Debug) + +IF (MSYS) + SET(EXTRA_LIBS ${EXTRA_LIBS} psapi) + + # SET(CMAKE_RC_COMPILER_INIT windres) + # ENABLE_LANGUAGE(RC) + # SET(CMAKE_RC_COMPILE_OBJECT " -O coff -i -o ") + + SET(EXTRA_SOURCES ${EXTRA_SOURCES} seafile-applet.rc) +ENDIF (MSYS) + + #################### ###### BEGIN: QT configuration #################### @@ -185,13 +197,11 @@ ADD_EXECUTABLE(seafile-applet ${moc_output} ${ui_output} ${resources_ouput} + ${EXTRA_SOURCES} ) INSTALL(TARGETS seafile-applet DESTINATION bin) -if (MSYS) - set(EXTRA_LIBS ${EXTRA_LIBS} psapi) -endif (MSYS) TARGET_LINK_LIBRARIES(seafile-applet ${QT_LIBRARIES} @@ -209,4 +219,4 @@ set(ARCHIVE_NAME ${CMAKE_PROJECT_NAME}-${PROJECT_VERSION}) add_custom_target(dist COMMAND git archive -v --prefix=${ARCHIVE_NAME}/ HEAD | gzip > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.gz - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) \ No newline at end of file + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) diff --git a/seafile-applet.rc b/seafile-applet.rc new file mode 100644 index 00000000..bcc2f0c3 --- /dev/null +++ b/seafile-applet.rc @@ -0,0 +1 @@ +1 24 DISCARDABLE Application.manifest \ No newline at end of file diff --git a/src/configurator.cpp b/src/configurator.cpp index ddfd7b4e..50340399 100644 --- a/src/configurator.cpp +++ b/src/configurator.cpp @@ -11,6 +11,12 @@ #include "configurator.h" +#if defined(Q_WS_WIN) +#include +#include +#endif + + namespace { #if defined(Q_WS_WIN) diff --git a/src/ui/init-seafile-dialog.cpp b/src/ui/init-seafile-dialog.cpp index 97e5a663..abb74c4b 100644 --- a/src/ui/init-seafile-dialog.cpp +++ b/src/ui/init-seafile-dialog.cpp @@ -7,10 +7,14 @@ namespace { #if defined(Q_WS_WIN) + +#include +#include + static QString get_largest_drive() { - wchar_t drives[SEAF_PATH_MAX]; + wchar_t drives[MAX_PATH]; wchar_t *p, *largest_drive; ULARGE_INTEGER free_space; ULARGE_INTEGER largest_free_space; @@ -34,8 +38,8 @@ get_largest_drive() } } else { - applet_warning ("failed to GetDiskFreeSpaceEx(), GLE=%lu\n", - GetLastError()); + qDebug ("failed to GetDiskFreeSpaceEx(), GLE=%lu\n", + GetLastError()); } } diff --git a/src/utils/process-win.cpp b/src/utils/process-win.cpp index 9920fbee..aef54ea9 100644 --- a/src/utils/process-win.cpp +++ b/src/utils/process-win.cpp @@ -1,8 +1,16 @@ -#include "process.h" - #include #include +#include +#include +#include +#include +#include +#include +#include + +#include "process.h" + namespace { HANDLE @@ -87,8 +95,8 @@ void shutdown_process (const char *name) int count_process (const char *process_name_in) { - char name[SEAF_PATH_MAX]; - char process_name[SEAF_PATH_MAX]; + char name[MAX_PATH]; + char process_name[MAX_PATH]; DWORD aProcesses[1024], cbNeeded, cProcesses; HANDLE hProcess; HMODULE hMods[1024]; diff --git a/src/utils/utils.cpp b/src/utils/utils.cpp index e4fb92a8..ed37591f 100644 --- a/src/utils/utils.cpp +++ b/src/utils/utils.cpp @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include