okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
4dad59ab3
main
1# cmake/strata_geometry.cmake - choose the model shape the kernels are compiled for (include/strata/core/geometry.hpp). 2# 3# -DSTRATA_GEOMETRY=<name> include/strata/core/geometries/<name>.hpp (default: flash_next) 4# -DSTRATA_GEOMETRY_FILE=<path> any geometry header, for a shape that is not in the tree yet (day one of a new model) 5# 6# With neither set (or STRATA_GEOMETRY=flash_next) nothing is added: no include directory, no definition, so the compile 7# commands are the ones the build had before shapes were selectable. Otherwise a one-line header 8# <build>/strata_geometry/strata/core/geometry_selected.hpp names the chosen file and its directory goes first on the include 9# path (geometry.hpp picks it up with __has_include). Included by CMakeLists.txt, metal/CMakeLists.txt and sycl/CMakeLists.txt 10# before any target is declared. 11set ( STRATA_GEOMETRY "flash_next" CACHE STRING "model shape the kernels are compiled for: a header in include/strata/core/geometries" ) 12set ( STRATA_GEOMETRY_FILE "" CACHE FILEPATH "a geometry header outside the tree (overrides STRATA_GEOMETRY)" ) 13 14get_filename_component ( _strata_geo_root " ${ CMAKE_CURRENT_LIST_DIR } /.." ABSOLUTE ) 15set ( _strata_geo_dir " ${ _strata_geo_root } /include/strata/core/geometries" ) 16file ( GLOB _strata_geo_all RELATIVE " ${ _strata_geo_dir } " " ${ _strata_geo_dir } /*.hpp" ) 17string ( REGEX REPLACE "\.hpp" "" _strata_geo_names " ${ _strata_geo_all } " ) 18list ( SORT _strata_geo_names ) 19 20set ( _strata_geo_header "" ) 21if ( STRATA_GEOMETRY_FILE) 22if ( NOT EXISTS " ${ STRATA_GEOMETRY_FILE } " ) 23message ( FATAL_ERROR "STRATA_GEOMETRY_FILE= ${ STRATA_GEOMETRY_FILE } does not exist" ) 24endif () 25get_filename_component ( _strata_geo_header " ${ STRATA_GEOMETRY_FILE } " ABSOLUTE ) 26get_filename_component ( _strata_geo_label " ${ STRATA_GEOMETRY_FILE } " NAME_WE ) 27elseif ( NOT STRATA_GEOMETRYSTREQUAL "flash_next" ) 28if ( NOT EXISTS " ${ _strata_geo_dir } / ${ STRATA_GEOMETRY } .hpp" ) 29string ( REPLACE ";" ", " _strata_geo_list " ${ _strata_geo_names } " ) 30message ( FATAL_ERROR "STRATA_GEOMETRY= ${ STRATA_GEOMETRY } : no include/strata/core/geometries/ ${ STRATA_GEOMETRY } .hpp (have: ${ _strata_geo_list } )" ) 31endif () 32set ( _strata_geo_header " ${ _strata_geo_dir } / ${ STRATA_GEOMETRY } .hpp" ) 33set ( _strata_geo_label " ${ STRATA_GEOMETRY } " ) 34endif () 35 36if ( _strata_geo_header) 37set ( _strata_geo_out " ${ CMAKE_BINARY_DIR } /strata_geometry" ) 38file ( MAKE_DIRECTORY " ${ _strata_geo_out } /strata/core" ) 39file ( WRITE " ${ _strata_geo_out } /strata/core/geometry_selected.hpp.tmp" 40"// written by cmake/strata_geometry.cmake: the shape this build is compiled for\n#pragma once\n#include \" ${ _strata_geo_header } \"\n" ) 41configure_file ( " ${ _strata_geo_out } /strata/core/geometry_selected.hpp.tmp" " ${ _strata_geo_out } /strata/core/geometry_selected.hpp" COPYONLY ) 42include_directories ( BEFORE " ${ _strata_geo_out } " ) 43set_property ( DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS " ${ _strata_geo_header } " ) 44message ( STATUS "strata: compiled geometry ${ _strata_geo_label } ( ${ _strata_geo_header } )" ) 45else () 46message ( STATUS "strata: compiled geometry flash_next (default)" ) 47endif ()