Skip to content
Snippets Groups Projects
Commit 05423608 authored by Martyn Gigg's avatar Martyn Gigg
Browse files

Fix cmake dependency issues with python package targets.

Refs #20381
parent b76b06c5
No related branches found
No related tags found
No related merge requests found
......@@ -4,16 +4,24 @@ find_package ( QScintillaQt4 REQUIRED )
include ( QtTargetFunctions )
# Function to create links to python packages in the source tree
# If the EXECUTABLE option is provided then it additional build rules are
# defined to ensure startup scripts are regenerated appropriately
function ( add_python_package pkg_name )
# Create a setup.py file
set ( _setup_py ${CMAKE_CURRENT_SOURCE_DIR}/setup.py )
set ( _egg_link_dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR} )
set ( _egg_link ${_egg_link_dir}/${pkg_name}.egg-link )
set ( _startup_script ${_egg_link_dir}/${pkg_name} )
if ( WIN32 )
set ( _startup_script ${_startup_script}.exe )
if ( ARGV0 EQUAL "EXECUTABLE" )
if ( WIN32 )
set ( _startup_script ${_egg_link_dir}/${pkg_name}-script.pyw )
set ( _startup_exe ${_egg_link_dir}/${pkg_name}.exe )
else ()
set ( _startup_script )
set ( _startup_exe ${_egg_link_dir}/${pkg_name} )
endif ()
endif ()
add_custom_command ( OUTPUT ${_egg_link} ${_startup_script}
set ( _outputs "${_egg_link} ${_startup_script} ${_startup_exe}" )
add_custom_command ( OUTPUT ${_outputs}
COMMAND ${CMAKE_COMMAND} -E env PYTHONPATH=${_egg_link_dir}
${PYTHON_EXECUTABLE} ${_setup_py} develop
--install-dir ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
......@@ -22,7 +30,7 @@ function ( add_python_package pkg_name )
DEPENDS ${_setup_py}
)
add_custom_target ( ${pkg_name} ALL
DEPENDS ${_egg_link_dir}/${pkg_name} ${_egg_link}
DEPENDS ${_outputs}
)
endfunction ()
......
# Creates egg link to binary output directory
add_python_package ( workbench )
add_python_package ( workbench EXECUTABLE )
add_dependencies ( workbench mantidqt )
# ctest targets
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment