Mercurial > molko
view cmake/FindSDL2.cmake @ 352:1c18b584e2cb
core: also requires libm
author | David Demelier <markand@malikania.fr> |
---|---|
date | Wed, 20 Oct 2021 18:33:22 +0200 |
parents | 3bfaaf5342a9 |
children |
line wrap: on
line source
# FindSDL2 # -------- # # Find SDL2 library and components, this modules defines: # # SDL2_LIBRARY, the name of the library to link against. # SDL2_MAIN_LIBRARY, for SDL2main (if present). # SDL2_LIBRARIES, alias to SDL2_LIBRARY. # SDL2_FOUND, true if found. # SDL2_INCLUDE_DIR, where to find SDL.h. # # The following imported targets will be defined: # # SDL2::SDL2 # SDL2::SDL2main (if present) # # This module also handle the following official SDL addons: # # - image # - mixer # - net # - ttf # # And thus, variables SDL2_<C>_LIBRARY, SDL2_<C>_INCLUDE_DIRS and SDL2::<C> # imported targets will be defined if they are found. # include(FindPackageHandleStandardArgs) # The official include convention is <SDL.h> not <SDL/SDL.h>. find_path( SDL2_INCLUDE_DIR NAMES SDL.h PATH_SUFFIXES include/SDL2 include ) find_library(SDL2_LIBRARY NAMES SDL2 libSDL2 SDL2d libSDL2d) find_library(SDL2_MAIN_LIBRARY NAMES SDL2main libSDL2main SDL2maind libSDL2maind) # Standard components. foreach (c ${SDL2_FIND_COMPONENTS}) find_path( SDL2_${c}_INCLUDE_DIR NAMES SDL.h PATH_SUFFIXES include/SDL2 include ) find_library( SDL2_${c}_LIBRARY NAMES SDL2_${c} libSDL2_${c} ) if (NOT TARGET SDL2::${c} AND SDL2_${c}_LIBRARY) set(SDL2_${c}_FOUND TRUE) add_library(SDL2::${c} UNKNOWN IMPORTED) set_target_properties( SDL2::${c} PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${SDL2_${c}_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_${c}_INCLUDE_DIRS}" ) endif () mark_as_advanced(SDL2_${c}_INCLUDE_DIR SDL2_${c}_LIBRARY) endforeach () find_package_handle_standard_args( SDL2 REQUIRED_VARS SDL2_LIBRARY SDL2_INCLUDE_DIR HANDLE_COMPONENTS ) if (SDL2_FOUND) set(SDL2_LIBRARIES ${SDL2_LIBRARY}) set(SDL2_INCLUDE_DIRS ${SDL2_INCLUDE_DIR}) if (NOT TARGET SDL2::SDL2) add_library(SDL2::SDL2 UNKNOWN IMPORTED) set_target_properties( SDL2::SDL2 PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${SDL2_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" ) endif () if (NOT TARGET SDL2::main AND SDL2_MAIN_LIBRARY) add_library(SDL2::main UNKNOWN IMPORTED) set_target_properties( SDL2::main PROPERTIES IMPORTED_LINK_INTERFACE_LANGUAGES "C" IMPORTED_LOCATION "${SDL2_MAIN_LIBRARY}" INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}" ) endif () endif () mark_as_advanced(SDL2_INCLUDE_DIR SDL2_LIBRARY)