I have installed the latest version of SDL2 as a framework (downloaded from the sdl2 website). So it appears alongside other frameworks (/Library/Frameworks/SDL2.framework).
I have been following the “Linking Frameworks” chapter from Professional CMake and cannot seem to make it work.
I have the following:
find_library(SDL2Fwk SDL2 REQUIRED)
message(STATUS "found SDL2Fwk=${SDL2Fwk}")
# trying to build imgui library
add_library(imgui STATIC "${imgui_BUILD_SOURCES}")
target_include_directories(imgui PUBLIC "${imgui_CPP_SRC_DIR}")
target_link_libraries(imgui PUBLIC "-framework SDL2")
which generates
-- found SDL2Fwk=/Library/Frameworks/SDL2.framework
So clearly the framework is found in its proper location. But that does not seem to work as I get:
fatal error: 'SDL.h' file not found
#include <SDL.h>
^~~~~~~
1 error generated.
I have tried with ninja as a generator (which is the default with CLion) but also the XCode generator.
From what you show, it is the expected behavior: option -F/Library/Frameworks is specified. So headers should be under /Library/Frameworks/SDL2.framework/Headers and you must specify headers in the form '<SDL2/SDL.h>` (this is the conventions for framework consumption):