blob: 689f0fcd74503a62be910a03c9f69473e23dd399 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
cmake_minimum_required(VERSION 2.6)
project(SDL2_image C)
### configuration ###
list(APPEND CMAKE_MODULE_PATH "${CURRENT_INSTALLED_DIR}/share/libwebp")
# enable all file formats which are supported natively
set(SUPPORTED_FORMATS BMP GIF LBM PCX PNM TGA XPM XCF XV SVG)
# enable all file formats which are supported through external dependencies
# first try to load them statically (lib file in vcpkg installation)
# if this fails try to make them a dynamic dependency (dll will be loaded at runtime) if possible. vcpkg cannot resolve these dependencies!
# else do not support this file format at all
# Can be explicitly enabled or disabled via USE_XYZ
set(DEPENDENCIES PNG JPEG TIFF WEBP)
# patch library names for preprocessor flags
set(JPEG_FLAG JPG)
set(TIFF_FLAG TIF)
# names of potentially dynamically loaded libraries
set(JPEG_DYNAMIC \"libjpeg-9.dll\")
set(PNG_DYNAMIC \"libpng16-16.dll\")
set(TIFF_DYNAMIC \"libtiff-5.dll\")
set(WEBP_DYNAMIC \"libwebp-4.dll\")
### implementation ###
add_library(SDL2_image
IMG.c
IMG_bmp.c
IMG_gif.c
IMG_jpg.c
IMG_lbm.c
IMG_pcx.c
IMG_png.c
IMG_pnm.c
IMG_svg.c
IMG_tga.c
IMG_tif.c
IMG_webp.c
IMG_xcf.c
IMG_xpm.c
IMG_xv.c
IMG_xxx.c
IMG_WIC.c
version.rc
)
if (APPLE)
target_sources(SDL2_image PRIVATE
IMG_ImageIO.m
)
target_compile_options(SDL2_image BEFORE PRIVATE
"-x" "objective-c"
)
endif()
set_target_properties(SDL2_image PROPERTIES DEFINE_SYMBOL DLL_EXPORT)
foreach(FORMAT ${SUPPORTED_FORMATS})
add_definitions(-DLOAD_${FORMAT})
endforeach(FORMAT)
# SDL
find_path(SDL_INCLUDE_DIR SDL2/SDL.h)
find_package(SDL2 CONFIG REQUIRED)
include_directories(${SDL_INCLUDE_DIR})
include_directories(${SDL_INCLUDE_DIR}/SDL2)
include_directories(${CMAKE_SOURCE_DIR})
target_link_libraries(SDL2_image SDL2::SDL2)
# external dependencies
foreach(DEPENDENCY IN LISTS DEPENDENCIES)
if(NOT USE_${DEPENDENCY})
continue()
endif()
find_package(${DEPENDENCY})
if(NOT DEFINED ${DEPENDENCY}_FLAG)
set(${DEPENDENCY}_FLAG ${DEPENDENCY})
endif()
add_definitions(-DLOAD_${${DEPENDENCY}_FLAG})
if(${DEPENDENCY}_FOUND)
message(STATUS " --> linking statically.")
target_link_libraries(SDL2_image ${${DEPENDENCY}_LIBRARIES})
elseif(DEFINED ${DEPENDENCY}_DYNAMIC)
message(STATUS " --> linking dynamically.")
add_definitions(-DLOAD_${${DEPENDENCY}_FLAG}_DYNAMIC=${${DEPENDENCY}_DYNAMIC})
set(RUNTIME_DEPENDENCIES ON)
else()
message(STATUS " --> skipping.")
endif()
endforeach(DEPENDENCY)
if(DEFINED RUNTIME_DEPENDENCIES)
include_directories(VisualC/external/include)
endif()
install(TARGETS SDL2_image
EXPORT SDL2_image
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib)
install(FILES SDL_image.h DESTINATION include/SDL2 CONFIGURATIONS Release)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/sdl2-image-config.cmake"
[[include(CMakeFindDependencyMacro)
find_dependency(SDL2 CONFIG)
include("${CMAKE_CURRENT_LIST_DIR}/sdl2-image-targets.cmake")
]])
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/sdl2-image-config.cmake DESTINATION share/sdl2-image)
install(EXPORT SDL2_image
DESTINATION share/sdl2-image/
FILE sdl2-image-targets.cmake
NAMESPACE SDL2::
)
message(STATUS "Link-time dependencies:")
message(STATUS " " SDL2::SDL2)
foreach(DEPENDENCY ${DEPENDENCIES})
if(${DEPENDENCY}_FOUND)
message(STATUS " " ${DEPENDENCY})
endif()
endforeach(DEPENDENCY)
if(DEFINED RUNTIME_DEPENDENCIES)
message(STATUS "Run-time dependencies:")
foreach(DEPENDENCY ${DEPENDENCIES})
if(NOT ${DEPENDENCY}_FOUND AND DEFINED ${DEPENDENCY}_DYNAMIC)
message(STATUS " " ${${DEPENDENCY}_DYNAMIC})
endif()
endforeach(DEPENDENCY)
endif()
|