diff options
author | Jannik Alber <alber.jannik@gmail.com> | 2022-10-25 20:13:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-04-28 13:33:28 (GMT) |
commit | 1d6db661796b2b764e845b7cf6b9f8399037c668 (patch) | |
tree | 89f470f1bf4e927cd085952c3bffbeadd23027dc /Tests/CPackInnoSetupGenerator | |
parent | 9b0dc652ffc328394e70bf6ee015b50cfefa4125 (diff) | |
download | CMake-1d6db661796b2b764e845b7cf6b9f8399037c668.zip CMake-1d6db661796b2b764e845b7cf6b9f8399037c668.tar.gz CMake-1d6db661796b2b764e845b7cf6b9f8399037c668.tar.bz2 |
CPack: Add Inno Setup generator
Diffstat (limited to 'Tests/CPackInnoSetupGenerator')
-rw-r--r-- | Tests/CPackInnoSetupGenerator/CMakeLists.txt | 55 | ||||
-rw-r--r-- | Tests/CPackInnoSetupGenerator/Code.pas | 4 | ||||
-rw-r--r-- | Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake | 136 | ||||
-rw-r--r-- | Tests/CPackInnoSetupGenerator/main.c | 7 | ||||
-rw-r--r-- | Tests/CPackInnoSetupGenerator/my_bitmap.bmp | bin | 0 -> 9294 bytes | |||
-rw-r--r-- | Tests/CPackInnoSetupGenerator/my_file.txt | 1 |
6 files changed, 203 insertions, 0 deletions
diff --git a/Tests/CPackInnoSetupGenerator/CMakeLists.txt b/Tests/CPackInnoSetupGenerator/CMakeLists.txt new file mode 100644 index 0000000..bca0ad6 --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/CMakeLists.txt @@ -0,0 +1,55 @@ +cmake_minimum_required(VERSION 3.13) + +project(CPackInnoSetupGenerator VERSION 42.0 HOMEPAGE_URL "https://www.example.com") + +add_executable(hello main.c) +file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty) + +install(TARGETS hello DESTINATION / COMPONENT application) +install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/empty DESTINATION / COMPONENT extras) +install(FILES my_bitmap.bmp DESTINATION awesome COMPONENT extras) +install(FILES my_file.txt DESTINATION / COMPONENT hidden_component) +install(FILES my_file.txt DESTINATION / COMPONENT hidden_component2) + +set(CPACK_GENERATOR "INNOSETUP") + +set(CPACK_PACKAGE_NAME "Hello, World!") # Test constant escape (like {cm:...}, see code documentation) +set(CPACK_PACKAGE_VENDOR "Sheldon Cooper") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "hello_world") +set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "hello_world") +set(CPACK_PACKAGE_FILE_NAME "hello_world_setup") +set(CPACK_SYSTEM_NAME "win32") +set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/my_bitmap.bmp") +set(CPACK_VERBATIM_VARIABLES ON) +set(CPACK_PACKAGE_EXECUTABLES "hello" "Hello, World!") +set(CPACK_CREATE_DESKTOP_LINKS hello) + +set(CPACK_INNOSETUP_INSTALL_ROOT "{autopf}\\Sheldon Cooper") +set(CPACK_INNOSETUP_PROGRAM_MENU_FOLDER ".") +set(CPACK_INNOSETUP_IGNORE_LICENSE_PAGE ON) +set(CPACK_INNOSETUP_IGNORE_README_PAGE OFF) # Test if only readme page is shown +set(CPACK_INNOSETUP_SETUP_AppComments ON) # Test if CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT works +set(CPACK_INNOSETUP_CUSTOM_INSTALL_INSTRUCTIONS "extras/empty" + "Name: \"{userdocs}\\empty\"\; Check: ReturnTrue\; Components: accessories\\extras") +set(CPACK_INNOSETUP_MENU_LINKS "https://www.example.com" "Web" + "my_file.txt" "Text") +set(CPACK_INNOSETUP_RUN_EXECUTABLES hello) +set(CPACK_INNOSETUP_CREATE_UNINSTALL_LINK ON) +# Test if this macro is available in the code file below containing the check function +set(CPACK_INNOSETUP_DEFINE_PascalMacro "end;") +set(CPACK_INNOSETUP_CODE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/Code.pas") +set(CPACK_INNOSETUP_EXECUTABLE "ISCC.exe") + +include(CPackComponent) + +cpack_add_install_type(basic DISPLAY_NAME "Basic installation") +cpack_add_install_type(full DISPLAY_NAME "\"Large\" installation") # Test double quote syntax +cpack_add_component_group(accessories DISPLAY_NAME "Accessories") + +cpack_add_component(application DISPLAY_NAME "Application" INSTALL_TYPES basic full REQUIRED) +cpack_add_component(extras DISPLAY_NAME "Additional components" INSTALL_TYPES full GROUP accessories) +cpack_add_component(hidden_component HIDDEN) +cpack_add_component(hidden_component2 HIDDEN DISABLED) +set(CPACK_INNOSETUP_extras_INSTALL_DIRECTORY "{userdocs}") + +include(CPack) diff --git a/Tests/CPackInnoSetupGenerator/Code.pas b/Tests/CPackInnoSetupGenerator/Code.pas new file mode 100644 index 0000000..d96d82f --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/Code.pas @@ -0,0 +1,4 @@ +function ReturnTrue(): Boolean; +begin + Result := true; +{#PascalMacro} diff --git a/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake b/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake new file mode 100644 index 0000000..72a26ee --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/RunCPackVerifyResult.cmake @@ -0,0 +1,136 @@ +message(STATUS "=============================================================") +message(STATUS "CTEST_FULL_OUTPUT (Avoid ctest truncation of output)") +message(STATUS "") + +if(NOT CPackInnoSetupGenerator_BINARY_DIR) + message(FATAL_ERROR "CPackInnoSetupGenerator_BINARY_DIR not set") +endif() + +message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") +message(STATUS "CMAKE_CPACK_COMMAND: ${CMAKE_CPACK_COMMAND}") +message(STATUS "CPackInnoSetupGenerator_BINARY_DIR: ${CPackInnoSetupGenerator_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_output + WORKING_DIRECTORY "${CPackInnoSetupGenerator_BINARY_DIR}") + +if(CPack_result) + message(FATAL_ERROR "CPack execution went wrong!, Output: ${CPack_output}") +else () + message(STATUS "Output: ${CPack_output}") +endif() + +file(GLOB project_file "${CPackInnoSetupGenerator_BINARY_DIR}/_CPack_Packages/win32/INNOSETUP/ISScript.iss") +file(GLOB installer_file "${CPackInnoSetupGenerator_BINARY_DIR}/_CPack_Packages/win32/INNOSETUP/hello_world_setup.exe") + +message(STATUS "Project file: '${project_file}'") +message(STATUS "Installer file: '${installer_file}'") + +if(NOT project_file) + message(FATAL_ERROR "Project file does not exist") +endif() + +if(NOT installer_file) + message(FATAL_ERROR "Installer file does not exist") +endif() + +# Test if the correct registry key is set +file(STRINGS "${project_file}" results REGEX "^AppId=hello_world$") +if(results STREQUAL "") + message(FATAL_ERROR "CPACK_PACKAGE_INSTALL_REGISTRY_KEY doesn't match AppId") +endif() + +# Test if only readme page is shown +file(STRINGS "${project_file}" results REGEX "^LicenseFile=") +file(STRINGS "${project_file}" results2 REGEX "^InfoBeforeFile=") +if(NOT results STREQUAL "" OR results2 STREQUAL "") + message(FATAL_ERROR "Erroneous output with license and readme files") +endif() + +# Test if classic style is used by default +file(STRINGS "${project_file}" results REGEX "compiler:SetupClassicIcon\\.ico") +file(STRINGS "${project_file}" results2 REGEX "compiler:WizClassicImage\\.bmp") +if(results STREQUAL "" OR results2 STREQUAL "") + message(FATAL_ERROR "Images of classic style not used") +endif() + +# Test if the top-level start menu folder is used +file(STRINGS "${project_file}" results REGEX "{autoprograms}") +file(STRINGS "${project_file}" results2 REGEX "{group}") +if(results STREQUAL "" OR NOT results2 STREQUAL "") + message(FATAL_ERROR "Top-level start menu folder not used") +endif() + +# Test CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT +file(STRINGS "${project_file}" results REGEX "^AppComments=yes$") +if(results STREQUAL "") + message(FATAL_ERROR "CPACK_INNOSETUP_USE_CMAKE_BOOL_FORMAT doesn't convert booleans") +endif() + +# Test the custom installation rule +file(STRINGS "${project_file}" results REGEX "^Name: \"{userdocs}\\\\empty\"; Check: ReturnTrue; Components: accessories\\\\extras$") +if(results STREQUAL "") + message(FATAL_ERROR "Custom installation rule not found or incomplete") +endif() + +# Test if an uninstall shortcut has been created +file(STRINGS "${project_file}" results REGEX "{uninstallexe}") +if(results STREQUAL "") + message(FATAL_ERROR "No uninstall shortcut created") +endif() + +# Test CPACK_INNOSETUP_<compName>_INSTALL_DIRECTORY +file(STRINGS "${project_file}" results REGEX "{app}.*Components: accessories\\\\extras") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Component not in custom install directory") +endif() + +# Test if component names are nested correctly +file(STRINGS "${project_file}" results REGEX "Components:.* extras") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Component names must contain their parent groups according to the documentation") +endif() + +# Test if custom installation type exists +file(STRINGS "${project_file}" results REGEX "Flags: .*iscustom") +if(results STREQUAL "") + message(FATAL_ERROR "Custom installation type doesn't exist") +endif() + +# Test if hidden components are processed but not displayed +file(STRINGS "${project_file}" results REGEX "Source:.+hidden_component\\\\my_file\\.txt") +file(STRINGS "${project_file}" results2 REGEX "Name: \"hidden_component\"") +if(results STREQUAL "" OR NOT results2 STREQUAL "") + message(FATAL_ERROR "Hidden component displayed or one of its files ignored") +endif() + +# Test if disabled and hidden components are ignored at all +file(STRINGS "${project_file}" results REGEX "Source:.+hidden_component2\\\\my_file\\.txt") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Disabled and hidden component not ignored") +endif() + +# Test if required components ignore their installation types +file(STRINGS "${project_file}" results REGEX "Types: (basic|full|custom|basic full|full basic|basic custom|full custom); Flags: fixed") +if(NOT results STREQUAL "") + message(FATAL_ERROR "Required components don't ignore their installation types") +endif() + +# Test constant escape (should contain Hello%2c World!) +file(STRINGS "${project_file}" results REGEX "Hello%2c World!") +if(results STREQUAL "") + message(FATAL_ERROR "The comma character isn't escaped to %2c") +endif() + +# Test double quote syntax +file(STRINGS "${project_file}" results REGEX "\"\"Large\"\"") +if(results STREQUAL "") + message(FATAL_ERROR "The quote character isn't escaped correctly") +endif() diff --git a/Tests/CPackInnoSetupGenerator/main.c b/Tests/CPackInnoSetupGenerator/main.c new file mode 100644 index 0000000..413899c --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/main.c @@ -0,0 +1,7 @@ +#include <stdio.h> + +int main() +{ + printf("Hello, World!\n"); + return 42; +} diff --git a/Tests/CPackInnoSetupGenerator/my_bitmap.bmp b/Tests/CPackInnoSetupGenerator/my_bitmap.bmp Binary files differnew file mode 100644 index 0000000..d0e562f --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/my_bitmap.bmp diff --git a/Tests/CPackInnoSetupGenerator/my_file.txt b/Tests/CPackInnoSetupGenerator/my_file.txt new file mode 100644 index 0000000..8ab686e --- /dev/null +++ b/Tests/CPackInnoSetupGenerator/my_file.txt @@ -0,0 +1 @@ +Hello, World! |