aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules
diff options
context:
space:
mode:
authorVasyl Gello <vasek.gello@gmail.com>2021-10-31 14:32:56 +0000
committerVasyl Gello <vasek.gello@gmail.com>2021-11-03 15:51:23 +0000
commite864302e870b75dd34a2c4d0dc217f4b920fb30e (patch)
treebd263d632355a70bc1dcb559b968c6214a4c855b /cmake/modules
parent105de4bf4872c95229c3d605bc83ce61707af58c (diff)
Split TexturePacker executed during build and shipped
Before this commit, shippable TexturePacker is not built at all if: * the pre-built TexturePacker is supplied by -DWITH_TEXTUREPACKER * build is KODI_DEPENDSBUILD * building for Windows This breaks generation of kodi-tools-texturepacker package on Linux and FreeBSD if cross-compiling. The new commit separates installable and executable TexturePackers. Executable TexturePacker is executed on all platforms, but it can be overriden by a binary specified by KODI_DEPENDSBUILD or WITH_TEXTUREPACKER options on non-depends build. Installable TexturePacker is shipped only on Linux and FreeBSD platforms, and is executed only if the build is not a cross-compilation and the executable TexturePacker not overridden by one of the options above. If external TexturePacker is specified WITH_TEXTUREPACKER but its executable file can not be found, a warning is raised and the module falls back to build internal TexturePacker if it can be executed during the build. Signed-off-by: Vasyl Gello <vasek.gello@gmail.com>
Diffstat (limited to 'cmake/modules')
-rw-r--r--cmake/modules/FindTexturePacker.cmake75
1 files changed, 56 insertions, 19 deletions
diff --git a/cmake/modules/FindTexturePacker.cmake b/cmake/modules/FindTexturePacker.cmake
index 5284d72887..173b74d0ff 100644
--- a/cmake/modules/FindTexturePacker.cmake
+++ b/cmake/modules/FindTexturePacker.cmake
@@ -9,44 +9,81 @@
#
# This will define the following (imported) targets::
#
-# TexturePacker::TexturePacker - The TexturePacker executable
+# TexturePacker::TexturePacker::Executable - The TexturePacker executable participating in build
+# TexturePacker::TexturePacker::Installable - The TexturePacker executable shipped in the Kodi package
-if(NOT TARGET TexturePacker::TexturePacker)
+if(NOT TARGET TexturePacker::TexturePacker::Executable)
if(KODI_DEPENDSBUILD)
get_filename_component(_tppath "${NATIVEPREFIX}/bin" ABSOLUTE)
find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker" TexturePacker
HINTS ${_tppath})
- add_executable(TexturePacker::TexturePacker IMPORTED GLOBAL)
- set_target_properties(TexturePacker::TexturePacker PROPERTIES
- IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
+ set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
+ IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ message(STATUS "External TexturePacker for KODI_DEPENDSBUILD will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
elseif(WIN32)
get_filename_component(_tppath "${DEPENDENCIES_DIR}/tools/TexturePacker" ABSOLUTE)
find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker.exe" TexturePacker.exe
HINTS ${_tppath})
- add_executable(TexturePacker::TexturePacker IMPORTED GLOBAL)
- set_target_properties(TexturePacker::TexturePacker PROPERTIES
- IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
+ set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
+ IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ message(STATUS "External TexturePacker for WIN32 will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
else()
if(WITH_TEXTUREPACKER)
get_filename_component(_tppath ${WITH_TEXTUREPACKER} ABSOLUTE)
get_filename_component(_tppath ${_tppath} DIRECTORY)
find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker" TexturePacker
- HINTS ${_tppath})
+ HINTS ${_tppath})
- include(FindPackageHandleStandardArgs)
- find_package_handle_standard_args(TexturePacker "Could not find '${APP_NAME_LC}-TexturePacker' or 'TexturePacker' executable in ${_tppath} supplied by -DWITH_TEXTUREPACKER. Make sure the executable file name matches these names!"
- TEXTUREPACKER_EXECUTABLE)
- if(TEXTUREPACKER_FOUND)
- add_executable(TexturePacker::TexturePacker IMPORTED GLOBAL)
- set_target_properties(TexturePacker::TexturePacker PROPERTIES
- IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ # Use external TexturePacker executable if found
+ if(TEXTUREPACKER_EXECUTABLE)
+ add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
+ set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
+ IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
+ message(STATUS "Found external TexturePacker: ${TEXTUREPACKER_EXECUTABLE}")
+ else()
+ # Warn about external TexturePacker supplied but not fail fatally
+ # because we might have internal TexturePacker executable built
+ # and unset TEXTUREPACKER_EXECUTABLE variable
+ message(WARNING "Could not find '${APP_NAME_LC}-TexturePacker' or 'TexturePacker' executable in ${_tppath} supplied by -DWITH_TEXTUREPACKER. Make sure the executable file name matches these names!")
endif()
- mark_as_advanced(TEXTUREPACKER)
- else()
+ endif()
+
+ # Ship TexturePacker only on Linux and FreeBSD
+ if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(INTERNAL_TEXTUREPACKER_INSTALLABLE TRUE)
+ endif()
+
+ # Use it during build if build architecture is same as host
+ # (not cross-compiling) and TEXTUREPACKER_EXECUTABLE is not found
+ if(CORE_HOST_IS_TARGET AND NOT TEXTUREPACKER_EXECUTABLE)
+ set(INTERNAL_TEXTUREPACKER_EXECUTABLE TRUE)
+ endif()
+
+ # Build and install internal TexturePacker if needed
+ if (INTERNAL_TEXTUREPACKER_EXECUTABLE OR INTERNAL_TEXTUREPACKER_INSTALLABLE)
add_subdirectory(${CMAKE_SOURCE_DIR}/tools/depends/native/TexturePacker build/texturepacker)
- add_executable(TexturePacker::TexturePacker ALIAS TexturePacker)
+ message(STATUS "Building internal TexturePacker")
endif()
+
+ if(INTERNAL_TEXTUREPACKER_INSTALLABLE)
+ add_executable(TexturePacker::TexturePacker::Installable ALIAS TexturePacker)
+ message(STATUS "Shipping internal TexturePacker")
+ endif()
+
+ if(INTERNAL_TEXTUREPACKER_EXECUTABLE)
+ add_executable(TexturePacker::TexturePacker::Executable ALIAS TexturePacker)
+ message(STATUS "Internal TexturePacker will be executed during build")
+ else()
+ message(STATUS "External TexturePacker will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
+
+ include(FindPackageHandleStandardArgs)
+ find_package_handle_standard_args(TexturePacker DEFAULT_MSG TEXTUREPACKER_EXECUTABLE)
+ endif()
+
+ mark_as_advanced(INTERNAL_TEXTUREPACKER_EXECUTABLE INTERNAL_TEXTUREPACKER_INSTALLABLE TEXTUREPACKER)
endif()
endif()