From 939e0e372e44944afd91ef0ad430cf5ea3f315c1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 6 Mar 2016 09:28:20 +0100 Subject: [PATCH] changed order: first find PETSc, than determine the compiler abilities --- CMakeLists.txt | 82 +++++++++++++++++++++++++---------------------- build_spectral.sh | 26 ++++++++++----- 2 files changed, 61 insertions(+), 47 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b20a6188..7da86d6e8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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" @@ -443,4 +447,4 @@ endif(SPECTRAL) # Enable Dashboard scripting # include (CTest) -# set (CTEST_PROJECT_NAME "DAMASK") \ No newline at end of file +# set (CTEST_PROJECT_NAME "DAMASK") diff --git a/build_spectral.sh b/build_spectral.sh index dd1164558..e40700566 100755 --- a/build_spectral.sh +++ b/build_spectral.sh @@ -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