Created
May 18, 2024 11:07
-
-
Save dogukanarat/d5a3ee36ddf20aec715153e66d42479c to your computer and use it in GitHub Desktop.
FindSDL2 cmake module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# FindSDL2 - Find SDL2 library | |
# This module finds if SDL2 is installed and determines where the include | |
# files and libraries are. It also determines where the other SDL libraries | |
# (SDL2_mixer, SDL2_image, etc) are installed. | |
# This module defines the following variables: | |
# SDL2_FOUND - True if SDL2 is available | |
# SDL2_INCLUDE_DIRS - Where to find the SDL2 headers | |
# SDL2_LIBRARIES - The libraries to link against | |
find_library( | |
SDL2_LIBRARY | |
NAMES SDL2_FOUND | |
/usr/local/lib | |
/usr/lib | |
/usr/local/lib64 | |
/usr/lib64 | |
/opt/local/lib | |
/opt/homebrew/Cellar/ | |
) | |
find_path( | |
SDL2_INCLUDE_DIR | |
NAMES SDL.h | |
PATH_SUFFIXES SDL2 | |
PATHS | |
/usr/local/include | |
/usr/include | |
/opt/local/include | |
/opt/homebrew/Cellar | |
) | |
if(SDL2_LIBRARY AND SDL2_INCLUDE_DIR) | |
set(SDL2_FOUND TRUE) | |
set(SDL2_LIBRARIES ${SDL2_LIBRARY}) | |
set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) | |
get_filename_component(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS} DIRECTORY) | |
message(STATUS "SDL2 found: ${SDL2_LIBRARIES} ${SDL2_INCLUDE_DIRS}") | |
else() | |
set(SDL2_FOUND FALSE) | |
message(FATAL_ERROR "SDL2 not found") | |
endif() | |
# FindSDL2_image - Find SDL2_image library | |
# This module finds if SDL2_image is installed and determines where the include | |
# files and libraries are. | |
# This module defines the following variables: | |
# SDL2_IMAGE_FOUND - True if SDL2_image is available | |
# SDL2_IMAGE_INCLUDE_DIRS - Where to find the SDL2_image headers | |
# SDL2_IMAGE_LIBRARIES - The libraries to link against | |
find_library( | |
SDL2_IMAGE_LIBRARY | |
NAMES SDL2_image | |
/usr/local/lib | |
/usr/lib | |
/usr/local/lib64 | |
/usr/lib64 | |
/opt/local/lib | |
/opt/homebrew/Cellar/ | |
) | |
find_path( | |
SDL2_IMAGE_INCLUDE_DIR | |
NAMES SDL_image.h | |
PATH_SUFFIXES SDL2 | |
PATHS | |
/usr/local/include | |
/usr/include | |
/opt/local/include | |
/opt/homebrew/Cellar/ | |
) | |
if(SDL2_IMAGE_LIBRARY AND SDL2_IMAGE_INCLUDE_DIR) | |
set(SDL2_IMAGE_FOUND TRUE) | |
set(SDL2_IMAGE_LIBRARIES ${SDL2_IMAGE_LIBRARY}) | |
set(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIR}) | |
get_filename_component(SDL2_IMAGE_INCLUDE_DIRS ${SDL2_IMAGE_INCLUDE_DIRS} DIRECTORY) | |
message(STATUS "SDL2_image found: ${SDL2_IMAGE_LIBRARIES} ${SDL2_IMAGE_INCLUDE_DIRS}") | |
else() | |
set(SDL2_IMAGE_FOUND FALSE) | |
message(FATAL_ERROR "SDL2_image not found") | |
endif() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment