forked from LuxCoreRender/BlendLuxCore
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
74 lines (62 loc) · 2.17 KB
/
CMakeLists.txt
File metadata and controls
74 lines (62 loc) · 2.17 KB
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
# To build extension:
# cmake . && cmake --build .
cmake_minimum_required(VERSION 3.25)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
project(BlendLuxCore LANGUAGES NONE)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out)
# Create output directory (otherwise Blender complains)
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
function(validate_blender_version result blender)
execute_process(
COMMAND ${blender} --version
OUTPUT_VARIABLE blender_output
)
if (blender_output MATCHES "Blender ([0-9]+\.[0-9]+\.[0-9]+).*")
set(version ${CMAKE_MATCH_1})
message(STATUS "Found Blender - version ${version}")
if (${version} VERSION_LESS "4.2.0")
message(FATAL_ERROR "ERROR: Blender version is not suitable - expected 4.2.0 or higher")
set(${result} FALSE PARENT_SCOPE)
else()
message(STATUS "Blender version OK")
set(${result} TRUE PARENT_SCOPE)
endif()
else()
message(FATAL_ERROR "Blender version: Not found")
set(${result} FALSE PARENT_SCOPE)
endif()
endfunction()
# Get BlendLuxCore version
find_package(Python 3.11 REQUIRED COMPONENTS Interpreter)
if (CMAKE_BUILD_TYPE STREQUAL "Latest")
set(BLC_VERSION "Latest")
else()
execute_process(
COMMAND python
${CMAKE_CURRENT_SOURCE_DIR}/cmake/blendluxcore_version.py
${CMAKE_CURRENT_SOURCE_DIR}/blender_manifest.toml
OUTPUT_VARIABLE BLC_VERSION
)
endif()
find_program(BLENDER blender NAMES blender.exe VALIDATOR validate_blender_version NO_CACHE REQUIRED)
# Add BlendLuxCore target
# https://docs.blender.org/manual/en/latest/advanced/command_line/extension_arguments.html
add_custom_target(
extension ALL ${BLENDER}
--command extension build
--source-dir ${CMAKE_CURRENT_SOURCE_DIR}
--output-filepath ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlendLuxCore-${BLC_VERSION}.zip
VERBATIM
)
# Add install
# cmake --install .
install(CODE "
execute_process(
COMMAND ${BLENDER} --command extension install-file -r blender_org ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlendLuxCore-${BLC_VERSION}.zip
OUTPUT_VARIABLE INSTALL_OUTPUT
ERROR_VARIABLE INSTALL_OUTPUT
)
message(STATUS \"Blender output: \${INSTALL_OUTPUT}\")
")