annidy / notes

0 stars 0 forks source link

cmake with objc #165

Open annidy opened 6 months ago

annidy commented 6 months ago

Use framework in cmake

target_link_libraries(${PROJECT_NAME}
    "-framework Foundation"
    "-lobjc"
)

Sometime, you will get this in your cpp file

expected unqualified-id @class NSString

this is because cpp file can't include objc file, only .m/.mm support.

#ifdef __OBJC__
#include <Fondation/Foundation.h>
#endif
annidy commented 5 months ago

another OpenGL example

if (APPLE)
    set(CMAKE_CXX_FLAGS "-framework Cocoa -framework IOKit -framework Foundation -framework OpenGL -framework CoreVideo")
    # -framework OpenGL -framework CoreVideo
    add_compile_definitions(GL_SILENCE_DEPRECATION)
    add_compile_options(-Wno-unused-command-line-argument)
endif ()