cmake_minimum_required(VERSION 3.12)

project(PulseExplorer VERSION 3.1.0 LANGUAGES C CXX)

include(cmake/config.cmake)

#------------------------------------------------------------------------------
# Superbuild
#------------------------------------------------------------------------------
option(${PROJECT_NAME}_SUPERBUILD
  "Build ourself and our dependencies as subprojects"
  ON
  )
option(${PROJECT_NAME}_LIBRARY_ONLY
  "Build only the widget library, not the executable"
  OFF
  )
option(${PROJECT_NAME}_CREATE_EXPORT
  "Install only the widget library, always installed if LIBRARY_ONLY is selected"
  OFF
  )

if(${PROJECT_NAME}_SUPERBUILD)

  include(cmake/superbuild.cmake)

  if(${PROJECT_NAME}_DEPENDENCIES)
    # Transfer to cmake/external/CMakeLists.txt which will drive building our
    # dependencies, and ourself, as external projects, and then halt further
    # evaluation; the external project for ourself will reinvoke this same
    # CMakeLists.txt with SUPERBUILD=OFF
    add_subdirectory(cmake/external)
    return()
  else()
    message(STATUS "No dependencies are enabled, skipping superbuild")
  endif()
endif()

#------------------------------------------------------------------------------
# Regular build
#------------------------------------------------------------------------------

# Include various utility modules
include(CMakePackageConfigHelpers)
include(GenerateExportHeader)
include(GNUInstallDirs)

# Include project dependencies and utilities
include(cmake/dependencies.cmake)
include(cmake/utilities.cmake)

add_subdirectory(src)
