diff --git a/CMakeLists.txt b/CMakeLists.txt index b6f157fbe..1e02244ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Darwin)" OR OBS_CMAKE_VERSION VERSION_GREATE project(obs-studio VERSION ${OBS_VERSION_CANONICAL}) - if(CMAKE_SIZEOF_VOID_P EQUAL 4) + if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Windows)" AND CMAKE_SIZEOF_VOID_P EQUAL 4) include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/32bit/projects.cmake") return() endif() @@ -34,6 +34,22 @@ if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Darwin)" OR OBS_CMAKE_VERSION VERSION_GREATE return() endif() +if(CMAKE_HOST_SYSTEM_NAME MATCHES "(Windows|Darwin)") + message( + DEPRECATION + "\n" + "============ LEGACY BUILD SYSTEM IS DEPRECATED ============" + "\n" + "You are using the legacy build system to build OBS Studio. " + "The legacy build system is unsupported and will be removed in the near future." + "\n" + "To migrate to the new build system, familiarize yourself with CMake presets " + "(https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html) and create " + "a user preset with your customized build settings, inheriting from one of the default presets." + "\n" + "============ LEGACY BUILD SYSTEM IS DEPRECATED ============") +endif() + list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake/Modules") include(VersionConfig) diff --git a/CMakePresets.json b/CMakePresets.json index 184d1cfd8..3869d53a3 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,5 +1,5 @@ { - "version": 5, + "version": 3, "cmakeMinimumRequired": { "major": 3, "minor": 22, @@ -10,10 +10,10 @@ "name": "environmentVars", "hidden": true, "cacheVariables": { - "TWITCH_CLIENTID": {"type": "STRING", "value": "$penv{TWITCH_CLIENTID}"}, - "TWITCH_HASH": {"type": "STRING", "value": "$penv{TWITCH_HASH}"}, "RESTREAM_CLIENTID": {"type": "STRING", "value": "$penv{RESTREAM_CLIENTID}"}, "RESTREAM_HASH": {"type": "STRING", "value": "$penv{RESTREAM_HASH}"}, + "TWITCH_CLIENTID": {"type": "STRING", "value": "$penv{TWITCH_CLIENTID}"}, + "TWITCH_HASH": {"type": "STRING", "value": "$penv{TWITCH_HASH}"}, "YOUTUBE_CLIENTID": {"type": "STRING", "value": "$penv{YOUTUBE_CLIENTID}"}, "YOUTUBE_CLIENTID_HASH": {"type": "STRING", "value": "$penv{YOUTUBE_CLIENTID_HASH}"}, "YOUTUBE_SECRET": {"type": "STRING", "value": "$penv{YOUTUBE_SECRET}"}, @@ -33,16 +33,16 @@ "generator": "Xcode", "binaryDir": "${sourceDir}/build_macos", "cacheVariables": { - "ENABLE_BROWSER": true, "CMAKE_OSX_DEPLOYMENT_TARGET": {"type": "STRING", "value": "11.0"}, - "OBS_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"}, "OBS_CODESIGN_IDENTITY": {"type": "STRING", "value": "$penv{CODESIGN_IDENT}"}, + "OBS_CODESIGN_TEAM": {"type": "STRING", "value": "$penv{CODESIGN_TEAM}"}, "OBS_PROVISIONING_PROFILE": {"type": "STRING", "value": "$penv{PROVISIONING_PROFILE}"}, "VIRTUALCAM_DEVICE_UUID": {"type": "STRING", "value": "7626645E-4425-469E-9D8B-97E0FA59AC75"}, - "VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"}, "VIRTUALCAM_SINK_UUID": {"type": "STRING", "value": "A3F16177-7044-4DD8-B900-72E2419F7A9A"}, + "VIRTUALCAM_SOURCE_UUID": {"type": "STRING", "value": "A8D7B8AA-65AD-4D21-9C42-66480DBFA8E1"}, "SPARKLE_APPCAST_URL": {"type": "STRING", "value": "https://obsproject.com/osx_update/updates_$(ARCHS)_v2.xml"}, - "SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="} + "SPARKLE_PUBLIC_KEY": {"type": "STRING", "value": "HQ5/Ba9VHOuEWaM0jtVjZzgHKFJX9YTl+HNVpgNF0iM="}, + "ENABLE_BROWSER": true } }, { @@ -56,75 +56,35 @@ } }, { - "name": "linux-aarch64", - "displayName": "Linux aarch64", - "description": "obs-studio for Linux (aarch64)", + "name": "ubuntu", + "displayName": "Ubuntu", + "description": "obs-studio for Ubuntu", "inherits": ["environmentVars"], "condition": { "type": "equals", "lhs": "${hostSystemName}", "rhs": "Linux" }, - "binaryDir": "${sourceDir}/build_aarch64", + "binaryDir": "${sourceDir}/build_ubuntu", "generator": "Ninja", "warnings": {"dev": true, "deprecated": true}, "cacheVariables": { - "ENABLE_WAYLAND": true, + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_INSTALL_LIBDIR": "lib/CMAKE_SYSTEM_PROCESSOR-linux-gnu", + "OBS_CMAKE_VERSION": {"type": "STRING", "value": "3.0.0"}, + "ENABLE_AJA": false, + "ENABLE_NATIVE_NVENC": false, "ENABLE_VLC": true, - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "linux-ci-aarch64", - "inherits": ["linux-aarch64"], - "hidden": true, - "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "linux-release-aarch64", - "displayName": "Linux aarch64 (Release)", - "description": "obs-studio for Linux (aarch64) - Release Configuration", - "inherits": "linux-aarch64", - "cacheVariables": { - "ENABLE_RELEASE_BUILD": true - } - }, - { - "name": "linux-x86_64", - "displayName": "Linux x86_64", - "description": "obs-studio for Linux (x86_64)", - "inherits": ["environmentVars"], - "condition": { - "type": "equals", - "lhs": "${hostSystemName}", - "rhs": "Linux" - }, - "binaryDir": "${sourceDir}/build_x86_64", - "generator": "Ninja", - "warnings": {"dev": true, "deprecated": true}, - "cacheVariables": { "ENABLE_WAYLAND": true, - "ENABLE_VLC": true, - "CMAKE_BUILD_TYPE": {"type": "STRING", "value": "Debug"} + "ENABLE_WEBRTC": false } }, { - "name": "linux-ci-x86_64", - "inherits": ["linux-x86_64"], + "name": "ubuntu-ci", + "inherits": ["ubuntu"], "cacheVariables": { - "CMAKE_BUILD_TYPE": "RelWithDebInfo" - } - }, - { - "name": "linux-release-x86_64", - "displayName": "Linux x86_64 (Release)", - "description": "obs-studio for Linux (x86_64) - Release Configuration", - "inherits": "linux-x86_64", - "cacheVariables": { - "ENABLE_RELEASE_BUILD": true, - "ENABLE_BROWSER": true + "CMAKE_BUILD_TYPE": "RelWithDebInfo", + "CMAKE_COMPILE_WARNING_AS_ERROR": true } }, { @@ -142,9 +102,9 @@ "generator": "Visual Studio 17 2022", "cacheVariables": { "OBS_CMAKE_VERSION": {"type": "STRING", "value": "3.0.0"}, - "ENABLE_BROWSER": true, - "VIRTUALCAM_GUID": {"type": "STRING", "value": "A3FCE0F5-3493-419F-958A-ABA1250EC20B"}, "GPU_PRIORITY_VAL": {"type": "STRING", "value": "$penv{GPU_PRIORITY_VAL}"}, + "VIRTUALCAM_GUID": {"type": "STRING", "value": "A3FCE0F5-3493-419F-958A-ABA1250EC20B"}, + "ENABLE_BROWSER": true, "ENABLE_CCACHE": false } }, @@ -161,20 +121,6 @@ } ], "buildPresets": [ - { - "name": "linux-aarch64", - "configurePreset": "linux-aarch64", - "displayName": "Linux aarch64", - "description": "Linux build for aarch64 (aka arm64)", - "configuration": "RelWithDebInfo" - }, - { - "name": "linux-x86_64", - "configurePreset": "linux-x86_64", - "displayName": "Linux x86_64", - "description": "Linux build for x86_64 (aka amd64)", - "configuration": "RelWithDebInfo" - }, { "name": "windows-x64", "configurePreset": "windows-x64", diff --git a/cmake/common/buildnumber.cmake b/cmake/common/buildnumber.cmake index 5f1bee564..4d509adc1 100644 --- a/cmake/common/buildnumber.cmake +++ b/cmake/common/buildnumber.cmake @@ -12,7 +12,7 @@ if(NOT DEFINED OBS_BUILD_NUMBER AND EXISTS "${_BUILD_NUMBER_CACHE}") file(READ "${_BUILD_NUMBER_CACHE}" OBS_BUILD_NUMBER) math(EXPR OBS_BUILD_NUMBER "${OBS_BUILD_NUMBER}+1") elseif(NOT DEFINED OBS_BUILD_NUMBER) - if($ENV{CI} AND $ENV{GITHUB_RUN_ID}) + if("$ENV{CI}" AND "$ENV{GITHUB_RUN_ID}") set(OBS_BUILD_NUMBER "$ENV{GITHUB_RUN_ID}") else() set(OBS_BUILD_NUMBER "1") diff --git a/cmake/common/compiler_common.cmake b/cmake/common/compiler_common.cmake index 885b8e5de..ccae3d220 100644 --- a/cmake/common/compiler_common.cmake +++ b/cmake/common/compiler_common.cmake @@ -2,6 +2,9 @@ include_guard(GLOBAL) +option(OBS_COMPILE_DEPRECATION_AS_WARNING "Downgrade deprecation warnings to actual warnings" FALSE) +mark_as_advanced(OBS_COMPILE_DEPRECATION_AS_WARNING) + # Set C and C++ language standards to C17 and C++17 if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.21) set(CMAKE_C_STANDARD 17) @@ -57,7 +60,8 @@ set(_obs_clang_common_options -Wno-semicolon-before-method-body -Wformat-security -Wvla - -Wno-error=shorten-64-to-32) + -Wno-error=shorten-64-to-32 + $<$:-Wno-error=deprecated-declarations>) # clang options for C set(_obs_clang_c_options ${_obs_clang_common_options} -Wno-shadow -Wno-float-conversion) diff --git a/cmake/finders/FindFFmpeg.cmake b/cmake/finders/FindFFmpeg.cmake index 9e2cdc8ac..bf28f8ab9 100644 --- a/cmake/finders/FindFFmpeg.cmake +++ b/cmake/finders/FindFFmpeg.cmake @@ -277,8 +277,8 @@ endif() if(EXISTS "${FFmpeg_avutil_INCLUDE_DIR}/libavutil/ffversion.h") file(STRINGS "${FFmpeg_avutil_INCLUDE_DIR}/libavutil/ffversion.h" _version_string - REGEX "^.*FFMPEG_VERSION[ \t]+\"n[0-9a-z\\.-]+\"[ \t]*$") - string(REGEX REPLACE ".*FFMPEG_VERSION[ \t]+\"n([0-9]+\\.[0-9]).+\".*" "\\1" FFmpeg_VERSION "${_version_string}") + REGEX "^.*FFMPEG_VERSION[ \t]+\"n?[0-9a-z\\.-]+\"[ \t]*$") + string(REGEX REPLACE ".*FFMPEG_VERSION[ \t]+\"n?([0-9]+\\.[0-9]).*\".*" "\\1" FFmpeg_VERSION "${_version_string}") endif() list(REMOVE_DUPLICATES FFmpeg_INCLUDE_DIRS) diff --git a/cmake/finders/FindGio.cmake b/cmake/finders/FindGio.cmake new file mode 100644 index 000000000..a134dc2f8 --- /dev/null +++ b/cmake/finders/FindGio.cmake @@ -0,0 +1,121 @@ +#[=======================================================================[.rst +FindGio +------- + +FindModule for gio and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``gio::gio``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Gio_FOUND`` + True, if all required components and the core library were found. +``Gio_VERSION`` + Detected version of found gio libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Gio_LIBRARY`` + Path to the library component of gio. +``Gio_INCLUDE_DIR`` + Directory containing ``gio.h`` + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Gio QUIET gio-2.0 gio) + pkg_search_module(PC_GioUnix QUIET gio-unix-2.0) +endif() + +find_path( + Gio_INCLUDE_DIR + NAMES gio/gio.h + HINTS ${PC_Gio_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES glib-2.0 + DOC "gio-2.0 include directory") + +find_path( + GioUnix_INCLUDE_DIR + NAMES gio/gunixfdmessage.h + HINTS ${PC_GioUnix_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES gio-unix-2.0 + DOC "gio-unix-2.0 include directory") + +find_library( + Gio_LIBRARY + NAMES libgio-2.0 gio-2.0 gio-unix-2.0 + HINTS ${PC_Gio_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "gio-2.0 location") + +find_path( + Glib_INCLUDE_DIR + NAMES glibconfig.h + HINTS ${PC_Gio_INCLUDE_DIRS} + PATHS /usr/lib /usr/local/lib + PATH_SUFFIXES glib-2.0/include) + +if(PC_Gio_VERSION VERSION_GREATER 0) + set(Gio_VERSION ${PC_Gio_VERSION}) +else() + if(NOT Gio_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find gio version.") + endif() + set(Gio_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Gio + REQUIRED_VARS Gio_LIBRARY Gio_INCLUDE_DIR GioUnix_INCLUDE_DIR Glib_INCLUDE_DIR + VERSION_VAR Gio_VERSION REASON_FAILURE_MESSAGE "Ensure that glib is installed on the system.") +mark_as_advanced(Gio_INCLUDE_DIR Gio_LIBRARY Glib_INCLUDE_DIR) + +if(Gio_FOUND) + if(NOT TARGET gio::gio) + if(IS_ABSOLUTE "${Gio_LIBRARY}") + add_library(gio::gio UNKNOWN IMPORTED) + set_property(TARGET gio::gio PROPERTY IMPORTED_LOCATION "${Gio_LIBRARY}") + else() + add_library(gio::gio INTERFACE IMPORTED) + set_property(TARGET gio::gio PROPERTY IMPORTED_LIBNAME "${Gio_LIBRARY}") + endif() + + set_target_properties( + gio::gio + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Gio_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Gio_INCLUDE_DIR};${GioUnix_INCLUDE_DIR};${Glib_INCLUDE_DIR}" + VERSION ${Gio_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Gio PROPERTIES + URL "https://docs.gtk.org/gio" + DESCRIPTION + "A library providing useful classes for general purpose I/O, networking, IPC, settings, and other high level application functionality." +) diff --git a/cmake/finders/FindJack.cmake b/cmake/finders/FindJack.cmake new file mode 100644 index 000000000..a7547d0d9 --- /dev/null +++ b/cmake/finders/FindJack.cmake @@ -0,0 +1,104 @@ +#[=======================================================================[.rst +FindJack +-------- + +FindModule for Jack and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Jack::Jack``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Jack_FOUND`` + True, if all required components and the core library were found. +``Jack_VERSION`` + Detected version of found Jack libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Jack_LIBRARY`` + Path to the library component of Jack. +``Jack_INCLUDE_DIR`` + Directory containing ``jack.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Jack QUIET jack) +endif() + +find_path( + Jack_INCLUDE_DIR + NAMES jack/jack.h + HINTS ${PC_Jack_INCLUDE_DIR} + PATHS /usr/include /usr/local/include + DOC "Jack include directory") + +find_library( + Jack_LIBRARY + NAMES jack + HINTS ${PC_Jack_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Jack location") + +if(PC_Jack_VERSION VERSION_GREATER 0) + set(Jack_VERSION ${PC_Jack_VERSION}) +else() + if(NOT Jack_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Jack version.") + endif() + set(Jack_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Jack + REQUIRED_VARS Jack_LIBRARY Jack_INCLUDE_DIR + VERSION_VAR Jack_VERSION REASON_FAILURE_MESSAGE "Ensure that Jack is installed on the system.") +mark_as_advanced(Jack_INCLUDE_DIR Jack_LIBRARY) + +if(Jack_FOUND) + if(NOT TARGET Jack::Jack) + if(IS_ABSOLUTE "${Jack_LIBRARY}") + add_library(Jack::Jack UNKNOWN IMPORTED) + set_property(TARGET Jack::Jack PROPERTY IMPORTED_LOCATION "${Jack_LIBRARY}") + else() + add_library(Jack::Jack INTERFACE IMPORTED) + set_property(TARGET Jack::Jack PROPERTY IMPORTED_LIBNAME "${Jack_LIBRARY}") + endif() + + set_target_properties( + Jack::Jack + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Jack_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Jack_INCLUDE_DIR}" + VERSION ${Jack_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Jack PROPERTIES + URL "https://www.jackaudio.org" + DESCRIPTION + "JACK Audio Connection Kit (or JACK) is a professional sound server API and pair of daemon implementations to provide real-time, low-latency connections for both audio and MIDI data between applications." +) diff --git a/cmake/finders/FindLibUUID.cmake b/cmake/finders/FindLibUUID.cmake new file mode 100644 index 000000000..5bd4c9d36 --- /dev/null +++ b/cmake/finders/FindLibUUID.cmake @@ -0,0 +1,103 @@ +#[=======================================================================[.rst +FindLibUUID +----------- + +FindModule for LibUUID and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``LibUUID::LibUUID``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``LibUUID_FOUND`` + True, if all required components and the core library were found. +``LibUUID_VERSION`` + Detected version of found LibUUID libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``LibUUID_LIBRARY`` + Path to the library component of LibUUID. +``LibUUID_INCLUDE_DIR`` + Directory containing ``LibUUID.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_LibUUID QUIET LibUUID uuid) +endif() + +find_path( + LibUUID_INCLUDE_DIR + NAMES uuid/uuid.h + HINTS ${PC_LibUUID_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "LibUUID include directory") + +find_library( + LibUUID_LIBRARY + NAMES uuid + HINTS ${PC_LibUUID_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "LibUUID location") + +if(PC_LibUUID_VERSION VERSION_GREATER 0) + set(LibUUID_VERSION ${PC_LibUUID_VERSION}) +else() + if(NOT LibUUID_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find LibUUID version.") + endif() + set(LibUUID_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + LibUUID + REQUIRED_VARS LibUUID_LIBRARY LibUUID_INCLUDE_DIR + VERSION_VAR LibUUID_VERSION REASON_FAILURE_MESSAGE "Ensure that e2fsprogs is installed on the system.") +mark_as_advanced(LibUUID_INCLUDE_DIR LibUUID_LIBRARY) + +if(LibUUID_FOUND) + if(NOT TARGET LibUUID::LibUUID) + if(IS_ABSOLUTE "${LibUUID_LIBRARY}") + add_library(LibUUID::LibUUID UNKNOWN IMPORTED) + set_property(TARGET LibUUID::LibUUID PROPERTY IMPORTED_LOCATION "${LibUUID_LIBRARY}") + else() + add_library(LibUUID::LibUUID INTERFACE IMPORTED) + set_property(TARGET LibUUID::LibUUID PROPERTY IMPORTED_LIBNAME "${LibUUID_LIBRARY}") + endif() + + set_target_properties( + LibUUID::LibUUID + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_LibUUID_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${LibUUID_INCLUDE_DIR}" + VERSION ${LibUUID_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + LibUUID PROPERTIES + URL "http://e2fsprogs.sourceforge.net/" + DESCRIPTION + "The libuuid library is used to generate unique identifiers for objects that may be accessible beyond the local system." +) diff --git a/cmake/finders/FindLibdrm.cmake b/cmake/finders/FindLibdrm.cmake new file mode 100644 index 000000000..de5a25bc8 --- /dev/null +++ b/cmake/finders/FindLibdrm.cmake @@ -0,0 +1,105 @@ +#[=======================================================================[.rst +FindLibdrm +---------- + +FindModule for Libdrm and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libdrm::Libdrm``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libdrm_FOUND`` + True, if all required components and the core library were found. +``Libdrm_VERSION`` + Detected version of found Libdrm libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libdrm_LIBRARY`` + Path to the library component of Libdrm. +``Libdrm_INCLUDE_DIR`` + Directory containing ``drm_fourcc.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libdrm QUIET libdrm) +endif() + +find_path( + Libdrm_INCLUDE_DIR + NAMES drm_fourcc.h + HINTS ${PC_Libdrm_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES libdrm + DOC "Libdrm include directory") + +find_library( + Libdrm_LIBRARY + NAMES drm libdrm + HINTS ${PC_Libdrm_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libdrm location") + +if(PC_Libdrm_VERSION VERSION_GREATER 0) + set(Libdrm_VERSION ${PC_Libdrm_VERSION}) +else() + if(NOT Libdrm_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libdrm version.") + endif() + set(Libdrm_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libdrm + REQUIRED_VARS Libdrm_LIBRARY Libdrm_INCLUDE_DIR + VERSION_VAR Libdrm_VERSION REASON_FAILURE_MESSAGE "Ensure that libdrm is installed on the system.") +mark_as_advanced(Libdrm_INCLUDE_DIR Libdrm_LIBRARY) + +if(Libdrm_FOUND) + if(NOT TARGET Libdrm::Libdrm) + if(IS_ABSOLUTE "${Libdrm_LIBRARY}") + add_library(Libdrm::Libdrm UNKNOWN IMPORTED) + set_property(TARGET Libdrm::Libdrm PROPERTY IMPORTED_LOCATION "${Libdrm_LIBRARY}") + else() + add_library(Libdrm::Libdrm INTERFACE IMPORTED) + set_property(TARGET Libdrm::Libdrm PROPERTY IMPORTED_LIBNAME "${Libdrm_LIBRARY}") + endif() + + set_target_properties( + Libdrm::Libdrm + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libdrm_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libdrm_INCLUDE_DIR}" + VERSION ${Libdrm_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libdrm PROPERTIES + URL "https://gitlab.freedesktop.org/mesa/drm" + DESCRIPTION + "A low-level library, typically used by graphics drivers such as the Mesa drivers, the X drivers, libva and similar projects." +) diff --git a/cmake/finders/FindLibfdk.cmake b/cmake/finders/FindLibfdk.cmake new file mode 100644 index 000000000..ee345b72c --- /dev/null +++ b/cmake/finders/FindLibfdk.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindLibfdk +---------- + +FindModule for Libfdk and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libfdk::Libfdk``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libfdk_FOUND`` + True, if all required components and the core library were found. +``Libfdk_VERSION`` + Detected version of found Libfdk libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libfdk_LIBRARY`` + Path to the library component of Libfdk. +``Libfdk_INCLUDE_DIR`` + Directory containing ``fdk-aac/aacenc_lib.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libfdk QUIET fdk-aac Libfdk-aac) +endif() + +find_path( + Libfdk_INCLUDE_DIR + NAMES fdk-aac/aacenc_lib.h + HINTS ${PC_Libfdk_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + DOC "Libfdk include directory") + +find_library( + Libfdk_LIBRARY + NAMES fdk-aac Libfdk-aac + HINTS ${PC_Libfdk_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libfdk location") + +if(PC_Libfdk_VERSION VERSION_GREATER 0) + set(Libfdk_VERSION ${PC_Libfdk_VERSION}) +else() + if(NOT Libfdk_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libfdk version.") + endif() + set(Libfdk_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libfdk + REQUIRED_VARS Libfdk_LIBRARY Libfdk_INCLUDE_DIR + VERSION_VAR Libfdk_VERSION REASON_FAILURE_MESSAGE "Ensure that Libfdk is installed on the system.") +mark_as_advanced(Libfdk_INCLUDE_DIR Libfdk_LIBRARY) + +if(Libfdk_FOUND) + if(NOT TARGET Libfdk::Libfdk) + if(IS_ABSOLUTE "${Libfdk_LIBRARY}") + add_library(Libfdk::Libfdk UNKNOWN IMPORTED) + set_property(TARGET Libfdk::Libfdk PROPERTY IMPORTED_LOCATION "${Libfdk_LIBRARY}") + else() + add_library(Libfdk::Libfdk INTERFACE IMPORTED) + set_property(TARGET Libfdk::Libfdk PROPERTY IMPORTED_LIBNAME "${Libfdk_LIBRARY}") + endif() + + set_target_properties( + Libfdk::Libfdk + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libfdk_CFLAFGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libfdk_INCLUDE_DIR}" + VERSION ${Libfdk_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libfdk PROPERTIES + URL "https://github.com/mstorsjo/fdk-aac" + DESCRIPTION "A standalone library of the Fraunhofer FDK AAC code from Android.") diff --git a/cmake/finders/FindLibpci.cmake b/cmake/finders/FindLibpci.cmake new file mode 100644 index 000000000..18ebe6ed9 --- /dev/null +++ b/cmake/finders/FindLibpci.cmake @@ -0,0 +1,105 @@ +#[=======================================================================[.rst +FindLibpci +---------- + +FindModule for Libpci and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libpci::pci``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libpci_FOUND`` + True, if all required components and the core library were found. +``Libpci_VERSION`` + Detected version of found Libpci libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libpci_LIBRARY`` + Path to the library component of Libpci. +``Libpci_INCLUDE_DIR`` + Directory containing ``Libpci.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libpci QUIET libpci) +endif() + +find_path( + Libpci_INCLUDE_DIR + NAMES pci.h + HINTS ${PC_Libpci_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + PATH_SUFFIXES pci + DOC "Libpci include directory") + +find_library( + Libpci_LIBRARY + NAMES libpci pci + HINTS ${PC_Libpci_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libpci location") + +if(PC_Libpci_VERSION VERSION_GREATER 0) + set(Libpci_VERSION ${PC_Libpci_VERSION}) +elseif(EXISTS "${Libpci_INCLUDE_DIR}/config.h") + file(STRINGS "${Libpci_INCLUDE_DIR}/config.h" _VERSION_STRING REGEX "^.*PCILIB_VERSION[ \t]+\"[0-9\\.]+\"[ \t]*$") + string(REGEX REPLACE ".*PCILIB_VERSION[ \t]+\"([0-9\\.]+)\".*" "\\1" Libpci_VERSION "${_VERSION_STRING}") +else() + if(NOT Libpci_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libpci version.") + endif() + set(Libpci_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libpci + REQUIRED_VARS Libpci_LIBRARY Libpci_INCLUDE_DIR + VERSION_VAR Libpci_VERSION REASON_FAILURE_MESSAGE "Ensure that libpci is installed on the system.") +mark_as_advanced(Libpci_INCLUDE_DIR Libpci_LIBRARY) + +if(Libpci_FOUND) + if(NOT TARGET Libpci::pci) + if(IS_ABSOLUTE "${Libpci_LIBRARY}") + add_library(Libpci::pci UNKNOWN IMPORTED) + set_property(TARGET Libpci::pci PROPERTY IMPORTED_LOCATION "${Libpci_LIBRARY}") + else() + add_library(Libpci::pci INTERFACE IMPORTED) + set_property(TARGET Libpci::pci PROPERTY IMPORTED_LIBNAME "${Libpci_LIBRARY}") + endif() + + set_target_properties( + Libpci::pci + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libpci_CFLAFGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libpci_INCLUDE_DIR}" + VERSION ${Libpci_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libpci PROPERTIES + URL "https://mj.ucw.cz/sw/pciutils" + DESCRIPTION "Offers access to the PCI configuration space on a variety of operating systems.") diff --git a/cmake/finders/FindLibudev.cmake b/cmake/finders/FindLibudev.cmake new file mode 100644 index 000000000..5d7cc6601 --- /dev/null +++ b/cmake/finders/FindLibudev.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindLibudev +----------- + +FindModule for Libudev and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libudev::Libudev``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libudev_FOUND`` + True, if all required components and the core library were found. +``Libudev_VERSION`` + Detected version of found Libudev libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libudev_LIBRARY`` + Path to the library component of Libudev. +``Libudev_INCLUDE_DIR`` + Directory containing ``libudev.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libudev QUIET libudev) +endif() + +find_path( + Libudev_INCLUDE_DIR + NAMES libudev.h + HINTS ${PC_Libudev_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Libudev include directory") + +find_library( + Libudev_LIBRARY + NAMES udev libudev + HINTS ${PC_Libudev_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libudev location") + +if(PC_Libudev_VERSION VERSION_GREATER 0) + set(Libudev_VERSION ${PC_Libudev_VERSION}) +else() + if(NOT Libudev_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libudev version.") + endif() + set(Libudev_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libudev + REQUIRED_VARS Libudev_LIBRARY Libudev_INCLUDE_DIR + VERSION_VAR Libudev_VERSION REASON_FAILURE_MESSAGE "Ensure that Libudev is installed on the system.") +mark_as_advanced(Libudev_INCLUDE_DIR Libudev_LIBRARY) + +if(Libudev_FOUND) + if(NOT TARGET Libudev::Libudev) + if(IS_ABSOLUTE "${Libudev_LIBRARY}") + add_library(Libudev::Libudev UNKNOWN IMPORTED) + set_property(TARGET Libudev::Libudev PROPERTY IMPORTED_LOCATION "${Libudev_LIBRARY}") + else() + add_library(Libudev::Libudev INTERFACE IMPORTED) + set_property(TARGET Libudev::Libudev PROPERTY IMPORTED_LIBNAME "${Libudev_LIBRARY}") + endif() + + set_target_properties( + Libudev::Libudev + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libudev_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libudev_INCLUDE_DIR}" + VERSION ${Libudev_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libudev PROPERTIES + URL "https://www.freedesktop.org/wiki/Software/systemd/" + DESCRIPTION "API for enumerating and introspecting local devices.") diff --git a/cmake/finders/FindLibv4l2.cmake b/cmake/finders/FindLibv4l2.cmake new file mode 100644 index 000000000..45bf1a749 --- /dev/null +++ b/cmake/finders/FindLibv4l2.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindLibv4l2 +----------- + +FindModule for Libv4l2 and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Libv4l2::Libv4l2``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libv4l2_FOUND`` + True, if all required components and the core library were found. +``Libv4l2_VERSION`` + Detected version of found Libv4l2 libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libv4l2_LIBRARY`` + Path to the library component of Libv4l2. +``Libv4l2_INCLUDE_DIR`` + Directory containing ``libv4l2.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libv4l2 QUIET libv4l2 v4l2 v4l-utils) +endif() + +find_path( + Libv4l2_INCLUDE_DIR + NAMES libv4l2.h + HINTS ${PC_Libv4l2_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Libv4l2 include directory") + +find_library( + Libv4l2_LIBRARY + NAMES v4l2 + HINTS ${PC_Libv4l2_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libv4l2 location") + +if(PC_Libv4l2_VERSION VERSION_GREATER 0) + set(Libv4l2_VERSION ${PC_Libv4l2_VERSION}) +else() + if(NOT Libv4l2_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libv4l2 version.") + endif() + set(Libv4l2_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libv4l2 + REQUIRED_VARS Libv4l2_LIBRARY Libv4l2_INCLUDE_DIR + VERSION_VAR Libv4l2_VERSION REASON_FAILURE_MESSAGE "Ensure that v4l-utils is installed on the system.") +mark_as_advanced(Libv4l2_INCLUDE_DIR Libv4l2_LIBRARY) + +if(Libv4l2_FOUND) + if(NOT TARGET Libv4l2::Libv4l2) + if(IS_ABSOLUTE "${Libv4l2_LIBRARY}") + add_library(Libv4l2::Libv4l2 UNKNOWN IMPORTED) + set_property(TARGET Libv4l2::Libv4l2 PROPERTY IMPORTED_LOCATION "${Libv4l2_LIBRARY}") + else() + add_library(Libv4l2::Libv4l2 INTERFACE IMPORTED) + set_property(TARGET Libv4l2::Libv4l2 PROPERTY IMPORTED_LIBNAME "${Libv4l2_LIBRARY}") + endif() + + set_target_properties( + Libv4l2::Libv4l2 + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libv4l2_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libv4l2_INCLUDE_DIR}" + VERSION ${Libv4l2_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Lib4l2 PROPERTIES + URL "https://linuxtv.org/wiki/index.php/V4l-utils" + DESCRIPTION "The v4l-utils are a series of packages for handling media devices.") diff --git a/cmake/finders/FindLibva.cmake b/cmake/finders/FindLibva.cmake new file mode 100644 index 000000000..0ead897a8 --- /dev/null +++ b/cmake/finders/FindLibva.cmake @@ -0,0 +1,145 @@ +#[=======================================================================[.rst +FindLibva +--------- + +FindModule for Libva and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the following :prop_tgt:`IMPORTED` targets: + +``Libva::va`` + Video Acceleration (VA) API for Linux -- runtime + +``Libva::drm`` + Video Acceleration (VA) API for Linux -- DRM runtime + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Libva_FOUND`` + True, if all required components and the core library were found. +``Libva_VERSION`` + Detected version of found Libva libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Libva_LIBRARY`` + Path to the library component of Libva. +``Libva_INCLUDE_DIR`` + Directory containing ``libva.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Libva QUIET libva) + pkg_search_module(PC_LibvaDrm QUIET libva-drm) +endif() + +find_path( + Libva_INCLUDE_DIR + NAMES va.h + HINTS ${PC_Libva_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + PATH_SUFFIXES va + DOC "Libva include directory") + +find_library( + Libva_LIBRARY + NAMES libva va + HINTS ${PC_Libva_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libva location") + +find_library( + LibvaDrm_LIBRARY + NAMES libva-drm va-drm + HINTS ${PC_LibvaDrm_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Libva-drm location") + +if(PC_Libva_VERSION VERSION_GREATER 0) + set(Libva_VERSION ${PC_Libva_VERSION}) +elseif(EXISTS "${Libva_INCLUDE_DIR}/va_version.h") + file(STRINGS "${Libva_INCLUDE_DIR}/va_version.h" _VERSION_STRING + REGEX "^.*(MAJOR|MINOR|MICRO)_VERSION[ \t]+[0-9]+[ \t]*$") + string(REGEX REPLACE ".*MAJOR_VERSION[ \t]+([0-9]+).*" "\\1" VERSION_MAJOR "${_VERSION_STRING}") + string(REGEX REPLACE ".*MINOR_VERSION[ \t]+([0-9]+).*" "\\1" VERSION_MINOR "${_VERSION_STRING}") + string(REGEX REPLACE ".*MICRO_VERSION[ \t]+([0-9]+).*" "\\1" VERSION_MICRO "${_VERSION_STRING}") + + set(Libva_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}") +else() + if(NOT Libva_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Libva version.") + endif() + set(Libva_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Libva + REQUIRED_VARS Libva_LIBRARY Libva_INCLUDE_DIR + VERSION_VAR Libva_VERSION REASON_FAILURE_MESSAGE "Ensure that libva is installed on the system.") +mark_as_advanced(Libva_INCLUDE_DIR Libva_LIBRARY) + +if(Libva_FOUND) + if(NOT TARGET Libva::va) + if(IS_ABSOLUTE "${Libva_LIBRARY}") + add_library(Libva::va UNKNOWN IMPORTED) + set_property(TARGET Libva::va PROPERTY IMPORTED_LOCATION "${Libva_LIBRARY}") + else() + add_library(Libva::va INTERFACE IMPORTED) + set_property(TARGET Libva::va PROPERTY IMPORTED_LIBNAME "${Libva_LIBRARY}") + endif() + + set_target_properties( + Libva::va + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Libva_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libva_INCLUDE_DIR}" + VERSION ${Libva_VERSION}) + endif() + + if(LibvaDrm_LIBRARY) + if(NOT TARGET Libva::drm) + if(IS_ABSOLUTE "${LibvaDrm_LIBRARY}") + add_library(Libva::drm UNKNOWN IMPORTED) + set_property(TARGET Libva::drm PROPERTY IMPORTED_LOCATION "${LibvaDrm_LIBRARY}") + else() + add_library(Libva::drm INTERFACE IMPORTED) + set_property(TARGET Libva::drm PROPERTY IMPORTED_LIBNAME "${LibvaDrm_LIBRARY}") + endif() + + set_target_properties( + Libva::drm + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_LibvaDrm_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Libva_INCLUDE_DIR}" + VERSION ${Libva_VERSION}) + endif() + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Libva PROPERTIES + URL "https://01.org/intel-media-for-linux" + DESCRIPTION + "An implementation for VA-API (Video Acceleration API) - an open-source library which provides access to graphics hardware acceleration capabilities." +) diff --git a/cmake/finders/FindLibx264.cmake b/cmake/finders/FindLibx264.cmake index 123a32653..a09c3f0c8 100644 --- a/cmake/finders/FindLibx264.cmake +++ b/cmake/finders/FindLibx264.cmake @@ -107,8 +107,7 @@ if(PC_Libx264_VERSION VERSION_GREATER 0) set(Libx264_VERSION ${PC_Libx264_VERSION}) elseif(EXISTS "${Libx264_INCLUDE_DIR}/x264_config.h") file(STRINGS "${Libx264_INCLUDE_DIR}/x264_config.h" _VERSION_STRING REGEX "#define[ \t]+X264_POINTVER[ \t]+.+") - string(REGEX REPLACE ".*#define[ \t]+X264_POINTVER[ \t]+\"(.+)[ \t]+.+\".*" "\\1" Libx264_VERSION - "${_VERSION_STRING}") + string(REGEX REPLACE ".*#define[ \t]+X264_POINTVER[ \t]+\"([^ \t]+).*\".*" "\\1" Libx264_VERSION "${_VERSION_STRING}") else() if(NOT Libx264_FIND_QUIETLY) message(AUTHOR_WARNING "Failed to find Libx264 version.") diff --git a/cmake/finders/FindLuajit.cmake b/cmake/finders/FindLuajit.cmake index a329dddb3..28e4ff33c 100644 --- a/cmake/finders/FindLuajit.cmake +++ b/cmake/finders/FindLuajit.cmake @@ -79,14 +79,14 @@ find_path( NAMES lua.h luajit.h HINTS ${PC_Luajit_INCLUDE_DIRS} PATHS /usr/include /usr/local/include - PATH_SUFFIXES luajit-2.1 luajit + PATH_SUFFIXES luajit-2.1 luajit-2.0 luajit DOC "Luajit include directory") if(PC_Luajit_VERSION VERSION_GREATER 0) set(Luajit_VERSION ${PC_Luajit_VERSION}) -elseif(EXISTS "${Luajit_INCLUDE_DIR}/lua.h") - file(STRINGS "${Luajit_INCLUDE_DIR}/lua.h" _VERSION_STRING REGEX "#define[ \t]+LUA_RELEASE[ \t]+.+") - string(REGEX REPLACE ".*#define[ \t]+LUA_RELEASE[ \t]+\"Lua (.+)\".*" "\\1" Luajit_VERSION "${_VERSION_STRING}") +elseif(EXISTS "${Luajit_INCLUDE_DIR}/luajit.h") + file(STRINGS "${Luajit_INCLUDE_DIR}/luajit.h" _VERSION_STRING REGEX "#define[ \t]+LUAJIT_VERSION[ \t]+\".+\".*") + string(REGEX REPLACE ".*#define[ \t]+LUAJIT_VERSION[ \t]+\"LuaJIT (.+)\".*" "\\1" Luajit_VERSION "${_VERSION_STRING}") else() if(NOT Luajit_FIND_QUIETLY) message(AUTHOR_WARNING "Failed to find Luajit version.") diff --git a/cmake/finders/FindMbedTLS.cmake b/cmake/finders/FindMbedTLS.cmake index 272ff2b1b..0bec57d53 100644 --- a/cmake/finders/FindMbedTLS.cmake +++ b/cmake/finders/FindMbedTLS.cmake @@ -115,6 +115,11 @@ elseif(EXISTS "${MbedTLS_INCLUDE_DIR}/mbedtls/build_info.h") REGEX "#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+.+") string(REGEX REPLACE ".*#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+\"(.+)\".*" "\\1" MbedTLS_VERSION "${_VERSION_STRING}") +elseif(EXISTS "${MbedTLS_INCLUDE_DIR}/mbedtls/version.h") + file(STRINGS "${MbedTLS_INCLUDE_DIR}/mbedtls/version.h" _VERSION_STRING + REGEX "#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+.+") + string(REGEX REPLACE ".*#define[ \t]+MBEDTLS_VERSION_STRING[ \t]+\"(.+)\".*" "\\1" MbedTLS_VERSION + "${_VERSION_STRING}") else() if(NOT MbedTLS_FIND_QUIETLY) message(AUTHOR_WARNING "Failed to find MbedTLS version.") diff --git a/cmake/finders/FindOSS.cmake b/cmake/finders/FindOSS.cmake new file mode 100644 index 000000000..c32d51946 --- /dev/null +++ b/cmake/finders/FindOSS.cmake @@ -0,0 +1,64 @@ +#[=======================================================================[.rst +FindOSS +------- + +FindModule for OSS and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``OSS::OSS``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``OSS_FOUND`` + True, if all required components and the core library were found. +``OSS_VERSION`` + Detected version of found OSS libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``OSS_INCLUDE_DIR`` + Directory containing ``sys/soundcard.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_path( + OSS_INCLUDE_DIR + NAMES sys/soundcard.h + HINTS ${PC_OSS_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "OSS include directory") + +set(OSS_VERSION ${CMAKE_HOST_SYSTEM_VERSION}) + +find_package_handle_standard_args( + OSS + REQUIRED_VARS OSS_INCLUDE_DIR + VERSION_VAR OSS_VERSION REASON_FAILURE_MESSAGE "Ensure that OSS is installed on the system.") +mark_as_advanced(OSS_INCLUDE_DIR OSS_LIBRARY) + +if(OSS_FOUND) + if(NOT TARGET OSS::OSS) + add_library(OSS::OSS INTERFACE IMPORTED) + + set_target_properties(OSS::OSS PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${OSS_INCLUDE_DIR}" VERSION ${OSS_VERSION}) + endif() +endif() diff --git a/cmake/finders/FindPipeWire.cmake b/cmake/finders/FindPipeWire.cmake new file mode 100644 index 000000000..d7c225027 --- /dev/null +++ b/cmake/finders/FindPipeWire.cmake @@ -0,0 +1,122 @@ +#[=======================================================================[.rst +FindPipeWire +------------ + +FindModule for PipeWire and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``PipeWire::PipeWire``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``PipeWire_FOUND`` + True, if all required components and the core library were found. +``PipeWire_VERSION`` + Detected version of found PipeWire libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``PipeWire_LIBRARY`` + Path to the library component of PipeWire. +``PipeWire_INCLUDE_DIR`` + Directory containing ``PipeWire.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_PipeWire libpipewire-0.3 QUIET) + pkg_search_module(PC_Libspa libspa-0.2 QUIET) +endif() + +find_path( + PipeWire_INCLUDE_DIR + NAMES pipewire/pipewire.h + HINTS ${PC_PipeWire_INCLUDE_DIRS} + PATH_SUFFIXES pipewire-0.3 + PATHS /usr/include /usr/local/include + DOC "PipeWire include directory") + +find_path( + Libspa_INCLUDE_DIR + NAMES spa/param/props.h + HINTS ${PC_Libspa_INCLUDE_DIRS} + PATH_SUFFIXES spa-0.2 + PATHS /usr/include /usr/local/include + DOC "Libspa include directory") + +find_library( + PipeWire_LIBRARY + NAMES pipewire-0.3 + HINTS ${PC_PipeWire_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "PipeWire location") + +if(PC_PipeWire_VERSION VERSION_GREATER 0) + set(PipeWire_VERSION ${PC_PipeWire_VERSION}) +elseif(EXISTS "${PipeWire_INCLUDE_DIR}/pipewire/version.h") + file(STRINGS "${PipeWire_INCLUDE_DIR}/pipewire/version.h" _version_string + REGEX "^.*PW_(MAJOR|MINOR|MICRO)[ \t]+[0-9]+[ \t]*$") + string(REGEX REPLACE ".*PW_MAJOR[ \t]+([0-9]+).*" "\\1" _version_major "${_version_string}") + string(REGEX REPLACE ".*PW_MINOR[ \t]+([0-9]+).*" "\\1" _version_minor "${_version_string}") + string(REGEX REPLACE ".*PW_MICRO[ \t]+([0-9]+).*" "\\1" _version_micro "${_version_string}") + + set(PipeWire_VERSION "${_version_major}.${_version_minor}.${_version_micro}") + unset(_version_major) + unset(_version_minor) + unset(_version_micro) +else() + if(NOT PipeWire_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find PipeWire version.") + endif() + set(PipeWire_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + PipeWire + REQUIRED_VARS PipeWire_LIBRARY PipeWire_INCLUDE_DIR Libspa_INCLUDE_DIR + VERSION_VAR PipeWire_VERSION REASON_FAILURE_MESSAGE "Ensure that PipeWire is installed on the system.") +mark_as_advanced(PipeWire_LIBRARY PipeWire_INCLUDE_DIR) + +if(PipeWire_FOUND) + if(NOT TARGET PipeWire::PipeWire) + if(IS_ABSOLUTE "${PipeWire_LIBRARY}") + add_library(PipeWire::PipeWire UNKNOWN IMPORTED) + set_property(TARGET PipeWire::PipeWire PROPERTY IMPORTED_LOCATION "${PipeWire_LIBRARY}") + else() + add_library(PipeWire::PipeWire INTERFACE IMPORTED) + set_property(TARGET PipeWire::PipeWire PROPERTY IMPORTED_LIBNAME "${PipeWire_LIBRARY}") + endif() + + set_target_properties( + PipeWire::PipeWire + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_PipeWire_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${PipeWire_INCLUDE_DIR};${Libspa_INCLUDE_DIR}" + VERSION ${PipeWire_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + PipeWire PROPERTIES + URL "https://www.pipewire.org" + DESCRIPTION "PipeWire - multimedia processing") diff --git a/cmake/finders/FindPulseAudio.cmake b/cmake/finders/FindPulseAudio.cmake new file mode 100644 index 000000000..cbb035f6d --- /dev/null +++ b/cmake/finders/FindPulseAudio.cmake @@ -0,0 +1,108 @@ +#[=======================================================================[.rst +FindPulseAudio +-------------- + +FindModule for PulseAudio and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``PulseAudio::PulseAudio``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``PulseAudio_FOUND`` + True, if all required components and the core library were found. +``PulseAudio_VERSION`` + Detected version of found PulseAudio libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``PulseAudio_LIBRARY`` + Path to the library component of PulseAudio. +``PulseAudio_INCLUDE_DIR`` + Directory containing ``pulseaudio.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_PulseAudio QUIET libpulse) +endif() + +find_path( + PulseAudio_INCLUDE_DIR + NAMES pulse/pulseaudio.h + HINTS ${PC_PulseAudio_INCLUDE_DIRS} + PATHS /usr/include/ /usr/local/include + DOC "PulseAudio include directory") + +find_library( + PulseAudio_LIBRARY + NAMES pulse + HINTS ${PC_PulseAudio_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "PulseAudio location") + +if(PC_PulseAudio_VERSION VERSION_GREATER 0) + set(PulseAudio_VERSION ${PC_PulseAudio_VERSION}) +elseif(EXISTS "${PulseAudio_INCLUDE_DIR}/version.h") + file(STRINGS "${PulseAudio_INCLUDE_DIR}/version.h" _VERSION_STRING + REGEX "^.*pa_get_headers_version\\(\\)[\t ]+\\(\".*\"\\)[ \t]*$") + string(REGEX REPLACE ".*pa_get_headers_version\\(\\)[\t ]+\\(\"([^\"]*)\"\\).*" "\\1" PulseAudio_VERSION + "${_VERSION_STRING}") +else() + if(NOT PulseAudio_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find PulseAudio version.") + endif() + set(PulseAudio_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + PulseAudio + REQUIRED_VARS PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY + VERSION_VAR PulseAudio_VERSION REASON_FAILURE_MESSAGE "Ensure that PulseAudio is installed on the system.") +mark_as_advanced(PulseAudio_INCLUDE_DIR PulseAudio_LIBRARY) + +if(PulseAudio_FOUND) + if(NOT TARGET PulseAudio::PulseAudio) + if(IS_ABSOLUTE "${PulseAudio_LIBRARY}") + add_library(PulseAudio::PulseAudio UNKNOWN IMPORTED) + set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LOCATION "${PulseAudio_LIBRARY}") + else() + add_library(PulseAudio::PulseAudio INTERFACE IMPORTED) + set_property(TARGET PulseAudio::PulseAudio PROPERTY IMPORTED_LIBNAME "${PulseAudio_LIBRARY}") + endif() + + set_target_properties( + PulseAudio::PulseAudio + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_PulseAudio_CFLAFGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${PulseAudio_INCLUDE_DIR}" + VERSION ${PulseAudio_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + PulseAudio PROPERTIES + URL "https://www.freedesktop.org/wiki/Software/PulseAudio/" + DESCRIPTION + "PulseAudio is a sound server system for POSIX OSes, meaning that it is a proxy for your sound applications.") diff --git a/cmake/finders/FindSndio.cmake b/cmake/finders/FindSndio.cmake new file mode 100644 index 000000000..66702ba14 --- /dev/null +++ b/cmake/finders/FindSndio.cmake @@ -0,0 +1,101 @@ +#[=======================================================================[.rst +FindSndio +--------- + +FindModule for Sndio and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Sndio::Sndio``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Sndio_FOUND`` + True, if all required components and the core library were found. +``Sndio_VERSION`` + Detected version of found Sndio libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Sndio_LIBRARY`` + Path to the library component of Sndio. +``Sndio_INCLUDE_DIR`` + Directory containing ``sndio.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Sndio QUIET sndio) +endif() + +find_path( + Sndio_INCLUDE_DIR + NAMES sndio.h + HINTS ${PC_Sndio_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Sndio include directory") + +find_library( + Sndio_LIBRARY + NAMES sndio + HINTS ${PC_Sndio_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Sndio location") + +if(PC_Sndio_VERSION VERSION_GREATER 0) + set(Sndio_VERSION ${PC_Sndio_VERSION}) +else() + if(NOT Sndio_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Sndio version.") + endif() + set(Sndio_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Sndio + REQUIRED_VARS Sndio_LIBRARY Sndio_INCLUDE_DIR + VERSION_VAR Sndio_VERSION REASON_FAILURE_MESSAGE "Ensure that Sndio is installed on the system.") +mark_as_advanced(Sndio_INCLUDE_DIR Sndio_LIBRARY) + +if(Sndio_FOUND) + if(NOT TARGET Sndio::Sndio) + if(IS_ABSOLUTE "${Sndio_LIBRARY}") + add_library(Sndio::Sndio UNKNOWN IMPORTED) + set_property(TARGET Sndio::Sndio PROPERTY IMPORTED_LOCATION "${Sndio_LIBRARY}") + else() + add_library(Sndio::Sndio INTERFACE IMPORTED) + set_property(TARGET Sndio::Sndio PROPERTY IMPORTED_LIBNAME "${Sndio_LIBRARY}") + endif() + + set_target_properties( + Sndio::Sndio + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Sndio_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Sndio_INCLUDE_DIR}" + VERSION ${Sndio_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Sndio PROPERTIES + URL "https://www.sndio.org" + DESCRIPTION "Sndio is a small audio and MIDI framework part of the OpenBSD project and ported to FreeBSD.") diff --git a/cmake/finders/FindSysinfo.cmake b/cmake/finders/FindSysinfo.cmake new file mode 100644 index 000000000..a2c101cf1 --- /dev/null +++ b/cmake/finders/FindSysinfo.cmake @@ -0,0 +1,95 @@ +#[=======================================================================[.rst +FindSysinfo +----------- + +FindModule for Sysinfo and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``Sysinfo::Sysinfo``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Sysinfo_FOUND`` + True, if all required components and the core library were found. +``Sysinfo_VERSION`` + Detected version of found Sysinfo libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Sysinfo_LIBRARY`` + Path to the library component of Sysinfo. +``Sysinfo_INCLUDE_DIR`` + Directory containing ``sys/sysinfo.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Sysinfo QUIET sysinfo) +endif() + +find_path( + Sysinfo_INCLUDE_DIR + NAMES sys/sysinfo.h + HINTS ${PC_Sysinfo_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Sysinfo include directory") + +find_library( + Sysinfo_LIBRARY + NAMES sysinfo libsysinfo + HINTS ${PC_Sysinfo_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Sysinfo location") + +if(PC_Sysinfo_VERSION VERSION_GREATER 0) + set(Sysinfo_VERSION ${PC_Sysinfo_VERSION}) +else() + if(NOT Sysinfo_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Sysinfo version.") + endif() + set(Sysinfo_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Sysinfo + REQUIRED_VARS Sysinfo_LIBRARY Sysinfo_INCLUDE_DIR + VERSION_VAR Sysinfo_VERSION REASON_FAILURE_MESSAGE "Ensure that Sysinfo is installed on the system.") +mark_as_advanced(Sysinfo_INCLUDE_DIR Sysinfo_LIBRARY) + +if(Sysinfo_FOUND) + if(NOT TARGET Sysinfo::Sysinfo) + if(IS_ABSOLUTE "${Sysinfo_LIBRARY}") + add_library(Sysinfo::Sysinfo UNKNOWN IMPORTED) + set_property(TARGET Sysinfo::Sysinfo PROPERTY IMPORTED_LOCATION "${Sysinfo_LIBRARY}") + else() + add_library(Sysinfo::Sysinfo INTERFACE IMPORTED) + set_property(TARGET Sysinfo::Sysinfo PROPERTY IMPORTED_LIBNAME "${Sysinfo_LIBRARY}") + endif() + + set_target_properties( + Sysinfo::Sysinfo + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Sysinfo_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Sysinfo_INCLUDE_DIR}" + VERSION ${Sysinfo_VERSION}) + endif() +endif() diff --git a/cmake/finders/FindWayland.cmake b/cmake/finders/FindWayland.cmake new file mode 100644 index 000000000..ed43398c3 --- /dev/null +++ b/cmake/finders/FindWayland.cmake @@ -0,0 +1,177 @@ +#[=======================================================================[.rst +FindWayland +----------- + +FindModule for Wayland and and associated components + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Components +^^^^^^^^^^ + +.. versionadded:: 1.0 + +This module contains provides several components: + +``Client`` +``Server`` +``EGL`` +``Cursor`` + +Import targets exist for each component. + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``Wayland::Client`` + Wayland client component + +``Wayland::Server`` + Wayland server component + +``Wayland::EGL`` + Wayland EGL component + +``Wayland::Cursor`` + Wayland cursor component + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Wayland__FOUND`` + True, if required component was found. +``Wayland__VERSION`` + Detected version of Wayland component. +``Wayland__INCLUDE_DIRS`` + Include directories needed for Wayland component. +``Wayland__LIBRARIES`` + Libraries needed to link to Wayland component. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Wayland__LIBRARY`` + Path to the component of Wayland. +``Wayland__INCLUDE_DIR`` + Directory containing ``.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) + +list(APPEND _Wayland_DEFAULT_COMPONENTS Client Server EGL Cursor) +list(APPEND _Wayland_LIBRARIES wayland-client wayland-server wayland-egl wayland-cursor) + +if(NOT Wayland_FIND_COMPONENTS) + set(Wayland_FIND_COMPONENTS ${_Wayland_DEFAULT_COMPONENTS}) +endif() + +# Wayland_find_component: Macro to setup targets for specified Wayland component +macro(Wayland_find_component component) + list(GET _Wayland_DEFAULT_COMPONENTS ${component} COMPONENT_NAME) + list(GET _Wayland_LIBRARIES ${component} COMPONENT_LIBRARY) + + if(NOT TARGET Wayland::${COMPONENT_NAME}) + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Wayland_${COMPONENT_NAME} QUIET ${COMPONENT_LIBRARY}) + endif() + + find_path( + Wayland_${COMPONENT_NAME}_INCLUDE_DIR + NAMES ${COMPONENT_LIBRARY}.h + HINTS ${PC_Wayland_${COMPONENT_NAME}_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "Wayland ${COMPONENT_NAME} include directory") + + find_library( + Wayland_${COMPONENT_NAME}_LIBRARY + NAMES ${COMPONENT_LIBRARY} + HINTS ${PC_Wayland_${COMPONENT_NAME}_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "Wayland ${COMPONENT_NAME} location") + + if(PC_Wayland_${COMPONENT_NAME}_VERSION VERSION_GREATER 0) + set(Wayland_${COMPONENT_NAME}_VERSION ${PC_Wayland_${COMPONENT_NAME}_VERSION}) + else() + if(NOT Wayland_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find Wayland ${COMPONENT_NAME} version.") + endif() + set(Wayland_${COMPONENT_NAME}_VERSION 0.0.0) + endif() + + if(Wayland_${COMPONENT_NAME}_LIBRARY AND Wayland_${COMPONENT_NAME}_INCLUDE_DIR) + set(Wayland_${COMPONENT_NAME}_FOUND TRUE) + set(Wayland_${COMPONENT_NAME}_LIBRARIES ${Wayland_${COMPONENT_NAME}_LIBRARY}) + set(Wayland_${COMPONENT_NAME}_INCLUDE_DIRS ${Wayland_${COMPONENT_NAME}_INCLUDE_DIR}) + set(Wayland_${COMPONENT_NAME}_DEFINITIONS ${PC_Wayland_${COMPONENT_NAME}_CFLAGS_OTHER}) + mark_as_advanced(Wayland_${COMPONENT_NAME}_LIBRARY Wayland_${COMPONENT_NAME}_INCLUDE_DIR) + + if(IS_ABSOLUTE "${Wayland_${COMPONENT_NAME}_LIBRARY}") + add_library(Wayland::${COMPONENT_NAME} UNKNOWN IMPORTED) + set_property(TARGET Wayland::${COMPONENT_NAME} PROPERTY IMPORTED_LOCATION + "${Wayland_${COMPONENT_NAME}_LIBRARY}") + else() + add_library(Wayland::${COMPONENT_NAME} INTERFACE IMPORTED) + set_property(TARGET Wayland::${COMPONENT_NAME} PROPERTY IMPORTED_LIBNAME "${Wayland_${COMPONENT_NAME}_LIBRARY}") + endif() + + set_target_properties( + Wayland::${COMPONENT_NAME} + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Wayland_${COMPONENT_NAME}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Wayland_${COMPONENT_NAME}_INCLUDE_DIR}" + VERSION ${Wayland_${COMPONENT_NAME}_VERSION}) + list(APPEND Wayland_COMPONENTS Wayland::${COMPONENT_NAME}) + list(APPEND Wayland_INCLUDE_DIRS ${Wayland_${COMPONENT_NAME}_INCLUDE_DIR}) + list(APPEND Wayland_LIBRARIES ${Wayland_${COMPONENT_NAME}_LIBRARY}) + + if(NOT Wayland_VERSION) + set(Wayland_VERSION ${Wayland_${COMPONENT_NAME}_VERSION}) + endif() + endif() + else() + list(APPEND Wayland_COMPONENTS Wayland::${COMPONENT_NAME}) + endif() +endmacro() + +foreach(component IN LISTS Wayland_FIND_COMPONENTS) + list(FIND _Wayland_DEFAULT_COMPONENTS "${component}" valid_component) + + if(valid_component GREATER_EQUAL 0) + wayland_find_component(${valid_component}) + else() + message(FATAL_ERROR "Unknown Wayland component required: ${component}.") + endif() +endforeach() + +find_package_handle_standard_args( + Wayland + REQUIRED_VARS Wayland_LIBRARIES Wayland_INCLUDE_DIRS + VERSION_VAR Wayland_VERSION + HANDLE_COMPONENTS REASON_FAILURE_MESSAGE "Ensure that Wayland is installed on the system.") + +unset(_Wayland_DEFAULT_COMPONENTS) +unset(_Wayland_LIBRARIES) + +include(FeatureSummary) +set_package_properties( + Wayland PROPERTIES + URL "https://wayland.freedesktop.org" + DESCRIPTION + "A replacement for the X11 window system protocol and architecture with the aim to be easier to develop, extend, and maintain." +) diff --git a/cmake/finders/FindX11-xcb.cmake b/cmake/finders/FindX11-xcb.cmake new file mode 100644 index 000000000..3d7281f9f --- /dev/null +++ b/cmake/finders/FindX11-xcb.cmake @@ -0,0 +1,104 @@ +#[=======================================================================[.rst +FindX11-xcb +----------- + +FindModule for x11-xcb and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``X11::x11-xcb``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``X11-xcb_FOUND`` + True, if all required components and the core library were found. +``X11-xcb_VERSION`` + Detected version of found x11-xcb libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``X11-xcb_LIBRARY`` + Path to the library component of x11-xcb. +``X11-xcb_INCLUDE_DIR`` + Directory containing ``Xlib-xcb.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_X11-xcb QUIET x11-xcb) +endif() + +find_path( + X11-xcb_INCLUDE_DIR + NAMES X11/Xlib-xcb.h + HINTS ${PC_X11-xcb_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "X11-xcb include directory") + +find_library( + X11-xcb_LIBRARY + NAMES X11-xcb + HINTS ${PC_x11-xcb-LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "X11-xcb location") + +if(PC_X11-xcb_VERSION VERSION_GREATER 0) + set(X11-xcb_VERSION ${PC_X11-xcb_VERSION}) +else() + if(NOT X11-xcb_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find X11-xcb version.") + endif() + set(X11-xcb_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + X11-xcb + REQUIRED_VARS X11-xcb_LIBRARY X11-xcb_INCLUDE_DIR + VERSION_VAR X11-xcb_VERSION REASON_FAILURE_MESSAGE "Ensure that X11-xcb is installed on the system.") +mark_as_advanced(X11-xcb_INCLUDE_DIR X11-xcb_LIBRARY) + +if(X11-xcb_FOUND) + if(NOT TARGET X11::x11-xcb) + if(IS_ABSOLUTE "${X11-xcb_LIBRARY}") + add_library(X11::x11-xcb UNKNOWN IMPORTED) + set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LOCATION "${X11-xcb_LIBRARY}") + else() + add_library(X11::x11-xcb INTERFACE IMPORTED) + set_property(TARGET X11::x11-xcb PROPERTY IMPORTED_LIBNAME "${X11-xcb_LIBRARY}") + endif() + + set_target_properties( + X11::x11-xcb + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_X11-xcb_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${X11-xcb_INCLUDE_DIR}" + VERSION ${X11-xcb_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + X11-xcb PROPERTIES + URL "https://www.X.org" + DESCRIPTION + "Provides functions needed by clients which take advantage of Xlib/XCB to mix calls to both Xlib and XCB over the same X connection." +) diff --git a/cmake/finders/FindXcb.cmake b/cmake/finders/FindXcb.cmake new file mode 100644 index 000000000..979471c02 --- /dev/null +++ b/cmake/finders/FindXcb.cmake @@ -0,0 +1,302 @@ +#[=======================================================================[.rst +FindXcb +------- + +FindModule for XCB and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Components +^^^^^^^^^^ + +.. versionadded:: 1.0 + +This module contains provides several components: + +``xcb-xcb`` +``xcb-composite`` +``xcb-damage`` +``xcb-dri2,`` +``xcb-ewmh`` +``xcb-glx`` +``xcb-icccm`` +``xcb-image`` +``xcb-keysyms +``xcb-randr`` +``xcb-render`` +``xcb-renderutil`` +``xcb-shape`` +``xcb-shm`` +``xcb-sync`` +``xcb-util +``xcb-xfixes`` +``xcb-xtest`` +``xcb-xv`` +``xcb-xinput`` +``xcb-xinerama`` + +Import targets exist for each component. + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` targets: + +``xcb::xcb`` + xcb component + +``xcb::xcb-composite`` + xcb-composite component + +``xcb::xcb-damage`` + xcb-damage component + +``xcb::xcb-dri2`` + xcb-dri2 component + +``xcb::xcb-ewmh`` + xcb-ewmh component + +``xcb::xcb-glx`` + xcb-glx component + +``xcb::xcb-icccm`` + xcb-icccm component + +``xcb::xcb-image`` + xcb-image component + +``xcb::xcb-keysyms`` + xcb-keysyms component + +``xcb::xcb-randr`` + xcb-randr component + +``xcb::xcb-render`` + xcb-render component + +``xcb::xcb-renderutil`` + xcb-renderutil component + +``xcb::xcb-shape`` + xcb-shape component + +``xcb::xcb-shm`` + xcb-shm component + +``xcb::xcb-sync`` + xcb-sync component + +``xcb::xcb-util`` + xcb-util component + +``xcb::xcb-xfixes`` + xcb-xfixes component + +``xcb::xcb-xtest`` + xcb-xtest component + +``xcb::xcb-xv`` + xcb-xv component + +``xcb::xcb-xinput`` + xcb-xinput component + +``xcb::xcb-xinerema`` + xcb-xinerema component + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Xcb__FOUND`` + True, if required component was found. +``Xcb__VERSION`` + Detected version of found XCB component library. +``Xcb__INCLUDE_DIRS`` + Include directories needed for XCB component. +``Xcb__LIBRARIES`` + Libraries needed to link to XCB component. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Xcb__LIBRARY`` + Path to the library component of XCB. +``Xcb__INCLUDE_DIR`` + Directory containing ``.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-lint: disable=R0915 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) + +list( + APPEND + _Xcb_DEFAULT_COMPONENTS + xcb + xcb-composite + xcb-damage + xcb-dri2, + xcb-ewmh + xcb-glx + xcb-icccm + xcb-image + xcb-keysyms + xcb-randr + xcb-render + xcb-renderutil + xcb-shape + xcb-shm + xcb-sync + xcb-util + xcb-xfixes + xcb-xtest + xcb-xv + xcb-xinput + xcb-xinerama) +list( + APPEND + _Xcb_HEADERS + xcb.h + composite.h + damage.h + dri2h.h + xcb_ewmh.h + glx.h + xcb_icccm.h + xcb_image.h + xcb_keysyms.h + randr.h + render.h + xcb_renderutil.h + shape.h + shm.h + sync.h + xcb_util.h + xfixes.h + xtest.h + xv.h + xinput.h + xinerama.h) + +if(NOT Xcb_FIND_COMPONENTS) + set(Xcb_FIND_COMPONENTS ${_Xcb_DEFAULT_COMPONENTS}) +endif() + +# Xcb_find_component: Find and create targets for specified xcb component +macro(Xcb_find_component component) + list(GET _Xcb_DEFAULT_COMPONENTS ${component} COMPONENT_NAME) + list(GET _Xcb_HEADERS ${component} COMPONENT_HEADER) + + if(NOT TARGET xcb::${COMPONENT_NAME}) + if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Xcb_${COMPONENT_NAME} QUIET ${COMPONENT_NAME}) + endif() + + find_path( + Xcb_${COMPONENT_NAME}_INCLUDE_DIR + NAMES "xcb/${COMPONENT_HEADER}" + HINTS ${PC_Xcb_${COMPONENT_NAME}_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + DOC "XCB component ${COMPONENT_NAME} include directory") + + find_library( + Xcb_${COMPONENT_NAME}_LIBRARY + NAMES "${COMPONENT_NAME}" + HINTS ${PC_Xcb_${COMPONENT_NAME}_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "XCB component ${COMPONENT_NAME} location") + + if(PC_Xcb_${COMPONENT_NAME}_VERSION VERSION_GREATER 0) + set(Xcb_${COMPONENT_NAME}_VERSION ${PC_Xcb_${COMPONENT_NAME}_VERSION}) + else() + if(NOT Xcb_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find ${COMPONENT_NAME} version.") + endif() + set(Xcb_${COMPONENT_NAME}_VERSION 0.0.0) + endif() + + if(Xcb_${COMPONENT_NAME}_LIBRARY AND Xcb_${COMPONENT_NAME}_INCLUDE_DIR) + set(Xcb_${COMPONENT_NAME}_FOUND TRUE) + set(Xcb_${COMPONENT_NAME}_LIBRARIES ${Xcb_${COMPONENT_NAME}_LIBRARY}) + set(Xcb_${COMPONENT_NAME}_INCLUDE_DIRS ${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}) + set(Xcb_${COMPONENT_NAME}_DEFINITIONS ${PC_Xcb_${COMPONENT_NAME}_CFLAGS_OTHER}) + mark_as_advanced(Xcb_${COMPONENT_NAME}_LIBRARY Xcb_${COMPONENT_NAME}_INCLUDE_DIR) + + if(IS_ABSOLUTE "${Xcb_${COMPONENT_NAME}_LIBRARY}") + add_library(xcb::${COMPONENT_NAME} UNKNOWN IMPORTED) + set_property(TARGET xcb::${COMPONENT_NAME} PROPERTY IMPORTED_LOCATION "${Xcb_${COMPONENT_NAME}_LIBRARY}") + else() + add_library(xcb::${COMPONENT_NAME} INTERFACE IMPORTED) + set_property(TARGET xcb::${COMPONENT_NAME} PROPERTY IMPORTED_LIBNAME "${Xcb_${COMPONENT_NAME}_LIBRARY}") + endif() + + set_target_properties( + xcb::${COMPONENT_NAME} + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Xcb_${COMPONENT_NAME}_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}" + VERSION ${Xcb_${COMPONENT_NAME}_VERSION}) + list(APPEND Xcb_COMPONENTS xcb::${COMPONENT_NAME}) + list(APPEND Xcb_LIBRARIES ${Xcb_${COMPONENT_NAME}_LIBRARY}) + list(APPEND Xcb_INCLUDE_DIRS ${Xcb_${COMPONENT_NAME}_INCLUDE_DIR}) + if(NOT Xcb_VERSION) + set(Xcb_VERSION ${Xcb_${COMPONENT_NAME}_VERSION}) + endif() + endif() + else() + list(APPEND Xcb_COMPONENTS xcb::${COMPONENT_NAME}) + set(Xcb_${COMPONENT_NAME}_FOUND TRUE) + get_target_property(component_location xcb::${COMPONENT_NAME} IMPORTED_LOCATION) + if(NOT component_location) + get_target_property(component_location xcb::${COMPONENT_NAME} IMPORTED_LIBNAME) + endif() + get_target_property(component_include_dir xcb::${COMPONENT_NAME} INTERFACE_INCLUDE_DIRECTORIES) + list(APPEND Xcb_LIBRARIES ${component_location}) + list(APPEND Xcb_INCLUDE_DIRS ${component_include_dir}) + unset(component_location) + unset(component_include_dir) + endif() +endmacro() + +foreach(component IN LISTS Xcb_FIND_COMPONENTS) + list(FIND _Xcb_DEFAULT_COMPONENTS "${component}" valid_component) + + if(valid_component GREATER_EQUAL 0) + xcb_find_component(${valid_component}) + else() + message(FATAL_ERROR "Unknown XCB component required: ${component}.") + endif() +endforeach() + +list(REMOVE_DUPLICATES Xcb_INCLUDE_DIRS) + +find_package_handle_standard_args( + Xcb + REQUIRED_VARS Xcb_LIBRARIES Xcb_INCLUDE_DIRS + VERSION_VAR Xcb_VERSION + HANDLE_COMPONENTS REASON_FAILURE_MESSAGE "Ensure xcb is installed on the system.") + +unset(_Xcb_DEFAULT_COMPONENTS) +unset(_Xcb_HEADERS) + +include(FeatureSummary) +set_package_properties( + Xcb PROPERTIES + URL "https://xcb.freedesktop.org" + DESCRIPTION + "A replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility." +) diff --git a/cmake/finders/FindXkbcommon.cmake b/cmake/finders/FindXkbcommon.cmake new file mode 100644 index 000000000..1071c4ec8 --- /dev/null +++ b/cmake/finders/FindXkbcommon.cmake @@ -0,0 +1,105 @@ +#[=======================================================================[.rst +FindXkbcommon +------------- + +FindModule for xkbcommon and associated libraries + +.. versionchanged:: 3.0 + Updated FindModule to CMake standards + +Imported Targets +^^^^^^^^^^^^^^^^ + +.. versionadded:: 2.0 + +This module defines the :prop_tgt:`IMPORTED` target ``xkbcommon::xkbcommon``. + +Result Variables +^^^^^^^^^^^^^^^^ + +This module sets the following variables: + +``Xkbcommon_FOUND`` + True, if all required components and the core library were found. +``Xkbcommon_VERSION`` + Detected version of found xkbcommon libraries. + +Cache variables +^^^^^^^^^^^^^^^ + +The following cache variables may also be set: + +``Xkbcommon_LIBRARY`` + Path to the library component of xkbcommon. +``Xkbcommon_INCLUDE_DIR`` + Directory containing ``xkbcommon.h``. + +#]=======================================================================] + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-lint: disable=C0301 +# cmake-format: on + +include(FindPackageHandleStandardArgs) + +find_package(PkgConfig QUIET) +if(PKG_CONFIG_FOUND) + pkg_search_module(PC_Xkbcommon QUIET xkbcommon) +endif() + +find_path( + Xkbcommon_INCLUDE_DIR + NAMES xkbcommon/xkbcommon.h + HINTS ${PC_Xkbcommon_INCLUDE_DIRS} + PATHS /usr/include /usr/local/include + PATH_SUFFIXES xkbcommon + DOC "xkbcommon include directory") + +find_library( + Xkbcommon_LIBRARY + NAMES xkbcommon libxkbcommon + HINTS ${PC_Xkbcommon_LIBRARY_DIRS} + PATHS /usr/lib /usr/local/lib + DOC "xkbcommon location") + +if(PC_Xkbcommon_VERSION VERSION_GREATER 0) + set(Xkbcommon_VERSION ${PC_Xkbcommon_VERSION}) +else() + if(NOT Xkbcommon_FIND_QUIETLY) + message(AUTHOR_WARNING "Failed to find xkbcommon version.") + endif() + set(Xkbcommon_VERSION 0.0.0) +endif() + +find_package_handle_standard_args( + Xkbcommon + REQUIRED_VARS Xkbcommon_LIBRARY Xkbcommon_INCLUDE_DIR + VERSION_VAR Xkbcommon_VERSION REASON_FAILURE_MESSAGE "Ensure that xkbcommon is installed on the system.") +mark_as_advanced(Xkbcommon_INCLUDE_DIR Xkbcommon_LIBRARY) + +if(Xkbcommon_FOUND) + if(NOT TARGET xkbcommon::xkbcommon) + if(IS_ABSOLUTE "${Xkbcommon_LIBRARY}") + add_library(xkbcommon::xkbcommon UNKNOWN IMPORTED) + set_property(TARGET xkbcommon::xkbcommon PROPERTY IMPORTED_LOCATION "${Xkbcommon_LIBRARY}") + else() + add_library(xkbcommon::xkbcommon INTERFACE IMPORTED) + set_property(TARGET xkbcommon::xkbcommon PROPERTY IMPORTED_LIBNAME "${Xkbcommon_LIBRARY}") + endif() + + set_target_properties( + xkbcommon::xkbcommon + PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_Xkbcommon_CFLAGS_OTHER}" + INTERFACE_INCLUDE_DIRECTORIES "${Xkbcommon_INCLUDE_DIR}" + VERSION ${Xkbcommon_VERSION}) + endif() +endif() + +include(FeatureSummary) +set_package_properties( + Xkbcommon PROPERTIES + URL "https://www.xkbcommon.org" + DESCRIPTION + "A library for handling of keyboard descriptions, including loading them from disk, parsing them and handling their state." +) diff --git a/cmake/linux/compilerconfig.cmake b/cmake/linux/compilerconfig.cmake new file mode 100644 index 000000000..bc218df37 --- /dev/null +++ b/cmake/linux/compilerconfig.cmake @@ -0,0 +1,90 @@ +# OBS CMake Linux compiler configuration module + +include_guard(GLOBAL) + +include(ccache) +include(compiler_common) + +option(ENABLE_COMPILER_TRACE "Enable Clang time-trace (requires Clang and Ninja)" OFF) +mark_as_advanced(ENABLE_COMPILER_TRACE) + +# gcc options for C +set(_obs_gcc_c_options + # cmake-format: sortable + $<$:-Wno-error=deprecated-declarations> + -fno-strict-aliasing + -fopenmp-simd + -Wdeprecated-declarations + -Wempty-body + -Wenum-conversion + -Werror=return-type + -Wextra + -Wformat + -Wformat-security + -Wno-conversion + -Wno-float-conversion + -Wno-implicit-fallthrough + -Wno-missing-braces + -Wno-missing-field-initializers + -Wno-shadow + -Wno-sign-conversion + -Wno-trigraphs + -Wno-unknown-pragmas + -Wno-unused-function + -Wno-unused-label + -Wparentheses + -Wuninitialized + -Wunreachable-code + -Wunused-parameter + -Wunused-value + -Wunused-variable + -Wvla) + +add_compile_options( + -fopenmp-simd + "$<$:${_obs_gcc_c_options}>" + "$<$:-Wint-conversion;-Wno-missing-prototypes;-Wno-strict-prototypes;-Wpointer-sign>" + "$<$:${_obs_gcc_c_options}>" + "$<$:-Winvalid-offsetof;-Wno-overloaded-virtual>" + "$<$:${_obs_clang_c_options}>" + "$<$:${_obs_clang_cxx_options}>") + +# Add support for color diagnostics and CMake switch for warnings as errors to CMake < 3.24 +if(CMAKE_VERSION VERSION_LESS 3.24.0) + add_compile_options($<$:-fcolor-diagnostics> + $<$:-fcolor-diagnostics>) + if(CMAKE_COMPILE_WARNING_AS_ERROR) + add_compile_options(-Werror) + endif() +else() + set(CMAKE_COLOR_DIAGNOSTICS ON) +endif() + +if(CMAKE_CXX_COMPILER_ID STREQUAL GNU) + # * Disable false-positive warning in GCC 12.1.0 and later + # * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105562 + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1.0) + add_compile_options(-Wno-error=maybe-uninitialized) + endif() + + # * Add warning for infinite recursion (added in GCC 12) + # * Also disable warnings for stringop-overflow due to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106297 + if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.0.0) + add_compile_options(-Winfinite-recursion -Wno-stringop-overflow) + endif() + + if(CMAKE_SYSTEM_PROCESSOR STREQUAL aarch64) + add_compile_options(-Wno-error=type-limits) + endif() +endif() + +# Enable compiler and build tracing (requires Ninja generator) +if(ENABLE_COMPILER_TRACE AND CMAKE_GENERATOR STREQUAL "Ninja") + add_compile_options($<$:-ftime-trace> $<$:-ftime-trace>) +else() + set(ENABLE_COMPILER_TRACE + OFF + CACHE STRING "Enable Clang time-trace (required Clang and Ninja)" FORCE) +endif() + +add_compile_definitions($<$:DEBUG> $<$:_DEBUG> SIMDE_ENABLE_OPENMP) diff --git a/cmake/linux/cpackconfig.cmake b/cmake/linux/cpackconfig.cmake new file mode 100644 index 000000000..6a45f8346 --- /dev/null +++ b/cmake/linux/cpackconfig.cmake @@ -0,0 +1,69 @@ +# OBS CMake Linux CPack configuration module + +# cmake-format: off +# cmake-lint: disable=C0103 +# cmake-format: on + +include_guard(GLOBAL) + +include(cpackconfig_common) + +# Add GPLv2 license file to CPack +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/UI/data/license/gplv2.txt") +set(CPACK_PACKAGE_EXECUTABLES "obs") + +if(ENABLE_RELEASE_BUILD) + set(CPACK_PACKAGE_VERSION "${OBS_VERSION_CANONICAL}") +else() + set(CPACK_PACKAGE_VERSION "${OBS_VERSION}") +endif() + +set(CPACK_SOURCE_PACKAGE_FILE_NAME "obs-studio-${CPACK_PACKAGE_VERSION}-sources") +set(CPACK_SOURCE_GENERATOR "TGZ") +set(CPACK_SOURCE_IGNORE_FILES "/.git" "/.*build.*" "/.ccache" "/.deps") +set(CPACK_ARCHIVE_THREADS 0) + +if(OS_LINUX) + set(CPACK_GENERATOR "DEB") + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE) + set(CPACK_SET_DESTDIR TRUE) + set(CPACK_DEBIAN_DEBUGINFO_PACKAGE TRUE) + set(CPACK_DEBIAN_PACKAGE_MAINTAINER "${OBS_COMPANY_NAME}") +elseif(OS_FREEBSD) + set(CPACK_GENERATOR "FREEBSD") + + set(CPACK_FREEBSD_PACKAGE_MAINTAINER "${OBS_COMPANY_NAME}") + set(CPACK_FREEBSD_PACKAGE_LICENSE "GPLv2") + + set(CPACK_FREEBSD_PACKAGE_DEPS + # cmake-format: sortable + "audio/alsa-lib" + "audio/fdk-aac" + "audio/jack" + "audio/pulseaudio" + "audio/sndio" + "devel/jansson" + "devel/libpci" + "devel/libsysinfo" + "devel/nlohmann-json" + "devel/qt6-base" + "devel/qt6-svg" + "devel/swig" + "devel/websocketpp" + "ftp/curl" + "graphics/mesa-libs" + "graphics/qr-code-generator" + "lang/luajit" + "lang/python39" + "misc/e2fsprogs-libuuid" + "multimedia/ffmpeg" + "multimedia/librist" + "multimedia/pipewire" + "multimedia/v4l_compat" + "multimedia/vlc" + "net/asio" + "www/libdatachannel" + "www/srt") +endif() + +include(CPack) diff --git a/cmake/linux/defaults.cmake b/cmake/linux/defaults.cmake new file mode 100644 index 000000000..a495f0198 --- /dev/null +++ b/cmake/linux/defaults.cmake @@ -0,0 +1,41 @@ +# OBS CMake Linux defaults module + +include_guard(GLOBAL) + +option(ENABLE_PULSEAUDIO "Enable PulseAudio support" ON) +option(ENABLE_WAYLAND "Enable building with support for Wayland" ON) + +option(ENABLE_RELOCATABLE "Enable relocatable build" OFF) + +# Set default installation directories +include(GNUInstallDirs) + +if(CMAKE_INSTALL_LIBDIR MATCHES "(CMAKE_SYSTEM_PROCESSOR)") + string(REPLACE "CMAKE_SYSTEM_PROCESSOR" "${CMAKE_SYSTEM_PROCESSOR}" CMAKE_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}") +endif() + +if(ENABLE_RELOCATABLE) + set(OBS_EXECUTABLE_RPATH "$ORIGIN/;$ORIGIN/../${CMAKE_INSTALL_LIBDIR}") + set(OBS_LIBRARY_RPATH "$ORIGIN/") + set(OBS_MODULE_RPATH "$ORIGIN/;$ORIGIN/..") +endif() + +set(OBS_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/rundir") +set(OBS_EXECUTABLE_DESTINATION "${CMAKE_INSTALL_BINDIR}") +set(OBS_INCLUDE_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/obs") +set(OBS_LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}") +set(OBS_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-plugins") +set(OBS_SCRIPT_PLUGIN_DESTINATION "${CMAKE_INSTALL_LIBDIR}/obs-scripting") +set(OBS_DATA_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/obs") +set(OBS_CMAKE_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake") + +# Set additional paths used by OBS for self-discovery +set(OBS_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-plugins") +set(OBS_SCRIPT_PLUGIN_PATH "${CMAKE_INSTALL_LIBDIR}/obs-scripting") +set(OBS_DATA_PATH "${OBS_DATA_DESTINATION}") +set(OBS_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") + +# Enable find_package targets to become globally available targets +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) + +include(cpackconfig) diff --git a/cmake/linux/helpers.cmake b/cmake/linux/helpers.cmake new file mode 100644 index 000000000..01c3402c7 --- /dev/null +++ b/cmake/linux/helpers.cmake @@ -0,0 +1,291 @@ +# OBS CMake Linux helper functions module + +# cmake-format: off +# cmake-lint: disable=C0301 +# cmake-format: on + +include_guard(GLOBAL) + +include(helpers_common) + +# set_target_properties_obs: Set target properties for use in obs-studio +function(set_target_properties_obs target) + set(options "") + set(oneValueArgs "") + set(multiValueArgs PROPERTIES) + cmake_parse_arguments(PARSE_ARGV 0 _STPO "${options}" "${oneValueArgs}" "${multiValueArgs}") + + message(DEBUG "Setting additional properties for target ${target}...") + + while(_STPO_PROPERTIES) + list(POP_FRONT _STPO_PROPERTIES key value) + set_property(TARGET ${target} PROPERTY ${key} "${value}") + endwhile() + + get_target_property(target_type ${target} TYPE) + + if(target_type STREQUAL EXECUTABLE) + install(TARGETS ${target} RUNTIME DESTINATION "${OBS_EXECUTABLE_DESTINATION}" COMPONENT Runtime) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_EXECUTABLE_DESTINATION}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" + "${OBS_OUTPUT_DIR}/$/${OBS_EXECUTABLE_DESTINATION}" + COMMENT "Copy ${target} to binary directory" + VERBATIM) + + if(target STREQUAL obs-studio) + get_property(obs_executables GLOBAL PROPERTY _OBS_EXECUTABLES) + get_property(obs_modules GLOBAL PROPERTY OBS_MODULES_ENABLED) + add_dependencies(${target} ${obs_executables} ${obs_modules}) + + target_add_resource(${target} "${CMAKE_CURRENT_SOURCE_DIR}/../AUTHORS" + "${OBS_DATA_DESTINATION}/obs-studio/authors") + elseif(target STREQUAL browser-helper) + set_property(GLOBAL APPEND PROPERTY _OBS_EXECUTABLES ${target}) + return() + else() + set_property(GLOBAL APPEND PROPERTY _OBS_EXECUTABLES ${target}) + endif() + + set_target_properties(${target} PROPERTIES BUILD_RPATH "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + INSTALL_RPATH "${OBS_EXECUTABLE_RPATH}") + elseif(target_type STREQUAL SHARED_LIBRARY) + set_target_properties( + ${target} + PROPERTIES VERSION ${OBS_VERSION_MAJOR} + SOVERSION ${OBS_VERSION_CANONICAL} + BUILD_RPATH "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + INSTALL_RPATH "${OBS_LIBRARY_RPATH}") + + install( + TARGETS ${target} + LIBRARY DESTINATION "${OBS_LIBRARY_DESTINATION}" COMPONENT Runtime + PUBLIC_HEADER + DESTINATION "${OBS_INCLUDE_DESTINATION}" + COMPONENT Development + EXCLUDE_FROM_ALL) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" + "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}/" + COMMENT "Copy ${target} to library directory (${OBS_LIBRARY_DESTINATION})" + VERBATIM) + + if(target STREQUAL libobs OR target STREQUAL obs-frontend-api) + install( + FILES "$/$$.so.0" + DESTINATION "${OBS_LIBRARY_DESTINATION}") + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND + "${CMAKE_COMMAND}" -E create_symlink + "$$.so.${OBS_VERSION_MAJOR}" + "$$.so.0" + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different + "$/$$.so.0" + "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + COMMENT "Create symlink for legacy ${target}") + endif() + + elseif(target_type STREQUAL MODULE_LIBRARY) + if(target STREQUAL obs-browser) + set_target_properties(${target} PROPERTIES VERSION 0 SOVERSION ${OBS_VERSION_CANONICAL}) + else() + set_target_properties( + ${target} + PROPERTIES VERSION 0 + SOVERSION ${OBS_VERSION_CANONICAL} + BUILD_RPATH "${OBS_OUTPUT_DIR}/$/${OBS_LIBRARY_DESTINATION}" + INSTALL_RPATH "${OBS_MODULE_RPATH}") + endif() + + if(${target} STREQUAL obspython OR ${target} STREQUAL obslua) + set(plugin_destination "${OBS_SCRIPT_PLUGIN_DESTINATION}") + set_property(TARGET ${target} PROPERTY INSTALL_RPATH "$ORIGIN/;$ORIGIN/..") + else() + set(plugin_destination "${OBS_PLUGIN_DESTINATION}") + endif() + + install( + TARGETS ${target} + LIBRARY DESTINATION "${plugin_destination}" + COMPONENT Runtime + NAMELINK_COMPONENT Development) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${plugin_destination}" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" + "${OBS_OUTPUT_DIR}/$/${plugin_destination}" + COMMENT "Copy ${target} to plugin directory (${plugin_destination})" + VERBATIM) + + if(${target} STREQUAL obspython) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_SCRIPT_PLUGIN_DESTINATION}/" + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$/obspython.py" + "${OBS_OUTPUT_DIR}/$/${OBS_SCRIPT_PLUGIN_DESTINATION}/" + COMMENT "Add obspython import module") + + install( + FILES "$/obspython.py" + DESTINATION "${OBS_SCRIPT_PLUGIN_DESTINATION}" + COMPONENT Runtime) + elseif(${target} STREQUAL obs-browser) + message(DEBUG "Add Chromium Embedded Framework to project for obs-browser plugin...") + if(TARGET CEF::Library) + get_target_property(imported_location CEF::Library IMPORTED_LOCATION_RELEASE) + + if(imported_location) + cmake_path(GET imported_location PARENT_PATH cef_location) + cmake_path(GET cef_location PARENT_PATH cef_root_location) + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/" + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different "${imported_location}" "${cef_location}/chrome-sandbox" + "${cef_location}/libEGL.so" "${cef_location}/libGLESv2.so" "${cef_location}/libvk_swiftshader.so" + "${cef_location}/libvulkan.so.1" "${cef_location}/snapshot_blob.bin" + "${cef_location}/v8_context_snapshot.bin" "${cef_location}/vk_swiftshader_icd.json" + "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/" + COMMAND + "${CMAKE_COMMAND}" -E copy_if_different "${cef_root_location}/Resources/chrome_100_percent.pak" + "${cef_root_location}/Resources/chrome_200_percent.pak" "${cef_root_location}/Resources/icudtl.dat" + "${cef_root_location}/Resources/resources.pak" "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${cef_root_location}/Resources/locales" + "${OBS_OUTPUT_DIR}/$/${OBS_PLUGIN_DESTINATION}/locales" + COMMENT "Add Chromium Embedded Framwork to library directory") + + install( + FILES "${imported_location}" + "${cef_location}/chrome-sandbox" + "${cef_location}/libEGL.so" + "${cef_location}/libGLESv2.so" + "${cef_location}/libvk_swiftshader.so" + "${cef_location}/libvulkan.so.1" + "${cef_location}/snapshot_blob.bin" + "${cef_location}/v8_context_snapshot.bin" + "${cef_location}/vk_swiftshader_icd.json" + "${cef_root_location}/Resources/chrome_100_percent.pak" + "${cef_root_location}/Resources/chrome_200_percent.pak" + "${cef_root_location}/Resources/icudtl.dat" + "${cef_root_location}/Resources/resources.pak" + DESTINATION "${OBS_PLUGIN_DESTINATION}" + COMPONENT Runtime) + + install( + DIRECTORY "${cef_root_location}/Resources/locales" + DESTINATION "${OBS_PLUGIN_DESTINATION}" + USE_SOURCE_PERMISSIONS + COMPONENT Runtime) + endif() + endif() + endif() + + set_property(GLOBAL APPEND PROPERTY OBS_MODULES_ENABLED ${target}) + endif() + + target_install_resources(${target}) +endfunction() + +# Helper function to add resources into bundle +function(target_install_resources target) + message(DEBUG "Installing resources for target ${target}...") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/data") + file(GLOB_RECURSE data_files "${CMAKE_CURRENT_SOURCE_DIR}/data/*") + foreach(data_file IN LISTS data_files) + cmake_path(RELATIVE_PATH data_file BASE_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" OUTPUT_VARIABLE + relative_path) + cmake_path(GET relative_path PARENT_PATH relative_path) + target_sources(${target} PRIVATE "${data_file}") + source_group("Resources/${relative_path}" FILES "${data_file}") + endforeach() + + get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED) + if(target IN_LIST obs_module_list) + set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}") + elseif(target STREQUAL obs) + set(target_destination "${OBS_DATA_DESTINATION}/obs-studio") + else() + set(target_destination "${OBS_DATA_DESTINATION}/${target}") + endif() + + install( + DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/data/" + DESTINATION "${target_destination}" + USE_SOURCE_PERMISSIONS + COMPONENT Runtime) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${target_destination}" + COMMAND "${CMAKE_COMMAND}" -E copy_directory "${CMAKE_CURRENT_SOURCE_DIR}/data" + "${OBS_OUTPUT_DIR}/$/${target_destination}" + COMMENT "Copy ${target} resources to data directory (${target_destination})" + VERBATIM) + endif() +endfunction() + +# Helper function to add a specific resource to a bundle +function(target_add_resource target resource) + get_property(obs_module_list GLOBAL PROPERTY OBS_MODULES_ENABLED) + if(${ARGN}) + set(target_destination "${ARGN}") + elseif(${target} IN_LIST obs_module_list) + set(target_destination "${OBS_DATA_DESTINATION}/obs-plugins/${target}") + elseif(target STREQUAL obs) + set(target_destination "${OBS_DATA_DESTINATION}/obs-studio") + else() + set(target_destination "${OBS_DATA_DESTINATION}/${target}") + endif() + + message(DEBUG "Add resource ${resource} to target ${target} at destination ${target_destination}...") + + install( + FILES "${resource}" + DESTINATION "${target_destination}" + COMPONENT Runtime) + + add_custom_command( + TARGET ${target} + POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E make_directory "${OBS_OUTPUT_DIR}/$/${target_destination}/" + COMMAND "${CMAKE_COMMAND}" -E copy "${resource}" "${OBS_OUTPUT_DIR}/$/${target_destination}/" + COMMENT "Copy ${target} resource ${resource} to library directory (${target_destination})" + VERBATIM) +endfunction() + +# target_export: Helper function to export target as CMake package +function(target_export target) + set(exclude_variant "") + _target_export(${target}) + + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux/${target}.pc.in") + message(DEBUG "Generating pkgconfig file ${target}.pc.in...") + + install(CODE "set(OBS_VERSION_CANONICAL ${OBS_VERSION_CANONICAL})" COMPONENT Development) + install(CODE "set(CMAKE_C_STANDARD ${CMAKE_C_STANDARD})" COMPONENT Development) + install( + CODE "configure_file(\"${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux/${target}.pc.in\" \"${CMAKE_CURRENT_BINARY_DIR}/${target}.pc\" @ONLY)" + COMPONENT Development) + + install( + FILES "${CMAKE_CURRENT_BINARY_DIR}/${target}.pc" + DESTINATION "${OBS_LIBRARY_DESTINATION}/pkgconfig" + COMPONENT Development) + endif() +endfunction() diff --git a/cmake/linux/toolchain-aarch64-clang.cmake b/cmake/linux/toolchain-aarch64-clang.cmake new file mode 100644 index 000000000..3e25fcf77 --- /dev/null +++ b/cmake/linux/toolchain-aarch64-clang.cmake @@ -0,0 +1,11 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm64) + +set(CMAKE_C_COMPILER clang) +set(CMAKE_C_COMPILER_TARGET aarch64-linux-gnu) + +set(CMAKE_CXX_COMPILER clang++) +set(CMAKE_CXX_COMPILER_TARGET aarch64-linux-gnu) + +set(CMAKE_ASM_COMPILER clang) +set(CMAKE_ASM_COMPILER_TARGET aarch64-linux-gnu) diff --git a/cmake/linux/toolchain-aarch64-gcc.cmake b/cmake/linux/toolchain-aarch64-gcc.cmake new file mode 100644 index 000000000..2a2df085a --- /dev/null +++ b/cmake/linux/toolchain-aarch64-gcc.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR arm64) + +if(CROSS STREQUAL "") + set(CROSS aarch64-linux-gnu-) +endif() + +if(NOT CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER ${CROSS}gcc) +endif() + +if(NOT CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER ${CROSS}g++) +endif() + +if(NOT CMAKE_ASM_COMPILER) + set(CMAKE_ASM_COMPILER ${CROSS}as) +endif() diff --git a/cmake/linux/toolchain-x86_64-gcc.cmake b/cmake/linux/toolchain-x86_64-gcc.cmake new file mode 100644 index 000000000..39e6c8471 --- /dev/null +++ b/cmake/linux/toolchain-x86_64-gcc.cmake @@ -0,0 +1,18 @@ +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_PROCESSOR x86_64) + +if(CROSS STREQUAL "") + set(CROSS x86_64-linux-gnu-) +endif() + +if(NOT CMAKE_C_COMPILER) + set(CMAKE_C_COMPILER ${CROSS}gcc) +endif() + +if(NOT CMAKE_CXX_COMPILER) + set(CMAKE_CXX_COMPILER ${CROSS}g++) +endif() + +if(NOT CMAKE_ASM_COMPILER) + set(CMAKE_ASM_COMPILER ${CROSS}as) +endif()