diff options
Diffstat (limited to 'sources/pyside2/CMakeLists.txt')
-rw-r--r-- | sources/pyside2/CMakeLists.txt | 126 |
1 files changed, 76 insertions, 50 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt index d7d17f27d..e3a95c33f 100644 --- a/sources/pyside2/CMakeLists.txt +++ b/sources/pyside2/CMakeLists.txt @@ -1,7 +1,7 @@ include(cmake/Macros/icecc.cmake) # this must be the first line! -cmake_minimum_required(VERSION 3.0) -cmake_policy(VERSION 3.0) +cmake_minimum_required(VERSION 3.1) +cmake_policy(VERSION 3.1) # Don't ignore targets that do not exist, inside add_dependencies calls. cmake_policy(SET CMP0046 NEW) @@ -104,6 +104,11 @@ if(CMAKE_HOST_APPLE) endif() endif() +# Force usage of the C++11 standard, without a silent fallback +# to C++98 if the compiler does not support C++11. +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # Qt5: QT_INCLUDE_DIR does no longer exist. # On Windows, macOS, and Linux it can be computed from Qt5Core_INCLUDE_DIRS, which contains # a list of include directories. We take the first one. @@ -121,10 +126,6 @@ if (QtCore_is_framework) # QT_INCLUDE_DIR points to the QtCore.framework directory, so we need to adjust this to point # to the actual include directory, which has include files for non-framework parts of Qt. get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}/../../include" ABSOLUTE) - - # And then we append the framework dir, to mimic the way setup.py passed that in before to - # the old shiboken parser. - set(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}:${QT_FRAMEWORK_INCLUDE_DIR}") endif() if(MSVC) @@ -225,19 +226,51 @@ include(PySideModules) macro(COLLECT_MODULE_IF_FOUND shortname) set(name "Qt5${shortname}") find_package(${name}) + # If package is found, _name_found will be equal to 1 set(_name_found "${name}_FOUND") - if(${_name_found}) - message(STATUS "module ${name} found (${ARGN})") + # _name_dir will keep the path to the directory where the CMake rules were found + # e.g: ~/qt5.9-install/qtbase/lib/cmake/Qt5Core or /usr/lib64/cmake/Qt5Core + set(_name_dir "${name}_DIR") + # Qt5Core will set the base path to check if all the modules are on the same + # directory, to avoid CMake looking in another path. + # This will be saved in a global variable at the beginning of the modules + # collection process. + string(FIND "${name}" "Qt5Core" qtcore_found) + if(("${qtcore_found}" GREATER "0") OR ("${qtcore_found}" EQUAL "0")) + get_filename_component(_core_abs_dir "${${_name_dir}}/../" ABSOLUTE) + # Setting the absolute path where the Qt5Core was found + # e.g: ~/qt5.9-install/qtbase/lib/cmake or /usr/lib64/cmake + message(STATUS "CORE_ABS_DIR:" ${_core_abs_dir}) + endif() + + # Getting the absolute path for each module where the CMake was found, to + # compare it with CORE_ABS_DIR and check if they are in the same source directory + # e.g: ~/qt5.9-install/qtbase/lib/cmake/Qt5Script or /usr/lib64/cmake/Qt5Script + get_filename_component(_module_dir "${${_name_dir}}" ABSOLUTE) + string(FIND "${_module_dir}" "${_core_abs_dir}" found_basepath) + + # Determine essential/optional/missing + set(module_state "missing") + list(FIND ALL_ESSENTIAL_MODULES "${shortname}" essentialIndex) + if(${essentialIndex} EQUAL -1) + list(FIND ALL_OPTIONAL_MODULES "${shortname}" optionalIndex) + if(NOT ${optionalIndex} EQUAL -1) + set(module_state "optional") + endif() + else() + set(module_state "essential") + endif() - # Put the module at the end of pyside2_global.h - file(APPEND "${CMAKE_CURRENT_BINARY_DIR}/PySide2/pyside2_global.h.add" - "#include \"Qt${shortname}/Qt${shortname}\"\n") + # If the module was found, and also the module path is the same as the + # Qt5Core base path, we will generate the list with the modules to be install + if("${${_name_found}}" AND (("${found_basepath}" GREATER "0") OR ("${found_basepath}" EQUAL "0"))) + message(STATUS "${module_state} module ${name} found (${ARGN})") # record the shortnames for the tests list(APPEND all_module_shortnames ${shortname}) else() - if("${ARGN}" STREQUAL "opt") + if("${module_state}" STREQUAL "optional") message(STATUS "optional module ${name} skipped") - elseif("${ARGN}" STREQUAL "essential") + elseif("${module_state}" STREQUAL "essential") message(STATUS "skipped module ${name} is essential!\n" " We do not guarantee that all tests are working.") else() @@ -246,56 +279,49 @@ macro(COLLECT_MODULE_IF_FOUND shortname) endif() endmacro() +# Set default values for pyside2_global.h +set (Qt5X11Extras_FOUND "0") +set (Qt5Test_FOUND "0") +set (Qt5Widgets_FOUND "0") + +# Collect all essential modules. # note: the order of this list is relevant for dependencies. # For instance: Qt5Printsupport must come before Qt5WebKitWidgets. -COLLECT_MODULE_IF_FOUND(Core) -COLLECT_MODULE_IF_FOUND(Gui essential) -COLLECT_MODULE_IF_FOUND(Widgets essential) -COLLECT_MODULE_IF_FOUND(PrintSupport essential) -COLLECT_MODULE_IF_FOUND(Sql essential) -COLLECT_MODULE_IF_FOUND(Network essential) -COLLECT_MODULE_IF_FOUND(Test essential) -COLLECT_MODULE_IF_FOUND(Concurrent essential) +set(ALL_ESSENTIAL_MODULES Core Gui Widgets PrintSupport Sql Network Test Concurrent) if(UNIX AND NOT APPLE) - COLLECT_MODULE_IF_FOUND(X11Extras essential) + list(APPEND ALL_ESSENTIAL_MODULES X11Extras) endif() if(WIN32) - COLLECT_MODULE_IF_FOUND(WinExtras essential) + list(APPEND ALL_ESSENTIAL_MODULES WinExtras) endif() if(APPLE) - COLLECT_MODULE_IF_FOUND(MacExtras essential) + list(APPEND ALL_ESSENTIAL_MODULES MacExtras) endif() -COLLECT_MODULE_IF_FOUND(Xml) -COLLECT_MODULE_IF_FOUND(XmlPatterns opt) -COLLECT_MODULE_IF_FOUND(Help opt) -COLLECT_MODULE_IF_FOUND(Multimedia opt) -COLLECT_MODULE_IF_FOUND(MultimediaWidgets opt) -COLLECT_MODULE_IF_FOUND(OpenGL opt) -COLLECT_MODULE_IF_FOUND(Qml opt) -COLLECT_MODULE_IF_FOUND(Quick opt) -COLLECT_MODULE_IF_FOUND(QuickWidgets opt) -COLLECT_MODULE_IF_FOUND(Script opt) -COLLECT_MODULE_IF_FOUND(ScriptTools opt) -COLLECT_MODULE_IF_FOUND(Svg opt) + +# Collect all optional modules. +set(ALL_OPTIONAL_MODULES Xml XmlPatterns Help Multimedia MultimediaWidgets OpenGL Qml Quick QuickWidgets Script ScriptTools TextToSpeech Charts Svg DataVisualization) find_package(Qt5UiTools) if(Qt5UiTools_FOUND) - COLLECT_MODULE_IF_FOUND(UiTools opt) + list(APPEND ALL_OPTIONAL_MODULES UiTools) else() set(DISABLE_QtUiTools 1) endif() -COLLECT_MODULE_IF_FOUND(WebChannel opt) -# still forgotten: -#COLLECT_MODULE_IF_FOUND(WebEngineCore opt) -#COLLECT_MODULE_IF_FOUND(WebEngine opt) -COLLECT_MODULE_IF_FOUND(WebEngineWidgets opt) -COLLECT_MODULE_IF_FOUND(WebKit opt) -if(NOT MSVC) - # right now this does not build on windows - COLLECT_MODULE_IF_FOUND(WebKitWidgets opt) -else() - set(DISABLE_QtWebKitWidgets 1) -ENDIF() -COLLECT_MODULE_IF_FOUND(WebSockets opt) +if(WIN32) + list(APPEND ALL_OPTIONAL_MODULES AxContainer) +endif() +list(APPEND ALL_OPTIONAL_MODULES WebChannel WebEngineWidgets WebKit WebKitWidgets WebSockets) +if (Qt5Core_VERSION VERSION_GREATER 5.9.3 AND Qt5Core_VERSION VERSION_LESS 5.10.0) # Depending on fixes in Qt3D + list(APPEND ALL_OPTIONAL_MODULES 3DCore 3DRender 3DInput 3DLogic 3DAnimation 3DExtras) +endif() + +# Modules to be built unless specified by -DMODULES on command line +if (NOT MODULES) + set(MODULES "${ALL_ESSENTIAL_MODULES};${ALL_OPTIONAL_MODULES}") +endif() + +foreach(m ${MODULES}) + COLLECT_MODULE_IF_FOUND(${m}) +endforeach() string(REGEX MATCHALL "[0-9]+" qt_version_helper "${Qt5Core_VERSION}") |