diff --git a/CMakeLists.txt b/CMakeLists.txt index 716f107..365f915 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,12 @@ if (MSVC) add_compile_options(/utf-8) endif() +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") +message(STATUS "frelay use MINGW compiler.") +set(COMPILER_USE_MINGW ON) +add_definitions(-DCOMPILER_USE_MINGW) +endif() + if(WIN32) execute_process(COMMAND cmd /c ver OUTPUT_VARIABLE VER_OUTPUT diff --git a/Console/CMakeLists.txt b/Console/CMakeLists.txt index 1cfa74e..31ccda5 100644 --- a/Console/CMakeLists.txt +++ b/Console/CMakeLists.txt @@ -13,5 +13,10 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) add_executable(frelayConsole Console.h Console.cpp main.cpp ../Res/ico.rc) -target_link_libraries(frelayConsole PRIVATE Protocol Util crashelper) +target_link_libraries(frelayConsole PRIVATE Protocol Util) + +if(NOT DEFINED COMPILER_USE_MINGW) +target_link_libraries(frelayConsole PRIVATE crashelper) +endif() + target_link_libraries(frelayConsole PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network) \ No newline at end of file diff --git a/Console/main.cpp b/Console/main.cpp index 268e8b0..e044bf6 100644 --- a/Console/main.cpp +++ b/Console/main.cpp @@ -1,11 +1,16 @@ #include #include -#include #include "Console.h" +#ifndef COMPILER_USE_MINGW +#include +#endif + int main(int argc, char* argv[]) { + +#ifndef COMPILER_USE_MINGW auto configDir = Util::GetCurConfigPath("frelay"); #ifdef _WIN32 backward::SetDumpFileSavePath(configDir + "/dumpfile"); @@ -13,6 +18,8 @@ int main(int argc, char* argv[]) #else backward::SetDumpLogSavePath(configDir + QDir::separator() + "dumplog"); #endif +#endif + QCoreApplication app(argc, argv); Util::InitLogger("frelayConsole.log", "frelayConsole"); diff --git a/Gui/CMakeLists.txt b/Gui/CMakeLists.txt index 894b476..cc446e2 100644 --- a/Gui/CMakeLists.txt +++ b/Gui/CMakeLists.txt @@ -56,8 +56,12 @@ target_link_libraries(frelayGUI PRIVATE ClientCore Protocol Util Struct - crashelper ) + +if(NOT DEFINED COMPILER_USE_MINGW) +target_link_libraries(frelayGUI PRIVATE crashelper) +endif() + if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_SYSTEM_NAME MATCHES "Windows") target_link_libraries(frelayGUI PRIVATE ws2_32 wsock32) endif() diff --git a/Gui/main.cpp b/Gui/main.cpp index eb0a611..2d74459 100644 --- a/Gui/main.cpp +++ b/Gui/main.cpp @@ -4,18 +4,21 @@ #include "frelayGUI.h" -#ifndef ZZXXCC +#ifndef COMPILER_USE_MINGW #include #endif int main(int argc, char* argv[]) { + +#ifndef COMPILER_USE_MINGW auto configDir = Util::GetCurConfigPath("frelay"); #ifdef _WIN32 backward::SetDumpFileSavePath(configDir + "/dumpfile"); backward::SetDumpLogSavePath(configDir + "/dumplog"); #else backward::SetDumpLogSavePath(configDir + QDir::separator() + "dumplog"); +#endif #endif CRASHELPER_MARK_ENTRY(); diff --git a/Server/CMakeLists.txt b/Server/CMakeLists.txt index d5b79de..308ef3c 100644 --- a/Server/CMakeLists.txt +++ b/Server/CMakeLists.txt @@ -13,5 +13,10 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core Network) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network) add_executable(frelayServer Server.h Server.cpp main.cpp ../Res/server.rc) -target_link_libraries(frelayServer PRIVATE Protocol Util crashelper) +target_link_libraries(frelayServer PRIVATE Protocol Util) + +if(NOT DEFINED COMPILER_USE_MINGW) +target_link_libraries(frelayServer PRIVATE crashelper) +endif() + target_link_libraries(frelayServer PRIVATE Qt${QT_VERSION_MAJOR}::Core Qt${QT_VERSION_MAJOR}::Network) \ No newline at end of file diff --git a/Server/Server.h b/Server/Server.h index 8bacb43..0897030 100644 --- a/Server/Server.h +++ b/Server/Server.h @@ -7,7 +7,6 @@ #include #include #include -#include #include "Protocol.h" diff --git a/Server/main.cpp b/Server/main.cpp index b9866aa..efaace0 100644 --- a/Server/main.cpp +++ b/Server/main.cpp @@ -3,14 +3,21 @@ #include "Server.h" +#ifndef COMPILER_USE_MINGW +#include +#endif + int main(int argc, char* argv[]) { + +#ifndef COMPILER_USE_MINGW auto configDir = Util::GetCurConfigPath("frelay"); #ifdef _WIN32 backward::SetDumpFileSavePath(configDir + "/dumpfile"); backward::SetDumpLogSavePath(configDir + "/dumplog"); #else backward::SetDumpLogSavePath(configDir + QDir::separator() + "dumplog"); +#endif #endif QCoreApplication app(argc, argv);