This repository has been archived by the owner on Aug 31, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47c9c43
commit 68f4351
Showing
48 changed files
with
5,274 additions
and
688 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
if(WIN32) | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
sdl2_bin_win32 | ||
URL "https://www.libsdl.org/release/SDL2-devel-2.0.12-VC.zip") | ||
endif() | ||
|
||
function(requires_sdl2) | ||
find_package(SDL2) | ||
if(NOT SDL_FOUND) | ||
if(WIN32) | ||
# Download SDL2 binaries | ||
include(FetchContent) | ||
FetchContent_Declare( | ||
sdl2_bin_win32 | ||
URL "https://www.libsdl.org/release/SDL2-devel-2.0.12-VC.zip") | ||
FetchContent_GetProperties(sdl2_bin_win32) | ||
if(NOT ${sdl2_bin_win32_POPULATED}) | ||
FetchContent_Populate(sdl2_bin_win32) | ||
endif() | ||
# Manually set paths | ||
message("Using downloaded SDL2 win32 binaries") | ||
set(SDL2_INCLUDE_DIR "${sdl2_bin_win32_SOURCE_DIR}/include") | ||
set(SDL2_LIBRARY_RELEASE "${sdl2_bin_win32_SOURCE_DIR}/lib/x86/SDL2.lib") | ||
set(SDL2main_LIBRARIES "${sdl2_bin_win32_SOURCE_DIR}/lib/x86/SDL2main.lib") | ||
endif() | ||
endif() | ||
find_package(SDL2 REQUIRED) | ||
endfunction() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Licensed under the ISC license. Please see the LICENSE.md file for details. | ||
# Copyright (c) 2019 Sandro Stikić <https://github.com/opeik> | ||
|
||
#[[============================================================================ | ||
FindSDL2 | ||
--------- | ||
Try to find SDL2. | ||
This module defines the following IMPORTED targets: | ||
- SDL2::Core — Libraries should link against this. | ||
- SDL2::SDL2 — Applications should link against this instead of SDL2::Core. | ||
This module defines the following variables: | ||
- SDL2_FOUND | ||
- SDL2main_FOUND | ||
- SDL2_VERSION_STRING | ||
- SDL2_LIBRARIES (deprecated) | ||
- SDL2_INCLUDE_DIRS (deprecated) | ||
#============================================================================]] | ||
|
||
# Look for SDL2. | ||
find_path(SDL2_INCLUDE_DIR SDL.h | ||
PATH_SUFFIXES SDL2 include/SDL2 include | ||
PATHS ${SDL2_PATH} | ||
) | ||
|
||
if (NOT SDL2_LIBRARIES) | ||
# Determine architecture. | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_SDL2_PATH_SUFFIX lib/x64) | ||
else() | ||
set(_SDL2_PATH_SUFFIX lib/x86) | ||
endif() | ||
|
||
# Look for the release version of SDL2. | ||
find_library(SDL2_LIBRARY_RELEASE | ||
NAMES SDL2 SDL-2.0 | ||
PATH_SUFFIXES lib ${_SDL2_PATH_SUFFIX} | ||
PATHS ${SDL2_PATH} | ||
) | ||
|
||
# Look for the debug version of SDL2. | ||
find_library(SDL2_LIBRARY_DEBUG | ||
NAMES SDL2d | ||
PATH_SUFFIXES lib ${_SDL2_PATH_SUFFIX} | ||
PATHS ${SDL2_PATH} | ||
) | ||
|
||
# Look for SDL2main. | ||
find_library(SDL2main_LIBRARIES | ||
NAMES SDL2main | ||
PATH_SUFFIXES lib ${_SDL2_PATH_SUFFIX} | ||
PATHS ${SDL2_PATH} | ||
) | ||
|
||
include(SelectLibraryConfigurations) | ||
select_library_configurations(SDL2) | ||
endif() | ||
|
||
# Find the SDL2 version. | ||
if(SDL2_INCLUDE_DIR AND EXISTS "${SDL2_INCLUDE_DIR}/SDL_version.h") | ||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+[0-9]+$") | ||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL_MINOR_VERSION[ \t]+[0-9]+$") | ||
file(STRINGS "${SDL2_INCLUDE_DIR}/SDL_version.h" SDL2_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL_PATCHLEVEL[ \t]+[0-9]+$") | ||
string(REGEX REPLACE "^#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MAJOR "${SDL2_VERSION_MAJOR_LINE}") | ||
string(REGEX REPLACE "^#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_MINOR "${SDL2_VERSION_MINOR_LINE}") | ||
string(REGEX REPLACE "^#define[ \t]+SDL_PATCHLEVEL[ \t]+([0-9]+)$" "\\1" SDL2_VERSION_PATCH "${SDL2_VERSION_PATCH_LINE}") | ||
set(SDL2_VERSION_STRING ${SDL2_VERSION_MAJOR}.${SDL2_VERSION_MINOR}.${SDL2_VERSION_PATCH}) | ||
unset(SDL2_VERSION_MAJOR_LINE) | ||
unset(SDL2_VERSION_MINOR_LINE) | ||
unset(SDL2_VERSION_PATCH_LINE) | ||
unset(SDL2_VERSION_MAJOR) | ||
unset(SDL2_VERSION_MINOR) | ||
unset(SDL2_VERSION_PATCH) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(SDL2 | ||
REQUIRED_VARS SDL2_LIBRARIES SDL2_INCLUDE_DIR | ||
VERSION_VAR SDL2_VERSION_STRING) | ||
|
||
find_package_handle_standard_args(SDL2main | ||
REQUIRED_VARS SDL2main_LIBRARIES SDL2_INCLUDE_DIR | ||
VERSION_VAR SDL2_VERSION_STRING) | ||
|
||
if(SDL2_FOUND) | ||
set(SDL2_LIBRARIES ${SDL2_LIBRARY}) | ||
set(SDL2_INCLUDE_DIR ${SDL2_INCLUDE_DIR}) | ||
|
||
# Define the core SDL2 target. | ||
if(NOT TARGET SDL2::Core) | ||
add_library(SDL2::Core UNKNOWN IMPORTED) | ||
set_target_properties(SDL2::Core PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${SDL2_INCLUDE_DIR}) | ||
|
||
# Link against Cocoa on macOS. | ||
if(APPLE) | ||
set_property(TARGET SDL2::Core APPEND PROPERTY | ||
INTERFACE_LINK_OPTIONS -framework Cocoa) | ||
endif() | ||
|
||
if(SDL2_LIBRARY_RELEASE) | ||
set_property(TARGET SDL2::Core APPEND PROPERTY | ||
IMPORTED_CONFIGURATIONS RELEASE) | ||
set_target_properties(SDL2::Core PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${SDL2_LIBRARY_RELEASE}) | ||
endif() | ||
|
||
if(SDL2_LIBRARY_DEBUG) | ||
set_property(TARGET SDL2::Core APPEND PROPERTY | ||
IMPORTED_CONFIGURATIONS DEBUG) | ||
set_target_properties(SDL2::Core PROPERTIES | ||
IMPORTED_LOCATION_DEBUG ${SDL2_LIBRARY_DEBUG}) | ||
endif() | ||
|
||
if(NOT SDL2_LIBRARY_RELEASE AND NOT SDL2_LIBRARY_DEBUG) | ||
set_property(TARGET SDL2::Core APPEND PROPERTY | ||
IMPORTED_LOCATION ${SDL2_LIBRARY}) | ||
endif() | ||
endif() | ||
|
||
# Define the SDL2 target. | ||
if(NOT TARGET SDL2::SDL2) | ||
add_library(SDL2::SDL2 UNKNOWN IMPORTED) | ||
set_target_properties(SDL2::SDL2 PROPERTIES | ||
INTERFACE_LINK_LIBRARIES SDL2::Core | ||
IMPORTED_LOCATION ${SDL2main_LIBRARIES}) | ||
endif() | ||
endif() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Copyright © 2019 [Sandro Stikić](mailto:[email protected]) | ||
|
||
Permission to use, copy, modify, and/or distribute this software for | ||
any purpose with or without fee is hereby granted, provided that the | ||
above copyright notice and this permission notice appear in all | ||
copies. | ||
|
||
**The software is provided "as is" and the author disclaims all | ||
warranties with regard to this software including all implied | ||
warranties of merchantability and fitness. In no event shall the | ||
author be liable for any special, direct, indirect, or consequential | ||
damages or any damages whatsoever resulting from loss of use, data or | ||
profits, whether in an action of contract, negligence or other | ||
tortious action, arising out of or in connection with the use or | ||
performance of this software.** |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
# Licensed under the ISC license. Please see the LICENSE.md file for details. | ||
# Copyright (c) 2019 Sandro Stikić <https://github.com/opeik> | ||
|
||
#[[============================================================================ | ||
FindSDL2 | ||
--------- | ||
Try to find SDL2_gfx. | ||
This module defines the following IMPORTED targets: | ||
- SDL2::Gfx — Link against this. | ||
This module defines the following variables: | ||
- SDL2_GFX_FOUND | ||
- SDL2_GFX_VERSION_STRING | ||
- SDL2_GFX_LIBRARIES (deprecated) | ||
- SDL2_GFX_INCLUDE_DIRS (deprecated) | ||
#============================================================================]] | ||
|
||
# Ensure SDL2 is installed. | ||
find_package(SDL2 REQUIRED QUIET) | ||
|
||
if(NOT SDL2_FOUND) | ||
message(FATAL_ERROR "SDL2 not found") | ||
endif() | ||
|
||
# Look for SDL2_gfx. | ||
find_path(SDL2_GFX_INCLUDE_DIR SDL2_gfxPrimitives.h | ||
PATH_SUFFIXES SDL2 include/SDL2 include | ||
PATHS ${SDL2_GFX_PATH} | ||
) | ||
|
||
if (NOT SDL2_GFX_LIBRARIES) | ||
# Determine architecture. | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(_SDL2_GFX_PATH_SUFFIX lib/x64) | ||
else() | ||
set(_SDL2_GFX_PATH_SUFFIX lib/x86) | ||
endif() | ||
|
||
# Look for the release version of SDL2. | ||
find_library(SDL2_GFX_LIBRARY_RELEASE | ||
NAMES SDL2_gfx | ||
PATH_SUFFIXES lib ${_SDL2_GFX_PATH_SUFFIX} | ||
PATHS ${SDL2_PATH} | ||
) | ||
|
||
# Look for the debug version of SDL2. | ||
find_library(SDL2_GFX_LIBRARY_DEBUG | ||
NAMES SDL2_gfxd | ||
PATH_SUFFIXES lib ${_SDL2_GFX_PATH_SUFFIX} | ||
PATHS ${SDL2_PATH} | ||
) | ||
|
||
include(SelectLibraryConfigurations) | ||
select_library_configurations(SDL2_GFX) | ||
endif() | ||
|
||
# Find the SDL2_gfx version. | ||
if(SDL2_GFX_INCLUDE_DIR AND EXISTS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h") | ||
file(STRINGS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h" SDL2_GFX_VERSION_MAJOR_LINE REGEX "^#define[ \t]+SDL2_GFXPRIMITIVES_MAJOR[ \t]+[0-9]+$") | ||
file(STRINGS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h" SDL2_GFX_VERSION_MINOR_LINE REGEX "^#define[ \t]+SDL2_GFXPRIMITIVES_MINOR[ \t]+[0-9]+$") | ||
file(STRINGS "${SDL2_GFX_INCLUDE_DIR}/SDL2_gfxPrimitives.h" SDL2_GFX_VERSION_PATCH_LINE REGEX "^#define[ \t]+SDL2_GFXPRIMITIVES_MICRO[ \t]+[0-9]+$") | ||
string(REGEX REPLACE "^#define[ \t]+SDL2_GFXPRIMITIVES_MAJOR[ \t]+([0-9]+)$" "\\1" SDL2_GFX_VERSION_MAJOR "${SDL2_GFX_VERSION_MAJOR_LINE}") | ||
string(REGEX REPLACE "^#define[ \t]+SDL2_GFXPRIMITIVES_MINOR[ \t]+([0-9]+)$" "\\1" SDL2_GFX_VERSION_MINOR "${SDL2_GFX_VERSION_MINOR_LINE}") | ||
string(REGEX REPLACE "^#define[ \t]+SDL2_GFXPRIMITIVES_MICRO[ \t]+([0-9]+)$" "\\1" SDL2_GFX_VERSION_PATCH "${SDL2_GFX_VERSION_PATCH_LINE}") | ||
set(SDL2_GFX_VERSION_STRING ${SDL2_GFX_VERSION_MAJOR}.${SDL2_GFX_VERSION_MINOR}.${SDL2_GFX_VERSION_PATCH}) | ||
unset(SDL2_GFX_VERSION_MAJOR_LINE) | ||
unset(SDL2_GFX_VERSION_MINOR_LINE) | ||
unset(SDL2_GFX_VERSION_PATCH_LINE) | ||
unset(SDL2_GFX_VERSION_MAJOR) | ||
unset(SDL2_GFX_VERSION_MINOR) | ||
unset(SDL2_GFX_VERSION_PATCH) | ||
endif() | ||
|
||
include(FindPackageHandleStandardArgs) | ||
find_package_handle_standard_args(SDL2_gfx | ||
REQUIRED_VARS SDL2_GFX_LIBRARIES SDL2_GFX_INCLUDE_DIR | ||
VERSION_VAR SDL2_GFX_VERSION_STRING) | ||
|
||
if(SDL2_GFX_FOUND) | ||
set(SDL2_GFX_LIBRARIES ${SDL2_GFX_LIBRARY}) | ||
set(SDL2_GFX_INCLUDE_DIR ${SDL2_GFX_INCLUDE_DIR}) | ||
|
||
# Define the SDL2_gfx target. | ||
if(NOT TARGET SDL2::Gfx) | ||
add_library(SDL2::Gfx UNKNOWN IMPORTED) | ||
set_target_properties(SDL2::Gfx PROPERTIES | ||
INTERFACE_INCLUDE_DIRECTORIES ${SDL2_GFX_INCLUDE_DIR}) | ||
|
||
if(SDL2_GFX_LIBRARY_RELEASE) | ||
set_property(TARGET SDL2::Gfx APPEND PROPERTY | ||
IMPORTED_CONFIGURATIONS RELEASE) | ||
set_target_properties(SDL2::Gfx PROPERTIES | ||
IMPORTED_LOCATION_RELEASE ${SDL2_GFX_LIBRARY_RELEASE}) | ||
endif() | ||
|
||
if(SDL2_GFX_LIBRARY_DEBUG) | ||
set_property(TARGET SDL2::Gfx APPEND PROPERTY | ||
IMPORTED_CONFIGURATIONS DEBUG) | ||
set_target_properties(SDL2::Gfx PROPERTIES | ||
IMPORTED_LOCATION_DEBUG ${SDL2_GFX_LIBRARY_DEBUG}) | ||
endif() | ||
|
||
if(NOT SDL2_GFX_LIBRARY_RELEASE AND NOT SDL2_GFX_LIBRARY_DEBUG) | ||
set_property(TARGET SDL2::Gfx APPEND PROPERTY | ||
IMPORTED_LOCATION ${SDL2_GFX_LIBRARY}) | ||
endif() | ||
endif() | ||
endif() |
Oops, something went wrong.