From cf0791555ce844e9b8a3dc87d7aebe04308a4acc Mon Sep 17 00:00:00 2001
From: Dilawar Singh <dilawars@ncbs.res.in>
Date: Tue, 6 Mar 2018 21:24:55 +0530
Subject: [PATCH] This passes locally.

---
 CMakeLists.txt               | 19 +++++++++++++------
 cmake/build_moose-core.sh.in | 12 ++++--------
 2 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 16f104f7..05ad3854 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -9,18 +9,18 @@ endif(POLICY CMP0048)
 # version file. If GIT fails, use the previous known version.
 find_program(GIT_EXEC "git")
 message( STATUS "Looking for git ${GIT_EXEC}" )
-if(VERSION_MOOSE)
-    message( STATUS "MOOSE version is set to ${VERSION_MOOSE} at build time" )
+if(VERSION)
+    message( STATUS "MOOSE version is set to ${VERSION} at build time" )
 elseif(GIT_EXEC)
     message( STATUS "Getting version by reading git tags" )
     execute_process( 
         COMMAND ${GIT_EXEC} describe --tags --long
         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-        OUTPUT_VARIABLE VERSION_MOOSE
+        OUTPUT_VARIABLE VERSION
         OUTPUT_STRIP_TRAILING_WHITESPACE
     )
 endif( )
-message( STATUS "Building version ${VERSION_MOOSE}" )
+message( STATUS "Building version ${VERSION}" )
 
 # Prefix
 message( STATUS "CMAKE_INSTALL_PREFIX= ${CMAKE_INSTALL_PREFIX}" )
@@ -66,7 +66,8 @@ configure_file(
     ${PYMOOSE_BUILD_DIR}/build_moose-core.sh 
     )
 
-# Build pymoose module.
+# Build pymoose module, create bdist and  and unarchive the bdist to
+# PYMOOSE_INSTALL_DIR.
 add_custom_target( moose-core DEPENDS ${OUTPUT_MOOSEBIN} )
 add_custom_command( OUTPUT ${OUTPUT_MOOSEBIN}
     COMMAND ${PYMOOSE_BUILD_DIR}/build_moose-core.sh
@@ -74,6 +75,12 @@ add_custom_command( OUTPUT ${OUTPUT_MOOSEBIN}
     COMMENT "Building pymoose in ${PYMOOSE_BUILD_DIR}"
     VERBATIM
     )
+add_custom_command( TARGET moose-core POST_BUILD 
+    COMMAND ${CMAKE_COMMAND} -E chdir ${PYMOOSE_INSTALL_DIR} tar xvf
+        ${PYMOOSE_BUILD_DIR}/bdist/pymoose-${VERSION}.CMAKE.tar.gz
+    COMMENT "Unarchiving pymoose bdist"
+    VERBATIM
+    )
 
 if(WITH_GUI)
     # Now build moose-gui and moose-examples.
@@ -135,7 +142,7 @@ add_custom_target(uninstall DEPENDS __uninstall_moose-core__ )
 add_custom_command(OUTPUT __uninstall_moose-core__
     COMMAND xargs rm -rf < install_manifest.txt
     COMMAND pip uninstall -y moose 
-    COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_INSTALL_PREFIX}/bin/moose.bin
+    COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_INSTALL_PREFIX}/bin/moosegui
     )
 
 if(WITH_GUI)
diff --git a/cmake/build_moose-core.sh.in b/cmake/build_moose-core.sh.in
index 8d766209..a737eeb2 100755
--- a/cmake/build_moose-core.sh.in
+++ b/cmake/build_moose-core.sh.in
@@ -7,10 +7,6 @@ set -e
 # will play well with cmake. CMAKE replaces @FOO@ and ${FOO} with cmake variable
 # values.
 
-if [ ! -n "$MAKE" ]; then
-    MAKE=make -j4
-fi
-
 echo "Building pymoose and creating bdist."
 export GSL_ROOT_DIR=@GSL_ROOT_DIR@
 export HDF5_ROOT=@HDF5_ROOT@
@@ -19,10 +15,10 @@ cmake -DCMAKE_INSTALL_PREFIX=@PYMOOSE_INSTALL_DIR@ \
     -DCMAKE_BUILD_TYPE=Release \
     -DWITH_BOOST=@WITH_BOOST@ \
     -DPYTHON_EXECUTABLE=@PYTHON_EXECUTABLE@ \
-    -DVERSION_MOOSE=@MOOSE_VERSION@ \
-    -DPYMOOSE_BDIST_DIR=@PYMOOSE_BDIST_DIR@ \
+    -DVERSION_MOOSE=@VERSION@ \
     @CMAKE_PYMOOSE_ARGS@ \
     @PYMOOSE_SOURCE_DIR@ 
-$MAKE
+
+make -j3
 ctest --output-on-failure || echo "Some tests failed"
-$MAKE bdist VERBOSE=1
+make bdist 
-- 
GitLab