From a75c34aa5f93f5548ec4b119d2a29f74e37393d8 Mon Sep 17 00:00:00 2001 From: Frederik Hennig <frederik.hennig@fau.de> Date: Mon, 18 Nov 2024 18:58:31 +0100 Subject: [PATCH] Add CMakeLists.txt at project root; find SFG, specify interface target and include dirs there. --- CMakeLists.txt | 5 +++++ cmake/FindPystencilsSfg.cmake | 31 +++++++++++++++++++++++++++++++ include/CMakeLists.txt | 4 +++- include/GenericHbbBoundary.hpp | 2 -- include/GenericHbbBoundary.ipp | 1 - 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 cmake/FindPystencilsSfg.cmake delete mode 100644 include/GenericHbbBoundary.ipp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a60fac1 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,5 @@ + +SET ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake ) +find_package( PystencilsSfg REQUIRED ) + +add_subdirectory( include ) diff --git a/cmake/FindPystencilsSfg.cmake b/cmake/FindPystencilsSfg.cmake new file mode 100644 index 0000000..a5e7b11 --- /dev/null +++ b/cmake/FindPystencilsSfg.cmake @@ -0,0 +1,31 @@ +set( PystencilsSfg_FOUND OFF CACHE BOOL "pystencils source file generator found" ) + +mark_as_advanced( PystencilsSfg_FOUND ) + +find_package( Python COMPONENTS Interpreter REQUIRED ) + +# Try to find pystencils-sfg in the python environment + +execute_process(COMMAND ${Python_EXECUTABLE} -m pystencilssfg version --no-newline + RESULT_VARIABLE _PystencilsSfgFindResult OUTPUT_VARIABLE PystencilsSfg_VERSION ) + +if(${_PystencilsSfgFindResult} EQUAL 0) + set( PystencilsSfg_FOUND ON ) +endif() + +if(DEFINED PystencilsSfg_FIND_REQUIRED) + if(NOT ${PystencilsSfg_FOUND}) + message( FATAL_ERROR "Could not find pystencils-sfg in current Python environment." ) + endif() +endif() + +if(${PystencilsSfg_FOUND}) + message( STATUS "Found pystencils Source File Generator (Version ${PystencilsSfg_VERSION})") + + execute_process(COMMAND ${Python_EXECUTABLE} -m pystencilssfg cmake modulepath --no-newline + OUTPUT_VARIABLE _PystencilsSfg_CMAKE_MODULE_PATH) + + set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_PystencilsSfg_CMAKE_MODULE_PATH}) + include( PystencilsSfg ) +endif() + diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt index b7a8880..4111908 100644 --- a/include/CMakeLists.txt +++ b/include/CMakeLists.txt @@ -2,9 +2,11 @@ add_library( sfg_walberla INTERFACE ) target_sources( sfg_walberla - INTERFACE GenericHbbBoundary.hpp GenericHbbBoundary.ipp + INTERFACE GenericHbbBoundary.hpp ) +target_include_directories( sfg_walberla INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) + target_link_libraries( sfg_walberla INTERFACE diff --git a/include/GenericHbbBoundary.hpp b/include/GenericHbbBoundary.hpp index cf9e954..f68d5e1 100644 --- a/include/GenericHbbBoundary.hpp +++ b/include/GenericHbbBoundary.hpp @@ -124,5 +124,3 @@ void GenericHbbBoundary< Stencil_T >::fillFromFlagField(IBlock& block, ConstBloc } // namespace sfg } // namespace walberla - -#include "GenericHbbBoundary.ipp" diff --git a/include/GenericHbbBoundary.ipp b/include/GenericHbbBoundary.ipp deleted file mode 100644 index 6f70f09..0000000 --- a/include/GenericHbbBoundary.ipp +++ /dev/null @@ -1 +0,0 @@ -#pragma once -- GitLab