From 844fbec36fe830be36e96d8d64f3fa1a289c151f Mon Sep 17 00:00:00 2001
From: NissimHadar <nissim.hadar@gmail.com>
Date: Sat, 4 May 2019 18:09:54 -0700
Subject: [PATCH] So that both Jenkins and local Mac are happy.

---
 cmake/macros/FixupInterface.cmake | 44 ++++++++++++++++--------------
 cmake/macros/FixupNitpick.cmake   | 45 +++++++++++++++++--------------
 tools/nitpick/src/Nitpick.cpp     | 11 ++++----
 tools/nitpick/src/Nitpick.h       |  5 ++--
 4 files changed, 58 insertions(+), 47 deletions(-)

diff --git a/cmake/macros/FixupInterface.cmake b/cmake/macros/FixupInterface.cmake
index 93b5cc25fb..e1ade61c7a 100644
--- a/cmake/macros/FixupInterface.cmake
+++ b/cmake/macros/FixupInterface.cmake
@@ -10,28 +10,32 @@
 #
 
 macro(fixup_interface)
-  if (APPLE)
+    if (APPLE)
+        string(REPLACE " " "\\ " ESCAPED_BUNDLE_NAME ${INTERFACE_BUNDLE_NAME})
+        string(REPLACE " " "\\ " ESCAPED_INSTALL_PATH ${INTERFACE_INSTALL_DIR})
+        set(_INTERFACE_INSTALL_PATH "${ESCAPED_INSTALL_PATH}/${ESCAPED_BUNDLE_NAME}.app")
 
-    string(REPLACE " " "\\ " ESCAPED_BUNDLE_NAME ${INTERFACE_BUNDLE_NAME})
-    string(REPLACE " " "\\ " ESCAPED_INSTALL_PATH ${INTERFACE_INSTALL_DIR})
-    set(_INTERFACE_INSTALL_PATH "${ESCAPED_INSTALL_PATH}/${ESCAPED_BUNDLE_NAME}.app")
+        find_program(MACDEPLOYQT_COMMAND macdeployqt PATHS "${QT_DIR}/bin" NO_DEFAULT_PATH)
 
-    find_program(MACDEPLOYQT_COMMAND macdeployqt PATHS "${QT_DIR}/bin" NO_DEFAULT_PATH)
+        if (NOT MACDEPLOYQT_COMMAND AND (PRODUCTION_BUILD OR PR_BUILD))
+            message(FATAL_ERROR "Could not find macdeployqt at ${QT_DIR}/bin.\
+                It is required to produce an relocatable interface application.\
+                Check that the variable QT_DIR points to your Qt installation.\
+            ")
+        endif ()
 
-    if (NOT MACDEPLOYQT_COMMAND AND (PRODUCTION_BUILD OR PR_BUILD))
-      message(FATAL_ERROR "Could not find macdeployqt at ${QT_DIR}/bin.\
-        It is required to produce an relocatable interface application.\
-        Check that the environment variable QT_DIR points to your Qt installation.\
-      ")
+        if (DEV_BUILD)
+            install(CODE "
+                execute_process(COMMAND ${MACDEPLOYQT_COMMAND}\
+                    \${CMAKE_INSTALL_PREFIX}/${_INTERFACE_INSTALL_PATH}/\
+                    -verbose=2 -qmldir=${CMAKE_SOURCE_DIR}/interface/resources/qml/\
+                )"
+                COMPONENT ${CLIENT_COMPONENT}
+            )
+        else ()
+            add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
+                COMMAND ${MACDEPLOYQT_COMMAND} "$<TARGET_FILE_DIR:${TARGET_NAME}>/../.." -verbose=2 -qmldir=${CMAKE_SOURCE_DIR}/interface/resources/qml/
+            )
+        endif()
     endif ()
-
-    install(CODE "
-      execute_process(COMMAND ${MACDEPLOYQT_COMMAND}\
-        \${CMAKE_INSTALL_PREFIX}/${_INTERFACE_INSTALL_PATH}/\
-        -verbose=2 -qmldir=${CMAKE_SOURCE_DIR}/interface/resources/qml/\
-      )"
-      COMPONENT ${CLIENT_COMPONENT}
-    )
-
-  endif ()
 endmacro()
diff --git a/cmake/macros/FixupNitpick.cmake b/cmake/macros/FixupNitpick.cmake
index 8477b17823..0930019197 100644
--- a/cmake/macros/FixupNitpick.cmake
+++ b/cmake/macros/FixupNitpick.cmake
@@ -10,27 +10,32 @@
 #
 
 macro(fixup_nitpick)
-  if (APPLE)
-    string(REPLACE " " "\\ " ESCAPED_BUNDLE_NAME ${NITPICK_BUNDLE_NAME})
-    string(REPLACE " " "\\ " ESCAPED_INSTALL_PATH ${NITPICK_INSTALL_DIR})
-    set(_NITPICK_INSTALL_PATH "${ESCAPED_INSTALL_PATH}/${ESCAPED_BUNDLE_NAME}.app")
+    if (APPLE)
+        string(REPLACE " " "\\ " ESCAPED_BUNDLE_NAME ${NITPICK_BUNDLE_NAME})
+        string(REPLACE " " "\\ " ESCAPED_INSTALL_PATH ${NITPICK_INSTALL_DIR})
+        set(_NITPICK_INSTALL_PATH "${ESCAPED_INSTALL_PATH}/${ESCAPED_BUNDLE_NAME}.app")
 
