aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2024-05-06 18:27:08 +1000
committerfuzzard <fuzzard@kodi.tv>2024-05-07 10:00:27 +1000
commita550d6098904a63b5f21e26f296538820e38cb54 (patch)
tree72d5f96a450556576a4c50c691cefa4a3002b128
parentc2d154f620fa3a0ff7bf861672d98e3bdf1db1e2 (diff)
downloadxbmc-a550d6098904a63b5f21e26f296538820e38cb54.tar.xz
[cmake][modules] Introduce FindEffects11 find module
A module to enable locating and building the effects11 lib
-rw-r--r--cmake/modules/FindEffects11.cmake121
-rw-r--r--tools/depends/target/effects11/01-win-debugpostfix.patch11
-rw-r--r--tools/depends/target/effects11/EFFECTS11-VERSION5
3 files changed, 137 insertions, 0 deletions
diff --git a/cmake/modules/FindEffects11.cmake b/cmake/modules/FindEffects11.cmake
new file mode 100644
index 0000000000..0f4e4afaa8
--- /dev/null
+++ b/cmake/modules/FindEffects11.cmake
@@ -0,0 +1,121 @@
+# FindEffects11
+# -------
+# Finds the Effects11 library
+#
+# This will define the following target:
+#
+# windows::Effects11 - The Effects11 library
+
+if(NOT TARGET windows::Effects11)
+ include(cmake/scripts/common/ModuleHelpers.cmake)
+
+ macro(buildEffects11)
+
+ set(patches "${CMAKE_SOURCE_DIR}/tools/depends/target/${MODULE_LC}/01-win-debugpostfix.patch")
+ generate_patchcommand("${patches}")
+
+ # Effects 11 cant be built using /permissive-
+ # strip and manually set the rest of the build flags
+ string(REPLACE "/permissive-" "" EFFECTS_CXX_FLAGS ${CMAKE_CXX_FLAGS} )
+
+ set(CMAKE_ARGS
+ "-DCMAKE_CXX_FLAGS=${EFFECTS_CXX_FLAGS} $<$<CONFIG:Debug>:${CMAKE_CXX_FLAGS_DEBUG}> $<$<CONFIG:Release>:${CMAKE_CXX_FLAGS_RELEASE}>"
+ "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} $<$<CONFIG:Debug>:${CMAKE_EXE_LINKER_FLAGS_DEBUG}> $<$<CONFIG:Release>:${CMAKE_EXE_LINKER_FLAGS_RELEASE}>")
+
+ set(EFFECTS11_DEBUG_POSTFIX d)
+ set(WIN_DISABLE_PROJECT_FLAGS ON)
+
+ BUILD_DEP_TARGET()
+
+ set(EFFECTS11_VERSION ${${MODULE}_VER})
+
+ # Make INCLUDE_DIR match cmake config output
+ string(APPEND EFFECTS11_INCLUDE_DIR "/Effects11")
+ file(MAKE_DIRECTORY ${EFFECTS11_INCLUDE_DIR})
+ endmacro()
+
+ set(MODULE_LC effects11)
+
+ SETUP_BUILD_VARS()
+
+ find_package(effects11 CONFIG QUIET
+ HINTS ${DEPENDS_PATH}/share
+ ${${CORE_PLATFORM_NAME_LC}_SEARCH_CONFIG})
+
+ if(effects11_VERSION VERSION_LESS ${${MODULE}_VER})
+ buildEffects11()
+ else()
+ get_target_property(_EFFECTS_CONFIGURATIONS Microsoft::Effects11 IMPORTED_CONFIGURATIONS)
+ foreach(_effects_config IN LISTS _EFFECTS_CONFIGURATIONS)
+ # Some non standard config (eg None on Debian)
+ # Just set to RELEASE var so select_library_configurations can continue to work its magic
+ string(TOUPPER ${_effects_config} _effects_config_UPPER)
+ if((NOT ${_effects_config_UPPER} STREQUAL "RELEASE") AND
+ (NOT ${_effects_config_UPPER} STREQUAL "DEBUG"))
+ get_target_property(EFFECTS11_LIBRARY_RELEASE Microsoft::Effects11 IMPORTED_LOCATION_${_effects_config_UPPER})
+ else()
+ get_target_property(EFFECTS11_LIBRARY_${_effects_config_UPPER} Microsoft::Effects11 IMPORTED_LOCATION_${_effects_config_UPPER})
+ endif()
+ endforeach()
+
+ get_target_property(EFFECTS11_INCLUDE_DIR Microsoft::Effects11 INTERFACE_INCLUDE_DIRECTORIES)
+ set(EFFECTS11_VERSION ${effects11_VERSION})
+ endif()
+
+ include(SelectLibraryConfigurations)
+ select_library_configurations(EFFECTS11)
+ unset(EFFECTS11_LIBRARIES)
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(Effects11
+ REQUIRED_VARS EFFECTS11_LIBRARY EFFECTS11_INCLUDE_DIR
+ VERSION_VAR EFFECTS11_VERSION)
+
+ if(Effects11_FOUND)
+
+ if(TARGET Microsoft::Effects11 AND NOT TARGET effects11)
+ add_library(windows::Effects11 ALIAS Microsoft::Effects11)
+ else()
+ add_library(windows::Effects11 UNKNOWN IMPORTED)
+ set_target_properties(windows::Effects11 PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${EFFECTS11_INCLUDE_DIR}")
+
+ if(EFFECTS11_LIBRARY_RELEASE)
+ set_target_properties(windows::Effects11 PROPERTIES
+ IMPORTED_CONFIGURATIONS RELEASE
+ IMPORTED_LOCATION_RELEASE "${EFFECTS11_LIBRARY_RELEASE}")
+ endif()
+ if(EFFECTS11_LIBRARY_DEBUG)
+ set_target_properties(windows::Effects11 PROPERTIES
+ IMPORTED_CONFIGURATIONS DEBUG
+ IMPORTED_LOCATION_DEBUG "${EFFECTS11_LIBRARY_DEBUG}")
+ endif()
+ endif()
+
+ if(TARGET effects11)
+ add_dependencies(windows::Effects11 effects11)
+ endif()
+
+ # Add internal build target when a Multi Config Generator is used
+ # We cant add a dependency based off a generator expression for targeted build types,
+ # https://gitlab.kitware.com/cmake/cmake/-/issues/19467
+ # therefore if the find heuristics only find the library, we add the internal build
+ # target to the project to allow user to manually trigger for any build type they need
+ # in case only a specific build type is actually available (eg Release found, Debug Required)
+ # This is mainly targeted for windows who required different runtime libs for different
+ # types, and they arent compatible
+ if(_multiconfig_generator)
+ if(NOT TARGET effects11)
+ buildEffects11()
+ set_target_properties(effects11 PROPERTIES EXCLUDE_FROM_ALL TRUE)
+ endif()
+ add_dependencies(build_internal_depends effects11)
+ endif()
+
+ set_property(GLOBAL APPEND PROPERTY INTERNAL_DEPS_PROP windows::Effects11)
+ else()
+ if(Effects11_FIND_REQUIRED)
+ message(FATAL_ERROR "Could NOT find or build Effects11 library.")
+ endif()
+ endif()
+endif()
diff --git a/tools/depends/target/effects11/01-win-debugpostfix.patch b/tools/depends/target/effects11/01-win-debugpostfix.patch
new file mode 100644
index 0000000000..b10d6e96fe
--- /dev/null
+++ b/tools/depends/target/effects11/01-win-debugpostfix.patch
@@ -0,0 +1,11 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -22,6 +22,8 @@
+ set(CMAKE_CXX_STANDARD_REQUIRED ON)
+ set(CMAKE_CXX_EXTENSIONS OFF)
+
++set(CMAKE_DEBUG_POSTFIX d)
++
+ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
+ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
+ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/CMake")
diff --git a/tools/depends/target/effects11/EFFECTS11-VERSION b/tools/depends/target/effects11/EFFECTS11-VERSION
new file mode 100644
index 0000000000..a20e4907a3
--- /dev/null
+++ b/tools/depends/target/effects11/EFFECTS11-VERSION
@@ -0,0 +1,5 @@
+LIBNAME=FX11
+VERSION=11.29
+ARCHIVE=$(LIBNAME)-jun2023.tar.gz
+SHA512=93a90b42efbc8e1e9cb76de80c959bc24406536af9d943d21e324a82be677d695c201deb995490e331ecfcda301d8b42285b90577fbed9acd5bb61c753efd66c
+BYPRODUCT_WIN=effects11.lib