I follow a few tutorials from reddit.com/r/limeoats to learn some C ++ game development. I have no experience with CMake or CLion, and I have managed to do this so far.
I had everything until I upgraded OSX to El Capitan (10.11). It seems that I can no longer use #include "SDL2/SDL.h" , but instead use #include "SDL.h" . He can then find the SDL headers. The problem occurs when I also use #include "SDL_image.h" I get the following compiler error:
/Library/Frameworks/SDL2_image.framework/Headers/SDL_image.h:27:10: fatal error: 'SDL2/SDL.h' file not found
Looking at the header file in my Frameworks folder, it has #include <SDL2/SDL.h> , but CMake provides it as SDL.h for some reason after updating OSX to 10.11.
How do I get SDL extensions for a game with an updated header? Or how do I get CMake to return the old SDL2 / SDL.h path?
Below is my CMakeLists.txt, and I got FindSDL2.cmake (note the comment on line 50) and FindSDL2_image.cmake from here .
cmake_minimum_required(VERSION 3.3) project(Cavestory) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin) include_directories(${PROJECT_SOURCE_DIR}/source/headers) find_package(SDL2 REQUIRED) find_package(SDL2_image REQUIRED >=2.0.0) include_directories(${SDL2_INCLUDE_DIR}) include_directories(${SDL2_IMAGE_INCLUDE_DIR}) file(GLOB SOURCE_FILES "source/src/*.cpp") add_executable(Cavestory ${SOURCE_FILES})
And my directory structure (if that helps) ...
/Cavestory (root) CMakeLists.txt /bin /cmake FindSDL2.cmake FindSDL2_image.cmake /content /sprites **images** /docs /source /headers **header files** /src **code files**
source share