-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
105 lines (93 loc) · 4.07 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# 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_minimum_required(VERSION 3.12)
set(_PROJECT_INFO
korman
VERSION 0.17
DESCRIPTION "Blender plugin for creating ages for Cyan Worlds' proprietary Plasma engine and its open source variant, CyanWorlds.com Engine."
LANGUAGES CXX # This should probably be NONE, but we need the compiler for string_theory tests
)
project(${_PROJECT_INFO})
include(CMakeDependentOption)
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/install" CACHE PATH "")
# TODO: Maybe use cmake_path (requires CMake 3.21) to ensure Blender_EXECUTABLE is not in the CMAKE_INSTALL_PREFIX?
# That would indicate that we are installing Korman into the blender we found, so no need to install blender.
option(korman_INSTALL_BLENDER "Copy Blender as part of the INSTALL target" ON)
option(korman_INSTALL_SCRIPTS "Copy Korman python scripts as part of the INSTALL target" ON)
option(korman_INSTALL_PACKAGE "Buid Korman CPack installers" ON)
# While, yes, we could tie our build process into Blender's, Blender pulls in
# tons of dependencies and can be quite slow if you start trying to build
# errthang from source. So, we'll jst let you handle that. Good luck!
if(NOT "${Blender_PYTHON_VERSION}" OR korman_INSTALL_BLENDER)
set(_Blender_REQUIRED "REQUIRED")
elseif("${Blender_PYTHON_VERSION}" AND NOT "${Blender_PYTHON_VERSION}" MATCHES "^[0-9]+\\.[0-9]+$")
message(FATAL_ERROR "Your manually defined Blender python version ($CACHE{Blender_PYTHON_VERSION}) doesn't pass muster.")
endif()
find_package(Blender 2.79 EXACT ${_Blender_REQUIRED})
if(NOT Blender_FOUND)
set(Blender_VERSION "2.79")
endif()
# Gotta do this because libHSPlasma is still using the old broke-ass pre-3.12 find modules.
set(Python3_FIND_STRATEGY VERSION)
find_package(Python3 ${Blender_PYTHON_VERSION} EXACT COMPONENTS Development Interpreter REQUIRED)
include(Dependencies)
if(korman_INSTALL_PACKAGE)
include(Packaging)
endif()
if(korman_INSTALL_SCRIPTS)
set(korman_INSTALL_SCRIPTS_PATH "${Blender_VERSION}/scripts/addons" CACHE STRING "")
install(DIRECTORY
"${CMAKE_SOURCE_DIR}/korman"
DESTINATION "${korman_INSTALL_SCRIPTS_PATH}"
COMPONENT "Korman"
FILES_MATCHING
PATTERN "*.py"
)
endif()
# When we update to CMake 3.21, it might be worth separating the dependency build
# and Korman build a little more and using install(TARGETS RUNTIME_DEPENDENCIES). For now,
# this causes no observable problems and gives a good result, so meh.
set(korman_INSTALL_BINARY_DIR "${Blender_VERSION}/python/lib/site-packages" CACHE STRING "")
install(DIRECTORY
"${korman_HARVEST_DIR}/bin/"
DESTINATION "${korman_INSTALL_BINARY_DIR}"
COMPONENT "Korman"
FILES_MATCHING
PATTERN "*.dll"
PATTERN "*.pyd"
PATTERN "*.so"
)
if(korman_INSTALL_BLENDER)
get_filename_component(_Blender_PATH "${Blender_EXECUTABLE}" DIRECTORY)
install(DIRECTORY
"${_Blender_PATH}/"
DESTINATION "."
COMPONENT "Blender"
FILES_MATCHING
PATTERN "*"
# Don't install any korman stuff in the Blender install (yikes)
PATTERN "korman" EXCLUDE
PATTERN "__pycache__" EXCLUDE
REGEX [[vc[_.]?redist[_.]?x[0-9][0-9].exe]] EXCLUDE
)
endif()
if(korman_HARVEST_PYTHON22)
install(PROGRAMS
"${korman_HARVEST_DIR}/bin/Python-2.2.3.exe"
DESTINATION "."
COMPONENT "Python22"
)
endif()