CMAKE_MINIMUM_REQUIRED(VERSION 3.8.2 FATAL_ERROR)
PROJECT(mmm_api)

SET(CMAKE_CXX_STANDARD 17)
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_POSITION_INDEPENDENT_CODE ON)

add_definitions(-DPYBIND=1)
add_definitions(-DNOTORCH=1)

ADD_SUBDIRECTORY(pybind11)

INCLUDE_DIRECTORIES(midifile/include)
FILE(GLOB MIDIFILE_SRCS "midifile/src/*.cpp")
FILE(GLOB MIDIFILE_HDRS "midifile/src/*.cpp")
ADD_LIBRARY(midifile STATIC ${MIDIFILE_SRCS} ${MIDIFILE_HDRS})

INCLUDE(FindProtobuf)
FIND_PACKAGE(Protobuf REQUIRED)
INCLUDE_DIRECTORIES(${Protobuf_INCLUDE_DIRS})
#PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER src/mmm_api/protobuf/midi.proto)
FILE(GLOB PROTO_DEF "src/mmm_api/protobuf/*.proto")
PROTOBUF_GENERATE_CPP(PROTO_SRC PROTO_HEADER ${PROTO_DEF})
ADD_LIBRARY(proto ${PROTO_HEADER} ${PROTO_SRC})

PYBIND11_ADD_MODULE(mmm_api 
    src/mmm_api/lib.cpp
    src/mmm_api/dataset/lz4.c 
    src/mmm_api/protobuf/midi.pb.cc)
TARGET_LINK_LIBRARIES(mmm_api PRIVATE midifile proto "${Protobuf_LIBRARIES}")