From b2dd8e1d5ae31b442d36765e822d5283ef178bdc Mon Sep 17 00:00:00 2001 From: Daljit Singh Date: Tue, 2 Jul 2024 12:06:28 +0100 Subject: [PATCH] New EXTERNAL_PROJECT_COMMAND input for MakePythonExecutable.cmake To handle the installation of external Python commands, a new option for MakePythonExecutable is added to set a different location for the library files. --- cmake/MakePythonExecutable.cmake | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cmake/MakePythonExecutable.cmake b/cmake/MakePythonExecutable.cmake index b20cbbb878..65678cf413 100644 --- a/cmake/MakePythonExecutable.cmake +++ b/cmake/MakePythonExecutable.cmake @@ -2,6 +2,14 @@ # Inputs: # - CMDNAME: Name of the command # - OUTPUT_DIR: Directory in which to create the executable +# - EXTERNAL_PROJECT_COMMAND: Boolean indicating whether the command is part of an MRtrix3 external project + +set(PYTHON_LIB_PATH "os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib'))") + +# For external projects the python library sources are located in ../mrtrix3/lib +if(EXTERNAL_PROJECT_COMMAND) + set(PYTHON_LIB_PATH "os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'mrtrix3', 'lib'))") +endif() set(BINPATH_CONTENTS "#!/usr/bin/python3\n" @@ -11,7 +19,7 @@ set(BINPATH_CONTENTS "import os\n" "import sys\n" "\n" - "mrtrix_lib_path = os.path.normpath(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir, 'lib'))\n" + "mrtrix_lib_path = ${PYTHON_LIB_PATH}\n" "sys.path.insert(0, mrtrix_lib_path)\n" "from mrtrix3.app import _execute\n" "\n"