diff options
Diffstat (limited to 'sources/pyside2/cmake/Macros/PySideModules.cmake')
-rw-r--r-- | sources/pyside2/cmake/Macros/PySideModules.cmake | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/sources/pyside2/cmake/Macros/PySideModules.cmake b/sources/pyside2/cmake/Macros/PySideModules.cmake index 0bef89b0c..36488912d 100644 --- a/sources/pyside2/cmake/Macros/PySideModules.cmake +++ b/sources/pyside2/cmake/Macros/PySideModules.cmake @@ -54,34 +54,38 @@ macro(create_pyside_module # First add the main file. set(total_type_system_files ${typesystem_path}) - # Transform the path separator list back into a cmake list (so from a:b:c to a;b;c) - unmake_path(list_of_paths ${${module_typesystem_path}}) + get_filename_component(typesystem_root "${CMAKE_CURRENT_SOURCE_DIR}" DIRECTORY) - # Collect all XML files, in each given path, and append them to the final total list. - foreach(type_system_files_path ${list_of_paths}) - set(glob_expression "${type_system_files_path}/*.xml") + set(deps ${module_name} ${${module_deps}}) + foreach(dep ${deps}) + set(glob_expression "${typesystem_root}/${dep}/*.xml") file(GLOB type_system_files ${glob_expression}) set(total_type_system_files ${total_type_system_files} ${type_system_files}) - endforeach(type_system_files_path) + endforeach(dep) # Remove any possible duplicates. list(REMOVE_DUPLICATES total_type_system_files) # Contains include directories to pass to shiboken's preprocessor. set(shiboken_include_dirs ${pyside2_SOURCE_DIR}${PATH_SEP}${QT_INCLUDE_DIR}) + set(shiboken_framework_include_dirs_option "") if(CMAKE_HOST_APPLE) - # On macOS, provide the framework paths for OpenGL headers. - set(shiboken_include_dirs ${shiboken_include_dirs} ${CMAKE_SYSTEM_FRAMEWORK_PATH}) + set(shiboken_framework_include_dirs "${QT_FRAMEWORK_INCLUDE_DIR}") + make_path(shiboken_framework_include_dirs ${shiboken_framework_include_dirs}) + set(shiboken_framework_include_dirs_option "--framework-include-paths=${shiboken_framework_include_dirs}") endif() # Transform the path separators into something shiboken understands. make_path(shiboken_include_dirs ${shiboken_include_dirs}) + get_filename_component(pyside_binary_dir ${CMAKE_CURRENT_BINARY_DIR} DIRECTORY) + add_custom_command(OUTPUT ${${module_sources}} COMMAND "${SHIBOKEN_BINARY}" ${GENERATOR_EXTRA_FLAGS} - ${pyside2_BINARY_DIR}/pyside2_global.h + "${pyside2_BINARY_DIR}/${module_name}_global.h" --include-paths=${shiboken_include_dirs} - --typesystem-paths=${pyside2_SOURCE_DIR}${PATH_SEP}${${module_typesystem_path}} + ${shiboken_framework_include_dirs_option} + --typesystem-paths=${pyside_binary_dir}${PATH_SEP}${pyside2_SOURCE_DIR}${PATH_SEP}${${module_typesystem_path}} --output-directory=${CMAKE_CURRENT_BINARY_DIR} --license-file=${CMAKE_CURRENT_SOURCE_DIR}/../licensecomment.txt ${typesystem_path} @@ -100,6 +104,8 @@ macro(create_pyside_module LIBRARY_OUTPUT_DIRECTORY ${pyside2_BINARY_DIR}) if(WIN32) set_target_properties(${module_name} PROPERTIES SUFFIX ".pyd") + # Sanitize windows.h as pulled by gl.h to prevent clashes with QAbstract3dAxis::min(), etc. + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX") endif() target_link_libraries(${module_name} ${${module_libraries}}) @@ -113,7 +119,19 @@ macro(create_pyside_module install(FILES ${CMAKE_CURRENT_BINARY_DIR}/PySide2/${module_name}/pyside2_${lower_module_name}_python.h DESTINATION include/PySide2${pyside2_SUFFIX}/${module_name}/) file(GLOB typesystem_files ${CMAKE_CURRENT_SOURCE_DIR}/typesystem_*.xml ${typesystem_path}) - install(FILES ${typesystem_files} DESTINATION share/PySide2${pyside2_SUFFIX}/typesystems) + +# Copy typesystem files and remove module names from the <load-typesystem> element +# so that it works in a flat directory: +# <load-typesystem name="QtWidgets/typesystem_widgets.xml" ... -> +# <load-typesystem name="typesystem_widgets.xml" + foreach(typesystem_file ${typesystem_files}) + get_filename_component(typesystem_file_name "${typesystem_file}" NAME) + file(READ "${typesystem_file}" typesystemXml) + string(REGEX REPLACE "<load-typesystem name=\"[^/\"]+/" "<load-typesystem name=\"" typesystemXml "${typesystemXml}") + set (typesystem_target_file "${CMAKE_CURRENT_BINARY_DIR}/PySide2/typesystems/${typesystem_file_name}") + file(WRITE "${typesystem_target_file}" "${typesystemXml}") + install(FILES "${typesystem_target_file}" DESTINATION share/PySide2${pyside2_SUFFIX}/typesystems) + endforeach() endmacro() #macro(check_qt_class_with_namespace module namespace class optional_source_files dropped_entries [namespace] [module]) @@ -161,7 +179,11 @@ macro(check_qt_class module class optional_source_files dropped_entries) # Don't add version tagging, because for some reason linker fails with: # (.qtversion[qt_version_tag]+0x0): undefined reference to `qt_version_tag' - set(ADDITIONAL_FLAGS "${ADDITIONAL_FLAGS} -DQT_NO_VERSION_TAGGING") + # Force usage of the C++11 standard. CMAKE_CXX_STANDARD does not work with try_compile + # but the issue has a fix in CMake 3.9. Thus we use a terrible workaround, we pass the C++ + # standard flag the way CheckCXXSourceCompiles.cmake does it. + + set(ADDITIONAL_FLAGS "${ADDITIONAL_FLAGS} -DQT_NO_VERSION_TAGGING ${CMAKE_CXX11_EXTENSION_COMPILE_OPTION}") try_compile(Q_WORKS ${CMAKE_BINARY_DIR} ${SRC_FILE} |