externals: allow user to use system lodepng (#7138)
This commit is contained in:
parent
ee372572a6
commit
fcc0fd671a
|
@ -327,7 +327,13 @@ if (ENABLE_WEB_SERVICE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# lodepng
|
# lodepng
|
||||||
|
if(USE_SYSTEM_LODEPNG)
|
||||||
|
add_library(lodepng INTERFACE)
|
||||||
|
find_package(lodepng REQUIRED)
|
||||||
|
target_link_libraries(lodepng INTERFACE lodepng::lodepng)
|
||||||
|
else()
|
||||||
add_subdirectory(lodepng)
|
add_subdirectory(lodepng)
|
||||||
|
endif()
|
||||||
|
|
||||||
# (xperia64): Only use libyuv on Android b/c of build issues on Windows and mandatory JPEG
|
# (xperia64): Only use libyuv on Android b/c of build issues on Windows and mandatory JPEG
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
|
|
|
@ -21,6 +21,7 @@ option(USE_SYSTEM_ZSTD "Use the system Zstandard library (instead of the bundled
|
||||||
option(USE_SYSTEM_ENET "Use the system libenet (instead of the bundled one)" OFF)
|
option(USE_SYSTEM_ENET "Use the system libenet (instead of the bundled one)" OFF)
|
||||||
option(USE_SYSTEM_CRYPTOPP "Use the system cryptopp (instead of the bundled one)" OFF)
|
option(USE_SYSTEM_CRYPTOPP "Use the system cryptopp (instead of the bundled one)" OFF)
|
||||||
option(USE_SYSTEM_CUBEB "Use the system cubeb (instead of the bundled one)" OFF)
|
option(USE_SYSTEM_CUBEB "Use the system cubeb (instead of the bundled one)" OFF)
|
||||||
|
option(USE_SYSTEM_LODEPNG "Use the system lodepng (instead of the bundled one)" OFF)
|
||||||
|
|
||||||
# Qt and MoltenVK are handled separately
|
# Qt and MoltenVK are handled separately
|
||||||
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_SDL2 "Disable system SDL2" OFF "USE_SYSTEM_LIBS" OFF)
|
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_SDL2 "Disable system SDL2" OFF "USE_SYSTEM_LIBS" OFF)
|
||||||
|
@ -41,6 +42,7 @@ CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ZSTD "Disable system Zstandard" OFF "USE_S
|
||||||
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ENET "Disable system libenet" OFF "USE_SYSTEM_LIBS" OFF)
|
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_ENET "Disable system libenet" OFF "USE_SYSTEM_LIBS" OFF)
|
||||||
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_CRYPTOPP "Disable system cryptopp" OFF "USE_SYSTEM_LIBS" OFF)
|
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_CRYPTOPP "Disable system cryptopp" OFF "USE_SYSTEM_LIBS" OFF)
|
||||||
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_CUBEB "Disable system cubeb" OFF "USE_SYSTEM_LIBS" OFF)
|
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_CUBEB "Disable system cubeb" OFF "USE_SYSTEM_LIBS" OFF)
|
||||||
|
CMAKE_DEPENDENT_OPTION(DISABLE_SYSTEM_LODEPNG "Disable system lodepng" OFF "USE_SYSTEM_LIBS" OFF)
|
||||||
|
|
||||||
set(LIB_VAR_LIST
|
set(LIB_VAR_LIST
|
||||||
SDL2
|
SDL2
|
||||||
|
@ -61,6 +63,7 @@ set(LIB_VAR_LIST
|
||||||
ENET
|
ENET
|
||||||
CRYPTOPP
|
CRYPTOPP
|
||||||
CUBEB
|
CUBEB
|
||||||
|
LODEPNG
|
||||||
)
|
)
|
||||||
|
|
||||||
# First, check that USE_SYSTEM_XXX is not used with USE_SYSTEM_LIBS
|
# First, check that USE_SYSTEM_XXX is not used with USE_SYSTEM_LIBS
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
if(NOT LODEPNG_FOUND)
|
||||||
|
find_path(LODEPNG_INCLUDE_DIRS NAMES lodepng.h
|
||||||
|
PATHS
|
||||||
|
/usr/include
|
||||||
|
/usr/local/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(LODEPNG_LIBRARY_DIRS NAMES lodepng
|
||||||
|
PATHS
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(LODEPNG_INCLUDE_DIRS AND LODEPNG_LIBRARY_DIRS)
|
||||||
|
set(LODEPNG_FOUND TRUE CACHE INTERNAL "Found lodepng")
|
||||||
|
message(STATUS "Found lodepng: ${LODEPNG_LIBRARY_DIRS}, ${LODEPNG_INCLUDE_DIRS}")
|
||||||
|
else()
|
||||||
|
set(LODEPNG_FOUND FALSE CACHE INTERNAL "Found lodepng")
|
||||||
|
message(STATUS "Lodepng not found.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(LODEPNG_FOUND AND NOT TARGET lodepng::lodepng)
|
||||||
|
add_library(lodepng::lodepng UNKNOWN IMPORTED)
|
||||||
|
set_target_properties(lodepng::lodepng PROPERTIES
|
||||||
|
INCLUDE_DIRECTORIES ${LODEPNG_INCLUDE_DIRS}
|
||||||
|
INTERFACE_LINK_LIBRARIES ${LODEPNG_LIBRARY_DIRS}
|
||||||
|
IMPORTED_LOCATION ${LODEPNG_LIBRARY_DIRS}
|
||||||
|
)
|
||||||
|
|
||||||
|
endif()
|
Loading…
Reference in New Issue