cmake_minimum_required(VERSION 3.21)
project(graph_tutorial)

##
## Add our cmake directory to the module search path
##
list(INSERT CMAKE_MODULE_PATH 0
  ${PROJECT_SOURCE_DIR}/cmake)

##
## This plugin requires 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()

##
## Find dependent packages and configure build options.
##

# We find SMTK and ParaView since we use the API of both directly.
# In some cases, only SMTK is required (i.e., you use SMTK APIs
# which may themselves use ParaView, but do not use ParaView/VTK
# directly).
find_package(smtk REQUIRED)
find_package(ParaView REQUIRED)

# Since we are building ParaView plugins in some steps, we need shared libraries.
set(BUILD_SHARED_LIBS ON)

##
## Prepare installation paths as needed for ParaView plugins
##
# Setting this ensures that "make install" will leave rpaths to external
# libraries (not part of the build-tree e.g. Qt, ffmpeg, etc.) intact on
# "make install". This ensures that one can install a version of ParaView on the
# build machine without any issues. If this not desired, simply specify
# CMAKE_INSTALL_RPATH_USE_LINK_PATH when configuring and "make install" will
# strip all rpaths, which is default behavior.
if (NOT DEFINED CMAKE_INSTALL_RPATH_USE_LINK_PATH)
  set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif ()

# Use GNU install directories.
include(GNUInstallDirs)
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}-${PROJECT_VERSION}")

# Set the directory where the binaries will be stored
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_BINDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_CMAKE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR})

##
## Turn on testing (the exercises and solutions are registered as CMake tests).
##
include(CTest)
enable_testing()
include(TestingMacros)

##
## Build the code for the exercises (in subdirectories).
##
add_subdirectory(exercises)
add_subdirectory(solutions)
