wjakob / nori

Nori: an educational ray tracer
https://wjakob.github.io/nori
849 stars 182 forks source link

Bad Make File causing errors on recent Mac Xcode (With Fix) #20

Open cortis opened 3 years ago

cortis commented 3 years ago

I tried building nori on my Mac in 2020 and got errors like the following: /Users/cortis/Save The Machine/Experiments/nori/ext/nanogui/ext/glfw/src/cocoa_init.m:282:1: error: expected identifier or '(' @interface GLFWLayoutListener : NSObject ^ /Users/cortis/Save The Machine/Experiments/nori/ext/nanogui/ext/glfw/src/cocoa_init.m:292:1: error: expected identifier or '(' @end ^ ....

The problem can be fixed by deleting (or commenting out) lines 75-79 of nori/ext/nanogui/ext/glfw/src/CMakeLists.txt

Specifically you need to remove these lines for modern macs (Tested with macOS Catalina 10.15.4 and Xcode 11.6): if (APPLE)

For some reason, CMake doesn't know about .m

set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)

endif()

Modjular commented 3 years ago

Thanks so much for this fix! I never would have known to look there. Do you why this happens? (I know nothing about CMake)

For some reason,

if (APPLE)
# For some reason, CMake doesn't know about .m
set_source_files_properties(${glfw_SOURCES} PROPERTIES LANGUAGE C)
endif()

was lines 50-53 on my machine.

cortis commented 3 years ago

Do you why this happens?

I'm guessing that Cmake has been updated to know about .m files. It looked suspect to me because the error I was getting looked like it was treating the .m files as c-files.

msken commented 3 years ago

I'm trying to build GLFW3.3.0 included as a part of Open3D with Xcode 12.3 configured with CMake 3.19.0, and I encountered the same error with the first post. The lines 'if (APPLE) ... endif()' are not in CMakeLists.txt. Can anyone help me to work around this problem?

FantasyVR commented 3 years ago

This solution helps me a lot!

dvicini commented 3 years ago

@cortis @Modjular I was trying to reproduce your issue. It seems to not occur anymore using the latest version of Nori and MacOS, is that correct?

yvettemuki commented 3 years ago

The solution did work!