From 05423608c7e20696c69d63a35fa12b9f139d46e7 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@gmail.com> Date: Tue, 21 Nov 2017 17:32:54 +0000 Subject: [PATCH] Fix cmake dependency issues with python package targets. Refs #20381 --- qt/CMakeLists.txt | 18 +++++++++++++----- qt/applications/workbench/CMakeLists.txt | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/qt/CMakeLists.txt b/qt/CMakeLists.txt index 5f341c81f5f..82b42ecd9bc 100644 --- a/qt/CMakeLists.txt +++ b/qt/CMakeLists.txt @@ -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 () diff --git a/qt/applications/workbench/CMakeLists.txt b/qt/applications/workbench/CMakeLists.txt index 741841ff493..c6414f12390 100644 --- a/qt/applications/workbench/CMakeLists.txt +++ b/qt/applications/workbench/CMakeLists.txt @@ -1,5 +1,5 @@ # Creates egg link to binary output directory -add_python_package ( workbench ) +add_python_package ( workbench EXECUTABLE ) add_dependencies ( workbench mantidqt ) # ctest targets -- GitLab