#################################################
#
#  (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 )

