diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 771f5db686..428ec8be1a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1009,6 +1009,32 @@ if(BUILD_TESTING) "${CMake_BINARY_DIR}/Tests/CPackNSISGenerator/_CPack_Packages/win32/NSIS/NSISOutput.log") endif() + find_program(IFW_BINARYCREATOR_EXECUTABLE NAMES binarycreator + DOC "IFW binarycreator program location" + ) + + if(IFW_BINARYCREATOR_EXECUTABLE) + add_test(CPackIFWGenerator ${CMAKE_CTEST_COMMAND} + -C \${CTEST_CONFIGURATION_TYPE} + --build-and-test + "${CMake_SOURCE_DIR}/Tests/CPackIFWGenerator" + "${CMake_BINARY_DIR}/Tests/CPackIFWGenerator" + ${build_generator_args} + --build-project CPackIFWGenerator + --build-options + --test-command ${CMAKE_CMAKE_COMMAND} + "-DCPackIFWGenerator_BINARY_DIR:PATH=${CMake_BINARY_DIR}/Tests/CPackIFWGenerator" + "-Dconfig=\${CTEST_CONFIGURATION_TYPE}" + -P "${CMake_SOURCE_DIR}/Tests/CPackIFWGenerator/RunCPackVerifyResult.cmake") + + set_property(TEST CPackIFWGenerator PROPERTY + ATTACHED_FILES_ON_FAIL + "${CMake_BINARY_DIR}/Tests/CPackIFWGenerator/_CPack_Packages/Linux/IFW/IFWOutput.log" + "${CMake_BINARY_DIR}/Tests/CPackIFWGenerator/_CPack_Packages/Darwin/IFW/IFWOutput.log" + "${CMake_BINARY_DIR}/Tests/CPackIFWGenerator/_CPack_Packages/win32/IFW/IFWOutput.log" + ) + endif() + if(CTEST_TEST_CPACK) add_test(CPackUseDefaultVersion ${CMAKE_CTEST_COMMAND} --build-and-test diff --git a/Tests/CPackIFWGenerator/ApplicationIcon.png b/Tests/CPackIFWGenerator/ApplicationIcon.png new file mode 100644 index 0000000000..c715e1bc73 Binary files /dev/null and b/Tests/CPackIFWGenerator/ApplicationIcon.png differ diff --git a/Tests/CPackIFWGenerator/BundleIcon.icns b/Tests/CPackIFWGenerator/BundleIcon.icns new file mode 100644 index 0000000000..8808dd62db Binary files /dev/null and b/Tests/CPackIFWGenerator/BundleIcon.icns differ diff --git a/Tests/CPackIFWGenerator/CMakeLists.txt b/Tests/CPackIFWGenerator/CMakeLists.txt new file mode 100644 index 0000000000..342c83f14f --- /dev/null +++ b/Tests/CPackIFWGenerator/CMakeLists.txt @@ -0,0 +1,54 @@ +cmake_minimum_required(VERSION 3.16) + +project(CPackIFWGenerator) + +add_executable(hello main.cpp) + +install(TARGETS hello + ARCHIVE DESTINATION . + RUNTIME DESTINATION . + LIBRARY DESTINATION . + BUNDLE DESTINATION .) + +# Component that is a reserved name on Windows. +# See https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file +install( + DIRECTORY . + DESTINATION txt + COMPONENT CON + FILES_MATCHING PATTERN *.txt) +# Component name that is similar to a reserved name on Windows. +install( + DIRECTORY . + DESTINATION txt + COMPONENT Console + FILES_MATCHING PATTERN *.txt) +# Component name that is strongly discouraged on Windows. +install( + DIRECTORY . + DESTINATION txt + COMPONENT EndsWithDot. + FILES_MATCHING PATTERN *.txt) + +set(CPACK_IFW_PRODUCT_URL "https://cmake.org/") +if(WIN32) + set(CPACK_IFW_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/install.ico") +else() + set(CPACK_IFW_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/BundleIcon.icns") +endif() + +set(CPACK_IFW_PACKAGE_WINDOW_ICON "${PROJECT_SOURCE_DIR}/install.ico") +set(CPACK_GENERATOR "IFW") + +set(CPACK_IFW_PACKAGE_PRODUCT_IMAGES + "${PROJECT_SOURCE_DIR}/ApplicationIcon.png" + "${PROJECT_SOURCE_DIR}/SplashScreen.png" +) + +set(CPACK_IFW_PACKAGE_PRODUCT_IMAGE_URLS + "https://www.ApplicationIcon.org" + "https://www.SplashScreen.org" +) + +include(CPack) +include(CPackIFW) diff --git a/Tests/CPackIFWGenerator/RunCPackVerifyResult.cmake b/Tests/CPackIFWGenerator/RunCPackVerifyResult.cmake new file mode 100644 index 0000000000..4ae6d41ead --- /dev/null +++ b/Tests/CPackIFWGenerator/RunCPackVerifyResult.cmake @@ -0,0 +1,93 @@ +message(STATUS "=============================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackIFWGenerator_BINARY_DIR) + message(FATAL_ERROR "CPackIFWGenerator_BINARY_DIR not set") +endif() + +message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") +message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") +message(STATUS "CPackIFWGenerator_BINARY_DIR: ${CPackIFWGenerator_BINARY_DIR}") + +if(config) + set(_C_config -C ${config}) +endif() + +execute_process(COMMAND "${CMAKE_CPACK_COMMAND}" + ${_C_config} + RESULT_VARIABLE CPack_result + OUTPUT_VARIABLE CPack_output + ERROR_VARIABLE CPack_error + WORKING_DIRECTORY "${CPackIFWGenerator_BINARY_DIR}") + +if(CPack_result) + message(FATAL_ERROR "CPack execution went wrong!, CPack_output=${CPack_output}, CPack_error=${CPack_error}") +else () + message(STATUS "CPack_output=${CPack_output}") +endif() + +set(expected_file_mask "${CPackIFWGenerator_BINARY_DIR}/_CPack_Packages/*/IFW/*/config/config.xml") +file(GLOB project_file "${expected_file_mask}") + +message(STATUS "project_file='${project_file}'") +message(STATUS "expected_file_mask='${expected_file_mask}'") + +if(NOT project_file) + message(FATAL_ERROR "project_file does not exist.") +endif() + +# should match !define MUI_HEADERIMAGE_BITMAP "${PROJECT_SOURCE_DIR}\header-image.bmp" +file(STRINGS "${project_file}" lines) + +file(STRINGS "${project_file}" tag_start REGEX [[]]) +file(STRINGS "${project_file}" tag_end REGEX [[]]) +list(LENGTH tag_start tag_start_size) +list(LENGTH tag_end tag_end_size) + +if(NOT tag_start_size EQUAL 2) + message(FATAL_ERROR "Expected to have 2 not ${tag_start_size}") +endif() +if(NOT tag_end_size EQUAL 2) + message(FATAL_ERROR "Expected to have 2 not ${tag_end_size}") +endif() + +file(STRINGS "${project_file}" tag_start REGEX [[]]) +file(STRINGS "${project_file}" tag_end REGEX [[]]) +list(LENGTH tag_start tag_start_size) +list(LENGTH tag_end tag_end_size) + +if(NOT tag_start_size EQUAL 2) + message(FATAL_ERROR "Expected to have 2 not ${tag_start_size}") +endif() +if(NOT tag_end_size EQUAL 2) + message(FATAL_ERROR "Expected to have 2 not ${tag_end_size}") +endif() + +file(STRINGS "${project_file}" tag_start REGEX [[]]) +file(STRINGS "${project_file}" tag_end REGEX [[]]) +list(LENGTH tag_start tag_start_size) +list(LENGTH tag_end tag_end_size) + +if(NOT tag_start_size EQUAL 2) + message(FATAL_ERROR "Expected to have 2 not ${tag_start_size}") +endif() +if(NOT tag_end_size EQUAL 2) + message(FATAL_ERROR "Expected to have 2 not ${tag_end_size}") +endif() + +set(TO_SEARCHES + "" + "ApplicationIcon.png" + "https://www.ApplicationIcon.org" + "SplashScreen.png" + "https://www.SplashScreen.org" + "" +) +foreach(TO_SEARCH ${TO_SEARCHES}) + string(FIND "${lines}" "${TO_SEARCH}" output_index) + message(STATUS "Found the ${TO_SEARCH} at index ${output_index}") + if("${output_index}" EQUAL "-1") + message(FATAL_ERROR "${TO_SEARCH} not found in the project") + endif() +endforeach() diff --git a/Tests/CPackIFWGenerator/SplashScreen.png b/Tests/CPackIFWGenerator/SplashScreen.png new file mode 100644 index 0000000000..8342565809 Binary files /dev/null and b/Tests/CPackIFWGenerator/SplashScreen.png differ diff --git a/Tests/CPackIFWGenerator/install.ico b/Tests/CPackIFWGenerator/install.ico new file mode 100644 index 0000000000..3b1e480c00 Binary files /dev/null and b/Tests/CPackIFWGenerator/install.ico differ diff --git a/Tests/CPackIFWGenerator/main.cpp b/Tests/CPackIFWGenerator/main.cpp new file mode 100644 index 0000000000..956f345700 --- /dev/null +++ b/Tests/CPackIFWGenerator/main.cpp @@ -0,0 +1,4 @@ +int main() +{ + return 42; +}