View Bug Details

IDProjectCategoryView StatusLast Update
0002840DCP-o-maticBugspublic2024-06-30 15:19
Reporterbradel Assigned Tocarl  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Platform64-bitOSLinuxOS VersionArch
Product Version2.16.87 
Target Version2.16.88 
Summary0002840: DCPoMatic does not compile with ICU >= 75 due to c++17 requirement of icu
Description

Dear Carl,

Arch Linux recently rolled icu 75.1 out, which requires compilation with at least c++17. wscript specifies c++11 for the compilation of DCPoMatic. Overwriting this with c++17 leads to some namespace conflicts with the c++ stdlib and boost (filesystem and optional).
The attached patch adds a version check in the wscript file to detect ICU >= 75 and subsequently enables c++17, otherwise it leaves c++11 enabled. Additionally the patch adds the boost:: prefix to optional and filesystem in the files
src/wx/file_picker_ctrl.cc
src/wx/film_name_location_dialog.cc

Best regards,
Benjamin

Steps To Reproduce

Compile DCPoMatic with icu >= 75

TagsNo tags attached.
Branch2840-icu
Estimated weeks required
Estimated work requiredUndecided

Activities

bradel

2024-06-28 23:50

reporter  

0001-Make-DCPoMatic-compatible-with-ICU-75.patch (4,192 bytes)   
From 94e94a67d0ac74957b9ee51d858a659979bf74f6 Mon Sep 17 00:00:00 2001
From: Benjamin Radel <benjamin@radel.tk>
Date: Fri, 28 Jun 2024 21:56:36 +0200
Subject: [PATCH] Make DCPoMatic compatible with ICU >= 75

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/file_picker_ctrl.cc          |  8 ++++----
 src/wx/film_name_location_dialog.cc | 12 ++++++------
 wscript                             |  6 ++++++
 3 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/src/wx/file_picker_ctrl.cc b/src/wx/file_picker_ctrl.cc
index 7aa0bfb40..82978dad6 100644
--- a/src/wx/file_picker_ctrl.cc
+++ b/src/wx/file_picker_ctrl.cc
@@ -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;
 
diff --git a/src/wx/film_name_location_dialog.cc b/src/wx/film_name_location_dialog.cc
index 05ffa7a68..6c54f1848 100644
--- a/src/wx/film_name_location_dialog.cc
+++ b/src/wx/film_name_location_dialog.cc
@@ -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 5aeb4f1c3..744e45416 100644
--- a/wscript
+++ b/wscript
@@ -252,6 +252,12 @@ def configure(conf):
                        lib=['icuio', 'icui18n', 'icudata', 'icuuc'],
                        uselib_store='ICU')
 
+    # If ICU version > 75 we need stdc++17, otherwise we stick with stdc++11
+    if (conf.check_cfg(modversion='icu-i18n') >= '75'):
+        conf.env.append_value('CXXFLAGS', '-std=c++17')
+    else:
+        conf.env.append_value('CXXFLAGS', '-std=c++11')
+
     # libsamplerate
     conf.check_cfg(package='samplerate', args='--cflags --libs', uselib_store='SAMPLERATE', mandatory=True)
 
-- 
2.45.2

carl

2024-06-28 23:54

administrator   ~0006467

Thanks!

carl

2024-06-30 15:19

administrator   ~0006469

Merged to main as 0ca9937987ecf2bf3f579147ffc952838565415b with a few minor tweaks. Many thanks!

I added your name to the list of authors in the about box and on the website - let me know if you'd rather not be there.

Bug History

Date Modified Username Field Change
2024-06-28 23:50 bradel New Bug
2024-06-28 23:50 bradel File Added: 0001-Make-DCPoMatic-compatible-with-ICU-75.patch
2024-06-28 23:54 carl Note Added: 0006467
2024-06-28 23:54 carl Assigned To => carl
2024-06-28 23:54 carl Status new => confirmed
2024-06-28 23:54 carl Target Version => 2.16.88
2024-06-28 23:54 carl Estimated work required => Undecided
2024-06-29 00:00 carl Branch => 2840-icu
2024-06-29 00:02 carl Status confirmed => tests running
2024-06-30 15:19 carl Status tests running => resolved
2024-06-30 15:19 carl Resolution open => fixed
2024-06-30 15:19 carl Note Added: 0006469