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