[Bf-blender-cvs] [8edd1d8aa59] master: CMake: optionally disable OBJ, STL & GPencil SVG support

Campbell Barton noreply at git.blender.org
Wed Jun 8 05:29:58 CEST 2022


Commit: 8edd1d8aa597514d5089f8cf2aa640ec14c1e389
Author: Campbell Barton
Date:   Tue Jun 7 14:21:19 2022 +1000
Branches: master
https://developer.blender.org/rB8edd1d8aa597514d5089f8cf2aa640ec14c1e389

CMake: optionally disable OBJ, STL & GPencil SVG support

The following CMake options have been added (enabled by default),
except for the lite build configuration.

- WITH_IO_STL
- WITH_IO_WAVEFRONT_OBJ
- WITH_IO_GPENCIL (for grease pencil SVG importing).
  Note that it was already possible to disable grease pencil export
  by disabling WITH_PUGIXML & WITH_HARU.

This is intended to keep the lite builds fast and small for building,
linking & execution.

Reviewed By: iyadahmed2001, aras_p, antoniov, mont29

Ref D15141

===================================================================

M	CMakeLists.txt
M	build_files/cmake/config/blender_lite.cmake
M	release/scripts/startup/bl_ui/space_topbar.py
M	source/blender/editors/io/CMakeLists.txt
M	source/blender/editors/io/io_gpencil_export.c
M	source/blender/editors/io/io_gpencil_import.c
M	source/blender/editors/io/io_gpencil_utils.c
M	source/blender/editors/io/io_obj.c
M	source/blender/editors/io/io_ops.c
M	source/blender/editors/io/io_stl_ops.c
M	source/blender/io/CMakeLists.txt
M	source/blender/python/intern/CMakeLists.txt
M	source/blender/python/intern/bpy_app_build_options.c

