From 704adf47e3795eb5c16358efb851ad1eb46d20e1 Mon Sep 17 00:00:00 2001 From: Christoph Lehmann <christoph.lehmann@ufz.de> Date: Fri, 17 Aug 2018 09:24:50 +0200 Subject: [PATCH] [AppL] improved parsing and restructured CMakeLists --- Applications/ApplicationsLib/CMakeLists.txt | 8 ++++---- Applications/ApplicationsLib/ProjectData.cpp | 10 ++++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Applications/ApplicationsLib/CMakeLists.txt b/Applications/ApplicationsLib/CMakeLists.txt index 64bb9c87174..9d734bcb839 100644 --- a/Applications/ApplicationsLib/CMakeLists.txt +++ b/Applications/ApplicationsLib/CMakeLists.txt @@ -10,10 +10,6 @@ target_link_libraries(ApplicationsLib PRIVATE MathLib MeshLib MeshGeoToolsLib NumLib ) -if(OGS_USE_PYTHON) - target_include_directories(ApplicationsLib PRIVATE ${PYTHON_INCLUDE_DIRS}) -endif() - # Set cpp definitions if the cmake option is enabled for the given process. foreach(process ${ProcessesList}) if(OGS_BUILD_PROCESS_${process}) @@ -26,3 +22,7 @@ endforeach() if(OGS_USE_PCH) cotire(ApplicationsLib) endif() + +if(OGS_USE_PYTHON) + target_link_libraries(ApplicationsLib PRIVATE pybind11::pybind11) +endif() diff --git a/Applications/ApplicationsLib/ProjectData.cpp b/Applications/ApplicationsLib/ProjectData.cpp index de782c13f95..d3d07d07bd6 100644 --- a/Applications/ApplicationsLib/ProjectData.cpp +++ b/Applications/ApplicationsLib/ProjectData.cpp @@ -166,11 +166,11 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, { _mesh_vec = readMeshes(project_config, project_directory); -#ifdef OGS_USE_PYTHON if (auto const python_script = - project_config.getConfigParameterOptional<std::string>( - "python_script")) + //! \ogs_file_param{prj__python_script} + project_config.getConfigParameterOptional<std::string>("python_script")) { +#ifdef OGS_USE_PYTHON namespace py = pybind11; auto const script_path = BaseLib::copyPathToFileName(*python_script, project_directory); @@ -178,8 +178,10 @@ ProjectData::ProjectData(BaseLib::ConfigTree const& project_config, // Evaluate in scope of main module py::object scope = py::module::import("__main__").attr("__dict__"); py::eval_file(script_path, scope); - } +#else + OGS_FATAL("OpenGeoSys has not been built with Python support."); #endif // OGS_USE_PYTHON + } //! \ogs_file_param{prj__curves} parseCurves(project_config.getConfigSubtreeOptional("curves")); -- GitLab