Commit 1e126635 authored by Alvin Wong's avatar Alvin Wong

Generate CMake script for building NSIS installer

Differential Revision: https://phabricator.kde.org/D9687
parent 37737859
......@@ -688,6 +688,10 @@ configure_file(config-ocio.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ocio.h )
check_function_exists(powf HAVE_POWF)
configure_file(config-powf.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-powf.h)
if(WIN32)
include(${CMAKE_CURRENT_LIST_DIR}/packaging/windows/ConfigureInstallerNsis.cmake)
endif()
message("\nBroken tests:")
foreach(tst ${KRITA_BROKEN_TESTS})
message(" * ${tst}")
......
if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
set(INSTALLER_NSIS_IS_32_BIT NO)
else()
set(INSTALLER_NSIS_IS_32_BIT YES)
endif()
configure_file(
${CMAKE_CURRENT_LIST_DIR}/MakeInstallerNsis.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/MakeinstallerNsis.cmake
@ONLY
)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MakeinstallerNsis.cmake
DESTINATION ${CMAKE_INSTALL_PREFIX}
)
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
set(ARCH_IS_32_BIT @INSTALLER_NSIS_IS_32_BIT@)
if(ARCH_IS_32_BIT)
set(ARG_ARCH "/DKRITA_INSTALLER_32")
set(FILENAME_ARCH "-x86")
else()
set(ARG_ARCH "/DKRITA_INSTALLER_64")
set(FILENAME_ARCH "-x64")
endif()
if(NOT IS_DIRECTORY "${KRITA_PACKAGE_ROOT}")
message(FATAL_ERROR "KRITA_PACKAGE_ROOT not set")
endif()
if(NOT DEFINED OUTPUT_FILEPATH)
set(OUTPUT_FILEPATH "${CMAKE_CURRENT_BINARY_DIR}/krita-setup${FILENAME_ARCH}.exe")
endif()
if(NOT DEFINED DOWNLOAD_DIR)
set(DOWNLOAD_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
# Download and find NSIS
if(NOT DEFINED NO_DOWNLOAD_NSIS)
set(DOWNLOAD_NSIS_VERSION "3.02.1")
message(STATUS "Downloading NSIS...")
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/nsis-${DOWNLOAD_NSIS_VERSION}")
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/nsis-${DOWNLOAD_NSIS_VERSION}")
endif()
file(DOWNLOAD "https://sourceforge.net/projects/nsis/files/NSIS%203/${DOWNLOAD_NSIS_VERSION}/nsis-${DOWNLOAD_NSIS_VERSION}.zip/download"
"${DOWNLOAD_DIR}/nsis-${DOWNLOAD_NSIS_VERSION}.zip"
EXPECTED_HASH SHA1=06c791f9cf668d945564316c9c947ebb4cc469e9
)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${DOWNLOAD_DIR}/nsis-${DOWNLOAD_NSIS_VERSION}.zip"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
RESULT_VARIABLE result_extract
)
if(NOT result_extract EQUAL 0)
message(FATAL_ERROR "Failed to extract NSIS")
endif()
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/nsis-${DOWNLOAD_NSIS_VERSION}")
message(FATAL_ERROR "Failed to find NSIS after extracting")
endif()
find_program(TOOL_MAKENSIS
NAMES makensis.exe
PATHS
"${CMAKE_CURRENT_BINARY_DIR}/nsis-${DOWNLOAD_NSIS_VERSION}"
NO_DEFAULT_PATH
)
else()
find_program(TOOL_MAKENSIS
NAMES makensis.exe
HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS\\Unicode]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\NSIS\\Unicode]"
)
endif()
if(NOT TOOL_MAKENSIS)
message(FATAL_ERROR "Failed to find makensis.exe")
endif()
execute_process(COMMAND "${TOOL_MAKENSIS}" "/version"
OUTPUT_VARIABLE MAKENSIS_VERSION
)
# Check version is v3.*
if(NOT MAKENSIS_VERSION MATCHES "^v3\\.")
message(FATAL_ERROR "Expected NSIS version v3.*, got ${MAKENSIS_VERSION}")
endif()
message(STATUS "NSIS version ${MAKENSIS_VERSION}")
# Check if package contains debug symbols
file(TO_CMAKE_PATH "${KRITA_PACKAGE_ROOT}" KRITA_PACKAGE_ROOT_PATCHED)
file(GLOB_RECURSE globForDebugFiles
"${KRITA_PACKAGE_ROOT_PATCHED}/*.debug"
)
if(globForDebugFiles)
if(REMOVE_DEBUG)
message(STATUS "Removing debug symbols")
foreach(debugFileItem ${globForDebugFiles})
get_filename_component(debugFileDir "${debugFileItem}" DIRECTORY)
get_filename_component(debugDirName "${debugFileDir}" NAME)
if(debugDirName STREQUAL ".debug")
if(EXISTS "${debugFileDir}")
message(STATUS "Deleting ${debugFileDir}")
file(REMOVE_RECURSE "${debugFileDir}")
endif()
else()
message(STATUS "Deleting ${debugFileItem}")
file(REMOVE "${debugFileItem}")
endif()
endforeach()
else()
message(FATAL_ERROR "${KRITA_PACKAGE_ROOT} seems to contain debug symbols. Set REMOVE_DEBUG to true if you want to remove them.")
endif()
endif()
# Download installer script package
message(STATUS "Downloading NSIS script package...")
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/krita-nsis")
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/krita-nsis")
endif()
file(DOWNLOAD "https://github.com/alvinhochun/KritaShellExtension/releases/download/v1.2.4a/krita-nsis-v1.2.4a_krita4.zip"
"${DOWNLOAD_DIR}/krita-nsis.zip"
EXPECTED_HASH SHA1=fc389a1857327d10b760633ab721255d0034f31e
)
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xfz "${DOWNLOAD_DIR}/krita-nsis.zip"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
RESULT_VARIABLE result_extract
)
if(NOT result_extract EQUAL 0)
message(FATAL_ERROR "Failed to extract krita-nsis package")
endif()
if(NOT IS_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/krita-nsis")
message(FATAL_ERROR "Failed to find krita-nsis after extracting")
endif()
# Build installer
message(STATUS "Building installer...")
set(KRITA_VERSION_NUMBER "@KRITA_STABLE_VERSION_MAJOR@.@KRITA_STABLE_VERSION_MINOR@.@KRITA_VERSION_RELEASE@.@KRITA_VERSION_REVISION@")
set(KRITA_VERSION_STRING "@KRITA_VERSION_STRING@")
set(KRITA_GIT_SHA1_STRING "@KRITA_GIT_SHA1_STRING@")
if(KRITA_GIT_SHA1_STRING)
set(KRITA_VERSION_STRING "${KRITA_VERSION_STRING} (git ${KRITA_GIT_SHA1_STRING})")
endif()
execute_process(COMMAND "${TOOL_MAKENSIS}"
"${ARG_ARCH}"
"/DKRITA_VERSION=${KRITA_VERSION_NUMBER}"
"/DKRITA_VERSION_DISPLAY=${KRITA_VERSION_STRING}"
"/DKRITA_INSTALLER_OUTPUT_DIR="
"/DKRITA_INSTALLER_OUTPUT_NAME=${OUTPUT_FILEPATH}"
"/DKRITA_PACKAGE_ROOT=${KRITA_PACKAGE_ROOT}"
"/XSetCompressor /SOLID lzma"
"/V3"
"${CMAKE_CURRENT_BINARY_DIR}/krita-nsis/installer_krita.nsi"
RESULT_VARIABLE result_makensis
)
if(NOT result_makensis EQUAL 0)
message(FATAL_ERROR "Failed to build installer")
endif()
message(STATUS "Built installer")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment