Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / VSWinStorePhone / VerifyAppPackage.cmake
1 set(APP_PKG_NAME Direct3DApp1)
2
3 # List of files that are expected to be present in the generated app package
4 set(EXPECTED_APP_PKG_CONTENT
5   ${APP_PKG_NAME}.exe
6   CxxDll.dll
7   JusticeLeagueWinRT.winmd
8   JusticeLeagueWinRT.dll
9 )
10
11 # Windows app package formats can be either msix, appx or xap
12 file(GLOB_RECURSE ALL_APP_PKG_FILES ${APP_PACKAGE_DIR} ${APP_PKG_NAME}*.msix ${APP_PKG_NAME}*.appx ${APP_PKG_NAME}*.xap)
13
14 # There can be only one generated app package
15 list(LENGTH ALL_APP_PKG_FILES APP_PKG_COUNT)
16 if(NOT APP_PKG_COUNT EQUAL 1)
17   message(FATAL_ERROR "Expected 1 generated app package, but detected ${APP_PKG_COUNT}: ${ALL_APP_PKG_FILES}")
18 endif()
19
20 execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf ${ALL_APP_PKG_FILES}
21   OUTPUT_VARIABLE APP_PKG_CONTENT_OUTPUT
22   ERROR_VARIABLE error
23   RESULT_VARIABLE result)
24
25 if(NOT result EQUAL 0)
26   message(FATAL_ERROR "Listing app package content failed with: ${error}")
27 endif()
28
29 foreach(app_pkg_item IN LISTS EXPECTED_APP_PKG_CONTENT)
30   string(FIND ${APP_PKG_CONTENT_OUTPUT} ${app_pkg_item} _found)
31   if(_found EQUAL -1)
32     message(FATAL_ERROR "Generated app package is missing an expected item: ${app_pkg_item}")
33   endif()
34 endforeach()