project(TOOLS)

# list of TOOLS (option)
set(TOOLS_LIST lml pml qcustomplot mml coreschema)
# qtpropertybrowser is mandatory
set(TOOLS_SUBDIRS qtpropertybrowser)

#set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose makefile" FORCE)
set(TOOLS_INCLUDE_DIRECTORIES ${CAMITK_INCLUDE_DIRECTORIES})
set(TOOLS_LIBRARIES ) # Those libraries do not depend on anything...

foreach(TOOL_NAME ${TOOLS_LIST})
  string(TOUPPER ${TOOL_NAME} TOOL_NAME_CMAKE)
  if(NOT CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL)
      message(STATUS "Checking ${TOOL_NAME}")
      # add option to enable/disable this tool
      set(TOOL_${TOOL_NAME_CMAKE} FALSE CACHE BOOL "Build tool ${TOOL_NAME}")
      set(CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL TRUE CACHE BOOL "Is variable CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL already created?")
      mark_as_advanced(CAMITK_TOOL_${TOOL_NAME_CMAKE}_INTERNAL)
    endif()
endforeach()

foreach(TOOL_NAME ${TOOLS_LIST})
  string(TOUPPER ${TOOL_NAME} TOOL_NAME_CMAKE)
  if (TOOL_${TOOL_NAME_CMAKE})
    set(TOOLS_SUBDIRS ${TOOLS_SUBDIRS} ${TOOL_NAME})
  endif()
endforeach()

# Add subdirectories in CMake project
foreach(TOOL_NAME ${TOOLS_SUBDIRS})
  add_subdirectory(${TOOL_NAME})
  message(STATUS "Building tool ${TOOL_NAME}") 
endforeach()
