4 # Finds the TexturePacker
6 # If WITH_TEXTUREPACKER is defined and points to a directory,
7 # this path will be used to search for the Texturepacker binary
10 # This will define the following (imported) targets::
12 # TexturePacker::TexturePacker::Executable - The TexturePacker executable participating in build
13 # TexturePacker::TexturePacker::Installable - The TexturePacker executable shipped in the Kodi package
15 if(NOT TARGET TexturePacker::TexturePacker::Executable)
17 get_filename_component(_tppath "${NATIVEPREFIX}/bin" ABSOLUTE)
18 find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker" TexturePacker
21 add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
22 set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
23 IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
24 message(STATUS "External TexturePacker for KODI_DEPENDSBUILD will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
26 get_filename_component(_tppath "${DEPENDS_PATH}/tools/TexturePacker" ABSOLUTE)
27 find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker.exe" TexturePacker.exe
30 add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
31 set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
32 IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
33 message(STATUS "External TexturePacker for WIN32 will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
35 if(WITH_TEXTUREPACKER)
36 get_filename_component(_tppath ${WITH_TEXTUREPACKER} ABSOLUTE)
37 get_filename_component(_tppath ${_tppath} DIRECTORY)
38 find_program(TEXTUREPACKER_EXECUTABLE NAMES "${APP_NAME_LC}-TexturePacker" TexturePacker
41 # Use external TexturePacker executable if found
42 if(TEXTUREPACKER_EXECUTABLE)
43 add_executable(TexturePacker::TexturePacker::Executable IMPORTED GLOBAL)
44 set_target_properties(TexturePacker::TexturePacker::Executable PROPERTIES
45 IMPORTED_LOCATION "${TEXTUREPACKER_EXECUTABLE}")
46 message(STATUS "Found external TexturePacker: ${TEXTUREPACKER_EXECUTABLE}")
48 # Warn about external TexturePacker supplied but not fail fatally
49 # because we might have internal TexturePacker executable built
50 # and unset TEXTUREPACKER_EXECUTABLE variable
51 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!")
55 # Ship TexturePacker only on Linux and FreeBSD
56 if(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_SYSTEM_NAME STREQUAL "Linux")
57 # But skip shipping it if build architecture can be executed on host
58 # and TEXTUREPACKER_EXECUTABLE is found
59 if(NOT (HOST_CAN_EXECUTE_TARGET AND TEXTUREPACKER_EXECUTABLE))
60 set(INTERNAL_TEXTUREPACKER_INSTALLABLE TRUE CACHE BOOL "" FORCE)
64 # Use it during build if build architecture can be executed on host
65 # and TEXTUREPACKER_EXECUTABLE is not found
66 if(HOST_CAN_EXECUTE_TARGET AND NOT TEXTUREPACKER_EXECUTABLE)
67 set(INTERNAL_TEXTUREPACKER_EXECUTABLE TRUE)
70 # Build and install internal TexturePacker if needed
71 if (INTERNAL_TEXTUREPACKER_EXECUTABLE OR INTERNAL_TEXTUREPACKER_INSTALLABLE)
72 add_subdirectory(${CMAKE_SOURCE_DIR}/tools/depends/native/TexturePacker build/texturepacker)
73 message(STATUS "Building internal TexturePacker")
76 if(INTERNAL_TEXTUREPACKER_INSTALLABLE)
77 add_executable(TexturePacker::TexturePacker::Installable ALIAS TexturePacker)
78 message(STATUS "Shipping internal TexturePacker")
81 if(INTERNAL_TEXTUREPACKER_EXECUTABLE)
82 add_executable(TexturePacker::TexturePacker::Executable ALIAS TexturePacker)
83 message(STATUS "Internal TexturePacker will be executed during build")
85 message(STATUS "External TexturePacker will be executed during build: ${TEXTUREPACKER_EXECUTABLE}")
87 include(FindPackageHandleStandardArgs)
88 find_package_handle_standard_args(TexturePacker DEFAULT_MSG TEXTUREPACKER_EXECUTABLE)
91 mark_as_advanced(INTERNAL_TEXTUREPACKER_EXECUTABLE INTERNAL_TEXTUREPACKER_INSTALLABLE TEXTUREPACKER)