From 067dfa35c6b2f15f82554f9eeb72b510df2e7218 Mon Sep 17 00:00:00 2001 From: Kris Austin Date: Sat, 5 Sep 2026 12:14:59 -0500 Subject: [PATCH] fix: make Windows debug builds work (#15353) Co-authored-by: Rodrigo Faselli <162915171+RF47@users.noreply.github.com> --- deps/python3/python3.cmake | 8 ++------ deps/python3/stage_windows.cmake | 20 +++----------------- src/CMakeLists.txt | 13 ++++++++++++- src/slic3r/plugin/PluginAuditManager.hpp | 3 ++- src/slic3r/plugin/PythonInterpreter.hpp | 3 ++- 5 files changed, 21 insertions(+), 26 deletions(-) diff --git a/deps/python3/python3.cmake b/deps/python3/python3.cmake index e93045fe45..d926c7e888 100644 --- a/deps/python3/python3.cmake +++ b/deps/python3/python3.cmake @@ -53,12 +53,9 @@ if(WIN32) set(_python_pcbuild_output_dir win32) endif() + # pybind11 undefines _DEBUG around Python.h so a debug build links the + # release python3xx.lib; Py_DEBUG could not load release plugin modules. set(_python_pcbuild_config Release) - set(_python_layout_debug OFF) - if(DEFINED DEP_DEBUG AND DEP_DEBUG) - set(_python_pcbuild_config Debug) - set(_python_layout_debug ON) - endif() # CPython's PCbuild needs a 64-bit-hosted toolchain: find_msbuild.bat picks the # 32-bit Bin\MSBuild.exe, whose x86 cl.exe/link.exe run out of address space @@ -101,7 +98,6 @@ if(WIN32) -DPYTHON_BUILD_DIR=/PCbuild/${_python_pcbuild_output_dir} -DPYTHON_DEST_DIR=${DESTDIR}/libpython -DPYTHON_LAYOUT_ARCH=${_python_layout_arch} - -DPYTHON_DEBUG=${_python_layout_debug} -P ${CMAKE_CURRENT_LIST_DIR}/stage_windows.cmake ) elseif(APPLE) diff --git a/deps/python3/stage_windows.cmake b/deps/python3/stage_windows.cmake index b127f06b68..758e0be9f3 100644 --- a/deps/python3/stage_windows.cmake +++ b/deps/python3/stage_windows.cmake @@ -9,9 +9,6 @@ foreach(_var PYTHON_SOURCE_DIR PYTHON_BUILD_DIR PYTHON_DEST_DIR PYTHON_LAYOUT_AR endforeach() set(_python_exe "${PYTHON_BUILD_DIR}/python.exe") -if(PYTHON_DEBUG) - set(_python_exe "${PYTHON_BUILD_DIR}/python_d.exe") -endif() if(NOT EXISTS "${_python_exe}") message(FATAL_ERROR "Built Python executable not found: ${_python_exe}") @@ -49,22 +46,11 @@ endif() set(_required_files "${PYTHON_DEST_DIR}/Lib/encodings/__init__.py" "${PYTHON_DEST_DIR}/include/Python.h" + "${PYTHON_DEST_DIR}/python.exe" + "${PYTHON_DEST_DIR}/python${_python_abi}.dll" + "${PYTHON_DEST_DIR}/libs/python${_python_abi}.lib" ) -if(PYTHON_DEBUG) - list(APPEND _required_files - "${PYTHON_DEST_DIR}/python_d.exe" - "${PYTHON_DEST_DIR}/python${_python_abi}_d.dll" - "${PYTHON_DEST_DIR}/libs/python${_python_abi}_d.lib" - ) -else() - list(APPEND _required_files - "${PYTHON_DEST_DIR}/python.exe" - "${PYTHON_DEST_DIR}/python${_python_abi}.dll" - "${PYTHON_DEST_DIR}/libs/python${_python_abi}.lib" - ) -endif() - foreach(_required_file IN LISTS _required_files) if(NOT EXISTS "${_required_file}") message(FATAL_ERROR "Staged Python file missing: ${_required_file}") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0036af0a8c..f0de57f12c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -33,7 +33,8 @@ if (SLIC3R_GUI) set (wxWidgets_CONFIG_OPTIONS "--toolkit=gtk${SLIC3R_GTK}") find_package(wxWidgets 3.3 REQUIRED COMPONENTS base core adv html gl aui net media webview) else () - find_package(wxWidgets 3.3 CONFIG REQUIRED COMPONENTS html adv gl core base webview aui net media) + # propgrid is required by wxInspector. + find_package(wxWidgets 3.3 CONFIG REQUIRED COMPONENTS html adv gl core base webview aui net media propgrid) endif () if(UNIX) @@ -90,6 +91,16 @@ if (SLIC3R_GUI) # list(REMOVE_ITEM wxWidgets_LIBRARIES oleacc) find_package(wxInspector REQUIRED) + + # wxInspector's exported interface names the release wxWidgets import + # libraries, which a Debug build cannot link. wx is linked above instead. + get_target_property(_wxinspector_interface wxInspector::wxInspector INTERFACE_LINK_LIBRARIES) + if (_wxinspector_interface) + list(FILTER _wxinspector_interface EXCLUDE REGEX "wx(base|msw)3[0-9]u[_.]") + set_target_properties(wxInspector::wxInspector PROPERTIES + INTERFACE_LINK_LIBRARIES "${_wxinspector_interface}") + endif () + list(APPEND wxWidgets_LIBRARIES "wxInspector::wxInspector") message(STATUS "wx libs: ${wxWidgets_LIBRARIES}") diff --git a/src/slic3r/plugin/PluginAuditManager.hpp b/src/slic3r/plugin/PluginAuditManager.hpp index d6751a57fd..153f9d6107 100644 --- a/src/slic3r/plugin/PluginAuditManager.hpp +++ b/src/slic3r/plugin/PluginAuditManager.hpp @@ -1,7 +1,8 @@ #ifndef slic3r_PluginAuditManager_hpp_ #define slic3r_PluginAuditManager_hpp_ -#include +// Via pybind11 so this file requests the same python3xx.lib as everything else. +#include #include #include #include diff --git a/src/slic3r/plugin/PythonInterpreter.hpp b/src/slic3r/plugin/PythonInterpreter.hpp index ff69ce6846..e15aa91598 100644 --- a/src/slic3r/plugin/PythonInterpreter.hpp +++ b/src/slic3r/plugin/PythonInterpreter.hpp @@ -1,7 +1,8 @@ #ifndef slic3r_PythonInterpreter_hpp_ #define slic3r_PythonInterpreter_hpp_ -#include +// Via pybind11 so this file requests the same python3xx.lib as everything else. +#include #include #include #include