# MIDI Sequencer C++ Library
# Copyright (C) 2005-2019 Pedro Lopez-Cabanillas <plcl@users.sourceforge.net>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

set(CMAKE_INCLUDE_CURRENT_DIR ON)
#include_directories(${ALSA_INC_DIR})
link_directories(${ALSA_LIB_DIR})

set(drumstick-alsa_QTOBJ_SRCS
    ../include/drumstick/alsaclient.h
    ../include/drumstick/alsaevent.h
    ../include/drumstick/alsaport.h
    ../include/drumstick/alsaqueue.h
    ../include/drumstick/alsatimer.h
    ../include/drumstick/playthread.h
)

set(drumstick-alsa_HEADERS
    ../include/drumstick/alsaclient.h
    ../include/drumstick/alsaevent.h
    ../include/drumstick/alsaport.h
    ../include/drumstick/alsaqueue.h
    ../include/drumstick/alsatimer.h
    ../include/drumstick/drumstickcommon.h
    ../include/drumstick/playthread.h
    ../include/drumstick/subscription.h
)

SET(drumstick-alsa_SRCS
    alsaclient.cpp
    alsaevent.cpp
    alsaport.cpp
    alsaqueue.cpp
    alsatimer.cpp
    playthread.cpp
    subscription.cpp
)


qt5_wrap_cpp(drumstick-alsa_MOC_SRCS ${drumstick-alsa_QTOBJ_SRCS})

add_library(drumstick-alsa
    ${drumstick-alsa_MOC_SRCS}
    ${drumstick-alsa_SRCS}
    ${drumstick-alsa_HEADERS}
)

add_library(Drumstick::ALSA ALIAS drumstick-alsa)

target_include_directories(drumstick-alsa
    PUBLIC  $<BUILD_INTERFACE:${DRUMSTICK_SOURCE_DIR}/library/include>
            $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDE}>
    PRIVATE ${ALSA_INC_DIR}
)

target_link_libraries(drumstick-alsa
    ${ALSA_LIBS}
    Qt5::Core
)

if(USE_DBUS)
    target_link_libraries(drumstick-alsa
        Qt5::DBus
    )
endif()

if(STATIC_DRUMSTICK)
    set_target_properties(drumstick-alsa PROPERTIES
         STATIC_LIB "libdrumstick-alsa")
else()
    set_target_properties(drumstick-alsa PROPERTIES
        VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}
        SOVERSION ${VERSION_MAJOR}
    )
endif()

install(TARGETS drumstick-alsa EXPORT drumstick-alsa-config
        RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
        ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
        LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${drumstick-alsa_HEADERS}
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/drumstick)
install(FILES ../include/drumstick.h
        DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

install(EXPORT drumstick-alsa-config
        DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/drumstick/cmake)

export(TARGETS drumstick-alsa FILE drumstick-alsa-config.cmake)
