1
0
mirror of synced 2024-12-01 02:37:18 +01:00
ImHex/plugins/decompress/CMakeLists.txt
reggie 56b2e09b01
build: Fix zstd not being linked in correctly (#1544)
Prior to this, at least on Linux/MacOS/etc, I guess it was not possible
to compile with Zstd included for `hex::dec::zstd_decompress()`:


![image](https://github.com/WerWolv/ImHex/assets/56618074/008dbb3d-eeaf-4f49-a918-4751ec69f00c)

Every other target lib for the decompression plugin would compile,
**except for** Zstd. Additionally, the target name `zstd` caused CMake
to not be able to find `Find(ZSTD).cmake` due to case-sensitivity
differences between Windows and Unix-based file paths, of course.
With that said, I'm not too sure if this will break building w/ Zstd on
Windows... Hopefully not 😄
2024-02-13 20:22:28 +01:00

46 lines
1.0 KiB
CMake

cmake_minimum_required(VERSION 3.16)
include(ImHexPlugin)
macro(addOptionalLibrary package library)
find_package(${package})
if (${package}_FOUND)
string(TOUPPER ${package} PACKAGE)
set(LIBRARIES ${LIBRARIES} ${package}::${library})
message(STATUS "Enabling decompression support using ${package} (${${package}_VERSION})")
enable_plugin_feature(${PACKAGE})
endif()
endmacro()
add_imhex_plugin(
NAME
decompress
SOURCES
source/plugin_decompress.cpp
source/content/pl_functions.cpp
INCLUDES
include
LIBRARIES
ui
fonts
FEATURES
ZLIB
BZIP2
LIBLZMA
ZSTD
)
find_package(ZSTD)
if(ZSTD_FOUND)
set(LIBRARIES ${LIBRARIES} "${ZSTD_LIBRARY}")
message(STATUS "Enabling decompression support using ZSTD (${ZSTD_VERSION})")
enable_plugin_feature(ZSTD)
endif()
addOptionalLibrary(ZLIB ZLIB)
addOptionalLibrary(BZip2 BZip2)
addOptionalLibrary(LibLZMA LibLZMA)
target_link_libraries(decompress PRIVATE ${LIBRARIES})