# Copyright 2025 Digitalwerk GmbH.
#
#     This Source Code Form is subject to the terms of the Mozilla
#     Public License, v. 2.0. If a copy of the MPL was not distributed
#     with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# If it is not possible or desirable to put the notice in a particular file, then
# You may include the notice in a location (such as a LICENSE file in a
# relevant directory) where a recipient would be likely to look for such a notice.
#
# You may add additional accurate notices of copyright ownership.
find_package(adtf_sdk 3.21 REQUIRED COMPONENTS adtf_file adtfdat_processing)

configure_file(version.py.in "${CMAKE_CURRENT_BINARY_DIR}/version.py")

add_library(adtf_file_python_bindings STATIC adtf_file_python_bindings.cpp adtf_file_python_bindings.h)

target_link_libraries(adtf_file_python_bindings PUBLIC pybind11::module PRIVATE adtf_file adtfdat_processing decoder)
if (NOT WIN32)
    target_link_libraries(adtf_file_python_bindings PUBLIC "-Wl,-z,undefs")
endif ()
set_target_properties(adtf_file_python_bindings PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(adtf_file_python_bindings PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
target_compile_features(adtf_file_python_bindings PUBLIC cxx_std_17)
target_compile_definitions(adtf_file_python_bindings PUBLIC MODULE_RELEASE_ABI_VERSION=${MODULE_RELEASE_ABI_VERSION})

pybind11_add_module(_adtf_file MODULE adtf_file_python_module.cpp)
target_link_libraries(_adtf_file PRIVATE adtf_file_python_bindings Python::Module)

install_module(adtf_file)