diff --git a/CMakeLists.txt b/CMakeLists.txt index aa9bb912b072678586e80f69e616cd06b8111ed6..2aede962162b7082a31b68574f451f3bdef54507 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,7 @@ endif() #--- Include CMake macros and functions --- include(GetFilenameComponent) # overwrite CMake command +include(BornAgainMacros) include(SearchInstalledSoftware) include(CheckCompiler) if(ZERO_TOLERANCE) diff --git a/Core/Instrument/IntensityDataFunctions.cpp b/Core/Instrument/IntensityDataFunctions.cpp index 9a0c2defcaf3e32b201bb5144858ac6f890c5705..daed770dc9efde136bf74830c6e5166da78ec24b 100644 --- a/Core/Instrument/IntensityDataFunctions.cpp +++ b/Core/Instrument/IntensityDataFunctions.cpp @@ -79,8 +79,8 @@ IntensityDataFunctions::createRearrangedDataSet(const OutputData<double>& data, // creating index mapping std::function<void(std::vector<int>&)> index_mapping; if (n == 2) { - const int end_bin_x = x_axis.size() - 1; - const int end_bin_y = y_axis.size() - 1; + const int end_bin_x = static_cast<int>(x_axis.size()) - 1; + const int end_bin_y = static_cast<int>(y_axis.size()) - 1; index_mapping = [end_bin_x, end_bin_y](std::vector<int>& inds) { inds[0] = end_bin_x - inds[0]; inds[1] = end_bin_y - inds[1]; @@ -91,7 +91,7 @@ IntensityDataFunctions::createRearrangedDataSet(const OutputData<double>& data, index_mapping = [rev_axis_i, end_bin](std::vector<int>& inds) { const int tmp_index = inds[rev_axis_i]; inds[rev_axis_i] = inds[rev_axis_i ^ 1]; - inds[rev_axis_i ^ 1] = end_bin - tmp_index; + inds[rev_axis_i ^ 1] = static_cast<int>(end_bin) - tmp_index; }; } @@ -177,11 +177,11 @@ double IntensityDataFunctions::coordinateFromBinf(double value, const IAxis& axi if(index < 0) { Bin1D bin = axis.getBin(0); result = bin.m_lower + value*bin.getBinSize(); - } else if(index >= (int)axis.size()) { + } else if(index >= static_cast<int>(axis.size())) { Bin1D bin = axis.getBin(axis.size()-1); result = bin.m_upper + (value-axis.size())*bin.getBinSize(); } else { - Bin1D bin = axis.getBin(index); + Bin1D bin = axis.getBin(static_cast<size_t>(index)); result = bin.m_lower + (value - static_cast<double>(index))*bin.getBinSize(); } diff --git a/Core/StandardSamples/LatticeBuilder.cpp b/Core/StandardSamples/LatticeBuilder.cpp index ef4f916baa99d4f27a0dcbe6d45f628699c4ce94..78a3458c543a09257146faaf967450fa7aa4f10d 100644 --- a/Core/StandardSamples/LatticeBuilder.cpp +++ b/Core/StandardSamples/LatticeBuilder.cpp @@ -46,7 +46,7 @@ MultiLayer* Lattice1DBuilder::buildSample() const Layer substrate_layer(substrate_material); InterferenceFunction1DLattice interference_function(m_length, m_xi); - FTDecayFunction1DCauchy pdf(1000.0*Units::nanometer); + FTDecayFunction1DCauchy pdf(m_corr_length); interference_function.setDecayFunction(pdf); FormFactorCylinder ff_cylinder(m_cylinder_radius, m_cylinder_height); diff --git a/Core/Tools/PyEmbeddedUtils.cpp b/Core/Tools/PyEmbeddedUtils.cpp index cf81809a7a30c1dd41d04e551adb7d1320cecfd7..b552cb30fac38322f7dc4f1d424fc6c2fd77e48b 100644 --- a/Core/Tools/PyEmbeddedUtils.cpp +++ b/Core/Tools/PyEmbeddedUtils.cpp @@ -92,9 +92,9 @@ void PyEmbeddedUtils::import_bornagain(const std::string& path) // Stores signal handler before numpy's mess it up. // This is to make ctrl-c working from terminal. - PyOS_sighandler_t sighandler; #ifndef _WIN32 - sighandler = PyOS_getsig(SIGINT); + PyOS_sighandler_t sighandler; + sighandler = PyOS_getsig(SIGINT); #endif PyObject* pmod = PyImport_ImportModule("bornagain"); if (!pmod) { @@ -104,7 +104,7 @@ void PyEmbeddedUtils::import_bornagain(const std::string& path) // restores single handler to make ctr-c alive. #ifndef _WIN32 - PyOS_setsig(SIGINT, sighandler); + PyOS_setsig(SIGINT, sighandler); #endif } diff --git a/Core/Tools/SysUtils.h b/Core/Tools/SysUtils.h index 03632071085d18ccb647a3d4d69d679e8054b5dd..fa1eff5cad9381d4bf6d7c7ebe3f32253c319046 100644 --- a/Core/Tools/SysUtils.h +++ b/Core/Tools/SysUtils.h @@ -17,7 +17,6 @@ #define SYSUTILS_H #include "WinDllMacros.h" -#include "StringUtils.h" #include <string> //! Utility functions getCurrentDateAndTime, enableFloatingPointExceptions. diff --git a/GUI/coregui/Models/FitParameterHelper.cpp b/GUI/coregui/Models/FitParameterHelper.cpp index 5c5801baabd803eecb503b498b282e1236a8e437..a1c79188d33c27f7572c3dd8b0e266426270768a 100644 --- a/GUI/coregui/Models/FitParameterHelper.cpp +++ b/GUI/coregui/Models/FitParameterHelper.cpp @@ -124,7 +124,7 @@ ParameterItem *FitParameterHelper::getParameterItem(FitParameterContainerItem *c while (cur && cur->modelType() != Constants::JobItemType) { cur = cur->parent(); } - Q_ASSERT(cur->modelType() == Constants::JobItemType); + Q_ASSERT(cur && cur->modelType() == Constants::JobItemType); JobItem *jobItem = dynamic_cast<JobItem *>(cur); Q_ASSERT(jobItem); return dynamic_cast<ParameterItem *>( diff --git a/GUI/coregui/Models/GUIObjectBuilder.cpp b/GUI/coregui/Models/GUIObjectBuilder.cpp index b40b0652dc38056ea629c0e4c6bc8f0cad04d718..b76898e67463141fd37e4f0ca897dee168444441 100644 --- a/GUI/coregui/Models/GUIObjectBuilder.cpp +++ b/GUI/coregui/Models/GUIObjectBuilder.cpp @@ -179,7 +179,6 @@ void GUIObjectBuilder::visit(const Layer* p_sample) auto p_multilayer = dynamic_cast<const MultiLayer*>(m_itemToSample[p_parent]); Q_ASSERT(p_multilayer); size_t layer_index = p_multilayer->indexOfLayer(p_sample); - Q_ASSERT(layer_index != -1u); const LayerInterface* p_interface = p_multilayer->layerTopInterface(layer_index); SessionItem* p_layer_item = m_sampleModel->insertNewItem( diff --git a/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp b/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp index 83501f2c6c43b064505e37fe84eaff06677fcd8c..ea4ea6a720560ee32ad05bd888a65c02f44b5542 100644 --- a/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp +++ b/GUI/coregui/Views/InfoWidgets/ComboSelectorDialog.cpp @@ -35,13 +35,13 @@ ComboSelectorDialog::ComboSelectorDialog(QWidget* parent) setAutoFillBackground(true); setPalette(palette); - setFixedSize(550, 250); + setFixedSize(500, 250); setWindowTitle("Please make a selection"); setWindowFlags( Qt::Dialog ); auto topLayout = new QHBoxLayout; - topLayout->addLayout(createLogoLayout()); - topLayout->addLayout(createInfoLayout()); + topLayout->addLayout(createLogoLayout(), 0); + topLayout->addLayout(createInfoLayout(), 1); auto mainLayout = new QVBoxLayout; mainLayout->addLayout(topLayout); @@ -86,7 +86,7 @@ QBoxLayout* ComboSelectorDialog::createLogoLayout() result->addWidget(label); result->addStretch(1); - result->setContentsMargins(5, 5, 5, 5); + result->setContentsMargins(0, 5, 0, 5); return result; } diff --git a/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp b/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp index 842238777bcc303f4af2e065cdd0e175d942b2a7..ba7ec46ae7032b30ba538ce6ec0dc24053d03f3d 100644 --- a/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp +++ b/GUI/coregui/Views/InfoWidgets/PythonSyntaxHighlighter.cpp @@ -190,9 +190,8 @@ void PythonSyntaxHighlighter::highlightBlock(const QString &text) setCurrentBlockState(0); // Do multi-line strings - bool isInMultilne = matchMultiline(text, triSingleQuote, 1, basicStyles.value("string2")); - if (!isInMultilne) - isInMultilne = matchMultiline(text, triDoubleQuote, 2, basicStyles.value("string2")); + if(!matchMultiline(text, triSingleQuote, 1, basicStyles.value("string2"))) + matchMultiline(text, triDoubleQuote, 2, basicStyles.value("string2")); } bool PythonSyntaxHighlighter::matchMultiline(const QString &text, const QRegExp &delimiter, diff --git a/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorWidget.cpp b/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorWidget.cpp index 142be979b6033ba39fb738827ecbd8432362d3a8..4696ef5d119f79ac415be5ac906731aced7f9e6a 100644 --- a/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorWidget.cpp +++ b/GUI/coregui/Views/InstrumentWidgets/RectangularDetectorWidget.cpp @@ -106,10 +106,10 @@ void RectangularDetectorWidget::setColumnResizer(ColumnResizer* columnResizer) if (m_columnResizer) { connect(m_columnResizer, SIGNAL(destroyed(QObject*)), this, SLOT(onColumnResizerDestroyed(QObject*))); + m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 0); + m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 1); + m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } - m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 0); - m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 1); - m_columnResizer->addWidgetsFromGridLayout(m_gridLayout, 2); } //! create various editors to hold RectangularDetector properties diff --git a/GUI/coregui/Views/widgetbox/images/ff_Mesocrystal_32.png b/GUI/coregui/Views/widgetbox/images/ff_Mesocrystal_32.png new file mode 100644 index 0000000000000000000000000000000000000000..4f76e1c6255d8c652dee688835ea932c929ed26a Binary files /dev/null and b/GUI/coregui/Views/widgetbox/images/ff_Mesocrystal_32.png differ diff --git a/GUI/coregui/Views/widgetbox/widgetbox.qrc b/GUI/coregui/Views/widgetbox/widgetbox.qrc index 63f4960080582b86290ed51cdfcc2d2293fc8c36..848b11fc1f23c61d21ba202020a1b637089f66ca 100644 --- a/GUI/coregui/Views/widgetbox/widgetbox.qrc +++ b/GUI/coregui/Views/widgetbox/widgetbox.qrc @@ -14,6 +14,7 @@ <file>images/ff_FullSpheroid_32.png</file> <file>images/ff_HemiEllipsoid_32.png</file> <file>images/ff_Icosahedron_32.png</file> + <file>images/ff_Mesocrystal_32.png</file> <file>images/ff_Prism3_32.png</file> <file>images/ff_Prism6_32.png</file> <file>images/ff_Pyramid_32.png</file> diff --git a/GUI/coregui/Views/widgetbox/widgetbox.xml b/GUI/coregui/Views/widgetbox/widgetbox.xml index a1cd1dcb8346378671c713f3edc67fef73d7c240..64bff146b2afab26dba64d3815d6c9f87b88d0ed 100644 --- a/GUI/coregui/Views/widgetbox/widgetbox.xml +++ b/GUI/coregui/Views/widgetbox/widgetbox.xml @@ -280,7 +280,7 @@ </widget> </categoryentry> - <categoryentry name="Meso Crystal" icon="images/ParticleComposition.png"> + <categoryentry name="Meso Crystal" icon="images/ff_Mesocrystal_32.png"> <widget class="MesoCrystal"> <property name="objectName"> <string notr="true">somestring</string> diff --git a/GUI/coregui/mainwindow/PyImportAssistant.cpp b/GUI/coregui/mainwindow/PyImportAssistant.cpp index 72cf26cd8a3e229a37c21d0f87bc97769cdd3357..01aa966d2191cf055deee509e1fa4bd3bb78194c 100644 --- a/GUI/coregui/mainwindow/PyImportAssistant.cpp +++ b/GUI/coregui/mainwindow/PyImportAssistant.cpp @@ -222,15 +222,17 @@ void PyImportAssistant::populateModels(const MultiLayer& multilayer, const QStri GUIObjectBuilder guiBuilder; guiBuilder.populateSampleModel(m_mainWindow->sampleModel(), multilayer, name); + QString message("Seems that import was successfull.\n\n" + "Check SampleView for new sample and material editor for new materials."); + GUIHelpers::information(m_mainWindow, "PyImport", message); + } catch(const std::exception& ex) { - QString message("Exception thrown while trying to build GUI models.\n\n"); - message += QString::fromStdString(std::string(ex.what())); - GUIHelpers::warning(m_mainWindow, "GUIObjectBuilder failure", message); + QString message("Exception thrown while trying to build GUI models.\n" + "GUI models might be in unconsistent state.\n\n"); + QString details = QString::fromStdString(std::string(ex.what())); + DetailedMessageBox warning(m_mainWindow, "GUIObjectBuilder failure", message, details); + warning.exec(); } - QString message("Seems that import was successfull.\n\n" - "Check SampleView for new sample and material editor for new materials."); - - GUIHelpers::information(m_mainWindow, "PyImport", message); } diff --git a/ThirdParty/GUI/qcustomplot/qcustomplot.h b/ThirdParty/GUI/qcustomplot/qcustomplot.h index 6d442a7477d1576585f153c1c7369e9aa0d428b9..fc82a24dc60fbd40e6523413317645ba7419cea9 100644 --- a/ThirdParty/GUI/qcustomplot/qcustomplot.h +++ b/ThirdParty/GUI/qcustomplot/qcustomplot.h @@ -3329,7 +3329,7 @@ public: void setSelectionDecorator(QCPSelectionDecorator *decorator); // introduced virtual methods: - virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const = 0; + virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details=0) const override = 0; virtual QCPPlottableInterface1D *interface1D() { return 0; } virtual QCPRange getKeyRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth) const = 0; virtual QCPRange getValueRange(bool &foundRange, QCP::SignDomain inSignDomain=QCP::sdBoth, const QCPRange &inKeyRange=QCPRange()) const = 0; diff --git a/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt b/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt index 990c2b0a7308ee49beef064dc60a003e8189530f..8e48ceaf884fa8de662c0d1b3946acb9c8338c6c 100644 --- a/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt +++ b/ThirdParty/GUI/qt-manhattan-style/CMakeLists.txt @@ -14,7 +14,7 @@ set(SRCS stylehelper.cpp styledbar.cpp styleanimator.cpp - stringutils.cpp + settingsutils.cpp qtcolorbutton.cpp qtcassert.cpp progressbar.cpp @@ -30,7 +30,7 @@ set(SRCS stylehelper.h styledbar.h styleanimator.h - stringutils.h + settingsutils.h qtcolorbutton.h qtcolorbutton_p.h qtcassert.h diff --git a/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp b/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp index 7bb7d611008dc68c74c2cf7e01d3082d7674e1cb..4d7bd72b633c5fcf88edce4afe4e03f634f12fac 100644 --- a/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp +++ b/ThirdParty/GUI/qt-manhattan-style/fancyactionbar.cpp @@ -31,7 +31,7 @@ #include "coreconstants.h" #include "stylehelper.h" -#include "stringutils.h" +#include "settingsutils.h" #include <QHBoxLayout> diff --git a/ThirdParty/GUI/qt-manhattan-style/stringutils.cpp b/ThirdParty/GUI/qt-manhattan-style/settingsutils.cpp similarity index 99% rename from ThirdParty/GUI/qt-manhattan-style/stringutils.cpp rename to ThirdParty/GUI/qt-manhattan-style/settingsutils.cpp index 83b652439ea4e8e78f4aa9a5db661ec7d3bd3f5c..bfbeb751e127658ad5383b0f954d42890627271f 100644 --- a/ThirdParty/GUI/qt-manhattan-style/stringutils.cpp +++ b/ThirdParty/GUI/qt-manhattan-style/settingsutils.cpp @@ -27,7 +27,7 @@ ** ****************************************************************************/ -#include "stringutils.h" +#include "settingsutils.h" #include <QString> #include <QStringList> diff --git a/ThirdParty/GUI/qt-manhattan-style/stringutils.h b/ThirdParty/GUI/qt-manhattan-style/settingsutils.h similarity index 100% rename from ThirdParty/GUI/qt-manhattan-style/stringutils.h rename to ThirdParty/GUI/qt-manhattan-style/settingsutils.h diff --git a/ThirdParty/GUI/qtpropertybrowser/qttreepropertybrowser.cpp b/ThirdParty/GUI/qtpropertybrowser/qttreepropertybrowser.cpp index d13511a5a6b925818fb2fb8e18207166528b3227..8db4c3d304b97f4a48434760f524f2307781b029 100644 --- a/ThirdParty/GUI/qtpropertybrowser/qttreepropertybrowser.cpp +++ b/ThirdParty/GUI/qtpropertybrowser/qttreepropertybrowser.cpp @@ -344,7 +344,7 @@ void QtPropertyEditorDelegate::paint(QPainter *painter, const QStyleOptionViewIt opt.palette.setColor(QPalette::Text, opt.palette.color(QPalette::BrightText)); } else { c = m_editorPrivate->calculatedBackgroundColor(m_editorPrivate->indexToBrowserItem(index)); - if (c.isValid() && (opt.features & QStyleOptionViewItemV2::Alternate)) + if (c.isValid() && (opt.features & QStyleOptionViewItem::Alternate)) c = c.lighter(112); } if (c.isValid()) diff --git a/cmake/bornagain/modules/BornAgainMacros.cmake b/cmake/bornagain/modules/BornAgainMacros.cmake new file mode 100644 index 0000000000000000000000000000000000000000..255c790ec92d72de18bab8ee650163deec34ae41 --- /dev/null +++ b/cmake/bornagain/modules/BornAgainMacros.cmake @@ -0,0 +1,116 @@ + +function(ValidatePythonInstallation) + message(STATUS "--> Validating Python installation corresponding to the interpreter ${PYTHON_EXECUTABLE}") + + execute_process(COMMAND "${PYTHON_EXECUTABLE}" "-c" + "from distutils import sysconfig as s;import sys;import struct; +print('.'.join(str(v) for v in sys.version_info)); +print(sys.prefix); +print(s.get_python_inc(plat_specific=True)); +print(s.get_python_lib(plat_specific=True)); +print(s.get_config_var('SO')); +print(hasattr(sys, 'gettotalrefcount')+0); +print(struct.calcsize('@P')); +print(s.get_config_var('LDVERSION') or s.get_config_var('VERSION')); +" + RESULT_VARIABLE _PYTHON_SUCCESS + OUTPUT_VARIABLE _PYTHON_VALUES + ERROR_VARIABLE _PYTHON_ERROR_VALUE + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(NOT _PYTHON_SUCCESS MATCHES 0) + set(ALT_PYTHONLIBS_FOUND FALSE) + return() + endif() + + # Convert the process output into a list + string(REGEX REPLACE ";" "\\\\;" _PYTHON_VALUES ${_PYTHON_VALUES}) + string(REGEX REPLACE "\n" ";" _PYTHON_VALUES ${_PYTHON_VALUES}) + list(GET _PYTHON_VALUES 0 _PYTHON_VERSION_LIST) + list(GET _PYTHON_VALUES 1 ALT_PYTHON_PREFIX) + list(GET _PYTHON_VALUES 2 ALT_PYTHON_INCLUDE_DIRS) + list(GET _PYTHON_VALUES 3 ALT_PYTHON_SITE_PACKAGES) + list(GET _PYTHON_VALUES 4 ALT_PYTHON_MODULE_EXTENSION) + list(GET _PYTHON_VALUES 5 ALT_PYTHON_IS_DEBUG) + list(GET _PYTHON_VALUES 6 ALT_PYTHON_SIZEOF_VOID_P) + list(GET _PYTHON_VALUES 7 ALT_PYTHON_LIBRARY_SUFFIX) + + string(REGEX REPLACE "\\." ";" _PYTHON_VERSION_LIST ${_PYTHON_VERSION_LIST}) + list(GET _PYTHON_VERSION_LIST 0 ALT_PYTHON_VERSION_MAJOR) + list(GET _PYTHON_VERSION_LIST 1 ALT_PYTHON_VERSION_MINOR) + list(GET _PYTHON_VERSION_LIST 2 ALT_PYTHON_VERSION_PATCH) + + set(ALT_PYTHON_VERSION_STRING ${ALT_PYTHON_VERSION_MAJOR}.${ALT_PYTHON_VERSION_MINOR}.${ALT_PYTHON_VERSION_PATCH}) + + message(STATUS "----> ALT_PYTHON_PREFIX:${ALT_PYTHON_PREFIX}") + message(STATUS "----> ALT_PYTHON_INCLUDE_DIRS:${ALT_PYTHON_INCLUDE_DIRS}") + message(STATUS "----> ALT_PYTHON_SITE_PACKAGES:${ALT_PYTHON_SITE_PACKAGES}") + message(STATUS "----> ALT_PYTHON_MODULE_EXTENSION:${ALT_PYTHON_MODULE_EXTENSION}") + message(STATUS "----> ALT_PYTHON_IS_DEBUG:${ALT_PYTHON_IS_DEBUG}") + message(STATUS "----> ALT_PYTHON_SIZEOF_VOID_P:${ALT_PYTHON_SIZEOF_VOID_P} ") + message(STATUS "----> ALT_PYTHON_LIBRARY_SUFFIX:${ALT_PYTHON_LIBRARY_SUFFIX}") + + if(NOT PYTHON_INCLUDE_DIRS STREQUAL ALT_PYTHON_INCLUDE_DIRS) + message(STATUS "----> Python interpreter reports include directory (see ALT_PYTHON_INCLUDE_DIRS) which differs from what we have learned before (see PYTHON_INCLUDE_DIRS).") + message(STATUS "----> Setting PYTHON_INCLUDE_DIRS=${ALT_PYTHON_INCLUDE_DIRS}") + set(PYTHON_INCLUDE_DIRS ${ALT_PYTHON_INCLUDE_DIRS} PARENT_SCOPE) + endif() + + if(PYTHONLIBS_FOUND) + if(NOT PYTHON_VERSION_STRING STREQUAL PYTHONLIBS_VERSION_STRING) + message(STATUS "---> PYTHON_VERSION_STRING ${PYTHON_VERSION_STRING} differs from PYTHONLIBS_VERSION_STRING ${PYTHONLIBS_VERSION_STRING}") + if(APPLE) + set(ALT_PYTHON_LIBRARIES "${ALT_PYTHON_PREFIX}/lib/libpython${ALT_PYTHON_LIBRARY_SUFFIX}.dylib") + message(STATUS "----> Will use library from ${ALT_PYTHON_LIBRARIES} instead") + set(PYTHON_LIBRARIES ${ALT_PYTHON_LIBRARIES} PARENT_SCOPE) + else() + message(STATUS "---> There is inconcistency between versions of interpreter and library.") + endif() + + endif() + endif() + + if(NOT PYTHONLIBS_FOUND) + if(APPLE) + message(STATUS "----> There was a complain that no suitable Python library has been found. This is APPLE of course... well, let's see... ") + set(ALT_PYTHON_LIBRARIES "${ALT_PYTHON_PREFIX}/lib/libpython${ALT_PYTHON_LIBRARY_SUFFIX}.dylib") + if(${PYTHON_LIBRARIES} STREQUAL ${ALT_PYTHON_LIBRARIES}) + message(STATUS "----> ... we found that the library is OK. Ignoring complain.") + set(PYTHONLIBS_FOUND TRUE) + else() + if(EXISTS ${ALT_PYTHON_LIBRARIES}) + message(STATUS "----> ... there is another one which seems to be OK ${ALT_PYTHON_LIBRARIES}.") + set(PYTHONLIBS_FOUND TRUE) + set(PYTHON_LIBRARIES ${ALT_PYTHON_LIBRARIES} PARENT_SCOPE) + endif() + endif() + endif() + endif() + + if(PYTHONLIBS_FOUND) + if(NOT WIN32) + GET_FILENAME_COMPONENT(PyLibExtension ${PYTHON_LIBRARIES} EXT) + if(${PyLibExtension} STREQUAL ".a") + find_package( Threads ) + set(syslibs "-lm -ldl -lutil ${CMAKE_THREAD_LIBS_INIT} -rdynamic") + message(STATUS "----> Static python library detected, adding ${syslibs}") + set(PYTHON_LIBRARIES "${syslibs} ${PYTHON_LIBRARIES}" PARENT_SCOPE) + endif() + endif() + if(BUILD_DEBIAN) + set(PYTHON_SITE_PACKAGES ${ALT_PYTHON_SITE_PACKAGES} PARENT_SCOPE) + endif() + endif() + + if(PYTHONLIBS_FOUND) + set(PYTHONLIBS_FOUND TRUE PARENT_SCOPE) + message(STATUS "--> Python seems to be OK.") + else() + message(FATAL_ERROR "No appropriate Python library has been found. Sorry.") + endif() + +# set(ALT_PYTHONLIBS_FOUND ${ALT_PYTHONLIBS_FOUND} PARENT_SCOPE) +# set(ALT_PYTHON_VERSION_STRING ${ALT_PYTHON_VERSION_STRING} PARENT_SCOPE) +# set(ALT_PYTHON_INCLUDE_DIRS ${ALT_PYTHON_INCLUDE_DIRS} PARENT_SCOPE) +endfunction() diff --git a/cmake/bornagain/modules/SearchInstalledSoftware.cmake b/cmake/bornagain/modules/SearchInstalledSoftware.cmake index 6d156e2a2f84caa4fed5f0015aed1622c9b293d1..00c99456c213e6e1816819ff14d0829540ec4679 100644 --- a/cmake/bornagain/modules/SearchInstalledSoftware.cmake +++ b/cmake/bornagain/modules/SearchInstalledSoftware.cmake @@ -58,6 +58,11 @@ if(BORNAGAIN_PYTHON OR BORNAGAIN_GUI) message(FATAL_ERROR "No Python library has been found") endif() message(STATUS "Found Python libraries version ${PYTHONLIBS_VERSION_STRING} at ${PYTHON_LIBRARIES}; includes at ${PYTHON_INCLUDE_DIRS}") + + if(NOT WIN32) + ValidatePythonInstallation() + endif() + find_package(Numpy REQUIRED) find_package(PyYaml REQUIRED) endif() diff --git a/cmake/generic/modules/FindNumpy.cmake b/cmake/generic/modules/FindNumpy.cmake index 561d056ba590547f0b6b26d628b6b00d278db24a..f17b75c44158a6fa393598e3cc376e1288792ff8 100644 --- a/cmake/generic/modules/FindNumpy.cmake +++ b/cmake/generic/modules/FindNumpy.cmake @@ -26,7 +26,6 @@ else() message(STATUS "Can't find numpy/arrayobject.h, please install python-numpy-devel package") else() set (NUMPY_FOUND TRUE) - set (NUMPY_INCLUDE_DIR ${NUMPY_INCLUDE_DIR} CACHE STRING "Numpy include path") execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.__version__)" OUTPUT_VARIABLE numpy_version_number RESULT_VARIABLE numpy_return_value @@ -45,6 +44,9 @@ else() endif() endif() +if(WIN32) + STRING(REGEX REPLACE "\\\\" "/" NUMPY_INCLUDE_DIR ${NUMPY_INCLUDE_DIR}) +endif() MARK_AS_ADVANCED (NUMPY_INCLUDE_DIR) MARK_AS_ADVANCED (NUMPY_VERSION_STRING)