diff --git a/pkgs/by-name/ca/casacore/casacore-pkgconfig.patch b/pkgs/by-name/ca/casacore/casacore-pkgconfig.patch new file mode 100644 index 000000000000..58b0e29adf9e --- /dev/null +++ b/pkgs/by-name/ca/casacore/casacore-pkgconfig.patch @@ -0,0 +1,29 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 574150c05..109e96889 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -566,6 +566,14 @@ foreach (module ${_modules}) + endforeach (module) + + # Install pkg-config support file ++set(pc_req_public "") ++if (_usewcs AND WCSLIB_FOUND) ++ list(APPEND pc_req_public "wcslib") ++endif() ++if (_usefits AND CFITSIO_FOUND) ++ list(APPEND pc_req_public "cfitsio") ++endif() ++list(JOIN pc_req_public " " pc_req_public) + CONFIGURE_FILE("casacore.pc.in" "casacore.pc" @ONLY) + set(CASA_PKGCONFIG_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig") + INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/casacore.pc" DESTINATION "${CASA_PKGCONFIG_INSTALL_PREFIX}") +diff --git a/casacore.pc.in b/casacore.pc.in +index 6881300df..d0a01b240 100644 +--- a/casacore.pc.in ++++ b/casacore.pc.in +@@ -9,4 +9,4 @@ Version: @PROJECT_VERSION@ + Requires: @pc_req_public@ + Requires.private: @pc_req_private@ + Libs: -L${libdir} @PRIVATE_LIBS@ +-Cflags: -I${includedir} -I@WCSLIB_INCLUDE_DIR@ ++Cflags: -I${includedir} diff --git a/pkgs/by-name/ca/casacore/package.nix b/pkgs/by-name/ca/casacore/package.nix index dc1cae89fe07..5a026b41ba10 100644 --- a/pkgs/by-name/ca/casacore/package.nix +++ b/pkgs/by-name/ca/casacore/package.nix @@ -14,8 +14,33 @@ fftwFloat, readline, gsl, + mpi, + adios2, + hdf5, + llvmPackages, + mpiSupport ? false, + adios2Support ? false, + hdf5Support ? false, }: - +let + casacorePackages = { + adios2 = adios2.override { + inherit mpi mpiSupport; + }; + fftw = fftw.override { + inherit mpi; + enableMpi = mpiSupport; + }; + fftwFloat = fftwFloat.override { + inherit mpi; + enableMpi = mpiSupport; + }; + hdf5 = hdf5.override { + inherit mpi mpiSupport; + cppSupport = !mpiSupport; + }; + }; +in stdenv.mkDerivation (finalAttrs: { pname = "casacore"; version = "3.8.0"; @@ -27,31 +52,55 @@ stdenv.mkDerivation (finalAttrs: { hash = "sha256-NOxuHMCuHGk9XuWXMwQTN6kOFDI0QuHMgfNRDdlPw44="; }; + strictDeps = true; + nativeBuildInputs = [ cmake gfortran flex bison - ]; + ] + ++ lib.optional mpiSupport mpi; + + propagatedBuildInputs = [ + wcslib + cfitsio + ] + ++ lib.optional hdf5Support casacorePackages.hdf5 + ++ lib.optional mpiSupport mpi + ++ lib.optional adios2Support casacorePackages.adios2; buildInputs = [ blas lapack - cfitsio - wcslib - fftw - fftwFloat + casacorePackages.fftw + casacorePackages.fftwFloat readline gsl + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + llvmPackages.openmp + ]; + + patches = [ + # Fix the generated .pc file: set Requires from a variable instead of + # leaving it empty, and remove hardcoded absolute cmake build paths from + # Cflags (which would embed /nix/store paths from the build environment). + ./casacore-pkgconfig.patch ]; enableParallelBuilding = true; - strictDeps = true; - cmakeFlags = [ (lib.cmakeBool "ENABLE_SHARED" (!stdenv.hostPlatform.isStatic)) - (lib.cmakeBool "BUILD_PYTHON3" false) # TODO: If/when we package python-casacore, this will change + (lib.cmakeBool "BUILD_PYTHON3" false) + (lib.cmakeBool "USE_OPENMP" true) + (lib.cmakeBool "USE_ADIOS2" adios2Support) + (lib.cmakeBool "USE_HDF5" hdf5Support) + (lib.cmakeBool "USE_MPI" mpiSupport) + (lib.cmakeBool "PORTABLE" true) + (lib.cmakeBool "USE_PCH" false) + (lib.cmakeBool "BUILD_FFTPACK_DEPRECATED" true) # Needed for casacpp ]; meta = {