Cannot find "SDL_ttf.h" even though Cmake ran fine

Answered

So I took the FindSDL2TTF.cmake, and replaced the path corresponding to my SDL2_ttf-2.0.14 files (I use Development Libraries for MinGW 32/64-bit).

My CMakeList.txt looks like this:

cmake_minimum_required(VERSION 3.9)
project(MY_PROJECT)

set(CMAKE_C_STANDARD 99)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/Cmake")
find_package(SDL2 REQUIRED)
find_package(SDL2_IMAGE REQUIRED)
#find_package(SDL2_MIXER REQUIRED)
Find_Package (SDL2TTF REQUIRED)

include_directories( ${SDL2_INCLUDE_DIR} )

add_executable(MY_PROJECT main.c )

include_directories(${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_MIXER_INCLUDE_DIR}
${SDL2TFF_LIBRARY}
)
target_link_libraries(MY_PROJECT ${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARY}
${SDL2_MIXER_LIBRARY}
${SDL2TFF_LIBRARY}
)

And I have loaded the Cmake file successfully, no error whatsover. I can run and build my project also.
However, if I include my SDL_tff.h library, Clion just cannot find it, making it impossible to use the library.

Any idea what could be the cause, and some solutions?

Thanks

0
2 comments

Hi! It seems that you've specified header search path for SDL2_IMAGE (${SDL2_IMAGE_INCLUDE_DIR} in include_directories) and haven't specified for SDL2TTF (${SDL2TFF_LIBRARY} is specified in include_directories instead of ${SDL2TTF_INCLUDE_DIR}).

1
Avatar
Permanently deleted user

Again, you saved my day.
Thank youuuuuuuuuuuuuuuuuuuuuuu

0

Please sign in to leave a comment.