Warning, /jana2/src/python/CMakeLists.txt is written in an unsupported language. File is not indexed.
0001 #
0002 # Top-level CMakeLists.txt for JANA2 python interfaces
0003 #
0004 #
0005 # Note, the python interface requires pybind11. A version
0006 # is bundled with JANA, but the user may also specify an
0007 # external version. The easiest way to get the latests
0008 # version of pybind11 and build JANA against it is:
0009 #
0010 # python -m venv
0011 # source venv/bin/activate
0012 # pip install pybind11
0013 # export pybind11_ROOT=${PWD}/venv/lib/python3.*/site-packages/pybind11
0014 #
0015 # Then, just specify -DUSE_PYTHON=1 to the cmake configure
0016 # command.
0017 #
0018 # This also supports setting the USE_BUNDLED_PYBIND11 cmake
0019 # variable to force using the bundled or external pybind11.
0020 # If USE_BUNDLED_PYBIND11 is not set then an external package
0021 # is first tried using find_package(pybind11) and if that fails
0022 # it falls back to the bundled version.
0023 #
0024 # JANA2 developer's note:
0025 # To get a new version of pybind11 to bundle do something
0026 # like this:
0027 # cd src/python/externals
0028 # wget https://github.com/pybind/pybind11/archive/refs/tags/v2.10.3.tar.gz
0029 # tar xzf v2.10.3.tar.gz
0030 # git rm -r pybind11-2.6.1
0031 # git add pybind11-2.10.3
0032 #
0033
0034 if (${USE_PYTHON})
0035
0036 # Ensure that all components needed for pybind11 are imported.
0037 # In situation when an external package requests python, but
0038 # doesn't request all the required components, the pybind11's
0039 # cmake module will not re-run find_package(Python) again.
0040 # e.g. https://github.com/AIDASoft/podio/blob/f4c9219ddde59b1efc73db3fd9c25139222a7b3c/cmake/podioConfig.cmake.in#L28-L32
0041 find_package(Python 3.6 COMPONENTS Interpreter Development REQUIRED)
0042
0043 set(bundled_pybind11 externals/pybind11-2.10.3)
0044
0045 # If the user has defined USE_BUNDLED_PYBIND11 then
0046 # exclusively try using what they indicated.
0047 #
0048 # If USE_BUNDLED_PYBIND11 is not set, then first
0049 # look in the environment with find_package() and if
0050 # not found there fall back to the bundled version.
0051 if(DEFINED USE_BUNDLED_PYBIND11)
0052 if( ${USE_BUNDLED_PYBIND11} )
0053 add_subdirectory(${bundled_pybind11})
0054 message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIR}")
0055 else()
0056 find_package(pybind11 REQUIRED)
0057 endif()
0058 else()
0059 find_package(pybind11 QUIET)
0060 if(NOT ${pybind11_FOUND})
0061 message(STATUS "External pybind11 not found (set pybind11_ROOT envar. to use external). Using bundled version.")
0062 add_subdirectory(${bundled_pybind11})
0063 message(STATUS "Found pybind11: ${pybind11_INCLUDE_DIR}")
0064 endif()
0065 endif()
0066
0067 # dump_cmake_variables(pybind11)
0068
0069 # Note that the common directory contains source common to
0070 # both the plugins and modules directories. We do not,
0071 # however build it as a library here. Rather, it is
0072 # compiled by each of those separately (so it is compiled
0073 # multiple times).
0074
0075 include_directories(${PROJECT_SOURCE_DIR}/src/plugins) # needed to include janacontrol/janaJSON.h
0076
0077 add_subdirectory(plugins/janapy)
0078 add_subdirectory(modules/jana)
0079
0080 else()
0081 message(STATUS "Skipping python/* because USE_PYTHON=Off")
0082 endif()