Browse Source

Fixed build when building without GUI

Lukas Matena 1 year ago
parent
commit
b82aa37bf5
2 changed files with 23 additions and 7 deletions
  1. 17 6
      src/PrusaSlicer.cpp
  2. 6 1
      tests/CMakeLists.txt

+ 17 - 6
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<int, int>              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<std::string>              &load_configs		      = m_config.option<ConfigOptionStrings>("load", true)->values;
     const ForwardCompatibilitySubstitutionRule   config_substitution_rule = m_config.option<ConfigOptionEnum<ForwardCompatibilitySubstitutionRule>>("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<int, int>              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)

+ 6 - 1
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)