@@ -819,6 +819,10 @@ def _cmake_executables_file(self):
819
819
def _cmake_entry_point_file (self ):
820
820
return os .path .join ("lib" , "cmake" , "Qt6Core" , "conan_qt_entry_point.cmake" )
821
821
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
+
822
826
def _cmake_qt6_private_file (self , module ):
823
827
return os .path .join ("lib" , "cmake" , f"Qt6{ module } " , f"conan_qt_qt6_{ module .lower ()} private.cmake" )
824
828
@@ -964,6 +968,29 @@ def _create_private_module(module, dependencies):
964
968
)""" )
965
969
save (self , os .path .join (self .package_folder , self ._cmake_entry_point_file ), contents )
966
970
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
+
967
994
def package_info (self ):
968
995
self .cpp_info .set_property ("cmake_file_name" , "Qt6" )
969
996
self .cpp_info .set_property ("pkg_config_name" , "qt6" )
@@ -1027,7 +1054,18 @@ def _create_plugin(pluginname, libname, plugintype, requires):
1027
1054
requires .append ("Core" )
1028
1055
self .cpp_info .components [componentname ].requires = _get_corrected_reqs (requires )
1029
1056
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" ]
1031
1069
if self .options .with_pcre2 :
1032
1070
core_reqs .append ("pcre2::pcre2" )
1033
1071
if self .options .with_doubleconversion :
@@ -1054,12 +1092,8 @@ def _create_plugin(pluginname, libname, plugintype, requires):
1054
1092
if self .settings .os == "Windows" :
1055
1093
self .cpp_info .components ["qtCore" ].system_libs .append ("authz" )
1056
1094
if is_msvc (self ):
1057
- self .cpp_info .components ["qtCore" ].cxxflags .append ("-permissive-" )
1058
- self .cpp_info .components ["qtCore" ].cxxflags .append ("-Zc:__cplusplus" )
1059
1095
self .cpp_info .components ["qtCore" ].system_libs .append ("synchronization" )
1060
1096
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 ())]
1063
1097
if self .options .with_dbus :
1064
1098
_create_module ("DBus" , ["dbus::dbus" ])
1065
1099
if self .settings .os == "Windows" :
@@ -1514,6 +1548,9 @@ def _create_plugin(pluginname, libname, plugintype, requires):
1514
1548
# https://github.com/qt/qtbase/blob/v6.6.1/src/corelib/CMakeLists.txt#L1079-L1082
1515
1549
self .cpp_info .components ["qtCore" ].frameworks .append ("WatchKit" )
1516
1550
1551
+ if self .settings .os == "Windows" or is_msvc (self ):
1552
+ _add_build_module ("qtPlatform" , self ._cmake_platform_target_setup_file )
1553
+
1517
1554
self .cpp_info .components ["qtCore" ].builddirs .append (os .path .join ("bin" ))
1518
1555
_add_build_module ("qtCore" , self ._cmake_executables_file )
1519
1556
_add_build_module ("qtCore" , self ._cmake_qt6_private_file ("Core" ))
0 commit comments