@@ -22,9 +22,14 @@ include(AlwaysColourCompilation)
2222include_directories (include )
2323
2424# Find Python
25- find_package (Python3 COMPONENTS Interpreter Development REQUIRED)
25+ find_package (Python3 COMPONENTS Interpreter Development.Module REQUIRED)
2626include_directories (${Python3_INCLUDE_DIRS} )
2727
28+ # Make sure we can install ffbidx into correct location.
29+ if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
30+ set (CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR} /install" CACHE PATH "Install path" FORCE)
31+ endif ()
32+
2833# Dependency fetching
2934set (FETCHCONTENT_QUIET OFF )
3035include (FetchContent)
@@ -48,6 +53,21 @@ FetchContent_Declare(
4853)
4954FetchContent_MakeAvailable(argparse)
5055
56+ # Required for Python module build of ffbidx
57+ set (BUILD_FAST_INDEXER ON CACHE BOOL "" FORCE)
58+ set (PYTHON_MODULE ON CACHE BOOL "" FORCE)
59+ set (PYTHON_MODULE_RPATH ON CACHE BOOL "" FORCE)
60+
61+ # Override install path for ffbidx to site-packages
62+ set (PYTHON_MODULE_PATH ${Python3_SITEARCH} CACHE PATH "Python install path" FORCE)
63+
64+ FetchContent_Declare(
65+ ffbidx
66+ GIT_REPOSITORY https://github.com/paulscherrerinstitute/fast-feedback-indexer.git
67+ GIT_TAG main
68+ )
69+ FetchContent_MakeAvailable(ffbidx)
70+
5171find_package (fmt REQUIRED)
5272find_package (spdlog REQUIRED)
5373
@@ -128,4 +148,13 @@ add_subdirectory(h5read)
128148add_subdirectory (baseline)
129149add_subdirectory (spotfinder)
130150
151+ # define a ssx_index 'executable' that actually just runs the python code (for style consistency)
131152configure_file (${CMAKE_SOURCE_DIR} /scripts/ssx_index ${CMAKE_BINARY_DIR} /bin/ssx_index COPYONLY )
153+
154+ # run 'pip install .' to install the c++ extension for ssx_index
155+ install (CODE "
156+ execute_process(
157+ COMMAND ${Python3_EXECUTABLE} -m pip install .
158+ WORKING_DIRECTORY \" ${CMAKE_SOURCE_DIR} \"
159+ )
160+ " )
0 commit comments