From f02531e224fb248793c7e1062472292a7624187e Mon Sep 17 00:00:00 2001
From: Martyn Gigg <martyn.gigg@stfc.ac.uk>
Date: Mon, 2 Jun 2014 08:13:47 +0100
Subject: [PATCH] Use cmake variable to set MantidPlot used for docs build

This will allow us to use a package rather than a fresh build if
necessary.
Refs #9521
---
 Code/Mantid/docs/CMakeLists.txt  | 15 ++++++++-------
 Code/Mantid/docs/runsphinx.py.in |  2 +-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Code/Mantid/docs/CMakeLists.txt b/Code/Mantid/docs/CMakeLists.txt
index 4f19643c586..e9dac87df73 100644
--- a/Code/Mantid/docs/CMakeLists.txt
+++ b/Code/Mantid/docs/CMakeLists.txt
@@ -4,20 +4,21 @@
 find_package ( Sphinx )
 
 if ( SPHINX_FOUND )
-  # Fill in the config file and autogen file with build information
-  
-  # We generate a target per build type, i.e docs-html
-  set ( SPHINX_BUILD ${CMAKE_BINARY_DIR}/docs )
-  set ( SCREENSHOTS_DIR ${SPHINX_BUILD}/screenshots )
+  # We generate a target per build type, i.e docs-html, docs-test
+  set ( SPHINX_BUILD_DIR ${CMAKE_BINARY_DIR}/docs )
+  set ( SCREENSHOTS_DIR ${SPHINX_BUILD_DIR}/screenshots )
 
   # targets
   set ( TARGET_PREFIX docs)
+  # runner - default=current build
+  set ( DOCS_RUNNER_EXE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/MantidPlot CACHE FILEPATH 
+                        "MantidPlot executable to use to build the documentation" )
 
   # HTML target
   set ( BUILDER html )
   configure_file ( runsphinx.py.in runsphinx_html.py @ONLY )
   add_custom_target ( ${TARGET_PREFIX}-html
-    COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/MantidPlot -xq runsphinx_html.py
+    COMMAND ${DOCS_RUNNER_EXE} -xq runsphinx_html.py
     COMMENT "Building html documentation"
   )
 
@@ -25,7 +26,7 @@ if ( SPHINX_FOUND )
   set ( BUILDER doctest )
   configure_file ( runsphinx.py.in runsphinx_doctest.py @ONLY )
   add_custom_target ( ${TARGET_PREFIX}-test
-    COMMAND ${PYTHON_EXECUTABLE} runsphinx_doctest.py
+    COMMAND ${DOCS_RUNNER_EXE} -xq runsphinx_doctest.py
     COMMENT "Running documentation tests"
   )
 
diff --git a/Code/Mantid/docs/runsphinx.py.in b/Code/Mantid/docs/runsphinx.py.in
index 8d1011908dd..45724dc86fe 100644
--- a/Code/Mantid/docs/runsphinx.py.in
+++ b/Code/Mantid/docs/runsphinx.py.in
@@ -12,7 +12,7 @@ mantidplot = "@CMAKE_RUNTIME_OUTPUT_DIRECTORY@/MantidPlot"
 builder = "@BUILDER@"
 src_dir = "@CMAKE_CURRENT_SOURCE_DIR@/source"
 screenshots_dir = "@SCREENSHOTS_DIR@"
-output_dir = os.path.join("@SPHINX_BUILD@", builder)
+output_dir = os.path.join("@SPHINX_BUILD_DIR@", builder)
 
 # set environment
 os.environ["SCREENSHOTS_DIR"] = screenshots_dir
-- 
GitLab