Skip to content

Commit ab78685

Browse files
committed
ENH: Add Qt6-specific build_all file and update generator resource handling
Introduce `build_all_qt6.txt` for Qt6 builds and update generator to conditionally copy appropriate resource files. Improved resource copying logic and adjusted CMake commands for enhanced Qt5/6 compatibility.
1 parent f23f420 commit ab78685

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

generator/CMakeLists.txt

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/sim
4040
get_filename_component(PYTHONQT_GENERATED_PATH "${CMAKE_CURRENT_BINARY_DIR}" PATH)
4141
set(PYTHONQT_GENERATED_PATH "${PYTHONQT_GENERATED_PATH}/generated_cpp")
4242

43-
file(GLOB resources_files *.txt *.xml qtscript_masterinclude.h)
44-
foreach(resources_file IN LISTS resources_files)
45-
configure_file(${resources_file} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
46-
endforeach()
47-
4843
if(WIN32)
4944
set(LIBRARY_SEARCH_PATH PATH)
5045
else()
@@ -63,6 +58,7 @@ foreach(wrapper IN LISTS wrapper_list)
6358
set(PYTHONQT_WRAPPER_${WRAPPER}_SOURCES ${PYTHONQT_WRAPPER_${WRAPPER}_SOURCES} PARENT_SCOPE)
6459
endforeach()
6560

61+
# Determine the Qt include prefix
6662
get_target_property(_qtcore_include_dirs Qt${QT_VERSION_MAJOR}::Core INTERFACE_INCLUDE_DIRECTORIES)
6763
foreach(_qtcore_include_dir IN LISTS _qtcore_include_dirs)
6864
# Some versions of Qt may have subdirectories like "QtCore" for header files
@@ -76,12 +72,33 @@ foreach(_qtcore_include_dir IN LISTS _qtcore_include_dirs)
7672
break()
7773
endif()
7874
endif()
75+
endforeach()
7976

77+
# Copy resource to the build tree
78+
message(STATUS "Copying resource files from ${CMAKE_CURRENT_LIST_DIR} to ${CMAKE_CURRENT_BINARY_DIR}")
79+
file(GLOB resources_files *.txt *.xml qtscript_masterinclude.h)
80+
foreach(resources_file IN LISTS resources_files)
81+
configure_file(${resources_file} ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
8082
endforeach()
83+
set(gen_masterinclude_file "${CMAKE_CURRENT_BINARY_DIR}/qtscript_masterinclude.h")
84+
85+
if(QT_VERSION_MAJOR EQUAL 5)
86+
set(gen_build_all_file "${CMAKE_CURRENT_SOURCE_DIR}/build_all.txt")
87+
else()
88+
# For Qt6, we need to generate a different master include file
89+
set(gen_build_all_file "${CMAKE_CURRENT_BINARY_DIR}/build_all_qt6.txt")
90+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/build_all_qt6.txt ${gen_build_all_file} COPYONLY)
91+
endif()
8192

8293
add_custom_command(OUTPUT ${PYTHONQT_WRAPPER_SOURCES}
83-
COMMAND ${CMAKE_COMMAND} -E env --modify ${LIBRARY_SEARCH_PATH}=path_list_prepend:$<TARGET_FILE_DIR:Qt${QT_VERSION_MAJOR}::Widgets>
84-
$<TARGET_FILE:${PROJECT_NAME}> --qt-include-prefix="${_qt_include_prefix}"
94+
COMMAND ${CMAKE_COMMAND} -E env QTDIR=${Qt${QT_VERSION_MAJOR}_DIR}
95+
--modify ${LIBRARY_SEARCH_PATH}=path_list_prepend:$<TARGET_FILE_DIR:Qt${QT_VERSION_MAJOR}::Widgets>
96+
$<TARGET_FILE:${PROJECT_NAME}>
97+
--qt-include-prefix="${_qt_include_prefix}"
98+
--debug-level=full
99+
--output-dir=${PYTHONQT_GENERATED_PATH}
100+
${gen_masterinclude_file} ${gen_build_all_file}
101+
COMMENT "Generating PythonQt wrapper sources: $<TARGET_FILE:${PROJECT_NAME}>"
85102
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
86103
DEPENDS ${PROJECT_NAME}
87104
)

generator/build_all_qt6.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<typesystem>
2+
<load-typesystem name="typesystem_core.xml" generate="yes" />
3+
<load-typesystem name="typesystem_gui.xml" generate="yes" />
4+
<load-typesystem name="typesystem_sql.xml" generate="yes" />
5+
<load-typesystem name="typesystem_opengl.xml" generate="yes" />
6+
<load-typesystem name="typesystem_svg.xml" generate="yes" />
7+
<load-typesystem name="typesystem_network.xml" generate="yes" />
8+
<load-typesystem name="typesystem_xml.xml" generate="yes" />
9+
<load-typesystem name="typesystem_webenginewidgets.xml" generate="yes" />
10+
<load-typesystem name="typesystem_uitools.xml" generate="yes" />
11+
<load-typesystem name="typesystem_multimedia.xml" generate="yes" />
12+
<load-typesystem name="typesystem_qml.xml" generate="yes" />
13+
<load-typesystem name="typesystem_quick.xml" generate="yes" />
14+
</typesystem>

0 commit comments

Comments
 (0)