Support minimal dependency linux build.

This commit is contained in:
James Grogan 2022-11-10 09:06:02 +00:00
parent 92a35a5bc9
commit 7ce29ce8ae
14 changed files with 421 additions and 176 deletions

View file

@ -0,0 +1,27 @@
if(WIN32)
add_executable(sample_gui_win WIN32 gui-main-win.cpp)
target_include_directories(sample_gui PUBLIC
"${PROJECT_SOURCE_DIR}/src/console"
"${PROJECT_SOURCE_DIR}/src/client"
)
target_link_libraries(sample_gui_win PUBLIC client windows console core
network database geometry audio web)
set_property(TARGET sample_gui_win PROPERTY FOLDER apps)
else()
find_package(X11 QUIET)
if(X11_FOUND)
add_executable(sample_gui gui-main.cpp)
target_include_directories(sample_gui PUBLIC
"${PROJECT_SOURCE_DIR}/src/console"
"${PROJECT_SOURCE_DIR}/src/client"
)
target_link_libraries(sample_gui PUBLIC client windows console core
network database geometry audio web)
set_property(TARGET sample_gui PROPERTY FOLDER apps)
else()
message(STATUS "Skipping sample GUI as no X11 dev support")
endif()
endif()

View file

@ -0,0 +1,67 @@
#ifndef UNICODE
#define UNICODE
#endif
#include "MainApplication.h"
#include "GuiApplication.h"
#include "CommandLineArgs.h"
#include "Win32WindowInterface.h"
#include "FileLogger.h"
#include "StringUtils.h"
#include "windows.h"
#include <iostream>
#include <vector>
#include <string>
void initializeCommandLineArgs(CommandLineArgs* args)
{
int nArgs{ 0 };
auto szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);
if (szArglist == nullptr)
{
return;
}
std::vector<std::string> windowsArgs(nArgs);
for (int idx = 0; idx < nArgs; idx++)
{
windowsArgs[idx] = StringUtils::convert(szArglist[idx]);
}
LocalFree(szArglist);
args->Process(windowsArgs);
}
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PWSTR pCmdLine, int nCmdShow)
{
std::ofstream out("out.txt");
std::cout.rdbuf(out.rdbuf());
auto args = CommandLineArgs::CreateUnique();
initializeCommandLineArgs(args.get());
args->RecordLaunchPath();
// Start the main app
auto main_app = MainApplication::Create();
auto applicationContext = std::make_unique<Win32ApplicationContext>();
applicationContext->hInstance = reinterpret_cast<void*>(hInstance);
applicationContext->nCmdShow = nCmdShow;
main_app->Initialize(std::move(args), std::move(applicationContext));
MLOG_INFO("Creating GUI Application");
// Start the gui application
auto gui_app = GuiApplication();
gui_app.SetMainApplication(main_app);
MLOG_INFO("Running GUI Application");
gui_app.Run();
main_app->ShutDown();
return 0;
}

View file

@ -0,0 +1,24 @@
#include <memory>
#include "GuiApplication.h"
#include "MainApplication.h"
#include "CommandLineArgs.h"
int main(int argc, char *argv[])
{
auto args = CommandLineArgs::Create();
args->process(argc, argv);
args->recordLaunchPath();
// Start the main app
auto main_app = MainApplication::Create();
main_app->Initialize(std::move(args));
// Start the gui app
auto gui_app = GuiApplication();
gui_app.SetMainApplication(main_app);
gui_app.Run();
main_app->ShutDown();
return 0;
}