-
-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CMakeLists.txt to build extension
- Loading branch information
Showing
4 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
cmake_minimum_required(VERSION 3.25) | ||
project(BlendLuxCore LANGUAGES NONE) | ||
|
||
file(MAKE_DIRECTORY build) | ||
|
||
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 "Blender version: ${version}") | ||
if (${version} VERSION_LESS "4.2.0") | ||
message(FATAL_ERROR "Bad Blender version - 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 | ||
execute_process( | ||
COMMAND python | ||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/blendluxcore_version.py | ||
${CMAKE_CURRENT_SOURCE_DIR}/blender_manifest.toml | ||
OUTPUT_VARIABLE BLC_VERSION | ||
) | ||
|
||
find_program(BLENDER blender NAMES blender.exe VALIDATOR validate_blender_version NO_CACHE) | ||
|
||
# Add BlendLuxCore target | ||
add_custom_target( | ||
extension ALL | ||
COMMAND ${BLENDER} | ||
--command extension build | ||
--source-dir ${CMAKE_CURRENT_SOURCE_DIR} | ||
--output-filepath ${CMAKE_CURRENT_BINARY_DIR}/build/BlendLuxCore-${BLC_VERSION}.zip | ||
VERBATIM | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Retrieve BlendLuxCore version from blender_manifest.toml""" | ||
import tomllib | ||
import os | ||
from pathlib import Path | ||
import argparse | ||
|
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument("filepath", type=Path) | ||
args = parser.parse_args() | ||
|
||
with open(args.filepath, 'rb') as fp: | ||
manifest = tomllib.load(fp) | ||
version = manifest['version'] | ||
print(version, end='') |