Subversion Repositories Games.Carmageddon

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 pmbaty 1
# SDL2 CMake configuration file:
2
# This file is meant to be placed in Resources/CMake of a SDL2 framework
3
 
4
# INTERFACE_LINK_OPTIONS needs CMake 3.12
5
cmake_minimum_required(VERSION 3.12)
6
 
7
include(FeatureSummary)
8
set_package_properties(SDL2 PROPERTIES
9
    URL "https://www.libsdl.org/"
10
    DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
11
)
12
 
13
# Copied from `configure_package_config_file`
14
macro(set_and_check _var _file)
15
    set(${_var} "${_file}")
16
    if(NOT EXISTS "${_file}")
17
        message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
18
    endif()
19
endmacro()
20
 
21
# Copied from `configure_package_config_file`
22
macro(check_required_components _NAME)
23
    foreach(comp ${${_NAME}_FIND_COMPONENTS})
24
        if(NOT ${_NAME}_${comp}_FOUND)
25
            if(${_NAME}_FIND_REQUIRED_${comp})
26
                set(${_NAME}_FOUND FALSE)
27
            endif()
28
        endif()
29
    endforeach()
30
endmacro()
31
 
32
set(SDL2_FOUND TRUE)
33
 
34
string(REGEX REPLACE "SDL2\\.framework.*" "SDL2.framework" SDL2_FRAMEWORK_PATH "${CMAKE_CURRENT_LIST_DIR}")
35
string(REGEX REPLACE "SDL2\\.framework.*" "" SDL2_FRAMEWORK_PARENT_PATH "${CMAKE_CURRENT_LIST_DIR}")
36
 
37
# For compatibility with autotools sdl2-config.cmake, provide SDL2_* variables.
38
 
39
set_and_check(SDL2_PREFIX       "${SDL2_FRAMEWORK_PATH}")
40
set_and_check(SDL2_EXEC_PREFIX  "${SDL2_FRAMEWORK_PATH}")
41
set_and_check(SDL2_INCLUDE_DIR  "${SDL2_FRAMEWORK_PATH}/Headers")
42
set(SDL2_INCLUDE_DIRS           "${SDL2_INCLUDE_DIR};${SDL2_FRAMEWORK_PATH}")
43
set_and_check(SDL2_BINDIR       "${SDL2_FRAMEWORK_PATH}")
44
set_and_check(SDL2_LIBDIR       "${SDL2_FRAMEWORK_PATH}")
45
 
46
set(SDL2_LIBRARIES "SDL2::SDL2")
47
 
48
# All targets are created, even when some might not be requested though COMPONENTS.
49
# This is done for compatibility with CMake generated SDL2-target.cmake files.
50
 
51
if(NOT TARGET SDL2::SDL2)
52
    add_library(SDL2::SDL2 INTERFACE IMPORTED)
53
    set_target_properties(SDL2::SDL2
54
        PROPERTIES
55
            INTERFACE_COMPILE_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\""
56
            INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
57
            INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2"
58
            COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
59
            INTERFACE_SDL2_SHARED "ON"
60
            COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
61
            INTERFACE_SDL_VERSION "SDL2"
62
    )
63
endif()
64
set(SDL2_SDL2_FOUND TRUE)
65
 
66
if(NOT TARGET SDL2::SDL2main)
67
    add_library(SDL2::SDL2main INTERFACE IMPORTED)
68
endif()
69
set(SDL2_SDL2main_FOUND TRUE)
70
 
71
check_required_components(SDL2)