===================================================================

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 90baadcac8b..31608b0c1ce 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -300,6 +300,9 @@ option(WITH_USD                 "Enable Universal Scene Description (USD) Suppor
 # 3D format support
 # Disable opencollada when we don't have precompiled libs
 option(WITH_OPENCOLLADA   "Enable OpenCollada Support (http://www.opencollada.org)" ON)
+option(WITH_IO_WAVEFRONT_OBJ  "Enable Wavefront-OBJ 3D file format support (*.obj)" ON)
+option(WITH_IO_STL            "Enable STL 3D file format support (*.stl)" ON)
+option(WITH_IO_GPENCIL        "Enable grease-pencil file format IO (*.svg, *.pdf)" ON)
 
 # Sound output
 option(WITH_SDL           "Enable SDL for sound" ON)
diff --git a/build_files/cmake/config/blender_lite.cmake b/build_files/cmake/config/blender_lite.cmake
index 2f6057ee9c0..5ce344d39e8 100644
--- a/build_files/cmake/config/blender_lite.cmake
+++ b/build_files/cmake/config/blender_lite.cmake
@@ -37,6 +37,9 @@ set(WITH_IMAGE_TIFF          OFF CACHE BOOL "" FORCE)
 set(WITH_IMAGE_WEBP          OFF CACHE BOOL "" FORCE)
 set(WITH_INPUT_NDOF          OFF CACHE BOOL "" FORCE)
 set(WITH_INTERNATIONAL       OFF CACHE BOOL "" FORCE)
+set(WITH_IO_STL              OFF CACHE BOOL "" FORCE)
+set(WITH_IO_WAVEFRONT_OBJ    OFF CACHE BOOL "" FORCE)
+set(WITH_IO_GPENCIL          OFF CACHE BOOL "" FORCE)
 set(WITH_JACK                OFF CACHE BOOL "" FORCE)
 set(WITH_LIBMV               OFF CACHE BOOL "" FORCE)
 set(WITH_LLVM                OFF CACHE BOOL "" FORCE)
diff --git a/release/scripts/startup/bl_ui/space_topbar.py b/release/scripts/startup/bl_ui/space_topbar.py
index 2980ec9ace7..d8bd724f554 100644
--- a/release/scripts/startup/bl_ui/space_topbar.py
+++ b/release/scripts/startup/bl_ui/space_topbar.py
@@ -453,9 +453,13 @@ class TOPBAR_MT_file_import(Menu):
             self.layout.operator(
                 "wm.usd_import", text="Universal Scene Description (.usd, .usdc, .usda)")
 
-        self.layout.operator("wm.gpencil_import_svg", text="SVG as Grease Pencil")
-        self.layout.operator("wm.obj_import", text="Wavefront (.obj) (experimental)")
-        self.layout.operator("wm.stl_import", text="STL (.stl) (experimental)")
+        if bpy.app.build_options.io_gpencil:
+            self.layout.operator("wm.gpencil_import_svg", text="SVG as Grease Pencil")
+
+        if bpy.app.build_options.io_wavefront_obj:
+            self.layout.operator("wm.obj_import", text="Wavefront (.obj) (experimental)")
+        if bpy.app.build_options.io_stl:
+            self.layout.operator("wm.stl_import", text="STL (.stl) (experimental)")
 
 
 class TOPBAR_MT_file_export(Menu):
@@ -472,14 +476,16 @@ class TOPBAR_MT_file_export(Menu):
             self.layout.operator(
                 "wm.usd_export", text="Universal Scene Description (.usd, .usdc, .usda)")
 
-        # Pugixml lib dependency
-        if bpy.app.build_options.pugixml:
-            self.layout.operator("wm.gpencil_export_svg", text="Grease Pencil as SVG")
-        # Haru lib dependency
-        if bpy.app.build_options.haru:
-            self.layout.operator("wm.gpencil_export_pdf", text="Grease Pencil as PDF")
+        if bpy.app.build_options.io_gpencil:
+            # Pugixml lib dependency
+            if bpy.app.build_options.pugixml:
+                self.layout.operator("wm.gpencil_export_svg", text="Grease Pencil as SVG")
+            # Haru lib dependency
+            if bpy.app.build_options.haru:
+                self.layout.operator("wm.gpencil_export_pdf", text="Grease Pencil as PDF")
 
-        self.layout.operator("wm.obj_export", text="Wavefront (.obj) (experimental)")
+        if bpy.app.build_options.io_wavefront_obj:
+            self.layout.operator("wm.obj_export", text="Wavefront (.obj) (experimental)")
 
 
 class TOPBAR_MT_file_external_data(Menu):
diff --git a/source/blender/editors/io/CMakeLists.txt b/source/blender/editors/io/CMakeLists.txt
index 98438c3e959..a716c00d5d9 100644
--- a/source/blender/editors/io/CMakeLists.txt
+++ b/source/blender/editors/io/CMakeLists.txt
@@ -49,8 +49,6 @@ set(SRC
 set(LIB
   bf_blenkernel
   bf_blenlib
-  bf_wavefront_obj
-  bf_stl
 )
 
 if(WITH_OPENCOLLADA)
@@ -60,6 +58,27 @@ if(WITH_OPENCOLLADA)
   add_definitions(-DWITH_COLLADA)
 endif()
 
+if(WITH_IO_WAVEFRONT_OBJ)
+  list(APPEND LIB
+    bf_wavefront_obj
+  )
+  add_definitions(-DWITH_IO_WAVEFRONT_OBJ)
+endif()
+
+if(WITH_IO_STL)
+  list(APPEND LIB
+    bf_stl
+  )
+  add_definitions(-DWITH_IO_STL)
+endif()
+
+if(WITH_IO_GPENCIL)
+  list(APPEND LIB
+    bf_gpencil
+  )
+  add_definitions(-DWITH_IO_GPENCIL)
+endif()
+
 if(WITH_ALEMBIC)
   list(APPEND LIB
     bf_alembic
@@ -82,6 +101,4 @@ if(WITH_HARU)
   add_definitions(-DWITH_HARU)
 endif()
 
-list(APPEND LIB bf_gpencil)
-
 blender_add_lib(bf_editor_io "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/editors/io/io_gpencil_export.c b/source/blender/editors/io/io_gpencil_export.c
index 7ac05fcca3e..6e5ae9f3cba 100644
--- a/source/blender/editors/io/io_gpencil_export.c
+++ b/source/blender/editors/io/io_gpencil_export.c
@@ -5,36 +5,38 @@
  * \ingroup editor/io
  */
 
-#include "BLI_path_util.h"
-#include "BLI_string.h"
+#ifdef WITH_IO_GPENCIL
 
-#include "DNA_gpencil_types.h"
-#include "DNA_space_types.h"
+#  include "BLI_path_util.h"
+#  include "BLI_string.h"
 
-#include "BKE_gpencil.h"
-#include "BKE_main.h"
-#include "BKE_report.h"
-#include "BKE_screen.h"
+#  include "DNA_gpencil_types.h"
+#  include "DNA_space_types.h"
 
-#include "BLT_translation.h"
+#  include "BKE_gpencil.h"
+#  include "BKE_main.h"
+#  include "BKE_report.h"
+#  include "BKE_screen.h"
 
-#include "RNA_access.h"
-#include "RNA_define.h"
+#  include "BLT_translation.h"
 
-#include "UI_interface.h"
-#include "UI_resources.h"
+#  include "RNA_access.h"
+#  include "RNA_define.h"
 
-#include "WM_api.h"
-#include "WM_types.h"
+#  include "UI_interface.h"
+#  include "UI_resources.h"
 
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
+#  include "WM_api.h"
+#  include "WM_types.h"
 
-#include "io_gpencil.h"
+#  include "DEG_depsgraph.h"
+#  include "DEG_depsgraph_query.h"
 
-#include "gpencil_io.h"
+#  include "io_gpencil.h"
 
-#if defined(WITH_PUGIXML) || defined(WITH_HARU)
+#  include "gpencil_io.h"
+
+#  if defined(WITH_PUGIXML) || defined(WITH_HARU)
 /* Definition of enum elements to export. */
 /* Common props for exporting. */
 static void gpencil_export_common_props_definition(wmOperatorType *ot)
@@ -87,10 +89,10 @@ static void set_export_filepath(bContext *C, wmOperator *op, const char *extensi
     RNA_string_set(op->ptr, "filepath", filepath);
   }
 }
-#endif
+#  endif
 
 /* <-------- SVG single frame export. --------> */
-#ifdef WITH_PUGIXML
+#  ifdef WITH_PUGIXML
 static bool wm_gpencil_export_svg_common_check(bContext *UNUSED(C), wmOperator *op)
 {
   char filepath[FILE_MAX];
@@ -241,10 +243,10 @@ void WM_OT_gpencil_export_svg(wmOperatorType *ot)
                   "Clip Camera",
                   "Clip drawings to camera size when export in camera view");
 }
-#endif
+#  endif
 
 /* <-------- PDF single frame export. --------> */
-#ifdef WITH_HARU
+#  ifdef WITH_HARU
 static bool wm_gpencil_export_pdf_common_check(bContext *UNUSED(C), wmOperator *op)
 {
 
@@ -406,4 +408,6 @@ void WM_OT_gpencil_export_pdf(wmOperatorType *ot)
                           "Frames",
                           "Which frames to include in the export");
 }
-#endif
+#  endif /* WITH_HARU */
+
+#endif /* WITH_IO_GPENCIL */
diff --git a/source/blender/editors/io/io_gpencil_import.c b/source/blender/editors/io/io_gpencil_import.c
index 8bed32ad6c3..45f5441616f 100644
--- a/source/blender/editors/io/io_gpencil_import.c
+++ b/source/blender/editors/io/io_gpencil_import.c
@@ -5,34 +5,36 @@
  * \ingroup editor/io
  */
 
-#include "BLI_path_util.h"
+#ifdef WITH_IO_GPENCIL
 
-#include "DNA_gpencil_types.h"
-#include "DNA_space_types.h"
+#  include "BLI_path_util.h"
 
-#include "BKE_context.h"
-#include "BKE_gpencil.h"
-#include "BKE_report.h"
+#  include "DNA_gpencil_types.h"
+#  include "DNA_space_types.h"
 
-#include "BLT_translation.h"
+#  include "BKE_context.h"
+#  include "BKE_gpencil.h"
+#  include "BKE_report.h"
 
-#include "RNA_access.h"
-#include "RNA_define.h"
+#  include "BLT_translation.h"
 
-#include "UI_interface.h"
-#include "UI_resources.h"
+#  include "RNA_access.h"
+#  include "RNA_define.h"
 
-#include "WM_api.h"
-#include "WM_types.h"
+#  include "UI_interface.h"
+#  include "UI_resources.h"
 
-#include "DEG_depsgraph.h"
-#include "DEG_depsgraph_query.h"
+#  include "WM_api.h"
+#  include "WM_types.h"
 
-#include "ED_gpencil.h"
+#  include "DEG_depsgraph.h"
+#  include "DEG_depsgraph_query.h"
 
-#include "io_gpencil.h"
+#  include "ED_gpencil.h"
 
-#include "gpencil_io.h"
+#  include "io_gpencil.h"
+
+#  include "gpencil_io.h"
 
 /* <-------- SVG single frame import. --------> */
 static bool wm_gpencil_import_svg_common_check(bContext *UNUSED(C), wmOperator *op)
@@ -174,3 +176,5 @@ void WM_OT_gpencil_import_svg(wmOperatorType *ot)
                 0.001f,
                 100.0f);
 }
