Commit a9662542 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

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
parent 0062f231
Pipeline #222723 passed with stage
in 7 minutes and 27 seconds
......@@ -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})
......
......@@ -23,6 +23,7 @@ include(FindPackageHandleStandardArgs)
macro(BoostPython_TRY_COMPILE varname)
check_cxx_source_compiles("
#include <boost/python.hpp>
#include <boost/shared_ptr.hpp>
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()
......
......@@ -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);
......
......@@ -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;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment