avoid hardcoding (requires/ensures systematic naming)

This commit is contained in:
Martin Diehl 2023-12-30 15:52:35 +01:00
parent e39a9610d8
commit ebb2e3ca85
No known key found for this signature in database
GPG Key ID: 1FD50837275A0A9B
2 changed files with 7 additions and 19 deletions

View File

@ -17,17 +17,14 @@ 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_UPPER)
if(DAMASK_SOLVER STREQUAL "GRID") string(TOLOWER "${DAMASK_SOLVER}" DAMASK_SOLVER_LOWER)
project(damask-grid HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C) if("${DAMASK_SOLVER_UPPER}" MATCHES "^(GRID|MESH|TEST)$")
elseif(DAMASK_SOLVER STREQUAL "MESH") project("damask-${DAMASK_SOLVER_LOWER}" HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
project(damask-mesh HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
elseif(DAMASK_SOLVER STREQUAL "TEST")
project(damask-test 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_UPPER}")
set(CMAKE_Fortran_PREPROCESS "ON") # works only for CMake >= 3.18 set(CMAKE_Fortran_PREPROCESS "ON") # works only for CMake >= 3.18

View File

@ -1,16 +1,7 @@
file(GLOB damask-sources CONFIGURE_DEPENDS *.f90 *.c) file(GLOB damask-sources CONFIGURE_DEPENDS *.f90 *.c)
if(PROJECT_NAME STREQUAL "damask-grid") set(executable-name "DAMASK_${DAMASK_SOLVER_LOWER}")
set(executable-name "DAMASK_grid") file(GLOB solver-sources CONFIGURE_DEPENDS ${DAMASK_SOLVER_LOWER}/*.f90)
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)
elseif(PROJECT_NAME STREQUAL "damask-test")
set(executable-name "DAMASK_test")
file(GLOB solver-sources CONFIGURE_DEPENDS test/*.f90)
endif()
if(NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY") if(NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
add_executable(${executable-name} ${damask-sources} ${solver-sources}) add_executable(${executable-name} ${damask-sources} ${solver-sources})