cmake_minimum_required (VERSION 3.0)

project (libubus-cpp)

set (CMAKE_MODULE_PATH "${MODULE_PATH}")
set (CMAKE_CXX_STANDARD 11)

set(UBUS_MAX_MSGLEN 1048576)
add_definitions(-DUBUS_MAX_MSGLEN=${UBUS_MAX_MSGLEN})
add_definitions(-DUBUS_UNIX_SOCKET="/tmp/ubus.sock")

include (br)

include_directories (${workspaceRoot}/src/lib/libubus-cpp/include/)

file(
	GLOB_RECURSE
	source_files
	${workspaceRoot}/src/lib/libubus-cpp/src/ubus-object.cpp
	${workspaceRoot}/src/lib/libubus-cpp/src/ubus-call.cpp
	${workspaceRoot}/src/lib/libubus-cpp/src/ubus-exec-receiver.cpp
	${workspaceRoot}/src/lib/libubus-cpp/src/ubus-event-receiver.cpp
	${workspaceRoot}/src/lib/libubus-cpp/src/ubus-event.cpp
	${workspaceRoot}/src/lib/libubus-cpp/src/uloop-timer.cpp
	${workspaceRoot}/src/lib/libubus-cpp/src/ubus-sync.c
)

add_library(
        ubus-cpp
        SHARED
        ${source_files}
)

target_link_libraries (ubus-cpp 
	LINK_PUBLIC
	ubus
	blobmsg_json
)

target_include_directories (ubus-cpp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

install (TARGETS ubus-cpp LIBRARY DESTINATION local/lib)

file (GLOB headers ${workspaceRoot}/src/lib/libubus-cpp/include/ubus-cpp/*)
install (FILES ${headers} DESTINATION include/ubus-cpp)
