# Include Flex/Bison generation rules
include(${CMAKE_SOURCE_DIR}/cmake/flexYacc.cmake)

# Consolidated smocore library with all source files
add_library(smocore STATIC
    # Core files
    mind.cpp
    mindComponent.cpp
    componentThread.cpp
    opts.cpp

    # Body
    body/body.cpp

    # Director
    director/director.cpp

    # Simulator
    simulator/simulator.cpp

    # Marionette
    marionette/main.cpp
    marionette/salmanoff.cpp
    marionette/lifetime.cpp
    marionette/qualeEvent.cpp
	marionette/negtrinEvent.cpp

    # DeviceManager
    deviceManager/deviceManager.cpp
    deviceManager/deviceReattacher.cpp
    deviceManager/deviceAttachmentPipeSpecParser.cpp
    ${LEX_OUTPUT}
    ${YACC_OUTPUT}

    # SenseApis
    stimBuffApis/stimBuffApiManager.cpp

    # ComputeManager
    computeManager/computeManager.cpp

    # MindManager
    mindManager/mindManager.cpp
)

target_include_directories(smocore PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_CURRENT_BINARY_DIR}
	${Boost_INCLUDE_DIRS}
	${OPENCL_INCLUDE_DIRS}
)

# smocore public headers expose Qutex and friends
target_link_libraries(smocore PUBLIC
	spinscale
)

# Link against pthread for CPU affinity functions
find_package(Threads REQUIRED)
target_link_libraries(smocore PRIVATE
	Threads::Threads
	Boost::system
	Boost::log
	${OPENCL_LIBRARIES}
	attachmentSupport
)
target_link_directories(smocore PRIVATE
	${OPENCL_LIBRARY_DIRS}
)
