Skip to content

Commit 85e7087

Browse files
wip
1 parent 5f199e0 commit 85e7087

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

recipes/qt/6.x.x/conanfile.py

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,10 @@ def _cmake_executables_file(self):
819819
def _cmake_entry_point_file(self):
820820
return os.path.join("lib", "cmake", "Qt6Core", "conan_qt_entry_point.cmake")
821821

822+
@property
823+
def _cmake_platform_target_setup_file(self):
824+
return os.path.join("lib", "cmake", "Qt6", "conan_qt_platform_target_setup.cmake")
825+
822826
def _cmake_qt6_private_file(self, module):
823827
return os.path.join("lib", "cmake", f"Qt6{module}", f"conan_qt_qt6_{module.lower()}private.cmake")
824828

@@ -964,6 +968,29 @@ def _create_private_module(module, dependencies):
964968
)""")
965969
save(self, os.path.join(self.package_folder, self._cmake_entry_point_file), contents)
966970

971+
if self.settings.os == "Windows" or is_msvc(self):
972+
contents = textwrap.dedent("""\
973+
set(utf8_flags "")
974+
if(MSVC)
975+
list(APPEND utf8_flags "$<$<CXX_COMPILER_ID:MSVC>:-utf-8>")
976+
endif()
977+
978+
if(utf8_flags)
979+
set(opt_out_condition "$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_UTF8_SOURCE>>>")
980+
set(language_condition "$<COMPILE_LANGUAGE:C,CXX>")
981+
set(genex_condition "$<AND:${opt_out_condition},${language_condition}>")
982+
set(utf8_flags "$<${genex_condition}:${utf8_flags}>")
983+
target_compile_options(Qt6::Platform INTERFACE "${utf8_flags}")
984+
endif()
985+
986+
if(WIN32)
987+
set(no_unicode_condition
988+
"$<NOT:$<BOOL:$<TARGET_PROPERTY:QT_NO_UNICODE_DEFINES>>>")
989+
target_compile_definitions(Qt6::Platform
990+
INTERFACE "$<${no_unicode_condition}:UNICODE$<SEMICOLON>_UNICODE>")
991+
endif()""")
992+
save(self, os.path.join(self.package_folder, self._cmake_platform_target_setup_file), contents)
993+
967994
def package_info(self):
968995
self.cpp_info.set_property("cmake_file_name", "Qt6")
969996
self.cpp_info.set_property("pkg_config_name", "qt6")
@@ -1027,7 +1054,18 @@ def _create_plugin(pluginname, libname, plugintype, requires):
10271054
requires.append("Core")
10281055
self.cpp_info.components[componentname].requires = _get_corrected_reqs(requires)
10291056

1030-
core_reqs = ["zlib::zlib"]
1057+
# https://github.com/qt/qtbase/blob/v6.7.3/cmake/QtPlatformTargetHelpers.cmake
1058+
self.cpp_info.components["qtPlatform"].set_property("cmake_target_name", "Qt6::Platform")
1059+
self.cpp_info.components["qtPlatform"].includedirs = [os.path.join("mkspecs", self._xplatform())]
1060+
if self.settings.os == "Android":
1061+
self.cpp_info.components["qtPlatform"].system_libs.append("log")
1062+
if self.settings.os in ["Linux", "FreeBSD"]:
1063+
self.cpp_info.components["qtPlatform"].system_libs.append("pthread")
1064+
if is_msvc(self):
1065+
self.cpp_info.components["qtPlatform"].cxxflags.append("-permissive-")
1066+
self.cpp_info.components["qtPlatform"].cxxflags.append("-Zc:__cplusplus")
1067+
1068+
core_reqs = ["Platform", "zlib::zlib"]
10311069
if self.options.with_pcre2:
10321070
core_reqs.append("pcre2::pcre2")
10331071
if self.options.with_doubleconversion:
@@ -1054,12 +1092,8 @@ def _create_plugin(pluginname, libname, plugintype, requires):
10541092
if self.settings.os == "Windows":
10551093
self.cpp_info.components["qtCore"].system_libs.append("authz")
10561094
if is_msvc(self):
1057-
self.cpp_info.components["qtCore"].cxxflags.append("-permissive-")
1058-
self.cpp_info.components["qtCore"].cxxflags.append("-Zc:__cplusplus")
10591095
self.cpp_info.components["qtCore"].system_libs.append("synchronization")
10601096
self.cpp_info.components["qtCore"].system_libs.append("runtimeobject")
1061-
self.cpp_info.components["qtPlatform"].set_property("cmake_target_name", "Qt6::Platform")
1062-
self.cpp_info.components["qtPlatform"].includedirs = [os.path.join("mkspecs", self._xplatform())]
10631097
if self.options.with_dbus:
10641098
_create_module("DBus", ["dbus::dbus"])
10651099
if self.settings.os == "Windows":
@@ -1514,6 +1548,9 @@ def _create_plugin(pluginname, libname, plugintype, requires):
15141548
# https://github.com/qt/qtbase/blob/v6.6.1/src/corelib/CMakeLists.txt#L1079-L1082
15151549
self.cpp_info.components["qtCore"].frameworks.append("WatchKit")
15161550

1551+
if self.settings.os == "Windows" or is_msvc(self):
1552+
_add_build_module("qtPlatform", self._cmake_platform_target_setup_file)
1553+
15171554
self.cpp_info.components["qtCore"].builddirs.append(os.path.join("bin"))
15181555
_add_build_module("qtCore", self._cmake_executables_file)
15191556
_add_build_module("qtCore", self._cmake_qt6_private_file("Core"))

0 commit comments

Comments
 (0)