Skip to content

Commit

Permalink
libchdr: add build option for using system library
Browse files Browse the repository at this point in the history
The added build option USE_HOST_LIBCHDR allows to build with libchdr provided by
the system. The option is disabled by default.
  • Loading branch information
bsdcode authored and flyinghead committed Nov 14, 2024
1 parent e2f8de3 commit d259a2e
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ option(USE_GLES2 "Use GLES2 API" OFF)
option(USE_HOST_GLSLANG "Use host glslang" OFF)
option(USE_HOST_LIBZIP "Use host libzip" ON)
option(USE_HOST_SDL "Use host SDL library" ${USE_HOST_SDL_DEFAULT})
option(USE_HOST_LIBCHDR "Use host libchdr" OFF)
option(USE_OPENMP "Use OpenMP if available" ON)
option(USE_VULKAN "Build with Vulkan support" ON)
option(USE_DX9 "Build with Direct3D 9 support" ON)
Expand Down Expand Up @@ -481,9 +482,15 @@ if(NOT LIBRETRO)
endif()
endif()

add_subdirectory(core/deps/libchdr EXCLUDE_FROM_ALL)
target_link_libraries(${PROJECT_NAME} PRIVATE chdr-static)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/libchdr/include)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND AND USE_HOST_LIBCHDR AND NOT LIBRETRO)
pkg_check_modules(LIBCHDR IMPORTED_TARGET libchdr)
target_link_libraries(${PROJECT_NAME} PRIVATE PkgConfig::LIBCHDR)
else()
add_subdirectory(core/deps/libchdr EXCLUDE_FROM_ALL)
target_link_libraries(${PROJECT_NAME} PRIVATE chdr-static)
target_include_directories(${PROJECT_NAME} PRIVATE core/deps/libchdr/include)
endif()

if(NOT WITH_SYSTEM_ZLIB)
set(ZLIB_RELATIVE_PATH "core/deps/libchdr/deps/zlib-1.3.1")
Expand All @@ -497,7 +504,6 @@ if(NOT WITH_SYSTEM_ZLIB)
get_target_property(ZLIB_LIBRARY_DEBUG zlibstatic LOCATION_Debug)
endif()

find_package(PkgConfig)
if(PKG_CONFIG_FOUND AND NOT ANDROID AND NOT APPLE AND NOT LIBRETRO)
if(USE_LIBAO)
pkg_check_modules(AO IMPORTED_TARGET ao)
Expand Down

0 comments on commit d259a2e

Please sign in to comment.