cmake_minimum_required(VERSION 2.8)
project(spmod_midi)

find_package ( PortMidi REQUIRED )
if (MSVC)	
	find_file (PortMidi_RUNTIME_REL portmidi.dll HINTS $ENV{PORTMIDIDIR}/lib $ENV{PORTMIDIDIR}/bin)
	find_file (PortMidi_RUNTIME_DBG portmidid.dll HINTS $ENV{PORTMIDIDIR}/lib $ENV{PORTMIDIDIR}/bin)
		
	install_to_msvc_build_directory("${EXECUTABLE_OUTPUT_PATH}" "${PortMidi_RUNTIME_REL}")
	install_to_msvc_build_directory("${EXECUTABLE_OUTPUT_PATH}" "${PortMidi_RUNTIME_DBG}")
endif(MSVC)

set(spmod_midi_SRCS
	${CUSTOM_INCLUDE_PATH}/mod_midi/midi_types.h
	mod_midi.cpp
	midiconfiggui.h
	midiconfiggui.cpp
)

include_directories (${PortMidi_INCLUDE_DIRS})
add_library (spmod_midi MODULE ${spmod_midi_SRCS})
target_link_libraries(spmod_midi spcore)
target_link_libraries(spmod_midi ${PortMidi_LIBRARIES})
target_link_libraries(spmod_midi ${wxWidgets_LIBRARIES})

IF(BUILD_TESTS)
	ADD_SUBDIRECTORY(tests)
ENDIF(BUILD_TESTS)

INSTALL (TARGETS spmod_midi RUNTIME DESTINATION ${LIBRUNTIMEDIR} LIBRARY DESTINATION ${PLUGINDIR})

if(WIN32)
	install(FILES ${PortMidi_RUNTIME_DBG} DESTINATION "${LIBRUNTIMEDIR}" CONFIGURATIONS Debug)
	install(FILES ${PortMidi_RUNTIME_REL} DESTINATION "${LIBRUNTIMEDIR}" CONFIGURATIONS Release RelWithDebInfo)
endif(WIN32)