+
+#endif /* WITH_IO_GPENCIL */
diff --git a/source/blender/editors/io/io_gpencil_utils.c b/source/blender/editors/io/io_gpencil_utils.c
index fa5fcd79b96..9a88daef1a1 100644
--- a/source/blender/editors/io/io_gpencil_utils.c
+++ b/source/blender/editors/io/io_gpencil_utils.c
@@ -5,14 +5,16 @@
  * \ingroup editor/io
  */
 
-#include "DNA_space_types.h"
+#ifdef WITH_IO_GPENCIL
 
-#include "BKE_context.h"
-#include "BKE_screen.h"
+#  include "DNA_space_types.h"
 
-#include "WM_api.h"
+#  include "BKE_context.h"
+#  include "BKE_screen.h"
 
-#include "io_gpencil.h"
+#  include "WM_api.h"
+
+#  include "io_gpencil.h"
 
 ARegion *get_invoke_region(bContext *C)
 {
@@ -46,3 +48,5 @@ View3D *get_invoke_view3d(bContext *C)
 
   return NULL;
 }
+
+#endif /* WITH_IO_GPENCIL */
diff --git a/source/blender/editors/io/io_obj.c b/source/blender/editors/io/io_obj.c
index 05bccce7948..a8eed136df3 100644
--- a/source/blender/editors/io/io_obj.c
+++ b/source/blender/editors/io/io_obj.c
@@ -4,37 +4,39 @@
  * \ingroup editor/io
  */
 
-#include "DNA_space_types.h"
+#ifdef WITH_IO_WAVEFRONT_OBJ
 
-#include "BKE_context.h"

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list