diff --git a/CMakeLists.txt b/CMakeLists.txt index a944af1c..9d9d574e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,8 +61,7 @@ endif() # Injection of the GCC-specific compilation flags if(CMAKE_COMPILER_IS_GNUCXX) message(STATUS "GCC detected, adding compile flags") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") - add_definitions("-Wall" "-Wextra" "-pedantic" "-Wno-variadic-macros" "-Wno-strict-aliasing" "-fPIC") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -pedantic -Wno-variadic-macros -Wno-strict-aliasing -fPIC") endif() add_compile_definitions(QT5) diff --git a/qdlt/qdltoptmanager.cpp b/qdlt/qdltoptmanager.cpp index 89ab1c86..fd1d9fd9 100644 --- a/qdlt/qdltoptmanager.cpp +++ b/qdlt/qdltoptmanager.cpp @@ -105,6 +105,19 @@ void QDltOptManager::printUsage(const QString& helpText) qDebug() << " dlt-viewer.exe -t -c output.txt input1.mf4 input2.mf4"; } +void QDltOptManager::freeWindowsConsole() +{ +#if (WIN32 || WIN64) + HWND consoleWnd = GetConsoleWindow(); + DWORD dwProcessId; + GetWindowThreadProcessId(consoleWnd, &dwProcessId); + if (GetCurrentProcessId() == dwProcessId) + { + FreeConsole(); + } +#endif +} + void QDltOptManager::parse(const QStringList& args) { m_parser.parse(args); @@ -120,18 +133,26 @@ void QDltOptManager::parse(const QStringList& args) if (m_parser.optionNames().isEmpty() && m_parser.positionalArguments().size() == 1) { const QString& arg = m_parser.positionalArguments().at(0); + bool closeConsole = false; if(arg.endsWith(".dlp") || arg.endsWith(".DLP")) { projectFile = arg; project = true; qDebug()<< "Project filename:" << projectFile; - return; + closeConsole = true; } if (arg.endsWith(".dlt") || arg.endsWith(".DLT")) { const QString logFile = arg; logFiles += logFile; qDebug()<< "DLT filename:" << logFile; + closeConsole = true; + } + + if(closeConsole) + { + // user launched the application with a double click on a dlt/project file: we do not need console + freeWindowsConsole(); return; } } @@ -246,19 +267,11 @@ void QDltOptManager::parse(const QStringList& args) * Unfortunateley Windows opens a console anyway. * So we have to close it in this case */ - #if (WIN32) - if (!commandline_mode) - { - HWND consoleWnd = GetConsoleWindow(); - DWORD dwProcessId; - GetWindowThreadProcessId(consoleWnd, &dwProcessId); - if (GetCurrentProcessId() == dwProcessId) - { - // user launched the application with a double click from explorer: we do not need console - FreeConsole(); - } - } - #endif + if (!commandline_mode) + { + // user launched the application with a double click from explorer: we do not need console + freeWindowsConsole(); + } } bool QDltOptManager::isProjectFile(){ return project;} diff --git a/qdlt/qdltoptmanager.h b/qdlt/qdltoptmanager.h index e1cb12d0..53dc9eae 100644 --- a/qdlt/qdltoptmanager.h +++ b/qdlt/qdltoptmanager.h @@ -48,6 +48,7 @@ class QDLT_EXPORT QDltOptManager void printUsage(const QString& helpText); void printVersion(QString appname); void parse(const QStringList& opt); + void freeWindowsConsole(); bool isProjectFile(); bool isTerminate(); diff --git a/scripts/windows/version.cmake b/scripts/windows/version.cmake index 01efc4d0..dc3e61bf 100644 --- a/scripts/windows/version.cmake +++ b/scripts/windows/version.cmake @@ -62,10 +62,11 @@ execute_process( OUTPUT_STRIP_TRAILING_WHITESPACE ) -set(VS_VERSION ${MSVC_TOOLSET_VERSION}) -string(REPLACE "140" "msvc2015" VS_VERSION ${VS_VERSION}) -string(REPLACE "141" "msvc2017" VS_VERSION ${VS_VERSION}) -string(REPLACE "142" "msvc2019" VS_VERSION ${VS_VERSION}) -string(REPLACE "143" "msvc2022" VS_VERSION ${VS_VERSION}) - +if(MSVC) + set(VS_VERSION ${MSVC_TOOLSET_VERSION}) + string(REPLACE "140" "msvc2015" VS_VERSION ${VS_VERSION}) + string(REPLACE "141" "msvc2017" VS_VERSION ${VS_VERSION}) + string(REPLACE "142" "msvc2019" VS_VERSION ${VS_VERSION}) + string(REPLACE "143" "msvc2022" VS_VERSION ${VS_VERSION}) +endif() set(DLT_VERSION_SUFFIX "STABLE-qt${DLT_QT_VERSION}-r${GIT_PATCH_VERSION}_${VS_VERSION}_${CMAKE_CXX_COMPILER_ARCHITECTURE_ID}")