changed order: first find PETSc, than determine the compiler abilities
This commit is contained in:
parent
13072fedc5
commit
939e0e372e
|
@ -2,55 +2,20 @@
|
|||
# CMAKE for build the Material subroutine for BVP solution
|
||||
########################################################################################
|
||||
cmake_minimum_required (VERSION 2.8.0 FATAL_ERROR)
|
||||
project (DAMASK Fortran)
|
||||
|
||||
# THE VERSION NUMBER.
|
||||
set (DAMASK_VERSION_MAJOR 1)
|
||||
set (DAMASK_VERSION_MINOR ${DAMASK_V})
|
||||
|
||||
# PETSC IS REQUIRED
|
||||
#---------------------------------------------------------------------------------------
|
||||
# Find PETSc because the entire build will rely on it
|
||||
if (NOT DEFINED PETSC_DIR)
|
||||
message (FATAL_ERROR "PETSC_DIR is not found!")
|
||||
endif (NOT DEFINED PETSC_DIR)
|
||||
|
||||
# Setting installation prefix
|
||||
if (NOT DEFINED DAMASK_INSTALL)
|
||||
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/bin")
|
||||
elseif(DEFINED DAMASK_INSTALL)
|
||||
set (CMAKE_INSTALL_PREFIX "${DAMASK_INSTALL}")
|
||||
endif(NOT DEFINED DAMASK_INSTALL)
|
||||
message("\n***The binary will be installed at\n${CMAKE_INSTALL_PREFIX}\n")
|
||||
|
||||
# DAMASK DRIVER SELECTION
|
||||
set (SPECTRAL OFF)
|
||||
set (FEM OFF)
|
||||
if ("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
|
||||
set (SPECTRAL ON )
|
||||
endif("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
|
||||
#
|
||||
if ("${DAMASK_DRIVER}" STREQUAL "FEM")
|
||||
set (FEM ON )
|
||||
endif("${DAMASK_DRIVER}" STREQUAL "FEM")
|
||||
|
||||
# COMPILE VARIABLES
|
||||
add_definitions(-DDAMASKVERSION="${DAMASK_V}")
|
||||
add_definitions(-DPETSc)
|
||||
add_definitions(-DFLOAT=8)
|
||||
add_definitions(-DINT=4)
|
||||
if (SPECTRAL)
|
||||
add_definitions(-DSpectral)
|
||||
endif(SPECTRAL)
|
||||
if (FEM)
|
||||
add_definitions(-DFEM)
|
||||
endif(FEM)
|
||||
|
||||
# BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN PETSC
|
||||
# ref:
|
||||
# https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
|
||||
set(petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
|
||||
set(petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" )
|
||||
# A temporary makefile to probe the PETSc configuration
|
||||
set (petsc_config_makefile "${PROJECT_BINARY_DIR}/Makefile.petsc")
|
||||
set (petsc_config_makefile "/home/m/DAMASK/build/Makefile.petsc") #MD: don't know how get the path here
|
||||
file (WRITE "${petsc_config_makefile}"
|
||||
"## This file was auto generated by CMake
|
||||
# PETSC_DIR = ${PETSC_DIR}
|
||||
|
@ -76,6 +41,45 @@ linker:
|
|||
\t@echo \${LINKERNAME}
|
||||
|
||||
")
|
||||
# https://cmake.org/Wiki/CMake_FAQ#How_do_I_use_a_different_compiler.3F
|
||||
set(CMAKE_Fortran_COMPILER "/opt/petsc/gfortran/bin/mpif90") #MD: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake might help
|
||||
set(CMAKE_C_COMPILER "/opt/petsc/gfortran/bin/mpicc") #MD: https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake might help
|
||||
#---------------------------------------------------------------------------------------
|
||||
# Now start to care about DAMASK
|
||||
|
||||
# THE VERSION NUMBER.
|
||||
set (DAMASK_VERSION_MAJOR 1)
|
||||
set (DAMASK_VERSION_MINOR ${DAMASK_V})
|
||||
|
||||
project (DAMASK Fortran C)
|
||||
|
||||
# COMPILE VARIABLES
|
||||
add_definitions(-DDAMASKVERSION="${DAMASK_V}")
|
||||
add_definitions(-DPETSc)
|
||||
add_definitions(-DFLOAT=8)
|
||||
add_definitions(-DINT=4)
|
||||
|
||||
# Setting installation prefix
|
||||
if (NOT DEFINED DAMASK_INSTALL)
|
||||
set (CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/bin")
|
||||
elseif(DEFINED DAMASK_INSTALL)
|
||||
set (CMAKE_INSTALL_PREFIX "${DAMASK_INSTALL}")
|
||||
endif(NOT DEFINED DAMASK_INSTALL)
|
||||
message("\n***The binary will be installed at\n${CMAKE_INSTALL_PREFIX}\n")
|
||||
|
||||
# DAMASK DRIVER SELECTION
|
||||
set (SPECTRAL OFF)
|
||||
set (FEM OFF)
|
||||
if ("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
|
||||
set (SPECTRAL ON )
|
||||
add_definitions(-DSpectral)
|
||||
endif("${DAMASK_DRIVER}" STREQUAL "SPECTRAL")
|
||||
#
|
||||
if ("${DAMASK_DRIVER}" STREQUAL "FEM")
|
||||
set (FEM ON )
|
||||
add_definitions(-DFEM)
|
||||
endif("${DAMASK_DRIVER}" STREQUAL "FEM")
|
||||
|
||||
|
||||
find_program (MAKE_EXECUTABLE NAMES make gmake)
|
||||
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "includes"
|
||||
|
|
|
@ -2,8 +2,18 @@
|
|||
|
||||
cat README
|
||||
echo
|
||||
echo "Building spectral solver with ${FC}"
|
||||
|
||||
if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then
|
||||
DAMASK_ROOT=$(readlink -f "`dirname $BASH_SOURCE`")
|
||||
else
|
||||
[[ "${BASH_SOURCE::1}" == "/" ]] && BASE="" || BASE="`pwd`/"
|
||||
STAT=$(stat "`dirname $BASE$BASH_SOURCE`")
|
||||
DAMASK_ROOT=${STAT##* }
|
||||
fi
|
||||
|
||||
DAMASKVERSION=$(cat VERSION)
|
||||
BUILDROOT=$DAMASK_ROOT/build
|
||||
BUILDDIR=spectral
|
||||
|
||||
# prepare building directory
|
||||
# structure:
|
||||
|
@ -11,15 +21,15 @@ DAMASKVERSION=$(cat VERSION)
|
|||
# |-BUILD_SPECTRAL
|
||||
# |-BUILD_FEM
|
||||
# |-BUILD_MARC
|
||||
if [ ! -d build ]; then
|
||||
mkdir build
|
||||
if [ ! -d $BUILDROOT ]; then
|
||||
mkdir $BUILDROOT
|
||||
fi
|
||||
cd build
|
||||
if [ -d spectral ] ; then
|
||||
rm -rf spectral
|
||||
cd $BUILDROOT
|
||||
if [ -d $BUILDDIR ] ; then
|
||||
rm -rf $BUILDDIR
|
||||
fi
|
||||
mkdir spectral
|
||||
cd spectral
|
||||
mkdir $BUILDDIR
|
||||
cd $BUILDDIR
|
||||
|
||||
##
|
||||
# CMake call
|
||||
|
|
Loading…
Reference in New Issue