hdf5-subproject.cmake 2.65 KB
Newer Older
1
if (FLEUR_HDF5_SUBMODULE)
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
#get source code
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/external/hdf5-git/src" )
    find_package(Git REQUIRED)
    execute_process(COMMAND ${GIT_EXECUTABLE} submodule init external/hdf5-git WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _res_init OUTPUT_QUIET ERROR_QUIET)
    execute_process(COMMAND ${GIT_EXECUTABLE} submodule update  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} RESULT_VARIABLE _res_update OUTPUT_QUIET ERROR_QUIET)
    if( ${_res_init} GREATER 0 OR ${_res_update} GREATER 0 )
        message(FATAL_ERROR "HDF5 source could not be downloaded.\n"
                            "We tried: 'git submodule init external/hdf5-git && git submodule update' and resulted in error" )
    endif()
endif()

#configure HDF5
set(HDF5_EXTERNALLY_CONFIGURED 1)
set(HDF5_EXPORTED_TARGETS "hdf5_fortran-static")
set(HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support")
set(HDF5_BUILD_CPP_LIB OFF CACHE BOOL "Build HDF5 C++ Library")
set(HDF5_BUILD_HL_LIB OFF CACHE BOOL "Build HIGH Level HDF5 Library")
set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build Shared Libraries")
set(HDF5_BUILD_TOOLS OFF CACHE BOOL "Build HDF5 Tools")
set(HDF5_BUILD_EXAMPLES OFF CACHE BOOL "Build HDF5 Library Examples")
set(BUILD_TESTING OFF CACHE BOOL "Build HDF5 Unit Testing")
if (FLEUR_USE_MPI)
set(HDF5_ENABLE_PARALLEL ON CACHE BOOL "Enable parallel build (requires MPI)")
else()
set(HDF5_ENABLE_PARALLEL OFF CACHE BOOL "Enable parallel build (requires MPI)")
endif()
28
#set(HDF5_F90_BINARY_DIR "${CMAKE_SOURCE_DIR}/external/hdf5-git/fortran/")
29
set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5")
30 31 32
#set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/external/hdf5/CMake-hdf5-1.10.3/HDF_Group/HDF5/1.10.3/include/")
add_subdirectory (external/hdf5-git)

33 34
#Now set all the FLEUR specific stuff

35 36 37 38 39
if(${FLEUR_USE_MPI})
  target_link_libraries(fleur_MPI hdf5_fortran-static)
  target_compile_definitions(fleur_MPI PUBLIC "CPP_HDF5MPI")
  target_compile_definitions(fleur_MPI PUBLIC "CPP_HDF")
  target_compile_definitions(juDFT PUBLIC "CPP_HDF5MPI")
40
  target_compile_options(fleur_MPI PUBLIC "-I${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5/static")
41 42 43 44 45
endif()
if (${FLEUR_USE_SERIAL})
  target_link_libraries(fleur hdf5_fortran-static)
  target_link_libraries(inpgen hdf5_fortran-static)
  target_compile_definitions(fleur PUBLIC "CPP_HDF")
46
  target_compile_options(fleur PUBLIC "-I${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5/static")
47 48 49 50 51
endif()

target_link_libraries(juDFT hdf5_fortran-static)
target_link_libraries(juDFT hdf5-static)
target_compile_definitions(juDFT PUBLIC "CPP_HDF")
52
target_compile_options(juDFT PUBLIC "-I${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5/static")
53 54

endif()