feat(mfem): added mfem into source tree along with patch based build system

MFEM is a dependency of our code and we want to build it with our code for portability, here I add a meson subproject which fetches mfem and builds it. Because of some issues with CMake and meson I apply a patch which manually disables running tests and building examples and miniapps in mfem. This is okay as mfem here is not intenteded to be linked against other programs (though it still can be).
This commit is contained in:
2025-02-12 16:24:13 -05:00
parent 0bf4c40699
commit 112e626760
5 changed files with 74 additions and 0 deletions

View File

@@ -0,0 +1,41 @@
--- subprojects/mfem/CMakeLists.txt 2025-02-12 15:54:52.454728232 -0500
+++ CMakeLists.txt.bak 2025-02-12 16:08:06.654542689 -0500
@@ -765,7 +765,7 @@
if (MFEM_ENABLE_EXAMPLES)
add_subdirectory(examples) #install examples if enabled
else()
- add_subdirectory(examples EXCLUDE_FROM_ALL)
+ # add_subdirectory(examples EXCLUDE_FROM_ALL)
endif()
# Create a target for all miniapps and, optionally, enable it.
@@ -774,7 +774,7 @@
if (MFEM_ENABLE_MINIAPPS)
add_subdirectory(miniapps) #install miniapps if enabled
else()
- add_subdirectory(miniapps EXCLUDE_FROM_ALL)
+ # add_subdirectory(miniapps EXCLUDE_FROM_ALL)
endif()
# Target to build all executables, i.e. everything.
@@ -801,19 +801,7 @@
add_dependencies(${MFEM_EXEC_PREREQUISITES_TARGET_NAME} copy_data)
endif()
-# Add 'check' target - quick test
-set(MFEM_CHECK_TARGET_NAME ${MFEM_CUSTOM_TARGET_PREFIX}check)
-if (NOT MFEM_USE_MPI)
- add_custom_target(${MFEM_CHECK_TARGET_NAME}
- ${CMAKE_CTEST_COMMAND} -R \"^ex1_ser\" -C ${CMAKE_CFG_INTDIR}
- USES_TERMINAL)
- add_dependencies(${MFEM_CHECK_TARGET_NAME} ex1)
-else()
- add_custom_target(${MFEM_CHECK_TARGET_NAME}
- ${CMAKE_CTEST_COMMAND} -R \"^ex1p\" -C ${CMAKE_CFG_INTDIR}
- USES_TERMINAL)
- add_dependencies(${MFEM_CHECK_TARGET_NAME} ex1p)
-endif()
+message(STATUS "MFEM Miniapps and Examples disabled by patch!")
#-------------------------------------------------------------------------------
# Documentation

View File

@@ -0,0 +1,24 @@
cmake = import('cmake')
patchFile = files('disable_mfem_selfcheck.patch')
patch_check = run_command('grep', '-q', 'MFEM_CHECK_TARGET_NAME', 'subprojects/mfem/CMakeLists.txt', check: false)
if patch_check.returncode() == 0
message('Patching MFEM CMakeLists.txt to remove self checks')
run_command('patch', '-p4', '-d', '../../subprojects/mfem', '-i', patchFile[0].full_path(), check: true)
else
message('MFEM CMakeLists.txt already patched')
endif
mfem_cmake_options = cmake.subproject_options()
mfem_cmake_options.add_cmake_defines({
'MFEM_ENABLE_EXAMPLES': 'OFF',
'MFEM_ENABLE_TESTING': 'OFF',
'MFEM_ENABLE_MINIAPPS': 'OFF',
'MFEM_USE_BENCMARK': 'OFF',
})
mfem_sp = cmake.subproject(
'mfem',
options: mfem_cmake_options)
mfem_dep = mfem_sp.dependency('mfem')
add_project_arguments('-I' + meson.current_build_dir() + '/subprojects/mfem/__CMake_build/config', language: 'cpp')