[Bf-blender-cvs] [42a6c226d03] master: CMake: fix AUDASPACE disabling WITH_PYTHON for Blender

Campbell Barton noreply at git.blender.org
Fri May 20 03:26:17 CEST 2022


Commit: 42a6c226d03624d880fe480eeaf2fda1bf8f5ab9
Author: Campbell Barton
Date:   Fri May 20 11:17:34 2022 +1000
Branches: master
https://developer.blender.org/rB42a6c226d03624d880fe480eeaf2fda1bf8f5ab9

CMake: fix AUDASPACE disabling WITH_PYTHON for Blender

When AUDASPACE couldn't find NUMPY, it would disable WITH_PYTHON for
the rest of Blender. Now setting the value globally is only done for
standalone AUDASPACE builds. Now it's possible to build Blender with
AUDASPACE & PYTHON but without NUMPY.

While this isn't an especially important configuration to support,
having Python mysteriously disabled is a hassle to troubleshoot.

NOTE: extern/audaspace/CMakeLists.txt has become out sync with the
original [0], it seems this is being maintained in our repository.

[0]: https://github.com/neXyon/audaspace/blob/master/CMakeLists.txt

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

M	extern/audaspace/CMakeLists.txt
M	intern/audaspace/CMakeLists.txt
M	source/blender/python/intern/CMakeLists.txt
M	source/blender/python/intern/bpy_interface.c

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

diff --git a/extern/audaspace/CMakeLists.txt b/extern/audaspace/CMakeLists.txt
index 9877c8f7768..ca1849321e2 100644
--- a/extern/audaspace/CMakeLists.txt
+++ b/extern/audaspace/CMakeLists.txt
@@ -450,7 +450,11 @@ if(WITH_COREAUDIO)
 		if(WITH_STRICT_DEPENDENCIES)
 			message(FATAL_ERROR "CoreAudio not found!")
 		else()
-			set(WITH_COREAUDIO FALSE CACHE BOOL "Build With CoreAudio" FORCE)
+			if(AUDASPACE_STANDALONE)
+				set(WITH_COREAUDIO FALSE CACHE BOOL "Build With CoreAudio" FORCE)
+			else()
+				set(WITH_COREAUDIO FALSE)
+			endif()
 			message(WARNING "CoreAudio not found, plugin will not be built.")
 		endif()
 	endif()
@@ -487,7 +491,11 @@ if(WITH_FFMPEG)
 			list(APPEND DLLS ${FFMPEG_DLLS})
 		endif()
 	else()
-		set(WITH_FFMPEG FALSE CACHE BOOL "Build With FFMPEG" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_FFMPEG FALSE CACHE BOOL "Build With FFMPEG" FORCE)
+		else()
+			set(WITH_FFMPEG FALSE)
+		endif()
 		message(WARNING "FFMPEG not found, plugin will not be built.")
 	endif()
 endif()
@@ -536,7 +544,11 @@ if(WITH_FFTW)
 			list(APPEND DLLS ${FFTW_DLLS})
 		endif()
 	else()
-		set(WITH_FFTW FALSE CACHE BOOL "Build With FFTW" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_FFTW FALSE CACHE BOOL "Build With FFTW" FORCE)
+		else()
+			set(WITH_FFTW FALSE)
+		endif()
 		message(WARNING "FFTW not found, convolution functionality will not be built.")
 	endif()
 endif()
@@ -579,7 +591,11 @@ if(WITH_JACK)
 			list(APPEND DLLS ${JACK_DLLS})
 		endif()
 	else()
-		set(WITH_JACK FALSE CACHE BOOL "Build With JACK" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_JACK FALSE CACHE BOOL "Build With JACK" FORCE)
+		else()
+			set(WITH_JACK FALSE)
+		endif()
 		message(WARNING "JACK not found, plugin will not be built.")
 	endif()
 endif()
@@ -615,7 +631,11 @@ if(WITH_LIBSNDFILE)
 			list(APPEND DLLS ${LIBSNDFILE_DLLS})
 		endif()
 	else()
-		set(WITH_LIBSNDFILE FALSE CACHE BOOL "Build With LibSndFile" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_LIBSNDFILE FALSE CACHE BOOL "Build With LibSndFile" FORCE)
+		else()
+			set(WITH_LIBSNDFILE FALSE)
+		endif()
 		message(WARNING "LibSndFile not found, plugin will not be built.")
 	endif()
 endif()
@@ -649,7 +669,11 @@ if(WITH_OPENAL)
 			list(APPEND DLLS ${OPENAL_DLLS})
 		endif()
 	else()
-		set(WITH_OPENAL FALSE CACHE BOOL "Build With OpenAL" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_OPENAL FALSE CACHE BOOL "Build With OpenAL" FORCE)
+		else()
+			set(WITH_OPENAL FALSE)
+		endif()
 		message(WARNING "OpenAL not found, plugin will not be built.")
 	endif()
 endif()
@@ -685,7 +709,11 @@ if(WITH_PULSEAUDIO)
 			list(APPEND STATIC_PLUGINS PulseAudioDevice)
 		endif()
 	else()
-		set(WITH_PULSEAUDIO FALSE CACHE BOOL "Build With PulseAudio" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_PULSEAUDIO FALSE CACHE BOOL "Build With PulseAudio" FORCE)
+		else()
+			set(WITH_PULSEAUDIO FALSE)
+		endif()
 		message(WARNING "PulseAudio not found, plugin will not be built.")
 	endif()
 endif()
@@ -716,8 +744,12 @@ if(WITH_PYTHON)
 			list(APPEND DLLS ${PYTHON_DLLS})
 		endif()
 	else()
