@@ -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
@@ -965,6 +969,29 @@ def _create_private_module(module, dependencies):
965
969
)""" )
966
970
save (self , os .path .join (self .package_folder , self ._cmake_entry_point_file ), contents )
967
971
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
+
968
995
def package_info (self ):
969
996
self .cpp_info .set_property ("cmake_file_name" , "Qt6" )
970
997
self .cpp_info .set_property ("pkg_config_name" , "qt6" )
@@ -1028,7 +1055,18 @@ def _create_plugin(pluginname, libname, plugintype, requires):
1028
1055
requires .append ("Core" )
1029
1056
self .cpp_info .components [componentname ].requires = _get_corrected_reqs (requires )
1030
1057
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" ]
1032
1070
if self .options .with_pcre2 :
1033
1071
core_reqs .append ("pcre2::pcre2" )
1034
1072
if self .options .with_doubleconversion :
@@ -1055,12 +1093,8 @@ def _create_plugin(pluginname, libname, plugintype, requires):
1055
1093
if self .settings .os == "Windows" :
1056
1094
self .cpp_info .components ["qtCore" ].system_libs .append ("authz" )
1057
1095
if is_msvc (self ):
1058
- self .cpp_info .components ["qtCore" ].cxxflags .append ("-permissive-" )
1059
- self .cpp_info .components ["qtCore" ].cxxflags .append ("-Zc:__cplusplus" )
1060
1096
self .cpp_info .components ["qtCore" ].system_libs .append ("synchronization" )
1061
1097
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 ())]
1064
1098
if self .options .with_dbus :
1065
1099
_create_module ("DBus" , ["dbus::dbus" ])
1066
1100
if self .settings .os == "Windows" :
@@ -1515,6 +1549,9 @@ def _create_plugin(pluginname, libname, plugintype, requires):
1515
1549
# https://github.com/qt/qtbase/blob/v6.6.1/src/corelib/CMakeLists.txt#L1079-L1082
1516
1550
self .cpp_info .components ["qtCore" ].frameworks .append ("WatchKit" )
1517
1551
1552
+ if self .settings .os == "Windows" or is_msvc (self ):
1553
+ _add_build_module ("qtPlatform" , self ._cmake_platform_target_setup_file )
1554
+
1518
1555
self .cpp_info .components ["qtCore" ].builddirs .append (os .path .join ("bin" ))
1519
1556
_add_build_module ("qtCore" , self ._cmake_executables_file )
1520
1557
_add_build_module ("qtCore" , self ._cmake_qt6_private_file ("Core" ))
0 commit comments