avoid hardcoding (requires/ensures systematic naming)
This commit is contained in:
parent
e39a9610d8
commit
ebb2e3ca85
|
@ -17,17 +17,14 @@ pkg_get_variable(CMAKE_Fortran_COMPILER PETSc fcompiler)
|
|||
pkg_get_variable(CMAKE_C_COMPILER PETSc ccompiler)
|
||||
|
||||
# Solver determines name of project
|
||||
string(TOUPPER "${DAMASK_SOLVER}" DAMASK_SOLVER)
|
||||
if(DAMASK_SOLVER STREQUAL "GRID")
|
||||
project(damask-grid HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||
elseif(DAMASK_SOLVER STREQUAL "MESH")
|
||||
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)
|
||||
string(TOUPPER "${DAMASK_SOLVER}" DAMASK_SOLVER_UPPER)
|
||||
string(TOLOWER "${DAMASK_SOLVER}" DAMASK_SOLVER_LOWER)
|
||||
if("${DAMASK_SOLVER_UPPER}" MATCHES "^(GRID|MESH|TEST)$")
|
||||
project("damask-${DAMASK_SOLVER_LOWER}" HOMEPAGE_URL https://damask.mpie.de LANGUAGES Fortran C)
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid solver: DAMASK_SOLVER=${DAMASK_SOLVER}")
|
||||
endif()
|
||||
add_definitions("-D${DAMASK_SOLVER}")
|
||||
add_definitions("-D${DAMASK_SOLVER_UPPER}")
|
||||
|
||||
set(CMAKE_Fortran_PREPROCESS "ON") # works only for CMake >= 3.18
|
||||
|
||||
|
|
|
@ -1,16 +1,7 @@
|
|||
file(GLOB damask-sources CONFIGURE_DEPENDS *.f90 *.c)
|
||||
|
||||
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)
|
||||
elseif(PROJECT_NAME STREQUAL "damask-test")
|
||||
set(executable-name "DAMASK_test")
|
||||
file(GLOB solver-sources CONFIGURE_DEPENDS test/*.f90)
|
||||
endif()
|
||||
|
||||
set(executable-name "DAMASK_${DAMASK_SOLVER_LOWER}")
|
||||
file(GLOB solver-sources CONFIGURE_DEPENDS ${DAMASK_SOLVER_LOWER}/*.f90)
|
||||
|
||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY")
|
||||
add_executable(${executable-name} ${damask-sources} ${solver-sources})
|
||||
|
|
Loading…
Reference in New Issue