# XCB/Xorg Window Attaching StimBuffAPI backend
cmake_dependent_option(ENABLE_STIMBUFFAPI_xcbWindow
    "Enable XCB/Xorg Window Attaching StimBuffAPI backend" ON
    "ENABLE_LIB_xcbXorg" OFF)

if(ENABLE_STIMBUFFAPI_xcbWindow)
    # Set CONFIG variable for config.h
    set(CONFIG_STIMBUFFAPI_XCBWINDOW_ENABLED 1)

    add_library(xcbWindow SHARED
        xcbWindow.cpp
    )

    set_target_properties(xcbWindow PROPERTIES
        VERSION ${PROJECT_VERSION}
        SOVERSION ${PROJECT_VERSION_MAJOR}
    )

    target_include_directories(xcbWindow PUBLIC
        ${CMAKE_CURRENT_SOURCE_DIR}
        ${CMAKE_CURRENT_SOURCE_DIR}/../../include
        ${CMAKE_CURRENT_SOURCE_DIR}/../../smocore/include
        ${CMAKE_CURRENT_SOURCE_DIR}/../../commonLibs
    )

    # Link against XCB library directly (libxcbXorg will be loaded dynamically)
    pkg_check_modules(XCB REQUIRED xcb)
    target_link_libraries(xcbWindow
		Boost::system Boost::log
		${XCB_LIBRARIES}
		spinscale)

    # Install rules
    install(TARGETS xcbWindow
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} NAMELINK_SKIP
    )
endif()
