CMake: Properly include lzma include directories

This commit is contained in:
TellowKrinkle 2022-08-01 17:35:34 -05:00
parent 048f6fac52
commit 1bc133f3ae
3 changed files with 15 additions and 8 deletions

View File

@ -8,3 +8,13 @@ function(dolphin_alias_library new old)
endif()
add_library(${new} ALIAS _alias_${library_no_namespace})
endfunction()
# Makes an imported target if it doesn't exist. Useful for when find scripts from older versions of cmake don't make the targets you need
function(dolphin_make_imported_target_if_missing target lib)
if(${lib}_FOUND AND NOT TARGET ${target})
add_library(_${lib} INTERFACE)
target_link_libraries(_${lib} INTERFACE "${${lib}_LIBRARIES}")
target_include_directories(_${lib} INTERFACE "${${lib}_INCLUDE_DIRS}")
add_library(${target} ALIAS _${lib})
endif()
endfunction()

View File

@ -761,16 +761,13 @@ endif()
# macOS ships with liblzma.dylib but no headers, so check for the headers too
find_package(LibLZMA)
check_include_file(lzma.h HAVE_LZMA_H)
if(LIBLZMA_FOUND AND HAVE_LZMA_H)
if(LIBLZMA_FOUND)
# Imported target added in CMake 3.14
dolphin_make_imported_target_if_missing(LibLZMA::LibLZMA LIBLZMA)
message(STATUS "Using shared lzma")
else()
check_vendoring_approved(lzma)
if(LIBLZMA_FOUND AND NOT HAVE_LZMA_H)
message(STATUS "Shared lzma found but lacks headers, falling back to the static library")
else()
message(STATUS "Shared lzma not found, falling back to the static library")
endif()
message(STATUS "Shared lzma not found, falling back to the static library")
add_subdirectory(Externals/liblzma)
endif()

View File

@ -70,7 +70,7 @@ target_link_libraries(discio
PUBLIC
core
BZip2::BZip2
lzma
LibLZMA::LibLZMA
zstd::zstd
PRIVATE