From ad6d0491df3220f9a3ef3a4fe9456f6a5fa6c256 Mon Sep 17 00:00:00 2001 From: Diane Trout Date: Mon, 22 May 2006 22:29:20 +0000 Subject: [PATCH] make linking python optional I'm getting a crash when running under rosetta which i think might be related to having linked in python. So since I'm not currently using the embedded interpreter, lets not bother linking it in. --- qui/CMakeLists.txt | 10 +++++++--- qui/mussagl.cpp | 19 +++++++++++++------ 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/qui/CMakeLists.txt b/qui/CMakeLists.txt index e134342..580c5af 100644 --- a/qui/CMakeLists.txt +++ b/qui/CMakeLists.txt @@ -78,8 +78,12 @@ TARGET_LINK_LIBRARIES(mussagl ${OPENGL_gl_LIBRARY} ${BOOST_PROGRAM_OPTIONS_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY} - ${BOOST_PYTHON_LIBRARY} - optimized ${PYTHON_LIBRARIES} - debug ${PYTHON_DEBUG_LIBRARIES} + ) +IF(USE_PYTHON) + TARGET_LINK_LIBRARIES(mussagl + ${BOOST_PYTHON_LIBRARY} + optimized ${PYTHON_LIBRARIES} + debug ${PYTHON_DEBUG_LIBRARIES} ) +ENDIF(USE_PYTHON) diff --git a/qui/mussagl.cpp b/qui/mussagl.cpp index 1b6dd95..15b01b2 100644 --- a/qui/mussagl.cpp +++ b/qui/mussagl.cpp @@ -1,5 +1,7 @@ #include +#ifdef USE_PYTHON #include +#endif using namespace boost::filesystem; @@ -22,8 +24,6 @@ int main(int argc, char **argv) QApplication app(argc, argv, opts.useGUI); Q_INIT_RESOURCE(icons); - //PyImport_AppendInittab("mussa", initmussa); - Py_Initialize(); initialize_mussa(opts, argc, argv); @@ -32,7 +32,9 @@ int main(int argc, char **argv) } try { +#ifdef USE_PYTHON if (opts.runAsPythonInterpeter) { + Py_Initialize(); boost::python::object main_module((boost::python::handle<>(boost::python::borrowed(PyImport_AddModule("__main__"))))); boost::python::object main_namespace = main_module.attr("__dict__"); @@ -52,7 +54,9 @@ int main(int argc, char **argv) int result = boost::python::extract(square(3)); std::cout << "C++ has " << result << std::endl; PyRun_InteractiveLoop(stdin, "mussa"); - } else if (opts.useGUI) { + } else +#endif /* USE_PYTHON */ + if (opts.useGUI) { MussaWindow win(opts.analysis); win.show(); app.exec(); @@ -62,13 +66,16 @@ int main(int argc, char **argv) qFatal(e.what()); } catch (boost::filesystem::filesystem_error e) { qFatal(e.what()); - } catch (boost::python::error_already_set e) { + } +#ifdef USE_PYTHON + catch (boost::python::error_already_set e) { PyErr_Print(); - } catch (std::runtime_error e) { + } +#endif /* USE_PYTHON */ + catch (std::runtime_error e) { qFatal(e.what()); } catch (...) { qFatal("unrecognized exception"); } - Py_Finalize(); return 1; } -- 2.30.2