From b82aa37bf566dd1872cc350b69f7f7aaca393374 Mon Sep 17 00:00:00 2001 From: Lukas Matena Date: Tue, 2 Jan 2024 16:01:14 +0100 Subject: [PATCH] Fixed build when building without GUI --- src/PrusaSlicer.cpp | 23 +++++++++++++++++------ tests/CMakeLists.txt | 7 ++++++- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/PrusaSlicer.cpp b/src/PrusaSlicer.cpp index 1517729ba0..a07256fd7b 100644 --- a/src/PrusaSlicer.cpp +++ b/src/PrusaSlicer.cpp @@ -130,12 +130,6 @@ int CLI::run(int argc, char **argv) // On Unix systems, the prusa-slicer binary may be symlinked to give the application a different meaning. boost::algorithm::iends_with(boost::filesystem::path(argv[0]).filename().string(), "gcodeviewer"); #endif // _WIN32 -#if ENABLE_GL_CORE_PROFILE - std::pair opengl_version = { 0, 0 }; -#if ENABLE_OPENGL_DEBUG_OPTION - bool opengl_debug = false; -#endif // ENABLE_OPENGL_DEBUG_OPTION -#endif // ENABLE_GL_CORE_PROFILE const std::vector &load_configs = m_config.option("load", true)->values; const ForwardCompatibilitySubstitutionRule config_substitution_rule = m_config.option>("config_compatibility", true)->value; @@ -174,7 +168,13 @@ int CLI::run(int argc, char **argv) m_print_config.apply(config); } +#ifdef SLIC3R_GUI #if ENABLE_GL_CORE_PROFILE + std::pair opengl_version = { 0, 0 }; +#if ENABLE_OPENGL_DEBUG_OPTION + bool opengl_debug = false; +#endif // ENABLE_OPENGL_DEBUG_OPTION + // search for special keys into command line parameters auto it = std::find(m_actions.begin(), m_actions.end(), "gcodeviewer"); if (it != m_actions.end()) { @@ -222,6 +222,17 @@ int CLI::run(int argc, char **argv) } } #endif // ENABLE_GL_CORE_PROFILE +#else // SLIC3R_GUI + // If there is no GUI, we shall ignore the parameters. Remove them from the list. + for (const std::string& s : { "opengl-version", "opengl-debug", "gcodeviewer" }) { + auto it = std::find(m_actions.cbegin(), m_actions.cend(), s); + if (it != m_actions.end()) { + boost::nowide::cerr << "Parameter '" << s << "' is ignored, this PrusaSlicer build is CLI only." << std::endl; + m_actions.erase(it); + } + } +#endif + // Read input file(s) if any. for (const std::string& file : m_input_files) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f00a2eb7ee..82027558cc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -24,8 +24,13 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) add_subdirectory(arrange) add_subdirectory(thumbnails) add_subdirectory(libslic3r) -add_subdirectory(slic3rutils) add_subdirectory(fff_print) add_subdirectory(sla_print) add_subdirectory(cpp17 EXCLUDE_FROM_ALL) # does not have to be built all the time + +if (SLIC3R_GUI) + add_subdirectory(slic3rutils) +endif() + + # add_subdirectory(example)