cmake_minimum_required(VERSION 3.6)

project(fusion VERSION 1.3.3)

option(BUILD_SHARED "build shared library" ON)


message(STATUS "CMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}")
message(STATUS "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}")


set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}")
include(utils)
include(vars)


include_directories(${LIBHV_HEADERS})

aux_target_directory(hal_srcs hal hal_audio t40)
aux_target_directory(hal_srcs hal hal_video t40)
aux_target_directory(hal_srcs hal hal_flash linux)
aux_target_directory(hal_srcs hal hal_wifi)
aux_target_directory(hal_srcs hal hal_gpio t40)

aux_target_directory(com_srcs common iobuffer)
aux_target_directory(com_srcs common jsonpacket)
aux_target_directory(com_srcs common ringbuffer)
aux_target_directory(com_srcs common slab)
aux_target_directory(com_srcs common threadpool)
aux_target_directory(com_srcs common utils)
aux_target_directory(com_srcs common workqueue)
aux_target_directory(com_srcs common xbuf)

aux_target_directory(mw_srcs mw mmc)
aux_target_directory(mw_srcs mw config)
aux_target_directory(mw_srcs mw dmc)
aux_target_directory(mw_srcs mw shutdownmgr)
aux_target_directory(mw_srcs mw soft_watchdog)
aux_target_directory(mw_srcs mw storage)
aux_target_directory(mw_srcs mw tcpclient)
aux_target_directory(mw_srcs mw tcpserver)
aux_target_directory(mw_srcs mw unittest)
aux_target_directory(mw_srcs mw media)

aux_target_directory(3rd_srcs third_party crc16)
aux_target_directory(3rd_srcs third_party crc32)
aux_target_directory(3rd_srcs third_party cJSON)
aux_target_directory(3rd_srcs third_party hashmap)

aux_target_directory(app_srcs app)
aux_target_directory(prj_srcs project)
aux_target_directory(prj_srcs project unittest)

add_library(fusion SHARED  ${hal_srcs} ${com_srcs} ${mw_srcs} ${3rd_srcs} ${app_srcs} ${prj_srcs})


aux_source_directory(. DIR_SRCS)
link_directories(${LIBHV_PATH}/build/lib build)
add_executable(fusion.bin ${DIR_SRCS})
target_link_libraries(fusion.bin libfusion.so libhv.so pthread)

