update cmake build system

This commit is contained in:
Chen Zhang 2016-04-18 11:14:32 -04:00
parent 672c8d0606
commit a7c4cdaa2f
6 changed files with 25 additions and 33 deletions

View File

@ -48,6 +48,12 @@ compilerc:
linker:
\t@echo \${LINKERNAME}")
# Find DAMASK version (DAMASK_V) in DAMASK_ROOT
find_program (CAT_EXECUTABLE NAMES cat)
execute_process(COMMAND ${CAT_EXECUTABLE} ../../VERSION
RESULT_VARIABLE DAMASK_VERSION_RETURN
OUTPUT_VARIABLE DAMASK_V
OUTPUT_STRIP_TRAILING_WHITESPACE)
# CMake will execute each target in the ${petsc_config_makefile}
# to acquire corresponding PETSc Variables.
@ -69,11 +75,11 @@ execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "extlibs"
# //its version information is used to identify whether it is INTEL FORTRAN
# //or GNU FORTRAN,
# //e.g. for PETSc configured with INTEL FORTRAN compiler
# // >>${MPIEXEC} -v
# // >>${MPIFC} -v
# // ifort version 14.0.3 --> This line is captured and parsed by CMake
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "compilerf"
RESULT_VARIABLE MPIEXEC_RETURN
OUTPUT_VARIABLE MPIEXEC
RESULT_VARIABLE MPIFC_RETURN
OUTPUT_VARIABLE MPIFC
OUTPUT_STRIP_TRAILING_WHITESPACE)
# PETSc specified linker (MPIF90 + PETSc linking flags)
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "linker"
@ -95,14 +101,14 @@ foreach (exlib ${TMP_LIST})
set(PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB} ${exlib}")
endforeach(exlib)
set(CMAKE_Fortran_COMPILER "${MPIEXEC}")
set(CMAKE_Fortran_COMPILER "${MPIFC}")
project (DAMASK Fortran)
message("***Found PETSC_DIR:\n${PETSC_DIR}\n" )
message("***Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" )
message("***Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
message("***Found PETSC_LINKER:\n${PETSC_LINKER}\n" )
message("***Found FORTRAN MPI COMPILER:\n${MPIEXEC}\n" )
message("***Found FORTRAN MPI COMPILER:\n${MPIFC}\n" )
# # https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
@ -116,9 +122,9 @@ set (DAMASK_VERSION_MINOR ${DAMASK_V})
# Built-in options for DAMASK build system
# -> can be overwritten from commandline/install_script
option(OPENMP "Use OpenMP libaries for DAMASK" ON )
option(OPTIMIZATION "DAMASK optimization level[NONE,DEFENSIVE,AGGRESSIVE,ULTRA]" "NONE")
option(OPTIMIZATION "DAMASK optimization level [OFF,DEFENSIVE,AGGRESSIVE]" "DEFENSIVE" )
option(SPECTRAL "Build spectral sovler for DAMASAK" OFF )
option(FEM "Builb FEM solver for DAMASK" OFF )
option(FEM "Build FEM solver for DAMASK" OFF )
# COMPILE VARIABLES
add_definitions(-DDAMASKVERSION="${DAMASK_V}")
@ -148,7 +154,7 @@ endif()
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} ${PETSC_INCLUDES}" )
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} -I${PROJECT_SOURCE_DIR}/lib")
if ("${OPTIMIZATION}" STREQUAL "NONE")
if ("${OPTIMIZATION}" STREQUAL "OFF")
set (OPTIMIZATION_ifort "-O0 -no-ip")
set (OPTIMIZATION_gfortran "-O0" )
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
@ -157,9 +163,6 @@ elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE")
elseif ("${OPTIMIZATION}" STREQUAL "AGGRESSIVE") #ToDo: this is not fully correct here, check old makefile
set (OPTIMIZATION_ifort "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
set (OPTIMIZATION_gfortran "-O3 -ffast-math -funroll-loops -ftree-vectorize")
elseif ("${OPTIMIZATION}" STREQUAL "ULTRA")
set (OPTIMIZATION_ifort "-ipo -O3 -no-prec-div -fp-model fast=2 -xHost" ) #-fast = -ipo, -O3, -no-prec-div, -static, -fp-model fast=2, and -xHost"
set (OPTIMIZATION_gfortran "-O3 -ffast-math -funroll-loops -ftree-vectorize")
else()
set (OPTIMIZATION_ifort "-O2")
set (OPTIMIZATION_gfortran "-O2")
@ -445,10 +448,10 @@ add_subdirectory(src)
# INSTALL BUILT BINARIES
if (SPECTRAL)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASKSpectral.exe
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_spectral
DESTINATION ${CMAKE_INSTALL_PREFIX})
elseif (FEM)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_FEM.exe
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_FEM
DESTINATION ${CMAKE_INSTALL_PREFIX})
endif(SPECTRAL)

View File

@ -41,8 +41,8 @@ cd $BUILDDIR
# OPTIMIZATION | [OFF,DEFENSIVE,AGGRESSIVE,ULTRA]
# DAMASK_DRIVER | [SPECTRAL, FEM]
# DAMASK_INSTALL | Directory to install binary output
# DAMASK_PREFIX | Compiler prefix
# DAMASK_SUFFIX | Compiler suffix,
# BUILDCMD_PRE | Compiler prefix
# BUILDCMD_POST | Compiler suffix,
# | e.g. DAMASK_SUFFIX="-Wl,--verbose"
cmake -D PETSC_DIR=${PETSC_DIR} \
-D DAMASK_V=${DAMASKVERSION} \
@ -52,8 +52,8 @@ cmake -D PETSC_DIR=${PETSC_DIR} \
-D OPTIMIZATION=DEFENSIVE \
-D DAMASK_DRIVER=SPECTRAL \
-D DAMASK_INSTALL=${HOME}/bin \
-D DAMASK_PREFIX="" \
-D DAMASK_SUFFIX="-Wl,--verbose" \
-D BUILDCMD_PRE="" \
-D BUILDCMD_POST="-Wl,--verbose" \
../..
echo

8
code/.gitattributes vendored
View File

@ -1,8 +0,0 @@
# from https://help.github.com/articles/dealing-with-line-endings/
#
# always use LF, even if the files are edited on windows, they need to be compiled/used on unix
* text eol=lf
# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary

3
code/.gitignore vendored
View File

@ -1,3 +0,0 @@
DAMASK_marc*.f90
quit__genmod.f90
*.marc

View File

@ -168,8 +168,8 @@ if (FEM)
add_library(DAMASK_FEM_DRIVER "DAMASK_FEM_driver.f90")
target_link_libraries(DAMASK_FEM_DRIVER DAMASK_FEM_BASE)
add_executable(DAMASK_FEM.exe "DAMASK_FEM_driver.f90")
target_link_libraries(DAMASK_FEM.exe DAMASK_FEM_DRIVER)
add_executable(DAMASK_FEM "DAMASK_FEM_driver.f90")
target_link_libraries(DAMASK_FEM DAMASK_FEM_DRIVER)
endif(FEM)
if (SPECTRAL)
@ -193,6 +193,6 @@ if (SPECTRAL)
target_link_libraries(DAMASK_EXE DAMASK_SPECTRAL_BASE)
target_link_libraries(DAMASK_EXE DAMASK_SPECTRAL_MECH)
add_executable(DAMASKSpectral.exe "DAMASK_spectral.f90")
target_link_libraries(DAMASKSpectral.exe DAMASK_EXE)
add_executable(DAMASK_spectral "DAMASK_spectral.f90")
target_link_libraries(DAMASK_spectral DAMASK_EXE)
endif(SPECTRAL)

View File

@ -1,4 +1,4 @@
!COMPILER-GENERATED INTERFACE MODULE: Thu Mar 3 12:28:23 2016
!COMPILER-GENERATED INTERFACE MODULE: Mon Apr 18 09:43:53 2016
MODULE QUIT__genmod
INTERFACE
SUBROUTINE QUIT(STOP_ID)