|
1 | 1 | # To build extension: |
2 | | -# Get out of the tree, for instance in .. |
3 | | -# cmake -B blc-build -S BlendLuxCore && cmake --build blc-build |
| 2 | +# cmake . && cmake --build . |
4 | 3 |
|
5 | 4 | cmake_minimum_required(VERSION 3.25) |
6 | 5 |
|
7 | | -set(CMAKE_DISABLE_SOURCE_CHANGES ON) |
8 | | -set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) |
9 | 6 | if(NOT CMAKE_BUILD_TYPE) |
10 | 7 | set(CMAKE_BUILD_TYPE "Release") |
11 | 8 | endif() |
12 | 9 |
|
13 | 10 | project(BlendLuxCore LANGUAGES NONE) |
14 | | -if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") |
15 | | - message(SEND_ERROR "In-source builds are not allowed.") |
16 | | -endif() |
| 11 | +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/out) |
| 12 | + |
| 13 | +# Create output directory (otherwise Blender complains) |
| 14 | +file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) |
| 15 | + |
17 | 16 |
|
18 | 17 | function(validate_blender_version result blender) |
19 | 18 | execute_process( |
@@ -53,10 +52,23 @@ endif() |
53 | 52 | find_program(BLENDER blender NAMES blender.exe VALIDATOR validate_blender_version NO_CACHE REQUIRED) |
54 | 53 |
|
55 | 54 | # Add BlendLuxCore target |
| 55 | +# https://docs.blender.org/manual/en/latest/advanced/command_line/extension_arguments.html |
56 | 56 | add_custom_target( |
57 | 57 | extension ALL ${BLENDER} |
58 | 58 | --command extension build |
59 | 59 | --source-dir ${CMAKE_CURRENT_SOURCE_DIR} |
60 | | - --output-filepath ${CMAKE_CURRENT_BINARY_DIR}/BlendLuxCore-${BLC_VERSION}.zip |
| 60 | + --output-filepath ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlendLuxCore-${BLC_VERSION}.zip |
61 | 61 | VERBATIM |
62 | 62 | ) |
| 63 | + |
| 64 | +# Add install |
| 65 | +# cmake --install . |
| 66 | +install(CODE " |
| 67 | + execute_process( |
| 68 | + COMMAND ${BLENDER} --command extension install-file -r blender_org ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/BlendLuxCore-${BLC_VERSION}.zip |
| 69 | + OUTPUT_VARIABLE INSTALL_OUTPUT |
| 70 | + ERROR_VARIABLE INSTALL_OUTPUT |
| 71 | + ) |
| 72 | + message(STATUS \"Blender output: \${INSTALL_OUTPUT}\") |
| 73 | +
|
| 74 | + ") |
0 commit comments