-		set(WITH_PYTHON FALSE CACHE BOOL "Build With Python Library" FORCE)
-		message(WARNING "Python libraries not found, language binding will not be built.")
+		if(AUDASPACE_STANDALONE)
+			set(WITH_PYTHON FALSE CACHE BOOL "Build With Python Library" FORCE)
+		else()
+			set(WITH_PYTHON FALSE)
+		endif()
+		message(WARNING "Python & NumPy libraries not found, language binding will not be built.")
 	endif()
 endif()
 
@@ -759,7 +791,11 @@ if(WITH_SDL)
 			list(APPEND DLLS ${SDL_DLLS})
 		endif()
 	else()
-		set(WITH_SDL FALSE CACHE BOOL "Build With SDL" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_SDL FALSE CACHE BOOL "Build With SDL" FORCE)
+		else()
+			set(WITH_SDL FALSE)
+		endif()
 		message(WARNING "SDL not found, plugin will not be built.")
 	endif()
 endif()
@@ -1116,7 +1152,11 @@ if(WITH_DOCS)
 
 		add_custom_target(audaspace_doc ALL ${DOXYGEN_EXECUTABLE} Doxyfile COMMENT "Building C++ HTML documentation with Doxygen.")
 	else()
-		set(WITH_DOCS FALSE CACHE BOOL "Build C++ HTML Documentation with Doxygen" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_DOCS FALSE CACHE BOOL "Build C++ HTML Documentation with Doxygen" FORCE)
+		else()
+			set(WITH_DOCS FALSE)
+		endif()
 		message(WARNING "Doxygen (and/or dot) not found, documentation will not be built.")
 	endif()
 endif()
@@ -1129,7 +1169,11 @@ if(WITH_BINDING_DOCS)
 
 		add_custom_target(bindings_doc ALL COMMAND ${PYTHON_EXECUTABLE} setup.py --build-docs ${SPHINX_EXECUTABLE} -q -b html -c "${CMAKE_CURRENT_BINARY_DIR}" -d "${CMAKE_CURRENT_BINARY_DIR}/_doctrees" "${CMAKE_CURRENT_SOURCE_DIR}/bindings/doc" "${CMAKE_CURRENT_BINARY_DIR}/doc/bindings" DEPENDS pythonmodule COMMENT "Building C/Python HTML documentation with Sphinx.")
 	else()
-		set(WITH_BINDING_DOCS FALSE CACHE BOOL "Build C/Python HTML Documentation with Sphinx" FORCE)
+		if(AUDASPACE_STANDALONE)
+			set(WITH_BINDING_DOCS FALSE CACHE BOOL "Build C/Python HTML Documentation with Sphinx" FORCE)
+		else()
+			set(WITH_BINDING_DOCS FALSE)
+		endif()
 		message(WARNING "Sphinx not found, binding documentation will not be built.")
 	endif()
 endif()
diff --git a/intern/audaspace/CMakeLists.txt b/intern/audaspace/CMakeLists.txt
index 67b45be8158..0e2b27c0760 100644
--- a/intern/audaspace/CMakeLists.txt
+++ b/intern/audaspace/CMakeLists.txt
@@ -35,11 +35,15 @@ if(NOT WITH_SYSTEM_AUDASPACE)
 else()
   list(APPEND LIB
     ${AUDASPACE_C_LIBRARIES}
-    ${AUDASPACE_PY_LIBRARIES}
   )
+  if(WITH_PYTHON AND WITH_PYTHON_NUMPY)
+    list(APPEND LIB
+      ${AUDASPACE_PY_LIBRARIES}
+    )
+  endif()
 endif()
 
-if(WITH_PYTHON)
+if(WITH_PYTHON AND WITH_PYTHON_NUMPY)
   list(APPEND INC_SYS
     ${PYTHON_INCLUDE_DIRS}
   )
diff --git a/source/blender/python/intern/CMakeLists.txt b/source/blender/python/intern/CMakeLists.txt
index e4e198ab812..959fbc7ee98 100644
--- a/source/blender/python/intern/CMakeLists.txt
+++ b/source/blender/python/intern/CMakeLists.txt
@@ -143,10 +143,13 @@ if(WITH_PYTHON_SAFETY)
   add_definitions(-DWITH_PYTHON_SAFETY)
 endif()
 
-
-
 if(WITH_AUDASPACE)
+  # It's possible to build with AUDASPACE (for file IO) but without the `aud` Python API,
+  # when building without NUMPY so define both `WITH_AUDASPACE` & `DWITH_AUDASPACE_PY`.
   add_definitions(-DWITH_AUDASPACE)
+  if(WITH_PYTHON_NUMPY)
+    add_definitions(-DWITH_AUDASPACE_PY)
+  endif()
 endif()
 
 if(WITH_BULLET)
diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c
index 5c9de638d8a..0ab8b4385e5 100644
--- a/source/blender/python/intern/bpy_interface.c
+++ b/source/blender/python/intern/bpy_interface.c
@@ -238,7 +238,7 @@ void BPY_context_set(bContext *C)
 extern PyObject *Manta_initPython(void);
 #endif
 
-#ifdef WITH_AUDASPACE
+#ifdef WITH_AUDASPACE_PY
 /* defined in AUD_C-API.cpp */
 extern PyObject *AUD_initPython(void);
 #endif
@@ -272,7 +272,7 @@ static struct _inittab bpy_internal_modules[] = {
 #ifdef WITH_FLUID
     {"manta", Manta_initPython},
 #endif
-#ifdef WITH_AUDASPACE
+#ifdef WITH_AUDASPACE_PY
     {"aud", AUD_initPython},
 #endif
 #ifdef WITH_CYCLES



More information about the Bf-blender-cvs mailing list