Fix macOS build with CMake 4.x and Xcode 16+#10717
Open
karlingen wants to merge 1 commit into
Open
Conversation
- deps-macos: Add CMAKE_POLICY_VERSION_MINIMUM=3.5 to DEP_CMAKE_OPTS to fix CMake 4.x compatibility for all ExternalProject sub-builds - Assimp: Set ASSIMP_BUILD_ZLIB=OFF to use system zlib instead of Assimp's bundled zlib, which has an fdopen macro conflict with newer macOS SDKs (Xcode 16+) - Clipper2: Add -Wno-unknown-warning-option to prevent -Werror from failing on unrecognized flags propagated from the parent CMakeLists - wxMediaCtrl2/MediaPlayCtrl: Change constexpr to const for wxMediaState casts that fail with newer Clang's stricter constexpr enum rules - AMSMaterialsSetting: Fix call to non-existent method get_extruder_id_by_ams_id; use GetFilaSystem()->GetExtruderIdByAmsId()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Building BambuStudio on macOS fails with CMake ≥ 4.0 and Xcode 16+ (AppleClang 18+) due to several issues:
CMake 4.x removed compatibility with
cmake_minimum_required< 3.5, causing multiple dependency sub-builds (Boost, OpenSSL, wxWidgets cotire, etc.) to fail during configuration.Assimp's bundled zlib defines
#define fdopen(fd,mode) NULLinzutil.h, which conflicts with the macOS SDK'sfdopendeclaration in_stdio.hstarting with Xcode 16, producing:Clipper2's
-Werrorcauses the build to fail because the parentCMakeLists.txtadds-Wno-error=enum-constexpr-conversion(line 286), which is an unrecognized warning option on some AppleClang versions. Combined with Clipper2's-Werror, this triggers-Werror,-Wunknown-warning-option.constexprenum casts inwxMediaCtrl2.handMediaPlayCtrl.hfail with newer Clang, which enforces stricter rules forconstexprwith unscoped enum types:AMSMaterialsSetting.cppcallsobj->get_extruder_id_by_ams_id(), a method that does not exist onMachineObject. This is a code bug that fails on any compiler.Changes
deps/deps-macos.cmakeAdd
-DCMAKE_POLICY_VERSION_MINIMUM=3.5toDEP_CMAKE_OPTSso it propagates to allExternalProject_Addsub-builds viabambustudio_add_cmake_project.deps/Assimp/Assimp.cmakeChange
ASSIMP_BUILD_ZLIBfromONtoOFF. This uses the system zlib instead of Assimp's bundled copy, which is the standard approach on macOS where system zlib is always available.src/clipper2/CMakeLists.txtAdd
-Wno-unknown-warning-optionalongside-Werrorfor non-Windows builds. This prevents the build from failing when the parent project adds warning flags that the current compiler version doesn't recognize.src/slic3r/GUI/wxMediaCtrl2.handsrc/slic3r/GUI/MediaPlayCtrl.hChange
static constexpr wxMediaStatetostatic const wxMediaStatefor custom media state constants. Casting integer values to an unscoped enum in aconstexprcontext is rejected by Clang 18+ (Xcode 16+). Usingconstpreserves identical runtime behavior.src/slic3r/GUI/AMSMaterialsSetting.cppReplace call to non-existent
obj->get_extruder_id_by_ams_id()withobj->GetFilaSystem()->GetExtruderIdByAmsId(), which is the correct API used elsewhere in the same file (e.g., lines 597 and 1025).Build environment tested
Wiki update suggestion
The Mac Compile Guide should note that CMake 4.x users need to prefix build commands with:
export CMAKE_POLICY_VERSION_MINIMUM=3.5or use CMake 3.x until upstream dependencies update their
cmake_minimum_required()declarations.