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: linker:
\t@echo \${LINKERNAME}") \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} # CMake will execute each target in the ${petsc_config_makefile}
# to acquire corresponding PETSc Variables. # 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 # //its version information is used to identify whether it is INTEL FORTRAN
# //or GNU FORTRAN, # //or GNU FORTRAN,
# //e.g. for PETSc configured with INTEL FORTRAN compiler # //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 # // ifort version 14.0.3 --> This line is captured and parsed by CMake
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "compilerf" execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "compilerf"
RESULT_VARIABLE MPIEXEC_RETURN RESULT_VARIABLE MPIFC_RETURN
OUTPUT_VARIABLE MPIEXEC OUTPUT_VARIABLE MPIFC
OUTPUT_STRIP_TRAILING_WHITESPACE) OUTPUT_STRIP_TRAILING_WHITESPACE)
# PETSc specified linker (MPIF90 + PETSc linking flags) # PETSc specified linker (MPIF90 + PETSc linking flags)
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "linker" 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}") set(PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB} ${exlib}")
endforeach(exlib) endforeach(exlib)
set(CMAKE_Fortran_COMPILER "${MPIEXEC}") set(CMAKE_Fortran_COMPILER "${MPIFC}")
project (DAMASK Fortran) project (DAMASK Fortran)
message("***Found PETSC_DIR:\n${PETSC_DIR}\n" ) message("***Found PETSC_DIR:\n${PETSC_DIR}\n" )
message("***Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" ) message("***Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" )
message("***Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n") message("***Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
message("***Found PETSC_LINKER:\n${PETSC_LINKER}\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 # # 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 # Built-in options for DAMASK build system
# -> can be overwritten from commandline/install_script # -> can be overwritten from commandline/install_script
option(OPENMP "Use OpenMP libaries for DAMASK" ON ) 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(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 # COMPILE VARIABLES
add_definitions(-DDAMASKVERSION="${DAMASK_V}") 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} ${PETSC_INCLUDES}" )
set (DAMASK_INCLUDE_FLAGS "${DAMASK_INCLUDE_FLAGS} -I${PROJECT_SOURCE_DIR}/lib") 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_ifort "-O0 -no-ip")
set (OPTIMIZATION_gfortran "-O0" ) set (OPTIMIZATION_gfortran "-O0" )
elseif ("${OPTIMIZATION}" STREQUAL "DEFENSIVE") 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 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_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") 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() else()
set (OPTIMIZATION_ifort "-O2") set (OPTIMIZATION_ifort "-O2")
set (OPTIMIZATION_gfortran "-O2") set (OPTIMIZATION_gfortran "-O2")
@ -445,10 +448,10 @@ add_subdirectory(src)
# INSTALL BUILT BINARIES # INSTALL BUILT BINARIES
if (SPECTRAL) if (SPECTRAL)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASKSpectral.exe INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_spectral
DESTINATION ${CMAKE_INSTALL_PREFIX}) DESTINATION ${CMAKE_INSTALL_PREFIX})
elseif (FEM) elseif (FEM)
INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_FEM.exe INSTALL(PROGRAMS ${PROJECT_BINARY_DIR}/src/DAMASK_FEM
DESTINATION ${CMAKE_INSTALL_PREFIX}) DESTINATION ${CMAKE_INSTALL_PREFIX})
endif(SPECTRAL) endif(SPECTRAL)

View File

@ -41,8 +41,8 @@ cd $BUILDDIR
# OPTIMIZATION | [OFF,DEFENSIVE,AGGRESSIVE,ULTRA] # OPTIMIZATION | [OFF,DEFENSIVE,AGGRESSIVE,ULTRA]
# DAMASK_DRIVER | [SPECTRAL, FEM] # DAMASK_DRIVER | [SPECTRAL, FEM]
# DAMASK_INSTALL | Directory to install binary output # DAMASK_INSTALL | Directory to install binary output
# DAMASK_PREFIX | Compiler prefix # BUILDCMD_PRE | Compiler prefix
# DAMASK_SUFFIX | Compiler suffix, # BUILDCMD_POST | Compiler suffix,
# | e.g. DAMASK_SUFFIX="-Wl,--verbose" # | e.g. DAMASK_SUFFIX="-Wl,--verbose"
cmake -D PETSC_DIR=${PETSC_DIR} \ cmake -D PETSC_DIR=${PETSC_DIR} \
-D DAMASK_V=${DAMASKVERSION} \ -D DAMASK_V=${DAMASKVERSION} \
@ -52,8 +52,8 @@ cmake -D PETSC_DIR=${PETSC_DIR} \
-D OPTIMIZATION=DEFENSIVE \ -D OPTIMIZATION=DEFENSIVE \
-D DAMASK_DRIVER=SPECTRAL \ -D DAMASK_DRIVER=SPECTRAL \
-D DAMASK_INSTALL=${HOME}/bin \ -D DAMASK_INSTALL=${HOME}/bin \
-D DAMASK_PREFIX="" \ -D BUILDCMD_PRE="" \
-D DAMASK_SUFFIX="-Wl,--verbose" \ -D BUILDCMD_POST="-Wl,--verbose" \
../.. ../..
echo 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") add_library(DAMASK_FEM_DRIVER "DAMASK_FEM_driver.f90")
target_link_libraries(DAMASK_FEM_DRIVER DAMASK_FEM_BASE) target_link_libraries(DAMASK_FEM_DRIVER DAMASK_FEM_BASE)
add_executable(DAMASK_FEM.exe "DAMASK_FEM_driver.f90") add_executable(DAMASK_FEM "DAMASK_FEM_driver.f90")
target_link_libraries(DAMASK_FEM.exe DAMASK_FEM_DRIVER) target_link_libraries(DAMASK_FEM DAMASK_FEM_DRIVER)
endif(FEM) endif(FEM)
if (SPECTRAL) if (SPECTRAL)
@ -193,6 +193,6 @@ if (SPECTRAL)
target_link_libraries(DAMASK_EXE DAMASK_SPECTRAL_BASE) target_link_libraries(DAMASK_EXE DAMASK_SPECTRAL_BASE)
target_link_libraries(DAMASK_EXE DAMASK_SPECTRAL_MECH) target_link_libraries(DAMASK_EXE DAMASK_SPECTRAL_MECH)
add_executable(DAMASKSpectral.exe "DAMASK_spectral.f90") add_executable(DAMASK_spectral "DAMASK_spectral.f90")
target_link_libraries(DAMASKSpectral.exe DAMASK_EXE) target_link_libraries(DAMASK_spectral DAMASK_EXE)
endif(SPECTRAL) 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 MODULE QUIT__genmod
INTERFACE INTERFACE
SUBROUTINE QUIT(STOP_ID) SUBROUTINE QUIT(STOP_ID)