@@ -53,6 +53,9 @@ endfunction(tuttle_install_shared_libs)
5353
5454
5555# Use this function to create a new plugin target
56+ # Each new plugin is added to 2 Makefile custom targets:
57+ # * 'ofxplugins'
58+ # * 'ofx<plugin_parent_dir>'
5659# The first argument is the plugin name
5760# the second argument is a list of files to compile
5861function (tuttle_ofx_plugin_target PLUGIN_NAME)
@@ -111,20 +114,34 @@ function(tuttle_ofx_plugin_target PLUGIN_NAME)
111114 # Plugin target is a shared library
112115 add_library (${PLUGIN_NAME} MODULE ${PLUGIN_SOURCES} )
113116
117+ # Get plugin parent directory
118+ get_filename_component (PLUGIN_PARENT_ABSOLUTE_PATH ${CMAKE_CURRENT_SOURCE_DIR} PATH )
119+ get_filename_component (PLUGIN_PARENT_DIR ${PLUGIN_PARENT_ABSOLUTE_PATH} NAME )
120+ set (PLUGIN_CUSTOM_TARGET "ofx${PLUGIN_PARENT_DIR} " )
121+ set (PLUGIN_COMMON_TARGET "ofxplugins" )
122+
123+ # Create custom target if it does not exist
124+ if (NOT TARGET ${PLUGIN_COMMON_TARGET} )
125+ add_custom_target (${PLUGIN_COMMON_TARGET} )
126+ endif ()
127+ if (NOT TARGET ${PLUGIN_CUSTOM_TARGET} )
128+ add_custom_target (${PLUGIN_CUSTOM_TARGET} )
129+ endif ()
130+
131+ # Add this new plugin to custom Makefile targets
132+ add_dependencies (${PLUGIN_COMMON_TARGET} ${PLUGIN_NAME} )
133+ add_dependencies (${PLUGIN_CUSTOM_TARGET} ${PLUGIN_NAME} )
134+
114135 # Static link with a common plugin library
115- set (IS_IOPLUGIN ${ARGV2} )
116- if (IS_IOPLUGIN)
136+ if (${PLUGIN_PARENT_DIR} STREQUAL "io" )
117137 target_link_libraries (${PLUGIN_NAME} tuttleIOPluginLib)
118- else (IS_IOPLUGIN )
138+ else ()
119139 target_link_libraries (${PLUGIN_NAME} tuttlePluginLib)
120- endif (IS_IOPLUGIN )
140+ endif ()
121141
122142 set_target_properties (${PLUGIN_NAME} PROPERTIES SUFFIX "${_plugin_version_suffix} .ofx" )
123143 set_target_properties (${PLUGIN_NAME} PROPERTIES PREFIX "" )
124144
125- # Add this new plugin to the global alias ofxplugins
126- add_dependencies (ofxplugins ${PLUGIN_NAME} )
127-
128145 # FIXME: why tuttlePluginLib depends on OpenGL ? is it necessary ?
129146 if (APPLE )
130147 find_package (OpenGL)
0 commit comments