3.7.5: macOS failed build when using latest os version (12.3)

I generated a plugin with the provided generator (and latest 3.7.5). If you remove the line

    # set(CMAKE_OSX_DEPLOYMENT_TARGET 10.12)

from the generated CMakeLists.txt, it builds with the “latest” version which, in my case is 12.3 and this leads to this error

    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++ -target arm64-apple-macos12.3 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk -L/Users/ypujante/tmp/KoozaGenerated/build/bin/Debug -F/Users/ypujante/tmp/KoozaGenerated/build/bin/Debug -filelist /Users/ypujante/tmp/KoozaGenerated/build/vst3sdk/public.sdk/samples/vst-hosting/inspectorapp/KoozaGenerated.build/Debug/VST3Inspector.build/Objects-normal/arm64/VST3Inspector.LinkFileList -Xlinker -object_path_lto -Xlinker /Users/ypujante/tmp/KoozaGenerated/build/vst3sdk/public.sdk/samples/vst-hosting/inspectorapp/KoozaGenerated.build/Debug/VST3Inspector.build/Objects-normal/arm64/VST3Inspector_lto.o -Xlinker -no_deduplicate -stdlib\=libc++ -fobjc-link-runtime -Wl,-search_paths_first -Wl,-headerpad_max_install_names /Users/ypujante/tmp/KoozaGenerated/build/lib/Debug/libvstgui.a /Users/ypujante/tmp/KoozaGenerated/build/lib/Debug/libvstgui_uidescription.a /Users/ypujante/tmp/KoozaGenerated/build/lib/Debug/libvstgui_standalone.a /Users/ypujante/tmp/KoozaGenerated/build/lib/Debug/libvstgui.a -framework Cocoa -framework QuartzCore -framework Accelerate -framework OpenGL -lexpat -Xlinker -no_adhoc_codesign -Xlinker -dependency_info -Xlinker /Users/ypujante/tmp/KoozaGenerated/build/vst3sdk/public.sdk/samples/vst-hosting/inspectorapp/KoozaGenerated.build/Debug/VST3Inspector.build/Objects-normal/arm64/VST3Inspector_dependency_info.dat -o /Users/ypujante/tmp/KoozaGenerated/build/bin/Debug/VST3Inspector.app/Contents/MacOS/VST3Inspector
Undefined symbols for architecture arm64:
  "_OBJC_CLASS_$_UTType", referenced from:
      objc-class-ref in libvstgui.a(macfileselector.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

You need to set a deployment target.
If you want to set this to macOS 12 you need to set(CMAKE_OSX_DEPLOYMENT_TARGET 12).

Not setting it, picks up the “default” which is 12.3. The problem is not “not setting it”. The problem is that with 12.3 it doesn’t work. I tried explicitly setting it to 12.3 with the same result.

Even tho, not setting it will indeed use 12.3 in the compiler, but due to a change in macOS that if you set this to anything newer than macOS 11, you need to add another framework to be able to successfully link.
As cmake does not know the default which is used if you don’t set it, you have to set it otherwise the framework is not added to the linker as argument.
The real problem with the CMakeLists.txt generated by the project generator is, that it sets the variable too late. It must be put directly below the project function at the top.

Interesting… According to the CMake documentation, shouldn’t it be put actually before the project() definition? CMAKE_OSX_DEPLOYMENT_TARGET — CMake 3.28.0-rc5 Documentation

Seems so. I will make a bug entry for this in our internal database.