Great.
So, @jcfr and @lassoan, since this is my first time contributing to open source, like ctk, I will need your guidance throughout the process of making these changes.
Following @jcfr’s suggested hints, here’s what I did:
Firstly, I’ve used this version of ctk_compile_python_scripts.cmake.in
. I’ve also defined an option at the top of the file ctkMacroCompilePythonScript.cmake
:
# For default behavior
set(CTK_COMPILE_PYTHON_SCRIPT_SKIP_SCRIPT_COPY FALSE)
Then,
In ctkFunctionAddCompilePythonScriptTargets
function , I’ve made the following changes:
if(NOT MY_GLOBAL_TARGET)
ctkFunctionAddCompilePythonScriptTargets(${target} ${CTK_COMPILE_PYTHON_SCRIPT_SKIP_SCRIPT_COPY})
endif()
function(ctkFunctionAddCompilePythonScriptTargets target SKIP_SCRIPT_COPY)
if (NOT ${SKIP_SCRIPT_COPY})
_ctk_add_copy_python_files_target(${target} Script ${ARGN})
endif()
_ctk_add_copy_python_files_target(${target} Resource ${ARGN})
_ctk_add_compile_python_directories_target(${target})
endfunction()
and in Slicer/CmakeLists.txt:
# Create targets CopySlicerPython{Resource, Script}Files, CompileSlicerPythonFiles
if(Slicer_USE_PYTHONQT)
slicerFunctionAddPythonQtResourcesTargets(SlicerPythonResources)
ctkFunctionAddCompilePythonScriptTargets(
${CTK_COMPILE_PYTHON_SCRIPTS_GLOBAL_TARGET_NAME}
${CTK_COMPILE_PYTHON_SCRIPT_SKIP_SCRIPT_COPY}
DEPENDS SlicerPythonResources
)
....
Finally,
In SlicerConfig.cmake.in
, I’m setting up the flag of CTK_COMPILE_PYTHON_SCRIPT_SKIP_SCRIPT_COPY
to be TRUE
:
set(CTK_COMPILE_PYTHON_SCRIPT_SKIP_SCRIPT_COPY TRUE)
If I understood correctly, when the `SKIP_SCRIPT_COPY` argument is set to TRUE, I don't think the compilation step will work, since `CompileSlicerPythonFiles` depends on `CopySlicerPythonScriptFiles` target. Is this correct, or did I make a mistake in the changes?