CMakeLists.txt (9074B)
1 add_library(util 2 audio_stream.cpp 3 audio_stream.h 4 cd_image.cpp 5 cd_image.h 6 cd_image_bin.cpp 7 cd_image_cue.cpp 8 cd_image_chd.cpp 9 cd_image_device.cpp 10 cd_image_ecm.cpp 11 cd_image_hasher.cpp 12 cd_image_hasher.h 13 cd_image_m3u.cpp 14 cd_image_memory.cpp 15 cd_image_mds.cpp 16 cd_image_pbp.cpp 17 cd_image_ppf.cpp 18 cd_subchannel_replacement.cpp 19 cd_subchannel_replacement.h 20 compress_helpers.cpp 21 compress_helpers.h 22 cue_parser.cpp 23 cue_parser.h 24 gpu_device.cpp 25 gpu_device.h 26 gpu_framebuffer_manager.h 27 gpu_shader_cache.cpp 28 gpu_shader_cache.h 29 gpu_texture.cpp 30 gpu_texture.h 31 host.cpp 32 host.h 33 http_downloader.cpp 34 http_downloader.h 35 image.cpp 36 image.h 37 imgui_fullscreen.cpp 38 imgui_fullscreen.h 39 imgui_manager.cpp 40 imgui_manager.h 41 ini_settings_interface.cpp 42 ini_settings_interface.h 43 input_manager.cpp 44 input_manager.h 45 input_source.cpp 46 input_source.h 47 iso_reader.cpp 48 iso_reader.h 49 media_capture.cpp 50 media_capture.h 51 page_fault_handler.cpp 52 page_fault_handler.h 53 platform_misc.h 54 postprocessing.cpp 55 postprocessing.h 56 postprocessing_shader.cpp 57 postprocessing_shader.h 58 postprocessing_shader_fx.cpp 59 postprocessing_shader_fx.h 60 postprocessing_shader_glsl.cpp 61 postprocessing_shader_glsl.h 62 shadergen.cpp 63 shadergen.h 64 shiftjis.cpp 65 shiftjis.h 66 sockets.cpp 67 sockets.h 68 state_wrapper.cpp 69 state_wrapper.h 70 wav_writer.cpp 71 wav_writer.h 72 window_info.cpp 73 window_info.h 74 ) 75 76 target_precompile_headers(util PRIVATE "pch.h") 77 target_include_directories(util PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..") 78 target_include_directories(util PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/..") 79 target_link_libraries(util PUBLIC common simpleini imgui) 80 target_link_libraries(util PRIVATE libchdr JPEG::JPEG PNG::PNG WebP::libwebp ZLIB::ZLIB SoundTouch::SoundTouchDLL xxhash Zstd::Zstd reshadefx) 81 82 if(ENABLE_X11) 83 target_compile_definitions(util PRIVATE "-DENABLE_X11=1") 84 target_link_libraries(util PRIVATE X11::X11 X11::Xrandr) 85 endif() 86 87 if(ENABLE_WAYLAND) 88 target_compile_definitions(util PRIVATE "-DENABLE_WAYLAND=1") 89 endif() 90 91 if(ENABLE_OPENGL) 92 target_sources(util PRIVATE 93 opengl_context.cpp 94 opengl_context.h 95 opengl_device.cpp 96 opengl_device.h 97 opengl_loader.h 98 opengl_pipeline.cpp 99 opengl_pipeline.h 100 opengl_stream_buffer.cpp 101 opengl_stream_buffer.h 102 opengl_texture.cpp 103 opengl_texture.h 104 ) 105 target_compile_definitions(util PUBLIC "ENABLE_OPENGL=1") 106 target_link_libraries(util PRIVATE glad) 107 108 if(WIN32) 109 target_sources(util PRIVATE 110 opengl_context_wgl.cpp 111 opengl_context_wgl.h 112 ) 113 target_link_libraries(util PRIVATE "opengl32.lib") 114 endif() 115 116 if(LINUX OR BSD OR ANDROID) 117 target_sources(util PRIVATE 118 opengl_context_egl.cpp 119 opengl_context_egl.h 120 ) 121 target_compile_definitions(util PRIVATE "-DENABLE_EGL=1") 122 123 if(ENABLE_X11) 124 target_sources(util PRIVATE 125 opengl_context_egl_x11.cpp 126 opengl_context_egl_x11.h 127 ) 128 endif() 129 if(ENABLE_WAYLAND) 130 target_sources(util PRIVATE 131 opengl_context_egl_wayland.cpp 132 opengl_context_egl_wayland.h 133 ) 134 endif() 135 if(ANDROID) 136 target_include_directories(util PRIVATE "${CMAKE_SOURCE_DIR}/android/app/src/cpp") 137 endif() 138 endif() 139 140 if(APPLE) 141 target_sources(util PRIVATE 142 opengl_context_agl.mm 143 opengl_context_agl.h 144 ) 145 set_source_files_properties(opengl_context_agl.mm PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) 146 endif() 147 endif() 148 149 if(ENABLE_VULKAN) 150 target_sources(util PRIVATE 151 vulkan_builders.cpp 152 vulkan_builders.h 153 vulkan_device.cpp 154 vulkan_device.h 155 vulkan_entry_points.h 156 vulkan_entry_points.inl 157 vulkan_loader.cpp 158 vulkan_loader.h 159 vulkan_pipeline.cpp 160 vulkan_pipeline.h 161 vulkan_stream_buffer.cpp 162 vulkan_stream_buffer.h 163 vulkan_swap_chain.cpp 164 vulkan_swap_chain.h 165 vulkan_texture.cpp 166 vulkan_texture.h 167 ) 168 target_compile_definitions(util PUBLIC "ENABLE_VULKAN=1") 169 target_link_libraries(util PUBLIC vulkan-headers) 170 endif() 171 172 if(ENABLE_VULKAN OR APPLE) 173 # shaderc is loaded dynamically to reduce module loads on startup. 174 get_target_property(SHADERC_INCLUDE_DIR Shaderc::shaderc_shared INTERFACE_INCLUDE_DIRECTORIES) 175 target_include_directories(util PUBLIC ${SHADERC_INCLUDE_DIR}) 176 endif() 177 178 if(NOT ANDROID) 179 target_sources(util PRIVATE 180 cubeb_audio_stream.cpp 181 sdl_audio_stream.cpp 182 sdl_input_source.cpp 183 sdl_input_source.h 184 ) 185 target_link_libraries(util PUBLIC 186 cubeb 187 freesurround 188 SDL2::SDL2 189 ) 190 # FFmpeg loaded dynamically on demand. 191 target_include_directories(util PUBLIC ${FFMPEG_INCLUDE_DIRS}) 192 endif() 193 194 if(WIN32) 195 target_sources(util PRIVATE 196 d3d_common.cpp 197 d3d_common.h 198 d3d11_device.cpp 199 d3d11_device.h 200 d3d11_pipeline.cpp 201 d3d11_pipeline.h 202 d3d11_stream_buffer.cpp 203 d3d11_stream_buffer.h 204 d3d11_texture.cpp 205 d3d11_texture.h 206 d3d12_builders.cpp 207 d3d12_builders.h 208 d3d12_descriptor_heap_manager.cpp 209 d3d12_descriptor_heap_manager.h 210 d3d12_device.cpp 211 d3d12_device.h 212 d3d12_pipeline.cpp 213 d3d12_pipeline.h 214 d3d12_stream_buffer.cpp 215 d3d12_stream_buffer.h 216 d3d12_texture.cpp 217 d3d12_texture.h 218 dinput_source.cpp 219 dinput_source.h 220 http_downloader_winhttp.cpp 221 http_downloader_winhttp.h 222 platform_misc_win32.cpp 223 win32_raw_input_source.cpp 224 win32_raw_input_source.h 225 xinput_source.cpp 226 xinput_source.h 227 ) 228 target_link_libraries(util PRIVATE d3d12ma) 229 target_link_libraries(util PRIVATE d3d11.lib d3d12.lib d3dcompiler.lib dxgi.lib winmm.lib Dwmapi.lib winhttp.lib) 230 231 if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug") 232 target_link_libraries(util PRIVATE WinPixEventRuntime::WinPixEventRuntime) 233 endif() 234 elseif(APPLE) 235 include(AddMetalSources) 236 237 set(MAC_SOURCES 238 metal_device.h 239 metal_device.mm 240 metal_layer.h 241 metal_stream_buffer.h 242 metal_stream_buffer.mm 243 platform_misc_mac.mm 244 ) 245 set(METAL_SOURCES 246 "${CMAKE_CURRENT_SOURCE_DIR}/metal_shaders.metal" 247 ) 248 set_property(GLOBAL PROPERTY UTIL_METAL_SOURCES ${METAL_SOURCES}) 249 target_sources(util PRIVATE ${MAC_SOURCES}) 250 find_library(IOK_LIBRARY IOKit REQUIRED) 251 find_library(METAL_LIBRARY Metal) 252 find_library(QUARTZCORE_LIBRARY QuartzCore) 253 target_link_libraries(util PRIVATE ${METAL_LIBRARY} ${QUARTZCORE_LIBRARY} ${IOK_LIBRARY}) 254 set_source_files_properties(${MAC_SOURCES} PROPERTIES SKIP_PRECOMPILE_HEADERS TRUE) 255 elseif(NOT ANDROID) 256 target_sources(util PRIVATE 257 platform_misc_unix.cpp 258 ) 259 find_package(PkgConfig REQUIRED) 260 pkg_check_modules(DBUS REQUIRED dbus-1) 261 target_include_directories(util PRIVATE ${DBUS_INCLUDE_DIRS}) 262 target_link_libraries(util PRIVATE ${DBUS_LINK_LIBRARIES}) 263 264 if(LINUX) 265 target_link_libraries(util PRIVATE UDEV::UDEV) 266 endif() 267 endif() 268 269 if(NOT WIN32 AND NOT ANDROID) 270 target_sources(util PRIVATE 271 http_downloader_curl.cpp 272 http_downloader_curl.h 273 ) 274 target_link_libraries(util PRIVATE 275 CURL::libcurl 276 ) 277 endif() 278 279 function(add_util_resources target) 280 if(APPLE) 281 get_property(UTIL_METAL_SOURCES GLOBAL PROPERTY UTIL_METAL_SOURCES) 282 add_metal_sources(${target} ${UTIL_METAL_SOURCES}) 283 284 # Copy MoltenVK into the bundle 285 unset(MOLTENVK_PATH CACHE) 286 find_file(MOLTENVK_PATH NAMES 287 libMoltenVK.dylib 288 lib/libMoltenVK.dylib 289 ) 290 if (MOLTENVK_PATH) 291 target_sources(${target} PRIVATE "${MOLTENVK_PATH}") 292 set_source_files_properties("${MOLTENVK_PATH}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) 293 message(STATUS "Using MoltenVK from ${MOLTENVK_PATH}") 294 else() 295 message(WARNING "MoltenVK not found in path, it will depend on the target system having it.") 296 endif() 297 298 # Copy shaderc/spirv-cross into the bundle 299 get_target_property(SPIRV_CROSS_LIBRARY spirv-cross-c-shared IMPORTED_SONAME_RELEASE) 300 get_target_property(SHADERC_LIBRARY Shaderc::shaderc_shared IMPORTED_LOCATION_RELEASE) 301 target_sources(${target} PRIVATE "${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}") 302 set_source_files_properties("${SHADERC_LIBRARY}" "${SPIRV_CROSS_LIBRARY}" PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) 303 304 # Copy FFmpeg libraries into the bundle 305 foreach(component avcodec avformat avutil swresample swscale) 306 string(REGEX REPLACE "\([0-9]+\)\.[0-9]+\.[0-9]+" "\\1" major "${FFMPEG_${component}_VERSION}") 307 string(REPLACE "lib${component}.dylib" "lib${component}.${major}.dylib" version_lib "${FFMPEG_${component}_LIBRARIES}") 308 target_sources(${target} PRIVATE ${version_lib}) 309 set_source_files_properties(${target} PRIVATE ${version_lib} PROPERTIES MACOSX_PACKAGE_LOCATION Frameworks) 310 endforeach() 311 elseif(ALLOW_INSTALL) 312 # Ensure we look for dependency libraries in the installation directory. 313 set_target_properties(${target} PROPERTIES INSTALL_RPATH "$ORIGIN") 314 315 # Copy dependency libraries to installation directory. 316 install_imported_dep_library(Shaderc::shaderc_shared) 317 install_imported_dep_library(spirv-cross-c-shared) 318 install_imported_dep_library(SoundTouch::SoundTouchDLL) 319 endif() 320 endfunction()