cmake_minimum_required(VERSION 2.8.12)

set(PROJECT x502_rdy_cntr_tst)

project(${PROJECT} C)

set(SOURCES main.c)
set(HEADERS )

include_directories(${X502API_INCLUDE_DIR})
link_directories(${X502API_LIBRARIES_DIR})

add_executable(${PROJECT} ${HEADERS} ${SOURCES})

set(TEST_LIBS x502api)
#find_package(Threads REQUIRED)
#set(TEST_LIBS ${CMAKE_THREAD_LIBS_INIT} x502api)
set(COMPILE_DEFINITIONS)
if(X502API_ENABLE_DEV_L502)
    set(TEST_LIBS ${TEST_LIBS} l502api)
    set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} X502API_ENABLE_DEV_L502)
endif(X502API_ENABLE_DEV_L502)
if(X502API_ENABLE_DEV_E502)
    set(TEST_LIBS ${TEST_LIBS} e502api)
    set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} X502API_ENABLE_DEV_E502)
    if(E502API_ENABLE_TCP)
        set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} E502API_ENABLE_TCP)
    endif(E502API_ENABLE_TCP)
    if(E502API_ENABLE_USB)
        set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} E502API_ENABLE_USB)
    endif(E502API_ENABLE_USB)
    if(E502API_ENABLE_DNSSD)
        set(COMPILE_DEFINITIONS ${COMPILE_DEFINITIONS} E502API_ENABLE_DNSSD)
    endif(E502API_ENABLE_DNSSD)
endif(X502API_ENABLE_DEV_E502)

target_link_libraries(${PROJECT} ${TEST_LIBS})

if(COMPILE_DEFINITIONS)
    set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_DEFINITIONS "${COMPILE_DEFINITIONS}")
endif(COMPILE_DEFINITIONS)
