gnucash unstable: Multiple changes pushed

Geert Janssens gjanssens at code.gnucash.org
Mon Jan 29 13:47:04 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/6e5ac260 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/c7415102 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4aa10620 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/f319a8e2 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/49a936c1 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/36cb167b (commit)
	 via  https://github.com/Gnucash/gnucash/commit/ec213360 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/9d8def84 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/4317d8a8 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/3dff4e52 (commit)
	 via  https://github.com/Gnucash/gnucash/commit/1258a2ad (commit)
	 via  https://github.com/Gnucash/gnucash/commit/b12a6cf4 (commit)
	from  https://github.com/Gnucash/gnucash/commit/86226723 (commit)



commit 6e5ac2608b51a8e6fd53da6e7366dd7424db0cfa
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Jan 27 14:12:27 2018 +0100

    More translation fixes detected by Mechtilde and reported on IRC

diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
index 238faf4..cccbd24 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
@@ -747,7 +747,7 @@ void CsvImpPriceAssist::preview_populate_settings_combo()
          * For now this is safe, because the shared pointers in this case are
          * long-lived, but this may need refactoring.
          */
-        gtk_list_store_set (GTK_LIST_STORE(model), &iter, SET_GROUP, preset.get(), SET_NAME, preset->m_name.c_str(), -1);
+        gtk_list_store_set (GTK_LIST_STORE(model), &iter, SET_GROUP, preset.get(), SET_NAME, _(preset->m_name.c_str()), -1);
     }
 }
 
diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
index a13ddae..2b8f55e 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
@@ -687,7 +687,7 @@ void CsvImpTransAssist::preview_populate_settings_combo()
          * For now this is safe, because the shared pointers in this case are
          * long-lived, but this may need refactoring.
          */
-        gtk_list_store_set (GTK_LIST_STORE(model), &iter, SET_GROUP, preset.get(), SET_NAME, preset->m_name.c_str(), -1);
+        gtk_list_store_set (GTK_LIST_STORE(model), &iter, SET_GROUP, preset.get(), SET_NAME, _(preset->m_name.c_str()), -1);
     }
 }
 

commit c7415102fd530ac72fe946c5accad5d7df957f88
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Jan 27 13:47:56 2018 +0100

    Fix a few more translation issues discovered during code review

diff --git a/gnucash/import-export/csv-imp/assistant-csv-account-import.glade b/gnucash/import-export/csv-imp/assistant-csv-account-import.glade
index 102da25..b119eb1 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-account-import.glade
+++ b/gnucash/import-export/csv-imp/assistant-csv-account-import.glade
@@ -309,7 +309,7 @@ Cancel to abort.</property>
           <object class="GtkLabel" id="summary_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">label</property>
+            <property name="label">label</property>
             <property name="use_markup">True</property>
           </object>
           <packing>
@@ -354,6 +354,9 @@ Cancel to abort.</property>
       <object class="GtkBox" id="assistant-action_area2">
         <property name="can_focus">False</property>
       </object>
+      <packing>
+        <property name="has_padding">False</property>
+      </packing>
     </child>
   </object>
 </interface>
diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
index 47a6f2b..238faf4 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.cpp
@@ -501,7 +501,7 @@ CsvImpPriceAssist::CsvImpPriceAssist ()
     file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
     g_signal_connect (G_OBJECT(file_chooser), "file-activated",
                       G_CALLBACK(csv_price_imp_file_confirm_cb), this);
-    auto button = gtk_button_new_with_label (_("OK"));
+    auto button = gtk_button_new_with_mnemonic (_("_OK"));
     gtk_widget_set_size_request (button, 100, -1);
     gtk_widget_show (button);
     auto h_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
@@ -1761,11 +1761,34 @@ void
 CsvImpPriceAssist::assist_summary_page_prepare ()
 {
     auto text = std::string("<span size=\"medium\"><b>");
-    text += _("The prices were imported from the file '") + m_file_name + "'.";
-    text += _("\n\nThere were ") + std::to_string(price_imp->m_prices_added);
-    text += _(" Prices added, ") + std::to_string(price_imp->m_prices_duplicated);
-    text += _(" duplicated and ") + std::to_string(price_imp->m_prices_replaced);
-    text += _(" replaced.</b></span>");
+    /* Translators: This is a ngettext(3) message, %d is the number of prices added */
+    auto added_str = g_strdup_printf (ngettext ("%d added price",
+                                                "%d added prices",
+                                                price_imp->m_prices_added),
+                                      price_imp->m_prices_added);
+    /* Translators: This is a ngettext(3) message, %d is the number of duplicate prices */
+    auto dupl_str = g_strdup_printf (ngettext ("%d duplicate price",
+                                               "%d duplicate prices",
+                                               price_imp->m_prices_duplicated),
+                                     price_imp->m_prices_duplicated);
+    /* Translators: This is a ngettext(3) message, %d is the number of replaced prices */
+    auto repl_str = g_strdup_printf (ngettext ("%d replaced price",
+                                               "%d replaced prices",
+                                               price_imp->m_prices_replaced),
+                                     price_imp->m_prices_replaced);
+    auto msg = g_strdup_printf (
+        _("The prices were imported from file '%s'.\n\n"
+          "Import summary:\n"
+          "- %s\n"
+          "- %s\n"
+          "- %s"),
+          m_file_name.c_str(), added_str, dupl_str,repl_str);
+    text += msg;
+    text += "</b></span>";
+
+    g_free (added_str);
+    g_free (dupl_str);
+    g_free (repl_str);
 
     gtk_label_set_markup (GTK_LABEL(summary_label), text.c_str());
 }
diff --git a/gnucash/import-export/csv-imp/assistant-csv-price-import.glade b/gnucash/import-export/csv-imp/assistant-csv-price-import.glade
index b1ba9c0..d465787 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-price-import.glade
+++ b/gnucash/import-export/csv-imp/assistant-csv-price-import.glade
@@ -73,6 +73,7 @@ Click on 'Forward' to proceed or 'Cancel' to Abort Import.</property>
       <packing>
         <property name="page_type">intro</property>
         <property name="complete">True</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
@@ -99,6 +100,7 @@ Select location and file name for the Import, then click 'OK'...
       </object>
       <packing>
         <property name="title" translatable="yes">Select File for Import</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
@@ -1048,6 +1050,7 @@ For example
       <packing>
         <property name="page_type">intro</property>
         <property name="complete">True</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
@@ -1082,6 +1085,7 @@ Cancel to abort.</b></property>
       <packing>
         <property name="page_type">confirm</property>
         <property name="title" translatable="yes">Import Prices Now</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child>
@@ -1094,7 +1098,7 @@ Cancel to abort.</b></property>
           <object class="GtkLabel" id="summary_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">label</property>
+            <property name="label">label</property>
             <property name="use_markup">True</property>
             <property name="wrap">True</property>
           </object>
@@ -1109,6 +1113,7 @@ Cancel to abort.</b></property>
         <property name="page_type">summary</property>
         <property name="title" translatable="yes">Import Summary</property>
         <property name="complete">True</property>
+        <property name="has_padding">False</property>
       </packing>
     </child>
     <child internal-child="action_area">
@@ -1116,6 +1121,7 @@ Cancel to abort.</b></property>
         <property name="can_focus">False</property>
       </object>
       <packing>
+        <property name="has_padding">False</property>
       </packing>
     </child>
   </object>
diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
index f593a0c..a13ddae 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
+++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.cpp
@@ -423,7 +423,7 @@ CsvImpTransAssist::CsvImpTransAssist ()
     file_chooser = gtk_file_chooser_widget_new (GTK_FILE_CHOOSER_ACTION_OPEN);
     g_signal_connect (G_OBJECT(file_chooser), "file-activated",
                       G_CALLBACK(csv_tximp_file_confirm_cb), this);
-    auto button = gtk_button_new_with_label (_("OK"));
+    auto button = gtk_button_new_with_mnemonic (_("_OK"));
     gtk_widget_set_size_request (button, 100, -1);
     gtk_widget_show (button);
     auto h_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
diff --git a/gnucash/import-export/csv-imp/assistant-csv-trans-import.glade b/gnucash/import-export/csv-imp/assistant-csv-trans-import.glade
index c15f378..3a7300b 100644
--- a/gnucash/import-export/csv-imp/assistant-csv-trans-import.glade
+++ b/gnucash/import-export/csv-imp/assistant-csv-trans-import.glade
@@ -1174,7 +1174,7 @@ More information can be displayed by using the help button.</property>
           <object class="GtkLabel" id="summary_label">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="label" translatable="yes">label</property>
+            <property name="label">label</property>
             <property name="use_markup">True</property>
             <property name="wrap">True</property>
           </object>
@@ -1196,6 +1196,9 @@ More information can be displayed by using the help button.</property>
       <object class="GtkBox" id="assistant-action_area2">
         <property name="can_focus">False</property>
       </object>
+      <packing>
+        <property name="has_padding">False</property>
+      </packing>
     </child>
   </object>
 </interface>

commit 4aa1062045fdb9c8eaedc69bccad6480a25f8217
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Jan 27 12:11:36 2018 +0100

    Bug 792947 - Missing translatable strings
    
    In addition
    - the icon was restored on the new account button while importing
    - an unused button was removed from the Tip of the day window
    - a couple of whitespace issues were fixed
    
    bug fixup

diff --git a/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade b/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade
index 4515ebc..2206248 100644
--- a/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade
+++ b/gnucash/gnome-utils/gtkbuilder/dialog-totd.glade
@@ -52,20 +52,6 @@
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="cancel-button">
-                <property name="label" translatable="yes">_Cancel</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkButton" id="close-button">
                 <property name="label" translatable="yes">_Close</property>
                 <property name="visible">True</property>
@@ -77,7 +63,7 @@
               <packing>
                 <property name="expand">False</property>
                 <property name="fill">False</property>
-                <property name="position">3</property>
+                <property name="position">2</property>
               </packing>
             </child>
           </object>
@@ -192,7 +178,6 @@
     <action-widgets>
       <action-widget response="2">back-button</action-widget>
       <action-widget response="1">forward-button</action-widget>
-      <action-widget response="-6">cancel-button</action-widget>
       <action-widget response="-7">close-button</action-widget>
     </action-widgets>
   </object>
diff --git a/gnucash/import-export/dialog-import.glade b/gnucash/import-export/dialog-import.glade
index 8f329fb..d12dc36 100644
--- a/gnucash/import-export/dialog-import.glade
+++ b/gnucash/import-export/dialog-import.glade
@@ -2,50 +2,10 @@
 <!-- Generated with glade 3.20.0 -->
 <interface>
   <requires lib="gtk+" version="3.10"/>
-  <object class="GtkBox" id="account_picker_content">
+  <object class="GtkImage" id="account_new_icon">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="orientation">vertical</property>
-    <child>
-      <object class="GtkLabel" id="label847715">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Please select or create an appropriate GnuCash account for:</property>
-        <property name="justify">center</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">False</property>
-        <property name="position">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="online_id_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="label" translatable="yes">Online account ID here...</property>
-        <property name="justify">center</property>
-      </object>
-      <packing>
-        <property name="expand">False</property>
-        <property name="fill">False</property>
-        <property name="position">1</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkScrolledWindow" id="account_tree_sw">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <child>
-          <placeholder/>
-        </child>
-      </object>
-      <packing>
-        <property name="expand">True</property>
-        <property name="fill">True</property>
-        <property name="position">2</property>
-      </packing>
-    </child>
+    <property name="icon_name">gnc-account-new</property>
   </object>
   <object class="GtkDialog" id="account_picker_dialog">
     <property name="visible">True</property>
@@ -67,12 +27,14 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="newbutton">
-                <property name="label">gnc-new-account</property>
+                <property name="label">New _Account...</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
+                <property name="image">account_new_icon</property>
                 <property name="use_underline">True</property>
+                <property name="always_show_image">True</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -82,7 +44,7 @@
             </child>
             <child>
               <object class="GtkButton" id="cancelbutton">
-                <property name="label">_Cancel</property>
+                <property name="label" translatable="yes">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -97,7 +59,7 @@
             </child>
             <child>
               <object class="GtkButton" id="okbutton">
-                <property name="label">_OK</property>
+                <property name="label" translatable="yes">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -138,6 +100,51 @@
       <action-widget response="-5">okbutton</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkBox" id="account_picker_content">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <child>
+      <object class="GtkLabel" id="label847715">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Please select or create an appropriate GnuCash account for:</property>
+        <property name="justify">center</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="online_id_label">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="label" translatable="yes">Online account ID here...</property>
+        <property name="justify">center</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">False</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkScrolledWindow" id="account_tree_sw">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <child>
+          <placeholder/>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">True</property>
+        <property name="fill">True</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+  </object>
   <object class="GtkAdjustment" id="atm_fee_adj">
     <property name="upper">1000</property>
     <property name="value">2</property>
@@ -179,7 +186,7 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="okbutton1">
-                <property name="label">_OK</property>
+                <property name="label" translatable="yes">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -301,7 +308,7 @@
         <property name="can_focus">False</property>
         <child>
           <object class="GtkCheckButton" id="pref/dialogs.import.generic/enable-skip">
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Enable skip transaction action</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Enable skip transaction action</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
@@ -321,7 +328,7 @@
         </child>
         <child>
           <object class="GtkCheckButton" id="pref/dialogs.import.generic/enable-update">
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Enable update match action</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Enable update match action</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
@@ -437,9 +444,10 @@
         <child>
           <object class="GtkLabel" id="label847789">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Commercial ATM _fees threshold</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Commercial ATM _fees threshold</property>
             <property name="use_underline">True</property>
             <property name="mnemonic_widget">pref/dialogs.import.generic/atm-fee-threshold</property>
           </object>
@@ -451,9 +459,10 @@
         <child>
           <object class="GtkLabel" id="label847788">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Auto-c_lear threshold</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Auto-c_lear threshold</property>
             <property name="use_underline">True</property>
             <property name="mnemonic_widget">pref/dialogs.import.generic/auto-clear-threshold</property>
           </object>
@@ -465,9 +474,10 @@
         <child>
           <object class="GtkLabel" id="label847787">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Auto-_add threshold</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Auto-_add threshold</property>
             <property name="use_underline">True</property>
             <property name="mnemonic_widget">pref/dialogs.import.generic/auto-add-threshold</property>
           </object>
@@ -479,9 +489,10 @@
         <child>
           <object class="GtkLabel" id="label847786">
             <property name="visible">True</property>
+            <property name="can_focus">False</property>
             <property name="halign">start</property>
             <property name="margin_left">12</property>
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Match _display threshold</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Match _display threshold</property>
             <property name="use_underline">True</property>
             <property name="mnemonic_widget">pref/dialogs.import.generic/match-threshold</property>
           </object>
@@ -492,7 +503,7 @@
         </child>
         <child>
           <object class="GtkCheckButton" id="pref/dialogs.import.generic/use-bayes">
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Use _bayesian matching</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Use _bayesian matching</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
@@ -512,7 +523,7 @@
         </child>
         <child>
           <object class="GtkCheckButton" id="pref/dialogs.import.generic/auto-create-commodity">
-            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Automatically create new commodities</property>
+            <property name="label" translatable="yes" comments="Preferences->Online Banking:Generic">Automatically create new commodities</property>
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="receives_default">False</property>
@@ -572,7 +583,7 @@
             </child>
             <child>
               <object class="GtkButton" id="cancel_button1">
-                <property name="label">_Cancel</property>
+                <property name="label" translatable="yes">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -587,7 +598,7 @@
             </child>
             <child>
               <object class="GtkButton" id="ok_button1">
-                <property name="label">_OK</property>
+                <property name="label" translatable="yes">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -616,6 +627,7 @@
             <child>
               <object class="GtkLabel" id="label847772">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" translatable="yes" comments="Dialog Select matching transactions">Imported transaction's first split:</property>
                 <property name="justify">center</property>
               </object>
@@ -650,6 +662,7 @@
             <child>
               <object class="GtkLabel" id="label847766">
                 <property name="visible">True</property>
+                <property name="can_focus">False</property>
                 <property name="label" translatable="yes" comments="Dialog Select matching transactions">Potential splits matching the selected transaction: </property>
                 <property name="justify">center</property>
               </object>
@@ -727,7 +740,7 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="matcher_help_close">
-                <property name="label">_Close</property>
+                <property name="label" translatable="yes">_Close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -1131,7 +1144,7 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="matcher_cancel">
-                <property name="label">_Cancel</property>
+                <property name="label" translatable="yes">_Cancel</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -1147,7 +1160,7 @@
             </child>
             <child>
               <object class="GtkButton" id="matcher_ok">
-                <property name="label">_OK</property>
+                <property name="label" translatable="yes">_OK</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
@@ -1164,7 +1177,7 @@
             </child>
             <child>
               <object class="GtkButton" id="matcher__help">
-                <property name="label">_Help</property>
+                <property name="label" translatable="yes">_Help</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
diff --git a/gnucash/import-export/import-account-matcher.c b/gnucash/import-export/import-account-matcher.c
index 555ad5e..4e59b98 100644
--- a/gnucash/import-export/import-account-matcher.c
+++ b/gnucash/import-export/import-account-matcher.c
@@ -293,6 +293,7 @@ Account * gnc_import_select_account(GtkWidget *parent,
     {
         /* load the interface */
         builder = gtk_builder_new();
+        gnc_builder_add_from_file (builder, "dialog-import.glade", "account_new_icon");
         gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_dialog");
         gnc_builder_add_from_file (builder, "dialog-import.glade", "account_picker_content");
         /* connect the signals in the interface */
diff --git a/gnucash/import-export/qif-imp/dialog-account-picker.glade b/gnucash/import-export/qif-imp/dialog-account-picker.glade
index 9a21943..f88bede 100644
--- a/gnucash/import-export/qif-imp/dialog-account-picker.glade
+++ b/gnucash/import-export/qif-imp/dialog-account-picker.glade
@@ -155,7 +155,7 @@
             <property name="layout_style">end</property>
             <child>
               <object class="GtkButton" id="newbutton">
-                <property name="label">gnc-new-account</property>
+                <property name="label">gnc-account-new</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
diff --git a/gnucash/report/standard-reports/account-piecharts.scm b/gnucash/report/standard-reports/account-piecharts.scm
index 0fc3b86..c5cfdad 100644
--- a/gnucash/report/standard-reports/account-piecharts.scm
+++ b/gnucash/report/standard-reports/account-piecharts.scm
@@ -158,9 +158,9 @@ balance at a given time"))
      (gnc:make-simple-boolean-option
       gnc:pagename-display optname-fullname
       "a"
-      (N_ (if depth-based?
-              "Show the full account name in legend?"
-              "Show the full security name in the legend?"))
+      (if depth-based?
+        (N_ "Show the full account name in legend?")
+        (N_ "Show the full security name in the legend?"))
       #f))
 
     (add-option
diff --git a/gnucash/report/standard-reports/income-gst-statement.scm b/gnucash/report/standard-reports/income-gst-statement.scm
index b9b6e52..9d3171c 100644
--- a/gnucash/report/standard-reports/income-gst-statement.scm
+++ b/gnucash/report/standard-reports/income-gst-statement.scm
@@ -1675,7 +1675,7 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
           ; - include/exclude splits to/from selected accounts
           ; - include only Invoices & Regular Transactions (i.e. remove Link & Payments)
           ; - disallow Closing Transactions, and
-          ; - substring/regex matcher for Description/Notes/Memo 
+          ; - substring/regex matcher for Description/Notes/Memo
           (set! splits (filter
                         (lambda (split)
                           (let* ((trans (xaccSplitGetParent split))
@@ -1782,24 +1782,26 @@ for taxes paid on expenses, and type LIABILITY for taxes collected on sales.")
                  document
                  (gnc:html-make-no-account-warning
                   report-title (gnc:report-id report-obj)))
-                
+
                 (gnc:html-document-add-object!
                  document
                  (gnc:make-html-text
                   (gnc:html-markup-p
-                   "This report is useful to calculate periodic business tax payable/receivable from"
-                   " authorities. From <i>Edit report options</i> above, choose your Business Income and Business Expense accounts."
-                   " Each transaction may contain, in addition to the accounts payable/receivable or bank accounts,"
-                   " a split to a tax account, e.g. Income:Sales -$1000, Liability:GST on Sales -$100, Asset:Bank $1100.")
+                   (_
+                   "This report is useful to calculate periodic business tax payable/receivable from
+ authorities. From <i>Edit report options</i> above, choose your Business Income and Business Expense accounts.
+ Each transaction may contain, in addition to the accounts payable/receivable or bank accounts,
+ a split to a tax account, e.g. Income:Sales -$1000, Liability:GST on Sales -$100, Asset:Bank $1100."))
                   (gnc:html-markup-p
-                   " These tax accounts can either be populated using the standard register, or from Business Invoices and Bills "
-                   " which will require Business > Sales Tax Tables to be set up correctly. Please see the documentation.")))
-                
+                   (_
+                   "These tax accounts can either be populated using the standard register, or from Business Invoices and Bills
+ which will require Business > Sales Tax Tables to be set up correctly. Please see the documentation."))))
+
                 (gnc:html-document-add-object!
                  document
                  (gnc:make-html-text
                   (gnc:html-markup-p TAX-SETUP-DESC))))
-            
+
               (begin
                 (gnc:html-document-add-object!
                  document

commit f319a8e2a4a735114860bed02a26fa504e7c5d62
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jan 29 19:15:02 2018 +0100

    Re-enable building a dist tarball from within distcheck

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 124f293..283424e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -781,10 +781,6 @@ endif()
 dist_add_generated(ChangeLog)
 
 ############################ BEGIN MAKE DIST #################
-# For now only enable the dist target when building from git
-# the generation of dist_generated should be improved to work
-# also when running from a tarball before that can be generalized.
-IF (BUILDING_FROM_VCS)
 
 SET(PACKAGE_PREFIX "${PACKAGE}-${PACKAGE_VERSION}")
 SET(DIST_FILE "${PACKAGE_PREFIX}.tar")
@@ -847,9 +843,6 @@ ADD_CUSTOM_TARGET(distcheck DEPENDS dist
             -P ${CMAKE_SOURCE_DIR}/common/cmake_modules/MakeDistCheck.cmake
         )
 
-
-
-ENDIF()
 ############################# END MAKE DIST #################
 
 # uninstall target
diff --git a/common/cmake_modules/MakeDistCheck.cmake b/common/cmake_modules/MakeDistCheck.cmake
index 3868aa2..100ff4f 100644
--- a/common/cmake_modules/MakeDistCheck.cmake
+++ b/common/cmake_modules/MakeDistCheck.cmake
@@ -76,12 +76,12 @@ FUNCTION(RUN_DIST_CHECK PACKAGE_PREFIX EXT)
             ERROR_MSG "Ninja check failed."
     )
 
-#    # Run ninja dist
-#    EXECUTE_PROCESS_AND_CHECK_RESULT(
-#            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
-#            WORKING_DIRECTORY ${BUILD_DIR}
-#            ERROR_MSG "Ninja dist failed."
-#    )
+    # Run ninja dist
+    EXECUTE_PROCESS_AND_CHECK_RESULT(
+            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
+            WORKING_DIRECTORY ${BUILD_DIR}
+            ERROR_MSG "Ninja dist failed."
+    )
 
     MESSAGE("distcheck complete.")
 

commit 49a936c1fd11bc06aa0ec78e5627d800c1fa7116
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jan 29 18:54:13 2018 +0100

    Rewrite gnc_add_swig_guile_command to work in dist tarball as well
    
    When building from git it will add targets to generate the swig files.
    When building from tarball it will just point at the generated source
    files from the tarball.

diff --git a/common/cmake_modules/GncAddSwigCommand.cmake b/common/cmake_modules/GncAddSwigCommand.cmake
index 44ba69b..31e1e86 100644
--- a/common/cmake_modules/GncAddSwigCommand.cmake
+++ b/common/cmake_modules/GncAddSwigCommand.cmake
@@ -4,26 +4,43 @@
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-macro (GNC_ADD_SWIG_COMMAND _target _output _input)
+# gnc_add_swig_guile_command is used to generate guile swig wrappers
+# it will only really generate the wrappers when building from git
+# when building from tarball it will set up everything so the version of the wrapper
+# from the tarball will be used instead
+# - _target is the name of a global target that will be set for this wrapper file,
+#    this can be used elsewhere to create a depencency on this wrapper
+# - _out_var will be set to the full path to the generated wrapper file
+#   when building from git, it points to the actually generated file
+#   however when building from a tarball, it will point to the version from the tarball instead
+# - _output is the name of the wrapper file to generate (or to look up in the tarball)
+# - input it the swig interface file (*.i) to generate this wrapper from
+# Any additional parameters will be used as dependencies for this wrapper target
+macro (gnc_add_swig_guile_command _target _out_var _output _input)
 
-    add_custom_command (
-        OUTPUT ${_output}
-        DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
-        COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libgnucash/engine -I${CMAKE_SOURCE_DIR}/common  -o ${_output} ${_input}
-    )
+    if (BUILDING_FROM_VCS)
+        set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+        set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
+    else()
+        set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+        set(SW_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+    endif()
 
-    add_custom_target(${_target} DEPENDS ${_output})
+    set(outfile ${SW_CURR_BUILD_SOURCE_DIR}/${_output})
+    set(${_out_var} ${outfile}) # This variable is set for convenience to use in the calling CMakeLists.txt
 
     if (BUILDING_FROM_VCS)
-        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
-    else()
-        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+        add_custom_command (
+            OUTPUT ${outfile}
+            DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
+            COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libgnucash/engine -I${CMAKE_SOURCE_DIR}/common  -o ${outfile} ${_input}
+        )
+        add_custom_target(${_target} DEPENDS ${outfile})
     endif()
 
-    # Add the output file _output to the dist tarball
-    file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
-    dist_add_generated(${generated})
-endmacro (GNC_ADD_SWIG_COMMAND)
+    # Add the output file outfile to the dist tarball
+    dist_add_generated(${_output})
+endmacro (gnc_add_swig_guile_command)
 
 
 # gnc_add_swig_python_command is used to generate python swig wrappers
diff --git a/common/test-core/CMakeLists.txt b/common/test-core/CMakeLists.txt
index 095e152..7ebf514 100644
--- a/common/test-core/CMakeLists.txt
+++ b/common/test-core/CMakeLists.txt
@@ -27,14 +27,13 @@ IF (UNIX)
   TARGET_COMPILE_OPTIONS(test-core PRIVATE -fPIC)
 ENDIF()
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_UNITTEST_SUPPORT_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-guile.c)
-  GNC_ADD_SWIG_COMMAND (swig-unittest-support-guile-c ${SWIG_UNITTEST_SUPPORT_GUILE_C}
-      ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS})
-ELSE()
-  SET (SWIG_UNITTEST_SUPPORT_GUILE_C  swig-unittest-support-guile.c)
-ENDIF()
+# Command to generate the swig-unittest-support-guile.c wrapper file
+gnc_add_swig_guile_command (swig-unittest-support-guile-c
+    SWIG_UNITTEST_SUPPORT_GUILE_C swig-unittest-support-guile.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS}
+)
 
+# Command to generate the swig-unittest-support-python.c wrapper file
 gnc_add_swig_python_command (swig-unittest-support-python
     SWIG_UNITTEST_SUPPORT_PYTHON_C SWIG_UNITTEST_SUPPORT_PYTHON_PY
     swig-unittest-support-python.c unittest_support.py
diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt
index 05aa983..2ee2380 100644
--- a/gnucash/gnome-utils/CMakeLists.txt
+++ b/gnucash/gnome-utils/CMakeLists.txt
@@ -5,12 +5,11 @@ ADD_SUBDIRECTORY(gtkbuilder)
 ADD_SUBDIRECTORY(ui)
 ADD_SUBDIRECTORY(test)
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_GNOME_UTILS_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnome-utils.c)
-  GNC_ADD_SWIG_COMMAND (swig-gnome-utils-c ${SWIG_GNOME_UTILS_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnome-utils.i)
-ELSE()
-  SET (SWIG_GNOME_UTILS_C swig-gnome-utils.c)
-ENDIF()
+# Command to generate the swig-gnome-utils.c wrapper file
+gnc_add_swig_guile_command (swig-gnome-utils-c
+    SWIG_GNOME_UTILS_C swig-gnome-utils.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/gnome-utils.i
+)
 
 CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/gschemas/org.gnucash.warnings.gschema.xml.in.in
                ${CMAKE_CURRENT_BINARY_DIR}/gschemas/org.gnucash.warnings.gschema.xml.in)
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 70305b8..5b54a95 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -59,12 +59,11 @@ SET (gnc_gnome_noinst_HEADERS
   window-autoclear.h
 )
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_GNOME_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnome.c)
-  GNC_ADD_SWIG_COMMAND (swig-gnome-c ${SWIG_GNOME_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnome.i ${gnc_gnome_HEADERS})
-ELSE()
-  SET (SWIG_GNOME_C swig-gnome.c)
-ENDIF()
+# Command to generate the swig-gnome.c wrapper file
+gnc_add_swig_guile_command (swig-gnome-c
+    SWIG_GNOME_C swig-gnome.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/gnome.i ${gnc_gnome_HEADERS}
+)
 
 SET (gnc_gnome_SOURCES 
 
diff --git a/gnucash/html/CMakeLists.txt b/gnucash/html/CMakeLists.txt
index eeb3491..768a9c2 100644
--- a/gnucash/html/CMakeLists.txt
+++ b/gnucash/html/CMakeLists.txt
@@ -9,12 +9,11 @@ SET (html_HEADERS
   gnc-html-webkit.h
 )
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_GNC_HTML_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-html.c)
-  GNC_ADD_SWIG_COMMAND (swig-gnc-html-c ${SWIG_GNC_HTML_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnc-html.i "${gncmod_html_HEADERS}")
-ELSE()
-  SET (SWIG_GNC_HTML_C swig-gnc-html.c)
-ENDIF()
+# Command to generate the swig-gnc-html.c wrapper file
+gnc_add_swig_guile_command (swig-gnc-html-c
+    SWIG_GNC_HTML_C swig-gnc-html.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/gnc-html.i "${gncmod_html_HEADERS}"
+)
 
 SET (html_SOURCES
   gncmod-html.c
diff --git a/gnucash/report/report-gnome/CMakeLists.txt b/gnucash/report/report-gnome/CMakeLists.txt
index ee2996a..291e386 100644
--- a/gnucash/report/report-gnome/CMakeLists.txt
+++ b/gnucash/report/report-gnome/CMakeLists.txt
@@ -8,12 +8,11 @@ SET (report_gnome_HEADERS
   window-report.h
 )
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_REPORT_GNOME_C ${CMAKE_CURRENT_BINARY_DIR}/swig-report-gnome.c)
-  GNC_ADD_SWIG_COMMAND (swig-report-gnome-c ${SWIG_REPORT_GNOME_C} ${CMAKE_CURRENT_SOURCE_DIR}/report-gnome.i ${report_gnome_HEADERS})
-ELSE()
-  SET (SWIG_REPORT_GNOME_C swig-report-gnome.c)
-ENDIF()
+# Command to generate the swig-report-gnome.c wrapper file
+gnc_add_swig_guile_command (swig-report-gnome-c
+    SWIG_REPORT_GNOME_C swig-report-gnome.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/report-gnome.i ${report_gnome_HEADERS}
+)
 
 SET (report_gnome_SOURCES
   dialog-report-column-view.c
diff --git a/gnucash/report/report-system/CMakeLists.txt b/gnucash/report/report-system/CMakeLists.txt
index 0ed1d8e..01940ba 100644
--- a/gnucash/report/report-system/CMakeLists.txt
+++ b/gnucash/report/report-system/CMakeLists.txt
@@ -2,15 +2,13 @@ ADD_SUBDIRECTORY(test)
 
 SET (report_system_HEADERS
   gnc-report.h
-)  
-
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_REPORT_SYSTEM_C ${CMAKE_CURRENT_BINARY_DIR}/swig-report-system.c)
-  GNC_ADD_SWIG_COMMAND (swig-report-system-c ${SWIG_REPORT_SYSTEM_C} ${CMAKE_CURRENT_SOURCE_DIR}/report-system.i ${report_system_HEADERS})
-ELSE()
-  SET (SWIG_REPORT_SYSTEM_C swig-report-system.c)
-ENDIF()
+)
 
+# Command to generate the swig-report-system.c wrapper file
+gnc_add_swig_guile_command (swig-report-system-c
+    SWIG_REPORT_SYSTEM_C swig-report-system.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/report-system.i ${report_system_HEADERS}
+)
 
 SET (report_system_SOURCES
   gncmod-report-system.c
diff --git a/libgnucash/app-utils/CMakeLists.txt b/libgnucash/app-utils/CMakeLists.txt
index a52bf45..1c25008 100644
--- a/libgnucash/app-utils/CMakeLists.txt
+++ b/libgnucash/app-utils/CMakeLists.txt
@@ -33,18 +33,15 @@ SET (app_utils_HEADERS
   gnc-ui-balances.h
   guile-util.h
   option-util.h
-
 )
 
+# Command to generate the swig-app-utils-guile.c wrapper file
+gnc_add_swig_guile_command (swig-apputils-guile-c
+    SWIG_APP_UTILS_GUILE_C swig-app-utils-guile.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i
+)
 
-IF (BUILDING_FROM_VCS)
-  # Command to generate the swig-app-utils.c wrapper file
-  SET (SWIG_APP_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-app-utils-guile.c)
-  GNC_ADD_SWIG_COMMAND (swig-apputils-guile-c ${SWIG_APP_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i)
-ELSE()
-  SET (SWIG_APP_UTILS_GUILE_C swig-app-utils-guile.c)
-ENDIF()
-
+# Command to generate the swig-app-utils-python.c wrapper file
 gnc_add_swig_python_command (swig-app-utils-python
     SWIG_APP_UTILS_PYTHON_C SWIG_APP_UTILS_PYTHON_PY
     swig-app-utils-python.c sw_app_utils.py
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index 407c1c6..f8dee6b 100644
--- a/libgnucash/core-utils/CMakeLists.txt
+++ b/libgnucash/core-utils/CMakeLists.txt
@@ -2,13 +2,13 @@
 
 ADD_SUBDIRECTORY(test)
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_CORE_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-guile.c)
-  GNC_ADD_SWIG_COMMAND (swig-core-utils-guile-c ${SWIG_CORE_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
-ELSE()
-  SET(SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c)
-ENDIF()
+# Command to generate the swig-core-utils-guile.c wrapper file
+gnc_add_swig_guile_command (swig-core-utils-guile-c
+    SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i
+)
 
+# Command to generate the swig-core-utils-python.c wrapper file
 gnc_add_swig_python_command (swig-core-utils-python
     SWIG_CORE_UTILS_PYTHON_C SWIG_CORE_UTILS_PYTHON_PY
     swig-core-utils-python.c sw_core_utils.py
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index d88d710..560bc38 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -117,13 +117,11 @@ SET (engine_HEADERS
   qof-string-cache.h
 )
 
-IF (BUILDING_FROM_VCS)
-  # Command to generate the swig-engine.c wrapper file
-  SET (SWIG_ENGINE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-engine.c)
-  GNC_ADD_SWIG_COMMAND (swig-engine-c ${SWIG_ENGINE_C} ${CMAKE_CURRENT_SOURCE_DIR}/engine.i ${engine_HEADERS})
-ELSE()
-  SET (SWIG_ENGINE_C swig-engine.c)
-ENDIF()
+# Command to generate the swig-engine.c wrapper file
+gnc_add_swig_guile_command (swig-engine-c
+    SWIG_ENGINE_C swig-engine.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/engine.i ${engine_HEADERS}
+)
 
 # Command to generate the iso-4217-currencies.c file
 SET (ISO_4217_C ${CMAKE_CURRENT_BINARY_DIR}/iso-4217-currencies.c)
diff --git a/libgnucash/gnc-module/CMakeLists.txt b/libgnucash/gnc-module/CMakeLists.txt
index 120a592..c5ce2fe 100644
--- a/libgnucash/gnc-module/CMakeLists.txt
+++ b/libgnucash/gnc-module/CMakeLists.txt
@@ -2,13 +2,11 @@
 ADD_SUBDIRECTORY(test)
 ADD_SUBDIRECTORY(example)
 
-IF (BUILDING_FROM_VCS)
-  # Command to generate the swig-gnc-module.c wrapper file
-  SET (SWIG_GNC_MODULE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-gnc-module.c)
-  GNC_ADD_SWIG_COMMAND (swig-gnc-module-c ${SWIG_GNC_MODULE_C} ${CMAKE_CURRENT_SOURCE_DIR}/gnc-module.i)
-ELSE()
-  SET (SWIG_GNC_MODULE_C swig-gnc-module.c)
-ENDIF()
+# Command to generate the swig-gnc-module.c wrapper file
+gnc_add_swig_guile_command (swig-gnc-module-c
+    SWIG_GNC_MODULE_C swig-gnc-module.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/gnc-module.i
+)
 
 SET (gnc_module_SOURCES gnc-module.c)
 
diff --git a/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt b/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt
index 06763b1..257f811 100644
--- a/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt
+++ b/libgnucash/gnc-module/test/mod-bar/CMakeLists.txt
@@ -1,10 +1,8 @@
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_BAR_C ${CMAKE_CURRENT_BINARY_DIR}/swig-bar.c)
-  GNC_ADD_SWIG_COMMAND (swig-bar-c ${SWIG_BAR_C} ${CMAKE_CURRENT_SOURCE_DIR}/bar.i bar.h)
-ELSE()
-  SET (SWIG_BAR_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-bar.c)
-ENDIF()
+gnc_add_swig_guile_command (swig-bar-c
+    SWIG_BAR_C swig-bar.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/bar.i bar.h
+)
 
 ADD_LIBRARY(bar EXCLUDE_FROM_ALL bar.c bar.h)
 ADD_LIBRARY(gncmodbar EXCLUDE_FROM_ALL gnc-mod-bar.c)
diff --git a/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt b/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt
index 1a60d90..7702374 100644
--- a/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt
+++ b/libgnucash/gnc-module/test/mod-baz/CMakeLists.txt
@@ -1,10 +1,8 @@
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_BAZ_C ${CMAKE_CURRENT_BINARY_DIR}/swig-baz.c)
-  GNC_ADD_SWIG_COMMAND (swig-baz-c ${SWIG_BAZ_C} ${CMAKE_CURRENT_SOURCE_DIR}/baz.i baz.h)
-ELSE()
-  SET (SWIG_BAZ_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-baz.c)
-ENDIF()
+gnc_add_swig_guile_command (swig-baz-c
+    SWIG_BAZ_C swig-baz.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/baz.i baz.h
+)
 
 ADD_LIBRARY(baz EXCLUDE_FROM_ALL baz.c baz.h)
 TARGET_INCLUDE_DIRECTORIES(baz PRIVATE
diff --git a/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt b/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt
index 5b6eb8c..4c9734e 100644
--- a/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt
+++ b/libgnucash/gnc-module/test/mod-foo/CMakeLists.txt
@@ -1,10 +1,8 @@
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_FOO_C ${CMAKE_CURRENT_BINARY_DIR}/swig-foo.c)
-  GNC_ADD_SWIG_COMMAND (swig-foo-c ${SWIG_FOO_C} ${CMAKE_CURRENT_SOURCE_DIR}/foo.i foo.h)
-ELSE()
-  SET (SWIG_FOO_C ${CMAKE_CURRENT_SOURCE_DIR}/swig-foo.c)
-ENDIF()
+gnc_add_swig_guile_command (swig-foo-c
+    SWIG_FOO_C swig-foo.c
+    ${CMAKE_CURRENT_SOURCE_DIR}/foo.i foo.h
+)
 
 ADD_LIBRARY(foo EXCLUDE_FROM_ALL foo.c foo.h)
 ADD_LIBRARY(gncmodfoo EXCLUDE_FROM_ALL gnc-mod-foo.c)

commit 36cb167b682bfee82027ffd3f2ef7463a113e137
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jan 29 18:04:08 2018 +0100

    Rewrite gnc_add_swig_python_command to work in dist tarball as well
    
    When building from git it will add targets to generate the swig files.
    When building from tarball it will just point at the generated source
    files from the tarball.

diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index 1625bd1..8bdde03 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -3,9 +3,8 @@ ADD_SUBDIRECTORY(tests)
 
 SET(PYEXEC_FILES  __init__.py function_class.py gnucash_business.py gnucash_core.py)
 
-IF (BUILDING_FROM_VCS)
-  SET(SWIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core.i ${CMAKE_CURRENT_SOURCE_DIR}/time64.i)
-  SET(GNUCASH_CORE_C_INCLUDES
+set(SWIG_FILES ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core.i ${CMAKE_CURRENT_SOURCE_DIR}/time64.i)
+set(GNUCASH_CORE_C_INCLUDES
     ${CONFIG_H}
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/qofsession.h
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/qofbook.h
@@ -35,22 +34,16 @@ IF (BUILDING_FROM_VCS)
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/gncIDSearch.h
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/gnc-pricedb.h
     ${CMAKE_SOURCE_DIR}/libgnucash/app-utils/gnc-prefs-utils.h
-  )
-
-  SET (SWIG_GNUCASH_CORE_C ${CMAKE_CURRENT_BINARY_DIR}/gnucash_core.c)
-  SET (SWIG_GNUCASH_CORE_PY ${CMAKE_CURRENT_BINARY_DIR}/gnucash_core_c.py)
+)
 
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-gnucash-core ${SWIG_GNUCASH_CORE_C}
-    ${SWIG_GNUCASH_CORE_PY}
+gnc_add_swig_python_command (swig-gnucash-core
+    SWIG_GNUCASH_CORE_C SWIG_GNUCASH_CORE_PY
+    gnucash_core.c gnucash_core_c.py
     ${SWIG_FILES}
     ${CMAKE_SOURCE_DIR}/common/base-typemaps.i
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/engine-common.i
     ${GNUCASH_CORE_C_INCLUDES}
-  )
-ELSE()
-  SET (SWIG_GNUCASH_CORE_C gnucash_core.c)
-  SET (SWIG_GNUCASH_CORE_PY ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core_c.py)
-ENDIF()
+)
 
 IF(WITH_PYTHON)
 
diff --git a/common/cmake_modules/GncAddSwigCommand.cmake b/common/cmake_modules/GncAddSwigCommand.cmake
index de32e0f..44ba69b 100644
--- a/common/cmake_modules/GncAddSwigCommand.cmake
+++ b/common/cmake_modules/GncAddSwigCommand.cmake
@@ -1,5 +1,5 @@
 # Copyright (c) 2010, Christian Stimming
-
+# Copyright (c) 2018, Geert Janssens
 
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
@@ -26,41 +26,60 @@ macro (GNC_ADD_SWIG_COMMAND _target _output _input)
 endmacro (GNC_ADD_SWIG_COMMAND)
 
 
-macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _py_output _input)
+# gnc_add_swig_python_command is used to generate python swig wrappers
+# it will only really generate the wrappers when building from git
+# when building from tarball it will set up everything so the version of the wrapper
+# from the tarball will be used instead
+# - _target is the name of a global target that will be set for this wrapper file,
+#    this can be used elsewhere to create a depencency on this wrapper
+# - _out_var will be set to the full path to the generated wrapper file
+#   when building from git, it points to the actually generated file
+#   however when building from a tarball, it will point to the version from the tarball instead
+# - _py_out_var is the same but for the python module that's generated together with the wrapper
+# - _output is the name of the wrapper file to generate (or to look up in the tarball)
+# - _py_output is the name of the python module associated with this wrapper
+# - input it the swig interface file (*.i) to generate this wrapper from
+# Any additional parameters will be used as dependencies for this wrapper target
+macro (gnc_add_swig_python_command _target _out_var _py_out_var _output _py_output _input)
 
-    set (DEFAULT_SWIG_PYTHON_FLAGS
-        -python
-        -Wall -Werror
-        ${SWIG_ARGS}
-    )
-    set (DEFAULT_SWIG_PYTHON_C_INCLUDES
-        ${GLIB2_INCLUDE_DIRS}
-        ${CMAKE_SOURCE_DIR}/common
-        ${CMAKE_SOURCE_DIR}/libgnucash/engine
-        ${CMAKE_SOURCE_DIR}/libgnucash/app-utils
-    )
+    if (BUILDING_FROM_VCS)
+        set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+        set(SW_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
+    else()
+        set(SW_CURR_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+        set(SW_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+    endif()
 
-    set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
-    foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
-        list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
-    endforeach (dir)
-    add_custom_command(OUTPUT ${_output} ${_py_output}
-        COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${_output} ${_input}
-        DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
-    )
-    add_custom_target(${_target} ALL DEPENDS ${_output} ${_py_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
+    set(outfile ${SW_CURR_BUILD_SOURCE_DIR}/${_output})
+    set(${_out_var} ${outfile}) # This variable is set for convenience to use in the calling CMakeLists.txt
 
+    set(py_outfile ${SW_CURR_BUILD_SOURCE_DIR}/${_py_output})
+    set(${_py_out_var} ${py_outfile}) # This variable is set for convenience to use in the calling CMakeLists.txt
 
     if (BUILDING_FROM_VCS)
-        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
-    else()
-        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+        set (DEFAULT_SWIG_PYTHON_FLAGS
+            -python
+            -Wall -Werror
+            ${SWIG_ARGS}
+        )
+        set (DEFAULT_SWIG_PYTHON_C_INCLUDES
+            ${GLIB2_INCLUDE_DIRS}
+            ${CMAKE_SOURCE_DIR}/common
+            ${CMAKE_SOURCE_DIR}/libgnucash/engine
+            ${CMAKE_SOURCE_DIR}/libgnucash/app-utils
+        )
+
+        set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
+        foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
+            list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
+        endforeach (dir)
+        add_custom_command(OUTPUT ${outfile} ${py_outfile}
+            COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${outfile} ${_input}
+            DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
+        )
+        add_custom_target(${_target} ALL DEPENDS ${outfile} ${py_outfile} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
     endif()
 
     # Add the output files _output and _py_output to the dist tarball
-    file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
-    dist_add_generated(${generated})
-
-    file(RELATIVE_PATH py_generated ${BUILD_SOURCE_DIR} ${_py_output})
-    dist_add_generated(${py_generated})
+    dist_add_generated(${_output} ${_py_output})
 endmacro()
diff --git a/common/test-core/CMakeLists.txt b/common/test-core/CMakeLists.txt
index e2e4a44..095e152 100644
--- a/common/test-core/CMakeLists.txt
+++ b/common/test-core/CMakeLists.txt
@@ -31,18 +31,15 @@ IF (BUILDING_FROM_VCS)
   SET (SWIG_UNITTEST_SUPPORT_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-guile.c)
   GNC_ADD_SWIG_COMMAND (swig-unittest-support-guile-c ${SWIG_UNITTEST_SUPPORT_GUILE_C}
       ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS})
-  SET (SWIG_UNITTEST_SUPPORT_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-python.c)
-  SET (SWIG_UNITTEST_SUPPORT_PYTHON_PY ${CMAKE_CURRENT_BINARY_DIR}/unittest_support.py)
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-unittest-support-python
-        ${SWIG_UNITTEST_SUPPORT_PYTHON_C}
-        ${SWIG_UNITTEST_SUPPORT_PYTHON_PY}
-        ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i)
 ELSE()
   SET (SWIG_UNITTEST_SUPPORT_GUILE_C  swig-unittest-support-guile.c)
-  SET (SWIG_UNITTEST_SUPPORT_PYTHON_C swig-unittest-support-python.c)
-  FILE(COPY unittest_support.py DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
 ENDIF()
 
+gnc_add_swig_python_command (swig-unittest-support-python
+    SWIG_UNITTEST_SUPPORT_PYTHON_C SWIG_UNITTEST_SUPPORT_PYTHON_PY
+    swig-unittest-support-python.c unittest_support.py
+    ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i
+)
 
 ADD_LIBRARY(test-core-guile ${SWIG_UNITTEST_SUPPORT_GUILE_C})
 TARGET_LINK_LIBRARIES(test-core-guile test-core ${GUILE_LDFLAGS} ${GLIB2_LDFLAGS})
diff --git a/libgnucash/app-utils/CMakeLists.txt b/libgnucash/app-utils/CMakeLists.txt
index a3ab7b1..a52bf45 100644
--- a/libgnucash/app-utils/CMakeLists.txt
+++ b/libgnucash/app-utils/CMakeLists.txt
@@ -41,17 +41,16 @@ IF (BUILDING_FROM_VCS)
   # Command to generate the swig-app-utils.c wrapper file
   SET (SWIG_APP_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-app-utils-guile.c)
   GNC_ADD_SWIG_COMMAND (swig-apputils-guile-c ${SWIG_APP_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i)
-  SET (SWIG_APP_UTILS_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-app-utils-python.c)
-  SET (SWIG_APP_UTILS_PYTHON_PY ${CMAKE_CURRENT_BINARY_DIR}/sw_app_utils.py)
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-app-utils-python
-        ${SWIG_APP_UTILS_PYTHON_C}
-        ${SWIG_APP_UTILS_PYTHON_PY}
-        ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i)
 ELSE()
   SET (SWIG_APP_UTILS_GUILE_C swig-app-utils-guile.c)
-  SET (SWIG_APP_UTILS_PYTHON_C swig-app-utils-python.c)
 ENDIF()
 
+gnc_add_swig_python_command (swig-app-utils-python
+    SWIG_APP_UTILS_PYTHON_C SWIG_APP_UTILS_PYTHON_PY
+    swig-app-utils-python.c sw_app_utils.py
+    ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i
+)
+
 SET (app_utils_SOURCES
   calculation/expression_parser.c
   calculation/fin.c
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index fa2b48f..407c1c6 100644
--- a/libgnucash/core-utils/CMakeLists.txt
+++ b/libgnucash/core-utils/CMakeLists.txt
@@ -5,17 +5,16 @@ ADD_SUBDIRECTORY(test)
 IF (BUILDING_FROM_VCS)
   SET (SWIG_CORE_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-guile.c)
   GNC_ADD_SWIG_COMMAND (swig-core-utils-guile-c ${SWIG_CORE_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
-  SET (SWIG_CORE_UTILS_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-python.c)
-  SET (SWIG_CORE_UTILS_PYTHON_PY ${CMAKE_CURRENT_BINARY_DIR}/sw_core_utils.py)
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-core-utils-python
-        ${SWIG_CORE_UTILS_PYTHON_C}
-        ${SWIG_CORE_UTILS_PYTHON_PY}
-        ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
 ELSE()
   SET(SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c)
-  SET(SWIG_CORE_UTILS_PYTHON_C swig-core-utils-python.c)
 ENDIF()
 
+gnc_add_swig_python_command (swig-core-utils-python
+    SWIG_CORE_UTILS_PYTHON_C SWIG_CORE_UTILS_PYTHON_PY
+    swig-core-utils-python.c sw_core_utils.py
+    ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i
+)
+
 SET (core_utils_SOURCES
   binreloc.c
   gnc-prefs.c

commit ec213360f33a0d53e9ccd06630e78d780c6f28d2
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jan 29 17:29:40 2018 +0100

    Review which built files are really needed in the dist tarball
    
    Several were only there because they used to be generated via autogen.sh
    and hence had to be included because autogen.sh was not supposed to be run
    in a tarball based build.
    A few others aren't clear so I have left them in for now:
    - gnucash.1 (man page)
    - gnucash-design.info (because it's unclear what we want to do with that one)
    
    These files should clearly be in the tarball:
    - gnucash.pot -> for our translators
    - ChangeLog -> can't be generated outside of a git repo
    - gnc-vcs-info.h -> can't be generated outside of a git repo
    - guile/python bindings -> to avoid a swig dependency when building from tarball

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 51c1549..124f293 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -774,11 +774,11 @@ if (BUILDING_FROM_VCS)
         COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2018-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     )
-    dist_add_generated(ChangeLog)
     install(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
 else()
     install(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
 endif()
+dist_add_generated(ChangeLog)
 
 ############################ BEGIN MAKE DIST #################
 # For now only enable the dist target when building from git
diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index 1153059..5ed12cc 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -32,8 +32,9 @@ ADD_DEFINITIONS (-DHAVE_CONFIG_H)
 
 # Some settings are platform dependent. Let's define them per platform.
 IF (WIN32)
-  # Windows specific settings go here:
-  SET (GNUCASH_RESOURCE_FILE gnucash.rc)
+    # Windows specific settings go here:
+    set (GNUCASH_RESOURCE_FILE gnucash.rc)
+    configure_file(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
 
 ELSE (WIN32)
   # All other platforms use these settings:
@@ -110,8 +111,6 @@ SET(GNUCASH_BIN_INSTALL_NAME "gnucash")
 
 SET(VALGRIND_OUTDIR ${BINDIR_BUILD})
 
-configure_file(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
-dist_add_configured(gnucash.rc)
 configure_file(gnucash-valgrind.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gnucash-valgrind @ONLY)
 
 FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gnucash-valgrind
diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt
index 71754cb..05aa983 100644
--- a/gnucash/gnome-utils/CMakeLists.txt
+++ b/gnucash/gnome-utils/CMakeLists.txt
@@ -32,10 +32,6 @@ ADD_CUSTOM_COMMAND(
     ${LIBXSLT_XSLTPROC_EXECUTABLE} -o ${GNC_WARNINGS_H} ${CMAKE_CURRENT_SOURCE_DIR}/make-gnc-warnings-h.xsl ${CMAKE_CURRENT_BINARY_DIR}/${WARNINGS_SCHEMA}
 )
 
-ADD_CUSTOM_TARGET(gnc-warnings-c DEPENDS ${GNC_WARNINGS_C})
-dist_add_generated(gnc-warnings.c)
-# FIXME why is gnc-warnings.c added to dist and gnc-warnings.h not ? I think neither is necessary...
-
 #GTK before 3.14 didn't have GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK
 if (NOT have_mod_mask)
 if (MAC_INTEGRATION)
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index 5331383..70305b8 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -175,7 +175,7 @@ ADD_CUSTOM_COMMAND(
       LC_ALL=C
       ${PERL_EXECUTABLE} ${INTLTOOL_MERGE} -x -u -c ${CMAKE_SOURCE_DIR}/po/.intltool-merge-cache ${CMAKE_SOURCE_DIR}/po
         ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in gnucash.appdata.xml
-    MAIN_DEPENDENCY ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in
+    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.appdata.xml.in
 )
 
 ADD_CUSTOM_TARGET(gnucash-appdata ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml)
@@ -185,8 +185,6 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION  ${CMA
 #=======
 
 configure_file(gnucash.desktop.in.in gnucash.desktop.in)
-dist_add_configured(gnucash.desktop.in)
-
 
 ADD_CUSTOM_COMMAND(
     OUTPUT gnucash.desktop
@@ -194,7 +192,7 @@ ADD_CUSTOM_COMMAND(
       LC_ALL=C
       ${PERL_EXECUTABLE} ${INTLTOOL_MERGE} -d -u -c ${CMAKE_SOURCE_DIR}/po/.intltool-merge-cache ${CMAKE_SOURCE_DIR}/po
         gnucash.desktop.in gnucash.desktop
-    MAIN_DEPENDENCY gnucash.desktop.in
+    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop.in
 )
 
 ADD_CUSTOM_TARGET(gnucash-desktop ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.desktop)
diff --git a/libgnucash/doc/design/CMakeLists.txt b/libgnucash/doc/design/CMakeLists.txt
index 99ff155..d2993c0 100644
--- a/libgnucash/doc/design/CMakeLists.txt
+++ b/libgnucash/doc/design/CMakeLists.txt
@@ -28,7 +28,6 @@ SET(VERSION_TEXI_IN
 
 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.texi ${VERSION_TEXI_IN})
 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/stamp-vti ${VERSION_TEXI_IN})
-dist_add_configured(version.texi stamp-vti)
 
 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" TEXI_BINARY_DIR)
 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gnucash-design.texi" TEXI_SOURCE_FILE)
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index 8d38edd..d88d710 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -134,7 +134,6 @@ ADD_CUSTOM_COMMAND (
     ${LIBXSLT_XSLTPROC_EXECUTABLE} -o ${ISO_4217_C} "${CMAKE_CURRENT_SOURCE_DIR}/iso-currencies-to-c.xsl" "${CMAKE_CURRENT_SOURCE_DIR}/iso-4217-currencies.xml"
     )
 ADD_CUSTOM_TARGET(iso-4217-c DEPENDS ${ISO_4217_C})
-dist_add_generated(iso-4217-currencies.c)
 
 SET (engine_SOURCES
   Account.cpp
@@ -230,8 +229,8 @@ ADD_LIBRARY (gncmod-engine
   ${engine_noinst_HEADERS}
 )
 
-# Add dependency on swig-runtime.h
-add_dependencies (gncmod-engine swig-runtime-h)
+# Add dependency on swig-runtime.h and iso-4217-currencies.c
+add_dependencies (gncmod-engine swig-runtime-h iso-4217-c)
 
 TARGET_LINK_LIBRARIES(gncmod-engine gnc-core-utils gnc-module ${Boost_DATE_TIME_LIBRARIES}  ${Boost_REGEX_LIBRARIES} ${REGEX_LDFLAGS} ${GMODULE_LDFLAGS} ${GLIB2_LDFLAGS} ${GOBJECT_LDFLAGS} ${GUILE_LDFLAGS})
 
diff --git a/libgnucash/scm/CMakeLists.txt b/libgnucash/scm/CMakeLists.txt
index 3794b84..076bddd 100644
--- a/libgnucash/scm/CMakeLists.txt
+++ b/libgnucash/scm/CMakeLists.txt
@@ -8,7 +8,7 @@ SET (scm_SCHEME_4
 )
 
 configure_file(build-config.scm.in ${BUILD_CONFIG_SCM})
-dist_add_configured(build-config.scm)
+add_custom_target(build-config-scm DEPENDS ${BUILD_CONFIG_SCM})
 
 SET(GUILE_DEPENDS      scm-core-utils scm-gnc-module)
 
@@ -27,7 +27,7 @@ GNC_ADD_SCHEME_TARGETS(scm-scm-1 "printf.scm" gnucash "" FALSE)
 GNC_ADD_SCHEME_TARGETS(scm-scm-2
   main.scm
   gnucash
-  "scm-scm-1;${GUILE_DEPENDS}"  # requires printf.scm from scm-scm-1 and modules from GUILE_DEPENDS
+  "scm-scm-1;${GUILE_DEPENDS};build-config-scm"  # requires printf.scm from scm-scm-1 and modules from GUILE_DEPENDS
   FALSE
 )
 

commit 9d8def84f33b3b03ac70015e6cf83336bde2a61e
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jan 29 13:46:46 2018 +0100

    Fix version number inclusion in gnucash.desktop file

diff --git a/gnucash/gnome/gnucash.desktop.in.in b/gnucash/gnome/gnucash.desktop.in.in
index 6514737..b167540 100644
--- a/gnucash/gnome/gnucash.desktop.in.in
+++ b/gnucash/gnome/gnucash.desktop.in.in
@@ -1,7 +1,7 @@
 [Desktop Entry]
 Type=Application
 MimeType=application/x-gnucash;
-Version=0.9.4
+Version=@VERSION@
 _Name=GnuCash
 _GenericName=Finance Management
 _Comment=Manage your finances, accounts, and investments

commit 4317d8a8f6f808a1ca1ff0389854dcd000561354
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Mon Jan 29 12:19:47 2018 +0100

    Improve handling of generated distributable files
    
    - the two dist_add_... macros now both take a list of file names
    as argument so more files can be added at once to the dist tarball.
    - dist_add_generated now creates the right target by itself. There's
      no need to pass one any more
    - make the swig generated *.py module files explicit output files
    - change a couple of custom_targets into custom_commands. The only
      reason they were defined as targets was to ensure they got built
      before the dist tarball. This is now properly handled by the
      dist_add_... macros.
    - correctly handle dependency on swig-runtime.h (using OBJECT_DEPENDS
      was not the way to do it according to that property's help page)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index aea4982..51c1549 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -774,7 +774,7 @@ if (BUILDING_FROM_VCS)
         COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2018-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
         WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
     )
-    dist_add_generated(ChangeLog ChangeLog)
+    dist_add_generated(ChangeLog)
     install(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
 else()
     install(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index 2f9e929..1625bd1 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -38,19 +38,18 @@ IF (BUILDING_FROM_VCS)
   )
 
   SET (SWIG_GNUCASH_CORE_C ${CMAKE_CURRENT_BINARY_DIR}/gnucash_core.c)
-  SET (SWIG_GNUCASH_CORE_C_PY ${CMAKE_CURRENT_BINARY_DIR}/gnucash_core_c.py)
+  SET (SWIG_GNUCASH_CORE_PY ${CMAKE_CURRENT_BINARY_DIR}/gnucash_core_c.py)
 
   GNC_ADD_SWIG_PYTHON_COMMAND (swig-gnucash-core ${SWIG_GNUCASH_CORE_C}
+    ${SWIG_GNUCASH_CORE_PY}
     ${SWIG_FILES}
     ${CMAKE_SOURCE_DIR}/common/base-typemaps.i
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/engine-common.i
     ${GNUCASH_CORE_C_INCLUDES}
   )
-  add_custom_target(swig-gnucash-core-c-py DEPENDS swig-gnucash-core)
-  dist_add_generated(swig-gnucash-core-c-py gnucash_core_c.py)
 ELSE()
   SET (SWIG_GNUCASH_CORE_C gnucash_core.c)
-  SET (SWIG_GNUCASH_CORE_C_PY ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core_c.py)
+  SET (SWIG_GNUCASH_CORE_PY ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core_c.py)
 ENDIF()
 
 IF(WITH_PYTHON)
@@ -87,14 +86,14 @@ IF(WITH_PYTHON)
     LIBRARY DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
     ARCHIVE DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
   )
-  INSTALL(FILES ${PYEXEC_FILES} ${SWIG_GNUCASH_CORE_C_PY}
+  INSTALL(FILES ${PYEXEC_FILES} ${SWIG_GNUCASH_CORE_PY}
     DESTINATION ${PYTHON_SYSCONFIG_OUTPUT}/gnucash
   )
 
   FILE(COPY ${PYEXEC_FILES} DESTINATION ${PYTHON_SYSCONFIG_BUILD}/gnucash)
 
   ADD_CUSTOM_TARGET(gnucash-core-c-py ALL
-    COMMAND ${CMAKE_COMMAND} -E copy ${SWIG_GNUCASH_CORE_C_PY} ${PYTHON_SYSCONFIG_BUILD}/gnucash
+    COMMAND ${CMAKE_COMMAND} -E copy ${SWIG_GNUCASH_CORE_PY} ${PYTHON_SYSCONFIG_BUILD}/gnucash
     DEPENDS ${SWIG_GNUCASH_CORE_C})
 
   ADD_CUSTOM_TARGET(gnucash-core-c-build ALL
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index c94daf1..f1ab34a 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -12,12 +12,21 @@ SET(common_EXTRA_DIST
         guile-mappings.h
         platform.h)
 
-IF (BUILDING_FROM_VCS)
-  SET (SWIG_RUNTIME_H ${CMAKE_CURRENT_BINARY_DIR}/swig-runtime.h PARENT_SCOPE)
-ELSE()
-  SET (SWIG_RUNTIME_H ${CMAKE_CURRENT_SOURCE_DIR}/swig-runtime.h PARENT_SCOPE)
-ENDIF()
-dist_add_generated(swig-runtime-h swig-runtime.h)
+
+if (BUILDING_FROM_VCS)
+    set (SWIG_RUNTIME_H ${CMAKE_CURRENT_BINARY_DIR}/swig-runtime.h)
+    # Command to generate the swig-runtime.h header
+    add_custom_command (
+        OUTPUT ${SWIG_RUNTIME_H}
+        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
+        COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H}
+    )
+else()
+    set (SWIG_RUNTIME_H ${CMAKE_CURRENT_SOURCE_DIR}/swig-runtime.h)
+endif()
+dist_add_generated(swig-runtime.h)
+
+add_custom_target (swig-runtime-h DEPENDS ${SWIG_RUNTIME_H})
 
 SET_LOCAL_DIST(common_DIST_local CMakeLists.txt ${common_EXTRA_DIST})
 
diff --git a/common/cmake_modules/GncAddSwigCommand.cmake b/common/cmake_modules/GncAddSwigCommand.cmake
index b1cf1e9..de32e0f 100644
--- a/common/cmake_modules/GncAddSwigCommand.cmake
+++ b/common/cmake_modules/GncAddSwigCommand.cmake
@@ -20,12 +20,13 @@ macro (GNC_ADD_SWIG_COMMAND _target _output _input)
         set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
     endif()
 
+    # Add the output file _output to the dist tarball
     file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
-    dist_add_generated(${_target} ${generated})
+    dist_add_generated(${generated})
 endmacro (GNC_ADD_SWIG_COMMAND)
 
 
-macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
+macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _py_output _input)
 
     set (DEFAULT_SWIG_PYTHON_FLAGS
         -python
@@ -39,16 +40,15 @@ macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
         ${CMAKE_SOURCE_DIR}/libgnucash/app-utils
     )
 
-
     set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
     foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
         list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
     endforeach (dir)
-    add_custom_command(OUTPUT ${_output}
+    add_custom_command(OUTPUT ${_output} ${_py_output}
         COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${_output} ${_input}
         DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
     )
-    add_custom_target(${_target} ALL DEPENDS ${_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
+    add_custom_target(${_target} ALL DEPENDS ${_output} ${_py_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
 
 
     if (BUILDING_FROM_VCS)
@@ -57,6 +57,10 @@ macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
         set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
     endif()
 
+    # Add the output files _output and _py_output to the dist tarball
     file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
-    dist_add_generated(${_target} ${generated})
+    dist_add_generated(${generated})
+
+    file(RELATIVE_PATH py_generated ${BUILD_SOURCE_DIR} ${_py_output})
+    dist_add_generated(${py_generated})
 endmacro()
diff --git a/common/cmake_modules/MakeDistFiles.cmake b/common/cmake_modules/MakeDistFiles.cmake
index 98bf436..359e243 100644
--- a/common/cmake_modules/MakeDistFiles.cmake
+++ b/common/cmake_modules/MakeDistFiles.cmake
@@ -30,32 +30,54 @@ FUNCTION(EXECUTE_PROCESS_AND_CHECK_RESULT)
     ENDIF()
 ENDFUNCTION()
 
-# These macros can be called to add a generated file (as opposed to a source file)
+macro(make_target_name target source)
+    if(BUILDING_FROM_VCS)
+        set(TGT_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
+        set(TGT_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+    else()
+        set(TGT_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+        set(TGT_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+    endif()
+
+    file(RELATIVE_PATH rel_file ${TGT_BUILD_SOURCE_DIR} ${TGT_CURRENT_BUILD_SOURCE_DIR}/${source})
+    string(REPLACE "/" "-" target_tmp ${rel_file})
+    string(REPLACE "_" "-" target_tmp2 ${target_tmp})
+    string(REPLACE "." "-" ${target} dist-${target_tmp2})
+endmacro()
+
+# These macros can be called to add generated files (as opposed to source files)
 # to the distribution tarball
-# - dist_add_configured will only add the file to the tarball. This macro
+# - dist_add_configured will only add the files to the tarball. This macro
 #   should be used for files that are generated during a cmake run (for example with configure_file)
-# - dist_add_generated will add the file to the tarball and generate a dependency
-#   for the file to the dist target. This macro should be used for all files that
-#   will be generated during a "make" or "ninja-build" run
-macro(dist_add_configured _configured)
-    if (BUILDING_FROM_VCS)
-        set(BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
-        set(CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+# - dist_add_generated will add the files to the tarball and generate a dependency
+#   for each file to the dist target. This macro should be used for all files that
+#   will be generated during a "make" or "ninja-build" run (for example those that are
+#   the result of an add_custom_command)
+macro(dist_add_configured)
+    if(BUILDING_FROM_VCS)
+        set(CONF_BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
+        set(CONF_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
     else()
-        set(BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
-        set(CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+        set(CONF_BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+        set(CONF_CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
     endif()
-    file(RELATIVE_PATH rel_conf ${BUILD_SOURCE_DIR} ${CURRENT_BUILD_SOURCE_DIR}/${_configured})
 
     set(local_generated ${dist_generated})
-    list(APPEND local_generated ${rel_conf})
+    foreach(conf_file ${ARGN})
+        file(RELATIVE_PATH rel_conf ${CONF_BUILD_SOURCE_DIR} ${CONF_CURRENT_BUILD_SOURCE_DIR}/${conf_file})
+        list(APPEND local_generated ${rel_conf})
+    endforeach()
     set(dist_generated ${local_generated} CACHE INTERNAL "generated files that will be included in the distribution tarball")
 endmacro()
 
-macro(dist_add_generated _target _generated)
-    dist_add_configured(${_generated})
+macro(dist_add_generated)
+    dist_add_configured(${ARGN})
 
     set(local_generated_depends ${dist_generated_depends})
-    list(APPEND local_generated_depends ${_target})
+    foreach(gen_file ${ARGN})
+        make_target_name(dist_target ${gen_file})
+        add_custom_target(${dist_target} DEPENDS ${TGT_CURRENT_BUILD_SOURCE_DIR}/${gen_file}) # Note TGT_CURRENT_BUILD_SOURCE_DIR trickles down from the make_target macro
+        list(APPEND local_generated_depends ${dist_target})
+    endforeach()
     set(dist_generated_depends ${local_generated_depends} CACHE INTERNAL "global targets for generated files that will be included in the distribution tarball")
 endmacro()
diff --git a/common/test-core/CMakeLists.txt b/common/test-core/CMakeLists.txt
index 161d94a..e2e4a44 100644
--- a/common/test-core/CMakeLists.txt
+++ b/common/test-core/CMakeLists.txt
@@ -32,9 +32,11 @@ IF (BUILDING_FROM_VCS)
   GNC_ADD_SWIG_COMMAND (swig-unittest-support-guile-c ${SWIG_UNITTEST_SUPPORT_GUILE_C}
       ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS})
   SET (SWIG_UNITTEST_SUPPORT_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-python.c)
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-unittest-support-python ${SWIG_UNITTEST_SUPPORT_PYTHON_C} ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i)
-  add_custom_target(unittest-support-py DEPENDS swig-unittest-support-python)
-  dist_add_generated(unittest-support-py unittest_support.py)
+  SET (SWIG_UNITTEST_SUPPORT_PYTHON_PY ${CMAKE_CURRENT_BINARY_DIR}/unittest_support.py)
+  GNC_ADD_SWIG_PYTHON_COMMAND (swig-unittest-support-python
+        ${SWIG_UNITTEST_SUPPORT_PYTHON_C}
+        ${SWIG_UNITTEST_SUPPORT_PYTHON_PY}
+        ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i)
 ELSE()
   SET (SWIG_UNITTEST_SUPPORT_GUILE_C  swig-unittest-support-guile.c)
   SET (SWIG_UNITTEST_SUPPORT_PYTHON_C swig-unittest-support-python.c)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index c2d1953..a3b3e4b 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -84,6 +84,6 @@ ADD_CUSTOM_COMMAND(OUTPUT gnucash.1
                            -P ${CMAKE_CURRENT_BINARY_DIR}/manpage.cmake
   )
 ADD_CUSTOM_TARGET(gnucash-manpage DEPENDS gnucash.1)
-dist_add_generated(gnucash-manpage gnucash.1)
+dist_add_generated(gnucash.1)
 
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1 DESTINATION  ${CMAKE_INSTALL_MANDIR}/man1)
diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt
index 13eb87f..71754cb 100644
--- a/gnucash/gnome-utils/CMakeLists.txt
+++ b/gnucash/gnome-utils/CMakeLists.txt
@@ -33,7 +33,7 @@ ADD_CUSTOM_COMMAND(
 )
 
 ADD_CUSTOM_TARGET(gnc-warnings-c DEPENDS ${GNC_WARNINGS_C})
-dist_add_generated(gnc-warnings-c gnc-warnings.c)
+dist_add_generated(gnc-warnings.c)
 # FIXME why is gnc-warnings.c added to dist and gnc-warnings.h not ? I think neither is necessary...
 
 #GTK before 3.14 didn't have GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index c80d7d8..5331383 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -128,7 +128,6 @@ SET (gnc_gnome_SOURCES
 )  
 
 SET_SOURCE_FILES_PROPERTIES (${gnc_gnome_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
-SET_SOURCE_FILES_PROPERTIES (business-options-gnome.c PROPERTIES OBJECT_DEPENDS ${SWIG_RUNTIME_H})
 
 IF (WIN32)
   SET (gnc_gnome_SOURCES ${gnc_gnome_SOURCES} ${CMAKE_SOURCE_DIR}/borrowed/libc/strfmon.c)
@@ -148,6 +147,7 @@ TARGET_INCLUDE_DIRECTORIES(gnc-gnome
     ${GTK_MAC_INCLUDE_DIRS}
 )
 
+add_dependencies (gnc-gnome swig-runtime-h)
 
 IF (MAC_INTEGRATION)
   TARGET_COMPILE_OPTIONS(gnc-gnome PRIVATE ${OSX_EXTRA_COMPILE_FLAGS})
diff --git a/libgnucash/app-utils/CMakeLists.txt b/libgnucash/app-utils/CMakeLists.txt
index bd8accd..a3ab7b1 100644
--- a/libgnucash/app-utils/CMakeLists.txt
+++ b/libgnucash/app-utils/CMakeLists.txt
@@ -42,7 +42,11 @@ IF (BUILDING_FROM_VCS)
   SET (SWIG_APP_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-app-utils-guile.c)
   GNC_ADD_SWIG_COMMAND (swig-apputils-guile-c ${SWIG_APP_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i)
   SET (SWIG_APP_UTILS_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-app-utils-python.c)
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-app-utils-python ${SWIG_APP_UTILS_PYTHON_C} ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i)
+  SET (SWIG_APP_UTILS_PYTHON_PY ${CMAKE_CURRENT_BINARY_DIR}/sw_app_utils.py)
+  GNC_ADD_SWIG_PYTHON_COMMAND (swig-app-utils-python
+        ${SWIG_APP_UTILS_PYTHON_C}
+        ${SWIG_APP_UTILS_PYTHON_PY}
+        ${CMAKE_CURRENT_SOURCE_DIR}/app-utils.i)
 ELSE()
   SET (SWIG_APP_UTILS_GUILE_C swig-app-utils-guile.c)
   SET (SWIG_APP_UTILS_PYTHON_C swig-app-utils-python.c)
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index 2f179c7..fa2b48f 100644
--- a/libgnucash/core-utils/CMakeLists.txt
+++ b/libgnucash/core-utils/CMakeLists.txt
@@ -6,7 +6,11 @@ IF (BUILDING_FROM_VCS)
   SET (SWIG_CORE_UTILS_GUILE_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-guile.c)
   GNC_ADD_SWIG_COMMAND (swig-core-utils-guile-c ${SWIG_CORE_UTILS_GUILE_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
   SET (SWIG_CORE_UTILS_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-core-utils-python.c)
-  GNC_ADD_SWIG_PYTHON_COMMAND (swig-core-utils-python ${SWIG_CORE_UTILS_PYTHON_C} ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
+  SET (SWIG_CORE_UTILS_PYTHON_PY ${CMAKE_CURRENT_BINARY_DIR}/sw_core_utils.py)
+  GNC_ADD_SWIG_PYTHON_COMMAND (swig-core-utils-python
+        ${SWIG_CORE_UTILS_PYTHON_C}
+        ${SWIG_CORE_UTILS_PYTHON_PY}
+        ${CMAKE_CURRENT_SOURCE_DIR}/core-utils.i)
 ELSE()
   SET(SWIG_CORE_UTILS_GUILE_C swig-core-utils-guile.c)
   SET(SWIG_CORE_UTILS_PYTHON_C swig-core-utils-python.c)
@@ -28,20 +32,6 @@ SET (core_utils_SOURCES
 # Add dependency on config.h
 SET_SOURCE_FILES_PROPERTIES (${core_utils_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFIG_H})
 
-IF (BUILDING_FROM_VCS)
-  # Command to generate the swig-runtime.h header
-  ADD_CUSTOM_COMMAND (
-    OUTPUT ${SWIG_RUNTIME_H}
-    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
-    COMMAND ${SWIG_EXECUTABLE} -guile -external-runtime ${SWIG_RUNTIME_H}
-  )
-ENDIF()
-
-ADD_CUSTOM_TARGET(swig-runtime-h DEPENDS ${SWIG_RUNTIME_H})
-
-# Add dependency on swig-runtime.h
-SET_SOURCE_FILES_PROPERTIES (gnc-guile-utils.c PROPERTIES OBJECT_DEPENDS ${SWIG_RUNTIME_H})
-
 SET(prefix ${CMAKE_INSTALL_PREFIX})
 if(ENABLE_BINRELOC)
   SET(datadir ${DATADIR})
@@ -122,7 +112,7 @@ ENDIF()
 ELSE(BUILDING_FROM_VCS)
   ADD_CUSTOM_TARGET(gnc-vcs-info DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnc-vcs-info.h)
 ENDIF(BUILDING_FROM_VCS)
-dist_add_generated(gnc-vcs-info gnc-vcs-info.h)
+dist_add_generated(gnc-vcs-info.h)
 ### Compile library
 
 SET(core_utils_noinst_HEADERS
@@ -157,8 +147,8 @@ IF (MAC_INTEGRATION)
   LIST(APPEND core_utils_ALL_LIBRARIES ${OSX_EXTRA_LIBRARIES})
 ENDIF()
 
-ADD_LIBRARY	(gnc-core-utils ${core_utils_ALL_SOURCES} ${SWIG_CORE_UTILS_GUILE_C})
-ADD_DEPENDENCIES(gnc-core-utils gnc-vcs-info)
+ADD_LIBRARY(gnc-core-utils ${core_utils_ALL_SOURCES} ${SWIG_CORE_UTILS_GUILE_C})
+add_dependencies(gnc-core-utils gnc-vcs-info swig-runtime-h)
 
 TARGET_LINK_LIBRARIES(gnc-core-utils ${core_utils_ALL_LIBRARIES})
 
diff --git a/libgnucash/doc/design/CMakeLists.txt b/libgnucash/doc/design/CMakeLists.txt
index dab6769..99ff155 100644
--- a/libgnucash/doc/design/CMakeLists.txt
+++ b/libgnucash/doc/design/CMakeLists.txt
@@ -28,8 +28,7 @@ SET(VERSION_TEXI_IN
 
 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.texi ${VERSION_TEXI_IN})
 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/stamp-vti ${VERSION_TEXI_IN})
-dist_add_configured(version.texi)
-dist_add_configured(stamp-vti)
+dist_add_configured(version.texi stamp-vti)
 
 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" TEXI_BINARY_DIR)
 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gnucash-design.texi" TEXI_SOURCE_FILE)
@@ -37,18 +36,19 @@ find_program(MAKEINFO makeinfo)
 if (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
 
   IF(${CMAKE_VERSION} VERSION_GREATER 3.1)
-    ADD_CUSTOM_TARGET(gnucash-design-info ALL
+    add_custom_command(
+      OUTPUT gnucash-design.info
       COMMAND ${MAKEINFO} -I ${TEXI_BINARY_DIR} ${TEXI_SOURCE_FILE}
-      BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/gnucash-design.info
       DEPENDS ${gnucash_design_TEXINFOS}
       )
   ELSE()
-    ADD_CUSTOM_TARGET(gnucash-design-info ALL
+    add_custom_command(
+      OUTPUT gnucash-design.info
       COMMAND ${MAKEINFO} -I ${TEXI_BINARY_DIR} ${TEXI_SOURCE_FILE}
       DEPENDS ${gnucash_design_TEXINFOS}
       )
   ENDIF()
 endif (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
-dist_add_generated(gnucash-design-info gnucash-design.info)
+dist_add_generated(gnucash-design.info)
 
 SET_DIST_LIST(doc_design_DIST CMakeLists.txt gnucash-design.texi ${gnucash_design_TEXINFOS})
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index c0b5a9d..8d38edd 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -134,7 +134,7 @@ ADD_CUSTOM_COMMAND (
     ${LIBXSLT_XSLTPROC_EXECUTABLE} -o ${ISO_4217_C} "${CMAKE_CURRENT_SOURCE_DIR}/iso-currencies-to-c.xsl" "${CMAKE_CURRENT_SOURCE_DIR}/iso-4217-currencies.xml"
     )
 ADD_CUSTOM_TARGET(iso-4217-c DEPENDS ${ISO_4217_C})
-dist_add_generated(iso-4217-c iso-4217-currencies.c)
+dist_add_generated(iso-4217-currencies.c)
 
 SET (engine_SOURCES
   Account.cpp
@@ -221,9 +221,6 @@ SET_SOURCE_FILES_PROPERTIES (${engine_SOURCES} PROPERTIES OBJECT_DEPENDS ${CONFI
 # Add dependency on iso-4217-currencies.c
 SET_SOURCE_FILES_PROPERTIES (gnc-commodity.c PROPERTIES OBJECT_DEPENDS "${ISO_4217_C};${CONFIG_H}")
 
-# Add dependency on swig-runtime.h
-SET_SOURCE_FILES_PROPERTIES (gnc-hooks.c engine-helpers.c kvp-scm.cpp glib-helpers.c PROPERTIES OBJECT_DEPENDS "${CONFIG_H};${SWIG_RUNTIME_H}")
-
 
 
 ADD_LIBRARY (gncmod-engine
@@ -233,6 +230,9 @@ ADD_LIBRARY (gncmod-engine
   ${engine_noinst_HEADERS}
 )
 
+# Add dependency on swig-runtime.h
+add_dependencies (gncmod-engine swig-runtime-h)
+
 TARGET_LINK_LIBRARIES(gncmod-engine gnc-core-utils gnc-module ${Boost_DATE_TIME_LIBRARIES}  ${Boost_REGEX_LIBRARIES} ${REGEX_LDFLAGS} ${GMODULE_LDFLAGS} ${GLIB2_LDFLAGS} ${GOBJECT_LDFLAGS} ${GUILE_LDFLAGS})
 
 TARGET_COMPILE_DEFINITIONS (gncmod-engine PRIVATE -DG_LOG_DOMAIN=\"gnc.engine\")
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 96a4ab3..50544ab 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -159,7 +159,7 @@ IF(BUILDING_FROM_VCS)
     MESSAGE(FATAL_ERROR "Can't find the 'xgettext' program.")
   ENDIF ()
 
-  add_custom_target(gnucash-pot
+  add_custom_command(OUTPUT gnucash.pot
         COMMAND ${CMAKE_COMMAND}
            -D INTLTOOL_EXTRACT=${INTLTOOL_EXTRACT}
            -D INTLTOOL_UPDATE=${INTLTOOL_UPDATE}
@@ -171,12 +171,8 @@ IF(BUILDING_FROM_VCS)
            -P ${CMAKE_CURRENT_SOURCE_DIR}/gnucash-pot.cmake
         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
   )
-
-ELSE()
-    add_custom_target(gnucash-pot
-        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot)
 ENDIF()
-dist_add_generated(gnucash-pot gnucash.pot)
+dist_add_generated(gnucash.pot)
 
 ADD_CUSTOM_TARGET(check-po
         COMMAND ${CMAKE_COMMAND}

commit 3dff4e521126f6600da2ca3090b8f3e9c15b950b
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sun Jan 28 17:45:49 2018 +0100

    Fix make dist on a clean checkout
    
    cmake with unix makefiles fails to resolve dist dependencies
    added from COPY_FROM_BUILD if these dependencies aren't built yet.
    
    This commit replaces the COPY_FROM_BUILD based logic with two new functions
    'dist_add_configured' and 'dist_add_generated' to indicate which files should
    be included in the dist tarball. The latter also adds a target level dependency
    to the dist tarball custom command. Hence the former should
    be used for files that get generated during a cmake run while the latter
    should be used for files generated as the result of a 'make/ninja-build' run
    (like files for which an add_custom_command rule exists).
    
    Note: this commit also temporarily disables the dist target when building
    from a tarball (and hence it won't be tested in distcheck either). This
    will be handled in a future commit.

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1c0170e..aea4982 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,10 @@ SET (GNUCASH_RESAVE_VERSION "19920")
 
 SET(GETTEXT_PACKAGE "gnucash")
 
+# Clear cache variables that will be filled later during the cmake run
+unset(dist_generated CACHE)
+unset(dist_generated_depends CACHE)
+
 # Extra cmake macros
 SET (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/common/cmake_modules;${CMAKE_MODULE_PATH}")
 # CMake does a non-recursive build that puts the final build product directories in the build root. Some code needs to know this.
@@ -763,9 +767,24 @@ ADD_SUBDIRECTORY (util)
 # it contains post-install actions to execute.
 ADD_SUBDIRECTORY(cmake)
 
-############################ BEGIN MAKE DIST #################
+# Generate the ChangeLog
 
+if (BUILDING_FROM_VCS)
+    add_custom_target(ChangeLog ALL
+        COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2018-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
+        WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+    )
+    dist_add_generated(ChangeLog ChangeLog)
+    install(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
+else()
+    install(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
+endif()
 
+############################ BEGIN MAKE DIST #################
+# For now only enable the dist target when building from git
+# the generation of dist_generated should be improved to work
+# also when running from a tarball before that can be generalized.
+IF (BUILDING_FROM_VCS)
 
 SET(PACKAGE_PREFIX "${PACKAGE}-${PACKAGE_VERSION}")
 SET(DIST_FILE "${PACKAGE_PREFIX}.tar")
@@ -800,12 +819,6 @@ ENDIF()
 STRING(REPLACE ";" "\n" ALL_DIST_LINES "${ALL_DIST}")
 FILE(WRITE ${CMAKE_BINARY_DIR}/dist_manifest.txt ${ALL_DIST_LINES})
 
-SET(DIST_GENERATED_FILES2 "")
-FOREACH(file ${COPY_FROM_BUILD})
-  LIST(APPEND DIST_GENERATED_FILES2 ${BUILD_SOURCE_DIR}/${file})
-ENDFOREACH()
-
-
 ADD_CUSTOM_COMMAND(OUTPUT ${DIST_FILE}.gz ${DIST_FILE}.bz2
         COMMAND ${CMAKE_COMMAND}
            -D CMAKE_MODULE_PATH=${CMAKE_SOURCE_DIR}/common/cmake_modules
@@ -815,10 +828,11 @@ ADD_CUSTOM_COMMAND(OUTPUT ${DIST_FILE}.gz ${DIST_FILE}.bz2
            -D BUILDING_FROM_VCS=${BUILDING_FROM_VCS}
            -D SHELL=${SHELL}
            -D WITH_GNUCASH=${WITH_GNUCASH}
+           "-Ddist_generated=\"${dist_generated}\""
            -P ${CMAKE_SOURCE_DIR}/common/cmake_modules/MakeDist.cmake
 
         DEPENDS
-          ${ALL_DIST} ${DIST_GENERATED_FILES2} gnc-vcs-info iso-4217-c gnc-warnings-c gnucash-design-info ChangeLog gnucash-pot
+          ${ALL_DIST} ${dist_generated_depends}
         )
 
 ADD_CUSTOM_TARGET(dist DEPENDS ${DIST_FILE}.gz ${DIST_FILE}.bz2)
@@ -835,6 +849,7 @@ ADD_CUSTOM_TARGET(distcheck DEPENDS dist
 
 
 
+ENDIF()
 ############################# END MAKE DIST #################
 
 # uninstall target
@@ -876,18 +891,6 @@ IF (WIN32)
   )
 ENDIF()
 
-# Generate the ChangeLog
-
-IF (BUILDING_FROM_VCS)
-  ADD_CUSTOM_TARGET(ChangeLog ALL
-    COMMAND ${GIT_EXECUTABLE} log --format=\"%ad %aN %n%n%x09* %s%d%n\" --date=short --since=2018-01-01 > ${CMAKE_BINARY_DIR}/ChangeLog
-    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
-  )
-  INSTALL(FILES ${CMAKE_BINARY_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
-ELSE()
-  INSTALL(FILES ${CMAKE_SOURCE_DIR}/ChangeLog DESTINATION ${CMAKE_INSTALL_DOCDIR})
-ENDIF()
-
 #Link LICENSE to COPYING so that people expecting to find it,
 #will. COPYING is normally linked by autogen.sh to the latest
 #automake-provided version.
diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt
index 299887b..2f9e929 100644
--- a/bindings/python/CMakeLists.txt
+++ b/bindings/python/CMakeLists.txt
@@ -46,6 +46,8 @@ IF (BUILDING_FROM_VCS)
     ${CMAKE_SOURCE_DIR}/libgnucash/engine/engine-common.i
     ${GNUCASH_CORE_C_INCLUDES}
   )
+  add_custom_target(swig-gnucash-core-c-py DEPENDS swig-gnucash-core)
+  dist_add_generated(swig-gnucash-core-c-py gnucash_core_c.py)
 ELSE()
   SET (SWIG_GNUCASH_CORE_C gnucash_core.c)
   SET (SWIG_GNUCASH_CORE_C_PY ${CMAKE_CURRENT_SOURCE_DIR}/gnucash_core_c.py)
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt
index 1a4833d..c94daf1 100644
--- a/common/CMakeLists.txt
+++ b/common/CMakeLists.txt
@@ -17,7 +17,7 @@ IF (BUILDING_FROM_VCS)
 ELSE()
   SET (SWIG_RUNTIME_H ${CMAKE_CURRENT_SOURCE_DIR}/swig-runtime.h PARENT_SCOPE)
 ENDIF()
-
+dist_add_generated(swig-runtime-h swig-runtime.h)
 
 SET_LOCAL_DIST(common_DIST_local CMakeLists.txt ${common_EXTRA_DIST})
 
diff --git a/common/cmake_modules/GncAddSwigCommand.cmake b/common/cmake_modules/GncAddSwigCommand.cmake
index 1fdcaa54..b1cf1e9 100644
--- a/common/cmake_modules/GncAddSwigCommand.cmake
+++ b/common/cmake_modules/GncAddSwigCommand.cmake
@@ -4,41 +4,59 @@
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-MACRO (GNC_ADD_SWIG_COMMAND _target _output _input)
-
-ADD_CUSTOM_COMMAND (
-  OUTPUT ${_output}
-  DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
-COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libgnucash/engine -I${CMAKE_SOURCE_DIR}/common  -o ${_output} ${_input}
-)
-
-ADD_CUSTOM_TARGET(${_target} DEPENDS ${_output})
-
-ENDMACRO (GNC_ADD_SWIG_COMMAND)
-
-
-MACRO (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
-
-  set (DEFAULT_SWIG_PYTHON_FLAGS
-    -python
-    -Wall -Werror
-    ${SWIG_ARGS}
-  )
-  set (DEFAULT_SWIG_PYTHON_C_INCLUDES
-    ${GLIB2_INCLUDE_DIRS}
-    ${CMAKE_SOURCE_DIR}/common
-    ${CMAKE_SOURCE_DIR}/libgnucash/engine
-    ${CMAKE_SOURCE_DIR}/libgnucash/app-utils
-  )
-
-
-  set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
-  foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
-    list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
-  endforeach (dir)
-  ADD_CUSTOM_COMMAND(OUTPUT ${_output}
-    COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${_output} ${_input}
-    DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
-  )
-  ADD_CUSTOM_TARGET(${_target} ALL DEPENDS ${_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
-ENDMACRO()
+macro (GNC_ADD_SWIG_COMMAND _target _output _input)
+
+    add_custom_command (
+        OUTPUT ${_output}
+        DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
+        COMMAND ${SWIG_EXECUTABLE} -guile ${SWIG_ARGS} -Linkage module -I${CMAKE_SOURCE_DIR}/libgnucash/engine -I${CMAKE_SOURCE_DIR}/common  -o ${_output} ${_input}
+    )
+
+    add_custom_target(${_target} DEPENDS ${_output})
+
+    if (BUILDING_FROM_VCS)
+        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+    else()
+        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+    endif()
+
+    file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
+    dist_add_generated(${_target} ${generated})
+endmacro (GNC_ADD_SWIG_COMMAND)
+
+
+macro (GNC_ADD_SWIG_PYTHON_COMMAND _target _output _input)
+
+    set (DEFAULT_SWIG_PYTHON_FLAGS
+        -python
+        -Wall -Werror
+        ${SWIG_ARGS}
+    )
+    set (DEFAULT_SWIG_PYTHON_C_INCLUDES
+        ${GLIB2_INCLUDE_DIRS}
+        ${CMAKE_SOURCE_DIR}/common
+        ${CMAKE_SOURCE_DIR}/libgnucash/engine
+        ${CMAKE_SOURCE_DIR}/libgnucash/app-utils
+    )
+
+
+    set (PYTHON_SWIG_FLAGS ${DEFAULT_SWIG_PYTHON_FLAGS})
+    foreach (dir ${DEFAULT_SWIG_PYTHON_C_INCLUDES})
+        list (APPEND PYTHON_SWIG_FLAGS "-I${dir}")
+    endforeach (dir)
+    add_custom_command(OUTPUT ${_output}
+        COMMAND ${SWIG_EXECUTABLE} ${PYTHON_SWIG_FLAGS} -o ${_output} ${_input}
+        DEPENDS ${_input} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${ARGN}
+    )
+    add_custom_target(${_target} ALL DEPENDS ${_output} ${CMAKE_SOURCE_DIR}/common/base-typemaps.i ${_input} ${ARGN})
+
+
+    if (BUILDING_FROM_VCS)
+        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+    else()
+        set(BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+    endif()
+
+    file(RELATIVE_PATH generated ${BUILD_SOURCE_DIR} ${_output})
+    dist_add_generated(${_target} ${generated})
+endmacro()
diff --git a/common/cmake_modules/MakeDist.cmake b/common/cmake_modules/MakeDist.cmake
index 0f531d0..9429b6d 100644
--- a/common/cmake_modules/MakeDist.cmake
+++ b/common/cmake_modules/MakeDist.cmake
@@ -1,15 +1,13 @@
 # This file implements the process of making source distribution tarballs. It expects to find list in
 # 'dist_manifest.txt' of all of the files to be included in the distribution, EXCEPT those
-# files that are generated. The list of generated files is specified in MakeDistFiles.cmake in the
-# COPY_FROM_BUILD and COPY_FROM_BUILD_2 variables.
+# files that are generated. The list of generated files handled via the 'dist_generated' cmake cache variable
 #
 # Given all of these files, the procedure is to:
 # 1. Remove any existing dist directory and make a new one.
-# 2. Copy of all the files in dist_manifest.text, COPY_FROM_BUILD and COPY_FROM_BUILD_2
+# 2. Copy of all the files in dist_manifest.text and ${dist_generated}
 #    into the dist directory.
-# 3. Run autogen.sh if build a dist from Git.
-# 4. Create the tarball and compress it with gzip and bzip2.
-# 5. Then remove the dist directory.
+# 3. Create the tarball and compress it with gzip and bzip2.
+# 4. Then remove the dist directory.
 
 include(${CMAKE_MODULE_PATH}/MakeDistFiles.cmake)
 
@@ -48,7 +46,7 @@ FUNCTION(MAKE_DIST PACKAGE_PREFIX GNUCASH_SOURCE_DIR BUILD_SOURCE_DIR BUILDING_F
 
     # -- Copy in build products that are distributed.
 
-    FOREACH(file ${COPY_FROM_BUILD} ${COPY_FROM_BUILD_2})
+    FOREACH(file ${dist_generated})
         EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy ${BUILD_SOURCE_DIR}/${file} ${PACKAGE_PREFIX}/${file})
         IF (NOT EXISTS ${PACKAGE_PREFIX}/${file})
             MESSAGE(FATAL_ERROR "Copy of ${BUILD_SOURCE_DIR}/${file} to dist dir '${PACKAGE_PREFIX}' failed.")
diff --git a/common/cmake_modules/MakeDistCheck.cmake b/common/cmake_modules/MakeDistCheck.cmake
index 05d019c..3868aa2 100644
--- a/common/cmake_modules/MakeDistCheck.cmake
+++ b/common/cmake_modules/MakeDistCheck.cmake
@@ -63,7 +63,6 @@ FUNCTION(RUN_DIST_CHECK PACKAGE_PREFIX EXT)
     )
 
     # Run ninja install
-
     EXECUTE_PROCESS_AND_CHECK_RESULT(
             COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} install
             WORKING_DIRECTORY ${BUILD_DIR}
@@ -77,12 +76,12 @@ FUNCTION(RUN_DIST_CHECK PACKAGE_PREFIX EXT)
             ERROR_MSG "Ninja check failed."
     )
 
-    # Run ninja dist
-    EXECUTE_PROCESS_AND_CHECK_RESULT(
-            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
-            WORKING_DIRECTORY ${BUILD_DIR}
-            ERROR_MSG "Ninja dist failed."
-    )
+#    # Run ninja dist
+#    EXECUTE_PROCESS_AND_CHECK_RESULT(
+#            COMMAND ${MY_CMAKE_COMMAND} ${NINJA_COMMAND} dist
+#            WORKING_DIRECTORY ${BUILD_DIR}
+#            ERROR_MSG "Ninja dist failed."
+#    )
 
     MESSAGE("distcheck complete.")
 
diff --git a/common/cmake_modules/MakeDistFiles.cmake b/common/cmake_modules/MakeDistFiles.cmake
index 68aa8b3..98bf436 100644
--- a/common/cmake_modules/MakeDistFiles.cmake
+++ b/common/cmake_modules/MakeDistFiles.cmake
@@ -30,57 +30,32 @@ FUNCTION(EXECUTE_PROCESS_AND_CHECK_RESULT)
     ENDIF()
 ENDFUNCTION()
 
-
-# This is a list of files generated at build time that
-# should be copied into the dist tarball. An item in
-# this list should be a file, not a directory or glob.
-# File in this list become dependenices of the 'dist'
-# target.
-
-
-SET(COPY_FROM_BUILD
-  ChangeLog
-  doc/gnucash.1
-  libgnucash/app-utils/swig-app-utils-guile.c
-  libgnucash/app-utils/swig-app-utils-python.c
-  gnucash/gnucash.rc
-  libgnucash/core-utils/gnc-vcs-info.h
-  libgnucash/core-utils/swig-core-utils-guile.c
-  libgnucash/core-utils/swig-core-utils-python.c
-  libgnucash/doc/design/gnucash-design.info
-  libgnucash/engine/iso-4217-currencies.c
-  libgnucash/engine/swig-engine.c
-  libgnucash/gnc-module/swig-gnc-module.c
-  libgnucash/gnc-module/test/mod-bar/swig-bar.c
-  libgnucash/gnc-module/test/mod-baz/swig-baz.c
-  libgnucash/gnc-module/test/mod-foo/swig-foo.c
-  gnucash/gnome/gnucash.desktop.in
-  gnucash/gnome/swig-gnome.c
-  gnucash/gnome-utils/gnc-warnings.c
-  gnucash/gnome-utils/swig-gnome-utils.c
-  gnucash/html/swig-gnc-html.c
-  bindings/python/gnucash_core.c
-  gnucash/report/report-gnome/swig-report-gnome.c
-  gnucash/report/report-system/swig-report-system.c
-  libgnucash/scm/build-config.scm
-  common/swig-runtime.h
-  common/test-core/swig-unittest-support-guile.c
-  common/test-core/swig-unittest-support-python.c
-)
-
-# This list is similiar to the COPY_FROM_BUILD list
-# above, except that we don't create an explicit
-# dependency on this for the 'dist' target. I need
-# to fix the creation of these files so that we
-# can add them as dependencies for 'dist'. These
-# file are not generated using CONFIGURE_FILE(),
-# so CMake does not realize these are generated files.
-
-SET(COPY_FROM_BUILD_2
-        po/gnucash.pot
-        libgnucash/doc/design/stamp-vti
-        libgnucash/doc/design/version.texi
-        bindings/python/gnucash_core_c.py
-        common/test-core/unittest_support.py
-
-        )
+# These macros can be called to add a generated file (as opposed to a source file)
+# to the distribution tarball
+# - dist_add_configured will only add the file to the tarball. This macro
+#   should be used for files that are generated during a cmake run (for example with configure_file)
+# - dist_add_generated will add the file to the tarball and generate a dependency
+#   for the file to the dist target. This macro should be used for all files that
+#   will be generated during a "make" or "ninja-build" run
+macro(dist_add_configured _configured)
+    if (BUILDING_FROM_VCS)
+        set(BUILD_SOURCE_DIR ${CMAKE_BINARY_DIR})
+        set(CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR})
+    else()
+        set(BUILD_SOURCE_DIR ${CMAKE_SOURCE_DIR})
+        set(CURRENT_BUILD_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+    endif()
+    file(RELATIVE_PATH rel_conf ${BUILD_SOURCE_DIR} ${CURRENT_BUILD_SOURCE_DIR}/${_configured})
+
+    set(local_generated ${dist_generated})
+    list(APPEND local_generated ${rel_conf})
+    set(dist_generated ${local_generated} CACHE INTERNAL "generated files that will be included in the distribution tarball")
+endmacro()
+
+macro(dist_add_generated _target _generated)
+    dist_add_configured(${_generated})
+
+    set(local_generated_depends ${dist_generated_depends})
+    list(APPEND local_generated_depends ${_target})
+    set(dist_generated_depends ${local_generated_depends} CACHE INTERNAL "global targets for generated files that will be included in the distribution tarball")
+endmacro()
diff --git a/common/test-core/CMakeLists.txt b/common/test-core/CMakeLists.txt
index 410eede..161d94a 100644
--- a/common/test-core/CMakeLists.txt
+++ b/common/test-core/CMakeLists.txt
@@ -33,6 +33,8 @@ IF (BUILDING_FROM_VCS)
       ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i ${test_core_HEADERS})
   SET (SWIG_UNITTEST_SUPPORT_PYTHON_C ${CMAKE_CURRENT_BINARY_DIR}/swig-unittest-support-python.c)
   GNC_ADD_SWIG_PYTHON_COMMAND (swig-unittest-support-python ${SWIG_UNITTEST_SUPPORT_PYTHON_C} ${CMAKE_CURRENT_SOURCE_DIR}/unittest-support.i)
+  add_custom_target(unittest-support-py DEPENDS swig-unittest-support-python)
+  dist_add_generated(unittest-support-py unittest_support.py)
 ELSE()
   SET (SWIG_UNITTEST_SUPPORT_GUILE_C  swig-unittest-support-guile.c)
   SET (SWIG_UNITTEST_SUPPORT_PYTHON_C swig-unittest-support-python.c)
diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt
index caced19..c2d1953 100644
--- a/doc/CMakeLists.txt
+++ b/doc/CMakeLists.txt
@@ -84,5 +84,6 @@ ADD_CUSTOM_COMMAND(OUTPUT gnucash.1
                            -P ${CMAKE_CURRENT_BINARY_DIR}/manpage.cmake
   )
 ADD_CUSTOM_TARGET(gnucash-manpage DEPENDS gnucash.1)
+dist_add_generated(gnucash-manpage gnucash.1)
 
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.1 DESTINATION  ${CMAKE_INSTALL_MANDIR}/man1)
diff --git a/gnucash/CMakeLists.txt b/gnucash/CMakeLists.txt
index 1c26f42..1153059 100644
--- a/gnucash/CMakeLists.txt
+++ b/gnucash/CMakeLists.txt
@@ -110,7 +110,8 @@ SET(GNUCASH_BIN_INSTALL_NAME "gnucash")
 
 SET(VALGRIND_OUTDIR ${BINDIR_BUILD})
 
-CONFIGURE_FILE(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
+configure_file(gnucash.rc.in gnucash.rc @ONLY NEWLINE_STYLE WIN32)
+dist_add_configured(gnucash.rc)
 configure_file(gnucash-valgrind.in ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gnucash-valgrind @ONLY)
 
 FILE(COPY ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/gnucash-valgrind
diff --git a/gnucash/gnome-utils/CMakeLists.txt b/gnucash/gnome-utils/CMakeLists.txt
index b437dc3..13eb87f 100644
--- a/gnucash/gnome-utils/CMakeLists.txt
+++ b/gnucash/gnome-utils/CMakeLists.txt
@@ -33,6 +33,8 @@ ADD_CUSTOM_COMMAND(
 )
 
 ADD_CUSTOM_TARGET(gnc-warnings-c DEPENDS ${GNC_WARNINGS_C})
+dist_add_generated(gnc-warnings-c gnc-warnings.c)
+# FIXME why is gnc-warnings.c added to dist and gnc-warnings.h not ? I think neither is necessary...
 
 #GTK before 3.14 didn't have GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK
 if (NOT have_mod_mask)
diff --git a/gnucash/gnome/CMakeLists.txt b/gnucash/gnome/CMakeLists.txt
index a68470e..c80d7d8 100644
--- a/gnucash/gnome/CMakeLists.txt
+++ b/gnucash/gnome/CMakeLists.txt
@@ -184,7 +184,8 @@ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gnucash.appdata.xml DESTINATION  ${CMA
 
 #=======
 
-CONFIGURE_FILE(gnucash.desktop.in.in gnucash.desktop.in)
+configure_file(gnucash.desktop.in.in gnucash.desktop.in)
+dist_add_configured(gnucash.desktop.in)
 
 
 ADD_CUSTOM_COMMAND(
diff --git a/libgnucash/core-utils/CMakeLists.txt b/libgnucash/core-utils/CMakeLists.txt
index 6d6809e..2f179c7 100644
--- a/libgnucash/core-utils/CMakeLists.txt
+++ b/libgnucash/core-utils/CMakeLists.txt
@@ -122,6 +122,7 @@ ENDIF()
 ELSE(BUILDING_FROM_VCS)
   ADD_CUSTOM_TARGET(gnc-vcs-info DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnc-vcs-info.h)
 ENDIF(BUILDING_FROM_VCS)
+dist_add_generated(gnc-vcs-info gnc-vcs-info.h)
 ### Compile library
 
 SET(core_utils_noinst_HEADERS
diff --git a/libgnucash/doc/design/CMakeLists.txt b/libgnucash/doc/design/CMakeLists.txt
index 091bd5e..dab6769 100644
--- a/libgnucash/doc/design/CMakeLists.txt
+++ b/libgnucash/doc/design/CMakeLists.txt
@@ -28,6 +28,8 @@ SET(VERSION_TEXI_IN
 
 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version.texi ${VERSION_TEXI_IN})
 FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/stamp-vti ${VERSION_TEXI_IN})
+dist_add_configured(version.texi)
+dist_add_configured(stamp-vti)
 
 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_BINARY_DIR}" TEXI_BINARY_DIR)
 FILE(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/gnucash-design.texi" TEXI_SOURCE_FILE)
@@ -47,5 +49,6 @@ if (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
       )
   ENDIF()
 endif (NOT ${MAKEINFO} STREQUAL "MAKEINFO-NOTFOUND")
+dist_add_generated(gnucash-design-info gnucash-design.info)
 
 SET_DIST_LIST(doc_design_DIST CMakeLists.txt gnucash-design.texi ${gnucash_design_TEXINFOS})
diff --git a/libgnucash/engine/CMakeLists.txt b/libgnucash/engine/CMakeLists.txt
index f5301de..c0b5a9d 100644
--- a/libgnucash/engine/CMakeLists.txt
+++ b/libgnucash/engine/CMakeLists.txt
@@ -134,6 +134,7 @@ ADD_CUSTOM_COMMAND (
     ${LIBXSLT_XSLTPROC_EXECUTABLE} -o ${ISO_4217_C} "${CMAKE_CURRENT_SOURCE_DIR}/iso-currencies-to-c.xsl" "${CMAKE_CURRENT_SOURCE_DIR}/iso-4217-currencies.xml"
     )
 ADD_CUSTOM_TARGET(iso-4217-c DEPENDS ${ISO_4217_C})
+dist_add_generated(iso-4217-c iso-4217-currencies.c)
 
 SET (engine_SOURCES
   Account.cpp
diff --git a/libgnucash/scm/CMakeLists.txt b/libgnucash/scm/CMakeLists.txt
index dc21241..3794b84 100644
--- a/libgnucash/scm/CMakeLists.txt
+++ b/libgnucash/scm/CMakeLists.txt
@@ -8,6 +8,7 @@ SET (scm_SCHEME_4
 )
 
 configure_file(build-config.scm.in ${BUILD_CONFIG_SCM})
+dist_add_configured(build-config.scm)
 
 SET(GUILE_DEPENDS      scm-core-utils scm-gnc-module)
 
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index cec4a05..96a4ab3 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -176,6 +176,7 @@ ELSE()
     add_custom_target(gnucash-pot
         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot)
 ENDIF()
+dist_add_generated(gnucash-pot gnucash.pot)
 
 ADD_CUSTOM_TARGET(check-po
         COMMAND ${CMAKE_COMMAND}

commit 1258a2adfd06773ab60db2d156fd906c9828316a
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Jan 27 19:00:30 2018 +0100

    Make potfile generation a custom target, and make the dist target depend on it

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7691be..1c0170e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -800,7 +800,7 @@ ENDIF()
 STRING(REPLACE ";" "\n" ALL_DIST_LINES "${ALL_DIST}")
 FILE(WRITE ${CMAKE_BINARY_DIR}/dist_manifest.txt ${ALL_DIST_LINES})
 
-SET(DIST_GENERATED_FILES "")
+SET(DIST_GENERATED_FILES2 "")
 FOREACH(file ${COPY_FROM_BUILD})
   LIST(APPEND DIST_GENERATED_FILES2 ${BUILD_SOURCE_DIR}/${file})
 ENDFOREACH()
@@ -818,7 +818,7 @@ ADD_CUSTOM_COMMAND(OUTPUT ${DIST_FILE}.gz ${DIST_FILE}.bz2
            -P ${CMAKE_SOURCE_DIR}/common/cmake_modules/MakeDist.cmake
 
         DEPENDS
-          ${ALL_DIST} ${DIST_GENERATED_FILES2} gnc-vcs-info iso-4217-c gnc-warnings-c gnucash-design-info ChangeLog
+          ${ALL_DIST} ${DIST_GENERATED_FILES2} gnc-vcs-info iso-4217-c gnc-warnings-c gnucash-design-info ChangeLog gnucash-pot
         )
 
 ADD_CUSTOM_TARGET(dist DEPENDS ${DIST_FILE}.gz ${DIST_FILE}.bz2)
diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt
index 457a21c..cec4a05 100644
--- a/po/CMakeLists.txt
+++ b/po/CMakeLists.txt
@@ -23,7 +23,7 @@ FOREACH(lingua ${ALL_LINGUAS})
 ENDFOREACH()
 
 SET_LOCAL_DIST(po_DIST_local ${po_SOURCES} CMakeLists.txt ChangeLog Makevars
-  POTFILES.ignore POTFILES.in POTFILES.skip README check-po.cmake)
+  POTFILES.ignore POTFILES.in POTFILES.skip README check-po.cmake gnucash-pot.cmake)
 SET(po_DIST ${po_DIST_local} ${po_glossary_DIST} PARENT_SCOPE)
 
 FOREACH(lingua ${ALL_LINGUAS})
@@ -159,31 +159,22 @@ IF(BUILDING_FROM_VCS)
     MESSAGE(FATAL_ERROR "Can't find the 'xgettext' program.")
   ENDIF ()
 
-  IF (${CMAKE_VERSION} VERSION_GREATER 3.1 AND NOT WIN32)
-    EXECUTE_PROCESS(
-            COMMAND ${CMAKE_COMMAND_TMP} INTLTOOL_EXTRACT=${INTLTOOL_EXTRACT} XGETTEXT=${XGETTEXT} srcdir=${CMAKE_CURRENT_SOURCE_DIR} ${INTLTOOL_UPDATE} --gettext-package ${PACKAGE} --pot
-            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-            RESULT_VARIABLE GNUCASH_POT_RESULT
-    )
-    IF(NOT ${GNUCASH_POT_RESULT} STREQUAL "0")
-      MESSAGE(FATAL_ERROR "Error when creating gnucash.pot: ${GNUCASH_POT_RESULT}")
-    ENDIF()
-  ELSE()
-    CONFIGURE_FILE(make-gnucash-pot.sh.in make-gnucash-pot.sh)
-    EXECUTE_PROCESS(
-            COMMAND ${SHELL} ${CMAKE_CURRENT_BINARY_DIR}/make-gnucash-pot.sh
-            WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
-            RESULT_VARIABLE GNUCASH_POT_RESULT_SHELL
-    )
-    IF(NOT ${GNUCASH_POT_RESULT_SHELL} STREQUAL "0")
-      MESSAGE(FATAL_ERROR "Error when creating gnucash.pot from shell script: ${GNUCASH_POT_RESULT_SHELL}")
-    ENDIF()
-  ENDIF()
-
-  IF (NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/gnucash.pot)
-    MESSAGE(FATAL_ERROR "POT file '${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot' was not successfully created.")
-  ENDIF()
+  add_custom_target(gnucash-pot
+        COMMAND ${CMAKE_COMMAND}
+           -D INTLTOOL_EXTRACT=${INTLTOOL_EXTRACT}
+           -D INTLTOOL_UPDATE=${INTLTOOL_UPDATE}
+           -D PO_SRC_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+           -D PO_BIN_DIR=${CMAKE_CURRENT_BINARY_DIR}
+           -D PACKAGE=${PACKAGE}
+           -D PERL=${PERL_EXECUTABLE}
+           -D XGETTEXT=${XGETTEXT}
+           -P ${CMAKE_CURRENT_SOURCE_DIR}/gnucash-pot.cmake
+        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+  )
 
+ELSE()
+    add_custom_target(gnucash-pot
+        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gnucash.pot)
 ENDIF()
 
 ADD_CUSTOM_TARGET(check-po
diff --git a/po/gnucash-pot.cmake b/po/gnucash-pot.cmake
new file mode 100644
index 0000000..25d8092
--- /dev/null
+++ b/po/gnucash-pot.cmake
@@ -0,0 +1,20 @@
+# Note: the set commands below can be integrated in the execute process
+#       the day we require cmake > 3.1
+# The command would then become
+# COMMAND {CMAKE_COMMAND} -E env INTLTOOL_EXTRACT=${INTLTOOL_EXTRACT} .... ${PERL} ${INTLTOOL_UPDATE} ....
+
+set(ENV{INTLTOOL_EXTRACT} ${INTLTOOL_EXTRACT})
+set(ENV{XGETTEXT} ${XGETTEXT})
+set(ENV{srcdir} ${PO_SRC_DIR})
+execute_process(
+  COMMAND ${PERL} ${INTLTOOL_UPDATE} --gettext-package ${PACKAGE} --pot
+  WORKING_DIRECTORY ${PO_BIN_DIR}
+  RESULT_VARIABLE GNUCASH_POT_RESULT
+)
+if (NOT ${GNUCASH_POT_RESULT} STREQUAL "0")
+  message(FATAL_ERROR "Error when creating gnucash.pot: ${GNUCASH_POT_RESULT}")
+endif()
+
+if (NOT EXISTS ${PO_BIN_DIR}/gnucash.pot)
+  message(FATAL_ERROR "POT file '${PO_BIN_DIR}/gnucash.pot' was not successfully created.")
+endif()

commit b12a6cf4d2ad7d8a7f523f140bbcb66a62c46af7
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Sat Jan 27 17:04:41 2018 +0100

    Revert "Partially revert commit 85bfbd8e8258e"
    
    This reverts commit b6aae753172eae1c4a8e01477512f944d8d4f9d1.
    
    I was mistaken. We still need po/make-gnucash-pot.sh.in, not
    make-gnucash-potfiles.in...

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 65ddfca..f7691be 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -771,7 +771,7 @@ SET(PACKAGE_PREFIX "${PACKAGE}-${PACKAGE_VERSION}")
 SET(DIST_FILE "${PACKAGE_PREFIX}.tar")
 
 SET(toplvl_DIST_local ${gnucash_DOCS}
-  CMakeLists.txt make-gnucash-potfiles.in README)
+  CMakeLists.txt README)
 
 
 SET_LOCAL_DIST(toplvl_DIST ${toplvl_DIST_local})
diff --git a/make-gnucash-potfiles.in b/make-gnucash-potfiles.in
deleted file mode 100644
index feed1f5..0000000
--- a/make-gnucash-potfiles.in
+++ /dev/null
@@ -1,83 +0,0 @@
-#!@PERL@ -w
-# -*- perl -*-
-#
-# This perl script is used to make po/POTFILES.in, the list
-# of files to be searched for translatable strings.
-#
-# It will exclude any files listed in po/POTFILES.skip, po/POTFILES.ignore
-# or that match the regexp patterns listed in @ignorepatterns.
-#
-# Author: Dave Peticolas <dave at krondo.com>
-
-use strict;
-use File::Basename;
-
-# Note: These are perl regexp patterns, *not* normal shell wildcards!
-my @ignorepatterns = ('gw-', 'test', 'experimental', 'python-bindings', 'swig-.*\.c');
-my (@skipped_files, @ignored_files);
-open(IN, "< @SRCDIR@/po/POTFILES.skip");
-while (<IN>) {
-    push @skipped_files, $_ unless $_ =~ /^\#/;
-}
-close IN;
-open(IN, "< @SRCDIR@/po/POTFILES.ignore");
-while (<IN>) {
-    push @ignored_files, $_ unless $_ =~ /^\#/;
-}
-close IN;
-
-# Sort filenames in POTFILES.in in a consistent way
-# This reduces the amount of clutter in our version manangement system
-# The files will be sorted
-# * per directory
-# * case-insensitive
-# * ignoring punctuation (-,_,.)
-#
-# This sort function has been extracted into a separate file (util/elegant-sort.pl)
-# in order to use the same algorithm in both cmake and autools based builds
-
-my @possible_files = `cd @SRCDIR@ && \\
-                      find bindings borrowed common libgnucash gnucash -name '*.c' \\
-                      -o -name '*.cpp' -o -name '*.glade' \\
-                      -o -name '*.desktop.in' -o -name '*.keys.in' \\
-                      -o -name '*.gschema.xml.in.in' -o -name '*.scm' \\
-                      | util/elegant-sort.pl`;
-## For perl files add the following:
-# -o -name '*.pl'
-
-print "# This is a list of files which contain translatable strings.\n";
-print "# This file was generated by ../make-gnucash-potfiles.\n";
-
-my %ignores;
-foreach my $file (@possible_files) {
-    chomp($file);
-    my ($name, $path) = fileparse($file);
-    $path =~ s/^\.\///;
-
-    foreach my $pat (@ignorepatterns, @skipped_files, @ignored_files) {
-        chomp($pat);
-        next unless $pat;
-
-        if ($file =~ m/$pat/ || $name =~ m/$pat/ || $path =~ m/$pat/) {
-            $ignores{$path . $name} = 1;
-        }
-    }
-    next if $ignores{$path . $name};
-
-    # Ignore unreadable files, e.g. dangling symlinks
-    next unless (-r "@SRCDIR@/" . $path . $name);
-
-    # Force parse type for gsettings files
-    my $type = "";
-    if ($file =~ m/.gschema.xml.in.in/ ){
-        $type = "[type: gettext/gsettings]";
-    }
-
-    print $type . $path . $name . "\n";
-}
-
-# These are manually added, because they're not picked up by the generation script
-print "gnucash/gnome/gnucash.appdata.xml.in\n";
-print "gnucash/gnome/gnucash.desktop.in.in\n";
-print "libgnucash/engine/qofbookslots.h\n";
-print "doc/tip_of_the_day.list.in\n";



Summary of changes:
 CMakeLists.txt                                     |  42 +++----
 bindings/python/CMakeLists.txt                     |  24 ++--
 common/CMakeLists.txt                              |  19 ++-
 common/cmake_modules/GncAddSwigCommand.cmake       | 120 ++++++++++++++-----
 common/cmake_modules/MakeDist.cmake                |  12 +-
 common/cmake_modules/MakeDistCheck.cmake           |   1 -
 common/cmake_modules/MakeDistFiles.cmake           |  95 +++++++--------
 common/test-core/CMakeLists.txt                    |  22 ++--
 doc/CMakeLists.txt                                 |   1 +
 gnucash/CMakeLists.txt                             |   6 +-
 gnucash/gnome-utils/CMakeLists.txt                 |  13 +-
 gnucash/gnome-utils/gtkbuilder/dialog-totd.glade   |  17 +--
 gnucash/gnome/CMakeLists.txt                       |  20 ++--
 gnucash/gnome/gnucash.desktop.in.in                |   2 +-
 gnucash/html/CMakeLists.txt                        |  11 +-
 .../csv-imp/assistant-csv-account-import.glade     |   5 +-
 .../csv-imp/assistant-csv-price-import.cpp         |  37 ++++--
 .../csv-imp/assistant-csv-price-import.glade       |   8 +-
 .../csv-imp/assistant-csv-trans-import.cpp         |   4 +-
 .../csv-imp/assistant-csv-trans-import.glade       |   5 +-
 gnucash/import-export/dialog-import.glade          | 133 +++++++++++----------
 gnucash/import-export/import-account-matcher.c     |   1 +
 .../qif-imp/dialog-account-picker.glade            |   2 +-
 gnucash/report/report-gnome/CMakeLists.txt         |  11 +-
 gnucash/report/report-system/CMakeLists.txt        |  14 +--
 .../report/standard-reports/account-piecharts.scm  |   6 +-
 .../standard-reports/income-gst-statement.scm      |  22 ++--
 libgnucash/app-utils/CMakeLists.txt                |  22 ++--
 libgnucash/core-utils/CMakeLists.txt               |  40 +++----
 libgnucash/doc/design/CMakeLists.txt               |   8 +-
 libgnucash/engine/CMakeLists.txt                   |  18 ++-
 libgnucash/gnc-module/CMakeLists.txt               |  12 +-
 libgnucash/gnc-module/test/mod-bar/CMakeLists.txt  |  10 +-
 libgnucash/gnc-module/test/mod-baz/CMakeLists.txt  |  10 +-
 libgnucash/gnc-module/test/mod-foo/CMakeLists.txt  |  10 +-
 libgnucash/scm/CMakeLists.txt                      |   3 +-
 make-gnucash-potfiles.in                           |  83 -------------
 po/CMakeLists.txt                                  |  40 +++----
 po/gnucash-pot.cmake                               |  20 ++++
 39 files changed, 458 insertions(+), 471 deletions(-)
 delete mode 100644 make-gnucash-potfiles.in
 create mode 100644 po/gnucash-pot.cmake



More information about the gnucash-changes mailing list