set(HEADERS
    Bindings.h
    Function.h)
set(HEADERS_PRIVATE)
set(SOURCE
    AnnotationsModel.cpp
    AppInfoModel.cpp
    AudioModel.cpp
    Bindings.cpp
    ColorModel.cpp
    CommandsModel.cpp
    DrawModel.cpp
    FilesModel.cpp
    MarkersModel.cpp
    OCIOModel.cpp
    Parse.cpp
    Playlist.cpp
    RecentFilesModel.cpp
    Review.cpp
    SettingsModel.cpp
    Shortcuts.cpp
    TimeUnitsModel.cpp
    ToolsModel.cpp
    ViewportModel.cpp)

# Static. The bindings are linked by the djv module and nothing else, so there is no
# API here for anything to import -- the module absorbs them.
add_library(djvModelsPy 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(djvModelsPy PROPERTIES
    POSITION_INDEPENDENT_CODE ON
    CXX_VISIBILITY_PRESET hidden
    VISIBILITY_INLINES_HIDDEN ON)

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

# ftkUI directly: the bindings name ftk::Settings and ftk::RecentFilesModel,
# which djvModels does not carry in its link interface.
target_link_libraries(djvModelsPy PUBLIC djvModels ftk::ftkUI PRIVATE ${DJV_NANOBIND_LIBRARY})

# The settings 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(djvModelsPy PRIVATE $<$<CXX_COMPILER_ID:MSVC>:/bigobj>)

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

install(TARGETS djvModelsPy
    ARCHIVE DESTINATION lib COMPONENT dev
    LIBRARY DESTINATION lib
    RUNTIME DESTINATION bin
    PUBLIC_HEADER DESTINATION include/djv/ModelsPy COMPONENT dev)
