Merge branch 'Cmake-write-file-list' into 'development'
save list of files used for compilation See merge request damask/DAMASK!443
This commit is contained in:
commit
5995a78773
170
CMakeLists.txt
170
CMakeLists.txt
|
@ -1,117 +1,117 @@
|
||||||
cmake_minimum_required (VERSION 3.12.0)
|
cmake_minimum_required(VERSION 3.12.0)
|
||||||
include (FindPkgConfig REQUIRED)
|
include(FindPkgConfig REQUIRED)
|
||||||
|
|
||||||
if (DEFINED ENV{PETSC_DIR})
|
if(DEFINED ENV{PETSC_DIR})
|
||||||
message ("PETSC_DIR:\n$ENV{PETSC_DIR}\n")
|
message("PETSC_DIR:\n$ENV{PETSC_DIR}\n")
|
||||||
else ()
|
else()
|
||||||
message (FATAL_ERROR "PETSc location (PETSC_DIR) is not defined")
|
message(FATAL_ERROR "PETSc location (PETSC_DIR) is not defined")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
# Dummy project to determine compiler names and version
|
# Dummy project to determine compiler names and version
|
||||||
project (Prerequisites LANGUAGES)
|
project(Prerequisites LANGUAGES)
|
||||||
set(ENV{PKG_CONFIG_PATH} "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig")
|
set(ENV{PKG_CONFIG_PATH} "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/pkgconfig")
|
||||||
pkg_check_modules (PETSC REQUIRED PETSc>=3.12.0 PETSc<3.17.0)
|
pkg_check_modules(PETSC REQUIRED PETSc>=3.12.0 PETSc<3.17.0)
|
||||||
pkg_get_variable (CMAKE_Fortran_COMPILER PETSc fcompiler)
|
pkg_get_variable(CMAKE_Fortran_COMPILER PETSc fcompiler)
|
||||||
pkg_get_variable (CMAKE_C_COMPILER PETSc ccompiler)
|
pkg_get_variable(CMAKE_C_COMPILER PETSc ccompiler)
|
||||||
|
|
||||||
# Solver determines name of project
|
# Solver determines name of project
|
||||||
string(TOUPPER "${DAMASK_SOLVER}" DAMASK_SOLVER)
|
string(TOUPPER "${DAMASK_SOLVER}" DAMASK_SOLVER)
|
||||||
if (DAMASK_SOLVER STREQUAL "GRID")
|
if(DAMASK_SOLVER STREQUAL "GRID")
|
||||||
project (damask-grid HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
project(damask-grid HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||||
elseif (DAMASK_SOLVER STREQUAL "MESH")
|
elseif(DAMASK_SOLVER STREQUAL "MESH")
|
||||||
project (damask-mesh HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
project(damask-mesh HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||||
else ()
|
else()
|
||||||
message (FATAL_ERROR "Invalid solver: DAMASK_SOLVER=${DAMASK_SOLVER}")
|
message(FATAL_ERROR "Invalid solver: DAMASK_SOLVER=${DAMASK_SOLVER}")
|
||||||
endif ()
|
endif()
|
||||||
add_definitions ("-D${DAMASK_SOLVER}")
|
add_definitions("-D${DAMASK_SOLVER}")
|
||||||
|
|
||||||
file (STRINGS ${PROJECT_SOURCE_DIR}/VERSION DAMASK_VERSION)
|
file(STRINGS ${PROJECT_SOURCE_DIR}/VERSION DAMASK_VERSION)
|
||||||
|
|
||||||
message ("\nBuilding ${CMAKE_PROJECT_NAME} ${DAMASK_VERSION}\n")
|
message("\nBuilding ${CMAKE_PROJECT_NAME} ${DAMASK_VERSION}\n")
|
||||||
|
|
||||||
add_definitions (-DPETSC)
|
add_definitions(-DPETSC)
|
||||||
add_definitions (-DDAMASKVERSION="${DAMASK_VERSION}")
|
add_definitions(-DDAMASKVERSION="${DAMASK_VERSION}")
|
||||||
add_definitions (-DCMAKE_SYSTEM="${CMAKE_SYSTEM}")
|
add_definitions(-DCMAKE_SYSTEM="${CMAKE_SYSTEM}")
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "")
|
if(CMAKE_BUILD_TYPE STREQUAL "")
|
||||||
set (CMAKE_BUILD_TYPE "RELEASE")
|
set(CMAKE_BUILD_TYPE "RELEASE")
|
||||||
endif ()
|
endif()
|
||||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
# Predefined sets for OPTIMIZATION/OPENMP based on BUILD_TYPE
|
# Predefined sets for OPTIMIZATION/OPENMP based on BUILD_TYPE
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
if(CMAKE_BUILD_TYPE STREQUAL "DEBUG" OR CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -DDEBUG")
|
set(DEBUG_FLAGS "${DEBUG_FLAGS} -DDEBUG")
|
||||||
set (PARALLEL "OFF")
|
set(PARALLEL "OFF")
|
||||||
set (OPTI "OFF")
|
set(OPTI "OFF")
|
||||||
elseif (CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
elseif(CMAKE_BUILD_TYPE STREQUAL "RELEASE")
|
||||||
set (PARALLEL "ON")
|
set(PARALLEL "ON")
|
||||||
set (OPTI "DEFENSIVE")
|
set(OPTI "DEFENSIVE")
|
||||||
elseif (CMAKE_BUILD_TYPE STREQUAL "DEBUGRELEASE")
|
elseif(CMAKE_BUILD_TYPE STREQUAL "DEBUGRELEASE")
|
||||||
set (DEBUG_FLAGS "${DEBUG_FLAGS} -DDEBUG")
|
set(DEBUG_FLAGS "${DEBUG_FLAGS} -DDEBUG")
|
||||||
set (PARALLEL "ON")
|
set(PARALLEL "ON")
|
||||||
set (OPTI "DEFENSIVE")
|
set(OPTI "DEFENSIVE")
|
||||||
elseif (CMAKE_BUILD_TYPE STREQUAL "PERFORMANCE")
|
elseif(CMAKE_BUILD_TYPE STREQUAL "PERFORMANCE")
|
||||||
set (PARALLEL "ON")
|
set(PARALLEL "ON")
|
||||||
set (OPTI "AGGRESSIVE")
|
set(OPTI "AGGRESSIVE")
|
||||||
else ()
|
else()
|
||||||
message (FATAL_ERROR "Invalid build type: CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
message(FATAL_ERROR "Invalid build type: CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
# $OPTIMIZATION takes precedence over $BUILD_TYPE defaults
|
# $OPTIMIZATION takes precedence over $BUILD_TYPE defaults
|
||||||
if (OPTIMIZATION STREQUAL "" OR NOT DEFINED OPTIMIZATION)
|
if(OPTIMIZATION STREQUAL "" OR NOT DEFINED OPTIMIZATION)
|
||||||
set (OPTIMIZATION "${OPTI}")
|
set(OPTIMIZATION "${OPTI}")
|
||||||
else ()
|
else()
|
||||||
set (OPTIMIZATION "${OPTIMIZATION}")
|
set(OPTIMIZATION "${OPTIMIZATION}")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
# $OPENMP takes precedence over $BUILD_TYPE defaults
|
# $OPENMP takes precedence over $BUILD_TYPE defaults
|
||||||
if (OPENMP STREQUAL "" OR NOT DEFINED OPENMP)
|
if(OPENMP STREQUAL "" OR NOT DEFINED OPENMP)
|
||||||
set (OPENMP "${PARALLEL}")
|
set(OPENMP "${PARALLEL}")
|
||||||
else ()
|
else()
|
||||||
set(OPENMP "${OPENMP}")
|
set(OPENMP "${OPENMP}")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
# syntax check only (mainly for pre-receive hook)
|
# syntax check only(mainly for pre-receive hook)
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
if(CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
set (BUILDCMD_POST "${BUILDCMD_POST} -fsyntax-only")
|
set(BUILDCMD_POST "${BUILDCMD_POST} -fsyntax-only")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
|
||||||
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
|
if (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
|
||||||
include (Compiler-Intel)
|
include(Compiler-Intel)
|
||||||
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||||
include (Compiler-GNU)
|
include(Compiler-GNU)
|
||||||
else ()
|
else()
|
||||||
message (FATAL_ERROR "Compiler type (CMAKE_Fortran_COMPILER_ID) not recognized")
|
message(FATAL_ERROR "Compiler type(CMAKE_Fortran_COMPILER_ID) not recognized")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
file (STRINGS "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/petsc/conf/petscvariables" PETSC_EXTERNAL_LIB REGEX "PETSC_WITH_EXTERNAL_LIB = .*$?")
|
file(STRINGS "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/petsc/conf/petscvariables" PETSC_EXTERNAL_LIB REGEX "PETSC_WITH_EXTERNAL_LIB = .*$?")
|
||||||
string (REGEX MATCHALL "-[lLW]([^\" ]+)" PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB}")
|
string(REGEX MATCHALL "-[lLW]([^\" ]+)" PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB}")
|
||||||
list (REMOVE_DUPLICATES PETSC_EXTERNAL_LIB)
|
list(REMOVE_DUPLICATES PETSC_EXTERNAL_LIB)
|
||||||
string (REPLACE ";" " " PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB}")
|
string(REPLACE ";" " " PETSC_EXTERNAL_LIB "${PETSC_EXTERNAL_LIB}")
|
||||||
message ("PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
|
message("PETSC_EXTERNAL_LIB:\n${PETSC_EXTERNAL_LIB}\n")
|
||||||
|
|
||||||
file (STRINGS "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/petsc/conf/petscvariables" PETSC_INCLUDES REGEX "PETSC_FC_INCLUDES = .*$?")
|
file(STRINGS "$ENV{PETSC_DIR}/$ENV{PETSC_ARCH}/lib/petsc/conf/petscvariables" PETSC_INCLUDES REGEX "PETSC_FC_INCLUDES = .*$?")
|
||||||
string (REGEX MATCHALL "-I([^\" ]+)" PETSC_INCLUDES "${PETSC_INCLUDES}")
|
string(REGEX MATCHALL "-I([^\" ]+)" PETSC_INCLUDES "${PETSC_INCLUDES}")
|
||||||
list (REMOVE_DUPLICATES PETSC_INCLUDES)
|
list(REMOVE_DUPLICATES PETSC_INCLUDES)
|
||||||
string (REPLACE ";" " " PETSC_INCLUDES "${PETSC_INCLUDES}")
|
string(REPLACE ";" " " PETSC_INCLUDES "${PETSC_INCLUDES}")
|
||||||
message ("PETSC_INCLUDES:\n${PETSC_INCLUDES}\n")
|
message("PETSC_INCLUDES:\n${PETSC_INCLUDES}\n")
|
||||||
|
|
||||||
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${BUILDCMD_PRE} ${OPENMP_FLAGS} ${STANDARD_CHECK} ${OPTIMIZATION_FLAGS} ${COMPILE_FLAGS} ${PRECISION_FLAGS}")
|
set(CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${BUILDCMD_PRE} ${OPENMP_FLAGS} ${STANDARD_CHECK} ${OPTIMIZATION_FLAGS} ${COMPILE_FLAGS} ${PRECISION_FLAGS}")
|
||||||
set (CMAKE_Fortran_LINK_EXECUTABLE "${BUILDCMD_PRE} ${CMAKE_Fortran_COMPILER} ${OPENMP_FLAGS} ${OPTIMIZATION_FLAGS} ${LINKER_FLAGS}")
|
set(CMAKE_Fortran_LINK_EXECUTABLE "${BUILDCMD_PRE} ${CMAKE_Fortran_COMPILER} ${OPENMP_FLAGS} ${OPTIMIZATION_FLAGS} ${LINKER_FLAGS}")
|
||||||
|
|
||||||
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
if(CMAKE_BUILD_TYPE STREQUAL "DEBUG")
|
||||||
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${DEBUG_FLAGS}")
|
set(CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${DEBUG_FLAGS}")
|
||||||
set (CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} ${DEBUG_FLAGS}")
|
set(CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} ${DEBUG_FLAGS}")
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
set (CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${PETSC_INCLUDES} ${BUILDCMD_POST}")
|
set(CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE} "${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}} ${PETSC_INCLUDES} ${BUILDCMD_POST}")
|
||||||
set (CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} -lz ${BUILDCMD_POST}")
|
set(CMAKE_Fortran_LINK_EXECUTABLE "${CMAKE_Fortran_LINK_EXECUTABLE} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> ${PETSC_EXTERNAL_LIB} -lz ${BUILDCMD_POST}")
|
||||||
|
|
||||||
message ("Fortran Compiler Flags:\n${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}\n")
|
message("Fortran Compiler Flags:\n${CMAKE_Fortran_FLAGS_${CMAKE_BUILD_TYPE}}\n")
|
||||||
message ("C Compiler Flags:\n${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}\n")
|
message("C Compiler Flags:\n${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}\n")
|
||||||
message ("Fortran Linker Command:\n${CMAKE_Fortran_LINK_EXECUTABLE}\n")
|
message("Fortran Linker Command:\n${CMAKE_Fortran_LINK_EXECUTABLE}\n")
|
||||||
|
|
||||||
# location of code
|
# location of code
|
||||||
add_subdirectory (src)
|
add_subdirectory(src)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# special flags for some files
|
# special flags for some files
|
||||||
if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
|
||||||
# long lines for interaction matrix
|
# long lines for interaction matrix
|
||||||
SET_SOURCE_FILES_PROPERTIES("lattice.f90" PROPERTIES COMPILE_FLAGS "-ffree-line-length-240")
|
SET_SOURCE_FILES_PROPERTIES("lattice.f90" PROPERTIES COMPILE_FLAGS "-ffree-line-length-240")
|
||||||
endif()
|
endif()
|
||||||
|
@ -12,25 +12,24 @@ list(FILTER damask-sources EXCLUDE REGEX ".*DAMASK_Marc.*.f90")
|
||||||
list(FILTER damask-sources EXCLUDE REGEX ".*commercialFEM_fileList.*.f90")
|
list(FILTER damask-sources EXCLUDE REGEX ".*commercialFEM_fileList.*.f90")
|
||||||
|
|
||||||
|
|
||||||
if (PROJECT_NAME STREQUAL "damask-grid")
|
if(PROJECT_NAME STREQUAL "damask-grid")
|
||||||
|
set(executable-name "DAMASK_grid")
|
||||||
|
file(GLOB solver-sources CONFIGURE_DEPENDS grid/*.f90)
|
||||||
|
elseif(PROJECT_NAME STREQUAL "damask-mesh")
|
||||||
|
set(executable-name "DAMASK_mesh")
|
||||||
|
file(GLOB solver-sources CONFIGURE_DEPENDS mesh/*.f90)
|
||||||
|
endif()
|
||||||
|
|
||||||
file(GLOB grid-sources CONFIGURE_DEPENDS grid/*.f90)
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||||
|
add_executable(${executable-name} ${damask-sources} ${solver-sources})
|
||||||
|
install(TARGETS ${executable-name} RUNTIME DESTINATION bin)
|
||||||
|
else()
|
||||||
|
add_library(${executable-name} OBJECT ${damask-sources} ${solver-sources})
|
||||||
|
exec_program(mktemp OUTPUT_VARIABLE nothing)
|
||||||
|
exec_program(mktemp ARGS -d OUTPUT_VARIABLE black_hole)
|
||||||
|
install(PROGRAMS ${nothing} DESTINATION ${black_hole})
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
string(REPLACE ";" "\n" sources "${damask-sources};${solver-sources}")
|
||||||
add_executable(DAMASK_grid ${damask-sources} ${grid-sources})
|
message(${CMAKE_BINARY_DIR})
|
||||||
install (TARGETS DAMASK_grid RUNTIME DESTINATION bin)
|
file(WRITE ${CMAKE_BINARY_DIR}/sources.txt ${sources})
|
||||||
else ()
|
|
||||||
add_library(DAMASK_grid OBJECT ${damask-sources} ${grid-sources})
|
|
||||||
exec_program (mktemp OUTPUT_VARIABLE nothing)
|
|
||||||
exec_program (mktemp ARGS -d OUTPUT_VARIABLE black_hole)
|
|
||||||
install (PROGRAMS ${nothing} DESTINATION ${black_hole})
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
elseif (PROJECT_NAME STREQUAL "damask-mesh")
|
|
||||||
|
|
||||||
file(GLOB mesh-sources CONFIGURE_DEPENDS mesh/*.f90)
|
|
||||||
|
|
||||||
add_executable(DAMASK_mesh ${damask-sources} ${mesh-sources})
|
|
||||||
install (TARGETS DAMASK_mesh RUNTIME DESTINATION bin)
|
|
||||||
|
|
||||||
endif ()
|
|
||||||
|
|
Loading…
Reference in New Issue