diff --git a/.github/workflows/MacOS.yml b/.github/workflows/MacOS.yml index 46ac2a1e..2ce1fd26 100644 --- a/.github/workflows/MacOS.yml +++ b/.github/workflows/MacOS.yml @@ -18,8 +18,8 @@ jobs: - name: ccache uses: hendrikmuhs/ccache-action@v1.2 - name: install-deps - run: brew install qt6 ninja lua + run: brew install qt6 ninja lua openssl - name: configure - run: cmake -B build -G Ninja -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache + run: cmake -B build -G Ninja -D CMAKE_C_COMPILER_LAUNCHER=ccache -D CMAKE_CXX_COMPILER_LAUNCHER=ccache -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl - name: make run: cmake --build build --target hydra \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 624fd8fb..6a307d91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,8 @@ include(ExternalProject) project(hydra VERSION 0.2.0 LANGUAGES CXX) project(hydra_server) +option(USE_LUA "Use lua for script support" ON) + if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE Release) endif() @@ -50,7 +52,10 @@ set(OpenGL_GL_PREFERENCE GLVND) find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets OpenGL OpenGLWidgets) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets OpenGL OpenGLWidgets) -find_package(Lua REQUIRED) + +if (USE_LUA) + find_package(Lua REQUIRED) +endif() find_package(OpenSSL REQUIRED) add_subdirectory(vendored/fmt) @@ -89,9 +94,15 @@ set(HYDRA_INCLUDE_DIRECTORIES core/include vendored vendored/fmt/include - ${LUA_INCLUDE_DIR} ) +if(USE_LUA) + set(HYDRA_INCLUDE_DIRECTORIES + ${HYDRA_INCLUDE_DIRECTORIES} + ${LUA_INCLUDE_DIR} + ) +endif() + qt_add_executable(hydra MANUAL_FINALIZATION ${HYDRA_COMMON_FILES} @@ -102,10 +113,15 @@ if(APPLE) target_link_libraries(hydra PRIVATE "-framework Security") endif() +if(WIN32) + target_compile_definitions(hydra PRIVATE WIN32_LEAN_AND_MEAN NOMINMAX) +endif() + target_link_libraries(hydra PRIVATE Qt${QT_VERSION_MAJOR}::Widgets Qt${QT_VERSION_MAJOR}::OpenGL Qt${QT_VERSION_MAJOR}::OpenGLWidgets - ${CMAKE_DL_LIBS} fmt::fmt ${LUA_LIBRARIES} OpenSSL::SSL) + ${CMAKE_DL_LIBS} fmt::fmt ${LUA_LIBRARIES} + OpenSSL::SSL) target_include_directories(hydra PRIVATE ${HYDRA_INCLUDE_DIRECTORIES}) set_target_properties(hydra PROPERTIES hydra_properties MACOSX_BUNDLE_GUI_IDENTIFIER offtkp.hydra.com diff --git a/qt/keypicker.cxx b/qt/keypicker.cxx index 6f468903..2ec7afd7 100644 --- a/qt/keypicker.cxx +++ b/qt/keypicker.cxx @@ -101,7 +101,7 @@ InputPage::InputPage(const std::vector>& li std::vector files = hydra::Input::Scan(dirpath, ".json"); for (const auto& path : files) { - QFile file(path.c_str()); + QFile file(QString::fromStdString(path.string())); file.open(QIODevice::ReadOnly); add_tab_from_file(file); } @@ -265,8 +265,7 @@ void InputPage::onRemoveButtonClicked() std::filesystem::remove(path, ec); if (ec) { - QMessageBox::warning(this, "Warning", - QString("Failed to remove mapping file: ") + path.c_str()); + QMessageBox::warning(this, "Warning", "Failed to remove mapping file"); } } } diff --git a/qt/mainwindow.cxx b/qt/mainwindow.cxx index e55a160b..9a8f2db6 100644 --- a/qt/mainwindow.cxx +++ b/qt/mainwindow.cxx @@ -275,6 +275,9 @@ void MainWindow::create_actions() scripts_act_->setStatusTip("Open the script editor"); scripts_act_->setIcon(QIcon(":/images/scripts.png")); connect(scripts_act_, &QAction::triggered, this, &MainWindow::open_scripts); +#ifndef HYDRA_USE_LUA + scripts_act_->setEnabled(false); +#endif terminal_act_ = new QAction(tr("&Terminal"), this); terminal_act_->setShortcut(Qt::Key_F9); terminal_act_->setStatusTip("Open the terminal"); @@ -566,6 +569,7 @@ void MainWindow::open_terminal() // TODO: compiler option to turn off lua support void MainWindow::run_script(const std::string& script, bool safe_mode) { +#ifdef HYDRA_USE_LUA static bool initialized = false; static sol::state lua; static auto environment = sol::environment(lua, sol::create); @@ -613,6 +617,7 @@ void MainWindow::run_script(const std::string& script, bool safe_mode) lua.script(script); } }); +#endif } void MainWindow::screenshot()