Make DCPoMatic compatible with ICU >= 75
authorBenjamin Radel <benjamin@radel.tk>
Fri, 28 Jun 2024 19:56:36 +0000 (21:56 +0200)
committerCarl Hetherington <cth@carlh.net>
Sun, 30 Jun 2024 14:17:18 +0000 (16:17 +0200)
ICU >= 75 uses c++17 features and therefore requires compilation with
-std=c++17. However, this causes some namespace issues in
src/wx/file_picker_ctrl.cc and
src/wx/film_name_location_dialog.cc
between boost::optional, boost::filesystem and the corresponding
names from the std lib.

The patch fixes this namespace issues and adds a version check in
wscript to enable compilation with c++17, if icu >= 75 is detected.

src/wx/about_dialog.cc
src/wx/file_picker_ctrl.cc
src/wx/film_name_location_dialog.cc
wscript

index 2c742cce3a1549be4368297cbc0c59cd6f3e4496..59fad08786cc06907bd789672c1f11d2858a1b8d 100644 (file)
@@ -99,6 +99,7 @@ AboutDialog::AboutDialog (wxWindow* parent)
        written_by.Add (wxT ("Terrence Meiczinger"));
        written_by.Add (wxT ("Mart Jansink"));
        written_by.Add (wxT ("Ole Laursen"));
+       written_by.Add (wxT ("Benjamin Radel"));
        add_section (_("Written by"), written_by);
 
        wxArrayString with_help_from;
index 7aa0bfb40cc9d9031a238c7e3f39f2980773a34d..82978dad61fe7aae9d2db7c0a65cd97ddc3ddcf2 100644 (file)
@@ -43,8 +43,8 @@ FilePickerCtrl::FilePickerCtrl(
        bool open,
        bool warn_overwrite,
        std::string initial_path_key,
-       optional<std::string> initial_filename,
-       optional<filesystem::path> override_path
+       boost::optional<std::string> initial_filename,
+       boost::optional<boost::filesystem::path> override_path
        )
        : wxPanel (parent)
        , _prompt (prompt)
@@ -72,7 +72,7 @@ FilePickerCtrl::FilePickerCtrl(
 
 
 void
-FilePickerCtrl::set_filename(optional<string> filename)
+FilePickerCtrl::set_filename(boost::optional<string> filename)
 {
        if (filename) {
                _file->SetLabel(std_to_wx(*filename));
@@ -83,7 +83,7 @@ FilePickerCtrl::set_filename(optional<string> filename)
 
 
 void
-FilePickerCtrl::set_path(optional<boost::filesystem::path> path)
+FilePickerCtrl::set_path(boost::optional<boost::filesystem::path> path)
 {
        _path = path;
 
index 05ffa7a685264cfbd46a3e683f21015b3be2bd16..6c54f184872d483a02bf9f86abb0cc4368801967 100644 (file)
@@ -39,7 +39,7 @@ using namespace std;
 using namespace boost;
 
 
-optional<filesystem::path> FilmNameLocationDialog::_directory;
+boost::optional<boost::filesystem::path> FilmNameLocationDialog::_directory;
 
 
 FilmNameLocationDialog::FilmNameLocationDialog (wxWindow* parent, wxString title, bool offer_templates)
@@ -112,17 +112,17 @@ FilmNameLocationDialog::folder_changed ()
 }
 
 
-filesystem::path
+boost::filesystem::path
 FilmNameLocationDialog::path () const
 {
-       filesystem::path p;
+       boost::filesystem::path p;
        p /= wx_to_std (_folder->GetPath());
        p /= wx_to_std (_name->GetValue());
        return p;
 }
 
 
-optional<string>
+boost::optional<string>
 FilmNameLocationDialog::template_name () const
 {
        if (!_use_template->GetValue() || _template_name->GetSelection() == -1) {
@@ -139,7 +139,7 @@ FilmNameLocationDialog::template_name () const
 bool
 FilmNameLocationDialog::check_path ()
 {
-       if (filesystem::is_directory(path()) && !filesystem::is_empty(path())) {
+       if (boost::filesystem::is_directory(path()) && !boost::filesystem::is_empty(path())) {
                if (!confirm_dialog (
                            this,
                            std_to_wx (
@@ -150,7 +150,7 @@ FilmNameLocationDialog::check_path ()
                            )) {
                        return false;
                }
-       } else if (filesystem::is_regular_file(path())) {
+       } else if (boost::filesystem::is_regular_file(path())) {
                error_dialog (
                        this,
                        String::compose (wx_to_std(_("%1 already exists as a file, so you cannot use it for a film.")), path().c_str())
diff --git a/wscript b/wscript
index 5aeb4f1c30b59ab2ffc514ddd6a16a11fe359319..d418ab6f43fa32776be3269c9c50c8dafa8904fb 100644 (file)
--- a/wscript
+++ b/wscript
@@ -252,6 +252,10 @@ def configure(conf):
                        lib=['icuio', 'icui18n', 'icudata', 'icuuc'],
                        uselib_store='ICU')
 
+    # For ICU version > 75 we need stdc++17
+    if conf.check_cfg(modversion='icu-i18n') >= '75':
+        conf.env.append_value('CXXFLAGS', '-std=c++17')
+
     # libsamplerate
     conf.check_cfg(package='samplerate', args='--cflags --libs', uselib_store='SAMPLERATE', mandatory=True)