cmake_minimum_required(VERSION 3.9.0)

if (POLICY CMP0048)
  cmake_policy(SET CMP0048 NEW)
endif()

#If the user/superbuild hasn't explicitly stated what c++ standard to use
#require C++11
if(NOT DEFINED CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 11)
  set(CMAKE_CXX_STANDARD_REQUIRED True)
  set(CMAKE_CXX_EXTENSIONS FALSE)
endif()

################################################################################
# CMB version number
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CMBVersion.cmake)

project(cmb VERSION ${cmb_version})
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

find_package(ParaView COMPONENTS vtkIOGDAL REQUIRED)
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)

include(CMBPreamble) # Determine architecture, set up build-output directories.
include(CMBTesting) # Add an option to enable testing and set up pointers to the test data.
include(CMBInstallRules) # Fetch CMB version from version.txt and set up install/output directories.
include(CMBCoverage) # Add options for performing code coverage tests.

# Do not report some warnings from generated code to the dashboard:
configure_file(
  "${CMAKE_CURRENT_SOURCE_DIR}/CTestCustom.cmake.in"
  "${CMAKE_CURRENT_BINARY_DIR}/CTestCustom.cmake")

set(cmb_plugin_paths
  "${cmb_plugin_paths}"
  "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
  CACHE STRING "Semi-colon separated paths for testing plugins."
)
mark_as_advanced(cmb_plugin_paths)

add_subdirectory(thirdparty)
add_subdirectory(plugins) # Plugins must be built before the app so .plugins file will be correct.
add_subdirectory(modelbuilder)

option(cmb_enable_documentation "Include targets Sphinx-generated documentation" OFF)
if (cmb_enable_documentation)
  find_package(Sphinx)
  add_subdirectory(doc)
endif()

# Add rules to build packages
include(CMBPackaging)
