Skip to content

Make cmake build work on MacOS#1596

Draft
SiebrenW wants to merge 1 commit intoturanszkij:masterfrom
SiebrenW:fix/macos_build_cmake
Draft

Make cmake build work on MacOS#1596
SiebrenW wants to merge 1 commit intoturanszkij:masterfrom
SiebrenW:fix/macos_build_cmake

Conversation

@SiebrenW
Copy link
Copy Markdown

@SiebrenW SiebrenW commented Apr 5, 2026

So I tried building the MacOS version of the engine, since I just got a MacBook, but I did notice that XCode is a massive POS and I couldn't even figure out what setting to change to make it work. (because its error messages are 20 clicks away and cryptic as they can be)

After messing quite a bit with it I gave up and I spent significantly less time to fix/hack it in CMake, which is my preference anyway (which is a low bar).

Since it's not production ready or anything I figured it may be helpful to have it. I still notice some wonkiness, but at least it builds.

Apple clang was crashing when building, so I switched to llvm clang. I also suppressed/solved some warnings.

Cheers.

FILE WickedEngineTargets.cmake
NAMESPACE WickedEngine::
DESTINATION ${INSTALL_CONFIGDIR})
# I don't quite get why, but this conflicts with specifying the include dirs in Editor
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC install is currently broken anyway, we can just comment it out for now

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the generated files should all be put into build (aswell as the compiled shaders) so you don't have to run Editor from inside the WickedEngine dir, but the build dir. (if that makes sense)

The installation can be a pain with CMake. Maybe I can look at it sometime, since I have some experience with that, but mostly for linux specifically and statically linked libraries.

@brakhane
Copy link
Copy Markdown
Collaborator

brakhane commented Apr 6, 2026

@SiebrenW BTW, check out the build failures, there currently are some problems on Linux GCC (invalid flag gets added now) and on Windows.

(And since my communication style often catches people off guard: your work on this PR is appreciated)

@SiebrenW SiebrenW force-pushed the fix/macos_build_cmake branch from d0586a7 to c81b5bb Compare April 6, 2026 15:36
@SiebrenW SiebrenW force-pushed the fix/macos_build_cmake branch 2 times, most recently from ab04522 to 1250d15 Compare April 8, 2026 13:08

if (APPLE)
list(APPEND SOURCE_FILES main_MacOS.mm)
# PCH has disabled objective C, so don't use PCH
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw, what do you mean by "has disabled objective C", do you mean they are broken in obj C?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was some warning about saying "disabled ojective C" related to the precompiled headers. I didn't really find it necessary to find out how to re-enable it, so I just disabled PCH for the objective C files.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point is that the comment is very confusing, and I have no idea what it's supposed to tell me. "We don't use PCH on Mac because PCH disables objective C". Could you maybe recheck what the warning says specifically? According to my (admittedly very short) research objective C does support PCH, so I'm a bit confused why it needs to be disabled.
I'm fine with disabling it if it doesn't work in our case for some reason, but we should document the exact reason (just so we/somebody else can re-enable it in the future when that reason doesn't exist anymore)

For context: I've worked with quite a few projects that had workarounds like this that stopped being needed for 5 years, but everybody had assumed they still are. That's why I'm a bit anal about carefully documenting special cases.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, sorry. I'm at work and will be busy/not have access to my Mac until the afternoon (CET) tomorrow, but I was hoping this would be at least a bit informative.

If I had my mac on me I would have elaborated better with snippets and all. Probably just fixed it 😐 .

Thank you for taking the time to review by the way. My intent was to have it as a throwaway hack to get it working, but I'll take it a bit more seriously (hopefully) tomorrow during my break.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error in particular is error:

Objective-C was disabled in precompiled file '.../WickedEngine/build/Editor/CMakeFiles/Editor.dir/cmake_pch.hxx.pch' but is currently enabled
1 error generated.

I think the real issue is down to the fact that the precompiled header is a pure C++ header, not objective C. I couldn't find a way to enable it for both, so I think disabling it has the least impact. Then we have 1 file built without PCH, which isn't such a big deal I think.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to this thread it could be all that's needed is adding LANGUAGES C CXX OBJC OBJCXX to the target line(s)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably omit C but better first test it with to make sure it's not required when using OBJC

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. That did work.

Now the question is: do we really want this? I don' know what the impact is on other targets. I can simply throw it over the fence and see what the pipeline does I suppose.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we would need LANGUAGES CXX on Windows/Linux (maybe LANGUAGES C CXX, not sure) and add objective C for mac, something like

if(APPLE)
set(OBJ_C_LANGS OBJC OBJCXX)
endif()
project(... LANGUAGES C CXX ${OBJ_C_LANGS})

(I don't quite remember from the top of my head if CMake treats undefined vars as empty string, if not, we'd just use a set(LANGUAGES C CXX) for linux and the 4 for mac)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not working for all other platforms, I will stick with the exclusion.

target_compile_definitions(WickedEngine_common PUBLIC _XM_F16C_INTRINSICS_)
endif()
if (USE_FMADD)
target_compile_options(WickedEngine_common PUBLIC -mfma)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above.

@SiebrenW SiebrenW force-pushed the fix/macos_build_cmake branch from 1250d15 to 05c6b5b Compare April 14, 2026 14:37
@SiebrenW SiebrenW force-pushed the fix/macos_build_cmake branch from 05c6b5b to f050c4a Compare April 14, 2026 14:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants