diff options
Diffstat (limited to 'CMakeModules')
| -rw-r--r-- | CMakeModules/FindDiscordRPC.cmake | 27 | ||||
| -rw-r--r-- | CMakeModules/FindFFmpeg.cmake | 195 | ||||
| -rw-r--r-- | CMakeModules/FindOpus.cmake | 15 | ||||
| -rw-r--r-- | CMakeModules/Findenet.cmake | 16 | ||||
| -rw-r--r-- | CMakeModules/Findhttplib.cmake | 21 | ||||
| -rw-r--r-- | CMakeModules/Findinih.cmake | 16 | ||||
| -rw-r--r-- | CMakeModules/Findlibusb.cmake | 16 | ||||
| -rw-r--r-- | CMakeModules/Findlz4.cmake | 26 | ||||
| -rw-r--r-- | CMakeModules/Findzstd.cmake | 26 | ||||
| -rw-r--r-- | CMakeModules/WindowsCopyFiles.cmake | 27 | 
10 files changed, 385 insertions, 0 deletions
| diff --git a/CMakeModules/FindDiscordRPC.cmake b/CMakeModules/FindDiscordRPC.cmake new file mode 100644 index 000000000..44ca9904f --- /dev/null +++ b/CMakeModules/FindDiscordRPC.cmake @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf> +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_path(DiscordRPC_INCLUDE_DIR discord_rpc.h) + +find_library(DiscordRPC_LIBRARY discord-rpc) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(DiscordRPC +    REQUIRED_VARS +        DiscordRPC_LIBRARY +        DiscordRPC_INCLUDE_DIR +) + +if (DiscordRPC_FOUND AND NOT TARGET DiscordRPC::discord-rpc) +    add_library(DiscordRPC::discord-rpc UNKNOWN IMPORTED) +    set_target_properties(DiscordRPC::discord-rpc PROPERTIES +        IMPORTED_LOCATION "${DiscordRPC_LIBRARY}" +        INTERFACE_INCLUDE_DIRECTORIES "${DiscordRPC_INCLUDE_DIR}" +    ) +endif() + +mark_as_advanced( +    DiscordRPC_INCLUDE_DIR +    DiscordRPC_LIBRARY +) diff --git a/CMakeModules/FindFFmpeg.cmake b/CMakeModules/FindFFmpeg.cmake new file mode 100644 index 000000000..eedf28aea --- /dev/null +++ b/CMakeModules/FindFFmpeg.cmake @@ -0,0 +1,195 @@ +# SPDX-FileCopyrightText: 2019 Citra Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +# FindFFmpeg +# ---------- +# +# Find the native FFmpeg includes and libraries +# +# This module defines the following variables: +# +#  FFmpeg_INCLUDE_<component>: where to find <component>.h +#  FFmpeg_LIBRARY_<component>: where to find the <component> library +#  FFmpeg_INCLUDE_DIR: aggregate all the include paths +#  FFmpeg_LIBRARIES: aggregate all the paths to the libraries +#  FFmpeg_FOUND: True if all components have been found +# +# This module defines the following targets, which are prefered over variables: +# +#  FFmpeg::<component>: Target to use <component> directly, with include path, +#    library and dependencies set up. If you are using a static build, you are +#    responsible for adding any external dependencies (such as zlib, bzlib...). +# +# <component> can be one of: +#   avcodec +#   avdevice +#   avfilter +#   avformat +#   avutil +#   postproc +#   swresample +#   swscale +# + +set(_FFmpeg_ALL_COMPONENTS +    avcodec +    avdevice +    avfilter +    avformat +    avutil +    postproc +    swresample +    swscale +) + +set(_FFmpeg_DEPS_avcodec avutil) +set(_FFmpeg_DEPS_avdevice avcodec avformat avutil) +set(_FFmpeg_DEPS_avfilter avutil) +set(_FFmpeg_DEPS_avformat avcodec avutil) +set(_FFmpeg_DEPS_postproc avutil) +set(_FFmpeg_DEPS_swresample avutil) +set(_FFmpeg_DEPS_swscale avutil) + +function(find_ffmpeg LIBNAME) +  if(DEFINED ENV{FFMPEG_DIR}) +    set(FFMPEG_DIR $ENV{FFMPEG_DIR}) +  endif() + +  if(FFMPEG_DIR) +    list(APPEND INCLUDE_PATHS +      ${FFMPEG_DIR} +      ${FFMPEG_DIR}/ffmpeg +      ${FFMPEG_DIR}/lib${LIBNAME} +      ${FFMPEG_DIR}/include/lib${LIBNAME} +      ${FFMPEG_DIR}/include/ffmpeg +      ${FFMPEG_DIR}/include +      NO_DEFAULT_PATH +      NO_CMAKE_FIND_ROOT_PATH +    ) +    list(APPEND LIB_PATHS +      ${FFMPEG_DIR} +      ${FFMPEG_DIR}/lib +      ${FFMPEG_DIR}/lib${LIBNAME} +      NO_DEFAULT_PATH +      NO_CMAKE_FIND_ROOT_PATH +    ) +  else() +    list(APPEND INCLUDE_PATHS +      /usr/local/include/ffmpeg +      /usr/local/include/lib${LIBNAME} +      /usr/include/ffmpeg +      /usr/include/lib${LIBNAME} +      /usr/include/ffmpeg/lib${LIBNAME} +    ) + +    list(APPEND LIB_PATHS +      /usr/local/lib +      /usr/lib +    ) +  endif() + +  find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h +    HINTS ${INCLUDE_PATHS} +  ) + +  find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME} +    HINTS ${LIB_PATHS} +  ) + +  if(NOT FFMPEG_DIR AND (NOT FFmpeg_LIBRARY_${LIBNAME} OR NOT FFmpeg_INCLUDE_${LIBNAME})) +    # Didn't find it in the usual paths, try pkg-config +    find_package(PkgConfig QUIET) +    pkg_check_modules(FFmpeg_PKGCONFIG_${LIBNAME} QUIET lib${LIBNAME}) + +    find_path(FFmpeg_INCLUDE_${LIBNAME} lib${LIBNAME}/${LIBNAME}.h +      ${FFmpeg_PKGCONFIG_${LIBNAME}_INCLUDE_DIRS} +    ) + +    find_library(FFmpeg_LIBRARY_${LIBNAME} ${LIBNAME} +      ${FFmpeg_PKGCONFIG_${LIBNAME}_LIBRARY_DIRS} +    ) +  endif() + +  if(FFmpeg_INCLUDE_${LIBNAME} AND FFmpeg_LIBRARY_${LIBNAME}) +    set(FFmpeg_INCLUDE_${LIBNAME} "${FFmpeg_INCLUDE_${LIBNAME}}" PARENT_SCOPE) +    set(FFmpeg_LIBRARY_${LIBNAME} "${FFmpeg_LIBRARY_${LIBNAME}}" PARENT_SCOPE) + +    # Extract FFmpeg version from version.h +    foreach(v MAJOR MINOR MICRO) +      set(FFmpeg_${LIBNAME}_VERSION_${v} 0) +    endforeach() +    string(TOUPPER ${LIBNAME} LIBNAME_UPPER) +    file(STRINGS "${FFmpeg_INCLUDE_${LIBNAME}}/lib${LIBNAME}/version.h" _FFmpeg_VERSION_H_CONTENTS REGEX "#define LIB${LIBNAME_UPPER}_VERSION_(MAJOR|MINOR|MICRO) ") +    set(_FFmpeg_VERSION_REGEX "([0-9]+)") +    foreach(v MAJOR MINOR MICRO) +      if("${_FFmpeg_VERSION_H_CONTENTS}" MATCHES "#define LIB${LIBNAME_UPPER}_VERSION_${v}[\\t ]+${_FFmpeg_VERSION_REGEX}") +        set(FFmpeg_${LIBNAME}_VERSION_${v} "${CMAKE_MATCH_1}") +      endif() +    endforeach() +    set(FFmpeg_${LIBNAME}_VERSION "${FFmpeg_${LIBNAME}_VERSION_MAJOR}.${FFmpeg_${LIBNAME}_VERSION_MINOR}.${FFmpeg_${LIBNAME}_VERSION_MICRO}") +    set(FFmpeg_${c}_VERSION "${FFmpeg_${LIBNAME}_VERSION}" PARENT_SCOPE) +    unset(_FFmpeg_VERSION_REGEX) +    unset(_FFmpeg_VERSION_H_CONTENTS) + +    set(FFmpeg_${c}_FOUND TRUE PARENT_SCOPE) +    if(NOT FFmpeg_FIND_QUIETLY) +      message("--  Found ${LIBNAME}: ${FFmpeg_INCLUDE_${LIBNAME}} ${FFmpeg_LIBRARY_${LIBNAME}} (version: ${FFmpeg_${LIBNAME}_VERSION})") +    endif() +  endif() +endfunction() + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) +  find_ffmpeg(${c}) +endforeach() + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) +  if(FFmpeg_${c}_FOUND) +    list(APPEND FFmpeg_INCLUDE_DIR ${FFmpeg_INCLUDE_${c}}) +    list(APPEND FFmpeg_LIBRARIES ${FFmpeg_LIBRARY_${c}}) + +    add_library(FFmpeg::${c} IMPORTED UNKNOWN) +    set_target_properties(FFmpeg::${c} PROPERTIES +      IMPORTED_LOCATION ${FFmpeg_LIBRARY_${c}} +      INTERFACE_INCLUDE_DIRECTORIES ${FFmpeg_INCLUDE_${c}} +    ) +    if(_FFmpeg_DEPS_${c}) +      set(deps) +      foreach(dep ${_FFmpeg_DEPS_${c}}) +        list(APPEND deps FFmpeg::${dep}) +      endforeach() + +      set_target_properties(FFmpeg::${c} PROPERTIES +        INTERFACE_LINK_LIBRARIES "${deps}" +      ) +      unset(deps) +    endif() +  endif() +endforeach() + +if(FFmpeg_INCLUDE_DIR) +  list(REMOVE_DUPLICATES FFmpeg_INCLUDE_DIR) +endif() + +foreach(c ${FFmpeg_FIND_COMPONENTS}) +  list(APPEND _FFmpeg_REQUIRED_VARS FFmpeg_INCLUDE_${c} FFmpeg_LIBRARY_${c}) +endforeach() + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFmpeg +  REQUIRED_VARS ${_FFmpeg_REQUIRED_VARS} +  HANDLE_COMPONENTS +) + +foreach(c ${_FFmpeg_ALL_COMPONENTS}) +  unset(_FFmpeg_DEPS_${c}) +endforeach() +unset(_FFmpeg_ALL_COMPONENTS) +unset(_FFmpeg_REQUIRED_VARS) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(FFmpeg +  REQUIRED_VARS +    FFmpeg_LIBRARIES +    FFmpeg_INCLUDE_DIR +  HANDLE_COMPONENTS +) diff --git a/CMakeModules/FindOpus.cmake b/CMakeModules/FindOpus.cmake new file mode 100644 index 000000000..25a44fd87 --- /dev/null +++ b/CMakeModules/FindOpus.cmake @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(OPUS QUIET IMPORTED_TARGET opus) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Opus +    REQUIRED_VARS OPUS_LINK_LIBRARIES +    VERSION_VAR OPUS_VERSION +) + +if (Opus_FOUND AND NOT TARGET Opus::opus) +    add_library(Opus::opus ALIAS PkgConfig::OPUS) +endif() diff --git a/CMakeModules/Findenet.cmake b/CMakeModules/Findenet.cmake new file mode 100644 index 000000000..859a6f386 --- /dev/null +++ b/CMakeModules/Findenet.cmake @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf> +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(ENET QUIET IMPORTED_TARGET libenet) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(enet +    REQUIRED_VARS ENET_LINK_LIBRARIES +    VERSION_VAR ENET_VERSION +) + +if (enet_FOUND AND NOT TARGET enet::enet) +    add_library(enet::enet ALIAS PkgConfig::ENET) +endif() diff --git a/CMakeModules/Findhttplib.cmake b/CMakeModules/Findhttplib.cmake new file mode 100644 index 000000000..861207eb5 --- /dev/null +++ b/CMakeModules/Findhttplib.cmake @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2022 Andrea Pappacoda <andrea@pappacoda.it> +# +# SPDX-License-Identifier: GPL-2.0-or-later + +include(FindPackageHandleStandardArgs) + +find_package(httplib QUIET CONFIG) +if (httplib_CONSIDERED_CONFIGS) +    find_package_handle_standard_args(httplib CONFIG_MODE) +else() +    find_package(PkgConfig QUIET) +    pkg_search_module(HTTPLIB QUIET IMPORTED_TARGET cpp-httplib) +    find_package_handle_standard_args(httplib +        REQUIRED_VARS HTTPLIB_INCLUDEDIR +        VERSION_VAR HTTPLIB_VERSION +    ) +endif() + +if (httplib_FOUND AND NOT TARGET httplib::httplib) +    add_library(httplib::httplib ALIAS PkgConfig::HTTPLIB) +endif() diff --git a/CMakeModules/Findinih.cmake b/CMakeModules/Findinih.cmake new file mode 100644 index 000000000..b8d38dcff --- /dev/null +++ b/CMakeModules/Findinih.cmake @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf> +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(INIREADER QUIET IMPORTED_TARGET INIReader) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(inih +    REQUIRED_VARS INIREADER_LINK_LIBRARIES +    VERSION_VAR INIREADER_VERSION +) + +if (inih_FOUND AND NOT TARGET inih::INIReader) +    add_library(inih::INIReader ALIAS PkgConfig::INIREADER) +endif() diff --git a/CMakeModules/Findlibusb.cmake b/CMakeModules/Findlibusb.cmake new file mode 100644 index 000000000..0eadce957 --- /dev/null +++ b/CMakeModules/Findlibusb.cmake @@ -0,0 +1,16 @@ +# SPDX-FileCopyrightText: 2022 Alexandre Bouvier <contact@amb.tf> +# +# SPDX-License-Identifier: GPL-3.0-or-later + +find_package(PkgConfig QUIET) +pkg_search_module(LIBUSB QUIET IMPORTED_TARGET libusb-1.0) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(libusb +    REQUIRED_VARS LIBUSB_LINK_LIBRARIES +    VERSION_VAR LIBUSB_VERSION +) + +if (libusb_FOUND AND NOT TARGET libusb::usb) +    add_library(libusb::usb ALIAS PkgConfig::LIBUSB) +endif() diff --git a/CMakeModules/Findlz4.cmake b/CMakeModules/Findlz4.cmake new file mode 100644 index 000000000..7a9a02d4e --- /dev/null +++ b/CMakeModules/Findlz4.cmake @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +include(FindPackageHandleStandardArgs) + +find_package(lz4 QUIET CONFIG) +if (lz4_CONSIDERED_CONFIGS) +    find_package_handle_standard_args(lz4 CONFIG_MODE) +else() +    find_package(PkgConfig QUIET) +    pkg_search_module(LZ4 QUIET IMPORTED_TARGET liblz4) +    find_package_handle_standard_args(lz4 +        REQUIRED_VARS LZ4_LINK_LIBRARIES +        VERSION_VAR LZ4_VERSION +    ) +endif() + +if (lz4_FOUND AND NOT TARGET lz4::lz4) +    if (TARGET LZ4::lz4_shared) +        add_library(lz4::lz4 ALIAS LZ4::lz4_shared) +    elseif (TARGET LZ4::lz4_static) +        add_library(lz4::lz4 ALIAS LZ4::lz4_static) +    else() +        add_library(lz4::lz4 ALIAS PkgConfig::LZ4) +    endif() +endif() diff --git a/CMakeModules/Findzstd.cmake b/CMakeModules/Findzstd.cmake new file mode 100644 index 000000000..ae3ea0865 --- /dev/null +++ b/CMakeModules/Findzstd.cmake @@ -0,0 +1,26 @@ +# SPDX-FileCopyrightText: 2022 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +include(FindPackageHandleStandardArgs) + +find_package(zstd QUIET CONFIG) +if (zstd_CONSIDERED_CONFIGS) +    find_package_handle_standard_args(zstd CONFIG_MODE) +else() +    find_package(PkgConfig QUIET) +    pkg_search_module(ZSTD QUIET IMPORTED_TARGET libzstd) +    find_package_handle_standard_args(zstd +        REQUIRED_VARS ZSTD_LINK_LIBRARIES +        VERSION_VAR ZSTD_VERSION +    ) +endif() + +if (zstd_FOUND AND NOT TARGET zstd::zstd) +    if (TARGET zstd::libzstd_shared) +        add_library(zstd::zstd ALIAS zstd::libzstd_shared) +    elseif (TARGET zstd::libzstd_static) +        add_library(zstd::zstd ALIAS zstd::libzstd_static) +    else() +        add_library(zstd::zstd ALIAS PkgConfig::ZSTD) +    endif() +endif() diff --git a/CMakeModules/WindowsCopyFiles.cmake b/CMakeModules/WindowsCopyFiles.cmake new file mode 100644 index 000000000..08b598365 --- /dev/null +++ b/CMakeModules/WindowsCopyFiles.cmake @@ -0,0 +1,27 @@ +# SPDX-FileCopyrightText: 2018 yuzu Emulator Project +# SPDX-License-Identifier: GPL-2.0-or-later + +# This file provides the function windows_copy_files. +# This is only valid on Windows. + +# Include guard +if(__windows_copy_files) +	return() +endif() +set(__windows_copy_files YES) + +# Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR. +# This copying happens post-build. +function(windows_copy_files TARGET SOURCE_DIR DEST_DIR) +    # windows commandline expects the / to be \ so switch them +    string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR}) +    string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR}) + +    # /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output +    # cmake adds an extra check for command success which doesn't work too well with robocopy +    # so trick it into thinking the command was successful with the || cmd /c "exit /b 0" +    add_custom_command(TARGET ${TARGET} POST_BUILD +        COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR} +        COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0" +    ) +endfunction() | 
