Commit 6a64258a authored by Daniel Wortmann's avatar Daniel Wortmann

Changes to cmake build system. First try to add hdf5 as subproject.

parent b482089a
......@@ -12,10 +12,15 @@ include("cmake/CompilerConfig.txt")
include("cmake/ReportConfig.txt")
include("cmake/Generate_Schema.cmake")
include("cmake/Files_and_Targets.txt")
include("cmake/filespecific.cmake")
include("cmake/hdf5-subproject.cmake")
#install(TARGETS fleur inpgen DESTINATION bin)
install(PROGRAMS ${CMAKE_BINARY_DIR}/fleur
CONFIGURATIONS Debug
......
......@@ -77,12 +77,14 @@ if (${FLEUR_USE_SERIAL})
#Serial executables
add_executable(fleur ${fleur_SRC} ${c_filesFleur})
target_compile_definitions(fleur PUBLIC ${FLEUR_DEFINITIONS})
target_compile_options(fleur PUBLIC ${FLEUR_PRECISION_OPTION})
target_link_libraries(fleur ${FLEUR_LIBRARIES})
target_link_libraries(fleur juDFT)
set_target_properties(fleur PROPERTIES Fortran_MODULE_DIRECTORY modules/fleur COMPILE_OPTIONS -Imodules/fleur)
#inpgen executable
add_executable(inpgen ${inpgen_F77} ${inpgen_F90} ${juDFT_SRC_F90} ${c_filesInpgen})
target_compile_definitions(inpgen PUBLIC ${FLEUR_DEFINITIONS})
target_compile_options(inpgen PUBLIC ${FLEUR_PRECISION_OPTION})
target_link_libraries(inpgen ${FLEUR_LIBRARIES})
target_link_libraries(inpgen juDFT)
set_target_properties(inpgen PROPERTIES Fortran_MODULE_DIRECTORY modules/inpgen COMPILE_OPTIONS -Imodules/inpgen)
......@@ -92,8 +94,9 @@ if(${FLEUR_USE_MPI})
#fleur_MPI
add_executable(fleur_MPI ${juDFT_HDF} ${juDFT_SRC_F90} ${fleur_SRC} ${c_filesFleur} ${fleur_SRC_MPI})
target_compile_definitions(fleur_MPI PUBLIC ${FLEUR_MPI_DEFINITIONS})
target_compile_options(fleur_MPI PUBLIC ${FLEUR_PRECISION_OPTION})
target_link_libraries(fleur_MPI ${FLEUR_LIBRARIES})
target_link_libraries(fleur_MPI juDFT)
target_link_libraries(fleur_MPI juDFT)
set_target_properties(fleur_MPI PROPERTIES Fortran_MODULE_DIRECTORY modules/fleur_MPI COMPILE_OPTIONS -Imodules/fleur_MPI)
endif ()
......
#cmake file to set compiler flags for some of the known compilers
if (${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
message("Intel Fortran detected")
set(FLEUR_PRECISION_OPTION "-r8")
if (${CMAKE_Fortran_COMPILER_VERSION} VERSION_LESS "13.0.0.0")
set(FLEUR_WARN_MESSAGE "You are using an old version of the Intel Fortran Compiler. Most likely FLEUR will not be build sucessfully. Consider to upgrade your compiler.")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mkl -r8 -openmp -assume byterecl")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mkl -openmp -assume byterecl")
set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_OLDINTEL")
set(FLEUR_DEFINITIONS ${FLEUR_DEFINITIONS} "CPP_OLDINTEL")
elseif (${CMAKE_Fortran_COMPILER_VERSION} VERSION_LESS "14.1.0.0")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mkl -r8 -openmp -assume byterecl")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mkl -openmp -assume byterecl")
else()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mkl -r8 -qopenmp -assume byterecl")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mkl -qopenmp -assume byterecl")
endif()
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -xHost -O2 -g")
if (${CMAKE_Fortran_COMPILER_VERSION} VERSION_LESS "19.0.0.0")
......@@ -18,20 +19,22 @@ if (${CMAKE_Fortran_COMPILER_ID} MATCHES "Intel")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -CB -traceback -O0 -g -ftrapuv -check uninit -check pointers -DCPP_DEBUG")
endif()
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "PGI")
set(FLEUR_PRECISION_OPTION "-Mr8 -Mr8intrinsics")
message("PGI Fortran detected")
set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "") #fix problem in cmake
#CPU
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mr8 -Mr8intrinsics")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp")
#GPU
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mr8 -Mr8intrinsics -Mcuda=cuda9.0,cc60 -Mcudalib=cublas")
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mr8 -Mr8intrinsics -Mcuda:kepler+ -ta:tesla:cuda7.5 -DUSE_STREAMS -DNUM_STREAMS=${N_STREAMS} -Minfo=accel -acc")
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mr8 -Mr8intrinsics -Mcuda:cuda9.0,cc70 -DUSE_STREAMS -DNUM_STREAMS=${N_STREAMS} -Minfo=accel -acc")
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mcuda=cuda9.0,cc60 -Mcudalib=cublas")
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mcuda:kepler+ -ta:tesla:cuda7.5 -DUSE_STREAMS -DNUM_STREAMS=${N_STREAMS} -Minfo=accel -acc")
#set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -mp -Mcuda:cuda9.0,cc70 -DUSE_STREAMS -DNUM_STREAMS=${N_STREAMS} -Minfo=accel -acc")
#set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -fast -O3")
set(CMAKE_Fortran_FLAGS_RELEASE "-O1 ") # to prevent cmake from putting -fast which auses problems with PGI18.4
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -C -traceback -O0 -g -Mchkstk -Mchkptr -Ktrap=fp -DCPP_DEBUG")
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "XL")
message("IBM/BG Fortran detected")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp=omp -qnosave -qarch=qp -qtune=qp -qrealsize=8 -qfixed -qsuppress=1520-022 -qessl")
set(FLEUR_PRECISION_OPTION "-qrealsize=8")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -qsmp=omp -qnosave -qarch=qp -qtune=qp -qfixed -qsuppress=1520-022 -qessl")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -O4 -qsuppress=1500-036")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -O0 -g -DCPP_DEBUG")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I/bgsys/local/libxml2/include/libxml2")
......@@ -39,10 +42,11 @@ elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "XL")
set(FLEUR_MPI_DEFINITIONS ${FLEUR_MPI_DEFINITIONS} "CPP_AIX")
elseif(${CMAKE_Fortran_COMPILER_ID} MATCHES "GNU")
message("gfortran detected")
set(FLEUR_PRECISION_OPTION "-fdefault-real-8")
if (${CMAKE_Fortran_COMPILER_VERSION} VERSION_LESS "6.1.0")
message(FATAL_ERROR "Only modern versions of gfortran >6.3 will be able to compile FLEUR\nYou need to specify a different compiler.\nSee the docs at www.flapw.de.\n")
endif()
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none -fopenmp -fdefault-real-8 ")
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -ffree-line-length-none -fopenmp ")
set(CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -O2")
set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -fdump-core -Wall -Wextra -Warray-temporaries -fbacktrace -fcheck=all -finit-real=nan -O0 -g -DCPP_DEBUG")
endif()
if (FLEUR_HDF5_SUBMODULE)
set(HDF5_EXTERNALLY_CONFIGURED ON)
#set(HDF5_EXTERNAL_LIB_PREFIX "fleur")
set(HDF5_ENABLE_F2003 ON)
set(HDF5_ENABLE_FORTRAN ON)
set(HDF5_BUILD_FORTRAN ON)
set(HDF5_BUILD_CPP_LIB OFF)
set(HDF5_BUILD_HL_LIB OFF)
set(HDF5_ENABLE_Z_LIB_SUPPORT OFF)
set(HDF5_ENABLE_SZIP_SUPPORT OFF)
set(BUILD_STATIC_LIBS ON)
set(HDF5_ENABLE_PARALLEL FLEUR_USE_MPI)
#set(HDF5_F90_BINARY_DIR "${CMAKE_SOURCE_DIR}/external/hdf5-git/fortran/")
#set(CMAKE_Fortran_MODULE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/modules/hdf5")
#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)
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")
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")
endif()
target_link_libraries(juDFT hdf5_fortran-static)
target_link_libraries(juDFT hdf5-static)
target_compile_definitions(juDFT PUBLIC "CPP_HDF")
set (FLEUR_USE_HDF 1)
endif()
......@@ -31,5 +31,7 @@ juDFT/xmlOutput.F90
)
target_compile_definitions(juDFT PUBLIC ${FLEUR_DEFINITIONS})
target_link_libraries(juDFT ${FLEUR_LIBRARIES})
target_compile_options(juDFT PUBLIC ${FLEUR_PRECISION_OPTION})
include_directories("${CMAKE_CURRENT_BINARY_DIR}/modules/juDFT")
target_link_libraries(juDFT "hdf5;hdf5_fortran")
set_target_properties(juDFT PROPERTIES Fortran_MODULE_DIRECTORY modules/juDFT)
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