cmake_minimum_required(VERSION 3.10)
project(spectra)

if (NOT IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/pybind11/docs")
  message(FATAL_ERROR "The project dependencies are missing! "
    "You probably did not clone the project with --recursive. It is possible to recover "
    "by calling \"git submodule update --init --recursive\"")
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
  message(STATUS "Setting build type to 'Release' as none was specified.")
  set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release"
    "MinSizeRel" "RelWithDebInfo")
endif()

# use -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_subdirectory(pybind11)
set(TBB_BUILD_SHARED          OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_STATIC          ON  CACHE BOOL " " FORCE)
set(TBB_BUILD_TESTS           OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC       OFF CACHE BOOL " " FORCE)
set(TBB_BUILD_TBBMALLOC_PROXY OFF CACHE BOOL " " FORCE)
add_subdirectory(tbb)

include_directories(
  /usr/local/include
  /usr/local/include/eigen3
  /usr/include/eigen3
  /usr/include/python3.6m
  ${CMAKE_CURRENT_SOURCE_DIR}/tbb/include
)
link_directories(
  /usr/local/lib
)
add_compile_options(-std=c++14)

pybind11_add_module(spectra spectra.cpp)
target_link_libraries(spectra PRIVATE glog ceres tbb_static)

