From 41e223deb37767d9beb8c4462b8b8df88ba2dedf Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 14 Sep 2020 14:47:41 -0400 Subject: CMake GUI: Split up into libraries, add test shim --- Source/QtDialog/CMakeGUIExec.cxx | 15 +++++++++++++++ Source/QtDialog/CMakeLists.txt | 16 +++++++++++----- Source/QtDialog/CMakeSetup.cxx | 7 +++++-- 3 files changed, 31 insertions(+), 7 deletions(-) create mode 100644 Source/QtDialog/CMakeGUIExec.cxx diff --git a/Source/QtDialog/CMakeGUIExec.cxx b/Source/QtDialog/CMakeGUIExec.cxx new file mode 100644 index 0000000..1572112 --- /dev/null +++ b/Source/QtDialog/CMakeGUIExec.cxx @@ -0,0 +1,15 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include + +class CMakeSetupDialog; + +void SetupDefaultQSettings() +{ +} + +int CMakeGUIExec(CMakeSetupDialog* /*window*/) +{ + return QApplication::exec(); +} diff --git a/Source/QtDialog/CMakeLists.txt b/Source/QtDialog/CMakeLists.txt index e6d6b17..0ec012c 100644 --- a/Source/QtDialog/CMakeLists.txt +++ b/Source/QtDialog/CMakeLists.txt @@ -81,7 +81,6 @@ endif() set(SRCS AddCacheEntry.cxx AddCacheEntry.h - CMakeSetup.cxx CMakeSetupDialog.cxx CMakeSetupDialog.h Compilers.h @@ -150,11 +149,18 @@ endif() set(CMAKE_INCLUDE_CURRENT_DIR ON) -add_executable(cmake-gui WIN32 MACOSX_BUNDLE ${SRCS} ${MANIFEST_FILE}) -target_link_libraries(cmake-gui CMakeLib Qt5::Core Qt5::Widgets ${CMake_QT_EXTRA_LIBRARIES}) +add_library(CMakeGUILib STATIC ${SRCS}) +# CMake_QT_EXTRA_LIBRARIES have to come before the main libraries on the link line +target_link_libraries(CMakeGUILib PUBLIC CMakeLib ${CMake_QT_EXTRA_LIBRARIES} Qt5::Core Qt5::Widgets) + +add_library(CMakeGUIMainLib STATIC CMakeSetup.cxx) +target_link_libraries(CMakeGUIMainLib PUBLIC CMakeGUILib) + +add_executable(cmake-gui WIN32 MACOSX_BUNDLE CMakeGUIExec.cxx ${MANIFEST_FILE}) +target_link_libraries(cmake-gui CMakeGUIMainLib Qt5::Core) if(WIN32) - target_sources(cmake-gui PRIVATE $) + target_sources(CMakeGUILib INTERFACE $) endif() if(CMake_JOB_POOL_LINK_BIN) @@ -163,7 +169,7 @@ endif() # cmake-gui has not been updated for `include-what-you-use`. # Block the tool until this is done. -set_target_properties(cmake-gui PROPERTIES +set_target_properties(CMakeGUILib CMakeGUIMainLib cmake-gui PROPERTIES CXX_INCLUDE_WHAT_YOU_USE "" ) diff --git a/Source/QtDialog/CMakeSetup.cxx b/Source/QtDialog/CMakeSetup.cxx index 7ef5a72..37c1f15 100644 --- a/Source/QtDialog/CMakeSetup.cxx +++ b/Source/QtDialog/CMakeSetup.cxx @@ -21,7 +21,6 @@ #include "cmDocumentationEntry.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" // IWYU pragma: keep -#include "cmVersion.h" #include "cmake.h" static const char* cmDocumentationName[][2] = { { nullptr, @@ -55,6 +54,9 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin); # endif #endif +int CMakeGUIExec(CMakeSetupDialog* window); +void SetupDefaultQSettings(); + int main(int argc, char** argv) { cmSystemTools::EnsureStdPipes(); @@ -108,6 +110,7 @@ int main(int argc, char** argv) QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); #endif + SetupDefaultQSettings(); QApplication app(argc, argv); setlocale(LC_NUMERIC, "C"); @@ -215,7 +218,7 @@ int main(int argc, char** argv) } } - return QApplication::exec(); + return CMakeGUIExec(&dialog); } #if defined(Q_OS_MAC) -- cgit v0.12