CMake GUI: Split up into libraries, add test shim

This commit is contained in:
Kyle Edwards
2020-09-14 14:47:41 -04:00
parent b7995b62f0
commit 41e223deb3
3 changed files with 31 additions and 7 deletions

View File

@@ -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 <QApplication>
class CMakeSetupDialog;
void SetupDefaultQSettings()
{
}
int CMakeGUIExec(CMakeSetupDialog* /*window*/)
{
return QApplication::exec();
}

View File

@@ -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_OBJECTS:CMakeVersion>)
target_sources(CMakeGUILib INTERFACE $<TARGET_OBJECTS:CMakeVersion>)
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 ""
)

View File

@@ -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)