auto extract PETSC_DIR from env

This commit is contained in:
Chen Zhang 2016-04-18 18:32:08 -04:00
parent a7c4cdaa2f
commit 247a6e36c3
3 changed files with 24 additions and 27 deletions

View File

@ -6,10 +6,12 @@ cmake_minimum_required (VERSION 2.8.0 FATAL_ERROR)
# //The rest of the script relies on it to figure out relative position
#---------------------------------------------------------------------------------------
# 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)
# Find PETSc from environment
set(PETSC_DIR $ENV{PETSC_DIR})
# if (NOT DEFINED PETSC_DIR)
# message (FATAL_ERROR "PETSC_DIR is not found!")
# endif (NOT DEFINED PETSC_DIR)
exec_program(mktemp ARGS -d OUTPUT_VARIABLE PETSC_TEMP)
@ -428,16 +430,16 @@ set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${CMAKE_Fortr
set (CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} ${DEBUG_FLAGS}" )
# Finalizing, adding PREFIX and SUFFIX to compiler chain
set (CMAKE_Fortran_FLAGS_RELEASE "${DAMASK_PREFIX} ${CMAKE_Fortran_FLAGS_RELEASE} ${DAMASK_INCLUDE_FLAGS} ${DAMASK_SUFFIX}")
set (CMAKE_Fortran_FLAGS_DEBUG "${DAMASK_PREFIX} ${CMAKE_Fortran_FLAGS_DEBUG} ${DAMASK_INCLUDE_FLAGS} ${DAMASK_SUFFIX}")
set (CMAKE_Fortran_FLAGS_RELEASE "${BUILDCMD_PRE} ${CMAKE_Fortran_FLAGS_RELEASE} ${DAMASK_INCLUDE_FLAGS} ${BUILDCMD_POST}")
set (CMAKE_Fortran_FLAGS_DEBUG "${BUILDCMD_PRE} ${CMAKE_Fortran_FLAGS_DEBUG} ${DAMASK_INCLUDE_FLAGS} ${BUILDCMD_POST}")
set (CMAKE_LINKER "${PETSC_LINKER}")
if ("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
set (CMAKE_Fortran_LINK_EXECUTABLE
"${DAMASK_PREFIX} ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS_RELEASE} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} ${DAMASK_SUFFIX}")
"${BUILDCMD_PRE} ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS_RELEASE} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} ${BUILDCMD_POST}")
else("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
set (CMAKE_Fortran_LINK_EXECUTABLE
"${DAMASK_PREFIX} ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS_DEBUG} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} ${DAMASK_SUFFIX}")
"${BUILDCMD_PRE} ${CMAKE_LINKER} ${CMAKE_EXE_LINKER_FLAGS_DEBUG} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} ${BUILDCMD_POST}")
endif("${CMAKE_BUILD_TYPE}" STREQUAL "RELEASE")
message("***COMPILE FLAGS:\n${CMAKE_Fortran_FLAGS_RELEASE}\n")

View File

@ -3,11 +3,15 @@ SHELL = /bin/sh
# Makefile for the installation of DAMASK
########################################################################################
.PHONY: all
all: spectral marc processing
all: spectral FEM
.PHONY: spectral
spectral:
$(MAKE) DAMASK_spectral.exe -C src
spectral: build
@if [ ! -d build/spectral ]; then mkdir build/spectral; fi
(cd build/spectral; cmake ../../ ;)
build:
mkdir build
.PHONY: FEM
FEM:
@ -32,11 +36,7 @@ tidy:
@$(MAKE) tidy -C src >/dev/null
.PHONY: clean
clean:
@$(MAKE) cleanDAMASK -C src >/dev/null
.PHONY: install
install:
@./installation/symlink_Code.py ${MAKEFLAGS}
@./installation/symlink_Processing.py ${MAKEFLAGS}
rm -rvf build

View File

@ -11,7 +11,6 @@ else
DAMASK_ROOT=${STAT##* }
fi
DAMASKVERSION=$(cat VERSION)
BUILDROOT=$DAMASK_ROOT/build
BUILDDIR=spectral
@ -34,7 +33,6 @@ cd $BUILDDIR
##
# CMake call
# PETSC_DIR | PETSC directory
# DAMASK_V | DAMASK current revision
# CMAKE_BUILD_TYPE | Default set to release (no debugging output)
# CMAKE_VERBOSE_MAKEFILE | [ON/OFF] toggle makefile verbose output
# OPENMP | [ON/OFF]
@ -45,7 +43,6 @@ cd $BUILDDIR
# BUILDCMD_POST | Compiler suffix,
# | e.g. DAMASK_SUFFIX="-Wl,--verbose"
cmake -D PETSC_DIR=${PETSC_DIR} \
-D DAMASK_V=${DAMASKVERSION} \
-D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_VERBOSE_MAKEFILE=OFF \
-D OPENMP=ON \
@ -56,8 +53,6 @@ cmake -D PETSC_DIR=${PETSC_DIR} \
-D BUILDCMD_POST="-Wl,--verbose" \
../..
echo
echo "Please move to the build directory using"
echo " cd build/spectral"
echo "Using the following command to build DAMASK spectral solver"
echo " make clean all install"
echo "Start compiling DAMASK_spectral"
make
make install