# ============================================================================
# List aevol main binaries
# ============================================================================
set(AEVOL_BINS create run)


# Set dummy targets to be used by the user when they want to build a subset of
# aevol flavors, e.g. `make aevol_4b`
# Dependencies will be added to these targets as we define them
foreach (AEVOL_FLAVOR IN LISTS AEVOL_FLAVORS)
  add_custom_target(${AEVOL_FLAVOR})
endforeach (AEVOL_FLAVOR)

# ============================================================================
# Tell cmake about subdirectories to look into
# ============================================================================
add_subdirectory(libaevol)

if (with-post-treatments)
  add_subdirectory(post_treatments)
endif()

# ============================================================================
# Add targets add their dependencies
# ============================================================================
foreach (AEVOL_RAW_FLAVOR IN LISTS AEVOL_RAW_FLAVORS)
  foreach (AEVOL_BIN IN LISTS AEVOL_BINS)
    set(FLAVORED_BIN_NAME aevol_${AEVOL_BIN}_${AEVOL_RAW_FLAVOR})
    add_executable(${FLAVORED_BIN_NAME} aevol_${AEVOL_BIN}.cpp)
    target_link_libraries(${FLAVORED_BIN_NAME} PUBLIC libaevol_${AEVOL_RAW_FLAVOR})
    add_dependencies(aevol_${AEVOL_RAW_FLAVOR} ${FLAVORED_BIN_NAME})
  endforeach (AEVOL_BIN)
endforeach (AEVOL_RAW_FLAVOR)

# ============================================================================
# Set behaviour on make install
# ============================================================================
foreach (AEVOL_RAW_FLAVOR IN LISTS AEVOL_RAW_FLAVORS)
  install(TARGETS aevol_create_${AEVOL_RAW_FLAVOR})
  install(TARGETS aevol_run_${AEVOL_RAW_FLAVOR})
endforeach (AEVOL_RAW_FLAVOR)
