Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

Commit

Permalink
Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
Your Name authored and OFFTKP committed Oct 26, 2023
1 parent 9559c31 commit bf7069f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 8 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/MacOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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}
Expand All @@ -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
Expand Down
5 changes: 2 additions & 3 deletions qt/keypicker.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ InputPage::InputPage(const std::vector<std::tuple<QComboBox*, int, QString>>& li
std::vector<std::filesystem::path> 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);
}
Expand Down Expand Up @@ -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");
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions qt/mainwindow.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -613,6 +617,7 @@ void MainWindow::run_script(const std::string& script, bool safe_mode)
lua.script(script);
}
});
#endif
}

void MainWindow::screenshot()
Expand Down

0 comments on commit bf7069f

Please sign in to comment.