cmake_minimum_required(VERSION 3.9.0)

#if(POLICY CMP0025)
#  #setup policy rules for CMake 3.0 while we have a minimum required of 2.8.X
#  #both 42 and 25 were introduced in the same cmake version
#  cmake_policy(SET CMP0025 NEW)  # Clang is now Clang and Apple Clang
#  cmake_policy(SET CMP0042 OLD)  # Disable @rpath on Apple
#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()

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

option(CMB_BUILD_TESTING "Build CMB Testing" ON)
if (CMB_BUILD_TESTING)
  enable_testing()
  include(CTest)
endif()

# Fetch CMB version from version.txt and set up install/output directories:
include(CMBInstallRules)

# Add options for performing code coverage tests:
include(CMBCoverage)

# 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")

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

include(${PARAVIEW_USE_FILE})

add_subdirectory(thirdparty)
add_subdirectory(modelbuilder)

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