cmake_minimum_required(VERSION 3.15..3.26)

# Set a name and a version number for your project:
project(
  pybind11-numpy-example
  VERSION 0.0.10
  LANGUAGES CXX)

# Initialize some default paths
include(GNUInstallDirs)

# Define the minimum C++ standard that is required
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Configuration options
option(BUILD_PYTHON "Enable building of Python bindings" ON)
option(BUILD_DOCS "Enable building of documentation" ON)

# Build the c++ library
add_subdirectory(lib)

# Build the c++ tests
include(CTest)
if(BUILD_TESTING)
  add_subdirectory(ext/Catch2)
  include(./ext/Catch2/extras/Catch.cmake)
  add_subdirectory(tests/cpp)
endif()

# Build the documentation
if(BUILD_DOCS)
  add_subdirectory(doc)
endif()

# Build the python bindings
if(BUILD_PYTHON)
  add_subdirectory(src)
endif()

# Add an alias target for use if this project is included as a subproject in
# another project
add_library(pybind11_numpy_example::pybind11_numpy_example ALIAS
            pybind11_numpy_example)

# Install targets and configuration
install(
  TARGETS pybind11_numpy_example
  EXPORT pybind11_numpy_example_config
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})

install(
  EXPORT pybind11_numpy_example_config
  NAMESPACE pybind11_numpy_example::
  DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pybind11_numpy_example)

install(DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/include/
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# This prints a summary of found dependencies
include(FeatureSummary)
feature_summary(WHAT ALL)
