INCLUDE_DIRECTORIES("${CMAKE_SOURCE_DIR}/include")
FILE(GLOB PLUGIN_SOURCES tap-plugins/*.c)
LIST(SORT PLUGIN_SOURCES)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3 -Wno-write-strings -fomit-frame-pointer -fno-strict-aliasing -funroll-loops -ffast-math")
FOREACH(_item ${PLUGIN_SOURCES})
	GET_FILENAME_COMPONENT(_plugin "${_item}" NAME_WE)
	ADD_LIBRARY("${_plugin}" MODULE "${_item}")
	# TAP pinknoise will re-init srand(); use existing seed instead
	IF("${_plugin}" MATCHES "tap_pinknoise")
		TARGET_COMPILE_DEFINITIONS("${_plugin}" PRIVATE TAP_DISABLE_SRAND=1)
	ENDIF()
	INSTALL(TARGETS "${_plugin}" LIBRARY DESTINATION "${PLUGIN_DIR}/ladspa")
	SET_TARGET_PROPERTIES("${_plugin}" PROPERTIES PREFIX "")
	# Don't strip if "Debug" or "RelWithDebInfo"
	IF(LMMS_BUILD_WIN32 AND NOT CMAKE_BUILD_TYPE MATCHES "Deb")
		ADD_CUSTOM_COMMAND(TARGET "${_plugin}" POST_BUILD COMMAND "${STRIP}" \"$<TARGET_FILE:${_plugin}>\")
	ENDIF()
	IF(NOT MSVC)
		TARGET_LINK_LIBRARIES("${_plugin}" m)
	ENDIF()
ENDFOREACH()

