Skip to content

CMake iOS build fails on objective-c sources #5418

@guusw

Description

@guusw
> cmake --version
cmake version 3.22.2
> cmake -Bbuild_sdl_ios_x86 -HSDL -GXcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_SYSTEM_PROCESSOR=x86_64 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM=...
> cmake --build build_sdl_ios_x86 --target SDL2 -- -sdk iphonesimulator -arch x86_64

From src/filesystem/cocoa/SDL_sysfilesystem.m:28

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator15.2.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSObjCRuntime.h:523:1: error: 
      expected identifier or '('
@class NSString, Protocol;
^

While searching I found the following similar closed issues/PRs:
#4286
#5010
#4274

There seems to be these lines in the main list (1963):

file(GLOB FILESYSTEM_SOURCES ${SDL2_SOURCE_DIR}/src/filesystem/cocoa/*.m)
# !!! FIXME: modern CMake doesn't need "LANGUAGE C" for Objective-C.
set_source_files_properties(${FILESYSTEM_SOURCES} PROPERTIES LANGUAGE C)

This forces objective-c sources to be compiled as C files, which makes no sense.
I tried some older versions of cmake (3.0, 3.10, 3.16, 3.18) however none of them seem to be able to even build in this way with various issues. 3.19 seems to start working after removing the set_source_files_properties
Also tried to set CMP0119 to OLD, however this did nothing.

Can we remove the set_source_files_properties on objective-c files? (or at least for versions >= 3.19)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions