adapt_cmakelists_file.pl 16.4 KB
Newer Older
Laurent Montel's avatar
Laurent Montel committed
1 2
#!/usr/bin/perl -w

Laurent Montel's avatar
Laurent Montel committed
3 4 5
# Laurent Montel <montel@kde.org> 2014-2015
# Modifies CMakeLists.txt to use kf5 macro
# find -iname "CMakeLists.txt" |xargs kde-dev-scripts/kf5/adapt_cmakelists_file.pl
Laurent Montel's avatar
Laurent Montel committed
6 7

use strict;
Laurent Montel's avatar
Laurent Montel committed
8 9

foreach my $file (@ARGV) {
Laurent Montel's avatar
Laurent Montel committed
10 11 12 13
open(my $FILE, "<", $file) || die;
my $modified = 0;
my @l = map {
  my $orig = $_;
Laurent Montel's avatar
Laurent Montel committed
14
  if (/kde4_no_enable_final/i) {
15 16 17
     $_ = "";
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
18
  if (/KDE4_INCLUDE_DIR/) {
19
     $_ =~ s/\$\{KDE4_INCLUDE_DIR\}//;
Laurent Montel's avatar
Laurent Montel committed
20 21 22
     $modified = 1;
  }
  if (/QT_INCLUDES/ ) {
23
     $_ =~ s/\$\{QT_INCLUDES\}//;
Laurent Montel's avatar
Laurent Montel committed
24 25
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
26 27
  if (/kde4_install_icons/i) {
     $_ =~ s/kde4_install_icons/ecm_install_icons/i;
Laurent Montel's avatar
Laurent Montel committed
28 29
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
30 31
  if (/kde4_add_library/i) {
     $_ =~ s/kde4_add_library/add_library/i;
Laurent Montel's avatar
Laurent Montel committed
32 33
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
34 35
  if (/kde4_add_ui_files/i) {
     $_ =~ s/kde4_add_ui_files/ki18n_wrap_ui/i;
Laurent Montel's avatar
Laurent Montel committed
36 37
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
38 39
  if (/kde4_add_kcfg_files/i) {
      $_ =~ s/kde4_add_kcfg_files/kconfig_add_kcfg_files/i;
Laurent Montel's avatar
Laurent Montel committed
40 41
      $modified = 1;
  }
42 43
  if (/kde4_add_executable\s*\(\s*([\w_]+)/i) {
      my $target = $1;
44
      $_ =~ s/kde4_add_executable/add_executable/i;
45 46 47 48 49 50
      if (s/ NOGUI//) {
          $_ .= "ecm_mark_nongui_executable($target)\n";
      }
      if (s/ TEST//) {
          $_ .= "ecm_mark_as_test($target)\n";
      }
Laurent Montel's avatar
Laurent Montel committed
51 52
      $modified = 1;
  }
53 54 55 56 57 58 59
  if (/kde4_add_unit_test\s*\(\s*([\w_]+)/i) {
      my $target = $1;
      $_ =~ s/kde4_add_unit_test/add_executable/i;
      s/ TEST//;
      $_ .= "add_test($target $target)\n";
      $_ .= "ecm_mark_as_test($target)\n";
  }
60

Laurent Montel's avatar
Laurent Montel committed
61 62
  if (/KDE4_ENABLE_EXCEPTIONS/i) {
      $_ =~ s/set\s*\(\s*CMAKE_CXX_FLAGS\s*\"\$\{CMAKE_CXX_FLAGS\} \$\{KDE4_ENABLE_EXCEPTIONS\}\"\s*\)/kde_enable_exceptions\(\)/i;
Laurent Montel's avatar
Laurent Montel committed
63
      $_ =~ s/add_definitions\(\s*\$\{KDE4_ENABLE_EXCEPTIONS\}\s*\)/kde_enable_exceptions\(\)/i;
Laurent Montel's avatar
Laurent Montel committed
64
      $modified = 1;
Laurent Montel's avatar
Laurent Montel committed
65
  } 
Laurent Montel's avatar
Laurent Montel committed
66 67
  if (/qt4_add_dbus_adaptor/i) {
      $_ =~ s/qt4_add_dbus_adaptor/qt5_add_dbus_adaptor/i;
Laurent Montel's avatar
Laurent Montel committed
68 69
      $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
70 71
  if (/qt4_wrap_ui/i) {
      $_ =~ s/qt4_wrap_ui/ki18n_wrap_ui/i;
Laurent Montel's avatar
Laurent Montel committed
72 73
      $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
74
  if (/KDE4_KCALCORE_LIBS/) {
75
     $_ =~ s/\$\{KDE4_KCALCORE_LIBS\}/KF5::CalendarCore/;
Laurent Montel's avatar
Laurent Montel committed
76 77
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
78
  if (/KDE4_KMIME_LIBRARY/) {
79
     $_ =~ s/\$\{KDE4_KMIME_LIBRARY\}/KF5::Mime/;
Laurent Montel's avatar
Laurent Montel committed
80 81
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
82
  if (/KDEPIMLIBS_AKONADI_LIBS/) {
83
     $_ =~ s/\$\{KDEPIMLIBS_AKONADI_LIBS\}/KF5::AkonadiCore/;
Laurent Montel's avatar
Laurent Montel committed
84 85 86
     $modified = 1;
  }
  if (/KDEPIMLIBS_KCALCORE_LIBS/) {
87
     $_ =~ s/\$\{KDEPIMLIBS_KCALCORE_LIBS\}/KF5::CalendarCore/;
Laurent Montel's avatar
Laurent Montel committed
88 89 90
     $modified = 1;
  }
  if (/KDEPIMLIBS_KPIMUTILS_LIBS/) {
91
     $_ =~ s/\$\{KDEPIMLIBS_KPIMUTILS_LIBS\}//;
Laurent Montel's avatar
Laurent Montel committed
92 93
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
94
  if (/KDEPIMLIBS_MAILTRANSPORT_LIBS/) {
95
     $_ =~ s/\$\{KDEPIMLIBS_MAILTRANSPORT_LIBS\}/KF5::MailTransport/;
Laurent Montel's avatar
Laurent Montel committed
96 97 98
     $modified = 1;
  }
  if (/KDEPIMLIBS_KMIME_LIBS/) {
99
     $_ =~ s/\$\{KDEPIMLIBS_KMIME_LIBS\}/KF5::Mime/;
Laurent Montel's avatar
Laurent Montel committed
100 101 102
     $modified = 1;
  }
  if (/KDEPIMLIBS_KPIMIDENTITIES_LIBS/) {
103
     $_ =~ s/\$\{KDEPIMLIBS_KPIMIDENTITIES_LIBS\}/KF5::PimIdentities/;
Laurent Montel's avatar
Laurent Montel committed
104 105 106
     $modified = 1;
  }
  if (/KDE4_KIO_LIBS/) {
107
     $_ =~ s/\$\{KDE4_KIO_LIBS\}/KF5::KIOCore/;
Laurent Montel's avatar
Laurent Montel committed
108 109 110
     $modified = 1;
  }
  if (/KDE4_KROSSCORE_LIBS/) {
111
     $_ =~ s/\$\{KDE4_KROSSCORE_LIBS\}/KF5::KrossCore/;
Laurent Montel's avatar
Laurent Montel committed
112 113
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
114
  if (/QT_QTDBUS_LIBRARY/) {
115
     $_ =~ s/\$\{QT_QTDBUS_LIBRARY\}/Qt5::DBus/;
Laurent Montel's avatar
Laurent Montel committed
116 117
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
118
  if (/QT_QTXML_LIBRARY/) {
119
     $_ =~ s/\$\{QT_QTXML_LIBRARY\}/Qt5::Xml/;
Laurent Montel's avatar
Laurent Montel committed
120 121
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
122
  if (/QT_QTXML_LIBRARIES/) {
123
     $_ =~ s/\$\{QT_QTXML_LIBRARIES\}/Qt5::Xml/;
Laurent Montel's avatar
Laurent Montel committed
124 125
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
126
  if (/QT_QTCORE_LIBRARY/) {
127
     $_ =~ s/\$\{QT_QTCORE_LIBRARY\}/Qt5::Core/;
Laurent Montel's avatar
Laurent Montel committed
128 129
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
130
  if (/QT_QTCORE_LIBRARIES/) {
131
     $_ =~ s/\$\{QT_QTCORE_LIBRARIES\}/Qt5::Core/;
Laurent Montel's avatar
Laurent Montel committed
132 133
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
134
  if (/QT_QTGUI_LIBRARY/) {
135
     $_ =~ s/\$\{QT_QTGUI_LIBRARY\}/Qt5::Gui/;
Laurent Montel's avatar
Laurent Montel committed
136 137
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
138
  if (/QT_QTGUI_LIBRARIES/) {
139
     $_ =~ s/\$\{QT_QTGUI_LIBRARIES\}/Qt5::Gui/;
Laurent Montel's avatar
Laurent Montel committed
140 141
     $modified = 1;
  }
Kevin Funk's avatar
Kevin Funk committed
142
  if (/QT_QTHELP_LIBRARIES/) {
143
     $_ =~ s/\$\{QT_QTHELP_LIBRARIES\}/Qt5::Help/;
Kevin Funk's avatar
Kevin Funk committed
144 145
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
146
  if (/QT_QTNETWORK_LIBRARY/) {
147
     $_ =~ s/\$\{QT_QTNETWORK_LIBRARY\}/Qt5::Network/;
Laurent Montel's avatar
Laurent Montel committed
148 149
     $modified = 1;
  }
Kevin Funk's avatar
Kevin Funk committed
150
  if (/QT_QTSCRIPT_LIBRARY/) {
151
     $_ =~ s/\$\{QT_QTSCRIPT_LIBRARY\}/Qt5::Script/;
Kevin Funk's avatar
Kevin Funk committed
152 153
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
154
  if (/KDE4_KDECORE_LIBS/) {
155
     $_ =~ s/\$\{KDE4_KDECORE_LIBS}/KF5::KDELibs4Support/;
Laurent Montel's avatar
Laurent Montel committed
156 157
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
158
  if (/KDEPIMLIBS_KIMAP_LIBS/) {
159
     $_ =~ s/\$\{KDEPIMLIBS_KIMAP_LIBS}/KF5::IMAP/;
Laurent Montel's avatar
Laurent Montel committed
160 161 162
     $modified = 1;
  }
  if (/KDEPIMLIBS_AKONADI_KMIME_LIBS/) {
163
     $_ =~ s/\$\{KDEPIMLIBS_AKONADI_KMIME_LIBS}/KF5::AkonadiMime/;
Laurent Montel's avatar
Laurent Montel committed
164 165 166
     $modified = 1;
  }
  if (/KDE4_KNOTIFYCONFIG_LIBS/) {
167
     $_ =~ s/\$\{KDE4_KNOTIFYCONFIG_LIBS}/KF5::NotifyConfig/;
Laurent Montel's avatar
Laurent Montel committed
168 169
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
170
  if (/KDEPIMLIBS_KPIMTEXTEDIT_LIBS/) {
171
     $_ =~ s/\$\{KDEPIMLIBS_KPIMTEXTEDIT_LIBS}/KF5::PimTextEdit/;
Laurent Montel's avatar
Laurent Montel committed
172 173 174
     $modified = 1;
  }
  if (/KDE4_KDEWEBKIT_LIBRARY/) {
175
     $_ =~ s/\$\{KDE4_KDEWEBKIT_LIBRARY}/KF5::WebKit/;
Laurent Montel's avatar
Laurent Montel committed
176 177 178
     $modified = 1;
  }
  if (/KDEPIMLIBS_KMBOX_LIBS/) {
179
     $_ =~ s/\$\{KDEPIMLIBS_KMBOX_LIBS}/KF5::Mbox/;
Laurent Montel's avatar
Laurent Montel committed
180 181
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
182
  if (/QT_QTUITOOLS_LIBRARY/) {
183
     $_ =~ s/\$\{QT_QTUITOOLS_LIBRARY\}/Qt5::UiTools/;
Laurent Montel's avatar
Laurent Montel committed
184 185 186
     $modified = 1;

  }
Laurent Montel's avatar
Laurent Montel committed
187
  if (/KDEPIMLIBS_KALARMCAL_LIBS/) {
188
     $_ =~ s/\$\{KDEPIMLIBS_KALARMCAL_LIBS}/KF5::AlarmCalendar/;
Laurent Montel's avatar
Laurent Montel committed
189 190
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
191
  if (/KDEPIMLIBS_KABC_LIBS/) {
192
     $_ =~ s/\$\{KDEPIMLIBS_KABC_LIBS}/KF5::Contacts/;
Laurent Montel's avatar
Laurent Montel committed
193 194
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
195 196 197 198 199
  if (/KF5::Abc/) {
     $_ =~ s/KF5::Abc/KF5::Contacts/;
     $modified = 1;
  }

Laurent Montel's avatar
Laurent Montel committed
200
  if (/KDEPIMLIBS_AKONADI_CONTACT_LIBS/) {
201
     $_ =~ s/\$\{KDEPIMLIBS_AKONADI_CONTACT_LIBS}/KF5::AkonadiContact/;
Laurent Montel's avatar
Laurent Montel committed
202 203 204
     $modified = 1;
  }
  if (/KDE4_KDEUI_LIBS/) {
205
     $_ =~ s/\$\{KDE4_KDEUI_LIBS}//;
Laurent Montel's avatar
Laurent Montel committed
206 207 208
     $modified = 1;
  }
  if (/KDEPIMLIBS_KTNEF_LIBS/) {
209
     $_ =~ s/\$\{KDEPIMLIBS_KTNEF_LIBS}/KF5::KTnef/;
Laurent Montel's avatar
Laurent Montel committed
210 211 212
     $modified = 1;
  }
  if (/KDEPIMLIBS_KBLOG_LIBS/) {
213
     $_ =~ s/\$\{KDEPIMLIBS_KBLOG_LIBS}/KF5::Blog/;
Laurent Montel's avatar
Laurent Montel committed
214 215
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
216
  if (/KDEPIMLIBS_AKONADI_KABC_LIBS/) {
217
     $_ =~ s/\$\{KDEPIMLIBS_AKONADI_KABC_LIBS}/KF5::AkonadiAbc/;
Laurent Montel's avatar
Laurent Montel committed
218 219
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
220
  if (/KDE4_KNEWSTUFF3_LIBS/) {
221
     $_ =~ s/\$\{KDE4_KNEWSTUFF3_LIBS}/KF5::NewStuff/;
Laurent Montel's avatar
Laurent Montel committed
222 223
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
224
  if (/KDE4_KNEWSTUFF3_LIBRARY/) {
225
     $_ =~ s/\$\{KDE4_KNEWSTUFF3_LIBRARY}/KF5::NewStuff/;
Laurent Montel's avatar
Laurent Montel committed
226 227
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
228
  if (/KDEPIMLIBS_KLDAP_LIBS/) {
229
     $_ =~ s/\$\{KDEPIMLIBS_KLDAP_LIBS}/KF5::KLdap/;
Laurent Montel's avatar
Laurent Montel committed
230 231 232
     $modified = 1;
  }
  if (/BALOO_LIBRARIES/) {
233
     $_ =~ s/\$\{BALOO_LIBRARIES}/Baloo/;
Laurent Montel's avatar
Laurent Montel committed
234 235 236
     $modified = 1;
  }
  if (/KDE4_KCMUTILS_LIBS/) {
237
     $_ =~ s/\$\{KDE4_KCMUTILS_LIBS}/KF5::KCMUtils/;
Laurent Montel's avatar
Laurent Montel committed
238 239
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
240
  if (/KDEPIMLIBS_KCALUTILS_LIBS/) {
241
     $_ =~ s/\$\{KDEPIMLIBS_KCALUTILS_LIBS}/KF5::CalendarUtils/;
Laurent Montel's avatar
Laurent Montel committed
242 243 244
     $modified = 1;
  }
  if (/KDEPIMLIBS_KHOLIDAYS_LIBS/) {
245
     $_ =~ s/\$\{KDEPIMLIBS_KHOLIDAYS_LIBS}/KF5::Holidays/;
Laurent Montel's avatar
Laurent Montel committed
246 247 248
     $modified = 1;
  }
  if (/KDE4_KUTILS_LIBS/) {
249
     $_ =~ s/\$\{KDE4_KUTILS_LIBS}//;
Laurent Montel's avatar
Laurent Montel committed
250 251 252
     $modified = 1;
  }
  if (/KDE4_KDECORE_LIBRARY/) {
253
     $_ =~ s/\$\{KDE4_KDECORE_LIBRARY}//;
Laurent Montel's avatar
Laurent Montel committed
254 255 256
     $modified = 1;
  }
  if (/KDE4_KDEUI_LIBRARY/) {
257
     $_ =~ s/\$\{KDE4_KDEUI_LIBRARY}//;
Laurent Montel's avatar
Laurent Montel committed
258 259 260
     $modified = 1;
  }
  if (/KDE4_KTEXTEDITOR_LIBS/) {
261
     $_ =~ s/\$\{KDE4_KTEXTEDITOR_LIBS}/KF5::TextEditor/;
Laurent Montel's avatar
Laurent Montel committed
262 263
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
264 265
  if (/qt4_wrap_cpp/i) {
     $_ =~ s/qt4_wrap_cpp/qt5_wrap_cpp/i;
Laurent Montel's avatar
Laurent Montel committed
266 267 268
     $modified = 1;
  }
  if (/KDEPIMLIBS_SYNDICATION_LIBS/) {
269
     $_ =~ s/\$\{KDEPIMLIBS_SYNDICATION_LIBS}/KF5::Syndication/;
Laurent Montel's avatar
Laurent Montel committed
270 271 272
     $modified = 1;
  }
  if (/KDE4_KHTML_LIBS/) {
273
     $_ =~ s/\$\{KDE4_KHTML_LIBS}/KF5::KHtml/;
Laurent Montel's avatar
Laurent Montel committed
274 275
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
276
  if (/KDEPIMLIBS_KONTACTINTERFACE_LIBS/) {
277
     $_ =~ s/\$\{KDEPIMLIBS_KONTACTINTERFACE_LIBS}/KF5::KontactInterface/;
Laurent Montel's avatar
Laurent Montel committed
278 279 280
     $modified = 1;
  }
  if (/KDE4_KNOTIFYCONFIG_LIBRARY/) {
281
     $_ =~ s/\$\{KDE4_KNOTIFYCONFIG_LIBRARY}/KF5::NotifyConfig/;
Laurent Montel's avatar
Laurent Montel committed
282 283
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
284
  if (/QT_QTDECLARATIVE_LIBRARY/) {
285
     $_ =~ s/\$\{QT_QTDECLARATIVE_LIBRARY\}/Qt5::Declarative/;
Laurent Montel's avatar
Laurent Montel committed
286 287
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
288
  if (/QT_QTDECLARATIVE_LIBRARIES/) {
289
     $_ =~ s/\$\{QT_QTDECLARATIVE_LIBRARIES\}/Qt5::Declarative/;
Laurent Montel's avatar
Laurent Montel committed
290 291 292
     $modified = 1;
  }

Laurent Montel's avatar
Laurent Montel committed
293
  if (/KDE4_KPARTS_LIBS/) {
294
     $_ =~ s/\$\{KDE4_KPARTS_LIBS}/KF5::Parts/;
Laurent Montel's avatar
Laurent Montel committed
295 296
     $modified = 1;
  }
Laurent Montel's avatar
Adapt++  
Laurent Montel committed
297
  if (/KDE4_KPARTS_LIBRARY/) {
298
     $_ =~ s/\$\{KDE4_KPARTS_LIBRARY}/KF5::Parts/;
Laurent Montel's avatar
Adapt++  
Laurent Montel committed
299 300 301
     $modified = 1;
  }

302
  if (/KDE4_PHONON_LIBS/) {
303
     $_ =~ s/\$\{KDE4_PHONON_LIBS}/Phonon::phonon4qt5/;
304 305
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
306
  if (/KDE4_PHONON_LIBRARY/) {
307
     $_ =~ s/\$\{KDE4_PHONON_LIBRARY}/Phonon::phonon4qt5/;
Laurent Montel's avatar
Laurent Montel committed
308 309 310
     $modified = 1;
  }

Laurent Montel's avatar
Laurent Montel committed
311
  if (/QT_QTTEST_LIBRARY/) {
312
     $_ =~ s/\$\{QT_QTTEST_LIBRARY\}/Qt5::Test/;
Laurent Montel's avatar
Laurent Montel committed
313 314
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
315

Laurent Montel's avatar
Laurent Montel committed
316 317
  if (/kde4_create_handbook/i) {
     $_ =~ s/kde4_create_handbook/kdoctools_create_handbook/i;
318 319
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
320 321
  if (/kde4_create_manpage/i) {
     $_ =~ s/kde4_create_manpage/kdoctools_create_manpage/i;
322 323 324
     $modified = 1;
  }
  if (/KDEPIMLIBS_MICROBLOG_LIBS/) {
325
     $_ =~ s/\$\{KDEPIMLIBS_MICROBLOG_LIBS}/KF5::MicroBlog/;
326 327
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
328
  if (/KDE4_SOLID_LIBS/) {
329
     $_ =~ s/\$\{KDE4_SOLID_LIBS}//;
Laurent Montel's avatar
Laurent Montel committed
330 331
     $modified = 1;     
  }
Laurent Montel's avatar
Laurent Montel committed
332
  if (/QT_QTWEBKIT_LIBRARY/) {
333
     $_ =~ s/\$\{QT_QTWEBKIT_LIBRARY\}/Qt5::WebKitWidgets/;
Laurent Montel's avatar
Laurent Montel committed
334 335
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
336
  if (/QT_QTSQL_LIBRARY/) {
337
     $_ =~ s/\$\{QT_QTSQL_LIBRARY\}/Qt5::Sql/;
Laurent Montel's avatar
Laurent Montel committed
338 339
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
340
  if (/KDE4_KFILE_LIBS/) {
341
     $_ =~ s/\$\{KDE4_KFILE_LIBS}//;
Laurent Montel's avatar
Laurent Montel committed
342 343
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
344
  if (/KDEPIMLIBS_AKONADI_NOTES_LIBS/) {
345
     $_ =~ s/\$\{KDEPIMLIBS_AKONADI_NOTES_LIBS}/KF5::AkonadiNotes/;
Laurent Montel's avatar
Laurent Montel committed
346 347 348
     $modified = 1;
  }
  if (/KDE4_KIO_LIBRARY/) {
349
     $_ =~ s/\$\{KDE4_KIO_LIBRARY}/KF5::KIOCore/;
Laurent Montel's avatar
Laurent Montel committed
350 351 352
     $modified = 1;
  }
 
353
  if (/KDEVPLATFORM_INTERFACES_LIBRARIES/) {
354
     $_ =~ s/\$\{KDEVPLATFORM_INTERFACES_LIBRARIES}/KDev::Interfaces/;
355 356 357
     $modified = 1;
  }
  if (/KDEVPLATFORM_SHELL_LIBRARIES/) {
358
     $_ =~ s/\$\{KDEVPLATFORM_SHELL_LIBRARIES}/KDev::Shell/;
359 360 361
     $modified = 1;
  }
  if (/KDEVPLATFORM_LANGUAGE_LIBRARIES/) {
362
     $_ =~ s/\$\{KDEVPLATFORM_LANGUAGE_LIBRARIES}/KDev::Language/;
363 364 365
     $modified = 1;
  }
  if (/KDEVPLATFORM_UTIL_LIBRARIES/) {
366
     $_ =~ s/\$\{KDEVPLATFORM_UTIL_LIBRARIES}/KDev::Util/;
367 368 369
     $modified = 1;
  }
  if (/KDEVPLATFORM_PROJECT_LIBRARIES/) {
370
     $_ =~ s/\$\{KDEVPLATFORM_PROJECT_LIBRARIES}/KDev::Project/;
371 372 373
     $modified = 1;
  }
  if (/KDEVPLATFORM_OUTPUTVIEW_LIBRARIES/) {
374
     $_ =~ s/\$\{KDEVPLATFORM_OUTPUTVIEW_LIBRARIES}/KDev::OutputView/;
375 376 377
     $modified = 1;
  }
  if (/KDEVPLATFORM_VCS_LIBRARIES/) {
378
     $_ =~ s/\$\{KDEVPLATFORM_VCS_LIBRARIES}/KDev::Vcs/;
379 380 381
     $modified = 1;
  }
  if (/KDEVPLATFORM_TESTS_LIBRARIES/) {
382
     $_ =~ s/\$\{KDEVPLATFORM_TESTS_LIBRARIES}/KDev::Tests/;
383 384 385
     $modified = 1;
  }
  if (/KDEVPLATFORM_JSONTESTS_LIBRARIES/) {
386
     $_ =~ s/\$\{KDEVPLATFORM_JSONTESTS_LIBRARIES}/KDev::JsonTests/;
387 388 389
     $modified = 1;
  }
  if (/KDEVPLATFORM_DOCUMENTATION_LIBRARIES/) {
390
     $_ =~ s/\$\{KDEVPLATFORM_DOCUMENTATION_LIBRARIES}/KDev::Documentation/;
391 392 393
     $modified = 1;
  }
  if (/KDEVPLATFORM_DEBUGGER_LIBRARIES/) {
394
     $_ =~ s/\$\{KDEVPLATFORM_DEBUGGER_LIBRARIES}/KDev::Debugger/;
395 396 397
     $modified = 1;
  }
  if (/KDEVPLATFORM_SUBLIME_LIBRARIES/) {
398
     $_ =~ s/\$\{KDEVPLATFORM_SUBLIME_LIBRARIES}/KDev::Sublime/;
399 400
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
401
  if (/KDE4_THREADWEAVER_LIBRARIES/) {
402
     $_ =~ s/\$\{KDE4_THREADWEAVER_LIBRARIES}/KF5::ThreadWeaver/;
Laurent Montel's avatar
Laurent Montel committed
403 404 405
     $modified = 1;
  }
  if (/QT_AND_KDECORE_LIBS/) {
406
     $_ =~ s/\$\{QT_AND_KDECORE_LIBS}//;
Laurent Montel's avatar
Laurent Montel committed
407 408 409
     $modified = 1;
  }
  if (/KIPI_LIBRARIES/) {
410
     $_ =~ s/\$\{KIPI_LIBRARIES}/KF5::Kipi/;
Laurent Montel's avatar
Laurent Montel committed
411 412 413
     $modified = 1;
  }
  if (/KEXIV2_LIBRARIES/) {
414
     $_ =~ s/\$\{KEXIV2_LIBRARIES}/KF5::KExiv2/;
Laurent Montel's avatar
Laurent Montel committed
415 416 417
     $modified = 1;     
  }
  if (/KDCRAW_LIBRARIES/) {
418
     $_ =~ s/\$\{KDCRAW_LIBRARIES}/KF5::KDcraw/;
Laurent Montel's avatar
Laurent Montel committed
419 420
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
421
  if (/KSANE_LIBRARY/) {
422
     $_ =~ s/\$\{KSANE_LIBRARY}/KF5::Sane/;
Laurent Montel's avatar
Laurent Montel committed
423 424
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
425 426 427 428
  if (/kdegamesprivate/) {
     $_ =~ s/kdegamesprivate/KF5KDEGamesPrivate/;
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
429
  if (/KDECLARATIVE_LIBRARIES/) {
430
     $_ =~ s/\$\{KDECLARATIVE_LIBRARIES}/KF5::Declarative/;
Laurent Montel's avatar
Laurent Montel committed
431 432
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
433 434 435 436
  if (/kdegames/) {
     $_ =~ s/kdegames/KF5KDEGames/;
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
437
  if (/LIBKONQ_LIBRARY/) {
438
     $_ =~ s/\$\{LIBKONQ_LIBRARY}/KF5::Konq/;
Laurent Montel's avatar
Laurent Montel committed
439 440
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
441
  if (/QT_QTOPENGL_LIBRARY/) {
442
     $_ =~ s/\$\{QT_QTOPENGL_LIBRARY\}/Qt5::OpenGL/;
Laurent Montel's avatar
Laurent Montel committed
443 444
     $modified = 1;
  }
445 446 447 448
  #if (/macro_optional_add_subdirectory/) {
  #   $_ =~ s/macro_optional_add_subdirectory/add_subdirectory/;
  #   $modified = 1;
  #}
449

Laurent Montel's avatar
Laurent Montel committed
450 451
  if (/qt4_add_dbus_interfaces/i) {
     $_ =~ s/qt4_add_dbus_interfaces/qt5_add_dbus_interfaces/i;
452 453
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
454 455
  if (/qt4_add_dbus_interface/i) {
     $_ =~ s/qt4_add_dbus_interface/qt5_add_dbus_interface/i;
Laurent Montel's avatar
Laurent Montel committed
456 457
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
458 459
  if (/qt4_generate_moc/i) {
     $_ =~ s/qt4_generate_moc/qt5_generate_moc/i;
Laurent Montel's avatar
Laurent Montel committed
460 461
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
462 463
  if (/qt4_generate_dbus_interface/i) {
     $_ =~ s/qt4_generate_dbus_interface/qt5_generate_dbus_interface/i;
Laurent Montel's avatar
Laurent Montel committed
464 465
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
466 467
  if (/kde4_install_auth_helper_files/i) {
     $_ =~ s/kde4_install_auth_helper_files/kauth_install_helper_files/i;
Laurent Montel's avatar
Laurent Montel committed
468 469
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
470 471
  if (/kde4_install_auth_actions/i) {
     $_ =~ s/kde4_install_auth_actions/kauth_install_actions/i;
Laurent Montel's avatar
Laurent Montel committed
472 473
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
474 475
  if (/qt4_add_resources/i) {
     $_ =~ s/qt4_add_resources/qt5_add_resources/i;
476 477
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
478
  if (/KDE4_INCLUDES/) {
479
     $_ =~ s/\$\{KDE4_INCLUDES}//;
Laurent Montel's avatar
Laurent Montel committed
480 481
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
482
  if (/KDE4_KDNSSD_LIBS/) {
483
     $_ =~ s/\$\{KDE4_KDNSSD_LIBS}/KF5::DNSSD/;
Laurent Montel's avatar
Laurent Montel committed
484 485 486
     $modified = 1;
  }

Laurent Montel's avatar
Laurent Montel committed
487 488 489 490
  if (/akonadi-kde/) {
     $_ =~ s/akonadi-kde//;
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
491
  if (/QT_QTSVG_LIBRARY/) {
492
     $_ =~ s/\$\{QT_QTSVG_LIBRARY\}/Qt5::Svg/;
Laurent Montel's avatar
Laurent Montel committed
493 494
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
495 496 497 498
  if (/KF5::KDE4Support/) {
     $_ =~ s/KF5::KDE4Support/KF5::KDELibs4Support/;
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
499 500
  if (/macro_optional_add_subdirectory/i) {
     $_ =~ s/macro_optional_add_subdirectory/ecm_optional_add_subdirectory/i;
501 502 503
     $modified = 1;
     warn "Need to add \'include(ECMOptionalAddSubdirectory)\' in $file \n";
  }
Laurent Montel's avatar
Laurent Montel committed
504

505 506 507 508
  if (/kde4_moc_headers/i) {
     $_ = "";
     $modified = 1;
  }
509 510 511 512 513 514 515 516 517
  if (/\.notifyrc/) {
     my $regexp = qr/
                  ^(\s*install\s*\(\s*FILES\s+[^\s)]+\.notifyrc\s+DESTINATION\s+)
                  \$\{DATA_INSTALL_DIR\}\/[^\s)]+
                  (.*)$
                  /x; # /x Enables extended whitespace mode
     if (my ($begin, $end) = $_ =~ $regexp) {
        $_ = $begin . "\${KNOTIFYRC_INSTALL_DIR}" . $end . "\n";
        $modified = 1;
518
     } elsif (not /KNOTIFYRC_INSTALL_DIR/ and not /_INSTALL_KNOTIFY5RCDIR/) {
519 520 521 522 523 524
        my $line = $_;
        $line =~ s/\s*$//;
        print "Could not fix a .notifyrc file installation call ($line)\n"
     }
  }

525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544

  #kde4_add_app_icon(importwizard_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/icons/hi*-app-kontact-import-wizard.png")
  my $kde4AppIconRegexp = qr/
               ^(\s*)                  # (1) Indentation
               kde4_add_app_icon\s*\(    # 
               (.*)\s+                   #source name
               (.*)\)$                   #end
               /x; # /x Enables extended whitespace mode
  if (my ($indent, $sourcename, $icons) = $_ =~ $kde4AppIconRegexp) {
     warn "found kde4_add_app_icon\n";
     warn "You need to increase ecm to 1.7 and add include(ECMAddAppIcon)\n";
     if ($icons =~ /\*/) {
        $_ = $indent . "file(GLOB ICONS_SRCS " . "$icons" . ")\n";
        $_ .= $indent . "ecm_add_app_icon($sourcename ICONS \${ICONS_SRCS})\n";
        $modified = 1;
     } else {
        $_ = $indent . "ecm_add_app_icon($sourcename ICONS $icons)\n";
        $modified = 1;
     }
  }
545
 
546 547


548 549 550 551 552 553 554 555
  #kde4_add_plugin(kio_mbox ${kio_mbox_PART_SRCS})
  my $regexp = qr/
               ^(\s*)                  # (1) Indentation
               kde4_add_plugin\s*\(    # 
               \s*([^ ]*)\s*           # (2) libname
               (.*)$                   # (3) end
               /x; # /x Enables extended whitespace mode
  if (my ($indent, $libname, $end) = $_ =~ $regexp) {
Laurent Montel's avatar
Laurent Montel committed
556
     $_ = $indent . "add_library($libname MODULE " . $end . "\n";
557 558
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
559 560 561 562 563 564 565 566 567 568
  my $regexpUpperCase = qr/
               ^(\s*)                  # (1) Indentation
               KDE4_ADD_PLUGIN\s*\(    # 
               \s*([^ ]*)\s*           # (2) libname
               (.*)$                   # (3) end
               /x; # /x Enables extended whitespace mode
  if (my ($indent, $libname, $end) = $_ =~ $regexpUpperCase) {
     $_ = $indent . "add_library($libname MODULE " . $end . "\n";
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
569 570 571 572 573
  # At the end include_directories can be empty
  if (/include_directories\s*\(\s*\)/i) {
     $_ = "";
     $modified = 1;
  }
Laurent Montel's avatar
Laurent Montel committed
574 575 576 577 578 579 580 581 582
  $modified ||= $orig ne $_;
  $_;
} <$FILE>;

if ($modified) {
    open (my $OUT, ">", $file);
    print $OUT @l;
    close ($OUT);
}
Laurent Montel's avatar
Laurent Montel committed
583
}