Skip to content

Feature/auto fetch deps#128

Draft
marjohma wants to merge 18 commits into
mainfrom
feature/auto-fetch-deps
Draft

Feature/auto fetch deps#128
marjohma wants to merge 18 commits into
mainfrom
feature/auto-fetch-deps

Conversation

@marjohma

@marjohma marjohma commented Apr 2, 2026

Copy link
Copy Markdown
Member

Summary

  • Layered dependency discovery on macOS: the build system no longer requires Homebrew. It tries standard CMake discovery first (respects PATH, CMAKE_PREFIX_PATH, user-provided variables), then falls back to Homebrew if available.
  • Nix support: adds flake.nix with a dev shell providing all build dependencies. Nix environments are detected automatically (NIX_CC / IN_NIX_SHELL) to avoid Homebrew/Nix toolchain conflicts.
  • Compiler detection: explicitly selects gfortran (project uses gfortran-specific flags), Homebrew LLVM clang for C/C++ (Apple Clang lacks OpenMP), with PATH fallback for non-Homebrew setups.
  • Dependency fixes: skip MPI-enabled system HDF5 (build from source instead), find OpenBLAS for BLAS/LAPACK, locate libomp before find_package(OpenMP) so gfortran test compiles can link.
  • Cleanup: remove SuperLU (unused), remove Doxygen FATAL_ERROR, remove duplicate OpenMP detection from QL-Balance, try system GSL before building from source.

Changes by area

Build system (CMakeLists.txt)

  • Compiler cascade: Homebrew LLVM then PATH (C/C++), gfortran from PATH (Fortran)
  • Nix detection: skip Homebrew paths when in Nix shell
  • OpenMP: locate libomp before find_package(OpenMP) for linker test
  • OpenBLAS: add to CMAKE_LIBRARY_PATH, set BLA_VENDOR=OpenBLAS

CMake modules (cmake/)

  • FetchHDF5.cmake: detect MPI-enabled system HDF5 and skip it
  • FetchGSL.cmake: try find_package(GSL) before building from source
  • FetchLapack.cmake: remove REQUIRED, allow fallback to source build

Subprojects

  • QL-Balance/CMakeLists.txt: remove duplicate Homebrew libomp detection, inherit from parent
  • KiLCA/CMakeLists.txt: remove Doxygen FATAL_ERROR
  • KIM: remove unused SuperLU dependency

Nix

Docs

  • README.md: platform-specific build instructions (macOS, Nix, Linux)
  • Design spec and implementation plan in docs/superpowers/

Test plan

  • CMake configure succeeds on macOS with Homebrew
  • CMake configure succeeds in Nix dev shell
  • Compiler detection picks correct compilers (LLVM clang, gfortran)
  • OpenMP found for both C and Fortran
  • HDF5 MPI detection skips Homebrew parallel-enabled HDF5
  • BLAS/LAPACK found via OpenBLAS
  • Full build on macOS with Homebrew
  • Full build in Nix dev shell (blocked by Nix build on macOS: C++ header ordering conflict with stdenv #127)
  • Full build on Linux

marjohma and others added 18 commits March 31, 2026 09:21
- Add cmake/FetchHDF5.cmake: downloads and builds HDF5 1.14.x from
  source when not found on the system (serial, with Fortran and HL)
- Centralize HDF5 in cmake/Dependencies.cmake, remove duplicate
  find_package(HDF5) from KIM and QL-Balance CMakeLists
- Makefile: detect Ninja, fall back to Unix Makefiles with warning
- Remove MPI from requirements (not used by KAMEL)
- Update README dependency sections

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
SuperLU was never used at runtime — sparse_solve_method is hardcoded
to 3 (SuiteSparse). Remove:
- SuperLU C source files (c_fortran_dgssv.c, c_fortran_zgssv.c)
- SuperLU subroutine definitions from sparse_mod.f90
- find_package(SuperLU) from KIM CMakeLists
- FindSuperLU.cmake module
- SuperLU from README optional dependencies

Method=1 branches replaced with error stop for safety.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Support building without Homebrew by trying standard CMake discovery
first (PATH, CMAKE_PREFIX_PATH, user variables) before falling back
to Homebrew.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…t from parent

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Apple Clang (found on PATH) lacks OpenMP support, so search Homebrew
LLVM first, then fall back to PATH for Nix/manual installs.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
flang -fopenmp links against libomp but cannot find it without an
explicit -L path. Locate libomp before find_package(OpenMP) so the
test compile can link. Cascade: user-provided LIBOMP_PREFIX, then
standard library paths (Nix, manual), then Homebrew fallback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Homebrew HDF5 is built with ENABLE_PARALLEL=ON, which requires MPI.
Since KAMEL does not use MPI, detect this and build HDF5 from source.
Also remove pre-project HDF5 detection that caused enable_language
warnings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Explicitly prefer gfortran over flang since the project uses
gfortran-specific flags (-fbacktrace, -fcheck=all, etc.).
On macOS, find OpenBLAS for BLAS/LAPACK since flang cannot use
-framework Accelerate. Also skip MPI-enabled system HDF5.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The KiLCA Doxygen documentation is not maintained. Remove the
FATAL_ERROR that blocked builds without Doxygen installed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Provides a devShell with all build dependencies (compilers, OpenBLAS,
HDF5, GSL, NetCDF, libomp, etc.) and a package derivation. Uses the
same HDF5 merge workaround as libneo to fix Nix store path issues.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add flake.nix with devShell providing all build dependencies
- Detect Nix environment (NIX_CC/IN_NIX_SHELL) and skip Homebrew
  compiler detection to avoid toolchain conflicts
- FetchGSL: try system GSL before building from source
- Add gmp, mpfr, suitesparse to Nix dependencies
- Fix HDF5 merged derivation to include mod/shared symlink

Known issue: Nix on macOS has C++ header ordering conflicts
between libcxx and the macOS SDK that need stdenv-level fixes.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Document the layered dependency discovery, Nix flake support,
and platform-specific build requirements.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
HDF5 1.14.6 source build fails with LLVM clang 21 (FLT16_MAX).
Instead of always skipping parallel-enabled system HDF5, check if
MPI is available first. If MPI is found, use the system HDF5.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant