mirror of
https://github.com/H-uru/korman.git
synced 2025-07-14 02:27:36 -04:00
Add "Blender for Korman" and build/package process.
This will allow us to automate releases with the Blender 2.79 "experimenntal nightly" codebase. This is great because the newer Blender uses Python 3.7 (instead of 3.5). This pulls from my fork of Blender, which has a number of build improvements added on top.
This commit is contained in:
253
cmake/Dependencies.cmake
Normal file
253
cmake/Dependencies.cmake
Normal file
@ -0,0 +1,253 @@
|
||||
# This file is part of Korman.
|
||||
#
|
||||
# Korman is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Korman is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(korman_EXTERNAL_STAGING_DIR "${PROJECT_BINARY_DIR}/external" CACHE PATH "External project staging directory")
|
||||
mark_as_advanced(korman_EXTERNAL_STAGING_DIR)
|
||||
|
||||
set(korman_HARVEST_DIR "${PROJECT_BINARY_DIR}/harvest" CACHE PATH "")
|
||||
|
||||
cmake_dependent_option(
|
||||
korman_HARVEST_VCREDIST
|
||||
"Harvest the vcredist executable as part of Korman's build process"
|
||||
ON
|
||||
"MSVC"
|
||||
OFF
|
||||
)
|
||||
|
||||
cmake_dependent_option(
|
||||
korman_HARVEST_PYTHON22
|
||||
"Harvest (read: download) the Python 2.2.3 installer as part of Korman's build process"
|
||||
ON
|
||||
"WIN32" # If we ever decide to allow NSIS installers, NSIS can run on non-Windows.
|
||||
OFF
|
||||
)
|
||||
|
||||
# Since we are (ideally) building everything static, inline right here, we can use IPO on
|
||||
# all of the static libraries for a uuuuge file size win. Most libs do not do the correct
|
||||
# CMake magic to turn this on.
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(
|
||||
RESULT _IPO_SUPPORTED
|
||||
OUTPUT _IPO_OUTPUT
|
||||
)
|
||||
message(STATUS "Checking for IPO: ${_IPO_SUPPORTED} ${_IPO_OUTPUT}")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${_IPO_SUPPORTED} CACHE BOOL "")
|
||||
|
||||
if(WIN32)
|
||||
set(_BUILD_SYSTEM_LIBS ON)
|
||||
else()
|
||||
set(_BUILD_SYSTEM_LIBS OFF)
|
||||
endif()
|
||||
|
||||
option(korman_BUILD_HSPLASMA "Build libHSPlasma as part of Korman's build process" ON)
|
||||
option(korman_BUILD_JPEG "Build libpjeg-turbo as part of Korman's build process" ${_BUILD_SYSTEM_LIBS})
|
||||
option(korman_BUILD_OGGVORBIS "Build libogg and libvorbis as part of Korman's build process" ${_BUILD_SYSTEM_LIBS})
|
||||
option(korman_BUILD_PNG "Build libpng as part of Korman's build process" ${_BUILD_SYSTEM_LIBS})
|
||||
option(korman_BUILD_ZLIB "Build zlib as part of Korman's build process" ${_BUILD_SYSTEM_LIBS})
|
||||
option(korman_BUILD_STRING_THEORY "Build string_theory as part of Korman's build process" ON)
|
||||
option(korman_BUILD_ALWAYS_UPDATE "Always run the update phase for external dependencies" OFF)
|
||||
|
||||
if(korman_BUILD_HSPLASMA)
|
||||
list(APPEND korlib_DEPENDS HSPlasma)
|
||||
endif()
|
||||
if(korman_BUILD_JPEG)
|
||||
list(APPEND HSPlasma_DEPENDS libjpeg-turbo)
|
||||
endif()
|
||||
if(korman_BUILD_OGGVORBIS)
|
||||
list(APPEND korlib_DEPENDS libvorbis)
|
||||
list(APPEND libvorbis_DEPENDS libogg)
|
||||
endif()
|
||||
if(korman_BUILD_STRING_THEORY)
|
||||
list(APPEND HSPlasma_DEPENDS string_theory)
|
||||
endif()
|
||||
if(korman_BUILD_PNG)
|
||||
list(APPEND HSPlasma_DEPENDS libpng)
|
||||
endif()
|
||||
if(korman_BUILD_ZLIB)
|
||||
list(APPEND HSPlasma_DEPENDS zlib)
|
||||
list(APPEND libpng_DEPENDS zlib)
|
||||
endif()
|
||||
|
||||
set(_ExternalProjectCMakeCache
|
||||
-DCMAKE_INSTALL_PREFIX:PATH=${korman_HARVEST_DIR}
|
||||
-DCMAKE_POLICY_DEFAULT_CMP0069:STRING=NEW
|
||||
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION:BOOL=${CMAKE_INTERPROCEDURAL_OPTIMIZATION}
|
||||
)
|
||||
|
||||
include(ExternalProject)
|
||||
include(FetchContent)
|
||||
|
||||
function(korman_add_external_project TARGET)
|
||||
set(_args ${ARGN})
|
||||
|
||||
if("GIT_REPOSITORY" IN_LIST _args)
|
||||
list(APPEND _args GIT_PROGRESS TRUE)
|
||||
if(NOT "GIT_SHALLOW" IN_LIST _args)
|
||||
list(APPEND _args GIT_SHALLOW TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(FIND _args "CMAKE_CACHE_ARGS" _cache_args_idx)
|
||||
if(_cache_args_idx EQUAL -1)
|
||||
list(APPEND _args CMAKE_CACHE_ARGS ${_ExternalProjectCMakeCache})
|
||||
else()
|
||||
math(EXPR _cache_insert_pos "${_cache_args_idx} + 1")
|
||||
list(INSERT _args ${_cache_insert_pos} ${_ExternalProjectCMakeCache})
|
||||
endif()
|
||||
|
||||
set(_builddir "${korman_EXTERNAL_STAGING_DIR}/${TARGET}/src/build")
|
||||
if(CMAKE_GENERATOR_PLATFORM)
|
||||
string(APPEND _builddir "-${CMAKE_GENERATOR_PLATFORM}")
|
||||
endif()
|
||||
|
||||
list(APPEND _args
|
||||
PREFIX "${korman_EXTERNAL_STAGING_DIR}"
|
||||
BINARY_DIR "${_builddir}"
|
||||
DEPENDS ${${TARGET}_DEPENDS}
|
||||
)
|
||||
|
||||
ExternalProject_Add(${TARGET} ${_args})
|
||||
endfunction()
|
||||
|
||||
if(korman_BUILD_JPEG)
|
||||
korman_add_external_project(libjpeg-turbo
|
||||
GIT_REPOSITORY "https://github.com/libjpeg-turbo/libjpeg-turbo.git"
|
||||
GIT_TAG 2.1.0
|
||||
CMAKE_CACHE_ARGS
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DENABLE_SHARED:BOOL=FALSE
|
||||
-DENABLE_STATIC:BOOL=TRUE
|
||||
-DWITH_CRT_DLL:BOOL=ON # WTF libjpeg-turbo, this is a smell.
|
||||
-DWITH_JAVA:BOOL=FALSE
|
||||
-DWITH_TURBOJPEG:BOOL=FALSE
|
||||
)
|
||||
endif()
|
||||
|
||||
if(korman_BUILD_OGGVORBIS)
|
||||
korman_add_external_project(libogg
|
||||
GIT_REPOSITORY "https://github.com/xiph/ogg.git"
|
||||
GIT_TAG v1.3.5
|
||||
CMAKE_CACHE_ARGS
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DBUILD_TESTING:BOOL=OFF
|
||||
-DINSTALL_DOCS:BOOL=OFF
|
||||
)
|
||||
korman_add_external_project(libvorbis
|
||||
GIT_REPOSITORY "https://github.com/xiph/vorbis.git"
|
||||
GIT_TAG v1.3.7
|
||||
CMAKE_CACHE_ARGS
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
)
|
||||
endif()
|
||||
|
||||
if(korman_BUILD_STRING_THEORY)
|
||||
# Woe betide us if comaptibility breaks...
|
||||
if(MSVC AND MSVC_VERSION LESS 1900)
|
||||
set(_string_theory_tag 2.4)
|
||||
else()
|
||||
set(_string_theory_tag 3.4)
|
||||
endif()
|
||||
|
||||
korman_add_external_project(string_theory
|
||||
GIT_REPOSITORY "https://github.com/zrax/string_theory.git"
|
||||
GIT_TAG ${_string_theory_tag}
|
||||
CMAKE_CACHE_ARGS
|
||||
-DST_BUILD_TESTS:BOOL=OFF
|
||||
)
|
||||
endif()
|
||||
|
||||
if(korman_BUILD_ZLIB)
|
||||
# Using zlib-ng instead of zlib because the latter's CMakeLists is a pile of steaming garbage
|
||||
# in that it always produces a shared library if BUILD_SHARED_LIBS=OFF, and bad problems when
|
||||
# `if(UNIX)` -> TRUE. Grrr.
|
||||
korman_add_external_project(zlib
|
||||
#URL
|
||||
# "https://zlib.net/zlib-1.2.11.tar.gz"
|
||||
# "https://sourceforge.net/projects/libpng/files/zlib/1.2.11/zlib-1.2.11.tar.gz/download"
|
||||
#DOWNLOAD_NAME "zlib-1.2.11.tar.gz"
|
||||
#URL_HASH "SHA256=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1"
|
||||
GIT_REPOSITORY "https://github.com/zlib-ng/zlib-ng.git"
|
||||
GIT_TAG 2.0.5
|
||||
CMAKE_CACHE_ARGS
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DZLIB_COMPAT:BOOL=ON
|
||||
-DZLIB_ENABLE_TESTS:BOOL=OFF
|
||||
)
|
||||
endif()
|
||||
|
||||
if(korman_BUILD_PNG)
|
||||
korman_add_external_project(libpng
|
||||
URL "https://sourceforge.net/projects/libpng/files/libpng16/1.6.37/libpng-1.6.37.tar.gz/download"
|
||||
DOWNLOAD_NAME "libpng-1.6.37.tar.gz"
|
||||
URL_HASH "SHA256=daeb2620d829575513e35fecc83f0d3791a620b9b93d800b763542ece9390fb4"
|
||||
CMAKE_CACHE_ARGS
|
||||
-DBUILD_SHARED_LIBS:BOOL=OFF
|
||||
-DPNG_EXECUTABLES:BOOL=OFF
|
||||
-DPNG_SHARED:BOOL=OFF
|
||||
-DPNG_TESTS:BOOL=OFF
|
||||
)
|
||||
endif()
|
||||
|
||||
if(korman_BUILD_HSPLASMA)
|
||||
korman_add_external_project(HSPlasma
|
||||
GIT_REPOSITORY "https://github.com/H-uru/libhsplasma.git"
|
||||
# Be sure to increase this as the feature set used by Korman increases
|
||||
GIT_TAG 7871b5def20f7352c93be46316982999ed883777
|
||||
# We can only do shallow checkouts if the above is a branch or tag.
|
||||
GIT_SHALLOW FALSE
|
||||
CMAKE_CACHE_ARGS
|
||||
-DCMAKE_UNITY_BUILD:BOOL=ON
|
||||
-DENABLE_NET:BOOL=OFF
|
||||
-DENABLE_PHYSX:BOOL=OFF
|
||||
-DENABLE_PYTHON:BOOL=ON
|
||||
-DENABLE_TOOLS:BOOL=OFF
|
||||
-DPYTHON_INCLUDE_DIR:PATH=${Python3_INCLUDE_DIRS}
|
||||
-DPYTHON_LIBRARY:FILEPATH=${Python3_LIBRARIES}
|
||||
)
|
||||
endif()
|
||||
|
||||
korman_add_external_project(korlib
|
||||
SOURCE_DIR "${PROJECT_SOURCE_DIR}/korlib"
|
||||
CMAKE_CACHE_ARGS
|
||||
-Dkorlib_PYTHON_VERSION:STRING=${Blender_PYTHON_VERSION}
|
||||
-DPython3_ROOT:PATH=${Python3_ROOT} # Passthru helper
|
||||
)
|
||||
|
||||
if(korman_HARVEST_VCREDIST)
|
||||
find_package(VCRedist COMPONENTS Executable REQUIRED)
|
||||
set(_vcredist_destination "${korman_HARVEST_DIR}/bin/${VCRedist_NAME}")
|
||||
add_custom_target(VCRedist
|
||||
ALL
|
||||
COMMAND "${CMAKE_COMMAND}" -E make_directory "${korman_HARVEST_DIR}"
|
||||
COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${VCRedist_EXECUTABLE}" "${_vcredist_destination}"
|
||||
BYPRODUCTS "${_vcredist_destination}"
|
||||
)
|
||||
install(
|
||||
PROGRAMS
|
||||
"${_vcredist_destination}"
|
||||
DESTINATION "."
|
||||
)
|
||||
endif()
|
||||
|
||||
FetchContent_Declare(Python22
|
||||
URL "https://www.python.org/ftp/python/2.2.3/Python-2.2.3.exe"
|
||||
URL_HASH MD5=d76e774a4169794ae0d7a8598478e69e
|
||||
DOWNLOAD_DIR "${korman_HARVEST_DIR}/bin"
|
||||
DOWNLOAD_NAME "Python-2.2.3.exe"
|
||||
DOWNLOAD_NO_EXTRACT TRUE # Why is this not a flag? Yes, that bit me.
|
||||
)
|
||||
if(korman_HARVEST_PYTHON22 AND NOT Python22_POPULATED)
|
||||
FetchContent_Populate(Python22)
|
||||
endif()
|
85
cmake/FindBlender.cmake
Normal file
85
cmake/FindBlender.cmake
Normal file
@ -0,0 +1,85 @@
|
||||
# This file is part of Korman.
|
||||
#
|
||||
# Korman is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Korman is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# The parens in this env variable give CMake heartburn, so we whisper sweet nothings.
|
||||
set(_PROGRAMFILES_X86 "PROGRAMFILES(X86)")
|
||||
set(_PROGRAMFILES_X86 "$ENV{${_PROGRAMFILES_X86}}")
|
||||
|
||||
find_program(Blender_EXECUTABLE
|
||||
NAMES blender
|
||||
PATHS
|
||||
"${Blender_ROOT}"
|
||||
"$ENV{PROGRAMFILES}/Blender Foundation/Blender"
|
||||
"${_PROGRAMFILES_X86}/Blender Foundation/Blender"
|
||||
)
|
||||
|
||||
# Hacky? On Windows, we want to make sure that the Blender EXE matches sizeof void*
|
||||
# Yes, this has bitten me. If it bites you, the result will be "Import Error: PyHSPlasma is not a
|
||||
# valid Win32 application." That's hardly useful...
|
||||
if(WIN32 AND EXISTS "${Blender_EXECUTABLE}")
|
||||
find_package(dumpbin)
|
||||
if(dumpbin_FOUND)
|
||||
execute_process(
|
||||
COMMAND "${dumpbin_EXECUTABLE}" /headers "${Blender_EXECUTABLE}"
|
||||
RESULTS_VARIABLE _RETURNCODE
|
||||
OUTPUT_VARIABLE _dumpbin_output
|
||||
ERROR_VARIABLE _dumpbin_error
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(_RETURNCODE EQUAL 0)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_expected_arch "machine \\(x64\\)")
|
||||
else()
|
||||
set(_expected_arch "machine \\(x86\\)")
|
||||
endif()
|
||||
if(NOT "${_dumpbin_output}" MATCHES "${_expected_arch}")
|
||||
unset(Blender_EXECUTABLE CACHE)
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "dumpbin failed ${_dumpbin_error}")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "dumpbin not found, not verifying blender executable")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(EXISTS "${Blender_EXECUTABLE}")
|
||||
# Starting Blender is noisy on stdout, so all the extra characters will make sure things go right.
|
||||
# https://youtu.be/SlQFIsQ0dbs?t=19
|
||||
set(_Blender_PYTHON_EXPR
|
||||
"import sys; print('!!! OOGABOOGA {}.{} AGOOBAGOO !!!'.format(sys.version_info[0], sys.version_info[1]))"
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "${Blender_EXECUTABLE}" -b --python-expr "${_Blender_PYTHON_EXPR}"
|
||||
RESULTS_VARIABLE _RETURNCODE
|
||||
OUTPUT_VARIABLE _Blender_VERSION_OUTPUT
|
||||
ERROR_VARIABLE _Blender_VERSION_OUTPUT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(REGEX MATCH [[Blender ([0-9]+\.[0-9]+)]] _match "${_Blender_VERSION_OUTPUT}")
|
||||
set(Blender_VERSION "${CMAKE_MATCH_1}")
|
||||
string(REGEX MATCH [[!!! OOGABOOGA ([0-9]+\.[0-9]+) AGOOBAGOO !!!]] _match "${_Blender_VERSION_OUTPUT}")
|
||||
set(Blender_PYTHON_VERSION "${CMAKE_MATCH_1}")
|
||||
endif()
|
||||
|
||||
mark_as_advanced(Blender_EXECUTABLE)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Blender
|
||||
REQUIRED_VARS Blender_EXECUTABLE Blender_VERSION Blender_PYTHON_VERSION
|
||||
VERSION_VAR Blender_VERSION
|
||||
)
|
120
cmake/FindVCRedist.cmake
Normal file
120
cmake/FindVCRedist.cmake
Normal file
@ -0,0 +1,120 @@
|
||||
# This file is part of Korman.
|
||||
#
|
||||
# Korman is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Korman is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
cmake_policy(PUSH)
|
||||
cmake_policy(SET CMP0057 NEW) # if(IN_LIST)
|
||||
|
||||
function(_get_subdirectories RESULT DIRECTORY)
|
||||
file(GLOB children INCLUDE_DIRECTORIES RELATIVE "${DIRECTORY}" "${DIRECTORY}/*")
|
||||
foreach(child IN LISTS children)
|
||||
if(IS_DIRECTORY "${DIRECTORY}/${child}")
|
||||
list(APPEND subdirectories "${child}")
|
||||
endif()
|
||||
endforeach()
|
||||
set(${RESULT} ${subdirectories} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Is this even legal?
|
||||
if(NOT VCRedist_FIND_COMPONENTS)
|
||||
set(VCRedist_FIND_COMPONENTS Executable MergeModules)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# The parens in this env variable give CMake heartburn, so we whisper sweet nothings.
|
||||
set(_PROGRAMFILES_X86 "PROGRAMFILES(X86)")
|
||||
set(_PROGRAMFILES_X86 "$ENV{${_PROGRAMFILES_X86}}")
|
||||
|
||||
# TODO: support non visual studio generators
|
||||
set(_vs_install_root "${CMAKE_VS_DEVENV_COMMAND}/../../../")
|
||||
get_filename_component(_vs_install_root "${_vs_install_root}" ABSOLUTE)
|
||||
|
||||
# Valid paths:
|
||||
# 2013, 2015: VC/redist/1033/<exe>
|
||||
# 2017, 2019: VC/redist/MSVC/<MSVC VERSION>/<exe>
|
||||
# 2019: VC/redist/MSVC/<toolset version>/<exe>
|
||||
set(_redist_dir "${_vs_install_root}/VC/redist")
|
||||
_get_subdirectories(_msvc_subdirs "${_redist_dir}/MSVC")
|
||||
foreach(_subdir IN LISTS _msvc_subdirs)
|
||||
list(APPEND _redist_paths "${_redist_dir}/MSVC/${_subdir}")
|
||||
endforeach()
|
||||
|
||||
# These are known, valid locations, so we prefer them first.
|
||||
list(INSERT _redist_paths 0 "${_redist_dir}/1033" "${_redist_dir}/MSVC/v${MSVC_TOOLSET_VERSION}")
|
||||
list(REMOVE_DUPLICATES _redist_paths)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_redist_arch x64)
|
||||
else()
|
||||
set(_redist_arch x86)
|
||||
endif()
|
||||
|
||||
if("Executable" IN_LIST VCRedist_FIND_COMPONENTS)
|
||||
list(APPEND _required_vars "VCRedist_EXECUTABLE")
|
||||
|
||||
find_program(VCRedist_EXECUTABLE
|
||||
NAMES "vcredist_${_redist_arch}" "vc_redist.${_redist_arch}"
|
||||
PATHS ${_redist_paths}
|
||||
)
|
||||
|
||||
mark_as_advanced(VCRedist_EXECUTABLE)
|
||||
set(VCRedist_NAME "vcredist_${_redist_arch}.exe")
|
||||
if(EXISTS "${VCRedist_EXECUTABLE}")
|
||||
set(VCRedist_Executable_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Valid Paths:
|
||||
# Visual Studio <= 2015: <Program Files (x86)>/Common Files/Merge Modules/
|
||||
# Visual Studio >= 2017: <Visual Studio root>/VC/<MSVC or toolset version>/MergeModules/
|
||||
if("MergeModules" IN_LIST VCRedist_FIND_COMPONENTS)
|
||||
list(APPEND _merge_module_paths "${_PROGRAMFILES_X86}/Common Files" ${_redist_paths})
|
||||
set(_merge_module_suffixes "Merge Modules" "MergeModules")
|
||||
|
||||
# We'll flip it OFF if anything is missing
|
||||
set(VCRedist_MergeModules_FOUND TRUE)
|
||||
function(_find_merge_module MODULE_NAME)
|
||||
string(TOUPPER "${MODULE_NAME}" _module_name_upper)
|
||||
set(VARIABLE "VCRedist_${_module_name_upper}_MERGE_MODULE")
|
||||
find_file(${VARIABLE}
|
||||
NAMES "Microsoft_VC${MSVC_TOOLSET_VERSION}_${MODULE_NAME}_${_redist_arch}.msm"
|
||||
PATHS ${_merge_module_paths}
|
||||
PATH_SUFFIXES ${_merge_module_suffixes}
|
||||
)
|
||||
mark_as_advanced(${VARIABLE})
|
||||
set(_required_vars ${_required_vars} ${VARIABLE} PARENT_SCOPE)
|
||||
if(EXISTS "${${VARIABLE}}")
|
||||
set(VCRedist_MERGE_MODULES ${VCRedist_MERGE_MODULES} "${${VARIABLE}}" PARENT_SCOPE)
|
||||
else()
|
||||
set(VCRedist_MergeModules_FOUND FALSE PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
_find_merge_module(CRT)
|
||||
_find_merge_module(MFC)
|
||||
_find_merge_module(MFCLOC)
|
||||
_find_merge_module(OpenMP)
|
||||
if(MSVC_TOOLSET_VERSION GREATER_EQUAL 110)
|
||||
_find_merge_module(CXXAMP)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(VCRedist
|
||||
REQUIRED_VARS ${_required_vars} # Optional in CMake 3.18+, but we only require 3.12
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
|
||||
cmake_policy(POP)
|
26
cmake/Finddumpbin.cmake
Normal file
26
cmake/Finddumpbin.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
# This file is part of Korman.
|
||||
#
|
||||
# Korman is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Korman is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
get_filename_component(_linker_dir "${CMAKE_LINKER}" DIRECTORY)
|
||||
find_program(dumpbin_EXECUTABLE
|
||||
NAMES dumpbin
|
||||
PATHS ${_linker_dir}
|
||||
)
|
||||
|
||||
mark_as_advanced(dumpbin_EXECUTABLE)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(dumpbin REQUIRED_VARS dumpbin_EXECUTABLE)
|
121
cmake/Packaging.cmake
Normal file
121
cmake/Packaging.cmake
Normal file
@ -0,0 +1,121 @@
|
||||
# This file is part of Korman.
|
||||
#
|
||||
# Korman is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# Korman is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
set(CPACK_PACKAGE_NAME Korman)
|
||||
set(CPACK_PACKAGE_VENDOR "Guild of Writers")
|
||||
set(CPACK_PACKAGE_DIRECTORY "${PROJECT_BINARY_DIR}/package")
|
||||
set(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/installer/Icon.ico")
|
||||
set(CPACK_THREADS 0) # Allows multi-threaded LZMA compression in CMake 3.21+
|
||||
|
||||
find_package(Git)
|
||||
if(Git_FOUND)
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} describe --tags --dirty
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE _korman_rev
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
)
|
||||
string(REGEX REPLACE "[\r\n]" " " _korman_rev "${_korman_rev}")
|
||||
else()
|
||||
set(_korman_rev "untracked")
|
||||
endif()
|
||||
|
||||
# Don't rely on the hardwired version number from project() since this may be some rando
|
||||
# git checkout or CI run. Also, apparently CPACK_SYSTEM_NAME is faulty. Stupid CMake.
|
||||
if(WIN32)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(_korman_system "windows64")
|
||||
else()
|
||||
set(_korman_system "windows32")
|
||||
endif()
|
||||
else()
|
||||
set(_korman_system "${CMAKE_SYSTEM_NAME}")
|
||||
endif()
|
||||
set(CPACK_PACKAGE_FILE_NAME "korman-${_korman_rev}-${_korman_system}")
|
||||
|
||||
set(CPACK_PACKAGE_CHECKSUM SHA256)
|
||||
|
||||
# Generate license file based on the install settings
|
||||
if(korman_INSTALL_BINARY_DIR OR korman_INSTALL_SCRIPTS)
|
||||
set(KORMAN_LICENSE "Korman is licensed under the GNU GPLv3.")
|
||||
file(READ "${PROJECT_SOURCE_DIR}/installer/GPLv3.txt" _license)
|
||||
string(APPEND LICENSE_TEXT "${_license}\n")
|
||||
endif()
|
||||
if(korman_INSTALL_BLENDER)
|
||||
set(BLENDER_LICENSE "Blender is licensed under the GNU GPLv2.")
|
||||
file(READ "${PROJECT_SOURCE_DIR}/installer/GPLv2.txt" _license)
|
||||
string(APPEND LICENSE_TEXT "${_license}\n")
|
||||
endif()
|
||||
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/installer/license.txt.in"
|
||||
"${PROJECT_BINARY_DIR}/license.txt"
|
||||
@ONLY
|
||||
)
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_BINARY_DIR}/license.txt")
|
||||
install(FILES
|
||||
"${PROJECT_BINARY_DIR}/license.txt"
|
||||
DESTINATION "."
|
||||
)
|
||||
|
||||
set(CPACK_COMPONENTS_ALL "Korman")
|
||||
set(CPACK_COMPONENTS_GROUPING "ALL_COMPONENTS_IN_ONE")
|
||||
set(CPACK_COMPONENT_KORMAN_HIDDEN TRUE)
|
||||
|
||||
if(korman_INSTALL_BLENDER)
|
||||
list(APPEND CPACK_PACKAGE_EXECUTABLES blender Blender)
|
||||
list(APPEND CPACK_COMPONENTS_ALL "Blender")
|
||||
set(CPACK_COMPONENT_BLENDER_HIDDEN TRUE)
|
||||
endif()
|
||||
|
||||
if(korman_HARVEST_PYTHON22)
|
||||
list(APPEND CPACK_COMPONENTS_ALL "Python22")
|
||||
set(CPACK_COMPONENT_PYTHON22_HIDDEN TRUE)
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
# We're not actually going to ship this variant, but better prepared than sorry.
|
||||
if(korman_HARVEST_VCREDIST)
|
||||
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS
|
||||
"ExecWait \\\"$INSTDIR\\\\${VCRedist_NAME} /q /norestart\\\""
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CPACK_WIX_UPGRADE_GUID 84ef4b1d-27b6-54de-a73b-8fb1beb007ac) # KormanUpgrade
|
||||
# I think this should be randomized by CPack and not hardcoded?
|
||||
#set(CPACK_WIX_PRODUCT_GUID 74e91f5d-6d09-5d7f-a48f-3d0b011ef2df) # KormanProduct
|
||||
|
||||
find_package(VCRedist COMPONENTS MergeModules REQUIRED)
|
||||
configure_file(
|
||||
"${PROJECT_SOURCE_DIR}/installer/WiX.template.in"
|
||||
"${PROJECT_BINARY_DIR}/WiX.template"
|
||||
@ONLY
|
||||
)
|
||||
set(CPACK_WIX_TEMPLATE "${PROJECT_BINARY_DIR}/WiX.template")
|
||||
|
||||
set(CPACK_WIX_UI_BANNER "${PROJECT_SOURCE_DIR}/installer/WIX_UI_BANNER.bmp")
|
||||
set(CPACK_WIX_UI_DIALOG "${PROJECT_SOURCE_DIR}/installer/WIX_UI_DIALOG.bmp")
|
||||
|
||||
set(CPACK_WIX_ROOT_FEATURE_TITLE "Blender for Korman")
|
||||
|
||||
# Great release compression. Change it to "none" to iterate faster.
|
||||
set(CPACK_WIX_LIGHT_EXTRA_FLAGS -dcl:high)
|
||||
endif()
|
||||
|
||||
set(CPACK_ARCHIVE_THREADS 0)
|
||||
|
||||
# Apparently this has to come last. Shaweet.
|
||||
include(CPack)
|
Reference in New Issue
Block a user