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 for build the Material subroutine for BVP solution
|
||||||
########################################################################################
|
########################################################################################
|
||||||
cmake_minimum_required (VERSION 2.8.0 FATAL_ERROR)
|
cmake_minimum_required (VERSION 2.8.0 FATAL_ERROR)
|
||||||
project (DAMASK Fortran)
|
|
||||||
|
|
||||||
# THE VERSION NUMBER.
|
#---------------------------------------------------------------------------------------
|
||||||
set (DAMASK_VERSION_MAJOR 1)
|
# Find PETSc because the entire build will rely on it
|
||||||
set (DAMASK_VERSION_MINOR ${DAMASK_V})
|
|
||||||
|
|
||||||
# PETSC IS REQUIRED
|
|
||||||
if (NOT DEFINED PETSC_DIR)
|
if (NOT DEFINED PETSC_DIR)
|
||||||
message (FATAL_ERROR "PETSC_DIR is not found!")
|
message (FATAL_ERROR "PETSC_DIR is not found!")
|
||||||
endif (NOT DEFINED PETSC_DIR)
|
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
|
# BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN PETSC
|
||||||
# ref:
|
# ref:
|
||||||
# https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
|
# https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake
|
||||||
set(petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
|
set(petsc_conf_variables "${PETSC_DIR}/lib/petsc/conf/variables")
|
||||||
set(petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" )
|
set(petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" )
|
||||||
# A temporary makefile to probe the PETSc configuration
|
# 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}"
|
file (WRITE "${petsc_config_makefile}"
|
||||||
"## This file was auto generated by CMake
|
"## This file was auto generated by CMake
|
||||||
# PETSC_DIR = ${PETSC_DIR}
|
# PETSC_DIR = ${PETSC_DIR}
|
||||||
|
@ -76,6 +41,45 @@ linker:
|
||||||
\t@echo \${LINKERNAME}
|
\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)
|
find_program (MAKE_EXECUTABLE NAMES make gmake)
|
||||||
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "includes"
|
execute_process(COMMAND ${MAKE_EXECUTABLE} -f ${petsc_config_makefile} "includes"
|
||||||
|
|
|
@ -2,8 +2,18 @@
|
||||||
|
|
||||||
cat README
|
cat README
|
||||||
echo
|
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)
|
DAMASKVERSION=$(cat VERSION)
|
||||||
|
BUILDROOT=$DAMASK_ROOT/build
|
||||||
|
BUILDDIR=spectral
|
||||||
|
|
||||||
# prepare building directory
|
# prepare building directory
|
||||||
# structure:
|
# structure:
|
||||||
|
@ -11,15 +21,15 @@ DAMASKVERSION=$(cat VERSION)
|
||||||
# |-BUILD_SPECTRAL
|
# |-BUILD_SPECTRAL
|
||||||
# |-BUILD_FEM
|
# |-BUILD_FEM
|
||||||
# |-BUILD_MARC
|
# |-BUILD_MARC
|
||||||
if [ ! -d build ]; then
|
if [ ! -d $BUILDROOT ]; then
|
||||||
mkdir build
|
mkdir $BUILDROOT
|
||||||
fi
|
fi
|
||||||
cd build
|
cd $BUILDROOT
|
||||||
if [ -d spectral ] ; then
|
if [ -d $BUILDDIR ] ; then
|
||||||
rm -rf spectral
|
rm -rf $BUILDDIR
|
||||||
fi
|
fi
|
||||||
mkdir spectral
|
mkdir $BUILDDIR
|
||||||
cd spectral
|
cd $BUILDDIR
|
||||||
|
|
||||||
##
|
##
|
||||||
# CMake call
|
# CMake call
|
||||||
|
|
Loading…
Reference in New Issue