cmake_minimum_required(VERSION 3.4...3.18)
project(aggfuse_cpu LANGUAGES CXX)

set(CMAKE_CXX_FLAGS "-Wall -Wextra")

set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -g")
set (CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address")

set(CMAKE_CXX_FLAGS_RELEASE "-O3 -march=native")

find_package(pybind11 CONFIG)
find_package(BLAS REQUIRED)
if(BLAS_FOUND)
    message("BLAS found.")
    include_directories(${BLAS_INCLUDE_DIRS})
    link_libraries(${BLAS_LIBRARIES})
endif(BLAS_FOUND)
pybind11_add_module(aggfuse_cpu src/main.cpp)

# EXAMPLE_VERSION_INFO is defined by setup.py and passed into the C++ code as a
# define (VERSION_INFO) here.
target_compile_definitions(aggfuse_cpu PRIVATE VERSION_INFO=${EXAMPLE_VERSION_INFO})
target_compile_features(aggfuse_cpu PUBLIC cxx_std_17)
set_target_properties(aggfuse_cpu PROPERTIES CXX_EXTENSIONS OFF)
