From 446f6d44e6f961a4b9a970cf5bc2ad9209dca91b Mon Sep 17 00:00:00 2001 From: Akash Mozumdar Date: Fri, 21 Apr 2023 00:52:32 -0400 Subject: [PATCH] upgrade build configuration to not rely on qt creator which is no longer required by qt installer --- .gitignore | 1 + CMakeLists.txt | 4 ++++ CMakeSettings.json | 6 +++++- GUI/CMakeLists.txt | 4 ---- cmake/QtUtils.cmake | 14 ++++++++------ extensions/CMakeLists.txt | 3 --- 6 files changed, 18 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 2883364..aaf87ce 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ *.vscode/ *.user *.aps +CMakeSettings.json diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d2f709..c764684 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,10 @@ target_precompile_headers(pch PUBLIC include/common.h) file(GLOB ASSETS assets/*) file(COPY ${ASSETS} DESTINATION ${CMAKE_FINAL_OUTPUT_DIRECTORY}) +include(QtUtils) +msvc_registry_search() +find_qt5(Core Widgets WinExtras WebSockets) + add_library(text text.cpp) target_compile_definitions(text PRIVATE ${TEXT_LANGUAGE}) link_libraries(text) diff --git a/CMakeSettings.json b/CMakeSettings.json index aa5b84e..6e602c7 100644 --- a/CMakeSettings.json +++ b/CMakeSettings.json @@ -4,25 +4,29 @@ "name": "x86-Debug", "generator": "Ninja", "configurationType": "Debug", + "cmakeCommandArgs": "-DQT_ROOT=C:/Qt/", "inheritEnvironments": [ "msvc_x86" ] }, { "name": "x86-RelWithDebInfo", "generator": "Ninja", "configurationType": "RelWithDebInfo", + "cmakeCommandArgs": "-DQT_ROOT=C:/Qt/", "inheritEnvironments": [ "msvc_x86" ] }, { "name": "x64-Debug", "generator": "Ninja", "configurationType": "Debug", + "cmakeCommandArgs": "-DQT_ROOT=C:/Qt/", "inheritEnvironments": [ "msvc_x64" ] }, { "name": "x64-RelWithDebInfo", "generator": "Ninja", "configurationType": "RelWithDebInfo", + "cmakeCommandArgs": "-DQT_ROOT=C:/Qt/", "inheritEnvironments": [ "msvc_x64" ] } ] -} +} \ No newline at end of file diff --git a/GUI/CMakeLists.txt b/GUI/CMakeLists.txt index 8ca32b5..7c4fa34 100644 --- a/GUI/CMakeLists.txt +++ b/GUI/CMakeLists.txt @@ -1,7 +1,3 @@ -include(QtUtils) -msvc_registry_search() -find_qt5(Core Widgets WinExtras) - add_executable(Textractor WIN32 main.cpp exception.cpp diff --git a/cmake/QtUtils.cmake b/cmake/QtUtils.cmake index 0cf9875..fc164a8 100644 --- a/cmake/QtUtils.cmake +++ b/cmake/QtUtils.cmake @@ -1,12 +1,14 @@ macro(msvc_registry_search) if(NOT DEFINED Qt5_DIR) - # look for user-registry pointing to qtcreator - get_filename_component(QT_BIN [HKEY_CURRENT_USER\\Software\\Classes\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\Command] PATH) + if (NOT EXISTS ${QT_ROOT}) + # look for user-registry pointing to qtcreator + get_filename_component(QT_ROOT [HKEY_CURRENT_USER\\Software\\Classes\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\Command] PATH) - # get root path so we can search for 5.3, 5.4, 5.5, etc - string(REPLACE "/Tools" ";" QT_BIN "${QT_BIN}") - list(GET QT_BIN 0 QT_BIN) - file(GLOB QT_VERSIONS "${QT_BIN}/5.1*") + # get root path + string(REPLACE "/Tools" ";" QT_ROOT "${QT_ROOT}") + list(GET QT_ROOT 0 QT_ROOT) + endif() + file(GLOB QT_VERSIONS "${QT_ROOT}/5.13*") list(SORT QT_VERSIONS) # assume the latest version will be last alphabetically diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt index 3e3d0a6..114a543 100644 --- a/extensions/CMakeLists.txt +++ b/extensions/CMakeLists.txt @@ -1,6 +1,3 @@ -include(QtUtils) -msvc_registry_search() -find_qt5(Core Widgets WebSockets) cmake_policy(SET CMP0037 OLD) add_library(Bing\ Translate MODULE bingtranslate.cpp translatewrapper.cpp network.cpp extensionimpl.cpp)