project(lb_interface_manager_test C)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=deprecated-declarations -Wno-deprecated-declarations")

pkg_check_modules(IM_CLI REQUIRED lbInterfaceManager-client)
aux_source_directory(./test_interface/mock/public MOCK_PUB)
aux_source_directory(./test_interface/mock/server MOCK_SRV)
aux_source_directory(./test_interface/mock/client MOCK_CLI)
add_executable(lb_interface_manager_test test_service.c)
add_executable(lb_interface_manager_mock mock_service.c)
add_library(lbInterfaceManagerMock-server SHARED ${MOCK_SRV})
add_library(lbInterfaceManagerMock-public SHARED ${MOCK_PUB})
add_library(lbInterfaceManagerMock-client SHARED ${MOCK_CLI})

pkg_check_modules(LB_CORE REQUIRED lb_core)
pkg_check_modules(LB_BASE REQUIRED lb_base)
pkg_check_modules(GIO REQUIRED gio-2.0)

target_include_directories(lb_interface_manager_test PUBLIC
    test_interface/mock
    inc
    ${GLIB2_INCLUDE_DIRS}
    ${LB_BASE_INCLUDE_DIRS}
    ${LB_CORE_INCLUDE_DIRS}
    ${IM_CLI_INCLUDE_DIRS}
)
target_link_directories(lb_interface_manager_test PUBLIC
    ${GLIB2_LIBRARY_DIRS}
    ${LB_CORE_LIBRARY_DIRS}
    ${IM_CLI_LIBRARY_DIRS}
)
target_link_libraries(lb_interface_manager_test PUBLIC
    ${GLIB2_LIBRARIES}
    ${LB_CORE_LIBRARIES}
    ${GIO_LIBRARIES}
    ${CONN_PUB_LIBRARIES}
    ${IM_CLI_LIBRARIES}
    lbInterfaceManagerMock-client
    lbInterfaceManagerTest-client
)

target_include_directories(lb_interface_manager_mock PUBLIC
    test_interface/mock
    ${GLIB2_INCLUDE_DIRS}
    ${LB_BASE_INCLUDE_DIRS}
    ${LB_CORE_INCLUDE_DIRS}
)
target_link_directories(lb_interface_manager_mock PUBLIC
    ${GLIB2_LIBRARY_DIRS}
    ${LB_CORE_LIBRARY_DIRS}
)
target_link_libraries(lb_interface_manager_mock PUBLIC
    ${GLIB2_LIBRARIES}
    ${LB_CORE_LIBRARIES}
    ${GIO_LIBRARIES}
    ${CONN_PUB_LIBRARIES}
    lbInterfaceManagerMock-server
)
target_include_directories(lbInterfaceManagerMock-public PUBLIC ${GLIB2_INCLUDE_DIRS} ${LB_BASE_INCLUDE_DIRS} test_interface/mock)
target_link_libraries(lbInterfaceManagerMock-public PUBLIC ${LB_BASE_LIBRARIES})
target_link_directories(lbInterfaceManagerMock-public PUBLIC ${LB_BASE_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(lbInterfaceManagerMock-public PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})

target_include_directories(lbInterfaceManagerMock-server PUBLIC ${GLIB2_INCLUDE_DIRS} ${LB_BASE_INCLUDE_DIRS} test_interface/mock)
target_link_libraries(lbInterfaceManagerMock-server PUBLIC ${LB_BASE_LIBRARIES} lbInterfaceManagerMock-public)
target_link_directories(lbInterfaceManagerMock-server PUBLIC ${LB_BASE_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(lbInterfaceManagerMock-server PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})

target_include_directories(lbInterfaceManagerMock-client PUBLIC ${GLIB2_INCLUDE_DIRS} ${LB_BASE_INCLUDE_DIRS} test_interface/mock)
target_link_libraries(lbInterfaceManagerMock-client PUBLIC ${LB_BASE_LIBRARIES} lbInterfaceManagerMock-public)
target_link_directories(lbInterfaceManagerMock-client PUBLIC ${LB_BASE_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(lbInterfaceManagerMock-client PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})
install(TARGETS lbInterfaceManagerMock-public DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS lbInterfaceManagerMock-server DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS lbInterfaceManagerMock-client DESTINATION ${CMAKE_INSTALL_LIBDIR})
file(GLOB MOCK_XML_FILE "test_interface/mock/public/com.litebmc.InterfaceManagerMock*.xml")
install(FILES ${MOCK_XML_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/interfaces)
install(FILES test_interface/mock/server/schema/lbInterfaceManagerMock.json DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/litebmc/schema/)

# com.litebmc.InterfaceManagerTest start
aux_source_directory(./test_interface/test/public TEST_PUB)
aux_source_directory(./test_interface/test/server TEST_SRV)
aux_source_directory(./test_interface/test/client TEST_CLI)
add_library(lbInterfaceManagerTest-server SHARED ${TEST_SRV})
add_library(lbInterfaceManagerTest-public SHARED ${TEST_PUB})
add_library(lbInterfaceManagerTest-client SHARED ${TEST_CLI})
target_include_directories(lbInterfaceManagerTest-public PUBLIC ${GLIB2_INCLUDE_DIRS} ${LB_BASE_INCLUDE_DIRS} test_interface/test)
target_link_libraries(lbInterfaceManagerTest-public PUBLIC ${LB_BASE_LIBRARIES})
target_link_directories(lbInterfaceManagerTest-public PUBLIC ${LB_BASE_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(lbInterfaceManagerTest-public PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})

target_include_directories(lbInterfaceManagerTest-server PUBLIC ${GLIB2_INCLUDE_DIRS} ${LB_BASE_INCLUDE_DIRS} test_interface/test)
target_link_libraries(lbInterfaceManagerTest-server PUBLIC ${LB_BASE_LIBRARIES} lbInterfaceManagerTest-public)
target_link_directories(lbInterfaceManagerTest-server PUBLIC ${LB_BASE_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(lbInterfaceManagerTest-server PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})

target_include_directories(lbInterfaceManagerTest-client PUBLIC ${GLIB2_INCLUDE_DIRS} ${LB_BASE_INCLUDE_DIRS} test_interface/test)
target_link_libraries(lbInterfaceManagerTest-client PUBLIC ${LB_BASE_LIBRARIES} lbInterfaceManagerTest-public)
target_link_directories(lbInterfaceManagerTest-client PUBLIC ${LB_BASE_LIBRARY_DIRS})
SET_TARGET_PROPERTIES(lbInterfaceManagerTest-client PROPERTIES VERSION ${CMAKE_PROJECT_VERSION} SOVERSION ${CMAKE_PROJECT_VERSION_MAJOR})
install(TARGETS lbInterfaceManagerTest-public DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS lbInterfaceManagerTest-server DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS lbInterfaceManagerTest-client DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES test_interface/test/server/schema/lbInterfaceManagerTest.json DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/litebmc/schema/)
file(GLOB TEST_XML_FILE "test_interface/test/public/com.litebmc.InterfaceManagerTest*.xml")
install(FILES ${TEST_XML_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/dbus-1/interfaces)

install(TARGETS lb_interface_manager_test DESTINATION opt/litebmc/apps/lb_core)
install(TARGETS lb_interface_manager_mock DESTINATION opt/litebmc/apps/lb_core)
