Allow zlib through find_package

This commit is contained in:
Jeremy 2023-10-04 19:47:14 -04:00
parent cd4fa0dd0c
commit 1ee7f68850
No known key found for this signature in database
GPG Key ID: 19AA8270105E8EB4

View File

@ -217,6 +217,11 @@ check_c_source_compiles([=[
}]=] HAVE_STDAFX_H)
#message(STATUS "Checking have windows stdafx.h... ${HAVE_STDAFX_H}")
option(CMAKE_DWARF_FINDPACKAGE_Z "" OFF)
mark_as_advanced(CMAKE_DWARF_FINDPACKAGE_Z)
if(NOT CMAKE_DWARF_FINDPACKAGE_Z)
set(CMAKE_REQUIRED_LIBRARIES z)
check_c_source_compiles( [=[
#include "zlib.h"
@ -286,6 +291,10 @@ if (HAVE_ZSTD)
# For linking in libzstd
set(DW_FZSTD "zstd")
endif()
else()
find_package(z REQUIRED)
set(DW_FZLIB "z")
endif()
check_c_source_compiles([=[
#include <stdint.h>
@ -434,7 +443,7 @@ target_include_directories(
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)
target_link_libraries(dwarf PUBLIC ${LIBELF_LIBRARIES} ${DW_FZLIB} ${DW_FZSTD})
target_link_libraries(dwarf PUBLIC ${DW_FZLIB} ${DW_FZSTD})
# TODO: Something will have to be figured out for dynamic linking, but for now there's nothing to install
# if(NOT CMAKE_SKIP_INSTALL_RULES)