-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
76 lines (66 loc) · 2.36 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
cmake_minimum_required(VERSION 3.14)
include(FetchContent)
include(RezBuild)
# Show download progress
set(FETCHCONTENT_QUIET OFF)
# Download and unpack the mGear release
FetchContent_Declare(mgear URL $ENV{FETCH_URL})
FetchContent_MakeAvailable(mgear)
# Copy download to build directory to make it easier to compare and avoid
# redownloading
file(COPY "${mgear_SOURCE_DIR}/release/" DESTINATION ${mgear_BINARY_DIR})
file(RELATIVE_PATH build_subpath ${CMAKE_SOURCE_DIR} ${mgear_BINARY_DIR})
# Generate a new .mod file with only the platform being targeted
if(WIN32)
set(maya_module_platform "win64")
else()
set(maya_module_platform $ENV{REZ_PLATFORM_VERSION})
endif()
file(
WRITE "${mgear_BINARY_DIR}/mGear.mod"
"+ MAYAVERSION:$ENV{REZ_MAYA_MAJOR_VERSION} PLATFORM:${maya_module_platform} \
$ENV{REZ_BUILD_PROJECT_NAME} $ENV{REZ_BUILD_PROJECT_VERSION} .")
# Prepare and install Python files
file(GLOB_RECURSE py_files "${mgear_BINARY_DIR}/scripts/*.py")
foreach(py_file ${py_files})
if(UNIX)
execute_process(COMMAND dos2unix --keepdate --oldfile ${py_file})
# Some files have not been made Python 3 compatible
execute_process(COMMAND sed -i -E "s/^(\\s+)print (.+)/\\1print(\\2)/"
${py_file})
endif(UNIX)
if(WIN32)
# Some files have not been made Python 3 compatible
execute_process(
COMMAND
powershell -Command
"(get-content ${py_file}) | %{$_ -replace '^(\\s+)print (.+)', '\${1}print(\${2})'} | set-content ${py_file}"
COMMAND_ECHO STDOUT)
endif(WIN32)
endforeach()
# rez_install_python hardcodes the executable name, so use install_python
# directly
install_python(
py
FILES
${py_files}
RELATIVE
${build_subpath}
BIN
$ENV{PYTHON_EXE}
DESTINATION
.)
# Prepare and install other script files next to the Python files
file(GLOB_RECURSE script_files "${mgear_BINARY_DIR}/scripts/*")
list(FILTER script_files EXCLUDE REGEX "\.py$")
rez_install_files(${script_files} RELATIVE ${build_subpath} DESTINATION .)
# Install icons
rez_install_dirs("${mgear_BINARY_DIR}/icons" DESTINATION .)
# Install the platform-specific plug-ins
rez_install_dirs(
"${mgear_BINARY_DIR}/platforms/$ENV{REZ_MAYA_MAJOR_VERSION}/$ENV{REZ_PLATFORM_VERSION}/x64/"
DESTINATION
.)
# Install the custom .mod file
rez_install_files("${mgear_BINARY_DIR}/mGear.mod" RELATIVE ${build_subpath}
DESTINATION .)