Skip to content

Instantly share code, notes, and snippets.

@knedlsepp
Last active April 18, 2020 13:12
Show Gist options
  • Save knedlsepp/e3cb53b36abb876870a7490958bd4adb to your computer and use it in GitHub Desktop.
Save knedlsepp/e3cb53b36abb876870a7490958bd4adb to your computer and use it in GitHub Desktop.
hdf5-fortran-nix
cmake_minimum_required(VERSION 3.5)
project(test-hdf5 C Fortran)
find_package(HDF5 REQUIRED COMPONENTS Fortran)
add_library(hdf5::hdf5 INTERFACE IMPORTED)
set_property(TARGET hdf5::hdf5 PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${HDF5_Fortran_INCLUDE_DIRS})
set_property(TARGET hdf5::hdf5 PROPERTY
INTERFACE_LINK_LIBRARIES ${HDF5_Fortran_LIBRARIES} ${HDF5_Fortran_HL_LIBRARIES})
add_executable(test test.f95)
target_link_libraries(test hdf5::hdf5)
install(TARGETS test)
let
pkgs = import <nixpkgs> {};
in
pkgs.stdenv.mkDerivation {
name = "hdf5-test";
src = builtins.fetchGit ./.;
nativeBuildInputs = with pkgs; [
gfortran
cmake
];
hardeningDisable = [ "format" ];
buildInputs = with pkgs; [
hdf5-fortran
];
}
program test
use hdf5
implicit none
end program test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment