set(HEADERS
    Bindings.h
    OTIOCasters.h)
set(HEADERS_PRIVATE)
set(SOURCE
    Audio.cpp
    AudioSystem.cpp
    BackgroundOptions.cpp
    Bindings.cpp
    ColorOptions.cpp
    CompareOptions.cpp
    DisplayOptions.cpp
    ForegroundOptions.cpp
    IRender.cpp
    Player.cpp
    PlayerOptions.cpp
    System.cpp
    TimeUnits.cpp
    Timeline.cpp
    TimelineOptions.cpp
    Transition.cpp
    Util.cpp
    Video.cpp)

# Static. The bindings are linked by the tlrender module and nothing else,
# so there is no API here for anything to import -- the module absorbs them.
add_library(tlTimelinePy STATIC ${HEADERS} ${HEADERS_PRIVATE} ${SOURCE})
# Hidden, as the module is: the binding classes hold nanobind's types,
# which are hidden, and GCC warns about a class more visible than its
# members. Nothing here is exported anyway.
set_target_properties(tlTimelinePy PROPERTIES
    POSITION_INDEPENDENT_CODE ON
    CXX_VISIBILITY_PRESET hidden
    VISIBILITY_INLINES_HIDDEN ON)

target_include_directories(tlTimelinePy
    PUBLIC
        $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/lib>
        $<INSTALL_INTERFACE:include>)
target_include_directories(tlTimelinePy
    PRIVATE
        ${NB_DIR}/include
        ${NB_DIR}/ext/robin_map/include)

target_link_libraries(tlTimelinePy PUBLIC tlTimeline PRIVATE ${TLRENDER_NANOBIND_LIBRARY})

# The player bindings alone go past what a COFF object can hold, which is what
# pybind11 does to a translation unit that names a lot of types:
#
#     error C1128: number of sections exceeded object file format limit
target_compile_options(tlTimelinePy PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/bigobj>)

set_target_properties(tlTimelinePy PROPERTIES FOLDER lib)
set_target_properties(tlTimelinePy PROPERTIES PUBLIC_HEADER "${HEADERS}")

install(TARGETS tlTimelinePy
    ARCHIVE DESTINATION lib COMPONENT dev ${TLRENDER_PYTHON_ARCHIVE_INSTALL}
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
    PUBLIC_HEADER DESTINATION include/tlRender/tlTimelinePy COMPONENT dev)
