diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c89b8e62..b90f79afd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,6 @@ cmake_minimum_required (VERSION 2.8.0 FATAL_ERROR) # PROJECT DEFINITION HAS TO BE ON TOP # //The rest of the script relies on it to figure out relative position -project (DAMASK Fortran C) #--------------------------------------------------------------------------------------- # Find PETSc because the entire build will rely on it @@ -12,6 +11,8 @@ 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) + # BRUTAL FORCE TO FIND THE VARIABLES DEFINED IN PETSC # ref: # https://github.com/jedbrown/cmake-modules/blob/master/FindPETSc.cmake @@ -20,7 +21,7 @@ set(petsc_conf_rules "${PETSC_DIR}/lib/petsc/conf/rules" ) # Generate a temporary makerfile to probe the PETSc configuration # This file will be deleted once the setting from PETSc is parsed # into CMake -set (petsc_config_makefile "${PROJECT_SOURCE_DIR}/Makefile.petsc") +set (petsc_config_makefile "${PETSC_TEMP}/Makefile.petsc") file (WRITE "${petsc_config_makefile}" "## This file was auto generated by CMake # PETSC_DIR = ${PETSC_DIR} @@ -49,6 +50,7 @@ compilerc: linker: \t@echo \${LINKERNAME}") + # CMake will execute each target in the ${petsc_config_makefile} # to acquire corresponding PETSc Variables. # The include path and linking libraries in PETSc usually contains @@ -100,6 +102,10 @@ foreach (exlib ${TMP_LIST}) set(PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB} ${exlib}") endforeach(exlib) +set(CMAKE_Fortran_COMPILER "${MPIEXEC}") +set(CMAKE_C_COMPILER "${COMPILERC}") +project (DAMASK Fortran C) + message("***Found PETSC_DIR:\n${PETSC_DIR}\n" ) message("***Found PETSC_INCLUDES:\n${PETSC_INCLUDES}\n" ) message("***Found PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")