summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Marrec <julien.marrec@gmail.com>2024-09-05 15:58:37 (GMT)
committerBrad King <brad.king@kitware.com>2024-09-11 12:44:09 (GMT)
commit5b8fa21512fa4b283847aea4bcd3be43e6fce7b7 (patch)
tree650ff370d51b7849febfb0260d14baabf7c9a284
parent3331c7032f474515c5f207afb8ed978293d26a0b (diff)
downloadCMake-5b8fa21512fa4b283847aea4bcd3be43e6fce7b7.zip
CMake-5b8fa21512fa4b283847aea4bcd3be43e6fce7b7.tar.gz
CMake-5b8fa21512fa4b283847aea4bcd3be43e6fce7b7.tar.bz2
Tests: Add a test covering the CPack IFW Generator
-rw-r--r--Tests/CMakeLists.txt26
-rw-r--r--Tests/CPackIFWGenerator/ApplicationIcon.pngbin0 -> 2335 bytes
-rw-r--r--Tests/CPackIFWGenerator/BundleIcon.icnsbin0 -> 33452 bytes
-rw-r--r--Tests/CPackIFWGenerator/CMakeLists.txt54
-rw-r--r--Tests/CPackIFWGenerator/RunCPackVerifyResult.cmake93
-rw-r--r--Tests/CPackIFWGenerator/SplashScreen.pngbin0 -> 909 bytes
-rw-r--r--Tests/CPackIFWGenerator/install.icobin0 -> 838 bytes
-rw-r--r--Tests/CPackIFWGenerator/main.cpp4
8 files changed, 177 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 771f5db..428ec8b 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 0000000..c715e1b
--- /dev/null
+++ b/Tests/CPackIFWGenerator/ApplicationIcon.png
Binary files differ
diff --git a/Tests/CPackIFWGenerator/BundleIcon.icns b/Tests/CPackIFWGenerator/BundleIcon.icns
new file mode 100644
index 0000000..8808dd6
--- /dev/null
+++ b/Tests/CPackIFWGenerator/BundleIcon.icns
Binary files differ
diff --git a/Tests/CPackIFWGenerator/CMakeLists.txt b/Tests/CPackIFWGenerator/CMakeLists.txt
new file mode 100644
index 0000000..342c83f
--- /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 0000000..4ae6d41
--- /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 [[<ProductImage>]])
+file(STRINGS "${project_file}" tag_end REGEX [[</ProductImage>]])
+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 <ProductImage> not ${tag_start_size}")
+endif()
+if(NOT tag_end_size EQUAL 2)
+ message(FATAL_ERROR "Expected to have 2 </ProductImage> not ${tag_end_size}")
+endif()
+
+file(STRINGS "${project_file}" tag_start REGEX [[<Image>]])
+file(STRINGS "${project_file}" tag_end REGEX [[</Image>]])
+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 <Image> not ${tag_start_size}")
+endif()
+if(NOT tag_end_size EQUAL 2)
+ message(FATAL_ERROR "Expected to have 2 </Image> not ${tag_end_size}")
+endif()
+
+file(STRINGS "${project_file}" tag_start REGEX [[<Url>]])
+file(STRINGS "${project_file}" tag_end REGEX [[</Url>]])
+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 <Url> not ${tag_start_size}")
+endif()
+if(NOT tag_end_size EQUAL 2)
+ message(FATAL_ERROR "Expected to have 2 </Url> not ${tag_end_size}")
+endif()
+
+set(TO_SEARCHES
+ "<ProductImages>"
+ "<Image>ApplicationIcon.png</Image>"
+ "<Url>https://www.ApplicationIcon.org</Url>"
+ "<Image>SplashScreen.png</Image>"
+ "<Url>https://www.SplashScreen.org</Url>"
+ "</ProductImages>"
+)
+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 0000000..8342565
--- /dev/null
+++ b/Tests/CPackIFWGenerator/SplashScreen.png
Binary files differ
diff --git a/Tests/CPackIFWGenerator/install.ico b/Tests/CPackIFWGenerator/install.ico
new file mode 100644
index 0000000..3b1e480
--- /dev/null
+++ b/Tests/CPackIFWGenerator/install.ico
Binary files differ
diff --git a/Tests/CPackIFWGenerator/main.cpp b/Tests/CPackIFWGenerator/main.cpp
new file mode 100644
index 0000000..956f345
--- /dev/null
+++ b/Tests/CPackIFWGenerator/main.cpp
@@ -0,0 +1,4 @@
+int main()
+{
+ return 42;
+}