From dd3b047f8b4d7aa2155fb9b3570f536240dbd06f Mon Sep 17 00:00:00 2001 From: Eric Cosky Date: Tue, 13 Oct 2020 08:45:22 -0600 Subject: Windows/CMake:Support BLENDER_USER_SCRIPTS in IDE This diff adds support for respecting the `BLENDER_USER_SCRIPTS` environment variable when setting up the IDE environment. Previously the scripts from the users profile folder were always used even when this variable was set, leading to the possibility of the wrong scripts being visible in the IDE. Differential Revision: https://developer.blender.org/D9189 Reviewed By: Ray Molenkamp --- build_files/cmake/platform/platform_win32.cmake | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake index 2dd8d5f4600..e7474b0035d 100644 --- a/build_files/cmake/platform/platform_win32.cmake +++ b/build_files/cmake/platform/platform_win32.cmake @@ -720,14 +720,24 @@ if(WINDOWS_PYTHON_DEBUG) string(REPLACE "/" "\\" _group_path "${_source_path}") source_group("${_group_path}" FILES "${_source}") endforeach() - # Include the user scripts from the profile folder in the blender_python_user_scripts project. - set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender foundation/blender/${BLENDER_VERSION}") + + # If the user scripts env var is set, include scripts from there otherwise + # include user scripts in the profile folder. + if(DEFINED ENV{BLENDER_USER_SCRIPTS}) + message(STATUS "Including user scripts from environment BLENDER_USER_SCRIPTS=$ENV{BLENDER_USER_SCRIPTS}") + set(USER_SCRIPTS_ROOT "$ENV{BLENDER_USER_SCRIPTS}") + else() + message(STATUS "Including user scripts from the profile folder") + # Include the user scripts from the profile folder in the blender_python_user_scripts project. + set(USER_SCRIPTS_ROOT "$ENV{appdata}/blender foundation/blender/${BLENDER_VERSION}/scripts") + endif() + file(TO_CMAKE_PATH ${USER_SCRIPTS_ROOT} USER_SCRIPTS_ROOT) - FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/scripts/*.*" ) + FILE(GLOB_RECURSE inFiles "${USER_SCRIPTS_ROOT}/*.*" ) ADD_CUSTOM_TARGET(blender_python_user_scripts SOURCES ${inFiles}) foreach(_source IN ITEMS ${inFiles}) get_filename_component(_source_path "${_source}" PATH) - string(REPLACE "${USER_SCRIPTS_ROOT}/scripts" "" _source_path "${_source_path}") + string(REPLACE "${USER_SCRIPTS_ROOT}" "" _source_path "${_source_path}") string(REPLACE "/" "\\" _group_path "${_source_path}") source_group("${_group_path}" FILES "${_source}") endforeach() -- cgit v1.2.3