From c628c028dc4dca68da2acc4316b63ff0ab7a3e59 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 15 Oct 2021 22:14:37 +0200 Subject: [PATCH] SYNTAXONLY for mesh, avoid code duplication --- src/CMakeLists.txt | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6ffa26441..cb1436579 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,5 @@ # special flags for some files -if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") +if(CMAKE_Fortran_COMPILER_ID STREQUAL "GNU") # long lines for interaction matrix SET_SOURCE_FILES_PROPERTIES("lattice.f90" PROPERTIES COMPILE_FLAGS "-ffree-line-length-240") endif() @@ -12,25 +12,20 @@ list(FILTER damask-sources EXCLUDE REGEX ".*DAMASK_Marc.*.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(DAMASK_grid ${damask-sources} ${grid-sources}) - install (TARGETS DAMASK_grid RUNTIME DESTINATION bin) - 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 () +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(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()