yuzu/externals/find-modules/FindCatch2.cmake
Andrea Pappacoda cdb240f3d4
chore: make yuzu REUSE compliant
[REUSE] is a specification that aims at making file copyright
information consistent, so that it can be both human and machine
readable. It basically requires that all files have a header containing
copyright and licensing information. When this isn't possible, like
when dealing with binary assets, generated files or embedded third-party
dependencies, it is permitted to insert copyright information in the
`.reuse/dep5` file.

Oh, and it also requires that all the licenses used in the project are
present in the `LICENSES` folder, that's why the diff is so huge.
This can be done automatically with `reuse download --all`.

The `reuse` tool also contains a handy subcommand that analyzes the
project and tells whether or not the project is (still) compliant,
`reuse lint`.

Following REUSE has a few advantages over the current approach:

- Copyright information is easy to access for users / downstream
- Files like `dist/license.md` do not need to exist anymore, as
  `.reuse/dep5` is used instead
- `reuse lint` makes it easy to ensure that copyright information of
  files like binary assets / images is always accurate and up to date

To add copyright information of files that didn't have it I looked up
who committed what and when, for each file. As yuzu contributors do not
have to sign a CLA or similar I couldn't assume that copyright ownership
was of the "yuzu Emulator Project", so I used the name and/or email of
the commit author instead.

[REUSE]: https://reuse.software

Follow-up to 01cf05bc75
2022-07-27 12:53:49 +02:00

52 lines
1.7 KiB
CMake

# SPDX-FileCopyrightText: 2020 yuzu Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later
find_package(PkgConfig QUIET)
pkg_check_modules(PC_Catch2 QUIET Catch2)
find_path(Catch2_INCLUDE_DIR
NAMES catch.hpp
PATHS ${PC_Catch2_INCLUDE_DIRS} ${CONAN_CATCH2_ROOT}
PATH_SUFFIXES catch2
)
if(Catch2_INCLUDE_DIR)
file(STRINGS "${Catch2_INCLUDE_DIR}/catch.hpp" _Catch2_version_lines
REGEX "#define[ \t]+CATCH_VERSION_(MAJOR|MINOR|PATCH)")
string(REGEX REPLACE ".*CATCH_VERSION_MAJOR +\([0-9]+\).*" "\\1" _Catch2_version_major "${_Catch2_version_lines}")
string(REGEX REPLACE ".*CATCH_VERSION_MINOR +\([0-9]+\).*" "\\1" _Catch2_version_minor "${_Catch2_version_lines}")
string(REGEX REPLACE ".*CATCH_VERSION_PATCH +\([0-9]+\).*" "\\1" _Catch2_version_patch "${_Catch2_version_lines}")
set(Catch2_VERSION "${_Catch2_version_major}.${_Catch2_version_minor}.${_Catch2_version_patch}")
unset(_Catch2_version_major)
unset(_Catch2_version_minor)
unset(_Catch2_version_patch)
unset(_Catch2_version_lines)
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Catch2
FOUND_VAR Catch2_FOUND
REQUIRED_VARS
Catch2_INCLUDE_DIR
Catch2_VERSION
VERSION_VAR Catch2_VERSION
)
if(Catch2_FOUND)
set(Catch2_INCLUDE_DIRS ${Catch2_INCLUDE_DIR})
set(Catch2_DEFINITIONS ${PC_Catch2_CFLAGS_OTHER})
endif()
if(Catch2_FOUND AND NOT TARGET Catch2::Catch2)
add_library(Catch2::Catch2 UNKNOWN IMPORTED)
set_target_properties(Catch2::Catch2 PROPERTIES
IMPORTED_LOCATION "${Catch2_LIBRARY}"
INTERFACE_COMPILE_OPTIONS "${PC_Catch2_CFLAGS_OTHER}"
INTERFACE_INCLUDE_DIRECTORIES "${Catch2_INCLUDE_DIR}"
)
endif()
mark_as_advanced(
Catch2_INCLUDE_DIR
)