From 602faa7b96d4467f127ccd581228ca7245283c32 Mon Sep 17 00:00:00 2001 From: Enar Vaikene Date: Fri, 25 May 2012 15:48:57 +0300 Subject: [PATCH] Changes to build the software with mingw on Windows. --- CMakeWin.txt | 17 ++++++++++++++++- src/apps/FileFinder/Engine/CMakeLists.txt | 4 ++-- src/apps/FileFinder/GUI/CMakeLists.txt | 4 ++-- src/apps/PswGen/CLI/CMakeLists.txt | 4 ++-- src/apps/PswGen/GUI/CMakeLists.txt | 4 ++-- src/apps/PswGen/Generator/CMakeLists.txt | 4 ++-- src/apps/PswGen/Storage/CMakeLists.txt | 4 ++-- src/libs/Common/CMakeLists.txt | 4 ++-- src/libs/Common/logger.cpp | 4 ++++ src/libs/Gui/CMakeLists.txt | 4 ++-- src/libs/Plugins/CMakeLists.txt | 4 ++-- src/libs/Plugins/pluginmanager.h | 4 ++++ src/main/CLI/CMakeLists.txt | 4 ++-- src/main/GUI/CMakeLists.txt | 4 ++-- src/plugins/LogView/CMakeLists.txt | 4 ++-- src/plugins/SdiWindow/CMakeLists.txt | 4 ++-- src/plugins/Test/CMakeLists.txt | 4 ++-- 17 files changed, 52 insertions(+), 29 deletions(-) diff --git a/CMakeWin.txt b/CMakeWin.txt index 6e43b9a..95a9500 100644 --- a/CMakeWin.txt +++ b/CMakeWin.txt @@ -1,3 +1,18 @@ # Extra rules for Windows builds -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-") +if(MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + + # gcc options for release and debug builds + IF(CMAKE_BUILD_TYPE STREQUAL Release) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2") + ELSE(CMAKE_BUILD_TYPE STREQUAL Release) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") + ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) + + set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--no-undefined") + +else(MINGW) + # Assume a Microsoft Visual C++ compiler + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:wchar_t-") +endif(MINGW) diff --git a/src/apps/FileFinder/Engine/CMakeLists.txt b/src/apps/FileFinder/Engine/CMakeLists.txt index 4e9e9ba..af9c24a 100644 --- a/src/apps/FileFinder/Engine/CMakeLists.txt +++ b/src/apps/FileFinder/Engine/CMakeLists.txt @@ -26,9 +26,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/apps/FileFinder/GUI/CMakeLists.txt b/src/apps/FileFinder/GUI/CMakeLists.txt index cdc585f..56b5db4 100644 --- a/src/apps/FileFinder/GUI/CMakeLists.txt +++ b/src/apps/FileFinder/GUI/CMakeLists.txt @@ -26,9 +26,9 @@ set(MOC_HDRS #) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_add_resources(RCC_SRCS ${RCCS}) diff --git a/src/apps/PswGen/CLI/CMakeLists.txt b/src/apps/PswGen/CLI/CMakeLists.txt index 63f57a7..ef8ee22 100644 --- a/src/apps/PswGen/CLI/CMakeLists.txt +++ b/src/apps/PswGen/CLI/CMakeLists.txt @@ -22,9 +22,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/apps/PswGen/GUI/CMakeLists.txt b/src/apps/PswGen/GUI/CMakeLists.txt index bea3cd6..561060e 100644 --- a/src/apps/PswGen/GUI/CMakeLists.txt +++ b/src/apps/PswGen/GUI/CMakeLists.txt @@ -21,9 +21,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/apps/PswGen/Generator/CMakeLists.txt b/src/apps/PswGen/Generator/CMakeLists.txt index 9325fe9..3d7c7eb 100644 --- a/src/apps/PswGen/Generator/CMakeLists.txt +++ b/src/apps/PswGen/Generator/CMakeLists.txt @@ -25,9 +25,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/apps/PswGen/Storage/CMakeLists.txt b/src/apps/PswGen/Storage/CMakeLists.txt index 13722c3..2169469 100644 --- a/src/apps/PswGen/Storage/CMakeLists.txt +++ b/src/apps/PswGen/Storage/CMakeLists.txt @@ -26,9 +26,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/libs/Common/CMakeLists.txt b/src/libs/Common/CMakeLists.txt index a9916b4..83affd4 100644 --- a/src/libs/Common/CMakeLists.txt +++ b/src/libs/Common/CMakeLists.txt @@ -45,9 +45,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/libs/Common/logger.cpp b/src/libs/Common/logger.cpp index bb88073..358b314 100644 --- a/src/libs/Common/logger.cpp +++ b/src/libs/Common/logger.cpp @@ -421,7 +421,11 @@ QString Logger::printf(char const * const fmt, ...) const va_list ap; #ifdef Q_OS_WIN32 va_start(ap, fmt); +# ifdef Q_CC_GNU + vsnprintf(str, sizeof(str), fmt, ap); +# else _vsnprintf_s(str, sizeof(str), _TRUNCATE, fmt, ap); +# endif va_end(ap); #else ::va_start(ap, fmt); diff --git a/src/libs/Gui/CMakeLists.txt b/src/libs/Gui/CMakeLists.txt index 19fd172..8821dc1 100644 --- a/src/libs/Gui/CMakeLists.txt +++ b/src/libs/Gui/CMakeLists.txt @@ -24,9 +24,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/libs/Plugins/CMakeLists.txt b/src/libs/Plugins/CMakeLists.txt index 0aadd65..edcfae6 100644 --- a/src/libs/Plugins/CMakeLists.txt +++ b/src/libs/Plugins/CMakeLists.txt @@ -29,9 +29,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/libs/Plugins/pluginmanager.h b/src/libs/Plugins/pluginmanager.h index f79193c..c9806af 100644 --- a/src/libs/Plugins/pluginmanager.h +++ b/src/libs/Plugins/pluginmanager.h @@ -58,7 +58,11 @@ namespace Internal { inline QString expandPluginName(QString const & name) { #ifdef Q_OS_WIN32 +# ifdef Q_CC_MINGW + return "lib" + name + ".dll"; +# else return name + ".dll"; +# endif #elif defined Q_OS_LINUX return "lib" + name + ".so"; #else diff --git a/src/main/CLI/CMakeLists.txt b/src/main/CLI/CMakeLists.txt index d6a5b14..a3983a6 100644 --- a/src/main/CLI/CMakeLists.txt +++ b/src/main/CLI/CMakeLists.txt @@ -23,9 +23,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc cli.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/main/GUI/CMakeLists.txt b/src/main/GUI/CMakeLists.txt index 8483bb5..367e2f5 100644 --- a/src/main/GUI/CMakeLists.txt +++ b/src/main/GUI/CMakeLists.txt @@ -38,9 +38,9 @@ set(MOC_HDRS #) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc gui.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_add_resources(RCC_SRCS ${RCCS}) diff --git a/src/plugins/LogView/CMakeLists.txt b/src/plugins/LogView/CMakeLists.txt index 8f68dd1..ac0d07f 100644 --- a/src/plugins/LogView/CMakeLists.txt +++ b/src/plugins/LogView/CMakeLists.txt @@ -26,9 +26,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/plugins/SdiWindow/CMakeLists.txt b/src/plugins/SdiWindow/CMakeLists.txt index c87eed6..cd0a8c0 100644 --- a/src/plugins/SdiWindow/CMakeLists.txt +++ b/src/plugins/SdiWindow/CMakeLists.txt @@ -26,9 +26,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) diff --git a/src/plugins/Test/CMakeLists.txt b/src/plugins/Test/CMakeLists.txt index 35393d7..bbf03ba 100644 --- a/src/plugins/Test/CMakeLists.txt +++ b/src/plugins/Test/CMakeLists.txt @@ -23,9 +23,9 @@ set(MOC_HDRS ) # Version info resource file for Windows builds -if(WIN32) +if(WIN32 AND NOT MINGW) set(SRCS ${SRCS} version.rc) -endif(WIN32) +endif(WIN32 AND NOT MINGW) qt4_wrap_cpp(MOC_SRCS ${MOC_HDRS}) -- 2.47.0