SET(K3D_PLUGINS "" CACHE INTERNAL "" FORCE)

INCLUDE(K3DParseArguments)

MACRO(K3D_BUILD_MODULE MODULE_NAME)
	K3D_PARSE_ARGUMENTS(MODULE "EXTRA_SOURCES;EXCLUDE_SOURCES" "" ${ARGN})

	SET(K3D_PLUGINS ${K3D_PLUGINS} ${MODULE_NAME} CACHE INTERNAL "" FORCE)

	FILE(GLOB ABSOLUTE_HEADERS *.h)
	FILE(GLOB ABSOLUTE_SOURCES *.cpp)

	LIST(SORT ABSOLUTE_HEADERS)
	LIST(SORT ABSOLUTE_SOURCES)

	FOREACH(ABSOLUTE_HEADER ${ABSOLUTE_HEADERS})
		GET_FILENAME_COMPONENT(HEADER ${ABSOLUTE_HEADER} NAME)
		LIST(APPEND HEADERS ${HEADER})
	ENDFOREACH()

	FOREACH(ABSOLUTE_SOURCE ${ABSOLUTE_SOURCES})
		GET_FILENAME_COMPONENT(SOURCE ${ABSOLUTE_SOURCE} NAME)
		LIST(APPEND SOURCES ${SOURCE})
	ENDFOREACH()

	LIST(LENGTH HEADERS HEADER_COUNT)
	LIST(LENGTH SOURCES SOURCE_COUNT)

	IF(HEADER_COUNT GREATER 0)
		FOREACH(MODULE_EXCLUDE_SOURCE ${MODULE_EXCLUDE_SOURCES})
			LIST(REMOVE_ITEM HEADERS ${MODULE_EXCLUDE_SOURCE})
		ENDFOREACH()
	ENDIF()

	IF(SOURCE_COUNT GREATER 0)
		FOREACH(MODULE_EXCLUDE_SOURCE ${MODULE_EXCLUDE_SOURCES})
			LIST(REMOVE_ITEM SOURCES ${MODULE_EXCLUDE_SOURCE})
		ENDFOREACH()
	ENDIF()

	INCLUDE_DIRECTORIES(${k3d_SOURCE_DIR})
	INCLUDE_DIRECTORIES(${k3dsdk_BINARY_DIR})
	INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
	INCLUDE_DIRECTORIES(${K3D_GLIBMM_INCLUDE_DIRS})
	INCLUDE_DIRECTORIES(${K3D_SIGC_INCLUDE_DIRS})
	INCLUDE_DIRECTORIES(${K3D_OPENGL_INCLUDE_DIR})

	IF(K3D_ENABLE_NLS)
		INCLUDE_DIRECTORIES(${K3D_INTL_INCLUDE_DIRS})
	ENDIF(K3D_ENABLE_NLS)

	IF(K3D_ENABLE_PARALLEL)
		INCLUDE_DIRECTORIES(${K3D_TBB_INCLUDE_DIR})
	ENDIF(K3D_ENABLE_PARALLEL)

	IF(K3D_ENABLE_PROFILING)
		INCLUDE_DIRECTORIES(${K3D_GPERFTOOLS_INCLUDE_DIR})
	ENDIF(K3D_ENABLE_PROFILING)

	LINK_DIRECTORIES(${K3D_SIGC_LIB_DIRS})

	ADD_LIBRARY(${MODULE_NAME} MODULE ${HEADERS} ${SOURCES} ${MODULE_EXTRA_SOURCES})
	SET_TARGET_PROPERTIES(${MODULE_NAME} PROPERTIES
		LIBRARY_OUTPUT_DIRECTORY ${K3D_MODULE_OUTPUT_DIRECTORY}
		PREFIX ""
		SUFFIX ".module"
		)

	TARGET_LINK_LIBRARIES(${MODULE_NAME} k3dsdk)

	IF(K3D_ENABLE_NLS)
		TARGET_LINK_LIBRARIES(${MODULE_NAME} ${K3D_INTL_LIBS})
	ENDIF(K3D_ENABLE_NLS)

	IF(K3D_ENABLE_PROFILING)
		TARGET_LINK_LIBRARIES(${MODULE_NAME} ${K3D_PROFILER_LIBRARY})
	ENDIF(K3D_ENABLE_PROFILING)

	INSTALL(TARGETS ${MODULE_NAME}
		RUNTIME DESTINATION ${K3D_LIBDIR}/k3d/plugins
		LIBRARY DESTINATION ${K3D_LIBDIR}/k3d/plugins)
ENDMACRO(K3D_BUILD_MODULE)

MACRO(K3D_BUILD_NGUI_MODULE MODULE_NAME)
	INCLUDE_DIRECTORIES(${K3D_CAIROMM_INCLUDE_DIRS})
	INCLUDE_DIRECTORIES(${K3D_GTKMM_INCLUDE_DIRS})
	INCLUDE_DIRECTORIES(${K3D_GTKGLEXT_INCLUDE_DIRS})

	LINK_DIRECTORIES(${K3D_GTKGLEXT_LIB_DIRS})

	K3D_BUILD_MODULE(${MODULE_NAME} ${ARGN})

	TARGET_LINK_LIBRARIES(${MODULE_NAME} k3dsdk-ngui)
	TARGET_LINK_LIBRARIES(${MODULE_NAME} ${K3D_CAIROMM_LIBS})
ENDMACRO(K3D_BUILD_NGUI_MODULE)

MACRO(K3D_BUILD_QTUI_MODULE MODULE_NAME)
	ADD_DEFINITIONS(-DQT_NO_KEYWORDS)

	INCLUDE_DIRECTORIES(${k3dsdk-qtui_BINARY_DIR})
	INCLUDE_DIRECTORIES(${QT_INCLUDES})

	K3D_BUILD_MODULE(${MODULE_NAME} ${ARGN})
	TARGET_LINK_LIBRARIES(${MODULE_NAME} k3dsdk-qtui)
ENDMACRO()

MACRO(K3D_CREATE_MODULE_PROXY MODULE_NAME)
	GET_TARGET_PROPERTY(K3D_MAKE_MODULE_PROXY k3d-make-module-proxy LOCATION)
	GET_TARGET_PROPERTY(MODULE ${MODULE_NAME} LOCATION)
	ADD_CUSTOM_COMMAND(
		OUTPUT ${MODULE}.proxy
		COMMAND ${K3D_MAKE_MODULE_PROXY} ${MODULE} ${MODULE}.proxy
		DEPENDS k3d-make-module-proxy ${MODULE_NAME}
		)
	ADD_CUSTOM_TARGET(${MODULE_NAME}-proxy ALL DEPENDS ${MODULE}.proxy)
	INSTALL(FILES ${MODULE}.proxy DESTINATION ${K3D_LIBDIR}/k3d/plugins)
ENDMACRO(K3D_CREATE_MODULE_PROXY)

K3D_ADD_SUBDIRECTORY(3ds_io REQUIRES K3D_BUILD_3DS_IO_MODULE)
K3D_ADD_SUBDIRECTORY(advanced_opengl_painters REQUIRES K3D_BUILD_ADVANCED_OPENGL_PAINTERS_MODULE)
K3D_ADD_SUBDIRECTORY(animation REQUIRES K3D_BUILD_ANIMATION_MODULE)
K3D_ADD_SUBDIRECTORY(annotation REQUIRES K3D_BUILD_ANNOTATION_MODULE)
K3D_ADD_SUBDIRECTORY(aqsis REQUIRES K3D_BUILD_AQSIS_MODULE)
K3D_ADD_SUBDIRECTORY(array REQUIRES K3D_BUILD_ARRAY_MODULE)
K3D_ADD_SUBDIRECTORY(bicubic_patch REQUIRES K3D_BUILD_BICUBIC_PATCH_MODULE)
K3D_ADD_SUBDIRECTORY(bilinear_patch REQUIRES K3D_BUILD_BILINEAR_PATCH_MODULE)
K3D_ADD_SUBDIRECTORY(bitmap REQUIRES K3D_BUILD_BITMAP_MODULE)
K3D_ADD_SUBDIRECTORY(blobby REQUIRES K3D_BUILD_BLOBBY_MODULE)
K3D_ADD_SUBDIRECTORY(bundled_renderman_engines REQUIRES K3D_BUILD_BUNDLED_RENDERMAN_ENGINES_MODULE)
K3D_ADD_SUBDIRECTORY(carve REQUIRES K3D_BUILD_CARVE_MODULE)
K3D_ADD_SUBDIRECTORY(cgal REQUIRES K3D_BUILD_CGAL_MODULE)
K3D_ADD_SUBDIRECTORY(cloth REQUIRES K3D_BUILD_CLOTH_MODULE)
K3D_ADD_SUBDIRECTORY(collada_io REQUIRES K3D_BUILD_COLLADA_IO_MODULE)
K3D_ADD_SUBDIRECTORY(compiz REQUIRES K3D_BUILD_COMPIZ_MODULE)
K3D_ADD_SUBDIRECTORY(core REQUIRES K3D_BUILD_CORE_MODULE)
K3D_ADD_SUBDIRECTORY(cuda REQUIRES K3D_BUILD_CUDA_MODULE)
K3D_ADD_SUBDIRECTORY(deformation REQUIRES K3D_BUILD_DEFORMATION_MODULE)
K3D_ADD_SUBDIRECTORY(development REQUIRES K3D_BUILD_DEVELOPMENT_MODULE)
K3D_ADD_SUBDIRECTORY(double REQUIRES K3D_BUILD_DOUBLE_MODULE)
K3D_ADD_SUBDIRECTORY(euler_operations REQUIRES K3D_BUILD_EULER_OPERATIONS_MODULE)
K3D_ADD_SUBDIRECTORY(file_magic REQUIRES K3D_BUILD_FILE_MAGIC_MODULE)
K3D_ADD_SUBDIRECTORY(freetype2 REQUIRES K3D_BUILD_FREETYPE2_MODULE)
K3D_ADD_SUBDIRECTORY(glx REQUIRES K3D_BUILD_GLX_MODULE)
K3D_ADD_SUBDIRECTORY(gmsh_io REQUIRES K3D_BUILD_GMSH_IO_MODULE)
K3D_ADD_SUBDIRECTORY(gnome REQUIRES K3D_BUILD_GNOME_MODULE)
K3D_ADD_SUBDIRECTORY(gperftools REQUIRES K3D_BUILD_GPERFTOOLS_MODULE K3D_ENABLE_PROFILING)
K3D_ADD_SUBDIRECTORY(graphviz REQUIRES K3D_BUILD_GRAPHVIZ_MODULE)
K3D_ADD_SUBDIRECTORY(gts_io REQUIRES K3D_BUILD_GTS_IO_MODULE)
K3D_ADD_SUBDIRECTORY(gts REQUIRES K3D_BUILD_GTS_MODULE)
K3D_ADD_SUBDIRECTORY(highlighting REQUIRES K3D_BUILD_HIGHLIGHTING_MODULE)
K3D_ADD_SUBDIRECTORY(iges_io REQUIRES K3D_BUILD_IGES_IO_MODULE)
K3D_ADD_SUBDIRECTORY(imagemagick_io REQUIRES K3D_BUILD_IMAGEMAGICK_IO_MODULE)
K3D_ADD_SUBDIRECTORY(indigo REQUIRES K3D_BUILD_INDIGO_MODULE)
K3D_ADD_SUBDIRECTORY(inotify REQUIRES K3D_BUILD_INOTIFY_MODULE)
K3D_ADD_SUBDIRECTORY(jpeg_io REQUIRES K3D_BUILD_JPEG_IO_MODULE)
K3D_ADD_SUBDIRECTORY(k3d_io REQUIRES K3D_BUILD_K3D_IO_MODULE)
K3D_ADD_SUBDIRECTORY(linear_curve REQUIRES K3D_BUILD_LINEAR_CURVE_MODULE)
K3D_ADD_SUBDIRECTORY(lipsync REQUIRES K3D_BUILD_LIPSYNC_MODULE)
K3D_ADD_SUBDIRECTORY(lsystem REQUIRES K3D_BUILD_LSYSTEM_MODULE)
K3D_ADD_SUBDIRECTORY(luxrender REQUIRES K3D_BUILD_LUXRENDER_MODULE)
K3D_ADD_SUBDIRECTORY(matrix REQUIRES K3D_BUILD_MATRIX_MODULE)
K3D_ADD_SUBDIRECTORY(md2_io REQUIRES K3D_BUILD_MD2_IO_MODULE)
K3D_ADD_SUBDIRECTORY(mesh_attributes REQUIRES K3D_BUILD_MESH_ATTRIBUTES_MODULE)
K3D_ADD_SUBDIRECTORY(mesh_instance REQUIRES K3D_BUILD_MESH_INSTANCE_MODULE)
K3D_ADD_SUBDIRECTORY(mesh REQUIRES K3D_BUILD_MESH_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_about REQUIRES K3D_BUILD_NGUI_ABOUT_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_animation_timeline_panel REQUIRES K3D_BUILD_NGUI_ANIMATION_TIMELINE_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_assign_hotkeys REQUIRES K3D_BUILD_NGUI_ASSIGN_HOTKEYS_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_atk_event_recorder REQUIRES K3D_BUILD_NGUI_ATK_EVENT_RECORDER_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_knot_vector_control REQUIRES K3D_BUILD_NGUI_KNOT_VECTOR_CONTROL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_learning REQUIRES K3D_BUILD_NGUI_LEARNING_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_log REQUIRES K3D_BUILD_NGUI_LOG_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_material_manager_panel REQUIRES K3D_BUILD_NGUI_MATERIAL_MANAGER_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_mesh_control REQUIRES K3D_BUILD_NGUI_MESH_CONTROL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui REQUIRES K3D_BUILD_NGUI_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_morph_points_page REQUIRES K3D_BUILD_NGUI_MORPH_POINTS_PAGE_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_node_list_panel REQUIRES K3D_BUILD_NGUI_NODE_LIST_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_node_properties_panel REQUIRES K3D_BUILD_NGUI_NODE_PROPERTIES_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_opengl_dialog REQUIRES K3D_BUILD_NGUI_OPENGL_DIALOG_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_parent_tool REQUIRES K3D_BUILD_NGUI_PARENT_TOOL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_pipeline_panel REQUIRES K3D_BUILD_NGUI_PIPELINE_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_pipeline_profiler_panel REQUIRES K3D_BUILD_NGUI_PIPELINE_PROFILER_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_python_shell REQUIRES K3D_BUILD_NGUI_PYTHON_SHELL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_rectangle_control REQUIRES K3D_BUILD_NGUI_RECTANGLE_CONTROL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_render_region_tool REQUIRES K3D_BUILD_NGUI_RENDER_REGION_TOOL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_selection_control REQUIRES K3D_BUILD_NGUI_SELECTION_CONTROL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_snap_tool REQUIRES K3D_BUILD_NGUI_SNAP_TOOL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_space_navigator REQUIRES K3D_BUILD_NGUI_SPACE_NAVIGATOR_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_text_editor REQUIRES K3D_BUILD_NGUI_TEXT_EDITOR_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_timeline_panel REQUIRES K3D_BUILD_NGUI_TIMELINE_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_toolbar_panel REQUIRES K3D_BUILD_NGUI_TOOLBAR_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_tool_properties_panel REQUIRES K3D_BUILD_NGUI_TOOL_PROPERTIES_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_undo_tree_panel REQUIRES K3D_BUILD_NGUI_UNDO_TREE_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(ngui_uv_editor_panel REQUIRES K3D_BUILD_NGUI_UV_EDITOR_PANEL_MODULE)
K3D_ADD_SUBDIRECTORY(nui REQUIRES K3D_BUILD_NUI_MODULE)
K3D_ADD_SUBDIRECTORY(nurbs REQUIRES K3D_BUILD_NURBS_MODULE)
K3D_ADD_SUBDIRECTORY(nurbs_sources REQUIRES K3D_BUILD_NURBS_SOURCES_MODULE)
K3D_ADD_SUBDIRECTORY(obj_io REQUIRES K3D_BUILD_OBJ_IO_MODULE)
K3D_ADD_SUBDIRECTORY(ode REQUIRES K3D_BUILD_ODE_MODULE)
K3D_ADD_SUBDIRECTORY(ogre_io REQUIRES K3D_BUILD_OGRE_IO_MODULE)
K3D_ADD_SUBDIRECTORY(openexr_io REQUIRES K3D_BUILD_OPENEXR_IO_MODULE)
K3D_ADD_SUBDIRECTORY(opengl REQUIRES K3D_BUILD_OPENGL_MODULE)
K3D_ADD_SUBDIRECTORY(osmesa REQUIRES K3D_BUILD_OSMESA_MODULE)
K3D_ADD_SUBDIRECTORY(osx REQUIRES K3D_BUILD_OSX_MODULE)
K3D_ADD_SUBDIRECTORY(particle REQUIRES K3D_BUILD_PARTICLE_MODULE)
K3D_ADD_SUBDIRECTORY(pdiff REQUIRES K3D_BUILD_PDIFF_MODULE)
K3D_ADD_SUBDIRECTORY(pixie REQUIRES K3D_BUILD_PIXIE_MODULE)
K3D_ADD_SUBDIRECTORY(plot REQUIRES K3D_BUILD_PLOT_MODULE)
K3D_ADD_SUBDIRECTORY(ply_io REQUIRES K3D_BUILD_PLY_IO_MODULE)
K3D_ADD_SUBDIRECTORY(png_io REQUIRES K3D_BUILD_PNG_IO_MODULE)
K3D_ADD_SUBDIRECTORY(polyhedron REQUIRES K3D_BUILD_POLYHEDRON_MODULE)
K3D_ADD_SUBDIRECTORY(polyhedron_sources REQUIRES K3D_BUILD_POLYHEDRON_SOURCES_MODULE)
K3D_ADD_SUBDIRECTORY(python REQUIRES K3D_BUILD_PYTHON_MODULE)
K3D_ADD_SUBDIRECTORY(pyui REQUIRES K3D_BUILD_PYUI_MODULE)
K3D_ADD_SUBDIRECTORY(qslim REQUIRES K3D_BUILD_QSLIM_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_about_dialog REQUIRES K3D_BUILD_QTUI_ABOUT_DIALOG_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_aqsis_mode REQUIRES K3D_BUILD_QTUI_AQSIS_MODE_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_aqsis REQUIRES K3D_BUILD_QTUI_AQSIS_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_boolean REQUIRES K3D_BUILD_QTUI_BOOLEAN_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_color REQUIRES K3D_BUILD_QTUI_COLOR_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_default_mode REQUIRES K3D_BUILD_QTUI_DEFAULT_MODE_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_javascript_shell REQUIRES K3D_BUILD_QTUI_JAVASCRIPT_SHELL_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_log REQUIRES K3D_BUILD_QTUI_LOG_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_matrix REQUIRES K3D_BUILD_QTUI_MATRIX_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_move_mode REQUIRES K3D_BUILD_QTUI_MOVE_MODE_MODULE)
K3D_ADD_SUBDIRECTORY(qtui REQUIRES K3D_BUILD_QTUI_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_node_list REQUIRES K3D_BUILD_QTUI_NODE_LIST_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_node_properties REQUIRES K3D_BUILD_QTUI_NODE_PROPERTIES_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_opengl REQUIRES K3D_BUILD_QTUI_OPENGL_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_path REQUIRES K3D_BUILD_QTUI_PATH_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_programmable_mode REQUIRES K3D_BUILD_QTUI_PROGRAMMABLE_MODE_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_string REQUIRES K3D_BUILD_QTUI_STRING_MODULE)
K3D_ADD_SUBDIRECTORY(qtui_text_editor REQUIRES K3D_BUILD_QTUI_TEXT_EDITOR_MODULE)
K3D_ADD_SUBDIRECTORY(quadrics REQUIRES K3D_BUILD_QUADRICS_MODULE)
K3D_ADD_SUBDIRECTORY(reference_opengl_painters REQUIRES K3D_BUILD_REFERENCE_OPENGL_PAINTERS_MODULE)
K3D_ADD_SUBDIRECTORY(release REQUIRES K3D_BUILD_RELEASE_MODULE)
K3D_ADD_SUBDIRECTORY(renderman_engines REQUIRES K3D_BUILD_RENDERMAN_ENGINES_MODULE)
K3D_ADD_SUBDIRECTORY(renderman REQUIRES K3D_BUILD_RENDERMAN_MODULE)
K3D_ADD_SUBDIRECTORY(renderman_painters REQUIRES K3D_BUILD_RENDERMAN_PAINTERS_MODULE)
K3D_ADD_SUBDIRECTORY(scripted_plugins REQUIRES K3D_BUILD_SCRIPTED_PLUGINS_MODULE)
K3D_ADD_SUBDIRECTORY(scripting REQUIRES K3D_BUILD_SCRIPTING_MODULE)
K3D_ADD_SUBDIRECTORY(selection REQUIRES K3D_BUILD_SELECTION_MODULE)
K3D_ADD_SUBDIRECTORY(solar REQUIRES K3D_BUILD_SOLAR_MODULE)
K3D_ADD_SUBDIRECTORY(stl_io REQUIRES K3D_BUILD_STL_IO_MODULE)
K3D_ADD_SUBDIRECTORY(subdivision_surface REQUIRES K3D_BUILD_SUBDIVISION_SURFACE_MODULE)
K3D_ADD_SUBDIRECTORY(svg_io REQUIRES K3D_BUILD_SVG_IO_MODULE)
K3D_ADD_SUBDIRECTORY(test REQUIRES K3D_BUILD_TEST_MODULE)
K3D_ADD_SUBDIRECTORY(tiff_io REQUIRES K3D_BUILD_TIFF_IO_MODULE)
K3D_ADD_SUBDIRECTORY(time REQUIRES K3D_BUILD_TIME_MODULE)
K3D_ADD_SUBDIRECTORY(uniform_polyhedron REQUIRES K3D_BUILD_UNIFORM_POLYHEDRON_MODULE)
K3D_ADD_SUBDIRECTORY(virtual_offscreen REQUIRES K3D_BUILD_VIRTUAL_OFFSCREEN_MODULE)
K3D_ADD_SUBDIRECTORY(virtual_opengl_painters REQUIRES K3D_BUILD_VIRTUAL_OPENGL_PAINTERS_MODULE)
K3D_ADD_SUBDIRECTORY(wgl REQUIRES K3D_BUILD_WGL_MODULE)
K3D_ADD_SUBDIRECTORY(windows REQUIRES K3D_BUILD_WINDOWS_MODULE)
K3D_ADD_SUBDIRECTORY(xtrackcad REQUIRES K3D_BUILD_XTRACKCAD_MODULE)
K3D_ADD_SUBDIRECTORY(yafray REQUIRES K3D_BUILD_YAFRAY_MODULE)

ADD_SUBDIRECTORY(external)

# Test for unwanted plugin binaries ...
FILE(GLOB_RECURSE PLUGIN_BINARIES "${K3D_MODULE_OUTPUT_DIRECTORY}/*")
LIST(SORT PLUGIN_BINARIES)
FOREACH(PLUGIN_BINARY ${PLUGIN_BINARIES})
	GET_FILENAME_COMPONENT(RELATIVE_PLUGIN_BINARY ${PLUGIN_BINARY} NAME)

	SET(UNEXPECTED_FILE 1)
	FOREACH(K3D_PLUGIN ${K3D_PLUGINS})
		IF(RELATIVE_PLUGIN_BINARY MATCHES "${K3D_PLUGIN}.module")
			SET(UNEXPECTED_FILE 0)
			BREAK()
		ELIF(RELATIVE_PLUGIN_BINARY MATCHES "${K3D_PLUGIN}.module.proxy")
			SET(UNEXPECTED_FILE 0)
			BREAK()
		ENDIF()
	ENDFOREACH()

	IF(UNEXPECTED_FILE)
		MESSAGE(SEND_ERROR "Unexpected file in plugin directory ... delete ${PLUGIN_BINARY} to eliminate this error.")
	ENDIF()
ENDFOREACH()
