From 3033b99b5158c12f520ac6026d26c3f77783c56d Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 6 May 2020 16:45:23 +0200 Subject: shiboken: Prepare build system for Qt 6 Introduce a version variable to the CMakeLists. Task-number: PYSIDE-904 Change-Id: Icf823db22025f6d4ac1867ae86e9357fff824daa Reviewed-by: Cristian Maureira-Fredes --- sources/shiboken2/ApiExtractor/CMakeLists.txt | 14 +++++++------- sources/shiboken2/ApiExtractor/tests/CMakeLists.txt | 2 +- sources/shiboken2/CMakeLists.txt | 6 ++++-- sources/shiboken2/generator/CMakeLists.txt | 2 +- sources/shiboken2/tests/CMakeLists.txt | 2 +- sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt | 2 +- sources/shiboken2/tests/test_generator/CMakeLists.txt | 6 +++--- 7 files changed, 18 insertions(+), 16 deletions(-) diff --git a/sources/shiboken2/ApiExtractor/CMakeLists.txt b/sources/shiboken2/ApiExtractor/CMakeLists.txt index 65150eb92..de6bf019f 100644 --- a/sources/shiboken2/ApiExtractor/CMakeLists.txt +++ b/sources/shiboken2/ApiExtractor/CMakeLists.txt @@ -30,8 +30,8 @@ parser/enumvalue.cpp xmlutils.cpp ) -find_package(Qt5XmlPatterns 5.12) -find_package(Qt5Xml 5.12) +find_package(Qt${QT_MAJOR_VERSION}XmlPatterns 5.12) +find_package(Qt${QT_MAJOR_VERSION}Xml 5.12) find_package(LibXml2 2.6.32) find_package(LibXslt 1.1.19) @@ -40,7 +40,7 @@ if (LIBXSLT_FOUND AND LIBXML2_FOUND) set(HAS_LIBXSLT 1) endif() -if(NOT Qt5XmlPatterns_FOUND AND NOT HAS_LIBXSLT) +if(NOT Qt${QT_MAJOR_VERSION}XmlPatterns_FOUND AND NOT HAS_LIBXSLT) set(DISABLE_DOCSTRINGS TRUE) message(WARNING "Documentation will not be built due to missing dependency (no Qt5XmlPatterns found).") @@ -54,7 +54,7 @@ target_include_directories(apiextractor PRIVATE ${CLANG_EXTRA_INCLUDES} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/parser) -target_link_libraries(apiextractor PUBLIC Qt5::Core) +target_link_libraries(apiextractor PUBLIC Qt${QT_MAJOR_VERSION}::Core) target_link_libraries(apiextractor PRIVATE ${CLANG_EXTRA_LIBRARIES}) if (HAS_LIBXSLT) @@ -66,10 +66,10 @@ if (HAS_LIBXSLT) PRIVATE ${LIBXSLT_LIBRARIES} ${LIBXML2_LIBRARIES}) endif() -if (Qt5XmlPatterns_FOUND) +if (Qt${QT_MAJOR_VERSION}XmlPatterns_FOUND) target_compile_definitions(apiextractor PUBLIC HAVE_QTXMLPATTERNS) target_sources(apiextractor PRIVATE xmlutils_qt.cpp) - target_link_libraries(apiextractor PUBLIC Qt5::Xml Qt5::XmlPatterns) + target_link_libraries(apiextractor PUBLIC Qt${QT_MAJOR_VERSION}::Xml Qt${QT_MAJOR_VERSION}::XmlPatterns) endif() if (NOT DISABLE_DOCSTRINGS) @@ -87,7 +87,7 @@ target_compile_definitions(apiextractor PRIVATE CMAKE_CXX_COMPILER="${CMAKE_CXX_ set(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is /lib${LIB_SUFFIX})" FORCE) if (BUILD_TESTS) - find_package(Qt5Test 5.12 REQUIRED) + find_package(Qt${QT_MAJOR_VERSION}Test 5.12 REQUIRED) set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/tests) enable_testing() add_subdirectory(tests) diff --git a/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt b/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt index a36cc17de..97ae0f850 100644 --- a/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt +++ b/sources/shiboken2/ApiExtractor/tests/CMakeLists.txt @@ -15,7 +15,7 @@ macro(declare_test testname) ${CMAKE_CURRENT_BINARY_DIR} ${apiextractor_SOURCE_DIR} ) - target_link_libraries(${testname} PRIVATE apiextractor Qt5::Test) + target_link_libraries(${testname} PRIVATE apiextractor Qt${QT_MAJOR_VERSION}::Test) add_test(${testname} ${testname}) if (INSTALL_TESTS) install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${testname} diff --git a/sources/shiboken2/CMakeLists.txt b/sources/shiboken2/CMakeLists.txt index c1349cae6..3a9f2378b 100644 --- a/sources/shiboken2/CMakeLists.txt +++ b/sources/shiboken2/CMakeLists.txt @@ -18,7 +18,9 @@ option(BUILD_TESTS "Build tests." TRUE) option(USE_PYTHON_VERSION "Use specific python version to build shiboken2." "") option(DISABLE_DOCSTRINGS "Disable documentation extraction." FALSE) -find_package(Qt5 5.12 REQUIRED COMPONENTS Core) +set (QT_MAJOR_VERSION 5) +message(STATUS "Using Qt ${QT_MAJOR_VERSION}") +find_package(Qt${QT_MAJOR_VERSION} 5.12 REQUIRED COMPONENTS Core) if (QUIET_BUILD) set_quiet_build() @@ -208,7 +210,7 @@ add_subdirectory(libshiboken) add_subdirectory(doc) # deps found, compile the generator. -if (Qt5Core_FOUND AND PYTHONINTERP_FOUND) +if (Qt${QT_MAJOR_VERSION}Core_FOUND AND PYTHONINTERP_FOUND) add_subdirectory(generator) add_subdirectory(shibokenmodule) diff --git a/sources/shiboken2/generator/CMakeLists.txt b/sources/shiboken2/generator/CMakeLists.txt index 15b965d9d..e311d400e 100644 --- a/sources/shiboken2/generator/CMakeLists.txt +++ b/sources/shiboken2/generator/CMakeLists.txt @@ -20,7 +20,7 @@ target_include_directories(shiboken2 PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ${apiextractor_SOURCE_DIR} ) -target_link_libraries(shiboken2 apiextractor Qt5::Core) +target_link_libraries(shiboken2 apiextractor Qt${QT_MAJOR_VERSION}::Core) if (NOT DISABLE_DOCSTRINGS) target_sources(shiboken2 PRIVATE qtdoc/qtdocgenerator.cpp) target_compile_definitions(shiboken2 PUBLIC DOCSTRINGS_ENABLED) diff --git a/sources/shiboken2/tests/CMakeLists.txt b/sources/shiboken2/tests/CMakeLists.txt index 375215369..0a9a6f11a 100644 --- a/sources/shiboken2/tests/CMakeLists.txt +++ b/sources/shiboken2/tests/CMakeLists.txt @@ -1,5 +1,5 @@ if(BUILD_TESTS) - find_package(Qt5Test 5.12 REQUIRED) + find_package(Qt${QT_MAJOR_VERSION}Test 5.12 REQUIRED) endif() add_subdirectory(libminimal) diff --git a/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt b/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt index 7c6d60fe2..5c5e2c7b0 100644 --- a/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt +++ b/sources/shiboken2/tests/dumpcodemodel/CMakeLists.txt @@ -3,4 +3,4 @@ add_executable(dumpcodemodel main.cpp) target_include_directories(dumpcodemodel PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${apiextractor_SOURCE_DIR}) -target_link_libraries(dumpcodemodel PUBLIC apiextractor Qt5::Core) +target_link_libraries(dumpcodemodel PUBLIC apiextractor Qt${QT_MAJOR_VERSION}::Core) diff --git a/sources/shiboken2/tests/test_generator/CMakeLists.txt b/sources/shiboken2/tests/test_generator/CMakeLists.txt index 5f5099897..da8cde6f8 100644 --- a/sources/shiboken2/tests/test_generator/CMakeLists.txt +++ b/sources/shiboken2/tests/test_generator/CMakeLists.txt @@ -8,7 +8,7 @@ set_property(TARGET dummy_generator PROPERTY PREFIX "") add_executable(dummygenerator main.cpp) set(DUMMYGENERATOR_EXECUTABLE dummygenerator${generator_SUFFIX}) set_target_properties(dummygenerator PROPERTIES OUTPUT_NAME ${DUMMYGENERATOR_EXECUTABLE}) -target_link_libraries(dummygenerator ${Qt5Core_LIBRARIES}) +target_link_libraries(dummygenerator ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES}) configure_file(dummygentestconfig.h.in "${CMAKE_CURRENT_BINARY_DIR}/dummygentestconfig.h" @ONLY) @@ -50,8 +50,8 @@ macro(declare_test testname) target_link_libraries(${testname} ${QT_QTTEST_LIBRARY} ${QT_QTCORE_LIBRARY} - ${Qt5Test_LIBRARIES} - ${Qt5Core_LIBRARIES} + ${Qt${QT_MAJOR_VERSION}Test_LIBRARIES} + ${Qt${QT_MAJOR_VERSION}Core_LIBRARIES} ) m_add_test(${testname}) endmacro(declare_test testname) -- cgit v1.2.3