Skip to content

Commit 8500bb5

Browse files
wip
1 parent 956d212 commit 8500bb5

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

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

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

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

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

0 commit comments

Comments
 (0)