﻿# This CMakeLists file will add the source files in this directory for compilation

# common_includes will have all the functions and classes from CBICA_Toolkit_ITK branch and more

# each header file, "$application.h" : main entry point of an application whose input will be either a single "itk::Image" or a "std::vector< itk::Image >"

# each application-specific include folder, "/$application_includes" : dependencies which are not taken care by the default dependencies (i.e., ITK and OpenCV), for example libSVM for recurrence 

FILE( GLOB 
  COMMON_DEPENDENCIES
  "${CMAKE_CURRENT_SOURCE_DIR}/common_includes/*.h"
  "${CMAKE_CURRENT_SOURCE_DIR}/common_includes/*.cpp"
)

SET( SOURCES "" )
SET( DEPENDENCIES ${COMMON_DEPENDENCIES} )
SET( INCLUDES "")

SET( APPLICATIONS
  EGFRvIIISurrogateIndex
  GeodesicSegmentation
  RecurrenceEstimator
  SurvivalPredictor
)
SET( APP_LIST "" )

SET(PREPROCESSING_ALGOS "Denoise-SUSAN Register BiasCorrect-N3" CACHE STRING "All Preprocessing algorithms available")

FOREACH(application ${APPLICATIONS})
  
  # ensure that specified application has been found
  IF( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${application}.h") 
    SET( SOURCES 
      ${SOURCES} 
      "${CMAKE_CURRENT_SOURCE_DIR}/${application}.h"
    )
    
    # if implementation is present, include that for compilation
    IF( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${application}.cpp")
      SET( SOURCES 
        ${SOURCES} 
        "${CMAKE_CURRENT_SOURCE_DIR}/${application}.cpp"
      )
    ENDIF()
    
    # include dependency directory of ${application} for compilation
    SET( INCLUDES
      ${INCLUDES}
      "${CMAKE_CURRENT_SOURCE_DIR}/${application}_includes/"
    )
    
    # add all dependencies of ${application} to compilation
    FILE( GLOB 
      APPLICATION_SPECIFIC_DEPENDENCIES
      "${CMAKE_CURRENT_SOURCE_DIR}/${application}_includes/*.h"
      "${CMAKE_CURRENT_SOURCE_DIR}/${application}_includes/*.cpp"
    )
    
    # keep storing all dependencies
    SET( DEPENDENCIES
      ${DEPENDENCIES}
      ${APPLICATION_SPECIFIC_DEPENDENCIES}
    )
    
    # add to variable which will be used in source code to generate menu items
    SET( APP_LIST "${APP_LIST} ${application}" )
  ENDIF()
  
ENDFOREACH()

SET( INCLUDES
      ${INCLUDES}
    )

SET( APPS_LIST_PY_GUI "ITK-SNAP LIBRA Confetti WhiteStripe SBRT_Segmentation SBRT_Analyze" CACHE STRING "Stand-alone apps")

SET( APP_LIST ${APP_LIST} CACHE STRING "All Applications")
SET( APPLICATION_SOURCES  "${SOURCES}" CACHE STRING "All Application sources")
SET( APPLICATION_INCLUDES "${INCLUDES}" CACHE STRING "All Application dependency folders")
SET( APPLICATION_DEPENDS "${DEPENDENCIES}" CACHE STRING "All Application dependencies" FORCE)

MARK_AS_ADVANCED(${APPLICATION_SOURCES} )
MARK_AS_ADVANCED(${APPLICATION_INCLUDES})
MARK_AS_ADVANCED(${APPLICATION_DEPENDS} )
MARK_AS_ADVANCED(${APP_LIST}            )
MARK_AS_ADVANCED(${APPS_LIST_PY_GUI}            )
