Commit 0ce89449 authored by Remi Perenon's avatar Remi Perenon

Debugging cmake scripts to build with HDF5

parent 40fa8b83
......@@ -48,13 +48,13 @@ message(STATUS "CrysFML installation path set to ${CRYSFML_PREFIX}")
# Include and library paths for HDF5.
# They must be set by the user.
if(DEFINED HDF5_INCLUDE_PATH)
if(DEFINED HDF5_INCLUDE_PATH)
set(HDF5_INCLUDE_PATH ${HDF5_INCLUDE_PATH} CACHE PATH "HDF5 include path")
else()
set(HDF5_INCLUDE_PATH "" CACHE PATH "HDF5 include path")
endif()
if(NOT DEFINED HDF5_LIBRARY_PATH)
if(DEFINED HDF5_LIBRARY_PATH)
set(HDF5_LIBRARY_PATH ${HDF5_LIBRARY_PATH} CACHE PATH "HDF5 library path")
else()
set(HDF5_LIBRARY_PATH "" CACHE PATH "HDF5 library path")
......@@ -95,9 +95,6 @@ if (NOT CRYSFML08)
set_compiler_flags()
# The subdirectories of the project.
add_subdirectory(Src)
#if (USE_HDF)
# add_subdirectory(SrcCpp)
#endif()
else()
include(set_compiler_flags_08)
set_compiler_flags_08()
......
......@@ -2,9 +2,10 @@
# Include section
#################################
#if(USE_HDF)
# add_definitions(-DUSE_HDF)
#endif()
if(USE_HDF)
add_definitions(-DUSE_HDF)
find_package(hdf5_crysfml)
endif()
# Build crysfml_common library.
include(crysfml_common.cmake)
......@@ -16,4 +17,3 @@ include(crysfml.cmake)
if(GUI)
include(wcrysfml.cmake)
endif()
......@@ -8,7 +8,6 @@ set(SOURCES CFML_IO_Mess.f90
# Add CFML_HDF5 module if USE_HDF5 = ON
if(USE_HDF)
include(hdf5.cmake)
set(SOURCES ${SOURCES} CFML_HDF5.f90)
endif()
......@@ -29,30 +28,28 @@ set_source_files_properties(${CRYSFML_COMMON_OBJECTS} PROPERTIES GENERATED true)
set(LIBRARY_NAME crysfml)
# This directory contains the crysfml_common library mod files.
include_directories(${CRYSFML_COMMON_MODULE_DIRECTORY})
if(USE_HDF)
include_directories(${HDF5_INCLUDE_PATH})
link_directories(${HDF5_LIBRARY_PATH})
endif()
# The crysfml library is the CONSOLE version of the library.
add_library(${LIBRARY_NAME} STATIC ${SOURCES} ${CRYSFML_COMMON_OBJECTS})
# Add a dependency to crysfml_common to keep sure that the crysfml_common library will be built first.
add_dependencies(${LIBRARY_NAME} crysfml_common)
if(USE_HDF)
# The library is linked to hdf5
target_link_libraries(${LIBRARY_NAME} ${HDF5_LIBS})
endif()
# The directory where the crysfml specific module files will be stored.
set(CRYSFML_MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/crysfml_modules)
# Sets the path where to place the mod files for the crysfml library.
set_target_properties(${LIBRARY_NAME} PROPERTIES Fortran_MODULE_DIRECTORY ${CRYSFML_MODULE_DIRECTORY})
# This directory contains the crysfml_common library mod files.
include_directories(${CRYSFML_COMMON_MODULE_DIRECTORY})
# HDF
if(USE_HDF)
include_directories(${HDF5_INCLUDE_DIR})
link_directories(${HDF5_LIBRARY_DIR})
target_link_libraries(${LIBRARY_NAME} ${HDF5_LIBS})
endif()
#################################
# Install section
#################################
......
# Find hdf5 libraries
find_library(hdf5_fortran NAME libhdf5_fortran PATHS ${HDF5_LIBRARY_PATH})
if(hdf5_fortran STREQUAL hdf5_fortran-NOTFOUND)
message(FATAL_ERROR "libhdf5_fortran not found")
# Try to find by casual method if include path or library path (or both) is not defined
if(NOT HDF5_INCLUDE_PATH AND NOT HDF5_LIBRARY_PATH)
find_package(HDF5)
endif()
find_library(hdf5_f90cstub NAME libhdf5_f90cstub PATHS ${HDF5_LIBRARY_PATH})
if(hdf5_f90cstub STREQUAL hdf5_f90cstub-NOTFOUND)
message(FATAL_ERROR "libhdf5_f90cstub not found")
# Override include path if user defined it
if(HDF5_INCLUDE_PATH)
set(HDF5_INCLUDE_DIR ${HDF5_INCLUDE_PATH})
message(STATUS "Using ${HDF5_INCLUDE_PATH} as HDF5 headers (provided by user)")
endif()
find_library(hdf5 NAME libhdf5 PATHS ${HDF5_LIBRARY_PATH})
if(hdf5 STREQUAL hdf5-NOTFOUND)
message(FATAL_ERROR "libhdf5 not found")
# Override library path if user defined it
if(HDF5_LIBRARY_PATH)
find_library(hdf5_fortran NAME libhdf5_fortran PATHS ${HDF5_LIBRARY_PATH})
if(hdf5_fortran STREQUAL hdf5_fortran-NOTFOUND)
message(FATAL_ERROR "libhdf5_fortran not found")
endif()
find_library(hdf5_f90cstub NAME libhdf5_f90cstub PATHS ${HDF5_LIBRARY_PATH})
if(hdf5_f90cstub STREQUAL hdf5_f90cstub-NOTFOUND)
message(FATAL_ERROR "libhdf5_f90cstub not found")
endif()
find_library(hdf5 NAME libhdf5 PATHS ${HDF5_LIBRARY_PATH})
if(hdf5 STREQUAL hdf5-NOTFOUND)
message(FATAL_ERROR "libhdf5 not found")
endif()
find_library(szip NAME libszip PATHS ${HDF5_LIBRARY_PATH})
if(szip STREQUAL szip-NOTFOUND)
message(FATAL_ERROR "libszip not found")
endif()
find_library(zlib NAME libzlib PATHS ${HDF5_LIBRARY_PATH})
if(zlib STREQUAL zlib-NOTFOUND)
message(FATAL_ERROR "libzlib not found")
endif()
endif()
find_library(szip NAME libszip PATHS ${HDF5_LIBRARY_PATH})
if(szip STREQUAL szip-NOTFOUND)
message(FATAL_ERROR "libszip not found")
endif()
find_library(zlib NAME libzlib PATHS ${HDF5_LIBRARY_PATH})
if(zlib STREQUAL zlib-NOTFOUND)
message(FATAL_ERROR "libzlib not found")
endif()
set(HDF5_LIBS libhdf5_fortran libhdf5_f90cstub libhdf5 libszip libzlib)
# Set HDF5_libs
set(HDF5_LIBS libhdf5_fortran libhdf5_f90cstub libhdf5 libszip libzlib)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment