From a96625421c714017019c14ef4337dfafd30c52b9 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Wed, 24 Aug 2022 21:38:15 +0200 Subject: [PATCH] Fix compilation of the Python scripting code 3 changes are needed: * Fix boost/python detection code in cmake We can't detect the header without having detected python first because when linking the app that uses the header we need to link to python, so move the header to the code that we're trying to compile * Fix ObjectImpType constructor, 0 is not a valid KLazyLocalizedString * Set QT_NO_KEYWORDS since the new python has a variable called slots, we need to tell Qt to not use that --- CMakeLists.txt | 2 +- cmake/modules/FindBoostPython.cmake | 13 +++++-------- scripting/newscriptwizard.h | 4 ++-- scripting/python_type.cc | 2 +- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dfbbc098..07f00045 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,7 +50,7 @@ find_package(Qt${QT_MAJOR_VERSION}XmlPatterns ${QT_REQUIRED_VERSION}) ecm_setup_version(${RELEASE_SERVICE_VERSION} VARIABLE_PREFIX KIG VERSION_HEADER kig_version.h) -add_definitions (-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS) +add_definitions (-DQT_USE_FAST_CONCATENATION -DQT_USE_FAST_OPERATOR_PLUS -DQT_NO_KEYWORDS) include_directories (${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) diff --git a/cmake/modules/FindBoostPython.cmake b/cmake/modules/FindBoostPython.cmake index 4881b08b..52196398 100644 --- a/cmake/modules/FindBoostPython.cmake +++ b/cmake/modules/FindBoostPython.cmake @@ -23,6 +23,7 @@ include(FindPackageHandleStandardArgs) macro(BoostPython_TRY_COMPILE varname) check_cxx_source_compiles(" #include +#include const char* greet() { return \"Hello world!\"; } BOOST_PYTHON_MODULE(hello) { boost::python::def(\"greet\", greet); } int main() { return 0; } @@ -39,10 +40,6 @@ if(NOT Boost_PYTHON3_FOUND) endif(NOT Boost_PYTHON3_FOUND) cmake_push_check_state() -set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIRS}) -set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${Boost_PYTHON3_LIBRARY}) - -check_include_file_cxx(boost/shared_ptr.hpp HAVE_BOOST_SHARED_PTR_HPP) # This variable is not checked/used when user provide both # BoostPython_INCLUDE_DIRS and BoostPython_LIBRARIES, by design. @@ -52,15 +49,15 @@ set(BoostPython_COMPILES) # If shared_ptr.hpp or Python library is not available, then there is # no point to do anything. -if(HAVE_BOOST_SHARED_PTR_HPP AND Boost_PYTHON3_FOUND) +if(Boost_PYTHON3_FOUND) if(NOT BoostPython_INCLUDE_DIRS OR NOT BoostPython_LIBRARIES) # First try: check if CMake Python is suitable. set(Python_ADDITIONAL_VERSIONS "3.9;3.8;3.7;3.6;3.5") find_package(PythonLibs 3 QUIET) if(PYTHONLIBS_FOUND) cmake_push_check_state() - set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PYTHON_INCLUDE_DIRS}) - set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PYTHON_LIBRARIES}) + set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PYTHON_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}) + set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${PYTHON_LIBRARIES} ${Boost_PYTHON3_LIBRARY}) BoostPython_TRY_COMPILE(BoostPython_FromCMake) cmake_pop_check_state() @@ -104,7 +101,7 @@ if(HAVE_BOOST_SHARED_PTR_HPP AND Boost_PYTHON3_FOUND) endforeach(_pyver ${PYTHON_VERSIONS}) endif(PKG_CONFIG_FOUND) endif(NOT BoostPython_INCLUDE_DIRS OR NOT BoostPython_LIBRARIES ) -endif(HAVE_BOOST_SHARED_PTR_HPP AND Boost_PYTHON3_FOUND) +endif(Boost_PYTHON3_FOUND) cmake_pop_check_state() diff --git a/scripting/newscriptwizard.h b/scripting/newscriptwizard.h index 2b888f38..86a7e114 100644 --- a/scripting/newscriptwizard.h +++ b/scripting/newscriptwizard.h @@ -34,11 +34,11 @@ public: void setType(ScriptType::Type type); -public slots: +public Q_SLOTS: void accept() override; void reject() override; -protected slots: +protected Q_SLOTS: void slotHelpClicked(); void currentIdChanged(int id); diff --git a/scripting/python_type.cc b/scripting/python_type.cc index 4f7c0af5..0616b7b2 100644 --- a/scripting/python_type.cc +++ b/scripting/python_type.cc @@ -40,7 +40,7 @@ PythonCompiledScriptImp::PythonCompiledScriptImp(const CompiledPythonScript &s) const ObjectImpType *PythonCompiledScriptImp::stype() { - static const ObjectImpType t(BogusImp::stype(), "python-compiled-script-imp", 0, 0, 0, 0, 0, 0, 0, 0, 0); + static const ObjectImpType t(BogusImp::stype(), "python-compiled-script-imp", {}, 0, 0, {}, {}, {}, {}, {}, {}); return &t; } -- GitLab