From d1887db2a5db04e50b87dad0b7c1c7d7d659b89d Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Sat, 18 Apr 2020 19:04:07 -0600 Subject: [PATCH] use precompiled headers --- CMakeLists.txt | 3 +++ GUI/CMakeLists.txt | 1 + GUI/host/CMakeLists.txt | 1 + GUI/host/exception.cpp | 1 - GUI/host/hookcode.h | 1 - GUI/host/host.h | 1 - GUI/host/textthread.h | 1 - extensions/CMakeLists.txt | 15 +++++++++++++++ extensions/blockmarkup.h | 1 - extensions/extension.h | 2 -- extensions/network.h | 1 - include/module.h | 1 - include/qtcommon.h | 1 - include/types.h | 1 - test/CMakeLists.txt | 2 ++ test/main.cpp | 3 +-- texthook/CMakeLists.txt | 2 +- texthook/hookfinder.h | 1 - texthook/main.h | 1 - texthook/texthook.h | 1 - texthook/util/util.h | 2 -- 21 files changed, 24 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5968dd5..a955bfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,9 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${CMAKE_FINAL_OUTPUT_DIRECTORY}>) include_directories(include) +add_library(pch text.cpp) +target_precompile_headers(pch PUBLIC include/common.h) + file(GLOB ASSETS assets/*) file(COPY ${ASSETS} DESTINATION ${CMAKE_FINAL_OUTPUT_DIRECTORY}) diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index e8d0276..eed044b 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -13,6 +13,7 @@ add_executable(Textractor WIN32 Textractor.rc Textractor.ico ) +target_precompile_headers(Textractor REUSE_FROM pch) target_link_libraries(${PROJECT_NAME} Qt5::Widgets shell32 winhttp) if (NOT EXISTS ${CMAKE_FINAL_OUTPUT_DIRECTORY}/Qt5Core.dll) diff --git a/GUI/host/CMakeLists.txt b/GUI/host/CMakeLists.txt index 6f4594f..c8ee81d 100644 --- a/GUI/host/CMakeLists.txt +++ b/GUI/host/CMakeLists.txt @@ -6,3 +6,4 @@ add_executable(TextractorCLI textthread.cpp hookcode.cpp ) +target_precompile_headers(TextractorCLI REUSE_FROM pch) diff --git a/GUI/host/exception.cpp b/GUI/host/exception.cpp index 4bd8787..33880db 100644 --- a/GUI/host/exception.cpp +++ b/GUI/host/exception.cpp @@ -1,4 +1,3 @@ -#include "common.h" #include "module.h" #include diff --git a/GUI/host/hookcode.h b/GUI/host/hookcode.h index 42c352a..2e5a1f3 100644 --- a/GUI/host/hookcode.h +++ b/GUI/host/hookcode.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include "types.h" namespace HookCode diff --git a/GUI/host/host.h b/GUI/host/host.h index 033be04..c0d24a2 100644 --- a/GUI/host/host.h +++ b/GUI/host/host.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include "textthread.h" namespace Host diff --git a/GUI/host/textthread.h b/GUI/host/textthread.h index 3208846..7171c78 100644 --- a/GUI/host/textthread.h +++ b/GUI/host/textthread.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include "types.h" class TextThread diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 6c17052..751ec15 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -19,6 +19,21 @@ add_library(Remove\ 30\ Repeated\ Sentences MODULE removerepeatsentence.cpp exte add_library(Replacer MODULE replacer.cpp extensionimpl.cpp) add_library(Thread\ Linker MODULE threadlinker.cpp extensionimpl.cpp) +target_precompile_headers(Bing\ Translate REUSE_FROM pch) +target_precompile_headers(Copy\ to\ Clipboard REUSE_FROM pch) +target_precompile_headers(DeepL\ Translate REUSE_FROM pch) +target_precompile_headers(Extra\ Newlines REUSE_FROM pch) +target_precompile_headers(Extra\ Window REUSE_FROM pch) +target_precompile_headers(Google\ Translate REUSE_FROM pch) +target_precompile_headers(Lua REUSE_FROM pch) +target_precompile_headers(Regex\ Filter REUSE_FROM pch) +target_precompile_headers(Remove\ Repeated\ Characters REUSE_FROM pch) +target_precompile_headers(Remove\ Repeated\ Phrases REUSE_FROM pch) +target_precompile_headers(Remove\ Repeated\ Phrases\ 2 REUSE_FROM pch) +target_precompile_headers(Remove\ 30\ Repeated\ Sentences REUSE_FROM pch) +target_precompile_headers(Replacer REUSE_FROM pch) +target_precompile_headers(Thread\ Linker REUSE_FROM pch) + target_link_libraries(Bing\ Translate winhttp Qt5::Widgets) target_link_libraries(DeepL\ Translate winhttp Qt5::Widgets) target_link_libraries(Extra\ Window Qt5::Widgets) diff --git a/extensions/blockmarkup.h b/extensions/blockmarkup.h index 132863f..ebd8654 100644 --- a/extensions/blockmarkup.h +++ b/extensions/blockmarkup.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include template // windows file block size diff --git a/extensions/extension.h b/extensions/extension.h index aa361cd..6a15ae2 100644 --- a/extensions/extension.h +++ b/extensions/extension.h @@ -1,7 +1,5 @@ #pragma once -#include "common.h" - struct InfoForExtension { const char* name; diff --git a/extensions/network.h b/extensions/network.h index b970700..d01ab3e 100644 --- a/extensions/network.h +++ b/extensions/network.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include using InternetHandle = AutoHandle>; diff --git a/include/module.h b/include/module.h index ddf508e..4d38685 100644 --- a/include/module.h +++ b/include/module.h @@ -1,4 +1,3 @@ -#include "common.h" #include inline std::optional GetModuleFilename(DWORD processId, HMODULE module = NULL) diff --git a/include/qtcommon.h b/include/qtcommon.h index 0525f24..a4fa3cb 100644 --- a/include/qtcommon.h +++ b/include/qtcommon.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include #include #include diff --git a/include/types.h b/include/types.h index c8da53a..765b189 100644 --- a/include/types.h +++ b/include/types.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include "const.h" class WinMutex // Like CMutex but works with scoped_lock diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c4362bc..08cab61 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,4 +4,6 @@ find_qt5(Core Widgets) add_executable(Test WIN32 main.cpp resource.rc) +target_precompile_headers(Test REUSE_FROM pch) + target_link_libraries(Test Qt5::Widgets) diff --git a/test/main.cpp b/test/main.cpp index f72f564..6e0dd6b 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -1,5 +1,4 @@ -#include "common.h" -#include "resource.h" +#include "resource.h" #include #include #include diff --git a/texthook/CMakeLists.txt b/texthook/CMakeLists.txt index d59c983..0952dbf 100644 --- a/texthook/CMakeLists.txt +++ b/texthook/CMakeLists.txt @@ -28,5 +28,5 @@ set(texthook_src endif() add_library(texthook MODULE ${texthook_src}) - +target_precompile_headers(texthook REUSE_FROM pch) target_link_libraries(texthook minhook) diff --git a/texthook/hookfinder.h b/texthook/hookfinder.h index 977e5d4..17f36f5 100644 --- a/texthook/hookfinder.h +++ b/texthook/hookfinder.h @@ -1,6 +1,5 @@ #pragma once -#include "common.h" #include "types.h" void SearchForText(wchar_t* text, UINT codepage); diff --git a/texthook/main.h b/texthook/main.h index e610037..f801a52 100644 --- a/texthook/main.h +++ b/texthook/main.h @@ -4,7 +4,6 @@ // 8/23/2013 jichi // Branch: ITH/IHF_DLL.h, rev 66 -#include "common.h" #include "types.h" void TextOutput(ThreadParam tp, BYTE (*buffer)[PIPE_BUFFER_SIZE], int len); diff --git a/texthook/texthook.h b/texthook/texthook.h index 75c70ca..f0b9ccd 100644 --- a/texthook/texthook.h +++ b/texthook/texthook.h @@ -7,7 +7,6 @@ // 8/24/2013 TODO: // - Clean up this file // - Reduce global variables. Use namespaces or singleton classes instead. -#include "common.h" #include "types.h" // Artikash 6/17/2019 TODO: These have the wrong values on x64 diff --git a/texthook/util/util.h b/texthook/util/util.h index 91d7920..87d4275 100644 --- a/texthook/util/util.h +++ b/texthook/util/util.h @@ -3,8 +3,6 @@ // util.h // 8/23/2013 jichi -#include "common.h" - namespace Util { bool unloadCurrentModule();