@@ -27,6 +27,8 @@ if(UNIX AND NOT APPLE)
2727 ninja-build
2828 git
2929 libopenmpi-dev
30+ libblas-dev
31+ liblapack-dev
3032 screen
3133 nano
3234 RESULT_VARIABLE APT_RESULT
@@ -96,28 +98,26 @@ endif()
9698find_package (Python REQUIRED COMPONENTS Interpreter Development.Module )
9799find_package (pybind11 CONFIG REQUIRED )
98100
99- # --- Basix: use the basix that is installed in this Python env (fenics-basix wheel) ---
100- execute_process (
101- COMMAND "${Python_EXECUTABLE} " -c
102- "import basix, os; print(os.path.join(os.path.dirname(basix.__file__), 'lib'))"
103- OUTPUT_VARIABLE BASIX_PY_LIBDIR
104- OUTPUT_STRIP_TRAILING_WHITESPACE
105- RESULT_VARIABLE _basix_rc
106- )
107- if (NOT _basix_rc EQUAL 0)
108- message (FATAL_ERROR
109- "Basix not importable in this Python env. Install: python -m pip install fenics-basix" )
110- endif ()
101+ # ------------------------------------------------------------
102+ # FEniCS Basix (C++) automatic compilation via FetchContent
103+ # ------------------------------------------------------------
104+ find_package (BLAS REQUIRED )
105+ find_package (LAPACK REQUIRED )
111106
112- find_library (BASIX_LIB
113- NAMES basix
114- PATHS "${BASIX_PY_LIBDIR} "
115- NO_DEFAULT_PATH
116- REQUIRED
107+ include (FetchContent )
108+ FetchContent_Declare (
109+ basix
110+ GIT_REPOSITORY https://github.com/FEniCS/basix.git
111+ GIT_TAG v0.10.0 # Matches the >=0.10.0 requirement in your pyproject.toml
112+ SOURCE_SUBDIR cpp # Tells CMake to look for CMakeLists.txt inside the cpp/ folder
117113)
118114
119- message (STATUS "Basix wheel libdir: ${BASIX_PY_LIBDIR} " )
120- message (STATUS "Basix wheel lib: ${BASIX_LIB} " )
115+ FetchContent_GetProperties (basix)
116+ if (NOT basix_POPULATED)
117+ message (STATUS "Fetching and building FEniCS Basix C++ library from GitHub..." )
118+ FetchContent_Populate (basix)
119+ add_subdirectory (${basix_SOURCE_DIR} /cpp ${basix_BINARY_DIR} )
120+ endif ()
121121
122122# ------------------------------------------------------------
123123# Eigen3 automatic installation (cached and robust)
@@ -168,7 +168,7 @@ foreach(mod ${MODULES})
168168 ${Python_INCLUDE_DIRS}
169169 )
170170
171- target_link_libraries (${mod} PRIVATE " ${BASIX_LIB} " )
171+ target_link_libraries (${mod} PRIVATE basix )
172172
173173 # Apply high-performance compile flags
174174 target_compile_options (${mod} PRIVATE
@@ -207,4 +207,4 @@ message(STATUS " Pybind11 includes: ${pybind11_INCLUDE_DIRS}")
207207message (STATUS " Eigen include dir: ${EIGEN_INCLUDE_DIR} " )
208208message (STATUS " Eigen unsupported: ${EIGEN_UNSUPPORTED_DIR} " )
209209message (STATUS " LTO enabled: ${CMAKE_INTERPROCEDURAL_OPTIMIZATION} " )
210- message (STATUS "------------------------------------------------------------" )
210+ message (STATUS "------------------------------------------------------------" )
0 commit comments