mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-07-06 06:51:18 +12:00
This is a big rework of how dependencies are handled internally. All the calls to CMake functions changing directory-wide properties that were previously used to link to external and internal dependencies have been replaced with their "target_" counterparts. This makes it possible to express more clearly the relationships between different targets and should also make the build script more robust in general. In doing this, I've also made it possible to link to system libraries if so desired; the versioned calls to find_package() will make sure that the found dependencies are compatible with the ones required by Cemu, and will abort the build otherwise. Cemu's internal targets are deeply interconnected, making it hard to fully benefit from a target-based approach. Nonetheless, I did my best to mark PUBLIC dependencies as such, for example when an internal target like CemuGui exposes a dependency as part of its API, i.e. it includes a third party header in one of its public headers. This will significantly help with improving the build experience on Linux, thus helping a bit with the resolution of #1.
33 lines
895 B
CMake
33 lines
895 B
CMake
# SPDX-FileCopyrightText: 2022 Andrea Pappacoda <andrea@pappacoda.it>
|
|
# SPDX-License-Identifier: ISC
|
|
|
|
include(FindPackageHandleStandardArgs)
|
|
|
|
find_package(zstd CONFIG)
|
|
if (zstd_FOUND)
|
|
# Use upstream zstdConfig.cmake if possible
|
|
if (NOT TARGET zstd::zstd)
|
|
if (TARGET zstd::libzstd_static)
|
|
add_library(zstd::zstd ALIAS zstd::libzstd_static)
|
|
elseif (TARGET zstd::libzstd_shared)
|
|
add_library(zstd::zstd ALIAS zstd::libzstd_shared)
|
|
endif()
|
|
endif()
|
|
find_package_handle_standard_args(zstd CONFIG_MODE)
|
|
else()
|
|
# Fallback to pkg-config otherwise
|
|
find_package(PkgConfig)
|
|
if (PKG_CONFIG_FOUND)
|
|
pkg_search_module(libzstd IMPORTED_TARGET GLOBAL libzstd)
|
|
if (libzstd_FOUND)
|
|
add_library(zstd::zstd ALIAS PkgConfig::libzstd)
|
|
endif()
|
|
endif()
|
|
|
|
find_package_handle_standard_args(zstd
|
|
REQUIRED_VARS
|
|
libzstd_LINK_LIBRARIES
|
|
libzstd_FOUND
|
|
VERSION_VAR libzstd_VERSION
|
|
)
|
|
endif()
|