-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
161 lines (140 loc) · 4.21 KB
/
CMakeLists.txt
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required (VERSION 3.1.0)
##
# Hunter Cross-platform package manager
##
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/mchiasson/hunter/archive/v0.18.47-mchiasson.tar.gz"
SHA1 "f32df697c8456749551173c56b060c23a70d2183"
LOCAL
)
project (SDL2_image)
set(SDLIMAGE_SUPPORT_BMP ON CACHE BOOL "Support for BMP file format")
set(SDLIMAGE_SUPPORT_GIF ON CACHE BOOL "Support for GIF file format")
set(SDLIMAGE_SUPPORT_LBM ON CACHE BOOL "Support for LBM file format")
set(SDLIMAGE_SUPPORT_PCX ON CACHE BOOL "Support for PCX file format")
set(SDLIMAGE_SUPPORT_PNM ON CACHE BOOL "Support for PNM file format")
set(SDLIMAGE_SUPPORT_TGA ON CACHE BOOL "Support for TGA file format")
set(SDLIMAGE_SUPPORT_XPM ON CACHE BOOL "Support for XPM file format")
set(SDLIMAGE_SUPPORT_XV ON CACHE BOOL "Support for XV file format")
set(SDLIMAGE_SUPPORT_JPEG ON CACHE BOOL "Support for JPEG file format")
set(SDLIMAGE_SUPPORT_PNG ON CACHE BOOL "Support for PNG file format")
set(SDLIMAGE_SUPPORT_WEBP ON CACHE BOOL "Support for WEBP file format")
set(SDLIMAGE_SUPPORT_TIFF ON CACHE BOOL "Support for TIFF file format")
hunter_add_package(SDL2)
find_package(SDL2 CONFIG REQUIRED)
list(APPEND SDL2_IMAGE_DEPS SDL2::SDL2-static)
include_directories(SDL2)
if(SDLIMAGE_SUPPORT_BMP)
add_definitions(-DLOAD_BMP)
endif()
if(SDLIMAGE_SUPPORT_GIF)
add_definitions(-DLOAD_GIF)
endif()
if(SDLIMAGE_SUPPORT_LBM)
add_definitions(-DLOAD_LBM)
endif()
if(SDLIMAGE_SUPPORT_PCX)
add_definitions(-DLOAD_PCX)
endif()
if(SDLIMAGE_SUPPORT_PNM)
add_definitions(-DLOAD_PNM)
endif()
if(SDLIMAGE_SUPPORT_TGA)
add_definitions(-DLOAD_TGA)
endif()
if(SDLIMAGE_SUPPORT_XPM)
add_definitions(-DLOAD_XPM)
endif()
if(SDLIMAGE_SUPPORT_XV)
add_definitions(-DLOAD_XV)
endif()
if(SDLIMAGE_SUPPORT_JPEG)
add_definitions(-DLOAD_JPG)
hunter_add_package(Jpeg)
find_package(JPEG CONFIG REQUIRED)
list(APPEND SDL2_IMAGE_DEPS JPEG::jpeg)
endif()
if(SDLIMAGE_SUPPORT_PNG)
add_definitions(-DLOAD_PNG)
hunter_add_package(PNG)
find_package(PNG CONFIG REQUIRED)
list(APPEND SDL2_IMAGE_DEPS PNG::png)
endif()
if(SDLIMAGE_SUPPORT_TIFF)
add_definitions(-DLOAD_TIF)
hunter_add_package(TIFF)
find_package(TIFF CONFIG REQUIRED)
list(APPEND SDL2_IMAGE_DEPS TIFF::libtiff)
endif()
if(SDLIMAGE_SUPPORT_WEBP)
add_definitions(-DLOAD_WEBP)
hunter_add_package(WebP)
find_package(WebP CONFIG REQUIRED)
list(APPEND SDL2_IMAGE_DEPS WebP::webp)
endif()
set(SDLIMAGE_SOURCES
IMG.c
IMG_bmp.c
IMG_gif.c
IMG_jpg.c
IMG_lbm.c
IMG_pcx.c
IMG_png.c
IMG_pnm.c
IMG_tga.c
IMG_tif.c
IMG_webp.c
IMG_xcf.c
IMG_xpm.c
IMG_xv.c
IMG_xxx.c
showimage.c
)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
add_library(${PROJECT_NAME} STATIC
${SDLIMAGE_SOURCES}
)
target_link_libraries (${PROJECT_NAME}
PUBLIC ${SDL2_IMAGE_DEPS}
)
# Install the heades and libraries.
install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/SDL_image.h
DESTINATION
include/SDL2
COMPONENT
Development
)
# Create the CMake version file.
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/SDL2_imageConfigVersion.cmake"
VERSION 2.0.1
COMPATIBILITY AnyNewerVersion
)
set(targets_export_name "SDL2_imageTargets")
# Create the Config file.
include(CMakePackageConfigHelpers)
set(ConfigPackageLocation lib/cmake/SDL2_image)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/SDL2_imageConfig.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/SDL2_imageConfig.cmake
INSTALL_DESTINATION ${ConfigPackageLocation}
)
install(TARGETS ${PROJECT_NAME}
EXPORT ${targets_export_name}
LIBRARY DESTINATION lib COMPONENT Runtime
ARCHIVE DESTINATION lib COMPONENT Development
RUNTIME DESTINATION bin COMPONENT Runtime
PUBLIC_HEADER DESTINATION include COMPONENT Development
BUNDLE DESTINATION bin COMPONENT Runtime
)
# Install the generated CMake files.
install(EXPORT ${targets_export_name} NAMESPACE "SDL2::" DESTINATION ${ConfigPackageLocation})
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/SDL2_imageConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/SDL2_imageConfig.cmake"
DESTINATION ${ConfigPackageLocation}
)