aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside2/CMakeLists.txt')
-rw-r--r--sources/pyside2/CMakeLists.txt193
1 files changed, 13 insertions, 180 deletions
diff --git a/sources/pyside2/CMakeLists.txt b/sources/pyside2/CMakeLists.txt
index c5dbc623c..16038594a 100644
--- a/sources/pyside2/CMakeLists.txt
+++ b/sources/pyside2/CMakeLists.txt
@@ -9,8 +9,10 @@ cmake_policy(SET CMP0046 NEW)
project(pysidebindings)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../cmake_helpers/
+ ${CMAKE_CURRENT_SOURCE_DIR}/../shiboken2/data/
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Macros/
${CMAKE_MODULE_PATH})
+include(shiboken_helpers)
include(helpers)
# Don't display "up-to-date / install" messages when installing, to reduce visual clutter.
@@ -128,31 +130,8 @@ if (QtCore_is_framework)
get_filename_component(QT_INCLUDE_DIR "${QT_INCLUDE_DIR}/../../include" ABSOLUTE)
endif()
-if(MSVC)
- # Qt5: this flag has changed from /Zc:wchar_t- in Qt4.X
- set(CMAKE_CXX_FLAGS "/Zc:wchar_t /GR /EHsc /DNOCOLOR /DWIN32 /D_WINDOWS /D_SCL_SECURE_NO_WARNINGS") # XXX
-else()
- if(CMAKE_HOST_UNIX AND NOT CYGWIN)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -fvisibility=hidden -Wno-strict-aliasing")
- endif()
- set(CMAKE_CXX_FLAGS_DEBUG "-g")
- option(ENABLE_GCC_OPTIMIZATION "Enable specific GCC flags to optimization library size and performance. Only available on Release Mode" 0)
- if(ENABLE_GCC_OPTIMIZATION)
- set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG -Os -Wl,-O1")
- if(NOT CMAKE_HOST_APPLE)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wl,--hash-style=gnu")
- endif()
- endif()
+set_cmake_cxx_flags()
- if(CMAKE_HOST_APPLE)
- # ALTERNATIVE_QT_INCLUDE_DIR is deprecated, because CMake takes care of finding the proper
- # include folders using the qmake found in the environment. Only use it for now in case
- # something goes wrong with the cmake process.
- if(ALTERNATIVE_QT_INCLUDE_DIR AND NOT QT_INCLUDE_DIR)
- set(QT_INCLUDE_DIR ${ALTERNATIVE_QT_INCLUDE_DIR})
- endif()
- endif()
-endif()
message(STATUS "*** computed QT_INCLUDE_DIR as ${QT_INCLUDE_DIR}")
set(BINDING_NAME PySide2)
@@ -171,111 +150,13 @@ compute_config_py_values(BINDING_API_VERSION)
include(PySideModules)
-macro(COLLECT_MODULE_IF_FOUND shortname)
- set(name "Qt5${shortname}")
- set(_qt_module_name "${name}")
- if ("${shortname}" STREQUAL "OpenGLFunctions")
- set(_qt_module_name "Qt5Gui")
- endif()
- # 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()
-
- # Silence warnings when optional packages are not found when doing a quiet build.
- set(quiet_argument "")
- if (QUIET_BUILD AND "${module_state}" STREQUAL "optional")
- set(quiet_argument "QUIET")
- endif()
-
- find_package(${_qt_module_name} ${quiet_argument})
- # If package is found, _name_found will be equal to 1
- set(_name_found "${_qt_module_name}_FOUND")
- # _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 "${_qt_module_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)
-
- # 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 installed
- set(looked_in_message ". Looked in: ${${_name_dir}}")
- if("${${_name_found}}" AND (("${found_basepath}" GREATER "0") OR ("${found_basepath}" EQUAL "0")))
- message(STATUS "${module_state} module ${name} found (${ARGN})${looked_in_message}")
- # record the shortnames for the tests
- list(APPEND all_module_shortnames ${shortname})
- else()
- if("${module_state}" STREQUAL "optional")
- message(STATUS "optional module ${name} skipped${looked_in_message}")
- elseif("${module_state}" STREQUAL "essential")
- message(STATUS "skipped module ${name} is essential!\n"
- " We do not guarantee that all tests are working.${looked_in_message}")
- else()
- message(FATAL_ERROR "module ${name} MISSING${looked_in_message}")
- endif()
- 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.
-set(ALL_ESSENTIAL_MODULES Core Gui Widgets PrintSupport Sql Network Test Concurrent)
-if(UNIX AND NOT APPLE)
- list(APPEND ALL_ESSENTIAL_MODULES X11Extras)
-endif()
-if(WIN32)
- list(APPEND ALL_ESSENTIAL_MODULES WinExtras)
-endif()
-if(APPLE)
- list(APPEND ALL_ESSENTIAL_MODULES MacExtras)
-endif()
-
-# Collect all optional modules.
-set(ALL_OPTIONAL_MODULES Xml XmlPatterns Help Multimedia
-MultimediaWidgets OpenGL OpenGLFunctions Positioning Location Qml Quick QuickWidgets RemoteObjects Scxml Script ScriptTools Sensors TextToSpeech Charts Svg DataVisualization)
-find_package(Qt5UiTools)
-if(Qt5UiTools_FOUND)
- list(APPEND ALL_OPTIONAL_MODULES UiTools)
-else()
- set(DISABLE_QtUiTools 1)
-endif()
-if(WIN32)
- list(APPEND ALL_OPTIONAL_MODULES AxContainer)
-endif()
-# Disabling WebKit by default
-# If WebKit support is needed add the following elements
-# to the list: WebKit WebKitWidgets
-list(APPEND ALL_OPTIONAL_MODULES WebChannel WebEngineCore WebEngine WebEngineWidgets WebSockets)
-if (Qt5Core_VERSION VERSION_GREATER 5.9.3) # Depending on fixes in Qt3D
- list(APPEND ALL_OPTIONAL_MODULES 3DCore 3DRender 3DInput 3DLogic 3DAnimation 3DExtras)
-endif()
+collect_essential_modules()
+collect_optional_modules()
# Modules to be built unless specified by -DMODULES on command line
if (NOT MODULES)
@@ -285,22 +166,7 @@ endif()
# This will contain the set of modules for which bindings are not built.
set(DISABLED_MODULES "${ALL_ESSENTIAL_MODULES};${ALL_OPTIONAL_MODULES}")
-# Removing from the MODULES list the items that were defined with
-# -DSKIP_MODULES on command line
-if (SKIP_MODULES)
- foreach(s ${SKIP_MODULES})
- list(REMOVE_ITEM MODULES ${s})
- endforeach()
-endif()
-
-foreach(m ${MODULES})
- COLLECT_MODULE_IF_FOUND(${m})
- list(FIND all_module_shortnames ${m} is_module_collected)
- # If the module was collected, remove it from disabled modules list.
- if (NOT is_module_collected EQUAL -1)
- list(REMOVE_ITEM DISABLED_MODULES ${m})
- endif()
-endforeach()
+remove_skipped_modules()
# Mark all non-collected modules as disabled. This is used for disabling tests
# that depend on the disabled modules.
@@ -323,24 +189,7 @@ endif()
# no more supported: include(${QT_USE_FILE})
# Configure OS support
-set(ENABLE_X11 "0")
-set(ENABLE_MAC "0")
-set(ENABLE_WIN "0")
-set(ENABLE_SIMULATOR "0")
-
-# no more Maemo, no more simulator
-if(CMAKE_HOST_APPLE)
- set(ENABLE_MAC "1")
- set(AUTO_OS "mac")
-elseif(CMAKE_HOST_WIN32)
- set(ENABLE_WIN "1")
- set(AUTO_OS "win")
-elseif(CMAKE_HOST_UNIX)
- set(ENABLE_X11 "1")
- set(AUTO_OS "x11")
-else()
- message(FATAL_ERROR "OS not supported")
-endif()
+check_os()
message(STATUS "Detected OS: ${AUTO_OS}")
# Define supported Qt Version
@@ -379,33 +228,17 @@ set(GENERATOR_EXTRA_FLAGS --generator-set=shiboken
--enable-pyside-extensions
--enable-return-value-heuristic
--use-isnull-as-nb_nonzero)
-# 2017-04-24 The protected hack can unfortunately not be disabled, because
-# Clang does produce linker errors when we disable the hack.
-# But the ugly workaround in Python is replaced by a shiboken change.
-if(WIN32 OR DEFINED AVOID_PROTECTED_HACK)
- message(STATUS "PySide2 will be generated avoiding the protected hack!")
- set(GENERATOR_EXTRA_FLAGS ${GENERATOR_EXTRA_FLAGS} --avoid-protected-hack)
- add_definitions(-DAVOID_PROTECTED_HACK)
-else()
- message(STATUS "PySide will be generated using the protected hack!")
-endif()
+use_protected_as_public_hack()
# Build with Address sanitizer enabled if requested. This may break things, so use at your own risk.
if (SANITIZE_ADDRESS AND NOT MSVC)
- # Currently this does not check that the clang / gcc version used supports Address sanitizer,
- # so once again, use at your own risk.
- add_compile_options("-fsanitize=address" "-g" "-fno-omit-frame-pointer")
- # We need to add the sanitize address option to all linked executables / shared libraries
- # so that proper sanitizer symbols are linked in.
- #
- # Note that when running tests, you may need to set an additional environment variable
- # in set_tests_properties for shiboken2 / pyside tests, or exported in your shell. Address
- # sanitizer will tell you what environment variable needs to be exported. For example:
- # export DYLD_INSERT_LIBRARIES=/Applications/Xcode.app/Contents/Developer/Toolchains/
- # ./XcodeDefault.xctoolchain/usr/lib/clang/8.1.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib
- set(CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_STANDARD_LIBRARIES} -fsanitize=address")
+ setup_sanitize_address()
endif()
+#####################################################################
+# Adding sub-directories to build
+#####################################################################
+
add_subdirectory(libpyside)
find_package(Qt5Designer)
if(Qt5UiTools_FOUND AND Qt5Designer_FOUND)