1

I need to add a specific MacOSX framework in my CMake files. In my MacOSX machine they are installed SDK 10.9 and 10.10, and in particular I want to use 10.10.

The line I want to add is the following:

target_link_libraries(myappexecutable -framework /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/ApplicationServices.framework/ApplicationServices)

but somehow the 10.9 SDK is mixed therein because I have errors like

/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Headers/LSInfo.h:922:63: error: expected function body after function declarator
CFErrorRef *  outError)                                     __OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_NA);
Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/Availability.h:159:50: note: expanded from macro '__OSX_AVAILABLE_STARTING'
#define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx

What I suppose is that somehow the header files are taken from the SDK 10.9, as far as I understand from the path MacOSX10.9.sdk/usr/include/Availability.h

How can I tell the framework to search in the proper include directory?

I tried to add

include_directories(/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include)

but it seems not working.

What am I doing wrong?

(ps I prefer not to use find_library(), as for example in this question)

To give you some more context, I am switching from qmake to cmake. The corresponding line in qmake was

LIBS += -F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks -framework ApplicationServices

and it is working as expected.

n3mo
  • 663
  • 8
  • 23
  • 1
    So your problem seems not in using a particular *framework*, but in using **proper SDK**. Like in that question: https://stackoverflow.com/questions/10165335/can-cmake-specify-the-base-sdk-on-mac-os-x. – Tsyvarev Sep 19 '18 at 14:20
  • Indeed that was the correct solution, adding `CMAKE_OSX_SYSROOT` solved my problem ;) If you write it as an answer, I will accept it. Thanks – n3mo Sep 20 '18 at 10:06

0 Answers0