-    find_program(MACDEPLOYQT_COMMAND macdeployqt PATHS "${QT_DIR}/bin" NO_DEFAULT_PATH)
+        find_program(MACDEPLOYQT_COMMAND macdeployqt PATHS "${QT_DIR}/bin" NO_DEFAULT_PATH)
 
-    if (NOT MACDEPLOYQT_COMMAND AND (PRODUCTION_BUILD OR PR_BUILD))
-      message(FATAL_ERROR "Could not find macdeployqt at ${QT_DIR}/bin.\
-        It is required to produce a relocatable nitpick application.\
-        Check that the environment variable QT_DIR points to your Qt installation.\
-      ")
+        if (NOT MACDEPLOYQT_COMMAND AND (PRODUCTION_BUILD OR PR_BUILD))
+            message(FATAL_ERROR "Could not find macdeployqt at ${QT_DIR}/bin.\
+                It is required to produce a relocatable nitpick application.\
+                Check that the variable QT_DIR points to your Qt installation.\
+            ")
+        endif ()
+
+        if (DEV_BUILD)
+            install(CODE "
+                execute_process(COMMAND ${MACDEPLOYQT_COMMAND}\
+                    \${CMAKE_INSTALL_PREFIX}/${_NITPICK_INSTALL_PATH}/\
+                    -verbose=2 -qmldir=${CMAKE_SOURCE_DIR}/interface/resources/qml/\
+                )"
+                COMPONENT ${CLIENT_COMPONENT}
+            )
+        else ()
+            add_custom_command(TARGET ${TARGET_NAME} POST_BUILD
+                COMMAND ${MACDEPLOYQT_COMMAND} "$<TARGET_FILE_DIR:${TARGET_NAME}>/../.." -verbose=2 -qmldir=${CMAKE_SOURCE_DIR}/interface/resources/qml/
+            )
+        endif()
     endif ()
-
-    install(CODE "
-      execute_process(COMMAND ${MACDEPLOYQT_COMMAND}\
-        \${CMAKE_INSTALL_PREFIX}/${_NITPICK_INSTALL_PATH}/\
-        -verbose=2 -qmldir=${CMAKE_SOURCE_DIR}/interface/resources/qml/\
-      )"
-      COMPONENT ${CLIENT_COMPONENT}
-    )
-
-  endif ()
 endmacro()
diff --git a/tools/nitpick/src/Nitpick.cpp b/tools/nitpick/src/Nitpick.cpp
index 16cad8726c..3bed7cde65 100644
--- a/tools/nitpick/src/Nitpick.cpp
+++ b/tools/nitpick/src/Nitpick.cpp
@@ -192,14 +192,19 @@ void Nitpick::on_createTestsOutlinePushbutton_clicked() {
     _testCreator->createTestsOutline();
 }
 
+// TestRail interface
 void Nitpick::on_createTestRailTestCasesPushbutton_clicked() {
     _testCreator->createTestRailTestCases();
 }
 
-void Nitpick::on_createTestRailRunButton_clicked() {
+void Nitpick::on_createTestRailRunPushButton_clicked() {
     _testCreator->createTestRailRun();
 }
 
+void Nitpick::on_updateTestRailRunResultsPushbutton_clicked() {
+    _testCreator->updateTestRailRunResult();
+}
+
 void Nitpick::on_setWorkingFolderRunOnDesktopPushbutton_clicked() {
     _testRunnerDesktop->setWorkingFolderAndEnableControls();
 }
@@ -231,10 +236,6 @@ void Nitpick::automaticTestRunEvaluationComplete(QString zippedFolderName, int n
     _testRunnerDesktop->automaticTestRunEvaluationComplete(zippedFolderName, numberOfFailures);
 }
 
-void Nitpick::on_updateTestRailRunResultsPushbutton_clicked() {
-    _testCreator->updateTestRailRunResult();
-}
-
 // To toggle between show and hide
 //   if (uState & ABS_AUTOHIDE) on_showTaskbarButton_clicked();
 //   else on_hideTaskbarButton_clicked();
diff --git a/tools/nitpick/src/Nitpick.h b/tools/nitpick/src/Nitpick.h
index 9aa0ea00ba..d1f077a344 100644
--- a/tools/nitpick/src/Nitpick.h
+++ b/tools/nitpick/src/Nitpick.h
@@ -65,8 +65,10 @@ private slots:
 
     void on_createTestsOutlinePushbutton_clicked();
 
+    // TestRail interface
     void on_createTestRailTestCasesPushbutton_clicked();
-    void on_createTestRailRunButton_clicked();
+    void on_createTestRailRunPushButton_clicked();
+    void on_updateTestRailRunResultsPushbutton_clicked();
 
     void on_setWorkingFolderRunOnDesktopPushbutton_clicked();
     void on_runNowPushbutton_clicked();
@@ -75,7 +77,6 @@ private slots:
     void on_runLatestOnDesktopCheckBox_clicked();
     void on_runFullSuiteOnDesktopCheckBox_clicked();
 
-    void on_updateTestRailRunResultsPushbutton_clicked();
 
     void on_hideTaskbarPushbutton_clicked();
     void on_showTaskbarPushbutton_clicked();