diff --git a/CMakeLists.txt b/CMakeLists.txt index 7454784..d7daa29 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,11 +101,8 @@ if (MINGW) list(APPEND SCRIPT_FILES scripts/wine.sh) endif () if (WIN32) - list(APPEND CMAKE_TEMPLATE_FILES - cmake/templates/windows.rc.in - cmake/templates/windows-cli-wrapper.rc.in - cmake/templates/cli-wrapper.cpp - ) + list(APPEND CMAKE_TEMPLATE_FILES cmake/templates/windows.rc.in cmake/templates/windows-cli-wrapper.rc.in + cmake/templates/cli-wrapper.cpp) endif () set(EXCLUDED_FILES cmake/templates/cli-wrapper.cpp) diff --git a/application/commandlineutils.cpp b/application/commandlineutils.cpp index 0f95662..86d518c 100644 --- a/application/commandlineutils.cpp +++ b/application/commandlineutils.cpp @@ -198,7 +198,7 @@ void startConsole() // attach to the parent process' console or allocate a new console if that's not possible if (!skip && (AttachConsole(ATTACH_PARENT_PROCESS) || AllocConsole())) { - FILE* fp; + FILE *fp; #ifdef _MSC_VER // take care of normal streams if (!skipstdout) { @@ -215,8 +215,10 @@ void startConsole() std::cin.clear(); } // take care of wide streams - auto hConOut = CreateFile(_T("CONOUT$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); - auto hConIn = CreateFile(_T("CONIN$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + auto hConOut = CreateFile( + _T("CONOUT$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); + auto hConIn = CreateFile( + _T("CONIN$"), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (!skipstdout) { SetStdHandle(STD_OUTPUT_HANDLE, hConOut); std::wcout.clear(); diff --git a/cmake/modules/TemplateFinder.cmake b/cmake/modules/TemplateFinder.cmake index 6c80221..35d3c5e 100644 --- a/cmake/modules/TemplateFinder.cmake +++ b/cmake/modules/TemplateFinder.cmake @@ -8,7 +8,9 @@ set(TEMPLATE_FINDER_LOADED YES) function (find_template_file FILE_NAME_WITHOUT_EXTENSION PROJECT_VAR_NAME OUTPUT_VAR) find_template_file_full_name("${FILE_NAME_WITHOUT_EXTENSION}.in" "${PROJECT_VAR_NAME}" "${OUTPUT_VAR}") - set(${OUTPUT_VAR} "${${OUTPUT_VAR}}" PARENT_SCOPE) + set(${OUTPUT_VAR} + "${${OUTPUT_VAR}}" + PARENT_SCOPE) endfunction () function (find_template_file_full_name FILE_NAME PROJECT_VAR_NAME OUTPUT_VAR) diff --git a/cmake/templates/cli-wrapper.cpp b/cmake/templates/cli-wrapper.cpp index 677dd98..4907523 100644 --- a/cmake/templates/cli-wrapper.cpp +++ b/cmake/templates/cli-wrapper.cpp @@ -3,8 +3,8 @@ #include #include #include -#include #include +#include /*! * \brief Returns \a replacement if \a value matches \a key; otherwise returns \a value. @@ -58,17 +58,16 @@ int main() startupInfo.dwFlags |= STARTF_USESTDHANDLES; // start main executable in new group and print debug information if that's not possible - auto res = CreateProcessW( - pathBuffer, // path of main executable - commadLine, // command line arguments - nullptr, // process handle not inheritable - nullptr, // thread handle not inheritable - true, // set handle inheritance to true - CREATE_NEW_PROCESS_GROUP, // creation flags - nullptr, // use parent's environment block - nullptr, // use parent's starting directory - &startupInfo, // pointer to STARTUPINFO structure - &processInformation); // pointer to PROCESS_INFORMATION structure + auto res = CreateProcessW(pathBuffer, // path of main executable + commadLine, // command line arguments + nullptr, // process handle not inheritable + nullptr, // thread handle not inheritable + true, // set handle inheritance to true + CREATE_NEW_PROCESS_GROUP, // creation flags + nullptr, // use parent's environment block + nullptr, // use parent's starting directory + &startupInfo, // pointer to STARTUPINFO structure + &processInformation); // pointer to PROCESS_INFORMATION structure if (!res) { std::cerr << "Unable to launch main executable: " << std::error_code(GetLastError(), std::system_category()) << '\n'; std::wcerr << L" - assumed path: " << pathBuffer << L'\n';