From e49b3c75bd61c93db9553aefeb038f67ec14d485 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Mon, 16 Oct 2023 19:32:58 -0700 Subject: [PATCH] externals: Make system dynamic library headers flags instead of auto-detect. (#7065) --- .gitmodules | 2 +- CMakeLists.txt | 2 + externals/CMakeLists.txt | 32 ++++++++++++- .../{library-headers => }/library-headers | 0 externals/library-headers/CMakeLists.txt | 48 ------------------- 5 files changed, 34 insertions(+), 50 deletions(-) rename externals/{library-headers => }/library-headers (100%) delete mode 100644 externals/library-headers/CMakeLists.txt diff --git a/.gitmodules b/.gitmodules index 0311d459d8..bfd9c9a7f2 100644 --- a/.gitmodules +++ b/.gitmodules @@ -80,7 +80,7 @@ path = externals/sirit url = https://github.com/yuzu-emu/sirit [submodule "library-headers"] - path = externals/library-headers/library-headers + path = externals/library-headers url = https://github.com/citra-emu/ext-library-headers.git [submodule "libadrenotools"] path = externals/libadrenotools diff --git a/CMakeLists.txt b/CMakeLists.txt index 08cc24fdb0..65b16f44e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,8 @@ option(USE_SYSTEM_DYNARMIC "Use the system dynarmic (instead of the bundled one) option(USE_SYSTEM_FMT "Use the system fmt (instead of the bundled one)" OFF) option(USE_SYSTEM_XBYAK "Use the system xbyak (instead of the bundled one)" OFF) option(USE_SYSTEM_INIH "Use the system inih (instead of the bundled one)" OFF) +option(USE_SYSTEM_FDK_AAC_HEADERS "Use the system fdk-aac headers (instead of the bundled one)" OFF) +option(USE_SYSTEM_FFMPEG_HEADERS "Use the system FFmpeg headers (instead of the bundled one)" OFF) if (CITRA_USE_PRECOMPILED_HEADERS) message(STATUS "Using Precompiled Headers.") diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index aeb53f619f..f9b24f1b3d 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -150,7 +150,37 @@ endif() add_subdirectory(open_source_archives) # Dynamic library headers -add_subdirectory(library-headers EXCLUDE_FROM_ALL) +add_library(library-headers INTERFACE) + +if (USE_SYSTEM_FDK_AAC_HEADERS) + find_path(SYSTEM_FDK_AAC_INCLUDES NAMES fdk-aac/aacdecoder_lib.h) + if (SYSTEM_FDK_AAC_INCLUDES STREQUAL "SYSTEM_FDK_AAC_INCLUDES-NOTFOUND") + message(WARNING "System fdk-aac headers not found. Falling back on bundled headers.") + else() + message(STATUS "Using system fdk_aac headers.") + target_include_directories(library-headers SYSTEM INTERFACE ${SYSTEM_FDK_AAC_INCLUDES}) + set(FOUND_FDK_AAC_HEADERS ON) + endif() +endif() +if (NOT FOUND_FDK_AAC_HEADERS) + message(STATUS "Using bundled fdk_aac headers.") + target_include_directories(library-headers SYSTEM INTERFACE ./library-headers/fdk-aac/include) +endif() + +if (USE_SYSTEM_FFMPEG_HEADERS) + find_path(SYSTEM_FFMPEG_INCLUDES NAMES libavutil/avutil.h) + if (SYSTEM_FFMPEG_INCLUDES STREQUAL "SYSTEM_FFMPEG_INCLUDES-NOTFOUND") + message(WARNING "System FFmpeg headers not found. Falling back on bundled headers.") + else() + message(STATUS "Using system FFmpeg headers.") + target_include_directories(library-headers SYSTEM INTERFACE ${SYSTEM_FFMPEG_INCLUDES}) + set(FOUND_FFMPEG_HEADERS ON) + endif() +endif() +if (NOT FOUND_FFMPEG_HEADERS) + message(STATUS "Using bundled ffmpeg headers.") + target_include_directories(library-headers SYSTEM INTERFACE ./library-headers/ffmpeg/include) +endif() # SoundTouch if(NOT USE_SYSTEM_SOUNDTOUCH) diff --git a/externals/library-headers/library-headers b/externals/library-headers similarity index 100% rename from externals/library-headers/library-headers rename to externals/library-headers diff --git a/externals/library-headers/CMakeLists.txt b/externals/library-headers/CMakeLists.txt deleted file mode 100644 index a3cc026064..0000000000 --- a/externals/library-headers/CMakeLists.txt +++ /dev/null @@ -1,48 +0,0 @@ -add_library(library-headers INTERFACE) - -# libfdk-aac headers -find_path(FDK_AAC_INCLUDES NAMES fdk-aac/aacdecoder_lib.h) -if (FDK_AAC_INCLUDES STREQUAL "FDK_AAC_INCLUDES-NOTFOUND") - message(STATUS "fdk_aac headers not found, using bundled headers.") - target_include_directories(library-headers INTERFACE ./library-headers/fdk-aac/include) -else() - message(STATUS "Using headers from system fdk_aac") - target_include_directories(library-headers SYSTEM INTERFACE ${FDK_AAC_INCLUDES}) -endif() - -# FFmpeg headers -find_path(AVUTIL_INCLUDES NAMES libavutil/avutil.h) -find_path(AVCODEC_INCLUDES NAMES libavcodec/avcodec.h) -find_path(AVFORMAT_INCLUDES NAMES libavformat/avformat.h) -find_path(AVFILTER_INCLUDES NAMES libavfilter/avfilter.h) -find_path(SWRESAMPLE_INCLUDES NAMES libswresample/swresample.h) -# Make sure all the headers are found and from the same place, so we don't -# have missing or mismatched components. -if (AVUTIL_INCLUDES STREQUAL "AVUTIL_INCLUDES-NOTFOUND" - OR NOT AVCODEC_INCLUDES STREQUAL AVUTIL_INCLUDES - OR NOT AVFORMAT_INCLUDES STREQUAL AVUTIL_INCLUDES - OR NOT AVFILTER_INCLUDES STREQUAL AVUTIL_INCLUDES - OR NOT SWRESAMPLE_INCLUDES STREQUAL AVUTIL_INCLUDES) - message(STATUS "Complete FFmpeg headers not found, using bundled headers.") - target_include_directories(library-headers INTERFACE ./library-headers/ffmpeg/include) -else() - # Extract libavutil version from header. - file(STRINGS "${AVUTIL_INCLUDES}/libavutil/version.h" AVUTIL_VERSION_DATA - REGEX "#define LIBAVUTIL_VERSION_(MAJOR|MINOR|MICRO) ") - set(AVUTIL_VERSION_REGEX "([0-9]+)") - foreach(v MAJOR MINOR MICRO) - if("${AVUTIL_VERSION_DATA}" MATCHES "#define LIBAVUTIL_VERSION_${v}[\\t ]+${AVUTIL_VERSION_REGEX}") - set(AVUTIL_VERSION_${v} "${CMAKE_MATCH_1}") - endif() - endforeach() - set(AVUTIL_VERSION "${AVUTIL_VERSION_MAJOR}.${AVUTIL_VERSION_MINOR}.${AVUTIL_VERSION_MICRO}") - - message(STATUS "Detected FFmpeg libavutil version is ${AVUTIL_VERSION}") - if ("${AVUTIL_VERSION}" VERSION_LESS "56.30.100") - message(WARNING "System FFmpeg version is too low (< 4.2), using bundled headers.") - target_include_directories(library-headers INTERFACE ./library-headers/ffmpeg/include) - else() - message(STATUS "Using headers from system FFmpeg") - target_include_directories(library-headers SYSTEM INTERFACE ${AVUTIL_INCLUDES}) - endif() -endif()