#################################################
#
#  (C) 2011 Timothy Pearson
#  kb9vqf (AT) pearsoncomputing.net
#
#  Improvements and feedback are welcome
#
#  This file is released under GPL >= 2
#
#################################################

include_directories(
  ${TQT_INCLUDE_DIRS}
  ${TDE_INCLUDE_DIR}
  ${CMAKE_BINARY_DIR}
  ${CMAKE_BINARY_DIR}/src
  ${CMAKE_SOURCE_DIR}/src
  ${CMAKE_SOURCE_DIR}/src/base
  ${ALSA_INC_DIR}
  ${JACK_INC_DIR}
  ${XFT_INC_DIR}
  ${DSSI_INC_DIR}
  ${LIBLO_INC_DIR}
  ${LADSPA_INC_DIR}
  ${LRDF_INC_DIR}
  ${LIRC_INC_DIR}
  ${FFTW3F_INC_DIR}
)

link_directories(
  ${TQT_LIBRARY_DIRS}
  ${TDE_LIBRARY_DIR}
  ${ALSA_LIB_DIR}
  ${JACK_LIB_DIR}
  ${XFT_LIB_DIR}
  ${LIBLO_LIB_DIR}
  ${LRDF_LIB_DIR}
  ${LIRC_LIB_DIR}
  ${FFTW3F_LIB_DIR}
  ${CMAKE_BINARY_DIR}/src
)

##### include cmake file lists ##################

set( CMAKE_INCLUDE_PATH "." )

# Common sources
include( BaseFileList.txt )
include( MiscFileList.txt )

# Sound sources
include( SoundFileList.txt )

# sequencer executable
include( SequencerFileList.txt )

# gui executable
include( GUIFileList.txt )

##### other data ################################

# Install helper scripts
install( PROGRAMS
    helpers/rosegarden-lilypondview
    helpers/rosegarden-project-package
    helpers/rosegarden-audiofile-importer
  DESTINATION ${BIN_INSTALL_DIR} )

# Install GUI resource files
file( GLOB RC_FILES gui/ui/*.rc )
install( FILES ${RC_FILES} DESTINATION ${DATA_INSTALL_DIR}/rosegarden )


##### RosegardenCommon ##############################

tde_add_library( RosegardenCommon STATIC AUTOMOC
  SOURCES ${misc_SRCS} ${base_SRCS} ${common_sound_SRCS}
  LINK dl
  DESTINATION ${LIB_INSTALL_DIR}
)


##### rosegardensequencer ###########################

if( WANT_SOUND )
  set( snd_SRCS ${sound_SRCS} )
else( WANT_SOUND )
  set( snd_SRCS ${nosnd_SRCS} )
endif( WANT_SOUND )

tde_add_executable( rosegardensequencer AUTOMOC
  SOURCES ${seq_dcop_SRCS} ${snd_SRCS} ${sequencer_SRCS}
  LINK dl pthread tdecore-shared ${ALSA_LIBS} ${JACK_LIBS} ${LIBLO_LIBS} ${LRDF_LIBS} ${FFTW3F_LIBS} tdeui-shared RosegardenCommon
  DESTINATION ${BIN_INSTALL_DIR}
)

target_link_libraries( rosegardensequencer dl )

ADD_DEPENDENCIES(rosegardensequencer RosegardenCommon-static)

##### RosegardenExtended ############################

tde_add_library( RosegardenExtended STATIC AUTOMOC
  SOURCES ${document_SRCS} ${gui_SRCS} ${gui_dcop_SRCS} ${ui_SRCS}
  LINK dl ${LIBLO_LIBS}
  DESTINATION ${LIB_INSTALL_DIR}
)


##### RosegardenCommands ############################

tde_add_library( RosegardenCommands STATIC AUTOMOC
  SOURCES ${commands_SRCS}
#  LINK dl
  DESTINATION ${LIB_INSTALL_DIR}
)


##### RosegardenSegmentCanvas #######################

tde_add_library( RosegardenSegmentCanvas STATIC AUTOMOC
  SOURCES ${segmentcanvas_SRCS}
#  LINK dl
  DESTINATION ${LIB_INSTALL_DIR}
)


##### rosegarden ####################################

tde_add_executable( rosegarden AUTOMOC
  SOURCES gui/application/main.cpp
  LINK dl pthread fontconfig tdecore-shared ${LIBLO_LIBS} ${LRDF_LIBS} ${FFTW3F_LIBS} ${XFT_LIBS} ${LIRC_LIBS} ${JACK_LIBS} tdeio-shared tdeui-shared tdeprint-shared RosegardenExtended RosegardenSegmentCanvas RosegardenCommands RosegardenCommon
  DESTINATION ${BIN_INSTALL_DIR}
)

target_link_libraries( rosegarden dl )
target_link_libraries( rosegarden tdeprint-shared )

ADD_DEPENDENCIES(rosegarden RosegardenExtended-static)
ADD_DEPENDENCIES(rosegarden RosegardenSegmentCanvas-static)
ADD_DEPENDENCIES(rosegarden RosegardenCommands-static)
ADD_DEPENDENCIES(rosegarden RosegardenCommon-static)
ADD_DEPENDENCIES(rosegarden RosegardenExtended-static)
ADD_DEPENDENCIES(rosegarden RosegardenSegmentCanvas-static)
ADD_DEPENDENCIES(rosegarden RosegardenCommands-static)
ADD_DEPENDENCIES(rosegarden RosegardenCommon-static)

if( WANT_TEST )
  include( TestFileList.txt )

  CREATE_TEST_SOURCELIST(RosegardenTest
    RosegardenTestDriver.cpp
    ${tests_SRCS}
#    base/test/transpose.cpp
#    base/test/segmenttransposecommand.cpp
  )

  tde_add_executable( RosegardenTestDriver AUTOMOC
    SOURCES RosegardenTestDriver.cpp ${tests_SRCS}
    LINK dl tdecore-shared ${LIBLO_LIBS} ${LRDF_LIBS} ${FFTW3F_LIBS} ${XFT_LIBS} ${LIRC_LIBS} ${JACK_LIBS} tdeio-shared tdeui-shared tdeprint-shared RosegardenExtended RosegardenSegmentCanvas RosegardenCommands RosegardenCommon
    DESTINATION ${BIN_INSTALL_DIR}
  )

  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenExtended-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenSegmentCanvas-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenCommands-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenCommon-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenExtended-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenSegmentCanvas-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenCommands-static)
  ADD_DEPENDENCIES(RosegardenTestDriver RosegardenCommon-static)

  FOREACH(currenttest ${tests_SRCS})
    GET_FILENAME_COMPONENT(TestName ${currenttest} NAME_WE)
    ADD_TEST(test/${TestName} RosegardenTestDriver test/${TestName})
  ENDFOREACH(currenttest ${tests_SRCS})
endif( WANT_TEST )